| @@ -17,14 +17,14 @@ | ||
| 17 | 17 | * @return void |
| 18 | 18 | */ |
| 19 | 19 | public function __construct( $core ) { |
| 20 | 20 | parent::__construct( $core ); |
| 21 | - add_action( 'admin_head', array( $this, 'add_meta_nonce' ) ); | |
| 22 | - add_action( 'admin_menu', array( $this, 'add_menu_pages' ) ); | |
| 23 | - add_action( 'network_admin_menu', array( $this, 'network_menu' ) ); | |
| 24 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) ); | |
| 25 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); | |
| 26 | - add_filter( 'plugin_action_links_' . $this->plugin->basename, array( $this, 'admin_settings' ) ); | |
| 21 | + add_action( 'admin_head', [ $this, 'add_meta_nonce' ] ); | |
| 22 | + add_action( 'admin_menu', [ $this, 'add_menu_pages' ] ); | |
| 23 | + add_action( 'network_admin_menu', [ $this, 'network_menu' ] ); | |
| 24 | + add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_styles' ] ); | |
| 25 | + add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] ); | |
| 26 | + add_filter( 'plugin_action_links_' . $this->plugin->basename, [ $this, 'admin_settings' ] ); | |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Add Patchstack nonce as meta tag so we can access it in our JavaScript files. |
| @@ -43,9 +43,9 @@ | ||
| 43 | 43 | * |
| 44 | 44 | * @return void |
| 45 | 45 | */ |
| 46 | 46 | public function add_menu_pages() { |
| 47 | - add_submenu_page( $this->plugin->name, 'Main', __( 'Settings', 'patchstack' ), 'manage_options', $this->plugin->name, array( $this, 'render_settings_page' ) ); | |
| 47 | + add_submenu_page( $this->plugin->name, 'Main', __( 'Settings', 'patchstack' ), 'manage_options', $this->plugin->name, [ $this, 'render_settings_page' ] ); | |
| 48 | 48 | add_options_page( 'Security', 'Security', 'manage_options', $this->plugin->name ); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
| @@ -53,12 +53,12 @@ | ||
| 53 | 53 | * |
| 54 | 54 | * @return void |
| 55 | 55 | */ |
| 56 | 56 | public function network_menu() { |
| 57 | - add_menu_page( 'Patchstack', 'Patchstack', 'manage_options', 'patchstack-multisite', array( $this->plugin->multisite, 'sites_section_callback' ) ); | |
| 58 | - add_submenu_page( 'patchstack-multisite', 'Activate', 'Activate', 'manage_options', 'patchstack-multisite-settings&tab=multisite', array( $this->plugin->multisite, 'settings' ) ); | |
| 59 | - add_submenu_page( 'patchstack-multisite', 'Sites', 'Sites', 'manage_options', 'patchstack-multisite', array( $this->plugin->multisite, 'sites_section_callback' ) ); | |
| 60 | - add_submenu_page( 'patchstack-multisite', 'Settings', 'Settings', 'manage_options', 'patchstack-multisite-settings', array( $this, 'render_settings_page' ) ); | |
| 57 | + add_menu_page( 'Patchstack', 'Patchstack', 'manage_options', 'patchstack-multisite', [ $this->plugin->multisite, 'sites_section_callback' ] ); | |
| 58 | + add_submenu_page( 'patchstack-multisite', 'Activate', 'Activate', 'manage_options', 'patchstack-multisite-settings&tab=multisite', [ $this->plugin->multisite, 'settings' ] ); | |
| 59 | + add_submenu_page( 'patchstack-multisite', 'Sites', 'Sites', 'manage_options', 'patchstack-multisite', [ $this->plugin->multisite, 'sites_section_callback' ] ); | |
| 60 | + add_submenu_page( 'patchstack-multisite', 'Settings', 'Settings', 'manage_options', 'patchstack-multisite-settings', [ $this, 'render_settings_page' ] ); | |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * Render the settings page. |
| @@ -78,19 +78,19 @@ | ||
| 78 | 78 | $screen = get_current_screen(); |
| 79 | 79 | |
| 80 | 80 | // Load the Patchstack style on all Patchstack pages except site overview. |
| 81 | 81 | if ( isset( $screen->base, $_GET['page'] ) && stripos( $screen->base, 'patchstack' ) !== false && $_GET['page'] != 'patchstack-multisite' ) { |
| 82 | - wp_enqueue_style( 'patchstack', $this->plugin->url . 'assets/css/patchstack.min.css', array(), $this->plugin->version ); | |
| 82 | + wp_enqueue_style( 'patchstack', $this->plugin->url . 'assets/css/patchstack.min.css', [], $this->plugin->version ); | |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | // Only load the selectize CSS file on the firewall settings page. |
| 86 | - if ( isset( $screen->base ) && stripos( $screen->base, 'patchstack' ) !== false && isset( $_GET['tab'] ) && $_GET['tab'] == 'firewall' ) { | |
| 87 | - wp_enqueue_style( 'patchstack-selectize', $this->plugin->url . 'assets/css/selectize.min.css', array( ), $this->plugin->version ); | |
| 86 | + if ( isset( $screen->base ) && stripos( $screen->base, 'patchstack' ) !== false ) { | |
| 87 | + wp_enqueue_style( 'patchstack-selectize', $this->plugin->url . 'assets/css/selectize.min.css', [ ], $this->plugin->version ); | |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | // Only load the dataTables CSS fileon the logs page. |
| 91 | 91 | if ( isset( $screen->base ) && stripos( $screen->base, 'patchstack' ) !== false && isset( $_GET['tab'] ) && $_GET['tab'] == 'logs' ) { |
| 92 | - wp_enqueue_style( 'patchstack-logs', $this->plugin->url . 'assets/css/jquery.dataTables.min.css', array( ), $this->plugin->version ); | |
| 92 | + wp_enqueue_style( 'patchstack-logs', $this->plugin->url . 'assets/css/jquery.dataTables.min.css', [ ], $this->plugin->version ); | |
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
| @@ -100,35 +100,35 @@ | ||
| 100 | 100 | */ |
| 101 | 101 | public function enqueue_scripts() { |
| 102 | 102 | $screen = get_current_screen(); |
| 103 | 103 | if ( isset( $screen->base ) && ( stripos( $screen->base, 'patchstack' ) !== false ) && current_user_can( 'manage_options' ) ) { |
| 104 | - wp_enqueue_script( 'patchstack', $this->plugin->url . 'assets/js/patchstack.min.js', array( 'jquery' ), $this->plugin->version ); | |
| 104 | + wp_enqueue_script( 'patchstack', $this->plugin->url . 'assets/js/patchstack.min.js', [ 'jquery' ], $this->plugin->version ); | |
| 105 | 105 | wp_enqueue_script( 'google-jsapi', 'https://www.google.com/jsapi' ); |
| 106 | 106 | wp_localize_script( |
| 107 | 107 | 'patchstack', |
| 108 | 108 | 'PatchstackVars', |
| 109 | - array( | |
| 109 | + [ | |
| 110 | 110 | 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
| 111 | 111 | 'nonce' => wp_create_nonce( 'patchstack-nonce' ), |
| 112 | 112 | 'error_message' => __( 'Sorry, there was a problem processing your request.', 'patchstack' ), |
| 113 | - ) | |
| 113 | + ] | |
| 114 | 114 | ); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | // Only load the colorpicker on the cookie notice settings page. |
| 118 | 118 | if ( isset( $screen->base ) && stripos( $screen->base, 'patchstack' ) !== false && isset( $_GET['tab'] ) && $_GET['tab'] == 'cookienotice' ) { |
| 119 | - wp_enqueue_script( 'patchstack-jscolor', $this->plugin->url . 'assets/js/jscolor.js', array( ), $this->plugin->version ); | |
| 119 | + wp_enqueue_script( 'patchstack-jscolor', $this->plugin->url . 'assets/js/jscolor.js', [ ], $this->plugin->version ); | |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | // Only load the selectize library on the firewall settings page. |
| 123 | - if ( isset( $screen->base ) && stripos( $screen->base, 'patchstack' ) !== false && isset( $_GET['tab'] ) && $_GET['tab'] == 'firewall' ) { | |
| 124 | - wp_enqueue_script( 'patchstack-selectize', $this->plugin->url . 'assets/js/selectize.min.js', array( ), $this->plugin->version ); | |
| 123 | + if ( isset( $screen->base ) && stripos( $screen->base, 'patchstack' ) !== false ) { | |
| 124 | + wp_enqueue_script( 'patchstack-selectize', $this->plugin->url . 'assets/js/selectize.min.js', [ ], $this->plugin->version ); | |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | // Only load the dataTables related libraries on the logs page. |
| 128 | 128 | if ( isset( $screen->base ) && stripos( $screen->base, 'patchstack' ) !== false && isset( $_GET['tab'] ) && $_GET['tab'] == 'logs' ) { |
| 129 | - wp_enqueue_script( 'patchstack-bootstrap', $this->plugin->url . 'assets/js/bootstrap.min.js', array( 'jquery' ), $this->plugin->version ); | |
| 130 | - wp_enqueue_script( 'patchstack-logs', $this->plugin->url . 'assets/js/jquery.dataTables.min.js', array( ), $this->plugin->version ); | |
| 129 | + wp_enqueue_script( 'patchstack-bootstrap', $this->plugin->url . 'assets/js/bootstrap.min.js', [ 'jquery' ], $this->plugin->version ); | |
| 130 | + wp_enqueue_script( 'patchstack-logs', $this->plugin->url . 'assets/js/jquery.dataTables.min.js', [ ], $this->plugin->version ); | |
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
| @@ -137,7 +137,7 @@ | ||
| 137 | 137 | * @param array $links |
| 138 | 138 | * @return array |
| 139 | 139 | */ |
| 140 | 140 | public function admin_settings( $links ) { |
| 141 | - return array_merge( array( '<a href="admin.php?page=patchstack&tab=firewall">' . __( 'Settings', 'patchstack' ) . '</a>' ), $links ); | |
| 141 | + return array_merge( [ '<a href="admin.php?page=patchstack&tab=license">' . __( 'Settings', 'patchstack' ) . '</a>' ], $links ); | |
| 142 | 142 | } |
| 143 | 143 | } |