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