Changeset 1489597
- Timestamp:
- 09/03/2016 11:35:31 PM (9 years ago)
- Location:
- well-handled/trunk
- Files:
-
- 2 edited
-
index.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
well-handled/trunk/index.php
r1479786 r1489597 4 4 Plugin URI: https://well-handled.io 5 5 Description: Easy and powerful handlebar/mustache email template management for developers. 6 Version: 1.5. 16 Version: 1.5.2 7 7 Author: well-handled.io 8 8 Author URI: https://well-handled.io … … 444 444 445 445 //------------------------------------------------- 446 // Reverse parse_url() to get back to a URL 447 // 448 // @param parsed 449 // @return url or false 450 function 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 //------------------------------------------------- 446 516 // is the blog utf-8? 447 517 // … … 1003 1073 1004 1074 //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); 1009 1084 $link->setAttribute('href', $url); 1010 1085 } -
well-handled/trunk/readme.txt
r1479786 r1489597 67 67 == Changelog == 68 68 69 = 1.5.2 = 70 * [fixed] bug affecting UTM tag insertion on links with #hash fragments 71 69 72 = 1.5.1 = 70 73 * [improved] #inflect helper can now accept an array as the 'count' variable; … … 90 93 == Upgrade Notice == 91 94 95 = 1.5.2 = 96 * [fixed] bug affecting UTM tag insertion on links with #hash fragments 97 92 98 = 1.5.1 = 93 99 * [improved] #inflect helper can now accept an array as the 'count' variable;
Note: See TracChangeset
for help on using the changeset viewer.