/bp-core/admin/bp-core-admin-actions.php

  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( 'wpmu_new_blog', '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. /** 
  63. * When a new site is created in a multisite installation, run the activation 
  64. * routine on that site. 
  65. * 
  66. * @since 1.7.0 
  67. * 
  68. * @param int $blog_id ID of the blog being installed to. 
  69. * @param int $user_id ID of the user the install is for. 
  70. * @param string $domain Domain to use with the install. 
  71. * @param string $path Path to use with the install. 
  72. * @param int $site_id ID of the site being installed to. 
  73. * @param array $meta Metadata to use with the site creation. 
  74. */ 
  75. function bp_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { 
  76.  
  77. // Bail if plugin is not network activated. 
  78. if ( ! is_plugin_active_for_network( buddypress()->basename ) ) 
  79. return; 
  80.  
  81. // Switch to the new blog. 
  82. switch_to_blog( $blog_id ); 
  83.  
  84. /** 
  85. * Fires the activation routine for a new site created in a multisite installation. 
  86. * 
  87. * @since 1.7.0 
  88. * 
  89. * @param int $blog_id ID of the blog being installed to. 
  90. * @param int $user_id ID of the user the install is for. 
  91. * @param string $domain Domain to use with the install. 
  92. * @param string $path Path to use with the install. 
  93. * @param int $site_id ID of the site being installed to. 
  94. * @param array $meta Metadata to use with the site creation. 
  95. */ 
  96. do_action( 'bp_new_site', $blog_id, $user_id, $domain, $path, $site_id, $meta ); 
  97.  
  98. // Restore original blog. 
  99. restore_current_blog(); 
  100.  
  101. /** Sub-Actions ***************************************************************/ 
  102.  
  103. /** 
  104. * Piggy back admin_init action. 
  105. * 
  106. * @since 1.7.0 
  107. * 
  108. */ 
  109. function bp_admin_init() { 
  110.  
  111. /** 
  112. * Fires inside the bp_admin_init function. 
  113. * 
  114. * @since 1.6.0 
  115. */ 
  116. do_action( 'bp_admin_init' ); 
  117.  
  118. /** 
  119. * Piggy back admin_menu action. 
  120. * 
  121. * @since 1.7.0 
  122. * 
  123. */ 
  124. function bp_admin_menu() { 
  125.  
  126. /** 
  127. * Fires inside the bp_admin_menu function. 
  128. * 
  129. * @since 1.7.0 
  130. */ 
  131. do_action( 'bp_admin_menu' ); 
  132.  
  133. /** 
  134. * Piggy back admin_head action. 
  135. * 
  136. * @since 1.7.0 
  137. * 
  138. */ 
  139. function bp_admin_head() { 
  140.  
  141. /** 
  142. * Fires inside the bp_admin_head function. 
  143. * 
  144. * @since 1.6.0 
  145. */ 
  146. do_action( 'bp_admin_head' ); 
  147.  
  148. /** 
  149. * Piggy back admin_notices action. 
  150. * 
  151. * @since 1.7.0 
  152. * 
  153. */ 
  154. function bp_admin_notices() { 
  155.  
  156. /** 
  157. * Fires inside the bp_admin_notices function. 
  158. * 
  159. * @since 1.5.0 
  160. */ 
  161. do_action( 'bp_admin_notices' ); 
  162.  
  163. /** 
  164. * Piggy back admin_enqueue_scripts action. 
  165. * 
  166. * @since 1.7.0 
  167. * 
  168. * @param string $hook_suffix The current admin page, passed to 
  169. * 'admin_enqueue_scripts'. 
  170. */ 
  171. function bp_admin_enqueue_scripts( $hook_suffix = '' ) { 
  172.  
  173. /** 
  174. * Fires inside the bp_admin_enqueue_scripts function. 
  175. * 
  176. * @since 1.7.0 
  177. * 
  178. * @param string $hook_suffix The current admin page, passed to admin_enqueue_scripts. 
  179. */ 
  180. do_action( 'bp_admin_enqueue_scripts', $hook_suffix ); 
  181.  
  182. /** 
  183. * Dedicated action to register BuddyPress importers. 
  184. * 
  185. * @since 1.7.0 
  186. * 
  187. */ 
  188. function bp_register_importers() { 
  189.  
  190. /** 
  191. * Fires inside the bp_register_importers function. 
  192. * 
  193. * Used to register a BuddyPress importer. 
  194. * 
  195. * @since 1.7.0 
  196. */ 
  197. do_action( 'bp_register_importers' ); 
  198.  
  199. /** 
  200. * Dedicated action to register admin styles. 
  201. * 
  202. * @since 1.7.0 
  203. * 
  204. */ 
  205. function bp_register_admin_style() { 
  206.  
  207. /** 
  208. * Fires inside the bp_register_admin_style function. 
  209. * 
  210. * @since 1.7.0 
  211. */ 
  212. do_action( 'bp_register_admin_style' ); 
  213.  
  214. /** 
  215. * Dedicated action to register admin settings. 
  216. * 
  217. * @since 1.7.0 
  218. * 
  219. */ 
  220. function bp_register_admin_settings() { 
  221.  
  222. /** 
  223. * Fires inside the bp_register_admin_settings function. 
  224. * 
  225. * @since 1.6.0 
  226. */ 
  227. do_action( 'bp_register_admin_settings' ); 
.