WordPress.org

Plugin Directory

Changeset 862895


Ignore:
Timestamp:
02/22/14 05:30:10 (4 years ago)
Author:
markparolisi
Message:

fix php warning

Location:
voce-widget-cache/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • voce-widget-cache/trunk

    • Property svn:ignore
      •  

        old new  
        1 deploy.sh 
         1wpsvn-deploy 
        22README.md 
         3test 
         4tests 
        35.git 
        46.gitignore 
  • voce-widget-cache/trunk/readme.txt

    r631819 r862895  
    1 === Plugin Name === 
     1=== Voce Widget Cache === 
    22Contributors: johnciacia, markparolisi, voceplatforms 
    33Tags: widget 
    44Requires at least: 3.3 
    55Tested up to: 3.4 
    6 Stable tag: 1.1 
     6Stable tag: 1.3 
    77License: GPLv2 or later 
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html 
    99 
    10 Cache widget output for better performance. 
     10Easily cache widget output for better performance. 
    1111 
    1212== Description == 
     
    1818$widget_cache = Voce_Widget_Cache::GetInstance(); 
    1919$widget_cache->cache_widget( 'Archive_Links_Widget', array( 'save_post' ) ); 
     20$widget_cache->cache_widget( 'WP_Widget_Recent_Posts' ); 
    2021` 
    21  
    2222 
    2323== Installation == 
    2424 
    25251. Upload `voce-widget-cache` to the `/wp-content/plugins/` directory 
    26 1. Activate the plugin through the 'Plugins' menu in WordPress 
    27 1. Usage:  
    28  
     262. Activate the plugin through the 'Plugins' menu in WordPress 
     273. Usage:  
     28` 
    2929$widget_cache = Voce_Widget_Cache::GetInstance(); 
    3030$widget_cache->cache_widget( 'Archive_Links_Widget', array( 'save_post' ) ); 
    31  
     31$widget_cache->cache_widget( 'WP_Widget_Recent_Posts' ); 
     32` 
    3233 
    3334== Frequently Asked Questions == 
     
    3637 
    3738The caching is not automatic. Refer to the documentation to see how to implement caching on widgets. 
    38  
    3939 
    4040= How can I verify my widgets are being cached? = 
     
    4646== Changelog == 
    4747 
     48= 1.3 = 
     49Fix PHP Warning is widget array is not set. 
     50 
     51= 1.2 = 
     52Hooks to clear a widget's cache are now optional. 
     53 
    4854= 1.1 = 
    4955Updated documentation. 
  • voce-widget-cache/trunk/voce-widget-cache.php

    r631819 r862895  
    44  Plugin URI: http://voceconnect.com 
    55  Description: Serve cached WordPress Widgets. 
    6   Version: 1.1 
     6  Version: 1.3 
    77  Author: John Ciacia, Mark Parolisi 
    88  License: GPL2 
     
    7575         * @param $hooks an array of hooks to clear the widget from the cache 
    7676         */ 
    77         public function cache_widget( $widget_class, array $hooks ) { 
     77        public function cache_widget( $widget_class, array $hooks = array() ) { 
    7878            $this->widget_classes[] = $widget_class; 
    79             foreach( $hooks as $hook ){ 
    80                 add_action( "$hook", create_function( '', "Voce_Widget_Cache::GetInstance()->delete_cached_widgets('$widget_class');" ) ); 
     79            if ( ! empty( $hooks ) ) {   
     80                foreach( $hooks as $hook ){ 
     81                    add_action( "$hook", create_function( '', "Voce_Widget_Cache::GetInstance()->delete_cached_widgets('$widget_class');" ) ); 
     82                } 
    8183            } 
    8284            return $this; 
     
    123125         */ 
    124126        public function delete_cached_widgets( $widget_class ) { 
    125             foreach( $this->widget_ids[$widget_class] as $widget ){ 
    126                 $this->delete( $widget ); 
     127            if( is_array(  $this->widget_ids[$widget_class] ) ){ 
     128                foreach( $this->widget_ids[$widget_class] as $widget ){ 
     129                    $this->delete( $widget ); 
     130                } 
    127131            } 
    128132        } 
Note: See TracChangeset for help on using the changeset viewer.