| 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 |
| 17 |
* bbp-admin/bbp-admin.php |
| 18 |
* |
| 19 |
* @see bbp-core-actions.php |
| 20 |
* @see bbp-core-filters.php |
| 21 |
*/ |
| 22 |
|
| 23 |
// Exit if accessed directly |
| 24 |
if ( !defined( 'ABSPATH' ) ) exit; |
| 25 |
|
| 26 |
/** |
| 27 |
* Attach bbPress to WordPress |
| 28 |
* |
| 29 |
* bbPress uses its own internal actions to help aid in third-party plugin |
| 30 |
* development, and to limit the amount of potential future code changes when |
| 31 |
* updates to WordPress core occur. |
| 32 |
* |
| 33 |
* These actions exist to create the concept of 'plugin dependencies'. They |
| 34 |
* provide a safe way for plugins to execute code *only* when bbPress is |
| 35 |
* installed and activated, without needing to do complicated guesswork. |
| 36 |
* |
| 37 |
* For more information on how this works, see the 'Plugin Dependency' section |
| 38 |
* near the bottom of this file. |
| 39 |
* |
| 40 |
* v--WordPress Actions v--bbPress Sub-actions |
| 41 |
*/ |
| 42 |
add_action( 'admin_menu', 'bbp_admin_menu' ); |
| 43 |
add_action( 'admin_init', 'bbp_admin_init' ); |
| 44 |
add_action( 'admin_head', 'bbp_admin_head' ); |
| 45 |
add_action( 'admin_notices', 'bbp_admin_notices' ); |
| 46 |
add_action( 'custom_menu_order', 'bbp_admin_custom_menu_order' ); |
| 47 |
add_action( 'menu_order', 'bbp_admin_menu_order' ); |
| 48 |
add_action( 'wpmu_new_blog', 'bbp_new_site', 10, 6 ); |
| 49 |
|
| 50 |
// Hook on to admin_init |
| 51 |
add_action( 'bbp_admin_init', 'bbp_admin_forums' ); |
| 52 |
add_action( 'bbp_admin_init', 'bbp_admin_topics' ); |
| 53 |
add_action( 'bbp_admin_init', 'bbp_admin_replies' ); |
| 54 |
add_action( 'bbp_admin_init', 'bbp_setup_updater', 999 ); |
| 55 |
add_action( 'bbp_admin_init', 'bbp_register_importers' ); |
| 56 |
add_action( 'bbp_admin_init', 'bbp_register_admin_style' ); |
| 57 |
add_action( 'bbp_admin_init', 'bbp_register_admin_settings' ); |
| 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_add_roles', 1 ); |
| 67 |
add_action( 'bbp_activation', 'bbp_add_caps', 2 ); |
| 68 |
add_action( 'bbp_activation', 'bbp_add_options', 1 ); |
| 69 |
add_action( 'bbp_activation', 'flush_rewrite_rules' ); |
| 70 |
|
| 71 |
// Deactivation |
| 72 |
add_action( 'bbp_deactivation', 'bbp_remove_caps', 1 ); |
| 73 |
add_action( 'bbp_deactivation', 'bbp_remove_roles', 2 ); |
| 74 |
add_action( 'bbp_deactivation', 'flush_rewrite_rules' ); |
| 75 |
|
| 76 |
// |
| 77 |
add_action( 'bbp_new_site', 'bbp_add_roles', 2 ); |
| 78 |
add_action( 'bbp_new_site', 'bbp_add_caps', 4 ); |
| 79 |
add_action( 'bbp_new_site', 'bbp_add_options', 6 ); |
| 80 |
add_action( 'bbp_new_site', 'bbp_create_initial_content', 8 ); |
| 81 |
add_action( 'bbp_new_site', 'flush_rewrite_rules' ); |
| 82 |
|
| 83 |
// Contextual Helpers |
| 84 |
add_action( 'load-settings_page_bbpress', 'bbp_admin_settings_help' ); |
| 85 |
|
| 86 |
// Handle submission of Tools pages |
| 87 |
add_action( 'load-tools_page_bbp-repair', 'bbp_admin_repair_handler' ); |
| 88 |
add_action( 'load-tools_page_bbp-reset', 'bbp_admin_reset_handler' ); |
| 89 |
|
| 90 |
// Add sample permalink filter |
| 91 |
add_filter( 'post_type_link', 'bbp_filter_sample_permalink', 10, 4 ); |
| 92 |
|
| 93 |
/** |
| 94 |
* When a new site is created in a multisite installation, run the activation |
| 95 |
* routine on that site |
| 96 |
* |
| 97 |
* @since bbPress (r3283) |
| 98 |
* |
| 99 |
* @param int $blog_id |
| 100 |
* @param int $user_id |
| 101 |
* @param string $domain |
| 102 |
* @param string $path |
| 103 |
* @param int $site_id |
| 104 |
* @param array() $meta |
| 105 |
*/ |
| 106 |
function bbp_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
| 107 |
|
| 108 |
// Switch to the new blog |
| 109 |
switch_to_blog( $blog_id ); |
| 110 |
|
| 111 |
// Do the bbPress activation routine |
| 112 |
do_action( 'bbp_new_site' ); |
| 113 |
|
| 114 |
// restore original blog |
| 115 |
restore_current_blog(); |
| 116 |
} |
| 117 |
|
| 118 |
/** Sub-Actions ***************************************************************/ |
| 119 |
|
| 120 |
/** |
| 121 |
* Piggy back admin_init action |
| 122 |
* |
| 123 |
* @since bbPress (r3766) |
| 124 |
* @uses do_action() Calls 'bbp_admin_init' |
| 125 |
*/ |
| 126 |
function bbp_admin_init() { |
| 127 |
do_action( 'bbp_admin_init' ); |
| 128 |
} |
| 129 |
|
| 130 |
/** |
| 131 |
* Piggy back admin_menu action |
| 132 |
* |
| 133 |
* @since bbPress (r3766) |
| 134 |
* @uses do_action() Calls 'bbp_admin_menu' |
| 135 |
*/ |
| 136 |
function bbp_admin_menu() { |
| 137 |
do_action( 'bbp_admin_menu' ); |
| 138 |
} |
| 139 |
|
| 140 |
/** |
| 141 |
* Piggy back admin_head action |
| 142 |
* |
| 143 |
* @since bbPress (r3766) |
| 144 |
* @uses do_action() Calls 'bbp_admin_head' |
| 145 |
*/ |
| 146 |
function bbp_admin_head() { |
| 147 |
do_action( 'bbp_admin_head' ); |
| 148 |
} |
| 149 |
|
| 150 |
/** |
| 151 |
* Piggy back admin_notices action |
| 152 |
* |
| 153 |
* @since bbPress (r3766) |
| 154 |
* @uses do_action() Calls 'bbp_admin_notices' |
| 155 |
*/ |
| 156 |
function bbp_admin_notices() { |
| 157 |
do_action( 'bbp_admin_notices' ); |
| 158 |
} |
| 159 |
|
| 160 |
/** |
| 161 |
* Dedicated action to register bbPress importers |
| 162 |
* |
| 163 |
* @since bbPress (r3766) |
| 164 |
* @uses do_action() Calls 'bbp_admin_notices' |
| 165 |
*/ |
| 166 |
function bbp_register_importers() { |
| 167 |
do_action( 'bbp_register_importers' ); |
| 168 |
} |
| 169 |
|
| 170 |
/** |
| 171 |
* Dedicated action to register admin styles |
| 172 |
* |
| 173 |
* @since bbPress (r3766) |
| 174 |
* @uses do_action() Calls 'bbp_admin_notices' |
| 175 |
*/ |
| 176 |
function bbp_register_admin_style() { |
| 177 |
do_action( 'bbp_register_admin_style' ); |
| 178 |
} |
| 179 |
|
| 180 |
/** |
| 181 |
* Dedicated action to register admin settings |
| 182 |
* |
| 183 |
* @since bbPress (r3766) |
| 184 |
* @uses do_action() Calls 'bbp_register_admin_settings' |
| 185 |
*/ |
| 186 |
function bbp_register_admin_settings() { |
| 187 |
do_action( 'bbp_register_admin_settings' ); |
| 188 |
} |
| 189 |
|