Skip to:
Content

BuddyPress.org

Ticket #8046: 8046.1.diff

File 8046.1.diff, 3.5 KB (added by dcavins, 3 years ago)

Use bp_get_template_part() in Nouveau's AJAX template loader.

  • src/bp-core/bp-core-template-loader.php

    diff --git src/bp-core/bp-core-template-loader.php src/bp-core/bp-core-template-loader.php
    index a4750638a..26c64edb6 100644
    defined( 'ABSPATH' ) || exit; 
    1919 *
    2020 * @since 1.7.0
    2121 *
    22  * @param string      $slug Template part slug. Used to generate filenames,
    23  *                          eg 'friends' for 'friends.php'.
    24  * @param string|null $name Optional. Template part name. Used to generate
    25  *                          secondary filenames, eg 'personal' for 'activity-personal.php'.
     22 * @param string      $slug         Template part slug. Used to generate filenames,
     23 *                                  eg 'friends' for 'friends.php'.
     24 * @param string|null $name         Optional. Template part name. Used to generate
     25 *                                  secondary filenames, eg 'personal' for 'activity-personal.php'.
     26 * @param bool|null   $load         Optional. If true, the template file will be loaded when
     27 *                                  found. If false, the path will be returned. Default: true.
     28 * @param bool|null   $require_once Optional. Whether to require_once or require. Has
     29 *                                  no effect if $load is false. Default: false.
    2630 * @return false|string Path to located template. See {@link bp_locate_template()}.
    2731 */
    28 function bp_get_template_part( $slug, $name = null ) {
     32function bp_get_template_part( $slug, $name = null, $load = true, $require_once = false ) {
    2933
    3034        /**
    3135         * Fires at the start of bp_get_template_part().
    function bp_get_template_part( $slug, $name = null ) { 
    5862        $templates = apply_filters( 'bp_get_template_part', $templates, $slug, $name );
    5963
    6064        // Return the part that is found.
    61         return bp_locate_template( $templates, true, false );
     65        return bp_locate_template( $templates, $load, $require_once );
    6266}
    6367
    6468/**
    function bp_locate_template( $template_names, $load = false, $require_once = tru 
    105109        // No file found yet.
    106110        $located            = false;
    107111        $template_locations = bp_get_template_stack();
    108 
    109112        // Try to find a template file.
    110113        foreach ( (array) $template_names as $template_name ) {
    111114
  • src/bp-templates/bp-nouveau/includes/ajax.php

    diff --git src/bp-templates/bp-nouveau/includes/ajax.php src/bp-templates/bp-nouveau/includes/ajax.php
    index bbefca7bc..f4e30c2ef 100644
    function bp_nouveau_ajax_object_template_loader() { 
    103103        switch ( $template ) {
    104104                case 'group_members' :
    105105                case 'groups/single/members' :
    106                         $template_part = 'groups/single/members-loop.php';
     106                        $template_part = 'groups/single/members-loop';
    107107                break;
    108108
    109109                case 'group_requests' :
    110                         $template_part = 'groups/single/requests-loop.php';
     110                        $template_part = 'groups/single/requests-loop';
    111111                break;
    112112
    113113                case 'friend_requests' :
    114                         $template_part = 'members/single/friends/requests-loop.php';
     114                        $template_part = 'members/single/friends/requests-loop';
    115115                break;
    116116
    117117                case 'member_notifications' :
    118                         $template_part = 'members/single/notifications/notifications-loop.php';
     118                        $template_part = 'members/single/notifications/notifications-loop';
    119119                break;
    120120
    121121                default :
    122                         $template_part = $object . '/' . $object . '-loop.php';
     122                        $template_part = $object . '/' . $object . '-loop';
    123123                break;
    124124        }
    125125
    126126        ob_start();
    127127
    128         $template_path = bp_locate_template( array( $template_part ), false );
     128        $template_path = bp_get_template_part( $template_part, null, false );
    129129
    130130        /**
    131131         * Filters the server path for the template loader.