PluginProbe
bbPress / 2.6.17
bbPress v2.6.17
2.6.17 trunk 2.0 2.0-beta-1 2.0-beta-2b 2.0-beta-3 2.0-beta-3b 2.0-rc-2 2.0-rc-3 2.0-rc-4 2.0-rc-5 2.0.1 2.0.2 2.0.3 2.1 2.1-beta-1 2.1-rc1 2.1-rc2 2.1-rc3 2.1-rc4 2.1.1 2.1.2 2.1.3 2.2 2.2.1 All 72 releases
← All changes | bbpress.php +715 -487 2.12.6.17 View file →
@@ -4,9 +4,9 @@
4 4 * The bbPress Plugin
5 5 *
6 6 * bbPress is forum software with a twist from the creators of WordPress.
7 7 *
8 - * $Id: bbpress.php 4073 2012-07-08 11:06:00Z johnjamesjacoby $
8 + * $Id: bbpress.php 7528 2026-09-16 06:42:34Z johnjamesjacoby $
9 9 *
10 10 * @package bbPress
11 11 * @subpackage Main
12 12 */
@@ -11,28 +11,33 @@
11 11 * @subpackage Main
12 12 */
13 13
14 14 /**
15 - * Plugin Name: bbPress
16 - * Plugin URI: http://bbpress.org
17 - * Description: bbPress is forum software with a twist from the creators of WordPress.
18 - * Author: The bbPress Community
19 - * Author URI: http://bbpress.org
20 - * Version: 2.1
21 - * Text Domain: bbpress
22 - * Domain Path: /bbp-languages/
15 + * Plugin Name: bbPress
16 + * Plugin URI: https://bbpress.org
17 + * Description: bbPress is forum software with a twist from the creators of WordPress.
18 + * Author: The bbPress Contributors
19 + * Author URI: https://bbpress.org
20 + * License: GNU General Public License v2 or later
21 + * License URI: https://www.gnu.org/licenses/gpl-2.0.html
22 + * Text Domain: bbpress
23 + * Domain Path: /languages/
24 + * Requires PHP: 5.6.20
25 + * Requires at least: 6.0
26 + * Tested up to: 7.1
27 + * Version: 2.6.17
23 28 */
24 29
25 30 // Exit if accessed directly
26 -if ( !defined( 'ABSPATH' ) ) exit;
31 +defined( 'ABSPATH' ) || exit;
27 32
28 -if ( !class_exists( 'bbPress' ) ) :
33 +if ( ! class_exists( 'bbPress' ) ) :
29 34 /**
30 35 * Main bbPress Class
31 36 *
32 - * Tap tap tap... Is this thing on?
37 + * "Word hard. Stay bumble."
33 38 *
34 - * @since bbPress (r2464)
39 + * @since 2.0.0 bbPress (r2464)
35 40 */
36 41 final class bbPress {
37 42
38 43 /** Magic *****************************************************************/
@@ -37,14 +42,15 @@
37 42
38 43 /** Magic *****************************************************************/
39 44
40 45 /**
41 - * bbPress uses many variables, most of which can be filtered to customize
42 - * the way that it works. To prevent unauthorized access, these variables
43 - * are stored in a private array that is magically updated using PHP 5.2+
44 - * methods. This is to prevent third party plugins from tampering with
45 - * essential information indirectly, which would cause issues later.
46 + * bbPress uses many variables, several of which can be filtered to
47 + * customize the way it operates. Most of these variables are stored in a
48 + * private array that gets updated with the help of PHP magic methods.
46 49 *
50 + * This is a precautionary measure, to avoid potential errors produced by
51 + * unanticipated direct manipulation of run-time data.
52 + *
47 53 * @see bbPress::setup_globals()
48 54 * @var array
49 55 */
50 56 private $data;
@@ -56,9 +62,9 @@
56 62 */
57 63 public $current_user = false;
58 64
59 65 /**
60 - * @var obj Add-ons append to this (Akismet, BuddyPress, etc...)
66 + * @var stdClass Add-ons append to this (Akismet, BuddyPress, etc...)
61 67 */
62 68 public $extend;
63 69
64 70 /**
@@ -63,27 +69,32 @@
63 69
64 70 /**
65 71 * @var array Topic views
66 72 */
67 - public $views = array();
73 + public $views = array();
68 74
69 75 /**
70 76 * @var array Overloads get_option()
71 77 */
72 - public $options = array();
78 + public $options = array();
73 79
74 80 /**
81 + * @var array Storage of options not in the database
82 + */
83 + public $not_options = array();
84 +
85 + /**
75 86 * @var array Overloads get_user_meta()
76 87 */
77 88 public $user_options = array();
78 89
79 - /** Singleton *************************************************************/
80 -
81 90 /**
82 - * @var bbPress The one true bbPress
91 + * @var array Dynamically initialized user roles
83 92 */
84 - private static $instance;
93 + public $roles = array();
85 94
95 + /** Singleton *************************************************************/
96 +
86 97 /**
87 98 * Main bbPress Instance
88 99 *
89 100 * bbPress is fun
@@ -92,24 +103,30 @@
92 103 *
93 104 * Insures that only one instance of bbPress exists in memory at any one
94 105 * time. Also prevents needing to define globals all over the place.
95 106 *
96 - * @since bbPress (r3757)
97 - * @staticvar array $instance
98 - * @uses bbPress::setup_globals() Setup the globals needed
99 - * @uses bbPress::includes() Include the required files
100 - * @uses bbPress::setup_actions() Setup the hooks and actions
107 + * @since 2.1.0 bbPress (r3757)
108 + *
109 + * @staticvar object $instance
101 110 * @see bbpress()
102 - * @return The one true bbPress
111 + * @return bbPress The one true bbPress
103 112 */
104 113 public static function instance() {
105 - if ( ! isset( self::$instance ) ) {
106 - self::$instance = new bbPress;
107 - self::$instance->setup_globals();
108 - self::$instance->includes();
109 - self::$instance->setup_actions();
114 +
115 + // Store the instance locally to avoid private static replication
116 + static $instance = null;
117 +
118 + // Only run these methods if they haven't been ran previously
119 + if ( null === $instance ) {
120 + $instance = new bbPress();
121 + $instance->setup_environment();
122 + $instance->includes();
123 + $instance->setup_variables();
124 + $instance->setup_actions();
110 125 }
111 - return self::$instance;
126 +
127 + // Always return the instance
128 + return $instance;
112 129 }
113 130
114 131 /** Magic Methods *********************************************************/
115 132
@@ -115,90 +132,140 @@
115 132
116 133 /**
117 134 * A dummy constructor to prevent bbPress from being loaded more than once.
118 135 *
119 - * @since bbPress (r2464)
136 + * @since 2.0.0 bbPress (r2464)
137 + *
120 138 * @see bbPress::instance()
121 139 * @see bbpress();
122 140 */
123 - private function __construct() { /* Do nothing here */ }
141 + private function __construct() {
142 + /* Do nothing here */
143 + }
124 144
125 145 /**
126 146 * A dummy magic method to prevent bbPress from being cloned
127 147 *
128 - * @since bbPress (r2464)
148 + * @since 2.0.0 bbPress (r2464)
129 149 */
130 - public function __clone() { wp_die( __( 'Cheatin’ huh?', 'bbpress' ) ); }
150 + public function __clone() {
151 + _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'bbpress' ), '2.1' );
152 + }
131 153
132 154 /**
133 155 * A dummy magic method to prevent bbPress from being unserialized
134 156 *
135 - * @since bbPress (r2464)
157 + * @since 2.0.0 bbPress (r2464)
136 158 */
137 - public function __wakeup() { wp_die( __( 'Cheatin’ huh?', 'bbpress' ) ); }
159 + public function __wakeup() {
160 + _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'bbpress' ), '2.1' );
161 + }
138 162
139 163 /**
140 164 * Magic method for checking the existence of a certain custom field
141 165 *
142 - * @since bbPress (r3951)
166 + * @since 2.1.0 bbPress (r3951)
143 167 */
144 - public function __isset( $key ) { return isset( $this->data[$key] ); }
168 + public function __isset( $key ) {
169 + return isset( $this->data[ $key ] );
170 + }
145 171
146 172 /**
147 - * Magic method for getting bbPress varibles
173 + * Magic method for getting bbPress variables
148 174 *
149 - * @since bbPress (r3951)
175 + * @since 2.1.0 bbPress (r3951)
150 176 */
151 - public function __get( $key ) { return isset( $this->data[$key] ) ? $this->data[$key] : null; }
177 + public function __get( $key ) {
178 + return isset( $this->data[ $key ] )
179 + ? $this->data[ $key ]
180 + : null;
181 + }
152 182
153 183 /**
154 - * Magic method for setting bbPress varibles
184 + * Magic method for setting bbPress variables
155 185 *
156 - * @since bbPress (r3951)
186 + * @since 2.1.0 bbPress (r3951)
157 187 */
158 - public function __set( $key, $value ) { $this->data[$key] = $value; }
188 + public function __set( $key, $value ) {
189 + $this->data[ $key ] = $value;
190 + }
159 191
192 + /**
193 + * Magic method for unsetting bbPress variables
194 + *
195 + * @since 2.3.0 bbPress (r4628)
196 + */
197 + public function __unset( $key ) {
198 + if ( isset( $this->data[ $key ] ) ) {
199 + unset( $this->data[ $key ] );
200 + }
201 + }
202 +
203 + /**
204 + * Magic method to prevent notices and errors from invalid method calls
205 + *
206 + * @since 2.2.0 bbPress (r4252)
207 + */
208 + public function __call( $name = '', $args = array() ) {
209 + unset( $name, $args );
210 + return null;
211 + }
212 +
160 213 /** Private Methods *******************************************************/
161 214
162 215 /**
163 - * Set some smart defaults to class variables. Allow some of them to be
164 - * filtered to allow for early overriding.
216 + * Setup the environment variables to allow the rest of bbPress to function
217 + * more easily.
165 218 *
166 - * @since bbPress (r2626)
219 + * @since 2.0.0 bbPress (r2626)
220 + *
167 221 * @access private
168 - * @uses plugin_dir_path() To generate bbPress plugin path
169 - * @uses plugin_dir_url() To generate bbPress plugin url
170 - * @uses apply_filters() Calls various filters
171 222 */
172 - private function setup_globals() {
223 + private function setup_environment() {
173 224
174 225 /** Versions **********************************************************/
175 226
176 - $this->version = '2.1'; // bbPress version
177 - $this->db_version = '210'; // bbPress DB version
227 + $this->version = '2.6.17';
228 + $this->db_version = '263';
178 229
179 230 /** Paths *************************************************************/
180 231
181 - // Setup some base path and URL information
182 - $this->file = __FILE__;
183 - $this->basename = apply_filters( 'bbp_plugin_basenname', plugin_basename( $this->file ) );
184 - $this->plugin_dir = apply_filters( 'bbp_plugin_dir_path', plugin_dir_path( $this->file ) );
185 - $this->plugin_url = apply_filters( 'bbp_plugin_dir_url', plugin_dir_url ( $this->file ) );
232 + // File & base
233 + $this->file = __FILE__;
234 + $this->basename = apply_filters( 'bbp_plugin_basename', str_replace( array( 'build/', 'src/' ), '', plugin_basename( $this->file ) ) );
235 + $this->basepath = apply_filters( 'bbp_plugin_basepath', trailingslashit( dirname( $this->basename ) ) );
186 236
187 - // Themes
188 - $this->themes_dir = apply_filters( 'bbp_themes_dir', trailingslashit( $this->plugin_dir . 'bbp-themes' ) );
189 - $this->themes_url = apply_filters( 'bbp_themes_url', trailingslashit( $this->plugin_url . 'bbp-themes' ) );
237 + // Path and URL
238 + $this->plugin_dir = apply_filters( 'bbp_plugin_dir_path', plugin_dir_path( $this->file ) );
239 + $this->plugin_url = apply_filters( 'bbp_plugin_dir_url', plugin_dir_url ( $this->file ) );
190 240
241 + // Includes
242 + $this->includes_dir = apply_filters( 'bbp_includes_dir', trailingslashit( $this->plugin_dir . 'includes' ) );
243 + $this->includes_url = apply_filters( 'bbp_includes_url', trailingslashit( $this->plugin_url . 'includes' ) );
244 +
191 245 // Languages
192 - $this->lang_dir = apply_filters( 'bbp_lang_dir', trailingslashit( $this->plugin_dir . 'bbp-languages' ) );
246 + $this->lang_base = apply_filters( 'bbp_lang_base', trailingslashit( $this->basepath . 'languages' ) );
247 + $this->lang_dir = apply_filters( 'bbp_lang_dir', trailingslashit( $this->plugin_dir . 'languages' ) );
193 248
249 + // Templates
250 + $this->themes_dir = apply_filters( 'bbp_themes_dir', trailingslashit( $this->plugin_dir . 'templates' ) );
251 + $this->themes_url = apply_filters( 'bbp_themes_url', trailingslashit( $this->plugin_url . 'templates' ) );
252 + }
253 +
254 + /**
255 + * Smart defaults to many bbPress specific class variables.
256 + *
257 + * @since 2.6.0 bbPress (r6330)
258 + */
259 + private function setup_variables() {
260 +
194 261 /** Identifiers *******************************************************/
195 262
196 263 // Post type identifiers
197 264 $this->forum_post_type = apply_filters( 'bbp_forum_post_type', 'forum' );
198 265 $this->topic_post_type = apply_filters( 'bbp_topic_post_type', 'topic' );
266 + $this->topic_tag_tax_id = apply_filters( 'bbp_topic_tag_tax_id', 'topic-tag' );
199 267 $this->reply_post_type = apply_filters( 'bbp_reply_post_type', 'reply' );
200 - $this->topic_tag_tax_id = apply_filters( 'bbp_topic_tag_tax_id', 'topic-tag' );
201 268
202 269 // Status identifiers
203 270 $this->spam_status_id = apply_filters( 'bbp_spam_post_status', 'spam' );
204 271 $this->closed_status_id = apply_filters( 'bbp_closed_post_status', 'closed' );
@@ -209,22 +276,33 @@
209 276 $this->hidden_status_id = apply_filters( 'bbp_hidden_post_status', 'hidden' );
210 277 $this->trash_status_id = apply_filters( 'bbp_trash_post_status', 'trash' );
211 278
212 279 // Other identifiers
213 - $this->user_id = apply_filters( 'bbp_user_id', 'bbp_user' );
214 - $this->view_id = apply_filters( 'bbp_view_id', 'bbp_view' );
215 - $this->edit_id = apply_filters( 'bbp_edit_id', 'edit' );
280 + $this->user_id = apply_filters( 'bbp_user_id', 'bbp_user' );
281 + $this->tops_id = apply_filters( 'bbp_tops_id', 'bbp_tops' );
282 + $this->reps_id = apply_filters( 'bbp_reps_id', 'bbp_reps' );
283 + $this->favs_id = apply_filters( 'bbp_favs_id', 'bbp_favs' );
284 + $this->subs_id = apply_filters( 'bbp_subs_id', 'bbp_subs' );
285 + $this->view_id = apply_filters( 'bbp_view_id', 'bbp_view' );
286 + $this->edit_id = apply_filters( 'bbp_edit_id', 'edit' );
287 + $this->paged_id = apply_filters( 'bbp_paged_id', 'paged' );
288 + $this->search_id = apply_filters( 'bbp_search_id', 'bbp_search' );
289 + $this->engagements_id = apply_filters( 'bbp_engagements_id', 'bbp_engagements' );
216 290
217 291 /** Queries ***********************************************************/
218 292
293 + $this->current_view_id = 0; // Current view id
219 294 $this->current_forum_id = 0; // Current forum id
220 295 $this->current_topic_id = 0; // Current topic id
221 296 $this->current_reply_id = 0; // Current reply id
222 297 $this->current_topic_tag_id = 0; // Current topic tag id
298 + $this->current_user_id = 0; // Current topic tag id
223 299
224 - $this->forum_query = new stdClass; // Main forum query
225 - $this->topic_query = new stdClass; // Main topic query
226 - $this->reply_query = new stdClass; // Main reply query
300 + $this->forum_query = new WP_Query(); // Main forum query
301 + $this->topic_query = new WP_Query(); // Main topic query
302 + $this->reply_query = new WP_Query(); // Main reply query
303 + $this->search_query = new WP_Query(); // Main search query
304 + $this->user_query = new BBP_User_Query(); // Main user query
227 305
228 306 /** Theme Compat ******************************************************/
229 307
230 308 $this->theme_compat = new stdClass(); // Base theme compatibility class
@@ -231,86 +309,98 @@
231 309 $this->filters = new stdClass(); // Used when adding/removing filters
232 310
233 311 /** Users *************************************************************/
234 312
235 - $this->current_user = new stdClass(); // Currently logged in user
236 - $this->displayed_user = new stdClass(); // Currently displayed user
313 + $this->current_user = new WP_User(); // Currently logged in user
314 + $this->displayed_user = new WP_User(); // Currently displayed user
237 315
238 316 /** Misc **************************************************************/
239 317
318 + $this->domain = 'bbpress'; // Unique identifier for retrieving translated strings
240 319 $this->extend = new stdClass(); // Plugins add data here
241 320 $this->errors = new WP_Error(); // Feedback
242 - $this->tab_index = apply_filters( 'bbp_default_tab_index', 100 );
243 321
244 - /** Cache *************************************************************/
322 + /** Deprecated ********************************************************/
245 323
246 - // Add bbPress to global cache groups
247 - wp_cache_add_global_groups( 'bbpress' );
324 + $this->tab_index = apply_filters( 'bbp_default_tab_index', 100 );
248 325 }
249 326
250 327 /**
251 328 * Include required files
252 329 *
253 - * @since bbPress (r2626)
330 + * @since 2.0.0 bbPress (r2626)
331 + *
254 332 * @access private
255 - * @todo Be smarter about conditionally loading code
256 - * @uses is_admin() If in WordPress admin, load additional file
257 333 */
258 334 private function includes() {
259 335
260 336 /** Core **************************************************************/
261 337
262 - require( $this->plugin_dir . 'bbp-includes/bbp-core-cache.php' ); // Cache helpers
263 - require( $this->plugin_dir . 'bbp-includes/bbp-core-actions.php' ); // All actions
264 - require( $this->plugin_dir . 'bbp-includes/bbp-core-filters.php' ); // All filters
265 - require( $this->plugin_dir . 'bbp-includes/bbp-core-functions.php' ); // Core functions
266 - require( $this->plugin_dir . 'bbp-includes/bbp-core-options.php' ); // Configuration options
267 - require( $this->plugin_dir . 'bbp-includes/bbp-core-caps.php' ); // Roles and capabilities
268 - require( $this->plugin_dir . 'bbp-includes/bbp-core-classes.php' ); // Common classes
269 - require( $this->plugin_dir . 'bbp-includes/bbp-core-widgets.php' ); // Sidebar widgets
270 - require( $this->plugin_dir . 'bbp-includes/bbp-core-shortcodes.php' ); // Shortcodes for use with pages and posts
271 - require( $this->plugin_dir . 'bbp-includes/bbp-core-update.php' ); // Database updater
338 + require $this->includes_dir . 'core/abstraction.php';
339 + require $this->includes_dir . 'core/sub-actions.php';
340 + require $this->includes_dir . 'core/functions.php';
341 + require $this->includes_dir . 'core/cache.php';
342 + require $this->includes_dir . 'core/options.php';
343 + require $this->includes_dir . 'core/capabilities.php';
344 + require $this->includes_dir . 'core/update.php';
345 + require $this->includes_dir . 'core/template-functions.php';
346 + require $this->includes_dir . 'core/template-loader.php';
347 + require $this->includes_dir . 'core/theme-compat.php';
272 348
273 - /** Templates *********************************************************/
349 + /** Components ********************************************************/
274 350
275 - require( $this->plugin_dir . 'bbp-includes/bbp-template-functions.php' ); // Template functions
276 - require( $this->plugin_dir . 'bbp-includes/bbp-template-loader.php' ); // Template loader
277 - require( $this->plugin_dir . 'bbp-includes/bbp-theme-compatibility.php' ); // Theme compatibility for existing themes
351 + // Common
352 + require $this->includes_dir . 'common/ajax.php';
353 + require $this->includes_dir . 'common/classes.php';
354 + require $this->includes_dir . 'common/engagements.php';
355 + require $this->includes_dir . 'common/functions.php';
356 + require $this->includes_dir . 'common/formatting.php';
357 + require $this->includes_dir . 'common/locale.php';
358 + require $this->includes_dir . 'common/locks.php';
359 + require $this->includes_dir . 'common/rest.php';
360 + require $this->includes_dir . 'common/xmlrpc.php';
361 + require $this->includes_dir . 'common/template.php';
362 + require $this->includes_dir . 'common/widgets.php';
363 + require $this->includes_dir . 'common/shortcodes.php';
278 364
279 - /** Extensions ********************************************************/
365 + // Forums
366 + require $this->includes_dir . 'forums/capabilities.php';
367 + require $this->includes_dir . 'forums/functions.php';
368 + require $this->includes_dir . 'forums/template.php';
280 369
281 - require( $this->plugin_dir . 'bbp-includes/bbp-extend-akismet.php' ); // Spam prevention for topics and replies
370 + // Topics
371 + require $this->includes_dir . 'topics/capabilities.php';
372 + require $this->includes_dir . 'topics/functions.php';
373 + require $this->includes_dir . 'topics/template.php';
282 374
283 - /**
284 - * BuddyPress extension is loaded in bbp-core-hooks.php
285 - *
286 - * @since bbPress (r3559)
287 - */
375 + // Replies
376 + require $this->includes_dir . 'replies/capabilities.php';
377 + require $this->includes_dir . 'replies/functions.php';
378 + require $this->includes_dir . 'replies/template.php';
288 379
289 - /** Components ********************************************************/
380 + // Search
381 + require $this->includes_dir . 'search/functions.php';
382 + require $this->includes_dir . 'search/template.php';
290 383
291 - require( $this->plugin_dir . 'bbp-includes/bbp-common-functions.php' ); // Common functions
292 - require( $this->plugin_dir . 'bbp-includes/bbp-common-template.php' ); // Common template tags
384 + // Users
385 + require $this->includes_dir . 'users/capabilities.php';
386 + require $this->includes_dir . 'users/engagements.php';
387 + require $this->includes_dir . 'users/functions.php';
388 + require $this->includes_dir . 'users/template.php';
389 + require $this->includes_dir . 'users/options.php';
390 + require $this->includes_dir . 'users/signups.php';
293 391
294 - require( $this->plugin_dir . 'bbp-includes/bbp-forum-functions.php' ); // Forum functions
295 - require( $this->plugin_dir . 'bbp-includes/bbp-forum-template.php' ); // Forum template tags
392 + /** Hooks *************************************************************/
296 393
297 - require( $this->plugin_dir . 'bbp-includes/bbp-topic-functions.php' ); // Topic functions
298 - require( $this->plugin_dir . 'bbp-includes/bbp-topic-template.php' ); // Topic template tags
394 + require $this->includes_dir . 'core/extend.php';
395 + require $this->includes_dir . 'core/actions.php';
396 + require $this->includes_dir . 'core/filters.php';
299 397
300 - require( $this->plugin_dir . 'bbp-includes/bbp-reply-functions.php' ); // Reply functions
301 - require( $this->plugin_dir . 'bbp-includes/bbp-reply-template.php' ); // Reply template tags
302 -
303 - require( $this->plugin_dir . 'bbp-includes/bbp-user-functions.php' ); // User functions
304 - require( $this->plugin_dir . 'bbp-includes/bbp-user-template.php' ); // User template tags
305 - require( $this->plugin_dir . 'bbp-includes/bbp-user-options.php' ); // User options
306 -
307 398 /** Admin *************************************************************/
308 399
309 400 // Quick admin check and load if needed
310 401 if ( is_admin() ) {
311 - require( $this->plugin_dir . 'bbp-admin/bbp-admin.php' );
312 - require( $this->plugin_dir . 'bbp-admin/bbp-actions.php' );
402 + require $this->includes_dir . 'admin/actions.php';
313 403 }
314 404 }
315 405
316 406 /**
@@ -315,14 +405,11 @@
315 405
316 406 /**
317 407 * Setup the default hooks and actions
318 408 *
319 - * @since bbPress (r2644)
409 + * @since 2.0.0 bbPress (r2644)
410 + *
320 411 * @access private
321 - * @todo Not use bbp_is_deactivation()
322 - * @uses register_activation_hook() To register the activation hook
323 - * @uses register_deactivation_hook() To register the deactivation hook
324 - * @uses add_action() To add various actions
325 412 */
326 413 private function setup_actions() {
327 414
328 415 // Add actions to plugin activation and deactivation hooks
@@ -329,29 +416,35 @@
329 416 add_action( 'activate_' . $this->basename, 'bbp_activation' );
330 417 add_action( 'deactivate_' . $this->basename, 'bbp_deactivation' );
331 418
332 419 // If bbPress is being deactivated, do not add any actions
333 - if ( bbp_is_deactivation( $this->basename ) )
420 + if ( bbp_is_deactivation( $this->basename ) ) {
334 421 return;
422 + }
335 423
336 424 // Array of bbPress core actions
337 425 $actions = array(
338 426 'setup_theme', // Setup the default theme compat
339 427 'setup_current_user', // Setup currently logged in user
428 + 'setup_engagements', // Setup user engagements strategy
429 + 'roles_init', // User roles init
430 + 'register_meta', // Register meta (forum|topic|reply|user)
340 431 'register_post_types', // Register post types (forum|topic|reply)
341 432 'register_post_statuses', // Register post statuses (closed|spam|orphan|hidden)
342 433 'register_taxonomies', // Register taxonomies (topic-tag)
434 + 'register_shortcodes', // Register shortcodes (bbp-login)
343 435 'register_views', // Register the views (no-replies)
344 - 'register_theme_directory', // Register the theme directory (bbp-themes)
345 436 'register_theme_packages', // Register bundled theme packages (bbp-theme-compat/bbp-themes)
346 437 'load_textdomain', // Load textdomain (bbpress)
347 - 'add_rewrite_tags', // Add rewrite tags (view|user|edit)
348 - 'generate_rewrite_rules' // Generate rewrite rules (view|edit)
438 + 'add_rewrite_tags', // Add rewrite tags (view|user|edit|search)
439 + 'add_rewrite_rules', // Generate rewrite rules (view|edit|paged|search)
440 + 'add_permastructs' // Add permalink structures (view|user|search)
349 441 );
350 442
351 443 // Add the actions
352 - foreach( $actions as $class_action )
444 + foreach ( $actions as $class_action ) {
353 445 add_action( 'bbp_' . $class_action, array( $this, $class_action ), 5 );
446 + }
354 447
355 448 // All bbPress actions are setup (includes bbp-core-hooks.php)
356 449 do_action_ref_array( 'bbp_after_setup_actions', array( &$this ) );
357 450 }
@@ -364,280 +457,164 @@
364 457 * Note that since we currently have complete control over bbp-themes and
365 458 * the bbp-theme-compat folders, it's fine to hardcode these here. If at a
366 459 * later date we need to automate this, and API will need to be built.
367 460 *
368 - * @since bbPress (r3829)
461 + * @since 2.1.0 bbPress (r3829)
369 462 */
370 463 public function register_theme_packages() {
371 464
372 - /** Default Theme *****************************************************/
465 + // Register the basic theme stack. This is really dope.
466 + bbp_register_template_stack( 'get_stylesheet_directory', 6 );
467 + bbp_register_template_stack( 'get_template_directory', 8 );
373 468
374 - bbp_register_theme_package( array(
375 - 'id' => 'default',
376 - 'name' => __( 'bbPress Default', 'bbpress' ),
377 - 'version' => bbp_get_version(),
378 - 'dir' => trailingslashit( $this->plugin_dir . 'bbp-theme-compat' ),
379 - 'url' => trailingslashit( $this->plugin_url . 'bbp-theme-compat' )
380 - ) );
381 -
382 - /** Twenty Ten ********************************************************/
383 -
384 - bbp_register_theme_package( array(
385 - 'id' => 'bbp-twentyten',
386 - 'name' => __( 'Twenty Ten (bbPress)', 'bbpress' ),
387 - 'version' => bbp_get_version(),
388 - 'dir' => trailingslashit( $this->themes_dir . 'bbp-twentyten' ),
389 - 'url' => trailingslashit( $this->themes_url . 'bbp-twentyten' )
390 - ) );
469 + // Register the default theme compatibility package
470 + bbp_register_theme_package(
471 + array(
472 + 'id' => 'default',
473 + 'name' => 'bbPress Default',
474 + 'version' => bbp_get_version(),
475 + 'dir' => trailingslashit( $this->themes_dir . 'default' ),
476 + 'url' => trailingslashit( $this->themes_url . 'default' )
477 + )
478 + );
391 479 }
392 480
393 481 /**
394 - * Setup the default bbPress theme compatability location.
482 + * Setup the default bbPress theme compatibility location.
395 483 *
396 - * @since bbPress (r3778)
484 + * @since 2.1.0 bbPress (r3778)
397 485 */
398 486 public function setup_theme() {
399 -
400 - // Bail if something already has this under control
401 - if ( ! empty( $this->theme_compat->theme ) )
402 - return;
403 -
404 - // Setup the theme package to use for compatibility
405 487 bbp_setup_theme_compat( bbp_get_theme_package_id() );
406 488 }
407 489
408 490 /**
409 - * Load the translation file for current language. Checks the languages
410 - * folder inside the bbPress plugin first, and then the default WordPress
411 - * languages folder.
491 + * Load the translation file for current language. Checks the deprecated
492 + * languages folder inside the bbPress plugin first, and then the default
493 + * WordPress languages folder.
412 494 *
413 495 * Note that custom translation files inside the bbPress plugin folder
414 496 * will be removed on bbPress updates. If you're creating custom
415 497 * translation files, please use the global language folder.
416 498 *
417 - * @since bbPress (r2596)
418 - *
419 - * @uses apply_filters() Calls 'bbpress_locale' with the
420 - * {@link get_locale()} value
421 - * @uses load_textdomain() To load the textdomain
422 - * @return bool True on success, false on failure
499 + * @since 2.0.0 bbPress (r2596)
423 500 */
424 501 public function load_textdomain() {
425 - $locale = get_locale(); // Default locale
426 - $locale = apply_filters( 'plugin_locale', $locale, 'bbpress' ); // Traditional WordPress plugin locale filter
427 - $locale = apply_filters( 'bbpress_locale', $locale ); // bbPress specific locale filter
428 - $mofile = sprintf( 'bbpress-%s.mo', $locale ); // Get mo file name
429 502
430 - // Setup paths to current locale file
431 - $mofile_local = $this->lang_dir . $mofile;
432 - $mofile_global = WP_LANG_DIR . '/bbpress/' . $mofile;
503 + // Define the old directory
504 + $old_dir = WP_LANG_DIR . '/bbpress/';
433 505
434 - // Look in local /wp-content/plugins/bbpress/bbp-languages/ folder
435 - if ( file_exists( $mofile_local ) ) {
436 - return load_textdomain( 'bbpress', $mofile_local );
506 + // Old location, deprecated in 2.6.0
507 + if ( is_dir( $old_dir ) ) {
437 508
438 - // Look in global /wp-content/languages/bbpress folder
439 - } elseif ( file_exists( $mofile_global ) ) {
440 - return load_textdomain( 'bbpress', $mofile_global );
509 + // Get locale & file-name
510 + $type = is_admin() ? get_user_locale() : get_locale();
511 + $locale = apply_filters( 'plugin_locale', $type, $this->domain );
512 + $mofile = sprintf( '%1$s-%2$s.mo', $this->domain, $locale );
513 +
514 + // Look in global /wp-content/languages/bbpress/ folder
515 + load_textdomain( $this->domain, $old_dir . $mofile );
441 516 }
442 517
443 - // Nothing found
444 - return false;
518 + // Look in global /wp-content/languages/plugins/
519 + load_plugin_textdomain( $this->domain, false, $this->lang_base );
445 520 }
446 521
447 522 /**
448 - * Sets up the bbPress theme directory to use in WordPress
449 - *
450 - * @since bbPress (r2507)
451 - * @uses register_theme_directory() To register the theme directory
452 - * @return bool True on success, false on failure
453 - */
454 - public function register_theme_directory() {
455 - return register_theme_directory( $this->themes_dir );
456 - }
457 -
458 - /**
459 523 * Setup the post types for forums, topics and replies
460 524 *
461 - * @since bbPress (r2597)
462 - * @uses register_post_type() To register the post types
463 - * @uses apply_filters() Calls various filters to modify the arguments
464 - * sent to register_post_type()
525 + * @since 2.0.0 bbPress (r2597)
465 526 */
466 527 public static function register_post_types() {
467 528
468 - // Define local variable(s)
469 - $post_type = array();
470 -
471 529 /** Forums ************************************************************/
472 530
473 - // Forum labels
474 - $post_type['labels'] = array(
475 - 'name' => __( 'Forums', 'bbpress' ),
476 - 'menu_name' => __( 'Forums', 'bbpress' ),
477 - 'singular_name' => __( 'Forum', 'bbpress' ),
478 - 'all_items' => __( 'All Forums', 'bbpress' ),
479 - 'add_new' => __( 'New Forum', 'bbpress' ),
480 - 'add_new_item' => __( 'Create New Forum', 'bbpress' ),
481 - 'edit' => __( 'Edit', 'bbpress' ),
482 - 'edit_item' => __( 'Edit Forum', 'bbpress' ),
483 - 'new_item' => __( 'New Forum', 'bbpress' ),
484 - 'view' => __( 'View Forum', 'bbpress' ),
485 - 'view_item' => __( 'View Forum', 'bbpress' ),
486 - 'search_items' => __( 'Search Forums', 'bbpress' ),
487 - 'not_found' => __( 'No forums found', 'bbpress' ),
488 - 'not_found_in_trash' => __( 'No forums found in Trash', 'bbpress' ),
489 - 'parent_item_colon' => __( 'Parent Forum:', 'bbpress' )
490 - );
491 -
492 - // Forum rewrite
493 - $post_type['rewrite'] = array(
494 - 'slug' => bbp_get_forum_slug(),
495 - 'with_front' => false
496 - );
497 -
498 - // Forum supports
499 - $post_type['supports'] = array(
500 - 'title',
501 - 'editor',
502 - 'revisions'
503 - );
504 -
505 531 // Register Forum content type
506 532 register_post_type(
507 533 bbp_get_forum_post_type(),
508 - apply_filters( 'bbp_register_forum_post_type', array(
509 - 'labels' => $post_type['labels'],
510 - 'rewrite' => $post_type['rewrite'],
511 - 'supports' => $post_type['supports'],
512 - 'description' => __( 'bbPress Forums', 'bbpress' ),
513 - 'capabilities' => bbp_get_forum_caps(),
514 - 'capability_type' => array( 'forum', 'forums' ),
515 - 'menu_position' => 555555,
516 - 'has_archive' => bbp_get_root_slug(),
517 - 'exclude_from_search' => true,
518 - 'show_in_nav_menus' => true,
519 - 'public' => true,
520 - 'show_ui' => bbp_current_user_can_see( bbp_get_forum_post_type() ),
521 - 'can_export' => true,
522 - 'hierarchical' => true,
523 - 'query_var' => true,
524 - 'menu_icon' => ''
525 - ) )
534 + apply_filters(
535 + 'bbp_register_forum_post_type',
536 + array(
537 + 'labels' => bbp_get_forum_post_type_labels(),
538 + 'rewrite' => bbp_get_forum_post_type_rewrite(),
539 + 'supports' => bbp_get_forum_post_type_supports(),
540 + 'description' => esc_html__( 'bbPress Forums', 'bbpress' ),
541 + 'capabilities' => bbp_get_forum_caps(),
542 + 'capability_type' => array( 'forum', 'forums' ),
543 + 'menu_position' => 555555,
544 + 'has_archive' => bbp_get_root_slug(),
545 + 'exclude_from_search' => true,
546 + 'show_in_nav_menus' => true,
547 + 'public' => true,
548 + 'show_ui' => current_user_can( 'bbp_forums_admin' ),
549 + 'rest_controller_class' => 'BBP_REST_Posts_Controller',
550 + 'can_export' => true,
551 + 'hierarchical' => true,
552 + 'query_var' => true,
553 + 'menu_icon' => '',
554 + 'source' => 'bbpress',
555 + )
556 + )
526 557 );
527 558
528 559 /** Topics ************************************************************/
529 560
530 - // Topic labels
531 - $post_type['labels'] = array(
532 - 'name' => __( 'Topics', 'bbpress' ),
533 - 'menu_name' => __( 'Topics', 'bbpress' ),
534 - 'singular_name' => __( 'Topic', 'bbpress' ),
535 - 'all_items' => __( 'All Topics', 'bbpress' ),
536 - 'add_new' => __( 'New Topic', 'bbpress' ),
537 - 'add_new_item' => __( 'Create New Topic', 'bbpress' ),
538 - 'edit' => __( 'Edit', 'bbpress' ),
539 - 'edit_item' => __( 'Edit Topic', 'bbpress' ),
540 - 'new_item' => __( 'New Topic', 'bbpress' ),
541 - 'view' => __( 'View Topic', 'bbpress' ),
542 - 'view_item' => __( 'View Topic', 'bbpress' ),
543 - 'search_items' => __( 'Search Topics', 'bbpress' ),
544 - 'not_found' => __( 'No topics found', 'bbpress' ),
545 - 'not_found_in_trash' => __( 'No topics found in Trash', 'bbpress' ),
546 - 'parent_item_colon' => __( 'Forum:', 'bbpress' )
547 - );
548 -
549 - // Topic rewrite
550 - $post_type['rewrite'] = array(
551 - 'slug' => bbp_get_topic_slug(),
552 - 'with_front' => false
553 - );
554 -
555 - // Topic supports
556 - $post_type['supports'] = array(
557 - 'title',
558 - 'editor',
559 - 'revisions'
560 - );
561 -
562 561 // Register Topic content type
563 562 register_post_type(
564 563 bbp_get_topic_post_type(),
565 - apply_filters( 'bbp_register_topic_post_type', array(
566 - 'labels' => $post_type['labels'],
567 - 'rewrite' => $post_type['rewrite'],
568 - 'supports' => $post_type['supports'],
569 - 'description' => __( 'bbPress Topics', 'bbpress' ),
570 - 'capabilities' => bbp_get_topic_caps(),
571 - 'capability_type' => array( 'topic', 'topics' ),
572 - 'menu_position' => 555555,
573 - 'has_archive' => bbp_get_topic_archive_slug(),
574 - 'exclude_from_search' => true,
575 - 'show_in_nav_menus' => false,
576 - 'public' => true,
577 - 'show_ui' => bbp_current_user_can_see( bbp_get_topic_post_type() ),
578 - 'can_export' => true,
579 - 'hierarchical' => false,
580 - 'query_var' => true,
581 - 'menu_icon' => ''
564 + apply_filters(
565 + 'bbp_register_topic_post_type',
566 + array(
567 + 'labels' => bbp_get_topic_post_type_labels(),
568 + 'rewrite' => bbp_get_topic_post_type_rewrite(),
569 + 'supports' => bbp_get_topic_post_type_supports(),
570 + 'description' => esc_html__( 'bbPress Topics', 'bbpress' ),
571 + 'capabilities' => bbp_get_topic_caps(),
572 + 'capability_type' => array( 'topic', 'topics' ),
573 + 'menu_position' => 555555,
574 + 'has_archive' => ( 'forums' === bbp_show_on_root() ) ? bbp_get_topic_archive_slug() : false,
575 + 'exclude_from_search' => true,
576 + 'show_in_nav_menus' => false,
577 + 'public' => true,
578 + 'show_ui' => current_user_can( 'bbp_topics_admin' ),
579 + 'rest_controller_class' => 'BBP_REST_Posts_Controller',
580 + 'can_export' => true,
581 + 'hierarchical' => false,
582 + 'query_var' => true,
583 + 'menu_icon' => '',
584 + 'source' => 'bbpress',
585 + )
582 586 )
583 - ) );
587 + );
584 588
585 589 /** Replies ***********************************************************/
586 590
587 - // Reply labels
588 - $post_type['labels'] = array(
589 - 'name' => __( 'Replies', 'bbpress' ),
590 - 'menu_name' => __( 'Replies', 'bbpress' ),
591 - 'singular_name' => __( 'Reply', 'bbpress' ),
592 - 'all_items' => __( 'All Replies', 'bbpress' ),
593 - 'add_new' => __( 'New Reply', 'bbpress' ),
594 - 'add_new_item' => __( 'Create New Reply', 'bbpress' ),
595 - 'edit' => __( 'Edit', 'bbpress' ),
596 - 'edit_item' => __( 'Edit Reply', 'bbpress' ),
597 - 'new_item' => __( 'New Reply', 'bbpress' ),
598 - 'view' => __( 'View Reply', 'bbpress' ),
599 - 'view_item' => __( 'View Reply', 'bbpress' ),
600 - 'search_items' => __( 'Search Replies', 'bbpress' ),
601 - 'not_found' => __( 'No replies found', 'bbpress' ),
602 - 'not_found_in_trash' => __( 'No replies found in Trash', 'bbpress' ),
603 - 'parent_item_colon' => __( 'Topic:', 'bbpress' )
604 - );
605 -
606 - // Reply rewrite
607 - $post_type['rewrite'] = array(
608 - 'slug' => bbp_get_reply_slug(),
609 - 'with_front' => false
610 - );
611 -
612 - // Reply supports
613 - $post_type['supports'] = array(
614 - 'title',
615 - 'editor',
616 - 'revisions'
617 - );
618 -
619 591 // Register reply content type
620 592 register_post_type(
621 593 bbp_get_reply_post_type(),
622 - apply_filters( 'bbp_register_reply_post_type', array(
623 - 'labels' => $post_type['labels'],
624 - 'rewrite' => $post_type['rewrite'],
625 - 'supports' => $post_type['supports'],
626 - 'description' => __( 'bbPress Replies', 'bbpress' ),
627 - 'capabilities' => bbp_get_reply_caps(),
628 - 'capability_type' => array( 'reply', 'replies' ),
629 - 'menu_position' => 555555,
630 - 'exclude_from_search' => true,
631 - 'has_archive' => false,
632 - 'show_in_nav_menus' => false,
633 - 'public' => true,
634 - 'show_ui' => bbp_current_user_can_see( bbp_get_reply_post_type() ),
635 - 'can_export' => true,
636 - 'hierarchical' => false,
637 - 'query_var' => true,
638 - 'menu_icon' => ''
639 - ) )
594 + apply_filters(
595 + 'bbp_register_reply_post_type',
596 + array(
597 + 'labels' => bbp_get_reply_post_type_labels(),
598 + 'rewrite' => bbp_get_reply_post_type_rewrite(),
599 + 'supports' => bbp_get_reply_post_type_supports(),
600 + 'description' => esc_html__( 'bbPress Replies', 'bbpress' ),
601 + 'capabilities' => bbp_get_reply_caps(),
602 + 'capability_type' => array( 'reply', 'replies' ),
603 + 'menu_position' => 555555,
604 + 'exclude_from_search' => true,
605 + 'has_archive' => false,
606 + 'show_in_nav_menus' => false,
607 + 'public' => true,
608 + 'show_ui' => current_user_can( 'bbp_replies_admin' ),
609 + 'rest_controller_class' => 'BBP_REST_Posts_Controller',
610 + 'can_export' => true,
611 + 'hierarchical' => false,
612 + 'query_var' => true,
613 + 'menu_icon' => '',
614 + 'source' => 'bbpress',
615 + )
616 + )
640 617 );
641 618 }
642 619
643 620 /**
@@ -645,13 +622,9 @@
645 622 *
646 623 * We do some manipulation of the 'trash' status so trashed topics and
647 624 * replies can be viewed from within the theme.
648 625 *
649 - * @since bbPress (r2727)
650 - * @uses register_post_status() To register post statuses
651 - * @uses $wp_post_statuses To modify trash and private statuses
652 - * @uses current_user_can() To check if the current user is capable &
653 - * modify $wp_post_statuses accordingly
626 + * @since 2.0.0 bbPress (r2727)
654 627 */
655 628 public static function register_post_statuses() {
656 629
657 630 // Closed
@@ -656,57 +629,78 @@
656 629
657 630 // Closed
658 631 register_post_status(
659 632 bbp_get_closed_status_id(),
660 - apply_filters( 'bbp_register_closed_post_status', array(
661 - 'label' => _x( 'Closed', 'post', 'bbpress' ),
662 - 'label_count' => _nx_noop( 'Closed <span class="count">(%s)</span>', 'Closed <span class="count">(%s)</span>', 'bbpress' ),
663 - 'public' => true,
664 - 'show_in_admin_all' => true
665 - ) )
633 + apply_filters(
634 + 'bbp_register_closed_post_status',
635 + array(
636 + 'label' => _x( 'Closed', 'post', 'bbpress' ),
637 + /* translators: %s: Number of closed items */
638 + 'label_count' => _nx_noop( 'Closed <span class="count">(%s)</span>', 'Closed <span class="count">(%s)</span>', 'post', 'bbpress' ),
639 + 'public' => true,
640 + 'show_in_admin_status_list' => true,
641 + 'show_in_admin_all_list' => true,
642 + 'source' => 'bbpress'
643 + )
644 + )
666 645 );
667 646
668 647 // Spam
669 648 register_post_status(
670 649 bbp_get_spam_status_id(),
671 - apply_filters( 'bbp_register_spam_post_status', array(
672 - 'label' => _x( 'Spam', 'post', 'bbpress' ),
673 - 'label_count' => _nx_noop( 'Spam <span class="count">(%s)</span>', 'Spam <span class="count">(%s)</span>', 'bbpress' ),
674 - 'protected' => true,
675 - 'exclude_from_search' => true,
676 - 'show_in_admin_status_list' => true,
677 - 'show_in_admin_all_list' => false
678 - ) )
679 - );
650 + apply_filters(
651 + 'bbp_register_spam_post_status',
652 + array(
653 + 'label' => _x( 'Spam', 'post', 'bbpress' ),
654 + /* translators: %s: Number of spammed items */
655 + 'label_count' => _nx_noop( 'Spam <span class="count">(%s)</span>', 'Spam <span class="count">(%s)</span>', 'post', 'bbpress' ),
656 + 'protected' => true,
657 + 'exclude_from_search' => true,
658 + 'show_in_admin_status_list' => true,
659 + 'show_in_admin_all_list' => false,
660 + 'source' => 'bbpress'
661 + )
662 + )
663 + );
680 664
681 665 // Orphan
682 666 register_post_status(
683 667 bbp_get_orphan_status_id(),
684 - apply_filters( 'bbp_register_orphan_post_status', array(
685 - 'label' => _x( 'Orphan', 'post', 'bbpress' ),
686 - 'label_count' => _nx_noop( 'Orphan <span class="count">(%s)</span>', 'Orphans <span class="count">(%s)</span>', 'bbpress' ),
687 - 'protected' => true,
688 - 'exclude_from_search' => true,
689 - 'show_in_admin_status_list' => true,
690 - 'show_in_admin_all_list' => false
691 - ) )
668 + apply_filters(
669 + 'bbp_register_orphan_post_status',
670 + array(
671 + 'label' => _x( 'Orphan', 'post', 'bbpress' ),
672 + /* translators: %s: Number of orphaned items */
673 + 'label_count' => _nx_noop( 'Orphan <span class="count">(%s)</span>', 'Orphans <span class="count">(%s)</span>', 'post', 'bbpress' ),
674 + 'protected' => true,
675 + 'exclude_from_search' => true,
676 + 'show_in_admin_status_list' => true,
677 + 'show_in_admin_all_list' => false,
678 + 'source' => 'bbpress'
679 + )
680 + )
692 681 );
693 682
694 683 // Hidden
695 684 register_post_status(
696 685 bbp_get_hidden_status_id(),
697 - apply_filters( 'bbp_register_hidden_post_status', array(
698 - 'label' => _x( 'Hidden', 'post', 'bbpress' ),
699 - 'label_count' => _nx_noop( 'Hidden <span class="count">(%s)</span>', 'Hidden <span class="count">(%s)</span>', 'bbpress' ),
700 - 'private' => true,
701 - 'exclude_from_search' => true,
702 - 'show_in_admin_status_list' => true,
703 - 'show_in_admin_all_list' => true
704 - ) )
686 + apply_filters(
687 + 'bbp_register_hidden_post_status',
688 + array(
689 + 'label' => _x( 'Hidden', 'post', 'bbpress' ),
690 + /* translators: %s: Number of hidden items */
691 + 'label_count' => _nx_noop( 'Hidden <span class="count">(%s)</span>', 'Hidden <span class="count">(%s)</span>', 'post', 'bbpress' ),
692 + 'private' => true,
693 + 'exclude_from_search' => true,
694 + 'show_in_admin_status_list' => true,
695 + 'show_in_admin_all_list' => true,
696 + 'source' => 'bbpress'
697 + )
698 + )
705 699 );
706 700
707 701 /**
708 - * Trash fix
702 + * Trash fix.
709 703 *
710 704 * We need to remove the internal arg and change that to
711 705 * protected so that the users with 'view_trash' cap can view
712 706 * single trashed topics/replies in the front-end as wp_query
@@ -713,9 +707,9 @@
713 707 * doesn't allow any hack for the trashed topics to be viewed.
714 708 */
715 709 global $wp_post_statuses;
716 710
717 - if ( !empty( $wp_post_statuses['trash'] ) ) {
711 + if ( ! empty( $wp_post_statuses['trash'] ) ) {
718 712
719 713 // User can view trash so set internal to false
720 714 if ( current_user_can( 'view_trash' ) ) {
721 715 $wp_post_statuses['trash']->internal = false;
@@ -721,9 +715,9 @@
721 715 $wp_post_statuses['trash']->internal = false;
722 716 $wp_post_statuses['trash']->protected = true;
723 717
724 718 // User cannot view trash so set internal to true
725 - } elseif ( !current_user_can( 'view_trash' ) ) {
719 + } else {
726 720 $wp_post_statuses['trash']->internal = true;
727 721 }
728 722 }
729 723 }
@@ -728,160 +722,392 @@
728 722 }
729 723 }
730 724
731 725 /**
732 - * Register the topic tag taxonomy
726 + * Register the topic tag and forum moderator taxonomies
733 727 *
734 - * @since bbPress (r2464)
735 - * @uses register_taxonomy() To register the taxonomy
728 + * @since 2.0.0 bbPress (r2464) Added bbp_get_topic_tag_tax_id() taxonomy
736 729 */
737 730 public static function register_taxonomies() {
738 731
739 - // Define local variable(s)
740 - $topic_tag = array();
741 -
742 - // Topic tag labels
743 - $topic_tag['labels'] = array(
744 - 'name' => __( 'Topic Tags', 'bbpress' ),
745 - 'singular_name' => __( 'Topic Tag', 'bbpress' ),
746 - 'search_items' => __( 'Search Tags', 'bbpress' ),
747 - 'popular_items' => __( 'Popular Tags', 'bbpress' ),
748 - 'all_items' => __( 'All Tags', 'bbpress' ),
749 - 'edit_item' => __( 'Edit Tag', 'bbpress' ),
750 - 'update_item' => __( 'Update Tag', 'bbpress' ),
751 - 'add_new_item' => __( 'Add New Tag', 'bbpress' ),
752 - 'new_item_name' => __( 'New Tag Name', 'bbpress' ),
753 - 'view_item' => __( 'View Topic Tag', 'bbpress' )
754 - );
755 -
756 - // Topic tag rewrite
757 - $topic_tag['rewrite'] = array(
758 - 'slug' => bbp_get_topic_tag_tax_slug(),
759 - 'with_front' => false
760 - );
761 -
762 - // Register the topic tag taxonomy
732 + // Register the topic-tag taxonomy.
763 733 register_taxonomy(
764 734 bbp_get_topic_tag_tax_id(),
765 735 bbp_get_topic_post_type(),
766 - apply_filters( 'bbp_register_topic_taxonomy', array(
767 - 'labels' => $topic_tag['labels'],
768 - 'rewrite' => $topic_tag['rewrite'],
769 - 'capabilities' => bbp_get_topic_tag_caps(),
770 - 'update_count_callback' => '_update_post_term_count',
771 - 'query_var' => true,
772 - 'show_tagcloud' => true,
773 - 'hierarchical' => false,
774 - 'public' => true,
775 - 'show_ui' => bbp_current_user_can_see( bbp_get_topic_tag_tax_id() )
736 + apply_filters(
737 + 'bbp_register_topic_taxonomy',
738 + array(
739 + 'labels' => bbp_get_topic_tag_tax_labels(),
740 + 'rewrite' => bbp_get_topic_tag_tax_rewrite(),
741 + 'capabilities' => bbp_get_topic_tag_caps(),
742 + 'update_count_callback' => 'bbp_update_topic_tag_count',
743 + 'query_var' => true,
744 + 'show_tagcloud' => true,
745 + 'hierarchical' => false,
746 + 'show_in_nav_menus' => false,
747 + 'public' => true,
748 + 'show_ui' => bbp_allow_topic_tags() && current_user_can( 'bbp_topic_tags_admin' ),
749 + 'source' => 'bbpress'
750 + )
776 751 )
777 - ) );
752 + );
778 753 }
779 754
780 755 /**
781 756 * Register the bbPress views
782 757 *
783 - * @since bbPress (r2789)
784 - * @uses bbp_register_view() To register the views
758 + * @since 2.0.0 bbPress (r2789)
785 759 */
786 760 public static function register_views() {
787 761
762 + // Popular topics
763 + bbp_register_view(
764 + 'popular',
765 + esc_html__( 'Most popular topics', 'bbpress' ),
766 + apply_filters(
767 + 'bbp_register_view_popular',
768 + array(
769 + 'meta_key' => '_bbp_reply_count',
770 + 'meta_type' => 'NUMERIC',
771 + 'max_num_pages' => 1,
772 + 'orderby' => 'meta_value_num',
773 + 'show_stickies' => false
774 + )
775 + )
776 + );
777 +
788 778 // Topics with no replies
789 779 bbp_register_view(
790 780 'no-replies',
791 - __( 'Topics with no replies', 'bbpress' ),
792 - apply_filters( 'bbp_register_view_no_replies', array(
793 - 'meta_key' => '_bbp_reply_count',
794 - 'meta_value' => 1,
795 - 'meta_compare' => '<',
796 - 'orderby' => ''
781 + esc_html__( 'Topics with no replies', 'bbpress' ),
782 + apply_filters(
783 + 'bbp_register_view_no_replies',
784 + array(
785 + 'meta_key' => '_bbp_reply_count',
786 + 'meta_type' => 'NUMERIC',
787 + 'meta_value' => 1,
788 + 'meta_compare' => '<',
789 + 'orderby' => '',
790 + 'show_stickies' => false
791 + )
797 792 )
798 - ) );
793 + );
799 794 }
800 795
801 796 /**
797 + * Register the bbPress shortcodes
798 + *
799 + * @since 2.0.0 bbPress (r3031)
800 + */
801 + public function register_shortcodes() {
802 + $this->shortcodes = new BBP_Shortcodes();
803 + }
804 +
805 + /**
806 + * Register bbPress meta-data
807 + *
808 + * Counts added in 2.6.0 to avoid negative values
809 + *
810 + * @since 2.6.0 bbPress (r6300)
811 + */
812 + public function register_meta() {
813 +
814 + // Define "count" meta-type array
815 + $count = array(
816 +
817 + // Counts are always integers
818 + 'type' => 'integer',
819 +
820 + // Generic count description
821 + 'description' => esc_html__( 'bbPress Item Count', 'bbpress' ),
822 +
823 + // Counts are single values
824 + 'single' => true,
825 +
826 + // Counts should be made available in REST
827 + 'show_in_rest' => true,
828 +
829 + // Never allow counts to go negative
830 + 'sanitize_callback' => 'bbp_number_not_negative',
831 +
832 + // All users may update count meta data
833 + 'auth_callback' => '__return_true'
834 + );
835 +
836 + /** Post **************************************************************/
837 +
838 + // Counts
839 + register_meta( 'post', '_bbp_topic_count', $count );
840 + register_meta( 'post', '_bbp_reply_count', $count );
841 + register_meta( 'post', '_bbp_total_topic_count', $count );
842 + register_meta( 'post', '_bbp_total_reply_count', $count );
843 + register_meta( 'post', '_bbp_voice_count', $count );
844 + register_meta( 'post', '_bbp_anonymous_reply_count', $count );
845 + register_meta( 'post', '_bbp_topic_count_hidden', $count );
846 + register_meta( 'post', '_bbp_reply_count_hidden', $count );
847 + register_meta( 'post', '_bbp_total_topic_count_hidden', $count );
848 + register_meta( 'post', '_bbp_total_reply_count_hidden', $count );
849 + register_meta( 'post', '_bbp_forum_subforum_count', $count );
850 +
851 + /** User **************************************************************/
852 +
853 + // Counts
854 + register_meta( 'user', '_bbp_topic_count', $count );
855 + register_meta( 'user', '_bbp_reply_count', $count );
856 +
857 + // Activity
858 + register_meta(
859 + 'user',
860 + '_bbp_last_posted',
861 + array(
862 + 'type' => 'integer',
863 + 'description' => esc_html__( 'bbPress User Activity', 'bbpress' ),
864 + 'single' => true,
865 + 'show_in_rest' => true,
866 + 'sanitize_callback' => 'bbp_number_not_negative',
867 + 'auth_callback' => '__return_true'
868 + )
869 + );
870 + }
871 +
872 + /**
802 873 * Setup the currently logged-in user
803 874 *
804 - * Do not to call this prematurely, I.E. before the 'init' action has
805 - * started. This function is naturally hooked into 'init' to ensure proper
806 - * execution. get_currentuserinfo() is used to check for XMLRPC_REQUEST to
807 - * avoid xmlrpc errors.
875 + * @since 2.0.0 bbPress (r2697)
876 + */
877 + public function setup_current_user() {
878 + $this->current_user = wp_get_current_user();
879 + }
880 +
881 + /**
882 + * Setup the user engagements strategy
808 883 *
809 - * @since bbPress (r2697)
810 - * @uses wp_get_current_user()
884 + * @since 2.6.0 bbPress (r6875)
811 885 */
812 - public function setup_current_user() {
813 - $this->current_user = &wp_get_current_user();
886 + public function setup_engagements() {
887 +
888 + // Setup the class name
889 + $strategy = ucwords( bbp_engagements_strategy() );
890 + $class_name = "BBP_User_Engagements_{$strategy}";
891 +
892 + // Setup the engagements interface
893 + $this->engagements = new $class_name();
814 894 }
815 895
896 + /**
897 + * Initialize forum-specific roles
898 + *
899 + * @since 2.6.0
900 + */
901 + public function roles_init() {
902 +
903 + // Get role IDs
904 + $keymaster = bbp_get_keymaster_role();
905 + $moderator = bbp_get_moderator_role();
906 + $participant = bbp_get_participant_role();
907 + $spectator = bbp_get_spectator_role();
908 + $blocked = bbp_get_blocked_role();
909 +
910 + // Build the roles into one useful array
911 + // phpcs:disable WordPress.Arrays.ArrayKeySpacingRestrictions.TooMuchSpaceAfterKey
912 + $this->roles[ $keymaster ] = new WP_Role( 'Keymaster', bbp_get_caps_for_role( $keymaster ) );
913 + $this->roles[ $moderator ] = new WP_Role( 'Moderator', bbp_get_caps_for_role( $moderator ) );
914 + $this->roles[ $participant ] = new WP_Role( 'Participant', bbp_get_caps_for_role( $participant ) );
915 + $this->roles[ $spectator ] = new WP_Role( 'Spectator', bbp_get_caps_for_role( $spectator ) );
916 + $this->roles[ $blocked ] = new WP_Role( 'Blocked', bbp_get_caps_for_role( $blocked ) );
917 + // phpcs:enable
918 + }
919 +
816 920 /** Custom Rewrite Rules **************************************************/
817 921
818 922 /**
819 923 * Add the bbPress-specific rewrite tags
820 924 *
821 - * @since bbPress (r2753)
822 - * @uses add_rewrite_tag() To add the rewrite tags
925 + * @since 2.0.0 bbPress (r2753)
823 926 */
824 927 public static function add_rewrite_tags() {
825 - add_rewrite_tag( '%%' . bbp_get_user_rewrite_id() . '%%', '([^/]+)' ); // User Profile tag
826 - add_rewrite_tag( '%%' . bbp_get_view_rewrite_id() . '%%', '([^/]+)' ); // View Page tag
827 - add_rewrite_tag( '%%' . bbp_get_edit_rewrite_id() . '%%', '([1]{1,})' ); // Edit Page tag
928 + add_rewrite_tag( '%' . bbp_get_view_rewrite_id() . '%', '([^/]+)' ); // View Page tag
929 + add_rewrite_tag( '%' . bbp_get_edit_rewrite_id() . '%', '([1]{1,})' ); // Edit Page tag
930 + add_rewrite_tag( '%' . bbp_get_search_rewrite_id() . '%', '([^/]+)' ); // Search Results tag
931 + add_rewrite_tag( '%' . bbp_get_user_rewrite_id() . '%', '([^/]+)' ); // User Profile tag
932 + add_rewrite_tag( '%' . bbp_get_user_favorites_rewrite_id() . '%', '([1]{1,})' ); // User Favorites tag
933 + add_rewrite_tag( '%' . bbp_get_user_subscriptions_rewrite_id() . '%', '([1]{1,})' ); // User Subscriptions tag
934 + add_rewrite_tag( '%' . bbp_get_user_engagements_rewrite_id() . '%', '([1]{1,})' ); // User Engagements tag
935 + add_rewrite_tag( '%' . bbp_get_user_topics_rewrite_id() . '%', '([1]{1,})' ); // User Topics Tag
936 + add_rewrite_tag( '%' . bbp_get_user_replies_rewrite_id() . '%', '([1]{1,})' ); // User Replies Tag
828 937 }
829 938
830 939 /**
831 - * Register bbPress-specific rewrite rules for uri's that are not
940 + * Add bbPress-specific rewrite rules for uri's that are not
832 941 * setup for us by way of custom post types or taxonomies. This includes:
833 942 * - Front-end editing
834 943 * - Topic views
835 944 * - User profiles
836 945 *
837 - * @since bbPress (r2688)
838 - * @param WP_Rewrite $wp_rewrite bbPress-sepecific rules are appended in
839 - * $wp_rewrite->rules
946 + * @since 2.0.0 bbPress (r2688)
947 + *
948 + * @todo Extract into an API
840 949 */
841 - public static function generate_rewrite_rules( $wp_rewrite ) {
950 + public static function add_rewrite_rules() {
842 951
843 - // Slugs
844 - $user_slug = bbp_get_user_slug();
845 - $view_slug = bbp_get_view_slug();
952 + /** Setup *************************************************************/
846 953
954 + // Add rules to top or bottom?
955 + $priority = 'top';
956 +
957 + // Single Slugs
958 + $forum_slug = bbp_get_forum_slug();
959 + $topic_slug = bbp_get_topic_slug();
960 + $reply_slug = bbp_get_reply_slug();
961 + $ttag_slug = bbp_get_topic_tag_tax_slug();
962 +
963 + // Archive Slugs
964 + $user_slug = bbp_get_user_slug();
965 + $view_slug = bbp_get_view_slug();
966 + $search_slug = bbp_get_search_slug();
967 + $topic_archive_slug = bbp_get_topic_archive_slug();
968 + $reply_archive_slug = bbp_get_reply_archive_slug();
969 +
970 + // Tertiary Slugs
971 + $feed_slug = 'feed';
972 + $edit_slug = bbp_get_edit_slug();
973 + $paged_slug = bbp_get_paged_slug();
974 + $user_favs_slug = bbp_get_user_favorites_slug();
975 + $user_subs_slug = bbp_get_user_subscriptions_slug();
976 + $user_engs_slug = bbp_get_user_engagements_slug();
977 +
847 978 // Unique rewrite ID's
848 - $user_id = bbp_get_user_rewrite_id();
849 - $view_id = bbp_get_view_rewrite_id();
850 - $edit_id = bbp_get_edit_rewrite_id();
979 + $feed_id = 'feed';
980 + $edit_id = bbp_get_edit_rewrite_id();
981 + $view_id = bbp_get_view_rewrite_id();
982 + $paged_id = bbp_get_paged_rewrite_id();
983 + $search_id = bbp_get_search_rewrite_id();
984 + $user_id = bbp_get_user_rewrite_id();
985 + $user_favs_id = bbp_get_user_favorites_rewrite_id();
986 + $user_subs_id = bbp_get_user_subscriptions_rewrite_id();
987 + $user_tops_id = bbp_get_user_topics_rewrite_id();
988 + $user_reps_id = bbp_get_user_replies_rewrite_id();
989 + $user_engs_id = bbp_get_user_engagements_rewrite_id();
851 990
852 991 // Rewrite rule matches used repeatedly below
853 - $root_rule = '/([^/]+)/?$';
854 - $edit_rule = '/([^/]+)/edit/?$';
855 - $feed_rule = '/([^/]+)/feed/?$';
856 - $page_rule = '/([^/]+)/page/?([0-9]{1,})/?$';
992 + $root_rule = '/([^/]+)/?$';
993 + $feed_rule = '/([^/]+)/' . $feed_slug . '/?$';
994 + $edit_rule = '/([^/]+)/' . $edit_slug . '/?$';
995 + $paged_rule = '/([^/]+)/' . $paged_slug . '/?([0-9]{1,})/?$';
857 996
858 - // New bbPress specific rules to merge with existing that are not
859 - // handled automatically by custom post types or taxonomy types
860 - $bbp_rules = array(
997 + // Search rules (without slug check)
998 + $search_root_rule = '/?$';
999 + $search_paged_rule = '/' . $paged_slug . '/?([0-9]{1,})/?$';
861 1000
862 - // Edit Forum|Topic|Reply|Topic-tag
863 - bbp_get_forum_slug() . $edit_rule => 'index.php?' . bbp_get_forum_post_type() . '=' . $wp_rewrite->preg_index( 1 ) . '&' . $edit_id . '=1',
864 - bbp_get_topic_slug() . $edit_rule => 'index.php?' . bbp_get_topic_post_type() . '=' . $wp_rewrite->preg_index( 1 ) . '&' . $edit_id . '=1',
865 - bbp_get_reply_slug() . $edit_rule => 'index.php?' . bbp_get_reply_post_type() . '=' . $wp_rewrite->preg_index( 1 ) . '&' . $edit_id . '=1',
866 - bbp_get_topic_tag_tax_slug() . $edit_rule => 'index.php?' . bbp_get_topic_tag_tax_id() . '=' . $wp_rewrite->preg_index( 1 ) . '&' . $edit_id . '=1',
1001 + /** Add ***************************************************************/
867 1002
868 - // User Pagination|Edit|View
869 - $user_slug . $page_rule => 'index.php?' . $user_id . '=' . $wp_rewrite->preg_index( 1 ) . '&paged=' . $wp_rewrite->preg_index( 2 ),
870 - $user_slug . $edit_rule => 'index.php?' . $user_id . '=' . $wp_rewrite->preg_index( 1 ) . '&' . $edit_id . '=1',
871 - $user_slug . $root_rule => 'index.php?' . $user_id . '=' . $wp_rewrite->preg_index( 1 ),
1003 + // User profile rules
1004 + $tops_rule = '/([^/]+)/' . $topic_archive_slug . '/?$';
1005 + $reps_rule = '/([^/]+)/' . $reply_archive_slug . '/?$';
1006 + $favs_rule = '/([^/]+)/' . $user_favs_slug . '/?$';
1007 + $subs_rule = '/([^/]+)/' . $user_subs_slug . '/?$';
1008 + $engs_rule = '/([^/]+)/' . $user_engs_slug . '/?$';
1009 + $tops_paged_rule = '/([^/]+)/' . $topic_archive_slug . '/' . $paged_slug . '/?([0-9]{1,})/?$';
1010 + $reps_paged_rule = '/([^/]+)/' . $reply_archive_slug . '/' . $paged_slug . '/?([0-9]{1,})/?$';
1011 + $favs_paged_rule = '/([^/]+)/' . $user_favs_slug . '/' . $paged_slug . '/?([0-9]{1,})/?$';
1012 + $subs_paged_rule = '/([^/]+)/' . $user_subs_slug . '/' . $paged_slug . '/?([0-9]{1,})/?$';
1013 + $engs_paged_rule = '/([^/]+)/' . $user_engs_slug . '/' . $paged_slug . '/?([0-9]{1,})/?$';
872 1014
873 - // Topic-View Pagination|Feed|View
874 - $view_slug . $page_rule => 'index.php?' . $view_id . '=' . $wp_rewrite->preg_index( 1 ) . '&paged=' . $wp_rewrite->preg_index( 2 ),
875 - $view_slug . $feed_rule => 'index.php?' . $view_id . '=' . $wp_rewrite->preg_index( 1 ) . '&feed=' . $wp_rewrite->preg_index( 2 ),
876 - $view_slug . $root_rule => 'index.php?' . $view_id . '=' . $wp_rewrite->preg_index( 1 ),
1015 + // Edit Forum|Topic|Reply|Topic-tag
1016 + add_rewrite_rule( $forum_slug . $edit_rule, 'index.php?' . bbp_get_forum_post_type() . '=$matches[1]&' . $edit_id . '=1', $priority );
1017 + add_rewrite_rule( $topic_slug . $edit_rule, 'index.php?' . bbp_get_topic_post_type() . '=$matches[1]&' . $edit_id . '=1', $priority );
1018 + add_rewrite_rule( $reply_slug . $edit_rule, 'index.php?' . bbp_get_reply_post_type() . '=$matches[1]&' . $edit_id . '=1', $priority );
1019 + add_rewrite_rule( $ttag_slug . $edit_rule, 'index.php?' . bbp_get_topic_tag_tax_id() . '=$matches[1]&' . $edit_id . '=1', $priority );
1020 +
1021 + // User Pagination|Edit|View
1022 + add_rewrite_rule( $user_slug . $tops_paged_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_tops_id . '=1&' . $paged_id . '=$matches[2]', $priority );
1023 + add_rewrite_rule( $user_slug . $reps_paged_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_reps_id . '=1&' . $paged_id . '=$matches[2]', $priority );
1024 + add_rewrite_rule( $user_slug . $favs_paged_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_favs_id . '=1&' . $paged_id . '=$matches[2]', $priority );
1025 + add_rewrite_rule( $user_slug . $subs_paged_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_subs_id . '=1&' . $paged_id . '=$matches[2]', $priority );
1026 + add_rewrite_rule( $user_slug . $engs_paged_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_engs_id . '=1&' . $paged_id . '=$matches[2]', $priority );
1027 + add_rewrite_rule( $user_slug . $tops_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_tops_id . '=1', $priority );
1028 + add_rewrite_rule( $user_slug . $reps_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_reps_id . '=1', $priority );
1029 + add_rewrite_rule( $user_slug . $favs_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_favs_id . '=1', $priority );
1030 + add_rewrite_rule( $user_slug . $subs_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_subs_id . '=1', $priority );
1031 + add_rewrite_rule( $user_slug . $engs_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_engs_id . '=1', $priority );
1032 + add_rewrite_rule( $user_slug . $edit_rule, 'index.php?' . $user_id . '=$matches[1]&' . $edit_id . '=1', $priority );
1033 + add_rewrite_rule( $user_slug . $root_rule, 'index.php?' . $user_id . '=$matches[1]', $priority );
1034 +
1035 + // Topic-View Pagination|Feed|View
1036 + add_rewrite_rule( $view_slug . $paged_rule, 'index.php?' . $view_id . '=$matches[1]&' . $paged_id . '=$matches[2]', $priority );
1037 + add_rewrite_rule( $view_slug . $feed_rule, 'index.php?' . $view_id . '=$matches[1]&' . $feed_id . '=$matches[2]', $priority );
1038 + add_rewrite_rule( $view_slug . $root_rule, 'index.php?' . $view_id . '=$matches[1]', $priority );
1039 +
1040 + // Search All
1041 + add_rewrite_rule( $search_slug . $search_paged_rule, 'index.php?' . $paged_id .'=$matches[1]', $priority );
1042 + add_rewrite_rule( $search_slug . $search_root_rule, 'index.php?' . $search_id, $priority );
1043 + }
1044 +
1045 + /**
1046 + * Add permalink structures for new archive-style destinations.
1047 + *
1048 + * - Users
1049 + * - Topic Views
1050 + * - Search
1051 + *
1052 + * @since 2.4.0 bbPress (r4930)
1053 + */
1054 + public static function add_permastructs() {
1055 +
1056 + // Get unique ID's
1057 + $user_id = bbp_get_user_rewrite_id();
1058 + $view_id = bbp_get_view_rewrite_id();
1059 + $search_id = bbp_get_search_rewrite_id();
1060 +
1061 + // Get root slugs
1062 + $user_slug = bbp_get_user_slug();
1063 + $view_slug = bbp_get_view_slug();
1064 + $search_slug = bbp_get_search_slug();
1065 +
1066 + // User Permastruct
1067 + add_permastruct(
1068 + $user_id,
1069 + $user_slug . '/%' . $user_id . '%',
1070 + array(
1071 + 'with_front' => false,
1072 + 'ep_mask' => EP_NONE,
1073 + 'paged' => false,
1074 + 'feed' => false,
1075 + 'forcomments' => false,
1076 + 'walk_dirs' => true,
1077 + 'endpoints' => false,
1078 + )
877 1079 );
878 1080
879 - // Merge bbPress rules with existing
880 - $wp_rewrite->rules = array_merge( $bbp_rules, $wp_rewrite->rules );
1081 + // Topic View Permastruct
1082 + add_permastruct(
1083 + $view_id,
1084 + $view_slug . '/%' . $view_id . '%',
1085 + array(
1086 + 'with_front' => false,
1087 + 'ep_mask' => EP_NONE,
1088 + 'paged' => false,
1089 + 'feed' => false,
1090 + 'forcomments' => false,
1091 + 'walk_dirs' => true,
1092 + 'endpoints' => false,
1093 + )
1094 + );
881 1095
882 - // Return merged rules
883 - return $wp_rewrite;
1096 + // Search Permastruct
1097 + add_permastruct(
1098 + $search_id,
1099 + $search_slug . '/%' . $search_id . '%',
1100 + array(
1101 + 'with_front' => false,
1102 + 'ep_mask' => EP_NONE,
1103 + 'paged' => true,
1104 + 'feed' => false,
1105 + 'forcomments' => false,
1106 + 'walk_dirs' => true,
1107 + 'endpoints' => false,
1108 + )
1109 + );
884 1110 }
885 1111 }
886 1112
887 1113 /**
@@ -892,12 +1118,14 @@
892 1118 * to declare the global.
893 1119 *
894 1120 * Example: <?php $bbp = bbpress(); ?>
895 1121 *
896 - * @return The one true bbPress Instance
1122 + * @since 2.0.0 bbPress (r2464)
1123 + *
1124 + * @return bbPress The one true bbPress Instance
897 1125 */
898 1126 function bbpress() {
899 - return bbpress::instance();
1127 + return bbPress::instance();
900 1128 }
901 1129
902 1130 /**
903 1131 * Hook bbPress early onto the 'plugins_loaded' action.