PluginProbe
bbPress / 2.6.6
bbPress v2.6.6
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 2.2.2 All 71 releases
← All changes | includes/admin/tools.php +374 -447 trunk2.6.6 View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2
3 3 /**
4 - * bbPress Admin Tools Page.
4 + * bbPress Admin Tools Page
5 5 *
6 6 * @package bbPress
7 7 * @subpackage Administration
8 8 */
@@ -10,13 +10,11 @@
10 10 // Exit if accessed directly
11 11 defined( 'ABSPATH' ) || exit;
12 12
13 13 /**
14 - * Output a bbPress specific tools box.
14 + * Output a bbPress specific tools box
15 15 *
16 16 * @since 2.6.0 bbPress (r6273)
17 - *
18 - * @return void
19 17 */
20 18 function bbp_admin_tools_box() {
21 19
22 20 // Bail if user cannot access tools page
@@ -28,9 +26,9 @@
28 26 $links = array();
29 27 $tools = bbp_get_tools_admin_pages(); ?>
30 28
31 29 <div class="card">
32 - <h3 class="title"><?php esc_html_e( 'Forums', 'bbpress' ); ?></h3>
30 + <h3 class="title"><?php esc_html_e( 'Forums', 'bbpress' ) ?></h3>
33 31 <p><?php esc_html_e( 'bbPress provides the following tools to help you manage your forums:', 'bbpress' ); ?></p>
34 32
35 33 <?php
36 34
@@ -54,37 +52,33 @@
54 52 <?php
55 53 }
56 54
57 55 /**
58 - * Register an admin area repair tool.
56 + * Register an admin area repair tool
59 57 *
60 58 * @since 2.6.0 bbPress (r5885)
61 59 *
62 60 * @param array $args
63 - * @return void
61 + * @return
64 62 */
65 63 function bbp_register_repair_tool( $args = array() ) {
66 64
67 65 // Parse arguments
68 - $r = bbp_parse_args(
69 - $args,
70 - array(
71 - 'id' => '',
72 - 'type' => '',
73 - 'title' => '',
74 - 'description' => '',
75 - 'callback' => '',
76 - 'priority' => 0,
77 - 'overhead' => 'low',
78 - 'version' => '',
79 - 'components' => array(),
66 + $r = bbp_parse_args( $args, array(
67 + 'id' => '',
68 + 'type' => '',
69 + 'title' => '',
70 + 'description' => '',
71 + 'callback' => '',
72 + 'priority' => 0,
73 + 'overhead' => 'low',
74 + 'version' => '',
75 + 'components' => array(),
80 76
81 - // @todo
82 - 'success' => esc_html__( 'The repair was completed successfully', 'bbpress' ),
83 - 'failure' => esc_html__( 'The repair was not successful', 'bbpress' )
84 - ),
85 - 'register_repair_tool'
86 - );
77 + // @todo
78 + 'success' => esc_html__( 'The repair was completed successfully', 'bbpress' ),
79 + 'failure' => esc_html__( 'The repair was not successful', 'bbpress' )
80 + ), 'register_repair_tool' );
87 81
88 82 // Bail if missing required values
89 83 if ( empty( $r['id'] ) || empty( $r['priority'] ) || empty( $r['title'] ) || empty( $r['callback'] ) ) {
90 84 return;
@@ -107,9 +101,9 @@
107 101 );
108 102 }
109 103
110 104 /**
111 - * Register the default repair tools.
105 + * Register the default repair tools
112 106 *
113 107 * @since 2.6.0 bbPress (r5885)
114 108 */
115 109 function bbp_register_default_repair_tools() {
@@ -114,461 +108,403 @@
114 108 */
115 109 function bbp_register_default_repair_tools() {
116 110
117 111 // Topic meta
118 - bbp_register_repair_tool(
119 - array(
120 - 'id' => 'bbp-sync-topic-meta',
121 - 'type' => 'repair',
122 - 'title' => esc_html__( 'Recalculate parent topic for each reply', 'bbpress' ),
123 - 'description' => esc_html__( 'Run this if replies appear in the wrong topics.', 'bbpress' ),
124 - 'callback' => 'bbp_admin_repair_topic_meta',
125 - 'priority' => 5,
126 - 'overhead' => 'low',
127 - 'components' => array( bbp_get_reply_post_type() )
128 - )
129 - );
112 + bbp_register_repair_tool( array(
113 + 'id' => 'bbp-sync-topic-meta',
114 + 'type' => 'repair',
115 + 'title' => esc_html__( 'Recalculate parent topic for each reply', 'bbpress' ),
116 + 'description' => esc_html__( 'Run this if replies appear in the wrong topics.', 'bbpress' ),
117 + 'callback' => 'bbp_admin_repair_topic_meta',
118 + 'priority' => 5,
119 + 'overhead' => 'low',
120 + 'components' => array( bbp_get_reply_post_type() )
121 + ) );
130 122
131 123 // Forum meta
132 - bbp_register_repair_tool(
133 - array(
134 - 'id' => 'bbp-sync-forum-meta',
135 - 'type' => 'repair',
136 - 'title' => esc_html__( 'Recalculate parent forum for each topic and reply', 'bbpress' ),
137 - 'description' => esc_html__( 'Run this if topics or replies appear in the wrong forums.', 'bbpress' ),
138 - 'callback' => 'bbp_admin_repair_forum_meta',
139 - 'priority' => 10,
140 - 'overhead' => 'low',
141 - 'components' => array( bbp_get_topic_post_type(), bbp_get_reply_post_type() )
142 - )
143 - );
124 + bbp_register_repair_tool( array(
125 + 'id' => 'bbp-sync-forum-meta',
126 + 'type' => 'repair',
127 + 'title' => esc_html__( 'Recalculate parent forum for each topic and reply', 'bbpress' ),
128 + 'description' => esc_html__( 'Run this if topics or replies appear in the wrong forums.', 'bbpress' ),
129 + 'callback' => 'bbp_admin_repair_forum_meta',
130 + 'priority' => 10,
131 + 'overhead' => 'low',
132 + 'components' => array( bbp_get_topic_post_type(), bbp_get_reply_post_type() )
133 + ) );
144 134
145 135 // Forum visibility
146 - bbp_register_repair_tool(
147 - array(
148 - 'id' => 'bbp-sync-forum-visibility',
149 - 'type' => 'repair',
150 - 'title' => esc_html__( 'Recalculate private and hidden forums', 'bbpress' ),
151 - 'description' => esc_html__( 'Run this if non-public forums are publicly visible.', 'bbpress' ),
152 - 'callback' => 'bbp_admin_repair_forum_visibility',
153 - 'priority' => 15,
154 - 'overhead' => 'low',
155 - 'components' => array( bbp_get_forum_post_type() )
156 - )
157 - );
136 + bbp_register_repair_tool( array(
137 + 'id' => 'bbp-sync-forum-visibility',
138 + 'type' => 'repair',
139 + 'title' => esc_html__( 'Recalculate private and hidden forums', 'bbpress' ),
140 + 'description' => esc_html__( 'Run this if non-public forums are publicly visible.', 'bbpress' ),
141 + 'callback' => 'bbp_admin_repair_forum_visibility',
142 + 'priority' => 15,
143 + 'overhead' => 'low',
144 + 'components' => array( bbp_get_forum_post_type() )
145 + ) );
158 146
159 147 // Sync all topics in all forums
160 - bbp_register_repair_tool(
161 - array(
162 - 'id' => 'bbp-sync-all-topics-forums',
163 - 'type' => 'repair',
164 - 'title' => esc_html__( 'Recalculate last activity in each topic and forum', 'bbpress' ),
165 - 'description' => esc_html__( 'Run this if freshness appears incorrectly.', 'bbpress' ),
166 - 'callback' => 'bbp_admin_repair_freshness',
167 - 'priority' => 20,
168 - 'overhead' => 'high',
169 - 'components' => array( bbp_get_forum_post_type(), bbp_get_topic_post_type(), bbp_get_reply_post_type() )
170 - )
171 - );
148 + bbp_register_repair_tool( array(
149 + 'id' => 'bbp-sync-all-topics-forums',
150 + 'type' => 'repair',
151 + 'title' => esc_html__( 'Recalculate last activity in each topic and forum', 'bbpress' ),
152 + 'description' => esc_html__( 'Run this if freshness appears incorrectly.', 'bbpress' ),
153 + 'callback' => 'bbp_admin_repair_freshness',
154 + 'priority' => 20,
155 + 'overhead' => 'high',
156 + 'components' => array( bbp_get_forum_post_type(), bbp_get_topic_post_type(), bbp_get_reply_post_type() )
157 + ) );
172 158
173 159 // Sync all sticky topics in all forums
174 - bbp_register_repair_tool(
175 - array(
176 - 'id' => 'bbp-sync-all-topics-sticky',
177 - 'type' => 'repair',
178 - 'title' => esc_html__( 'Recalculate sticky relationship of each topic', 'bbpress' ),
179 - 'description' => esc_html__( 'Run this if sticky topics appear incorrectly.', 'bbpress' ),
180 - 'callback' => 'bbp_admin_repair_sticky',
181 - 'priority' => 25,
182 - 'overhead' => 'low',
183 - 'components' => array( bbp_get_topic_post_type() )
184 - )
185 - );
160 + bbp_register_repair_tool( array(
161 + 'id' => 'bbp-sync-all-topics-sticky',
162 + 'type' => 'repair',
163 + 'title' => esc_html__( 'Recalculate sticky relationship of each topic', 'bbpress' ),
164 + 'description' => esc_html__( 'Run this if sticky topics appear incorrectly.', 'bbpress' ),
165 + 'callback' => 'bbp_admin_repair_sticky',
166 + 'priority' => 25,
167 + 'overhead' => 'low',
168 + 'components' => array( bbp_get_topic_post_type() )
169 + ) );
186 170
187 171 // Sync all hierarchical reply positions
188 - bbp_register_repair_tool(
189 - array(
190 - 'id' => 'bbp-sync-all-reply-positions',
191 - 'type' => 'repair',
192 - 'title' => esc_html__( 'Recalculate position of each reply in each topic', 'bbpress' ),
193 - 'description' => esc_html__( 'Run this if replies appear in the wrong order.', 'bbpress' ),
194 - 'callback' => 'bbp_admin_repair_reply_menu_order',
195 - 'priority' => 30,
196 - 'overhead' => 'high',
197 - 'components' => array( bbp_get_reply_post_type() )
198 - )
199 - );
172 + bbp_register_repair_tool( array(
173 + 'id' => 'bbp-sync-all-reply-positions',
174 + 'type' => 'repair',
175 + 'title' => esc_html__( 'Recalculate position of each reply in each topic', 'bbpress' ),
176 + 'description' => esc_html__( 'Run this if replies appear in the wrong order.', 'bbpress' ),
177 + 'callback' => 'bbp_admin_repair_reply_menu_order',
178 + 'priority' => 30,
179 + 'overhead' => 'high',
180 + 'components' => array( bbp_get_reply_post_type() )
181 + ) );
200 182
201 183 // Sync all topic engagements for all users
202 - bbp_register_repair_tool(
203 - array(
204 - 'id' => 'bbp-topic-engagements',
205 - 'type' => 'repair',
206 - 'title' => esc_html__( 'Recalculate engagements in each topic for each user', 'bbpress' ),
207 - 'description' => esc_html__( 'Run this if voices appear incorrectly.', 'bbpress' ),
208 - 'callback' => 'bbp_admin_repair_topic_voice_count',
209 - 'priority' => 35,
210 - 'overhead' => 'high',
211 - 'components' => array( bbp_get_topic_post_type(), bbp_get_user_rewrite_id() )
212 - )
213 - );
184 + bbp_register_repair_tool( array(
185 + 'id' => 'bbp-topic-engagements',
186 + 'type' => 'repair',
187 + 'title' => esc_html__( 'Recalculate engagements in each topic for each user', 'bbpress' ),
188 + 'description' => esc_html__( 'Run this if voices appear incorrectly.', 'bbpress' ),
189 + 'callback' => 'bbp_admin_repair_topic_voice_count',
190 + 'priority' => 35,
191 + 'overhead' => 'high',
192 + 'components' => array( bbp_get_topic_post_type(), bbp_get_user_rewrite_id() )
193 + ) );
214 194
215 195 // Update closed topic counts
216 - bbp_register_repair_tool(
217 - array(
218 - 'id' => 'bbp-sync-closed-topics',
219 - 'type' => 'repair',
220 - 'title' => esc_html__( 'Repair closed topic statuses', 'bbpress' ),
221 - 'description' => esc_html__( 'Run this if closed topics appear incorrectly.', 'bbpress' ),
222 - 'callback' => 'bbp_admin_repair_closed_topics',
223 - 'priority' => 40,
224 - 'overhead' => 'medium',
225 - 'components' => array( bbp_get_topic_post_type() )
226 - )
227 - );
196 + bbp_register_repair_tool( array(
197 + 'id' => 'bbp-sync-closed-topics',
198 + 'type' => 'repair',
199 + 'title' => esc_html__( 'Repair closed topic statuses', 'bbpress' ),
200 + 'description' => esc_html__( 'Run this if closed topics appear incorrectly.', 'bbpress' ),
201 + 'callback' => 'bbp_admin_repair_closed_topics',
202 + 'priority' => 40,
203 + 'overhead' => 'medium',
204 + 'components' => array( bbp_get_topic_post_type() )
205 + ) );
228 206
229 207 // Count topics
230 - bbp_register_repair_tool(
231 - array(
232 - 'id' => 'bbp-forum-topics',
233 - 'type' => 'repair',
234 - 'title' => esc_html__( 'Recount topics in each forum', 'bbpress' ),
235 - 'description' => esc_html__( 'Run this if the number of topics in any forums are incorrect.', 'bbpress' ),
236 - 'callback' => 'bbp_admin_repair_forum_topic_count',
237 - 'priority' => 45,
238 - 'overhead' => 'medium',
239 - 'components' => array( bbp_get_forum_post_type(), bbp_get_topic_post_type() )
240 - )
241 - );
208 + bbp_register_repair_tool( array(
209 + 'id' => 'bbp-forum-topics',
210 + 'type' => 'repair',
211 + 'title' => esc_html__( 'Recount topics in each forum', 'bbpress' ),
212 + 'description' => esc_html__( 'Run this if the number of topics in any forums are incorrect.', 'bbpress' ),
213 + 'callback' => 'bbp_admin_repair_forum_topic_count',
214 + 'priority' => 45,
215 + 'overhead' => 'medium',
216 + 'components' => array( bbp_get_forum_post_type(), bbp_get_topic_post_type() )
217 + ) );
242 218
243 219 // Count topic tags
244 - bbp_register_repair_tool(
245 - array(
246 - 'id' => 'bbp-topic-tags',
247 - 'type' => 'repair',
248 - 'title' => esc_html__( 'Recount topics in each topic-tag', 'bbpress' ),
249 - 'description' => esc_html__( 'Run this if the number of topics in any topic-tags are incorrect.', 'bbpress' ),
250 - 'callback' => 'bbp_admin_repair_topic_tag_count',
251 - 'priority' => 50,
252 - 'overhead' => 'medium',
253 - 'components' => array( bbp_get_topic_post_type(), bbp_get_topic_tag_tax_id() )
254 - )
255 - );
220 + bbp_register_repair_tool( array(
221 + 'id' => 'bbp-topic-tags',
222 + 'type' => 'repair',
223 + 'title' => esc_html__( 'Recount topics in each topic-tag', 'bbpress' ),
224 + 'description' => esc_html__( 'Run this if the number of topics in any topic-tags are incorrect.', 'bbpress' ),
225 + 'callback' => 'bbp_admin_repair_topic_tag_count',
226 + 'priority' => 50,
227 + 'overhead' => 'medium',
228 + 'components' => array( bbp_get_topic_post_type(), bbp_get_topic_tag_tax_id() )
229 + ) );
256 230
257 231 // Count forum replies
258 - bbp_register_repair_tool(
259 - array(
260 - 'id' => 'bbp-forum-replies',
261 - 'type' => 'repair',
262 - 'title' => esc_html__( 'Recount replies in each forum', 'bbpress' ),
263 - 'description' => esc_html__( 'Run this if the number of replies in any forums are incorrect.', 'bbpress' ),
264 - 'callback' => 'bbp_admin_repair_forum_reply_count',
265 - 'priority' => 55,
266 - 'overhead' => 'high',
267 - 'components' => array( bbp_get_forum_post_type(), bbp_get_reply_post_type() )
268 - )
269 - );
232 + bbp_register_repair_tool( array(
233 + 'id' => 'bbp-forum-replies',
234 + 'type' => 'repair',
235 + 'title' => esc_html__( 'Recount replies in each forum', 'bbpress' ),
236 + 'description' => esc_html__( 'Run this if the number of replies in any forums are incorrect.', 'bbpress' ),
237 + 'callback' => 'bbp_admin_repair_forum_reply_count',
238 + 'priority' => 55,
239 + 'overhead' => 'high',
240 + 'components' => array( bbp_get_forum_post_type(), bbp_get_reply_post_type() )
241 + ) );
270 242
271 243 // Count non-published replies to each forum
272 - bbp_register_repair_tool(
273 - array(
274 - 'id' => 'bbp-forum-hidden-replies',
275 - 'type' => 'repair',
276 - 'title' => esc_html__( 'Recount pending, spammed, and trashed replies in each forum', 'bbpress' ),
277 - 'description' => esc_html__( 'Run this if non-public replies display incorrectly in forums.', 'bbpress' ),
278 - 'callback' => 'bbp_admin_repair_forum_hidden_reply_count',
279 - 'priority' => 60,
280 - 'overhead' => 'high',
281 - 'components' => array( bbp_get_forum_post_type(), bbp_get_reply_post_type() )
282 - )
283 - );
244 + bbp_register_repair_tool( array(
245 + 'id' => 'bbp-forum-hidden-replies',
246 + 'type' => 'repair',
247 + 'title' => esc_html__( 'Recount pending, spammed, and trashed replies in each forum', 'bbpress' ),
248 + 'description' => esc_html__( 'Run this if non-public replies display incorrectly in forums.', 'bbpress' ),
249 + 'callback' => 'bbp_admin_repair_forum_hidden_reply_count',
250 + 'priority' => 60,
251 + 'overhead' => 'high',
252 + 'components' => array( bbp_get_forum_post_type(), bbp_get_reply_post_type() )
253 + ) );
284 254
285 255 // Count topic replies
286 - bbp_register_repair_tool(
287 - array(
288 - 'id' => 'bbp-topic-replies',
289 - 'type' => 'repair',
290 - 'title' => esc_html__( 'Recount replies in each topic', 'bbpress' ),
291 - 'description' => esc_html__( 'Run this if the number of replies in any topics are incorrect.', 'bbpress' ),
292 - 'callback' => 'bbp_admin_repair_topic_reply_count',
293 - 'priority' => 65,
294 - 'overhead' => 'high',
295 - 'components' => array( bbp_get_topic_post_type(), bbp_get_reply_post_type() )
296 - )
297 - );
256 + bbp_register_repair_tool( array(
257 + 'id' => 'bbp-topic-replies',
258 + 'type' => 'repair',
259 + 'title' => esc_html__( 'Recount replies in each topic', 'bbpress' ),
260 + 'description' => esc_html__( 'Run this if the number of replies in any topics are incorrect.', 'bbpress' ),
261 + 'callback' => 'bbp_admin_repair_topic_reply_count',
262 + 'priority' => 65,
263 + 'overhead' => 'high',
264 + 'components' => array( bbp_get_topic_post_type(), bbp_get_reply_post_type() )
265 + ) );
298 266
299 267 // Count non-published replies to each topic
300 - bbp_register_repair_tool(
301 - array(
302 - 'id' => 'bbp-topic-hidden-replies',
303 - 'type' => 'repair',
304 - 'title' => esc_html__( 'Recount pending, spammed, and trashed replies in each topic', 'bbpress' ),
305 - 'description' => esc_html__( 'Run this if non-public replies display incorrectly in topics.', 'bbpress' ),
306 - 'callback' => 'bbp_admin_repair_topic_hidden_reply_count',
307 - 'priority' => 70,
308 - 'overhead' => 'high',
309 - 'components' => array( bbp_get_topic_post_type(), bbp_get_reply_post_type() )
310 - )
311 - );
268 + bbp_register_repair_tool( array(
269 + 'id' => 'bbp-topic-hidden-replies',
270 + 'type' => 'repair',
271 + 'title' => esc_html__( 'Recount pending, spammed, and trashed replies in each topic', 'bbpress' ),
272 + 'description' => esc_html__( 'Run this if non-public replies display incorrectly in topics.', 'bbpress' ),
273 + 'callback' => 'bbp_admin_repair_topic_hidden_reply_count',
274 + 'priority' => 70,
275 + 'overhead' => 'high',
276 + 'components' => array( bbp_get_topic_post_type(), bbp_get_reply_post_type() )
277 + ) );
312 278
313 279 // Recount topics for each user
314 - bbp_register_repair_tool(
315 - array(
316 - 'id' => 'bbp-user-topics',
317 - 'type' => 'repair',
318 - 'title' => esc_html__( 'Recount topics for each user', 'bbpress' ),
319 - 'description' => esc_html__( 'Run this to get fresh topic counts for all users.', 'bbpress' ),
320 - 'callback' => 'bbp_admin_repair_user_topic_count',
321 - 'priority' => 75,
322 - 'overhead' => 'medium',
323 - 'components' => array( bbp_get_topic_post_type(), bbp_get_user_rewrite_id() )
324 - )
325 - );
280 + bbp_register_repair_tool( array(
281 + 'id' => 'bbp-user-topics',
282 + 'type' => 'repair',
283 + 'title' => esc_html__( 'Recount topics for each user', 'bbpress' ),
284 + 'description' => esc_html__( 'Run this to get fresh topic counts for all users.', 'bbpress' ),
285 + 'callback' => 'bbp_admin_repair_user_topic_count',
286 + 'priority' => 75,
287 + 'overhead' => 'medium',
288 + 'components' => array( bbp_get_topic_post_type(), bbp_get_user_rewrite_id() )
289 + ) );
326 290
327 291 // Recount topics for each user
328 - bbp_register_repair_tool(
329 - array(
330 - 'id' => 'bbp-user-replies',
331 - 'type' => 'repair',
332 - 'title' => esc_html__( 'Recount replies for each user', 'bbpress' ),
333 - 'description' => esc_html__( 'Run this to get fresh reply counts for all users.', 'bbpress' ),
334 - 'callback' => 'bbp_admin_repair_user_reply_count',
335 - 'priority' => 80,
336 - 'overhead' => 'medium',
337 - 'components' => array( bbp_get_reply_post_type(), bbp_get_user_rewrite_id() )
338 - )
339 - );
292 + bbp_register_repair_tool( array(
293 + 'id' => 'bbp-user-replies',
294 + 'type' => 'repair',
295 + 'title' => esc_html__( 'Recount replies for each user', 'bbpress' ),
296 + 'description' => esc_html__( 'Run this to get fresh reply counts for all users.', 'bbpress' ),
297 + 'callback' => 'bbp_admin_repair_user_reply_count',
298 + 'priority' => 80,
299 + 'overhead' => 'medium',
300 + 'components' => array( bbp_get_reply_post_type(), bbp_get_user_rewrite_id() )
301 + ) );
340 302
341 303 // Remove unpublished topics from user favorites
342 - bbp_register_repair_tool(
343 - array(
344 - 'id' => 'bbp-user-favorites',
345 - 'type' => 'repair',
346 - 'title' => esc_html__( 'Remove unpublished topics from user favorites', 'bbpress' ),
347 - 'description' => esc_html__( 'Run this to remove trashed or deleted topics from all user favorites.', 'bbpress' ),
348 - 'callback' => 'bbp_admin_repair_user_favorites',
349 - 'priority' => 85,
350 - 'overhead' => 'medium',
351 - 'components' => array( bbp_get_topic_post_type(), bbp_get_user_rewrite_id() )
352 - )
353 - );
304 + bbp_register_repair_tool( array(
305 + 'id' => 'bbp-user-favorites',
306 + 'type' => 'repair',
307 + 'title' => esc_html__( 'Remove unpublished topics from user favorites', 'bbpress' ),
308 + 'description' => esc_html__( 'Run this to remove trashed or deleted topics from all user favorites.', 'bbpress' ),
309 + 'callback' => 'bbp_admin_repair_user_favorites',
310 + 'priority' => 85,
311 + 'overhead' => 'medium',
312 + 'components' => array( bbp_get_topic_post_type(), bbp_get_user_rewrite_id() )
313 + ) );
354 314
355 315 // Remove unpublished topics from user subscriptions
356 - bbp_register_repair_tool(
357 - array(
358 - 'id' => 'bbp-user-topic-subscriptions',
359 - 'type' => 'repair',
360 - 'title' => esc_html__( 'Remove unpublished topics from user subscriptions', 'bbpress' ),
361 - 'description' => esc_html__( 'Run this to remove trashed or deleted topics from all user subscriptions.', 'bbpress' ),
362 - 'callback' => 'bbp_admin_repair_user_topic_subscriptions',
363 - 'priority' => 90,
364 - 'overhead' => 'medium',
365 - 'components' => array( bbp_get_topic_post_type(), bbp_get_user_rewrite_id() )
366 - )
367 - );
316 + bbp_register_repair_tool( array(
317 + 'id' => 'bbp-user-topic-subscriptions',
318 + 'type' => 'repair',
319 + 'title' => esc_html__( 'Remove unpublished topics from user subscriptions', 'bbpress' ),
320 + 'description' => esc_html__( 'Run this to remove trashed or deleted topics from all user subscriptions.', 'bbpress' ),
321 + 'callback' => 'bbp_admin_repair_user_topic_subscriptions',
322 + 'priority' => 90,
323 + 'overhead' => 'medium',
324 + 'components' => array( bbp_get_topic_post_type(), bbp_get_user_rewrite_id() )
325 + ) );
368 326
369 327 // Remove unpublished forums from user subscriptions
370 - bbp_register_repair_tool(
371 - array(
372 - 'id' => 'bbp-user-forum-subscriptions',
373 - 'type' => 'repair',
374 - 'title' => esc_html__( 'Remove unpublished forums from user subscriptions', 'bbpress' ),
375 - 'description' => esc_html__( 'Run this to remove trashed or deleted forums from all user subscriptions.', 'bbpress' ),
376 - 'callback' => 'bbp_admin_repair_user_forum_subscriptions',
377 - 'priority' => 95,
378 - 'overhead' => 'medium',
379 - 'components' => array( bbp_get_forum_post_type(), bbp_get_user_rewrite_id() )
380 - )
381 - );
328 + bbp_register_repair_tool( array(
329 + 'id' => 'bbp-user-forum-subscriptions',
330 + 'type' => 'repair',
331 + 'title' => esc_html__( 'Remove unpublished forums from user subscriptions', 'bbpress' ),
332 + 'description' => esc_html__( 'Run this to remove trashed or deleted forums from all user subscriptions.', 'bbpress' ),
333 + 'callback' => 'bbp_admin_repair_user_forum_subscriptions',
334 + 'priority' => 95,
335 + 'overhead' => 'medium',
336 + 'components' => array( bbp_get_forum_post_type(), bbp_get_user_rewrite_id() )
337 + ) );
382 338
383 339 // Remove unpublished forums from user subscriptions
384 - bbp_register_repair_tool(
385 - array(
386 - 'id' => 'bbp-user-role-map',
387 - 'type' => 'repair',
388 - 'title' => esc_html__( 'Remap all users to default forum roles', 'bbpress' ),
389 - 'description' => esc_html__( 'Run this if users have issues accessing the forums.', 'bbpress' ),
390 - 'callback' => 'bbp_admin_repair_user_roles',
391 - 'priority' => 100,
392 - 'overhead' => 'low',
393 - 'components' => array( bbp_get_user_rewrite_id() )
394 - )
395 - );
340 + bbp_register_repair_tool( array(
341 + 'id' => 'bbp-user-role-map',
342 + 'type' => 'repair',
343 + 'title' => esc_html__( 'Remap all users to default forum roles', 'bbpress' ),
344 + 'description' => esc_html__( 'Run this if users have issues accessing the forums.', 'bbpress' ),
345 + 'callback' => 'bbp_admin_repair_user_roles',
346 + 'priority' => 100,
347 + 'overhead' => 'low',
348 + 'components' => array( bbp_get_user_rewrite_id() )
349 + ) );
396 350
397 351 // Migrate topic engagements to post-meta
398 - bbp_register_repair_tool(
399 - array(
400 - 'id' => 'bbp-user-topic-engagements-move',
401 - 'type' => 'upgrade',
402 - 'title' => esc_html__( 'Upgrade user topic engagements', 'bbpress' ),
403 - 'description' => esc_html__( 'Copies engagements from user meta to topic meta.', 'bbpress' ),
404 - 'callback' => 'bbp_admin_upgrade_user_engagements',
405 - 'priority' => 105,
406 - 'version' => '2.6.0',
407 - 'overhead' => 'high',
408 - 'components' => array( bbp_get_user_rewrite_id(), bbp_get_user_engagements_rewrite_id() )
409 - )
410 - );
352 + bbp_register_repair_tool( array(
353 + 'id' => 'bbp-user-topic-engagements-move',
354 + 'type' => 'upgrade',
355 + 'title' => esc_html__( 'Upgrade user topic engagements', 'bbpress' ),
356 + 'description' => esc_html__( 'Copies engagements from user meta to topic meta.', 'bbpress' ),
357 + 'callback' => 'bbp_admin_upgrade_user_engagements',
358 + 'priority' => 105,
359 + 'version' => '2.6.0',
360 + 'overhead' => 'high',
361 + 'components' => array( bbp_get_user_rewrite_id(), bbp_get_user_engagements_rewrite_id() )
362 + ) );
411 363
412 364 // Migrate favorites from user-meta to post-meta
413 - bbp_register_repair_tool(
414 - array(
415 - 'id' => 'bbp-user-favorites-move',
416 - 'type' => 'upgrade',
417 - 'title' => esc_html__( 'Upgrade user topic favorites', 'bbpress' ),
418 - 'description' => esc_html__( 'Copies favorites from user meta to topic meta.', 'bbpress' ),
419 - 'callback' => 'bbp_admin_upgrade_user_favorites',
420 - 'priority' => 110,
421 - 'version' => '2.6.0',
422 - 'overhead' => 'high',
423 - 'components' => array( bbp_get_user_rewrite_id(), bbp_get_user_favorites_rewrite_id() )
424 - )
425 - );
365 + bbp_register_repair_tool( array(
366 + 'id' => 'bbp-user-favorites-move',
367 + 'type' => 'upgrade',
368 + 'title' => esc_html__( 'Upgrade user topic favorites', 'bbpress' ),
369 + 'description' => esc_html__( 'Copies favorites from user meta to topic meta.', 'bbpress' ),
370 + 'callback' => 'bbp_admin_upgrade_user_favorites',
371 + 'priority' => 110,
372 + 'version' => '2.6.0',
373 + 'overhead' => 'high',
374 + 'components' => array( bbp_get_user_rewrite_id(), bbp_get_user_favorites_rewrite_id() )
375 + ) );
426 376
427 377 // Migrate topic subscriptions from user-meta to post-meta
428 - bbp_register_repair_tool(
429 - array(
430 - 'id' => 'bbp-user-topic-subscriptions-move',
431 - 'type' => 'upgrade',
432 - 'title' => esc_html__( 'Upgrade user topic subscriptions', 'bbpress' ),
433 - 'description' => esc_html__( 'Copies topic subscriptions from user meta to topic meta.', 'bbpress' ),
434 - 'callback' => 'bbp_admin_upgrade_user_topic_subscriptions',
435 - 'priority' => 115,
436 - 'version' => '2.6.0',
437 - 'overhead' => 'high',
438 - 'components' => array( bbp_get_user_rewrite_id(), bbp_get_user_subscriptions_rewrite_id() )
439 - )
440 - );
378 + bbp_register_repair_tool( array(
379 + 'id' => 'bbp-user-topic-subscriptions-move',
380 + 'type' => 'upgrade',
381 + 'title' => esc_html__( 'Upgrade user topic subscriptions', 'bbpress' ),
382 + 'description' => esc_html__( 'Copies topic subscriptions from user meta to topic meta.', 'bbpress' ),
383 + 'callback' => 'bbp_admin_upgrade_user_topic_subscriptions',
384 + 'priority' => 115,
385 + 'version' => '2.6.0',
386 + 'overhead' => 'high',
387 + 'components' => array( bbp_get_user_rewrite_id(), bbp_get_user_subscriptions_rewrite_id() )
388 + ) );
441 389
442 390 // Migrate forum subscriptions from user-meta to post-meta
443 - bbp_register_repair_tool(
444 - array(
445 - 'id' => 'bbp-user-forum-subscriptions-move',
446 - 'type' => 'upgrade',
447 - 'title' => esc_html__( 'Upgrade user forum subscriptions', 'bbpress' ),
448 - 'description' => esc_html__( 'Copies forum subscriptions from user meta to forum meta.', 'bbpress' ),
449 - 'callback' => 'bbp_admin_upgrade_user_forum_subscriptions',
450 - 'priority' => 120,
451 - 'version' => '2.6.0',
452 - 'overhead' => 'high',
453 - 'components' => array( bbp_get_user_rewrite_id(), bbp_get_user_subscriptions_rewrite_id() )
454 - )
455 - );
391 + bbp_register_repair_tool( array(
392 + 'id' => 'bbp-user-forum-subscriptions-move',
393 + 'type' => 'upgrade',
394 + 'title' => esc_html__( 'Upgrade user forum subscriptions', 'bbpress' ),
395 + 'description' => esc_html__( 'Copies forum subscriptions from user meta to forum meta.', 'bbpress' ),
396 + 'callback' => 'bbp_admin_upgrade_user_forum_subscriptions',
397 + 'priority' => 120,
398 + 'version' => '2.6.0',
399 + 'overhead' => 'high',
400 + 'components' => array( bbp_get_user_rewrite_id(), bbp_get_user_subscriptions_rewrite_id() )
401 + ) );
456 402
457 403 // Remove favorites from user-meta
458 - bbp_register_repair_tool(
459 - array(
460 - 'id' => 'bbp-user-favorites-delete',
461 - 'type' => 'upgrade',
462 - 'title' => esc_html__( 'Remove favorites from user-meta', 'bbpress' ),
463 - 'description' => esc_html__( 'Run this to delete old data (after confirming successful favorites upgrade)', 'bbpress' ),
464 - 'callback' => 'bbp_admin_upgrade_remove_favorites_from_usermeta',
465 - 'priority' => 125,
466 - 'version' => '2.6.1',
467 - 'overhead' => 'medium',
468 - 'components' => array( bbp_get_user_rewrite_id(), bbp_get_user_favorites_rewrite_id() )
469 - )
470 - );
404 + bbp_register_repair_tool( array(
405 + 'id' => 'bbp-user-favorites-delete',
406 + 'type' => 'upgrade',
407 + 'title' => esc_html__( 'Remove favorites from user-meta', 'bbpress' ),
408 + 'description' => esc_html__( 'Run this to delete old data (after confirming successful favorites upgrade)', 'bbpress' ),
409 + 'callback' => 'bbp_admin_upgrade_remove_favorites_from_usermeta',
410 + 'priority' => 125,
411 + 'version' => '2.6.1',
412 + 'overhead' => 'medium',
413 + 'components' => array( bbp_get_user_rewrite_id(), bbp_get_user_favorites_rewrite_id() )
414 + ) );
471 415
472 416 // Remove topic subscriptions from user-meta
473 - bbp_register_repair_tool(
474 - array(
475 - 'id' => 'bbp-user-topic-subscriptions-delete',
476 - 'type' => 'upgrade',
477 - 'title' => esc_html__( 'Remove topic subscriptions from user-meta', 'bbpress' ),
478 - 'description' => esc_html__( 'Run this to delete old data (after confirming successful topic subscriptions upgrade)', 'bbpress' ),
479 - 'callback' => 'bbp_admin_upgrade_remove_topic_subscriptions_from_usermeta',
480 - 'priority' => 130,
481 - 'version' => '2.6.1',
482 - 'overhead' => 'medium',
483 - 'components' => array( bbp_get_user_rewrite_id(), bbp_get_user_subscriptions_rewrite_id() )
484 - )
485 - );
417 + bbp_register_repair_tool( array(
418 + 'id' => 'bbp-user-topic-subscriptions-delete',
419 + 'type' => 'upgrade',
420 + 'title' => esc_html__( 'Remove topic subscriptions from user-meta', 'bbpress' ),
421 + 'description' => esc_html__( 'Run this to delete old data (after confirming successful topic subscriptions upgrade)', 'bbpress' ),
422 + 'callback' => 'bbp_admin_upgrade_remove_topic_subscriptions_from_usermeta',
423 + 'priority' => 130,
424 + 'version' => '2.6.1',
425 + 'overhead' => 'medium',
426 + 'components' => array( bbp_get_user_rewrite_id(), bbp_get_user_subscriptions_rewrite_id() )
427 + ) );
486 428
487 429 // Remove forum subscriptions from user-meta
488 - bbp_register_repair_tool(
489 - array(
490 - 'id' => 'bbp-user-forum-subscriptions-delete',
491 - 'type' => 'upgrade',
492 - 'title' => esc_html__( 'Remove forum subscriptions from user-meta', 'bbpress' ),
493 - 'description' => esc_html__( 'Run this to delete old data (after confirming successful forum subscriptions upgrade)', 'bbpress' ),
494 - 'callback' => 'bbp_admin_upgrade_remove_forum_subscriptions_from_usermeta',
495 - 'priority' => 135,
496 - 'version' => '2.6.1',
497 - 'overhead' => 'medium',
498 - 'components' => array( bbp_get_user_rewrite_id(), bbp_get_user_subscriptions_rewrite_id() )
499 - )
500 - );
430 + bbp_register_repair_tool( array(
431 + 'id' => 'bbp-user-forum-subscriptions-delete',
432 + 'type' => 'upgrade',
433 + 'title' => esc_html__( 'Remove forum subscriptions from user-meta', 'bbpress' ),
434 + 'description' => esc_html__( 'Run this to delete old data (after confirming successful forum subscriptions upgrade)', 'bbpress' ),
435 + 'callback' => 'bbp_admin_upgrade_remove_forum_subscriptions_from_usermeta',
436 + 'priority' => 135,
437 + 'version' => '2.6.1',
438 + 'overhead' => 'medium',
439 + 'components' => array( bbp_get_user_rewrite_id(), bbp_get_user_subscriptions_rewrite_id() )
440 + ) );
501 441
502 442 // Sync all BuddyPress group forum relationships
503 - bbp_register_repair_tool(
504 - array(
505 - 'id' => 'bbp-group-forums',
506 - 'type' => 'upgrade',
507 - 'title' => esc_html__( 'Upgrade BuddyPress Group Forum relationships', 'bbpress' ),
508 - 'description' => esc_html__( 'Run this if you just upgraded BuddyPress Forums from Legacy.', 'bbpress' ),
509 - 'callback' => 'bbp_admin_upgrade_group_forum_relationship',
510 - 'priority' => 140,
511 - 'version' => esc_html__( 'Any', 'bbpress' ),
512 - 'overhead' => 'low',
513 - 'components' => array( bbp_get_forum_post_type() )
514 - )
515 - );
443 + bbp_register_repair_tool( array(
444 + 'id' => 'bbp-group-forums',
445 + 'type' => 'upgrade',
446 + 'title' => esc_html__( 'Upgrade BuddyPress Group Forum relationships', 'bbpress' ),
447 + 'description' => esc_html__( 'Run this if you just upgraded BuddyPress Forums from Legacy.', 'bbpress' ),
448 + 'callback' => 'bbp_admin_upgrade_group_forum_relationship',
449 + 'priority' => 140,
450 + 'version' => esc_html__( 'Any', 'bbpress' ),
451 + 'overhead' => 'low',
452 + 'components' => array( bbp_get_forum_post_type() )
453 + ) );
516 454 }
517 455
518 456 /**
519 - * Output the tabs in the admin area.
457 + * Output the tabs in the admin area
520 458 *
521 459 * @since 2.1.0 bbPress (r3872)
522 460 *
523 - * @param string $active_tab Name of the tab that is active.
461 + * @param string $active_tab Name of the tab that is active
524 462 */
525 463 function bbp_tools_admin_tabs( $active_tab = '' ) {
526 464 echo bbp_get_tools_admin_tabs( $active_tab );
527 465 }
528 466
529 -/**
530 - * Output the tabs in the admin area.
531 - *
532 - * @since 2.1.0 bbPress (r3872)
533 - *
534 - * @param string $active_tab Name of the tab that is active.
535 - *
536 - * @return string
537 - */
538 -function bbp_get_tools_admin_tabs( $active_tab = '' ) {
467 + /**
468 + * Output the tabs in the admin area
469 + *
470 + * @since 2.1.0 bbPress (r3872)
471 + *
472 + * @param string $active_tab Name of the tab that is active
473 + */
474 + function bbp_get_tools_admin_tabs( $active_tab = '' ) {
539 475
540 - // Declare local variables
541 - $tabs_html = '';
542 - $idle_class = 'nav-tab';
543 - $active_class = 'nav-tab nav-tab-active';
476 + // Declare local variables
477 + $tabs_html = '';
478 + $idle_class = 'nav-tab';
479 + $active_class = 'nav-tab nav-tab-active';
544 480
545 - // Setup core admin tabs
546 - $tabs = bbp_get_tools_admin_pages();
481 + // Setup core admin tabs
482 + $tabs = bbp_get_tools_admin_pages();
547 483
548 - // Loop through tabs and build navigation
549 - foreach ( $tabs as $tab ) {
484 + // Loop through tabs and build navigation
485 + foreach ( $tabs as $tab ) {
550 486
551 - // Skip if user cannot visit page
552 - if ( ! current_user_can( $tab['cap'] ) ) {
553 - continue;
487 + // Skip if user cannot visit page
488 + if ( ! current_user_can( $tab['cap'] ) ) {
489 + continue;
490 + }
491 +
492 + // Setup tab HTML
493 + $is_current = (bool) ( $tab['page'] === $active_tab );
494 + $tab_class = $is_current ? $active_class : $idle_class;
495 + $tab_url = add_query_arg( array( 'page' => $tab['page'] ), admin_url( 'tools.php' ) );
496 +
497 + // Tab name is not escaped - may contain HTML
498 + $tabs_html .= '<a href="' . esc_url( $tab_url ) . '" class="' . esc_attr( $tab_class ) . '">' . $tab['name'] . '</a>';
554 499 }
555 500
556 - // Setup tab HTML
557 - $is_current = (bool) ( $tab['page'] === $active_tab );
558 - $tab_class = $is_current ? $active_class : $idle_class;
559 - $tab_url = add_query_arg( array( 'page' => $tab['page'] ), admin_url( 'tools.php' ) );
560 -
561 - // Tab name is not escaped - may contain HTML
562 - $tabs_html .= '<a href="' . esc_url( $tab_url ) . '" class="' . esc_attr( $tab_class ) . '">' . $tab['name'] . '</a>';
501 + // Output the tabs
502 + return $tabs_html;
563 503 }
564 504
565 - // Output the tabs
566 - return $tabs_html;
567 -}
568 -
569 505 /**
570 - * Return possible tools pages.
506 + * Return possible tools pages
571 507 *
572 508 * @since 2.6.0 bbPress (r6273)
573 509 *
574 510 * @return array
@@ -577,53 +513,44 @@
577 513
578 514 // Get tools URL one time & use in each tab
579 515 $tools_url = admin_url( 'tools.php' );
580 516
581 - /**
582 - * Filters the tools admin pages.
583 - *
584 - * @since 2.6.0 bbPress (r6273)
585 - *
586 - * @param array $pages The default array of tools pages.
587 - */
588 - return (array) apply_filters(
589 - 'bbp_tools_admin_tabs',
517 + // Filter & return
518 + return (array) apply_filters( 'bbp_tools_admin_tabs', array(
590 519 array(
591 - array(
592 - 'page' => 'bbp-repair',
593 - 'func' => 'bbp_admin_repair_page',
594 - 'cap' => 'bbp_tools_repair_page',
595 - 'name' => bbp_maybe_append_pending_upgrade_count( esc_html__( 'Repair Forums', 'bbpress' ), 'repair' ),
520 + 'page' => 'bbp-repair',
521 + 'func' => 'bbp_admin_repair_page',
522 + 'cap' => 'bbp_tools_repair_page',
523 + 'name' => bbp_maybe_append_pending_upgrade_count( esc_html__( 'Repair Forums', 'bbpress' ), 'repair' ),
596 524
597 - // Deprecated 2.6.0
598 - 'href' => add_query_arg( array( 'page' => 'bbp-repair' ), $tools_url )
599 - ),
600 - array(
601 - 'page' => 'bbp-upgrade',
602 - 'func' => 'bbp_admin_upgrade_page',
603 - 'cap' => 'bbp_tools_upgrade_page',
604 - 'name' => bbp_maybe_append_pending_upgrade_count( esc_html__( 'Upgrade Forums', 'bbpress' ), 'upgrade' ),
525 + // Deprecated 2.6.0
526 + 'href' => add_query_arg( array( 'page' => 'bbp-repair' ), $tools_url )
527 + ),
528 + array(
529 + 'page' => 'bbp-upgrade',
530 + 'func' => 'bbp_admin_upgrade_page',
531 + 'cap' => 'bbp_tools_upgrade_page',
532 + 'name' => bbp_maybe_append_pending_upgrade_count( esc_html__( 'Upgrade Forums', 'bbpress' ), 'upgrade' ),
605 533
606 - // Deprecated 2.6.0
607 - 'href' => add_query_arg( array( 'page' => 'bbp-upgrade' ), $tools_url )
608 - ),
609 - array(
610 - 'page' => 'bbp-converter',
611 - 'func' => 'bbp_converter_settings_page',
612 - 'cap' => 'bbp_tools_import_page',
613 - 'name' => esc_html__( 'Import Forums', 'bbpress' ),
534 + // Deprecated 2.6.0
535 + 'href' => add_query_arg( array( 'page' => 'bbp-upgrade' ), $tools_url )
536 + ),
537 + array(
538 + 'page' => 'bbp-converter',
539 + 'func' => 'bbp_converter_settings_page',
540 + 'cap' => 'bbp_tools_import_page',
541 + 'name' => esc_html__( 'Import Forums', 'bbpress' ),
614 542
615 - // Deprecated 2.6.0
616 - 'href' => add_query_arg( array( 'page' => 'bbp-converter' ), $tools_url )
617 - ),
618 - array(
619 - 'page' => 'bbp-reset',
620 - 'func' => 'bbp_admin_reset_page',
621 - 'cap' => 'bbp_tools_reset_page',
622 - 'name' => esc_html__( 'Reset Forums', 'bbpress' ),
543 + // Deprecated 2.6.0
544 + 'href' => add_query_arg( array( 'page' => 'bbp-converter' ), $tools_url )
545 + ),
546 + array(
547 + 'page' => 'bbp-reset',
548 + 'func' => 'bbp_admin_reset_page',
549 + 'cap' => 'bbp_tools_reset_page',
550 + 'name' => esc_html__( 'Reset Forums', 'bbpress' ),
623 551
624 - // Deprecated 2.6.0
625 - 'href' => add_query_arg( array( 'page' => 'bbp-reset' ), $tools_url )
626 - )
552 + // Deprecated 2.6.0
553 + 'href' => add_query_arg( array( 'page' => 'bbp-reset' ), $tools_url )
627 554 )
628 - );
555 + ) );
629 556 }