Ticket #54797: 54797-domainpath.diff
File 54797-domainpath.diff, 1.2 KB (added by , 20 months ago) |
---|
-
src/wp-includes/blocks.php
127 127 } 128 128 129 129 if ( ! empty( $metadata['textdomain'] ) && in_array( 'wp-i18n', $script_dependencies, true ) ) { 130 wp_set_script_translations( $script_handle, $metadata['textdomain'] ); 130 $translations_path = null; 131 if ( ! empty( $metadata['domainpath'] ) ) { 132 list( $plugin_name ) = explode( '/', dirname( plugin_basename( $script_path_norm ) ) ); 133 $translations_path = WP_PLUGIN_DIR . '/' . $plugin_name . $metadata['domainpath']; 134 } 135 wp_set_script_translations( $script_handle, $metadata['textdomain'], $translations_path ); 131 136 } 132 137 133 138 return $script_handle; … … 221 226 * @since 5.5.0 222 227 * @since 5.7.0 Added support for `textdomain` field and i18n handling for all translatable fields. 223 228 * @since 5.9.0 Added support for `variations` and `viewScript` fields. 229 * @since 6.0.0 Added support for `domainpath` field. 224 230 * 225 231 * @param string $file_or_folder Path to the JSON file with metadata definition for 226 232 * the block or path to the folder where the `block.json` file is located.