Making WordPress.org

Changeset 8057

Timestamp:
01/09/2019 05:51:12 AM (6 years ago)
Author:
dd32
Message:

Forums: International: Update the redirects plugin to support redirecting of the >200char topic URLS in addition to id-based ones.

This fixes cases where threads with long slugs were no longer redirecting to their proper locations, now that bbPress2 has a 200-char slug limitation from WordPress.

Fixes #2228.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-bbp-redirect/wporg-bbp-redirect.php

    r3767 r8057  
    22/**
    33 * Plugin Name: bbPress: Redirect
    4  * Description: Redirect bbPress 1 id-based slugs to new title-based slugs.
     4 * Description: Redirect bbPress 1 id-based slugs to new title-based slugs.
    55 * Version:     1.0
    66 * Author:      WordPress.org
     
    5555
    5656            if ( in_array( $post_type, array( 'forum', 'topic' ) ) ) {
    57                 $maybe_id = get_query_var( 'name' );
     57                $maybe_id = get_query_var( $post_type ); // 'name' will be truncated to 200char, topic and forum are not.
     58
     59                $meta_key = '_wp_old_slug';
    5860                if ( is_numeric( $maybe_id ) ) {
     61
     62
    5963                    if ( absint( $maybe_id ) != $maybe_id ) {
    6064                        return;
    6165                    }
     66
     67
    6268                }
    63                 $post_id = $wpdb->get_var( $wpdb->prepare( "
    64                     SELECT post_id
     69
     70                $post_id = $wpdb->get_var( $wpdb->prepare(
     71                    "SELECT post_id
    6572                    FROM $wpdb->postmeta, $wpdb->posts
    6673                    WHERE ID = post_id
    6774                        AND post_type = %s
    6875                        AND meta_key = %s
    69                         AND meta_value = %d
     76                        AND meta_value = %
    7077                    LIMIT 1",
    7178                    $post_type,
    72                     sprintf( '_bbp_old_%s_id', $post_type ),
    73                     $maybe_id ) );
     79                    $meta_key,
     80                    $maybe_id
     81                ) );
    7482                if ( $post_id ) {
    7583                    $link = get_permalink( $post_id );
Note: See TracChangeset for help on using the changeset viewer.