diff --git src/bp-core/bp-core-template-loader.php src/bp-core/bp-core-template-loader.php
index 2c1000a1a..d58c9abd4 100644
|
|
|
defined( 'ABSPATH' ) || exit; |
| 18 | 18 | * Get a BuddyPress template part for display in a theme. |
| 19 | 19 | * |
| 20 | 20 | * @since 1.7.0 |
| | 21 | * @since 7.0.0 Added $args parameter. |
| 21 | 22 | * |
| 22 | 23 | * @param string $slug Template part slug. Used to generate filenames, |
| 23 | 24 | * eg 'friends' for 'friends.php'. |
| 24 | 25 | * @param string|null $name Optional. Template part name. Used to generate |
| 25 | 26 | * secondary filenames, eg 'personal' for 'activity-personal.php'. |
| | 27 | * @param array $args Optional. Extra args to pass to locate_template(). |
| 26 | 28 | * @return false|string Path to located template. See {@link bp_locate_template()}. |
| 27 | 29 | */ |
| 28 | | function bp_get_template_part( $slug, $name = null ) { |
| | 30 | function bp_get_template_part( $slug, $name = null, $args = array() ) { |
| 29 | 31 | |
| 30 | 32 | /** |
| 31 | 33 | * Fires at the start of bp_get_template_part(). |
| … |
… |
function bp_get_template_part( $slug, $name = null ) { |
| 33 | 35 | * This is a variable hook that is dependent on the slug passed in. |
| 34 | 36 | * |
| 35 | 37 | * @since 1.7.0 |
| | 38 | * @since 7.0.0 Added $args parameter. |
| 36 | 39 | * |
| 37 | 40 | * @param string $slug Template part slug requested. |
| 38 | 41 | * @param string $name Template part name requested. |
| | 42 | * @param array $args Extra args to pass to locate_template(). |
| 39 | 43 | */ |
| 40 | | do_action( 'get_template_part_' . $slug, $slug, $name ); |
| | 44 | do_action( 'get_template_part_' . $slug, $slug, $name, $args ); |
| 41 | 45 | |
| 42 | 46 | // Setup possible parts. |
| 43 | 47 | $templates = array(); |
| … |
… |
function bp_get_template_part( $slug, $name = null ) { |
| 50 | 54 | * Filters the template parts to be loaded. |
| 51 | 55 | * |
| 52 | 56 | * @since 1.7.0 |
| | 57 | * @since 7.0.0 Added $args parameter. |
| 53 | 58 | * |
| 54 | 59 | * @param array $templates Array of templates located. |
| 55 | 60 | * @param string $slug Template part slug requested. |
| 56 | 61 | * @param string $name Template part name requested. |
| | 62 | * @param array $args Extra args to pass to locate_template(). |
| 57 | 63 | */ |
| 58 | | $templates = apply_filters( 'bp_get_template_part', $templates, $slug, $name ); |
| | 64 | $templates = apply_filters( 'bp_get_template_part', $templates, $slug, $name, $args ); |
| 59 | 65 | |
| 60 | 66 | // Return the part that is found. |
| 61 | | return bp_locate_template( $templates, true, false ); |
| | 67 | return bp_locate_template( $templates, true, false, $args ); |
| 62 | 68 | } |
| 63 | 69 | |
| 64 | 70 | /** |
| … |
… |
function bp_get_template_part( $slug, $name = null ) { |
| 68 | 74 | * prepended to the slug. |
| 69 | 75 | * |
| 70 | 76 | * @since 2.6.0 |
| | 77 | * @since 7.0.0 Added $args parameter. |
| 71 | 78 | * |
| 72 | 79 | * @see bp_get_template_part() for full documentation. |
| 73 | 80 | * |
| 74 | 81 | * @param string $slug Template slug. |
| 75 | 82 | * @param string|null $name Template name. |
| | 83 | * @param array $args Optional. Extra args to pass to locate_template(). |
| 76 | 84 | * @return false|string |
| 77 | 85 | */ |
| 78 | | function bp_get_asset_template_part( $slug, $name = null ) { |
| 79 | | return bp_get_template_part( "assets/{$slug}", $name ); |
| | 86 | function bp_get_asset_template_part( $slug, $name = null, $args = array() ) { |
| | 87 | return bp_get_template_part( "assets/{$slug}", $name, $args ); |
| 80 | 88 | } |
| 81 | 89 | |
| 82 | 90 | /** |
| … |
… |
function bp_get_asset_template_part( $slug, $name = null ) { |
| 87 | 95 | * not found in either of those, it looks in the theme-compat folder last. |
| 88 | 96 | * |
| 89 | 97 | * @since 1.7.0 |
| | 98 | * @since 7.0.0 Added $args parameter. |
| 90 | 99 | * |
| 91 | 100 | * @param string|array $template_names Template file(s) to search for, in order. |
| 92 | 101 | * @param bool $load Optional. If true, the template file will be loaded when |
| 93 | 102 | * found. If false, the path will be returned. Default: false. |
| 94 | 103 | * @param bool $require_once Optional. Whether to require_once or require. Has |
| 95 | 104 | * no effect if $load is false. Default: true. |
| | 105 | * @param array $args Optional. Extra args to pass to locate_template(). |
| 96 | 106 | * @return string The template filename if one is located. |
| 97 | 107 | */ |
| 98 | | function bp_locate_template( $template_names, $load = false, $require_once = true ) { |
| | 108 | function bp_locate_template( $template_names, $load = false, $require_once = true, $args = array() ) { |
| 99 | 109 | |
| 100 | 110 | // Bail when there are no templates to locate. |
| 101 | 111 | if ( empty( $template_names ) ) { |
| … |
… |
function bp_locate_template( $template_names, $load = false, $require_once = tru |
| 140 | 150 | * If you want to override a specific template part, please either filter |
| 141 | 151 | * 'bp_get_template_part' or add a new location to the template stack. |
| 142 | 152 | */ |
| 143 | | do_action( 'bp_locate_template', $located, $template_name, $template_names, $template_locations, $load, $require_once ); |
| | 153 | do_action( 'bp_locate_template', $located, $template_name, $template_names, $template_locations, $load, $require_once, $args ); |
| 144 | 154 | |
| 145 | 155 | /** |
| 146 | 156 | * Filter here to allow/disallow template loading. |
| … |
… |
function bp_locate_template( $template_names, $load = false, $require_once = tru |
| 152 | 162 | $load_template = (bool) apply_filters( 'bp_locate_template_and_load', true ); |
| 153 | 163 | |
| 154 | 164 | if ( $load_template && $load && ! empty( $located ) ) { |
| 155 | | load_template( $located, $require_once ); |
| | 165 | load_template( $located, $require_once, $args ); |
| 156 | 166 | } |
| 157 | 167 | |
| 158 | 168 | return $located; |