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:
@ -30,7 +30,7 @@ class Maintenance_Mode {
|
||||
*/
|
||||
public function init(): void {
|
||||
|
||||
add_action('wp_ultimo_load', [$this, 'add_settings']);
|
||||
add_action('init', [$this, 'add_settings']);
|
||||
|
||||
if (wu_get_setting('maintenance_mode')) {
|
||||
$this->hooks();
|
||||
@ -71,7 +71,7 @@ class Maintenance_Mode {
|
||||
* Add maintenance mode Notice to Admin Bar
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @param WP_Admin_Bar $wp_admin_bar The Admin Bar class.
|
||||
* @param \WP_Admin_Bar $wp_admin_bar The Admin Bar class.
|
||||
* @return void
|
||||
*/
|
||||
public function add_notice_to_admin_bar($wp_admin_bar): void {
|
||||
@ -84,11 +84,11 @@ class Maintenance_Mode {
|
||||
$args = [
|
||||
'id' => 'wu-maintenance-mode',
|
||||
'parent' => 'top-secondary',
|
||||
'title' => __('Maintenance Mode - Active', 'wp-ultimo'),
|
||||
'title' => __('Maintenance Mode - Active', 'wp-multisite-waas'),
|
||||
'href' => '#wp-ultimo-site-maintenance-element',
|
||||
'meta' => [
|
||||
'class' => 'wu-maintenance-mode ' . (self::check_maintenance_mode() ? '' : 'hidden'),
|
||||
'title' => __('This means that your site is not available for visitors at the moment. Only you and other logged users have access to it. Click here to toggle this option.', 'wp-ultimo'),
|
||||
'title' => __('This means that your site is not available for visitors at the moment. Only you and other logged users have access to it. Click here to toggle this option.', 'wp-multisite-waas'),
|
||||
],
|
||||
];
|
||||
|
||||
@ -110,15 +110,15 @@ class Maintenance_Mode {
|
||||
|
||||
$text = apply_filters(
|
||||
'wu_maintenance_mode_text',
|
||||
__('Website under planned maintenance. Please check back later.', 'wp-ultimo')
|
||||
__('Website under planned maintenance. Please check back later.', 'wp-multisite-waas')
|
||||
);
|
||||
|
||||
$title = apply_filters(
|
||||
'wu_maintenance_mode_title',
|
||||
__('Under Maintenance', 'wp-ultimo')
|
||||
__('Under Maintenance', 'wp-multisite-waas')
|
||||
);
|
||||
|
||||
wp_die($text, $title, 503);
|
||||
wp_die(esc_html($text), esc_html($title), 503);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -140,14 +140,21 @@ class Maintenance_Mode {
|
||||
*/
|
||||
public function toggle_maintenance_mode() {
|
||||
|
||||
check_ajax_referer('wu_toggle_maintenance_mode', $_POST['_wpnonce']);
|
||||
if ( ! check_ajax_referer('wu_toggle_maintenance_mode', '_wpnonce', false)) {
|
||||
wp_send_json_error(
|
||||
[
|
||||
'message' => __('Request failed, please refresh and try again.', 'wp-multisite-waas'),
|
||||
'value' => false,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$site_id = \WP_Ultimo\Helpers\Hash::decode(wu_request('site_hash'), 'site');
|
||||
|
||||
if ( ! current_user_can_for_blog($site_id, 'manage_options')) {
|
||||
return wp_send_json_error(
|
||||
if ( ! current_user_can_for_site($site_id, 'manage_options')) {
|
||||
wp_send_json_error(
|
||||
[
|
||||
'message' => __('You do not have the necessary permissions to perform this option.', 'wp-ultimo'),
|
||||
'message' => __('You do not have the necessary permissions to perform this option.', 'wp-multisite-waas'),
|
||||
'value' => false,
|
||||
]
|
||||
);
|
||||
@ -160,7 +167,7 @@ class Maintenance_Mode {
|
||||
update_site_meta($site_id, 'wu_maintenance_mode', $value);
|
||||
|
||||
$return = [
|
||||
'message' => __('New maintenance settings saved.', 'wp-ultimo'),
|
||||
'message' => __('New maintenance settings saved.', 'wp-multisite-waas'),
|
||||
'value' => $value,
|
||||
];
|
||||
|
||||
@ -182,8 +189,8 @@ class Maintenance_Mode {
|
||||
'sites',
|
||||
'maintenance_mode',
|
||||
[
|
||||
'title' => __('Site Maintenance Mode', 'wp-ultimo'),
|
||||
'desc' => __('Allow your customers and super admins to quickly take sites offline via a toggle on the site dashboard.', 'wp-ultimo'),
|
||||
'title' => __('Site Maintenance Mode', 'wp-multisite-waas'),
|
||||
'desc' => __('Allow your customers and super admins to quickly take sites offline via a toggle on the site dashboard.', 'wp-multisite-waas'),
|
||||
'type' => 'toggle',
|
||||
'default' => 0,
|
||||
'order' => 23,
|
||||
|
Reference in New Issue
Block a user