Use new code style

This commit is contained in:
David Stone
2025-02-07 19:02:33 -07:00
parent 0181024ae1
commit 8433379d90
672 changed files with 37107 additions and 45249 deletions

View File

@ -40,8 +40,7 @@ class Scripts {
add_action('wp_ajax_wu_toggle_container', array($this, 'update_use_container'));
add_filter('admin_body_class', array($this, 'add_body_class_container_boxed'));
} // end init;
}
/**
* Wrapper for the register scripts function.
@ -56,8 +55,7 @@ class Scripts {
public function register_script($handle, $src, $deps = array()) {
wp_register_script($handle, $src, $deps, wu_get_version());
} // end register_script;
}
/**
* Wrapper for the register styles function.
@ -72,8 +70,7 @@ class Scripts {
public function register_style($handle, $src, $deps = array()) {
wp_register_style($handle, $src, $deps, wu_get_version());
} // end register_style;
}
/**
* Registers the default WP Multisite WaaS scripts.
@ -138,16 +135,20 @@ class Scripts {
*/
$this->register_script('wu-functions', wu_get_asset('functions.js', 'js'), array('jquery-core', 'wu-tiptip', 'wu-flatpicker', 'wu-block-ui', 'wu-accounting', 'clipboard', 'wp-hooks'));
wp_localize_script('wu-functions', 'wu_settings', array(
'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'),
'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),
));
wp_localize_script(
'wu-functions',
'wu_settings',
array(
'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'),
'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),
)
);
/*
* Adds Fields & Components
@ -157,12 +158,16 @@ class Scripts {
/*
* Localize components
*/
wp_localize_script('wu-fields', 'wu_fields', array(
'l10n' => array(
'image_picker_title' => __('Select an Image.', 'wp-ultimo'),
'image_picker_button_text' => __('Use this image', 'wp-ultimo'),
),
));
wp_localize_script(
'wu-fields',
'wu_fields',
array(
'l10n' => array(
'image_picker_title' => __('Select an Image.', 'wp-ultimo'),
'image_picker_button_text' => __('Use this image', 'wp-ultimo'),
),
)
);
/*
* Adds Admin Script
@ -183,33 +188,45 @@ class Scripts {
/*
* Localize selectizer
*/
wp_localize_script('wu-functions', 'wu_selectizer', array(
'ajaxurl' => wu_ajax_url(),
));
wp_localize_script(
'wu-functions',
'wu_selectizer',
array(
'ajaxurl' => wu_ajax_url(),
)
);
/*
* Load variables to localized it
*/
wp_localize_script('wu-functions', 'wu_ticker', array(
wp_localize_script(
'wu-functions',
'wu_ticker',
array(
'server_clock_offset' => (wu_get_current_time('timestamp') - time()) / 60 / 60, // phpcs:ignore
'moment_clock_timezone_name' => wp_date('e'),
'moment_clock_timezone_offset' => wp_date('Z'),
));
)
);
/*
* Adds our thickbox fork.
*/
$this->register_script('wubox', wu_get_asset('wubox.js', 'js'), array('wu-vue-apps'));
wp_localize_script('wubox', 'wuboxL10n', array(
'next' => __('Next >'),
'prev' => __('< Prev'),
'image' => __('Image'),
'of' => __('of'),
'close' => __('Close'),
'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'),
'loadingAnimation' => includes_url('js/thickbox/loadingAnimation.gif'),
));
wp_localize_script(
'wubox',
'wuboxL10n',
array(
'next' => __('Next >'),
'prev' => __('< Prev'),
'image' => __('Image'),
'of' => __('of'),
'close' => __('Close'),
'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'),
'loadingAnimation' => includes_url('js/thickbox/loadingAnimation.gif'),
)
);
/*
* WordPress localizes month names and all, but
@ -217,8 +234,7 @@ class Scripts {
* times to be translated, so we need to do it ourselves.
*/
$this->localize_moment();
} // end register_default_scripts;
}
/**
* Localize moment.js relative times.
@ -231,15 +247,18 @@ class Scripts {
$time_format = get_option('time_format', __('g:i a'));
$date_format = get_option('date_format', __('F j, Y'));
$long_date_formats = array_map('wu_convert_php_date_format_to_moment_js_format', array(
'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'),
'LL' => $date_format,
'LLL' => sprintf('%s %s', $date_format, $time_format),
'LLLL' => sprintf('%s %s', $date_format, $time_format),
));
$long_date_formats = array_map(
'wu_convert_php_date_format_to_moment_js_format',
array(
'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'),
'LL' => $date_format,
'LLL' => sprintf('%s %s', $date_format, $time_format),
'LLLL' => sprintf('%s %s', $date_format, $time_format),
)
);
// phpcs:disable
$strings = array(
@ -268,8 +287,7 @@ class Scripts {
$inline_script = sprintf("moment.updateLocale( '%s', %s );", get_user_locale(), wp_json_encode($strings));
return did_action('init') && wp_add_inline_script('moment', $inline_script, 'after');
} // end localize_moment;
}
/**
* Registers the default WP Multisite WaaS styles.
@ -286,8 +304,7 @@ class Scripts {
$this->register_style('wu-checkout', wu_get_asset('checkout.css', 'css'), array(), wu_get_version());
$this->register_style('wu-flags', wu_get_asset('flags.css', 'css'), array(), wu_get_version());
} // end register_default_styles;
}
/**
* Loads the default admin styles.
@ -298,8 +315,7 @@ class Scripts {
public function enqueue_default_admin_styles() {
wp_enqueue_style('wu-admin');
} // end enqueue_default_admin_styles;
}
/**
* Loads the default admin scripts.
@ -310,8 +326,7 @@ class Scripts {
public function enqueue_default_admin_scripts() {
wp_enqueue_script('wu-admin');
} // end enqueue_default_admin_scripts;
}
/**
* Update the use container setting.
@ -323,13 +338,12 @@ class Scripts {
check_ajax_referer('wu_toggle_container', 'nonce');
$new_value = (bool) !(get_user_setting('wu_use_container', false));
$new_value = (bool) ! (get_user_setting('wu_use_container', false));
set_user_setting('wu_use_container', $new_value);
wp_die();
} // end update_use_container;
}
/**
* Add body classes of container boxed if user has setting.
@ -342,13 +356,9 @@ class Scripts {
public function add_body_class_container_boxed($classes) {
if (get_user_setting('wu_use_container', false)) {
$classes .= ' has-wu-container ';
} // end if;
}
return $classes;
} // end add_body_class_container_boxed;
} // end class Scripts;
}
}