[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-core/ -> bp-core-adminbar.php (source)

   1  <?php
   2  /**
   3   * BuddyPress Core Toolbar.
   4   *
   5   * Handles the core functions related to the WordPress Toolbar.
   6   *
   7   * @package BuddyPress
   8   * @subpackage Core
   9   * @since 1.0.0
  10   */
  11  
  12  // Exit if accessed directly.
  13  defined( 'ABSPATH' ) || exit;
  14  
  15  /**
  16   * Add the secondary BuddyPress area to the my-account menu.
  17   *
  18   * @since 1.6.0
  19   *
  20   * @global WP_Admin_Bar $wp_admin_bar.
  21   */
  22  function bp_admin_bar_my_account_root() {
  23      global $wp_admin_bar;
  24  
  25      // Bail if this is an ajax request.
  26      if ( !bp_use_wp_admin_bar() || defined( 'DOING_AJAX' ) )
  27          return;
  28  
  29      // Only add menu for logged in user.
  30      if ( is_user_logged_in() ) {
  31  
  32          // Add secondary parent item for all BuddyPress components.
  33          $wp_admin_bar->add_node( array(
  34              'parent'    => 'my-account',
  35              'id'        => 'my-account-buddypress',
  36              'title'     => __( 'My Account', 'buddypress' ),
  37              'group'     => true,
  38              'meta'      => array(
  39                  'class' => 'ab-sub-secondary'
  40              )
  41          ) );
  42      }
  43  }
  44  add_action( 'admin_bar_menu', 'bp_admin_bar_my_account_root', 100 );
  45  
  46  /**
  47   * Toggle the display of the toolbar based on certain conditions.
  48   *
  49   * @since 1.2.0
  50   */
  51  function bp_core_load_admin_bar() {
  52      // Show the Toolbar for logged out users.
  53      if ( ! is_user_logged_in() && (int) bp_get_option( 'hide-loggedout-adminbar' ) != 1 ) {
  54          show_admin_bar( true );
  55      }
  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      }
  62  }
  63  add_action( 'init', 'bp_core_load_admin_bar', 9 );
  64  
  65  /**
  66   * Handle the enqueueing of toolbar CSS.
  67   *
  68   * This function exists mostly for backwards compatibility reasons, so anyone
  69   * previously unhooking this function can continue to do so. It's hooked to
  70   * the `bp_init` action in `bp-core-actions.php`.
  71   *
  72   * @since 1.5.0
  73   */
  74  function bp_core_load_admin_bar_css() {
  75      add_action( 'bp_enqueue_scripts',       'bp_core_enqueue_admin_bar_css', 1 );
  76      add_action( 'bp_admin_enqueue_scripts', 'bp_core_enqueue_admin_bar_css', 1 );
  77  }
  78  
  79  /**
  80   * Enqueue supplemental WordPress Toolbar styling.
  81   *
  82   * @since 2.1.0
  83   *
  84   * @see bp_core_register_common_styles()
  85   * @see bp_core_load_admin_bar_css()
  86   */
  87  function bp_core_enqueue_admin_bar_css() {
  88  
  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() ) {
  92          return;
  93      }
  94  
  95      // Enqueue the additional adminbar css.
  96      wp_enqueue_style( 'bp-admin-bar' );
  97  }


Generated: Thu Nov 21 01:00:57 2024 Cross-referenced by PHPXref 0.7.1