PageRenderTime 65ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/bbpress/includes/admin/settings.php

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