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

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

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