PageRenderTime 54ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/Thane2376/death-edge.ru
PHP | 1759 lines | 839 code | 346 blank | 574 comment | 20 complexity | 4413de6966fd8eca40d7a2ce670d7581 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, LGPL-3.0, AGPL-1.0

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

Large files files are truncated, but you can click here to view the full file