PluginProbe
bbPress / 2.1.3
bbPress v2.1.3
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 2.2.2 All 71 releases
bbpress / bbp-admin / bbp-admin.php

bbp-admin.php in bbPress 2.1.3, at bbp-admin/bbp-admin.php

1,224 lines 36.1 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 /** Functions *************************************************************/
55
56 /**
57 * The main bbPress admin loader
58 *
59 * @since bbPress (r2515)
60 *
61 * @uses BBP_Admin::setup_globals() Setup the globals needed
62 * @uses BBP_Admin::includes() Include the required files
63 * @uses BBP_Admin::setup_actions() Setup the hooks and actions
64 */
65 public function __construct() {
66 $this->setup_globals();
67 $this->includes();
68 $this->setup_actions();
69 }
70
71 /**
72 * Admin globals
73 *
74 * @since bbPress (r2646)
75 * @access private
76 */
77 private function setup_globals() {
78 $bbp = bbpress();
79 $this->admin_dir = trailingslashit( $bbp->plugin_dir . 'bbp-admin' ); // Admin path
80 $this->admin_url = trailingslashit( $bbp->plugin_url . 'bbp-admin' ); // Admin url
81 $this->images_url = trailingslashit( $this->admin_url . 'images' ); // Admin images URL
82 $this->styles_url = trailingslashit( $this->admin_url . 'styles' ); // Admin styles URL
83 }
84
85 /**
86 * Include required files
87 *
88 * @since bbPress (r2646)
89 * @access private
90 */
91 private function includes() {
92 require( $this->admin_dir . 'bbp-tools.php' );
93 require( $this->admin_dir . 'bbp-converter.php' );
94 require( $this->admin_dir . 'bbp-settings.php' );
95 require( $this->admin_dir . 'bbp-functions.php' );
96 require( $this->admin_dir . 'bbp-metaboxes.php' );
97 require( $this->admin_dir . 'bbp-forums.php' );
98 require( $this->admin_dir . 'bbp-topics.php' );
99 require( $this->admin_dir . 'bbp-replies.php' );
100 }
101
102 /**
103 * Setup the admin hooks, actions and filters
104 *
105 * @since bbPress (r2646)
106 * @access private
107 *
108 * @uses add_action() To add various actions
109 * @uses add_filter() To add various filters
110 */
111 private function setup_actions() {
112
113 /** General Actions ***************************************************/
114
115 add_action( 'bbp_admin_menu', array( $this, 'admin_menus' ) ); // Add menu item to settings menu
116 add_action( 'bbp_admin_head', array( $this, 'admin_head' ) ); // Add some general styling to the admin area
117 add_action( 'bbp_admin_notices', array( $this, 'activation_notice' ) ); // Add notice if not using a bbPress theme
118 add_action( 'bbp_register_admin_style', array( $this, 'register_admin_style' ) ); // Add green admin style
119 add_action( 'bbp_register_admin_settings', array( $this, 'register_admin_settings' ) ); // Add settings
120 add_action( 'bbp_activation', array( $this, 'new_install' ) ); // Add menu item to settings menu
121 add_action( 'wp_dashboard_setup', array( $this, 'dashboard_widget_right_now' ) ); // Forums 'Right now' Dashboard widget
122
123 /** Filters ***********************************************************/
124
125 // Add link to settings page
126 add_filter( 'plugin_action_links', array( $this, 'add_settings_link' ), 10, 2 );
127
128 /** Network Admin *****************************************************/
129
130 // Add menu item to settings menu
131 add_action( 'network_admin_menu', array( $this, 'network_admin_menus' ) );
132
133 /** Dependencies ******************************************************/
134
135 // Allow plugins to modify these actions
136 do_action_ref_array( 'bbp_admin_loaded', array( &$this ) );
137 }
138
139 /**
140 * Add the admin menus
141 *
142 * @since bbPress (r2646)
143 *
144 * @uses add_management_page() To add the Recount page in Tools section
145 * @uses add_options_page() To add the Forums settings page in Settings
146 * section
147 */
148 public function admin_menus() {
149
150 $hooks = array();
151
152 // These are later removed in admin_head
153 if ( bbp_current_user_can_see( 'bbp_tools_page' ) ) {
154 if ( bbp_current_user_can_see( 'bbp_tools_repair_page' ) ) {
155 $hooks[] = add_management_page(
156 __( 'Repair Forums', 'bbpress' ),
157 __( 'Forum Repair', 'bbpress' ),
158 $this->minimum_capability,
159 'bbp-repair',
160 'bbp_admin_repair'
161 );
162 }
163
164 if ( bbp_current_user_can_see( 'bbp_tools_import_page' ) ) {
165 $hooks[] = add_management_page(
166 __( 'Import Forums', 'bbpress' ),
167 __( 'Forum Import', 'bbpress' ),
168 $this->minimum_capability,
169 'bbp-converter',
170 'bbp_converter_settings'
171 );
172 }
173
174 if ( bbp_current_user_can_see( 'bbp_tools_reset_page' ) ) {
175 $hooks[] = add_management_page(
176 __( 'Reset Forums', 'bbpress' ),
177 __( 'Forum Reset', 'bbpress' ),
178 $this->minimum_capability,
179 'bbp-reset',
180 'bbp_admin_reset'
181 );
182 }
183
184 // Fudge the highlighted subnav item when on a bbPress admin page
185 foreach( $hooks as $hook ) {
186 add_action( "admin_head-$hook", 'bbp_tools_modify_menu_highlight' );
187 }
188
189 // Forums Tools Root
190 add_management_page(
191 __( 'Forums', 'bbpress' ),
192 __( 'Forums', 'bbpress' ),
193 $this->minimum_capability,
194 'bbp-repair',
195 'bbp_admin_repair'
196 );
197 }
198
199 // Are settings enabled?
200 if ( bbp_current_user_can_see( 'bbp_settings_page' ) ) {
201 add_options_page(
202 __( 'Forums', 'bbpress' ),
203 __( 'Forums', 'bbpress' ),
204 $this->minimum_capability,
205 'bbpress',
206 'bbp_admin_settings'
207 );
208 }
209 }
210
211 /**
212 * Add the network admin menus
213 *
214 * @since bbPress (r3689)
215 * @uses add_submenu_page() To add the Update Forums page in Updates
216 */
217 public function network_admin_menus() {
218 add_submenu_page(
219 'upgrade.php',
220 __( 'Update Forums', 'bbpress' ),
221 __( 'Update Forums', 'bbpress' ),
222 'manage_network',
223 'bbpress-update',
224 array( $this, 'network_update_screen' )
225 );
226 }
227
228 /**
229 * If this is a new installation, create some initial forum content.
230 *
231 * @since bbPress (r3767)
232 * @return type
233 */
234 public static function new_install() {
235 if ( !bbp_is_install() )
236 return;
237
238 bbp_create_initial_content();
239 }
240
241 /**
242 * Register the settings
243 *
244 * @since bbPress (r2737)
245 *
246 * @uses add_settings_section() To add our own settings section
247 * @uses add_settings_field() To add various settings fields
248 * @uses register_setting() To register various settings
249 * @todo Put fields into multidimensional array
250 */
251 public static function register_admin_settings() {
252
253 // Bail if no sections available
254 if ( ! $sections = bbp_admin_get_settings_sections() )
255 return false;
256
257 // Loop through sections
258 foreach ( $sections as $section_id => $section ) {
259
260 // Only proceed if current user can see this section
261 if ( ! bbp_current_user_can_see( $section_id ) )
262 continue;
263
264 // Only add section and fields if section has fields
265 if ( $fields = bbp_admin_get_settings_fields_for_section( $section_id ) ) {
266
267 // Add the section
268 add_settings_section( $section_id, $section['title'], $section['callback'], $section['page'] );
269
270 // Loop through fields for this section
271 foreach ( $fields as $field_id => $field ) {
272
273 // Add the field
274 add_settings_field( $field_id, $field['title'], $field['callback'], $section['page'], $section_id, $field['args'] );
275
276 // Register the setting
277 register_setting( $section['page'], $field_id, $field['sanitize_callback'] );
278 }
279 }
280 }
281 }
282
283 /**
284 * Register the importers
285 *
286 * @since bbPress (r2737)
287 *
288 * @uses apply_filters() Calls 'bbp_importer_path' filter to allow plugins
289 * to customize the importer script locations.
290 */
291 public function register_importers() {
292
293 // Leave if we're not in the import section
294 if ( !defined( 'WP_LOAD_IMPORTERS' ) )
295 return;
296
297 // Load Importer API
298 require_once( ABSPATH . 'wp-admin/includes/import.php' );
299
300 // Load our importers
301 $importers = apply_filters( 'bbp_importers', array( 'bbpress' ) );
302
303 // Loop through included importers
304 foreach ( $importers as $importer ) {
305
306 // Allow custom importer directory
307 $import_dir = apply_filters( 'bbp_importer_path', $this->admin_dir . 'importers', $importer );
308
309 // Compile the importer path
310 $import_file = trailingslashit( $import_dir ) . $importer . '.php';
311
312 // If the file exists, include it
313 if ( file_exists( $import_file ) ) {
314 require( $import_file );
315 }
316 }
317 }
318
319 /**
320 * Admin area activation notice
321 *
322 * Shows a nag message in admin area about the theme not supporting bbPress
323 *
324 * @since bbPress (r2743)
325 *
326 * @uses current_user_can() To check notice should be displayed.
327 */
328 public function activation_notice() {
329 // @todo - something fun
330 }
331
332 /**
333 * Add Settings link to plugins area
334 *
335 * @since bbPress (r2737)
336 *
337 * @param array $links Links array in which we would prepend our link
338 * @param string $file Current plugin basename
339 * @return array Processed links
340 */
341 public static function add_settings_link( $links, $file ) {
342
343 if ( plugin_basename( bbpress()->file ) == $file ) {
344 $settings_link = '<a href="' . add_query_arg( array( 'page' => 'bbpress' ), admin_url( 'options-general.php' ) ) . '">' . __( 'Settings', 'bbpress' ) . '</a>';
345 array_unshift( $links, $settings_link );
346 }
347
348 return $links;
349 }
350
351 /**
352 * Add the 'Right now in Forums' dashboard widget
353 *
354 * @since bbPress (r2770)
355 *
356 * @uses wp_add_dashboard_widget() To add the dashboard widget
357 */
358 public static function dashboard_widget_right_now() {
359 wp_add_dashboard_widget( 'bbp-dashboard-right-now', __( 'Right Now in Forums', 'bbpress' ), 'bbp_dashboard_widget_right_now' );
360 }
361
362 /**
363 * Add some general styling to the admin area
364 *
365 * @since bbPress (r2464)
366 *
367 * @uses bbp_get_forum_post_type() To get the forum post type
368 * @uses bbp_get_topic_post_type() To get the topic post type
369 * @uses bbp_get_reply_post_type() To get the reply post type
370 * @uses sanitize_html_class() To sanitize the classes
371 */
372 public function admin_head() {
373
374 // Remove the individual recount and converter menus.
375 // They are grouped together by h2 tabs
376 remove_submenu_page( 'tools.php', 'bbp-repair' );
377 remove_submenu_page( 'tools.php', 'bbp-converter' );
378 remove_submenu_page( 'tools.php', 'bbp-reset' );
379
380 // The /wp-admin/images/ folder
381 $wp_admin_url = admin_url( 'images/' );
382
383 // Icons for top level admin menus
384 $version = bbp_get_version();
385 $menu_icon_url = $this->images_url . 'menu.png?ver=' . $version;
386 $icon32_url = $this->images_url . 'icons32.png?ver=' . $version;
387 $menu_icon_url_2x = $this->images_url . 'menu-2x.png?ver=' . $version;
388 $icon32_url_2x = $this->images_url . 'icons32-2x.png?ver=' . $version;
389
390 // Top level menu classes
391 $forum_class = sanitize_html_class( bbp_get_forum_post_type() );
392 $topic_class = sanitize_html_class( bbp_get_topic_post_type() );
393 $reply_class = sanitize_html_class( bbp_get_reply_post_type() ); ?>
394
395 <style type="text/css" media="screen">
396 /*<![CDATA[*/
397
398 #bbp-dashboard-right-now p.sub,
399 #bbp-dashboard-right-now .table,
400 #bbp-dashboard-right-now .versions {
401 margin: -12px;
402 }
403
404 #bbp-dashboard-right-now .inside {
405 font-size: 12px;
406 padding-top: 20px;
407 margin-bottom: 0;
408 }
409
410 #bbp-dashboard-right-now p.sub {
411 padding: 5px 0 15px;
412 color: #8f8f8f;
413 font-size: 14px;
414 position: absolute;
415 top: -17px;
416 left: 15px;
417 }
418 body.rtl #bbp-dashboard-right-now p.sub {
419 right: 15px;
420 left: 0;
421 }
422
423 #bbp-dashboard-right-now .table {
424 margin: 0;
425 padding: 0;
426 position: relative;
427 }
428
429 #bbp-dashboard-right-now .table_content {
430 float: left;
431 border-top: #ececec 1px solid;
432 width: 45%;
433 }
434 body.rtl #bbp-dashboard-right-now .table_content {
435 float: right;
436 }
437
438 #bbp-dashboard-right-now .table_discussion {
439 float: right;
440 border-top: #ececec 1px solid;
441 width: 45%;
442 }
443 body.rtl #bbp-dashboard-right-now .table_discussion {
444 float: left;
445 }
446
447 #bbp-dashboard-right-now table td {
448 padding: 3px 0;
449 white-space: nowrap;
450 }
451
452 #bbp-dashboard-right-now table tr.first td {
453 border-top: none;
454 }
455
456 #bbp-dashboard-right-now td.b {
457 padding-right: 6px;
458 text-align: right;
459 font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
460 font-size: 14px;
461 width: 1%;
462 }
463 body.rtl #bbp-dashboard-right-now td.b {
464 padding-left: 6px;
465 padding-right: 0;
466 }
467
468 #bbp-dashboard-right-now td.b a {
469 font-size: 18px;
470 }
471
472 #bbp-dashboard-right-now td.b a:hover {
473 color: #d54e21;
474 }
475
476 #bbp-dashboard-right-now .t {
477 font-size: 12px;
478 padding-right: 12px;
479 padding-top: 6px;
480 color: #777;
481 }
482 body.rtl #bbp-dashboard-right-now .t {
483 padding-left: 12px;
484 padding-right: 0;
485 }
486
487 #bbp-dashboard-right-now .t a {
488 white-space: nowrap;
489 }
490
491 #bbp-dashboard-right-now .spam {
492 color: red;
493 }
494
495 #bbp-dashboard-right-now .waiting {
496 color: #e66f00;
497 }
498
499 #bbp-dashboard-right-now .approved {
500 color: green;
501 }
502
503 #bbp-dashboard-right-now .versions {
504 padding: 6px 10px 12px;
505 clear: both;
506 }
507
508 #bbp-dashboard-right-now .versions .b {
509 font-weight: bold;
510 }
511
512 #bbp-dashboard-right-now a.button {
513 float: right;
514 clear: right;
515 position: relative;
516 top: -5px;
517 }
518 body.rtl #bbp-dashboard-right-now a.button {
519 float: left;
520 clear: left;
521 }
522
523 /* Icon 32 */
524 #icon-edit.icon32-posts-<?php echo $forum_class; ?>,
525 #icon-edit.icon32-posts-<?php echo $topic_class; ?>,
526 #icon-edit.icon32-posts-<?php echo $reply_class; ?> {
527 background: url('<?php echo $icon32_url; ?>');
528 background-repeat: no-repeat;
529 }
530
531 /* Icon Positions */
532 #icon-edit.icon32-posts-<?php echo $forum_class; ?> {
533 background-position: -4px 0px;
534 }
535
536 #icon-edit.icon32-posts-<?php echo $topic_class; ?> {
537 background-position: -4px -90px;
538 }
539
540 #icon-edit.icon32-posts-<?php echo $reply_class; ?> {
541 background-position: -4px -180px;
542 }
543
544 /* Icon 32 2x */
545 @media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
546 #icon-edit.icon32-posts-<?php echo $forum_class; ?>,
547 #icon-edit.icon32-posts-<?php echo $topic_class; ?>,
548 #icon-edit.icon32-posts-<?php echo $reply_class; ?> {
549 background-image: url('<?php echo $icon32_url_2x; ?>');
550 background-size: 45px 255px;
551 }
552 }
553
554 /* Menu */
555 #menu-posts-<?php echo $forum_class; ?> .wp-menu-image,
556 #menu-posts-<?php echo $topic_class; ?> .wp-menu-image,
557 #menu-posts-<?php echo $reply_class; ?> .wp-menu-image,
558
559 #menu-posts-<?php echo $forum_class; ?>:hover .wp-menu-image,
560 #menu-posts-<?php echo $topic_class; ?>:hover .wp-menu-image,
561 #menu-posts-<?php echo $reply_class; ?>:hover .wp-menu-image,
562
563 #menu-posts-<?php echo $forum_class; ?>.wp-has-current-submenu .wp-menu-image,
564 #menu-posts-<?php echo $topic_class; ?>.wp-has-current-submenu .wp-menu-image,
565 #menu-posts-<?php echo $reply_class; ?>.wp-has-current-submenu .wp-menu-image {
566 background: url('<?php echo $menu_icon_url; ?>');
567 background-repeat: no-repeat;
568 }
569
570 /* Menu Positions */
571 #menu-posts-<?php echo $forum_class; ?> .wp-menu-image {
572 background-position: 0px -32px;
573 }
574 #menu-posts-<?php echo $forum_class; ?>:hover .wp-menu-image,
575 #menu-posts-<?php echo $forum_class; ?>.wp-has-current-submenu .wp-menu-image {
576 background-position: 0px 0px;
577 }
578 #menu-posts-<?php echo $topic_class; ?> .wp-menu-image {
579 background-position: -70px -32px;
580 }
581 #menu-posts-<?php echo $topic_class; ?>:hover .wp-menu-image,
582 #menu-posts-<?php echo $topic_class; ?>.wp-has-current-submenu .wp-menu-image {
583 background-position: -70px 0px;
584 }
585 #menu-posts-<?php echo $reply_class; ?> .wp-menu-image {
586 background-position: -35px -32px;
587 }
588 #menu-posts-<?php echo $reply_class; ?>:hover .wp-menu-image,
589 #menu-posts-<?php echo $reply_class; ?>.wp-has-current-submenu .wp-menu-image {
590 background-position: -35px 0px;
591 }
592
593 /* Menu 2x */
594 @media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
595 #menu-posts-<?php echo $forum_class; ?> .wp-menu-image,
596 #menu-posts-<?php echo $topic_class; ?> .wp-menu-image,
597 #menu-posts-<?php echo $reply_class; ?> .wp-menu-image,
598
599 #menu-posts-<?php echo $forum_class; ?>:hover .wp-menu-image,
600 #menu-posts-<?php echo $topic_class; ?>:hover .wp-menu-image,
601 #menu-posts-<?php echo $reply_class; ?>:hover .wp-menu-image,
602
603 #menu-posts-<?php echo $forum_class; ?>.wp-has-current-submenu .wp-menu-image,
604 #menu-posts-<?php echo $topic_class; ?>.wp-has-current-submenu .wp-menu-image,
605 #menu-posts-<?php echo $reply_class; ?>.wp-has-current-submenu .wp-menu-image {
606 background-image: url('<?php echo $menu_icon_url_2x; ?>');
607 background-size: 100px 64px;
608 }
609 }
610
611 <?php if ( 'bbpress' == get_user_option( 'admin_color' ) ) : ?>
612
613 /* Green Scheme Images */
614
615 .post-com-count {
616 background-image: url('<?php echo $wp_admin_url; ?>bubble_bg.gif');
617 }
618
619 .button,
620 .submit input,
621 .button-secondary {
622 background-image: url('<?php echo $wp_admin_url; ?>white-grad.png');
623 }
624
625 .button:active,
626 .submit input:active,
627 .button-secondary:active {
628 background-image: url('<?php echo $wp_admin_url; ?>white-grad-active.png');
629 }
630
631 .curtime #timestamp {
632 background-image: url('<?php echo $wp_admin_url; ?>date-button.gif');
633 }
634
635 .tagchecklist span a,
636 #bulk-titles div a {
637 background-image: url('<?php echo $wp_admin_url; ?>xit.gif');
638 }
639
640 .tagchecklist span a:hover,
641 #bulk-titles div a:hover {
642 background-image: url('<?php echo $wp_admin_url; ?>xit.gif');
643 }
644 #screen-meta-links a.show-settings {
645 background-image: url('<?php echo $wp_admin_url; ?>arrows.png');
646 }
647
648 #screen-meta-links a.show-settings.screen-meta-active {
649 background-image: url('<?php echo $wp_admin_url; ?>arrows.png');
650 }
651
652 #adminmenushadow,
653 #adminmenuback {
654 background-image: url('<?php echo $wp_admin_url; ?>menu-shadow.png');
655 }
656
657 #adminmenu li.wp-has-current-submenu.wp-menu-open .wp-menu-toggle,
658 #adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle {
659 background-image: url('<?php echo $wp_admin_url; ?>arrows-dark.png');
660 }
661
662 #adminmenu .wp-has-submenu:hover .wp-menu-toggle,
663 #adminmenu .wp-menu-open .wp-menu-toggle {
664 background-image: url('<?php echo $wp_admin_url; ?>arrows.png');
665 }
666
667 #collapse-button div {
668 background-image: url('<?php echo $wp_admin_url; ?>arrows.png');
669 }
670
671 /* menu and screen icons */
672 .icon16.icon-dashboard,
673 #adminmenu .menu-icon-dashboard div.wp-menu-image {
674 background-image: url('<?php echo $wp_admin_url; ?>menu.png?ver=20100531');
675 }
676
677 #adminmenu .menu-icon-dashboard:hover div.wp-menu-image,
678 #adminmenu .menu-icon-dashboard.wp-has-current-submenu div.wp-menu-image,
679 #adminmenu .menu-icon-dashboard.current div.wp-menu-image {
680 background-image: url('<?php echo $wp_admin_url; ?>menu.png?ver=20100531');
681 }
682
683 .icon16.icon-post,
684 #adminmenu .menu-icon-post div.wp-menu-image {
685 background-image: url('<?php echo $wp_admin_url; ?>menu.png?ver=20100531');
686 }
687
688 #adminmenu .menu-icon-post:hover div.wp-menu-image,
689 #adminmenu .menu-icon-post.wp-has-current-submenu div.wp-menu-image {
690 background-image: url('<?php echo $wp_admin_url; ?>menu.png?ver=20100531');
691 }
692
693 .icon16.icon-media,
694 #adminmenu .menu-icon-media div.wp-menu-image {
695 background-image: url('<?php echo $wp_admin_url; ?>menu.png?ver=20100531');
696 }
697
698 #adminmenu .menu-icon-media:hover div.wp-menu-image,
699 #adminmenu .menu-icon-media.wp-has-current-submenu div.wp-menu-image {
700 background-image: url('<?php echo $wp_admin_url; ?>menu.png?ver=20100531');
701 }
702
703 .icon16.icon-links,
704 #adminmenu .menu-icon-links div.wp-menu-image {
705 background-image: url('<?php echo $wp_admin_url; ?>menu.png?ver=20100531');
706 }
707
708 #adminmenu .menu-icon-links:hover div.wp-menu-image,
709 #adminmenu .menu-icon-links.wp-has-current-submenu div.wp-menu-image {
710 background-image: url('<?php echo $wp_admin_url; ?>menu.png?ver=20100531');
711 }
712
713 .icon16.icon-page,
714 #adminmenu .menu-icon-page div.wp-menu-image {
715 background-image: url('<?php echo $wp_admin_url; ?>menu.png?ver=20100531');
716 }
717
718 #adminmenu .menu-icon-page:hover div.wp-menu-image,
719 #adminmenu .menu-icon-page.wp-has-current-submenu div.wp-menu-image {
720 background-image: url('<?php echo $wp_admin_url; ?>menu.png?ver=20100531');
721 }
722
723 .icon16.icon-comments,
724 #adminmenu .menu-icon-comments div.wp-menu-image {
725 background-image: url('<?php echo $wp_admin_url; ?>menu.png?ver=20100531');
726 }
727
728 #adminmenu .menu-icon-comments:hover div.wp-menu-image,
729 #adminmenu .menu-icon-comments.wp-has-current-submenu div.wp-menu-image,
730 #adminmenu .menu-icon-comments.current div.wp-menu-image {
731 background-image: url('<?php echo $wp_admin_url; ?>menu.png?ver=20100531');
732 }
733
734 .icon16.icon-appearance,
735 #adminmenu .menu-icon-appearance div.wp-menu-image {
736 background-image: url('<?php echo $wp_admin_url; ?>menu.png?ver=20100531');
737 }
738
739 #adminmenu .menu-icon-appearance:hover div.wp-menu-image,
740 #adminmenu .menu-icon-appearance.wp-has-current-submenu div.wp-menu-image {
741 background-image: url('<?php echo $wp_admin_url; ?>menu.png?ver=20100531');
742 }
743
744 .icon16.icon-plugins,
745 #adminmenu .menu-icon-plugins div.wp-menu-image {
746 background-image: url('<?php echo $wp_admin_url; ?>menu.png?ver=20100531');
747 }
748
749 #adminmenu .menu-icon-plugins:hover div.wp-menu-image,
750 #adminmenu .menu-icon-plugins.wp-has-current-submenu div.wp-menu-image {
751 background-image: url('<?php echo $wp_admin_url; ?>menu.png?ver=20100531');
752 }
753
754 .icon16.icon-users,
755 #adminmenu .menu-icon-users div.wp-menu-image {
756 background-image: url('<?php echo $wp_admin_url; ?>menu.png?ver=20100531');
757 }
758
759 #adminmenu .menu-icon-users:hover div.wp-menu-image,
760 #adminmenu .menu-icon-users.wp-has-current-submenu div.wp-menu-image,
761 #adminmenu .menu-icon-users.current div.wp-menu-image {
762 background-image: url('<?php echo $wp_admin_url; ?>menu.png?ver=20100531');
763 }
764
765 .icon16.icon-tools,
766 #adminmenu .menu-icon-tools div.wp-menu-image {
767 background-image: url('<?php echo $wp_admin_url; ?>menu.png?ver=20100531');
768 }
769
770 #adminmenu .menu-icon-tools:hover div.wp-menu-image,
771 #adminmenu .menu-icon-tools.wp-has-current-submenu div.wp-menu-image,
772 #adminmenu .menu-icon-tools.current div.wp-menu-image {
773 background-image: url('<?php echo $wp_admin_url; ?>menu.png?ver=20100531');
774 }
775
776 .icon16.icon-settings,
777 #adminmenu .menu-icon-settings div.wp-menu-image {
778 background-image: url('<?php echo $wp_admin_url; ?>menu.png?ver=20100531');
779 }
780
781 #adminmenu .menu-icon-settings:hover div.wp-menu-image,
782 #adminmenu .menu-icon-settings.wp-has-current-submenu div.wp-menu-image {
783 background-image: url('<?php echo $wp_admin_url; ?>menu.png?ver=20100531');
784 }
785
786 .icon16.icon-site,
787 #adminmenu .menu-icon-site div.wp-menu-image {
788 background-image: url('<?php echo $wp_admin_url; ?>menu.png?ver=20100531');
789 }
790
791 #adminmenu .menu-icon-site:hover div.wp-menu-image,
792 #adminmenu .menu-icon-site.wp-has-current-submenu div.wp-menu-image {
793 background-image: url('<?php echo $wp_admin_url; ?>menu.png?ver=20100531');
794 }
795 /* end menu and screen icons */
796
797 /* Screen Icons */
798 .icon32.icon-post,
799 #icon-edit,
800 #icon-post {
801 background-image: url('<?php echo $wp_admin_url; ?>icons32.png?ver=20100531');
802 }
803
804 .icon32.icon-dashboard,
805 #icon-index {
806 background-image: url('<?php echo $wp_admin_url; ?>icons32.png?ver=20100531');
807 }
808
809 .icon32.icon-media,
810 #icon-upload {
811 background-image: url('<?php echo $wp_admin_url; ?>icons32.png?ver=20100531');
812 }
813
814 .icon32.icon-links,
815 #icon-link-manager,
816 #icon-link,
817 #icon-link-category {
818 background-image: url('<?php echo $wp_admin_url; ?>icons32.png?ver=20100531');
819 }
820
821 .icon32.icon-page,
822 #icon-edit-pages,
823 #icon-page {
824 background-image: url('<?php echo $wp_admin_url; ?>icons32.png?ver=20100531');
825 }
826
827 .icon32.icon-comments,
828 #icon-edit-comments {
829 background-image: url('<?php echo $wp_admin_url; ?>icons32.png?ver=20100531');
830 }
831
832 .icon32.icon-appearance,
833 #icon-themes {
834 background-image: url('<?php echo $wp_admin_url; ?>icons32.png?ver=20100531');
835 }
836
837 .icon32.icon-plugins,
838 #icon-plugins {
839 background-image: url('<?php echo $wp_admin_url; ?>icons32.png?ver=20100531');
840 }
841
842 .icon32.icon-users,
843 #icon-users,
844 #icon-profile,
845 #icon-user-edit {
846 background-image: url('<?php echo $wp_admin_url; ?>icons32.png?ver=20100531');
847 }
848
849 .icon32.icon-tools,
850 #icon-tools,
851 #icon-admin {
852 background-image: url('<?php echo $wp_admin_url; ?>icons32.png?ver=20100531');
853 }
854
855 .icon32.icon-settings,
856 #icon-options-general {
857 background-image: url('<?php echo $wp_admin_url; ?>icons32.png?ver=20100531');
858 }
859
860 .icon32.icon-site,
861 #icon-ms-admin {
862 background-image: url('<?php echo $wp_admin_url; ?>icons32.png?ver=20100531');
863 }
864 /* end screen icons */
865
866 .meta-box-sortables .postbox:hover .handlediv {
867 background-image: url('<?php echo $wp_admin_url; ?>arrows.png');
868 }
869
870 .tablenav .tablenav-pages a {
871 background-image: url('<?php echo $wp_admin_url; ?>menu-bits.gif?ver=20100610');
872 }
873
874 .view-switch #view-switch-list {
875 background-image: url('<?php echo $wp_admin_url; ?>list.png');
876 }
877
878 .view-switch .current #view-switch-list {
879 background-image: url('<?php echo $wp_admin_url; ?>list.png');
880 }
881
882 .view-switch #view-switch-excerpt {
883 background-image: url('<?php echo $wp_admin_url; ?>list.png');
884 }
885
886 .view-switch .current #view-switch-excerpt {
887 background-image: url('<?php echo $wp_admin_url; ?>list.png');
888 }
889
890 #header-logo {
891 background-image: url('<?php echo $wp_admin_url; ?>wp-logo.png?ver=20110504');
892 }
893
894 .sidebar-name-arrow {
895 background-image: url('<?php echo $wp_admin_url; ?>arrows.png');
896 }
897
898 .sidebar-name:hover .sidebar-name-arrow {
899 background-image: url('<?php echo $wp_admin_url; ?>arrows-dark.png');
900 }
901
902 .item-edit {
903 background-image: url('<?php echo $wp_admin_url; ?>arrows.png');
904 }
905
906 .item-edit:hover {
907 background-image: url('<?php echo $wp_admin_url; ?>arrows-dark.png');
908 }
909
910 .wp-badge {
911 background-image: url('<?php echo $wp_admin_url; ?>wp-badge.png');
912 background-image: url('<?php echo $wp_admin_url; ?>wp-badge.png'), -ms-linear-gradient(top, #378aac, #165d84); /* IE10 */
913 background-image: url('<?php echo $wp_admin_url; ?>wp-badge.png'), -moz-linear-gradient(top, #378aac, #165d84); /* Firefox */
914 background-image: url('<?php echo $wp_admin_url; ?>wp-badge.png'), -o-linear-gradient(top, #378aac, #165d84); /* Opera */
915 background-image: url('<?php echo $wp_admin_url; ?>wp-badge.png'), -webkit-gradient(linear, left top, left bottom, from(#378aac), to(#165d84)); /* old Webkit */
916 background-image: url('<?php echo $wp_admin_url; ?>wp-badge.png'), -webkit-linear-gradient(top, #378aac, #165d84); /* new Webkit */
917 background-image: url('<?php echo $wp_admin_url; ?>wp-badge.png'), linear-gradient(top, #378aac, #165d84); /* proposed W3C Markup */
918 }
919
920 .rtl .post-com-count {
921 background-image: url('<?php echo $wp_admin_url; ?>bubble_bg-rtl.gif');
922 }
923
924 /* Menu */
925 .rtl #adminmenushadow,
926 .rtl #adminmenuback {
927 background-image: url('<?php echo $wp_admin_url; ?>menu-shadow-rtl.png');
928 }
929
930 .rtl #adminmenu li.wp-has-current-submenu.wp-menu-open .wp-menu-toggle,
931 .rtl #adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle {
932 background-image: url('<?php echo $wp_admin_url; ?>arrows-dark.png');
933 }
934
935 .rtl #adminmenu .wp-has-submenu:hover .wp-menu-toggle,
936 .rtl #adminmenu .wp-menu-open .wp-menu-toggle {
937 background-image: url('<?php echo $wp_admin_url; ?>arrows.png');
938 }
939
940 .rtl .meta-box-sortables .postbox:hover .handlediv {
941 background-image: url('<?php echo $wp_admin_url; ?>arrows.png');
942 }
943
944 .rtl .tablenav .tablenav-pages a {
945 background-image: url('<?php echo $wp_admin_url; ?>menu-bits-rtl.gif?ver=20100610');
946 }
947
948 .rtl .sidebar-name-arrow {
949 background-image: url('<?php echo $wp_admin_url; ?>arrows.png');
950 }
951
952 .rtl .sidebar-name:hover .sidebar-name-arrow {
953 background-image: url('<?php echo $wp_admin_url; ?>arrows-dark.png');
954 }
955
956 @media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
957 .icon32.icon-post,
958 #icon-edit,
959 #icon-post,
960 .icon32.icon-dashboard,
961 #icon-index,
962 .icon32.icon-media,
963 #icon-upload,
964 .icon32.icon-links,
965 #icon-link-manager,
966 #icon-link,
967 #icon-link-category,
968 .icon32.icon-page,
969 #icon-edit-pages,
970 #icon-page,
971 .icon32.icon-comments,
972 #icon-edit-comments,
973 .icon32.icon-appearance,
974 #icon-themes,
975 .icon32.icon-plugins,
976 #icon-plugins,
977 .icon32.icon-users,
978 #icon-users,
979 #icon-profile,
980 #icon-user-edit,
981 .icon32.icon-tools,
982 #icon-tools,
983 #icon-admin,
984 .icon32.icon-settings,
985 #icon-options-general,
986 .icon32.icon-site,
987 #icon-ms-admin {
988 background-image: url('<?php echo $wp_admin_url; ?>icons32-2x.png?ver=20120412') !important;
989 background-size: 708px 45px;
990 }
991
992 .icon16.icon-dashboard,
993 .menu-icon-dashboard div.wp-menu-image,
994 .icon16.icon-post,
995 .menu-icon-post div.wp-menu-image,
996 .icon16.icon-media,
997 .menu-icon-media div.wp-menu-image,
998 .icon16.icon-links,
999 .menu-icon-links div.wp-menu-image,
1000 .icon16.icon-page,
1001 .menu-icon-page div.wp-menu-image,
1002 .icon16.icon-comments,
1003 .menu-icon-comments div.wp-menu-image,
1004 .icon16.icon-appearance,
1005 .menu-icon-appearance div.wp-menu-image,
1006 .icon16.icon-plugins,
1007 .menu-icon-plugins div.wp-menu-image,
1008 .icon16.icon-users,
1009 .menu-icon-users div.wp-menu-image,
1010 .icon16.icon-tools,
1011 .menu-icon-tools div.wp-menu-image,
1012 .icon16.icon-settings,
1013 .menu-icon-settings div.wp-menu-image,
1014 .icon16.icon-site,
1015 .menu-icon-site div.wp-menu-image {
1016 background-image: url('<?php echo $wp_admin_url; ?>menu-2x.png?ver=20120412') !important;
1017 background-size: 390px 64px;
1018 }
1019 }
1020 <?php endif; ?>
1021
1022 /*]]>*/
1023 </style>
1024
1025 <?php
1026 }
1027
1028 /**
1029 * Registers the bbPress admin color scheme
1030 *
1031 * Because wp-content can exist outside of the WordPress root there is no
1032 * way to be certain what the relative path of the admin images is.
1033 * We are including the two most common configurations here, just in case.
1034 *
1035 * @since bbPress (r2521)
1036 *
1037 * @uses wp_admin_css_color() To register the color scheme
1038 */
1039 public function register_admin_style () {
1040 wp_admin_css_color( 'bbpress', __( 'Green', 'bbpress' ), $this->styles_url . 'admin.css', array( '#222222', '#006600', '#deece1', '#6eb469' ) );
1041 }
1042
1043 /** Updaters **************************************************************/
1044
1045 /**
1046 * Update all bbPress forums across all sites
1047 *
1048 * @since bbPress (r3689)
1049 *
1050 * @global WPDB $wpdb
1051 * @uses get_blog_option()
1052 * @uses wp_remote_get()
1053 */
1054 public static function update_screen() {
1055
1056 // Get action
1057 $action = isset( $_GET['action'] ) ? $_GET['action'] : ''; ?>
1058
1059 <div class="wrap">
1060 <div id="icon-edit" class="icon32 icon32-posts-topic"><br /></div>
1061 <h2><?php _e( 'Update Forum', 'bbpress' ); ?></h2>
1062
1063 <?php
1064
1065 // Taking action
1066 switch ( $action ) {
1067 case 'bbpress-update' :
1068
1069 // @todo more update stuff here, evaluate performance
1070
1071 // Remove roles and caps
1072 bbp_remove_roles();
1073 bbp_remove_caps();
1074
1075 // Make sure roles, capabilities, and options exist
1076 bbp_add_roles();
1077 bbp_add_caps();
1078 bbp_add_options();
1079
1080 // Ensure any new permalinks are created
1081 flush_rewrite_rules();
1082
1083 // Ensure proper version in the DB
1084 bbp_version_bump();
1085
1086 ?>
1087
1088 <p><?php _e( 'All done!', 'bbpress' ); ?></p>
1089 <a class="button" href="index.php?page=bbpress-update"><?php _e( 'Go Back', 'bbpress' ); ?></a>
1090
1091 <?php
1092
1093 break;
1094
1095 case 'show' :
1096 default : ?>
1097
1098 <p><?php _e( 'You can update your forum through this page. Hit the link below to update.', 'bbpress' ); ?></p>
1099 <p><a class="button" href="index.php?page=bbpress-update&amp;action=bbpress-update"><?php _e( 'Update Forum', 'bbpress' ); ?></a></p>
1100
1101 <?php break;
1102
1103 } ?>
1104
1105 </div><?php
1106 }
1107
1108 /**
1109 * Update all bbPress forums across all sites
1110 *
1111 * @since bbPress (r3689)
1112 *
1113 * @global WPDB $wpdb
1114 * @uses get_blog_option()
1115 * @uses wp_remote_get()
1116 */
1117 public static function network_update_screen() {
1118 global $wpdb;
1119
1120 // Get action
1121 $action = isset( $_GET['action'] ) ? $_GET['action'] : ''; ?>
1122
1123 <div class="wrap">
1124 <div id="icon-edit" class="icon32 icon32-posts-topic"><br /></div>
1125 <h2><?php _e( 'Update Forums', 'bbpress' ); ?></h2>
1126
1127 <?php
1128
1129 // Taking action
1130 switch ( $action ) {
1131 case 'bbpress-update' :
1132
1133 // Site counter
1134 $n = isset( $_GET['n'] ) ? intval( $_GET['n'] ) : 0;
1135
1136 // Get blogs 5 at a time
1137 $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 );
1138
1139 // No blogs so all done!
1140 if ( empty( $blogs ) ) : ?>
1141
1142 <p><?php _e( 'All done!', 'bbpress' ); ?></p>
1143 <a class="button" href="update-core.php?page=bbpress-update"><?php _e( 'Go Back', 'bbpress' ); ?></a>
1144
1145 <?php break; ?>
1146
1147 <?php
1148
1149 // Still have sites to loop through
1150 else : ?>
1151
1152 <ul>
1153
1154 <?php foreach ( (array) $blogs as $details ) :
1155
1156 $siteurl = get_blog_option( $details['blog_id'], 'siteurl' ); ?>
1157
1158 <li><?php echo $siteurl; ?></li>
1159
1160 <?php
1161
1162 // Get the response of the bbPress update on this site
1163 $response = wp_remote_get(
1164 trailingslashit( $siteurl ) . 'wp-admin/index.php?page=bbpress-update&step=bbpress-update',
1165 array( 'timeout' => 120, 'httpversion' => '1.1' )
1166 );
1167
1168 // Site errored out, no response?
1169 if ( is_wp_error( $response ) )
1170 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() ) );
1171
1172 // Do some actions to allow plugins to do things too
1173 do_action( 'after_bbpress_upgrade', $response );
1174 do_action( 'bbp_upgrade_site', $details[ 'blog_id' ] );
1175
1176 endforeach; ?>
1177
1178 </ul>
1179
1180 <p>
1181 <?php _e( 'If your browser doesn&#8217;t start loading the next page automatically, click this link:', 'bbpress' ); ?>
1182 <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>
1183 </p>
1184 <script type='text/javascript'>
1185 <!--
1186 function nextpage() {
1187 location.href = 'update-core.php?page=bbpress-update&action=bbpress-update&n=<?php echo ( $n + 5 ) ?>';
1188 }
1189 setTimeout( 'nextpage()', 250 );
1190 //-->
1191 </script><?php
1192
1193 endif;
1194
1195 break;
1196
1197 case 'show' :
1198 default : ?>
1199
1200 <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>
1201 <p><a class="button" href="update-core.php?page=bbpress-update&amp;action=bbpress-update"><?php _e( 'Update Forums', 'bbpress' ); ?></a></p>
1202
1203 <?php break;
1204
1205 } ?>
1206
1207 </div><?php
1208 }
1209 }
1210 endif; // class_exists check
1211
1212 /**
1213 * Setup bbPress Admin
1214 *
1215 * @since bbPress (r2596)
1216 *
1217 * @uses BBP_Admin
1218 */
1219 function bbp_admin() {
1220 bbpress()->admin = new BBP_Admin();
1221
1222 bbpress()->admin->converter = new BBP_Converter();
1223 }
1224