PluginProbe
bbPress / 2.0-rc-2
bbPress v2.0-rc-2
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.0-rc-2, at bbp-admin/bbp-settings.php

607 lines 18.0 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 /** Start 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 settings for the bbPress plugin', '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 anonymous posting setting field
94 *
95 * @since bbPress (r2737)
96 *
97 * @uses checked() To display the checked attribute
98 */
99 function bbp_admin_setting_callback_anonymous() {
100 ?>
101
102 <input id="_bbp_allow_anonymous" name="_bbp_allow_anonymous" type="checkbox" id="_bbp_allow_anonymous" value="1" <?php checked( bbp_allow_anonymous( false ) ); ?> />
103 <label for="_bbp_allow_anonymous"><?php _e( 'Allow guest users without accounts to create topics and replies', 'bbpress' ); ?></label>
104
105 <?php
106 }
107
108 /**
109 * Allow global access setting field
110 *
111 * @since bbPress (r3378)
112 *
113 * @uses checked() To display the checked attribute
114 */
115 function bbp_admin_setting_callback_global_access() {
116 ?>
117
118 <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 ) ); ?> />
119 <label for="_bbp_allow_global_access"><?php _e( 'Allow all users of your multisite installation to create topics and replies', 'bbpress' ); ?></label>
120
121 <?php
122 }
123
124 /** Start Per Page Section ****************************************************/
125
126 /**
127 * Per page settings section description for the settings page
128 *
129 * @since bbPress (r2786)
130 */
131 function bbp_admin_setting_callback_per_page_section() {
132 ?>
133
134 <p><?php _e( 'Per page settings for the bbPress plugin', 'bbpress' ); ?></p>
135
136 <?php
137 }
138
139 /**
140 * Topics per page setting field
141 *
142 * @since bbPress (r2786)
143 *
144 * @uses bbp_form_option() To output the option value
145 */
146 function bbp_admin_setting_callback_topics_per_page() {
147 ?>
148
149 <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" />
150 <label for="_bbp_topics_per_page"><?php _e( 'per page', 'bbpress' ); ?></label>
151
152 <?php
153 }
154
155 /**
156 * Replies per page setting field
157 *
158 * @since bbPress (r2786)
159 *
160 * @uses bbp_form_option() To output the option value
161 */
162 function bbp_admin_setting_callback_replies_per_page() {
163 ?>
164
165 <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" />
166 <label for="_bbp_replies_per_page"><?php _e( 'per page', 'bbpress' ); ?></label>
167
168 <?php
169 }
170
171 /** Start Per RSS Page Section ************************************************/
172
173 /**
174 * Per page settings section description for the settings page
175 *
176 * @since bbPress (r2786)
177 */
178 function bbp_admin_setting_callback_per_rss_page_section() {
179 ?>
180
181 <p><?php _e( 'Per RSS page settings for the bbPress plugin', 'bbpress' ); ?></p>
182
183 <?php
184 }
185
186 /**
187 * Topics per RSS page setting field
188 *
189 * @since bbPress (r2786)
190 *
191 * @uses bbp_form_option() To output the option value
192 */
193 function bbp_admin_setting_callback_topics_per_rss_page() {
194 ?>
195
196 <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" />
197 <label for="_bbp_topics_per_rss_page"><?php _e( 'per page', 'bbpress' ); ?></label>
198
199 <?php
200 }
201
202 /**
203 * Replies per RSS page setting field
204 *
205 * @since bbPress (r2786)
206 *
207 * @uses bbp_form_option() To output the option value
208 */
209 function bbp_admin_setting_callback_replies_per_rss_page() {
210 ?>
211
212 <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" />
213 <label for="_bbp_replies_per_rss_page"><?php _e( 'per page', 'bbpress' ); ?></label>
214
215 <?php
216 }
217
218 /** Start Slug Section ********************************************************/
219
220 /**
221 * Slugs settings section description for the settings page
222 *
223 * @since bbPress (r2786)
224 */
225 function bbp_admin_setting_callback_root_slug_section() {
226
227 // Flush rewrite rules when this section is saved
228 if ( isset( $_GET['settings-updated'] ) && isset( $_GET['page'] ) )
229 flush_rewrite_rules(); ?>
230
231 <p><?php printf( __( 'Include 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>
232
233 <?php
234 }
235
236 /**
237 * Root slug setting field
238 *
239 * @since bbPress (r2786)
240 *
241 * @uses bbp_form_option() To output the option value
242 */
243 function bbp_admin_setting_callback_root_slug() {
244 ?>
245
246 <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 ); ?>" />
247
248 <?php
249 // Slug Check
250 bbp_form_slug_conflict_check( '_bbp_root_slug', 'forums' );
251 }
252
253 /**
254 * Topic archive slug setting field
255 *
256 * @since bbPress (r2786)
257 *
258 * @uses bbp_form_option() To output the option value
259 */
260 function bbp_admin_setting_callback_topic_archive_slug() {
261 ?>
262
263 <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 ); ?>" />
264
265 <?php
266 // Slug Check
267 bbp_form_slug_conflict_check( '_bbp_topic_archive_slug', 'topics' );
268 }
269
270 /** Single Slugs **************************************************************/
271
272 /**
273 * Slugs settings section description for the settings page
274 *
275 * @since bbPress (r2786)
276 */
277 function bbp_admin_setting_callback_single_slug_section() {
278
279 // Flush rewrite rules when this section is saved
280 if ( isset( $_GET['settings-updated'] ) && isset( $_GET['page'] ) )
281 flush_rewrite_rules(); ?>
282
283 <p><?php printf( __( 'You can enter custom slugs for your single forums, topics, replies, and tags URLs here. If you change these, existing permalinks will also change.', 'bbpress' ), get_admin_url( null, 'options-permalink.php' ) ); ?></p>
284
285 <?php
286 }
287
288 /**
289 * Include root slug setting field
290 *
291 * @since bbPress (r2786)
292 *
293 * @uses checked() To display the checked attribute
294 */
295 function bbp_admin_setting_callback_include_root() {
296 ?>
297
298 <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 ) ); ?> />
299 <label for="_bbp_include_root"><?php _e( 'Incude the Forum Base slug in your single forum item links', 'bbpress' ); ?></label>
300
301 <?php
302 }
303
304 /**
305 * Forum slug setting field
306 *
307 * @since bbPress (r2786)
308 *
309 * @uses bbp_form_option() To output the option value
310 */
311 function bbp_admin_setting_callback_forum_slug() {
312 ?>
313
314 <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 ); ?>" />
315
316 <?php
317 // Slug Check
318 bbp_form_slug_conflict_check( '_bbp_forum_slug', 'forum' );
319 }
320
321 /**
322 * Topic slug setting field
323 *
324 * @since bbPress (r2786)
325 *
326 * @uses bbp_form_option() To output the option value
327 */
328 function bbp_admin_setting_callback_topic_slug() {
329 ?>
330
331 <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 ); ?>" />
332
333 <?php
334 // Slug Check
335 bbp_form_slug_conflict_check( '_bbp_topic_slug', 'topic' );
336 }
337
338 /**
339 * Reply slug setting field
340 *
341 * @since bbPress (r2786)
342 *
343 * @uses bbp_form_option() To output the option value
344 */
345 function bbp_admin_setting_callback_reply_slug() {
346 ?>
347
348 <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 ); ?>" />
349
350 <?php
351 // Slug Check
352 bbp_form_slug_conflict_check( '_bbp_reply_slug', 'reply' );
353 }
354
355 /**
356 * Topic tag slug setting field
357 *
358 * @since bbPress (r2786)
359 *
360 * @uses bbp_form_option() To output the option value
361 */
362 function bbp_admin_setting_callback_topic_tag_slug() {
363 ?>
364
365 <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 ); ?>" />
366
367 <?php
368
369 // Slug Check
370 bbp_form_slug_conflict_check( '_bbp_topic_tag_slug', 'topic-tag' );
371 }
372
373 /** Other Slugs ***************************************************************/
374
375 /**
376 * User slug setting field
377 *
378 * @since bbPress (r2786)
379 *
380 * @uses bbp_form_option() To output the option value
381 */
382 function bbp_admin_setting_callback_user_slug() {
383 ?>
384
385 <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 ); ?>" />
386
387 <?php
388 // Slug Check
389 bbp_form_slug_conflict_check( '_bbp_user_slug', 'users' );
390 }
391
392 /**
393 * View slug setting field
394 *
395 * @since bbPress (r2789)
396 *
397 * @uses bbp_form_option() To output the option value
398 */
399 function bbp_admin_setting_callback_view_slug() {
400 ?>
401
402 <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 ); ?>" />
403
404 <?php
405 // Slug Check
406 bbp_form_slug_conflict_check( '_bbp_view_slug', 'view' );
407 }
408
409 /** Settings Page *************************************************************/
410
411 /**
412 * The main settings page
413 *
414 * @since bbPress (r2643)
415 *
416 * @uses screen_icon() To display the screen icon
417 * @uses settings_fields() To output the hidden fields for the form
418 * @uses do_settings_sections() To output the settings sections
419 */
420 function bbp_admin_settings() {
421 ?>
422
423 <div class="wrap">
424
425 <?php screen_icon(); ?>
426
427 <h2><?php _e( 'bbPress Settings', 'bbpress' ) ?></h2>
428
429 <form action="options.php" method="post">
430
431 <?php settings_fields( 'bbpress' ); ?>
432
433 <?php do_settings_sections( 'bbpress' ); ?>
434
435 <p class="submit">
436 <input type="submit" name="submit" class="button-primary" value="<?php _e( 'Save Changes', 'bbpress' ); ?>" />
437 </p>
438 </form>
439 </div>
440
441 <?php
442 }
443
444 /**
445 * Contextual help for bbPress settings page
446 *
447 * @since bbPress (r3119)
448 */
449 function bbp_admin_settings_help() {
450
451 $bbp_contextual_help[] = __('This screen provides access to basic bbPress settings.', 'bbpress' );
452 $bbp_contextual_help[] = __('In the Main Settings you have a number of options:', 'bbpress' );
453 $bbp_contextual_help[] =
454 '<ul>' .
455 '<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>' .
456 '<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>' .
457 '<li>' . __( 'You may choose to allow favorites, which are a way for users to save and later return to topics they favor. This is enabled by default.', 'bbpress' ) . '</li>' .
458 '<li>' . __( 'You may choose to allow subscriptions, which allows users to subscribe for notifications to topics that interest them. This is enabled by default.', 'bbpress' ) . '</li>' .
459 '<li>' . __( 'You may choose to allow "Anonymous Posting", which will allow guest users who do not have accounts on your site to both create topics as well as replies.', 'bbpress' ) . '</li>' .
460 '</ul>';
461
462 $bbp_contextual_help[] = __( 'Per Page settings allow you to control the number of topics and replies will appear on each of those pages. 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' );
463 $bbp_contextual_help[] = __( 'The Forums section allows you to control the permalink structure for your forums. Each "base" is what will be displayed after your main URL and right before your permalink slug.', 'bbpress' );
464 $bbp_contextual_help[] = __( 'You must click the Save Changes button at the bottom of the screen for new settings to take effect.', 'bbpress' );
465 $bbp_contextual_help[] = __( '<strong>For more information:</strong>', 'bbpress' );
466 $bbp_contextual_help[] =
467 '<ul>' .
468 '<li>' . __( '<a href="http://bbpress.org/documentation/">bbPress Documentation</a>', 'bbpress' ) . '</li>' .
469 '<li>' . __( '<a href="http://bbpress.org/forums/">bbPress Support Forums</a>', 'bbpress' ) . '</li>' .
470 '</ul>' ;
471
472 // Empty the default $contextual_help var
473 $contextual_help = '';
474
475 // Wrap each help item in paragraph tags
476 foreach( $bbp_contextual_help as $paragraph )
477 $contextual_help .= '<p>' . $paragraph . '</p>';
478
479 // Add help
480 add_contextual_help( 'settings_page_bbpress', $contextual_help );
481 }
482
483 /**
484 * Output settings API option
485 *
486 * @since bbPress (r3203)
487 *
488 * @uses bbp_get_bbp_form_option()
489 *
490 * @param string $option
491 * @param string $default
492 * @param bool $slug
493 */
494 function bbp_form_option( $option, $default = '' , $slug = false ) {
495 echo bbp_get_form_option( $option, $default, $slug );
496 }
497 /**
498 * Return settings API option
499 *
500 * @since bbPress (r3203)
501 *
502 * @uses get_option()
503 * @uses esc_attr()
504 * @uses apply_filters()
505 *
506 * @param string $option
507 * @param string $default
508 * @param bool $slug
509 */
510 function bbp_get_form_option( $option, $default = '', $slug = false ) {
511
512 // Get the option and sanitize it
513 $value = get_option( $option, $default );
514
515 // Slug?
516 if ( true === $slug )
517 $value = esc_attr( apply_filters( 'editable_slug', $value ) );
518
519 // Not a slug
520 else
521 $value = esc_attr( $value );
522
523 // Fallback to default
524 if ( empty( $value ) )
525 $value = $default;
526
527 // Allow plugins to further filter the output
528 return apply_filters( 'bbp_get_form_option', $value, $option );
529 }
530
531 /**
532 * Used to check if a bbPress slug conflicts with an existing known slug.
533 *
534 * @since bbPress (r3306)
535 *
536 * @param string $slug
537 * @param string $default
538 *
539 * @uses bbp_get_form_option() To get a sanitized slug string
540 */
541 function bbp_form_slug_conflict_check( $slug, $default ) {
542
543 // Get the form value
544 $this_slug = bbp_get_form_option( $slug, $default, true );
545
546 // Slugs to check
547 $core_slugs = apply_filters( 'bbp_slug_conflict_check', array(
548
549 /** WordPress Core ****************************************************/
550
551 // Core Post Types
552 'post_base' => array( 'name' => __( 'Posts' ), 'default' => 'post' ),
553 'page_base' => array( 'name' => __( 'Pages' ), 'default' => 'page' ),
554 'revision_base' => array( 'name' => __( 'Revisions' ), 'default' => 'revision' ),
555 'attachment_base' => array( 'name' => __( 'Attachments' ), 'default' => 'attachment' ),
556 'nav_menu_base' => array( 'name' => __( 'Menus' ), 'default' => 'nav_menu_item' ),
557
558 // Post Tags
559 'tag_base' => array( 'name' => __( 'Tag base' ), 'default' => 'tag' ),
560
561 // Post Categories
562 'category_base' => array( 'name' => __( 'Category base' ), 'default' => 'category' ),
563
564 /** bbPress Core ******************************************************/
565
566 // Forum archive slug
567 '_bbp_root_slug' => array( 'name' => __( 'Forums base', 'bbpress' ), 'default' => 'forums' ),
568
569 // Topic archive slug
570 '_bbp_topic_archive_slug' => array( 'name' => __( 'Topics base', 'bbpress' ), 'default' => 'topics' ),
571
572 // Forum slug
573 '_bbp_forum_slug' => array( 'name' => __( 'Forum slug', 'bbpress' ), 'default' => 'forum' ),
574
575 // Topic slug
576 '_bbp_topic_slug' => array( 'name' => __( 'Topic slug', 'bbpress' ), 'default' => 'topic' ),
577
578 // Reply slug
579 '_bbp_reply_slug' => array( 'name' => __( 'Reply slug', 'bbpress' ), 'default' => 'reply' ),
580
581 // User profile slug
582 '_bbp_user_slug' => array( 'name' => __( 'User base', 'bbpress' ), 'default' => 'users' ),
583
584 // View slug
585 '_bbp_view_slug' => array( 'name' => __( 'View base', 'bbpress' ), 'default' => 'view' ),
586
587 // Topic tag slug
588 '_bbp_topic_tag_slug' => array( 'name' => __( 'Topic tag slug', 'bbpress' ), 'default' => 'topic-tag' ),
589 ) );
590
591 // Loop through slugs to check
592 foreach( $core_slugs as $key => $value ) {
593
594 // Get the slug
595 $slug_check = bbp_get_form_option( $key, $value['default'], true );
596
597 // Compare
598 if ( ( $slug != $key ) && ( $slug_check == $this_slug ) ) : ?>
599
600 <span class="attention"><?php printf( __( 'Possible "%s" conflict', 'bbpress' ), $value['name'] ); ?></span>
601
602 <?php endif;
603 }
604 }
605
606 ?>
607