Prep Plugin for release on WordPress.org (#23)
* Update translation text domain * Escape everything that should be escaped. * Add nonce checks where needed. * Sanitize all inputs. * Apply Code style changes across the codebase. * Correct many deprecation notices. * Optimize load order of many filters. * Add Proper Build script * Use emojii flags * Fix i18n deprecation notice for translating too early * Put all scripts in footer and load async
This commit is contained in:
@ -47,14 +47,24 @@ class Scripts {
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param string $handle The script handle. Used to enqueue the script.
|
||||
* @param string $src URL to the file.
|
||||
* @param array $deps List of dependency scripts.
|
||||
* @param string $handle The script handle. Used to enqueue the script.
|
||||
* @param string $src URL to the file.
|
||||
* @param array $deps List of dependency scripts.
|
||||
* @param array|bool $args {
|
||||
* Optional. An array of additional script loading strategies. Default empty array.
|
||||
* Otherwise, it may be a boolean in which case it determines whether the script is printed in the footer. Default false.
|
||||
*
|
||||
* @type string $strategy Optional. If provided, may be either 'defer' or 'async'.
|
||||
* @type bool $in_footer Optional. Whether to print the script in the footer. Default 'false'.
|
||||
* }
|
||||
* @return void
|
||||
*/
|
||||
public function register_script($handle, $src, $deps = []): void {
|
||||
public function register_script($handle, $src, $deps = [], $args = [
|
||||
'async' => true,
|
||||
'in_footer' => true,
|
||||
]): void {
|
||||
|
||||
wp_register_script($handle, $src, $deps, wu_get_version());
|
||||
wp_register_script($handle, $src, $deps, wu_get_version(), $args);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -141,9 +151,9 @@ class Scripts {
|
||||
[
|
||||
'currency' => wu_get_setting('currency_symbol', 'USD'),
|
||||
'currency_symbol' => wu_get_currency_symbol(),
|
||||
'currency_position' => wu_get_setting('currency_position'),
|
||||
'decimal_separator' => wu_get_setting('decimal_separator'),
|
||||
'thousand_separator' => wu_get_setting('thousand_separator'),
|
||||
'currency_position' => wu_get_setting('currency_position', '%s %v'),
|
||||
'decimal_separator' => wu_get_setting('decimal_separator', '.'),
|
||||
'thousand_separator' => wu_get_setting('thousand_separator', ','),
|
||||
'precision' => wu_get_setting('precision', 2),
|
||||
'use_container' => get_user_setting('wu_use_container', false),
|
||||
'disable_image_zoom' => wu_get_setting('disable_image_zoom', false),
|
||||
@ -153,7 +163,11 @@ class Scripts {
|
||||
/*
|
||||
* Adds Fields & Components
|
||||
*/
|
||||
$this->register_script('wu-fields', wu_get_asset('fields.js', 'js'), ['jquery', 'wu-vue', 'wu-selectizer', 'wp-color-picker']);
|
||||
$this->register_script(
|
||||
'wu-fields',
|
||||
wu_get_asset('fields.js', 'js'),
|
||||
['jquery', 'wu-vue', 'wu-selectizer', 'wp-color-picker']
|
||||
);
|
||||
|
||||
/*
|
||||
* Localize components
|
||||
@ -163,8 +177,8 @@ class Scripts {
|
||||
'wu_fields',
|
||||
[
|
||||
'l10n' => [
|
||||
'image_picker_title' => __('Select an Image.', 'wp-ultimo'),
|
||||
'image_picker_button_text' => __('Use this image', 'wp-ultimo'),
|
||||
'image_picker_title' => __('Select an Image.', 'wp-multisite-waas'),
|
||||
'image_picker_button_text' => __('Use this image', 'wp-multisite-waas'),
|
||||
],
|
||||
]
|
||||
);
|
||||
@ -228,6 +242,13 @@ class Scripts {
|
||||
]
|
||||
);
|
||||
|
||||
wp_register_script_module(
|
||||
'wu-flags-polyfill',
|
||||
wu_get_asset('flags.js', 'js'),
|
||||
array(),
|
||||
\WP_Ultimo::VERSION
|
||||
);
|
||||
|
||||
/*
|
||||
* WordPress localizes month names and all, but
|
||||
* does not localize anything else. We need relative
|
||||
@ -253,7 +274,7 @@ class Scripts {
|
||||
'LT' => $time_format,
|
||||
'LTS' => str_replace(':i', ':i:s', (string) $time_format),
|
||||
/* translators: the day/month/year date format used by WP Multisite WaaS. You can changed it to localize this date format to your language. the default value is d/m/Y, which is the format 31/12/2021. */
|
||||
'L' => __('d/m/Y', 'wp-ultimo'),
|
||||
'L' => __('d/m/Y', 'wp-multisite-waas'),
|
||||
'LL' => $date_format,
|
||||
'LLL' => sprintf('%s %s', $date_format, $time_format),
|
||||
'LLLL' => sprintf('%s %s', $date_format, $time_format),
|
||||
@ -263,22 +284,22 @@ class Scripts {
|
||||
// phpcs:disable
|
||||
$strings = [
|
||||
'relativeTime' => [
|
||||
'future' => __('in %s', 'wp-ultimo'),
|
||||
'past' => __('%s ago', 'wp-ultimo'),
|
||||
's' => __('a few seconds', 'wp-ultimo'),
|
||||
'ss' => __('%d seconds', 'wp-ultimo'),
|
||||
'm' => __('a minute', 'wp-ultimo'),
|
||||
'mm' => __('%d minutes', 'wp-ultimo'),
|
||||
'h' => __('an hour', 'wp-ultimo'),
|
||||
'hh' => __('%d hours', 'wp-ultimo'),
|
||||
'd' => __('a day', 'wp-ultimo'),
|
||||
'dd' => __('%d days', 'wp-ultimo'),
|
||||
'w' => __('a week', 'wp-ultimo'),
|
||||
'ww' => __('%d weeks', 'wp-ultimo'),
|
||||
'M' => __('a month', 'wp-ultimo'),
|
||||
'MM' => __('%d months', 'wp-ultimo'),
|
||||
'y' => __('a year', 'wp-ultimo'),
|
||||
'yy' => __('%d years', 'wp-ultimo'),
|
||||
'future' => __('in %s', 'wp-multisite-waas'),
|
||||
'past' => __('%s ago', 'wp-multisite-waas'),
|
||||
's' => __('a few seconds', 'wp-multisite-waas'),
|
||||
'ss' => __('%d seconds', 'wp-multisite-waas'),
|
||||
'm' => __('a minute', 'wp-multisite-waas'),
|
||||
'mm' => __('%d minutes', 'wp-multisite-waas'),
|
||||
'h' => __('an hour', 'wp-multisite-waas'),
|
||||
'hh' => __('%d hours', 'wp-multisite-waas'),
|
||||
'd' => __('a day', 'wp-multisite-waas'),
|
||||
'dd' => __('%d days', 'wp-multisite-waas'),
|
||||
'w' => __('a week', 'wp-multisite-waas'),
|
||||
'ww' => __('%d weeks', 'wp-multisite-waas'),
|
||||
'M' => __('a month', 'wp-multisite-waas'),
|
||||
'MM' => __('%d months', 'wp-multisite-waas'),
|
||||
'y' => __('a year', 'wp-multisite-waas'),
|
||||
'yy' => __('%d years', 'wp-multisite-waas'),
|
||||
],
|
||||
'longDateFormat' => $long_date_formats,
|
||||
];
|
||||
|
Reference in New Issue
Block a user