Make WordPress Core

Ticket #54797: 54797-domainpath.diff

File 54797-domainpath.diff, 1.2 KB (added by gziolo, 20 months ago)

Domain Path handling in block.json

  • src/wp-includes/blocks.php

     
    127127        }
    128128
    129129        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 );
    131136        }
    132137
    133138        return $script_handle;
     
    221226 * @since 5.5.0
    222227 * @since 5.7.0 Added support for `textdomain` field and i18n handling for all translatable fields.
    223228 * @since 5.9.0 Added support for `variations` and `viewScript` fields.
     229 * @since 6.0.0 Added support for `domainpath` field.
    224230 *
    225231 * @param string $file_or_folder Path to the JSON file with metadata definition for
    226232 *                               the block or path to the folder where the `block.json` file is located.