/includes/admin/actions.php

  1. <?php 
  2.  
  3. /** 
  4. * bbPress Admin Actions 
  5. * 
  6. * @package bbPress 
  7. * @subpackage Admin 
  8. * 
  9. * This file contains the actions that are used through-out bbPress Admin. They 
  10. * are consolidated here to make searching for them easier, and to help developers 
  11. * understand at a glance the order in which things occur. 
  12. * 
  13. * There are a few common places that additional actions can currently be found 
  14. * 
  15. * - bbPress: In {@link bbPress::setup_actions()} in bbpress.php 
  16. * - Admin: More in {@link BBP_Admin::setup_actions()} in admin.php 
  17. * 
  18. * @see bbp-core-actions.php 
  19. * @see bbp-core-filters.php 
  20. */ 
  21.  
  22. // Exit if accessed directly 
  23. if ( !defined( 'ABSPATH' ) ) exit; 
  24.  
  25. /** 
  26. * Attach bbPress to WordPress 
  27. * 
  28. * bbPress uses its own internal actions to help aid in third-party plugin 
  29. * development, and to limit the amount of potential future code changes when 
  30. * updates to WordPress core occur. 
  31. * 
  32. * These actions exist to create the concept of 'plugin dependencies'. They 
  33. * provide a safe way for plugins to execute code *only* when bbPress is 
  34. * installed and activated, without needing to do complicated guesswork. 
  35. * 
  36. * For more information on how this works, see the 'Plugin Dependency' section 
  37. * near the bottom of this file. 
  38. * 
  39. * v--WordPress Actions v--bbPress Sub-actions 
  40. */ 
  41. add_action( 'admin_menu', 'bbp_admin_menu' ); 
  42. add_action( 'admin_init', 'bbp_admin_init' ); 
  43. add_action( 'admin_head', 'bbp_admin_head' ); 
  44. add_action( 'admin_notices', 'bbp_admin_notices' ); 
  45. add_action( 'custom_menu_order', 'bbp_admin_custom_menu_order' ); 
  46. add_action( 'menu_order', 'bbp_admin_menu_order' ); 
  47. add_action( 'wpmu_new_blog', 'bbp_new_site', 10, 6 ); 
  48.  
  49. // Hook on to admin_init 
  50. add_action( 'bbp_admin_init', 'bbp_admin_forums' ); 
  51. add_action( 'bbp_admin_init', 'bbp_admin_topics' ); 
  52. add_action( 'bbp_admin_init', 'bbp_admin_replies' ); 
  53. add_action( 'bbp_admin_init', 'bbp_setup_updater', 999 ); 
  54. add_action( 'bbp_admin_init', 'bbp_register_importers' ); 
  55. add_action( 'bbp_admin_init', 'bbp_register_admin_style' ); 
  56. add_action( 'bbp_admin_init', 'bbp_register_admin_settings' ); 
  57. add_action( 'bbp_admin_init', 'bbp_do_activation_redirect', 1 ); 
  58.  
  59. // Initialize the admin area 
  60. add_action( 'bbp_init', 'bbp_admin' ); 
  61.  
  62. // Reset the menu order 
  63. add_action( 'bbp_admin_menu', 'bbp_admin_separator' ); 
  64.  
  65. // Activation 
  66. add_action( 'bbp_activation', 'bbp_delete_rewrite_rules' ); 
  67. add_action( 'bbp_activation', 'bbp_make_current_user_keymaster' ); 
  68.  
  69. // Deactivation 
  70. add_action( 'bbp_deactivation', 'bbp_remove_caps' ); 
  71. add_action( 'bbp_deactivation', 'bbp_delete_rewrite_rules' ); 
  72.  
  73. // New Site 
  74. add_action( 'bbp_new_site', 'bbp_create_initial_content', 8 ); 
  75.  
  76. // Contextual Helpers 
  77. add_action( 'load-settings_page_bbpress', 'bbp_admin_settings_help' ); 
  78.  
  79. // Handle submission of Tools pages 
  80. add_action( 'load-tools_page_bbp-repair', 'bbp_admin_repair_handler' ); 
  81. add_action( 'load-tools_page_bbp-reset', 'bbp_admin_reset_handler' ); 
  82.  
  83. // Add sample permalink filter 
  84. add_filter( 'post_type_link', 'bbp_filter_sample_permalink', 10, 4 ); 
  85.  
  86. /** 
  87. * When a new site is created in a multisite installation, run the activation 
  88. * routine on that site 
  89. * 
  90. * @since bbPress (r3283) 
  91. * 
  92. * @param int $blog_id 
  93. * @param int $user_id 
  94. * @param string $domain 
  95. * @param string $path 
  96. * @param int $site_id 
  97. * @param array() $meta 
  98. */ 
  99. function bbp_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { 
  100.  
  101. // Bail if plugin is not network activated 
  102. if ( ! is_plugin_active_for_network( bbpress()->basename ) ) 
  103. return; 
  104.  
  105. // Switch to the new blog 
  106. switch_to_blog( $blog_id ); 
  107.  
  108. // Do the bbPress activation routine 
  109. do_action( 'bbp_new_site', $blog_id, $user_id, $domain, $path, $site_id, $meta ); 
  110.  
  111. // restore original blog 
  112. restore_current_blog(); 
  113.  
  114. /** Sub-Actions ***************************************************************/ 
  115.  
  116. /** 
  117. * Piggy back admin_init action 
  118. * 
  119. * @since bbPress (r3766) 
  120. * @uses do_action() Calls 'bbp_admin_init' 
  121. */ 
  122. function bbp_admin_init() { 
  123. do_action( 'bbp_admin_init' ); 
  124.  
  125. /** 
  126. * Piggy back admin_menu action 
  127. * 
  128. * @since bbPress (r3766) 
  129. * @uses do_action() Calls 'bbp_admin_menu' 
  130. */ 
  131. function bbp_admin_menu() { 
  132. do_action( 'bbp_admin_menu' ); 
  133.  
  134. /** 
  135. * Piggy back admin_head action 
  136. * 
  137. * @since bbPress (r3766) 
  138. * @uses do_action() Calls 'bbp_admin_head' 
  139. */ 
  140. function bbp_admin_head() { 
  141. do_action( 'bbp_admin_head' ); 
  142.  
  143. /** 
  144. * Piggy back admin_notices action 
  145. * 
  146. * @since bbPress (r3766) 
  147. * @uses do_action() Calls 'bbp_admin_notices' 
  148. */ 
  149. function bbp_admin_notices() { 
  150. do_action( 'bbp_admin_notices' ); 
  151.  
  152. /** 
  153. * Dedicated action to register bbPress importers 
  154. * 
  155. * @since bbPress (r3766) 
  156. * @uses do_action() Calls 'bbp_admin_notices' 
  157. */ 
  158. function bbp_register_importers() { 
  159. do_action( 'bbp_register_importers' ); 
  160.  
  161. /** 
  162. * Dedicated action to register admin styles 
  163. * 
  164. * @since bbPress (r3766) 
  165. * @uses do_action() Calls 'bbp_admin_notices' 
  166. */ 
  167. function bbp_register_admin_style() { 
  168. do_action( 'bbp_register_admin_style' ); 
  169.  
  170. /** 
  171. * Dedicated action to register admin settings 
  172. * 
  173. * @since bbPress (r3766) 
  174. * @uses do_action() Calls 'bbp_register_admin_settings' 
  175. */ 
  176. function bbp_register_admin_settings() { 
  177. do_action( 'bbp_register_admin_settings' ); 
.