PluginProbe
bbPress / 2.1-beta-1
bbPress v2.1-beta-1
2.6.17 trunk 2.0 2.0-beta-1 2.0-beta-2b 2.0-beta-3 2.0-beta-3b 2.0-rc-2 2.0-rc-3 2.0-rc-4 2.0-rc-5 2.0.1 2.0.2 2.0.3 2.1 2.1-beta-1 2.1-rc1 2.1-rc2 2.1-rc3 2.1-rc4 2.1.1 2.1.2 2.1.3 2.2 2.2.1 All 72 releases
bbpress / bbp-admin / bbp-admin.php

bbp-admin.php in bbPress 2.1-beta-1, at bbp-admin/bbp-admin.php

939 lines 31.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Main bbPress Admin Class
5 *
6 * @package bbPress
7 * @subpackage Administration
8 */
9
10 // Exit if accessed directly
11 if ( !defined( 'ABSPATH' ) ) exit;
12
13 if ( !class_exists( 'BBP_Admin' ) ) :
14 /**
15 * Loads bbPress plugin admin area
16 *
17 * @package bbPress
18 * @subpackage Administration
19 * @since bbPress (r2464)
20 */
21 class BBP_Admin {
22
23 /** Directory *************************************************************/
24
25 /**
26 * @var string Path to the bbPress admin directory
27 */
28 public $admin_dir = '';
29
30 /** URLs ******************************************************************/
31
32 /**
33 * @var string URL to the bbPress admin directory
34 */
35 public $admin_url = '';
36
37 /**
38 * @var string URL to the bbPress images directory
39 */
40 public $images_url = '';
41
42 /**
43 * @var string URL to the bbPress admin styles directory
44 */
45 public $styles_url = '';
46
47 /** Capability ************************************************************/
48
49 /**
50 * @var bool Minimum capability to access Tools and Settings
51 */
52 public $minimum_capability = 'manage_options';
53
54 /** Admin Scheme **********************************************************/
55
56 /**
57 * @var int Depth of custom WP_CONTENT_DIR difference
58 */
59 public $content_depth = 0;
60
61 /** Functions *************************************************************/
62
63 /**
64 * The main bbPress admin loader
65 *
66 * @since bbPress (r2515)
67 *
68 * @uses BBP_Admin::setup_globals() Setup the globals needed
69 * @uses BBP_Admin::includes() Include the required files
70 * @uses BBP_Admin::setup_actions() Setup the hooks and actions
71 */
72 public function __construct() {
73 $this->setup_globals();
74 $this->includes();
75 $this->setup_actions();
76 }
77
78 /**
79 * Setup the admin hooks, actions and filters
80 *
81 * @since bbPress (r2646)
82 * @access private
83 *
84 * @uses add_action() To add various actions
85 * @uses add_filter() To add various filters
86 */
87 private function setup_actions() {
88
89 /** General Actions ***************************************************/
90
91 // Add menu item to settings menu
92 add_action( 'bbp_admin_menu', array( $this, 'admin_menus' ) );
93
94 // Add some general styling to the admin area
95 add_action( 'bbp_admin_head', array( $this, 'admin_head' ) );
96
97 // Add notice if not using a bbPress theme
98 add_action( 'bbp_admin_notices', array( $this, 'activation_notice' ) );
99
100 // Add green admin style
101 add_action( 'bbp_register_admin_style', array( $this, 'register_admin_style' ) );
102
103 // Add settings
104 add_action( 'bbp_register_admin_settings', array( $this, 'register_admin_settings' ) );
105
106 // Add menu item to settings menu
107 add_action( 'bbp_activation', array( $this, 'new_install' ) );
108
109 // Forums 'Right now' Dashboard widget
110 add_action( 'wp_dashboard_setup', array( $this, 'dashboard_widget_right_now' ) );
111
112 /** Filters ***********************************************************/
113
114 // Add link to settings page
115 add_filter( 'plugin_action_links', array( $this, 'add_settings_link' ), 10, 2 );
116
117 /** Network Admin *****************************************************/
118
119 // Add menu item to settings menu
120 add_action( 'network_admin_menu', array( $this, 'network_admin_menus' ) );
121
122 /** Dependencies ******************************************************/
123
124 // Allow plugins to modify these actions
125 do_action_ref_array( 'bbp_admin_loaded', array( &$this ) );
126 }
127
128 /**
129 * Include required files
130 *
131 * @since bbPress (r2646)
132 * @access private
133 */
134 private function includes() {
135 require( $this->admin_dir . 'bbp-tools.php' );
136 require( $this->admin_dir . 'bbp-converter.php' );
137 require( $this->admin_dir . 'bbp-settings.php' );
138 require( $this->admin_dir . 'bbp-functions.php' );
139 require( $this->admin_dir . 'bbp-metaboxes.php' );
140 require( $this->admin_dir . 'bbp-forums.php' );
141 require( $this->admin_dir . 'bbp-topics.php' );
142 require( $this->admin_dir . 'bbp-replies.php' );
143 }
144
145 /**
146 * Admin globals
147 *
148 * @since bbPress (r2646)
149 * @access private
150 */
151 private function setup_globals() {
152 $bbp = bbpress();
153 $this->admin_dir = trailingslashit( $bbp->plugin_dir . 'bbp-admin' ); // Admin url
154 $this->admin_url = trailingslashit( $bbp->plugin_url . 'bbp-admin' ); // Admin url
155 $this->images_url = trailingslashit( $this->admin_url . 'images' ); // Admin images URL
156 $this->styles_url = trailingslashit( $this->admin_url . 'styles' ); // Admin styles URL
157 }
158
159 /**
160 * Add the admin menus
161 *
162 * @since bbPress (r2646)
163 *
164 * @uses add_management_page() To add the Recount page in Tools section
165 * @uses add_options_page() To add the Forums settings page in Settings
166 * section
167 */
168 public function admin_menus() {
169
170 $hooks = array();
171
172 // These are later removed in admin_head
173 if ( bbp_current_user_can_see( 'bbp_tools_page' ) ) {
174 if ( bbp_current_user_can_see( 'bbp_tools_repair_page' ) ) {
175 $hooks[] = add_management_page(
176 __( 'Repair Forums', 'bbpress' ),
177 __( 'Forum Repair', 'bbpress' ),
178 $this->minimum_capability,
179 'bbp-repair',
180 'bbp_admin_repair'
181 );
182 }
183
184 if ( bbp_current_user_can_see( 'bbp_tools_import_page' ) ) {
185 $hooks[] = add_management_page(
186 __( 'Import Forums', 'bbpress' ),
187 __( 'Forum Import', 'bbpress' ),
188 $this->minimum_capability,
189 'bbp-converter',
190 'bbp_converter_settings'
191 );
192 }
193
194 if ( bbp_current_user_can_see( 'bbp_tools_reset_page' ) ) {
195 $hooks[] = add_management_page(
196 __( 'Reset Forums', 'bbpress' ),
197 __( 'Forum Reset', 'bbpress' ),
198 $this->minimum_capability,
199 'bbp-reset',
200 'bbp_admin_reset'
201 );
202 }
203
204 // Fudge the highlighted subnav item when on a bbPress admin page
205 foreach( $hooks as $hook ) {
206 add_action( "admin_head-$hook", 'bbp_tools_modify_menu_highlight' );
207 }
208
209 // Forums Tools Root
210 add_management_page(
211 __( 'Forums', 'bbpress' ),
212 __( 'Forums', 'bbpress' ),
213 $this->minimum_capability,
214 'bbp-repair',
215 'bbp_admin_repair'
216 );
217 }
218
219 // Are settings enabled?
220 if ( bbp_current_user_can_see( 'bbp_settings_page' ) ) {
221 add_options_page(
222 __( 'Forums', 'bbpress' ),
223 __( 'Forums', 'bbpress' ),
224 $this->minimum_capability,
225 'bbpress',
226 'bbp_admin_settings'
227 );
228 }
229 }
230
231 /**
232 * Add the network admin menus
233 *
234 * @since bbPress (r3689)
235 * @uses add_submenu_page() To add the Update Forums page in Updates
236 */
237 public function network_admin_menus() {
238 add_submenu_page(
239 'upgrade.php',
240 __( 'Update Forums', 'bbpress' ),
241 __( 'Update Forums', 'bbpress' ),
242 'manage_network',
243 'bbpress-update',
244 array( $this, 'network_update_screen' )
245 );
246 }
247
248 /**
249 * If this is a new installation, create some initial forum content.
250 *
251 * @since bbPress (r3767)
252 * @return type
253 */
254 public static function new_install() {
255 if ( !bbp_is_install() )
256 return;
257
258 bbp_create_initial_content();
259 }
260
261 /**
262 * Register the settings
263 *
264 * @since bbPress (r2737)
265 *
266 * @uses add_settings_section() To add our own settings section
267 * @uses add_settings_field() To add various settings fields
268 * @uses register_setting() To register various settings
269 */
270 public static function register_admin_settings() {
271
272 /** Main Section ******************************************************/
273
274 $section = 'bbp_settings_main';
275 if ( bbp_current_user_can_see( $section ) ) {
276
277 // Add the main section
278 add_settings_section( $section, __( 'Main Settings', 'bbpress' ), 'bbp_admin_setting_callback_main_section', 'bbpress' );
279
280 // Edit lock setting
281 add_settings_field( '_bbp_edit_lock', __( 'Lock post editing after', 'bbpress' ), 'bbp_admin_setting_callback_editlock', 'bbpress', $section );
282 register_setting ( 'bbpress', '_bbp_edit_lock', 'intval' );
283
284 // Throttle setting
285 add_settings_field( '_bbp_throttle_time', __( 'Throttle time', 'bbpress' ), 'bbp_admin_setting_callback_throttle', 'bbpress', $section );
286 register_setting ( 'bbpress', '_bbp_throttle_time', 'intval' );
287
288 // Allow topic and reply revisions
289 add_settings_field( '_bbp_allow_revisions', __( 'Allow Revisions', 'bbpress' ), 'bbp_admin_setting_callback_revisions', 'bbpress', $section );
290 register_setting ( 'bbpress', '_bbp_allow_revisions', 'intval' );
291
292 // Allow favorites setting
293 add_settings_field( '_bbp_enable_favorites', __( 'Allow Favorites', 'bbpress' ), 'bbp_admin_setting_callback_favorites', 'bbpress', $section );
294 register_setting ( 'bbpress', '_bbp_enable_favorites', 'intval' );
295
296 // Allow subscriptions setting
297 add_settings_field( '_bbp_enable_subscriptions', __( 'Allow Subscriptions', 'bbpress' ), 'bbp_admin_setting_callback_subscriptions', 'bbpress', $section );
298 register_setting ( 'bbpress', '_bbp_enable_subscriptions', 'intval' );
299
300 // Allow anonymous posting setting
301 add_settings_field( '_bbp_allow_anonymous', __( 'Allow Anonymous Posting', 'bbpress' ), 'bbp_admin_setting_callback_anonymous', 'bbpress', $section );
302 register_setting ( 'bbpress', '_bbp_allow_anonymous', 'intval' );
303
304 // Allow global access setting
305 if ( is_multisite() ) {
306 add_settings_field( '_bbp_allow_global_access', __( 'Allow Global Access', 'bbpress' ), 'bbp_admin_setting_callback_global_access', 'bbpress', $section );
307 register_setting ( 'bbpress', '_bbp_allow_global_access', 'intval' );
308 }
309
310 // Allow fancy editor setting
311 add_settings_field( '_bbp_use_wp_editor', __( 'Fancy Editor', 'bbpress' ), 'bbp_admin_setting_callback_use_wp_editor', 'bbpress', $section );
312 register_setting ( 'bbpress', '_bbp_use_wp_editor', 'intval' );
313
314 // Allow auto embedding setting
315 add_settings_field( '_bbp_use_autoembed', __( 'Auto-embed Links', 'bbpress' ), 'bbp_admin_setting_callback_use_autoembed', 'bbpress', $section );
316 register_setting ( 'bbpress', '_bbp_use_autoembed', 'intval' );
317 }
318
319 /** Theme Packages ****************************************************/
320
321 $section = 'bbp_settings_theme_compat';
322 if ( bbp_current_user_can_see( $section ) ) {
323
324 // Add the per page section
325 add_settings_section( $section, __( 'Theme Packages', 'bbpress' ), 'bbp_admin_setting_callback_subtheme_section', 'bbpress' );
326
327 // Replies per page setting
328 add_settings_field( '_bbp_theme_package_id', __( 'Current Package', 'bbpress' ), 'bbp_admin_setting_callback_subtheme_id', 'bbpress', $section );
329 register_setting ( 'bbpress', '_bbp_theme_package_id', '' );
330 }
331
332 /** Per Page Section **************************************************/
333
334 $section = 'bbp_settings_per_page';
335 if ( bbp_current_user_can_see( $section ) ) {
336
337 // Add the per page section
338 add_settings_section( $section, __( 'Per Page', 'bbpress' ), 'bbp_admin_setting_callback_per_page_section', 'bbpress' );
339
340 // Topics per page setting
341 add_settings_field( '_bbp_topics_per_page', __( 'Topics', 'bbpress' ), 'bbp_admin_setting_callback_topics_per_page', 'bbpress', $section );
342 register_setting ( 'bbpress', '_bbp_topics_per_page', 'intval' );
343
344 // Replies per page setting
345 add_settings_field( '_bbp_replies_per_page', __( 'Replies', 'bbpress' ), 'bbp_admin_setting_callback_replies_per_page', 'bbpress', $section );
346 register_setting ( 'bbpress', '_bbp_replies_per_page', 'intval' );
347 }
348
349 /** Per RSS Page Section **********************************************/
350
351 $section = 'bbp_settings_per_page_rss';
352 if ( bbp_current_user_can_see( $section ) ) {
353
354 // Add the per page section
355 add_settings_section( $section, __( 'Per RSS Page', 'bbpress' ), 'bbp_admin_setting_callback_per_rss_page_section', 'bbpress' );
356
357 // Topics per page setting
358 add_settings_field( '_bbp_topics_per_page', __( 'Topics', 'bbpress' ), 'bbp_admin_setting_callback_topics_per_rss_page', 'bbpress', $section );
359 register_setting ( 'bbpress', '_bbp_topics_per_rss_page', 'intval' );
360
361 // Replies per page setting
362 add_settings_field( '_bbp_replies_per_page', __( 'Replies', 'bbpress' ), 'bbp_admin_setting_callback_replies_per_rss_page', 'bbpress', $section );
363 register_setting ( 'bbpress', '_bbp_replies_per_rss_page', 'intval' );
364 }
365
366 /** Front Slugs *******************************************************/
367
368 $section = 'bbp_settings_root_slugs';
369 if ( bbp_current_user_can_see( $section ) ) {
370
371 // Add the per page section
372 add_settings_section( $section, __( 'Archive Slugs', 'bbpress' ), 'bbp_admin_setting_callback_root_slug_section', 'bbpress' );
373
374 /**
375 * Here we sanitize with 'esc_sql', rather than 'sanitize_title' to
376 * allow for slashes or any other URI friendly format.
377 */
378
379 // Root slug setting
380 add_settings_field ( '_bbp_root_slug', __( 'Forums base', 'bbpress' ), 'bbp_admin_setting_callback_root_slug', 'bbpress', $section );
381 register_setting ( 'bbpress', '_bbp_root_slug', 'esc_sql' );
382
383 // Topic archive setting
384 add_settings_field ( '_bbp_topic_archive_slug', __( 'Topics base', 'bbpress' ), 'bbp_admin_setting_callback_topic_archive_slug', 'bbpress', $section );
385 register_setting ( 'bbpress', '_bbp_topic_archive_slug', 'esc_sql' );
386 }
387
388 /** Single slugs ******************************************************/
389
390 $section = 'bbp_settings_single_slugs';
391 if ( bbp_current_user_can_see( $section ) ) {
392
393 // Add the per page section
394 add_settings_section( $section, __( 'Single Slugs', 'bbpress' ), 'bbp_admin_setting_callback_single_slug_section', 'bbpress' );
395
396 // Include root setting
397 add_settings_field( '_bbp_include_root', __( 'Forum Prefix', 'bbpress' ), 'bbp_admin_setting_callback_include_root', 'bbpress', $section );
398 register_setting ( 'bbpress', '_bbp_include_root', 'intval' );
399
400 // Forum slug setting
401 add_settings_field( '_bbp_forum_slug', __( 'Forum slug', 'bbpress' ), 'bbp_admin_setting_callback_forum_slug', 'bbpress', $section );
402 register_setting ( 'bbpress', '_bbp_forum_slug', 'sanitize_title' );
403
404 // Topic slug setting
405 add_settings_field( '_bbp_topic_slug', __( 'Topic slug', 'bbpress' ), 'bbp_admin_setting_callback_topic_slug', 'bbpress', $section );
406 register_setting ( 'bbpress', '_bbp_topic_slug', 'sanitize_title' );
407
408 // Topic tag slug setting
409 add_settings_field( '_bbp_topic_tag_slug', __( 'Topic tag slug', 'bbpress' ), 'bbp_admin_setting_callback_topic_tag_slug', 'bbpress', $section );
410 register_setting ( 'bbpress', '_bbp_topic_tag_slug', 'sanitize_title' );
411
412 // Reply slug setting
413 add_settings_field( '_bbp_reply_slug', __( 'Reply slug', 'bbpress' ), 'bbp_admin_setting_callback_reply_slug', 'bbpress', $section );
414 register_setting ( 'bbpress', '_bbp_reply_slug', 'sanitize_title' );
415
416 /** Other slugs ***************************************************/
417
418 // User slug setting
419 add_settings_field( '_bbp_user_slug', __( 'User base', 'bbpress' ), 'bbp_admin_setting_callback_user_slug', 'bbpress', $section );
420 register_setting ( 'bbpress', '_bbp_user_slug', 'sanitize_title' );
421
422 // View slug setting
423 add_settings_field( '_bbp_view_slug', __( 'View base', 'bbpress' ), 'bbp_admin_setting_callback_view_slug', 'bbpress', $section );
424 register_setting ( 'bbpress', '_bbp_view_slug', 'sanitize_title' );
425 }
426
427 /** BuddyPress ********************************************************/
428
429 $section = 'bbp_settings_buddypress';
430 if ( bbp_current_user_can_see( $section ) ) {
431
432 // Add the per page section
433 add_settings_section( 'bbp_buddypress', __( 'BuddyPress', 'bbpress' ), 'bbp_admin_setting_callback_buddypress_section', 'bbpress' );
434
435 // Topics per page setting
436 add_settings_field( '_bbp_enable_group_forums', __( 'Enable Group Forums', 'bbpress' ), 'bbp_admin_setting_callback_group_forums', 'bbpress', 'bbp_buddypress' );
437 register_setting ( 'bbpress', '_bbp_enable_group_forums', 'intval' );
438
439 // Topics per page setting
440 add_settings_field( '_bbp_group_forums_root_id', __( 'Group Forums Parent', 'bbpress' ), 'bbp_admin_setting_callback_group_forums_root_id', 'bbpress', 'bbp_buddypress' );
441 register_setting ( 'bbpress', '_bbp_group_forums_root_id', 'intval' );
442 }
443
444 /** Akismet ***********************************************************/
445
446 $section = 'bbp_settings_akismet';
447 if ( bbp_current_user_can_see( $section ) ) {
448
449 // Add the per page section
450 add_settings_section( 'bbp_akismet', __( 'Akismet', 'bbpress' ), 'bbp_admin_setting_callback_akismet_section', 'bbpress' );
451
452 // Replies per page setting
453 add_settings_field( '_bbp_enable_akismet', __( 'Use Akismet', 'bbpress' ), 'bbp_admin_setting_callback_akismet', 'bbpress', 'bbp_akismet' );
454 register_setting ( 'bbpress', '_bbp_enable_akismet', 'intval' );
455 }
456 }
457
458 /**
459 * Register the importers
460 *
461 * @since bbPress (r2737)
462 *
463 * @uses apply_filters() Calls 'bbp_importer_path' filter to allow plugins
464 * to customize the importer script locations.
465 */
466 public function register_importers() {
467
468 // Leave if we're not in the import section
469 if ( !defined( 'WP_LOAD_IMPORTERS' ) )
470 return;
471
472 // Load Importer API
473 require_once( ABSPATH . 'wp-admin/includes/import.php' );
474
475 // Load our importers
476 $importers = apply_filters( 'bbp_importers', array( 'bbpress' ) );
477
478 // Loop through included importers
479 foreach ( $importers as $importer ) {
480
481 // Allow custom importer directory
482 $import_dir = apply_filters( 'bbp_importer_path', $this->admin_dir . 'importers', $importer );
483
484 // Compile the importer path
485 $import_file = trailingslashit( $import_dir ) . $importer . '.php';
486
487 // If the file exists, include it
488 if ( file_exists( $import_file ) ) {
489 require( $import_file );
490 }
491 }
492 }
493
494 /**
495 * Admin area activation notice
496 *
497 * Shows a nag message in admin area about the theme not supporting bbPress
498 *
499 * @since bbPress (r2743)
500 *
501 * @uses current_user_can() To check notice should be displayed.
502 */
503 public function activation_notice() {
504 // @todo - something fun
505 }
506
507 /**
508 * Add Settings link to plugins area
509 *
510 * @since bbPress (r2737)
511 *
512 * @param array $links Links array in which we would prepend our link
513 * @param string $file Current plugin basename
514 * @return array Processed links
515 */
516 public static function add_settings_link( $links, $file ) {
517
518 if ( plugin_basename( bbpress()->file ) == $file ) {
519 $settings_link = '<a href="' . add_query_arg( array( 'page' => 'bbpress' ), admin_url( 'options-general.php' ) ) . '">' . __( 'Settings', 'bbpress' ) . '</a>';
520 array_unshift( $links, $settings_link );
521 }
522
523 return $links;
524 }
525
526 /**
527 * Add the 'Right now in Forums' dashboard widget
528 *
529 * @since bbPress (r2770)
530 *
531 * @uses wp_add_dashboard_widget() To add the dashboard widget
532 */
533 public static function dashboard_widget_right_now() {
534 wp_add_dashboard_widget( 'bbp-dashboard-right-now', __( 'Right Now in Forums', 'bbpress' ), 'bbp_dashboard_widget_right_now' );
535 }
536
537 /**
538 * Add some general styling to the admin area
539 *
540 * @since bbPress (r2464)
541 *
542 * @uses bbp_get_forum_post_type() To get the forum post type
543 * @uses bbp_get_topic_post_type() To get the topic post type
544 * @uses bbp_get_reply_post_type() To get the reply post type
545 * @uses sanitize_html_class() To sanitize the classes
546 */
547 public function admin_head() {
548
549 // Remove the individual recount and converter menus.
550 // They are grouped together by h2 tabs
551 remove_submenu_page( 'tools.php', 'bbp-repair' );
552 remove_submenu_page( 'tools.php', 'bbp-converter' );
553 remove_submenu_page( 'tools.php', 'bbp-reset' );
554
555 // Icons for top level admin menus
556 $menu_icon_url = $this->images_url . 'menu.png';
557 $icon32_url = $this->images_url . 'icons32.png';
558
559 // Top level menu classes
560 $forum_class = sanitize_html_class( bbp_get_forum_post_type() );
561 $topic_class = sanitize_html_class( bbp_get_topic_post_type() );
562 $reply_class = sanitize_html_class( bbp_get_reply_post_type() ); ?>
563
564 <style type="text/css" media="screen">
565 /*<![CDATA[*/
566
567 #bbp-dashboard-right-now p.sub,
568 #bbp-dashboard-right-now .table,
569 #bbp-dashboard-right-now .versions {
570 margin: -12px;
571 }
572
573 #bbp-dashboard-right-now .inside {
574 font-size: 12px;
575 padding-top: 20px;
576 margin-bottom: 0;
577 }
578
579 #bbp-dashboard-right-now p.sub {
580 padding: 5px 0 15px;
581 color: #8f8f8f;
582 font-size: 14px;
583 position: absolute;
584 top: -17px;
585 left: 15px;
586 }
587 body.rtl #bbp-dashboard-right-now p.sub {
588 right: 15px;
589 left: 0;
590 }
591
592 #bbp-dashboard-right-now .table {
593 margin: 0;
594 padding: 0;
595 position: relative;
596 }
597
598 #bbp-dashboard-right-now .table_content {
599 float: left;
600 border-top: #ececec 1px solid;
601 width: 45%;
602 }
603 body.rtl #bbp-dashboard-right-now .table_content {
604 float: right;
605 }
606
607 #bbp-dashboard-right-now .table_discussion {
608 float: right;
609 border-top: #ececec 1px solid;
610 width: 45%;
611 }
612 body.rtl #bbp-dashboard-right-now .table_discussion {
613 float: left;
614 }
615
616 #bbp-dashboard-right-now table td {
617 padding: 3px 0;
618 white-space: nowrap;
619 }
620
621 #bbp-dashboard-right-now table tr.first td {
622 border-top: none;
623 }
624
625 #bbp-dashboard-right-now td.b {
626 padding-right: 6px;
627 text-align: right;
628 font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
629 font-size: 14px;
630 width: 1%;
631 }
632 body.rtl #bbp-dashboard-right-now td.b {
633 padding-left: 6px;
634 padding-right: 0;
635 }
636
637 #bbp-dashboard-right-now td.b a {
638 font-size: 18px;
639 }
640
641 #bbp-dashboard-right-now td.b a:hover {
642 color: #d54e21;
643 }
644
645 #bbp-dashboard-right-now .t {
646 font-size: 12px;
647 padding-right: 12px;
648 padding-top: 6px;
649 color: #777;
650 }
651 body.rtl #bbp-dashboard-right-now .t {
652 padding-left: 12px;
653 padding-right: 0;
654 }
655
656 #bbp-dashboard-right-now .t a {
657 white-space: nowrap;
658 }
659
660 #bbp-dashboard-right-now .spam {
661 color: red;
662 }
663
664 #bbp-dashboard-right-now .waiting {
665 color: #e66f00;
666 }
667
668 #bbp-dashboard-right-now .approved {
669 color: green;
670 }
671
672 #bbp-dashboard-right-now .versions {
673 padding: 6px 10px 12px;
674 clear: both;
675 }
676
677 #bbp-dashboard-right-now .versions .b {
678 font-weight: bold;
679 }
680
681 #bbp-dashboard-right-now a.button {
682 float: right;
683 clear: right;
684 position: relative;
685 top: -5px;
686 }
687 body.rtl #bbp-dashboard-right-now a.button {
688 float: left;
689 clear: left;
690 }
691
692 #menu-posts-<?php echo $forum_class; ?> .wp-menu-image {
693 background: url('<?php echo $menu_icon_url; ?>') no-repeat 0px -32px;
694 }
695 #menu-posts-<?php echo $forum_class; ?>:hover .wp-menu-image,
696 #menu-posts-<?php echo $forum_class; ?>.wp-has-current-submenu .wp-menu-image {
697 background: url('<?php echo $menu_icon_url; ?>') no-repeat 0px 0px;
698 }
699 #icon-edit.icon32-posts-<?php echo $forum_class; ?> {
700 background: url('<?php echo $icon32_url; ?>') no-repeat -4px 0px;
701 }
702
703 #menu-posts-<?php echo $topic_class; ?> .wp-menu-image {
704 background: url('<?php echo $menu_icon_url; ?>') no-repeat -70px -32px;
705 }
706 #menu-posts-<?php echo $topic_class; ?>:hover .wp-menu-image,
707 #menu-posts-<?php echo $topic_class; ?>.wp-has-current-submenu .wp-menu-image {
708 background: url('<?php echo $menu_icon_url; ?>') no-repeat -70px 0px;
709 }
710 #icon-edit.icon32-posts-<?php echo $topic_class; ?> {
711 background: url('<?php echo $icon32_url; ?>') no-repeat -4px -90px;
712 }
713
714 #menu-posts-<?php echo $reply_class; ?> .wp-menu-image {
715 background: url('<?php echo $menu_icon_url; ?>') no-repeat -35px -32px;
716 }
717 #menu-posts-<?php echo $reply_class; ?>:hover .wp-menu-image,
718 #menu-posts-<?php echo $reply_class; ?>.wp-has-current-submenu .wp-menu-image {
719 background: url('<?php echo $menu_icon_url; ?>') no-repeat -35px 0px;
720 }
721 #icon-edit.icon32-posts-<?php echo $reply_class; ?> {
722 background: url('<?php echo $icon32_url; ?>') no-repeat -4px -180px;
723 }
724
725 /*]]>*/
726 </style>
727
728 <?php
729 }
730
731 /**
732 * Registers the bbPress admin color scheme
733 *
734 * Because wp-content can exist outside of the WordPress root there is no
735 * way to be certain what the relative path of the admin images is.
736 * We are including the two most common configurations here, just in case.
737 *
738 * @since bbPress (r2521)
739 *
740 * @uses wp_admin_css_color() To register the color scheme
741 */
742 public function register_admin_style () {
743
744 // Normal wp-content dir
745 if ( 0 === $this->content_depth )
746 $css_file = $this->styles_url . 'admin.css';
747
748 // Custom wp-content dir is 1 level away
749 elseif ( 1 === $this->content_depth )
750 $css_file = $this->styles_url . 'admin-1.css';
751
752 // Custom wp-content dir is 1 level away
753 elseif ( 2 === $this->content_depth )
754 $css_file = $this->styles_url . 'admin-2.css';
755
756 // Load the admin CSS styling
757 wp_admin_css_color( 'bbpress', __( 'Green', 'bbpress' ), $css_file, array( '#222222', '#006600', '#deece1', '#6eb469' ) );
758 }
759
760 /**
761 * Update all bbPress forums across all sites
762 *
763 * @since bbPress (r3689)
764 *
765 * @global WPDB $wpdb
766 * @uses get_blog_option()
767 * @uses wp_remote_get()
768 */
769 public static function update_screen() {
770
771 // Get action
772 $action = isset( $_GET['action'] ) ? $_GET['action'] : ''; ?>
773
774 <div class="wrap">
775 <div id="icon-edit" class="icon32 icon32-posts-topic"><br /></div>
776 <h2><?php _e( 'Update Forum', 'bbpress' ); ?></h2>
777
778 <?php
779
780 // Taking action
781 switch ( $action ) {
782 case 'bbpress-update' :
783
784 // @todo more update stuff here, evaluate performance
785
786 // Remove roles and caps
787 bbp_remove_roles();
788 bbp_remove_caps();
789
790 // Make sure roles, capabilities, and options exist
791 bbp_add_roles();
792 bbp_add_caps();
793 bbp_add_options();
794
795 // Ensure any new permalinks are created
796 flush_rewrite_rules();
797
798 // Ensure proper version in the DB
799 bbp_version_bump();
800
801 ?>
802
803 <p><?php _e( 'All done!', 'bbpress' ); ?></p>
804 <a class="button" href="index.php?page=bbpress-update"><?php _e( 'Go Back', 'bbpress' ); ?></a>
805
806 <?php
807
808 break;
809
810 case 'show' :
811 default : ?>
812
813 <p><?php _e( 'You can update your forum through this page. Hit the link below to update.', 'bbpress' ); ?></p>
814 <p><a class="button" href="index.php?page=bbpress-update&amp;action=bbpress-update"><?php _e( 'Update Forum', 'bbpress' ); ?></a></p>
815
816 <?php break;
817
818 } ?>
819
820 </div><?php
821 }
822
823 /**
824 * Update all bbPress forums across all sites
825 *
826 * @since bbPress (r3689)
827 *
828 * @global WPDB $wpdb
829 * @uses get_blog_option()
830 * @uses wp_remote_get()
831 */
832 public static function network_update_screen() {
833 global $wpdb;
834
835 // Get action
836 $action = isset( $_GET['action'] ) ? $_GET['action'] : ''; ?>
837
838 <div class="wrap">
839 <div id="icon-edit" class="icon32 icon32-posts-topic"><br /></div>
840 <h2><?php _e( 'Update Forums', 'bbpress' ); ?></h2>
841
842 <?php
843
844 // Taking action
845 switch ( $action ) {
846 case 'bbpress-update' :
847
848 // Site counter
849 $n = isset( $_GET['n'] ) ? intval( $_GET['n'] ) : 0;
850
851 // Get blogs 5 at a time
852 $blogs = $wpdb->get_results( "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' AND spam = '0' AND deleted = '0' AND archived = '0' ORDER BY registered DESC LIMIT {$n}, 5", ARRAY_A );
853
854 // No blogs so all done!
855 if ( empty( $blogs ) ) : ?>
856
857 <p><?php _e( 'All done!', 'bbpress' ); ?></p>
858 <a class="button" href="update-core.php?page=bbpress-update"><?php _e( 'Go Back', 'bbpress' ); ?></a>
859
860 <?php break; ?>
861
862 <?php
863
864 // Still have sites to loop through
865 else : ?>
866
867 <ul>
868
869 <?php foreach ( (array) $blogs as $details ) :
870
871 $siteurl = get_blog_option( $details['blog_id'], 'siteurl' ); ?>
872
873 <li><?php echo $siteurl; ?></li>
874
875 <?php
876
877 // Get the response of the bbPress update on this site
878 $response = wp_remote_get(
879 trailingslashit( $siteurl ) . 'wp-admin/index.php?page=bbpress-update&step=bbpress-update',
880 array( 'timeout' => 120, 'httpversion' => '1.1' )
881 );
882
883 // Site errored out, no response?
884 if ( is_wp_error( $response ) )
885 wp_die( sprintf( __( 'Warning! Problem updating %1$s. Your server may not be able to connect to sites running on it. Error message: <em>%2$s</em>', 'bbpress' ), $siteurl, $response->get_error_message() ) );
886
887 // Do some actions to allow plugins to do things too
888 do_action( 'after_bbpress_upgrade', $response );
889 do_action( 'bbp_upgrade_site', $details[ 'blog_id' ] );
890
891 endforeach; ?>
892
893 </ul>
894
895 <p>
896 <?php _e( 'If your browser doesn&#8217;t start loading the next page automatically, click this link:', 'bbpress' ); ?>
897 <a class="button" href="update-core.php?page=bbpress-update&amp;action=bbpress-update&amp;n=<?php echo ( $n + 5 ); ?>"><?php _e( 'Next Forums', 'bbpress' ); ?></a>
898 </p>
899 <script type='text/javascript'>
900 <!--
901 function nextpage() {
902 location.href = 'update-core.php?page=bbpress-update&action=bbpress-update&n=<?php echo ( $n + 5 ) ?>';
903 }
904 setTimeout( 'nextpage()', 250 );
905 //-->
906 </script><?php
907
908 endif;
909
910 break;
911
912 case 'show' :
913 default : ?>
914
915 <p><?php _e( 'You can update all the forums on your network through this page. It works by calling the update script of each site automatically. Hit the link below to update.', 'bbpress' ); ?></p>
916 <p><a class="button" href="update-core.php?page=bbpress-update&amp;action=bbpress-update"><?php _e( 'Update Forums', 'bbpress' ); ?></a></p>
917
918 <?php break;
919
920 } ?>
921
922 </div><?php
923 }
924 }
925 endif; // class_exists check
926
927 /**
928 * Setup bbPress Admin
929 *
930 * @since bbPress (r2596)
931 *
932 * @uses BBP_Admin
933 */
934 function bbp_admin() {
935 bbpress()->admin = new BBP_Admin();
936
937 bbpress()->admin->converter = new BBP_Converter();
938 }
939