[wp-hackers] Help to fix orphaned plugin

Hikari lists at hikarinet.info
Mon Feb 15 03:09:53 UTC 2010


Hello guys, as a coincidence I'm having trouble with a plugin whose author is not accessible. It's essencial for my sites and I'm 
not able to fix it.

The plugin is sCategory Permalink: http://wordpress.org/extend/plugins/scategory-permalink/

It's on version 0.6.2, but I'm still using 0.3.0.



- 0.3.0 would be perfect if it didn't have a bug: comments pages return 404, so comments can't be breaken on pages.

- 0.4.0 fix this bug, but this version generates 404 for any permalink that uses %scategory% in it

- any other version after 0.4.0 has the same 404 bug, only 0.3.0 works



Well, I've tried everything. Disabled and re-enabled permalinks a lot of times, tried all kinds of permalinks. As soon as I remove 
%scategory% from permalink posts start back working. As soon as I add %scategory% back 404 is back too.

I decided to concentrate on 0.3.0 to 0.4.0 differences because they are almost the same.



There are basically 2 changes on these versions, one of them must be creating the 404 bug:

1) The following function is moved from 'post_rewrite_rules' filer to 'init' action:

0.3.0:

function addRewriteRules($rewrite) {
    global $wp_rewrite;
    $wp_rewrite->add_rewrite_tag('%scategory%', '(.+?)', 'category_name=');

    $scategory_structure = $wp_rewrite->root . "%scategory%/%postname%";

    $structure = ltrim($wp_rewrite->permalink_structure, '/');
    if (0 === strpos($structure, '%scategory%'))
        $wp_rewrite->use_verbose_page_rules = true;

    return array_merge($rewrite, $wp_rewrite->generate_rewrite_rules($scategory_structure));
}


0.4.0:

function addRewriteRules() {
    global $wp_rewrite;
    $wp_rewrite->add_rewrite_tag('%scategory%', '(.+?)', 'category_name=');
}




2) this new function, added to 0.4.0, hooked to 'post_rewrite_rules' filter:

function setVerbosePageRules($post_rewrite) {
    global $wp_rewrite;
    if (preg_match("/^[^%]*%scategory%/", $wp_rewrite->permalink_structure) )
        $wp_rewrite->use_verbose_page_rules = true;

    return $post_rewrite;
}





The lack of comments explaining what he is doing makes it harder to understand. IDK why he split the old function into 2 and moved 
part of it to 'init'. What he wanted to do and consequences.

I'm also not able to distinguish what part of code is fixing comment pages bug, and where permalink bug may be happening.

Any help will be very much appreciated.


---------------------------
Hikari -  A Luz ilumina a PAZ
http://Hikari.ws
http://ConscienciaPlanetaria.com

Tenha seu próprio email meunome @ ConscienciaPlanetaria.com.br!: http://seunome.ConscienciaPlanetaria.com.br



More information about the wp-hackers mailing list