Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/02/2024 07:12:25 PM (2 years ago)
Author:
espellcaste
Message:

WPCS: Part VIII: miscellaneous fixes for some of the files of the core component.

Follow-up to [13883], [13886], [13887], [13888], [13891], [13892], [13893]

See #9164 and #7228

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-component.php

    r13878 r13900  
    1111defined( 'ABSPATH' ) || exit;
    1212
    13 if ( !class_exists( 'BP_Component' ) ) :
     13if ( class_exists( 'BP_Component' ) ) {
     14        return;
     15}
    1416
    1517/**
     
    4042         *
    4143         * @since 1.5.0
     44         *
    4245         * @var string
    4346         */
     
    4851         *
    4952         * @since 1.5.0
     53         *
    5054         * @var string
    5155         */
     
    5660         *
    5761         * @since 1.5.0
     62         *
    5863         * @var bool
    5964         */
     
    6469         *
    6570         * @since 12.0.0
     71         *
    6672         * @var string
    6773         */
     
    7278         *
    7379         * @since 12.0.0
     80         *
    7481         * @var array
    7582         */
     
    8087         *
    8188         * @since 1.5.0
     89         *
    8290         * @var string
    8391         */
     
    8896         *
    8997         * @since 1.5.0
     98         *
    9099         * @var WP_Query
    91100         */
     
    96105         *
    97106         * @since 1.5.0
     107         *
    98108         * @var string
    99109         */
     
    104114         *
    105115         * @since 1.5.0
     116         *
    106117         * @var callable
    107118         */
     
    112123         *
    113124         * @since 1.5.0
     125         *
    114126         * @var array
    115127         */
     
    120132         *
    121133         * @since 1.6.0
     134         *
    122135         * @var string
    123136         */
     
    128141         *
    129142         * @since 1.6.0
     143         *
    130144         * @var string
    131145         */
     
    136150         *
    137151         * @since 2.0.0
     152         *
    138153         * @var array
    139154         */
     
    144159         *
    145160         * @since 2.0.0
     161         *
    146162         * @var array
    147163         */
     
    152168         *
    153169         * @since 12.0.0
     170         *
    154171         * @var string
    155172         */
     
    160177         *
    161178         * @since 2.4.0
     179         *
    162180         * @var string
    163181         */
     
    168186         *
    169187         * @since 9.0.0
     188         *
    170189         * @var array
    171190         */
     
    176195         *
    177196         * @since 1.5.0
     197         *
    178198         * @var int
    179199         */
     
    184204         *
    185205         * @since 1.5.0
     206         *
    186207         * @var string[]
    187208         */
     
    192213         *
    193214         * @since 2.0.0
     215         *
    194216         * @var string
    195217         */
     
    200222         *
    201223         * @since 12.0.0
     224         *
    202225         * @var array
    203226         */
     
    208231         *
    209232         * @since 12.0.0
     233         *
    210234         * @var array
    211235         */
    212         public $sub_nav  = array();
     236        public $sub_nav = array();
    213237
    214238        /** Methods ***************************************************************/
     
    239263
    240264                // Internal identifier of component.
    241                 $this->id   = $id;
     265                $this->id = $id;
    242266
    243267                // Internal component name.
     
    364388                                 * @param array $value The list of rewrite IDs for the component.
    365389                                 */
    366                                 (array) apply_filters( 'bp_' . $this->id. '_rewrite_ids', $r['rewrite_ids'] ),
     390                                (array) apply_filters( 'bp_' . $this->id . '_rewrite_ids', $r['rewrite_ids'] ),
    367391                                array_fill_keys( array_keys( bp_rewrites_get_default_url_chunks() ), '' )
    368392                        );
     
    480504         * @since 1.5.0
    481505         *
    482          *
    483506         * @param array $includes An array of file names, or file name chunks,
    484507         *                        to be parsed and then included.
     
    496519
    497520                                        // Passed with no extension.
    498                                         'bp-' . $this->id . '/bp-' . $this->id . '-' . $file  . '.php',
     521                                        'bp-' . $this->id . '/bp-' . $this->id . '-' . $file . '.php',
    499522                                        'bp-' . $this->id . '-' . $file . '.php',
    500523                                        'bp-' . $this->id . '/' . $file . '.php',
     
    508531                                foreach ( $paths as $path ) {
    509532                                        if ( @is_file( $slashed_path . $path ) ) {
    510                                                 require( $slashed_path . $path );
     533                                                require $slashed_path . $path;
    511534                                                break;
    512535                                        }
     
    540563         *
    541564         * @since 1.5.0
    542          *
    543565         */
    544566        public function setup_actions() {
    545567
    546568                // Setup globals.
    547                 add_action( 'bp_setup_globals',          array( $this, 'setup_globals'          ), 10 );
     569                add_action( 'bp_setup_globals', array( $this, 'setup_globals' ), 10 );
    548570
    549571                // 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 );
    551573
    552574                // Include required files. Called early to ensure that BP core
     
    555577                // compatibility; henceforth, plugins should register themselves by
    556578                // extending this base class.
    557                 add_action( 'bp_include',                array( $this, 'includes'               ), 8 );
     579                add_action( 'bp_include', array( $this, 'includes' ), 8 );
    558580
    559581                // 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 );
    561583
    562584                // Generate navigation.
    563                 add_action( 'bp_register_nav',           array( $this, 'register_nav'           ), 9 );
     585                add_action( 'bp_register_nav', array( $this, 'register_nav' ), 9 );
    564586
    565587                // Setup navigation.
    566                 add_action( 'bp_setup_nav',              array( $this, 'setup_nav'              ), 9 );
     588                add_action( 'bp_setup_nav', array( $this, 'setup_nav' ), 9 );
    567589
    568590                // 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 );
    570592
    571593                // 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 );
    573595
    574596                // 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 );
    576598
    577599                // 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 );
    579601
    580602                // Register post statuses.
     
    582604
    583605                // Register taxonomies.
    584                 add_action( 'bp_register_taxonomies',    array( $this, 'register_taxonomies'    ), 10 );
     606                add_action( 'bp_register_taxonomies', array( $this, 'register_taxonomies' ), 10 );
    585607
    586608                // 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 );
    588610
    589611                // 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 );
    591613
    592614                // 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 );
    594616
    595617                // 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 );
    597619
    598620                // Generate rewrite rules.
     
    722744
    723745                        // No sub nav items without a main nav item.
    724                         if ( $this->main_nav && $generate) {
     746                        if ( $this->main_nav && $generate ) {
    725747                                if ( isset( $this->main_nav['user_has_access_callback'] ) && is_callable( $this->main_nav['user_has_access_callback'] ) ) {
    726748                                        $this->main_nav['show_for_displayed_user'] = call_user_func( $this->main_nav['user_has_access_callback'] );
     
    824846
    825847                // Do we have Toolbar menus to add?
    826                 if ( !empty( $wp_admin_nav ) ) {
     848                if ( ! empty( $wp_admin_nav ) ) {
    827849                        // Fill in position if one wasn't passed for backpat.
    828                         $pos = 0;
     850                        $pos         = 0;
    829851                        $not_set_pos = 1;
    830852                        foreach ( $wp_admin_nav as $key => $nav ) {
    831853                                if ( ! isset( $nav['position'] ) ) {
    832                                         $wp_admin_nav[$key]['position'] = $pos + $not_set_pos;
     854                                        $wp_admin_nav[ $key ]['position'] = $pos + $not_set_pos;
    833855
    834856                                        if ( 9 !== $not_set_pos ) {
     
    871893         *
    872894         * @since 1.5.0
    873          *
    874895         */
    875896        public function setup_title() {
     
    882903                 * @since 1.5.0
    883904                 */
    884                 do_action(  'bp_' . $this->id . '_setup_title' );
     905                do_action( 'bp_' . $this->id . '_setup_title' );
    885906        }
    886907
     
    889910         *
    890911         * @since 2.2.0
    891          *
    892912         */
    893913        public function setup_cache_groups() {
     
    924944
    925945                // Add to the BuddyPress global object.
    926                 if ( !empty( $tables ) && is_array( $tables ) ) {
     946                if ( ! empty( $tables ) && is_array( $tables ) ) {
    927947                        foreach ( $tables as $global_name => $table_name ) {
    928948                                $this->{$global_name} = $table_name;
     
    971991                 * components to play nicely with the WordPress metadata API.
    972992                 */
    973                 if ( !empty( $tables ) && is_array( $tables ) ) {
     993                if ( ! empty( $tables ) && is_array( $tables ) ) {
    974994                        foreach ( $tables as $meta_prefix => $table_name ) {
    975995                                $wpdb->{$meta_prefix . 'meta'} = $table_name;
     
    9941014         *
    9951015         * @since 1.5.0
    996          *
    9971016         */
    9981017        public function register_post_types() {
     
    10291048         *
    10301049         * @since 1.5.0
    1031          *
    10321050         */
    10331051        public function register_taxonomies() {
     
    11321150                                } else {
    11331151                                        $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;
    11361154
    11371155                                        $rules[ $rule_key ]['regex'] = $regex . '/?$';
     
    13041322                                 */
    13051323                                $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() ) {
    13071325                                        bp_core_no_access();
    13081326                                }
     
    13651383         *
    13661384         * @since 1.5.0
    1367          *
    13681385         */
    13691386        public function generate_rewrite_rules() {
     
    14081425                                }
    14091426
    1410                                 $component_controller = new $controller;
     1427                                $component_controller = new $controller();
    14111428                                $component_controller->register_routes();
    14121429                        }
     
    14681485         *
    14691486         * @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() ) {
    14741490                _deprecated_function( __METHOD__, '12.0.0' );
     1491
    14751492                return $states;
    14761493        }
    14771494}
    1478 endif; // BP_Component.
Note: See TracChangeset for help on using the changeset viewer.