Changeset 13900 for trunk/src/bp-core/classes/class-bp-component.php
- Timestamp:
- 06/02/2024 07:12:25 PM (2 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-core/classes/class-bp-component.php (modified) (45 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/classes/class-bp-component.php
r13878 r13900 11 11 defined( 'ABSPATH' ) || exit; 12 12 13 if ( !class_exists( 'BP_Component' ) ) : 13 if ( class_exists( 'BP_Component' ) ) { 14 return; 15 } 14 16 15 17 /** … … 40 42 * 41 43 * @since 1.5.0 44 * 42 45 * @var string 43 46 */ … … 48 51 * 49 52 * @since 1.5.0 53 * 50 54 * @var string 51 55 */ … … 56 60 * 57 61 * @since 1.5.0 62 * 58 63 * @var bool 59 64 */ … … 64 69 * 65 70 * @since 12.0.0 71 * 66 72 * @var string 67 73 */ … … 72 78 * 73 79 * @since 12.0.0 80 * 74 81 * @var array 75 82 */ … … 80 87 * 81 88 * @since 1.5.0 89 * 82 90 * @var string 83 91 */ … … 88 96 * 89 97 * @since 1.5.0 98 * 90 99 * @var WP_Query 91 100 */ … … 96 105 * 97 106 * @since 1.5.0 107 * 98 108 * @var string 99 109 */ … … 104 114 * 105 115 * @since 1.5.0 116 * 106 117 * @var callable 107 118 */ … … 112 123 * 113 124 * @since 1.5.0 125 * 114 126 * @var array 115 127 */ … … 120 132 * 121 133 * @since 1.6.0 134 * 122 135 * @var string 123 136 */ … … 128 141 * 129 142 * @since 1.6.0 143 * 130 144 * @var string 131 145 */ … … 136 150 * 137 151 * @since 2.0.0 152 * 138 153 * @var array 139 154 */ … … 144 159 * 145 160 * @since 2.0.0 161 * 146 162 * @var array 147 163 */ … … 152 168 * 153 169 * @since 12.0.0 170 * 154 171 * @var string 155 172 */ … … 160 177 * 161 178 * @since 2.4.0 179 * 162 180 * @var string 163 181 */ … … 168 186 * 169 187 * @since 9.0.0 188 * 170 189 * @var array 171 190 */ … … 176 195 * 177 196 * @since 1.5.0 197 * 178 198 * @var int 179 199 */ … … 184 204 * 185 205 * @since 1.5.0 206 * 186 207 * @var string[] 187 208 */ … … 192 213 * 193 214 * @since 2.0.0 215 * 194 216 * @var string 195 217 */ … … 200 222 * 201 223 * @since 12.0.0 224 * 202 225 * @var array 203 226 */ … … 208 231 * 209 232 * @since 12.0.0 233 * 210 234 * @var array 211 235 */ 212 public $sub_nav = array();236 public $sub_nav = array(); 213 237 214 238 /** Methods ***************************************************************/ … … 239 263 240 264 // Internal identifier of component. 241 $this->id = $id;265 $this->id = $id; 242 266 243 267 // Internal component name. … … 364 388 * @param array $value The list of rewrite IDs for the component. 365 389 */ 366 (array) apply_filters( 'bp_' . $this->id . '_rewrite_ids', $r['rewrite_ids'] ),390 (array) apply_filters( 'bp_' . $this->id . '_rewrite_ids', $r['rewrite_ids'] ), 367 391 array_fill_keys( array_keys( bp_rewrites_get_default_url_chunks() ), '' ) 368 392 ); … … 480 504 * @since 1.5.0 481 505 * 482 *483 506 * @param array $includes An array of file names, or file name chunks, 484 507 * to be parsed and then included. … … 496 519 497 520 // Passed with no extension. 498 'bp-' . $this->id . '/bp-' . $this->id . '-' . $file . '.php',521 'bp-' . $this->id . '/bp-' . $this->id . '-' . $file . '.php', 499 522 'bp-' . $this->id . '-' . $file . '.php', 500 523 'bp-' . $this->id . '/' . $file . '.php', … … 508 531 foreach ( $paths as $path ) { 509 532 if ( @is_file( $slashed_path . $path ) ) { 510 require ( $slashed_path . $path );533 require $slashed_path . $path; 511 534 break; 512 535 } … … 540 563 * 541 564 * @since 1.5.0 542 *543 565 */ 544 566 public function setup_actions() { 545 567 546 568 // Setup globals. 547 add_action( 'bp_setup_globals', array( $this, 'setup_globals'), 10 );569 add_action( 'bp_setup_globals', array( $this, 'setup_globals' ), 10 ); 548 570 549 571 // Set up canonical stack. 550 add_action( 'bp_setup_canonical_stack', array( $this, 'setup_canonical_stack'), 10 );572 add_action( 'bp_setup_canonical_stack', array( $this, 'setup_canonical_stack' ), 10 ); 551 573 552 574 // Include required files. Called early to ensure that BP core … … 555 577 // compatibility; henceforth, plugins should register themselves by 556 578 // extending this base class. 557 add_action( 'bp_include', array( $this, 'includes' ),8 );579 add_action( 'bp_include', array( $this, 'includes' ), 8 ); 558 580 559 581 // Load files conditionally, based on certain pages. 560 add_action( 'bp_late_include', array( $this, 'late_includes'), 10 );582 add_action( 'bp_late_include', array( $this, 'late_includes' ), 10 ); 561 583 562 584 // Generate navigation. 563 add_action( 'bp_register_nav', array( $this, 'register_nav' ),9 );585 add_action( 'bp_register_nav', array( $this, 'register_nav' ), 9 ); 564 586 565 587 // Setup navigation. 566 add_action( 'bp_setup_nav', array( $this, 'setup_nav' ),9 );588 add_action( 'bp_setup_nav', array( $this, 'setup_nav' ), 9 ); 567 589 568 590 // Setup WP Toolbar menus. 569 add_action( 'bp_setup_admin_bar', array( $this, 'setup_admin_bar'), $this->adminbar_myaccount_order );591 add_action( 'bp_setup_admin_bar', array( $this, 'setup_admin_bar' ), $this->adminbar_myaccount_order ); 570 592 571 593 // Setup component title. 572 add_action( 'bp_setup_title', array( $this, 'setup_title'), 10 );594 add_action( 'bp_setup_title', array( $this, 'setup_title' ), 10 ); 573 595 574 596 // Setup cache groups. 575 add_action( 'bp_setup_cache_groups', array( $this, 'setup_cache_groups'), 10 );597 add_action( 'bp_setup_cache_groups', array( $this, 'setup_cache_groups' ), 10 ); 576 598 577 599 // Register post types. 578 add_action( 'bp_register_post_types', array( $this, 'register_post_types'), 10 );600 add_action( 'bp_register_post_types', array( $this, 'register_post_types' ), 10 ); 579 601 580 602 // Register post statuses. … … 582 604 583 605 // Register taxonomies. 584 add_action( 'bp_register_taxonomies', array( $this, 'register_taxonomies'), 10 );606 add_action( 'bp_register_taxonomies', array( $this, 'register_taxonomies' ), 10 ); 585 607 586 608 // Add the rewrite tags. 587 add_action( 'bp_add_rewrite_tags', array( $this, 'add_rewrite_tags'), 10, 0 );609 add_action( 'bp_add_rewrite_tags', array( $this, 'add_rewrite_tags' ), 10, 0 ); 588 610 589 611 // Add the rewrite rules. 590 add_action( 'bp_add_rewrite_rules', array( $this, 'add_rewrite_rules'), 10, 0 );612 add_action( 'bp_add_rewrite_rules', array( $this, 'add_rewrite_rules' ), 10, 0 ); 591 613 592 614 // Add the permalink structure. 593 add_action( 'bp_add_permastructs', array( $this, 'add_permastructs'), 10 );615 add_action( 'bp_add_permastructs', array( $this, 'add_permastructs' ), 10 ); 594 616 595 617 // Allow components to parse the main query. 596 add_action( 'bp_parse_query', array( $this, 'parse_query' ), 10 );618 add_action( 'bp_parse_query', array( $this, 'parse_query' ), 10 ); 597 619 598 620 // Generate rewrite rules. … … 722 744 723 745 // No sub nav items without a main nav item. 724 if ( $this->main_nav && $generate ) {746 if ( $this->main_nav && $generate ) { 725 747 if ( isset( $this->main_nav['user_has_access_callback'] ) && is_callable( $this->main_nav['user_has_access_callback'] ) ) { 726 748 $this->main_nav['show_for_displayed_user'] = call_user_func( $this->main_nav['user_has_access_callback'] ); … … 824 846 825 847 // Do we have Toolbar menus to add? 826 if ( ! empty( $wp_admin_nav ) ) {848 if ( ! empty( $wp_admin_nav ) ) { 827 849 // Fill in position if one wasn't passed for backpat. 828 $pos = 0;850 $pos = 0; 829 851 $not_set_pos = 1; 830 852 foreach ( $wp_admin_nav as $key => $nav ) { 831 853 if ( ! isset( $nav['position'] ) ) { 832 $wp_admin_nav[ $key]['position'] = $pos + $not_set_pos;854 $wp_admin_nav[ $key ]['position'] = $pos + $not_set_pos; 833 855 834 856 if ( 9 !== $not_set_pos ) { … … 871 893 * 872 894 * @since 1.5.0 873 *874 895 */ 875 896 public function setup_title() { … … 882 903 * @since 1.5.0 883 904 */ 884 do_action( 'bp_' . $this->id . '_setup_title' );905 do_action( 'bp_' . $this->id . '_setup_title' ); 885 906 } 886 907 … … 889 910 * 890 911 * @since 2.2.0 891 *892 912 */ 893 913 public function setup_cache_groups() { … … 924 944 925 945 // Add to the BuddyPress global object. 926 if ( ! empty( $tables ) && is_array( $tables ) ) {946 if ( ! empty( $tables ) && is_array( $tables ) ) { 927 947 foreach ( $tables as $global_name => $table_name ) { 928 948 $this->{$global_name} = $table_name; … … 971 991 * components to play nicely with the WordPress metadata API. 972 992 */ 973 if ( ! empty( $tables ) && is_array( $tables ) ) {993 if ( ! empty( $tables ) && is_array( $tables ) ) { 974 994 foreach ( $tables as $meta_prefix => $table_name ) { 975 995 $wpdb->{$meta_prefix . 'meta'} = $table_name; … … 994 1014 * 995 1015 * @since 1.5.0 996 *997 1016 */ 998 1017 public function register_post_types() { … … 1029 1048 * 1030 1049 * @since 1.5.0 1031 *1032 1050 */ 1033 1051 public function register_taxonomies() { … … 1132 1150 } else { 1133 1151 $regex = trailingslashit( $regex ) . $rule_information['regex']; 1134 $query .= '&' . $this->rewrite_ids[ $rule_key ] . '=$matches[' . $match .']';1135 $match += 1;1152 $query .= '&' . $this->rewrite_ids[ $rule_key ] . '=$matches[' . $match . ']'; 1153 ++$match; 1136 1154 1137 1155 $rules[ $rule_key ]['regex'] = $regex . '/?$'; … … 1304 1322 */ 1305 1323 $do_redirect_to_login_screen = apply_filters( 'bp_view_no_access_redirect_to_login_screen', false ); 1306 If ( true === $do_redirect_to_login_screen && ! is_user_logged_in() ) {1324 if ( true === $do_redirect_to_login_screen && ! is_user_logged_in() ) { 1307 1325 bp_core_no_access(); 1308 1326 } … … 1365 1383 * 1366 1384 * @since 1.5.0 1367 *1368 1385 */ 1369 1386 public function generate_rewrite_rules() { … … 1408 1425 } 1409 1426 1410 $component_controller = new $controller ;1427 $component_controller = new $controller(); 1411 1428 $component_controller->register_routes(); 1412 1429 } … … 1468 1485 * 1469 1486 * @param string[] $states An array of post display states. 1470 * @param WP_Post $post The current post object. 1471 * @return array The component's directory states. 1472 */ 1473 public function admin_directory_states( $states = array(), $post = null ) { 1487 * @return array The component's directory states. 1488 */ 1489 public function admin_directory_states( $states = array() ) { 1474 1490 _deprecated_function( __METHOD__, '12.0.0' ); 1491 1475 1492 return $states; 1476 1493 } 1477 1494 } 1478 endif; // BP_Component.
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)