Plugin Directory

Changeset 1402700


Ignore:
Timestamp:
04/23/2016 06:33:03 AM (10 years ago)
Author:
ze3kr
Message:

update readme

Location:
full-site-cache-kc/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • full-site-cache-kc/trunk/full-site-cache-kc.php

    r1402195 r1402700  
    4646        require_once( $fskeycdn_path );
    4747        add_filter( 'plugin_row_meta', 'fsckeycdn_meta', 91, 2 );
    48         add_filter( 'style_loader_src' , 'fsckeycdn_remove_admin' , 91 , 1 );
    49         add_filter( 'script_loader_src' , 'fsckeycdn_remove_admin' , 91 , 1 );
    5048        add_filter( 'plugin_action_links', 'fsckeycdn_add_settings', 91, 2 );
    51         add_action( 'wp', 'fsckeycdn_header' );
    5249        add_action( 'admin_menu', 'fsckeycdn_admin_menu', 5 );
    53         add_action( 'trashed_post', 'fsckeycdn_purge_blog', 91 );
    54         add_action( 'switch_theme', 'fsckeycdn_purge_blog', 91 );
    55         add_action( '_core_updated_successfully', 'fsckeycdn_purge_all', 91 );
    56         add_action( 'init', 'fsckeycdn_purge_button', 5 );
    57         add_action( 'init', 'fsckeycdn_register_publish_hooks', 99 );
    58         add_action( 'plugins_loaded', 'fsckeycdn_check_ce' );
    59         add_action( 'admin_bar_menu', 'fsckeycdn_add_admin_links', 99);
    60         add_action( 'transition_comment_status', 'fsckeycdn_change_comment', 91, 3 );
    61         add_action( 'edit_comment', 'fsckeycdn_edit_comment' );
    62         add_action( 'pre_comment_approved', 'fsckeycdn_new_comment', 99, 2);
    63         /* Add rewrite action */
    64         if(isset(explode('.',$fsckeycdn_realhost)[2]) && $_SERVER['HTTP_X_PULL'] == $fsckeycdn_x_pull_key){
    65             add_action( 'template_redirect','fsckeycdn_minify_html', 99 );
    66         } elseif((substr($fsckeycdn_realhost,0,9) == 'wp-admin.' || substr($fsckeycdn_realhost,0,9) == 'wp-admin-') && !strstr($_SERVER['REQUEST_URI'],'/options-general.php')) {
    67             add_action( 'wp_loaded','fsckeycdn_minify_html_admin', 99 );
     50        if(fsckeycdn_status()){
     51            add_action( 'init', 'fsckeycdn_register_publish_hooks', 99 );
     52            add_action( 'init', 'fsckeycdn_purge_button', 5 );
     53            add_action( 'wp', 'fsckeycdn_header' );
     54            add_action( 'admin_bar_menu', 'fsckeycdn_add_admin_links', 99);
     55            add_action( 'plugins_loaded', 'fsckeycdn_check_ce' );
     56            add_action( 'transition_comment_status', 'fsckeycdn_change_comment', 91, 3 );
     57            add_action( 'edit_comment', 'fsckeycdn_edit_comment' );
     58            add_action( 'pre_comment_approved', 'fsckeycdn_new_comment', 99, 2);
     59            add_action( 'trashed_post', 'fsckeycdn_purge_blog', 91 );
     60            add_action( 'switch_theme', 'fsckeycdn_purge_blog', 91 );
     61            add_action( '_core_updated_successfully', 'fsckeycdn_purge_all', 91 );
     62            /* Add rewrite action */
     63            if(isset(explode('.',$fsckeycdn_realhost)[2]) && $_SERVER['HTTP_X_PULL'] == $fsckeycdn_x_pull_key){
     64                add_action( 'template_redirect','fsckeycdn_minify_html', 99 );
     65            } elseif((substr($fsckeycdn_realhost,0,9) == 'wp-admin.' || substr($fsckeycdn_realhost,0,9) == 'wp-admin-') && !strstr($_SERVER['REQUEST_URI'],'/options-general.php')) {
     66                add_action( 'wp_loaded','fsckeycdn_minify_html_admin', 99 );
     67            }
    6868        }
    6969    } else {
  • full-site-cache-kc/trunk/functions.php

    r1402195 r1402700  
    109109function fsckeycdn_header(){
    110110    global $fsckeycdn_x_pull_key, $fsckeycdn_scheme, $fsckeycdn_realhost, $fsckeycdn_blog_id;
    111     if(fsckeycdn_status()){
    112         /* Set redirect if user not logged in */
    113         if(substr($_SERVER['REQUEST_URI'],0,11) != '/robots.txt' && $_SERVER['SCRIPT_NAME'] == '/index.php' && $_SERVER['HTTP_X_PULL'] != $fsckeycdn_x_pull_key && !is_user_logged_in()) {
    114             if(substr($fsckeycdn_realhost,0,9) == 'wp-admin-') {
    115                 header('HTTP/1.1 302 Moved Temporarily');
    116                 header('Location: '.wp_login_url($fsckeycdn_scheme.'://'.$fsckeycdn_realhost.$_SERVER['REQUEST_URI']));
    117                 exit();
    118             } elseif(substr($fsckeycdn_realhost,0,9) == 'wp-admin.') {
    119                 header('HTTP/1.1 302 Moved Temporarily');
    120                 header('Location: '.wp_login_url($fsckeycdn_scheme.'://'.$fsckeycdn_realhost.$_SERVER['REQUEST_URI']));
    121                 exit();
    122             }
     111    /* Set redirect if user not logged in */
     112    if(substr($_SERVER['REQUEST_URI'],0,11) != '/robots.txt' && $_SERVER['SCRIPT_NAME'] == '/index.php' && $_SERVER['HTTP_X_PULL'] != $fsckeycdn_x_pull_key && !is_user_logged_in()) {
     113        if(substr($fsckeycdn_realhost,0,9) == 'wp-admin-') {
     114            header('HTTP/1.1 302 Moved Temporarily');
     115            header('Location: '.wp_login_url($fsckeycdn_scheme.'://'.$fsckeycdn_realhost.$_SERVER['REQUEST_URI']));
     116            exit();
     117        } elseif(substr($fsckeycdn_realhost,0,9) == 'wp-admin.') {
     118            header('HTTP/1.1 302 Moved Temporarily');
     119            header('Location: '.wp_login_url($fsckeycdn_scheme.'://'.$fsckeycdn_realhost.$_SERVER['REQUEST_URI']));
     120            exit();
    123121        }
    124122    }
     
    287285}
    288286
    289 function fsckeycdn_remove_admin ( $url ) {
    290     $url = str_replace ( 'wp-admin.' , 'www.' , $url ) ;
    291     $url = str_replace ( 'wp-admin-' , '' , $url ) ;
    292     return $url ;
    293 }
    294 
    295287function fsckeycdn_minify_html_admin(){
    296288    // Set URL rewrite for admin page.
    297289    ob_start('fsckeycdn_compress_admin');
    298290}
     291
    299292function fsckeycdn_compress_admin($html){
    300293    global $fsckeycdn_realhost;
     
    303296        $html = str_replace('%3A%2F%2F'.$_SERVER['HTTP_HOST'],'%3A%2F%2Fwp-admin.'.substr($_SERVER['HTTP_HOST'],4),$html);
    304297        $html = str_replace(':\/\/'.$_SERVER['HTTP_HOST'],':\/\/wp-admin.'.substr($_SERVER['HTTP_HOST'],4),$html);
    305         return $html;
    306298    } elseif(isset(explode('.',$fsckeycdn_realhost)[2])) {
    307299        $html = str_replace('://'.$_SERVER['HTTP_HOST'],'://wp-admin-'.$_SERVER['HTTP_HOST'],$html);
    308300        $html = str_replace('%3A%2F%2F'.$_SERVER['HTTP_HOST'],'%3A%2F%2Fwp-admin-'.$_SERVER['HTTP_HOST'],$html);
    309301        $html = str_replace(':\/\/'.$_SERVER['HTTP_HOST'],':\/\/wp-admin-'.$_SERVER['HTTP_HOST'],$html);
    310         return $html;
    311     }
     302    }
     303    return $html;
    312304}
    313305
     
    316308    ob_start('fsckeycdn_compress');
    317309}
     310
     311function fsckeycdn_rewrite_url($asset) {
     312    global $fsckeycdn_cdn_domain,$fsckeycdn_scheme;
     313    return str_replace($fsckeycdn_scheme.'://'.$_SERVER['HTTP_HOST'], $fsckeycdn_scheme.'://'.$fsckeycdn_cdn_domain, $asset[0]);
     314}
     315
    318316function fsckeycdn_compress($html){
     317    global $fsckeycdn_cdn_domain,$fsckeycdn_scheme;
    319318    if(substr($_SERVER['HTTP_HOST'],0,4) == 'www.') {
    320319        $html = str_replace('://wp-admin.'.substr($_SERVER['HTTP_HOST'],4),'://'.$_SERVER['HTTP_HOST'],$html);
    321320        $html = str_replace('%3A%2F%2Fwp-admin.'.substr($_SERVER['HTTP_HOST'],4),'%3A%2F%2F'.$_SERVER['HTTP_HOST'],$html);
    322321        $html = str_replace(':\/\/wp-admin.'.substr($_SERVER['HTTP_HOST'],4),':\/\/'.$_SERVER['HTTP_HOST'],$html);
    323         return $html;
    324322    } else {
    325323        $html = str_replace('://wp-admin-'.$_SERVER['HTTP_HOST'],'://'.$_SERVER['HTTP_HOST'],$html);
    326324        $html = str_replace('%3A%2F%2Fwp-admin-'.$_SERVER['HTTP_HOST'],'%3A%2F%2F'.$_SERVER['HTTP_HOST'],$html);
    327325        $html = str_replace(':\/\/wp-admin-'.$_SERVER['HTTP_HOST'],':\/\/'.$_SERVER['HTTP_HOST'],$html);
    328         return $html;
    329     }
     326    }
     327
     328    if(isset($fsckeycdn_cdn_domain)){
     329        // get dir scope in regex format
     330        $dirs = 'wp\-content|wp\-includes';
     331
     332        // regex rule start
     333        $regex_rule = '#(?<=[(\"\'])'.$fsckeycdn_scheme.'://'.$_SERVER['HTTP_HOST'];
     334
     335        // regex rule end
     336        $regex_rule .= '/(?:((?:'.$dirs.')[^\"\')]+)|([^/\"\']+\.[^/\"\')]+))(?=[\"\')])#';
     337
     338        // call the cdn rewriter callback
     339        $html = preg_replace_callback($regex_rule, 'fsckeycdn_rewrite_url', $html);
     340    }
     341
     342    return $html;
    330343}
    331344
  • full-site-cache-kc/trunk/readme.txt

    r1402195 r1402700  
    243243    }
    244244
     245= Custom CDN Domain =
     246
     247You can custom your CDN domain, it’s a specific domain that only for Images, CSS and JS.
     248
     249Just add this in the `wp-config.php`.
     250
     251    $fsckeycdn_cdn_domain = 'cdn.example.com';
     252
    245253== About Purge ==
    246254
Note: See TracChangeset for help on using the changeset viewer.