Plugin Directory

Changeset 620442


Ignore:
Timestamp:
11/02/2012 06:10:43 PM (13 years ago)
Author:
AndrewZhang
Message:

update to 0.25.5

Location:
wp-widget-cache/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • wp-widget-cache/trunk/readme.txt

    r283227 r620442  
    44Tags: widget, sidebar, cache, caching, performance, google, wp-cache, wp-super-cache
    55Requires at least: 2.5.3
    6 Tested up to: 3.0.1
    7 Stable tag: 0.25.4
     6Tested up to: 3.4.2
     7Stable tag: 0.25.5
    88
    99Cache the output of your blog widgets. Usually it will significantly reduce the SQL queries to your database and speed up your site.
     
    1212
    1313A **high-performance** caching plugin for WordPress, and a **plus** for WP-Cache or WP Super Cache!
    14 
    15 [ChangeLog](http://www.nexwp.com/stories/wp-widget-cache-changelog)
    1614
    1715**Why we need this WP Widget Cache?**
  • wp-widget-cache/trunk/widget-cache.php

    r283227 r620442  
    55Description: Cache the output of your blog widgets. Usually it will significantly reduce the sql queries to your database and speed up your site.
    66Author: Andrew Zhang
    7 Version: 0.25.4
     7Version: 0.25.5
    88Author URI: http://www.nexwp.com
    99*/
     
    1414{
    1515    var $plugin_name='WP Widget Cache';
    16     var $plugin_version='0.25.4';
     16    var $plugin_version='0.25.5';
    1717    var $plugin_uri='http://www.nexwp.com';
    1818
     
    4444        else
    4545        {
    46             $this->wgcSettings = $this->wgc_get_option("widget_cache_settings");
    47             $this->wgcOptions = $this->wgc_get_option('widget_cache');
    48             $this->wgcTriggers = $this->wgc_get_option('widget_cache_action_trigger');
    49             $this->wgcVaryParams = $this->wgc_get_option('widget_cache_vary_param');
    50 
    51             $this->wgcEnabled= !($this->wgcSettings["wgc_disabled"]==="1");
    52             $this->wgcAutoExpireEnabled= !($this->wgcSettings["wgc_ae_ops_disabled"]==="1");
    53             $this->wgcVaryParamsEnabled= $this->wgcSettings["wgc_vary_by_params_enabled"]=="1";
     46            $this->wgc_load_opts();
    5447
    5548            if($this->wgcEnabled)
     
    10497        if(!$ops)$ops=array();
    10598        return $ops;
     99    }
     100   
     101    function wgc_load_opts()
     102    {
     103        $this->wgcSettings = $this->wgc_get_option("widget_cache_settings");
     104        $this->wgcOptions = $this->wgc_get_option('widget_cache');
     105        $this->wgcTriggers = $this->wgc_get_option('widget_cache_action_trigger');
     106        $this->wgcVaryParams = $this->wgc_get_option('widget_cache_vary_param');
     107
     108        $this->wgcEnabled= !($this->wgcSettings["wgc_disabled"]==="1");
     109        $this->wgcAutoExpireEnabled= !($this->wgcSettings["wgc_ae_ops_disabled"]==="1");
     110        $this->wgcVaryParamsEnabled= $this->wgcSettings["wgc_vary_by_params_enabled"]=="1";
    106111    }
    107112
     
    238243        $wc_varyparams = $this->wgcVaryParams;
    239244
    240         if ($this->wgcEnabled && 'post' == strtolower($_SERVER['REQUEST_METHOD']) )
    241         {
    242             if(isset($_POST["widget_cache-clear"]))
    243             {
    244                 $this->wcache->clear();
    245                 wp_redirect(add_query_arg( 'message','wgc#wgcoptions'));
    246                 exit();
    247             }
    248 
    249             foreach ((array)$_POST['widget-id'] as $widget_number => $widget_id )
    250             {
    251                 if (isset($_POST[$widget_id.'-widget_cache']))
    252                 {
    253                     $wc_options[$widget_id]= intval($_POST[$widget_id.'-widget_cache']);
    254                 }
    255                 if($this->wgcAutoExpireEnabled)
    256                 {
    257                     if(isset($_POST[$widget_id.'-widget_cache-trigger']))
    258                     {
    259                         $wc_trigers[$widget_id]=($_POST[$widget_id.'-widget_cache-trigger']);
    260                     }
    261                     else
    262                     {
    263                         unset($wc_trigers[$widget_id]);
    264                     }
    265                 }
    266                 if($this->wgcVaryParamsEnabled)
    267                 {
    268                     if(isset($_POST[$widget_id.'-widget_cache-varyparam']))
    269                     {
    270                         $wc_varyparams[$widget_id]=($_POST[$widget_id.'-widget_cache-varyparam']);
    271                     }
    272                     else
    273                     {
    274                         unset($wc_varyparams[$widget_id]);
    275                     }
    276                 }
    277             }
    278 
    279             $regd_plus_new=array_merge(array_keys($wp_registered_widgets),array_values((array) $_POST['widget-id']));
    280             foreach (array_keys($wc_options) as $key)
    281             {
    282                 if (!in_array($key, $regd_plus_new))
    283                 {
    284                     unset($wc_options[$key]);
    285                     if($this->wgcAutoExpireEnabled)unset($wc_trigers[$key]);
    286                     if($this->wgcVaryParamsEnabled)unset($wc_varyparams[$key]);
    287                 }
    288             }
    289 
    290             $this->wgc_update_option('widget_cache', $wc_options);
    291             if($this->wgcAutoExpireEnabled)$this->wgc_update_option('widget_cache_action_trigger', $wc_trigers);
    292             if($this->wgcVaryParamsEnabled)$this->wgc_update_option('widget_cache_vary_param', $wc_varyparams);
    293         }
    294         else
     245        if ($this->wgcEnabled)
    295246        {
    296247            foreach ( $wp_registered_widgets as $id => $widget )
     
    298249                if (!$wp_registered_widget_controls[$id])
    299250                wp_register_widget_control($id,$widget['name'], array(&$this, 'widget_cache_empty_control'));
    300 
     251   
    301252                if (!array_key_exists(0,$wp_registered_widget_controls[$id]['params'])  || is_array($wp_registered_widget_controls[$id]['params'][0]))
    302253                $wp_registered_widget_controls[$id]['params'][0]['id_for_wc']=$id;
     
    306257                    $wp_registered_widget_controls[$id]['height']+=40;
    307258                }
    308 
     259   
    309260                $wp_registered_widget_controls[$id]['callback_wc_redirect']=$wp_registered_widget_controls[$id]['callback'];
    310261                $wp_registered_widget_controls[$id]['callback']=array(&$this, 'widget_cache_extra_control');
     262            }
     263               
     264            if ( 'post' == strtolower($_SERVER['REQUEST_METHOD']) )
     265            {
     266                if(isset($_POST["widget_cache-clear"]))
     267                {
     268                    $this->wcache->clear();
     269                    wp_redirect(add_query_arg( 'message','wgc#wgcoptions'));
     270                    exit();
     271                }
     272   
     273                foreach ((array)$_POST['widget-id'] as $widget_number => $widget_id )
     274                {
     275                    if (isset($_POST[$widget_id.'-widget_cache']))
     276                    {
     277                        $wc_options[$widget_id]= intval($_POST[$widget_id.'-widget_cache']);
     278                    }
     279                    if($this->wgcAutoExpireEnabled)
     280                    {
     281                        if(isset($_POST[$widget_id.'-widget_cache-trigger']))
     282                        {
     283                            $wc_trigers[$widget_id]=($_POST[$widget_id.'-widget_cache-trigger']);
     284                        }
     285                        else
     286                        {
     287                            unset($wc_trigers[$widget_id]);
     288                        }
     289                    }
     290                    if($this->wgcVaryParamsEnabled)
     291                    {
     292                        if(isset($_POST[$widget_id.'-widget_cache-varyparam']))
     293                        {
     294                            $wc_varyparams[$widget_id]=($_POST[$widget_id.'-widget_cache-varyparam']);
     295                        }
     296                        else
     297                        {
     298                            unset($wc_varyparams[$widget_id]);
     299                        }
     300                    }
     301                }
     302   
     303                $regd_plus_new=array_merge(array_keys($wp_registered_widgets),array_values((array) $_POST['widget-id']));
     304                foreach (array_keys($wc_options) as $key)
     305                {
     306                    if (!in_array($key, $regd_plus_new))
     307                    {
     308                        unset($wc_options[$key]);
     309                        if($this->wgcAutoExpireEnabled)unset($wc_trigers[$key]);
     310                        if($this->wgcVaryParamsEnabled)unset($wc_varyparams[$key]);
     311                    }
     312                }
     313   
     314                $this->wgc_update_option('widget_cache', $wc_options);
     315               
     316                if($this->wgcAutoExpireEnabled)$this->wgc_update_option('widget_cache_action_trigger', $wc_trigers);
     317                if($this->wgcVaryParamsEnabled)$this->wgc_update_option('widget_cache_vary_param', $wc_varyparams);
     318               
     319                $this->wgc_load_opts();
    311320            }
    312321        }
     
    502511        if ($wc_value>0)
    503512        {
    504             echo "<!--$this->plugin_name $this->plugin_version ($this->plugin_uri) Begin -->\n";
     513            echo "<!--$this->plugin_name $this->plugin_version Begin -->\n";
    505514
    506515            while($this->wcache->save($this->get_widget_cache_key($id), $wc_value, array(), $id) || ($this->widget_cache_getcache($id, $wc_value) && false))
     
    508517                call_user_func_array($callback, $params);
    509518            }
     519           
    510520            echo "<!--$this->plugin_name End -->\n";
    511521        }
Note: See TracChangeset for help on using the changeset viewer.