Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/15/2015 07:57:03 PM (10 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-template-loader.php

    r10279 r10356  
    2727 * @param string $name Optional. Template part name. Used to generate
    2828 *                     secondary filenames, eg 'personal' for 'activity-personal.php'.
    29  *
    3029 * @return string Path to located template. See {@link bp_locate_template()}.
    3130 */
     
    4443    do_action( 'get_template_part_' . $slug, $slug, $name );
    4544
    46     // Setup possible parts
     45    // Setup possible parts.
    4746    $templates = array();
    4847    if ( isset( $name ) ) {
     
    6261    $templates = apply_filters( 'bp_get_template_part', $templates, $slug, $name );
    6362
    64     // Return the part that is found
     63    // Return the part that is found.
    6564    return bp_locate_template( $templates, true, false );
    6665}
     
    8079 * @param bool         $require_once   Optional. Whether to require_once or require. Has
    8180 *                                     no effect if $load is false. Default: true.
    82  *
    8381 * @return string The template filename if one is located.
    8482 */
    8583function bp_locate_template( $template_names, $load = false, $require_once = true ) {
    8684
    87     // No file found yet
     85    // No file found yet.
    8886    $located            = false;
    8987    $template_locations = bp_get_template_stack();
    9088
    91     // Try to find a template file
     89    // Try to find a template file.
    9290    foreach ( (array) $template_names as $template_name ) {
    9391
    94         // Continue if template is empty
     92        // Continue if template is empty.
    9593        if ( empty( $template_name ) ) {
    9694            continue;
    9795        }
    9896
    99         // Trim off any slashes from the template name
     97        // Trim off any slashes from the template name.
    10098        $template_name  = ltrim( $template_name, '/' );
    10199
    102         // Loop through template stack
     100        // Loop through template stack.
    103101        foreach ( (array) $template_locations as $template_location ) {
    104102
    105             // Continue if $template_location is empty
     103            // Continue if $template_location is empty.
    106104            if ( empty( $template_location ) ) {
    107105                continue;
    108106            }
    109107
    110             // Check child theme first
     108            // Check child theme first.
    111109            if ( file_exists( trailingslashit( $template_location ) . $template_name ) ) {
    112110                $located = trailingslashit( $template_location ) . $template_name;
     
    125123    do_action( 'bp_locate_template', $located, $template_name, $template_names, $template_locations, $load, $require_once );
    126124
    127     // Maybe load the template if one was located
     125    // Maybe load the template if one was located.
    128126    $use_themes = defined( 'WP_USE_THEMES' ) && WP_USE_THEMES;
    129127    $doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
     
    147145 * @param int    $priority          Optional. The priority parameter as passed to
    148146 *                                  add_filter(). Default: 10.
    149  *
    150147 * @return bool See {@link add_filter()}.
    151148 */
    152149function bp_register_template_stack( $location_callback = '', $priority = 10 ) {
    153150
    154     // Bail if no location, or function/method is not callable
     151    // Bail if no location, or function/method is not callable.
    155152    if ( empty( $location_callback ) || ! is_callable( $location_callback ) ) {
    156153        return false;
    157154    }
    158155
    159     // Add location callback to template stack
     156    // Add location callback to template stack.
    160157    return add_filter( 'bp_template_stack', $location_callback, (int) $priority );
    161158}
     
    171168 * @param int    $priority          Optional. The priority parameter passed to
    172169 *                                  {@link bp_register_template_stack()}. Default: 10.
    173  *
    174170 * @return bool See {@link remove_filter()}.
    175171 */
    176172function bp_deregister_template_stack( $location_callback = '', $priority = 10 ) {
    177173
    178     // Bail if no location, or function/method is not callable
     174    // Bail if no location, or function/method is not callable.
    179175    if ( empty( $location_callback ) || ! is_callable( $location_callback ) ) {
    180176        return false;
    181177    }
    182178
    183     // Add location callback to template stack
     179    // Add location callback to template stack.
    184180    return remove_filter( 'bp_template_stack', $location_callback, (int) $priority );
    185181}
     
    199195 * @global array $wp_current_filter Stores the list of current filters with
    200196 *                                  the current one last.
    201  *
    202197 * @return array The filtered value after all hooked functions are applied to it.
    203198 */
     
    205200    global $wp_filter, $merged_filters, $wp_current_filter;
    206201
    207     // Setup some default variables
     202    // Setup some default variables.
    208203    $tag  = 'bp_template_stack';
    209204    $args = $stack = array();
    210205
    211     // Add 'bp_template_stack' to the current filter array
     206    // Add 'bp_template_stack' to the current filter array.
    212207    $wp_current_filter[] = $tag;
    213208
    214     // Sort
     209    // Sort.
    215210    if ( class_exists( 'WP_Hook' ) ) {
    216211        $filter = $wp_filter[ $tag ]->callbacks;
     
    224219    }
    225220
    226     // Ensure we're always at the beginning of the filter array
     221    // Ensure we're always at the beginning of the filter array.
    227222    reset( $filter );
    228223
    229     // Loop through 'bp_template_stack' filters, and call callback functions
     224    // Loop through 'bp_template_stack' filters, and call callback functions.
    230225    do {
    231226        foreach( (array) current( $filter ) as $the_ ) {
     
    237232    } while ( next( $filter ) !== false );
    238233
    239     // Remove 'bp_template_stack' from the current filter array
     234    // Remove 'bp_template_stack' from the current filter array.
    240235    array_pop( $wp_current_filter );
    241236
    242     // Remove empties and duplicates
     237    // Remove empties and duplicates.
    243238    $stack = array_unique( array_filter( $stack ) );
    244239
     
    264259 * @param bool   $echo If true, template content will be echoed. If false,
    265260 *                     returned. Default: true.
    266  *
    267261 * @return string|null If $echo, returns the template content.
    268262 */
     
    270264    ob_start();
    271265
    272     // Remove 'bp_replace_the_content' filter to prevent infinite loops
     266    // Remove 'bp_replace_the_content' filter to prevent infinite loops.
    273267    remove_filter( 'the_content', 'bp_replace_the_content' );
    274268
    275269    bp_get_template_part( $slug, $name );
    276270
    277     // Remove 'bp_replace_the_content' filter to prevent infinite loops
     271    // Remove 'bp_replace_the_content' filter to prevent infinite loops.
    278272    add_filter( 'the_content', 'bp_replace_the_content' );
    279273
    280     // Get the output buffer contents
     274    // Get the output buffer contents.
    281275    $output = ob_get_clean();
    282276
    283     // Echo or return the output buffer contents
     277    // Echo or return the output buffer contents.
    284278    if ( true === $echo ) {
    285279        echo $output;
     
    305299 * @param string $type      Filename without extension.
    306300 * @param array  $templates An optional list of template candidates.
    307  *
    308301 * @return string Full path to file.
    309302 */
     
    352345 *
    353346 * @param array $templates Templates we are looking for.
    354  *
    355347 * @return array Possible subfolders to look in.
    356348 */
     
    379371 *
    380372 * @param array $stacks Array of template locations.
    381  *
    382373 * @return array() Array of all template locations registered so far.
    383374 */
     
    385376    $retval = array();
    386377
    387     // Get alternate locations
     378    // Get alternate locations.
    388379    $locations = bp_get_template_locations();
    389380
    390     // Loop through locations and stacks and combine
     381    // Loop through locations and stacks and combine.
    391382    foreach ( (array) $stacks as $stack ) {
    392383        foreach ( (array) $locations as $custom_location ) {
     
    411402 * @since 1.7.0
    412403 *
    413  * @param WP_Query $posts_query
     404 * @param WP_Query $posts_query WP_Query object.
    414405 */
    415406function bp_parse_query( $posts_query ) {
    416407
    417     // Bail if $posts_query is not the main loop
     408    // Bail if $posts_query is not the main loop.
    418409    if ( ! $posts_query->is_main_query() ) {
    419410        return;
    420411    }
    421412
    422     // Bail if filters are suppressed on this query
     413    // Bail if filters are suppressed on this query.
    423414    if ( true == $posts_query->get( 'suppress_filters' ) ) {
    424415        return;
    425416    }
    426417
    427     // Bail if in admin
     418    // Bail if in admin.
    428419    if ( is_admin() ) {
    429420        return;
     
    454445 * @since 1.7.0
    455446 *
    456  * @param string $template
    457  *
     447 * @param string $template The path to the template file that is being used.
    458448 * @return string The path to the template file that is being used.
    459449 */
     
    492482 *
    493483 * @param mixed $template Default: false.
    494  *
    495484 * @return mixed False if empty. Template name if template included.
    496485 */
     
    523512    global $pagenow, $wp_query;
    524513
    525     // do not load our custom BP functions file if theme compat is disabled
     514    // Do not load our custom BP functions file if theme compat is disabled.
    526515    if ( ! bp_use_theme_compat_with_current_theme() ) {
    527516        return;
    528517    }
    529518
    530     // Do not include on BuddyPress deactivation
     519    // Do not include on BuddyPress deactivation.
    531520    if ( bp_is_deactivation() ) {
    532521        return;
     
    536525    // or has been reset), load_template() will fail at setting certain
    537526    // global values. This does not happen on a normal page load, but can
    538     // cause problems when running automated tests
     527    // cause problems when running automated tests.
    539528    if ( ! is_a( $wp_query, 'WP_Query' ) ) {
    540529        return;
    541530    }
    542531
    543     // Only include if not installing or if activating via wp-activate.php
     532    // Only include if not installing or if activating via wp-activate.php.
    544533    if ( ! defined( 'WP_INSTALLING' ) || 'wp-activate.php' === $pagenow ) {
    545534        bp_locate_template( 'buddypress-functions.php', true );
Note: See TracChangeset for help on using the changeset viewer.