| 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 |
* @todo Put fields into multidimensional array |
| 270 |
*/ |
| 271 |
public static function register_admin_settings() { |
| 272 |
|
| 273 |
// Bail if no sections available |
| 274 |
if ( ! $sections = bbp_admin_get_settings_sections() ) |
| 275 |
return false; |
| 276 |
|
| 277 |
// Loop through sections |
| 278 |
foreach ( $sections as $section_id => $section ) { |
| 279 |
|
| 280 |
// Only proceed if current user can see this section |
| 281 |
if ( ! bbp_current_user_can_see( $section_id ) ) |
| 282 |
continue; |
| 283 |
|
| 284 |
// Only add section and fields if section has fields |
| 285 |
if ( $fields = bbp_admin_get_settings_fields_for_section( $section_id ) ) { |
| 286 |
|
| 287 |
// Add the section |
| 288 |
add_settings_section( $section_id, $section['title'], $section['callback'], $section['page'] ); |
| 289 |
|
| 290 |
// Loop through fields for this section |
| 291 |
foreach ( $fields as $field_id => $field ) { |
| 292 |
|
| 293 |
// Add the field |
| 294 |
add_settings_field( $field_id, $field['title'], $field['callback'], $field['page'], $section_id, $field['args'] ); |
| 295 |
|
| 296 |
// Register the setting |
| 297 |
register_setting( $section_id, $field_id, $field['sanitize_callback'] ); |
| 298 |
} |
| 299 |
} |
| 300 |
} |
| 301 |
} |
| 302 |
|
| 303 |
/** |
| 304 |
* Register the importers |
| 305 |
* |
| 306 |
* @since bbPress (r2737) |
| 307 |
* |
| 308 |
* @uses apply_filters() Calls 'bbp_importer_path' filter to allow plugins |
| 309 |
* to customize the importer script locations. |
| 310 |
*/ |
| 311 |
public function register_importers() { |
| 312 |
|
| 313 |
// Leave if we're not in the import section |
| 314 |
if ( !defined( 'WP_LOAD_IMPORTERS' ) ) |
| 315 |
return; |
| 316 |
|
| 317 |
// Load Importer API |
| 318 |
require_once( ABSPATH . 'wp-admin/includes/import.php' ); |
| 319 |
|
| 320 |
// Load our importers |
| 321 |
$importers = apply_filters( 'bbp_importers', array( 'bbpress' ) ); |
| 322 |
|
| 323 |
// Loop through included importers |
| 324 |
foreach ( $importers as $importer ) { |
| 325 |
|
| 326 |
// Allow custom importer directory |
| 327 |
$import_dir = apply_filters( 'bbp_importer_path', $this->admin_dir . 'importers', $importer ); |
| 328 |
|
| 329 |
// Compile the importer path |
| 330 |
$import_file = trailingslashit( $import_dir ) . $importer . '.php'; |
| 331 |
|
| 332 |
// If the file exists, include it |
| 333 |
if ( file_exists( $import_file ) ) { |
| 334 |
require( $import_file ); |
| 335 |
} |
| 336 |
} |
| 337 |
} |
| 338 |
|
| 339 |
/** |
| 340 |
* Admin area activation notice |
| 341 |
* |
| 342 |
* Shows a nag message in admin area about the theme not supporting bbPress |
| 343 |
* |
| 344 |
* @since bbPress (r2743) |
| 345 |
* |
| 346 |
* @uses current_user_can() To check notice should be displayed. |
| 347 |
*/ |
| 348 |
public function activation_notice() { |
| 349 |
// @todo - something fun |
| 350 |
} |
| 351 |
|
| 352 |
/** |
| 353 |
* Add Settings link to plugins area |
| 354 |
* |
| 355 |
* @since bbPress (r2737) |
| 356 |
* |
| 357 |
* @param array $links Links array in which we would prepend our link |
| 358 |
* @param string $file Current plugin basename |
| 359 |
* @return array Processed links |
| 360 |
*/ |
| 361 |
public static function add_settings_link( $links, $file ) { |
| 362 |
|
| 363 |
if ( plugin_basename( bbpress()->file ) == $file ) { |
| 364 |
$settings_link = '<a href="' . add_query_arg( array( 'page' => 'bbpress' ), admin_url( 'options-general.php' ) ) . '">' . __( 'Settings', 'bbpress' ) . '</a>'; |
| 365 |
array_unshift( $links, $settings_link ); |
| 366 |
} |
| 367 |
|
| 368 |
return $links; |
| 369 |
} |
| 370 |
|
| 371 |
/** |
| 372 |
* Add the 'Right now in Forums' dashboard widget |
| 373 |
* |
| 374 |
* @since bbPress (r2770) |
| 375 |
* |
| 376 |
* @uses wp_add_dashboard_widget() To add the dashboard widget |
| 377 |
*/ |
| 378 |
public static function dashboard_widget_right_now() { |
| 379 |
wp_add_dashboard_widget( 'bbp-dashboard-right-now', __( 'Right Now in Forums', 'bbpress' ), 'bbp_dashboard_widget_right_now' ); |
| 380 |
} |
| 381 |
|
| 382 |
/** |
| 383 |
* Add some general styling to the admin area |
| 384 |
* |
| 385 |
* @since bbPress (r2464) |
| 386 |
* |
| 387 |
* @uses bbp_get_forum_post_type() To get the forum post type |
| 388 |
* @uses bbp_get_topic_post_type() To get the topic post type |
| 389 |
* @uses bbp_get_reply_post_type() To get the reply post type |
| 390 |
* @uses sanitize_html_class() To sanitize the classes |
| 391 |
*/ |
| 392 |
public function admin_head() { |
| 393 |
|
| 394 |
// Remove the individual recount and converter menus. |
| 395 |
// They are grouped together by h2 tabs |
| 396 |
remove_submenu_page( 'tools.php', 'bbp-repair' ); |
| 397 |
remove_submenu_page( 'tools.php', 'bbp-converter' ); |
| 398 |
remove_submenu_page( 'tools.php', 'bbp-reset' ); |
| 399 |
|
| 400 |
// Icons for top level admin menus |
| 401 |
$version = bbp_get_version(); |
| 402 |
$menu_icon_url = $this->images_url . 'menu.png?ver=' . $version; |
| 403 |
$icon32_url = $this->images_url . 'icons32.png?ver=' . $version; |
| 404 |
$menu_icon_url_2x = $this->images_url . 'menu-2x.png?ver=' . $version; |
| 405 |
$icon32_url_2x = $this->images_url . 'icons32-2x.png?ver=' . $version; |
| 406 |
|
| 407 |
// Top level menu classes |
| 408 |
$forum_class = sanitize_html_class( bbp_get_forum_post_type() ); |
| 409 |
$topic_class = sanitize_html_class( bbp_get_topic_post_type() ); |
| 410 |
$reply_class = sanitize_html_class( bbp_get_reply_post_type() ); ?> |
| 411 |
|
| 412 |
<style type="text/css" media="screen"> |
| 413 |
/*<![CDATA[*/ |
| 414 |
|
| 415 |
#bbp-dashboard-right-now p.sub, |
| 416 |
#bbp-dashboard-right-now .table, |
| 417 |
#bbp-dashboard-right-now .versions { |
| 418 |
margin: -12px; |
| 419 |
} |
| 420 |
|
| 421 |
#bbp-dashboard-right-now .inside { |
| 422 |
font-size: 12px; |
| 423 |
padding-top: 20px; |
| 424 |
margin-bottom: 0; |
| 425 |
} |
| 426 |
|
| 427 |
#bbp-dashboard-right-now p.sub { |
| 428 |
padding: 5px 0 15px; |
| 429 |
color: #8f8f8f; |
| 430 |
font-size: 14px; |
| 431 |
position: absolute; |
| 432 |
top: -17px; |
| 433 |
left: 15px; |
| 434 |
} |
| 435 |
body.rtl #bbp-dashboard-right-now p.sub { |
| 436 |
right: 15px; |
| 437 |
left: 0; |
| 438 |
} |
| 439 |
|
| 440 |
#bbp-dashboard-right-now .table { |
| 441 |
margin: 0; |
| 442 |
padding: 0; |
| 443 |
position: relative; |
| 444 |
} |
| 445 |
|
| 446 |
#bbp-dashboard-right-now .table_content { |
| 447 |
float: left; |
| 448 |
border-top: #ececec 1px solid; |
| 449 |
width: 45%; |
| 450 |
} |
| 451 |
body.rtl #bbp-dashboard-right-now .table_content { |
| 452 |
float: right; |
| 453 |
} |
| 454 |
|
| 455 |
#bbp-dashboard-right-now .table_discussion { |
| 456 |
float: right; |
| 457 |
border-top: #ececec 1px solid; |
| 458 |
width: 45%; |
| 459 |
} |
| 460 |
body.rtl #bbp-dashboard-right-now .table_discussion { |
| 461 |
float: left; |
| 462 |
} |
| 463 |
|
| 464 |
#bbp-dashboard-right-now table td { |
| 465 |
padding: 3px 0; |
| 466 |
white-space: nowrap; |
| 467 |
} |
| 468 |
|
| 469 |
#bbp-dashboard-right-now table tr.first td { |
| 470 |
border-top: none; |
| 471 |
} |
| 472 |
|
| 473 |
#bbp-dashboard-right-now td.b { |
| 474 |
padding-right: 6px; |
| 475 |
text-align: right; |
| 476 |
font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif; |
| 477 |
font-size: 14px; |
| 478 |
width: 1%; |
| 479 |
} |
| 480 |
body.rtl #bbp-dashboard-right-now td.b { |
| 481 |
padding-left: 6px; |
| 482 |
padding-right: 0; |
| 483 |
} |
| 484 |
|
| 485 |
#bbp-dashboard-right-now td.b a { |
| 486 |
font-size: 18px; |
| 487 |
} |
| 488 |
|
| 489 |
#bbp-dashboard-right-now td.b a:hover { |
| 490 |
color: #d54e21; |
| 491 |
} |
| 492 |
|
| 493 |
#bbp-dashboard-right-now .t { |
| 494 |
font-size: 12px; |
| 495 |
padding-right: 12px; |
| 496 |
padding-top: 6px; |
| 497 |
color: #777; |
| 498 |
} |
| 499 |
body.rtl #bbp-dashboard-right-now .t { |
| 500 |
padding-left: 12px; |
| 501 |
padding-right: 0; |
| 502 |
} |
| 503 |
|
| 504 |
#bbp-dashboard-right-now .t a { |
| 505 |
white-space: nowrap; |
| 506 |
} |
| 507 |
|
| 508 |
#bbp-dashboard-right-now .spam { |
| 509 |
color: red; |
| 510 |
} |
| 511 |
|
| 512 |
#bbp-dashboard-right-now .waiting { |
| 513 |
color: #e66f00; |
| 514 |
} |
| 515 |
|
| 516 |
#bbp-dashboard-right-now .approved { |
| 517 |
color: green; |
| 518 |
} |
| 519 |
|
| 520 |
#bbp-dashboard-right-now .versions { |
| 521 |
padding: 6px 10px 12px; |
| 522 |
clear: both; |
| 523 |
} |
| 524 |
|
| 525 |
#bbp-dashboard-right-now .versions .b { |
| 526 |
font-weight: bold; |
| 527 |
} |
| 528 |
|
| 529 |
#bbp-dashboard-right-now a.button { |
| 530 |
float: right; |
| 531 |
clear: right; |
| 532 |
position: relative; |
| 533 |
top: -5px; |
| 534 |
} |
| 535 |
body.rtl #bbp-dashboard-right-now a.button { |
| 536 |
float: left; |
| 537 |
clear: left; |
| 538 |
} |
| 539 |
|
| 540 |
/* Icon 32 */ |
| 541 |
#icon-edit.icon32-posts-<?php echo $forum_class; ?> { |
| 542 |
background: url('<?php echo $icon32_url; ?>') no-repeat -4px 0px; |
| 543 |
} |
| 544 |
|
| 545 |
#icon-edit.icon32-posts-<?php echo $topic_class; ?> { |
| 546 |
background: url('<?php echo $icon32_url; ?>') no-repeat -4px -90px; |
| 547 |
} |
| 548 |
|
| 549 |
#icon-edit.icon32-posts-<?php echo $reply_class; ?> { |
| 550 |
background: url('<?php echo $icon32_url; ?>') no-repeat -4px -180px; |
| 551 |
} |
| 552 |
|
| 553 |
/* Menu */ |
| 554 |
#menu-posts-<?php echo $forum_class; ?> .wp-menu-image, |
| 555 |
#menu-posts-<?php echo $topic_class; ?> .wp-menu-image, |
| 556 |
#menu-posts-<?php echo $reply_class; ?> .wp-menu-image, |
| 557 |
|
| 558 |
#menu-posts-<?php echo $forum_class; ?>:hover .wp-menu-image, |
| 559 |
#menu-posts-<?php echo $topic_class; ?>:hover .wp-menu-image, |
| 560 |
#menu-posts-<?php echo $reply_class; ?>:hover .wp-menu-image, |
| 561 |
|
| 562 |
#menu-posts-<?php echo $forum_class; ?>.wp-has-current-submenu .wp-menu-image, |
| 563 |
#menu-posts-<?php echo $topic_class; ?>.wp-has-current-submenu .wp-menu-image, |
| 564 |
#menu-posts-<?php echo $reply_class; ?>.wp-has-current-submenu .wp-menu-image { |
| 565 |
background: url('<?php echo $menu_icon_url; ?>'); |
| 566 |
background-repeat: no-repeat; |
| 567 |
} |
| 568 |
|
| 569 |
/* Menu Positions */ |
| 570 |
#menu-posts-<?php echo $forum_class; ?> .wp-menu-image { |
| 571 |
background-position: 0px -32px; |
| 572 |
} |
| 573 |
#menu-posts-<?php echo $forum_class; ?>:hover .wp-menu-image, |
| 574 |
#menu-posts-<?php echo $forum_class; ?>.wp-has-current-submenu .wp-menu-image { |
| 575 |
background-position: 0px 0px; |
| 576 |
} |
| 577 |
#menu-posts-<?php echo $topic_class; ?> .wp-menu-image { |
| 578 |
background-position: -70px -32px; |
| 579 |
} |
| 580 |
#menu-posts-<?php echo $topic_class; ?>:hover .wp-menu-image, |
| 581 |
#menu-posts-<?php echo $topic_class; ?>.wp-has-current-submenu .wp-menu-image { |
| 582 |
background-position: -70px 0px; |
| 583 |
} |
| 584 |
#menu-posts-<?php echo $reply_class; ?> .wp-menu-image { |
| 585 |
background-position: -35px -32px; |
| 586 |
} |
| 587 |
#menu-posts-<?php echo $reply_class; ?>:hover .wp-menu-image, |
| 588 |
#menu-posts-<?php echo $reply_class; ?>.wp-has-current-submenu .wp-menu-image { |
| 589 |
background-position: -35px 0px; |
| 590 |
} |
| 591 |
|
| 592 |
/* Menu 2x */ |
| 593 |
@media only screen and (-webkit-min-device-pixel-ratio: 1.5) { |
| 594 |
#menu-posts-<?php echo $forum_class; ?> .wp-menu-image, |
| 595 |
#menu-posts-<?php echo $topic_class; ?> .wp-menu-image, |
| 596 |
#menu-posts-<?php echo $reply_class; ?> .wp-menu-image, |
| 597 |
|
| 598 |
#menu-posts-<?php echo $forum_class; ?>:hover .wp-menu-image, |
| 599 |
#menu-posts-<?php echo $topic_class; ?>:hover .wp-menu-image, |
| 600 |
#menu-posts-<?php echo $reply_class; ?>:hover .wp-menu-image, |
| 601 |
|
| 602 |
#menu-posts-<?php echo $forum_class; ?>.wp-has-current-submenu .wp-menu-image, |
| 603 |
#menu-posts-<?php echo $topic_class; ?>.wp-has-current-submenu .wp-menu-image, |
| 604 |
#menu-posts-<?php echo $reply_class; ?>.wp-has-current-submenu .wp-menu-image { |
| 605 |
background-image: url('<?php echo $menu_icon_url_2x; ?>'); |
| 606 |
background-size: 100px 64px; |
| 607 |
} |
| 608 |
} |
| 609 |
|
| 610 |
/*]]>*/ |
| 611 |
</style> |
| 612 |
|
| 613 |
<?php |
| 614 |
} |
| 615 |
|
| 616 |
/** |
| 617 |
* Registers the bbPress admin color scheme |
| 618 |
* |
| 619 |
* Because wp-content can exist outside of the WordPress root there is no |
| 620 |
* way to be certain what the relative path of the admin images is. |
| 621 |
* We are including the two most common configurations here, just in case. |
| 622 |
* |
| 623 |
* @since bbPress (r2521) |
| 624 |
* |
| 625 |
* @uses wp_admin_css_color() To register the color scheme |
| 626 |
*/ |
| 627 |
public function register_admin_style () { |
| 628 |
|
| 629 |
// Normal wp-content dir |
| 630 |
if ( 0 === $this->content_depth ) |
| 631 |
$css_file = $this->styles_url . 'admin.css'; |
| 632 |
|
| 633 |
// Custom wp-content dir is 1 level away |
| 634 |
elseif ( 1 === $this->content_depth ) |
| 635 |
$css_file = $this->styles_url . 'admin-1.css'; |
| 636 |
|
| 637 |
// Custom wp-content dir is 1 level away |
| 638 |
elseif ( 2 === $this->content_depth ) |
| 639 |
$css_file = $this->styles_url . 'admin-2.css'; |
| 640 |
|
| 641 |
// Load the admin CSS styling |
| 642 |
wp_admin_css_color( 'bbpress', __( 'Green', 'bbpress' ), $css_file, array( '#222222', '#006600', '#deece1', '#6eb469' ) ); |
| 643 |
} |
| 644 |
|
| 645 |
/** |
| 646 |
* Update all bbPress forums across all sites |
| 647 |
* |
| 648 |
* @since bbPress (r3689) |
| 649 |
* |
| 650 |
* @global WPDB $wpdb |
| 651 |
* @uses get_blog_option() |
| 652 |
* @uses wp_remote_get() |
| 653 |
*/ |
| 654 |
public static function update_screen() { |
| 655 |
|
| 656 |
// Get action |
| 657 |
$action = isset( $_GET['action'] ) ? $_GET['action'] : ''; ?> |
| 658 |
|
| 659 |
<div class="wrap"> |
| 660 |
<div id="icon-edit" class="icon32 icon32-posts-topic"><br /></div> |
| 661 |
<h2><?php _e( 'Update Forum', 'bbpress' ); ?></h2> |
| 662 |
|
| 663 |
<?php |
| 664 |
|
| 665 |
// Taking action |
| 666 |
switch ( $action ) { |
| 667 |
case 'bbpress-update' : |
| 668 |
|
| 669 |
// @todo more update stuff here, evaluate performance |
| 670 |
|
| 671 |
// Remove roles and caps |
| 672 |
bbp_remove_roles(); |
| 673 |
bbp_remove_caps(); |
| 674 |
|
| 675 |
// Make sure roles, capabilities, and options exist |
| 676 |
bbp_add_roles(); |
| 677 |
bbp_add_caps(); |
| 678 |
bbp_add_options(); |
| 679 |
|
| 680 |
// Ensure any new permalinks are created |
| 681 |
flush_rewrite_rules(); |
| 682 |
|
| 683 |
// Ensure proper version in the DB |
| 684 |
bbp_version_bump(); |
| 685 |
|
| 686 |
?> |
| 687 |
|
| 688 |
<p><?php _e( 'All done!', 'bbpress' ); ?></p> |
| 689 |
<a class="button" href="index.php?page=bbpress-update"><?php _e( 'Go Back', 'bbpress' ); ?></a> |
| 690 |
|
| 691 |
<?php |
| 692 |
|
| 693 |
break; |
| 694 |
|
| 695 |
case 'show' : |
| 696 |
default : ?> |
| 697 |
|
| 698 |
<p><?php _e( 'You can update your forum through this page. Hit the link below to update.', 'bbpress' ); ?></p> |
| 699 |
<p><a class="button" href="index.php?page=bbpress-update&action=bbpress-update"><?php _e( 'Update Forum', 'bbpress' ); ?></a></p> |
| 700 |
|
| 701 |
<?php break; |
| 702 |
|
| 703 |
} ?> |
| 704 |
|
| 705 |
</div><?php |
| 706 |
} |
| 707 |
|
| 708 |
/** |
| 709 |
* Update all bbPress forums across all sites |
| 710 |
* |
| 711 |
* @since bbPress (r3689) |
| 712 |
* |
| 713 |
* @global WPDB $wpdb |
| 714 |
* @uses get_blog_option() |
| 715 |
* @uses wp_remote_get() |
| 716 |
*/ |
| 717 |
public static function network_update_screen() { |
| 718 |
global $wpdb; |
| 719 |
|
| 720 |
// Get action |
| 721 |
$action = isset( $_GET['action'] ) ? $_GET['action'] : ''; ?> |
| 722 |
|
| 723 |
<div class="wrap"> |
| 724 |
<div id="icon-edit" class="icon32 icon32-posts-topic"><br /></div> |
| 725 |
<h2><?php _e( 'Update Forums', 'bbpress' ); ?></h2> |
| 726 |
|
| 727 |
<?php |
| 728 |
|
| 729 |
// Taking action |
| 730 |
switch ( $action ) { |
| 731 |
case 'bbpress-update' : |
| 732 |
|
| 733 |
// Site counter |
| 734 |
$n = isset( $_GET['n'] ) ? intval( $_GET['n'] ) : 0; |
| 735 |
|
| 736 |
// Get blogs 5 at a time |
| 737 |
$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 ); |
| 738 |
|
| 739 |
// No blogs so all done! |
| 740 |
if ( empty( $blogs ) ) : ?> |
| 741 |
|
| 742 |
<p><?php _e( 'All done!', 'bbpress' ); ?></p> |
| 743 |
<a class="button" href="update-core.php?page=bbpress-update"><?php _e( 'Go Back', 'bbpress' ); ?></a> |
| 744 |
|
| 745 |
<?php break; ?> |
| 746 |
|
| 747 |
<?php |
| 748 |
|
| 749 |
// Still have sites to loop through |
| 750 |
else : ?> |
| 751 |
|
| 752 |
<ul> |
| 753 |
|
| 754 |
<?php foreach ( (array) $blogs as $details ) : |
| 755 |
|
| 756 |
$siteurl = get_blog_option( $details['blog_id'], 'siteurl' ); ?> |
| 757 |
|
| 758 |
<li><?php echo $siteurl; ?></li> |
| 759 |
|
| 760 |
<?php |
| 761 |
|
| 762 |
// Get the response of the bbPress update on this site |
| 763 |
$response = wp_remote_get( |
| 764 |
trailingslashit( $siteurl ) . 'wp-admin/index.php?page=bbpress-update&step=bbpress-update', |
| 765 |
array( 'timeout' => 120, 'httpversion' => '1.1' ) |
| 766 |
); |
| 767 |
|
| 768 |
// Site errored out, no response? |
| 769 |
if ( is_wp_error( $response ) ) |
| 770 |
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() ) ); |
| 771 |
|
| 772 |
// Do some actions to allow plugins to do things too |
| 773 |
do_action( 'after_bbpress_upgrade', $response ); |
| 774 |
do_action( 'bbp_upgrade_site', $details[ 'blog_id' ] ); |
| 775 |
|
| 776 |
endforeach; ?> |
| 777 |
|
| 778 |
</ul> |
| 779 |
|
| 780 |
<p> |
| 781 |
<?php _e( 'If your browser doesn’t start loading the next page automatically, click this link:', 'bbpress' ); ?> |
| 782 |
<a class="button" href="update-core.php?page=bbpress-update&action=bbpress-update&n=<?php echo ( $n + 5 ); ?>"><?php _e( 'Next Forums', 'bbpress' ); ?></a> |
| 783 |
</p> |
| 784 |
<script type='text/javascript'> |
| 785 |
<!-- |
| 786 |
function nextpage() { |
| 787 |
location.href = 'update-core.php?page=bbpress-update&action=bbpress-update&n=<?php echo ( $n + 5 ) ?>'; |
| 788 |
} |
| 789 |
setTimeout( 'nextpage()', 250 ); |
| 790 |
//--> |
| 791 |
</script><?php |
| 792 |
|
| 793 |
endif; |
| 794 |
|
| 795 |
break; |
| 796 |
|
| 797 |
case 'show' : |
| 798 |
default : ?> |
| 799 |
|
| 800 |
<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> |
| 801 |
<p><a class="button" href="update-core.php?page=bbpress-update&action=bbpress-update"><?php _e( 'Update Forums', 'bbpress' ); ?></a></p> |
| 802 |
|
| 803 |
<?php break; |
| 804 |
|
| 805 |
} ?> |
| 806 |
|
| 807 |
</div><?php |
| 808 |
} |
| 809 |
} |
| 810 |
endif; // class_exists check |
| 811 |
|
| 812 |
/** |
| 813 |
* Setup bbPress Admin |
| 814 |
* |
| 815 |
* @since bbPress (r2596) |
| 816 |
* |
| 817 |
* @uses BBP_Admin |
| 818 |
*/ |
| 819 |
function bbp_admin() { |
| 820 |
bbpress()->admin = new BBP_Admin(); |
| 821 |
|
| 822 |
bbpress()->admin->converter = new BBP_Converter(); |
| 823 |
} |
| 824 |
|