WordPress.org

Ready to get started?Download WordPress

Forums

WP Widget Cache
Option to disable HTML comments (1 post)

  1. QuickeneR
    Member
    Posted 1 year ago #

    By default WP Widget Cache marks the beginning and end of each widget it cached, along with configured cache life and widget name. This is great for debugging but might be too much information for production. Here is a patch to make it optional.

    --- widget-cache.php.org2	2012-10-09 19:09:09.000000000 +0600
    +++ widget-cache.php	2012-10-10 13:24:20.000000000 +0600
    @@ -27,6 +27,7 @@
     	var $wgcEnabled=true;
     	var $wgcAutoExpireEnabled=true;
     	var $wgcVaryParamsEnabled=false;
    +	var $wgcDisableHtmlComments=false;
    
     	var $triggerActions=array();
     	var $varyParams=array();
    @@ -51,6 +52,7 @@
     			$this->wgcEnabled= !($this->wgcSettings["wgc_disabled"]==="1");
     			$this->wgcAutoExpireEnabled= !($this->wgcSettings["wgc_ae_ops_disabled"]==="1");
     			$this->wgcVaryParamsEnabled= $this->wgcSettings["wgc_vary_by_params_enabled"]=="1";
    +			$this->wgcDisableHtmlComments= $this->wgcSettings["wgc_disable_html_comments"]=="1";
    
     			if($this->wgcEnabled)
     			{
    @@ -139,6 +141,7 @@
     			"wgc_disabled" => $_POST['wgc_enabled']? false:"1",
     			"wgc_ae_ops_disabled" => $_POST['wgc_ae_ops_enabled']? false:"1",
     			"wgc_vary_by_params_enabled" => $_POST['wgc_vary_by_params_enabled'],
    +			"wgc_disable_html_comments" => $_POST['wgc_disable_html_comments'],
     			);
     			$this->wgc_update_option("widget_cache_settings",$wp_settings);
     			echo '<div id="message" class="updated fade"><p>Options Updated</p></div>';
    @@ -175,6 +178,12 @@
     		        <label for=wgc_vary_by_params_enabled><strong>Enable vary by params options (e.g. Vary by user levels, user agents)</strong> </label>
     		        </td>
     		      </tr>
    +		      <tr valign="top">
    +		        <td>
    +		        <input name="wgc_disable_html_comments" type="checkbox" id="wgc_disable_html_comments" value="1" <?php checked('1', ($wp_settings["wgc_disable_html_comments"]=="1")); ?> />
    +		        <label for=wgc_disable_html_comments><strong>Disable the HTML comments this plugin adds by default to the page source</strong> </label>
    +		        </td>
    +		      </tr>
     		    </table>
     		    <p class="submit">
     		      <input type="submit" name="wp_wgc_load_default" value="Reset to Default Options &raquo;" class="button" onclick="return confirm('Are you sure to reset options?')" />
    @@ -428,7 +437,9 @@
    
     	function  widget_cache_getcache($id, $cachetime)
     	{
    -		echo "<!-- WP Widget Cached $id For $cachetime second(s)-->\n";
    +		if ( ! $this->wgcDisableHtmlComments ) {
    +		  echo "<!-- WP Widget Cached $id For $cachetime second(s)-->\n";
    +		}
     		return false;
     	}
    
    @@ -501,13 +512,17 @@
    
     		if ($wc_value>0)
     		{
    -			echo "<!--$this->plugin_name $this->plugin_version ($this->plugin_uri) Begin -->\n";
    +			if ( ! $this->wgcDisableHtmlComments ) {
    +			  echo "<!--$this->plugin_name $this->plugin_version ($this->plugin_uri) Begin -->\n";
    +			}
    
     			while ($this->wcache->save( (function_exists('pll_current_language') ? pll_current_language() : "") . $this->get_widget_cache_key($id), $wc_value, array(), $id) || ($this->widget_cache_getcache($id, $wc_value) && false ) )
     			{
     				call_user_func_array($callback, $params);
     			}
    -			echo "<!--$this->plugin_name End -->\n";
    +			if ( ! $this->wgcDisableHtmlComments ) {
    +			  echo "<!--$this->plugin_name End -->\n";
    +			}
     		}
     		else
     		{

    http://wordpress.org/extend/plugins/wp-widget-cache/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.