Changeset 49981 for trunk/src/wp-includes/blocks.php
- Timestamp:
- 01/19/2021 11:04:03 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks.php
r49948 r49981 135 135 $script_asset['version'] 136 136 ); 137 return $result ? $script_handle : false; 137 if ( ! $result ) { 138 return false; 139 } 140 141 if ( ! empty( $metadata['textdomain'] ) ) { 142 wp_set_script_translations( $script_handle, $metadata['textdomain'] ); 143 } 144 145 return $script_handle; 138 146 } 139 147 … … 230 238 foreach ( $property_mappings as $key => $mapped_key ) { 231 239 if ( isset( $metadata[ $key ] ) ) { 232 $settings[ $mapped_key ] = $metadata[ $key ]; 240 $value = $metadata[ $key ]; 241 if ( empty( $metadata['textdomain'] ) ) { 242 $settings[ $mapped_key ] = $value; 243 continue; 244 } 245 $textdomain = $metadata['textdomain']; 246 switch ( $key ) { 247 case 'title': 248 case 'description': 249 // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralContext,WordPress.WP.I18n.NonSingularStringLiteralDomain 250 $settings[ $mapped_key ] = translate_with_gettext_context( $value, sprintf( 'block %s', $key ), $textdomain ); 251 break; 252 case 'keywords': 253 $settings[ $mapped_key ] = array(); 254 if ( ! is_array( $value ) ) { 255 continue 2; 256 } 257 258 foreach ( $value as $keyword ) { 259 // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralDomain 260 $settings[ $mapped_key ][] = translate_with_gettext_context( $keyword, 'block keyword', $textdomain ); 261 } 262 263 break; 264 case 'styles': 265 $settings[ $mapped_key ] = array(); 266 if ( ! is_array( $value ) ) { 267 continue 2; 268 } 269 270 foreach ( $value as $style ) { 271 if ( ! empty( $style['label'] ) ) { 272 // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralDomain 273 $style['label'] = translate_with_gettext_context( $style['label'], 'block style label', $textdomain ); 274 } 275 $settings[ $mapped_key ][] = $style; 276 } 277 278 break; 279 default: 280 $settings[ $mapped_key ] = $value; 281 } 233 282 } 234 283 }
Note: See TracChangeset
for help on using the changeset viewer.