PluginProbe
bbPress / 2.6.17
bbPress v2.6.17
2.6.17 trunk 2.0 2.0-beta-1 2.0-beta-2b 2.0-beta-3 2.0-beta-3b 2.0-rc-2 2.0-rc-3 2.0-rc-4 2.0-rc-5 2.0.1 2.0.2 2.0.3 2.1 2.1-beta-1 2.1-rc1 2.1-rc2 2.1-rc3 2.1-rc4 2.1.1 2.1.2 2.1.3 2.2 2.2.1 All 72 releases
← All changes | includes/admin/actions.php +199 -39 2.2.12.6.17 View file →
@@ -2,11 +2,8 @@
2 2
3 3 /**
4 4 * bbPress Admin Actions
5 5 *
6 - * @package bbPress
7 - * @subpackage Admin
8 - *
9 6 * This file contains the actions that are used through-out bbPress Admin. They
10 7 * are consolidated here to make searching for them easier, and to help developers
11 8 * understand at a glance the order in which things occur.
12 9 *
@@ -12,16 +9,19 @@
12 9 *
13 10 * There are a few common places that additional actions can currently be found
14 11 *
15 12 * - bbPress: In {@link bbPress::setup_actions()} in bbpress.php
16 - * - Admin: More in {@link BBP_Admin::setup_actions()} in admin.php
13 + * - Admin: More in {@link BBP_Admin::setup_actions()} in class-bbp-admin.php
17 14 *
15 + * @package bbPress
16 + * @subpackage Administration
17 + *
18 18 * @see bbp-core-actions.php
19 19 * @see bbp-core-filters.php
20 20 */
21 21
22 22 // Exit if accessed directly
23 -if ( !defined( 'ABSPATH' ) ) exit;
23 +defined( 'ABSPATH' ) || exit;
24 24
25 25 /**
26 26 * Attach bbPress to WordPress
27 27 *
@@ -37,34 +37,44 @@
37 37 * near the bottom of this file.
38 38 *
39 39 * v--WordPress Actions v--bbPress Sub-actions
40 40 */
41 +add_action( 'wpmu_new_blog', 'bbp_new_site', 10, 6 );
42 +add_action( 'current_screen', 'bbp_current_screen' );
43 +add_action( 'tool_box', 'bbp_admin_tool_box' );
41 44 add_action( 'admin_menu', 'bbp_admin_menu' );
42 45 add_action( 'admin_init', 'bbp_admin_init' );
43 46 add_action( 'admin_head', 'bbp_admin_head' );
44 47 add_action( 'admin_notices', 'bbp_admin_notices' );
45 -add_action( 'custom_menu_order', 'bbp_admin_custom_menu_order' );
46 48 add_action( 'menu_order', 'bbp_admin_menu_order' );
47 -add_action( 'wpmu_new_blog', 'bbp_new_site', 10, 6 );
49 +add_filter( 'custom_menu_order', 'bbp_admin_custom_menu_order' );
48 50
49 51 // 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 52 add_action( 'bbp_admin_init', 'bbp_setup_updater', 999 );
54 53 add_action( 'bbp_admin_init', 'bbp_register_importers' );
55 -add_action( 'bbp_admin_init', 'bbp_register_admin_style' );
54 +add_action( 'bbp_admin_init', 'bbp_register_admin_styles' );
55 +add_action( 'bbp_admin_init', 'bbp_register_admin_scripts' );
56 56 add_action( 'bbp_admin_init', 'bbp_register_admin_settings' );
57 -add_action( 'bbp_admin_init', 'bbp_do_activation_redirect', 1 );
58 57
58 +// Hook on to current_screen (only in Site admin, not Network or User)
59 +if ( is_blog_admin() ) {
60 + add_action( 'bbp_current_screen', 'bbp_admin_forums' );
61 + add_action( 'bbp_current_screen', 'bbp_admin_topics' );
62 + add_action( 'bbp_current_screen', 'bbp_admin_replies' );
63 +}
64 +
59 65 // Initialize the admin area
60 -add_action( 'bbp_init', 'bbp_admin' );
66 +add_action( 'bbp_init', 'bbp_setup_admin' );
61 67
62 68 // Reset the menu order
63 69 add_action( 'bbp_admin_menu', 'bbp_admin_separator' );
64 70
65 71 // Activation
66 -add_action( 'bbp_activation', 'bbp_delete_rewrite_rules' );
72 +add_action( 'bbp_activation', 'bbp_setup_new_site' );
73 +add_action( 'bbp_activation', 'bbp_add_activation_redirect' );
74 +add_action( 'bbp_activation', 'bbp_delete_rewrite_rules' );
75 +add_action( 'bbp_activation', 'bbp_make_current_user_keymaster' );
76 +add_action( 'load-plugins.php', 'bbp_do_activation_redirect' );
67 77
68 78 // Deactivation
69 79 add_action( 'bbp_deactivation', 'bbp_remove_caps' );
70 80 add_action( 'bbp_deactivation', 'bbp_delete_rewrite_rules' );
@@ -69,25 +79,60 @@
69 79 add_action( 'bbp_deactivation', 'bbp_remove_caps' );
70 80 add_action( 'bbp_deactivation', 'bbp_delete_rewrite_rules' );
71 81
72 82 // New Site
73 -add_action( 'bbp_new_site', 'bbp_create_initial_content', 8 );
83 +add_action( 'bbp_new_site', 'bbp_setup_new_site', 8 );
74 84
85 +// Load the default repair tools
86 +add_action( 'load-tools_page_bbp-repair', 'bbp_register_default_repair_tools' );
87 +add_action( 'load-tools_page_bbp-upgrade', 'bbp_register_default_repair_tools' );
88 +
75 89 // Contextual Helpers
76 -add_action( 'load-settings_page_bbpress', 'bbp_admin_settings_help' );
90 +add_action( 'load-settings_page_bbpress', 'bbp_admin_settings_help' );
91 +add_action( 'load-tools_page_bbp-repair', 'bbp_admin_tools_repair_help' );
92 +add_action( 'load-tools_page_bbp-upgrade', 'bbp_admin_tools_repair_help' );
93 +add_action( 'load-tools_page_bbp-converter', 'bbp_admin_tools_converter_help' );
94 +add_action( 'load-tools_page_bbp-reset', 'bbp_admin_tools_reset_help' );
77 95
78 96 // Handle submission of Tools pages
79 -add_action( 'load-tools_page_bbp-repair', 'bbp_admin_repair_handler' );
80 -add_action( 'load-tools_page_bbp-reset', 'bbp_admin_reset_handler' );
97 +add_action( 'load-tools_page_bbp-repair', 'bbp_admin_repair_handler' );
98 +add_action( 'load-tools_page_bbp-upgrade', 'bbp_admin_repair_handler' );
99 +add_action( 'load-tools_page_bbp-reset', 'bbp_admin_reset_handler' );
100 +add_action( 'bbp_admin_tool_box', 'bbp_admin_tools_box' );
81 101
82 102 // Add sample permalink filter
83 103 add_filter( 'post_type_link', 'bbp_filter_sample_permalink', 10, 4 );
84 104
105 +// Add quick stats to dashboard glance elements
106 +add_filter( 'dashboard_glance_items', 'bbp_filter_dashboard_glance_items', -99 );
107 +
108 +// Maybe use icons for column headers
109 +add_filter( 'bbp_admin_forums_column_headers', 'bbp_filter_column_headers' );
110 +add_filter( 'bbp_admin_topics_column_headers', 'bbp_filter_column_headers' );
111 +add_filter( 'bbp_admin_replies_column_headers', 'bbp_filter_column_headers' );
112 +
113 +// Load the converter early (page and AJAX)
114 +add_action( 'load-tools_page_bbp-converter', 'bbp_setup_converter', 2 );
115 +add_action( 'wp_ajax_bbp_converter_process', 'bbp_setup_converter', 2 );
116 +
117 +// Add New User
118 +add_action( 'user_new_form', 'bbp_add_user_form_role_field', 10, 1 );
119 +
85 120 /**
121 + * Setup bbPress admin
122 + *
123 + * @since 2.0.0 bbPress (r1000)
124 + * @since 2.6.0 bbPress (r6598) Moved to actions.php
125 + */
126 +function bbp_admin() {
127 + return bbp_setup_admin();
128 +}
129 +
130 +/**
86 131 * When a new site is created in a multisite installation, run the activation
87 132 * routine on that site
88 133 *
89 - * @since bbPress (r3283)
134 + * @since 2.0.0 bbPress (r3283)
90 135 *
91 136 * @param int $blog_id
92 137 * @param int $user_id
93 138 * @param string $domain
@@ -97,28 +142,106 @@
97 142 */
98 143 function bbp_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
99 144
100 145 // Bail if plugin is not network activated
101 - if ( ! is_plugin_active_for_network( bbpress()->basename ) )
146 + if ( ! is_plugin_active_for_network( bbpress()->basename ) ) {
102 147 return;
148 + }
103 149
104 - // Switch to the new blog
105 - switch_to_blog( $blog_id );
150 + // Switch to the new site
151 + bbp_switch_to_site( $blog_id );
106 152
107 153 // Do the bbPress activation routine
108 154 do_action( 'bbp_new_site', $blog_id, $user_id, $domain, $path, $site_id, $meta );
109 155
110 - // restore original blog
111 - restore_current_blog();
156 + // Restore original site
157 + bbp_restore_current_site();
112 158 }
113 159
160 +/**
161 + * Show icons in list-table column headers instead of strings
162 + *
163 + * @since 2.6.0 bbPress (r5833)
164 + *
165 + * @param array $columns Column headers fed into list-table objects
166 + *
167 + * @return array Possibly altered column headers
168 + */
169 +function bbp_filter_column_headers( $columns = array() ) {
170 +
171 + // Do not filter column headers by default - maybe we'll turn it on later
172 + if ( ! apply_filters( 'bbp_filter_column_headers', false ) ) {
173 + return $columns;
174 + }
175 +
176 + /** Forums ****************************************************************/
177 +
178 + // Forum topic count
179 + if ( isset( $columns['bbp_forum_topic_count'] ) ) {
180 + $columns['bbp_forum_topic_count'] = '<span class="vers bbp_topics_column" title="' . esc_attr__( 'Topics', 'bbpress' ) . '"><span class="screen-reader-text">' . esc_html__( 'Topics', 'bbpress' ) . '</span></span>';
181 + }
182 +
183 + // Forum reply count
184 + if ( isset( $columns['bbp_forum_reply_count'] ) ) {
185 + $columns['bbp_forum_reply_count'] = '<span class="vers bbp_replies_column" title="' . esc_attr__( 'Replies', 'bbpress' ) . '"><span class="screen-reader-text">' . esc_html__( 'Replies', 'bbpress' ) . '</span></span>';
186 + }
187 +
188 + /** Topics ****************************************************************/
189 +
190 + // Topic forum
191 + if ( isset( $columns['bbp_topic_forum'] ) ) {
192 + $columns['bbp_topic_forum'] = '<span class="vers bbp_forums_column" title="' . esc_attr__( 'Forum', 'bbpress' ) . '"><span class="screen-reader-text">' . esc_html__( 'Forum', 'bbpress' ) . '</span></span>';
193 + }
194 +
195 + // Topic reply count
196 + if ( isset( $columns['bbp_topic_reply_count'] ) ) {
197 + $columns['bbp_topic_reply_count'] = '<span class="vers bbp_replies_column" title="' . esc_attr__( 'Replies', 'bbpress' ) . '"><span class="screen-reader-text">' . esc_html__( 'Replies', 'bbpress' ) . '</span></span>';
198 + }
199 +
200 + /** Replies ***************************************************************/
201 +
202 + // Reply forum
203 + if ( isset( $columns['bbp_reply_forum'] ) ) {
204 + $columns['bbp_reply_forum'] = '<span class="vers bbp_forums_column" title="' . esc_attr__( 'Forum', 'bbpress' ) . '"><span class="screen-reader-text">' . esc_html__( 'Forum', 'bbpress' ) . '</span></span>';
205 + }
206 +
207 + // Reply topic
208 + if ( isset( $columns['bbp_reply_topic'] ) ) {
209 + $columns['bbp_reply_topic'] = '<span class="vers bbp_topics_column" title="' . esc_attr__( 'Topic', 'bbpress' ) . '"><span class="screen-reader-text">' . esc_html__( 'Topic', 'bbpress' ) . '</span></span>';
210 + }
211 +
212 + return $columns;
213 +}
214 +
215 +/**
216 + * Filter sample permalinks so that certain languages display properly.
217 + *
218 + * @since 2.0.0 bbPress (r3336)
219 + *
220 + * @param string $post_link Custom post type permalink
221 + * @param object $_post Post data object
222 + * @param bool $leavename Optional, defaults to false. Whether to keep post name or page name.
223 + * @param bool $sample Optional, defaults to false. Is it a sample permalink.
224 + *
225 + * @return string The custom post type permalink
226 + */
227 +function bbp_filter_sample_permalink( $post_link, $_post, $leavename = false, $sample = false ) {
228 +
229 + // Bail if not on an admin page and not getting a sample permalink
230 + if ( ! empty( $sample ) && is_admin() && bbp_is_custom_post_type() ) {
231 + return urldecode( $post_link );
232 + }
233 +
234 + // Return post link
235 + return $post_link;
236 +}
237 +
114 238 /** Sub-Actions ***************************************************************/
115 239
116 240 /**
117 241 * Piggy back admin_init action
118 242 *
119 - * @since bbPress (r3766)
120 - * @uses do_action() Calls 'bbp_admin_init'
243 + * @since 2.1.0 bbPress (r3766)
121 244 */
122 245 function bbp_admin_init() {
123 246 do_action( 'bbp_admin_init' );
124 247 }
@@ -125,10 +248,9 @@
125 248
126 249 /**
127 250 * Piggy back admin_menu action
128 251 *
129 - * @since bbPress (r3766)
130 - * @uses do_action() Calls 'bbp_admin_menu'
252 + * @since 2.1.0 bbPress (r3766)
131 253 */
132 254 function bbp_admin_menu() {
133 255 do_action( 'bbp_admin_menu' );
134 256 }
@@ -135,10 +257,9 @@
135 257
136 258 /**
137 259 * Piggy back admin_head action
138 260 *
139 - * @since bbPress (r3766)
140 - * @uses do_action() Calls 'bbp_admin_head'
261 + * @since 2.1.0 bbPress (r3766)
141 262 */
142 263 function bbp_admin_head() {
143 264 do_action( 'bbp_admin_head' );
144 265 }
@@ -145,10 +266,9 @@
145 266
146 267 /**
147 268 * Piggy back admin_notices action
148 269 *
149 - * @since bbPress (r3766)
150 - * @uses do_action() Calls 'bbp_admin_notices'
270 + * @since 2.1.0 bbPress (r3766)
151 271 */
152 272 function bbp_admin_notices() {
153 273 do_action( 'bbp_admin_notices' );
154 274 }
@@ -155,10 +275,9 @@
155 275
156 276 /**
157 277 * Dedicated action to register bbPress importers
158 278 *
159 - * @since bbPress (r3766)
160 - * @uses do_action() Calls 'bbp_admin_notices'
279 + * @since 2.1.0 bbPress (r3766)
161 280 */
162 281 function bbp_register_importers() {
163 282 do_action( 'bbp_register_importers' );
164 283 }
@@ -165,20 +284,61 @@
165 284
166 285 /**
167 286 * Dedicated action to register admin styles
168 287 *
169 - * @since bbPress (r3766)
170 - * @uses do_action() Calls 'bbp_admin_notices'
288 + * @since 2.6.0 bbPress (r6912)
171 289 */
172 -function bbp_register_admin_style() {
290 +function bbp_register_admin_styles() {
291 +
292 + /**
293 + * Action used to register the admin styling
294 + *
295 + * @since 2.1.0
296 + * @deprecated 2.6.0
297 + */
173 298 do_action( 'bbp_register_admin_style' );
299 +
300 + /**
301 + * Action used to register all admin styling
302 + *
303 + * @since 2.6.0
304 + */
305 + do_action( 'bbp_register_admin_styles' );
174 306 }
175 307
176 308 /**
309 + * Dedicated action to register admin scripts
310 + *
311 + * @since 2.6.0 bbPress (r6912)
312 + */
313 +function bbp_register_admin_scripts() {
314 + do_action( 'bbp_register_admin_scripts' );
315 +}
316 +
317 +/**
177 318 * Dedicated action to register admin settings
178 319 *
179 - * @since bbPress (r3766)
180 - * @uses do_action() Calls 'bbp_register_admin_settings'
320 + * @since 2.1.0 bbPress (r3766)
181 321 */
182 322 function bbp_register_admin_settings() {
183 323 do_action( 'bbp_register_admin_settings' );
324 +}
325 +
326 +/**
327 + * Dedicated action to output admin tools.php sections
328 + *
329 + * @since 2.6.0 bbPress (r6273)
330 + */
331 +function bbp_admin_tool_box() {
332 + do_action( 'bbp_admin_tool_box' );
333 +}
334 +
335 +/**
336 + * Dedicated action to hook into the current screen
337 + *
338 + * @since 2.6.0 bbPress (r6185)
339 + *
340 + * @param WP_Screen $current_screen
341 + */
342 +function bbp_current_screen( $current_screen = '' ) {
343 + do_action( 'bbp_current_screen', $current_screen );
184 344 }