Plugin Directory

Changeset 1489597


Ignore:
Timestamp:
09/03/2016 11:35:31 PM (9 years ago)
Author:
wellhandled
Message:

Release 1.5.2

Location:
well-handled/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • well-handled/trunk/index.php

    r1479786 r1489597  
    44Plugin URI: https://well-handled.io
    55Description: Easy and powerful handlebar/mustache email template management for developers.
    6 Version: 1.5.1
     6Version: 1.5.2
    77Author: well-handled.io
    88Author URI: https://well-handled.io
     
    444444
    445445//-------------------------------------------------
     446// Reverse parse_url() to get back to a URL
     447//
     448// @param parsed
     449// @return url or false
     450function wh_unparse_url($parsed){
     451
     452    $url = '';
     453
     454    $defaults = array(
     455        'scheme'=>'',
     456        'host'=>'',
     457        'user'=>'',
     458        'pass'=>'',
     459        'port'=>'',
     460        'path'=>'',
     461        'query'=>'',
     462        'fragment'=>''
     463    );
     464    $parsed = wh_parse_args($parsed, $defaults);
     465
     466    //to simplify, unset anything without length
     467    $parsed = array_map('trim', $parsed);
     468    foreach($parsed AS $k=>$v){
     469        $parsed[$k] = (string) $v;
     470        if(!strlen($parsed[$k]))
     471            unset($parsed[$k]);
     472    }
     473
     474    //we don't really care about validating url integrity,
     475    //but if nothing at all was passed then it is trash
     476    if(!count($parsed))
     477        return false;
     478
     479    if(isset($parsed['scheme']))
     480        $url = "{$parsed['scheme']}:";
     481
     482    if(isset($parsed['host'])){
     483        $url .= '//';
     484
     485        //is this a user:pass situation?
     486        if(isset($parsed['user'])){
     487            $url .= $parsed['user'];
     488            if(isset($parsed['pass']))
     489                $url .= ":{$parsed['pass']}";
     490            $url .= '@';
     491        }
     492
     493        //finally the host
     494        $url .= (filter_var($parsed['host'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) ? "[{$parsed['host']}]" : $parsed['host']);
     495
     496        if(isset($parsed['port']))
     497            $url .= ":{$parsed['port']}";
     498
     499        if(isset($parsed['path']) && substr($parsed['path'], 0, 1) !== '/')
     500            $url .= '/';
     501    }
     502
     503    if(isset($parsed['path']))
     504        $url .= $parsed['path'];
     505
     506    if(isset($parsed['query']))
     507        $url .= "?{$parsed['query']}";
     508
     509    if(isset($parsed['fragment']))
     510        $url .= "#{$parsed['fragment']}";
     511
     512    return strlen($url) ? $url : false;
     513}
     514
     515//-------------------------------------------------
    446516// is the blog utf-8?
    447517//
     
    10031073
    10041074                    //append UTM
    1005                     if(!is_null($utm_query) && filter_var($url, FILTER_VALIDATE_URL) && in_array(parse_url($url, PHP_URL_SCHEME), array('http','https')) && (!$options['utm_local_only'] || wh_is_site_url($url)))
    1006                     {
    1007                         //add UTM to URL with query string
    1008                         $url .= (strlen(parse_url($url, PHP_URL_QUERY)) ? "&$utm_query" : "?$utm_query");
     1075                    if(!is_null($utm_query) && filter_var($url, FILTER_VALIDATE_URL) && in_array(parse_url($url, PHP_URL_SCHEME), array('http','https')) && (!$options['utm_local_only'] || wh_is_site_url($url))){
     1076
     1077                        //break down the URL into parts so we can mess with it the right way
     1078                        $parsed = parse_url($url);
     1079                        if(isset($parsed['query']) && strlen($parsed['query']))
     1080                            $parsed['query'] .= '&';
     1081                        $parsed['query'] .= $utm_query;
     1082
     1083                        $url = wh_unparse_url($parsed);
    10091084                        $link->setAttribute('href', $url);
    10101085                    }
  • well-handled/trunk/readme.txt

    r1479786 r1489597  
    6767== Changelog ==
    6868
     69= 1.5.2 =
     70* [fixed] bug affecting UTM tag insertion on links with #hash fragments
     71
    6972= 1.5.1 =
    7073* [improved] #inflect helper can now accept an array as the 'count' variable;
     
    9093== Upgrade Notice ==
    9194
     95= 1.5.2 =
     96* [fixed] bug affecting UTM tag insertion on links with #hash fragments
     97
    9298= 1.5.1 =
    9399* [improved] #inflect helper can now accept an array as the 'count' variable;
Note: See TracChangeset for help on using the changeset viewer.