Changeset 10354
- Timestamp:
- 11/15/2015 06:56:24 PM (9 years ago)
- Location:
- trunk/src/bp-core/admin
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/admin/bp-core-admin-actions.php
r10108 r10354 35 35 * near the bottom of this file. 36 36 * 37 * 37 * v--WordPress Actions v--BuddyPress Sub-actions 38 38 */ 39 39 add_action( 'admin_menu', 'bp_admin_menu' ); … … 47 47 add_action( 'wpmu_new_blog', 'bp_new_site', 10, 6 ); 48 48 49 // Hook on to admin_init 49 // Hook on to admin_init. 50 50 add_action( 'bp_admin_init', 'bp_setup_updater', 1000 ); 51 51 add_action( 'bp_admin_init', 'bp_core_activation_notice', 1010 ); … … 55 55 add_action( 'bp_admin_init', 'bp_do_activation_redirect', 1 ); 56 56 57 // Add a new separator 57 // Add a new separator. 58 58 add_action( 'bp_admin_menu', 'bp_admin_separator' ); 59 59 … … 64 64 * @since 1.7.0 65 65 * 66 * @param int $blog_id 67 * @param int $user_id 68 * @param string $domain 69 * @param string $path 70 * @param int $site_id 71 * @param array $meta 66 * @param int $blog_id ID of the blog being installed to. 67 * @param int $user_id ID of the user the install is for. 68 * @param string $domain Domain to use with the install. 69 * @param string $path Path to use with the install. 70 * @param int $site_id ID of the site being installed to. 71 * @param array $meta Metadata to use with the site creation. 72 72 */ 73 73 function bp_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { 74 74 75 // Bail if plugin is not network activated 75 // Bail if plugin is not network activated. 76 76 if ( ! is_plugin_active_for_network( buddypress()->basename ) ) 77 77 return; 78 78 79 // Switch to the new blog 79 // Switch to the new blog. 80 80 switch_to_blog( $blog_id ); 81 81 … … 94 94 do_action( 'bp_new_site', $blog_id, $user_id, $domain, $path, $site_id, $meta ); 95 95 96 // restore original blog96 // Restore original blog. 97 97 restore_current_blog(); 98 98 } … … 104 104 * 105 105 * @since 1.7.0 106 * 106 107 * @uses do_action() Calls 'bp_admin_init'. 107 108 */ … … 120 121 * 121 122 * @since 1.7.0 123 * 122 124 * @uses do_action() Calls 'bp_admin_menu'. 123 125 */ … … 136 138 * 137 139 * @since 1.7.0 140 * 138 141 * @uses do_action() Calls 'bp_admin_head'. 139 142 */ … … 152 155 * 153 156 * @since 1.7.0 157 * 154 158 * @uses do_action() Calls 'bp_admin_notices'. 155 159 */ … … 169 173 * @since 1.7.0 170 174 * 171 * @uses do_action() Calls 'bp_admin_enqueue_scripts' '.175 * @uses do_action() Calls 'bp_admin_enqueue_scripts'. 172 176 * 173 177 * @param string $hook_suffix The current admin page, passed to … … 190 194 * 191 195 * @since 1.7.0 196 * 192 197 * @uses do_action() Calls 'bp_admin_notices'. 193 198 */ … … 208 213 * 209 214 * @since 1.7.0 215 * 210 216 * @uses do_action() Calls 'bp_admin_notices'. 211 217 */ … … 224 230 * 225 231 * @since 1.7.0 232 * 226 233 * @uses do_action() Calls 'bp_register_admin_settings'. 227 234 */ -
trunk/src/bp-core/admin/bp-core-admin-components.php
r10229 r10354 13 13 * Renders the Component Setup admin panel. 14 14 * 15 * @package BuddyPress16 15 * @since 1.6.0 16 * 17 17 * @uses bp_core_admin_component_options() 18 18 */ … … 42 42 * Creates reusable markup for component setup on the Components and Pages dashboard panel. 43 43 * 44 * @package BuddyPress45 44 * @since 1.6.0 45 * 46 46 * @todo Use settings API 47 47 */ 48 48 function bp_core_admin_components_options() { 49 49 50 // Declare local variables 50 // Declare local variables. 51 51 $deactivated_components = array(); 52 52 … … 60 60 $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) ); 61 61 62 // The default components (if none are previously selected) 62 // The default components (if none are previously selected). 63 63 $default_components = array( 64 64 'xprofile' => array( … … 80 80 $retired_components = bp_core_admin_get_components( 'retired' ); 81 81 82 // Don't show Forums component in optional components if it's disabled 82 // Don't show Forums component in optional components if it's disabled. 83 83 if ( ! bp_is_active( 'forums' ) ) { 84 84 unset( $optional_components['forums'] ); 85 85 } 86 86 87 // Merge optional and required together 87 // Merge optional and required together. 88 88 $all_components = $optional_components + $required_components; 89 89 … … 94 94 if ( !empty( $deactivated_components ) ) { 95 95 96 // Trim off namespace and filename 96 // Trim off namespace and filename. 97 97 $trimmed = array(); 98 98 foreach ( array_keys( (array) $deactivated_components ) as $component ) { … … 100 100 } 101 101 102 // Loop through the optional components to create an active component array 102 // Loop through the optional components to create an active component array. 103 103 foreach ( array_keys( (array) $optional_components ) as $ocomponent ) { 104 104 if ( !in_array( $ocomponent, $trimmed ) ) { … … 109 109 } 110 110 111 // On new install, set active components to default 111 // On new install, set active components to default. 112 112 if ( empty( $active_components ) ) { 113 113 $active_components = $default_components; 114 114 } 115 115 116 // Core component is always active 116 // Core component is always active. 117 117 $active_components['core'] = $all_components['core']; 118 118 $inactive_components = array_diff( array_keys( $all_components ) , array_keys( $active_components ) ); 119 119 120 /** Display ***************************************************************/ 121 122 // Get the total count of all plugins 120 /** Display ************************************************************** 121 */ 122 123 // Get the total count of all plugins. 123 124 $all_count = count( $all_components ); 124 125 $page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php'; … … 237 238 * 238 239 * @since 1.6.0 240 * 239 241 * @todo Use settings API when it supports saving network settings 240 242 */ 241 243 function bp_core_admin_components_settings_handler() { 242 244 243 // Bail if not saving settings 245 // Bail if not saving settings. 244 246 if ( ! isset( $_POST['bp-admin-component-submit'] ) ) 245 247 return; 246 248 247 // Bail if nonce fails 249 // Bail if nonce fails. 248 250 if ( ! check_admin_referer( 'bp-admin-component-setup' ) ) 249 251 return; 250 252 251 // Settings form submitted, now save the settings. First, set active components 253 // Settings form submitted, now save the settings. First, set active components. 252 254 if ( isset( $_POST['bp_components'] ) ) { 253 255 254 // Load up BuddyPress 256 // Load up BuddyPress. 255 257 $bp = buddypress(); 256 258 257 // Save settings and upgrade schema 259 // Save settings and upgrade schema. 258 260 require_once( $bp->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' ); 259 261 … … 269 271 $base_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components', 'updated' => 'true' ), 'admin.php' ) ); 270 272 271 // Redirect 273 // Redirect. 272 274 wp_redirect( $base_url ); 273 275 die(); … … 299 301 * @param array $submitted This is the array of component settings coming from the POST 300 302 * global. You should stripslashes_deep() before passing to this function. 301 *302 303 * @return array The calculated list of component settings 303 304 */ … … 318 319 unset( $current_components[ $retired_component ] ); 319 320 } 320 } 321 // fall through 321 } // Fall through. 322 322 323 323 324 case 'inactive' : … … 344 345 * 345 346 * @param string $type 'all', 'optional', 'retired', 'required'. 346 * 347 * @return array An array of requested component data 347 * @return array An array of requested component data. 348 348 */ 349 349 function bp_core_admin_get_components( $type = 'all' ) { 350 350 351 // Required components 351 // Required components. 352 352 $required_components = array( 353 353 'core' => array( … … 361 361 ); 362 362 363 // Retired components 363 // Retired components. 364 364 $retired_components = array( 365 365 'forums' => array( … … 369 369 ); 370 370 371 // Optional core components 371 // Optional core components. 372 372 $optional_components = array( 373 373 'xprofile' => array( … … 410 410 411 411 412 // Add blogs tracking if multisite 412 // Add blogs tracking if multisite. 413 413 if ( is_multisite() ) { 414 414 $optional_components['blogs']['description'] = __( 'Record activity for new sites, posts, and comments across your network.', 'buddypress' ); … … 440 440 * @param string $type Type of component list requested. 441 441 * Possible values include 'all', 'optional', 442 * 442 * 'retired', 'required'. 443 443 */ 444 444 return apply_filters( 'bp_core_admin_get_components', $components, $type ); -
trunk/src/bp-core/admin/bp-core-admin-functions.php
r10267 r10354 15 15 * Initializes the wp-admin area "BuddyPress" menus and sub menus. 16 16 * 17 * @package BuddyPress Core 18 * @uses bp_current_user_can() returns true if the current user is a site admin, false if not 17 * @uses bp_current_user_can() returns true if the current user is a site admin, false if not. 19 18 */ 20 19 function bp_core_admin_menu_init() { … … 32 31 * @global array $_registered_pages 33 32 * @global array $submenu 33 * 34 34 * @since 1.6.0 35 35 */ … … 38 38 39 39 // If there's no bp-general-settings menu (perhaps because the current 40 // user is not an Administrator), there's nothing to do here 40 // user is not an Administrator), there's nothing to do here. 41 41 if ( ! isset( $submenu['bp-general-settings'] ) ) { 42 42 return; … … 52 52 } 53 53 54 // This removes the top-level menu 54 // This removes the top-level menu. 55 55 remove_submenu_page( 'bp-general-settings', 'bp-general-settings' ); 56 56 remove_menu_page( 'bp-general-settings' ); 57 57 58 // These stop people accessing the URL directly 58 // These stop people accessing the URL directly. 59 59 unset( $_parent_pages['bp-general-settings'] ); 60 60 unset( $_registered_pages['toplevel_page_bp-general-settings'] ); … … 71 71 * @global string $plugin_page 72 72 * @global array $submenu 73 * 73 74 * @since 1.6.0 74 75 */ … … 76 77 global $plugin_page, $submenu_file; 77 78 78 // This tweaks the Settings subnav menu to show only one BuddyPress menu item 79 // This tweaks the Settings subnav menu to show only one BuddyPress menu item. 79 80 if ( ! in_array( $plugin_page, array( 'bp-activity', 'bp-general-settings', ) ) ) { 80 81 $submenu_file = 'bp-components'; 81 82 } 82 83 83 // Network Admin > Tools 84 // Network Admin > Tools. 84 85 if ( in_array( $plugin_page, array( 'bp-tools', 'available-tools' ) ) ) { 85 86 $submenu_file = $plugin_page; … … 93 94 * 94 95 * @see bp_core_admin_backpat_menu() 96 * 95 97 * @since 1.6.0 98 * 96 99 * @todo Add convenience links into the markup once new positions are finalised. 97 100 */ … … 125 128 function bp_core_print_admin_notices() { 126 129 127 // Only the super admin should see messages 130 // Only the super admin should see messages. 128 131 if ( ! bp_current_user_can( 'bp_moderate' ) ) { 129 132 return; … … 170 173 function bp_core_add_admin_notice( $notice = '', $type = 'updated' ) { 171 174 172 // Do not add if the notice is empty 175 // Do not add if the notice is empty. 173 176 if ( empty( $notice ) ) { 174 177 return; 175 178 } 176 179 177 // Double check the object before referencing it 180 // Double check the object before referencing it. 178 181 if ( ! isset( buddypress()->admin->notices ) ) { 179 182 buddypress()->admin->notices = array(); 180 183 } 181 184 182 // Add the notice 185 // Add the notice. 183 186 buddypress()->admin->notices[] = array( 184 187 'message' => $notice, … … 198 201 * @global WPDB $wpdb WordPress DB object 199 202 * @global WP_Rewrite $wp_rewrite 203 * 200 204 * @since 1.2.0 201 205 */ … … 203 207 global $wp_rewrite, $wpdb; 204 208 205 // Only the super admin gets warnings 209 // Only the super admin gets warnings. 206 210 if ( ! bp_current_user_can( 'bp_moderate' ) ) { 207 211 return; 208 212 } 209 213 210 // Bail in user admin 214 // Bail in user admin. 211 215 if ( is_user_admin() ) { 212 216 return; 213 217 } 214 218 215 // On multisite installs, don't load on a non-root blog, unless do_network_admin is overridden 219 // On multisite installs, don't load on a non-root blog, unless do_network_admin is overridden. 216 220 if ( is_multisite() && bp_core_do_network_admin() && ! bp_is_root_blog() ) { 217 221 return; 218 222 } 219 223 220 // Bail if in network admin, and BuddyPress is not network activated 224 // Bail if in network admin, and BuddyPress is not network activated. 221 225 if ( is_network_admin() && ! bp_is_network_activated() ) { 222 226 return; … … 237 241 } 238 242 239 // Add notice if no rewrite rules are enabled 243 // Add notice if no rewrite rules are enabled. 240 244 if ( empty( $wp_rewrite->permalink_structure ) ) { 241 245 bp_core_add_admin_notice( sprintf( __( '<strong>BuddyPress is almost ready</strong>. You must <a href="%s">update your permalink structure</a> to something other than the default for it to work.', 'buddypress' ), admin_url( 'options-permalink.php' ) ), 'error' ); 242 246 } 243 247 244 // Get BuddyPress instance 248 // Get BuddyPress instance. 245 249 $bp = buddypress(); 246 250 247 251 /** 248 * Check for orphaned BP components (BP component is enabled, no WP page exists) 252 * Check for orphaned BP components (BP component is enabled, no WP page exists). 249 253 */ 250 254 $orphaned_components = array(); 251 255 $wp_page_components = array(); 252 256 253 // Only components with 'has_directory' require a WP page to function 257 // Only components with 'has_directory' require a WP page to function. 254 258 foreach( array_keys( $bp->loaded_components ) as $component_id ) { 255 259 if ( !empty( $bp->{$component_id}->has_directory ) ) { … … 275 279 } 276 280 277 // On the first admin screen after a new installation, this isn't set, so grab it to suppress a misleading error message. 281 // On the first admin screen after a new installation, this isn't set, so grab it to suppress 282 // a misleading error message. 278 283 if ( empty( $bp->pages->members ) ) { 279 284 $bp->pages = bp_core_get_directory_pages(); … … 288 293 // Special case: If the Forums component is orphaned, but the bbPress 1.x installation is 289 294 // not correctly set up, don't show a nag. (In these cases, it's probably the case that the 290 // user is using bbPress 2.x; see https://buddypress.trac.wordpress.org/ticket/4292 295 // user is using bbPress 2.x; see https://buddypress.trac.wordpress.org/ticket/4292. 291 296 if ( isset( $bp->forums->name ) && in_array( $bp->forums->name, $orphaned_components ) && !bp_forums_is_installed_correctly() ) { 292 297 $forum_key = array_search( $bp->forums->name, $orphaned_components ); … … 312 317 } 313 318 314 // Make sure that there are no duplicate duplicates :) 319 // Make sure that there are no duplicate duplicates :). 315 320 $dupe_names = array_unique( $dupe_names ); 316 321 } 317 322 318 // If there are duplicates, post a message about them 323 // If there are duplicates, post a message about them. 319 324 if ( !empty( $dupe_names ) ) { 320 325 $admin_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) ); … … 341 346 function bp_do_activation_redirect() { 342 347 343 // Bail if no activation redirect 348 // Bail if no activation redirect. 344 349 if ( ! get_transient( '_bp_activation_redirect' ) ) { 345 350 return; 346 351 } 347 352 348 // Delete the redirect transient 353 // Delete the redirect transient. 349 354 delete_transient( '_bp_activation_redirect' ); 350 355 351 // Bail if activating from network, or bulk 356 // Bail if activating from network, or bulk. 352 357 if ( isset( $_GET['activate-multi'] ) ) { 353 358 return; … … 360 365 } 361 366 362 // Redirect to BuddyPress about page 367 // Redirect to BuddyPress about page. 363 368 wp_safe_redirect( add_query_arg( $query_args, bp_get_admin_url( 'index.php' ) ) ); 364 369 } … … 387 392 $tabs = apply_filters( 'bp_core_admin_tabs', bp_core_get_admin_tabs( $active_tab ) ); 388 393 389 // Loop through tabs and build navigation 394 // Loop through tabs and build navigation. 390 395 foreach ( array_values( $tabs ) as $tab_data ) { 391 396 $is_current = (bool) ( $tab_data['name'] == $active_tab ); … … 410 415 * 411 416 * @param string $active_tab Name of the tab that is active. Optional. 412 *413 417 * @return string 414 418 */ … … 429 433 ); 430 434 431 // If forums component is active, add additional tab 435 // If forums component is active, add additional tab. 432 436 if ( bp_is_active( 'forums' ) && class_exists( 'BP_Forums_Component' ) ) { 433 437 434 // enqueue thickbox438 // Enqueue thickbox. 435 439 wp_enqueue_script( 'thickbox' ); 436 440 wp_enqueue_style( 'thickbox' ); … … 455 459 456 460 /** 457 * adds contextual help to BuddyPress admin pages.461 * Adds contextual help to BuddyPress admin pages. 458 462 * 459 463 * @since 1.7.0 460 * @todo Make this part of the BP_Component class and split into each component 461 * 462 * @param string $screen 464 * @todo Make this part of the BP_Component class and split into each component. 465 * 466 * @param string $screen Current screen. 463 467 */ 464 468 function bp_core_add_contextual_help( $screen = '' ) { … … 468 472 switch ( $screen->id ) { 469 473 470 // Component page 474 // Component page. 471 475 case 'settings_page_bp-components' : 472 476 473 // help tabs477 // Help tabs. 474 478 $screen->add_help_tab( array( 475 479 'id' => 'bp-comp-overview', … … 478 482 ) ); 479 483 480 // help panel - sidebar links484 // Help panel - sidebar links. 481 485 $screen->set_help_sidebar( 482 486 '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' . … … 486 490 break; 487 491 488 // Pages page 492 // Pages page. 489 493 case 'settings_page_bp-page-settings' : 490 494 491 // Help tabs 495 // Help tabs. 492 496 $screen->add_help_tab( array( 493 497 'id' => 'bp-page-overview', … … 496 500 ) ); 497 501 498 // Help panel - sidebar links 502 // Help panel - sidebar links. 499 503 $screen->set_help_sidebar( 500 504 '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' . … … 505 509 break; 506 510 507 // Settings page 511 // Settings page. 508 512 case 'settings_page_bp-settings' : 509 513 510 // Help tabs 514 // Help tabs. 511 515 $screen->add_help_tab( array( 512 516 'id' => 'bp-settings-overview', … … 515 519 ) ); 516 520 517 // Help panel - sidebar links 521 // Help panel - sidebar links. 518 522 $screen->set_help_sidebar( 519 523 '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' . … … 524 528 break; 525 529 526 // Profile fields page 530 // Profile fields page. 527 531 case 'users_page_bp-profile-setup' : 528 532 529 // Help tabs 533 // Help tabs. 530 534 $screen->add_help_tab( array( 531 535 'id' => 'bp-profile-overview', … … 534 538 ) ); 535 539 536 // Help panel - sidebar links 540 // Help panel - sidebar links. 537 541 $screen->set_help_sidebar( 538 542 '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' . … … 547 551 548 552 /** 549 * renders contextual help content to contextual help tabs.553 * Renders contextual help content to contextual help tabs. 550 554 * 551 555 * @since 1.7.0 552 556 * 553 * @param string $tab 554 * 557 * @param string $tab Current help content tab. 555 558 * @return string 556 559 */ … … 579 582 } 580 583 581 // Wrap text in a paragraph tag 584 // Wrap text in a paragraph tag. 582 585 if ( !empty( $retval ) ) { 583 586 $retval = '<p>' . $retval . '</p>'; … … 598 601 function bp_admin_separator() { 599 602 600 // Bail if BuddyPress is not network activated and viewing network admin 603 // Bail if BuddyPress is not network activated and viewing network admin. 601 604 if ( is_network_admin() && ! bp_is_network_activated() ) { 602 605 return; 603 606 } 604 607 605 // Bail if BuddyPress is network activated and viewing site admin 608 // Bail if BuddyPress is network activated and viewing site admin. 606 609 if ( ! is_network_admin() && bp_is_network_activated() ) { 607 610 return; 608 611 } 609 612 610 // Prevent duplicate separators when no core menu items exist 613 // Prevent duplicate separators when no core menu items exist. 611 614 if ( ! bp_current_user_can( 'bp_moderate' ) ) { 612 615 return; … … 628 631 * 629 632 * @since 1.7.0 633 * 630 634 * @uses bp_current_user_can() To check users capability on root blog. 631 635 * 632 636 * @param bool $menu_order Menu order. 633 * 634 * @return bool Always true 637 * @return bool Always true. 635 638 */ 636 639 function bp_admin_custom_menu_order( $menu_order = false ) { 637 640 638 // Bail if user cannot see admin pages 641 // Bail if user cannot see admin pages. 639 642 if ( ! bp_current_user_can( 'bp_moderate' ) ) { 640 643 return $menu_order; … … 648 651 * 649 652 * @since 1.7.0 653 * 650 654 * @uses bp_current_user_can() To check users capability on root blog. 651 655 * 652 656 * @param array $menu_order Menu Order. 653 * 654 * @return array Modified menu order 657 * @return array Modified menu order. 655 658 */ 656 659 function bp_admin_menu_order( $menu_order = array() ) { 657 660 658 // Bail if user cannot see admin pages 661 // Bail if user cannot see admin pages. 659 662 if ( empty( $menu_order ) || ! bp_current_user_can( 'bp_moderate' ) ) { 660 663 return $menu_order; 661 664 } 662 665 663 // Initialize our custom order array 666 // Initialize our custom order array. 664 667 $bp_menu_order = array(); 665 668 666 // Menu values 669 // Menu values. 667 670 $last_sep = is_network_admin() ? 'separator1' : 'separator2'; 668 671 … … 676 679 $custom_menus = (array) apply_filters( 'bp_admin_menu_order', array() ); 677 680 678 // Bail if no components have top level admin pages 681 // Bail if no components have top level admin pages. 679 682 if ( empty( $custom_menus ) ) { 680 683 return $menu_order; 681 684 } 682 685 683 // Add our separator to beginning of array 686 // Add our separator to beginning of array. 684 687 array_unshift( $custom_menus, 'separator-buddypress' ); 685 688 686 // Loop through menu order and do some rearranging 689 // Loop through menu order and do some rearranging. 687 690 foreach ( (array) $menu_order as $item ) { 688 691 689 // Position BuddyPress menus above appearance 692 // Position BuddyPress menus above appearance. 690 693 if ( $last_sep == $item ) { 691 694 692 // Add our custom menus 695 // Add our custom menus. 693 696 foreach( (array) $custom_menus as $custom_menu ) { 694 697 if ( array_search( $custom_menu, $menu_order ) ) { … … 697 700 } 698 701 699 // Add the appearance separator 702 // Add the appearance separator. 700 703 $bp_menu_order[] = $last_sep; 701 704 702 // Skip our menu items 705 // Skip our menu items. 703 706 } elseif ( ! in_array( $item, $custom_menus ) ) { 704 707 $bp_menu_order[] = $item; … … 706 709 } 707 710 708 // Return our custom order 711 // Return our custom order. 709 712 return $bp_menu_order; 710 713 } … … 727 730 $action = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : ''; 728 731 729 // If the bottom is set, let it override the action 732 // If the bottom is set, let it override the action. 730 733 if ( ! empty( $_REQUEST['action2'] ) && $_REQUEST['action2'] != "-1" ) { 731 734 $action = $_REQUEST['action2']; … … 846 849 * @param array $actions User row action links. 847 850 * @param object $user_object Current user information. 848 *849 851 * @return array $actions User row action links. 850 852 */ 851 853 function bp_core_admin_user_row_actions( $actions, $user_object ) { 852 854 853 // Setup the $user_id variable from the current user object 855 // Setup the $user_id variable from the current user object. 854 856 $user_id = 0; 855 857 if ( !empty( $user_object->ID ) ) { … … 857 859 } 858 860 859 // Bail early if user cannot perform this action, or is looking at themselves 861 // Bail early if user cannot perform this action, or is looking at themselves. 860 862 if ( current_user_can( 'edit_user', $user_id ) && ( bp_loggedin_user_id() !== $user_id ) ) { 861 863 862 // Admin URL could be single site or network 864 // Admin URL could be single site or network. 863 865 $url = bp_get_admin_url( 'users.php' ); 864 866 865 // If spammed, create unspam link 867 // If spammed, create unspam link. 866 868 if ( bp_is_user_spammer( $user_id ) ) { 867 869 $url = add_query_arg( array( 'action' => 'ham', 'user' => $user_id ), $url ); … … 869 871 $actions['ham'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $unspam_link ), esc_html__( 'Not Spam', 'buddypress' ) ); 870 872 871 // If not already spammed, create spam link 873 // If not already spammed, create spam link. 872 874 } else { 873 875 $url = add_query_arg( array( 'action' => 'spam', 'user' => $user_id ), $url ); … … 877 879 } 878 880 879 // Create a "View" link 881 // Create a "View" link. 880 882 $url = bp_core_get_user_domain( $user_id ); 881 883 $actions['view'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $url ), esc_html__( 'View', 'buddypress' ) ); 882 884 883 // Return new actions 885 // Return new actions. 884 886 return $actions; 885 887 } … … 892 894 function bp_core_admin_user_manage_spammers() { 893 895 894 // Print our inline scripts on non-Multisite 896 // Print our inline scripts on non-Multisite. 895 897 add_action( 'admin_footer', 'bp_core_admin_user_spammed_js' ); 896 898 … … 899 901 $mode = isset( $_POST['mode'] ) ? $_POST['mode'] : false; 900 902 901 // if this is a multisite, bulk request, stop now!903 // If this is a multisite, bulk request, stop now! 902 904 if ( 'list' == $mode ) { 903 905 return; 904 906 } 905 907 906 // Process a spam/ham request 908 // Process a spam/ham request. 907 909 if ( ! empty( $action ) && in_array( $action, array( 'spam', 'ham' ) ) ) { 908 910 … … 919 921 $status = ( $action == 'spam' ) ? 'spam' : 'ham'; 920 922 921 // Process the user 923 // Process the user. 922 924 bp_core_process_spammer_status( $user_id, $status ); 923 925 … … 927 929 } 928 930 929 // Display feedback 931 // Display feedback. 930 932 if ( ! empty( $updated ) && in_array( $updated, array( 'marked-spam', 'marked-ham' ) ) ) { 931 933 -
trunk/src/bp-core/admin/bp-core-admin-schema.php
r10108 r10354 16 16 * 17 17 * @global $wpdb $wpdb 18 * 18 19 * @return string The default database character-set, if set. 19 20 */ … … 40 41 bp_pre_schema_upgrade(); 41 42 42 // If no components passed, get all the active components from the main site 43 // If no components passed, get all the active components from the main site. 43 44 if ( empty( $active_components ) ) { 44 45 … … 47 48 } 48 49 49 // Install Activity Streams even when inactive (to store last_activity data) 50 // Install Activity Streams even when inactive (to store last_activity data). 50 51 bp_core_install_activity_streams(); 51 52 52 // Install the signups table 53 // Install the signups table. 53 54 bp_core_maybe_install_signups(); 54 55 55 // Notifications 56 // Notifications. 56 57 if ( !empty( $active_components['notifications'] ) ) { 57 58 bp_core_install_notifications(); 58 59 } 59 60 60 // Friend Connections 61 // Friend Connections. 61 62 if ( !empty( $active_components['friends'] ) ) { 62 63 bp_core_install_friends(); 63 64 } 64 65 65 // Extensible Groups 66 // Extensible Groups. 66 67 if ( !empty( $active_components['groups'] ) ) { 67 68 bp_core_install_groups(); 68 69 } 69 70 70 // Private Messaging 71 // Private Messaging. 71 72 if ( !empty( $active_components['messages'] ) ) { 72 73 bp_core_install_private_messaging(); 73 74 } 74 75 75 // Extended Profiles 76 // Extended Profiles. 76 77 if ( !empty( $active_components['xprofile'] ) ) { 77 78 bp_core_install_extended_profiles(); 78 79 } 79 80 80 // Blog tracking 81 // Blog tracking. 81 82 if ( !empty( $active_components['blogs'] ) ) { 82 83 bp_core_install_blog_tracking(); … … 345 346 $bp_prefix = bp_core_get_table_prefix(); 346 347 347 // These values should only be updated if they are not already present 348 // These values should only be updated if they are not already present. 348 349 if ( ! bp_get_option( 'bp-xprofile-base-group-name' ) ) { 349 350 bp_update_option( 'bp-xprofile-base-group-name', _x( 'General', 'First field-group name', 'buddypress' ) ); … … 405 406 dbDelta( $sql ); 406 407 407 // Insert the default group and fields 408 // Insert the default group and fields. 408 409 $insert_sql = array(); 409 410 … … 466 467 global $wpdb; 467 468 468 // Signups is not there and we need it so let's create it 469 // Signups is not there and we need it so let's create it. 469 470 require_once( buddypress()->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' ); 470 471 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); 471 472 472 // Never use bp_core_get_table_prefix() for any global users tables 473 // Never use bp_core_get_table_prefix() for any global users tables. 473 474 $wpdb->signups = $wpdb->base_prefix . 'signups'; 474 475 475 // Use WP's core CREATE TABLE query 476 // Use WP's core CREATE TABLE query. 476 477 $create_queries = wp_get_db_schema( 'ms_global' ); 477 478 if ( ! is_array( $create_queries ) ) { … … 480 481 } 481 482 482 // Filter out all the queries except wp_signups 483 // Filter out all the queries except wp_signups. 483 484 foreach ( $create_queries as $key => $query ) { 484 485 if ( preg_match( "|CREATE TABLE ([^ ]*)|", $query, $matches ) ) { … … 489 490 } 490 491 491 // Run WordPress's database upgrader 492 // Run WordPress's database upgrader. 492 493 if ( ! empty( $create_queries ) ) { 493 494 dbDelta( $create_queries ); … … 513 514 global $wpdb; 514 515 515 // Bail if global tables should not be upgraded 516 // Bail if global tables should not be upgraded. 516 517 if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) { 517 518 return; 518 519 } 519 520 520 // Never use bp_core_get_table_prefix() for any global users tables 521 // Never use bp_core_get_table_prefix() for any global users tables. 521 522 $wpdb->signups = $wpdb->base_prefix . 'signups'; 522 523 523 // Attempt to alter the signups table 524 // Attempt to alter the signups table. 524 525 $wpdb->query( "ALTER TABLE {$wpdb->signups} ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST" ); 525 526 $wpdb->query( "ALTER TABLE {$wpdb->signups} DROP INDEX domain" ); -
trunk/src/bp-core/admin/bp-core-admin-settings.php
r10229 r10354 111 111 * @since 1.6.0 112 112 * 113 * @param bool $value 114 * 113 * @param bool $value Whether or not to sanitize. 115 114 * @return bool 116 115 */ … … 232 231 233 232 /** 234 * bb-config.php location field. 235 * 236 * @since 1.6.0 233 * The bb-config.php location field. 234 * 235 * @since 1.6.0 236 * 237 237 * @uses checked() To display the checked attribute. 238 238 * @uses bp_get_option() To get the config location. … … 270 270 function bp_core_admin_settings() { 271 271 272 // We're saving our own options, until the WP Settings API is updated to work with Multisite 272 // We're saving our own options, until the WP Settings API is updated to work with Multisite. 273 273 $form_action = add_query_arg( 'page', 'bp-settings', bp_get_admin_url( 'admin.php' ) ); 274 274 … … 306 306 307 307 // Because many settings are saved with checkboxes, and thus will have no values 308 // in the $_POST array when unchecked, we loop through the registered settings 308 // in the $_POST array when unchecked, we loop through the registered settings. 309 309 if ( isset( $wp_settings_fields['buddypress'] ) ) { 310 310 foreach( (array) $wp_settings_fields['buddypress'] as $section => $settings ) { … … 333 333 // Note: Each of these options is represented by its opposite in the UI 334 334 // Ie, the Profile Syncing option reads "Enable Sync", so when it's checked, 335 // the corresponding option should be unset 335 // the corresponding option should be unset. 336 336 $value = isset( $_POST[$legacy_option] ) ? '' : 1; 337 337 bp_update_option( $legacy_option, $value ); … … 350 350 * @uses bp_get_bp_form_option() 351 351 * 352 * @param string $option 353 * @param string $default 354 * @param bool $slug 352 * @param string $option Form option to echo. 353 * @param string $default Form option default. 354 * @param bool $slug Form option slug. 355 355 */ 356 356 function bp_form_option( $option, $default = '' , $slug = false ) { … … 366 366 * @uses apply_filters() 367 367 * 368 * @param string $option 369 * @param string $default 370 * @param bool $slug 371 * 368 * @param string $option Form option to return. 369 * @param string $default Form option default. 370 * @param bool $slug Form option slug. 372 371 * @return string 373 372 */ 374 373 function bp_get_form_option( $option, $default = '', $slug = false ) { 375 374 376 // Get the option and sanitize it 375 // Get the option and sanitize it. 377 376 $value = bp_get_option( $option, $default ); 378 377 … … 388 387 */ 389 388 $value = esc_attr( apply_filters( 'editable_slug', $value ) ); 390 } else { // Not a slug 389 } else { // Not a slug. 391 390 $value = esc_attr( $value ); 392 391 } 393 392 394 // Fallback to default 393 // Fallback to default. 395 394 if ( empty( $value ) ) 396 395 $value = $default; -
trunk/src/bp-core/admin/bp-core-admin-slugs.php
r10229 r10354 14 14 * 15 15 * @since 1.6.0 16 * 16 17 * @todo Use settings API 17 18 * @uses bp_core_admin_component_options() … … 42 43 * Creates reusable markup for page setup on the Components and Pages dashboard panel. 43 44 * 44 * @package BuddyPress45 45 * @since 1.6.0 46 * 46 47 * @todo Use settings API 47 48 */ … … 49 50 $bp = buddypress(); 50 51 51 // Get the existing WP pages 52 // Get the existing WP pages. 52 53 $existing_pages = bp_core_get_directory_page_ids(); 53 54 … … 56 57 $directory_pages = array(); 57 58 58 // Loop through loaded components and collect directories 59 // Loop through loaded components and collect directories. 59 60 if ( is_array( $bp->loaded_components ) ) { 60 61 foreach( $bp->loaded_components as $component_slug => $component_id ) { 61 62 62 // Only components that need directories should be listed here 63 // Only components that need directories should be listed here. 63 64 if ( isset( $bp->{$component_id} ) && !empty( $bp->{$component_id}->has_directory ) ) { 64 65 65 // component->name was introduced in BP 1.5, so we must provide a fallback66 // The component->name property was introduced in BP 1.5, so we must provide a fallback. 66 67 $directory_pages[$component_id] = !empty( $bp->{$component_id}->name ) ? $bp->{$component_id}->name : ucwords( $component_id ); 67 68 } … … 69 70 } 70 71 71 /** Directory Display *****************************************************/ 72 /** Directory Display **************************************************** 73 */ 72 74 73 75 /** … … 139 141 endif; 140 142 141 /** Static Display ********************************************************/ 142 143 // Static pages 143 /** Static Display ******************************************************* 144 */ 145 146 // Static pages. 144 147 $static_pages = array( 145 148 'register' => __( 'Register', 'buddypress' ), … … 216 219 * 217 220 * @since 1.6.0 221 * 218 222 * @todo Use settings API 219 223 */ … … 224 228 return false; 225 229 226 // Then, update the directory pages 230 // Then, update the directory pages. 227 231 if ( isset( $_POST['bp_pages'] ) ) { 228 232 -
trunk/src/bp-core/admin/bp-core-admin-tools.php
r10229 r10354 75 75 check_admin_referer( 'bp-do-counts' ); 76 76 77 // Stores messages 77 // Stores messages. 78 78 $messages = array(); 79 79 … … 104 104 // Members: 105 105 // - member count 106 // - last_activity migration (2.0) 106 // - last_activity migration (2.0). 107 107 $repair_list[20] = array( 108 108 'bp-total-member-count', … … 118 118 119 119 // Friends: 120 // - user friend count 120 // - user friend count. 121 121 if ( bp_is_active( 'friends' ) ) { 122 122 $repair_list[0] = array( … … 128 128 129 129 // Groups: 130 // - user group count 130 // - user group count. 131 131 if ( bp_is_active( 'groups' ) ) { 132 132 $repair_list[10] = array( … … 138 138 139 139 // Blogs: 140 // - user blog count 140 // - user blog count. 141 141 if ( bp_is_active( 'blogs' ) ) { 142 142 $repair_list[90] = array( … … 183 183 $bp = buddypress(); 184 184 185 // Walk through all users on the site 185 // Walk through all users on the site. 186 186 $total_users = $wpdb->get_row( "SELECT count(ID) as c FROM {$wpdb->users}" )->c; 187 187 … … 191 191 $offset = 0; 192 192 while ( $offset < $total_users ) { 193 // Only bother updating counts for users who actually have friendships 193 // Only bother updating counts for users who actually have friendships. 194 194 $friendships = $wpdb->get_results( $wpdb->prepare( "SELECT initiator_user_id, friend_user_id FROM {$bp->friends->table_name} WHERE is_confirmed = 1 AND ( ( initiator_user_id > %d AND initiator_user_id <= %d ) OR ( friend_user_id > %d AND friend_user_id <= %d ) )", $offset, $offset + $per_query, $offset, $offset + $per_query ) ); 195 195 196 196 // The previous query will turn up duplicates, so we 197 // filter them here 197 // filter them here. 198 198 foreach ( $friendships as $friendship ) { 199 199 if ( ! isset( $updated[ $friendship->initiator_user_id ] ) ) { … … 241 241 $bp = buddypress(); 242 242 243 // Walk through all users on the site 243 // Walk through all users on the site. 244 244 $total_users = $wpdb->get_row( "SELECT count(ID) as c FROM {$wpdb->users}" )->c; 245 245 … … 248 248 $offset = 0; 249 249 while ( $offset < $total_users ) { 250 // But only bother to update counts for users that have groups 250 // But only bother to update counts for users that have groups. 251 251 $users = $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE is_confirmed = 1 AND is_banned = 0 AND user_id > %d AND user_id <= %d", $offset, $offset + $per_query ) ); 252 252 … … 273 273 function bp_admin_repair_blog_records() { 274 274 275 // Description of this tool, displayed to the user 275 // Description of this tool, displayed to the user. 276 276 $statement = __( 'Repopulating Blogs records… %s', 'buddypress' ); 277 277 278 // Default to failure text 278 // Default to failure text. 279 279 $result = __( 'Failed!', 'buddypress' ); 280 280 281 // Default to unrepaired 281 // Default to unrepaired. 282 282 $repair = false; 283 283 284 // Run function if blogs component is active 284 // Run function if blogs component is active. 285 285 if ( bp_is_active( 'blogs' ) ) { 286 286 $repair = bp_blogs_record_existing_blogs(); 287 287 } 288 288 289 // Setup success/fail messaging 289 // Setup success/fail messaging. 290 290 if ( true === $repair ) { 291 291 $result = __( 'Complete!', 'buddypress' ); … … 328 328 * @param string $message Feedback message. 329 329 * @param string|bool $class Unused. 330 *331 330 * @return bool 332 331 */
Note: See TracChangeset
for help on using the changeset viewer.