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

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

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