PluginProbe
bbPress / 2.1
bbPress v2.1
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 / bbp-admin / bbp-settings.php

bbp-settings.php in bbPress 2.1, at bbp-admin/bbp-settings.php

1,422 lines 44.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 if ( !defined( 'ABSPATH' ) ) exit;
12
13 /** Sections ******************************************************************/
14
15 /**
16 * Get the bbPress settings sections.
17 *
18 * @since bbPress (r4001)
19 * @return array
20 */
21 function bbp_admin_get_settings_sections() {
22 return apply_filters( 'bbp_admin_get_settings_sections', array(
23 'bbp_settings_main' => array(
24 'title' => __( 'Main Settings', 'bbpress' ),
25 'callback' => 'bbp_admin_setting_callback_main_section',
26 'page' => 'bbpress',
27 ),
28 'bbp_settings_theme_compat' => array(
29 'title' => __( 'Theme Packages', 'bbpress' ),
30 'callback' => 'bbp_admin_setting_callback_subtheme_section',
31 'page' => 'bbpress',
32 ),
33 'bbp_settings_per_page' => array(
34 'title' => __( 'Per Page', 'bbpress' ),
35 'callback' => 'bbp_admin_setting_callback_per_page_section',
36 'page' => 'bbpress',
37 ),
38 'bbp_settings_per_rss_page' => array(
39 'title' => __( 'Per RSS Page', 'bbpress' ),
40 'callback' => 'bbp_admin_setting_callback_per_rss_page_section',
41 'page' => 'bbpress',
42 ),
43 'bbp_settings_root_slugs' => array(
44 'title' => __( 'Archive Slugs', 'bbpress' ),
45 'callback' => 'bbp_admin_setting_callback_root_slug_section',
46 'page' => 'bbpress',
47 ),
48 'bbp_settings_single_slugs' => array(
49 'title' => __( 'Single Slugs', 'bbpress' ),
50 'callback' => 'bbp_admin_setting_callback_single_slug_section',
51 'page' => 'bbpress',
52 ),
53 'bbp_settings_buddypress' => array(
54 'title' => __( 'BuddyPress', 'bbpress' ),
55 'callback' => 'bbp_admin_setting_callback_buddypress_section',
56 'page' => 'bbpress',
57 ),
58 'bbp_settings_akismet' => array(
59 'title' => __( 'Akismet', 'bbpress' ),
60 'callback' => 'bbp_admin_setting_callback_akismet_section',
61 'page' => 'bbpress'
62 )
63 ) );
64 }
65
66 /**
67 * Get all of the settings fields.
68 *
69 * @since bbPress (r4001)
70 * @return type
71 */
72 function bbp_admin_get_settings_fields() {
73 return apply_filters( 'bbp_admin_get_settings_fields', array(
74
75 /** Main Section ******************************************************/
76
77 'bbp_settings_main' => array(
78
79 // Edit lock setting
80 '_bbp_edit_lock' => array(
81 'title' => __( 'Lock post editing after', 'bbpress' ),
82 'callback' => 'bbp_admin_setting_callback_editlock',
83 'sanitize_callback' => 'intval',
84 'args' => array()
85 ),
86
87 // Throttle setting
88 '_bbp_throttle_time' => array(
89 'title' => __( 'Throttle time', 'bbpress' ),
90 'callback' => 'bbp_admin_setting_callback_throttle',
91 'sanitize_callback' => 'intval',
92 'args' => array()
93 ),
94
95 // Allow topic and reply revisions
96 '_bbp_allow_revisions' => array(
97 'title' => __( 'Allow Revisions', 'bbpress' ),
98 'callback' => 'bbp_admin_setting_callback_revisions',
99 'sanitize_callback' => 'intval',
100 'args' => array()
101 ),
102
103 // Allow favorites setting
104 '_bbp_enable_favorites' => array(
105 'title' => __( 'Allow Favorites', 'bbpress' ),
106 'callback' => 'bbp_admin_setting_callback_favorites',
107 'sanitize_callback' => 'intval',
108 'args' => array()
109 ),
110
111 // Allow subscriptions setting
112 '_bbp_enable_subscriptions' => array(
113 'title' => __( 'Allow Subscriptions', 'bbpress' ),
114 'callback' => 'bbp_admin_setting_callback_subscriptions',
115 'sanitize_callback' => 'intval',
116 'args' => array()
117 ),
118
119 // Allow anonymous posting setting
120 '_bbp_allow_anonymous' => array(
121 'title' => __( 'Allow Anonymous Posting', 'bbpress' ),
122 'callback' => 'bbp_admin_setting_callback_anonymous',
123 'sanitize_callback' => 'intval',
124 'args' => array()
125 ),
126
127 // Allow global access (on multisite)
128 '_bbp_allow_global_access' => array(
129 'title' => __( 'Allow Global Access', 'bbpress' ),
130 'callback' => 'bbp_admin_setting_callback_global_access',
131 'sanitize_callback' => 'intval',
132 'args' => array()
133 ),
134
135 // Allow fancy editor setting
136 '_bbp_use_wp_editor' => array(
137 'title' => __( 'Fancy Editor', 'bbpress' ),
138 'callback' => 'bbp_admin_setting_callback_use_wp_editor',
139 'args' => array(),
140 'sanitize_callback' => 'intval'
141 ),
142
143 // Allow auto embedding setting
144 '_bbp_use_autoembed' => array(
145 'title' => __( 'Auto-embed Links', 'bbpress' ),
146 'callback' => 'bbp_admin_setting_callback_use_autoembed',
147 'sanitize_callback' => 'intval',
148 'args' => array()
149 )
150 ),
151
152 /** Theme Packages ****************************************************/
153
154 'bbp_settings_theme_compat' => array(
155
156 // Replies per page setting
157 '_bbp_theme_package_id' => array(
158 'title' => __( 'Current Package', 'bbpress' ),
159 'callback' => 'bbp_admin_setting_callback_subtheme_id',
160 'sanitize_callback' => 'esc_sql',
161 'args' => array()
162 )
163 ),
164
165 /** Per Page Section **************************************************/
166
167 'bbp_settings_per_page' => array(
168
169 // Replies per page setting
170 '_bbp_topics_per_page' => array(
171 'title' => __( 'Topics', 'bbpress' ),
172 'callback' => 'bbp_admin_setting_callback_topics_per_page',
173 'sanitize_callback' => 'intval',
174 'args' => array()
175 ),
176
177 // Replies per page setting
178 '_bbp_replies_per_page' => array(
179 'title' => __( 'Replies', 'bbpress' ),
180 'callback' => 'bbp_admin_setting_callback_replies_per_page',
181 'sanitize_callback' => 'intval',
182 'args' => array()
183 )
184 ),
185
186 /** Per RSS Page Section **********************************************/
187
188 'bbp_settings_per_rss_page' => array(
189
190 // Replies per page setting
191 '_bbp_topics_per_rss_page' => array(
192 'title' => __( 'Topics', 'bbpress' ),
193 'callback' => 'bbp_admin_setting_callback_topics_per_rss_page',
194 'sanitize_callback' => 'intval',
195 'args' => array()
196 ),
197
198 // Replies per page setting
199 '_bbp_replies_per_rss_page' => array(
200 'title' => __( 'Replies', 'bbpress' ),
201 'callback' => 'bbp_admin_setting_callback_replies_per_rss_page',
202 'sanitize_callback' => 'intval',
203 'args' => array()
204 )
205 ),
206
207 /** Front Slugs *******************************************************/
208
209 'bbp_settings_root_slugs' => array(
210
211 // Root slug setting
212 '_bbp_root_slug' => array(
213 'title' => __( 'Forums base', 'bbpress' ),
214 'callback' => 'bbp_admin_setting_callback_root_slug',
215 'sanitize_callback' => 'esc_sql',
216 'args' => array()
217 ),
218
219 // Topic archive setting
220 '_bbp_topic_archive_slug' => array(
221 'title' => __( 'Topics base', 'bbpress' ),
222 'callback' => 'bbp_admin_setting_callback_topic_archive_slug',
223 'sanitize_callback' => 'esc_sql',
224 'args' => array()
225 )
226 ),
227
228 /** Single Slugs ******************************************************/
229
230 'bbp_settings_single_slugs' => array(
231
232 // Include root setting
233 '_bbp_include_root' => array(
234 'title' => __( 'Forum Prefix', 'bbpress' ),
235 'callback' => 'bbp_admin_setting_callback_include_root',
236 'sanitize_callback' => 'intval',
237 'args' => array()
238 ),
239
240 // Forum slug setting
241 '_bbp_forum_slug' => array(
242 'title' => __( 'Forum slug', 'bbpress' ),
243 'callback' => 'bbp_admin_setting_callback_forum_slug',
244 'sanitize_callback' => 'sanitize_title',
245 'args' => array()
246 ),
247
248 // Topic slug setting
249 '_bbp_topic_slug' => array(
250 'title' => __( 'Topic slug', 'bbpress' ),
251 'callback' => 'bbp_admin_setting_callback_topic_slug',
252 'sanitize_callback' => 'sanitize_title',
253 'args' => array()
254 ),
255
256 // Topic tag slug setting
257 '_bbp_topic_tag_slug' => array(
258 'title' => __( 'Topic tag slug', 'bbpress' ),
259 'callback' => 'bbp_admin_setting_callback_topic_tag_slug',
260 'sanitize_callback' => 'sanitize_title',
261 'args' => array()
262 ),
263
264 // Reply slug setting
265 '_bbp_reply_slug' => array(
266 'title' => __( 'Reply slug', 'bbpress' ),
267 'callback' => 'bbp_admin_setting_callback_reply_slug',
268 'sanitize_callback' => 'sanitize_title',
269 'args' => array()
270 ),
271
272 // User slug setting
273 '_bbp_user_slug' => array(
274 'title' => __( 'User slug', 'bbpress' ),
275 'callback' => 'bbp_admin_setting_callback_user_slug',
276 'sanitize_callback' => 'sanitize_title',
277 'args' => array()
278 ),
279
280 // View slug setting
281 '_bbp_view_slug' => array(
282 'title' => __( 'Topic view slug', 'bbpress' ),
283 'callback' => 'bbp_admin_setting_callback_view_slug',
284 'sanitize_callback' => 'sanitize_title',
285 'args' => array()
286 )
287 ),
288
289 /** BuddyPress ********************************************************/
290
291 'bbp_settings_buddypress' => array(
292
293 // Are group forums enabled?
294 '_bbp_enable_group_forums' => array(
295 'title' => __( 'Enable Group Forums', 'bbpress' ),
296 'callback' => 'bbp_admin_setting_callback_group_forums',
297 'sanitize_callback' => 'intval',
298 'args' => array()
299 ),
300
301 // Group forums parent forum ID
302 '_bbp_group_forums_root_id' => array(
303 'title' => __( 'Group Forums Parent', 'bbpress' ),
304 'callback' => 'bbp_admin_setting_callback_group_forums_root_id',
305 'sanitize_callback' => 'intval',
306 'args' => array()
307 )
308 ),
309
310 /** Akismet ***********************************************************/
311
312 'bbp_settings_akismet' => array(
313
314 // Should we use Akismet
315 '_bbp_enable_akismet' => array(
316 'title' => __( 'Use Akismet', 'bbpress' ),
317 'callback' => 'bbp_admin_setting_callback_akismet',
318 'sanitize_callback' => 'intval',
319 'args' => array()
320 )
321 )
322 ) );
323 }
324
325 /**
326 * Get settings fields by section.
327 *
328 * @since bbPress (r4001)
329 * @param string $section_id
330 * @return mixed False if section is invalid, array of fields otherwise.
331 */
332 function bbp_admin_get_settings_fields_for_section( $section_id = '' ) {
333
334 // Bail if section is empty
335 if ( empty( $section_id ) )
336 return false;
337
338 $fields = bbp_admin_get_settings_fields();
339 $retval = isset( $fields[$section_id] ) ? $fields[$section_id] : false;
340
341 return apply_filters( 'bbp_admin_get_settings_fields_for_section', $retval, $section_id );
342 }
343
344 /** Main Section **************************************************************/
345
346 /**
347 * Main settings section description for the settings page
348 *
349 * @since bbPress (r2786)
350 */
351 function bbp_admin_setting_callback_main_section() {
352 ?>
353
354 <p><?php _e( 'Main forum settings for enabling features and setting time limits', 'bbpress' ); ?></p>
355
356 <?php
357 }
358
359 /**
360 * Edit lock setting field
361 *
362 * @since bbPress (r2737)
363 *
364 * @uses bbp_form_option() To output the option value
365 */
366 function bbp_admin_setting_callback_editlock() {
367 ?>
368
369 <input name="_bbp_edit_lock" type="number" min="0" step="1" id="_bbp_edit_lock" value="<?php bbp_form_option( '_bbp_edit_lock', '5' ); ?>" class="small-text" />
370 <label for="_bbp_edit_lock"><?php _e( 'minutes', 'bbpress' ); ?></label>
371
372 <?php
373 }
374
375 /**
376 * Throttle setting field
377 *
378 * @since bbPress (r2737)
379 *
380 * @uses bbp_form_option() To output the option value
381 */
382 function bbp_admin_setting_callback_throttle() {
383 ?>
384
385 <input name="_bbp_throttle_time" type="number" min="0" step="1" id="_bbp_throttle_time" value="<?php bbp_form_option( '_bbp_throttle_time', '10' ); ?>" class="small-text" />
386 <label for="_bbp_throttle_time"><?php _e( 'seconds', 'bbpress' ); ?></label>
387
388 <?php
389 }
390
391 /**
392 * Allow favorites setting field
393 *
394 * @since bbPress (r2786)
395 *
396 * @uses checked() To display the checked attribute
397 */
398 function bbp_admin_setting_callback_favorites() {
399 ?>
400
401 <input id="_bbp_enable_favorites" name="_bbp_enable_favorites" type="checkbox" id="_bbp_enable_favorites" value="1" <?php checked( bbp_is_favorites_active( true ) ); ?> />
402 <label for="_bbp_enable_favorites"><?php _e( 'Allow users to mark topics as favorites', 'bbpress' ); ?></label>
403
404 <?php
405 }
406
407 /**
408 * Allow subscriptions setting field
409 *
410 * @since bbPress (r2737)
411 *
412 * @uses checked() To display the checked attribute
413 */
414 function bbp_admin_setting_callback_subscriptions() {
415 ?>
416
417 <input id="_bbp_enable_subscriptions" name="_bbp_enable_subscriptions" type="checkbox" id="_bbp_enable_subscriptions" value="1" <?php checked( bbp_is_subscriptions_active( true ) ); ?> />
418 <label for="_bbp_enable_subscriptions"><?php _e( 'Allow users to subscribe to topics', 'bbpress' ); ?></label>
419
420 <?php
421 }
422
423 /**
424 * Allow topic and reply revisions
425 *
426 * @since bbPress (r3412)
427 *
428 * @uses checked() To display the checked attribute
429 */
430 function bbp_admin_setting_callback_revisions() {
431 ?>
432
433 <input id="_bbp_allow_revisions" name="_bbp_allow_revisions" type="checkbox" id="_bbp_allow_revisions" value="1" <?php checked( bbp_allow_revisions( true ) ); ?> />
434 <label for="_bbp_allow_revisions"><?php _e( 'Allow topic and reply revision logging', 'bbpress' ); ?></label>
435
436 <?php
437 }
438
439 /**
440 * Allow anonymous posting setting field
441 *
442 * @since bbPress (r2737)
443 *
444 * @uses checked() To display the checked attribute
445 */
446 function bbp_admin_setting_callback_anonymous() {
447 ?>
448
449 <input id="_bbp_allow_anonymous" name="_bbp_allow_anonymous" type="checkbox" id="_bbp_allow_anonymous" value="1" <?php checked( bbp_allow_anonymous( false ) ); ?> />
450 <label for="_bbp_allow_anonymous"><?php _e( 'Allow guest users without accounts to create topics and replies', 'bbpress' ); ?></label>
451
452 <?php
453 }
454
455 /**
456 * Allow global access setting field
457 *
458 * @since bbPress (r3378)
459 *
460 * @uses checked() To display the checked attribute
461 */
462 function bbp_admin_setting_callback_global_access() {
463 ?>
464
465 <input id="_bbp_allow_global_access" name="_bbp_allow_global_access" type="checkbox" id="_bbp_allow_global_access" value="1" <?php checked( bbp_allow_global_access( false ) ); ?> />
466 <label for="_bbp_allow_global_access"><?php _e( 'Allow all users of your multisite installation to create topics and replies', 'bbpress' ); ?></label>
467
468 <?php
469 }
470
471 /**
472 * Use the WordPress editor setting field
473 *
474 * @since bbPress (r3586)
475 *
476 * @uses checked() To display the checked attribute
477 */
478 function bbp_admin_setting_callback_use_wp_editor() {
479 ?>
480
481 <input id="_bbp_use_wp_editor" name="_bbp_use_wp_editor" type="checkbox" id="_bbp_use_wp_editor" value="1" <?php checked( bbp_use_wp_editor( true ) ); ?> />
482 <label for="_bbp_use_wp_editor"><?php _e( 'Use the fancy WordPress editor to create and edit topics and replies', 'bbpress' ); ?></label>
483
484 <?php
485 }
486
487 /**
488 * Main subtheme section
489 *
490 * @since bbPress (r2786)
491 */
492 function bbp_admin_setting_callback_subtheme_section() {
493 ?>
494
495 <p><?php _e( 'How your forum content is displayed within your existing theme.', 'bbpress' ); ?></p>
496
497 <?php
498 }
499
500 /**
501 * Use the WordPress editor setting field
502 *
503 * @since bbPress (r3586)
504 *
505 * @uses checked() To display the checked attribute
506 */
507 function bbp_admin_setting_callback_subtheme_id() {
508
509 // Declare locale variable
510 $theme_options = '';
511 $current_package = bbp_get_theme_package_id( 'default' );
512
513 // Note: This should never be empty. /bbp-includes/bbp-theme-compat/ is the
514 // canonical backup if no other packages exist. If there's an error here,
515 // something else is wrong.
516 //
517 // @see bbPress::register_theme_packages()
518 foreach ( (array) bbpress()->theme_compat->packages as $id => $theme ) {
519 $theme_options .= '<option value="' . esc_attr( $id ) . '"' . selected( $theme->id, $current_package, false ) . '>' . sprintf( __( '%1$s - %2$s', 'bbpress' ), esc_html( $theme->name ), esc_html( str_replace( WP_CONTENT_DIR, '', $theme->dir ) ) ) . '</option>';
520 }
521
522 if ( !empty( $theme_options ) ) : ?>
523
524 <select name="_bbp_theme_package_id" id="_bbp_theme_package_id" /><?php echo $theme_options ?></select>
525 <label for="_bbp_theme_package_id"><?php _e( 'will serve all bbPress templates', 'bbpress' ); ?></label>
526
527 <?php else : ?>
528
529 <select name="_bbp_theme_package_id" id="_bbp_theme_package_id" /><?php echo $theme_options ?></select>
530 <label for="_bbp_theme_package_id"><?php _e( 'Use the fancy WordPress editor to create and edit topics and replies', 'bbpress' ); ?></label>
531
532 <?php endif;
533 }
534
535 /**
536 * Allow oEmbed in replies
537 *
538 * @since bbPress (r3752)
539 *
540 * @uses checked() To display the checked attribute
541 */
542 function bbp_admin_setting_callback_use_autoembed() {
543 ?>
544
545 <input id="_bbp_use_autoembed" name="_bbp_use_autoembed" type="checkbox" id="_bbp_use_autoembed" value="1" <?php checked( bbp_use_autoembed( true ) ); ?> />
546 <label for="_bbp_use_autoembed"><?php _e( 'Embed media (YouTube, Twitter, Flickr, etc...) directly into topics and replies.', 'bbpress' ); ?></label>
547
548 <?php
549 }
550
551 /** Per Page Section **********************************************************/
552
553 /**
554 * Per page settings section description for the settings page
555 *
556 * @since bbPress (r2786)
557 */
558 function bbp_admin_setting_callback_per_page_section() {
559 ?>
560
561 <p><?php _e( 'How many topics and replies to show per page', 'bbpress' ); ?></p>
562
563 <?php
564 }
565
566 /**
567 * Topics per page setting field
568 *
569 * @since bbPress (r2786)
570 *
571 * @uses bbp_form_option() To output the option value
572 */
573 function bbp_admin_setting_callback_topics_per_page() {
574 ?>
575
576 <input name="_bbp_topics_per_page" type="number" min="1" step="1" id="_bbp_topics_per_page" value="<?php bbp_form_option( '_bbp_topics_per_page', '15' ); ?>" class="small-text" />
577 <label for="_bbp_topics_per_page"><?php _e( 'per page', 'bbpress' ); ?></label>
578
579 <?php
580 }
581
582 /**
583 * Replies per page setting field
584 *
585 * @since bbPress (r2786)
586 *
587 * @uses bbp_form_option() To output the option value
588 */
589 function bbp_admin_setting_callback_replies_per_page() {
590 ?>
591
592 <input name="_bbp_replies_per_page" type="number" min="1" step="1" id="_bbp_replies_per_page" value="<?php bbp_form_option( '_bbp_replies_per_page', '15' ); ?>" class="small-text" />
593 <label for="_bbp_replies_per_page"><?php _e( 'per page', 'bbpress' ); ?></label>
594
595 <?php
596 }
597
598 /** Per RSS Page Section ******************************************************/
599
600 /**
601 * Per page settings section description for the settings page
602 *
603 * @since bbPress (r2786)
604 */
605 function bbp_admin_setting_callback_per_rss_page_section() {
606 ?>
607
608 <p><?php _e( 'How many topics and replies to show per RSS page', 'bbpress' ); ?></p>
609
610 <?php
611 }
612
613 /**
614 * Topics per RSS page setting field
615 *
616 * @since bbPress (r2786)
617 *
618 * @uses bbp_form_option() To output the option value
619 */
620 function bbp_admin_setting_callback_topics_per_rss_page() {
621 ?>
622
623 <input name="_bbp_topics_per_rss_page" type="number" min="1" step="1" id="_bbp_topics_per_rss_page" value="<?php bbp_form_option( '_bbp_topics_per_rss_page', '25' ); ?>" class="small-text" />
624 <label for="_bbp_topics_per_rss_page"><?php _e( 'per page', 'bbpress' ); ?></label>
625
626 <?php
627 }
628
629 /**
630 * Replies per RSS page setting field
631 *
632 * @since bbPress (r2786)
633 *
634 * @uses bbp_form_option() To output the option value
635 */
636 function bbp_admin_setting_callback_replies_per_rss_page() {
637 ?>
638
639 <input name="_bbp_replies_per_rss_page" type="number" min="1" step="1" id="_bbp_replies_per_rss_page" value="<?php bbp_form_option( '_bbp_replies_per_rss_page', '25' ); ?>" class="small-text" />
640 <label for="_bbp_replies_per_rss_page"><?php _e( 'per page', 'bbpress' ); ?></label>
641
642 <?php
643 }
644
645 /** Slug Section **************************************************************/
646
647 /**
648 * Slugs settings section description for the settings page
649 *
650 * @since bbPress (r2786)
651 */
652 function bbp_admin_setting_callback_root_slug_section() {
653
654 // Flush rewrite rules when this section is saved
655 if ( isset( $_GET['settings-updated'] ) && isset( $_GET['page'] ) )
656 flush_rewrite_rules(); ?>
657
658 <p><?php printf( __( 'Custom root slugs to prefix your forums and topics with. These can be partnered with WordPress pages to allow more flexibility.', 'bbpress' ), get_admin_url( null, 'options-permalink.php' ) ); ?></p>
659
660 <?php
661 }
662
663 /**
664 * Root slug setting field
665 *
666 * @since bbPress (r2786)
667 *
668 * @uses bbp_form_option() To output the option value
669 */
670 function bbp_admin_setting_callback_root_slug() {
671 ?>
672
673 <input name="_bbp_root_slug" type="text" id="_bbp_root_slug" class="regular-text code" value="<?php bbp_form_option( '_bbp_root_slug', 'forums', true ); ?>" />
674
675 <?php
676 // Slug Check
677 bbp_form_slug_conflict_check( '_bbp_root_slug', 'forums' );
678 }
679
680 /**
681 * Topic archive slug setting field
682 *
683 * @since bbPress (r2786)
684 *
685 * @uses bbp_form_option() To output the option value
686 */
687 function bbp_admin_setting_callback_topic_archive_slug() {
688 ?>
689
690 <input name="_bbp_topic_archive_slug" type="text" id="_bbp_topic_archive_slug" class="regular-text code" value="<?php bbp_form_option( '_bbp_topic_archive_slug', 'topics', true ); ?>" />
691
692 <?php
693 // Slug Check
694 bbp_form_slug_conflict_check( '_bbp_topic_archive_slug', 'topics' );
695 }
696
697 /** Single Slugs **************************************************************/
698
699 /**
700 * Slugs settings section description for the settings page
701 *
702 * @since bbPress (r2786)
703 */
704 function bbp_admin_setting_callback_single_slug_section() {
705 ?>
706
707 <p><?php printf( __( 'Custom slugs for single forums, topics, replies, tags, users, and views here. If you change these, existing permalinks will also change.', 'bbpress' ), get_admin_url( null, 'options-permalink.php' ) ); ?></p>
708
709 <?php
710 }
711
712 /**
713 * Include root slug setting field
714 *
715 * @since bbPress (r2786)
716 *
717 * @uses checked() To display the checked attribute
718 */
719 function bbp_admin_setting_callback_include_root() {
720 ?>
721
722 <input id="_bbp_include_root" name="_bbp_include_root" type="checkbox" id="_bbp_include_root" value="1" <?php checked( get_option( '_bbp_include_root', true ) ); ?> />
723 <label for="_bbp_include_root"><?php _e( 'Prefix your forum area with the Forum Base slug (Recommended)', 'bbpress' ); ?></label>
724
725 <?php
726 }
727
728 /**
729 * Forum slug setting field
730 *
731 * @since bbPress (r2786)
732 *
733 * @uses bbp_form_option() To output the option value
734 */
735 function bbp_admin_setting_callback_forum_slug() {
736 ?>
737
738 <input name="_bbp_forum_slug" type="text" id="_bbp_forum_slug" class="regular-text code" value="<?php bbp_form_option( '_bbp_forum_slug', 'forum', true ); ?>" />
739
740 <?php
741 // Slug Check
742 bbp_form_slug_conflict_check( '_bbp_forum_slug', 'forum' );
743 }
744
745 /**
746 * Topic slug setting field
747 *
748 * @since bbPress (r2786)
749 *
750 * @uses bbp_form_option() To output the option value
751 */
752 function bbp_admin_setting_callback_topic_slug() {
753 ?>
754
755 <input name="_bbp_topic_slug" type="text" id="_bbp_topic_slug" class="regular-text code" value="<?php bbp_form_option( '_bbp_topic_slug', 'topic', true ); ?>" />
756
757 <?php
758 // Slug Check
759 bbp_form_slug_conflict_check( '_bbp_topic_slug', 'topic' );
760 }
761
762 /**
763 * Reply slug setting field
764 *
765 * @since bbPress (r2786)
766 *
767 * @uses bbp_form_option() To output the option value
768 */
769 function bbp_admin_setting_callback_reply_slug() {
770 ?>
771
772 <input name="_bbp_reply_slug" type="text" id="_bbp_reply_slug" class="regular-text code" value="<?php bbp_form_option( '_bbp_reply_slug', 'reply', true ); ?>" />
773
774 <?php
775 // Slug Check
776 bbp_form_slug_conflict_check( '_bbp_reply_slug', 'reply' );
777 }
778
779 /**
780 * Topic tag slug setting field
781 *
782 * @since bbPress (r2786)
783 *
784 * @uses bbp_form_option() To output the option value
785 */
786 function bbp_admin_setting_callback_topic_tag_slug() {
787 ?>
788
789 <input name="_bbp_topic_tag_slug" type="text" id="_bbp_topic_tag_slug" class="regular-text code" value="<?php bbp_form_option( '_bbp_topic_tag_slug', 'topic-tag', true ); ?>" />
790
791 <?php
792
793 // Slug Check
794 bbp_form_slug_conflict_check( '_bbp_topic_tag_slug', 'topic-tag' );
795 }
796
797 /** Other Slugs ***************************************************************/
798
799 /**
800 * User slug setting field
801 *
802 * @since bbPress (r2786)
803 *
804 * @uses bbp_form_option() To output the option value
805 */
806 function bbp_admin_setting_callback_user_slug() {
807 ?>
808
809 <input name="_bbp_user_slug" type="text" id="_bbp_user_slug" class="regular-text code" value="<?php bbp_form_option( '_bbp_user_slug', 'users', true ); ?>" />
810
811 <?php
812 // Slug Check
813 bbp_form_slug_conflict_check( '_bbp_user_slug', 'users' );
814 }
815
816 /**
817 * View slug setting field
818 *
819 * @since bbPress (r2789)
820 *
821 * @uses bbp_form_option() To output the option value
822 */
823 function bbp_admin_setting_callback_view_slug() {
824 ?>
825
826 <input name="_bbp_view_slug" type="text" id="_bbp_view_slug" class="regular-text code" value="<?php bbp_form_option( '_bbp_view_slug', 'view', true ); ?>" />
827
828 <?php
829 // Slug Check
830 bbp_form_slug_conflict_check( '_bbp_view_slug', 'view' );
831 }
832
833 /** BuddyPress ****************************************************************/
834
835 /**
836 * Extension settings section description for the settings page
837 *
838 * @since bbPress (r3575)
839 */
840 function bbp_admin_setting_callback_buddypress_section() {
841 ?>
842
843 <p><?php _e( 'Forum settings for BuddyPress', 'bbpress' ); ?></p>
844
845 <?php
846 }
847
848 /**
849 * Allow BuddyPress group forums setting field
850 *
851 * @since bbPress (r3575)
852 *
853 * @uses checked() To display the checked attribute
854 */
855 function bbp_admin_setting_callback_group_forums() {
856 ?>
857
858 <input id="_bbp_enable_group_forums" name="_bbp_enable_group_forums" type="checkbox" id="_bbp_enable_group_forums" value="1" <?php checked( bbp_is_group_forums_active( true ) ); ?> />
859 <label for="_bbp_enable_group_forums"><?php _e( 'Allow BuddyPress Groups to have their own forums', 'bbpress' ); ?></label>
860
861 <?php
862 }
863
864 /**
865 * Replies per page setting field
866 *
867 * @since bbPress (r3575)
868 *
869 * @uses bbp_form_option() To output the option value
870 */
871 function bbp_admin_setting_callback_group_forums_root_id() {
872 ?>
873
874 <?php
875 bbp_dropdown( array(
876 'selected' => bbp_get_group_forums_root_id(),
877 'show_none' => __( '(Forum Root)', 'bbpress' ),
878 'select_id' => '_bbp_group_forums_root_id',
879 'disable_categories' => false
880 ) );
881 ?>
882
883 <label for="_bbp_group_forums_root_id"><?php _e( 'is the parent for all group forums', 'bbpress' ); ?></label>
884 <p class="description"><?php _e( 'Using the Forum Root is not recommended. Changing this does not move existing forums.', 'bbpress' ); ?></p>
885
886 <?php
887 }
888
889 /** Akismet *******************************************************************/
890
891 /**
892 * Extension settings section description for the settings page
893 *
894 * @since bbPress (r3575)
895 */
896 function bbp_admin_setting_callback_akismet_section() {
897 ?>
898
899 <p><?php _e( 'Forum settings for Akismet', 'bbpress' ); ?></p>
900
901 <?php
902 }
903
904
905 /**
906 * Allow Akismet setting field
907 *
908 * @since bbPress (r3575)
909 *
910 * @uses checked() To display the checked attribute
911 */
912 function bbp_admin_setting_callback_akismet() {
913 ?>
914
915 <input id="_bbp_enable_akismet" name="_bbp_enable_akismet" type="checkbox" id="_bbp_enable_akismet" value="1" <?php checked( bbp_is_akismet_active( true ) ); ?> />
916 <label for="_bbp_enable_akismet"><?php _e( 'Allow Akismet to actively prevent forum spam.', 'bbpress' ); ?></label>
917
918 <?php
919 }
920
921 /** Settings Page *************************************************************/
922
923 /**
924 * The main settings page
925 *
926 * @since bbPress (r2643)
927 *
928 * @uses screen_icon() To display the screen icon
929 * @uses settings_fields() To output the hidden fields for the form
930 * @uses do_settings_sections() To output the settings sections
931 */
932 function bbp_admin_settings() {
933 ?>
934
935 <div class="wrap">
936
937 <?php screen_icon(); ?>
938
939 <h2><?php _e( 'bbPress Settings', 'bbpress' ) ?></h2>
940
941 <form action="options.php" method="post">
942
943 <?php settings_fields( 'bbpress' ); ?>
944
945 <?php do_settings_sections( 'bbpress' ); ?>
946
947 <p class="submit">
948 <input type="submit" name="submit" class="button-primary" value="<?php _e( 'Save Changes', 'bbpress' ); ?>" />
949 </p>
950 </form>
951 </div>
952
953 <?php
954 }
955
956
957 /** Converter Section *********************************************************/
958
959 /**
960 * Main settings section description for the settings page
961 *
962 * @since bbPress (r3813)
963 */
964 function bbp_converter_setting_callback_main_section() {
965 ?>
966
967 <p><?php _e( 'Information about your previous forums database so that they can be converted. <strong>Backup your database before proceeding.</strong>', 'bbpress' ); ?></p>
968
969 <?php
970 }
971
972 /**
973 * Edit Platform setting field
974 *
975 * @since bbPress (r3813)
976 */
977 function bbp_converter_setting_callback_platform() {
978
979 $platform_options = array();
980
981 if ( $curdir = opendir( bbpress()->admin->admin_dir . 'converters/' ) ) {
982 while ( $file = readdir( $curdir ) ) {
983 if ( ( stristr( $file, '.php' ) ) && ( stristr( $file, 'index' ) === false ) ) {
984 $file = preg_replace( '/.php/', '', $file );
985 $platform_options .= '<option value="' . $file . '">' . $file . '</option>';
986 }
987 }
988 closedir( $curdir );
989 } ?>
990
991 <select name="_bbp_converter_platform" id="_bbp_converter_platform" /><?php echo $platform_options ?></select>
992 <label for="_bbp_converter_platform"><?php _e( 'is the previous forum software', 'bbpress' ); ?></label>
993
994 <?php
995 }
996
997 /**
998 * Edit Database Server setting field
999 *
1000 * @since bbPress (r3813)
1001 */
1002 function bbp_converter_setting_callback_dbserver() {
1003 ?>
1004
1005 <input name="_bbp_converter_db_server" type="text" id="_bbp_converter_db_server" value="<?php bbp_form_option( '_bbp_converter_db_server', 'localhost' ); ?>" class="medium-text" />
1006 <label for="_bbp_converter_db_server"><?php _e( 'IP or hostname', 'bbpress' ); ?></label>
1007
1008 <?php
1009 }
1010
1011 /**
1012 * Edit Database Server Port setting field
1013 *
1014 * @since bbPress (r3813)
1015 */
1016 function bbp_converter_setting_callback_dbport() {
1017 ?>
1018
1019 <input name="_bbp_converter_db_port" type="text" id="_bbp_converter_db_port" value="<?php bbp_form_option( '_bbp_converter_db_port', '3306' ); ?>" class="small-text" />
1020 <label for="_bbp_converter_db_port"><?php _e( 'Use default 3306 if unsure', 'bbpress' ); ?></label>
1021
1022 <?php
1023 }
1024
1025 /**
1026 * Edit Database User setting field
1027 *
1028 * @since bbPress (r3813)
1029 */
1030 function bbp_converter_setting_callback_dbuser() {
1031 ?>
1032
1033 <input name="_bbp_converter_db_user" type="text" id="_bbp_converter_db_user" value="<?php bbp_form_option( '_bbp_converter_db_user' ); ?>" class="medium-text" />
1034 <label for="_bbp_converter_db_user"><?php _e( 'User for your database connection', 'bbpress' ); ?></label>
1035
1036 <?php
1037 }
1038
1039 /**
1040 * Edit Database Pass setting field
1041 *
1042 * @since bbPress (r3813)
1043 */
1044 function bbp_converter_setting_callback_dbpass() {
1045 ?>
1046
1047 <input name="_bbp_converter_db_pass" type="password" id="_bbp_converter_db_pass" value="<?php bbp_form_option( '_bbp_converter_db_pass' ); ?>" class="medium-text" />
1048 <label for="_bbp_converter_db_pass"><?php _e( 'Password to access the database', 'bbpress' ); ?></label>
1049
1050 <?php
1051 }
1052
1053 /**
1054 * Edit Database Name setting field
1055 *
1056 * @since bbPress (r3813)
1057 */
1058 function bbp_converter_setting_callback_dbname() {
1059 ?>
1060
1061 <input name="_bbp_converter_db_name" type="text" id="_bbp_converter_db_name" value="<?php bbp_form_option( '_bbp_converter_db_name' ); ?>" class="medium-text" />
1062 <label for="_bbp_converter_db_name"><?php _e( 'Name of the database with your old forum data', 'bbpress' ); ?></label>
1063
1064 <?php
1065 }
1066
1067 /**
1068 * Main settings section description for the settings page
1069 *
1070 * @since bbPress (r3813)
1071 */
1072 function bbp_converter_setting_callback_options_section() {
1073 ?>
1074
1075 <p><?php _e( 'Some optional parameters to help tune the conversion process.', 'bbpress' ); ?></p>
1076
1077 <?php
1078 }
1079
1080 /**
1081 * Edit Table Prefix setting field
1082 *
1083 * @since bbPress (r3813)
1084 */
1085 function bbp_converter_setting_callback_dbprefix() {
1086 ?>
1087
1088 <input name="_bbp_converter_db_prefix" type="text" id="_bbp_converter_db_prefix" value="<?php bbp_form_option( '_bbp_converter_db_prefix' ); ?>" class="medium-text" />
1089 <label for="_bbp_converter_db_prefix"><?php _e( '(If converting from BuddyPress Forums, use "wp_bb_" or your custom prefix)', 'bbpress' ); ?></label>
1090
1091 <?php
1092 }
1093
1094 /**
1095 * Edit Rows Limit setting field
1096 *
1097 * @since bbPress (r3813)
1098 */
1099 function bbp_converter_setting_callback_rows() {
1100 ?>
1101
1102 <input name="_bbp_converter_rows" type="text" id="_bbp_converter_rows" value="<?php bbp_form_option( '_bbp_converter_rows', '100' ); ?>" class="small-text" />
1103 <label for="_bbp_converter_rows"><?php _e( 'rows to process at a time', 'bbpress' ); ?></label>
1104 <p class="description"><?php _e( 'Keep this low if you experience out-of-memory issues.', 'bbpress' ); ?></p>
1105
1106 <?php
1107 }
1108
1109 /**
1110 * Edit Delay Time setting field
1111 *
1112 * @since bbPress (r3813)
1113 */
1114 function bbp_converter_setting_callback_delay_time() {
1115 ?>
1116
1117 <input name="_bbp_converter_delay_time" type="text" id="_bbp_converter_delay_time" value="<?php bbp_form_option( '_bbp_converter_delay_time', '1' ); ?>" class="small-text" />
1118 <label for="_bbp_converter_delay_time"><?php _e( 'second(s) delay between each group of rows', 'bbpress' ); ?></label>
1119 <p class="description"><?php _e( 'Keep this high to prevent too-many-connection issues.', 'bbpress' ); ?></p>
1120
1121 <?php
1122 }
1123
1124 /**
1125 * Edit Restart setting field
1126 *
1127 * @since bbPress (r3813)
1128 */
1129 function bbp_converter_setting_callback_restart() {
1130 ?>
1131
1132 <input id="_bbp_converter_restart" name="_bbp_converter_restart" type="checkbox" id="_bbp_converter_restart" value="1" <?php checked( get_option( '_bbp_converter_restart', false ) ); ?> />
1133 <label for="_bbp_converter_restart"><?php _e( 'Start a fresh conversion from the beginning', 'bbpress' ); ?></label>
1134 <p class="description"><?php _e( 'You should clean old conversion information before starting over.', 'bbpress' ); ?></p>
1135
1136 <?php
1137 }
1138
1139 /**
1140 * Edit Clean setting field
1141 *
1142 * @since bbPress (r3813)
1143 */
1144 function bbp_converter_setting_callback_clean() {
1145 ?>
1146
1147 <input id="_bbp_converter_clean" name="_bbp_converter_clean" type="checkbox" id="_bbp_converter_clean" value="1" <?php checked( get_option( '_bbp_converter_clean', false ) ); ?> />
1148 <label for="_bbp_converter_clean"><?php _e( 'Purge all information from a previously attempted import', 'bbpress' ); ?></label>
1149 <p class="description"><?php _e( 'Use this if an import failed and you want to remove that incomplete data.', 'bbpress' ); ?></p>
1150
1151 <?php
1152 }
1153
1154 /**
1155 * Edit Convert Users setting field
1156 *
1157 * @since bbPress (r3813)
1158 */
1159 function bbp_converter_setting_callback_convert_users() {
1160 ?>
1161
1162 <input id="_bbp_converter_convert_users" name="_bbp_converter_convert_users" type="checkbox" id="_bbp_converter_convert_users" value="1" <?php checked( get_option( '_bbp_converter_convert_users', false ) ); ?> />
1163 <label for="_bbp_converter_convert_users"><?php _e( 'Attempt to import user accounts from previous forums', 'bbpress' ); ?></label>
1164 <p class="description"><?php _e( 'Non-bbPress passwords cannot be automatically converted. They will be converted as each user logs in.', 'bbpress' ); ?></p>
1165
1166 <?php
1167 }
1168
1169 /** Converter Page ************************************************************/
1170
1171 /**
1172 * The main settings page
1173 *
1174 * @uses screen_icon() To display the screen icon
1175 * @uses settings_fields() To output the hidden fields for the form
1176 * @uses do_settings_sections() To output the settings sections
1177 */
1178 function bbp_converter_settings() {
1179 ?>
1180
1181 <div class="wrap">
1182
1183 <?php screen_icon( 'tools' ); ?>
1184
1185 <h2 class="nav-tab-wrapper"><?php bbp_tools_admin_tabs( __( 'Import Forums', 'bbpress' ) ); ?></h2>
1186
1187 <form action="#" method="post" id="bbp-converter-settings">
1188
1189 <?php settings_fields( 'bbpress_converter' ); ?>
1190
1191 <?php do_settings_sections( 'bbpress_converter' ); ?>
1192
1193 <p class="submit">
1194 <input type="button" name="submit" class="button-primary" id="bbp-converter-start" value="<?php _e( 'Start', 'bbpress' ); ?>" onclick="bbconverter_start()" />
1195 <input type="button" name="submit" class="button-primary" id="bbp-converter-stop" value="<?php _e( 'Stop', 'bbpress' ); ?>" onclick="bbconverter_stop()" />
1196 <img id="bbp-converter-progress" src="">
1197 </p>
1198
1199 <div class="bbp-converter-updated" id="bbp-converter-message"></div>
1200 </form>
1201 </div>
1202
1203 <?php
1204 }
1205
1206 /** Helpers *******************************************************************/
1207
1208 /**
1209 * Contextual help for bbPress settings page
1210 *
1211 * @since bbPress (r3119)
1212 * @uses get_current_screen()
1213 */
1214 function bbp_admin_settings_help() {
1215
1216 $current_screen = get_current_screen();
1217
1218 // Bail if current screen could not be found
1219 if ( empty( $current_screen ) )
1220 return;
1221
1222 // Overview
1223 $current_screen->add_help_tab( array(
1224 'id' => 'overview',
1225 'title' => __( 'Overview', 'bbpress' ),
1226 'content' => '<p>' . __( 'This screen provides access to all of the bbPress settings.', 'bbpress' ) . '</p>' .
1227 '<p>' . __( 'Please see the additional help tabs for more information on each indiviual section.', 'bbpress' ) . '</p>'
1228 ) );
1229
1230 // Main Settings
1231 $current_screen->add_help_tab( array(
1232 'id' => 'main_settings',
1233 'title' => __( 'Main Settings', 'bbpress' ),
1234 'content' => '<p>' . __( 'In the Main Settings you have a number of options:', 'bbpress' ) . '</p>' .
1235 '<p>' .
1236 '<ul>' .
1237 '<li>' . __( '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>' .
1238 '<li>' . __( '"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>' .
1239 '<li>' . __( 'Favorites are a way for users to save and later return to topics they favor. This is enabled by default.', 'bbpress' ) . '</li>' .
1240 '<li>' . __( 'Subscriptions allow users to subscribe for notifications to topics that interest them. This is enabled by default.', 'bbpress' ) . '</li>' .
1241 '<li>' . __( '"Anonymous Posting" allows guest users who do not have accounts on your site to both create topics as well as replies.', 'bbpress' ) . '</li>' .
1242 '<li>' . __( 'The Fancy Editor brings the luxury of the Visual editor and HTML editor from the traditional WordPress dashboard into your theme.', 'bbpress' ) . '</li>' .
1243 '<li>' . __( 'Auto-embed will embed the media content from a URL directly into the replies. For example: links to Flickr and YouTube.', 'bbpress' ) . '</li>' .
1244 '</ul>' .
1245 '</p>' .
1246 '<p>' . __( 'You must click the Save Changes button at the bottom of the screen for new settings to take effect.', 'bbpress' ) . '</p>'
1247 ) );
1248
1249 // Per Page
1250 $current_screen->add_help_tab( array(
1251 'id' => 'per_page',
1252 'title' => __( 'Per Page', 'bbpress' ),
1253 'content' => '<p>' . __( 'Per Page settings allow you to control the number of topics and replies appear on each page.', 'bbpress' ) . '</p>' .
1254 '<p>' . __( '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' ) . '</p>' .
1255 '<p>' . __( 'These are broken up into two separate groups: one for what appears in your theme, another for RSS feeds.', 'bbpress' ) . '</p>'
1256 ) );
1257
1258 // Slugs
1259 $current_screen->add_help_tab( array(
1260 'id' => 'slus',
1261 'title' => __( 'Slugs', 'bbpress' ),
1262 'content' => '<p>' . __( 'The Slugs section allows you to control the permalink structure for your forums.', 'bbpress' ) . '</p>' .
1263 '<p>' . __( '"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' ) . '</p>' .
1264 '<p>' . __( '"Single Slugs" are used as a prefix when viewing an individual forum, topic, reply, user, or view.', 'bbpress' ) . '</p>' .
1265 '<p>' . __( 'In the event of a slug collision with WordPress or BuddyPress, a warning will appear next to the problem slug(s).', 'bbpress' ) . '</p>'
1266 ) );
1267
1268 // Help Sidebar
1269 $current_screen->set_help_sidebar(
1270 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
1271 '<p>' . __( '<a href="http://bbpress.org/documentation/" target="_blank">bbPress Documentation</a>', 'bbpress' ) . '</p>' .
1272 '<p>' . __( '<a href="http://bbpress.org/forums/" target="_blank">bbPress Support Forums</a>', 'bbpress' ) . '</p>'
1273 );
1274 }
1275
1276 /**
1277 * Output settings API option
1278 *
1279 * @since bbPress (r3203)
1280 *
1281 * @uses bbp_get_bbp_form_option()
1282 *
1283 * @param string $option
1284 * @param string $default
1285 * @param bool $slug
1286 */
1287 function bbp_form_option( $option, $default = '' , $slug = false ) {
1288 echo bbp_get_form_option( $option, $default, $slug );
1289 }
1290 /**
1291 * Return settings API option
1292 *
1293 * @since bbPress (r3203)
1294 *
1295 * @uses get_option()
1296 * @uses esc_attr()
1297 * @uses apply_filters()
1298 *
1299 * @param string $option
1300 * @param string $default
1301 * @param bool $slug
1302 */
1303 function bbp_get_form_option( $option, $default = '', $slug = false ) {
1304
1305 // Get the option and sanitize it
1306 $value = get_option( $option, $default );
1307
1308 // Slug?
1309 if ( true === $slug )
1310 $value = esc_attr( apply_filters( 'editable_slug', $value ) );
1311
1312 // Not a slug
1313 else
1314 $value = esc_attr( $value );
1315
1316 // Fallback to default
1317 if ( empty( $value ) )
1318 $value = $default;
1319
1320 // Allow plugins to further filter the output
1321 return apply_filters( 'bbp_get_form_option', $value, $option );
1322 }
1323
1324 /**
1325 * Used to check if a bbPress slug conflicts with an existing known slug.
1326 *
1327 * @since bbPress (r3306)
1328 *
1329 * @param string $slug
1330 * @param string $default
1331 *
1332 * @uses bbp_get_form_option() To get a sanitized slug string
1333 */
1334 function bbp_form_slug_conflict_check( $slug, $default ) {
1335
1336 // Only set the slugs once ver page load
1337 static $the_core_slugs = array();
1338
1339 // Get the form value
1340 $this_slug = bbp_get_form_option( $slug, $default, true );
1341
1342 if ( empty( $the_core_slugs ) ) {
1343
1344 // Slugs to check
1345 $core_slugs = apply_filters( 'bbp_slug_conflict_check', array(
1346
1347 /** WordPress Core ****************************************************/
1348
1349 // Core Post Types
1350 'post_base' => array( 'name' => __( 'Posts', 'bbpress' ), 'default' => 'post', 'context' => 'WordPress' ),
1351 'page_base' => array( 'name' => __( 'Pages', 'bbpress' ), 'default' => 'page', 'context' => 'WordPress' ),
1352 'revision_base' => array( 'name' => __( 'Revisions', 'bbpress' ), 'default' => 'revision', 'context' => 'WordPress' ),
1353 'attachment_base' => array( 'name' => __( 'Attachments', 'bbpress' ), 'default' => 'attachment', 'context' => 'WordPress' ),
1354 'nav_menu_base' => array( 'name' => __( 'Menus', 'bbpress' ), 'default' => 'nav_menu_item', 'context' => 'WordPress' ),
1355
1356 // Post Tags
1357 'tag_base' => array( 'name' => __( 'Tag base', 'bbpress' ), 'default' => 'tag', 'context' => 'WordPress' ),
1358
1359 // Post Categories
1360 'category_base' => array( 'name' => __( 'Category base', 'bbpress' ), 'default' => 'category', 'context' => 'WordPress' ),
1361
1362 /** bbPress Core ******************************************************/
1363
1364 // Forum archive slug
1365 '_bbp_root_slug' => array( 'name' => __( 'Forums base', 'bbpress' ), 'default' => 'forums', 'context' => 'bbPress' ),
1366
1367 // Topic archive slug
1368 '_bbp_topic_archive_slug' => array( 'name' => __( 'Topics base', 'bbpress' ), 'default' => 'topics', 'context' => 'bbPress' ),
1369
1370 // Forum slug
1371 '_bbp_forum_slug' => array( 'name' => __( 'Forum slug', 'bbpress' ), 'default' => 'forum', 'context' => 'bbPress' ),
1372
1373 // Topic slug
1374 '_bbp_topic_slug' => array( 'name' => __( 'Topic slug', 'bbpress' ), 'default' => 'topic', 'context' => 'bbPress' ),
1375
1376 // Reply slug
1377 '_bbp_reply_slug' => array( 'name' => __( 'Reply slug', 'bbpress' ), 'default' => 'reply', 'context' => 'bbPress' ),
1378
1379 // User profile slug
1380 '_bbp_user_slug' => array( 'name' => __( 'User base', 'bbpress' ), 'default' => 'users', 'context' => 'bbPress' ),
1381
1382 // View slug
1383 '_bbp_view_slug' => array( 'name' => __( 'View base', 'bbpress' ), 'default' => 'view', 'context' => 'bbPress' ),
1384
1385 // Topic tag slug
1386 '_bbp_topic_tag_slug' => array( 'name' => __( 'Topic tag slug', 'bbpress' ), 'default' => 'topic-tag', 'context' => 'bbPress' ),
1387 ) );
1388
1389 /** BuddyPress Core *******************************************************/
1390
1391 if ( defined( 'BP_VERSION' ) ) {
1392 global $bp;
1393
1394 // Loop through root slugs and check for conflict
1395 if ( !empty( $bp->pages ) ) {
1396 foreach ( $bp->pages as $page => $page_data ) {
1397 $page_base = $page . '_base';
1398 $page_title = sprintf( __( '%s page', 'bbpress' ), $page_data->title );
1399 $core_slugs[$page_base] = array( 'name' => $page_title, 'default' => $page_data->slug, 'context' => 'BuddyPress' );
1400 }
1401 }
1402 }
1403
1404 // Set the static
1405 $the_core_slugs = apply_filters( 'bbp_slug_conflict', $core_slugs );
1406 }
1407
1408 // Loop through slugs to check
1409 foreach( $the_core_slugs as $key => $value ) {
1410
1411 // Get the slug
1412 $slug_check = bbp_get_form_option( $key, $value['default'], true );
1413
1414 // Compare
1415 if ( ( $slug != $key ) && ( $slug_check == $this_slug ) ) : ?>
1416
1417 <span class="attention"><?php printf( __( 'Possible %1$s conflict: <strong>%2$s</strong>', 'bbpress' ), $value['context'], $value['name'] ); ?></span>
1418
1419 <?php endif;
1420 }
1421 }
1422