Changeset 12726
- Timestamp:
- 09/19/2020 06:19:45 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-template-loader.php
r12546 r12726 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, … … 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 /** … … 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. 39 */ 40 do_action( 'get_template_part_' . $slug, $slug, $name ); 42 * @param array $args Extra args to pass to locate_template(). 43 */ 44 do_action( 'get_template_part_' . $slug, $slug, $name, $args ); 41 45 42 46 // Setup possible parts. … … 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. 57 */ 58 $templates = apply_filters( 'bp_get_template_part', $templates, $slug, $name ); 62 * @param array $args Extra args to pass to locate_template(). 63 */ 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 … … 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. … … 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 … … 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. … … 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. … … 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 /** … … 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 … … 321 331 * 322 332 * @since 1.7.0 323 * 324 * @see bp_get_template_part() for a description of $slug and $name params. 333 * @since 7.0.0 Added $args parameter. 334 * 335 * @see bp_get_template_part() for a description of $slug, $name and $args params. 325 336 * 326 337 * @param string $slug See {@link bp_get_template_part()}. … … 328 339 * @param bool $echo If true, template content will be echoed. If false, 329 340 * returned. Default: true. 341 * @param array $args See {@link bp_get_template_part()}. 330 342 * @return string|null If $echo, returns the template content. 331 343 */ 332 function bp_buffer_template_part( $slug, $name = null, $echo = true ) {344 function bp_buffer_template_part( $slug, $name = null, $echo = true, $args = array() ) { 333 345 ob_start(); 334 346 … … 336 348 remove_filter( 'the_content', 'bp_replace_the_content' ); 337 349 338 bp_get_template_part( $slug, $name );350 bp_get_template_part( $slug, $name, $args ); 339 351 340 352 // Remove 'bp_replace_the_content' filter to prevent infinite loops.
Note: See TracChangeset
for help on using the changeset viewer.