Changeset 13002 for trunk/src/bp-core/bp-core-template-loader.php
- Timestamp:
- 07/14/2021 04:44:28 PM (5 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-core/bp-core-template-loader.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-template-loader.php
r12726 r13002 86 86 function bp_get_asset_template_part( $slug, $name = null, $args = array() ) { 87 87 return bp_get_template_part( "assets/{$slug}", $name, $args ); 88 } 89 90 /** 91 * Get a dynamic template part. 92 * 93 * @since 9.0.0 94 * 95 * @param string $template The Template Pack's relative path to the templata. 96 * Optional. 97 * @param string $type Whether to use the template for JavaScript or PHP. 98 * Optional. Defaults to `js`. 99 * @param array $tokens The data to use to customize the template. Optional. 100 * @param array $allowed_tags The allowed tags to use. Optional. 101 * @return string HTML/JS output. 102 */ 103 function bp_get_dynamic_template_part( $template = '', $type = 'js', $tokens = array(), $allowed_tags = array() ) { 104 $template_string = ''; 105 106 if ( ! $template ) { 107 return ''; 108 } 109 110 // Use the BP Theme Compat API to allow template override. 111 $template_path = bp_locate_template( $template ); 112 if ( $template_path ) { 113 $template_string = file_get_contents( $template_path ); 114 } 115 116 if ( ! $template_string ) { 117 return ''; 118 } 119 120 if ( ! $allowed_tags ) { 121 $allowed_tags = array( 122 'li' => array( 'class' => true ), 123 'div' => array( 'class' => true ), 124 'span' => array( 'class' => true ), 125 'a' => array( 126 'href' => true, 127 'class' => true, 128 'data-bp-tooltip' => true, 129 ), 130 'img' => array( 131 'src' => true, 132 'class' => true, 133 'loading' => true, 134 ), 135 ); 136 } 137 138 if ( 'js' !== $type ) { 139 $template_string = wp_kses( $template_string, $allowed_tags ); 140 141 return bp_core_replace_tokens_in_text( $template_string, $tokens ); 142 } 143 144 return $template_string; 88 145 } 89 146
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)