Making WordPress.org

Changeset 8213


Ignore:
Timestamp:
02/07/2019 06:59:25 AM (6 years ago)
Author:
dd32
Message:

Support Forum: Override WP::handle_404() for Theme/Plugin/Review forum views when a matching plugin/theme is found.

Fixes #4072.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php

    r7243 r8213  
    5959            // Remove new topic form at the bottom of reviews forum.
    6060            add_filter( 'bbp_get_template_part', array( $this, 'noop_reviews_forum_form_topic' ), 10, 3 );
     61
     62            // Tell WordPress not to 404 (before bbPress overrides it) so that Canonical can do it's job.
     63            add_filter( 'pre_handle_404', array( $this, 'abort_wp_handle_404' ) );
    6164        }
    6265    }
     
    394397        ||
    395398            ( ! empty( $this->contributors ) && in_array( $user->user_nicename, $this->contributors ) )
    396         || 
     399        ||
    397400            ( ! empty( $this->support_reps ) && in_array( $user->user_nicename, $this->support_reps ) )
    398         || 
     401        ||
    399402            // Back-compat for support reps added before https://meta.trac.wordpress.org/changeset/5867,
    400403            // can be removed once they are re-added via the Plugin Directory UI.
     
    705708
    706709    /**
     710     * Filter WP::handle_404() to not run on compat views, so as to allow Canonical to properly handle the request.
     711     */
     712    public function abort_wp_handle_404( $handled ) {
     713        if ( $this->slug() ) {
     714            // We've matched a term, so WordPress shouldn't 404 this request.
     715            $handled = true;
     716        }
     717
     718        return $handled;
     719    }
     720
     721
     722    /**
    707723     * Add a subscribe/unsubscribe link to the compat views.
    708724     */
     
    899915                     FROM {$prefix}terms AS t
    900916                     LEFT JOIN {$prefix}term_taxonomy AS tt ON tt.term_id = t.term_id
    901                      LEFT JOIN {$prefix}term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id 
     917                     LEFT JOIN {$prefix}term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id
    902918                     WHERE tt.taxonomy = 'plugin_committers' AND tr.object_id = %d",
    903919                     $plugin->ID
     
    934950                 FROM {$prefix}terms AS t
    935951                 LEFT JOIN {$prefix}term_taxonomy AS tt ON tt.term_id = t.term_id
    936                  LEFT JOIN {$prefix}term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id 
     952                 LEFT JOIN {$prefix}term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id
    937953                 WHERE tt.taxonomy = 'plugin_contributors' AND tr.object_id = %d",
    938954                 $plugin->ID
     
    968984                 FROM {$prefix}terms AS t
    969985                 LEFT JOIN {$prefix}term_taxonomy AS tt ON tt.term_id = t.term_id
    970                  LEFT JOIN {$prefix}term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id 
     986                 LEFT JOIN {$prefix}term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id
    971987                 WHERE tt.taxonomy = 'plugin_support_reps' AND tr.object_id = %d",
    972988                 $plugin->ID
Note: See TracChangeset for help on using the changeset viewer.