Skip to:
Content

BuddyPress.org

Changeset 13741


Ignore:
Timestamp:
02/23/2024 03:16:00 AM (3 years ago)
Author:
imath
Message:

Deprecate bp_use_wp_admin_bar() & BP_USE_WP_ADMIN_BAR

This function and constant were useful when BuddyPress was including an alternative toolbar to the WordPress Admin Bar called the "BuddyBar". The BuddyBar was removed in [12893] but we forgot to deprecate bp_use_wp_admin_bar() & BP_USE_WP_ADMIN_BAR. This commit is finally achieving the step we missed almost 3 years ago.

Props espellcaste, emaralive

Fixes #9104
Closes ​https://github.com/buddypress/buddypress/pull/234

Location:
trunk/src/bp-core
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-adminbar.php

    r13395 r13741  
    2424
    2525        // Bail if this is an ajax request.
    26         if ( !bp_use_wp_admin_bar() || defined( 'DOING_AJAX' ) )
     26        if ( wp_doing_ajax() ) {
    2727                return;
     28        }
    2829
    2930        // Only add menu for logged in user.
    … …  
    5455                show_admin_bar( true );
    5556        }
    56 
    57         // Hide the WordPress Toolbar.
    58         if ( ! bp_use_wp_admin_bar() ) {
    59                 // Keep the WP Toolbar from loading.
    60                 show_admin_bar( false );
    61         }
    6257}
    6358add_action( 'init', 'bp_core_load_admin_bar', 9 );
    … …  
    8782function bp_core_enqueue_admin_bar_css() {
    8883
    89         // Bail if not using WordPress's admin bar or it's not showing on this
    90         // page request.
    91         if ( ! bp_use_wp_admin_bar() || ! is_admin_bar_showing() ) {
     84        // Bail if WordPress's admin bar is not showing on this page request.
     85        if ( ! is_admin_bar_showing() ) {
    9286                return;
    9387        }
  • trunk/src/bp-core/bp-core-dependency.php

    r13490 r13741  
    191191 */
    192192function bp_setup_admin_bar() {
    193         if ( bp_use_wp_admin_bar() ) {
    194 
    195                 /**
    196                  * Fires inside the 'bp_setup_admin_bar' function, where plugins should add items to the WP admin bar.
    197                  *
    198                  * This hook will only fire if bp_use_wp_admin_bar() returns true.
    199                  *
    200                  * @since 1.5.0
    201                  */
    202                 do_action( 'bp_setup_admin_bar', array() );
    203         }
     193        /**
     194         * Fires inside the 'bp_setup_admin_bar' function, where plugins should add items to the WP admin bar.
     195         *
     196         * @since 1.5.0
     197         */
     198        do_action( 'bp_setup_admin_bar', array() );
    204199}
    205200
  • trunk/src/bp-core/bp-core-functions.php

    r13718 r13741  
    498498         */
    499499        return apply_filters( 'bp_is_username_compatibility_mode', defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) && BP_ENABLE_USERNAME_COMPATIBILITY_MODE );
    500 }
    501 
    502 /**
    503  * Should we use the WP Toolbar?
    504  *
    505  * The WP Toolbar, introduced in WP 3.1, is fully supported in BuddyPress as
    506  * of BP 1.5. For BP 1.6, the WP Toolbar is the default.
    507  *
    508  * @since 1.5.0
    509  *
    510  * @return bool Default: true. False when WP Toolbar support is disabled.
    511  */
    512 function bp_use_wp_admin_bar() {
    513 
    514         // Default to true.
    515         $use_admin_bar = true;
    516 
    517         // Has the WP Toolbar constant been explicitly opted into?
    518         if ( defined( 'BP_USE_WP_ADMIN_BAR' ) ) {
    519                 $use_admin_bar = (bool) BP_USE_WP_ADMIN_BAR;
    520         }
    521 
    522         /**
    523          * Filters whether or not to use the admin bar.
    524          *
    525          * @since 1.5.0
    526          *
    527          * @param bool $use_admin_bar Whether or not to use the admin bar.
    528          */
    529         return (bool) apply_filters( 'bp_use_wp_admin_bar', $use_admin_bar );
    530500}
    531501
  • trunk/src/bp-core/classes/class-bp-component.php

    r13662 r13741  
    808808
    809809                // Bail if this is an ajax request.
    810                 if ( defined( 'DOING_AJAX' ) ) {
    811                         return;
    812                 }
    813 
    814                 // Do not proceed if BP_USE_WP_ADMIN_BAR constant is not set or is false.
    815                 if ( ! bp_use_wp_admin_bar() ) {
     810                if ( wp_doing_ajax() ) {
    816811                        return;
    817812                }
  • trunk/src/bp-core/deprecated/14.0.php

    r13718 r13741  
    3232        _deprecated_function( __FUNCTION__, '14.0.0' );
    3333}
     34
     35/**
     36 * Should we use the WP Toolbar?
     37 *
     38 * The WP Toolbar, introduced in WP 3.1, is fully supported in BuddyPress as
     39 * of BP 1.5. For BP 1.6, the WP Toolbar is the default.
     40 *
     41 * @since 1.5.0
     42 * @deprecated 14.0.0
     43 *
     44 * @return bool Default: true. False when WP Toolbar support is disabled.
     45 */
     46function bp_use_wp_admin_bar() {
     47        _deprecated_function( __FUNCTION__, '14.0.0' );
     48
     49        // Default to true.
     50        $use_admin_bar = true;
     51
     52        if ( defined( 'BP_USE_WP_ADMIN_BAR' ) ) {
     53                _doing_it_wrong( 'BP_USE_WP_ADMIN_BAR', esc_html__( 'The BP_USE_WP_ADMIN_BAR constant is deprecated.', 'buddypress' ), 'BuddyPress 14.0.0' );
     54        }
     55
     56        /**
     57         * Filters whether or not to use the admin bar.
     58         *
     59         * @since 1.5.0
     60         * @deprecated 14.0.0
     61         *
     62         * @param bool $use_admin_bar Whether or not to use the admin bar.
     63         */
     64        return apply_filters_deprecated( 'bp_use_wp_admin_bar', array( $use_admin_bar ), '14.0.0' );
     65}
Note: See TracChangeset for help on using the changeset viewer.