Making WordPress.org

Changeset 15329


Ignore:
Timestamp:
10/14/2026 11:30:55 AM (9 days ago)
Author:
bor0
Message:

Support Forums: Clear singular query flags on user pages

Closes ​https://github.com/WordPress/wordpress.org/pull/1055.

File:
1 edited

Legend:

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

    r15191 r15329  
    2929                add_action( 'init',                            array( $this, 'add_rewrite_rules' ) );
    3030
     31                // Run after bbp_parse_query() (priority 2) has flagged user pages.
     32                add_action( 'parse_query', array( $this, 'reset_singular_flags_on_user_pages' ), 20 );
    3133
    3234                // Add bbPress support to the WordPress.org SEO plugin.
    … …  
    191193                if ( ! is_admin() && 'forum' === $query->get( 'post_type' ) ) {
    192194                        $query->set( 'post_status', 'publish' );
     195                }
     196        }
     197
     198        /**
     199         * Clear the singular flags on bbPress user pages.
     200         *
     201         * A stray `?page_id=` or `?pagename=` makes WP_Query flag the request as a page,
     202         * and bbPress keeps those flags when it takes over the query for a user page.
     203         * With no post to back them, get_body_class() then reads a null queried object.
     204         *
     205         * @param WP_Query $query Current query object.
     206         */
     207        public function reset_singular_flags_on_user_pages( $query ) {
     208                if ( $query->is_main_query() && ! empty( $query->bbp_is_single_user ) ) {
     209                        $query->is_page     = false;
     210                        $query->is_singular = false;
     211                        $query->is_single   = false;
    193212                }
    194213        }
Note: See TracChangeset for help on using the changeset viewer.