[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

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

   1  <?php
   2  /**
   3   * BuddyPress Activity Toolbar.
   4   *
   5   * Handles the activity functions related to the WordPress Toolbar.
   6   *
   7   * @package BuddyPress
   8   * @subpackage Activity
   9   */
  10  
  11  // Exit if accessed directly.
  12  defined( 'ABSPATH' ) || exit;
  13  
  14  /**
  15   * Add the Activity top-level menu link when viewing single activity item.
  16   *
  17   * @since 2.6.0
  18   *
  19   * @return null Null if user does not have access to editing functionality.
  20   */
  21  function bp_activity_admin_menu() {
  22      global $wp_admin_bar;
  23  
  24      // Only show if viewing a single activity item.
  25      if ( ! bp_is_single_activity() ) {
  26          return;
  27      }
  28  
  29      // Only show this menu to super admins.
  30      if ( ! bp_current_user_can( 'bp_moderate' ) ) {
  31          return;
  32      }
  33  
  34      $activity_edit_link = add_query_arg( array(
  35          'page' => 'bp-activity',
  36          'aid' => bp_current_action(),
  37          'action' => 'edit'
  38      ), bp_get_admin_url( 'admin.php' ) );
  39  
  40      // Add the top-level Edit Activity button.
  41      $wp_admin_bar->add_node( array(
  42          'id'    => 'activity-admin',
  43          'title' => __( 'Edit Activity', 'buddypress' ),
  44          'href'  => esc_url( $activity_edit_link ),
  45      ) );
  46  }
  47  add_action( 'admin_bar_menu', 'bp_activity_admin_menu', 99 );


Generated: Sat Dec 5 01:01:41 2020 Cross-referenced by PHPXref 0.7.1