WP Widget Cache
Polylang support (3 posts)

  1. QuickeneR
    Posted 3 years ago #

    Same as suggested in this thread by DSmidge, adjusted for polylang

    --- widget-cache.php.org	2012-10-09 18:36:17.000000000 +0600
    +++ widget-cache.php	2012-10-09 18:38:55.000000000 +0600
    @@ -503,7 +503,7 @@
     			echo "<!--$this->plugin_name $this->plugin_version ($this->plugin_uri) Begin -->\n";
    -			while($this->wcache->save($this->get_widget_cache_key($id), $wc_value, array(), $id) || ($this->widget_cache_getcache($id, $wc_value) && false))
    +			while ($this->wcache->save( 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);


  2. RavanH
    Posted 3 years ago #

    Wow. I came to this forum to make mention of the incompatibility between Polylang and WP Widget Cache, just to find there is a patch. Great! but...

    Any chance this will make it into WP Widget Cache? And if not, can I request a filter where we can hook into with some extra code to make the two plugins play nice without running any customised versions?

  3. leoloso
    Posted 3 years ago #

    Yes, this would be the best, let's hope the author adds a filter. Something as simple as:

    apply_filters('widget_cache_key_id', $this->get_widget_cache_key($id))

    Then we can implement a solution in our functions.php: when using qTranslate, we just do this:

    add_filter("widget_cache_key_id", "widgetcache_qtrans_lang");
    function widgetcache_qtrans_lang($id) {
    	return $id . '-' . qtrans_getLanguage();

    And for Polylang:

    add_filter("widget_cache_key_id", "widgetcache_poly_lang");
    function widgetcache_poly_lang($id) {
    	return $id . '-' . pll_current_language();

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic