PluginProbe
bbPress / 2.6.17
bbPress v2.6.17
2.6.17 trunk 2.0 2.0-beta-1 2.0-beta-2b 2.0-beta-3 2.0-beta-3b 2.0-rc-2 2.0-rc-3 2.0-rc-4 2.0-rc-5 2.0.1 2.0.2 2.0.3 2.1 2.1-beta-1 2.1-rc1 2.1-rc2 2.1-rc3 2.1-rc4 2.1.1 2.1.2 2.1.3 2.2 2.2.1 All 72 releases
bbpress / includes / admin / settings.php

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

2,250 lines 73.8 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 (r4001)
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 (r4001)
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' => 'sanitize_text_field',
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' => 'esc_sql',
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 * Get settings fields by section.
618 *
619 * @since 2.1.0 bbPress (r4001)
620 *
621 * @param string $section_id ID of the section to get fields for
622 * @staticvar array $fields All of the available fields
623 * @return mixed False if section is invalid, array of fields otherwise.
624 */
625 function bbp_admin_get_settings_fields_for_section( $section_id = '' ) {
626 static $fields = array();
627
628 // Default return value
629 $retval = array();
630
631 // Bail if section is empty
632 if ( empty( $section_id ) ) {
633 return false;
634 }
635
636 // Get all of the fields (so we can snag one section of them)
637 if ( empty( $fields ) ) {
638 $fields = bbp_admin_get_settings_fields();
639 }
640
641 // Get the field by section
642 if ( isset( $fields[ $section_id ] ) ) {
643 $retval = $fields[ $section_id ];
644 }
645
646 // Filter & return
647 return (array) apply_filters( 'bbp_admin_get_settings_fields_for_section', $retval, $section_id );
648 }
649
650 /** User Section **************************************************************/
651
652 /**
653 * User settings section description for the settings page
654 *
655 * @since 2.0.0 bbPress (r2786)
656 */
657 function bbp_admin_setting_callback_user_section() {
658 ?>
659
660 <p><?php esc_html_e( 'Setting time limits and other user posting capabilities', 'bbpress' ); ?></p>
661
662 <?php
663 }
664
665
666 /**
667 * Edit lock setting field
668 *
669 * @since 2.0.0 bbPress (r2737)
670 */
671 function bbp_admin_setting_callback_editlock() {
672
673 // Start the output buffer for the second option
674 ob_start(); ?>
675
676 </label>
677 <label for="_bbp_edit_lock">
678 <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' ); ?> />
679
680 <?php $select = ob_get_clean(); ?>
681
682 <label for="_bbp_allow_content_edit">
683 <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' ); ?> />
684 <?php
685 printf(
686 /* translators: %s: Total minutes to edit a post */
687 esc_html__( 'Allow users to edit their content for %s minutes after posting', 'bbpress' ),
688 $select
689 );
690 ?>
691 </label>
692 <p class="description"><?php esc_html_e( 'If checked, setting to "0 minutes" allows editing forever.', 'bbpress' ); ?></p>
693
694 <?php
695 }
696
697 /**
698 * Throttle setting field
699 *
700 * @since 2.0.0 bbPress (r2737)
701 */
702 function bbp_admin_setting_callback_throttle() {
703
704 // Start the output buffer for the second option
705 ob_start(); ?>
706
707 </label>
708 <label for="_bbp_throttle_time">
709 <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' ); ?> />
710
711 <?php $select = ob_get_clean(); ?>
712
713 <label for="_bbp_allow_content_throttle">
714 <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' ); ?> />
715 <?php
716 printf(
717 /* translators: %s: Total seconds to throttle a user */
718 esc_html__( 'Allow flood protection by throttling users for %s seconds after posting', 'bbpress' ),
719 $select
720 );
721 ?>
722 </label>
723 <p class="description"><?php esc_html_e( 'Use this to discourage users from spamming your forums.', 'bbpress' ); ?></p>
724
725 <?php
726 }
727
728 /**
729 * Allow anonymous posting setting field
730 *
731 * @since 2.0.0 bbPress (r2737)
732 */
733 function bbp_admin_setting_callback_anonymous() {
734 ?>
735
736 <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' ); ?> />
737 <label for="_bbp_allow_anonymous"><?php esc_html_e( 'Allow guest users without accounts to create topics and replies', 'bbpress' ); ?></label>
738 <p class="description"><?php esc_html_e( 'Works best on intranets or paired with antispam measures like Akismet.', 'bbpress' ); ?></p>
739
740 <?php
741 }
742
743 /**
744 * Allow global access setting field
745 *
746 * @since 2.0.0 bbPress (r3378)
747 */
748 function bbp_admin_setting_callback_global_access() {
749
750 // Get the default role once rather than loop repeatedly below
751 $default_role = bbp_get_default_role();
752 $roles = bbp_get_dynamic_roles();
753
754 // Start the output buffer for the select dropdown
755 ob_start(); ?>
756
757 </label>
758 <label for="_bbp_default_role">
759 <select name="_bbp_default_role" id="_bbp_default_role" <?php bbp_maybe_admin_setting_disabled( '_bbp_default_role' ); ?>>
760 <?php foreach ( $roles as $role => $details ) : ?>
761
762 <option <?php selected( $default_role, $role ); ?> value="<?php echo esc_attr( $role ); ?>"><?php echo bbp_translate_user_role( $details['name'] ); ?></option>
763
764 <?php endforeach; ?>
765 </select>
766
767 <?php $select = ob_get_clean(); ?>
768
769 <label for="_bbp_allow_global_access">
770 <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' ); ?> />
771 <?php
772 printf(
773 /* translators: %s: Default role name */
774 esc_html__( 'Automatically give registered visitors the %s forum role', 'bbpress' ),
775 $select
776 );
777 ?>
778 </label>
779 <p class="description"><?php esc_html_e( 'Uncheck this to manually assign all user access to your forums.', 'bbpress' ); ?></p>
780
781 <?php
782 }
783
784 /** Features Section **********************************************************/
785
786 /**
787 * Features settings section description for the settings page
788 *
789 * @since 2.0.0 bbPress (r2786)
790 */
791 function bbp_admin_setting_callback_features_section() {
792 ?>
793
794 <p><?php esc_html_e( 'Forum features that can be toggled on and off', 'bbpress' ); ?></p>
795
796 <?php
797 }
798
799 /**
800 * Allow favorites setting field
801 *
802 * @since 2.0.0 bbPress (r2786)
803 */
804 function bbp_admin_setting_callback_favorites() {
805 ?>
806
807 <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' ); ?> />
808 <label for="_bbp_enable_favorites"><?php esc_html_e( 'Allow users to mark topics as favorites', 'bbpress' ); ?></label>
809
810 <?php
811 }
812
813 /**
814 * Allow subscriptions setting field
815 *
816 * @since 2.0.0 bbPress (r2737)
817 */
818 function bbp_admin_setting_callback_subscriptions() {
819 ?>
820
821 <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' ); ?> />
822 <label for="_bbp_enable_subscriptions"><?php esc_html_e( 'Allow users to subscribe to forums and topics', 'bbpress' ); ?></label>
823
824 <?php
825 }
826
827 /**
828 * Allow engagements setting field
829 *
830 * @since 2.0.0 bbPress (r2737)
831 */
832 function bbp_admin_setting_callback_engagements() {
833 ?>
834
835 <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' ); ?> />
836 <label for="_bbp_enable_engagements"><?php esc_html_e( 'Allow tracking of topics each user engages in', 'bbpress' ); ?></label>
837
838 <?php
839 }
840
841 /**
842 * Allow topic tags setting field
843 *
844 * @since 2.4.0 bbPress (r4944)
845 */
846 function bbp_admin_setting_callback_topic_tags() {
847 ?>
848
849 <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' ); ?> />
850 <label for="_bbp_allow_topic_tags"><?php esc_html_e( 'Allow topics to have tags', 'bbpress' ); ?></label>
851
852 <?php
853 }
854
855 /**
856 * Allow forum-mods setting field
857 *
858 * @since 2.6.0 bbPress (r5834)
859 */
860 function bbp_admin_setting_callback_forum_mods() {
861 ?>
862
863 <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' ); ?> />
864 <label for="_bbp_allow_forum_mods"><?php esc_html_e( 'Allow forums to have dedicated moderators', 'bbpress' ); ?></label>
865 <p class="description"><?php esc_html_e( 'This does not include the ability to edit users.', 'bbpress' ); ?></p>
866
867 <?php
868 }
869
870 /**
871 * Allow super-mods setting field
872 *
873 * @since 2.6.0 bbPress (r6562)
874 */
875 function bbp_admin_setting_callback_super_mods() {
876 ?>
877
878 <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' ); ?> />
879 <label for="_bbp_allow_super_mods"><?php esc_html_e( 'Allow Moderators and Keymasters to edit users', 'bbpress' ); ?></label>
880 <p class="description"><?php esc_html_e( 'In forum profiles, this includes: names, contact info, about, and forum roles.', 'bbpress' ); ?></p>
881
882 <?php
883 }
884
885 /**
886 * Allow forum wide search
887 *
888 * @since 2.4.0 bbPress (r4970)
889 */
890 function bbp_admin_setting_callback_search() {
891 ?>
892
893 <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' ); ?> />
894 <label for="_bbp_allow_search"><?php esc_html_e( 'Allow forum wide search', 'bbpress' ); ?></label>
895
896 <?php
897 }
898
899 /**
900 * Hierarchical reply maximum depth level setting field
901 *
902 * Replies will be threaded if depth is 2 or greater
903 *
904 * @since 2.4.0 bbPress (r4944)
905 */
906 function bbp_admin_setting_callback_thread_replies_depth() {
907
908 // Set maximum depth for dropdown
909 $max_depth = (int) apply_filters( 'bbp_thread_replies_depth_max', 10 );
910 $current_depth = bbp_thread_replies_depth();
911
912 // Start an output buffer for the select dropdown
913 ob_start(); ?>
914
915 </label>
916 <label for="_bbp_thread_replies_depth">
917 <select name="_bbp_thread_replies_depth" id="_bbp_thread_replies_depth" <?php bbp_maybe_admin_setting_disabled( '_bbp_thread_replies_depth' ); ?>>
918 <?php for ( $i = 2; $i <= $max_depth; $i++ ) : ?>
919
920 <option value="<?php echo esc_attr( $i ); ?>" <?php selected( $i, $current_depth ); ?>><?php echo esc_html( $i ); ?></option>
921
922 <?php endfor; ?>
923 </select>
924
925 <?php $select = ob_get_clean(); ?>
926
927 <label for="_bbp_allow_threaded_replies">
928 <input name="_bbp_allow_threaded_replies" id="_bbp_allow_threaded_replies" type="checkbox" value="1" <?php checked( '1', bbp_allow_threaded_replies( false ) );
929 bbp_maybe_admin_setting_disabled( '_bbp_allow_threaded_replies' ); ?> />
930 <?php printf(
931 /* translators: %s: Depth level input field HTML */
932 esc_html__( 'Enable threaded (nested) replies %s levels deep', 'bbpress' ),
933 $select
934 );
935 ?>
936 </label>
937
938 <?php
939 }
940
941 /**
942 * Allow topic and reply revisions
943 *
944 * @since 2.0.0 bbPress (r3412)
945 */
946 function bbp_admin_setting_callback_revisions() {
947 ?>
948
949 <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' ); ?> />
950 <label for="_bbp_allow_revisions"><?php esc_html_e( 'Allow topic and reply revision logging', 'bbpress' ); ?></label>
951
952 <?php
953 }
954
955 /**
956 * Use the WordPress editor setting field
957 *
958 * @since 2.1.0 bbPress (r3586)
959 */
960 function bbp_admin_setting_callback_use_wp_editor() {
961 ?>
962
963 <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' ); ?> />
964 <label for="_bbp_use_wp_editor"><?php esc_html_e( 'Add toolbar & buttons to textareas to help with HTML formatting', 'bbpress' ); ?></label>
965
966 <?php
967 }
968
969 /**
970 * Main subtheme section
971 *
972 * @since 2.0.0 bbPress (r2786)
973 */
974 function bbp_admin_setting_callback_subtheme_section() {
975 ?>
976
977 <p><?php esc_html_e( 'How your forum content is displayed within your existing theme.', 'bbpress' ); ?></p>
978
979 <?php
980 }
981
982 /**
983 * Use the WordPress editor setting field
984 *
985 * @since 2.1.0 bbPress (r3586)
986 */
987 function bbp_admin_setting_callback_subtheme_id() {
988
989 // Declare locale variable
990 $theme_options = '';
991 $current_package = bbp_get_theme_package_id( 'default' );
992
993 // Note: This should never be empty. /templates/ is the
994 // canonical backup if no other packages exist. If there's an error here,
995 // something else is wrong.
996 //
997 // @see bbPress::register_theme_packages()
998 foreach ( (array) bbpress()->theme_compat->packages as $id => $theme ) {
999 $theme_options .= '<option value="' . esc_attr( $id ) . '"' . selected( $theme->id, $current_package, false ) . '>' . esc_html( $theme->name ) . '</option>';
1000 }
1001
1002 if ( ! empty( $theme_options ) ) : ?>
1003
1004 <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>
1005 <label for="_bbp_theme_package_id"><?php esc_html_e( 'will serve all bbPress templates', 'bbpress' ); ?></label>
1006
1007 <?php else : ?>
1008
1009 <p><?php esc_html_e( 'No template packages available.', 'bbpress' ); ?></p>
1010
1011 <?php endif;
1012 }
1013
1014 /**
1015 * Allow oEmbed in replies
1016 *
1017 * @since 2.1.0 bbPress (r3752)
1018 */
1019 function bbp_admin_setting_callback_use_autoembed() {
1020 ?>
1021
1022 <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' ); ?> />
1023 <label for="_bbp_use_autoembed"><?php esc_html_e( 'Embed media (YouTube, Twitter, Flickr, etc...) directly into topics and replies', 'bbpress' ); ?></label>
1024
1025 <?php
1026 }
1027
1028 /** Per Page Section **********************************************************/
1029
1030 /**
1031 * Per page settings section description for the settings page
1032 *
1033 * @since 2.0.0 bbPress (r2786)
1034 */
1035 function bbp_admin_setting_callback_per_page_section() {
1036 ?>
1037
1038 <p><?php esc_html_e( 'How many topics and replies to show per page', 'bbpress' ); ?></p>
1039
1040 <?php
1041 }
1042
1043 /**
1044 * Topics per page setting field
1045 *
1046 * @since 2.0.0 bbPress (r2786)
1047 */
1048 function bbp_admin_setting_callback_topics_per_page() {
1049 ?>
1050
1051 <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' ); ?> />
1052 <?php esc_html_e( 'per page', 'bbpress' ); ?>
1053
1054 <?php
1055 }
1056
1057 /**
1058 * Replies per page setting field
1059 *
1060 * @since 2.0.0 bbPress (r2786)
1061 */
1062 function bbp_admin_setting_callback_replies_per_page() {
1063 ?>
1064
1065 <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' ); ?> />
1066 <?php esc_html_e( 'per page', 'bbpress' ); ?>
1067
1068 <?php
1069 }
1070
1071 /** Per RSS Page Section ******************************************************/
1072
1073 /**
1074 * Per page settings section description for the settings page
1075 *
1076 * @since 2.0.0 bbPress (r2786)
1077 */
1078 function bbp_admin_setting_callback_per_rss_page_section() {
1079 ?>
1080
1081 <p><?php esc_html_e( 'How many topics and replies to show per RSS page', 'bbpress' ); ?></p>
1082
1083 <?php
1084 }
1085
1086 /**
1087 * Topics per RSS page setting field
1088 *
1089 * @since 2.0.0 bbPress (r2786)
1090 */
1091 function bbp_admin_setting_callback_topics_per_rss_page() {
1092 ?>
1093
1094 <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' ); ?> />
1095 <?php esc_html_e( 'per page', 'bbpress' ); ?>
1096
1097 <?php
1098 }
1099
1100 /**
1101 * Replies per RSS page setting field
1102 *
1103 * @since 2.0.0 bbPress (r2786)
1104 */
1105 function bbp_admin_setting_callback_replies_per_rss_page() {
1106 ?>
1107
1108 <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' ); ?> />
1109 <?php esc_html_e( 'per page', 'bbpress' ); ?>
1110
1111 <?php
1112 }
1113
1114 /** Slug Section **************************************************************/
1115
1116 /**
1117 * Slugs settings section description for the settings page
1118 *
1119 * @since 2.0.0 bbPress (r2786)
1120 */
1121 function bbp_admin_setting_callback_root_slug_section() {
1122
1123 // Flush rewrite rules when this section is saved
1124 if ( isset( $_GET['settings-updated'] ) && isset( $_GET['page'] ) ) {
1125 flush_rewrite_rules();
1126 } ?>
1127
1128 <p><?php esc_html_e( 'Customize your Forums root. Partner with a WordPress Page and use Shortcodes for more flexibility.', 'bbpress' ); ?></p>
1129
1130 <?php
1131 }
1132
1133 /**
1134 * Root slug setting field
1135 *
1136 * @since 2.0.0 bbPress (r2786)
1137 */
1138 function bbp_admin_setting_callback_root_slug() {
1139 ?>
1140
1141 <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' ); ?> />
1142
1143 <?php
1144 // Slug Check
1145 bbp_form_slug_conflict_check( '_bbp_root_slug', 'forums' );
1146 }
1147
1148 /**
1149 * Include root slug setting field
1150 *
1151 * @since 2.0.0 bbPress (r2786)
1152 */
1153 function bbp_admin_setting_callback_include_root() {
1154 ?>
1155
1156 <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' ); ?> />
1157 <label for="_bbp_include_root"><?php esc_html_e( 'Prefix all forum content with the Forum Root slug (Recommended)', 'bbpress' ); ?></label>
1158
1159 <?php
1160 }
1161
1162 /**
1163 * Include root slug setting field
1164 *
1165 * @since 2.0.0 bbPress (r2786)
1166 */
1167 function bbp_admin_setting_callback_show_on_root() {
1168
1169 // Current setting
1170 $show_on_root = bbp_show_on_root();
1171
1172 // Options for forum root output
1173 $root_options = array(
1174 'forums' => array(
1175 'name' => esc_attr__( 'Forum Index', 'bbpress' )
1176 ),
1177 'topics' => array(
1178 'name' => esc_attr__( 'Topics by Last Post', 'bbpress' )
1179 )
1180 ); ?>
1181
1182 <select name="_bbp_show_on_root" id="_bbp_show_on_root" <?php bbp_maybe_admin_setting_disabled( '_bbp_show_on_root' ); ?>>
1183
1184 <?php foreach ( $root_options as $option_id => $details ) : ?>
1185
1186 <option <?php selected( $show_on_root, $option_id ); ?> value="<?php echo esc_attr( $option_id ); ?>"><?php echo esc_html( $details['name'] ); ?></option>
1187
1188 <?php endforeach; ?>
1189
1190 </select>
1191
1192 <?php
1193
1194 // Look for theme support
1195 $forum_archive = basename( bbp_get_forum_archive_template() );
1196
1197 // This setting doesn't work if the theme has an archive-forum.php template.
1198 if ( ! empty( $forum_archive ) ) : ?>
1199
1200 <p class="description"><?php printf(
1201 /* translators: %s: Forum archive template file path */
1202 esc_html__( 'This setting will be ignored because %s was found in your theme.', 'bbpress' ),
1203 '<code>' . $forum_archive . '</code>'
1204 ); ?></p>
1205
1206 <?php endif;
1207 }
1208
1209 /** User Slug Section *********************************************************/
1210
1211 /**
1212 * Slugs settings section description for the settings page
1213 *
1214 * @since 2.0.0 bbPress (r2786)
1215 */
1216 function bbp_admin_setting_callback_user_slug_section() {
1217 ?>
1218
1219 <p><?php esc_html_e( 'Customize your user profile slugs.', 'bbpress' ); ?></p>
1220
1221 <?php
1222 }
1223
1224 /**
1225 * User slug setting field
1226 *
1227 * @since 2.0.0 bbPress (r2786)
1228 */
1229 function bbp_admin_setting_callback_user_slug() {
1230 ?>
1231
1232 <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' ); ?> />
1233
1234 <?php
1235 // Slug Check
1236 bbp_form_slug_conflict_check( '_bbp_user_slug', 'users' );
1237 }
1238
1239 /**
1240 * Topic archive slug setting field
1241 *
1242 * @since 2.0.0 bbPress (r2786)
1243 */
1244 function bbp_admin_setting_callback_topic_archive_slug() {
1245 ?>
1246
1247 <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' ); ?> />
1248
1249 <?php
1250 // Slug Check
1251 bbp_form_slug_conflict_check( '_bbp_topic_archive_slug', 'topics' );
1252 }
1253
1254 /**
1255 * Reply archive slug setting field
1256 *
1257 * @since 2.4.0 bbPress (r4932)
1258 */
1259 function bbp_admin_setting_callback_reply_archive_slug() {
1260 ?>
1261
1262 <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' ); ?> />
1263
1264 <?php
1265 // Slug Check
1266 bbp_form_slug_conflict_check( '_bbp_reply_archive_slug', 'replies' );
1267 }
1268
1269 /**
1270 * Favorites slug setting field
1271 *
1272 * @since 2.4.0 bbPress (r4932)
1273 */
1274 function bbp_admin_setting_callback_user_favs_slug() {
1275 ?>
1276
1277 <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' ); ?> />
1278
1279 <?php
1280 // Slug Check
1281 bbp_form_slug_conflict_check( '_bbp_user_favs_slug', 'favorites' );
1282 }
1283
1284 /**
1285 * Subscriptions slug setting field
1286 *
1287 * @since 2.4.0 bbPress (r4932)
1288 */
1289 function bbp_admin_setting_callback_user_subs_slug() {
1290 ?>
1291
1292 <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' ); ?> />
1293
1294 <?php
1295 // Slug Check
1296 bbp_form_slug_conflict_check( '_bbp_user_subs_slug', 'subscriptions' );
1297 }
1298
1299 /**
1300 * Engagements slug setting field
1301 *
1302 * @since 2.6.0 bbPress (r6320)
1303 */
1304 function bbp_admin_setting_callback_user_engagements_slug() {
1305 ?>
1306
1307 <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' ); ?> />
1308
1309 <?php
1310 // Slug Check
1311 bbp_form_slug_conflict_check( '_bbp_user_engs_slug', 'engagements' );
1312 }
1313
1314 /** Single Slugs **************************************************************/
1315
1316 /**
1317 * Slugs settings section description for the settings page
1318 *
1319 * @since 2.0.0 bbPress (r2786)
1320 */
1321 function bbp_admin_setting_callback_single_slug_section() {
1322 ?>
1323
1324 <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>
1325
1326 <?php
1327 }
1328
1329 /**
1330 * Forum slug setting field
1331 *
1332 * @since 2.0.0 bbPress (r2786)
1333 */
1334 function bbp_admin_setting_callback_forum_slug() {
1335 ?>
1336
1337 <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' ); ?> />
1338
1339 <?php
1340 // Slug Check
1341 bbp_form_slug_conflict_check( '_bbp_forum_slug', 'forum' );
1342 }
1343
1344 /**
1345 * Topic slug setting field
1346 *
1347 * @since 2.0.0 bbPress (r2786)
1348 */
1349 function bbp_admin_setting_callback_topic_slug() {
1350 ?>
1351
1352 <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' ); ?> />
1353
1354 <?php
1355 // Slug Check
1356 bbp_form_slug_conflict_check( '_bbp_topic_slug', 'topic' );
1357 }
1358
1359 /**
1360 * Reply slug setting field
1361 *
1362 * @since 2.0.0 bbPress (r2786)
1363 */
1364 function bbp_admin_setting_callback_reply_slug() {
1365 ?>
1366
1367 <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' ); ?> />
1368
1369 <?php
1370 // Slug Check
1371 bbp_form_slug_conflict_check( '_bbp_reply_slug', 'reply' );
1372 }
1373
1374 /**
1375 * Topic tag slug setting field
1376 *
1377 * @since 2.0.0 bbPress (r2786)
1378 */
1379 function bbp_admin_setting_callback_topic_tag_slug() {
1380 ?>
1381
1382 <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' ); ?> />
1383
1384 <?php
1385
1386 // Slug Check
1387 bbp_form_slug_conflict_check( '_bbp_topic_tag_slug', 'topic-tag' );
1388 }
1389
1390 /**
1391 * View slug setting field
1392 *
1393 * @since 2.0.0 bbPress (r2789)
1394 */
1395 function bbp_admin_setting_callback_view_slug() {
1396 ?>
1397
1398 <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' ); ?> />
1399
1400 <?php
1401 // Slug Check
1402 bbp_form_slug_conflict_check( '_bbp_view_slug', 'view' );
1403 }
1404
1405 /**
1406 * Search slug setting field
1407 *
1408 * @since 2.3.0 bbPress (r4579)
1409 */
1410 function bbp_admin_setting_callback_search_slug() {
1411 ?>
1412
1413 <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' ); ?> />
1414
1415 <?php
1416 // Slug Check
1417 bbp_form_slug_conflict_check( '_bbp_search_slug', 'search' );
1418 }
1419
1420 /**
1421 * Edit slug setting field
1422 *
1423 * @since 2.6.2 bbPress (r6965)
1424 */
1425 function bbp_admin_setting_callback_edit_slug() {
1426 ?>
1427
1428 <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' ); ?> />
1429
1430 <?php
1431 // Slug Check
1432 bbp_form_slug_conflict_check( '_bbp_edit_slug', 'edit' );
1433 }
1434
1435 /** BuddyPress ****************************************************************/
1436
1437 /**
1438 * Extension settings section description for the settings page
1439 *
1440 * @since 2.1.0 bbPress (r3575)
1441 */
1442 function bbp_admin_setting_callback_buddypress_section() {
1443 ?>
1444
1445 <p><?php esc_html_e( 'Forum settings for BuddyPress', 'bbpress' ); ?></p>
1446
1447 <?php
1448 }
1449
1450 /**
1451 * Allow BuddyPress group forums setting field
1452 *
1453 * @since 2.1.0 bbPress (r3575)
1454 */
1455 function bbp_admin_setting_callback_group_forums() {
1456 ?>
1457
1458 <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' ); ?> />
1459 <label for="_bbp_enable_group_forums"><?php esc_html_e( 'Allow BuddyPress Groups to have their own forums', 'bbpress' ); ?></label>
1460
1461 <?php
1462 }
1463
1464 /**
1465 * Replies per page setting field
1466 *
1467 * @since 2.1.0 bbPress (r3575)
1468 */
1469 function bbp_admin_setting_callback_group_forums_root_id() {
1470
1471 // Group root ID
1472 $group_root = bbp_get_group_forums_root_id();
1473 if ( ! bbp_get_forum( $group_root ) ) {
1474 delete_option( '_bbp_group_forums_root_id' );
1475 $group_root = 0;
1476 }
1477
1478 // Output the dropdown for all forums
1479 $select = bbp_get_dropdown(
1480 array(
1481 'selected' => $group_root,
1482 'show_none' => esc_html__( '&mdash; No parent &mdash;', 'bbpress' ),
1483 'orderby' => 'title',
1484 'order' => 'ASC',
1485 'select_id' => '_bbp_group_forums_root_id',
1486 'disable_categories' => false,
1487 'disabled' => '_bbp_group_forums_root_id'
1488 )
1489 );
1490
1491 // Check cap one time
1492 $can_add_new = current_user_can( 'publish_forums' );
1493 $button = '';
1494
1495 // Text variations based on configuration
1496 if ( empty( $group_root ) && ( true === $can_add_new ) ) {
1497
1498 // New URL
1499 $new_url = wp_nonce_url(
1500 add_query_arg(
1501 array(
1502 'page' => 'bbpress',
1503 'create' => 'bbp-group-forum-root'
1504 ),
1505 admin_url( 'options-general.php' )
1506 ),
1507 '_bbp_group_forums_root_id'
1508 );
1509
1510 // Button & text
1511 $button = '<a href="' . esc_url( $new_url ) . '">' . esc_html__( 'create a new one', 'bbpress' ) . '</a>';
1512 $text = esc_html__( 'Use %s to contain your group forums, or %s', 'bbpress' ); //phpcs:ignore
1513 } else {
1514 /* translators: %s: Forum select dropdown HTML */
1515 $text = esc_html__( 'Use %s to contain your group forums', 'bbpress' );
1516 }
1517
1518 // Output
1519 printf( $text, $select, $button ); ?>
1520 <p class="description"><?php esc_html_e( 'Changing this will not move existing forums.', 'bbpress' ); ?></p>
1521
1522 <?php
1523 }
1524
1525 /** Akismet *******************************************************************/
1526
1527 /**
1528 * Extension settings section description for the settings page
1529 *
1530 * @since 2.1.0 bbPress (r3575)
1531 */
1532 function bbp_admin_setting_callback_akismet_section() {
1533 ?>
1534
1535 <p><?php esc_html_e( 'Forum settings for Akismet', 'bbpress' ); ?></p>
1536
1537 <?php
1538 }
1539
1540
1541 /**
1542 * Allow Akismet setting field
1543 *
1544 * @since 2.1.0 bbPress (r3575)
1545 */
1546 function bbp_admin_setting_callback_akismet() {
1547 ?>
1548
1549 <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' ); ?> />
1550 <label for="_bbp_enable_akismet"><?php _e( 'Allow Akismet to actively prevent forum spam.', 'bbpress' ); // phpcs:ignore WordPress.Security.EscapeOutput.UnsafePrintingFunction ?></label>
1551
1552 <?php
1553 }
1554
1555 /** Settings Page *************************************************************/
1556
1557 /**
1558 * The main settings page
1559 *
1560 * @since 2.0.0 bbPress (r2643)
1561 */
1562 function bbp_admin_settings() {
1563 ?>
1564
1565 <div class="wrap">
1566 <h1 class="wp-heading-inline"><?php esc_html_e( 'Forums Settings', 'bbpress' ); ?></h1>
1567 <hr class="wp-header-end">
1568
1569 <form action="options.php" method="post">
1570
1571 <?php settings_fields( 'bbpress' ); ?>
1572
1573 <?php do_settings_sections( 'bbpress' ); ?>
1574
1575 <p class="submit">
1576 <input type="submit" name="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'bbpress' ); ?>" />
1577 </p>
1578 </form>
1579 </div>
1580
1581 <?php
1582 }
1583
1584 /** Converter Section *********************************************************/
1585
1586 /**
1587 * Main settings section description for the settings page
1588 *
1589 * @since 2.1.0 bbPress (r3813)
1590 */
1591 function bbp_converter_setting_callback_main_section() {
1592 ?>
1593
1594 <p><?php esc_html_e( 'Information about the database for your previous forums so they can be converted.', 'bbpress' ); ?></p>
1595
1596 <?php
1597 }
1598
1599 /**
1600 * Edit Platform setting field
1601 *
1602 * @since 2.1.0 bbPress (r3813)
1603 */
1604 function bbp_converter_setting_callback_platform() {
1605
1606 // Converters
1607 $current = get_option( '_bbp_converter_platform' );
1608 $converters = bbp_get_converters();
1609 $options = '';
1610
1611 // Put options together
1612 foreach ( $converters as $name => $file ) {
1613 $options .= '<option value="' . esc_attr( $name ) . '"' . selected( $name, $current, false ) . '>' . esc_html( $name ) . '</option>';
1614 } ?>
1615
1616 <select name="_bbp_converter_platform" id="_bbp_converter_platform"><?php echo $options; ?></select>
1617 <p class="description"><?php esc_html_e( 'The previous forum software', 'bbpress' ); ?></p>
1618
1619 <?php
1620 }
1621
1622 /**
1623 * Edit Database Server setting field
1624 *
1625 * @since 2.1.0 bbPress (r3813)
1626 */
1627 function bbp_converter_setting_callback_dbserver() {
1628 ?>
1629
1630 <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' ); ?> />
1631 <p class="description"><?php printf(
1632 /* translators: %s: Default value wrapped in code tags */
1633 esc_html__( 'Use default %s if same server, or IP or hostname', 'bbpress' ),
1634 '<code>localhost</code>'
1635 ); ?></p>
1636
1637 <?php
1638 }
1639
1640 /**
1641 * Edit Database Server Port setting field
1642 *
1643 * @since 2.1.0 bbPress (r3813)
1644 */
1645 function bbp_converter_setting_callback_dbport() {
1646 ?>
1647
1648 <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' ); ?> />
1649 <p class="description"><?php
1650 printf(
1651 /* translators: %s: Default port number wrapped in code tags */
1652 esc_html__( 'Use default %s if unsure', 'bbpress' ),
1653 '<code>3306</code>'
1654 ); ?></p>
1655
1656 <?php
1657 }
1658
1659 /**
1660 * Edit Database User setting field
1661 *
1662 * @since 2.1.0 bbPress (r3813)
1663 */
1664 function bbp_converter_setting_callback_dbuser() {
1665 ?>
1666
1667 <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' ); ?> />
1668 <p class="description"><?php esc_html_e( 'User to access the database', 'bbpress' ); ?></p>
1669
1670 <?php
1671 }
1672
1673 /**
1674 * Edit Database Pass setting field
1675 *
1676 * @since 2.1.0 bbPress (r3813)
1677 */
1678 function bbp_converter_setting_callback_dbpass() {
1679 ?>
1680
1681 <span class="bbp-converter-db-password-wrapper">
1682 <input name="_bbp_converter_db_pass" id="_bbp_converter_db_pass" class="bbp-converter-db-pass code" type="password" value="<?php bbp_form_option( '_bbp_converter_db_pass' ); ?>" autocomplete="off" <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_db_pass' ); ?> />
1683 <button type="button" class="bbp-db-pass-toggle password">
1684 <span class="screen-reader-text"><?php esc_html_e( 'Toggle', 'bbpress' ); ?></span>
1685 <span class="toggle-indicator" aria-hidden="true"></span>
1686 </button>
1687 </span>
1688 <p class="description"><?php esc_html_e( 'Password for the above database user', 'bbpress' ); ?></p>
1689
1690 <?php
1691 }
1692
1693 /**
1694 * Edit Database Name setting field
1695 *
1696 * @since 2.1.0 bbPress (r3813)
1697 */
1698 function bbp_converter_setting_callback_dbname() {
1699 ?>
1700
1701 <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' ); ?> />
1702 <p class="description"><?php esc_html_e( 'Name of the database with your old forum data', 'bbpress' ); ?></p>
1703
1704 <?php
1705 }
1706
1707 /**
1708 * Main settings section description for the settings page
1709 *
1710 * @since 2.1.0 bbPress (r3813)
1711 */
1712 function bbp_converter_setting_callback_options_section() {
1713 ?>
1714
1715 <p><?php esc_html_e( 'Some optional parameters to help tune the conversion process.', 'bbpress' ); ?></p>
1716
1717 <?php
1718 }
1719
1720 /**
1721 * Edit Table Prefix setting field
1722 *
1723 * @since 2.1.0 bbPress (r3813)
1724 */
1725 function bbp_converter_setting_callback_dbprefix() {
1726 ?>
1727
1728 <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' ); ?> />
1729 <p class="description"><?php printf(
1730 /* translators: %s: Database prefix example wrapped in code tags */
1731 esc_html__( 'Use %s if converting from BuddyPress Legacy', 'bbpress' ),
1732 '<code>wp_bb_</code>'
1733 ); ?></p>
1734
1735 <?php
1736 }
1737
1738 /**
1739 * Edit Rows Limit setting field
1740 *
1741 * @since 2.1.0 bbPress (r3813)
1742 */
1743 function bbp_converter_setting_callback_rows() {
1744 ?>
1745
1746 <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' ); ?> />
1747 <label for="_bbp_converter_rows"><?php esc_html_e( 'entry maximum when querying for data to convert', 'bbpress' ); ?></label>
1748 <p class="description"><?php esc_html_e( 'Keep this low if you experience out-of-memory issues.', 'bbpress' ); ?></p>
1749
1750 <?php
1751 }
1752
1753 /**
1754 * Edit Delay Time setting field
1755 *
1756 * @since 2.1.0 bbPress (r3813)
1757 */
1758 function bbp_converter_setting_callback_delay_time() {
1759 ?>
1760
1761 <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' ); ?> />
1762 <label for="_bbp_converter_delay_time"><?php esc_html_e( 'second delay between each query of rows above', 'bbpress' ); ?></label>
1763 <p class="description"><?php esc_html_e( 'Keep this high to prevent too-many-connection issues.', 'bbpress' ); ?></p>
1764
1765 <?php
1766 }
1767
1768 /**
1769 * Edit Halt setting field
1770 *
1771 * @since 2.6.0 bbPress (r6599)
1772 */
1773 function bbp_converter_setting_callback_halt() {
1774 ?>
1775
1776 <input name="_bbp_converter_halt" id="_bbp_converter_halt" type="checkbox" value="1" <?php checked( get_option( '_bbp_converter_halt', false ) ); ?> />
1777 <label for="_bbp_converter_halt"><?php esc_html_e( 'Halt the conversion if an error occurs', 'bbpress' ); ?></label>
1778 <p class="description"><?php esc_html_e( 'This is helpful if you want to debug problems.', 'bbpress' ); ?></p>
1779
1780 <?php
1781 }
1782
1783
1784 /**
1785 * Edit Restart setting field
1786 *
1787 * @since 2.1.0 bbPress (r3813)
1788 */
1789 function bbp_converter_setting_callback_restart() {
1790 ?>
1791
1792 <input name="_bbp_converter_restart" id="_bbp_converter_restart" type="checkbox" value="1" <?php checked( get_option( '_bbp_converter_restart', false ) ); ?> />
1793 <label for="_bbp_converter_restart"><?php esc_html_e( 'Restart the converter from the beginning', 'bbpress' ); ?></label>
1794 <p class="description"><?php esc_html_e( 'This forces all steps back to 0. Avoid duplicate data by purging or resetting first.', 'bbpress' ); ?></p>
1795
1796 <?php
1797 }
1798
1799 /**
1800 * Edit Clean setting field
1801 *
1802 * @since 2.1.0 bbPress (r3813)
1803 */
1804 function bbp_converter_setting_callback_clean() {
1805 ?>
1806
1807 <input name="_bbp_converter_clean" id="_bbp_converter_clean" type="checkbox" value="1" <?php checked( get_option( '_bbp_converter_clean', false ) ); ?> />
1808 <label for="_bbp_converter_clean"><?php esc_html_e( 'Purge all meta-data from a previous import', 'bbpress' ); ?></label>
1809 <p class="description"><?php esc_html_e( 'Use this if an import failed, or you just want to remove the relationship data.', 'bbpress' ); ?></p>
1810
1811 <?php
1812 }
1813
1814 /**
1815 * Edit Convert Users setting field
1816 *
1817 * @since 2.1.0 bbPress (r3813)
1818 */
1819 function bbp_converter_setting_callback_convert_users() {
1820 ?>
1821
1822 <input name="_bbp_converter_convert_users" id="_bbp_converter_convert_users" type="checkbox" value="1" <?php checked( get_option( '_bbp_converter_convert_users', false ) ); ?> <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_convert_users' ); ?> />
1823 <label for="_bbp_converter_convert_users"><?php esc_html_e( 'Import user accounts from previous forums', 'bbpress' ); ?></label>
1824 <p class="description"><?php esc_html_e( 'Passwords remain encrypted, and are converted as individual users log in.', 'bbpress' ); ?></p>
1825
1826 <?php
1827 }
1828
1829 /** Converter Page ************************************************************/
1830
1831 /**
1832 * The main settings page
1833 *
1834 * @since 2.1.0 bbPress (r3186)
1835 */
1836 function bbp_converter_settings_page() {
1837
1838 // Status
1839 $step = (int) get_option( '_bbp_converter_step', 0 );
1840 $max = (int) bbp_admin()->converter->max_steps;
1841
1842 // Starting or continuing?
1843 $status_text = ! empty( $step )
1844 /* translators: %s: Current step number */
1845 ? sprintf( esc_html__( 'Up next: step %s', 'bbpress' ), $step )
1846 : esc_html__( 'Ready', 'bbpress' );
1847
1848 // Starting or continuing?
1849 $start_text = ! empty( $step )
1850 ? esc_html__( 'Resume', 'bbpress' )
1851 : esc_html__( 'Start', 'bbpress' );
1852
1853 // Starting or continuing?
1854 $progress_text = ! empty( $step )
1855 /* translators: 1: Current step number, 2: Total number of steps */
1856 ? sprintf( esc_html__( 'Previously stopped at step %1$d of %2$d', 'bbpress' ), $step, $max )
1857 : esc_html__( 'Ready to go.', 'bbpress' ); ?>
1858
1859 <div class="wrap">
1860 <h1 class="wp-heading-inline"><?php esc_html_e( 'Forum Tools', 'bbpress' ); ?></h1>
1861 <hr class="wp-header-end">
1862 <h2 class="nav-tab-wrapper"><?php bbp_tools_admin_tabs( 'bbp-converter' ); ?></h2>
1863
1864 <div class="bbp-converter-wrap">
1865 <div id="poststuff" class="bbp-converter-monitor-wrap">
1866 <div id="post-body" class="metabox-holder columns-1">
1867 <div id="postbox-container-1" class="postbox-container">
1868 <div id="normal-sortables" class="meta-box-sortables ui-sortable">
1869 <div id="bbp-converter-monitor" class="postbox">
1870 <button type="button" class="handlediv" aria-expanded="true">
1871 <span class="screen-reader-text"><?php esc_html_e( 'Toggle panel: Import Status', 'bbpress' ); ?></span>
1872 <span class="toggle-indicator" aria-hidden="true"></span>
1873 </button>
1874 <h2 class="hndle ui-sortable-handle">
1875 <span><?php esc_html_e( 'Import Monitor', 'bbpress' ); ?></span>
1876 <span id="bbp-converter-status"><?php echo esc_html( $status_text ); ?></span>
1877 <span id="bbp-converter-step-percentage" class="bbp-progress-bar"></span>
1878 <span id="bbp-converter-total-percentage" class="bbp-progress-bar"></span>
1879 </h2>
1880 <div class="inside">
1881 <div id="bbp-converter-message" class="bbp-converter-log">
1882 <p><?php echo esc_html( $progress_text ); ?></p>
1883 </div>
1884 </div>
1885 <div class="actions">
1886 <input type="button" name="submit" class="button-primary" id="bbp-converter-start" value="<?php echo esc_attr( $start_text ); ?>" />
1887 <input type="button" name="submit" class="button-primary" id="bbp-converter-stop" value="<?php esc_attr_e( 'Pause', 'bbpress' ); ?>" />
1888 <span class="spinner" id="bbp-converter-spinner"></span>
1889 </div>
1890 </div>
1891 </div>
1892 </div>
1893 </div>
1894 </div>
1895
1896 <form action="#" method="post" id="bbp-converter-settings" class="bbp-converter-settings-wrap"><?php
1897
1898 // Fields
1899 settings_fields( 'converter' );
1900
1901 // Sections
1902 do_settings_sections( 'converter' );
1903
1904 ?></form>
1905 </div>
1906 </div>
1907 <?php
1908 }
1909
1910 /** Helpers *******************************************************************/
1911
1912 /**
1913 * Contextual help for Forums settings page
1914 *
1915 * @since 2.0.0 bbPress (r3119)
1916 */
1917 function bbp_admin_settings_help() {
1918
1919 $current_screen = get_current_screen();
1920
1921 // Bail if current screen could not be found
1922 if ( empty( $current_screen ) ) {
1923 return;
1924 }
1925
1926 // Overview
1927 $current_screen->add_help_tab(
1928 array(
1929 'id' => 'overview',
1930 'title' => esc_html__( 'Overview', 'bbpress' ),
1931 'content' =>
1932 '<p>' . esc_html__( 'This screen provides access to all of the Forums settings.', 'bbpress' ) . '</p>' .
1933 '<p>' . esc_html__( 'Please see the additional help tabs for more information on each individual section.', 'bbpress' ) . '</p>'
1934 )
1935 );
1936
1937 // Main Settings
1938 $current_screen->add_help_tab(
1939 array(
1940 'id' => 'main_settings',
1941 'title' => esc_html__( 'Main Settings', 'bbpress' ),
1942 'content' =>
1943 '<p>' . esc_html__( 'The "Main Settings" section includes a number of options:', 'bbpress' ) . '</p>' .
1944 '<p>' .
1945 '<ul>' .
1946 '<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>' .
1947 '<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>' .
1948 '<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>' .
1949 '<li>' . esc_html__( 'Subscriptions allow users to subscribe for notifications to topics that interest them. This is enabled by default.', 'bbpress' ) . '</li>' .
1950 '<li>' . esc_html__( 'Topic-Tags allow users to filter topics between forums. This is enabled by default.', 'bbpress' ) . '</li>' .
1951 '<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>' .
1952 '<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>' .
1953 '<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>' .
1954 '</ul>' .
1955 '</p>' .
1956 '<p>' . esc_html__( 'You must click the Save Changes button at the bottom of the screen for new settings to take effect.', 'bbpress' ) . '</p>'
1957 )
1958 );
1959
1960 // Theme Package
1961 $current_screen->add_help_tab(
1962 array(
1963 'id' => 'theme_packages',
1964 'title' => esc_html__( 'Theme Packages', 'bbpress' ),
1965 'content' =>
1966 '<p>' . esc_html__( 'The "Theme Packages" section allows you to choose which theme package should be used.', 'bbpress' ) . '</p>' .
1967 '<p>' .
1968 '<ul>' .
1969 '<li>' . esc_html__( 'The "bbPress Default" package is installed by default.', 'bbpress' ) . '</li>' .
1970 '<li>' . esc_html__( 'Some themes may choose to ignore this setting entirely.', 'bbpress' ) . '</li>' .
1971 '<li>' . esc_html__( 'Packages can be stacked to allow for intelligent fallbacks.', 'bbpress' ) . '</li>' .
1972 '</ul>' .
1973 '</p>'
1974 )
1975 );
1976
1977 // Per Page
1978 $current_screen->add_help_tab(
1979 array(
1980 'id' => 'per_page',
1981 'title' => esc_html__( 'Per Page', 'bbpress' ),
1982 'content' =>
1983 '<p>' . esc_html__( 'The "Per Page" section allows you to control the number of topics and replies appear on each page.', 'bbpress' ) . '</p>' .
1984 '<ul>' .
1985 '<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>' .
1986 '<li>' . esc_html__( 'These are broken up into two separate groups: one for what appears in your theme, another for RSS feeds.', 'bbpress' ) . '</li>' .
1987 '</ul>' .
1988 '<p>'
1989 )
1990 );
1991
1992 // Slugs
1993 $current_screen->add_help_tab(
1994 array(
1995 'id' => 'slugs',
1996 'title' => esc_html__( 'Slugs', 'bbpress' ),
1997 'content' =>
1998 '<p>' . esc_html__( 'The "Slugs" section allows you to control the permalink structure for your forums.', 'bbpress' ) . '</p>' .
1999 '<ul>' .
2000 '<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>' .
2001 '<li>' . esc_html__( '"Single Slugs" are used as a prefix when viewing an individual forum, topic, reply, user, or view.', 'bbpress' ) . '</li>' .
2002 '<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>' .
2003 '</ul>' .
2004 '<p>'
2005 )
2006 );
2007
2008 // Help Sidebar
2009 $current_screen->set_help_sidebar(
2010 '<p><strong>' . esc_html__( 'For more information:', 'bbpress' ) . '</strong></p>' .
2011 '<p>' . __( '<a href="https://codex.bbpress.org" target="_blank">bbPress Documentation</a>', 'bbpress' ) . '</p>' .
2012 '<p>' . __( '<a href="https://bbpress.org/forums/" target="_blank">bbPress Support Forums</a>', 'bbpress' ) . '</p>'
2013 );
2014 }
2015
2016 /**
2017 * Disable a settings field if it is forcibly set in the global options array.
2018 *
2019 * @since 2.2.0 bbPress (r4347)
2020 *
2021 * @param string $option_key
2022 */
2023 function bbp_maybe_admin_setting_disabled( $option_key = '' ) {
2024 disabled( isset( bbpress()->options[ $option_key ] ) );
2025 }
2026
2027 /**
2028 * Output settings API option
2029 *
2030 * @since 2.0.0 bbPress (r3203)
2031 *
2032 * @param string $option
2033 * @param string $default
2034 * @param bool $slug
2035 */
2036 function bbp_form_option( $option, $default = '', $slug = false ) {
2037 echo bbp_get_form_option( $option, $default, $slug );
2038 }
2039 /**
2040 * Return settings API option
2041 *
2042 * @since 2.0.0 bbPress (r3203)
2043 *
2044 * @param string $option
2045 * @param string $default
2046 * @param bool $is_slug
2047 *
2048 * @return mixed
2049 */
2050 function bbp_get_form_option( $option, $default = '', $is_slug = false ) {
2051
2052 // Get the option and sanitize it
2053 $value = get_option( $option, $default );
2054
2055 // Slug?
2056 if ( true === $is_slug ) {
2057 $value = esc_attr( apply_filters( 'editable_slug', $value ) );
2058
2059 // Not a slug
2060 } else {
2061 $value = esc_attr( $value );
2062 }
2063
2064 // Fallback to default, unless numeric (allow zero)
2065 if ( empty( $value ) && ! is_numeric( $value ) ) {
2066 $value = $default;
2067 }
2068
2069 // Filter & return
2070 return apply_filters( 'bbp_get_form_option', $value, $option, $default, $is_slug );
2071 }
2072
2073 /**
2074 * Used to check if a bbPress slug conflicts with an existing known slug.
2075 *
2076 * @since 2.0.0 bbPress (r3306)
2077 *
2078 * @param string $slug
2079 * @param string $default
2080 */
2081 function bbp_form_slug_conflict_check( $slug, $default ) {
2082
2083 // Only set the slugs once ver page load
2084 static $the_core_slugs = array();
2085
2086 // Get the form value
2087 $this_slug = bbp_get_form_option( $slug, $default, true );
2088
2089 if ( empty( $the_core_slugs ) ) {
2090
2091 // Slugs to check
2092 $core_slugs = apply_filters(
2093 'bbp_slug_conflict_check',
2094 array(
2095
2096 /** WordPress Core ****************************************************/
2097
2098 // Core Post Types
2099 'post_base' => array(
2100 'name' => esc_html__( 'Posts', 'bbpress' ),
2101 'default' => 'post',
2102 'context' => 'WordPress'
2103 ),
2104 'page_base' => array(
2105 'name' => esc_html__( 'Pages', 'bbpress' ),
2106 'default' => 'page',
2107 'context' => 'WordPress'
2108 ),
2109 'revision_base' => array(
2110 'name' => esc_html__( 'Revisions', 'bbpress' ),
2111 'default' => 'revision',
2112 'context' => 'WordPress'
2113 ),
2114 'attachment_base' => array(
2115 'name' => esc_html__( 'Attachments', 'bbpress' ),
2116 'default' => 'attachment',
2117 'context' => 'WordPress'
2118 ),
2119 'nav_menu_base' => array(
2120 'name' => esc_html__( 'Menus', 'bbpress' ),
2121 'default' => 'nav_menu_item',
2122 'context' => 'WordPress'
2123 ),
2124
2125 // Post Tags
2126 'tag_base' => array(
2127 'name' => esc_html__( 'Tag base', 'bbpress' ),
2128 'default' => 'tag',
2129 'context' => 'WordPress'
2130 ),
2131
2132 // Post Categories
2133 'category_base' => array(
2134 'name' => esc_html__( 'Category base', 'bbpress' ),
2135 'default' => 'category',
2136 'context' => 'WordPress'
2137 ),
2138
2139 /** bbPress Core ******************************************************/
2140
2141 // Forum archive slug
2142 '_bbp_root_slug' => array(
2143 'name' => esc_html__( 'Forums base', 'bbpress' ),
2144 'default' => 'forums',
2145 'context' => 'bbPress'
2146 ),
2147
2148 // Topic archive slug
2149 '_bbp_topic_archive_slug' => array(
2150 'name' => esc_html__( 'Topics base', 'bbpress' ),
2151 'default' => 'topics',
2152 'context' => 'bbPress'
2153 ),
2154
2155 // Forum slug
2156 '_bbp_forum_slug' => array(
2157 'name' => esc_html__( 'Forum slug', 'bbpress' ),
2158 'default' => 'forum',
2159 'context' => 'bbPress'
2160 ),
2161
2162 // Topic slug
2163 '_bbp_topic_slug' => array(
2164 'name' => esc_html__( 'Topic slug', 'bbpress' ),
2165 'default' => 'topic',
2166 'context' => 'bbPress'
2167 ),
2168
2169 // Reply slug
2170 '_bbp_reply_slug' => array(
2171 'name' => esc_html__( 'Reply slug', 'bbpress' ),
2172 'default' => 'reply',
2173 'context' => 'bbPress'
2174 ),
2175
2176 // Edit slug
2177 '_bbp_edit_slug' => array(
2178 'name' => esc_html__( 'Edit slug', 'bbpress' ),
2179 'default' => 'edit',
2180 'context' => 'bbPress'
2181 ),
2182
2183 // User profile slug
2184 '_bbp_user_slug' => array(
2185 'name' => esc_html__( 'User base', 'bbpress' ),
2186 'default' => 'users',
2187 'context' => 'bbPress'
2188 ),
2189
2190 // View slug
2191 '_bbp_view_slug' => array(
2192 'name' => esc_html__( 'View base', 'bbpress' ),
2193 'default' => 'view',
2194 'context' => 'bbPress'
2195 ),
2196
2197 // Topic tag slug
2198 '_bbp_topic_tag_slug' => array(
2199 'name' => esc_html__( 'Topic tag slug', 'bbpress' ),
2200 'default' => 'topic-tag',
2201 'context' => 'bbPress'
2202 ),
2203 )
2204 );
2205
2206 /** BuddyPress Core *******************************************************/
2207
2208 if ( defined( 'BP_VERSION' ) ) {
2209 $bp = buddypress();
2210
2211 // Loop through root slugs and check for conflict
2212 if ( ! empty( $bp->pages ) ) {
2213 foreach ( $bp->pages as $page => $page_data ) {
2214 $page_base = $page . '_base';
2215 /* translators: %s: BuddyPress page title */
2216 $page_title = sprintf( esc_html__( '%s page', 'bbpress' ), $page_data->title );
2217 $core_slugs[ $page_base ] = array(
2218 'name' => $page_title,
2219 'default' => $page_data->slug,
2220 'context' => 'BuddyPress'
2221 );
2222 }
2223 }
2224 }
2225
2226 // Set the static
2227 $the_core_slugs = apply_filters( 'bbp_slug_conflict', $core_slugs );
2228 }
2229
2230 // Loop through slugs to check
2231 foreach ( $the_core_slugs as $key => $value ) {
2232
2233 // Get the slug
2234 $slug_check = bbp_get_form_option( $key, $value['default'], true );
2235
2236 // Compare
2237 if ( ( $slug !== $key ) && ( $slug_check === $this_slug ) ) :
2238 ?>
2239
2240 <span class="attention"><?php printf(
2241 /* translators: 1: Context (e.g., "BuddyPress"), 2: Name of the conflicting item */
2242 esc_html__( 'Possible %1$s conflict: %2$s', 'bbpress' ),
2243 $value['context'],
2244 '<strong>' . $value['name'] . '</strong>'
2245 ); ?></span>
2246
2247 <?php endif;
2248 }
2249 }
2250