Changeset 54257 for trunk/src/wp-includes/blocks/template-part.php
- Timestamp:
- 09/20/2022 03:14:54 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks/template-part.php
r53879 r54257 34 34 array( 35 35 'taxonomy' => 'wp_theme', 36 'field' => ' slug',36 'field' => 'name', 37 37 'terms' => $attributes['theme'], 38 38 ), … … 160 160 161 161 /** 162 * Returns an array of variation objects for the template part block.162 * Returns an array of area variation objects for the template part block. 163 163 * 164 164 * @return array Array containing the block variation objects. 165 165 */ 166 function build_template_part_block_ variations() {166 function build_template_part_block_area_variations() { 167 167 $variations = array(); 168 168 $defined_areas = get_allowed_block_template_part_areas(); … … 185 185 186 186 /** 187 * Returns an array of instance variation objects for the template part block 188 * 189 * @return array Array containing the block variation objects. 190 */ 191 function build_template_part_block_instance_variations() { 192 $variations = array(); 193 $template_parts = get_block_templates( 194 array( 195 'post_type' => 'wp_template_part', 196 ), 197 'wp_template_part' 198 ); 199 200 $defined_areas = get_allowed_block_template_part_areas(); 201 $icon_by_area = array_combine( array_column( $defined_areas, 'area' ), array_column( $defined_areas, 'icon' ) ); 202 203 foreach ( $template_parts as $template_part ) { 204 $variations[] = array( 205 'name' => sanitize_title( $template_part->slug ), 206 'title' => $template_part->title, 207 // If there's no description for the template part don't show the 208 // block description. This is a bit hacky, but prevent the fallback 209 // by using a non-breaking space so that the value of description 210 // isn't falsey. 211 'description' => $template_part->description || ' ', 212 'attributes' => array( 213 'slug' => $template_part->slug, 214 'theme' => $template_part->theme, 215 'area' => $template_part->area, 216 ), 217 'scope' => array( 'inserter' ), 218 'icon' => $icon_by_area[ $template_part->area ], 219 'example' => array( 220 'attributes' => array( 221 'slug' => $template_part->slug, 222 'theme' => $template_part->theme, 223 'area' => $template_part->area, 224 ), 225 ), 226 ); 227 } 228 return $variations; 229 } 230 231 /** 232 * Returns an array of all template part block variations. 233 * 234 * @return array Array containing the block variation objects. 235 */ 236 function build_template_part_block_variations() { 237 return array_merge( build_template_part_block_area_variations(), build_template_part_block_instance_variations() ); 238 } 239 240 /** 187 241 * Registers the `core/template-part` block on the server. 188 242 */
Note: See TracChangeset
for help on using the changeset viewer.