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

495 lines 14.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 /** 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( true, 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( true, 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( true, 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 /** Start Per Page Section ****************************************************/
109
110 /**
111 * Per page settings section description for the settings page
112 *
113 * @since bbPress (r2786)
114 */
115 function bbp_admin_setting_callback_per_page_section() {
116 ?>
117
118 <p><?php _e( 'Per page settings for the bbPress plugin', 'bbpress' ); ?></p>
119
120 <?php
121 }
122
123 /**
124 * Topics per page setting field
125 *
126 * @since bbPress (r2786)
127 *
128 * @uses bbp_form_option() To output the option value
129 */
130 function bbp_admin_setting_callback_topics_per_page() {
131 ?>
132
133 <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" />
134 <label for="_bbp_topics_per_page"><?php _e( 'per page', 'bbpress' ); ?></label>
135
136 <?php
137 }
138
139 /**
140 * Replies 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_replies_per_page() {
147 ?>
148
149 <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" />
150 <label for="_bbp_replies_per_page"><?php _e( 'per page', 'bbpress' ); ?></label>
151
152 <?php
153 }
154
155 /** Start Per RSS Page Section ************************************************/
156
157 /**
158 * Per page settings section description for the settings page
159 *
160 * @since bbPress (r2786)
161 */
162 function bbp_admin_setting_callback_per_rss_page_section() {
163 ?>
164
165 <p><?php _e( 'Per RSS page settings for the bbPress plugin', 'bbpress' ); ?></p>
166
167 <?php
168 }
169
170 /**
171 * Topics per RSS page setting field
172 *
173 * @since bbPress (r2786)
174 *
175 * @uses bbp_form_option() To output the option value
176 */
177 function bbp_admin_setting_callback_topics_per_rss_page() {
178 ?>
179
180 <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" />
181 <label for="_bbp_topics_per_rss_page"><?php _e( 'per page', 'bbpress' ); ?></label>
182
183 <?php
184 }
185
186 /**
187 * Replies 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_replies_per_rss_page() {
194 ?>
195
196 <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" />
197 <label for="_bbp_replies_per_rss_page"><?php _e( 'per page', 'bbpress' ); ?></label>
198
199 <?php
200 }
201
202 /** Start Slug Section ********************************************************/
203
204 /**
205 * Slugs settings section description for the settings page
206 *
207 * @since bbPress (r2786)
208 */
209 function bbp_admin_setting_callback_root_slug_section() {
210
211 // Flush rewrite rules when this section is saved
212 if ( isset( $_GET['settings-updated'] ) && isset( $_GET['page'] ) )
213 flush_rewrite_rules(); ?>
214
215 <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>
216
217 <?php
218 }
219
220 /**
221 * Root slug setting field
222 *
223 * @since bbPress (r2786)
224 *
225 * @uses bbp_form_option() To output the option value
226 */
227 function bbp_admin_setting_callback_root_slug() {
228 ?>
229
230 <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 ); ?>" />
231
232 <?php
233 }
234
235 /**
236 * Topic archive slug 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_topic_archive_slug() {
243 ?>
244
245 <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 ); ?>" />
246
247 <?php
248 }
249
250 /** Single Slugs **************************************************************/
251
252 /**
253 * Slugs settings section description for the settings page
254 *
255 * @since bbPress (r2786)
256 */
257 function bbp_admin_setting_callback_single_slug_section() {
258
259 // Flush rewrite rules when this section is saved
260 if ( isset( $_GET['settings-updated'] ) && isset( $_GET['page'] ) )
261 flush_rewrite_rules(); ?>
262
263 <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>
264
265 <?php
266 }
267
268 /**
269 * Include root slug setting field
270 *
271 * @since bbPress (r2786)
272 *
273 * @uses checked() To display the checked attribute
274 */
275 function bbp_admin_setting_callback_include_root() {
276 ?>
277
278 <input id="_bbp_include_root" name="_bbp_include_root" type="checkbox" id="_bbp_include_root" value="1" <?php checked( true, get_option( '_bbp_include_root', true ) ); ?> />
279 <label for="_bbp_include_root"><?php _e( 'Incude the Forum Base slug in your single forum item links', 'bbpress' ); ?></label>
280
281 <?php
282 }
283
284 /**
285 * Forum slug setting field
286 *
287 * @since bbPress (r2786)
288 *
289 * @uses bbp_form_option() To output the option value
290 */
291 function bbp_admin_setting_callback_forum_slug() {
292 ?>
293
294 <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 ); ?>" />
295
296 <?php
297 }
298
299 /**
300 * Topic slug setting field
301 *
302 * @since bbPress (r2786)
303 *
304 * @uses bbp_form_option() To output the option value
305 */
306 function bbp_admin_setting_callback_topic_slug() {
307 ?>
308
309 <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 ); ?>" />
310
311 <?php
312 }
313
314 /**
315 * Reply slug setting field
316 *
317 * @since bbPress (r2786)
318 *
319 * @uses bbp_form_option() To output the option value
320 */
321 function bbp_admin_setting_callback_reply_slug() {
322 ?>
323
324 <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 ); ?>" />
325
326 <?php
327 }
328
329 /**
330 * Topic tag slug setting field
331 *
332 * @since bbPress (r2786)
333 *
334 * @uses bbp_form_option() To output the option value
335 */
336 function bbp_admin_setting_callback_topic_tag_slug() {
337 ?>
338
339 <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', 'tag', true ); ?>" />
340
341 <?php
342 }
343
344 /** Other Slugs ***************************************************************/
345
346 /**
347 * User slug setting field
348 *
349 * @since bbPress (r2786)
350 *
351 * @uses bbp_form_option() To output the option value
352 */
353 function bbp_admin_setting_callback_user_slug() {
354 ?>
355
356 <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 ); ?>" />
357
358 <?php
359 }
360
361 /**
362 * View slug setting field
363 *
364 * @since bbPress (r2789)
365 *
366 * @uses bbp_form_option() To output the option value
367 */
368 function bbp_admin_setting_callback_view_slug() {
369 ?>
370
371 <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 ); ?>" />
372
373 <?php
374 }
375
376 /** Settings Page *************************************************************/
377
378 /**
379 * The main settings page
380 *
381 * @since bbPress (r2643)
382 *
383 * @uses screen_icon() To display the screen icon
384 * @uses settings_fields() To output the hidden fields for the form
385 * @uses do_settings_sections() To output the settings sections
386 */
387 function bbp_admin_settings() {
388 ?>
389
390 <div class="wrap">
391
392 <?php screen_icon(); ?>
393
394 <h2><?php _e( 'bbPress Settings', 'bbpress' ) ?></h2>
395
396 <form action="options.php" method="post">
397
398 <?php settings_fields( 'bbpress' ); ?>
399
400 <?php do_settings_sections( 'bbpress' ); ?>
401
402 <p class="submit">
403 <input type="submit" name="submit" class="button-primary" value="<?php _e( 'Save Changes', 'bbpress' ); ?>" />
404 </p>
405 </form>
406 </div>
407
408 <?php
409 }
410
411 /**
412 * Contextual help for bbPress settings page
413 *
414 * @since bbPress (r3119)
415 */
416 function bbp_admin_settings_help() {
417
418 $bbp_contextual_help[] = __('This screen provides access to basic bbPress settings.', 'bbpress' );
419 $bbp_contextual_help[] = __('In the Main Settings you have a number of options:', 'bbpress' );
420 $bbp_contextual_help[] =
421 '<ul>' .
422 '<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>' .
423 '<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>' .
424 '<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>' .
425 '<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>' .
426 '<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>' .
427 '</ul>';
428
429 $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' );
430 $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' );
431 $bbp_contextual_help[] = __( 'You must click the Save Changes button at the bottom of the screen for new settings to take effect.', 'bbpress' );
432 $bbp_contextual_help[] = __( '<strong>For more information:</strong>', 'bbpress' );
433 $bbp_contextual_help[] =
434 '<ul>' .
435 '<li>' . __( '<a href="http://bbpress.org/documentation/">bbPress Documentation</a>', 'bbpress' ) . '</li>' .
436 '<li>' . __( '<a href="http://bbpress.org/forums/">bbPress Support Forums</a>', 'bbpress' ) . '</li>' .
437 '</ul>' ;
438
439 // Empty the default $contextual_help var
440 $contextual_help = '';
441
442 // Wrap each help item in paragraph tags
443 foreach( $bbp_contextual_help as $paragraph )
444 $contextual_help .= '<p>' . $paragraph . '</p>';
445
446 // Add help
447 add_contextual_help( 'settings_page_bbpress', $contextual_help );
448 }
449
450 /**
451 * Output settings API option
452 *
453 * @since bbPress (r3203)
454 *
455 * @uses bbp_get_bbp_form_option()
456 *
457 * @param string $option
458 * @param string $default
459 * @param bool $slug
460 */
461 function bbp_form_option( $option, $default = '' , $slug = false ) {
462 echo bbp_get_form_option( $option, $default, $slug );
463 }
464 /**
465 * Return settings API option
466 *
467 * @since bbPress (r3203)
468 *
469 * @uses get_option()
470 * @uses esc_attr()
471 * @uses apply_filters()
472 *
473 * @param string $option
474 * @param string $default
475 * @param bool $slug
476 */
477 function bbp_get_form_option( $option, $default = '', $slug = false ) {
478
479 // Get the option and sanitize it
480 $value = get_option( $option, $default );
481
482 // Slug?
483 if ( true === $slug )
484 $value = esc_attr( apply_filters( 'editable_slug', $value ) );
485
486 // Not a slug
487 else
488 $value = esc_attr( $value );
489
490 // Allow plugins to further filter the output
491 return apply_filters( 'bbp_get_form_option', $value, $option );
492 }
493
494 ?>
495