PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.5.0
Forumax – AI Powered Advanced Community Forum Plugin v2.5.0
2.5.0 2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 2.0.0 All 30 releases
← All changes | lib/bbpress/includes/replies/template.php +22 -5 2.4.2 → 2.5.0 View file →
@@ -128,13 +128,25 @@
128 128
129 129 /** Defaults **************************************************************/
130 130
131 131 // Other defaults
132 - $default_reply_search = bbp_sanitize_search_request( 'rs' );
133 - $default_post_parent = ( bbp_is_single_topic() ) ? bbp_get_topic_id() : 'any';
134 - $default_post_type = ( bbp_is_single_topic() && bbp_show_lead_topic() ) ? bbp_get_reply_post_type() : array( bbp_get_topic_post_type(), bbp_get_reply_post_type() );
135 - $default_thread_replies = (bool) ( bbp_is_single_topic() && bbp_thread_replies() );
132 + $default_reply_search = bbp_sanitize_search_request( 'rs' );
136 133
134 + // Prefer an explicit topic ID even when theme-compat has not marked this
135 + // request as a single topic yet. Otherwise post_parent defaults to 'any'
136 + // and the loop can load every topic and reply on the site.
137 + $single_topic_id = 0;
138 + if ( bbp_is_single_topic() ) {
139 + $single_topic_id = (int) bbp_get_topic_id();
140 + }
141 + if ( empty( $single_topic_id ) && ! empty( bbpress()->current_topic_id ) ) {
142 + $single_topic_id = (int) bbpress()->current_topic_id;
143 + }
144 +
145 + $default_post_parent = ! empty( $single_topic_id ) ? $single_topic_id : 'any';
146 + $default_post_type = ( ! empty( $single_topic_id ) && bbp_show_lead_topic() ) ? bbp_get_reply_post_type() : array( bbp_get_topic_post_type(), bbp_get_reply_post_type() );
147 + $default_thread_replies = (bool) ( ! empty( $single_topic_id ) && bbp_thread_replies() );
148 +
137 149 // Default query args
138 150 $default = array(
139 151 'post_type' => $default_post_type, // Only replies
140 152 'post_parent' => $default_post_parent, // Of this topic
@@ -182,9 +194,14 @@
182 194
183 195 // Set posts_per_page value if replies are threaded
184 196 $replies_per_page = (int) $r['posts_per_page'];
185 197 if ( true === $r['hierarchical'] ) {
186 - $r['posts_per_page'] = -1;
198 + // Never load the entire site: threaded queries require a topic parent.
199 + if ( is_numeric( $r['post_parent'] ) && (int) $r['post_parent'] > 0 ) {
200 + $r['posts_per_page'] = -1;
201 + } else {
202 + $r['hierarchical'] = false;
203 + }
187 204 }
188 205
189 206 // Get bbPress
190 207 $bbp = bbpress();