WordPress.org

Ready to get started?Download WordPress

Forums

Permalink Fix for Photopress 1.1 + WordPress 2.6.1 (2 posts)

  1. JodiJodiJodi
    Member
    Posted 5 years ago #

    Hello all,

    The permalink system of Photopress v1.1 is broken when you use a more recent version of wordpress (i'm using version 2.6.1).

    The problem is that the way photopress creates its permalinks is now broken.

    To fix the problem, you need to edit photopress.php and do the following changes:

    change
    add_filter('rewrite_rules_array', array('photopress_actions','photopress_album_rewrite'));
    to
    add_filter('generate_rewrite_rules', array('photopress_actions','photopress_album_rewrite'));

    and change
    class photopress_actions {
    // Rewrite rules for WP 2-ish, inspired by the Ultimate Tag Warrior plugin.
    function &photopress_album_rewrite(&$rules) {
    global $pp_options;
    if ($pp_options['wppermalinks'] == 'index') {
    $root_token = 'index.php/';
    } else {
    $root_token = '';
    }
    $rules[$root_token . $pp_options['album_token'] . '/([A-Za-z0-9-]+)/([0-9]+)?/?$'] = "index.php?pp_album=main&pp_cat=\$matches[1]&pp_page=\$matches[2]";
    $rules[$root_token . $pp_options['album_token'] . '/([A-Za-z0-9-]+)/(.+)?/?$'] = "index.php?pp_album=main&pp_cat=\$matches[1]&pp_image=\$matches[2]";
    $rules[$root_token . $pp_options['album_token'] . '/([A-Za-z0-9-]+)/?$'] = "index.php?pp_album=main&pp_cat=\$matches[1]";
    $rules[$root_token . '(' . $pp_options['album_token'] . ')/?$'] = "index.php?pp_album=main";
    return $rules;
    }
    // Adds some PP query vars to WP's array.
    function &pp_add_query_var(&$wpvar_array) {
    $wpvar_array[] = 'pp_album';
    $wpvar_array[] = 'pp_page';
    $wpvar_array[] = 'pp_cat';
    $wpvar_array[] = 'pp_image';
    return $wpvar_array;
    }
    }

    to
    class photopress_actions {
    // Rewrite rules for WP 2-ish, inspired by the Ultimate Tag Warrior plugin.
    function &photopress_album_rewrite(&$rules) {
    global $pp_options, $wp_rewrite;

    if ($pp_options['wppermalinks'] == 'index') {
    $root_token = 'index.php/';
    } else {
    $root_token = '';
    }
    $newrules[$root_token . $pp_options['album_token'] . '/([A-Za-z0-9-]+)/([0-9]+)?/?$'] = "index.php?pp_album=main&pp_cat=" . $wp_rewrite->preg_index(1) . "&pp_page=" . $wp_rewrite->preg_index(2);
    $newrules[$root_token . $pp_options['album_token'] . '/([A-Za-z0-9-]+)/(.+)?/?$'] = "index.php?pp_album=main&pp_cat=" . $wp_rewrite->preg_index(1) . "&pp_image=" . $wp_rewrite->preg_index(2);
    $newrules[$root_token . $pp_options['album_token'] . '/([A-Za-z0-9-]+)/?$'] = "index.php?pp_album=main&pp_cat=" . $wp_rewrite->preg_index(1);
    $newrules[$root_token . '(' . $pp_options['album_token'] . ')/?$'] = "index.php?pp_album=main";
    $wp_rewrite->rules = $newrules + $wp_rewrite->rules;
    }
    // Adds some PP query vars to WP's array.
    function &pp_add_query_var(&$wpvar_array) {
    $wpvar_array[] = 'pp_album';
    $wpvar_array[] = 'pp_page';
    $wpvar_array[] = 'pp_cat';
    $wpvar_array[] = 'pp_image';
    return $wpvar_array;
    }
    }

    ONE MORE STEP!
    Goto settings->permalinks and click on save. This will refresh the permalink structure and it will all work again :-)

    Heh, upgrading should be so painful!
    -Jodi

  2. silfver
    Member
    Posted 5 years ago #

    Thanks dude! :)

Topic Closed

This topic has been closed to new replies.

About this Topic