Changeset 3998 for branches/plugin/bbp-admin/bbp-admin.php
- Timestamp:
- 06/21/2012 06:23:43 AM (14 years ago)
- File:
-
- 1 edited
-
branches/plugin/bbp-admin/bbp-admin.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-admin/bbp-admin.php
r3995 r3998 267 267 * @uses add_settings_field() To add various settings fields 268 268 * @uses register_setting() To register various settings 269 * @todo Put fields into multidimensional array 269 270 */ 270 271 public static function register_admin_settings() { 271 272 272 /** Main Section ******************************************************/ 273 274 $section = 'bbp_settings_main'; 275 if ( bbp_current_user_can_see( $section ) ) { 276 277 // Add the main section 278 add_settings_section( $section, __( 'Main Settings', 'bbpress' ), 'bbp_admin_setting_callback_main_section', 'bbpress' ); 279 280 // Edit lock setting 281 add_settings_field( '_bbp_edit_lock', __( 'Lock post editing after', 'bbpress' ), 'bbp_admin_setting_callback_editlock', 'bbpress', $section ); 282 register_setting ( 'bbpress', '_bbp_edit_lock', 'intval' ); 283 284 // Throttle setting 285 add_settings_field( '_bbp_throttle_time', __( 'Throttle time', 'bbpress' ), 'bbp_admin_setting_callback_throttle', 'bbpress', $section ); 286 register_setting ( 'bbpress', '_bbp_throttle_time', 'intval' ); 287 288 // Allow topic and reply revisions 289 add_settings_field( '_bbp_allow_revisions', __( 'Allow Revisions', 'bbpress' ), 'bbp_admin_setting_callback_revisions', 'bbpress', $section ); 290 register_setting ( 'bbpress', '_bbp_allow_revisions', 'intval' ); 291 292 // Allow favorites setting 293 add_settings_field( '_bbp_enable_favorites', __( 'Allow Favorites', 'bbpress' ), 'bbp_admin_setting_callback_favorites', 'bbpress', $section ); 294 register_setting ( 'bbpress', '_bbp_enable_favorites', 'intval' ); 295 296 // Allow subscriptions setting 297 add_settings_field( '_bbp_enable_subscriptions', __( 'Allow Subscriptions', 'bbpress' ), 'bbp_admin_setting_callback_subscriptions', 'bbpress', $section ); 298 register_setting ( 'bbpress', '_bbp_enable_subscriptions', 'intval' ); 299 300 // Allow anonymous posting setting 301 add_settings_field( '_bbp_allow_anonymous', __( 'Allow Anonymous Posting', 'bbpress' ), 'bbp_admin_setting_callback_anonymous', 'bbpress', $section ); 302 register_setting ( 'bbpress', '_bbp_allow_anonymous', 'intval' ); 303 304 // Allow global access setting 305 if ( is_multisite() ) { 306 add_settings_field( '_bbp_allow_global_access', __( 'Allow Global Access', 'bbpress' ), 'bbp_admin_setting_callback_global_access', 'bbpress', $section ); 307 register_setting ( 'bbpress', '_bbp_allow_global_access', 'intval' ); 308 } 309 310 // Allow fancy editor setting 311 add_settings_field( '_bbp_use_wp_editor', __( 'Fancy Editor', 'bbpress' ), 'bbp_admin_setting_callback_use_wp_editor', 'bbpress', $section ); 312 register_setting ( 'bbpress', '_bbp_use_wp_editor', 'intval' ); 313 314 // Allow auto embedding setting 315 add_settings_field( '_bbp_use_autoembed', __( 'Auto-embed Links', 'bbpress' ), 'bbp_admin_setting_callback_use_autoembed', 'bbpress', $section ); 316 register_setting ( 'bbpress', '_bbp_use_autoembed', 'intval' ); 273 // Loop through sections 274 foreach ( self::get_settings_sections() as $section_id => $section ) { 275 276 // Only proceed if current user can see this section 277 if ( ! bbp_current_user_can_see( $section_id ) ) 278 continue; 279 280 // Add the section 281 add_settings_section( $section_id, $section['title'], $section['callback'], $section['page'] ); 282 283 switch ( $section_id ) { 284 285 /** Main Section **********************************************/ 286 287 case 'bbp_settings_main' : 288 289 // Edit lock setting 290 add_settings_field( '_bbp_edit_lock', __( 'Lock post editing after', 'bbpress' ), 'bbp_admin_setting_callback_editlock', 'bbpress', $section_id ); 291 register_setting ( 'bbpress', '_bbp_edit_lock', 'intval' ); 292 293 // Throttle setting 294 add_settings_field( '_bbp_throttle_time', __( 'Throttle time', 'bbpress' ), 'bbp_admin_setting_callback_throttle', 'bbpress', $section_id ); 295 register_setting ( 'bbpress', '_bbp_throttle_time', 'intval' ); 296 297 // Allow topic and reply revisions 298 add_settings_field( '_bbp_allow_revisions', __( 'Allow Revisions', 'bbpress' ), 'bbp_admin_setting_callback_revisions', 'bbpress', $section_id ); 299 register_setting ( 'bbpress', '_bbp_allow_revisions', 'intval' ); 300 301 // Allow favorites setting 302 add_settings_field( '_bbp_enable_favorites', __( 'Allow Favorites', 'bbpress' ), 'bbp_admin_setting_callback_favorites', 'bbpress', $section_id ); 303 register_setting ( 'bbpress', '_bbp_enable_favorites', 'intval' ); 304 305 // Allow subscriptions setting 306 add_settings_field( '_bbp_enable_subscriptions', __( 'Allow Subscriptions', 'bbpress' ), 'bbp_admin_setting_callback_subscriptions', 'bbpress', $section_id ); 307 register_setting ( 'bbpress', '_bbp_enable_subscriptions', 'intval' ); 308 309 // Allow anonymous posting setting 310 add_settings_field( '_bbp_allow_anonymous', __( 'Allow Anonymous Posting', 'bbpress' ), 'bbp_admin_setting_callback_anonymous', 'bbpress', $section_id ); 311 register_setting ( 'bbpress', '_bbp_allow_anonymous', 'intval' ); 312 313 // Allow global access setting 314 if ( is_multisite() ) { 315 add_settings_field( '_bbp_allow_global_access', __( 'Allow Global Access', 'bbpress' ), 'bbp_admin_setting_callback_global_access', 'bbpress', $section_id ); 316 register_setting ( 'bbpress', '_bbp_allow_global_access', 'intval' ); 317 } 318 319 // Allow fancy editor setting 320 add_settings_field( '_bbp_use_wp_editor', __( 'Fancy Editor', 'bbpress' ), 'bbp_admin_setting_callback_use_wp_editor', 'bbpress', $section_id ); 321 register_setting ( 'bbpress', '_bbp_use_wp_editor', 'intval' ); 322 323 // Allow auto embedding setting 324 add_settings_field( '_bbp_use_autoembed', __( 'Auto-embed Links', 'bbpress' ), 'bbp_admin_setting_callback_use_autoembed', 'bbpress', $section_id ); 325 register_setting ( 'bbpress', '_bbp_use_autoembed', 'intval' ); 326 break; 327 328 /** Theme Packages ********************************************/ 329 330 case 'bbp_settings_theme_compat' : 331 332 // Replies per page setting 333 add_settings_field( '_bbp_theme_package_id', __( 'Current Package', 'bbpress' ), 'bbp_admin_setting_callback_subtheme_id', 'bbpress', $section_id ); 334 register_setting ( 'bbpress', '_bbp_theme_package_id', '' ); 335 336 break; 337 338 /** Per Page Section ******************************************/ 339 340 case 'bbp_settings_per_page' : 341 342 // Topics per page setting 343 add_settings_field( '_bbp_topics_per_page', __( 'Topics', 'bbpress' ), 'bbp_admin_setting_callback_topics_per_page', 'bbpress', $section_id ); 344 register_setting ( 'bbpress', '_bbp_topics_per_page', 'intval' ); 345 346 // Replies per page setting 347 add_settings_field( '_bbp_replies_per_page', __( 'Replies', 'bbpress' ), 'bbp_admin_setting_callback_replies_per_page', 'bbpress', $section_id ); 348 register_setting ( 'bbpress', '_bbp_replies_per_page', 'intval' ); 349 350 break; 351 352 /** Per RSS Page Section **************************************/ 353 354 case 'bbp_settings_per_page_rss' : 355 356 // Topics per page setting 357 add_settings_field( '_bbp_topics_per_page', __( 'Topics', 'bbpress' ), 'bbp_admin_setting_callback_topics_per_rss_page', 'bbpress', $section_id ); 358 register_setting ( 'bbpress', '_bbp_topics_per_rss_page', 'intval' ); 359 360 // Replies per page setting 361 add_settings_field( '_bbp_replies_per_page', __( 'Replies', 'bbpress' ), 'bbp_admin_setting_callback_replies_per_rss_page', 'bbpress', $section_id ); 362 register_setting ( 'bbpress', '_bbp_replies_per_rss_page', 'intval' ); 363 364 break; 365 366 /** Front Slugs ***********************************************/ 367 368 case 'bbp_settings_root_slugs' : 369 370 /** 371 * Here we sanitize with 'esc_sql', rather than 'sanitize_title' to 372 * allow for slashes or any other URI friendly format. 373 */ 374 375 // Root slug setting 376 add_settings_field ( '_bbp_root_slug', __( 'Forums base', 'bbpress' ), 'bbp_admin_setting_callback_root_slug', 'bbpress', $section_id ); 377 register_setting ( 'bbpress', '_bbp_root_slug', 'esc_sql' ); 378 379 // Topic archive setting 380 add_settings_field ( '_bbp_topic_archive_slug', __( 'Topics base', 'bbpress' ), 'bbp_admin_setting_callback_topic_archive_slug', 'bbpress', $section_id ); 381 register_setting ( 'bbpress', '_bbp_topic_archive_slug', 'esc_sql' ); 382 383 break; 384 385 /** Single slugs **********************************************/ 386 387 case 'bbp_settings_single_slugs' : 388 389 // Include root setting 390 add_settings_field( '_bbp_include_root', __( 'Forum Prefix', 'bbpress' ), 'bbp_admin_setting_callback_include_root', 'bbpress', $section_id ); 391 register_setting ( 'bbpress', '_bbp_include_root', 'intval' ); 392 393 // Forum slug setting 394 add_settings_field( '_bbp_forum_slug', __( 'Forum slug', 'bbpress' ), 'bbp_admin_setting_callback_forum_slug', 'bbpress', $section_id ); 395 register_setting ( 'bbpress', '_bbp_forum_slug', 'sanitize_title' ); 396 397 // Topic slug setting 398 add_settings_field( '_bbp_topic_slug', __( 'Topic slug', 'bbpress' ), 'bbp_admin_setting_callback_topic_slug', 'bbpress', $section_id ); 399 register_setting ( 'bbpress', '_bbp_topic_slug', 'sanitize_title' ); 400 401 // Topic tag slug setting 402 add_settings_field( '_bbp_topic_tag_slug', __( 'Topic tag slug', 'bbpress' ), 'bbp_admin_setting_callback_topic_tag_slug', 'bbpress', $section_id ); 403 register_setting ( 'bbpress', '_bbp_topic_tag_slug', 'sanitize_title' ); 404 405 // Reply slug setting 406 add_settings_field( '_bbp_reply_slug', __( 'Reply slug', 'bbpress' ), 'bbp_admin_setting_callback_reply_slug', 'bbpress', $section_id ); 407 register_setting ( 'bbpress', '_bbp_reply_slug', 'sanitize_title' ); 408 409 /** Other slugs *******************************************/ 410 411 // User slug setting 412 add_settings_field( '_bbp_user_slug', __( 'User base', 'bbpress' ), 'bbp_admin_setting_callback_user_slug', 'bbpress', $section_id ); 413 register_setting ( 'bbpress', '_bbp_user_slug', 'sanitize_title' ); 414 415 // View slug setting 416 add_settings_field( '_bbp_view_slug', __( 'View base', 'bbpress' ), 'bbp_admin_setting_callback_view_slug', 'bbpress', $section_id ); 417 register_setting ( 'bbpress', '_bbp_view_slug', 'sanitize_title' ); 418 419 break; 420 421 /** BuddyPress ************************************************/ 422 423 case 'bbp_settings_buddypress' : 424 425 // Topics per page setting 426 add_settings_field( '_bbp_enable_group_forums', __( 'Enable Group Forums', 'bbpress' ), 'bbp_admin_setting_callback_group_forums', 'bbpress', $section_id ); 427 register_setting ( 'bbpress', '_bbp_enable_group_forums', 'intval' ); 428 429 // Topics per page setting 430 add_settings_field( '_bbp_group_forums_root_id', __( 'Group Forums Parent', 'bbpress' ), 'bbp_admin_setting_callback_group_forums_root_id', 'bbpress', $section_id ); 431 register_setting ( 'bbpress', '_bbp_group_forums_root_id', 'intval' ); 432 433 break; 434 435 /** Akismet ***************************************************/ 436 437 case 'bbp_settings_akismet' : 438 439 // Replies per page setting 440 add_settings_field( '_bbp_enable_akismet', __( 'Use Akismet', 'bbpress' ), 'bbp_admin_setting_callback_akismet', 'bbpress', $section_id ); 441 register_setting ( 'bbpress', '_bbp_enable_akismet', 'intval' ); 442 443 break; 444 } 317 445 } 318 319 /** Theme Packages ****************************************************/ 320 321 $section = 'bbp_settings_theme_compat'; 322 if ( bbp_current_user_can_see( $section ) ) { 323 324 // Add the per page section 325 add_settings_section( $section, __( 'Theme Packages', 'bbpress' ), 'bbp_admin_setting_callback_subtheme_section', 'bbpress' ); 326 327 // Replies per page setting 328 add_settings_field( '_bbp_theme_package_id', __( 'Current Package', 'bbpress' ), 'bbp_admin_setting_callback_subtheme_id', 'bbpress', $section ); 329 register_setting ( 'bbpress', '_bbp_theme_package_id', '' ); 330 } 331 332 /** Per Page Section **************************************************/ 333 334 $section = 'bbp_settings_per_page'; 335 if ( bbp_current_user_can_see( $section ) ) { 336 337 // Add the per page section 338 add_settings_section( $section, __( 'Per Page', 'bbpress' ), 'bbp_admin_setting_callback_per_page_section', 'bbpress' ); 339 340 // Topics per page setting 341 add_settings_field( '_bbp_topics_per_page', __( 'Topics', 'bbpress' ), 'bbp_admin_setting_callback_topics_per_page', 'bbpress', $section ); 342 register_setting ( 'bbpress', '_bbp_topics_per_page', 'intval' ); 343 344 // Replies per page setting 345 add_settings_field( '_bbp_replies_per_page', __( 'Replies', 'bbpress' ), 'bbp_admin_setting_callback_replies_per_page', 'bbpress', $section ); 346 register_setting ( 'bbpress', '_bbp_replies_per_page', 'intval' ); 347 } 348 349 /** Per RSS Page Section **********************************************/ 350 351 $section = 'bbp_settings_per_page_rss'; 352 if ( bbp_current_user_can_see( $section ) ) { 353 354 // Add the per page section 355 add_settings_section( $section, __( 'Per RSS Page', 'bbpress' ), 'bbp_admin_setting_callback_per_rss_page_section', 'bbpress' ); 356 357 // Topics per page setting 358 add_settings_field( '_bbp_topics_per_page', __( 'Topics', 'bbpress' ), 'bbp_admin_setting_callback_topics_per_rss_page', 'bbpress', $section ); 359 register_setting ( 'bbpress', '_bbp_topics_per_rss_page', 'intval' ); 360 361 // Replies per page setting 362 add_settings_field( '_bbp_replies_per_page', __( 'Replies', 'bbpress' ), 'bbp_admin_setting_callback_replies_per_rss_page', 'bbpress', $section ); 363 register_setting ( 'bbpress', '_bbp_replies_per_rss_page', 'intval' ); 364 } 365 366 /** Front Slugs *******************************************************/ 367 368 $section = 'bbp_settings_root_slugs'; 369 if ( bbp_current_user_can_see( $section ) ) { 370 371 // Add the per page section 372 add_settings_section( $section, __( 'Archive Slugs', 'bbpress' ), 'bbp_admin_setting_callback_root_slug_section', 'bbpress' ); 373 374 /** 375 * Here we sanitize with 'esc_sql', rather than 'sanitize_title' to 376 * allow for slashes or any other URI friendly format. 377 */ 378 379 // Root slug setting 380 add_settings_field ( '_bbp_root_slug', __( 'Forums base', 'bbpress' ), 'bbp_admin_setting_callback_root_slug', 'bbpress', $section ); 381 register_setting ( 'bbpress', '_bbp_root_slug', 'esc_sql' ); 382 383 // Topic archive setting 384 add_settings_field ( '_bbp_topic_archive_slug', __( 'Topics base', 'bbpress' ), 'bbp_admin_setting_callback_topic_archive_slug', 'bbpress', $section ); 385 register_setting ( 'bbpress', '_bbp_topic_archive_slug', 'esc_sql' ); 386 } 387 388 /** Single slugs ******************************************************/ 389 390 $section = 'bbp_settings_single_slugs'; 391 if ( bbp_current_user_can_see( $section ) ) { 392 393 // Add the per page section 394 add_settings_section( $section, __( 'Single Slugs', 'bbpress' ), 'bbp_admin_setting_callback_single_slug_section', 'bbpress' ); 395 396 // Include root setting 397 add_settings_field( '_bbp_include_root', __( 'Forum Prefix', 'bbpress' ), 'bbp_admin_setting_callback_include_root', 'bbpress', $section ); 398 register_setting ( 'bbpress', '_bbp_include_root', 'intval' ); 399 400 // Forum slug setting 401 add_settings_field( '_bbp_forum_slug', __( 'Forum slug', 'bbpress' ), 'bbp_admin_setting_callback_forum_slug', 'bbpress', $section ); 402 register_setting ( 'bbpress', '_bbp_forum_slug', 'sanitize_title' ); 403 404 // Topic slug setting 405 add_settings_field( '_bbp_topic_slug', __( 'Topic slug', 'bbpress' ), 'bbp_admin_setting_callback_topic_slug', 'bbpress', $section ); 406 register_setting ( 'bbpress', '_bbp_topic_slug', 'sanitize_title' ); 407 408 // Topic tag slug setting 409 add_settings_field( '_bbp_topic_tag_slug', __( 'Topic tag slug', 'bbpress' ), 'bbp_admin_setting_callback_topic_tag_slug', 'bbpress', $section ); 410 register_setting ( 'bbpress', '_bbp_topic_tag_slug', 'sanitize_title' ); 411 412 // Reply slug setting 413 add_settings_field( '_bbp_reply_slug', __( 'Reply slug', 'bbpress' ), 'bbp_admin_setting_callback_reply_slug', 'bbpress', $section ); 414 register_setting ( 'bbpress', '_bbp_reply_slug', 'sanitize_title' ); 415 416 /** Other slugs ***************************************************/ 417 418 // User slug setting 419 add_settings_field( '_bbp_user_slug', __( 'User base', 'bbpress' ), 'bbp_admin_setting_callback_user_slug', 'bbpress', $section ); 420 register_setting ( 'bbpress', '_bbp_user_slug', 'sanitize_title' ); 421 422 // View slug setting 423 add_settings_field( '_bbp_view_slug', __( 'View base', 'bbpress' ), 'bbp_admin_setting_callback_view_slug', 'bbpress', $section ); 424 register_setting ( 'bbpress', '_bbp_view_slug', 'sanitize_title' ); 425 } 426 427 /** BuddyPress ********************************************************/ 428 429 $section = 'bbp_settings_buddypress'; 430 if ( bbp_current_user_can_see( $section ) ) { 431 432 // Add the per page section 433 add_settings_section( 'bbp_buddypress', __( 'BuddyPress', 'bbpress' ), 'bbp_admin_setting_callback_buddypress_section', 'bbpress' ); 434 435 // Topics per page setting 436 add_settings_field( '_bbp_enable_group_forums', __( 'Enable Group Forums', 'bbpress' ), 'bbp_admin_setting_callback_group_forums', 'bbpress', 'bbp_buddypress' ); 437 register_setting ( 'bbpress', '_bbp_enable_group_forums', 'intval' ); 438 439 // Topics per page setting 440 add_settings_field( '_bbp_group_forums_root_id', __( 'Group Forums Parent', 'bbpress' ), 'bbp_admin_setting_callback_group_forums_root_id', 'bbpress', 'bbp_buddypress' ); 441 register_setting ( 'bbpress', '_bbp_group_forums_root_id', 'intval' ); 442 } 443 444 /** Akismet ***********************************************************/ 445 446 $section = 'bbp_settings_akismet'; 447 if ( bbp_current_user_can_see( $section ) ) { 448 449 // Add the per page section 450 add_settings_section( 'bbp_akismet', __( 'Akismet', 'bbpress' ), 'bbp_admin_setting_callback_akismet_section', 'bbpress' ); 451 452 // Replies per page setting 453 add_settings_field( '_bbp_enable_akismet', __( 'Use Akismet', 'bbpress' ), 'bbp_admin_setting_callback_akismet', 'bbpress', 'bbp_akismet' ); 454 register_setting ( 'bbpress', '_bbp_enable_akismet', 'intval' ); 455 } 446 } 447 448 /** 449 * Get the bbPress settings sections. 450 * 451 * @since bbPress (rxxxx) 452 */ 453 private static function get_settings_sections() { 454 return apply_filters( 'bbp_admin_get_settings_sections', array( 455 'bbp_settings_main' => array( 456 'title' => __( 'Main Settings', 'bbpress' ), 457 'callback' => 'bbp_admin_setting_callback_main_section', 458 'page' => 'bbpress', 459 ), 460 'bbp_settings_theme_compat' => array( 461 'title' => __( 'Theme Packages', 'bbpress' ), 462 'callback' => 'bbp_admin_setting_callback_subtheme_section', 463 'page' => 'bbpress', 464 ), 465 'bbp_settings_per_page' => array( 466 'title' => __( 'Per Page', 'bbpress' ), 467 'callback' => 'bbp_admin_setting_callback_per_page_section', 468 'page' => 'bbpress', 469 ), 470 'bbp_settings_per_page_rss' => array( 471 'title' => __( 'Per RSS Page', 'bbpress' ), 472 'callback' => 'bbp_admin_setting_callback_per_rss_page_section', 473 'page' => 'bbpress', 474 ), 475 'bbp_settings_root_slugs' => array( 476 'title' => __( 'Archive Slugs', 'bbpress' ), 477 'callback' => 'bbp_admin_setting_callback_root_slug_section', 478 'page' => 'bbpress', 479 ), 480 'bbp_settings_single_slugs' => array( 481 'title' => __( 'Single Slugs', 'bbpress' ), 482 'callback' => 'bbp_admin_setting_callback_single_slug_section', 483 'page' => 'bbpress', 484 ), 485 'bbp_settings_buddypress' => array( 486 'title' => __( 'BuddyPress', 'bbpress' ), 487 'callback' => 'bbp_admin_setting_callback_buddypress_section', 488 'page' => 'bbpress', 489 ), 490 'bbp_settings_akismet' => array( 491 'title' => __( 'Akismet', 'bbpress' ), 492 'callback' => 'bbp_admin_setting_callback_akismet_section', 493 'page' => 'bbpress' 494 ) 495 ) ); 456 496 } 457 497
Note: See TracChangeset
for help on using the changeset viewer.