Changeset 620442
- Timestamp:
- 11/02/2012 06:10:43 PM (13 years ago)
- Location:
- wp-widget-cache/trunk
- Files:
-
- 4 edited
-
readme.txt (modified) (2 diffs)
-
screenshot-1.jpg (modified) (previous)
-
screenshot-2.jpg (modified) (previous)
-
widget-cache.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-widget-cache/trunk/readme.txt
r283227 r620442 4 4 Tags: widget, sidebar, cache, caching, performance, google, wp-cache, wp-super-cache 5 5 Requires at least: 2.5.3 6 Tested up to: 3. 0.17 Stable tag: 0.25. 46 Tested up to: 3.4.2 7 Stable tag: 0.25.5 8 8 9 9 Cache the output of your blog widgets. Usually it will significantly reduce the SQL queries to your database and speed up your site. … … 12 12 13 13 A **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)16 14 17 15 **Why we need this WP Widget Cache?** -
wp-widget-cache/trunk/widget-cache.php
r283227 r620442 5 5 Description: Cache the output of your blog widgets. Usually it will significantly reduce the sql queries to your database and speed up your site. 6 6 Author: Andrew Zhang 7 Version: 0.25. 47 Version: 0.25.5 8 8 Author URI: http://www.nexwp.com 9 9 */ … … 14 14 { 15 15 var $plugin_name='WP Widget Cache'; 16 var $plugin_version='0.25. 4';16 var $plugin_version='0.25.5'; 17 17 var $plugin_uri='http://www.nexwp.com'; 18 18 … … 44 44 else 45 45 { 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(); 54 47 55 48 if($this->wgcEnabled) … … 104 97 if(!$ops)$ops=array(); 105 98 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"; 106 111 } 107 112 … … 238 243 $wc_varyparams = $this->wgcVaryParams; 239 244 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) 295 246 { 296 247 foreach ( $wp_registered_widgets as $id => $widget ) … … 298 249 if (!$wp_registered_widget_controls[$id]) 299 250 wp_register_widget_control($id,$widget['name'], array(&$this, 'widget_cache_empty_control')); 300 251 301 252 if (!array_key_exists(0,$wp_registered_widget_controls[$id]['params']) || is_array($wp_registered_widget_controls[$id]['params'][0])) 302 253 $wp_registered_widget_controls[$id]['params'][0]['id_for_wc']=$id; … … 306 257 $wp_registered_widget_controls[$id]['height']+=40; 307 258 } 308 259 309 260 $wp_registered_widget_controls[$id]['callback_wc_redirect']=$wp_registered_widget_controls[$id]['callback']; 310 261 $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(); 311 320 } 312 321 } … … 502 511 if ($wc_value>0) 503 512 { 504 echo "<!--$this->plugin_name $this->plugin_version ($this->plugin_uri)Begin -->\n";513 echo "<!--$this->plugin_name $this->plugin_version Begin -->\n"; 505 514 506 515 while($this->wcache->save($this->get_widget_cache_key($id), $wc_value, array(), $id) || ($this->widget_cache_getcache($id, $wc_value) && false)) … … 508 517 call_user_func_array($callback, $params); 509 518 } 519 510 520 echo "<!--$this->plugin_name End -->\n"; 511 521 }
Note: See TracChangeset
for help on using the changeset viewer.