Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/25/2023 05:18:41 PM (2 years ago)
Author:
imath
Message:

Fully deprecate bp_nav & bp_options_nav BP globals

These back compatibility mechanism, which was in BP since version 2.6, has moved to the BP Classic plugin.

Fixes #8927
Closes https://github.com/buddypress/buddypress/pull/121

File:
1 edited

Legend:

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

    r13500 r13507  
    44 *
    55 * @since 2.6.0
     6 * @deprecated 12.0.0
    67 */
    78
     
    1617 *
    1718 * @since 2.6.0
     19 * @deprecated 12.0.0
    1820 */
    1921class BP_Core_BP_Nav_BackCompat implements ArrayAccess {
     
    5759     *
    5860     * @since 2.6.0
     61     * @deprecated 12.0.0
    5962     *
    6063     * @param mixed $offset Array offset.
     
    6871            '2.6.0'
    6972        );
    70 
    71         $bp = buddypress();
    72 
    73         if ( is_array( $value ) ) {
    74             $value = new self( $value );
    75         }
    76 
    77         if ( $offset !== null ) {
    78             // Temporarily set the backcompat_nav.
    79             $this->backcompat_nav[ $offset ] = $value;
    80 
    81             $args = $this->to_array();
    82             if ( isset( $args['parent_slug'] ) ) {
    83                 $this->get_component_nav( $args['parent_slug'] )->edit_nav( $args, $args['slug'], $args['parent_slug'] );
    84             } elseif ( isset( $args['slug'] ) ) {
    85                 $bp->members->nav->edit_nav( $args, $args['slug'] );
    86             }
    87         }
     73        _deprecated_function( __METHOD__, '12.0.0' );
    8874    }
    8975
     
    9278     *
    9379     * @since 2.6.0
     80     * @deprecated 12.0.0
    9481     *
    9582     * @param mixed $offset Array offset.
     
    10390            '2.6.0'
    10491        );
    105 
    106         $nav = $this->get_nav( $offset );
    107         if ( $nav && isset( $nav[ $offset ] ) ) {
    108             $this->backcompat_nav[ $offset ] = new self( $nav[ $offset ] );
    109         }
    110 
    111         return $this->backcompat_nav[ $offset ];
     92        _deprecated_function( __METHOD__, '12.0.0' );
    11293    }
    11394
     
    11697     *
    11798     * @since 2.6.0
     99     * @deprecated 12.0.0
    118100     *
    119101     * @param mixed $offset Array offset.
     
    127109            '2.6.0'
    128110        );
    129 
    130         if ( isset( $this->backcompat_nav[ $offset ] ) ) {
    131             return true;
    132         }
    133 
    134         $nav = $this->get_nav( $offset );
    135         if ( $nav && isset( $nav[ $offset ] ) ) {
    136             return true;
    137         }
    138 
    139         return false;
     111        _deprecated_function( __METHOD__, '12.0.0' );
    140112    }
    141113
     
    144116     *
    145117     * @since 2.6.0
     118     * @deprecated 12.0.0
    146119     *
    147120     * @param mixed $offset Array offset.
     
    154127            '2.6.0'
    155128        );
    156 
    157         // For top-level nav items, the backcompat nav hasn't yet been initialized.
    158         if ( ! isset( $this->backcompat_nav[ $offset ] ) ) {
    159             buddypress()->members->nav->delete_nav( $offset );
    160             unset( $this->backcompat_nav[ $offset ] );
    161         }
     129        _deprecated_function( __METHOD__, '12.0.0' );
    162130    }
    163131
     
    166134     *
    167135     * @since 2.6.0
     136     * @deprecated 12.0.0
    168137     *
    169138     * @param string $component
    170139     */
    171140    public function set_component( $component ) {
    172         $this->component = $component;
     141        _deprecated_function( __METHOD__, '12.0.0' );
    173142    }
    174143
     
    181150     *
    182151     * @since 2.6.0
     152     * @deprecated 12.0.0
    183153     *
    184154     * @param mixed $offset Array offset.
     
    186156     */
    187157    public function get_component( $offset = '' ) {
    188         if ( ! isset( $this->component ) ) {
    189             if ( bp_is_active( 'groups' ) && $offset === bp_get_current_group_slug() ) {
    190                 $this->component = 'groups';
    191             } else {
    192                 $this->component = 'members';
    193             }
    194         }
    195 
    196         return $this->component;
     158        _deprecated_function( __METHOD__, '12.0.0' );
    197159    }
    198160
     
    203165     *
    204166     * @since 2.6.0
     167     * @deprecated 12.0.0
    205168     */
    206169    public function reset() {
    207         $this->backcompat_nav = array();
     170        _deprecated_function( __METHOD__, '12.0.0' );
    208171    }
    209172
     
    212175     *
    213176     * @since 2.6.0
     177     * @deprecated 12.0.0
    214178     *
    215179     * @param mixed $offset Array offset.
     
    217181     */
    218182    protected function get_nav( $offset ) {
    219         $component_nav = $this->get_component_nav( $offset );
    220         $primary_nav   = $component_nav->get_primary( array( 'slug' => $offset ), false );
    221 
    222         $nav = array();
    223 
    224         if ( empty( $primary_nav ) ) {
    225             return $nav;
    226         }
    227 
    228         foreach ( $primary_nav as $item ) {
    229             $nav[ $item->slug ] = (array) $item;
    230         }
    231 
    232         return $nav;
     183        _deprecated_function( __METHOD__, '12.0.0' );
    233184    }
    234185
     
    243194     *
    244195     * @since 2.6.0
     196     * @deprecated 12.0.0
    245197     *
    246198     * @param string $offset Nav item name.
     
    248200     */
    249201    protected function get_component_nav( $offset = '' ) {
    250         $component = $this->get_component( $offset );
    251 
    252         $bp = buddypress();
    253         if ( ! isset( $bp->{$component}->nav ) ) {
    254             return false;
    255         }
    256 
    257         return $bp->{$component}->nav;
     202        _deprecated_function( __METHOD__, '12.0.0' );
    258203    }
    259204
     
    262207     *
    263208     * @since 2.6.0
     209     * @deprecated 12.0.0
    264210     *
    265211     * @return array
    266212     */
    267213    protected function to_array() {
    268         return $this->backcompat_nav;
     214        _deprecated_function( __METHOD__, '12.0.0' );
    269215    }
    270216}
Note: See TracChangeset for help on using the changeset viewer.