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-core-nav.php

    r13878 r13900  
    1919 */
    2020class BP_Core_Nav {
     21
    2122        /**
    2223         * An associative array containing the nav items for the object ID.
    2324         *
    2425         * @since 2.6.0
     26         *
    2527         * @var array
    2628         */
     
    3133         *
    3234         * @since 2.6.0
     35         *
    3336         * @var int
    3437         */
     
    3942         *
    4043         * @since 12.0.0
     44         *
    4145         * @var string
    4246         */
     
    4852         * @since 2.6.0
    4953         *
    50          * @param int $object_id The item ID to build the nav for. Default is the displayed user ID.
     54         * @param int    $object_id The item ID to build the nav for. Default is the displayed user ID.
     55         * @param string $component_id Optional. The component ID. Default is 'members'.
    5156         */
    5257        public function __construct( $object_id = 0, $component_id = 'members' ) {
     
    114119         *
    115120         * @param string $key The nav item slug to get. Optional.
    116          * @return mixed       An array of nav item, a single nav item, or null if none found.
     121         * @return mixed An array of nav item, a single nav item, or null if none found.
    117122         */
    118123        public function get( $key = '' ) {
     
    127132                        }
    128133
    129                 // Return all nav item items.
     134                        // Return all nav item items.
    130135                } else {
    131136                        $return = $this->nav[ $this->object_id ];
     
    159164                        $args['secondary']                    = true;
    160165
    161                 // This is a parent.
     166                        // This is a parent.
    162167                } else {
    163168                        $slug                                 = $args['slug'];
     
    180185
    181186                                $chunk = 'single_item_action';
    182                                 if ( $path_chunks['single_item'] . '_manage' ===  $path_chunks['single_item_component'] ) {
     187                                if ( $path_chunks['single_item'] . '_manage' === $path_chunks['single_item_component'] ) {
    183188                                        $chunk                             = 'single_item_action_variables';
    184189                                        $path_chunks[ $chunk ]             = $path_chunks['single_item_action'];
    185190                                        $path_chunks['single_item_action'] = bp_rewrites_get_slug( 'groups', 'bp_group_read_admin', 'admin' );
    186                                         $group_screens = bp_get_group_screens( 'manage' );
     191                                        $group_screens                     = bp_get_group_screens( 'manage' );
    187192                                } else {
    188193                                        $group_screens = bp_get_group_screens( 'read' );
     
    259264                        return $this->nav[ $this->object_id ][ $slug ];
    260265
    261                 // We're editing a child.
     266                        // We're editing a child.
    262267                } else {
    263                         $sub_items = $this->get_secondary( array( 'parent_slug' => $parent_slug, 'slug' => $slug ), false );
     268                        $sub_items = $this->get_secondary(
     269                                array(
     270                                        'parent_slug' => $parent_slug,
     271                                        'slug'        => $slug,
     272                                ),
     273                                false
     274                        );
    264275
    265276                        if ( ! $sub_items ) {
     
    305316
    306317                        // Validate the subnav.
    307                         $sub_items = $this->get_secondary( array( 'parent_slug' => $parent_slug, 'slug' => $slug ), false );
     318                        $sub_items = $this->get_secondary(
     319                                array(
     320                                        'parent_slug' => $parent_slug,
     321                                        'slug'        => $slug,
     322                                ),
     323                                false
     324                        );
    308325
    309326                        if ( ! $sub_items ) {
     
    323340                        return array( $sub_item->screen_function );
    324341
    325                 // We're deleting a parent.
     342                        // We're deleting a parent.
    326343                } else {
    327344                        // Validate the nav.
     
    340357                        $screen_functions = array( $nav_item->screen_function );
    341358
    342                         // Life's unfair, children won't survive the parent :(
     359                        // Life's unfair, children won't survive the parent.
    343360                        $sub_items = $this->get_secondary( array( 'parent_slug' => $nav_item->slug ), false );
    344361
     
    384401
    385402                                do {
    386                                         $position += 1;
    387                                 } while ( in_array( $position, $sorted_keys ) );
     403                                        ++$position;
     404                                } while ( in_array( $position, $sorted_keys, true ) );
    388405                        }
    389406
     
    392409
    393410                ksort( $sorted );
     411
    394412                return $sorted;
    395413        }
     
    478496                        foreach ( $primary_nav_items as $key_nav => $primary_nav ) {
    479497                                // Try to get the children.
    480                                 $children = $this->get_secondary( array( 'parent_slug' => $primary_nav->slug, 'user_has_access' => true ) );
     498                                $children = $this->get_secondary(
     499                                        array(
     500                                                'parent_slug'     => $primary_nav->slug,
     501                                                'user_has_access' => true,
     502                                        )
     503                                );
    481504
    482505                                if ( $children ) {
    483                                         $primary_nav_items[ $key_nav ] = clone $primary_nav;
     506                                        $primary_nav_items[ $key_nav ]           = clone $primary_nav;
    484507                                        $primary_nav_items[ $key_nav ]->children = $children;
    485508                                }
Note: See TracChangeset for help on using the changeset viewer.