- Timestamp:
- 07/24/2023 10:27:28 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/classes/class-bp-group-extension.php
r13452 r13524 197 197 198 198 /** 199 * List of Group access levels.200 *201 * @since 12.0.0202 * @var string[]203 */204 public $access_levels = array( 'noone', 'admin', 'mod', 'member', 'loggedin', 'anyone' );205 206 /**207 199 * Whether the current user can visit the tab. 208 200 * … … 514 506 * `array( 'mod', 'admin' )`. Defaults to 'anyone' for public groups 515 507 * and 'member' for private groups. 508 * @type string|array $show_tab_callback The function to execute to set the $show_tab argument. 516 509 * } 517 510 */ … … 545 538 'access' => null, 546 539 'show_tab' => null, 540 'show_tab_callback' => '', 547 541 ) 548 542 ); 549 543 550 $show_tab = $this->params['show_tab']; 551 if ( $show_tab && ! in_array( $show_tab, $this->access_levels, true ) && is_callable( $show_tab ) ) { 552 $this->show_tab_callback = $show_tab; 553 554 // Group Admin can always see. 555 $this->params['show_tab'] = 'admin'; 544 if ( $this->params['show_tab_callback'] && is_callable( $this->params['show_tab_callback'] ) ) { 545 $this->show_tab_callback = $this->params['show_tab_callback']; 556 546 } 557 547 … … 867 857 $this->user_can_see_nav_item = false; 868 858 859 // Use the provided callback to show or hide the Group extension tab. 860 if ( $this->show_tab_callback ) { 861 $this->params['show_tab'] = call_user_func_array( $this->show_tab_callback, array( $this->group_id ) ); 862 } 863 869 864 /* 870 865 * Backward compatibility for components that do not provide 871 * explicit 'show_tab ' parameter.866 * explicit 'show_tab_callback' or 'show_tab' parameters. 872 867 */ 873 868 if ( empty( $this->params['show_tab'] ) ) { … … 1110 1105 if ( ( 'noone' !== $this->params['show_tab'] ) && bp_current_user_can( 'bp_moderate' ) ) { 1111 1106 return true; 1112 }1113 1114 if ( $this->show_tab_callback ) {1115 return call_user_func( $this->show_tab_callback );1116 1107 } 1117 1108
Note: See TracChangeset
for help on using the changeset viewer.