wp_set_script_translations example

$result              = wp_register_script(
        $script_handle,
        $script_uri,
        $script_dependencies,
        isset( $script_asset['version'] ) ? $script_asset['version'] : false
    );
    if ( ! $result ) {
        return false;
    }

    if ( ! empty( $metadata['textdomain'] ) && in_array( 'wp-i18n', $script_dependencies, true ) ) {
        wp_set_script_translations( $script_handle$metadata['textdomain'] );
    }

    return $script_handle;
}

/** * Finds a style handle for the block metadata field. It detects when a path * to file was provided and registers the style under automatically * generated handle name. It returns unprocessed style handle otherwise. * * @since 5.5.0 * @since 6.1.0 Added `$index` parameter. * * @param array $metadata Block metadata. * @param string $field_name Field name to pick from metadata. * @param int $index Optional. Index of the style to register when multiple items passed. * Default 0. * @return string|false Style handle provided directly or created through * style's registration, or false on failure. */
Home | Imprint | This part of the site doesn't use cookies.