Making WordPress.org

Changeset 8264


Ignore:
Timestamp:
02/18/2019 01:48:34 AM (8 years ago)
Author:
dd32
Message:

Support Forums: Don't output paged canonical links for user profiles.

Fixes #4170.

File:
1 edited

Legend:

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

    r8263 r8264  
    304304         * Returns the canonical URL for various bbPress pages.
    305305         *
    306          * @return string The canonical URL.
     306         * @return array The canonical URL.
    307307         */
    308308        public function get_canonical_url() {
    309                 $canonical_url = '';
     309                $canonical_url  = false;
     310                $supports_paged = true;
    310311
    311312                if ( bbp_is_topic_tag() ) {
    … …  
    321322                } elseif ( bbpress()->displayed_user && bbpress()->displayed_user->exists() ) {
    322323                        // This covers all user pages rather than using 6 different bbp_is_*() calls.
    323                         $canonical_url = 'https://profiles.wordpress.org/' . bbpress()->displayed_user->user_nicename . '/';
    324                 }
    325 
    326                 return $canonical_url;
     324                        $canonical_url  = 'https://profiles.wordpress.org/' . bbpress()->displayed_user->user_nicename . '/';
     325                        $supports_paged = false;
     326                }
     327
     328                return [ $canonical_url, $supports_paged ];
    327329        }
    328330
    … …  
    331333         */
    332334        public function rel_canonical() {
    333                 $canonical_url = $this->get_canonical_url();
     335                list( $canonical_url, $canonical_supports_paged ) = $this->get_canonical_url();
    334336
    335337                if ( bbp_is_single_topic() || bbp_is_single_forum() ) {
    … …  
    339341                // Make sure canonical has pagination if needed.
    340342                $page = get_query_var( 'paged', 0 );
    341                 if ( $canonical_url && $page >= 2 ) {
     343                if ( $canonical_url && $canonical_supports_paged && $page >= 2 ) {
    342344                        $canonical_url .= 'page/' . absint( $page ) . '/';
    343345                }
    … …  
    354356                global $wp_query;
    355357
    356                 $canonical_url = $this->get_canonical_url();
    357                 $max_pages     = $wp_query->max_num_pages;
     358                list( $canonical_url ) = $this->get_canonical_url();
     359
     360                $max_pages = $wp_query->max_num_pages;
    358361
    359362                if ( bbp_is_single_view() ) {
Note: See TracChangeset for help on using the changeset viewer.