[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-core/admin/ -> bp-core-admin-actions.php (source)

   1  <?php
   2  /**
   3   * BuddyPress Admin Actions.
   4   *
   5   * This file contains the actions that are used through-out BuddyPress Admin. They
   6   * are consolidated here to make searching for them easier, and to help developers
   7   * understand at a glance the order in which things occur.
   8   *
   9   * There are a few common places that additional actions can currently be found.
  10   *
  11   *  - BuddyPress: In {@link BuddyPress::setup_actions()} in BuddyPress.php
  12   *  - Admin: More in {@link bp_Admin::setup_actions()} in admin.php
  13   *
  14   * @package BuddyPress
  15   * @subpackage Admin
  16   * @since 2.3.0
  17   * @see bp-core-actions.php
  18   * @see bp-core-filters.php
  19   */
  20  
  21  // Exit if accessed directly.
  22  defined( 'ABSPATH' ) || exit;
  23  
  24  /**
  25   * Attach BuddyPress to WordPress.
  26   *
  27   * BuddyPress uses its own internal actions to help aid in third-party plugin
  28   * development, and to limit the amount of potential future code changes when
  29   * updates to WordPress core occur.
  30   *
  31   * These actions exist to create the concept of 'plugin dependencies'. They
  32   * provide a safe way for plugins to execute code *only* when BuddyPress is
  33   * installed and activated, without needing to do complicated guesswork.
  34   *
  35   * For more information on how this works, see the 'Plugin Dependency' section
  36   * near the bottom of this file.
  37   *
  38   *          v--WordPress Actions       v--BuddyPress Sub-actions
  39   */
  40  add_action( 'admin_menu',                         'bp_admin_menu'                    );
  41  add_action( 'admin_init',                         'bp_admin_init'                    );
  42  add_action( 'admin_head',                         'bp_admin_head'                    );
  43  add_action( 'admin_notices',                      'bp_admin_notices'                 );
  44  add_action( 'admin_enqueue_scripts',              'bp_admin_enqueue_scripts'         );
  45  add_action( 'customize_controls_enqueue_scripts', 'bp_admin_enqueue_scripts', 8      );
  46  add_action( 'network_admin_menu',                 'bp_admin_menu'                    );
  47  add_action( 'custom_menu_order',                  'bp_admin_custom_menu_order'       );
  48  add_action( 'menu_order',                         'bp_admin_menu_order'              );
  49  add_action( 'bp_insert_site',                     'bp_new_site',               10, 6 );
  50  
  51  // Hook on to admin_init.
  52  add_action( 'bp_admin_init', 'bp_setup_updater',          1000 );
  53  add_action( 'bp_admin_init', 'bp_core_activation_notice', 1010 );
  54  add_action( 'bp_admin_init', 'bp_register_importers'           );
  55  add_action( 'bp_admin_init', 'bp_register_admin_style'         );
  56  add_action( 'bp_admin_init', 'bp_register_admin_settings'      );
  57  add_action( 'bp_admin_init', 'bp_do_activation_redirect', 1    );
  58  
  59  // Add a new separator.
  60  add_action( 'bp_admin_menu', 'bp_admin_separator' );
  61  
  62  // Add a filter to include BP Components directory pages display states.
  63  add_filter( 'display_post_states', 'bp_admin_display_directory_states', 10, 2 );
  64  
  65  /**
  66   * When a new site is created in a multisite installation, run the activation
  67   * routine on that site.
  68   *
  69   * @since 1.7.0
  70   *
  71   * @param int    $blog_id ID of the blog being installed to.
  72   * @param int    $user_id ID of the user the install is for.
  73   * @param string $domain  Domain to use with the install.
  74   * @param string $path    Path to use with the install.
  75   * @param int    $site_id ID of the site being installed to.
  76   * @param array  $meta    Metadata to use with the site creation.
  77   */
  78  function bp_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
  79  
  80      // Bail if plugin is not network activated.
  81      if ( ! is_plugin_active_for_network( buddypress()->basename ) )
  82          return;
  83  
  84      // Switch to the new blog.
  85      switch_to_blog( $blog_id );
  86  
  87      /**
  88       * Fires the activation routine for a new site created in a multisite installation.
  89       *
  90       * @since 1.7.0
  91       *
  92       * @param int    $blog_id ID of the blog being installed to.
  93       * @param int    $user_id ID of the user the install is for.
  94       * @param string $domain  Domain to use with the install.
  95       * @param string $path    Path to use with the install.
  96       * @param int    $site_id ID of the site being installed to.
  97       * @param array  $meta    Metadata to use with the site creation.
  98       */
  99      do_action( 'bp_new_site', $blog_id, $user_id, $domain, $path, $site_id, $meta );
 100  
 101      // Restore original blog.
 102      restore_current_blog();
 103  }
 104  
 105  /** Sub-Actions ***************************************************************/
 106  
 107  /**
 108   * Piggy back admin_init action.
 109   *
 110   * @since 1.7.0
 111   *
 112   */
 113  function bp_admin_init() {
 114  
 115      /**
 116       * Fires inside the bp_admin_init function.
 117       *
 118       * @since 1.6.0
 119       */
 120      do_action( 'bp_admin_init' );
 121  }
 122  
 123  /**
 124   * Piggy back admin_menu action.
 125   *
 126   * @since 1.7.0
 127   *
 128   */
 129  function bp_admin_menu() {
 130  
 131      /**
 132       * Fires inside the bp_admin_menu function.
 133       *
 134       * @since 1.7.0
 135       */
 136      do_action( 'bp_admin_menu' );
 137  }
 138  
 139  /**
 140   * Piggy back admin_head action.
 141   *
 142   * @since 1.7.0
 143   *
 144   */
 145  function bp_admin_head() {
 146  
 147      /**
 148       * Fires inside the bp_admin_head function.
 149       *
 150       * @since 1.6.0
 151       */
 152      do_action( 'bp_admin_head' );
 153  }
 154  
 155  /**
 156   * Piggy back admin_notices action.
 157   *
 158   * @since 1.7.0
 159   *
 160   */
 161  function bp_admin_notices() {
 162  
 163      /**
 164       * Fires inside the bp_admin_notices function.
 165       *
 166       * @since 1.5.0
 167       */
 168      do_action( 'bp_admin_notices' );
 169  }
 170  
 171  /**
 172   * Piggy back admin_enqueue_scripts action.
 173   *
 174   * @since 1.7.0
 175   *
 176   * @param string $hook_suffix The current admin page, passed to
 177   *                            'admin_enqueue_scripts'.
 178   */
 179  function bp_admin_enqueue_scripts( $hook_suffix = '' ) {
 180  
 181      /**
 182       * Fires inside the bp_admin_enqueue_scripts function.
 183       *
 184       * @since 1.7.0
 185       *
 186       * @param string $hook_suffix The current admin page, passed to admin_enqueue_scripts.
 187       */
 188      do_action( 'bp_admin_enqueue_scripts', $hook_suffix );
 189  }
 190  
 191  /**
 192   * Dedicated action to register BuddyPress importers.
 193   *
 194   * @since 1.7.0
 195   *
 196   */
 197  function bp_register_importers() {
 198  
 199      /**
 200       * Fires inside the bp_register_importers function.
 201       *
 202       * Used to register a BuddyPress importer.
 203       *
 204       * @since 1.7.0
 205       */
 206      do_action( 'bp_register_importers' );
 207  }
 208  
 209  /**
 210   * Dedicated action to register admin styles.
 211   *
 212   * @since 1.7.0
 213   *
 214   */
 215  function bp_register_admin_style() {
 216  
 217      /**
 218       * Fires inside the bp_register_admin_style function.
 219       *
 220       * @since 1.7.0
 221       */
 222      do_action( 'bp_register_admin_style' );
 223  }
 224  
 225  /**
 226   * Dedicated action to register admin settings.
 227   *
 228   * @since 1.7.0
 229   *
 230   */
 231  function bp_register_admin_settings() {
 232  
 233      /**
 234       * Fires inside the bp_register_admin_settings function.
 235       *
 236       * @since 1.6.0
 237       */
 238      do_action( 'bp_register_admin_settings' );
 239  }
 240  
 241  /**
 242   * Dedicated filter to inform about BP components directory page states.
 243   *
 244   * @since 10.0.0
 245   *
 246   * @param string[] $post_states An array of post display states.
 247   * @param WP_Post  $post        The current post object.
 248   */
 249  function bp_admin_display_directory_states( $post_states = array(), $post = null ) {
 250      /**
 251       * Filter here to add BP Directory pages.
 252       *
 253       * Used internaly by BP_Component->admin_directory_states(). Please use the dynamic
 254       * filter in BP_Component->admin_directory_states() to edit the directory state
 255       * according to the component's ID.
 256       *
 257       * @since 10.0.0
 258       *
 259       * @param array    $value An empty array.
 260       * @param WP_Post  $post  The current post object.
 261       */
 262      $directory_page_states = apply_filters( 'bp_admin_display_directory_states', array(), $post );
 263  
 264      if ( $directory_page_states ) {
 265          $post_states = array_merge( $post_states, $directory_page_states );
 266      }
 267  
 268      return $post_states;
 269  }


Generated: Wed Nov 6 01:00:56 2024 Cross-referenced by PHPXref 0.7.1