Skip to:
Content

BuddyPress.org

Changeset 10354


Ignore:
Timestamp:
11/15/2015 06:56:24 PM (11 years ago)
Author:
tw2113
Message:

More documentation cleanup for part of BP-Core component.

See #6398.

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  
    3535 * near the bottom of this file.
    3636 *
    37  *           v--WordPress Actions       v--BuddyPress Sub-actions
     37 *          v--WordPress Actions       v--BuddyPress Sub-actions
    3838 */
    3939add_action( 'admin_menu',              'bp_admin_menu'                    );
     
    4747add_action( 'wpmu_new_blog',           'bp_new_site',               10, 6 );
    4848
    49 // Hook on to admin_init
     49// Hook on to admin_init.
    5050add_action( 'bp_admin_init', 'bp_setup_updater',          1000 );
    5151add_action( 'bp_admin_init', 'bp_core_activation_notice', 1010 );
     
    5555add_action( 'bp_admin_init', 'bp_do_activation_redirect', 1    );
    5656
    57 // Add a new separator
     57// Add a new separator.
    5858add_action( 'bp_admin_menu', 'bp_admin_separator' );
    5959
     
    6464 * @since 1.7.0
    6565 *
    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.
    7272 */
    7373function bp_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
    7474
    75         // Bail if plugin is not network activated
     75        // Bail if plugin is not network activated.
    7676        if ( ! is_plugin_active_for_network( buddypress()->basename ) )
    7777                return;
    7878
    79         // Switch to the new blog
     79        // Switch to the new blog.
    8080        switch_to_blog( $blog_id );
    8181
     
    9494        do_action( 'bp_new_site', $blog_id, $user_id, $domain, $path, $site_id, $meta );
    9595
    96         // restore original blog
     96        // Restore original blog.
    9797        restore_current_blog();
    9898}
     
    104104 *
    105105 * @since 1.7.0
     106 *
    106107 * @uses do_action() Calls 'bp_admin_init'.
    107108 */
     
    120121 *
    121122 * @since 1.7.0
     123 *
    122124 * @uses do_action() Calls 'bp_admin_menu'.
    123125 */
     
    136138 *
    137139 * @since 1.7.0
     140 *
    138141 * @uses do_action() Calls 'bp_admin_head'.
    139142 */
     
    152155 *
    153156 * @since 1.7.0
     157 *
    154158 * @uses do_action() Calls 'bp_admin_notices'.
    155159 */
     
    169173 * @since 1.7.0
    170174 *
    171  * @uses do_action() Calls 'bp_admin_enqueue_scripts''.
     175 * @uses do_action() Calls 'bp_admin_enqueue_scripts'.
    172176 *
    173177 * @param string $hook_suffix The current admin page, passed to
     
    190194 *
    191195 * @since 1.7.0
     196 *
    192197 * @uses do_action() Calls 'bp_admin_notices'.
    193198 */
     
    208213 *
    209214 * @since 1.7.0
     215 *
    210216 * @uses do_action() Calls 'bp_admin_notices'.
    211217 */
     
    224230 *
    225231 * @since 1.7.0
     232 *
    226233 * @uses do_action() Calls 'bp_register_admin_settings'.
    227234 */
  • trunk/src/bp-core/admin/bp-core-admin-components.php

    r10229 r10354  
    1313 * Renders the Component Setup admin panel.
    1414 *
    15  * @package BuddyPress
    1615 * @since 1.6.0
     16 *
    1717 * @uses bp_core_admin_component_options()
    1818 */
     
    4242 * Creates reusable markup for component setup on the Components and Pages dashboard panel.
    4343 *
    44  * @package BuddyPress
    4544 * @since 1.6.0
     45 *
    4646 * @todo Use settings API
    4747 */
    4848function bp_core_admin_components_options() {
    4949
    50         // Declare local variables
     50        // Declare local variables.
    5151        $deactivated_components = array();
    5252
     
    6060        $active_components      = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
    6161
    62         // The default components (if none are previously selected)
     62        // The default components (if none are previously selected).
    6363        $default_components = array(
    6464                'xprofile' => array(
     
    8080        $retired_components  = bp_core_admin_get_components( 'retired'  );
    8181
    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.
    8383        if ( ! bp_is_active( 'forums' ) ) {
    8484                unset( $optional_components['forums'] );
    8585        }
    8686
    87         // Merge optional and required together
     87        // Merge optional and required together.
    8888        $all_components = $optional_components + $required_components;
    8989
     
    9494                if ( !empty( $deactivated_components ) ) {
    9595
    96                         // Trim off namespace and filename
     96                        // Trim off namespace and filename.
    9797                        $trimmed = array();
    9898                        foreach ( array_keys( (array) $deactivated_components ) as $component ) {
     
    100100                        }
    101101
    102                         // Loop through the optional components to create an active component array
     102                        // Loop through the optional components to create an active component array.
    103103                        foreach ( array_keys( (array) $optional_components ) as $ocomponent ) {
    104104                                if ( !in_array( $ocomponent, $trimmed ) ) {
     
    109109        }
    110110
    111         // On new install, set active components to default
     111        // On new install, set active components to default.
    112112        if ( empty( $active_components ) ) {
    113113                $active_components = $default_components;
    114114        }
    115115
    116         // Core component is always active
     116        // Core component is always active.
    117117        $active_components['core'] = $all_components['core'];
    118118        $inactive_components       = array_diff( array_keys( $all_components ) , array_keys( $active_components ) );
    119119
    120         /** Display ***************************************************************/
    121 
    122         // Get the total count of all plugins
     120        /** Display **************************************************************
     121         */
     122
     123        // Get the total count of all plugins.
    123124        $all_count = count( $all_components );
    124125        $page      = bp_core_do_network_admin()  ? 'settings.php' : 'options-general.php';
     
    237238 *
    238239 * @since 1.6.0
     240 *
    239241 * @todo Use settings API when it supports saving network settings
    240242 */
    241243function bp_core_admin_components_settings_handler() {
    242244
    243         // Bail if not saving settings
     245        // Bail if not saving settings.
    244246        if ( ! isset( $_POST['bp-admin-component-submit'] ) )
    245247                return;
    246248
    247         // Bail if nonce fails
     249        // Bail if nonce fails.
    248250        if ( ! check_admin_referer( 'bp-admin-component-setup' ) )
    249251                return;
    250252
    251         // Settings form submitted, now save the settings. First, set active components
     253        // Settings form submitted, now save the settings. First, set active components.
    252254        if ( isset( $_POST['bp_components'] ) ) {
    253255
    254                 // Load up BuddyPress
     256                // Load up BuddyPress.
    255257                $bp = buddypress();
    256258
    257                 // Save settings and upgrade schema
     259                // Save settings and upgrade schema.
    258260                require_once( $bp->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' );
    259261
     
    269271        $base_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components', 'updated' => 'true' ), 'admin.php' ) );
    270272
    271         // Redirect
     273        // Redirect.
    272274        wp_redirect( $base_url );
    273275        die();
     
    299301 * @param array $submitted This is the array of component settings coming from the POST
    300302 *                         global. You should stripslashes_deep() before passing to this function.
    301  *
    302303 * @return array The calculated list of component settings
    303304 */
     
    318319                                        unset( $current_components[ $retired_component ] );
    319320                                }
    320                         }
    321                         // fall through
     321                        } // Fall through.
     322
    322323
    323324                case 'inactive' :
     
    344345 *
    345346 * @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.
    348348 */
    349349function bp_core_admin_get_components( $type = 'all' ) {
    350350
    351         // Required components
     351        // Required components.
    352352        $required_components = array(
    353353                'core' => array(
     
    361361        );
    362362
    363         // Retired components
     363        // Retired components.
    364364        $retired_components = array(
    365365                'forums' => array(
     
    369369        );
    370370
    371         // Optional core components
     371        // Optional core components.
    372372        $optional_components = array(
    373373                'xprofile' => array(
     
    410410
    411411
    412         // Add blogs tracking if multisite
     412        // Add blogs tracking if multisite.
    413413        if ( is_multisite() ) {
    414414                $optional_components['blogs']['description'] = __( 'Record activity for new sites, posts, and comments across your network.', 'buddypress' );
     
    440440         * @param string $type       Type of component list requested.
    441441         *                           Possible values include 'all', 'optional',
    442          *                                                      'retired', 'required'.
     442         *                          'retired', 'required'.
    443443         */
    444444        return apply_filters( 'bp_core_admin_get_components', $components, $type );
  • trunk/src/bp-core/admin/bp-core-admin-functions.php

    r10267 r10354  
    1515 * Initializes the wp-admin area "BuddyPress" menus and sub menus.
    1616 *
    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.
    1918 */
    2019function bp_core_admin_menu_init() {
     
    3231 * @global array $_registered_pages
    3332 * @global array $submenu
     33 *
    3434 * @since 1.6.0
    3535 */
     
    3838
    3939        // 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.
    4141        if ( ! isset( $submenu['bp-general-settings'] ) ) {
    4242                return;
     
    5252        }
    5353
    54         // This removes the top-level menu
     54        // This removes the top-level menu.
    5555        remove_submenu_page( 'bp-general-settings', 'bp-general-settings' );
    5656        remove_menu_page( 'bp-general-settings' );
    5757
    58         // These stop people accessing the URL directly
     58        // These stop people accessing the URL directly.
    5959        unset( $_parent_pages['bp-general-settings'] );
    6060        unset( $_registered_pages['toplevel_page_bp-general-settings'] );
     
    7171 * @global string $plugin_page
    7272 * @global array $submenu
     73 *
    7374 * @since 1.6.0
    7475 */
     
    7677        global $plugin_page, $submenu_file;
    7778
    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.
    7980        if ( ! in_array( $plugin_page, array( 'bp-activity', 'bp-general-settings', ) ) ) {
    8081                $submenu_file = 'bp-components';
    8182        }
    8283
    83         // Network Admin > Tools
     84        // Network Admin > Tools.
    8485        if ( in_array( $plugin_page, array( 'bp-tools', 'available-tools' ) ) ) {
    8586                $submenu_file = $plugin_page;
     
    9394 *
    9495 * @see bp_core_admin_backpat_menu()
     96 *
    9597 * @since 1.6.0
     98 *
    9699 * @todo Add convenience links into the markup once new positions are finalised.
    97100 */
     
    125128function bp_core_print_admin_notices() {
    126129
    127         // Only the super admin should see messages
     130        // Only the super admin should see messages.
    128131        if ( ! bp_current_user_can( 'bp_moderate' ) ) {
    129132                return;
     
    170173function bp_core_add_admin_notice( $notice = '', $type = 'updated' ) {
    171174
    172         // Do not add if the notice is empty
     175        // Do not add if the notice is empty.
    173176        if ( empty( $notice ) ) {
    174177                return;
    175178        }
    176179
    177         // Double check the object before referencing it
     180        // Double check the object before referencing it.
    178181        if ( ! isset( buddypress()->admin->notices ) ) {
    179182                buddypress()->admin->notices = array();
    180183        }
    181184
    182         // Add the notice
     185        // Add the notice.
    183186        buddypress()->admin->notices[] = array(
    184187                'message' => $notice,
     
    198201 * @global WPDB $wpdb WordPress DB object
    199202 * @global WP_Rewrite $wp_rewrite
     203 *
    200204 * @since 1.2.0
    201205 */
     
    203207        global $wp_rewrite, $wpdb;
    204208
    205         // Only the super admin gets warnings
     209        // Only the super admin gets warnings.
    206210        if ( ! bp_current_user_can( 'bp_moderate' ) ) {
    207211                return;
    208212        }
    209213
    210         // Bail in user admin
     214        // Bail in user admin.
    211215        if ( is_user_admin() ) {
    212216                return;
    213217        }
    214218
    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.
    216220        if ( is_multisite() && bp_core_do_network_admin() && ! bp_is_root_blog() ) {
    217221                return;
    218222        }
    219223
    220         // Bail if in network admin, and BuddyPress is not network activated
     224        // Bail if in network admin, and BuddyPress is not network activated.
    221225        if ( is_network_admin() && ! bp_is_network_activated() ) {
    222226                return;
     
    237241        }
    238242
    239         // Add notice if no rewrite rules are enabled
     243        // Add notice if no rewrite rules are enabled.
    240244        if ( empty( $wp_rewrite->permalink_structure ) ) {
    241245                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' );
    242246        }
    243247
    244         // Get BuddyPress instance
     248        // Get BuddyPress instance.
    245249        $bp = buddypress();
    246250
    247251        /**
    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).
    249253         */
    250254        $orphaned_components = array();
    251255        $wp_page_components  = array();
    252256
    253         // Only components with 'has_directory' require a WP page to function
     257        // Only components with 'has_directory' require a WP page to function.
    254258        foreach( array_keys( $bp->loaded_components ) as $component_id ) {
    255259                if ( !empty( $bp->{$component_id}->has_directory ) ) {
     
    275279        }
    276280
    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.
    278283        if ( empty( $bp->pages->members ) ) {
    279284                $bp->pages = bp_core_get_directory_pages();
     
    288293        // Special case: If the Forums component is orphaned, but the bbPress 1.x installation is
    289294        // 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.
    291296        if ( isset( $bp->forums->name ) && in_array( $bp->forums->name, $orphaned_components ) && !bp_forums_is_installed_correctly() ) {
    292297                $forum_key = array_search( $bp->forums->name, $orphaned_components );
     
    312317                }
    313318
    314                 // Make sure that there are no duplicate duplicates :)
     319                // Make sure that there are no duplicate duplicates :).
    315320                $dupe_names = array_unique( $dupe_names );
    316321        }
    317322
    318         // If there are duplicates, post a message about them
     323        // If there are duplicates, post a message about them.
    319324        if ( !empty( $dupe_names ) ) {
    320325                $admin_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) );
     
    341346function bp_do_activation_redirect() {
    342347
    343         // Bail if no activation redirect
     348        // Bail if no activation redirect.
    344349        if ( ! get_transient( '_bp_activation_redirect' ) ) {
    345350                return;
    346351        }
    347352
    348         // Delete the redirect transient
     353        // Delete the redirect transient.
    349354        delete_transient( '_bp_activation_redirect' );
    350355
    351         // Bail if activating from network, or bulk
     356        // Bail if activating from network, or bulk.
    352357        if ( isset( $_GET['activate-multi'] ) ) {
    353358                return;
     
    360365        }
    361366
    362         // Redirect to BuddyPress about page
     367        // Redirect to BuddyPress about page.
    363368        wp_safe_redirect( add_query_arg( $query_args, bp_get_admin_url( 'index.php' ) ) );
    364369}
     
    387392        $tabs         = apply_filters( 'bp_core_admin_tabs', bp_core_get_admin_tabs( $active_tab ) );
    388393
    389         // Loop through tabs and build navigation
     394        // Loop through tabs and build navigation.
    390395        foreach ( array_values( $tabs ) as $tab_data ) {
    391396                $is_current = (bool) ( $tab_data['name'] == $active_tab );
     
    410415 *
    411416 * @param string $active_tab Name of the tab that is active. Optional.
    412  *
    413417 * @return string
    414418 */
     
    429433        );
    430434
    431         // If forums component is active, add additional tab
     435        // If forums component is active, add additional tab.
    432436        if ( bp_is_active( 'forums' ) && class_exists( 'BP_Forums_Component' ) ) {
    433437
    434                 // enqueue thickbox
     438                // Enqueue thickbox.
    435439                wp_enqueue_script( 'thickbox' );
    436440                wp_enqueue_style( 'thickbox' );
     
    455459
    456460/**
    457  * adds contextual help to BuddyPress admin pages.
     461 * Adds contextual help to BuddyPress admin pages.
    458462 *
    459463 * @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.
    463467 */
    464468function bp_core_add_contextual_help( $screen = '' ) {
     
    468472        switch ( $screen->id ) {
    469473
    470                 // Component page
     474                // Component page.
    471475                case 'settings_page_bp-components' :
    472476
    473                         // help tabs
     477                        // Help tabs.
    474478                        $screen->add_help_tab( array(
    475479                                'id'      => 'bp-comp-overview',
     
    478482                        ) );
    479483
    480                         // help panel - sidebar links
     484                        // Help panel - sidebar links.
    481485                        $screen->set_help_sidebar(
    482486                                '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
     
    486490                        break;
    487491
    488                 // Pages page
     492                // Pages page.
    489493                case 'settings_page_bp-page-settings' :
    490494
    491                         // Help tabs
     495                        // Help tabs.
    492496                        $screen->add_help_tab( array(
    493497                                'id' => 'bp-page-overview',
     
    496500                        ) );
    497501
    498                         // Help panel - sidebar links
     502                        // Help panel - sidebar links.
    499503                        $screen->set_help_sidebar(
    500504                                '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
     
    505509                        break;
    506510
    507                 // Settings page
     511                // Settings page.
    508512                case 'settings_page_bp-settings' :
    509513
    510                         // Help tabs
     514                        // Help tabs.
    511515                        $screen->add_help_tab( array(
    512516                                'id'      => 'bp-settings-overview',
     
    515519                        ) );
    516520
    517                         // Help panel - sidebar links
     521                        // Help panel - sidebar links.
    518522                        $screen->set_help_sidebar(
    519523                                '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
     
    524528                        break;
    525529
    526                 // Profile fields page
     530                // Profile fields page.
    527531                case 'users_page_bp-profile-setup' :
    528532
    529                         // Help tabs
     533                        // Help tabs.
    530534                        $screen->add_help_tab( array(
    531535                                'id'      => 'bp-profile-overview',
     
    534538                        ) );
    535539
    536                         // Help panel - sidebar links
     540                        // Help panel - sidebar links.
    537541                        $screen->set_help_sidebar(
    538542                                '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
     
    547551
    548552/**
    549  * renders contextual help content to contextual help tabs.
     553 * Renders contextual help content to contextual help tabs.
    550554 *
    551555 * @since 1.7.0
    552556 *
    553  * @param string $tab
    554  *
     557 * @param string $tab Current help content tab.
    555558 * @return string
    556559 */
     
    579582        }
    580583
    581         // Wrap text in a paragraph tag
     584        // Wrap text in a paragraph tag.
    582585        if ( !empty( $retval ) ) {
    583586                $retval = '<p>' . $retval . '</p>';
     
    598601function bp_admin_separator() {
    599602
    600         // Bail if BuddyPress is not network activated and viewing network admin
     603        // Bail if BuddyPress is not network activated and viewing network admin.
    601604        if ( is_network_admin() && ! bp_is_network_activated() ) {
    602605                return;
    603606        }
    604607
    605         // Bail if BuddyPress is network activated and viewing site admin
     608        // Bail if BuddyPress is network activated and viewing site admin.
    606609        if ( ! is_network_admin() && bp_is_network_activated() ) {
    607610                return;
    608611        }
    609612
    610         // Prevent duplicate separators when no core menu items exist
     613        // Prevent duplicate separators when no core menu items exist.
    611614        if ( ! bp_current_user_can( 'bp_moderate' ) ) {
    612615                return;
     
    628631 *
    629632 * @since 1.7.0
     633 *
    630634 * @uses bp_current_user_can() To check users capability on root blog.
    631635 *
    632636 * @param bool $menu_order Menu order.
    633  *
    634  * @return bool Always true
     637 * @return bool Always true.
    635638 */
    636639function bp_admin_custom_menu_order( $menu_order = false ) {
    637640
    638         // Bail if user cannot see admin pages
     641        // Bail if user cannot see admin pages.
    639642        if ( ! bp_current_user_can( 'bp_moderate' ) ) {
    640643                return $menu_order;
     
    648651 *
    649652 * @since 1.7.0
     653 *
    650654 * @uses bp_current_user_can() To check users capability on root blog.
    651655 *
    652656 * @param array $menu_order Menu Order.
    653  *
    654  * @return array Modified menu order
     657 * @return array Modified menu order.
    655658 */
    656659function bp_admin_menu_order( $menu_order = array() ) {
    657660
    658         // Bail if user cannot see admin pages
     661        // Bail if user cannot see admin pages.
    659662        if ( empty( $menu_order ) || ! bp_current_user_can( 'bp_moderate' ) ) {
    660663                return $menu_order;
    661664        }
    662665
    663         // Initialize our custom order array
     666        // Initialize our custom order array.
    664667        $bp_menu_order = array();
    665668
    666         // Menu values
     669        // Menu values.
    667670        $last_sep     = is_network_admin() ? 'separator1' : 'separator2';
    668671
     
    676679        $custom_menus = (array) apply_filters( 'bp_admin_menu_order', array() );
    677680
    678         // Bail if no components have top level admin pages
     681        // Bail if no components have top level admin pages.
    679682        if ( empty( $custom_menus ) ) {
    680683                return $menu_order;
    681684        }
    682685
    683         // Add our separator to beginning of array
     686        // Add our separator to beginning of array.
    684687        array_unshift( $custom_menus, 'separator-buddypress' );
    685688
    686         // Loop through menu order and do some rearranging
     689        // Loop through menu order and do some rearranging.
    687690        foreach ( (array) $menu_order as $item ) {
    688691
    689                 // Position BuddyPress menus above appearance
     692                // Position BuddyPress menus above appearance.
    690693                if ( $last_sep == $item ) {
    691694
    692                         // Add our custom menus
     695                        // Add our custom menus.
    693696                        foreach( (array) $custom_menus as $custom_menu ) {
    694697                                if ( array_search( $custom_menu, $menu_order ) ) {
     
    697700                        }
    698701
    699                         // Add the appearance separator
     702                        // Add the appearance separator.
    700703                        $bp_menu_order[] = $last_sep;
    701704
    702                 // Skip our menu items
     705                // Skip our menu items.
    703706                } elseif ( ! in_array( $item, $custom_menus ) ) {
    704707                        $bp_menu_order[] = $item;
     
    706709        }
    707710
    708         // Return our custom order
     711        // Return our custom order.
    709712        return $bp_menu_order;
    710713}
     
    727730        $action = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
    728731
    729         // If the bottom is set, let it override the action
     732        // If the bottom is set, let it override the action.
    730733        if ( ! empty( $_REQUEST['action2'] ) && $_REQUEST['action2'] != "-1" ) {
    731734                $action = $_REQUEST['action2'];
     
    846849 * @param array  $actions     User row action links.
    847850 * @param object $user_object Current user information.
    848  *
    849851 * @return array $actions User row action links.
    850852 */
    851853function bp_core_admin_user_row_actions( $actions, $user_object ) {
    852854
    853         // Setup the $user_id variable from the current user object
     855        // Setup the $user_id variable from the current user object.
    854856        $user_id = 0;
    855857        if ( !empty( $user_object->ID ) ) {
     
    857859        }
    858860
    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.
    860862        if ( current_user_can( 'edit_user', $user_id ) && ( bp_loggedin_user_id() !== $user_id ) ) {
    861863
    862                 // Admin URL could be single site or network
     864                // Admin URL could be single site or network.
    863865                $url = bp_get_admin_url( 'users.php' );
    864866
    865                 // If spammed, create unspam link
     867                // If spammed, create unspam link.
    866868                if ( bp_is_user_spammer( $user_id ) ) {
    867869                        $url             = add_query_arg( array( 'action' => 'ham', 'user' => $user_id ), $url );
     
    869871                        $actions['ham']  = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $unspam_link ), esc_html__( 'Not Spam', 'buddypress' ) );
    870872
    871                 // If not already spammed, create spam link
     873                // If not already spammed, create spam link.
    872874                } else {
    873875                        $url             = add_query_arg( array( 'action' => 'spam', 'user' => $user_id ), $url );
     
    877879        }
    878880
    879         // Create a "View" link
     881        // Create a "View" link.
    880882        $url             = bp_core_get_user_domain( $user_id );
    881883        $actions['view'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $url ), esc_html__( 'View', 'buddypress' ) );
    882884
    883         // Return new actions
     885        // Return new actions.
    884886        return $actions;
    885887}
     
    892894function bp_core_admin_user_manage_spammers() {
    893895
    894         // Print our inline scripts on non-Multisite
     896        // Print our inline scripts on non-Multisite.
    895897        add_action( 'admin_footer', 'bp_core_admin_user_spammed_js' );
    896898
     
    899901        $mode    = isset( $_POST['mode'] ) ? $_POST['mode'] : false;
    900902
    901         // if this is a multisite, bulk request, stop now!
     903        // If this is a multisite, bulk request, stop now!
    902904        if ( 'list' == $mode ) {
    903905                return;
    904906        }
    905907
    906         // Process a spam/ham request
     908        // Process a spam/ham request.
    907909        if ( ! empty( $action ) && in_array( $action, array( 'spam', 'ham' ) ) ) {
    908910
     
    919921                $status = ( $action == 'spam' ) ? 'spam' : 'ham';
    920922
    921                 // Process the user
     923                // Process the user.
    922924                bp_core_process_spammer_status( $user_id, $status );
    923925
     
    927929        }
    928930
    929         // Display feedback
     931        // Display feedback.
    930932        if ( ! empty( $updated ) && in_array( $updated, array( 'marked-spam', 'marked-ham' ) ) ) {
    931933
  • trunk/src/bp-core/admin/bp-core-admin-schema.php

    r10108 r10354  
    1616 *
    1717 * @global $wpdb $wpdb
     18 *
    1819 * @return string The default database character-set, if set.
    1920 */
     
    4041        bp_pre_schema_upgrade();
    4142
    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.
    4344        if ( empty( $active_components ) ) {
    4445
     
    4748        }
    4849
    49         // Install Activity Streams even when inactive (to store last_activity data)
     50        // Install Activity Streams even when inactive (to store last_activity data).
    5051        bp_core_install_activity_streams();
    5152
    52         // Install the signups table
     53        // Install the signups table.
    5354        bp_core_maybe_install_signups();
    5455
    55         // Notifications
     56        // Notifications.
    5657        if ( !empty( $active_components['notifications'] ) ) {
    5758                bp_core_install_notifications();
    5859        }
    5960
    60         // Friend Connections
     61        // Friend Connections.
    6162        if ( !empty( $active_components['friends'] ) ) {
    6263                bp_core_install_friends();
    6364        }
    6465
    65         // Extensible Groups
     66        // Extensible Groups.
    6667        if ( !empty( $active_components['groups'] ) ) {
    6768                bp_core_install_groups();
    6869        }
    6970
    70         // Private Messaging
     71        // Private Messaging.
    7172        if ( !empty( $active_components['messages'] ) ) {
    7273                bp_core_install_private_messaging();
    7374        }
    7475
    75         // Extended Profiles
     76        // Extended Profiles.
    7677        if ( !empty( $active_components['xprofile'] ) ) {
    7778                bp_core_install_extended_profiles();
    7879        }
    7980
    80         // Blog tracking
     81        // Blog tracking.
    8182        if ( !empty( $active_components['blogs'] ) ) {
    8283                bp_core_install_blog_tracking();
     
    345346        $bp_prefix       = bp_core_get_table_prefix();
    346347
    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.
    348349        if ( ! bp_get_option( 'bp-xprofile-base-group-name' ) ) {
    349350                bp_update_option( 'bp-xprofile-base-group-name', _x( 'General', 'First field-group name', 'buddypress' ) );
     
    405406        dbDelta( $sql );
    406407
    407         // Insert the default group and fields
     408        // Insert the default group and fields.
    408409        $insert_sql = array();
    409410
     
    466467        global $wpdb;
    467468
    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.
    469470        require_once( buddypress()->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' );
    470471        require_once( ABSPATH                  . 'wp-admin/includes/upgrade.php'     );
    471472
    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.
    473474        $wpdb->signups = $wpdb->base_prefix . 'signups';
    474475
    475         // Use WP's core CREATE TABLE query
     476        // Use WP's core CREATE TABLE query.
    476477        $create_queries = wp_get_db_schema( 'ms_global' );
    477478        if ( ! is_array( $create_queries ) ) {
     
    480481        }
    481482
    482         // Filter out all the queries except wp_signups
     483        // Filter out all the queries except wp_signups.
    483484        foreach ( $create_queries as $key => $query ) {
    484485                if ( preg_match( "|CREATE TABLE ([^ ]*)|", $query, $matches ) ) {
     
    489490        }
    490491
    491         // Run WordPress's database upgrader
     492        // Run WordPress's database upgrader.
    492493        if ( ! empty( $create_queries ) ) {
    493494                dbDelta( $create_queries );
     
    513514        global $wpdb;
    514515
    515         // Bail if global tables should not be upgraded
     516        // Bail if global tables should not be upgraded.
    516517        if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
    517518                return;
    518519        }
    519520
    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.
    521522        $wpdb->signups = $wpdb->base_prefix . 'signups';
    522523
    523         // Attempt to alter the signups table
     524        // Attempt to alter the signups table.
    524525        $wpdb->query( "ALTER TABLE {$wpdb->signups} ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST" );
    525526        $wpdb->query( "ALTER TABLE {$wpdb->signups} DROP INDEX domain" );
  • trunk/src/bp-core/admin/bp-core-admin-settings.php

    r10229 r10354  
    111111 * @since 1.6.0
    112112 *
    113  * @param bool $value
    114  *
     113 * @param bool $value Whether or not to sanitize.
    115114 * @return bool
    116115 */
     
    232231
    233232/**
    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 *
    237237 * @uses checked() To display the checked attribute.
    238238 * @uses bp_get_option() To get the config location.
     
    270270function bp_core_admin_settings() {
    271271
    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.
    273273        $form_action = add_query_arg( 'page', 'bp-settings', bp_get_admin_url( 'admin.php' ) );
    274274
     
    306306
    307307                // 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.
    309309                if ( isset( $wp_settings_fields['buddypress'] ) ) {
    310310                        foreach( (array) $wp_settings_fields['buddypress'] as $section => $settings ) {
     
    333333                        // Note: Each of these options is represented by its opposite in the UI
    334334                        // 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.
    336336                        $value = isset( $_POST[$legacy_option] ) ? '' : 1;
    337337                        bp_update_option( $legacy_option, $value );
     
    350350 * @uses bp_get_bp_form_option()
    351351 *
    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.
    355355 */
    356356function bp_form_option( $option, $default = '' , $slug = false ) {
     
    366366         * @uses apply_filters()
    367367         *
    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.
    372371         * @return string
    373372         */
    374373        function bp_get_form_option( $option, $default = '', $slug = false ) {
    375374
    376                 // Get the option and sanitize it
     375                // Get the option and sanitize it.
    377376                $value = bp_get_option( $option, $default );
    378377
     
    388387                         */
    389388                        $value = esc_attr( apply_filters( 'editable_slug', $value ) );
    390                 } else { // Not a slug
     389                } else { // Not a slug.
    391390                        $value = esc_attr( $value );
    392391                }
    393392
    394                 // Fallback to default
     393                // Fallback to default.
    395394                if ( empty( $value ) )
    396395                        $value = $default;
  • trunk/src/bp-core/admin/bp-core-admin-slugs.php

    r10229 r10354  
    1414 *
    1515 * @since 1.6.0
     16 *
    1617 * @todo Use settings API
    1718 * @uses bp_core_admin_component_options()
     
    4243 * Creates reusable markup for page setup on the Components and Pages dashboard panel.
    4344 *
    44  * @package BuddyPress
    4545 * @since 1.6.0
     46 *
    4647 * @todo Use settings API
    4748 */
     
    4950        $bp = buddypress();
    5051
    51         // Get the existing WP pages
     52        // Get the existing WP pages.
    5253        $existing_pages = bp_core_get_directory_page_ids();
    5354
     
    5657        $directory_pages = array();
    5758
    58         // Loop through loaded components and collect directories
     59        // Loop through loaded components and collect directories.
    5960        if ( is_array( $bp->loaded_components ) ) {
    6061                foreach( $bp->loaded_components as $component_slug => $component_id ) {
    6162
    62                         // Only components that need directories should be listed here
     63                        // Only components that need directories should be listed here.
    6364                        if ( isset( $bp->{$component_id} ) && !empty( $bp->{$component_id}->has_directory ) ) {
    6465
    65                                 // component->name was introduced in BP 1.5, so we must provide a fallback
     66                                // The component->name property was introduced in BP 1.5, so we must provide a fallback.
    6667                                $directory_pages[$component_id] = !empty( $bp->{$component_id}->name ) ? $bp->{$component_id}->name : ucwords( $component_id );
    6768                        }
     
    6970        }
    7071
    71         /** Directory Display *****************************************************/
     72        /** Directory Display ****************************************************
     73         */
    7274
    7375        /**
     
    139141        endif;
    140142
    141         /** Static Display ********************************************************/
    142 
    143         // Static pages
     143        /** Static Display *******************************************************
     144         */
     145
     146        // Static pages.
    144147        $static_pages = array(
    145148                'register' => __( 'Register', 'buddypress' ),
     
    216219 *
    217220 * @since 1.6.0
     221 *
    218222 * @todo Use settings API
    219223 */
     
    224228                        return false;
    225229
    226                 // Then, update the directory pages
     230                // Then, update the directory pages.
    227231                if ( isset( $_POST['bp_pages'] ) ) {
    228232
  • trunk/src/bp-core/admin/bp-core-admin-tools.php

    r10229 r10354  
    7575        check_admin_referer( 'bp-do-counts' );
    7676
    77         // Stores messages
     77        // Stores messages.
    7878        $messages = array();
    7979
     
    104104        // Members:
    105105        // - member count
    106         // - last_activity migration (2.0)
     106        // - last_activity migration (2.0).
    107107        $repair_list[20] = array(
    108108                'bp-total-member-count',
     
    118118
    119119        // Friends:
    120         // - user friend count
     120        // - user friend count.
    121121        if ( bp_is_active( 'friends' ) ) {
    122122                $repair_list[0] = array(
     
    128128
    129129        // Groups:
    130         // - user group count
     130        // - user group count.
    131131        if ( bp_is_active( 'groups' ) ) {
    132132                $repair_list[10] = array(
     
    138138
    139139        // Blogs:
    140         // - user blog count
     140        // - user blog count.
    141141        if ( bp_is_active( 'blogs' ) ) {
    142142                $repair_list[90] = array(
     
    183183        $bp = buddypress();
    184184
    185         // Walk through all users on the site
     185        // Walk through all users on the site.
    186186        $total_users = $wpdb->get_row( "SELECT count(ID) as c FROM {$wpdb->users}" )->c;
    187187
     
    191191                $offset = 0;
    192192                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.
    194194                        $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 ) );
    195195
    196196                        // The previous query will turn up duplicates, so we
    197                         // filter them here
     197                        // filter them here.
    198198                        foreach ( $friendships as $friendship ) {
    199199                                if ( ! isset( $updated[ $friendship->initiator_user_id ] ) ) {
     
    241241        $bp = buddypress();
    242242
    243         // Walk through all users on the site
     243        // Walk through all users on the site.
    244244        $total_users = $wpdb->get_row( "SELECT count(ID) as c FROM {$wpdb->users}" )->c;
    245245
     
    248248                $offset = 0;
    249249                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.
    251251                        $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 ) );
    252252
     
    273273function bp_admin_repair_blog_records() {
    274274
    275         // Description of this tool, displayed to the user
     275        // Description of this tool, displayed to the user.
    276276        $statement = __( 'Repopulating Blogs records&hellip; %s', 'buddypress' );
    277277
    278         // Default to failure text
     278        // Default to failure text.
    279279        $result    = __( 'Failed!',   'buddypress' );
    280280
    281         // Default to unrepaired
     281        // Default to unrepaired.
    282282        $repair    = false;
    283283
    284         // Run function if blogs component is active
     284        // Run function if blogs component is active.
    285285        if ( bp_is_active( 'blogs' ) ) {
    286286                $repair = bp_blogs_record_existing_blogs();
    287287        }
    288288
    289         // Setup success/fail messaging
     289        // Setup success/fail messaging.
    290290        if ( true === $repair ) {
    291291                $result = __( 'Complete!', 'buddypress' );
     
    328328 * @param string      $message Feedback message.
    329329 * @param string|bool $class   Unused.
    330  *
    331330 * @return bool
    332331 */
Note: See TracChangeset for help on using the changeset viewer.