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:
@ -46,7 +46,7 @@ class Jumper {
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
add_action('wp_ultimo_load', [$this, 'add_settings'], 20);
|
||||
add_action('init', [$this, 'add_settings'], 20);
|
||||
|
||||
add_action('init', [$this, 'load_jumper']);
|
||||
}
|
||||
@ -136,10 +136,10 @@ class Jumper {
|
||||
*/
|
||||
public function rebuild_menu(): void {
|
||||
|
||||
if (isset($_GET[ $this->reset_slug ]) && current_user_can('manage_network')) {
|
||||
if (isset($_GET[ $this->reset_slug ]) && isset($_GET['nonce']) && current_user_can('manage_network') && wp_verify_nonce(sanitize_text_field(wp_unslash($_GET['nonce'])), 'reset_password')) {
|
||||
delete_site_transient($this->transient_key);
|
||||
|
||||
wp_redirect(network_admin_url());
|
||||
wp_safe_redirect(network_admin_url());
|
||||
|
||||
exit;
|
||||
}
|
||||
@ -185,7 +185,7 @@ class Jumper {
|
||||
$custom_links = $this->get_user_custom_links();
|
||||
|
||||
if ( ! empty($custom_links)) {
|
||||
$links[ __('Custom Links', 'wp-ultimo') ] = $custom_links;
|
||||
$links[ __('Custom Links', 'wp-multisite-waas') ] = $custom_links;
|
||||
}
|
||||
|
||||
return $links;
|
||||
@ -203,27 +203,27 @@ class Jumper {
|
||||
|
||||
if (isset($links['WP Ultimo'])) {
|
||||
$settings_tabs = [
|
||||
'general' => __('General', 'wp-ultimo'),
|
||||
'network' => __('Network Settings', 'wp-ultimo'),
|
||||
'gateways' => __('Payment Gateways', 'wp-ultimo'),
|
||||
'domain_mapping' => __('Domain Mapping & SSL', 'wp-ultimo'),
|
||||
'emails' => __('Emails', 'wp-ultimo'),
|
||||
'styling' => __('Styling', 'wp-ultimo'),
|
||||
'tools' => __('Tools', 'wp-ultimo'),
|
||||
'advanced' => __('Advanced', 'wp-ultimo'),
|
||||
'activation' => __('Activation & Support', 'wp-ultimo'),
|
||||
'general' => __('General', 'wp-multisite-waas'),
|
||||
'network' => __('Network Settings', 'wp-multisite-waas'),
|
||||
'gateways' => __('Payment Gateways', 'wp-multisite-waas'),
|
||||
'domain_mapping' => __('Domain Mapping & SSL', 'wp-multisite-waas'),
|
||||
'emails' => __('Emails', 'wp-multisite-waas'),
|
||||
'styling' => __('Styling', 'wp-multisite-waas'),
|
||||
'tools' => __('Tools', 'wp-multisite-waas'),
|
||||
'advanced' => __('Advanced', 'wp-multisite-waas'),
|
||||
'activation' => __('Activation & Support', 'wp-multisite-waas'),
|
||||
];
|
||||
|
||||
foreach ($settings_tabs as $tab => $tab_label) {
|
||||
$url = network_admin_url('admin.php?page=wp-ultimo-settings&wu-tab=' . $tab);
|
||||
|
||||
// translators: The placeholder represents the title of the Settings tab.
|
||||
$links['WP Ultimo'][ $url ] = sprintf(__('Settings: %s', 'wp-ultimo'), $tab_label);
|
||||
$links['WP Ultimo'][ $url ] = sprintf(__('Settings: %s', 'wp-multisite-waas'), $tab_label);
|
||||
}
|
||||
|
||||
$links['WP Ultimo'][ network_admin_url('admin.php?page=wp-ultimo-settings&wu-tab=tools') ] = __('Settings: Webhooks', 'wp-ultimo');
|
||||
$links['WP Ultimo'][ network_admin_url('admin.php?page=wp-ultimo-settings&wu-tab=tools') ] = __('Settings: Webhooks', 'wp-multisite-waas');
|
||||
|
||||
$links['WP Ultimo'][ network_admin_url('admin.php?page=wp-ultimo-system-info&wu-tab=logs') ] = __('System Info: Logs', 'wp-ultimo');
|
||||
$links['WP Ultimo'][ network_admin_url('admin.php?page=wp-ultimo-system-info&wu-tab=logs') ] = __('System Info: Logs', 'wp-multisite-waas');
|
||||
|
||||
/**
|
||||
* Adds Main Site Dashboard
|
||||
@ -231,7 +231,7 @@ class Jumper {
|
||||
if (isset($links[ __('Sites') ])) {
|
||||
$main_site_url = get_admin_url(get_current_site()->blog_id);
|
||||
|
||||
$links[ __('Sites') ][ $main_site_url ] = __('Main Site Dashboard', 'wp-ultimo');
|
||||
$links[ __('Sites') ][ $main_site_url ] = __('Main Site Dashboard', 'wp-multisite-waas');
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,7 +243,7 @@ class Jumper {
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
function get_defined_trigger_key(): string {
|
||||
public function get_defined_trigger_key(): string {
|
||||
|
||||
return substr((string) wu_get_setting('jumper_key', 'g'), 0, 1);
|
||||
}
|
||||
@ -259,7 +259,7 @@ class Jumper {
|
||||
* @param string $os OS to get the key combination for. Options: win or osx.
|
||||
* @return array
|
||||
*/
|
||||
function get_keys($os = 'win') {
|
||||
public function get_keys($os = 'win') {
|
||||
|
||||
$trigger_key = $this->get_defined_trigger_key();
|
||||
|
||||
@ -285,7 +285,7 @@ class Jumper {
|
||||
return $text;
|
||||
}
|
||||
|
||||
$os = stristr((string) $_SERVER['HTTP_USER_AGENT'], 'mac') ? 'osx' : 'win';
|
||||
$os = isset($_SERVER['HTTP_USER_AGENT']) && stristr(sanitize_text_field(wp_unslash($_SERVER['HTTP_USER_AGENT'])), 'mac') ? 'osx' : 'win';
|
||||
|
||||
$keys = $this->get_keys($os);
|
||||
|
||||
@ -298,7 +298,7 @@ class Jumper {
|
||||
$html = trim($html, '+');
|
||||
|
||||
// translators: the %s placeholder is the key combination to trigger the Jumper.
|
||||
return '<span class="wu-keys">' . sprintf(__('<strong>Quick Tip:</strong> Use %s to jump between pages.', 'wp-ultimo'), $html) . '</span>' . $text;
|
||||
return '<span class="wu-keys">' . sprintf(__('<strong>Quick Tip:</strong> Use %s to jump between pages.', 'wp-multisite-waas'), $html) . '</span>' . $text;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -317,7 +317,7 @@ class Jumper {
|
||||
'wu-jumper',
|
||||
'wu_jumper_vars',
|
||||
[
|
||||
'not_found_message' => __('Nothing found for', 'wp-ultimo'),
|
||||
'not_found_message' => __('Nothing found for', 'wp-multisite-waas'),
|
||||
'trigger_key' => $this->get_defined_trigger_key(),
|
||||
'network_base_url' => network_admin_url(),
|
||||
'ajaxurl' => wu_ajax_url(),
|
||||
@ -406,7 +406,7 @@ class Jumper {
|
||||
|
||||
return Logger::track_time(
|
||||
'jumper',
|
||||
__('Regenerating Jumper menu items', 'wp-ultimo'),
|
||||
__('Regenerating Jumper menu items', 'wp-multisite-waas'),
|
||||
function () {
|
||||
|
||||
global $menu, $submenu;
|
||||
@ -425,7 +425,7 @@ class Jumper {
|
||||
|
||||
$string = wu_get_isset($title, 0, '');
|
||||
|
||||
$title = preg_replace('/[0-9]+/', '', strip_tags($string));
|
||||
$title = preg_replace('/[0-9]+/', '', wp_strip_all_tags($string));
|
||||
|
||||
// If parent does not exists, skip
|
||||
if ( ! empty($title) && is_array($submenu_items)) {
|
||||
@ -435,7 +435,6 @@ class Jumper {
|
||||
$url = $this->get_target_url($submenu_item[2]);
|
||||
|
||||
// Add to our choices the admin urls
|
||||
$choices[ $title ][ $url ] = preg_replace('/[0-9]+/', '', strip_tags((string) $submenu_item[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -487,8 +486,8 @@ class Jumper {
|
||||
wu_register_settings_section(
|
||||
'tools',
|
||||
[
|
||||
'title' => __('Tools', 'wp-ultimo'),
|
||||
'desc' => __('Tools', 'wp-ultimo'),
|
||||
'title' => __('Tools', 'wp-multisite-waas'),
|
||||
'desc' => __('Tools', 'wp-multisite-waas'),
|
||||
'icon' => 'dashicons-wu-tools',
|
||||
]
|
||||
);
|
||||
@ -497,8 +496,8 @@ class Jumper {
|
||||
'tools',
|
||||
'tools_header',
|
||||
[
|
||||
'title' => __('Jumper', 'wp-ultimo'),
|
||||
'desc' => __('Spotlight-like search bar that allows you to easily access everything on your network.', 'wp-ultimo'),
|
||||
'title' => __('Jumper', 'wp-multisite-waas'),
|
||||
'desc' => __('Spotlight-like search bar that allows you to easily access everything on your network.', 'wp-multisite-waas'),
|
||||
'type' => 'header',
|
||||
]
|
||||
);
|
||||
@ -507,8 +506,8 @@ class Jumper {
|
||||
'tools',
|
||||
'enable_jumper',
|
||||
[
|
||||
'title' => __('Enable Jumper', 'wp-ultimo'),
|
||||
'desc' => __('Turn this option on to make the Jumper available on your network.', 'wp-ultimo'),
|
||||
'title' => __('Enable Jumper', 'wp-multisite-waas'),
|
||||
'desc' => __('Turn this option on to make the Jumper available on your network.', 'wp-multisite-waas'),
|
||||
'type' => 'toggle',
|
||||
'default' => 1,
|
||||
]
|
||||
@ -518,8 +517,8 @@ class Jumper {
|
||||
'tools',
|
||||
'jumper_key',
|
||||
[
|
||||
'title' => __('Trigger Key', 'wp-ultimo'),
|
||||
'desc' => __('Change the keyboard key used in conjunction with ctrl + alt (or cmd + option), to trigger the Jumper box.', 'wp-ultimo'),
|
||||
'title' => __('Trigger Key', 'wp-multisite-waas'),
|
||||
'desc' => __('Change the keyboard key used in conjunction with ctrl + alt (or cmd + option), to trigger the Jumper box.', 'wp-multisite-waas'),
|
||||
'type' => 'text',
|
||||
'default' => 'g',
|
||||
'require' => [
|
||||
@ -532,9 +531,9 @@ class Jumper {
|
||||
'tools',
|
||||
'jumper_custom_links',
|
||||
[
|
||||
'title' => __('Custom Links', 'wp-ultimo'),
|
||||
'desc' => __('Use this textarea to add custom links to the Jumper. Add one per line, with the format "Title : url".', 'wp-ultimo'),
|
||||
'placeholder' => __('Tile of Custom Link : http://link.com', 'wp-ultimo'),
|
||||
'title' => __('Custom Links', 'wp-multisite-waas'),
|
||||
'desc' => __('Use this textarea to add custom links to the Jumper. Add one per line, with the format "Title : url".', 'wp-multisite-waas'),
|
||||
'placeholder' => __('Tile of Custom Link : http://link.com', 'wp-multisite-waas'),
|
||||
'type' => 'textarea',
|
||||
'html_attr' => [
|
||||
'rows' => 4,
|
||||
|
Reference in New Issue
Block a user