Changeset 10356 for trunk/src/bp-core/bp-core-admin.php
- Timestamp:
- 11/15/2015 07:57:03 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-admin.php
r10318 r10356 17 17 * @package BuddyPress 18 18 * @subpackage CoreAdministration 19 * @todo Break this apart into each applicable Component 19 * @todo Break this apart into each applicable Component. 20 20 * 21 21 * @since 1.6.0 … … 97 97 98 98 // Paths and URLs 99 $this->admin_dir = trailingslashit( $bp->plugin_dir . 'bp-core/admin' ); // Admin path 100 $this->admin_url = trailingslashit( $bp->plugin_url . 'bp-core/admin' ); // Admin url 101 $this->images_url = trailingslashit( $this->admin_url . 'images' ); // Admin images URL 102 $this->css_url = trailingslashit( $this->admin_url . 'css' ); // Admin css URL 103 $this->js_url = trailingslashit( $this->admin_url . 'js' ); // Admin css URL 104 105 // Main settings page 99 $this->admin_dir = trailingslashit( $bp->plugin_dir . 'bp-core/admin' ); // Admin path. 100 $this->admin_url = trailingslashit( $bp->plugin_url . 'bp-core/admin' ); // Admin url. 101 $this->images_url = trailingslashit( $this->admin_url . 'images' ); // Admin images URL. 102 $this->css_url = trailingslashit( $this->admin_url . 'css' ); // Admin css URL. 103 $this->js_url = trailingslashit( $this->admin_url . 'js' ); // Admin css URL. 104 105 // Main settings page. 106 106 $this->settings_page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php'; 107 107 108 // Main capability 108 // Main capability. 109 109 $this->capability = bp_core_do_network_admin() ? 'manage_network_options' : 'manage_options'; 110 110 } … … 134 134 private function setup_actions() { 135 135 136 /* *General Actions ***************************************************/137 138 // Add some page specific output to the <head> 136 /* General Actions ***************************************************/ 137 138 // Add some page specific output to the <head>. 139 139 add_action( 'bp_admin_head', array( $this, 'admin_head' ), 999 ); 140 140 141 // Add menu item to settings menu 141 // Add menu item to settings menu. 142 142 add_action( bp_core_admin_hook(), array( $this, 'admin_menus' ), 5 ); 143 143 144 // Enqueue all admin JS and CSS 144 // Enqueue all admin JS and CSS. 145 145 add_action( 'bp_admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); 146 146 147 /* *BuddyPress Actions ************************************************/148 149 // Load the BuddyPress metabox in the WP Nav Menu Admin UI 147 /* BuddyPress Actions ************************************************/ 148 149 // Load the BuddyPress metabox in the WP Nav Menu Admin UI. 150 150 add_action( 'load-nav-menus.php', 'bp_admin_wp_nav_menu_meta_box' ); 151 151 152 // Add settings 152 // Add settings. 153 153 add_action( 'bp_register_admin_settings', array( $this, 'register_admin_settings' ) ); 154 154 155 // Add a link to BuddyPress About page to the admin bar 155 // Add a link to BuddyPress About page to the admin bar. 156 156 add_action( 'admin_bar_menu', array( $this, 'admin_bar_about_link' ), 15 ); 157 157 158 // Add a description of new BuddyPress tools in the available tools page 158 // Add a description of new BuddyPress tools in the available tools page. 159 159 add_action( 'tool_box', 'bp_core_admin_available_tools_intro' ); 160 160 add_action( 'bp_network_tool_box', 'bp_core_admin_available_tools_intro' ); 161 161 162 // On non-multisite, catch 162 // On non-multisite, catch. 163 163 add_action( 'load-users.php', 'bp_core_admin_user_manage_spammers' ); 164 164 165 /* *Filters ***********************************************************/166 167 // Add link to settings page 165 /* Filters ***********************************************************/ 166 167 // Add link to settings page. 168 168 add_filter( 'plugin_action_links', array( $this, 'modify_plugin_action_links' ), 10, 2 ); 169 169 add_filter( 'network_admin_plugin_action_links', array( $this, 'modify_plugin_action_links' ), 10, 2 ); 170 170 171 // Add "Mark as Spam" row actions on users.php 171 // Add "Mark as Spam" row actions on users.php. 172 172 add_filter( 'ms_user_row_actions', 'bp_core_admin_user_row_actions', 10, 2 ); 173 173 add_filter( 'user_row_actions', 'bp_core_admin_user_row_actions', 10, 2 ); … … 185 185 public function admin_menus() { 186 186 187 // Bail if user cannot moderate 187 // Bail if user cannot moderate. 188 188 if ( ! bp_current_user_can( 'manage_options' ) ) { 189 189 return; 190 190 } 191 191 192 // About 192 // About. 193 193 add_dashboard_page( 194 194 __( 'Welcome to BuddyPress', 'buddypress' ), … … 199 199 ); 200 200 201 // Credits 201 // Credits. 202 202 add_dashboard_page( 203 203 __( 'Welcome to BuddyPress', 'buddypress' ), … … 210 210 $hooks = array(); 211 211 212 // Changed in BP 1.6 . See bp_core_admin_backpat_menu() 212 // Changed in BP 1.6 . See bp_core_admin_backpat_menu(). 213 213 $hooks[] = add_menu_page( 214 214 __( 'BuddyPress', 'buddypress' ), … … 229 229 ); 230 230 231 // Add the option pages 231 // Add the option pages. 232 232 $hooks[] = add_submenu_page( 233 233 $this->settings_page, … … 258 258 259 259 // For consistency with non-Multisite, we add a Tools menu in 260 // the Network Admin as a home for our Tools panel 260 // the Network Admin as a home for our Tools panel. 261 261 if ( is_multisite() && bp_core_do_network_admin() ) { 262 262 $tools_parent = 'network-tools'; … … 269 269 'bp_core_tools_top_level_item', 270 270 '', 271 24 // just above Settings271 24 // Just above Settings. 272 272 ); 273 273 … … 293 293 ); 294 294 295 // Fudge the highlighted subnav item when on a BuddyPress admin page 295 // Fudge the highlighted subnav item when on a BuddyPress admin page. 296 296 foreach( $hooks as $hook ) { 297 297 add_action( "admin_head-$hook", 'bp_core_modify_admin_menu_highlight' ); … … 310 310 public function register_admin_settings() { 311 311 312 /* *Main Section ******************************************************/313 314 // Add the main section 312 /* Main Section ******************************************************/ 313 314 // Add the main section. 315 315 add_settings_section( 'bp_main', __( 'Main Settings', 'buddypress' ), 'bp_admin_setting_callback_main_section', 'buddypress' ); 316 316 317 // Hide toolbar for logged out users setting 317 // Hide toolbar for logged out users setting. 318 318 add_settings_field( 'hide-loggedout-adminbar', __( 'Toolbar', 'buddypress' ), 'bp_admin_setting_callback_admin_bar', 'buddypress', 'bp_main' ); 319 319 register_setting( 'buddypress', 'hide-loggedout-adminbar', 'intval' ); 320 320 321 // Only show 'switch to Toolbar' option if the user chose to retain the BuddyBar during the 1.6 upgrade 321 // Only show 'switch to Toolbar' option if the user chose to retain the BuddyBar during the 1.6 upgrade. 322 322 if ( (bool) bp_get_option( '_bp_force_buddybar', false ) ) { 323 323 add_settings_field( '_bp_force_buddybar', __( 'Toolbar', 'buddypress' ), 'bp_admin_setting_callback_force_buddybar', 'buddypress', 'bp_main' ); … … 325 325 } 326 326 327 // Allow account deletion 327 // Allow account deletion. 328 328 add_settings_field( 'bp-disable-account-deletion', __( 'Account Deletion', 'buddypress' ), 'bp_admin_setting_callback_account_deletion', 'buddypress', 'bp_main' ); 329 329 register_setting( 'buddypress', 'bp-disable-account-deletion', 'intval' ); 330 330 331 /* *XProfile Section **************************************************/331 /* XProfile Section **************************************************/ 332 332 333 333 if ( bp_is_active( 'xprofile' ) ) { 334 334 335 // Add the main section 335 // Add the main section. 336 336 add_settings_section( 'bp_xprofile', _x( 'Profile Settings', 'BuddyPress setting tab', 'buddypress' ), 'bp_admin_setting_callback_xprofile_section', 'buddypress' ); 337 337 338 // Avatars 338 // Avatars. 339 339 add_settings_field( 'bp-disable-avatar-uploads', __( 'Profile Photo Uploads', 'buddypress' ), 'bp_admin_setting_callback_avatar_uploads', 'buddypress', 'bp_xprofile' ); 340 340 register_setting( 'buddypress', 'bp-disable-avatar-uploads', 'intval' ); 341 341 342 // Cover images 342 // Cover images. 343 343 if ( bp_is_active( 'xprofile', 'cover_image' ) ) { 344 344 add_settings_field( 'bp-disable-cover-image-uploads', __( 'Cover Image Uploads', 'buddypress' ), 'bp_admin_setting_callback_cover_image_uploads', 'buddypress', 'bp_xprofile' ); … … 346 346 } 347 347 348 // Profile sync setting 348 // Profile sync setting. 349 349 add_settings_field( 'bp-disable-profile-sync', __( 'Profile Syncing', 'buddypress' ), 'bp_admin_setting_callback_profile_sync', 'buddypress', 'bp_xprofile' ); 350 350 register_setting ( 'buddypress', 'bp-disable-profile-sync', 'intval' ); 351 351 } 352 352 353 /* *Groups Section ****************************************************/353 /* Groups Section ****************************************************/ 354 354 355 355 if ( bp_is_active( 'groups' ) ) { 356 356 357 // Add the main section 357 // Add the main section. 358 358 add_settings_section( 'bp_groups', __( 'Groups Settings', 'buddypress' ), 'bp_admin_setting_callback_groups_section', 'buddypress' ); 359 359 360 // Allow subscriptions setting 360 // Allow subscriptions setting. 361 361 add_settings_field( 'bp_restrict_group_creation', __( 'Group Creation', 'buddypress' ), 'bp_admin_setting_callback_group_creation', 'buddypress', 'bp_groups' ); 362 362 register_setting( 'buddypress', 'bp_restrict_group_creation', 'intval' ); … … 373 373 } 374 374 375 /* *Forums ************************************************************/375 /* Forums ************************************************************/ 376 376 377 377 if ( bp_is_active( 'forums' ) ) { 378 378 379 // Add the main section 379 // Add the main section. 380 380 add_settings_section( 'bp_forums', __( 'Legacy Group Forums', 'buddypress' ), 'bp_admin_setting_callback_bbpress_section', 'buddypress' ); 381 381 382 // Allow subscriptions setting 382 // Allow subscriptions setting. 383 383 add_settings_field( 'bb-config-location', __( 'bbPress Configuration', 'buddypress' ), 'bp_admin_setting_callback_bbpress_configuration', 'buddypress', 'bp_forums' ); 384 384 register_setting( 'buddypress', 'bb-config-location', '' ); 385 385 } 386 386 387 /* *Activity Section **************************************************/387 /* Activity Section **************************************************/ 388 388 389 389 if ( bp_is_active( 'activity' ) ) { 390 390 391 // Add the main section 391 // Add the main section. 392 392 add_settings_section( 'bp_activity', __( 'Activity Settings', 'buddypress' ), 'bp_admin_setting_callback_activity_section', 'buddypress' ); 393 393 394 // Activity commenting on blog and forum posts 394 // Activity commenting on blog and forum posts. 395 395 add_settings_field( 'bp-disable-blogforum-comments', __( 'Blog & Forum Comments', 'buddypress' ), 'bp_admin_setting_callback_blogforum_comments', 'buddypress', 'bp_activity' ); 396 396 register_setting( 'buddypress', 'bp-disable-blogforum-comments', 'bp_admin_sanitize_callback_blogforum_comments' ); 397 397 398 // Activity Heartbeat refresh 398 // Activity Heartbeat refresh. 399 399 add_settings_field( '_bp_enable_heartbeat_refresh', __( 'Activity auto-refresh', 'buddypress' ), 'bp_admin_setting_callback_heartbeat', 'buddypress', 'bp_activity' ); 400 400 register_setting( 'buddypress', '_bp_enable_heartbeat_refresh', 'intval' ); 401 401 402 // Allow activity akismet 402 // Allow activity akismet. 403 403 if ( is_plugin_active( 'akismet/akismet.php' ) && defined( 'AKISMET_VERSION' ) ) { 404 404 add_settings_field( '_bp_enable_akismet', __( 'Akismet', 'buddypress' ), 'bp_admin_setting_callback_activity_akismet', 'buddypress', 'bp_activity' ); … … 433 433 * @param array $links Links array in which we would prepend our link. 434 434 * @param string $file Current plugin basename. 435 *436 435 * @return array Processed links. 437 436 */ 438 437 public function modify_plugin_action_links( $links, $file ) { 439 438 440 // Return normal links if not BuddyPress 439 // Return normal links if not BuddyPress. 441 440 if ( plugin_basename( buddypress()->basename ) != $file ) { 442 441 return $links; 443 442 } 444 443 445 // Add a few links to the existing links array 444 // Add a few links to the existing links array. 446 445 return array_merge( $links, array( 447 446 'settings' => '<a href="' . esc_url( add_query_arg( array( 'page' => 'bp-components' ), bp_get_admin_url( $this->settings_page ) ) ) . '">' . esc_html__( 'Settings', 'buddypress' ) . '</a>', … … 457 456 public function admin_head() { 458 457 459 // Settings pages 458 // Settings pages. 460 459 remove_submenu_page( $this->settings_page, 'bp-page-settings' ); 461 460 remove_submenu_page( $this->settings_page, 'bp-settings' ); 462 461 463 // Network Admin Tools 462 // Network Admin Tools. 464 463 remove_submenu_page( 'network-tools', 'network-tools' ); 465 464 466 // About and Credits pages 465 // About and Credits pages. 467 466 remove_submenu_page( 'index.php', 'bp-about' ); 468 467 remove_submenu_page( 'index.php', 'bp-credits' ); … … 797 796 public static function welcome_text() { 798 797 799 // Switch welcome text based on whether this is a new installation or not 798 // Switch welcome text based on whether this is a new installation or not. 800 799 $welcome_text = ( self::is_new_install() ) 801 800 ? __( 'Thank you for installing BuddyPress! BuddyPress helps you run any kind of social network on your WordPress, with member profiles, activity streams, user groups, messaging, and more.', 'buddypress' ) … … 825 824 * 826 825 * @since 2.2.0 827 * @param string $tab 826 * 827 * @param string $tab Tab to highlight as active. 828 828 */ 829 829 public static function tab_navigation( $tab = 'whats_new' ) { … … 865 865 public static function display_version() { 866 866 867 // Use static variable to prevent recalculations 867 // Use static variable to prevent recalculations. 868 868 static $display = ''; 869 869 870 // Only calculate on first run 870 // Only calculate on first run. 871 871 if ( '' === $display ) { 872 872 873 // Get current version 873 // Get current version. 874 874 $version = bp_get_version(); 875 875 876 // Check for prerelease hyphen 876 // Check for prerelease hyphen. 877 877 $pre = strpos( $version, '-' ); 878 878 879 // Strip prerelease suffix 879 // Strip prerelease suffix. 880 880 $display = ( false !== $pre ) 881 881 ? substr( $version, 0, $pre ) … … 887 887 } 888 888 } 889 endif; // class_exists check889 endif; // End class_exists check. 890 890 891 891 /** … … 902 902 903 903 // These are strings we may use to describe maintenance/security releases, where we aim for no new strings. 904 905 904 _n_noop( 'Maintenance Release', 'Maintenance Releases', 'buddypress' ); 906 905 _n_noop( 'Security Release', 'Security Releases', 'buddypress' );
Note: See TracChangeset
for help on using the changeset viewer.