WP Super Cache Error with Preloading Taxonomies on Mainblog of a Sub-directiory Multisite WordPress

With WP Super Cache 1.0, the author Donncha added a feature of preloading taxonomies (tags, categories) and custom post content. But if you run a multisite WordPress in sub-directory mode, this feature could be failure in the main blog.

UPDATE:

Been fixed in WPSC 1.3.2, using $out .= get_term_link( $term ). "\n"; to do the trick.

UPDATE:

This bug re-accured in WPSC version 1.3 and has not been fixed yet.

UPDATE:

This bug had been fixed in WPSC version 1.2.

As we know that WordPress uses blog before pre-base of tags, categories and posts to avoid url conflicts in main blog (via). The urls looks like:

https://cnzhx.net/blog/tag/multisite/
https://cnzhx.net/blog/category/wordpress/
https://cnzhx.net/blog/wpsc-error-with-preloading-taxonomies-on-mainblog-of-a-sub-directiory-multisite-wordpress/

And WP Super Cache (WPSC) doesn’t treat this well while preloading tags and categories. When preloading taxonomies, WPSC uses the following url pattern to get tags and categories pages:

https://cnzhx.net/blog/tag/multisite/
https://cnzhx.net/blog/category/wordpress/

Here is a snapshot of this:

Snapshot of WPSC preloading a tag page

This will not cause too much problems but it’s not elegant.

I will inform the author about this. Before it’s been solved, here are some tips maybe helpful:

1. Do not check option of “Preload tags, categories and other taxonomies”.

This option lies in “Preload” tab of “WP Super Cache Settings” page. (Recommended)

2. Fix the source code of this plugin as following description ( NOT recommended).

Open /wp-content/plugins/wp-super-cache/wp-cache.php file with a text editor.

Search for function wp_cron_preload_cache().

Find line of below (about 40 lines after the search result line) :

$taxonomies = apply_filters( 'wp_cache_preload_taxonomies', array( 'post_tag' => 'tag', 'category' => 'category' ) );

Add the following code snippet right after this line:

/**
 *
 * fix taxonomies url error, 2012.03.12 by Haoxian Zeng
 *
 * and line 2786
 */
 $main_blog_taxonomies_base = ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) == true && is_main_blog() ) ? 'blog/' : '';

Then find the folowing code line ( about 10 lines below),

$out .= site_url( $path . "/" . $term->slug . "/" ) . "\n";

change it to,

$out .= site_url( $main_blog_taxonomies_base . $path . "/" . $term->slug . "/" ) . "\n";

Notice:

  1. This bug affects only sub-directory mode of multisite WordPress.
  2. Even use the second way to fix the code, WPSC only preloads the first 50 tag-pages  because of the following line:
    $rows = array_splice( $details, 0, 50 );
  3. And then stop working which I think is another bug.

©

本文发表于水景一页。永久链接:<https://cnzhx.net/blog/wpsc-error-with-preloading-taxonomies-on-mainblog-of-a-sub-directiory-multisite-wordpress/>。转载请保留此信息及相应链接。

2 条关于 “WP Super Cache Error with Preloading Taxonomies on Mainblog of a Sub-directiory Multisite WordPress” 的评论

时间过去太久,评论已关闭。
如果您有话要说,请到讨论区留言并给出此文章链接。
谢谢您的理解 :-)