WordPress.org

Plugin Directory

Changeset 1438649


Ignore:
Timestamp:
06/17/16 17:03:13 (21 months ago)
Author:
xiaoxu125634
Message:

1.6.5

  • 2016-06-17
  • 修复Avada主题的webfont.js不兼容问题。
Location:
useso-take-over-google/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • useso-take-over-google/trunk/readme.txt

    r1244528 r1438649  
    44Tags: Open Sans, Google Fonts, Google Web Fonts, useso, 360前端公共库, Google字体库, Google公共库, Useso公共库, Useso字体库 
    55Requires at least: 3.0 
    6 Tested up to: 4.3 
     6Tested up to: 4.5.2 
    77Stable tag: trunk 
    88 
     
    2727 
    2828== Changelog == 
     29 
     30= 1.6.5 = 
     31* 2016-06-17 
     32* 修复Avada主题的webfont.js不兼容问题。 
    2933 
    3034= 1.6.4 = 
  • useso-take-over-google/trunk/useso-take-over-google.php

    r1244528 r1438649  
    66Author: Bruno Xu 
    77Author URI: http://www.brunoxu.com/ 
    8 Version: 1.6.4 
     8Version: 1.6.5 
    99License: GNU General Public License v2 or later 
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    4343 
    4444    /* 
     45    google fonts imported by 'Web Font Loader' 
     46        https://ajax.googleapis.com/ajax/libs/webfont/1.5.3/webfont.js 
     47        http://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js 
     48    */ 
     49    //$content = str_ireplace('//ajax.googleapis'.'.com/ajax/libs/webfont/1/webfont.js', substr($webfont_js, strpos($webfont_js,'//')), $content); 
     50    //$content = preg_replace('|//ajax.googleapis'.'.com/ajax/libs/webfont/[\d\.]+/webfont.js|i', substr($webfont_js, strpos($webfont_js,'//')), $content); 
     51    $regexp = "|(http(s)?:)?//ajax.googleapis".".com/ajax/libs/webfont/[\d\.]+/webfont.js|i"; 
     52    $content = preg_replace_callback( 
     53        $regexp, 
     54        "useso_take_over_google_str_handler2", 
     55        $content 
     56    ); 
     57 
     58    /* 
    4559    <link rel="stylesheet" id="open-sans-css" href="//fonts.googleapis.com/css?family=Open+Sans%3A300italic%2C400italic%2C600italic%2C300%2C400%2C600&amp;subset=latin%2Clatin-ext&amp;ver=3.9.2" type="text/css" media="all"> 
    4660    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script> 
     
    6579 
    6680    /* 
    67     google fonts imported by 'Web Font Loader' 
    68     */ 
    69     $webfont_js = USESO_TAKE_OVER_GOOGLE_PLUGIN_URL.'webfont_v1.5.3.js'; 
    70     if (is_ssl()) { 
    71         $webfont_js = USESO_TAKE_OVER_GOOGLE_PLUGIN_URL.'webfont_https_v1.5.3.js'; 
    72     } 
    73     //$content = str_ireplace('//ajax.googleapis'.'.com/ajax/libs/webfont/1/webfont.js', substr($webfont_js, strpos($webfont_js,'//')), $content); 
    74     $content = preg_replace('|//ajax.googleapis'.'.com/ajax/libs/webfont/[\d\.]+/webfont.js|i', substr($webfont_js, strpos($webfont_js,'//')), $content); 
    75  
    76     /* 
    77     gravatar imgs: 
     81    gravatar imgs 
    7882        <img src="http://1.gravatar.com/avatar/11fee321889526d1df2393655f48bd0c?s=26&d=retro&r=g"> 
    7983        <img src="https://secure.gravatar.com/avatar/06a2950d128ec9faf155e28d9e889baa?s=120"> 
    80     */ 
    81     /* v1 bak 
    82     $regexp = "/(\d+|www|secure|cn).gravatar.com\/avatar/i"; 
    83     $content = preg_replace($regexp, 'sdn.geekzu.org/avatar', $content); 
    8484    */ 
    8585    $regexp = "/<img([^<>]+)>/i"; 
    8686    $content = preg_replace_callback( 
    8787        $regexp, 
    88         "useso_take_over_google_str_handler2", 
     88        "useso_take_over_google_str_handler3", 
    8989        $content 
    9090    ); 
     
    9797    $str = $matches[0]; 
    9898 
    99     if (!is_ssl()) { 
     99    $is_ssl = false; 
     100    if (stristr($str, 'https://')) { 
     101        $is_ssl = true; 
     102    } else { 
     103        if (!stristr($str, 'http://') && is_ssl()) { 
     104            $is_ssl = true; 
     105        } 
     106    } 
     107 
     108    if (!$is_ssl) { 
    100109        $str = str_ireplace('//fonts.googleapis'.'.com/', '//fonts.useso.com/', $str); 
    101110        $str = str_ireplace('//ajax.googleapis'.'.com/', '//ajax.useso.com/', $str); 
     
    111120    } 
    112121 
    113     /* 
    114     fix below references: 
    115         https://fonts.useso.com/.... 
    116         https://ajax.useso.com/.... 
    117     */ 
    118     if (!is_ssl()) { 
    119         $str = str_ireplace('https://fonts.useso.com/', 'http://fonts.useso.com/', $str); 
    120         $str = str_ireplace('https://ajax.useso.com/', 'http://ajax.useso.com/', $str); 
     122    return $str; 
     123} 
    121124 
    122         $str = str_ireplace('https://fonts.geekzu.org/', 'http://fonts.geekzu.org/', $str); 
    123         $str = str_ireplace('https://fdn.geekzu.org/ajax/', 'http://fdn.geekzu.org/ajax/', $str); 
     125function useso_take_over_google_str_handler2($matches) 
     126{ 
     127    $str = $matches[0]; 
     128 
     129    $is_ssl = false; 
     130    if (stristr($str, 'https://')) { 
     131        $is_ssl = true; 
    124132    } else { 
    125         //... 
     133        if (!stristr($str, 'http://') && is_ssl()) { 
     134            $is_ssl = true; 
     135        } 
     136    } 
     137 
     138    if ($is_ssl) { 
     139        $webfont_js = USESO_TAKE_OVER_GOOGLE_PLUGIN_URL . 'webfont_https_v1.5.3.js'; 
     140    } else { 
     141        $webfont_js = USESO_TAKE_OVER_GOOGLE_PLUGIN_URL . 'webfont_v1.5.3.js'; 
     142    } 
     143 
     144    $str = preg_replace('|//ajax.googleapis'.'.com/ajax/libs/webfont/[\d\.]+/webfont.js|i', substr($webfont_js, strpos($webfont_js,'//')), $str); 
     145 
     146    // fix for Avada-4.0.3 
     147    if ($is_ssl && !is_ssl()) { 
     148        $str = str_ireplace('https://', 'http://', $str); 
     149    } 
     150    if (!$is_ssl && is_ssl()) { 
     151        $str = str_ireplace('http://', 'https://', $str); 
    126152    } 
    127153 
     
    129155} 
    130156 
    131 function useso_take_over_google_str_handler2($matches) 
     157function useso_take_over_google_str_handler3($matches) 
    132158{ 
    133159    $str = $matches[0]; 
Note: See TracChangeset for help on using the changeset viewer.