PluginProbe
Patchstack – WordPress & Plugins Security / 2.2.4
Patchstack – WordPress & Plugins Security v2.2.4
2.3.7 trunk 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.16 2.1.17 2.1.18 2.1.19 2.1.2 2.1.20 2.1.21 2.1.22 2.1.23 2.1.24 2.1.25 2.1.3 2.1.4 2.1.5 2.1.6 All 49 releases
← All changes | includes/admin/menu.php +33 -11 2.3.72.2.4 View file →
@@ -17,13 +17,8 @@
17 17 * @return void
18 18 */
19 19 public function __construct( $core ) {
20 20 parent::__construct( $core );
21 -
22 - if ( defined( 'PS_DISABLE_MENU' ) && PS_DISABLE_MENU ) {
23 - return;
24 - }
25 -
26 21 add_action( 'admin_head', [ $this, 'add_meta_nonce' ] );
27 22 add_action( 'admin_menu', [ $this, 'add_menu_pages' ] );
28 23 add_action( 'network_admin_menu', [ $this, 'network_menu' ] );
29 24 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_styles' ] );
@@ -37,9 +32,9 @@
37 32 * @return void
38 33 */
39 34 public function add_meta_nonce() {
40 35 $screen = get_current_screen();
41 - if ( current_user_can( 'manage_options' ) && isset( $screen->base ) && stripos( $screen->base, 'patchstack' ) !== false ) {
36 + if ( current_user_can( 'manage_options' ) && isset( $screen->base ) && ( $screen->base == 'dashboard' || stripos( $screen->base, 'patchstack' ) !== false ) ) {
42 37 echo '<meta name="patchstack_nonce" value="' . wp_create_nonce( 'patchstack-nonce' ) . '">';
43 38 }
44 39 }
45 40
@@ -48,9 +43,9 @@
48 43 *
49 44 * @return void
50 45 */
51 46 public function add_menu_pages() {
52 - add_submenu_page( $this->plugin->name, 'Main', esc_attr__( 'Settings', 'patchstack' ), 'manage_options', $this->plugin->name, [ $this, 'render_settings_page' ] );
47 + add_submenu_page( $this->plugin->name, 'Main', __( 'Settings', 'patchstack' ), 'manage_options', $this->plugin->name, [ $this, 'render_settings_page' ] );
53 48 add_options_page( 'Security', 'Security', 'manage_options', $this->plugin->name );
54 49 }
55 50
56 51 /**
@@ -59,9 +54,11 @@
59 54 * @return void
60 55 */
61 56 public function network_menu() {
62 57 add_menu_page( 'Patchstack', 'Patchstack', 'manage_options', 'patchstack-multisite', [ $this->plugin->multisite, 'sites_section_callback' ] );
63 - add_submenu_page( 'patchstack-multisite', 'Activate', 'Activate', 'manage_options', 'patchstack-multisite-settings', [ $this, 'render_settings_page' ] );
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' ] );
64 61 }
65 62
66 63 /**
67 64 * Render the settings page.
@@ -82,10 +79,19 @@
82 79
83 80 // Load the Patchstack style on all Patchstack pages except site overview.
84 81 if ( isset( $screen->base, $_GET['page'] ) && stripos( $screen->base, 'patchstack' ) !== false && $_GET['page'] != 'patchstack-multisite' ) {
85 82 wp_enqueue_style( 'patchstack', $this->plugin->url . 'assets/css/patchstack.min.css', [], $this->plugin->version );
86 - wp_enqueue_style( 'patchstack-hint', 'https://cdnjs.cloudflare.com/ajax/libs/hint.css/3.0.0/hint.min.css', [], $this->plugin->version );
87 83 }
84 +
85 + // Only load the selectize CSS file on the firewall settings page.
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 + }
89 +
90 + // Only load the dataTables CSS fileon the logs page.
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', [ ], $this->plugin->version );
93 + }
88 94 }
89 95
90 96 /**
91 97 * Register the JavaScript for the admin area.
@@ -102,12 +108,28 @@
102 108 'PatchstackVars',
103 109 [
104 110 'ajaxurl' => admin_url( 'admin-ajax.php' ),
105 111 'nonce' => wp_create_nonce( 'patchstack-nonce' ),
106 - 'error_message' => esc_attr__( 'Sorry, there was a problem processing your request.', 'patchstack' ),
112 + 'error_message' => __( 'Sorry, there was a problem processing your request.', 'patchstack' ),
107 113 ]
108 114 );
109 115 }
116 +
117 + // Only load the colorpicker on the cookie notice settings page.
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', [ ], $this->plugin->version );
120 + }
121 +
122 + // Only load the selectize library on the firewall settings page.
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 + }
126 +
127 + // Only load the dataTables related libraries on the logs page.
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', [ 'jquery' ], $this->plugin->version );
130 + wp_enqueue_script( 'patchstack-logs', $this->plugin->url . 'assets/js/jquery.dataTables.min.js', [ ], $this->plugin->version );
131 + }
110 132 }
111 133
112 134 /**
113 135 * Add the "Settings" hyperlink to the Patchstack section on the plugins page of WordPress.
@@ -115,7 +137,7 @@
115 137 * @param array $links
116 138 * @return array
117 139 */
118 140 public function admin_settings( $links ) {
119 - return array_merge( [ '<a href="admin.php?page=patchstack&tab=license">' . esc_attr__( 'Settings', 'patchstack' ) . '</a>' ], $links );
141 + return array_merge( [ '<a href="admin.php?page=patchstack&tab=license">' . __( 'Settings', 'patchstack' ) . '</a>' ], $links );
120 142 }
121 143 }