| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | - * The bbPress Plugin. | |
| 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 7418 2026-09-03 17:45:47Z johnjamesjacoby $ | |
| 8 | + * $Id: bbpress.php 7161 2020-11-06 01:05:46Z johnjamesjacoby $ | |
| 9 | 9 | * |
| 10 | 10 | * @package bbPress |
| 11 | 11 | * @subpackage Main |
| 12 | 12 | */ |
| @@ -16,16 +16,14 @@ | ||
| 16 | 16 | * Plugin URI: https://bbpress.org |
| 17 | 17 | * Description: bbPress is forum software with a twist from the creators of WordPress. |
| 18 | 18 | * Author: The bbPress Contributors |
| 19 | 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 | |
| 20 | + * Version: 2.6.6 | |
| 22 | 21 | * Text Domain: bbpress |
| 23 | 22 | * Domain Path: /languages/ |
| 24 | - * Requires PHP: 7.2 | |
| 25 | - * Requires at least: 6.0 | |
| 26 | - * Tested up to: 7.1 | |
| 27 | - * Version: 2.7.0-alpha-2 | |
| 23 | + * License: GPLv2 or later (license.txt) | |
| 24 | + * Requires PHP: 5.6.20 | |
| 25 | + * Requires at least: 5.0 | |
| 28 | 26 | */ |
| 29 | 27 | |
| 30 | 28 | // Exit if accessed directly |
| 31 | 29 | defined( 'ABSPATH' ) || exit; |
| @@ -31,9 +29,9 @@ | ||
| 31 | 29 | defined( 'ABSPATH' ) || exit; |
| 32 | 30 | |
| 33 | 31 | if ( ! class_exists( 'bbPress' ) ) : |
| 34 | 32 | /** |
| 35 | - * Main bbPress Class. | |
| 33 | + * Main bbPress Class | |
| 36 | 34 | * |
| 37 | 35 | * "Word hard. Stay bumble." |
| 38 | 36 | * |
| 39 | 37 | * @since 2.0.0 bbPress (r2464) |
| @@ -43,22 +41,23 @@ | ||
| 43 | 41 | /** Magic *****************************************************************/ |
| 44 | 42 | |
| 45 | 43 | /** |
| 46 | 44 | * bbPress uses many variables, several of which can be filtered to |
| 47 | - * customize the way it operates. Most of those variables are stored in this | |
| 48 | - * private array via PHP magic methods. | |
| 45 | + * customize the way it operates. Most of these variables are stored in a | |
| 46 | + * private array that gets updated with the help of PHP magic methods. | |
| 49 | 47 | * |
| 50 | 48 | * This is a precautionary measure, to avoid potential errors produced by |
| 51 | - * unanticipated direct manipulation of critical run-time data. | |
| 49 | + * unanticipated direct manipulation of run-time data. | |
| 52 | 50 | * |
| 53 | - * @var array All run-time data | |
| 51 | + * @see bbPress::setup_globals() | |
| 52 | + * @var array | |
| 54 | 53 | */ |
| 55 | - private $data = array(); | |
| 54 | + private $data; | |
| 56 | 55 | |
| 57 | 56 | /** Not Magic *************************************************************/ |
| 58 | 57 | |
| 59 | 58 | /** |
| 60 | - * @var mixed False when not logged in; WP_User object when logged in. | |
| 59 | + * @var mixed False when not logged in; WP_User object when logged in | |
| 61 | 60 | */ |
| 62 | 61 | public $current_user = false; |
| 63 | 62 | |
| 64 | 63 | /** |
| @@ -66,29 +65,29 @@ | ||
| 66 | 65 | */ |
| 67 | 66 | public $extend; |
| 68 | 67 | |
| 69 | 68 | /** |
| 70 | - * @var array Topic views. | |
| 69 | + * @var array Topic views | |
| 71 | 70 | */ |
| 72 | 71 | public $views = array(); |
| 73 | 72 | |
| 74 | 73 | /** |
| 75 | - * @var array Overloads get_option(). | |
| 74 | + * @var array Overloads get_option() | |
| 76 | 75 | */ |
| 77 | 76 | public $options = array(); |
| 78 | 77 | |
| 79 | 78 | /** |
| 80 | - * @var array Storage of options not in the database. | |
| 79 | + * @var array Storage of options not in the database | |
| 81 | 80 | */ |
| 82 | 81 | public $not_options = array(); |
| 83 | 82 | |
| 84 | 83 | /** |
| 85 | - * @var array Overloads get_user_meta(). | |
| 84 | + * @var array Overloads get_user_meta() | |
| 86 | 85 | */ |
| 87 | 86 | public $user_options = array(); |
| 88 | 87 | |
| 89 | 88 | /** |
| 90 | - * @var array Dynamically initialized user roles. | |
| 89 | + * @var array Dynamically initialized user roles | |
| 91 | 90 | */ |
| 92 | 91 | public $roles = array(); |
| 93 | 92 | |
| 94 | 93 | /** Singleton *************************************************************/ |
| @@ -93,13 +92,13 @@ | ||
| 93 | 92 | |
| 94 | 93 | /** Singleton *************************************************************/ |
| 95 | 94 | |
| 96 | 95 | /** |
| 97 | - * Main bbPress Instance. | |
| 96 | + * Main bbPress Instance | |
| 98 | 97 | * |
| 99 | - * bbPress is fun. | |
| 100 | - * Please load it only one time. | |
| 101 | - * For this, we thank you. | |
| 98 | + * bbPress is fun | |
| 99 | + * Please load it only one time | |
| 100 | + * For this, we thank you | |
| 102 | 101 | * |
| 103 | 102 | * Insures that only one instance of bbPress exists in memory at any one |
| 104 | 103 | * time. Also prevents needing to define globals all over the place. |
| 105 | 104 | * |
| @@ -106,9 +105,9 @@ | ||
| 106 | 105 | * @since 2.1.0 bbPress (r3757) |
| 107 | 106 | * |
| 108 | 107 | * @staticvar object $instance |
| 109 | 108 | * @see bbpress() |
| 110 | - * @return bbPress The one true bbPress. | |
| 109 | + * @return bbPress The one true bbPress | |
| 111 | 110 | */ |
| 112 | 111 | public static function instance() { |
| 113 | 112 | |
| 114 | 113 | // Store the instance locally to avoid private static replication |
| @@ -136,61 +135,47 @@ | ||
| 136 | 135 | * |
| 137 | 136 | * @see bbPress::instance() |
| 138 | 137 | * @see bbpress(); |
| 139 | 138 | */ |
| 140 | - private function __construct() { | |
| 141 | - /* Do nothing here */ | |
| 142 | - } | |
| 139 | + private function __construct() { /* Do nothing here */ } | |
| 143 | 140 | |
| 144 | 141 | /** |
| 145 | - * A dummy magic method to prevent bbPress from being cloned. | |
| 142 | + * A dummy magic method to prevent bbPress from being cloned | |
| 146 | 143 | * |
| 147 | 144 | * @since 2.0.0 bbPress (r2464) |
| 148 | 145 | */ |
| 149 | - public function __clone() { | |
| 150 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'bbpress' ), '2.1' ); | |
| 151 | - } | |
| 146 | + public function __clone() { _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'bbpress' ), '2.1' ); } | |
| 152 | 147 | |
| 153 | 148 | /** |
| 154 | - * A dummy magic method to prevent bbPress from being unserialized. | |
| 149 | + * A dummy magic method to prevent bbPress from being unserialized | |
| 155 | 150 | * |
| 156 | 151 | * @since 2.0.0 bbPress (r2464) |
| 157 | 152 | */ |
| 158 | - public function __wakeup() { | |
| 159 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'bbpress' ), '2.1' ); | |
| 160 | - } | |
| 153 | + public function __wakeup() { _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'bbpress' ), '2.1' ); } | |
| 161 | 154 | |
| 162 | 155 | /** |
| 163 | - * Magic method for checking the existence of a certain custom field. | |
| 156 | + * Magic method for checking the existence of a certain custom field | |
| 164 | 157 | * |
| 165 | 158 | * @since 2.1.0 bbPress (r3951) |
| 166 | 159 | */ |
| 167 | - public function __isset( $key ) { | |
| 168 | - return isset( $this->data[ $key ] ); | |
| 169 | - } | |
| 160 | + public function __isset( $key ) { return isset( $this->data[ $key ] ); } | |
| 170 | 161 | |
| 171 | 162 | /** |
| 172 | - * Magic method for getting bbPress variables. | |
| 163 | + * Magic method for getting bbPress variables | |
| 173 | 164 | * |
| 174 | 165 | * @since 2.1.0 bbPress (r3951) |
| 175 | 166 | */ |
| 176 | - public function __get( $key ) { | |
| 177 | - return isset( $this->data[ $key ] ) | |
| 178 | - ? $this->data[ $key ] | |
| 179 | - : null; | |
| 180 | - } | |
| 167 | + public function __get( $key ) { return isset( $this->data[ $key ] ) ? $this->data[ $key ] : null; } | |
| 181 | 168 | |
| 182 | 169 | /** |
| 183 | - * Magic method for setting bbPress variables. | |
| 170 | + * Magic method for setting bbPress variables | |
| 184 | 171 | * |
| 185 | 172 | * @since 2.1.0 bbPress (r3951) |
| 186 | 173 | */ |
| 187 | - public function __set( $key, $value ) { | |
| 188 | - $this->data[ $key ] = $value; | |
| 189 | - } | |
| 174 | + public function __set( $key , $value ) { $this->data[ $key ] = $value; } | |
| 190 | 175 | |
| 191 | 176 | /** |
| 192 | - * Magic method for unsetting bbPress variables. | |
| 177 | + * Magic method for unsetting bbPress variables | |
| 193 | 178 | * |
| 194 | 179 | * @since 2.3.0 bbPress (r4628) |
| 195 | 180 | */ |
| 196 | 181 | public function __unset( $key ) { |
| @@ -199,16 +184,13 @@ | ||
| 199 | 184 | } |
| 200 | 185 | } |
| 201 | 186 | |
| 202 | 187 | /** |
| 203 | - * Magic method to prevent notices and errors from invalid method calls. | |
| 188 | + * Magic method to prevent notices and errors from invalid method calls | |
| 204 | 189 | * |
| 205 | 190 | * @since 2.2.0 bbPress (r4252) |
| 206 | 191 | */ |
| 207 | - public function __call( $name = '', $args = array() ) { | |
| 208 | - unset( $name, $args ); | |
| 209 | - return null; | |
| 210 | - } | |
| 192 | + public function __call( $name = '', $args = array() ) { unset( $name, $args ); return null; } | |
| 211 | 193 | |
| 212 | 194 | /** Private Methods *******************************************************/ |
| 213 | 195 | |
| 214 | 196 | /** |
| @@ -222,9 +204,9 @@ | ||
| 222 | 204 | private function setup_environment() { |
| 223 | 205 | |
| 224 | 206 | /** Versions **********************************************************/ |
| 225 | 207 | |
| 226 | - $this->version = '2.7.0-alpha-2'; | |
| 208 | + $this->version = '2.6.6'; | |
| 227 | 209 | $this->db_version = '263'; |
| 228 | 210 | |
| 229 | 211 | /** Paths *************************************************************/ |
| 230 | 212 | |
| @@ -323,9 +305,9 @@ | ||
| 323 | 305 | $this->tab_index = apply_filters( 'bbp_default_tab_index', 100 ); |
| 324 | 306 | } |
| 325 | 307 | |
| 326 | 308 | /** |
| 327 | - * Include required files. | |
| 309 | + * Include required files | |
| 328 | 310 | * |
| 329 | 311 | * @since 2.0.0 bbPress (r2626) |
| 330 | 312 | * |
| 331 | 313 | * @access private |
| @@ -348,9 +330,8 @@ | ||
| 348 | 330 | /** Components ********************************************************/ |
| 349 | 331 | |
| 350 | 332 | // Common |
| 351 | 333 | require $this->includes_dir . 'common/ajax.php'; |
| 352 | - require $this->includes_dir . 'common/blocks.php'; | |
| 353 | 334 | require $this->includes_dir . 'common/classes.php'; |
| 354 | 335 | require $this->includes_dir . 'common/engagements.php'; |
| 355 | 336 | require $this->includes_dir . 'common/functions.php'; |
| 356 | 337 | require $this->includes_dir . 'common/formatting.php'; |
| @@ -401,9 +382,9 @@ | ||
| 401 | 382 | } |
| 402 | 383 | } |
| 403 | 384 | |
| 404 | 385 | /** |
| 405 | - * Setup the default hooks and actions. | |
| 386 | + * Setup the default hooks and actions | |
| 406 | 387 | * |
| 407 | 388 | * @since 2.0.0 bbPress (r2644) |
| 408 | 389 | * |
| 409 | 390 | * @access private |
| @@ -429,9 +410,8 @@ | ||
| 429 | 410 | 'register_post_types', // Register post types (forum|topic|reply) |
| 430 | 411 | 'register_post_statuses', // Register post statuses (closed|spam|orphan|hidden) |
| 431 | 412 | 'register_taxonomies', // Register taxonomies (topic-tag) |
| 432 | 413 | 'register_shortcodes', // Register shortcodes (bbp-login) |
| 433 | - 'register_blocks', // Register blocks (bbp-login) | |
| 434 | 414 | 'register_views', // Register the views (no-replies) |
| 435 | 415 | 'register_theme_packages', // Register bundled theme packages (bbp-theme-compat/bbp-themes) |
| 436 | 416 | 'load_textdomain', // Load textdomain (bbpress) |
| 437 | 417 | 'add_rewrite_tags', // Add rewrite tags (view|user|edit|search) |
| @@ -450,9 +430,9 @@ | ||
| 450 | 430 | |
| 451 | 431 | /** Public Methods ********************************************************/ |
| 452 | 432 | |
| 453 | 433 | /** |
| 454 | - * Register bundled theme packages. | |
| 434 | + * Register bundled theme packages | |
| 455 | 435 | * |
| 456 | 436 | * Note that since we currently have complete control over bbp-themes and |
| 457 | 437 | * the bbp-theme-compat folders, it's fine to hardcode these here. If at a |
| 458 | 438 | * later date we need to automate this, and API will need to be built. |
| @@ -465,17 +445,15 @@ | ||
| 465 | 445 | bbp_register_template_stack( 'get_stylesheet_directory', 6 ); |
| 466 | 446 | bbp_register_template_stack( 'get_template_directory', 8 ); |
| 467 | 447 | |
| 468 | 448 | // Register the default theme compatibility package |
| 469 | - bbp_register_theme_package( | |
| 470 | - array( | |
| 471 | - 'id' => 'default', | |
| 472 | - 'name' => 'bbPress Default', | |
| 473 | - 'version' => bbp_get_version(), | |
| 474 | - 'dir' => trailingslashit( $this->themes_dir . 'default' ), | |
| 475 | - 'url' => trailingslashit( $this->themes_url . 'default' ) | |
| 476 | - ) | |
| 477 | - ); | |
| 449 | + bbp_register_theme_package( array( | |
| 450 | + 'id' => 'default', | |
| 451 | + 'name' => 'bbPress Default', | |
| 452 | + 'version' => bbp_get_version(), | |
| 453 | + 'dir' => trailingslashit( $this->themes_dir . 'default' ), | |
| 454 | + 'url' => trailingslashit( $this->themes_url . 'default' ) | |
| 455 | + ) ); | |
| 478 | 456 | } |
| 479 | 457 | |
| 480 | 458 | /** |
| 481 | 459 | * Setup the default bbPress theme compatibility location. |
| @@ -518,9 +496,9 @@ | ||
| 518 | 496 | load_plugin_textdomain( $this->domain, false, $this->lang_base ); |
| 519 | 497 | } |
| 520 | 498 | |
| 521 | 499 | /** |
| 522 | - * Setup the post types for forums, topics and replies. | |
| 500 | + * Setup the post types for forums, topics and replies | |
| 523 | 501 | * |
| 524 | 502 | * @since 2.0.0 bbPress (r2597) |
| 525 | 503 | */ |
| 526 | 504 | public static function register_post_types() { |
| @@ -529,31 +507,27 @@ | ||
| 529 | 507 | |
| 530 | 508 | // Register Forum content type |
| 531 | 509 | register_post_type( |
| 532 | 510 | bbp_get_forum_post_type(), |
| 533 | - apply_filters( | |
| 534 | - 'bbp_register_forum_post_type', | |
| 535 | - array( | |
| 536 | - 'labels' => bbp_get_forum_post_type_labels(), | |
| 537 | - 'rewrite' => bbp_get_forum_post_type_rewrite(), | |
| 538 | - 'supports' => bbp_get_forum_post_type_supports(), | |
| 539 | - 'description' => esc_html__( 'bbPress Forums', 'bbpress' ), | |
| 540 | - 'capabilities' => bbp_get_forum_caps(), | |
| 541 | - 'capability_type' => array( 'forum', 'forums' ), | |
| 542 | - 'menu_position' => 555555, | |
| 543 | - 'has_archive' => bbp_get_root_slug(), | |
| 544 | - 'exclude_from_search' => true, | |
| 545 | - 'show_in_nav_menus' => true, | |
| 546 | - 'public' => true, | |
| 547 | - 'show_ui' => current_user_can( 'bbp_forums_admin' ), | |
| 548 | - 'show_in_rest' => true, | |
| 549 | - 'can_export' => true, | |
| 550 | - 'hierarchical' => true, | |
| 551 | - 'query_var' => true, | |
| 552 | - 'menu_icon' => '', | |
| 553 | - 'source' => 'bbpress', | |
| 554 | - ) | |
| 555 | - ) | |
| 511 | + apply_filters( 'bbp_register_forum_post_type', array( | |
| 512 | + 'labels' => bbp_get_forum_post_type_labels(), | |
| 513 | + 'rewrite' => bbp_get_forum_post_type_rewrite(), | |
| 514 | + 'supports' => bbp_get_forum_post_type_supports(), | |
| 515 | + 'description' => esc_html__( 'bbPress Forums', 'bbpress' ), | |
| 516 | + 'capabilities' => bbp_get_forum_caps(), | |
| 517 | + 'capability_type' => array( 'forum', 'forums' ), | |
| 518 | + 'menu_position' => 555555, | |
| 519 | + 'has_archive' => bbp_get_root_slug(), | |
| 520 | + 'exclude_from_search' => true, | |
| 521 | + 'show_in_nav_menus' => true, | |
| 522 | + 'public' => true, | |
| 523 | + 'show_ui' => current_user_can( 'bbp_forums_admin' ), | |
| 524 | + 'can_export' => true, | |
| 525 | + 'hierarchical' => true, | |
| 526 | + 'query_var' => true, | |
| 527 | + 'menu_icon' => '', | |
| 528 | + 'source' => 'bbpress', | |
| 529 | + ) ) | |
| 556 | 530 | ); |
| 557 | 531 | |
| 558 | 532 | /** Topics ************************************************************/ |
| 559 | 533 | |
| @@ -559,32 +533,28 @@ | ||
| 559 | 533 | |
| 560 | 534 | // Register Topic content type |
| 561 | 535 | register_post_type( |
| 562 | 536 | bbp_get_topic_post_type(), |
| 563 | - apply_filters( | |
| 564 | - 'bbp_register_topic_post_type', | |
| 565 | - array( | |
| 566 | - 'labels' => bbp_get_topic_post_type_labels(), | |
| 567 | - 'rewrite' => bbp_get_topic_post_type_rewrite(), | |
| 568 | - 'supports' => bbp_get_topic_post_type_supports(), | |
| 569 | - 'description' => esc_html__( 'bbPress Topics', 'bbpress' ), | |
| 570 | - 'capabilities' => bbp_get_topic_caps(), | |
| 571 | - 'capability_type' => array( 'topic', 'topics' ), | |
| 572 | - 'menu_position' => 555555, | |
| 573 | - 'has_archive' => ( 'forums' === bbp_show_on_root() ) ? bbp_get_topic_archive_slug() : false, | |
| 574 | - 'exclude_from_search' => true, | |
| 575 | - 'show_in_nav_menus' => false, | |
| 576 | - 'public' => true, | |
| 577 | - 'show_ui' => current_user_can( 'bbp_topics_admin' ), | |
| 578 | - 'show_in_rest' => true, | |
| 579 | - 'can_export' => true, | |
| 580 | - 'hierarchical' => false, | |
| 581 | - 'query_var' => true, | |
| 582 | - 'menu_icon' => '', | |
| 583 | - 'source' => 'bbpress', | |
| 584 | - ) | |
| 537 | + apply_filters( 'bbp_register_topic_post_type', array( | |
| 538 | + 'labels' => bbp_get_topic_post_type_labels(), | |
| 539 | + 'rewrite' => bbp_get_topic_post_type_rewrite(), | |
| 540 | + 'supports' => bbp_get_topic_post_type_supports(), | |
| 541 | + 'description' => esc_html__( 'bbPress Topics', 'bbpress' ), | |
| 542 | + 'capabilities' => bbp_get_topic_caps(), | |
| 543 | + 'capability_type' => array( 'topic', 'topics' ), | |
| 544 | + 'menu_position' => 555555, | |
| 545 | + 'has_archive' => ( 'forums' === bbp_show_on_root() ) ? bbp_get_topic_archive_slug() : false, | |
| 546 | + 'exclude_from_search' => true, | |
| 547 | + 'show_in_nav_menus' => false, | |
| 548 | + 'public' => true, | |
| 549 | + 'show_ui' => current_user_can( 'bbp_topics_admin' ), | |
| 550 | + 'can_export' => true, | |
| 551 | + 'hierarchical' => false, | |
| 552 | + 'query_var' => true, | |
| 553 | + 'menu_icon' => '', | |
| 554 | + 'source' => 'bbpress', | |
| 585 | 555 | ) |
| 586 | - ); | |
| 556 | + ) ); | |
| 587 | 557 | |
| 588 | 558 | /** Replies ***********************************************************/ |
| 589 | 559 | |
| 590 | 560 | // Register reply content type |
| @@ -589,36 +559,32 @@ | ||
| 589 | 559 | |
| 590 | 560 | // Register reply content type |
| 591 | 561 | register_post_type( |
| 592 | 562 | bbp_get_reply_post_type(), |
| 593 | - apply_filters( | |
| 594 | - 'bbp_register_reply_post_type', | |
| 595 | - array( | |
| 596 | - 'labels' => bbp_get_reply_post_type_labels(), | |
| 597 | - 'rewrite' => bbp_get_reply_post_type_rewrite(), | |
| 598 | - 'supports' => bbp_get_reply_post_type_supports(), | |
| 599 | - 'description' => esc_html__( 'bbPress Replies', 'bbpress' ), | |
| 600 | - 'capabilities' => bbp_get_reply_caps(), | |
| 601 | - 'capability_type' => array( 'reply', 'replies' ), | |
| 602 | - 'menu_position' => 555555, | |
| 603 | - 'exclude_from_search' => true, | |
| 604 | - 'has_archive' => false, | |
| 605 | - 'show_in_nav_menus' => false, | |
| 606 | - 'public' => true, | |
| 607 | - 'show_ui' => current_user_can( 'bbp_replies_admin' ), | |
| 608 | - 'show_in_rest' => true, | |
| 609 | - 'can_export' => true, | |
| 610 | - 'hierarchical' => false, | |
| 611 | - 'query_var' => true, | |
| 612 | - 'menu_icon' => '', | |
| 613 | - 'source' => 'bbpress', | |
| 614 | - ) | |
| 615 | - ) | |
| 563 | + apply_filters( 'bbp_register_reply_post_type', array( | |
| 564 | + 'labels' => bbp_get_reply_post_type_labels(), | |
| 565 | + 'rewrite' => bbp_get_reply_post_type_rewrite(), | |
| 566 | + 'supports' => bbp_get_reply_post_type_supports(), | |
| 567 | + 'description' => esc_html__( 'bbPress Replies', 'bbpress' ), | |
| 568 | + 'capabilities' => bbp_get_reply_caps(), | |
| 569 | + 'capability_type' => array( 'reply', 'replies' ), | |
| 570 | + 'menu_position' => 555555, | |
| 571 | + 'exclude_from_search' => true, | |
| 572 | + 'has_archive' => false, | |
| 573 | + 'show_in_nav_menus' => false, | |
| 574 | + 'public' => true, | |
| 575 | + 'show_ui' => current_user_can( 'bbp_replies_admin' ), | |
| 576 | + 'can_export' => true, | |
| 577 | + 'hierarchical' => false, | |
| 578 | + 'query_var' => true, | |
| 579 | + 'menu_icon' => '', | |
| 580 | + 'source' => 'bbpress', | |
| 581 | + ) ) | |
| 616 | 582 | ); |
| 617 | 583 | } |
| 618 | 584 | |
| 619 | 585 | /** |
| 620 | - * Register the post statuses used by bbPress. | |
| 586 | + * Register the post statuses used by bbPress | |
| 621 | 587 | * |
| 622 | 588 | * We do some manipulation of the 'trash' status so trashed topics and |
| 623 | 589 | * replies can be viewed from within the theme. |
| 624 | 590 | * |
| @@ -628,78 +594,62 @@ | ||
| 628 | 594 | |
| 629 | 595 | // Closed |
| 630 | 596 | register_post_status( |
| 631 | 597 | bbp_get_closed_status_id(), |
| 632 | - apply_filters( | |
| 633 | - 'bbp_register_closed_post_status', | |
| 634 | - array( | |
| 635 | - 'label' => _x( 'Closed', 'post', 'bbpress' ), | |
| 636 | - /* translators: %s: Number of closed items */ | |
| 637 | - 'label_count' => _nx_noop( 'Closed <span class="count">(%s)</span>', 'Closed <span class="count">(%s)</span>', 'post', 'bbpress' ), | |
| 638 | - 'public' => true, | |
| 639 | - 'show_in_admin_status_list' => true, | |
| 640 | - 'show_in_admin_all_list' => true, | |
| 641 | - 'source' => 'bbpress' | |
| 642 | - ) | |
| 643 | - ) | |
| 598 | + apply_filters( 'bbp_register_closed_post_status', array( | |
| 599 | + 'label' => _x( 'Closed', 'post', 'bbpress' ), | |
| 600 | + 'label_count' => _nx_noop( 'Closed <span class="count">(%s)</span>', 'Closed <span class="count">(%s)</span>', 'post', 'bbpress' ), | |
| 601 | + 'public' => true, | |
| 602 | + 'show_in_admin_status_list' => true, | |
| 603 | + 'show_in_admin_all_list' => true, | |
| 604 | + 'source' => 'bbpress' | |
| 605 | + ) ) | |
| 644 | 606 | ); |
| 645 | 607 | |
| 646 | 608 | // Spam |
| 647 | 609 | register_post_status( |
| 648 | 610 | bbp_get_spam_status_id(), |
| 649 | - apply_filters( | |
| 650 | - 'bbp_register_spam_post_status', | |
| 651 | - array( | |
| 652 | - 'label' => _x( 'Spam', 'post', 'bbpress' ), | |
| 653 | - /* translators: %s: Number of spammed items */ | |
| 654 | - 'label_count' => _nx_noop( 'Spam <span class="count">(%s)</span>', 'Spam <span class="count">(%s)</span>', 'post', 'bbpress' ), | |
| 655 | - 'protected' => true, | |
| 656 | - 'exclude_from_search' => true, | |
| 657 | - 'show_in_admin_status_list' => true, | |
| 658 | - 'show_in_admin_all_list' => false, | |
| 659 | - 'source' => 'bbpress' | |
| 660 | - ) | |
| 661 | - ) | |
| 611 | + apply_filters( 'bbp_register_spam_post_status', array( | |
| 612 | + 'label' => _x( 'Spam', 'post', 'bbpress' ), | |
| 613 | + 'label_count' => _nx_noop( 'Spam <span class="count">(%s)</span>', 'Spam <span class="count">(%s)</span>', 'post', 'bbpress' ), | |
| 614 | + 'protected' => true, | |
| 615 | + 'exclude_from_search' => true, | |
| 616 | + 'show_in_admin_status_list' => true, | |
| 617 | + 'show_in_admin_all_list' => false, | |
| 618 | + 'source' => 'bbpress' | |
| 619 | + ) ) | |
| 662 | 620 | ); |
| 663 | 621 | |
| 664 | 622 | // Orphan |
| 665 | 623 | register_post_status( |
| 666 | 624 | bbp_get_orphan_status_id(), |
| 667 | - apply_filters( | |
| 668 | - 'bbp_register_orphan_post_status', | |
| 669 | - array( | |
| 670 | - 'label' => _x( 'Orphan', 'post', 'bbpress' ), | |
| 671 | - /* translators: %s: Number of orphaned items */ | |
| 672 | - 'label_count' => _nx_noop( 'Orphan <span class="count">(%s)</span>', 'Orphans <span class="count">(%s)</span>', 'post', 'bbpress' ), | |
| 673 | - 'protected' => true, | |
| 674 | - 'exclude_from_search' => true, | |
| 675 | - 'show_in_admin_status_list' => true, | |
| 676 | - 'show_in_admin_all_list' => false, | |
| 677 | - 'source' => 'bbpress' | |
| 678 | - ) | |
| 679 | - ) | |
| 625 | + apply_filters( 'bbp_register_orphan_post_status', array( | |
| 626 | + 'label' => _x( 'Orphan', 'post', 'bbpress' ), | |
| 627 | + 'label_count' => _nx_noop( 'Orphan <span class="count">(%s)</span>', 'Orphans <span class="count">(%s)</span>', 'post', 'bbpress' ), | |
| 628 | + 'protected' => true, | |
| 629 | + 'exclude_from_search' => true, | |
| 630 | + 'show_in_admin_status_list' => true, | |
| 631 | + 'show_in_admin_all_list' => false, | |
| 632 | + 'source' => 'bbpress' | |
| 633 | + ) ) | |
| 680 | 634 | ); |
| 681 | 635 | |
| 682 | 636 | // Hidden |
| 683 | 637 | register_post_status( |
| 684 | 638 | bbp_get_hidden_status_id(), |
| 685 | - apply_filters( | |
| 686 | - 'bbp_register_hidden_post_status', | |
| 687 | - array( | |
| 688 | - 'label' => _x( 'Hidden', 'post', 'bbpress' ), | |
| 689 | - /* translators: %s: Number of hidden items */ | |
| 690 | - 'label_count' => _nx_noop( 'Hidden <span class="count">(%s)</span>', 'Hidden <span class="count">(%s)</span>', 'post', 'bbpress' ), | |
| 691 | - 'private' => true, | |
| 692 | - 'exclude_from_search' => true, | |
| 693 | - 'show_in_admin_status_list' => true, | |
| 694 | - 'show_in_admin_all_list' => true, | |
| 695 | - 'source' => 'bbpress' | |
| 696 | - ) | |
| 697 | - ) | |
| 639 | + apply_filters( 'bbp_register_hidden_post_status', array( | |
| 640 | + 'label' => _x( 'Hidden', 'post', 'bbpress' ), | |
| 641 | + 'label_count' => _nx_noop( 'Hidden <span class="count">(%s)</span>', 'Hidden <span class="count">(%s)</span>', 'post', 'bbpress' ), | |
| 642 | + 'private' => true, | |
| 643 | + 'exclude_from_search' => true, | |
| 644 | + 'show_in_admin_status_list' => true, | |
| 645 | + 'show_in_admin_all_list' => true, | |
| 646 | + 'source' => 'bbpress' | |
| 647 | + ) ) | |
| 698 | 648 | ); |
| 699 | 649 | |
| 700 | 650 | /** |
| 701 | - * Trash fix. | |
| 651 | + * Trash fix | |
| 702 | 652 | * |
| 703 | 653 | * We need to remove the internal arg and change that to |
| 704 | 654 | * protected so that the users with 'view_trash' cap can view |
| 705 | 655 | * single trashed topics/replies in the front-end as wp_query |
| @@ -721,9 +671,9 @@ | ||
| 721 | 671 | } |
| 722 | 672 | } |
| 723 | 673 | |
| 724 | 674 | /** |
| 725 | - * Register the topic tag and forum moderator taxonomies. | |
| 675 | + * Register the topic tag and forum moderator taxonomies | |
| 726 | 676 | * |
| 727 | 677 | * @since 2.0.0 bbPress (r2464) Added bbp_get_topic_tag_tax_id() taxonomy |
| 728 | 678 | */ |
| 729 | 679 | public static function register_taxonomies() { |
| @@ -731,29 +681,26 @@ | ||
| 731 | 681 | // Register the topic-tag taxonomy. |
| 732 | 682 | register_taxonomy( |
| 733 | 683 | bbp_get_topic_tag_tax_id(), |
| 734 | 684 | bbp_get_topic_post_type(), |
| 735 | - apply_filters( | |
| 736 | - 'bbp_register_topic_taxonomy', | |
| 737 | - array( | |
| 738 | - 'labels' => bbp_get_topic_tag_tax_labels(), | |
| 739 | - 'rewrite' => bbp_get_topic_tag_tax_rewrite(), | |
| 740 | - 'capabilities' => bbp_get_topic_tag_caps(), | |
| 741 | - 'update_count_callback' => 'bbp_update_topic_tag_count', | |
| 742 | - 'query_var' => true, | |
| 743 | - 'show_tagcloud' => true, | |
| 744 | - 'hierarchical' => false, | |
| 745 | - 'show_in_nav_menus' => false, | |
| 746 | - 'public' => true, | |
| 747 | - 'show_ui' => bbp_allow_topic_tags() && current_user_can( 'bbp_topic_tags_admin' ), | |
| 748 | - 'source' => 'bbpress' | |
| 749 | - ) | |
| 685 | + apply_filters( 'bbp_register_topic_taxonomy', array( | |
| 686 | + 'labels' => bbp_get_topic_tag_tax_labels(), | |
| 687 | + 'rewrite' => bbp_get_topic_tag_tax_rewrite(), | |
| 688 | + 'capabilities' => bbp_get_topic_tag_caps(), | |
| 689 | + 'update_count_callback' => 'bbp_update_topic_tag_count', | |
| 690 | + 'query_var' => true, | |
| 691 | + 'show_tagcloud' => true, | |
| 692 | + 'hierarchical' => false, | |
| 693 | + 'show_in_nav_menus' => false, | |
| 694 | + 'public' => true, | |
| 695 | + 'show_ui' => bbp_allow_topic_tags() && current_user_can( 'bbp_topic_tags_admin' ), | |
| 696 | + 'source' => 'bbpress' | |
| 750 | 697 | ) |
| 751 | - ); | |
| 698 | + ) ); | |
| 752 | 699 | } |
| 753 | 700 | |
| 754 | 701 | /** |
| 755 | - * Register the bbPress views. | |
| 702 | + * Register the bbPress views | |
| 756 | 703 | * |
| 757 | 704 | * @since 2.0.0 bbPress (r2789) |
| 758 | 705 | */ |
| 759 | 706 | public static function register_views() { |
| @@ -761,40 +708,34 @@ | ||
| 761 | 708 | // Popular topics |
| 762 | 709 | bbp_register_view( |
| 763 | 710 | 'popular', |
| 764 | 711 | esc_html__( 'Most popular topics', 'bbpress' ), |
| 765 | - apply_filters( | |
| 766 | - 'bbp_register_view_popular', | |
| 767 | - array( | |
| 768 | - 'meta_key' => '_bbp_reply_count', | |
| 769 | - 'meta_type' => 'NUMERIC', | |
| 770 | - 'max_num_pages' => 1, | |
| 771 | - 'orderby' => 'meta_value_num', | |
| 772 | - 'show_stickies' => false | |
| 773 | - ) | |
| 712 | + apply_filters( 'bbp_register_view_popular', array( | |
| 713 | + 'meta_key' => '_bbp_reply_count', | |
| 714 | + 'meta_type' => 'NUMERIC', | |
| 715 | + 'max_num_pages' => 1, | |
| 716 | + 'orderby' => 'meta_value_num', | |
| 717 | + 'show_stickies' => false | |
| 774 | 718 | ) |
| 775 | - ); | |
| 719 | + ) ); | |
| 776 | 720 | |
| 777 | 721 | // Topics with no replies |
| 778 | 722 | bbp_register_view( |
| 779 | 723 | 'no-replies', |
| 780 | 724 | esc_html__( 'Topics with no replies', 'bbpress' ), |
| 781 | - apply_filters( | |
| 782 | - 'bbp_register_view_no_replies', | |
| 783 | - array( | |
| 784 | - 'meta_key' => '_bbp_reply_count', | |
| 785 | - 'meta_type' => 'NUMERIC', | |
| 786 | - 'meta_value' => 1, | |
| 787 | - 'meta_compare' => '<', | |
| 788 | - 'orderby' => '', | |
| 789 | - 'show_stickies' => false | |
| 790 | - ) | |
| 725 | + apply_filters( 'bbp_register_view_no_replies', array( | |
| 726 | + 'meta_key' => '_bbp_reply_count', | |
| 727 | + 'meta_type' => 'NUMERIC', | |
| 728 | + 'meta_value' => 1, | |
| 729 | + 'meta_compare' => '<', | |
| 730 | + 'orderby' => '', | |
| 731 | + 'show_stickies' => false | |
| 791 | 732 | ) |
| 792 | - ); | |
| 733 | + ) ); | |
| 793 | 734 | } |
| 794 | 735 | |
| 795 | 736 | /** |
| 796 | - * Register the bbPress shortcodes. | |
| 737 | + * Register the bbPress shortcodes | |
| 797 | 738 | * |
| 798 | 739 | * @since 2.0.0 bbPress (r3031) |
| 799 | 740 | */ |
| 800 | 741 | public function register_shortcodes() { |
| @@ -801,20 +742,11 @@ | ||
| 801 | 742 | $this->shortcodes = new BBP_Shortcodes(); |
| 802 | 743 | } |
| 803 | 744 | |
| 804 | 745 | /** |
| 805 | - * Register the bbPress blocks. | |
| 806 | - * | |
| 807 | - * @since 2.7.0 bbPress (r7382) | |
| 808 | - */ | |
| 809 | - public function register_blocks() { | |
| 810 | - $this->blocks = new BBP_Blocks(); | |
| 811 | - } | |
| 812 | - | |
| 813 | - /** | |
| 814 | 746 | * Register bbPress meta-data |
| 815 | 747 | * |
| 816 | - * Counts added in 2.6.0 to avoid negative values. | |
| 748 | + * Counts added in 2.6.0 to avoid negative values | |
| 817 | 749 | * |
| 818 | 750 | * @since 2.6.0 bbPress (r6300) |
| 819 | 751 | */ |
| 820 | 752 | public function register_meta() { |
| @@ -842,49 +774,38 @@ | ||
| 842 | 774 | ); |
| 843 | 775 | |
| 844 | 776 | /** Post **************************************************************/ |
| 845 | 777 | |
| 846 | - // Forum | |
| 847 | - $count['object_subtype'] = bbp_get_forum_post_type(); | |
| 778 | + // Counts | |
| 848 | 779 | register_meta( 'post', '_bbp_topic_count', $count ); |
| 849 | 780 | register_meta( 'post', '_bbp_reply_count', $count ); |
| 850 | 781 | register_meta( 'post', '_bbp_total_topic_count', $count ); |
| 851 | 782 | register_meta( 'post', '_bbp_total_reply_count', $count ); |
| 783 | + register_meta( 'post', '_bbp_voice_count', $count ); | |
| 784 | + register_meta( 'post', '_bbp_anonymous_reply_count', $count ); | |
| 852 | 785 | register_meta( 'post', '_bbp_topic_count_hidden', $count ); |
| 853 | 786 | register_meta( 'post', '_bbp_reply_count_hidden', $count ); |
| 854 | 787 | register_meta( 'post', '_bbp_forum_subforum_count', $count ); |
| 855 | 788 | |
| 856 | - // Topic | |
| 857 | - $count['object_subtype'] = bbp_get_topic_post_type(); | |
| 858 | - register_meta( 'post', '_bbp_reply_count', $count ); | |
| 859 | - register_meta( 'post', '_bbp_voice_count', $count ); | |
| 860 | - register_meta( 'post', '_bbp_anonymous_reply_count', $count ); | |
| 861 | - register_meta( 'post', '_bbp_reply_count_hidden', $count ); | |
| 862 | - | |
| 863 | 789 | /* User ***************************************************************/ |
| 864 | 790 | |
| 865 | 791 | // Counts |
| 866 | - $count['object_subtype'] = ''; | |
| 867 | 792 | register_meta( 'user', '_bbp_topic_count', $count ); |
| 868 | 793 | register_meta( 'user', '_bbp_reply_count', $count ); |
| 869 | 794 | |
| 870 | 795 | // Activity |
| 871 | - register_meta( | |
| 872 | - 'user', | |
| 873 | - '_bbp_last_posted', | |
| 874 | - array( | |
| 875 | - 'type' => 'integer', | |
| 876 | - 'description' => esc_html__( 'bbPress User Activity', 'bbpress' ), | |
| 877 | - 'single' => true, | |
| 878 | - 'show_in_rest' => true, | |
| 879 | - 'sanitize_callback' => 'bbp_number_not_negative', | |
| 880 | - 'auth_callback' => '__return_true' | |
| 881 | - ) | |
| 882 | - ); | |
| 796 | + register_meta( 'user', '_bbp_last_posted', array( | |
| 797 | + 'type' => 'integer', | |
| 798 | + 'description' => esc_html__( 'bbPress User Activity', 'bbpress' ), | |
| 799 | + 'single' => true, | |
| 800 | + 'show_in_rest' => true, | |
| 801 | + 'sanitize_callback' => 'bbp_number_not_negative', | |
| 802 | + 'auth_callback' => '__return_true' | |
| 803 | + ) ); | |
| 883 | 804 | } |
| 884 | 805 | |
| 885 | 806 | /** |
| 886 | - * Setup the currently logged-in user. | |
| 807 | + * Setup the currently logged-in user | |
| 887 | 808 | * |
| 888 | 809 | * @since 2.0.0 bbPress (r2697) |
| 889 | 810 | */ |
| 890 | 811 | public function setup_current_user() { |
| @@ -891,9 +812,9 @@ | ||
| 891 | 812 | $this->current_user = wp_get_current_user(); |
| 892 | 813 | } |
| 893 | 814 | |
| 894 | 815 | /** |
| 895 | - * Setup the user engagements strategy. | |
| 816 | + * Setup the user engagements strategy | |
| 896 | 817 | * |
| 897 | 818 | * @since 2.6.0 bbPress (r6875) |
| 898 | 819 | */ |
| 899 | 820 | public function setup_engagements() { |
| @@ -906,9 +827,9 @@ | ||
| 906 | 827 | $this->engagements = new $class_name(); |
| 907 | 828 | } |
| 908 | 829 | |
| 909 | 830 | /** |
| 910 | - * Initialize forum-specific roles. | |
| 831 | + * Initialize forum-specific roles | |
| 911 | 832 | * |
| 912 | 833 | * @since 2.6.0 |
| 913 | 834 | */ |
| 914 | 835 | public function roles_init() { |
| @@ -920,21 +841,19 @@ | ||
| 920 | 841 | $spectator = bbp_get_spectator_role(); |
| 921 | 842 | $blocked = bbp_get_blocked_role(); |
| 922 | 843 | |
| 923 | 844 | // Build the roles into one useful array |
| 924 | - // phpcs:disable WordPress.Arrays.ArrayKeySpacingRestrictions.TooMuchSpaceAfterKey | |
| 925 | 845 | $this->roles[ $keymaster ] = new WP_Role( 'Keymaster', bbp_get_caps_for_role( $keymaster ) ); |
| 926 | 846 | $this->roles[ $moderator ] = new WP_Role( 'Moderator', bbp_get_caps_for_role( $moderator ) ); |
| 927 | 847 | $this->roles[ $participant ] = new WP_Role( 'Participant', bbp_get_caps_for_role( $participant ) ); |
| 928 | 848 | $this->roles[ $spectator ] = new WP_Role( 'Spectator', bbp_get_caps_for_role( $spectator ) ); |
| 929 | 849 | $this->roles[ $blocked ] = new WP_Role( 'Blocked', bbp_get_caps_for_role( $blocked ) ); |
| 930 | - // phpcs:enable | |
| 931 | 850 | } |
| 932 | 851 | |
| 933 | 852 | /** Custom Rewrite Rules **************************************************/ |
| 934 | 853 | |
| 935 | 854 | /** |
| 936 | - * Add the bbPress-specific rewrite tags. | |
| 855 | + * Add the bbPress-specific rewrite tags | |
| 937 | 856 | * |
| 938 | 857 | * @since 2.0.0 bbPress (r2753) |
| 939 | 858 | */ |
| 940 | 859 | public static function add_rewrite_tags() { |
| @@ -1076,51 +995,39 @@ | ||
| 1076 | 995 | $view_slug = bbp_get_view_slug(); |
| 1077 | 996 | $search_slug = bbp_get_search_slug(); |
| 1078 | 997 | |
| 1079 | 998 | // User Permastruct |
| 1080 | - add_permastruct( | |
| 1081 | - $user_id, | |
| 1082 | - $user_slug . '/%' . $user_id . '%', | |
| 1083 | - array( | |
| 1084 | - 'with_front' => false, | |
| 1085 | - 'ep_mask' => EP_NONE, | |
| 1086 | - 'paged' => false, | |
| 1087 | - 'feed' => false, | |
| 1088 | - 'forcomments' => false, | |
| 1089 | - 'walk_dirs' => true, | |
| 1090 | - 'endpoints' => false, | |
| 1091 | - ) | |
| 1092 | - ); | |
| 999 | + add_permastruct( $user_id, $user_slug . '/%' . $user_id . '%', array( | |
| 1000 | + 'with_front' => false, | |
| 1001 | + 'ep_mask' => EP_NONE, | |
| 1002 | + 'paged' => false, | |
| 1003 | + 'feed' => false, | |
| 1004 | + 'forcomments' => false, | |
| 1005 | + 'walk_dirs' => true, | |
| 1006 | + 'endpoints' => false, | |
| 1007 | + ) ); | |
| 1093 | 1008 | |
| 1094 | 1009 | // Topic View Permastruct |
| 1095 | - add_permastruct( | |
| 1096 | - $view_id, | |
| 1097 | - $view_slug . '/%' . $view_id . '%', | |
| 1098 | - array( | |
| 1099 | - 'with_front' => false, | |
| 1100 | - 'ep_mask' => EP_NONE, | |
| 1101 | - 'paged' => false, | |
| 1102 | - 'feed' => false, | |
| 1103 | - 'forcomments' => false, | |
| 1104 | - 'walk_dirs' => true, | |
| 1105 | - 'endpoints' => false, | |
| 1106 | - ) | |
| 1107 | - ); | |
| 1010 | + add_permastruct( $view_id, $view_slug . '/%' . $view_id . '%', array( | |
| 1011 | + 'with_front' => false, | |
| 1012 | + 'ep_mask' => EP_NONE, | |
| 1013 | + 'paged' => false, | |
| 1014 | + 'feed' => false, | |
| 1015 | + 'forcomments' => false, | |
| 1016 | + 'walk_dirs' => true, | |
| 1017 | + 'endpoints' => false, | |
| 1018 | + ) ); | |
| 1108 | 1019 | |
| 1109 | 1020 | // Search Permastruct |
| 1110 | - add_permastruct( | |
| 1111 | - $search_id, | |
| 1112 | - $search_slug . '/%' . $search_id . '%', | |
| 1113 | - array( | |
| 1114 | - 'with_front' => false, | |
| 1115 | - 'ep_mask' => EP_NONE, | |
| 1116 | - 'paged' => true, | |
| 1117 | - 'feed' => false, | |
| 1118 | - 'forcomments' => false, | |
| 1119 | - 'walk_dirs' => true, | |
| 1120 | - 'endpoints' => false, | |
| 1121 | - ) | |
| 1122 | - ); | |
| 1021 | + add_permastruct( $search_id, $search_slug . '/%' . $search_id . '%', array( | |
| 1022 | + 'with_front' => false, | |
| 1023 | + 'ep_mask' => EP_NONE, | |
| 1024 | + 'paged' => true, | |
| 1025 | + 'feed' => false, | |
| 1026 | + 'forcomments' => false, | |
| 1027 | + 'walk_dirs' => true, | |
| 1028 | + 'endpoints' => false, | |
| 1029 | + ) ); | |
| 1123 | 1030 | } |
| 1124 | 1031 | } |
| 1125 | 1032 | |
| 1126 | 1033 | /** |