Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/15/2015 07:57:03 PM (9 years ago)
Author:
tw2113
Message:

[Samus Aran]
I first battled the documentation inconsistencies on planet Zebes. It was there that I foiled the plans of the
Space Pirate leader Mother Brain to use the issues to attack galactic civilization...

I next fought the inconsistencies on their homeworld SR388. I completely eradicated them except for an @since tag,
which after hatching followed me like a confused child...

I personally delivered it to the Galactic Research Station at Ceres so scientists could study its energy production qualities...

The scientists' findings were astounding! They discovered that the powers of the docs inconsistencies
might be harnessed for the good of galactic civilization!

Satisfied that all was well, I left the station to seek a new bounty to hunt. But, I had hardly gone beyond the asteroid
belt when I picked up a distress signal!

Ceres station was under attack!

More documentation cleanup for part of BP-Core component.

See #6398.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-functions.php

    r10110 r10356  
    4747     *
    4848     * @since 1.6.0
     49     *
    4950     * @return string The BuddyPress database version.
    5051     */
     
    109110 * @since 2.2.0
    110111 *
    111  * @param  array      $items The items to be sorted. Its constituent items can be either associative arrays or objects.
    112  * @param  string|int $key   The array index or property name to sort by.
    113  * @param  string     $type  Sort type. 'alpha' for alphabetical, 'num' for numeric. Default: 'alpha'.
    114  * @return array      $items The sorted array.
     112 * @param array      $items The items to be sorted. Its constituent items can be either associative arrays or objects.
     113 * @param string|int $key   The array index or property name to sort by.
     114 * @param string     $type  Sort type. 'alpha' for alphabetical, 'num' for numeric. Default: 'alpha'.
     115 * @return array $items The sorted array.
    115116 */
    116117function bp_sort_by_key( $items, $key, $type = 'alpha' ) {
     
    158159 * @since 1.9.0
    159160 *
    160  * @param  array      $items The items to be sorted. Its constituent items can be either associative arrays or objects.
    161  * @param  string|int $key   The array index or property name to sort by.
    162  * @return array      $items The sorted array.
     161 * @param array      $items The items to be sorted. Its constituent items can be either associative arrays or objects.
     162 * @param string|int $key   The array index or property name to sort by.
     163 * @return array $items The sorted array.
    163164 */
    164165function bp_alpha_sort_by_key( $items, $key ) {
     
    171172 * @param int  $number   The number to be formatted.
    172173 * @param bool $decimals Whether to use decimals. See {@link number_format_i18n()}.
    173  *
    174174 * @return string The formatted number.
    175175 */
    176176function bp_core_number_format( $number = 0, $decimals = false ) {
    177177
    178     // Force number to 0 if needed
     178    // Force number to 0 if needed.
    179179    if ( ! is_numeric( $number ) ) {
    180180        $number = 0;
     
    227227 * @param array $old_args_keys Old argument indexs, keyed to their positions.
    228228 * @param array $func_args     The parameters passed to the originating function.
    229  *
    230229 * @return array $new_args The parsed arguments.
    231230 */
     
    256255 * @param array        $defaults   Array that serves as the defaults.
    257256 * @param string       $filter_key String to key the filters from.
    258  *
    259257 * @return array Merged user defined values with defaults.
    260258 */
    261259function bp_parse_args( $args, $defaults = array(), $filter_key = '' ) {
    262260
    263     // Setup a temporary array from $args
     261    // Setup a temporary array from $args.
    264262    if ( is_object( $args ) ) {
    265263        $r = get_object_vars( $args );
     
    270268    }
    271269
    272     // Passively filter the args before the parse
     270    // Passively filter the args before the parse.
    273271    if ( !empty( $filter_key ) ) {
    274272
     
    285283    }
    286284
    287     // Parse
     285    // Parse.
    288286    if ( is_array( $defaults ) && !empty( $defaults ) ) {
    289287        $r = array_merge( $defaults, $r );
    290288    }
    291289
    292     // Aggressively filter the args after the parse
     290    // Aggressively filter the args after the parse.
    293291    if ( !empty( $filter_key ) ) {
    294292
     
    305303    }
    306304
    307     // Return the parsed results
     305    // Return the parsed results.
    308306    return $r;
    309307}
     
    316314 * @since 2.2.0
    317315 *
    318  * @param  string $page_arg The $_REQUEST argument to look for.
    319  * @param  int    $page     The original page value to fall back to.
    320  *
    321  * @return int              A sanitized integer value, good for pagination.
     316 * @param string $page_arg The $_REQUEST argument to look for.
     317 * @param int    $page     The original page value to fall back to.
     318 * @return int A sanitized integer value, good for pagination.
    322319 */
    323320function bp_sanitize_pagination_arg( $page_arg = '', $page = 1 ) {
    324321
    325     // Check if request overrides exist
     322    // Check if request overrides exist.
    326323    if ( isset( $_REQUEST[ $page_arg ] ) ) {
    327324
    328         // Get the absolute integer value of the override
     325        // Get the absolute integer value of the override.
    329326        $int = absint( $_REQUEST[ $page_arg ] );
    330327
    331328        // If override is 0, do not use it. This prevents unlimited result sets.
    332         // @see https://buddypress.trac.wordpress.org/ticket/5796
     329        // @see https://buddypress.trac.wordpress.org/ticket/5796.
    333330        if ( $int ) {
    334331            $page = $int;
     
    348345 *
    349346 * @param string $order The 'order' string, as passed to the SQL constructor.
    350  *
    351347 * @return string The sanitized value 'DESC' or 'ASC'.
    352348 */
     
    369365 *
    370366 * @param string $text The raw text to be escaped.
    371  *
    372367 * @return string Text in the form of a LIKE phrase. Not SQL safe. Run through
    373368 *                wpdb::prepare() before use.
     
    420415function bp_use_wp_admin_bar() {
    421416
    422     // Default to true (to avoid loading deprecated BuddyBar code)
     417    // Default to true (to avoid loading deprecated BuddyBar code).
    423418    $use_admin_bar = true;
    424419
     
    464459    );
    465460
    466     // only add legacy forums if it is enabled
    467     // prevents conflicts with bbPress, which also uses the same 'forums' id
     461    // Only add legacy forums if it is enabled
     462    // prevents conflicts with bbPress, which also uses the same 'forums' id.
    468463    if ( class_exists( 'BP_Forums_Component' ) ) {
    469464        $components[] = 'forums';
     
    481476 *                       pages. When running save routines, use 'all' to avoid removing data related to inactive
    482477 *                       components. Default: 'active'.
    483  *
    484478 * @return array|string An array of page IDs, keyed by component names, or an
    485479 *                      empty string if the list is not found.
     
    488482    $page_ids = bp_get_option( 'bp-pages' );
    489483
    490     // Ensure that empty indexes are unset. Should only matter in edge cases
     484    // Ensure that empty indexes are unset. Should only matter in edge cases.
    491485    if ( !empty( $page_ids ) && is_array( $page_ids ) ) {
    492486        foreach( (array) $page_ids as $component_name => $page_id ) {
     
    526520 * Store the list of BP directory pages in the appropriate meta table.
    527521 *
    528  * bp-pages data is stored in site_options (falls back to options on non-MS),
     522 * The bp-pages data is stored in site_options (falls back to options on non-MS),
    529523 * in an array keyed by blog_id. This allows you to change your
    530524 * bp_get_root_blog_id() and go through the setup process again.
     
    549543    global $wpdb;
    550544
    551     // Look in cache first
     545    // Look in cache first.
    552546    $pages = wp_cache_get( 'directory_pages', 'bp' );
    553547
    554548    if ( false === $pages ) {
    555549
    556         // Set pages as standard class
     550        // Set pages as standard class.
    557551        $pages = new stdClass;
    558552
    559         // Get pages and IDs
     553        // Get pages and IDs.
    560554        $page_ids = bp_core_get_directory_page_ids();
    561555        if ( !empty( $page_ids ) ) {
    562556
    563557            // Always get page data from the root blog, except on multiblog mode, when it comes
    564             // from the current blog
     558            // from the current blog.
    565559            $posts_table_name = bp_is_multiblog_mode() ? $wpdb->posts : $wpdb->get_blog_prefix( bp_get_root_blog_id() ) . 'posts';
    566560            $page_ids_sql     = implode( ',', wp_parse_id_list( $page_ids ) );
     
    579573                        $slug[]                        = $page_name->post_name;
    580574
    581                         // Get the slug
     575                        // Get the slug.
    582576                        while ( $page_name->post_parent != 0 ) {
    583577                            $parent                 = $wpdb->get_results( $wpdb->prepare( "SELECT post_name, post_parent FROM {$posts_table_name} WHERE ID = %d", $page_name->post_parent ) );
     
    635629    $pages = bp_core_get_directory_page_ids( 'all' );
    636630
    637     // Delete any existing pages
     631    // Delete any existing pages.
    638632    if ( 'delete' === $existing ) {
    639633        foreach ( (array) $pages as $page_id ) {
     
    661655
    662656    // Register and Activate are not components, but need pages when
    663     // registration is enabled
     657    // registration is enabled.
    664658    if ( bp_get_signup_allowed() ) {
    665659        foreach ( array( 'register', 'activate' ) as $slug ) {
     
    670664    }
    671665
    672     // No need for a Sites directory unless we're on multisite
     666    // No need for a Sites directory unless we're on multisite.
    673667    if ( ! is_multisite() && isset( $pages_to_create['sites'] ) ) {
    674668        unset( $pages_to_create['sites'] );
    675669    }
    676670
    677     // Members must always have a page, no matter what
     671    // Members must always have a page, no matter what.
    678672    if ( ! isset( $pages['members'] ) && ! isset( $pages_to_create['members'] ) ) {
    679673        $pages_to_create['members'] = $page_titles['members'];
    680674    }
    681675
    682     // Create the pages
     676    // Create the pages.
    683677    foreach ( $pages_to_create as $component_name => $page_name ) {
    684678        $exists = get_page_by_path( $component_name );
    685679
    686         // If page already exists, use it
     680        // If page already exists, use it.
    687681        if ( ! empty( $exists ) ) {
    688682            $pages[ $component_name ] = $exists->ID;
     
    698692    }
    699693
    700     // Save the page mapping
     694    // Save the page mapping.
    701695    bp_update_option( 'bp-pages', $pages );
    702696
     
    711705 *
    712706 * Bails early on multisite installations when not viewing the root site.
     707 *
    713708 * @link https://buddypress.trac.wordpress.org/ticket/6226
    714709 *
     
    719714function bp_core_on_directory_page_delete( $post_id ) {
    720715
    721     // Stop if we are not on the main BP root blog
     716    // Stop if we are not on the main BP root blog.
    722717    if ( ! bp_is_root_blog() ) {
    723718        return;
     
    756751 *
    757752 * @param string $root_slug The root slug, which comes from $bp->pages->[component]->slug.
    758  *
    759753 * @return string The short slug for use in the middle of URLs.
    760754 */
     
    793787    $match = false;
    794788
    795     // Check if the slug is registered in the $bp->pages global
     789    // Check if the slug is registered in the $bp->pages global.
    796790    foreach ( (array) $bp->pages as $key => $page ) {
    797791        if ( $key == $slug || $page->slug == $slug ) {
     
    800794    }
    801795
    802     // Maybe create the add_root array
     796    // Maybe create the add_root array.
    803797    if ( empty( $bp->add_root ) ) {
    804798        $bp->add_root = array();
    805799    }
    806800
    807     // If there was no match, add a page for this root component
     801    // If there was no match, add a page for this root component.
    808802    if ( empty( $match ) ) {
    809803        $add_root_items   = $bp->add_root();
     
    812806    }
    813807
    814     // Make sure that this component is registered as requiring a top-level directory
     808    // Make sure that this component is registered as requiring a top-level directory.
    815809    if ( isset( $bp->{$slug} ) ) {
    816810        $bp->loaded_components[$bp->{$slug}->slug] = $bp->{$slug}->id;
     
    824818function bp_core_create_root_component_page() {
    825819
    826     // Get BuddyPress
     820    // Get BuddyPress.
    827821    $bp = buddypress();
    828822
     
    890884    // This ensures that the version of bp-default in the regular themes
    891885    // directory will always take precedence, as part of a migration away
    892     // from the version packaged with BuddyPress
     886    // from the version packaged with BuddyPress.
    893887    foreach ( array_values( (array) $GLOBALS['wp_theme_directories'] ) as $directory ) {
    894888        if ( is_dir( $directory . '/bp-default' ) ) {
     
    898892
    899893    // If the current theme is bp-default (or a bp-default child), BP
    900     // should register its directory
     894    // should register its directory.
    901895    $register = 'bp-default' === get_stylesheet() || 'bp-default' === get_template();
    902896
    903     // Legacy sites continue to have the theme registered
     897    // Legacy sites continue to have the theme registered.
    904898    if ( empty( $register ) && ( 1 == get_site_option( '_bp_retain_bp_default' ) ) ) {
    905899        $register = true;
     
    921915 * Return the domain for the root blog.
    922916 *
    923  * eg: http://example.com OR https://example.com
     917 * Eg: http://example.com OR https://example.com
    924918 *
    925919 * @uses get_blog_option() WordPress function to fetch blog meta.
     
    10091003            $site_path = '/';
    10101004        } else {
    1011             // Unset the first three segments (http(s)://example.com part)
     1005            // Unset the first three segments (http(s)://example.com part).
    10121006            unset( $site_path[0] );
    10131007            unset( $site_path[1] );
     
    10421036 * @param string $type See the 'type' parameter in {@link current_time()}.
    10431037 *                     Default: 'mysql'.
    1044  *
    10451038 * @return string Current time in 'Y-m-d h:i:s' format.
    10461039 */
     
    10801073 * @param int|bool   $newer_date Optional. Unix timestamp of date to compare older
    10811074 *                               date to. Default: false (current time).
    1082  *
    10831075 * @return string String representing the time since the older date, eg
    10841076 *         "2 hours and 50 minutes".
     
    11271119    $ago_text       = apply_filters( 'bp_core_time_since_ago_text',       __( '%s ago',    'buddypress' ) );
    11281120
    1129     // array of time period chunks
     1121    // Array of time period chunks.
    11301122    $chunks = array(
    11311123        YEAR_IN_SECONDS,
     
    11511143    $newer_date = ( !$newer_date ) ? bp_core_current_time( true, 'timestamp' ) : $newer_date;
    11521144
    1153     // Difference in seconds
     1145    // Difference in seconds.
    11541146    $since = $newer_date - $older_date;
    11551147
     
    11661158    } else {
    11671159
    1168         // Step one: the first chunk
     1160        // Step one: the first chunk.
    11691161        for ( $i = 0, $j = count( $chunks ); $i < $j; ++$i ) {
    11701162            $seconds = $chunks[$i];
    11711163
    1172             // Finding the biggest chunk (if the chunk fits, break)
     1164            // Finding the biggest chunk (if the chunk fits, break).
    11731165            $count = floor( $since / $seconds );
    11741166            if ( 0 != $count ) {
     
    11771169        }
    11781170
    1179         // If $i iterates all the way to $j, then the event happened 0 seconds ago
     1171        // If $i iterates all the way to $j, then the event happened 0 seconds ago.
    11801172        if ( !isset( $chunks[$i] ) ) {
    11811173            $output = $right_now_text;
     
    11831175        } else {
    11841176
    1185             // Set output var
     1177            // Set output var.
    11861178            switch ( $seconds ) {
    11871179                case YEAR_IN_SECONDS :
     
    12121204            // We've left the quirk in place, since fractions of a
    12131205            // minute are not a useful piece of information for our
    1214             // purposes
     1206            // purposes.
    12151207            if ( $i + 2 < $j ) {
    12161208                $seconds2 = $chunks[$i + 1];
    12171209                $count2   = floor( ( $since - ( $seconds * $count ) ) / $seconds2 );
    12181210
    1219                 // Add to output var
     1211                // Add to output var.
    12201212                if ( 0 != $count2 ) {
    12211213                    $output .= _x( ',', 'Separator in time since', 'buddypress' ) . ' ';
     
    12431235            }
    12441236
    1245             // No output, so happened right now
     1237            // No output, so happened right now.
    12461238            if ( ! (int) trim( $output ) ) {
    12471239                $output = $right_now_text;
     
    12501242    }
    12511243
    1252     // Append 'ago' to the end of time-since if not 'right now'
     1244    // Append 'ago' to the end of time-since if not 'right now'.
    12531245    if ( $output != $right_now_text ) {
    12541246        $output = sprintf( $ago_text, $output );
     
    12781270function bp_core_add_message( $message, $type = '' ) {
    12791271
    1280     // Success is the default
     1272    // Success is the default.
    12811273    if ( empty( $type ) ) {
    12821274        $type = 'success';
    12831275    }
    12841276
    1285     // Send the values to the cookie for page reload display
     1277    // Send the values to the cookie for page reload display.
    12861278    @setcookie( 'bp-message',      $message, time() + 60 * 60 * 24, COOKIEPATH );
    12871279    @setcookie( 'bp-message-type', $type,    time() + 60 * 60 * 24, COOKIEPATH );
    12881280
    1289     // Get BuddyPress
     1281    // Get BuddyPress.
    12901282    $bp = buddypress();
    12911283
    1292     /***
     1284    /**
    12931285     * Send the values to the $bp global so we can still output messages
    12941286     * without a page reload
     
    13121304function bp_core_setup_message() {
    13131305
    1314     // Get BuddyPress
     1306    // Get BuddyPress.
    13151307    $bp = buddypress();
    13161308
     
    13431335function bp_core_render_message() {
    13441336
    1345     // Get BuddyPress
     1337    // Get BuddyPress.
    13461338    $bp = buddypress();
    13471339
     
    13951387function bp_core_record_activity() {
    13961388
    1397     // Bail if user is not logged in
     1389    // Bail if user is not logged in.
    13981390    if ( ! is_user_logged_in() ) {
    13991391        return false;
    14001392    }
    14011393
    1402     // Get the user ID
     1394    // Get the user ID.
    14031395    $user_id = bp_loggedin_user_id();
    14041396
    1405     // Bail if user is not active
     1397    // Bail if user is not active.
    14061398    if ( bp_is_user_inactive( $user_id ) ) {
    14071399        return false;
    14081400    }
    14091401
    1410     // Get the user's last activity
     1402    // Get the user's last activity.
    14111403    $activity = bp_get_user_last_activity( $user_id );
    14121404
    1413     // Make sure it's numeric
     1405    // Make sure it's numeric.
    14141406    if ( ! is_numeric( $activity ) ) {
    14151407        $activity = strtotime( $activity );
    14161408    }
    14171409
    1418     // Get current time
     1410    // Get current time.
    14191411    $current_time = bp_core_current_time();
    14201412
    1421     // Use this action to detect the very first activity for a given member
     1413    // Use this action to detect the very first activity for a given member.
    14221414    if ( empty( $activity ) ) {
    14231415
     
    14341426    }
    14351427
    1436     // If it's been more than 5 minutes, record a newer last-activity time
     1428    // If it's been more than 5 minutes, record a newer last-activity time.
    14371429    if ( empty( $activity ) || ( strtotime( $current_time ) >= strtotime( '+5 minutes', $activity ) ) ) {
    14381430        bp_update_user_last_activity( $user_id, $current_time );
     
    14491441 * @param int|string $last_activity_date The date of last activity.
    14501442 * @param string     $string             A sprintf()-able statement of the form 'active %s'.
    1451  *
    14521443 * @return string $last_active A string of the form '3 years ago'.
    14531444 */
    14541445function bp_core_get_last_activity( $last_activity_date = '', $string = '' ) {
    14551446
    1456     // Setup a default string if none was passed
     1447    // Setup a default string if none was passed.
    14571448    $string = empty( $string )
    1458         ? '%s'     // Gettext placeholder
     1449        ? '%s'     // Gettext placeholder.
    14591450        : $string;
    14601451
    1461     // Use the string if a last activity date was passed
     1452    // Use the string if a last activity date was passed.
    14621453    $last_active = empty( $last_activity_date )
    14631454        ? __( 'Not recently active', 'buddypress' )
     
    14991490 *
    15001491 * @param string|bool $key The usermeta meta_key.
    1501  *
    15021492 * @return string $key The usermeta meta_key.
    15031493 */
     
    15291519 * @param string $key     The meta key to retrieve.
    15301520 * @param bool   $single  Whether to return a single value.
    1531  *
    15321521 * @return mixed Will be an array if $single is false. Will be value of meta data field if $single
    1533  *         is true.
     1522 *               is true.
    15341523 */
    15351524function bp_get_user_meta( $user_id, $key, $single = false ) {
     
    15531542 * @param mixed  $value      Metadata value.
    15541543 * @param mixed  $prev_value Optional. Previous value to check before removing.
    1555  *
    15561544 * @return bool False on failure, true on success.
    15571545 */
     
    15751563 * @param string $key     The meta key to delete.
    15761564 * @param mixed  $value   Optional. Metadata value.
    1577  *
    15781565 * @return bool False for failure. True for success.
    15791566 */
     
    15911578function bp_embed_init() {
    15921579
    1593     // Get BuddyPress
     1580    // Get BuddyPress.
    15941581    $bp = buddypress();
    15951582
     
    17091696     *                       obeys {@link force_ssl_admin()} and {@link is_ssl()}. 'http'
    17101697     *                       or 'https' can be passed to force those schemes.
    1711      *
    17121698     * @return string Admin url link with optional path appended.
    17131699     */
    17141700    function bp_get_admin_url( $path = '', $scheme = 'admin' ) {
    17151701
    1716         // Links belong in network admin
     1702        // Links belong in network admin.
    17171703        if ( bp_core_do_network_admin() ) {
    17181704            $url = network_admin_url( $path, $scheme );
    17191705
    1720         // Links belong in site admin
     1706        // Links belong in site admin.
    17211707        } else {
    17221708            $url = admin_url( $path, $scheme );
     
    17431729function bp_core_do_network_admin() {
    17441730
    1745     // Default
     1731    // Default.
    17461732    $retval = bp_is_network_activated();
    17471733
     
    17931779 *
    17941780 * @param int $blog_id Optional. Default: the ID of the current blog.
    1795  *
    17961781 * @return bool $is_root_blog Returns true if this is bp_get_root_blog_id().
    17971782 */
    17981783function bp_is_root_blog( $blog_id = 0 ) {
    17991784
    1800     // Assume false
     1785    // Assume false.
    18011786    $is_root_blog = false;
    18021787
    1803     // Use current blog if no ID is passed
     1788    // Use current blog if no ID is passed.
    18041789    if ( empty( $blog_id ) || ! is_int( $blog_id ) ) {
    18051790        $blog_id = get_current_blog_id();
    18061791    }
    18071792
    1808     // Compare to root blog ID
     1793    // Compare to root blog ID.
    18091794    if ( bp_get_root_blog_id() === $blog_id ) {
    18101795        $is_root_blog = true;
     
    18761861function bp_is_multiblog_mode() {
    18771862
    1878     // Setup some default values
     1863    // Setup some default values.
    18791864    $retval         = false;
    18801865    $is_multisite   = is_multisite();
     
    18821867    $is_multiblog   = defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG;
    18831868
    1884     // Multisite, Network Activated, and Specifically Multiblog
     1869    // Multisite, Network Activated, and Specifically Multiblog.
    18851870    if ( $is_multisite && $network_active && $is_multiblog ) {
    18861871        $retval = true;
    18871872
    1888     // Multisite, but not network activated
     1873    // Multisite, but not network activated.
    18891874    } elseif ( $is_multisite && ! $network_active ) {
    18901875        $retval = true;
     
    19151900function bp_is_network_activated() {
    19161901
    1917     // Default to is_multisite()
     1902    // Default to is_multisite().
    19181903    $retval  = is_multisite();
    19191904
    1920     // Check the sitewide plugins array
     1905    // Check the sitewide plugins array.
    19211906    $base    = buddypress()->basename;
    19221907    $plugins = get_site_option( 'active_sitewide_plugins' );
    19231908
    1924     // Override is_multisite() if not network activated
     1909    // Override is_multisite() if not network activated.
    19251910    if ( ! is_array( $plugins ) || ! isset( $plugins[ $base ] ) ) {
    19261911        $retval = false;
     
    20562041 * @param string $action    Action nonce.
    20572042 * @param string $query_arg Where to look for nonce in $_REQUEST.
    2058  *
    20592043 * @return bool True if the nonce is verified, otherwise false.
    20602044 */
    20612045function bp_verify_nonce_request( $action = '', $query_arg = '_wpnonce' ) {
    20622046
    2063     /** Home URL **************************************************************/
     2047    /* Home URL **************************************************************/
    20642048
    20652049    // Parse home_url() into pieces to remove query-strings, strange characters,
     
    20672051    $parsed_home = parse_url( home_url( '/', ( is_ssl() ? 'https' : 'http' ) ) );
    20682052
    2069     // Maybe include the port, if it's included in home_url()
     2053    // Maybe include the port, if it's included in home_url().
    20702054    if ( isset( $parsed_home['port'] ) ) {
    20712055        $parsed_host = $parsed_home['host'] . ':' . $parsed_home['port'];
     
    20742058    }
    20752059
    2076     // Set the home URL for use in comparisons
     2060    // Set the home URL for use in comparisons.
    20772061    $home_url = trim( strtolower( $parsed_home['scheme'] . '://' . $parsed_host . $parsed_home['path'] ), '/' );
    20782062
    2079     /** Requested URL *********************************************************/
    2080 
    2081     // Maybe include the port, if it's included in home_url()
     2063    /* Requested URL *********************************************************/
     2064
     2065    // Maybe include the port, if it's included in home_url().
    20822066    if ( isset( $parsed_home['port'] ) && false === strpos( $_SERVER['HTTP_HOST'], ':' ) ) {
    20832067        $request_host = $_SERVER['HTTP_HOST'] . ':' . $_SERVER['SERVER_PORT'];
     
    20862070    }
    20872071
    2088     // Build the currently requested URL
     2072    // Build the currently requested URL.
    20892073    $scheme        = is_ssl() ? 'https://' : 'http://';
    20902074    $requested_url = strtolower( $scheme . $request_host . $_SERVER['REQUEST_URI'] );
    20912075
    2092     /** Look for match ********************************************************/
     2076    /* Look for match ********************************************************/
    20932077
    20942078    /**
     
    21032087    $matched_url = apply_filters( 'bp_verify_nonce_request_url', $requested_url );
    21042088
    2105     // Check the nonce
     2089    // Check the nonce.
    21062090    $result = isset( $_REQUEST[$query_arg] ) ? wp_verify_nonce( $_REQUEST[$query_arg], $action ) : false;
    21072091
    2108     // Nonce check failed
     2092    // Nonce check failed.
    21092093    if ( empty( $result ) || empty( $action ) || ( strpos( $matched_url, $home_url ) !== 0 ) ) {
    21102094        $result = false;
     
    21302114 *
    21312115 * @since 1.9.0
     2116 *
    21322117 * @return bool
    21332118 */
     
    21402125 *
    21412126 * @since 1.9.0
     2127 *
    21422128 * @return bool
    21432129 */
     
    21802166    ) );
    21812167
    2182     // Try custom locations in WP_LANG_DIR
     2168    // Try custom locations in WP_LANG_DIR.
    21832169    foreach ( $locations as $location ) {
    21842170        if ( load_textdomain( 'buddypress', $location . $mofile_custom ) ) {
     
    21872173    }
    21882174
    2189     // default to WP and glotpress
     2175    // Default to WP and glotpress.
    21902176    return load_plugin_textdomain( $domain );
    21912177}
     
    23192305function bp_nav_menu_get_loggedin_pages() {
    23202306
    2321     // Try to catch the cached version first
     2307    // Try to catch the cached version first.
    23222308    if ( ! empty( buddypress()->wp_nav_menu_items->loggedin ) ) {
    23232309        return buddypress()->wp_nav_menu_items->loggedin;
    23242310    }
    23252311
    2326     // Pull up a list of items registered in BP's top-level nav array
     2312    // Pull up a list of items registered in BP's top-level nav array.
    23272313    $bp_menu_items = buddypress()->bp_nav;
    23282314
    2329     // Alphabetize
     2315    // Alphabetize.
    23302316    $bp_menu_items = bp_alpha_sort_by_key( $bp_menu_items, 'name' );
    23312317
     
    23382324    );
    23392325
    2340     // If there's nothing to show, we're done
     2326    // If there's nothing to show, we're done.
    23412327    if ( count( $bp_menu_items ) < 1 ) {
    23422328        return false;
     
    23472333    foreach ( $bp_menu_items as $bp_item ) {
    23482334
    2349         // Remove <span>number</span>
     2335        // Remove <span>number</span>.
    23502336        $item_name = preg_replace( '/([.0-9]+)/', '', $bp_item['name'] );
    23512337        $item_name = trim( strip_tags( $item_name ) );
     
    23892375function bp_nav_menu_get_loggedout_pages() {
    23902376
    2391     // Try to catch the cached version first
     2377    // Try to catch the cached version first.
    23922378    if ( ! empty( buddypress()->wp_nav_menu_items->loggedout ) ) {
    23932379        return buddypress()->wp_nav_menu_items->loggedout;
     
    24052391
    24062392    // The Register page will not always be available (ie, when
    2407     // registration is disabled)
     2393    // registration is disabled).
    24082394    $bp_directory_page_ids = bp_core_get_directory_page_ids();
    24092395
     
    24172403    }
    24182404
    2419     // If there's nothing to show, we're done
     2405    // If there's nothing to show, we're done.
    24202406    if ( count( $bp_menu_items ) < 1 ) {
    24212407        return false;
     
    24582444 * @param string $slug The slug of the nav item: login, register, or one of the
    24592445 *                     slugs from buddypress()->bp_nav.
    2460  *
    24612446 * @return string $nav_item_url The URL generated for the current user.
    24622447 */
     
    24822467 * @since 2.1.0
    24832468 *
    2484  * @param array $args
    2485  *
     2469 * @param array $args Array of args for the suggestions.
    24862470 * @return array|WP_Error Array of results. If there were any problems, returns a WP_Error object.
    24872471 */
     
    25662550        $need_switch = (bool) ( is_multisite() && ! bp_is_root_blog() );
    25672551
    2568         // Maybe juggle to root blog
     2552        // Maybe juggle to root blog.
    25692553        if ( true === $need_switch ) {
    25702554            switch_to_blog( bp_get_root_blog_id() );
    25712555        }
    25722556
    2573         // Get the upload directory (maybe for root blog)
     2557        // Get the upload directory (maybe for root blog).
    25742558        $wp_upload_dir = wp_upload_dir();
    25752559
    2576         // Maybe juggle back to current blog
     2560        // Maybe juggle back to current blog.
    25772561        if ( true === $need_switch ) {
    25782562            restore_current_blog();
    25792563        }
    25802564
    2581         // Bail if an error occurred
     2565        // Bail if an error occurred.
    25822566        if ( ! empty( $wp_upload_dir['error'] ) ) {
    25832567            return false;
Note: See TracChangeset for help on using the changeset viewer.