PluginProbe
bbPress / 2.6.19
bbPress v2.6.19
2.6.19 2.6.18 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 All 74 releases
bbpress / includes / admin / settings.php

settings.php in bbPress 2.6.19, at includes/admin/settings.php

2,304 lines 75.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * bbPress Admin Settings
5 *
6 * @package bbPress
7 * @subpackage Administration
8 */
9
10 // Exit if accessed directly
11 defined( 'ABSPATH' ) || exit;
12
13 /** Sections ******************************************************************/
14
15 /**
16 * Get the Forums settings sections.
17 *
18 * @since 2.1.0 bbPress (r4002)
19 *
20 * @return array
21 */
22 function bbp_admin_get_settings_sections() {
23
24 // Filter & return
25 return (array) apply_filters(
26 'bbp_admin_get_settings_sections',
27 array(
28
29 // Settings
30 'bbp_settings_users' => array(
31 'title' => esc_html__( 'Forum User Settings', 'bbpress' ),
32 'callback' => 'bbp_admin_setting_callback_user_section',
33 'page' => 'discussion'
34 ),
35 'bbp_settings_features' => array(
36 'title' => esc_html__( 'Forum Features', 'bbpress' ),
37 'callback' => 'bbp_admin_setting_callback_features_section',
38 'page' => 'discussion'
39 ),
40 'bbp_settings_theme_compat' => array(
41 'title' => esc_html__( 'Forum Theme Packages', 'bbpress' ),
42 'callback' => 'bbp_admin_setting_callback_subtheme_section',
43 'page' => 'general'
44 ),
45 'bbp_settings_per_page' => array(
46 'title' => esc_html__( 'Topics and Replies Per Page', 'bbpress' ),
47 'callback' => 'bbp_admin_setting_callback_per_page_section',
48 'page' => 'reading'
49 ),
50 'bbp_settings_per_rss_page' => array(
51 'title' => esc_html__( 'Topics and Replies Per RSS Page', 'bbpress' ),
52 'callback' => 'bbp_admin_setting_callback_per_rss_page_section',
53 'page' => 'reading',
54 ),
55 'bbp_settings_root_slugs' => array(
56 'title' => esc_html__( 'Forum Root Slug', 'bbpress' ),
57 'callback' => 'bbp_admin_setting_callback_root_slug_section',
58 'page' => 'permalink'
59 ),
60 'bbp_settings_single_slugs' => array(
61 'title' => esc_html__( 'Forum Single Slugs', 'bbpress' ),
62 'callback' => 'bbp_admin_setting_callback_single_slug_section',
63 'page' => 'permalink',
64 ),
65 'bbp_settings_user_slugs' => array(
66 'title' => esc_html__( 'Forum User Slugs', 'bbpress' ),
67 'callback' => 'bbp_admin_setting_callback_user_slug_section',
68 'page' => 'permalink',
69 ),
70
71 // Extend
72 'bbp_settings_buddypress' => array(
73 'title' => esc_html__( 'Forum Integration for BuddyPress', 'bbpress' ),
74 'callback' => 'bbp_admin_setting_callback_buddypress_section',
75 'page' => 'buddypress',
76 ),
77 'bbp_settings_akismet' => array(
78 'title' => esc_html__( 'Forum Integration for Akismet', 'bbpress' ),
79 'callback' => 'bbp_admin_setting_callback_akismet_section',
80 'page' => 'discussion'
81 ),
82
83 // Converter
84 'bbp_converter_connection' => array(
85 'title' => esc_html__( 'Database Settings', 'bbpress' ),
86 'callback' => 'bbp_converter_setting_callback_main_section',
87 'page' => 'converter'
88 ),
89 'bbp_converter_options' => array(
90 'title' => esc_html__( 'Options', 'bbpress' ),
91 'callback' => 'bbp_converter_setting_callback_options_section',
92 'page' => 'converter'
93 )
94 )
95 );
96 }
97
98 /**
99 * Get all of the settings fields.
100 *
101 * @since 2.1.0 bbPress (r4002)
102 *
103 * @return array
104 */
105 function bbp_admin_get_settings_fields() {
106
107 // Filter & return
108 return (array) apply_filters(
109 'bbp_admin_get_settings_fields',
110 array(
111
112 /** User Section ******************************************************/
113
114 'bbp_settings_users' => array(
115
116 // Default role setting
117 '_bbp_default_role' => array(
118 'sanitize_callback' => 'bbp_admin_sanitize_default_role',
119 'args' => array()
120 ),
121
122 // Allow global access
123 '_bbp_allow_global_access' => array(
124 'title' => esc_html__( 'Roles', 'bbpress' ),
125 'callback' => 'bbp_admin_setting_callback_global_access',
126 'sanitize_callback' => 'intval',
127 'args' => array()
128 ),
129
130 // Allow content throttling
131 '_bbp_allow_content_throttle' => array(
132 'sanitize_callback' => 'intval',
133 'args' => array()
134 ),
135
136 // Throttle setting
137 '_bbp_throttle_time' => array(
138 'title' => esc_html__( 'Flooding', 'bbpress' ),
139 'callback' => 'bbp_admin_setting_callback_throttle',
140 'sanitize_callback' => 'intval',
141 'args' => array()
142 ),
143
144 // Allow content editing
145 '_bbp_allow_content_edit' => array(
146 'sanitize_callback' => 'intval',
147 'args' => array()
148 ),
149
150 // Edit lock setting
151 '_bbp_edit_lock' => array(
152 'title' => esc_html__( 'Editing', 'bbpress' ),
153 'callback' => 'bbp_admin_setting_callback_editlock',
154 'sanitize_callback' => 'intval',
155 'args' => array()
156 ),
157
158 // Allow anonymous posting setting
159 '_bbp_allow_anonymous' => array(
160 'title' => esc_html__( 'Anonymous', 'bbpress' ),
161 'callback' => 'bbp_admin_setting_callback_anonymous',
162 'sanitize_callback' => 'intval',
163 'args' => array()
164 )
165 ),
166
167 /** Features Section **************************************************/
168
169 'bbp_settings_features' => array(
170
171 // Allow auto embedding setting
172 '_bbp_use_autoembed' => array(
173 'title' => esc_html__( 'Auto-embed links', 'bbpress' ),
174 'callback' => 'bbp_admin_setting_callback_use_autoembed',
175 'sanitize_callback' => 'intval',
176 'args' => array()
177 ),
178
179 // Set reply threading level
180 '_bbp_thread_replies_depth' => array(
181 'title' => esc_html__( 'Reply Threading', 'bbpress' ),
182 'callback' => 'bbp_admin_setting_callback_thread_replies_depth',
183 'sanitize_callback' => 'intval',
184 'args' => array()
185 ),
186
187 // Allow threaded replies
188 '_bbp_allow_threaded_replies' => array(
189 'sanitize_callback' => 'intval',
190 'args' => array()
191 ),
192
193 // Allow topic and reply revisions
194 '_bbp_allow_revisions' => array(
195 'title' => esc_html__( 'Revisions', 'bbpress' ),
196 'callback' => 'bbp_admin_setting_callback_revisions',
197 'sanitize_callback' => 'intval',
198 'args' => array()
199 ),
200
201 // Allow favorites setting
202 '_bbp_enable_favorites' => array(
203 'title' => esc_html__( 'Favorites', 'bbpress' ),
204 'callback' => 'bbp_admin_setting_callback_favorites',
205 'sanitize_callback' => 'intval',
206 'args' => array()
207 ),
208
209 // Allow subscriptions setting
210 '_bbp_enable_subscriptions' => array(
211 'title' => esc_html__( 'Subscriptions', 'bbpress' ),
212 'callback' => 'bbp_admin_setting_callback_subscriptions',
213 'sanitize_callback' => 'intval',
214 'args' => array()
215 ),
216
217 // Allow engagements setting
218 '_bbp_enable_engagements' => array(
219 'title' => esc_html__( 'Engagements', 'bbpress' ),
220 'callback' => 'bbp_admin_setting_callback_engagements',
221 'sanitize_callback' => 'intval',
222 'args' => array()
223 ),
224
225 // Allow topic tags
226 '_bbp_allow_topic_tags' => array(
227 'title' => esc_html__( 'Topic tags', 'bbpress' ),
228 'callback' => 'bbp_admin_setting_callback_topic_tags',
229 'sanitize_callback' => 'intval',
230 'args' => array()
231 ),
232
233 // Allow topic tags
234 '_bbp_allow_search' => array(
235 'title' => esc_html__( 'Search', 'bbpress' ),
236 'callback' => 'bbp_admin_setting_callback_search',
237 'sanitize_callback' => 'intval',
238 'args' => array()
239 ),
240
241 // Allow fancy editor setting
242 '_bbp_use_wp_editor' => array(
243 'title' => esc_html__( 'Post Formatting', 'bbpress' ),
244 'callback' => 'bbp_admin_setting_callback_use_wp_editor',
245 'args' => array(),
246 'sanitize_callback' => 'intval'
247 ),
248
249 // Allow per-forum moderators
250 '_bbp_allow_forum_mods' => array(
251 'title' => esc_html__( 'Per-Forum Moderators', 'bbpress' ),
252 'callback' => 'bbp_admin_setting_callback_forum_mods',
253 'sanitize_callback' => 'intval',
254 'args' => array()
255 ),
256
257 // Allow moderators to edit users
258 '_bbp_allow_super_mods' => array(
259 'title' => esc_html__( 'Super Moderators', 'bbpress' ),
260 'callback' => 'bbp_admin_setting_callback_super_mods',
261 'sanitize_callback' => 'intval',
262 'capability' => 'edit_users',
263 'args' => array()
264 )
265 ),
266
267 /** Theme Packages ****************************************************/
268
269 'bbp_settings_theme_compat' => array(
270
271 // Theme package setting
272 '_bbp_theme_package_id' => array(
273 'title' => esc_html__( 'Current Package', 'bbpress' ),
274 'callback' => 'bbp_admin_setting_callback_subtheme_id',
275 'sanitize_callback' => 'bbp_admin_sanitize_theme_package_id',
276 'args' => array()
277 )
278 ),
279
280 /** Per Page Section **************************************************/
281
282 'bbp_settings_per_page' => array(
283
284 // Topics per page setting
285 '_bbp_topics_per_page' => array(
286 'title' => esc_html__( 'Topics', 'bbpress' ),
287 'callback' => 'bbp_admin_setting_callback_topics_per_page',
288 'sanitize_callback' => 'intval',
289 'args' => array( 'label_for' => '_bbp_topics_per_page' )
290 ),
291
292 // Replies per page setting
293 '_bbp_replies_per_page' => array(
294 'title' => esc_html__( 'Replies', 'bbpress' ),
295 'callback' => 'bbp_admin_setting_callback_replies_per_page',
296 'sanitize_callback' => 'intval',
297 'args' => array( 'label_for' => '_bbp_replies_per_page' )
298 )
299 ),
300
301 /** Per RSS Page Section **********************************************/
302
303 'bbp_settings_per_rss_page' => array(
304
305 // Topics per page setting
306 '_bbp_topics_per_rss_page' => array(
307 'title' => esc_html__( 'Topics', 'bbpress' ),
308 'callback' => 'bbp_admin_setting_callback_topics_per_rss_page',
309 'sanitize_callback' => 'intval',
310 'args' => array( 'label_for' => '_bbp_topics_per_rss_page' )
311 ),
312
313 // Replies per page setting
314 '_bbp_replies_per_rss_page' => array(
315 'title' => esc_html__( 'Replies', 'bbpress' ),
316 'callback' => 'bbp_admin_setting_callback_replies_per_rss_page',
317 'sanitize_callback' => 'intval',
318 'args' => array( 'label_for' => '_bbp_replies_per_rss_page' )
319 )
320 ),
321
322 /** Front Slugs *******************************************************/
323
324 'bbp_settings_root_slugs' => array(
325
326 // Root slug setting
327 '_bbp_root_slug' => array(
328 'title' => esc_html__( 'Forum Root', 'bbpress' ),
329 'callback' => 'bbp_admin_setting_callback_root_slug',
330 'sanitize_callback' => 'bbp_sanitize_slug',
331 'args' => array( 'label_for' => '_bbp_root_slug' )
332 ),
333
334 // Include root setting
335 '_bbp_include_root' => array(
336 'title' => esc_html__( 'Forum Prefix', 'bbpress' ),
337 'callback' => 'bbp_admin_setting_callback_include_root',
338 'sanitize_callback' => 'intval',
339 'args' => array()
340 ),
341
342 // What to show on Forum Root
343 '_bbp_show_on_root' => array(
344 'title' => esc_html__( 'Forum root should show', 'bbpress' ),
345 'callback' => 'bbp_admin_setting_callback_show_on_root',
346 'sanitize_callback' => 'sanitize_text_field',
347 'args' => array( 'label_for' => '_bbp_show_on_root' )
348 ),
349 ),
350
351 /** Single Slugs ******************************************************/
352
353 'bbp_settings_single_slugs' => array(
354
355 // Forum slug setting
356 '_bbp_forum_slug' => array(
357 'title' => esc_html__( 'Forum', 'bbpress' ),
358 'callback' => 'bbp_admin_setting_callback_forum_slug',
359 'sanitize_callback' => 'bbp_sanitize_slug',
360 'args' => array( 'label_for' => '_bbp_forum_slug' )
361 ),
362
363 // Topic slug setting
364 '_bbp_topic_slug' => array(
365 'title' => esc_html__( 'Topic', 'bbpress' ),
366 'callback' => 'bbp_admin_setting_callback_topic_slug',
367 'sanitize_callback' => 'bbp_sanitize_slug',
368 'args' => array( 'label_for' => '_bbp_topic_slug' )
369 ),
370
371 // Topic tag slug setting
372 '_bbp_topic_tag_slug' => array(
373 'title' => esc_html__( 'Topic Tag', 'bbpress' ),
374 'callback' => 'bbp_admin_setting_callback_topic_tag_slug',
375 'sanitize_callback' => 'bbp_sanitize_slug',
376 'args' => array( 'label_for' => '_bbp_topic_tag_slug' )
377 ),
378
379 // View slug setting
380 '_bbp_view_slug' => array(
381 'title' => esc_html__( 'Topic View', 'bbpress' ),
382 'callback' => 'bbp_admin_setting_callback_view_slug',
383 'sanitize_callback' => 'bbp_sanitize_slug',
384 'args' => array( 'label_for' => '_bbp_view_slug' )
385 ),
386
387 // Reply slug setting
388 '_bbp_reply_slug' => array(
389 'title' => _x( 'Reply', 'noun', 'bbpress' ),
390 'callback' => 'bbp_admin_setting_callback_reply_slug',
391 'sanitize_callback' => 'bbp_sanitize_slug',
392 'args' => array( 'label_for' => '_bbp_reply_slug' )
393 ),
394
395 // Edit slug setting
396 '_bbp_edit_slug' => array(
397 'title' => esc_html__( 'Edit', 'bbpress' ),
398 'callback' => 'bbp_admin_setting_callback_edit_slug',
399 'sanitize_callback' => 'bbp_sanitize_slug',
400 'args' => array( 'label_for' => '_bbp_edit_slug' )
401 ),
402
403 // Search slug setting
404 '_bbp_search_slug' => array(
405 'title' => esc_html__( 'Search', 'bbpress' ),
406 'callback' => 'bbp_admin_setting_callback_search_slug',
407 'sanitize_callback' => 'bbp_sanitize_slug',
408 'args' => array( 'label_for' => '_bbp_search_slug' )
409 )
410 ),
411
412 /** User Slugs ********************************************************/
413
414 'bbp_settings_user_slugs' => array(
415
416 // User slug setting
417 '_bbp_user_slug' => array(
418 'title' => esc_html__( 'User Base', 'bbpress' ),
419 'callback' => 'bbp_admin_setting_callback_user_slug',
420 'sanitize_callback' => 'bbp_sanitize_slug',
421 'args' => array( 'label_for' => '_bbp_user_slug' )
422 ),
423
424 // Topics slug setting
425 '_bbp_topic_archive_slug' => array(
426 'title' => esc_html__( 'Topics Started', 'bbpress' ),
427 'callback' => 'bbp_admin_setting_callback_topic_archive_slug',
428 'sanitize_callback' => 'bbp_sanitize_slug',
429 'args' => array( 'label_for' => '_bbp_topic_archive_slug' )
430 ),
431
432 // Replies slug setting
433 '_bbp_reply_archive_slug' => array(
434 'title' => esc_html__( 'Replies Created', 'bbpress' ),
435 'callback' => 'bbp_admin_setting_callback_reply_archive_slug',
436 'sanitize_callback' => 'bbp_sanitize_slug',
437 'args' => array( 'label_for' => '_bbp_reply_archive_slug' )
438 ),
439
440 // Favorites slug setting
441 '_bbp_user_favs_slug' => array(
442 'title' => esc_html__( 'Favorite Topics', 'bbpress' ),
443 'callback' => 'bbp_admin_setting_callback_user_favs_slug',
444 'sanitize_callback' => 'bbp_sanitize_slug',
445 'args' => array( 'label_for' => '_bbp_user_favs_slug' )
446 ),
447
448 // Subscriptions slug setting
449 '_bbp_user_subs_slug' => array(
450 'title' => esc_html__( 'Subscriptions', 'bbpress' ),
451 'callback' => 'bbp_admin_setting_callback_user_subs_slug',
452 'sanitize_callback' => 'bbp_sanitize_slug',
453 'args' => array( 'label_for' => '_bbp_user_subs_slug' )
454 ),
455
456 // Engagements slug setting
457 '_bbp_user_engs_slug' => array(
458 'title' => esc_html__( 'Engagements', 'bbpress' ),
459 'callback' => 'bbp_admin_setting_callback_user_engagements_slug',
460 'sanitize_callback' => 'bbp_sanitize_slug',
461 'args' => array( 'label_for' => '_bbp_user_engs_slug' )
462 )
463 ),
464
465 /** BuddyPress ********************************************************/
466
467 'bbp_settings_buddypress' => array(
468
469 // Are group forums enabled?
470 '_bbp_enable_group_forums' => array(
471 'title' => esc_html__( 'Group Forums', 'bbpress' ),
472 'callback' => 'bbp_admin_setting_callback_group_forums',
473 'sanitize_callback' => 'intval',
474 'args' => array()
475 ),
476
477 // Group forums parent forum ID
478 '_bbp_group_forums_root_id' => array(
479 'title' => esc_html__( 'Primary Forum', 'bbpress' ),
480 'callback' => 'bbp_admin_setting_callback_group_forums_root_id',
481 'sanitize_callback' => 'intval',
482 'args' => array( 'label_for' => '_bbp_group_forums_root_id' )
483 )
484 ),
485
486 /** Akismet ***********************************************************/
487
488 'bbp_settings_akismet' => array(
489
490 // Should we use Akismet
491 '_bbp_enable_akismet' => array(
492 'title' => esc_html__( 'Use Akismet', 'bbpress' ),
493 'callback' => 'bbp_admin_setting_callback_akismet',
494 'sanitize_callback' => 'intval',
495 'args' => array()
496 )
497 ),
498
499 /** Converter Page ****************************************************/
500
501 // Connection
502 'bbp_converter_connection' => array(
503
504 // System Select
505 '_bbp_converter_platform' => array(
506 'title' => esc_html__( 'Select Platform', 'bbpress' ),
507 'callback' => 'bbp_converter_setting_callback_platform',
508 'sanitize_callback' => 'sanitize_text_field',
509 'args' => array( 'label_for' => '_bbp_converter_platform' )
510 ),
511
512 // Database Server
513 '_bbp_converter_db_server' => array(
514 'title' => esc_html__( 'Database Server', 'bbpress' ),
515 'callback' => 'bbp_converter_setting_callback_dbserver',
516 'sanitize_callback' => 'sanitize_text_field',
517 'args' => array( 'label_for' => '_bbp_converter_db_server' )
518 ),
519
520 // Database Server Port
521 '_bbp_converter_db_port' => array(
522 'title' => esc_html__( 'Database Port', 'bbpress' ),
523 'callback' => 'bbp_converter_setting_callback_dbport',
524 'sanitize_callback' => 'intval',
525 'args' => array( 'label_for' => '_bbp_converter_db_port' )
526 ),
527
528 // Database Name
529 '_bbp_converter_db_name' => array(
530 'title' => esc_html__( 'Database Name', 'bbpress' ),
531 'callback' => 'bbp_converter_setting_callback_dbname',
532 'sanitize_callback' => 'sanitize_text_field',
533 'args' => array( 'label_for' => '_bbp_converter_db_name' )
534 ),
535
536 // Database User
537 '_bbp_converter_db_user' => array(
538 'title' => esc_html__( 'Database User', 'bbpress' ),
539 'callback' => 'bbp_converter_setting_callback_dbuser',
540 'sanitize_callback' => 'sanitize_text_field',
541 'args' => array( 'label_for' => '_bbp_converter_db_user' )
542 ),
543
544 // Database Password
545 '_bbp_converter_db_pass' => array(
546 'title' => esc_html__( 'Database Password', 'bbpress' ),
547 'callback' => 'bbp_converter_setting_callback_dbpass',
548 'sanitize_callback' => 'sanitize_text_field',
549 'args' => array( 'label_for' => '_bbp_converter_db_pass' )
550 ),
551
552 // Database Prefix
553 '_bbp_converter_db_prefix' => array(
554 'title' => esc_html__( 'Table Prefix', 'bbpress' ),
555 'callback' => 'bbp_converter_setting_callback_dbprefix',
556 'sanitize_callback' => 'sanitize_text_field',
557 'args' => array( 'label_for' => '_bbp_converter_db_prefix' )
558 )
559 ),
560
561 // Options
562 'bbp_converter_options' => array(
563
564 // Rows Limit
565 '_bbp_converter_rows' => array(
566 'title' => esc_html__( 'Rows Limit', 'bbpress' ),
567 'callback' => 'bbp_converter_setting_callback_rows',
568 'sanitize_callback' => 'intval',
569 'args' => array( 'label_for' => '_bbp_converter_rows' )
570 ),
571
572 // Delay Time
573 '_bbp_converter_delay_time' => array(
574 'title' => esc_html__( 'Delay Time', 'bbpress' ),
575 'callback' => 'bbp_converter_setting_callback_delay_time',
576 'sanitize_callback' => 'intval',
577 'args' => array( 'label_for' => '_bbp_converter_delay_time' )
578 ),
579
580 // Convert Users
581 '_bbp_converter_convert_users' => array(
582 'title' => esc_html__( 'Convert Users', 'bbpress' ),
583 'callback' => 'bbp_converter_setting_callback_convert_users',
584 'sanitize_callback' => 'intval',
585 'args' => array( 'label_for' => '_bbp_converter_convert_users' )
586 ),
587
588 // Halt
589 '_bbp_converter_halt' => array(
590 'title' => esc_html__( 'Stop on Error', 'bbpress' ),
591 'callback' => 'bbp_converter_setting_callback_halt',
592 'sanitize_callback' => 'intval',
593 'args' => array( 'label_for' => '_bbp_converter_halt' )
594 ),
595
596 // Restart
597 '_bbp_converter_restart' => array(
598 'title' => esc_html__( 'Start Over', 'bbpress' ),
599 'callback' => 'bbp_converter_setting_callback_restart',
600 'sanitize_callback' => 'intval',
601 'args' => array( 'label_for' => '_bbp_converter_restart' )
602 ),
603
604 // Clean
605 '_bbp_converter_clean' => array(
606 'title' => esc_html__( 'Helper Data', 'bbpress' ),
607 'callback' => 'bbp_converter_setting_callback_clean',
608 'sanitize_callback' => 'intval',
609 'args' => array( 'label_for' => '_bbp_converter_clean' )
610 )
611 )
612 )
613 );
614 }
615
616 /**
617 * Keep the default forum role within the roles offered by bbPress.
618 *
619 * @since 2.6.19 bbPress (r7707)
620 *
621 * @param mixed $role Submitted role ID.
622 * @return string Valid role ID.
623 */
624 function bbp_admin_sanitize_default_role( $role ) {
625 $roles = bbp_get_dynamic_roles();
626
627 if ( is_string( $role ) && isset( $roles[ $role ] ) ) {
628 return $role;
629 }
630
631 $current = get_option( '_bbp_default_role', bbp_get_participant_role() );
632
633 return is_string( $current ) && isset( $roles[ $current ] )
634 ? $current
635 : bbp_get_participant_role();
636 }
637
638 /**
639 * Keep the active theme package within the registered packages.
640 *
641 * @since 2.6.19 bbPress (r7707)
642 *
643 * @param mixed $package Submitted package ID.
644 * @return string Valid package ID.
645 */
646 function bbp_admin_sanitize_theme_package_id( $package ) {
647 $packages = (array) bbpress()->theme_compat->packages;
648
649 if ( is_string( $package ) && isset( $packages[ $package ] ) ) {
650 return $package;
651 }
652
653 $current = get_option( '_bbp_theme_package_id', 'default' );
654
655 return is_string( $current ) && isset( $packages[ $current ] )
656 ? $current
657 : 'default';
658 }
659
660 /**
661 * Get settings fields by section.
662 *
663 * @since 2.1.0 bbPress (r4002)
664 *
665 * @param string $section_id ID of the section to get fields for
666 * @staticvar array $fields All of the available fields
667 * @return mixed False if section is invalid, array of fields otherwise.
668 */
669 function bbp_admin_get_settings_fields_for_section( $section_id = '' ) {
670 static $fields = array();
671
672 // Default return value
673 $retval = array();
674
675 // Bail if section is empty
676 if ( empty( $section_id ) ) {
677 return false;
678 }
679
680 // Get all of the fields (so we can snag one section of them)
681 if ( empty( $fields ) ) {
682 $fields = bbp_admin_get_settings_fields();
683 }
684
685 // Get the field by section
686 if ( isset( $fields[ $section_id ] ) ) {
687 $retval = $fields[ $section_id ];
688 }
689
690 // Filter & return
691 return (array) apply_filters( 'bbp_admin_get_settings_fields_for_section', $retval, $section_id );
692 }
693
694 /** User Section **************************************************************/
695
696 /**
697 * User settings section description for the settings page
698 *
699 * @since 2.4.0 bbPress (r4968)
700 */
701 function bbp_admin_setting_callback_user_section() {
702 ?>
703
704 <p><?php esc_html_e( 'Setting time limits and other user posting capabilities', 'bbpress' ); ?></p>
705
706 <?php
707 }
708
709
710 /**
711 * Edit lock setting field
712 *
713 * @since 2.0.0 bbPress (r2737)
714 */
715 function bbp_admin_setting_callback_editlock() {
716
717 // Start the output buffer for the second option
718 ob_start(); ?>
719
720 </label>
721 <label for="_bbp_edit_lock">
722 <input name="_bbp_edit_lock" id="_bbp_edit_lock" type="number" min="0" step="1" value="<?php bbp_form_option( '_bbp_edit_lock', '5' ); ?>" class="small-text"<?php bbp_maybe_admin_setting_disabled( '_bbp_edit_lock' ); ?> />
723
724 <?php $select = ob_get_clean(); ?>
725
726 <label for="_bbp_allow_content_edit">
727 <input name="_bbp_allow_content_edit" id="_bbp_allow_content_edit" type="checkbox" value="1" <?php checked( bbp_allow_content_edit( true ) ); ?><?php bbp_maybe_admin_setting_disabled( '_bbp_allow_content_edit' ); ?> />
728 <?php
729 printf(
730 /* translators: %s: Total minutes to edit a post */
731 esc_html__( 'Allow users to edit their content for %s minutes after posting', 'bbpress' ),
732 $select
733 );
734 ?>
735 </label>
736 <p class="description"><?php esc_html_e( 'If checked, setting to "0 minutes" allows editing forever.', 'bbpress' ); ?></p>
737
738 <?php
739 }
740
741 /**
742 * Throttle setting field
743 *
744 * @since 2.0.0 bbPress (r2737)
745 */
746 function bbp_admin_setting_callback_throttle() {
747
748 // Start the output buffer for the second option
749 ob_start(); ?>
750
751 </label>
752 <label for="_bbp_throttle_time">
753 <input name="_bbp_throttle_time" id="_bbp_throttle_time" type="number" min="0" step="1" value="<?php bbp_form_option( '_bbp_throttle_time', '10' ); ?>" class="small-text"<?php bbp_maybe_admin_setting_disabled( '_bbp_throttle_time' ); ?> />
754
755 <?php $select = ob_get_clean(); ?>
756
757 <label for="_bbp_allow_content_throttle">
758 <input name="_bbp_allow_content_throttle" id="_bbp_allow_content_throttle" type="checkbox" value="1" <?php checked( bbp_allow_content_throttle( true ) ); ?><?php bbp_maybe_admin_setting_disabled( '_bbp_allow_content_throttle' ); ?> />
759 <?php
760 printf(
761 /* translators: %s: Total seconds to throttle a user */
762 esc_html__( 'Allow flood protection by throttling users for %s seconds after posting', 'bbpress' ),
763 $select
764 );
765 ?>
766 </label>
767 <p class="description"><?php esc_html_e( 'Use this to discourage users from spamming your forums.', 'bbpress' ); ?></p>
768
769 <?php
770 }
771
772 /**
773 * Allow anonymous posting setting field
774 *
775 * @since 2.0.0 bbPress (r2737)
776 */
777 function bbp_admin_setting_callback_anonymous() {
778 ?>
779
780 <input name="_bbp_allow_anonymous" id="_bbp_allow_anonymous" type="checkbox" value="1" <?php checked( bbp_allow_anonymous( false ) ); ?><?php bbp_maybe_admin_setting_disabled( '_bbp_allow_anonymous' ); ?> />
781 <label for="_bbp_allow_anonymous"><?php esc_html_e( 'Allow guest users without accounts to create topics and replies', 'bbpress' ); ?></label>
782 <p class="description"><?php esc_html_e( 'Works best on intranets or paired with antispam measures like Akismet.', 'bbpress' ); ?></p>
783
784 <?php
785 }
786
787 /**
788 * Allow global access setting field
789 *
790 * @since 2.0.0 bbPress (r3378)
791 */
792 function bbp_admin_setting_callback_global_access() {
793
794 // Get the default role once rather than loop repeatedly below
795 $default_role = bbp_get_default_role();
796 $roles = bbp_get_dynamic_roles();
797
798 // Start the output buffer for the select dropdown
799 ob_start(); ?>
800
801 </label>
802 <label for="_bbp_default_role">
803 <select name="_bbp_default_role" id="_bbp_default_role" <?php bbp_maybe_admin_setting_disabled( '_bbp_default_role' ); ?>>
804 <?php foreach ( $roles as $role => $details ) : ?>
805
806 <option <?php selected( $default_role, $role ); ?> value="<?php echo esc_attr( $role ); ?>"><?php echo bbp_translate_user_role( $details['name'] ); ?></option>
807
808 <?php endforeach; ?>
809 </select>
810
811 <?php $select = ob_get_clean(); ?>
812
813 <label for="_bbp_allow_global_access">
814 <input name="_bbp_allow_global_access" id="_bbp_allow_global_access" type="checkbox" value="1" <?php checked( bbp_allow_global_access( true ) ); ?><?php bbp_maybe_admin_setting_disabled( '_bbp_allow_global_access' ); ?> />
815 <?php
816 printf(
817 /* translators: %s: Default role name */
818 esc_html__( 'Automatically give registered visitors the %s forum role', 'bbpress' ),
819 $select
820 );
821 ?>
822 </label>
823 <p class="description"><?php esc_html_e( 'Uncheck this to manually assign all user access to your forums.', 'bbpress' ); ?></p>
824
825 <?php
826 }
827
828 /** Features Section **********************************************************/
829
830 /**
831 * Features settings section description for the settings page
832 *
833 * @since 2.4.0 bbPress (r4968)
834 */
835 function bbp_admin_setting_callback_features_section() {
836 ?>
837
838 <p><?php esc_html_e( 'Forum features that can be toggled on and off', 'bbpress' ); ?></p>
839
840 <?php
841 }
842
843 /**
844 * Allow favorites setting field
845 *
846 * @since 2.0.0 bbPress (r2786)
847 */
848 function bbp_admin_setting_callback_favorites() {
849 ?>
850
851 <input name="_bbp_enable_favorites" id="_bbp_enable_favorites" type="checkbox" value="1" <?php checked( bbp_is_favorites_active( true ) ); ?><?php bbp_maybe_admin_setting_disabled( '_bbp_enable_favorites' ); ?> />
852 <label for="_bbp_enable_favorites"><?php esc_html_e( 'Allow users to mark topics as favorites', 'bbpress' ); ?></label>
853
854 <?php
855 }
856
857 /**
858 * Allow subscriptions setting field
859 *
860 * @since 2.0.0 bbPress (r2737)
861 */
862 function bbp_admin_setting_callback_subscriptions() {
863 ?>
864
865 <input name="_bbp_enable_subscriptions" id="_bbp_enable_subscriptions" type="checkbox" value="1" <?php checked( bbp_is_subscriptions_active( true ) ); ?><?php bbp_maybe_admin_setting_disabled( '_bbp_enable_subscriptions' ); ?> />
866 <label for="_bbp_enable_subscriptions"><?php esc_html_e( 'Allow users to subscribe to forums and topics', 'bbpress' ); ?></label>
867
868 <?php
869 }
870
871 /**
872 * Allow engagements setting field
873 *
874 * @since 2.6.0 bbPress (r6321)
875 */
876 function bbp_admin_setting_callback_engagements() {
877 ?>
878
879 <input name="_bbp_enable_engagements" id="_bbp_enable_engagements" type="checkbox" value="1" <?php checked( bbp_is_engagements_active( true ) ); ?><?php bbp_maybe_admin_setting_disabled( '_bbp_enable_engagements' ); ?> />
880 <label for="_bbp_enable_engagements"><?php esc_html_e( 'Allow tracking of topics each user engages in', 'bbpress' ); ?></label>
881
882 <?php
883 }
884
885 /**
886 * Allow topic tags setting field
887 *
888 * @since 2.2.0 bbPress (r4098)
889 */
890 function bbp_admin_setting_callback_topic_tags() {
891 ?>
892
893 <input name="_bbp_allow_topic_tags" id="_bbp_allow_topic_tags" type="checkbox" value="1" <?php checked( bbp_allow_topic_tags( true ) ); ?><?php bbp_maybe_admin_setting_disabled( '_bbp_allow_topic_tags' ); ?> />
894 <label for="_bbp_allow_topic_tags"><?php esc_html_e( 'Allow topics to have tags', 'bbpress' ); ?></label>
895
896 <?php
897 }
898
899 /**
900 * Allow forum-mods setting field
901 *
902 * @since 2.6.0 bbPress (r5834)
903 */
904 function bbp_admin_setting_callback_forum_mods() {
905 ?>
906
907 <input name="_bbp_allow_forum_mods" id="_bbp_allow_forum_mods" type="checkbox" value="1" <?php checked( bbp_allow_forum_mods( true ) ); ?><?php bbp_maybe_admin_setting_disabled( '_bbp_allow_forum_mods' ); ?> />
908 <label for="_bbp_allow_forum_mods"><?php esc_html_e( 'Allow forums to have dedicated moderators', 'bbpress' ); ?></label>
909 <p class="description"><?php esc_html_e( 'This does not include the ability to edit users.', 'bbpress' ); ?></p>
910
911 <?php
912 }
913
914 /**
915 * Allow super-mods setting field
916 *
917 * @since 2.6.0 bbPress (r6563)
918 */
919 function bbp_admin_setting_callback_super_mods() {
920 ?>
921
922 <input name="_bbp_allow_super_mods" id="_bbp_allow_super_mods" type="checkbox" value="1" <?php checked( bbp_allow_super_mods( false ) ); ?><?php bbp_maybe_admin_setting_disabled( '_bbp_allow_super_mods' ); ?> />
923 <label for="_bbp_allow_super_mods"><?php esc_html_e( 'Allow Moderators and Keymasters to edit users', 'bbpress' ); ?></label>
924 <p class="description"><?php esc_html_e( 'In forum profiles, this includes: names, contact info, about, and forum roles.', 'bbpress' ); ?></p>
925
926 <?php
927 }
928
929 /**
930 * Allow forum wide search
931 *
932 * @since 2.4.0 bbPress (r4971)
933 */
934 function bbp_admin_setting_callback_search() {
935 ?>
936
937 <input name="_bbp_allow_search" id="_bbp_allow_search" type="checkbox" value="1" <?php checked( bbp_allow_search( true ) ); ?><?php bbp_maybe_admin_setting_disabled( '_bbp_allow_search' ); ?> />
938 <label for="_bbp_allow_search"><?php esc_html_e( 'Allow forum wide search', 'bbpress' ); ?></label>
939
940 <?php
941 }
942
943 /**
944 * Hierarchical reply maximum depth level setting field
945 *
946 * Replies will be threaded if depth is 2 or greater
947 *
948 * @since 2.4.0 bbPress (r4944)
949 */
950 function bbp_admin_setting_callback_thread_replies_depth() {
951
952 // Set maximum depth for dropdown
953 $max_depth = (int) apply_filters( 'bbp_thread_replies_depth_max', 10 );
954 $current_depth = bbp_thread_replies_depth();
955
956 // Start an output buffer for the select dropdown
957 ob_start(); ?>
958
959 </label>
960 <label for="_bbp_thread_replies_depth">
961 <select name="_bbp_thread_replies_depth" id="_bbp_thread_replies_depth" <?php bbp_maybe_admin_setting_disabled( '_bbp_thread_replies_depth' ); ?>>
962 <?php for ( $i = 2; $i <= $max_depth; $i++ ) : ?>
963
964 <option value="<?php echo esc_attr( $i ); ?>" <?php selected( $i, $current_depth ); ?>><?php echo esc_html( $i ); ?></option>
965
966 <?php endfor; ?>
967 </select>
968
969 <?php $select = ob_get_clean(); ?>
970
971 <label for="_bbp_allow_threaded_replies">
972 <input name="_bbp_allow_threaded_replies" id="_bbp_allow_threaded_replies" type="checkbox" value="1" <?php checked( '1', bbp_allow_threaded_replies( false ) );
973 bbp_maybe_admin_setting_disabled( '_bbp_allow_threaded_replies' ); ?> />
974 <?php printf(
975 /* translators: %s: Depth level input field HTML */
976 esc_html__( 'Enable threaded (nested) replies %s levels deep', 'bbpress' ),
977 $select
978 );
979 ?>
980 </label>
981
982 <?php
983 }
984
985 /**
986 * Allow topic and reply revisions
987 *
988 * @since 2.0.0 bbPress (r3416)
989 */
990 function bbp_admin_setting_callback_revisions() {
991 ?>
992
993 <input name="_bbp_allow_revisions" id="_bbp_allow_revisions" type="checkbox" value="1" <?php checked( bbp_allow_revisions( true ) ); ?><?php bbp_maybe_admin_setting_disabled( '_bbp_allow_revisions' ); ?> />
994 <label for="_bbp_allow_revisions"><?php esc_html_e( 'Allow topic and reply revision logging', 'bbpress' ); ?></label>
995
996 <?php
997 }
998
999 /**
1000 * Use the WordPress editor setting field
1001 *
1002 * @since 2.1.0 bbPress (r3586)
1003 */
1004 function bbp_admin_setting_callback_use_wp_editor() {
1005 ?>
1006
1007 <input name="_bbp_use_wp_editor" id="_bbp_use_wp_editor" type="checkbox" value="1" <?php checked( bbp_use_wp_editor( true ) ); ?><?php bbp_maybe_admin_setting_disabled( '_bbp_use_wp_editor' ); ?> />
1008 <label for="_bbp_use_wp_editor"><?php esc_html_e( 'Add toolbar & buttons to textareas to help with HTML formatting', 'bbpress' ); ?></label>
1009
1010 <?php
1011 }
1012
1013 /**
1014 * Main subtheme section
1015 *
1016 * @since 2.1.0 bbPress (r3830)
1017 */
1018 function bbp_admin_setting_callback_subtheme_section() {
1019 ?>
1020
1021 <p><?php esc_html_e( 'How your forum content is displayed within your existing theme.', 'bbpress' ); ?></p>
1022
1023 <?php
1024 }
1025
1026 /**
1027 * Use the WordPress editor setting field
1028 *
1029 * @since 2.1.0 bbPress (r3830)
1030 */
1031 function bbp_admin_setting_callback_subtheme_id() {
1032
1033 // Declare locale variable
1034 $theme_options = '';
1035 $current_package = bbp_get_theme_package_id( 'default' );
1036
1037 // Note: This should never be empty. /templates/ is the
1038 // canonical backup if no other packages exist. If there's an error here,
1039 // something else is wrong.
1040 //
1041 // @see bbPress::register_theme_packages()
1042 foreach ( (array) bbpress()->theme_compat->packages as $id => $theme ) {
1043 $theme_options .= '<option value="' . esc_attr( $id ) . '"' . selected( $theme->id, $current_package, false ) . '>' . esc_html( $theme->name ) . '</option>';
1044 }
1045
1046 if ( ! empty( $theme_options ) ) : ?>
1047
1048 <select name="_bbp_theme_package_id" id="_bbp_theme_package_id" <?php bbp_maybe_admin_setting_disabled( '_bbp_theme_package_id' ); ?>><?php echo $theme_options; ?></select>
1049 <label for="_bbp_theme_package_id"><?php esc_html_e( 'will serve all bbPress templates', 'bbpress' ); ?></label>
1050
1051 <?php else : ?>
1052
1053 <p><?php esc_html_e( 'No template packages available.', 'bbpress' ); ?></p>
1054
1055 <?php endif;
1056 }
1057
1058 /**
1059 * Allow oEmbed in replies
1060 *
1061 * @since 2.1.0 bbPress (r3753)
1062 */
1063 function bbp_admin_setting_callback_use_autoembed() {
1064 ?>
1065
1066 <input name="_bbp_use_autoembed" id="_bbp_use_autoembed" type="checkbox" value="1" <?php checked( bbp_use_autoembed( true ) ); ?><?php bbp_maybe_admin_setting_disabled( '_bbp_use_autoembed' ); ?> />
1067 <label for="_bbp_use_autoembed"><?php esc_html_e( 'Embed media (YouTube, Twitter, Flickr, etc...) directly into topics and replies', 'bbpress' ); ?></label>
1068
1069 <?php
1070 }
1071
1072 /** Per Page Section **********************************************************/
1073
1074 /**
1075 * Per page settings section description for the settings page
1076 *
1077 * @since 2.0.0 bbPress (r2786)
1078 */
1079 function bbp_admin_setting_callback_per_page_section() {
1080 ?>
1081
1082 <p><?php esc_html_e( 'How many topics and replies to show per page', 'bbpress' ); ?></p>
1083
1084 <?php
1085 }
1086
1087 /**
1088 * Topics per page setting field
1089 *
1090 * @since 2.0.0 bbPress (r2786)
1091 */
1092 function bbp_admin_setting_callback_topics_per_page() {
1093 ?>
1094
1095 <input name="_bbp_topics_per_page" id="_bbp_topics_per_page" type="number" min="1" step="1" value="<?php bbp_form_option( '_bbp_topics_per_page', '15' ); ?>" class="small-text"<?php bbp_maybe_admin_setting_disabled( '_bbp_topics_per_page' ); ?> />
1096 <?php esc_html_e( 'per page', 'bbpress' ); ?>
1097
1098 <?php
1099 }
1100
1101 /**
1102 * Replies per page setting field
1103 *
1104 * @since 2.0.0 bbPress (r2786)
1105 */
1106 function bbp_admin_setting_callback_replies_per_page() {
1107 ?>
1108
1109 <input name="_bbp_replies_per_page" id="_bbp_replies_per_page" type="number" min="1" step="1" value="<?php bbp_form_option( '_bbp_replies_per_page', '15' ); ?>" class="small-text"<?php bbp_maybe_admin_setting_disabled( '_bbp_replies_per_page' ); ?> />
1110 <?php esc_html_e( 'per page', 'bbpress' ); ?>
1111
1112 <?php
1113 }
1114
1115 /** Per RSS Page Section ******************************************************/
1116
1117 /**
1118 * Per page settings section description for the settings page
1119 *
1120 * @since 2.0.0 bbPress (r3170)
1121 */
1122 function bbp_admin_setting_callback_per_rss_page_section() {
1123 ?>
1124
1125 <p><?php esc_html_e( 'How many topics and replies to show per RSS page', 'bbpress' ); ?></p>
1126
1127 <?php
1128 }
1129
1130 /**
1131 * Topics per RSS page setting field
1132 *
1133 * @since 2.0.0 bbPress (r3170)
1134 */
1135 function bbp_admin_setting_callback_topics_per_rss_page() {
1136 ?>
1137
1138 <input name="_bbp_topics_per_rss_page" id="_bbp_topics_per_rss_page" type="number" min="1" step="1" value="<?php bbp_form_option( '_bbp_topics_per_rss_page', '25' ); ?>" class="small-text"<?php bbp_maybe_admin_setting_disabled( '_bbp_topics_per_rss_page' ); ?> />
1139 <?php esc_html_e( 'per page', 'bbpress' ); ?>
1140
1141 <?php
1142 }
1143
1144 /**
1145 * Replies per RSS page setting field
1146 *
1147 * @since 2.0.0 bbPress (r3170)
1148 */
1149 function bbp_admin_setting_callback_replies_per_rss_page() {
1150 ?>
1151
1152 <input name="_bbp_replies_per_rss_page" id="_bbp_replies_per_rss_page" type="number" min="1" step="1" value="<?php bbp_form_option( '_bbp_replies_per_rss_page', '25' ); ?>" class="small-text"<?php bbp_maybe_admin_setting_disabled( '_bbp_replies_per_rss_page' ); ?> />
1153 <?php esc_html_e( 'per page', 'bbpress' ); ?>
1154
1155 <?php
1156 }
1157
1158 /** Slug Section **************************************************************/
1159
1160 /**
1161 * Slugs settings section description for the settings page
1162 *
1163 * @since 2.0.0 bbPress (r3170)
1164 */
1165 function bbp_admin_setting_callback_root_slug_section() {
1166
1167 // Flush rewrite rules when this section is saved
1168 if ( isset( $_GET['settings-updated'] ) && isset( $_GET['page'] ) ) {
1169 flush_rewrite_rules();
1170 } ?>
1171
1172 <p><?php esc_html_e( 'Customize your Forums root. Partner with a WordPress Page and use Shortcodes for more flexibility.', 'bbpress' ); ?></p>
1173
1174 <?php
1175 }
1176
1177 /**
1178 * Root slug setting field
1179 *
1180 * @since 2.0.0 bbPress (r2786)
1181 */
1182 function bbp_admin_setting_callback_root_slug() {
1183 ?>
1184
1185 <input name="_bbp_root_slug" id="_bbp_root_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_root_slug', 'forums', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_root_slug' ); ?> />
1186
1187 <?php
1188 // Slug Check
1189 bbp_form_slug_conflict_check( '_bbp_root_slug', 'forums' );
1190 }
1191
1192 /**
1193 * Include root slug setting field
1194 *
1195 * @since 2.0.0 bbPress (r2786)
1196 */
1197 function bbp_admin_setting_callback_include_root() {
1198 ?>
1199
1200 <input name="_bbp_include_root" id="_bbp_include_root" type="checkbox" value="1" <?php checked( bbp_include_root_slug() ); ?><?php bbp_maybe_admin_setting_disabled( '_bbp_include_root' ); ?> />
1201 <label for="_bbp_include_root"><?php esc_html_e( 'Prefix all forum content with the Forum Root slug (Recommended)', 'bbpress' ); ?></label>
1202
1203 <?php
1204 }
1205
1206 /**
1207 * Include root slug setting field
1208 *
1209 * @since 2.4.0 bbPress (r4932)
1210 */
1211 function bbp_admin_setting_callback_show_on_root() {
1212
1213 // Current setting
1214 $show_on_root = bbp_show_on_root();
1215
1216 // Options for forum root output
1217 $root_options = array(
1218 'forums' => array(
1219 'name' => esc_attr__( 'Forum Index', 'bbpress' )
1220 ),
1221 'topics' => array(
1222 'name' => esc_attr__( 'Topics by Last Post', 'bbpress' )
1223 )
1224 ); ?>
1225
1226 <select name="_bbp_show_on_root" id="_bbp_show_on_root" <?php bbp_maybe_admin_setting_disabled( '_bbp_show_on_root' ); ?>>
1227
1228 <?php foreach ( $root_options as $option_id => $details ) : ?>
1229
1230 <option <?php selected( $show_on_root, $option_id ); ?> value="<?php echo esc_attr( $option_id ); ?>"><?php echo esc_html( $details['name'] ); ?></option>
1231
1232 <?php endforeach; ?>
1233
1234 </select>
1235
1236 <?php
1237
1238 // Look for theme support
1239 $forum_archive = basename( bbp_get_forum_archive_template() );
1240
1241 // This setting doesn't work if the theme has an archive-forum.php template.
1242 if ( ! empty( $forum_archive ) ) : ?>
1243
1244 <p class="description"><?php printf(
1245 /* translators: %s: Forum archive template file path */
1246 esc_html__( 'This setting will be ignored because %s was found in your theme.', 'bbpress' ),
1247 '<code>' . $forum_archive . '</code>'
1248 ); ?></p>
1249
1250 <?php endif;
1251 }
1252
1253 /** User Slug Section *********************************************************/
1254
1255 /**
1256 * Slugs settings section description for the settings page
1257 *
1258 * @since 2.4.0 bbPress (r4932)
1259 */
1260 function bbp_admin_setting_callback_user_slug_section() {
1261 ?>
1262
1263 <p><?php esc_html_e( 'Customize your user profile slugs.', 'bbpress' ); ?></p>
1264
1265 <?php
1266 }
1267
1268 /**
1269 * User slug setting field
1270 *
1271 * @since 2.0.0 bbPress (r2786)
1272 */
1273 function bbp_admin_setting_callback_user_slug() {
1274 ?>
1275
1276 <input name="_bbp_user_slug" id="_bbp_user_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_user_slug', 'users', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_user_slug' ); ?> />
1277
1278 <?php
1279 // Slug Check
1280 bbp_form_slug_conflict_check( '_bbp_user_slug', 'users' );
1281 }
1282
1283 /**
1284 * Topic archive slug setting field
1285 *
1286 * @since 2.0.0 bbPress (r3186)
1287 */
1288 function bbp_admin_setting_callback_topic_archive_slug() {
1289 ?>
1290
1291 <input name="_bbp_topic_archive_slug" id="_bbp_topic_archive_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_topic_archive_slug', 'topics', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_topic_archive_slug' ); ?> />
1292
1293 <?php
1294 // Slug Check
1295 bbp_form_slug_conflict_check( '_bbp_topic_archive_slug', 'topics' );
1296 }
1297
1298 /**
1299 * Reply archive slug setting field
1300 *
1301 * @since 2.4.0 bbPress (r4932)
1302 */
1303 function bbp_admin_setting_callback_reply_archive_slug() {
1304 ?>
1305
1306 <input name="_bbp_reply_archive_slug" id="_bbp_reply_archive_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_reply_archive_slug', 'replies', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_reply_archive_slug' ); ?> />
1307
1308 <?php
1309 // Slug Check
1310 bbp_form_slug_conflict_check( '_bbp_reply_archive_slug', 'replies' );
1311 }
1312
1313 /**
1314 * Favorites slug setting field
1315 *
1316 * @since 2.4.0 bbPress (r4932)
1317 */
1318 function bbp_admin_setting_callback_user_favs_slug() {
1319 ?>
1320
1321 <input name="_bbp_user_favs_slug" id="_bbp_user_favs_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_user_favs_slug', 'favorites', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_user_favs_slug' ); ?> />
1322
1323 <?php
1324 // Slug Check
1325 bbp_form_slug_conflict_check( '_bbp_user_favs_slug', 'favorites' );
1326 }
1327
1328 /**
1329 * Subscriptions slug setting field
1330 *
1331 * @since 2.4.0 bbPress (r4932)
1332 */
1333 function bbp_admin_setting_callback_user_subs_slug() {
1334 ?>
1335
1336 <input name="_bbp_user_subs_slug" id="_bbp_user_subs_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_user_subs_slug', 'subscriptions', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_user_subs_slug' ); ?> />
1337
1338 <?php
1339 // Slug Check
1340 bbp_form_slug_conflict_check( '_bbp_user_subs_slug', 'subscriptions' );
1341 }
1342
1343 /**
1344 * Engagements slug setting field
1345 *
1346 * @since 2.6.0 bbPress (r6320)
1347 */
1348 function bbp_admin_setting_callback_user_engagements_slug() {
1349 ?>
1350
1351 <input name="_bbp_user_engs_slug" id="_bbp_user_engs_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_user_engs_slug', 'engagements', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_user_engs_slug' ); ?> />
1352
1353 <?php
1354 // Slug Check
1355 bbp_form_slug_conflict_check( '_bbp_user_engs_slug', 'engagements' );
1356 }
1357
1358 /** Single Slugs **************************************************************/
1359
1360 /**
1361 * Slugs settings section description for the settings page
1362 *
1363 * @since 2.0.0 bbPress (r3170)
1364 */
1365 function bbp_admin_setting_callback_single_slug_section() {
1366 ?>
1367
1368 <p><?php printf( esc_html__( 'Custom slugs for single forums, topics, replies, tags, views, edit, and search.', 'bbpress' ), get_admin_url( null, 'options-permalink.php' ) ); ?></p>
1369
1370 <?php
1371 }
1372
1373 /**
1374 * Forum slug setting field
1375 *
1376 * @since 2.0.0 bbPress (r2786)
1377 */
1378 function bbp_admin_setting_callback_forum_slug() {
1379 ?>
1380
1381 <input name="_bbp_forum_slug" id="_bbp_forum_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_forum_slug', 'forum', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_forum_slug' ); ?> />
1382
1383 <?php
1384 // Slug Check
1385 bbp_form_slug_conflict_check( '_bbp_forum_slug', 'forum' );
1386 }
1387
1388 /**
1389 * Topic slug setting field
1390 *
1391 * @since 2.0.0 bbPress (r2786)
1392 */
1393 function bbp_admin_setting_callback_topic_slug() {
1394 ?>
1395
1396 <input name="_bbp_topic_slug" id="_bbp_topic_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_topic_slug', 'topic', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_topic_slug' ); ?> />
1397
1398 <?php
1399 // Slug Check
1400 bbp_form_slug_conflict_check( '_bbp_topic_slug', 'topic' );
1401 }
1402
1403 /**
1404 * Reply slug setting field
1405 *
1406 * @since 2.0.0 bbPress (r2786)
1407 */
1408 function bbp_admin_setting_callback_reply_slug() {
1409 ?>
1410
1411 <input name="_bbp_reply_slug" id="_bbp_reply_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_reply_slug', 'reply', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_reply_slug' ); ?> />
1412
1413 <?php
1414 // Slug Check
1415 bbp_form_slug_conflict_check( '_bbp_reply_slug', 'reply' );
1416 }
1417
1418 /**
1419 * Topic tag slug setting field
1420 *
1421 * @since 2.0.0 bbPress (r2786)
1422 */
1423 function bbp_admin_setting_callback_topic_tag_slug() {
1424 ?>
1425
1426 <input name="_bbp_topic_tag_slug" id="_bbp_topic_tag_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_topic_tag_slug', 'topic-tag', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_topic_tag_slug' ); ?> />
1427
1428 <?php
1429
1430 // Slug Check
1431 bbp_form_slug_conflict_check( '_bbp_topic_tag_slug', 'topic-tag' );
1432 }
1433
1434 /**
1435 * View slug setting field
1436 *
1437 * @since 2.0.0 bbPress (r2789)
1438 */
1439 function bbp_admin_setting_callback_view_slug() {
1440 ?>
1441
1442 <input name="_bbp_view_slug" id="_bbp_view_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_view_slug', 'view', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_view_slug' ); ?> />
1443
1444 <?php
1445 // Slug Check
1446 bbp_form_slug_conflict_check( '_bbp_view_slug', 'view' );
1447 }
1448
1449 /**
1450 * Search slug setting field
1451 *
1452 * @since 2.3.0 bbPress (r4579)
1453 */
1454 function bbp_admin_setting_callback_search_slug() {
1455 ?>
1456
1457 <input name="_bbp_search_slug" id="_bbp_search_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_search_slug', 'search', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_search_slug' ); ?> />
1458
1459 <?php
1460 // Slug Check
1461 bbp_form_slug_conflict_check( '_bbp_search_slug', 'search' );
1462 }
1463
1464 /**
1465 * Edit slug setting field
1466 *
1467 * @since 2.6.2 bbPress (r6966)
1468 */
1469 function bbp_admin_setting_callback_edit_slug() {
1470 ?>
1471
1472 <input name="_bbp_edit_slug" id="_bbp_edit_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_edit_slug', 'edit', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_edit_slug' ); ?> />
1473
1474 <?php
1475 // Slug Check
1476 bbp_form_slug_conflict_check( '_bbp_edit_slug', 'edit' );
1477 }
1478
1479 /** BuddyPress ****************************************************************/
1480
1481 /**
1482 * Extension settings section description for the settings page
1483 *
1484 * @since 2.1.0 bbPress (r3575)
1485 */
1486 function bbp_admin_setting_callback_buddypress_section() {
1487 ?>
1488
1489 <p><?php esc_html_e( 'Forum settings for BuddyPress', 'bbpress' ); ?></p>
1490
1491 <?php
1492 }
1493
1494 /**
1495 * Allow BuddyPress group forums setting field
1496 *
1497 * @since 2.1.0 bbPress (r3575)
1498 */
1499 function bbp_admin_setting_callback_group_forums() {
1500 ?>
1501
1502 <input name="_bbp_enable_group_forums" id="_bbp_enable_group_forums" type="checkbox" value="1" <?php checked( bbp_is_group_forums_active( true ) ); ?><?php bbp_maybe_admin_setting_disabled( '_bbp_enable_group_forums' ); ?> />
1503 <label for="_bbp_enable_group_forums"><?php esc_html_e( 'Allow BuddyPress Groups to have their own forums', 'bbpress' ); ?></label>
1504
1505 <?php
1506 }
1507
1508 /**
1509 * Replies per page setting field
1510 *
1511 * @since 2.1.0 bbPress (r3575)
1512 */
1513 function bbp_admin_setting_callback_group_forums_root_id() {
1514
1515 // Group root ID
1516 $group_root = bbp_get_group_forums_root_id();
1517 if ( ! bbp_get_forum( $group_root ) ) {
1518 delete_option( '_bbp_group_forums_root_id' );
1519 $group_root = 0;
1520 }
1521
1522 // Output the dropdown for all forums
1523 $select = bbp_get_dropdown(
1524 array(
1525 'selected' => $group_root,
1526 'show_none' => esc_html__( '&mdash; No parent &mdash;', 'bbpress' ),
1527 'orderby' => 'title',
1528 'order' => 'ASC',
1529 'select_id' => '_bbp_group_forums_root_id',
1530 'disable_categories' => false,
1531 'disabled' => '_bbp_group_forums_root_id'
1532 )
1533 );
1534
1535 // Check cap one time
1536 $can_add_new = current_user_can( 'publish_forums' );
1537 $button = '';
1538
1539 // Text variations based on configuration
1540 if ( empty( $group_root ) && ( true === $can_add_new ) ) {
1541
1542 // New URL
1543 $new_url = wp_nonce_url(
1544 add_query_arg(
1545 array(
1546 'page' => 'bbpress',
1547 'create' => 'bbp-group-forum-root'
1548 ),
1549 admin_url( 'options-general.php' )
1550 ),
1551 '_bbp_group_forums_root_id'
1552 );
1553
1554 // Button & text
1555 $button = '<a href="' . esc_url( $new_url ) . '">' . esc_html__( 'create a new one', 'bbpress' ) . '</a>';
1556 $text = esc_html__( 'Use %s to contain your group forums, or %s', 'bbpress' ); //phpcs:ignore
1557 } else {
1558 /* translators: %s: Forum select dropdown HTML */
1559 $text = esc_html__( 'Use %s to contain your group forums', 'bbpress' );
1560 }
1561
1562 // Output
1563 printf( $text, $select, $button ); ?>
1564 <p class="description"><?php esc_html_e( 'Changing this will not move existing forums.', 'bbpress' ); ?></p>
1565
1566 <?php
1567 }
1568
1569 /** Akismet *******************************************************************/
1570
1571 /**
1572 * Extension settings section description for the settings page
1573 *
1574 * @since 2.1.0 bbPress (r3575)
1575 */
1576 function bbp_admin_setting_callback_akismet_section() {
1577 ?>
1578
1579 <p><?php esc_html_e( 'Forum settings for Akismet', 'bbpress' ); ?></p>
1580
1581 <?php
1582 }
1583
1584
1585 /**
1586 * Allow Akismet setting field
1587 *
1588 * @since 2.1.0 bbPress (r3575)
1589 */
1590 function bbp_admin_setting_callback_akismet() {
1591 ?>
1592
1593 <input name="_bbp_enable_akismet" id="_bbp_enable_akismet" type="checkbox" value="1" <?php checked( bbp_is_akismet_active( true ) ); ?><?php bbp_maybe_admin_setting_disabled( '_bbp_enable_akismet' ); ?> />
1594 <label for="_bbp_enable_akismet"><?php _e( 'Allow Akismet to actively prevent forum spam.', 'bbpress' ); // phpcs:ignore WordPress.Security.EscapeOutput.UnsafePrintingFunction ?></label>
1595
1596 <?php
1597 }
1598
1599 /** Settings Page *************************************************************/
1600
1601 /**
1602 * The main settings page
1603 *
1604 * @since 2.0.0 bbPress (r2594)
1605 */
1606 function bbp_admin_settings() {
1607 ?>
1608
1609 <div class="wrap">
1610 <h1 class="wp-heading-inline"><?php esc_html_e( 'Forums Settings', 'bbpress' ); ?></h1>
1611 <hr class="wp-header-end">
1612
1613 <form action="options.php" method="post">
1614
1615 <?php settings_fields( 'bbpress' ); ?>
1616
1617 <?php do_settings_sections( 'bbpress' ); ?>
1618
1619 <p class="submit">
1620 <input type="submit" name="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'bbpress' ); ?>" />
1621 </p>
1622 </form>
1623 </div>
1624
1625 <?php
1626 }
1627
1628 /** Converter Section *********************************************************/
1629
1630 /**
1631 * Main settings section description for the settings page
1632 *
1633 * @since 2.1.0 bbPress (r3816)
1634 */
1635 function bbp_converter_setting_callback_main_section() {
1636 ?>
1637
1638 <p><?php esc_html_e( 'Information about the database for your previous forums so they can be converted.', 'bbpress' ); ?></p>
1639
1640 <?php
1641 }
1642
1643 /**
1644 * Edit Platform setting field
1645 *
1646 * @since 2.1.0 bbPress (r3816)
1647 */
1648 function bbp_converter_setting_callback_platform() {
1649
1650 // Converters
1651 $current = get_option( '_bbp_converter_platform' );
1652 $converters = bbp_get_converters();
1653 $options = '';
1654
1655 // Put options together
1656 foreach ( $converters as $name => $file ) {
1657 $options .= '<option value="' . esc_attr( $name ) . '"' . selected( $name, $current, false ) . '>' . esc_html( $name ) . '</option>';
1658 } ?>
1659
1660 <select name="_bbp_converter_platform" id="_bbp_converter_platform"><?php echo $options; ?></select>
1661 <p class="description"><?php esc_html_e( 'The previous forum software', 'bbpress' ); ?></p>
1662
1663 <?php
1664 }
1665
1666 /**
1667 * Edit Database Server setting field
1668 *
1669 * @since 2.1.0 bbPress (r3816)
1670 */
1671 function bbp_converter_setting_callback_dbserver() {
1672 ?>
1673
1674 <input name="_bbp_converter_db_server" id="_bbp_converter_db_server" type="text" class="code" value="<?php bbp_form_option( '_bbp_converter_db_server', 'localhost' ); ?>" <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_db_server' ); ?> />
1675 <p class="description"><?php printf(
1676 /* translators: %s: Default value wrapped in code tags */
1677 esc_html__( 'Use default %s if same server, or IP or hostname', 'bbpress' ),
1678 '<code>localhost</code>'
1679 ); ?></p>
1680
1681 <?php
1682 }
1683
1684 /**
1685 * Edit Database Server Port setting field
1686 *
1687 * @since 2.1.0 bbPress (r3816)
1688 */
1689 function bbp_converter_setting_callback_dbport() {
1690 ?>
1691
1692 <input name="_bbp_converter_db_port" id="_bbp_converter_db_port" type="text" class="code" value="<?php bbp_form_option( '_bbp_converter_db_port', '3306' ); ?>" <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_db_port' ); ?> />
1693 <p class="description"><?php
1694 printf(
1695 /* translators: %s: Default port number wrapped in code tags */
1696 esc_html__( 'Use default %s if unsure', 'bbpress' ),
1697 '<code>3306</code>'
1698 ); ?></p>
1699
1700 <?php
1701 }
1702
1703 /**
1704 * Edit Database User setting field
1705 *
1706 * @since 2.1.0 bbPress (r3816)
1707 */
1708 function bbp_converter_setting_callback_dbuser() {
1709 ?>
1710
1711 <input name="_bbp_converter_db_user" id="_bbp_converter_db_user" type="text" class="code" value="<?php bbp_form_option( '_bbp_converter_db_user' ); ?>" <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_db_user' ); ?> />
1712 <p class="description"><?php esc_html_e( 'User to access the database', 'bbpress' ); ?></p>
1713
1714 <?php
1715 }
1716
1717 /**
1718 * Edit Database Pass setting field
1719 *
1720 * @since 2.1.0 bbPress (r3816)
1721 * @since 2.6.19 bbPress (r7739) Stop displaying the saved source password.
1722 */
1723 function bbp_converter_setting_callback_dbpass() {
1724 ?>
1725
1726 <span class="bbp-converter-db-password-wrapper">
1727 <input name="_bbp_converter_db_pass" id="_bbp_converter_db_pass" class="bbp-converter-db-pass code" type="password" value="" autocomplete="off" <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_db_pass' ); ?> />
1728 <button type="button" class="bbp-db-pass-toggle password">
1729 <span class="screen-reader-text"><?php esc_html_e( 'Toggle', 'bbpress' ); ?></span>
1730 <span class="toggle-indicator" aria-hidden="true"></span>
1731 </button>
1732 </span>
1733 <p class="description"><?php esc_html_e( 'Leave blank to keep the saved password.', 'bbpress' ); ?></p>
1734 <label for="_bbp_converter_db_pass_clear">
1735 <input name="_bbp_converter_db_pass_clear" id="_bbp_converter_db_pass_clear" type="checkbox" value="1" />
1736 <?php esc_html_e( 'Clear the saved password to use no password.', 'bbpress' ); ?>
1737 </label>
1738
1739 <?php
1740 }
1741
1742 /**
1743 * Edit Database Name setting field
1744 *
1745 * @since 2.1.0 bbPress (r3816)
1746 */
1747 function bbp_converter_setting_callback_dbname() {
1748 ?>
1749
1750 <input name="_bbp_converter_db_name" id="_bbp_converter_db_name" type="text" class="code" value="<?php bbp_form_option( '_bbp_converter_db_name' ); ?>" <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_db_name' ); ?> />
1751 <p class="description"><?php esc_html_e( 'Name of the database with your old forum data', 'bbpress' ); ?></p>
1752
1753 <?php
1754 }
1755
1756 /**
1757 * Main settings section description for the settings page
1758 *
1759 * @since 2.1.0 bbPress (r3872)
1760 */
1761 function bbp_converter_setting_callback_options_section() {
1762 ?>
1763
1764 <p><?php esc_html_e( 'Some optional parameters to help tune the conversion process.', 'bbpress' ); ?></p>
1765
1766 <?php
1767 }
1768
1769 /**
1770 * Edit Table Prefix setting field
1771 *
1772 * @since 2.1.0 bbPress (r3816)
1773 */
1774 function bbp_converter_setting_callback_dbprefix() {
1775 ?>
1776
1777 <input name="_bbp_converter_db_prefix" id="_bbp_converter_db_prefix" type="text" class="code" value="<?php bbp_form_option( '_bbp_converter_db_prefix' ); ?>" <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_db_prefix' ); ?> />
1778 <p class="description"><?php printf(
1779 /* translators: %s: Database prefix example wrapped in code tags */
1780 esc_html__( 'Use %s if converting from BuddyPress Legacy', 'bbpress' ),
1781 '<code>wp_bb_</code>'
1782 ); ?></p>
1783
1784 <?php
1785 }
1786
1787 /**
1788 * Edit Rows Limit setting field
1789 *
1790 * @since 2.1.0 bbPress (r3816)
1791 */
1792 function bbp_converter_setting_callback_rows() {
1793 ?>
1794
1795 <input name="_bbp_converter_rows" id="_bbp_converter_rows" type="number" min="1" max="5000" value="<?php bbp_form_option( '_bbp_converter_rows', '100' ); ?>" <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_rows' ); ?> />
1796 <label for="_bbp_converter_rows"><?php esc_html_e( 'entry maximum when querying for data to convert', 'bbpress' ); ?></label>
1797 <p class="description"><?php esc_html_e( 'Keep this low if you experience out-of-memory issues.', 'bbpress' ); ?></p>
1798
1799 <?php
1800 }
1801
1802 /**
1803 * Edit Delay Time setting field
1804 *
1805 * @since 2.1.0 bbPress (r3816)
1806 */
1807 function bbp_converter_setting_callback_delay_time() {
1808 ?>
1809
1810 <input name="_bbp_converter_delay_time" id="_bbp_converter_delay_time" type="number" min="2" max="3600" value="<?php bbp_form_option( '_bbp_converter_delay_time', '2' ); ?>" <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_delay_time' ); ?> />
1811 <label for="_bbp_converter_delay_time"><?php esc_html_e( 'second delay between each query of rows above', 'bbpress' ); ?></label>
1812 <p class="description"><?php esc_html_e( 'Keep this high to prevent too-many-connection issues.', 'bbpress' ); ?></p>
1813
1814 <?php
1815 }
1816
1817 /**
1818 * Edit Halt setting field
1819 *
1820 * @since 2.6.0 bbPress (r6600)
1821 */
1822 function bbp_converter_setting_callback_halt() {
1823 ?>
1824
1825 <input name="_bbp_converter_halt" id="_bbp_converter_halt" type="checkbox" value="1" <?php checked( get_option( '_bbp_converter_halt', false ) ); ?> />
1826 <label for="_bbp_converter_halt"><?php esc_html_e( 'Halt the conversion if an error occurs', 'bbpress' ); ?></label>
1827 <p class="description"><?php esc_html_e( 'This is helpful if you want to debug problems.', 'bbpress' ); ?></p>
1828
1829 <?php
1830 }
1831
1832
1833 /**
1834 * Edit Restart setting field
1835 *
1836 * @since 2.1.0 bbPress (r3816)
1837 */
1838 function bbp_converter_setting_callback_restart() {
1839 ?>
1840
1841 <input name="_bbp_converter_restart" id="_bbp_converter_restart" type="checkbox" value="1" <?php checked( get_option( '_bbp_converter_restart', false ) ); ?> />
1842 <label for="_bbp_converter_restart"><?php esc_html_e( 'Restart the converter from the beginning', 'bbpress' ); ?></label>
1843 <p class="description"><?php esc_html_e( 'This forces all steps back to 0. Avoid duplicate data by purging or resetting first.', 'bbpress' ); ?></p>
1844
1845 <?php
1846 }
1847
1848 /**
1849 * Edit Clean setting field
1850 *
1851 * @since 2.1.0 bbPress (r3816)
1852 */
1853 function bbp_converter_setting_callback_clean() {
1854 ?>
1855
1856 <input name="_bbp_converter_clean" id="_bbp_converter_clean" type="checkbox" value="1" <?php checked( get_option( '_bbp_converter_clean', false ) ); ?> />
1857 <label for="_bbp_converter_clean"><?php esc_html_e( 'Purge all meta-data from a previous import', 'bbpress' ); ?></label>
1858 <p class="description"><?php esc_html_e( 'Use this if an import failed, or you just want to remove the relationship data.', 'bbpress' ); ?></p>
1859
1860 <?php
1861 }
1862
1863 /**
1864 * Edit Convert Users setting field
1865 *
1866 * @since 2.1.0 bbPress (r3816)
1867 */
1868 function bbp_converter_setting_callback_convert_users() {
1869 $network_users_only = ! current_user_can( 'bbp_tools_import_users' );
1870 ?>
1871
1872 <input name="_bbp_converter_convert_users" id="_bbp_converter_convert_users" type="checkbox" value="1" <?php checked( ! $network_users_only && get_option( '_bbp_converter_convert_users', false ) ); ?> <?php disabled( $network_users_only || isset( bbpress()->options['_bbp_converter_convert_users'] ) ); ?> />
1873 <label for="_bbp_converter_convert_users"><?php esc_html_e( 'Import user accounts from previous forums', 'bbpress' ); ?></label>
1874 <?php if ( $network_users_only ) : ?>
1875 <p class="description"><?php esc_html_e( 'A network administrator is required to import user accounts.', 'bbpress' ); ?></p>
1876 <?php else : ?>
1877 <p class="description"><?php esc_html_e( 'Passwords remain encrypted, and are converted as individual users log in.', 'bbpress' ); ?></p>
1878 <?php endif; ?>
1879
1880 <?php
1881 }
1882
1883 /** Converter Page ************************************************************/
1884
1885 /**
1886 * The main settings page
1887 *
1888 * @since 2.6.0 bbPress (r6277)
1889 */
1890 function bbp_converter_settings_page() {
1891
1892 // Status
1893 $step = (int) get_option( '_bbp_converter_step', 0 );
1894 $max = (int) bbp_admin()->converter->max_steps;
1895
1896 // Starting or continuing?
1897 $status_text = ! empty( $step )
1898 /* translators: %s: Current step number */
1899 ? sprintf( esc_html__( 'Up next: step %s', 'bbpress' ), $step )
1900 : esc_html__( 'Ready', 'bbpress' );
1901
1902 // Starting or continuing?
1903 $start_text = ! empty( $step )
1904 ? esc_html__( 'Resume', 'bbpress' )
1905 : esc_html__( 'Start', 'bbpress' );
1906
1907 // Starting or continuing?
1908 $progress_text = ! empty( $step )
1909 /* translators: 1: Current step number, 2: Total number of steps */
1910 ? sprintf( esc_html__( 'Previously stopped at step %1$d of %2$d', 'bbpress' ), $step, $max )
1911 : esc_html__( 'Ready to go.', 'bbpress' ); ?>
1912
1913 <div class="wrap">
1914 <h1 class="wp-heading-inline"><?php esc_html_e( 'Forum Tools', 'bbpress' ); ?></h1>
1915 <hr class="wp-header-end">
1916 <h2 class="nav-tab-wrapper"><?php bbp_tools_admin_tabs( 'bbp-converter' ); ?></h2>
1917
1918 <div class="bbp-converter-wrap">
1919 <div id="poststuff" class="bbp-converter-monitor-wrap">
1920 <div id="post-body" class="metabox-holder columns-1">
1921 <div id="postbox-container-1" class="postbox-container">
1922 <div id="normal-sortables" class="meta-box-sortables ui-sortable">
1923 <div id="bbp-converter-monitor" class="postbox">
1924 <button type="button" class="handlediv" aria-expanded="true">
1925 <span class="screen-reader-text"><?php esc_html_e( 'Toggle panel: Import Status', 'bbpress' ); ?></span>
1926 <span class="toggle-indicator" aria-hidden="true"></span>
1927 </button>
1928 <h2 class="hndle ui-sortable-handle">
1929 <span><?php esc_html_e( 'Import Monitor', 'bbpress' ); ?></span>
1930 <span id="bbp-converter-status"><?php echo esc_html( $status_text ); ?></span>
1931 <span id="bbp-converter-step-percentage" class="bbp-progress-bar"></span>
1932 <span id="bbp-converter-total-percentage" class="bbp-progress-bar"></span>
1933 </h2>
1934 <div class="inside">
1935 <div id="bbp-converter-message" class="bbp-converter-log">
1936 <p><?php echo esc_html( $progress_text ); ?></p>
1937 </div>
1938 </div>
1939 <div class="actions">
1940 <input type="button" name="submit" class="button-primary" id="bbp-converter-start" value="<?php echo esc_attr( $start_text ); ?>" />
1941 <input type="button" name="submit" class="button-primary" id="bbp-converter-stop" value="<?php esc_attr_e( 'Pause', 'bbpress' ); ?>" />
1942 <span class="spinner" id="bbp-converter-spinner"></span>
1943 </div>
1944 </div>
1945 </div>
1946 </div>
1947 </div>
1948 </div>
1949
1950 <form action="#" method="post" id="bbp-converter-settings" class="bbp-converter-settings-wrap"><?php
1951
1952 // Fields
1953 settings_fields( 'converter' );
1954
1955 // Sections
1956 do_settings_sections( 'converter' );
1957
1958 ?></form>
1959 </div>
1960 </div>
1961 <?php
1962 }
1963
1964 /** Helpers *******************************************************************/
1965
1966 /**
1967 * Contextual help for Forums settings page
1968 *
1969 * @since 2.0.0 bbPress (r3119)
1970 */
1971 function bbp_admin_settings_help() {
1972
1973 $current_screen = get_current_screen();
1974
1975 // Bail if current screen could not be found
1976 if ( empty( $current_screen ) ) {
1977 return;
1978 }
1979
1980 // Overview
1981 $current_screen->add_help_tab(
1982 array(
1983 'id' => 'overview',
1984 'title' => esc_html__( 'Overview', 'bbpress' ),
1985 'content' =>
1986 '<p>' . esc_html__( 'This screen provides access to all of the Forums settings.', 'bbpress' ) . '</p>' .
1987 '<p>' . esc_html__( 'Please see the additional help tabs for more information on each individual section.', 'bbpress' ) . '</p>'
1988 )
1989 );
1990
1991 // Main Settings
1992 $current_screen->add_help_tab(
1993 array(
1994 'id' => 'main_settings',
1995 'title' => esc_html__( 'Main Settings', 'bbpress' ),
1996 'content' =>
1997 '<p>' . esc_html__( 'The "Main Settings" section includes a number of options:', 'bbpress' ) . '</p>' .
1998 '<p>' .
1999 '<ul>' .
2000 '<li>' . esc_html__( 'You can choose to lock a post after a certain number of minutes. "Locking post editing" will prevent the author from editing some amount of time after saving a post.', 'bbpress' ) . '</li>' .
2001 '<li>' . esc_html__( '"Throttle time" is the amount of time required between posts from a single author. The higher the throttle time, the longer a user will need to wait between posting to the forum.', 'bbpress' ) . '</li>' .
2002 '<li>' . esc_html__( 'Favorites are a way for users to save and later return to topics they favor. This is enabled by default.', 'bbpress' ) . '</li>' .
2003 '<li>' . esc_html__( 'Subscriptions allow users to subscribe for notifications to topics that interest them. This is enabled by default.', 'bbpress' ) . '</li>' .
2004 '<li>' . esc_html__( 'Topic-Tags allow users to filter topics between forums. This is enabled by default.', 'bbpress' ) . '</li>' .
2005 '<li>' . esc_html__( '"Anonymous Posting" allows guest users who do not have accounts on your site to both create topics as well as replies.', 'bbpress' ) . '</li>' .
2006 '<li>' . esc_html__( 'The Fancy Editor brings the luxury of the Visual editor and HTML editor from the traditional WordPress dashboard into your theme.', 'bbpress' ) . '</li>' .
2007 '<li>' . esc_html__( 'Auto-embed will embed the media content from a URL directly into the replies. For example: links to Flickr and YouTube.', 'bbpress' ) . '</li>' .
2008 '</ul>' .
2009 '</p>' .
2010 '<p>' . esc_html__( 'You must click the Save Changes button at the bottom of the screen for new settings to take effect.', 'bbpress' ) . '</p>'
2011 )
2012 );
2013
2014 // Theme Package
2015 $current_screen->add_help_tab(
2016 array(
2017 'id' => 'theme_packages',
2018 'title' => esc_html__( 'Theme Packages', 'bbpress' ),
2019 'content' =>
2020 '<p>' . esc_html__( 'The "Theme Packages" section allows you to choose which theme package should be used.', 'bbpress' ) . '</p>' .
2021 '<p>' .
2022 '<ul>' .
2023 '<li>' . esc_html__( 'The "bbPress Default" package is installed by default.', 'bbpress' ) . '</li>' .
2024 '<li>' . esc_html__( 'Some themes may choose to ignore this setting entirely.', 'bbpress' ) . '</li>' .
2025 '<li>' . esc_html__( 'Packages can be stacked to allow for intelligent fallbacks.', 'bbpress' ) . '</li>' .
2026 '</ul>' .
2027 '</p>'
2028 )
2029 );
2030
2031 // Per Page
2032 $current_screen->add_help_tab(
2033 array(
2034 'id' => 'per_page',
2035 'title' => esc_html__( 'Per Page', 'bbpress' ),
2036 'content' =>
2037 '<p>' . esc_html__( 'The "Per Page" section allows you to control the number of topics and replies appear on each page.', 'bbpress' ) . '</p>' .
2038 '<ul>' .
2039 '<li>' . esc_html__( 'This is comparable to the WordPress "Reading Settings" page, where you can set the number of posts that should show on blog pages and in feeds.', 'bbpress' ) . '</li>' .
2040 '<li>' . esc_html__( 'These are broken up into two separate groups: one for what appears in your theme, another for RSS feeds.', 'bbpress' ) . '</li>' .
2041 '</ul>' .
2042 '<p>'
2043 )
2044 );
2045
2046 // Slugs
2047 $current_screen->add_help_tab(
2048 array(
2049 'id' => 'slugs',
2050 'title' => esc_html__( 'Slugs', 'bbpress' ),
2051 'content' =>
2052 '<p>' . esc_html__( 'The "Slugs" section allows you to control the permalink structure for your forums.', 'bbpress' ) . '</p>' .
2053 '<ul>' .
2054 '<li>' . esc_html__( '"Archive Slugs" are used as the "root" for your forums and topics. If you combine these values with existing page slugs, bbPress will attempt to output the most correct title and content.', 'bbpress' ) . '</li>' .
2055 '<li>' . esc_html__( '"Single Slugs" are used as a prefix when viewing an individual forum, topic, reply, user, or view.', 'bbpress' ) . '</li>' .
2056 '<li>' . esc_html__( 'In the event of a slug collision with WordPress or BuddyPress, a warning will appear next to the problem slug(s).', 'bbpress' ) . '</li>' .
2057 '</ul>' .
2058 '<p>'
2059 )
2060 );
2061
2062 // Help Sidebar
2063 $current_screen->set_help_sidebar(
2064 '<p><strong>' . esc_html__( 'For more information:', 'bbpress' ) . '</strong></p>' .
2065 '<p>' . __( '<a href="https://codex.bbpress.org" target="_blank">bbPress Documentation</a>', 'bbpress' ) . '</p>' .
2066 '<p>' . __( '<a href="https://bbpress.org/forums/" target="_blank">bbPress Support Forums</a>', 'bbpress' ) . '</p>'
2067 );
2068 }
2069
2070 /**
2071 * Disable a settings field if it is forcibly set in the global options array.
2072 *
2073 * @since 2.2.0 bbPress (r4348)
2074 *
2075 * @param string $option_key
2076 */
2077 function bbp_maybe_admin_setting_disabled( $option_key = '' ) {
2078 disabled( isset( bbpress()->options[ $option_key ] ) );
2079 }
2080
2081 /**
2082 * Output settings API option
2083 *
2084 * @since 2.0.0 bbPress (r3203)
2085 *
2086 * @param string $option
2087 * @param string $default
2088 * @param bool $slug
2089 */
2090 function bbp_form_option( $option, $default = '', $slug = false ) {
2091 echo bbp_get_form_option( $option, $default, $slug );
2092 }
2093 /**
2094 * Return settings API option
2095 *
2096 * @since 2.0.0 bbPress (r3203)
2097 *
2098 * @param string $option
2099 * @param string $default
2100 * @param bool $is_slug
2101 *
2102 * @return mixed
2103 */
2104 function bbp_get_form_option( $option, $default = '', $is_slug = false ) {
2105
2106 // Get the option and sanitize it
2107 $value = get_option( $option, $default );
2108
2109 // Slug?
2110 if ( true === $is_slug ) {
2111 $value = esc_attr( apply_filters( 'editable_slug', $value ) );
2112
2113 // Not a slug
2114 } else {
2115 $value = esc_attr( $value );
2116 }
2117
2118 // Fallback to default, unless numeric (allow zero)
2119 if ( empty( $value ) && ! is_numeric( $value ) ) {
2120 $value = $default;
2121 }
2122
2123 // Filter & return
2124 return apply_filters( 'bbp_get_form_option', $value, $option, $default, $is_slug );
2125 }
2126
2127 /**
2128 * Used to check if a bbPress slug conflicts with an existing known slug.
2129 *
2130 * @since 2.0.0 bbPress (r3306)
2131 *
2132 * @param string $slug
2133 * @param string $default
2134 */
2135 function bbp_form_slug_conflict_check( $slug, $default ) {
2136
2137 // Only set the slugs once ver page load
2138 static $the_core_slugs = array();
2139
2140 // Get the form value
2141 $this_slug = bbp_get_form_option( $slug, $default, true );
2142
2143 if ( empty( $the_core_slugs ) ) {
2144
2145 // Slugs to check
2146 $core_slugs = apply_filters(
2147 'bbp_slug_conflict_check',
2148 array(
2149
2150 /** WordPress Core ****************************************************/
2151
2152 // Core Post Types
2153 'post_base' => array(
2154 'name' => esc_html__( 'Posts', 'bbpress' ),
2155 'default' => 'post',
2156 'context' => 'WordPress'
2157 ),
2158 'page_base' => array(
2159 'name' => esc_html__( 'Pages', 'bbpress' ),
2160 'default' => 'page',
2161 'context' => 'WordPress'
2162 ),
2163 'revision_base' => array(
2164 'name' => esc_html__( 'Revisions', 'bbpress' ),
2165 'default' => 'revision',
2166 'context' => 'WordPress'
2167 ),
2168 'attachment_base' => array(
2169 'name' => esc_html__( 'Attachments', 'bbpress' ),
2170 'default' => 'attachment',
2171 'context' => 'WordPress'
2172 ),
2173 'nav_menu_base' => array(
2174 'name' => esc_html__( 'Menus', 'bbpress' ),
2175 'default' => 'nav_menu_item',
2176 'context' => 'WordPress'
2177 ),
2178
2179 // Post Tags
2180 'tag_base' => array(
2181 'name' => esc_html__( 'Tag base', 'bbpress' ),
2182 'default' => 'tag',
2183 'context' => 'WordPress'
2184 ),
2185
2186 // Post Categories
2187 'category_base' => array(
2188 'name' => esc_html__( 'Category base', 'bbpress' ),
2189 'default' => 'category',
2190 'context' => 'WordPress'
2191 ),
2192
2193 /** bbPress Core ******************************************************/
2194
2195 // Forum archive slug
2196 '_bbp_root_slug' => array(
2197 'name' => esc_html__( 'Forums base', 'bbpress' ),
2198 'default' => 'forums',
2199 'context' => 'bbPress'
2200 ),
2201
2202 // Topic archive slug
2203 '_bbp_topic_archive_slug' => array(
2204 'name' => esc_html__( 'Topics base', 'bbpress' ),
2205 'default' => 'topics',
2206 'context' => 'bbPress'
2207 ),
2208
2209 // Forum slug
2210 '_bbp_forum_slug' => array(
2211 'name' => esc_html__( 'Forum slug', 'bbpress' ),
2212 'default' => 'forum',
2213 'context' => 'bbPress'
2214 ),
2215
2216 // Topic slug
2217 '_bbp_topic_slug' => array(
2218 'name' => esc_html__( 'Topic slug', 'bbpress' ),
2219 'default' => 'topic',
2220 'context' => 'bbPress'
2221 ),
2222
2223 // Reply slug
2224 '_bbp_reply_slug' => array(
2225 'name' => esc_html__( 'Reply slug', 'bbpress' ),
2226 'default' => 'reply',
2227 'context' => 'bbPress'
2228 ),
2229
2230 // Edit slug
2231 '_bbp_edit_slug' => array(
2232 'name' => esc_html__( 'Edit slug', 'bbpress' ),
2233 'default' => 'edit',
2234 'context' => 'bbPress'
2235 ),
2236
2237 // User profile slug
2238 '_bbp_user_slug' => array(
2239 'name' => esc_html__( 'User base', 'bbpress' ),
2240 'default' => 'users',
2241 'context' => 'bbPress'
2242 ),
2243
2244 // View slug
2245 '_bbp_view_slug' => array(
2246 'name' => esc_html__( 'View base', 'bbpress' ),
2247 'default' => 'view',
2248 'context' => 'bbPress'
2249 ),
2250
2251 // Topic tag slug
2252 '_bbp_topic_tag_slug' => array(
2253 'name' => esc_html__( 'Topic tag slug', 'bbpress' ),
2254 'default' => 'topic-tag',
2255 'context' => 'bbPress'
2256 ),
2257 )
2258 );
2259
2260 /** BuddyPress Core *******************************************************/
2261
2262 if ( defined( 'BP_VERSION' ) ) {
2263 $bp = buddypress();
2264
2265 // Loop through root slugs and check for conflict
2266 if ( ! empty( $bp->pages ) ) {
2267 foreach ( $bp->pages as $page => $page_data ) {
2268 $page_base = $page . '_base';
2269 /* translators: %s: BuddyPress page title */
2270 $page_title = sprintf( esc_html__( '%s page', 'bbpress' ), $page_data->title );
2271 $core_slugs[ $page_base ] = array(
2272 'name' => $page_title,
2273 'default' => $page_data->slug,
2274 'context' => 'BuddyPress'
2275 );
2276 }
2277 }
2278 }
2279
2280 // Set the static
2281 $the_core_slugs = apply_filters( 'bbp_slug_conflict', $core_slugs );
2282 }
2283
2284 // Loop through slugs to check
2285 foreach ( $the_core_slugs as $key => $value ) {
2286
2287 // Get the slug
2288 $slug_check = bbp_get_form_option( $key, $value['default'], true );
2289
2290 // Compare
2291 if ( ( $slug !== $key ) && ( $slug_check === $this_slug ) ) :
2292 ?>
2293
2294 <span class="attention"><?php printf(
2295 /* translators: 1: Context (e.g., "BuddyPress"), 2: Name of the conflicting item */
2296 esc_html__( 'Possible %1$s conflict: %2$s', 'bbpress' ),
2297 $value['context'],
2298 '<strong>' . $value['name'] . '</strong>'
2299 ); ?></span>
2300
2301 <?php endif;
2302 }
2303 }
2304