Skip to content

Commit 390e2ac

Browse files
Template part 'area' term - reword confusing 'type' terminology (#29679)
* reword confusing 'type' terminology * rename get areas function * rename hook string to be consistent
1 parent 654eb21 commit 390e2ac

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

lib/full-site-editing/block-templates.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function _gutenberg_add_template_part_area_info( $template_info ) {
129129
}
130130

131131
if ( isset( $theme_data[ $template_info['slug'] ]['area'] ) ) {
132-
$template_info['area'] = gutenberg_filter_template_part_area_type( $theme_data[ $template_info['slug'] ]['area'] );
132+
$template_info['area'] = gutenberg_filter_template_part_area( $theme_data[ $template_info['slug'] ]['area'] );
133133
} else {
134134
$template_info['area'] = WP_TEMPLATE_PART_AREA_UNCATEGORIZED;
135135
}

lib/full-site-editing/class-wp-rest-templates-controller.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,9 @@ protected function prepare_item_for_database( $request ) {
363363

364364
if ( 'wp_template_part' === $this->post_type ) {
365365
if ( isset( $request['area'] ) ) {
366-
$changes->tax_input['wp_template_part_area'] = gutenberg_filter_template_part_area_type( $request['area'] );
366+
$changes->tax_input['wp_template_part_area'] = gutenberg_filter_template_part_area( $request['area'] );
367367
} elseif ( null !== $template && ! $template->is_custom && $template->area ) {
368-
$changes->tax_input['wp_template_part_area'] = gutenberg_filter_template_part_area_type( $template->area );
368+
$changes->tax_input['wp_template_part_area'] = gutenberg_filter_template_part_area( $template->area );
369369
} elseif ( ! $template->area ) {
370370
$changes->tax_input['wp_template_part_area'] = WP_TEMPLATE_PART_AREA_UNCATEGORIZED;
371371
}

lib/full-site-editing/template-parts.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -163,41 +163,41 @@ function set_unique_slug_on_create_template_part( $post_id ) {
163163
add_action( 'save_post_wp_template_part', 'set_unique_slug_on_create_template_part' );
164164

165165
/**
166-
* Returns a filtered list of allowed area types for template parts.
166+
* Returns a filtered list of allowed area values for template parts.
167167
*
168-
* @return array The supported template part area types.
168+
* @return array The supported template part area values.
169169
*/
170-
function gutenberg_get_allowed_template_part_area_types() {
171-
$default_area_types = array(
170+
function gutenberg_get_allowed_template_part_areas() {
171+
$default_area_values = array(
172172
WP_TEMPLATE_PART_AREA_HEADER,
173173
WP_TEMPLATE_PART_AREA_FOOTER,
174174
WP_TEMPLATE_PART_AREA_SIDEBAR,
175175
WP_TEMPLATE_PART_AREA_UNCATEGORIZED,
176176
);
177177

178178
/**
179-
* Filters the list of allowed template part area types.
179+
* Filters the list of allowed template part area values.
180180
*
181-
* @param array $default_area_types An array of supported area types.
181+
* @param array $default_area_values An array of supported area values.
182182
*/
183-
return apply_filters( 'default_wp_template_part_area_types', $default_area_types );
183+
return apply_filters( 'default_wp_template_part_areas', $default_area_values );
184184
}
185185

186186
/**
187-
* Checks whether the input 'type' is a supported area type.
188-
* Returns the input if supported, otherwise returns the 'other' type.
187+
* Checks whether the input 'area' is a supported value.
188+
* Returns the input if supported, otherwise returns the 'uncategorized' value.
189189
*
190190
* @param string $type Template part area name.
191191
*
192-
* @return string Input if supported, else 'other'.
192+
* @return string Input if supported, else the uncategorized value.
193193
*/
194-
function gutenberg_filter_template_part_area_type( $type ) {
195-
if ( in_array( $type, gutenberg_get_allowed_template_part_area_types(), true ) ) {
194+
function gutenberg_filter_template_part_area( $type ) {
195+
if ( in_array( $type, gutenberg_get_allowed_template_part_areas(), true ) ) {
196196
return $type;
197197
}
198198

199-
/* translators: %1$s: Template area type, %2$s: the uncategorized template area type. */
200-
$warning_message = sprintf( __( '"%1$s" is not a supported wp_template_part_area type and has been added as "%2$s".', 'gutenberg' ), $type, WP_TEMPLATE_PART_AREA_UNCATEGORIZED );
199+
/* translators: %1$s: Template area type, %2$s: the uncategorized template area value. */
200+
$warning_message = sprintf( __( '"%1$s" is not a supported wp_template_part area value and has been added as "%2$s".', 'gutenberg' ), $type, WP_TEMPLATE_PART_AREA_UNCATEGORIZED );
201201
trigger_error( $warning_message, E_USER_NOTICE );
202202
return WP_TEMPLATE_PART_AREA_UNCATEGORIZED;
203203
}

0 commit comments

Comments
 (0)