Plugin Directory

Changeset 2360273


Ignore:
Timestamp:
08/13/2020 03:06:01 PM (6 years ago)
Author:
pagecdn
Message:

Removed unnecessary API call from all admin pages and limited it to only PageCDN Settings page.

Location:
pagecdn
Files:
11 added
3 edited

Legend:

Unmodified
Added
Removed
  • pagecdn/trunk/admin-functions.php

    r2357161 r2360273  
    434434        }
    435435       
     436        PageCDN_collect_repo_data();
     437       
    436438        $options = PageCDN_options();
    437439       
     
    453455   
    454456   
     457    function PageCDN_collect_repo_data( )
     458    {
     459        Global $PageCDN_options;
     460       
     461        if( strlen( $PageCDN_options['pagecdn_api_key'] ) && strlen( $PageCDN_options['url'] ) )
     462        {
     463            $repo   = trim( parse_url( $PageCDN_options['url'] , PHP_URL_PATH ) , '/' );
     464           
     465            $apikey = $PageCDN_options['pagecdn_api_key'];
     466           
     467            if( $response = PageCDN_get_API_response( '/private/repo/info' , array( 'apikey' => $apikey , 'repo' => $repo ) ) )
     468            {
     469                if( !PageCDN_display_API_error( $response ) )
     470                {
     471                    $response   = $response['response'];
     472                   
     473                    $PageCDN_options['compression_level']   = $response['compression_level'];
     474                    $PageCDN_options['http2_server_push']   = $response['server_push'] && $response['server_push_trigger'];
     475                    $PageCDN_options['update_css_paths']    = $response['update_css_paths'];
     476                    $PageCDN_options['http_cache_ttl']      = strtotime( "+{$response['browser_cache_number']} {$response['browser_cache_period']}" , 0 );
     477                    $PageCDN_options['cache_control']       = !!$PageCDN_options['http_cache_ttl'];
     478                }
     479            }
     480        }
     481    }
     482   
     483   
     484   
  • pagecdn/trunk/init-functions.php

    r2319458 r2360273  
    6464    function PageCDN_options( $option = null )
    6565    {
    66         Static $options = null;
    67        
    68         if( $options === null )
    69         {
    70             $options    = wp_parse_args( get_option('pagecdn') , PageCDN_defaults( ) );
    71            
     66        Global $PageCDN_options;
     67       
     68        //Static $options   = null;
     69       
     70        if( $PageCDN_options === null )
     71        {
     72            $PageCDN_options    = wp_parse_args( get_option('pagecdn') , PageCDN_defaults( ) );
     73           
     74            /*
    7275            if( is_admin( ) && strlen( $options['pagecdn_api_key'] ) && strlen( $options['url'] ) )
    7376            {
     
    9093                }
    9194            }
     95            */
    9296        }
    9397       
    9498        if( $option )
    9599        {
    96             if( isset( $options[$option] ) )
    97             {
    98                 return $options[$option];
     100            if( isset( $PageCDN_options[$option] ) )
     101            {
     102                return $PageCDN_options[$option];
    99103            }
    100104           
     
    102106        }
    103107       
    104         return $options;
     108        return $PageCDN_options;
    105109    }
    106110   
  • pagecdn/trunk/pagecdn.php

    r2357161 r2360273  
    77    Author URI: https://pagecdn.com
    88    License: GPLv2 or later
    9     Version: 5.10
     9    Version: 5.11
    1010*/
    1111   
     
    2020    //define( 'PAGECDN_IMG_CACHE'       , WP_CONTENT_DIR . '/cache/pagecdn/images.json' );
    2121    //define( 'PAGECDN_WEBP_CACHE'  , WP_CONTENT_DIR . '/cache/pagecdn/webp.json'   );
    22     define( 'PAGECDN_VER'           , '5.10'                                        );
     22    define( 'PAGECDN_VER'           , '5.11'                                            );
    2323   
    2424    $PageCDN_origin_scheme      = strtolower( parse_url( home_url( ) , PHP_URL_SCHEME ) );
     
    6767    $PageCDN_known_webp_URLs        = get_option( 'pagecdn-webp-cache' , json_encode( array( ) ) );
    6868   
     69   
     70    $PageCDN_options                = null;
    6971   
    7072   
Note: See TracChangeset for help on using the changeset viewer.