3
3
/**
4
4
* The admin-specific functionality of the plugin.
5
5
*
6
- * Defines the plugin name, version, other methods and
7
- * enqueue the admin-specific stylesheet and JavaScript.
6
+ * Defines the plugin name, version and other methods.
8
7
*
9
8
* @package Sass_To_Css_Compiler
10
9
* @subpackage Sass_To_Css_Compiler/admin
@@ -51,7 +50,8 @@ class Sass_To_Css_Compiler_Admin
51
50
/**
52
51
* Initialize the class and set its properties.
53
52
*
54
- * @since 2.0.0
53
+ * @since 2.0.0
54
+ * @access public
55
55
* @param string $plugin_name The name of this plugin.
56
56
* @param string $version The version of this plugin.
57
57
*/
@@ -69,7 +69,8 @@ public function __construct( $plugin_name, $version )
69
69
/**
70
70
* Register the stylesheets for the admin area.
71
71
*
72
- * @since 2.0.0
72
+ * @since 2.0.0
73
+ * @access public
73
74
*/
74
75
public function enqueue_styles ()
75
76
{
@@ -85,7 +86,8 @@ public function enqueue_styles()
85
86
/**
86
87
* Register the JavaScript for the admin area.
87
88
*
88
- * @since 2.0.0
89
+ * @since 2.0.0
90
+ * @access public
89
91
*/
90
92
public function enqueue_scripts ()
91
93
{
@@ -105,8 +107,8 @@ public function enqueue_scripts()
105
107
/**
106
108
* Adds a settings link to the plugin's action links on the plugin list table.
107
109
*
108
- * @since 2.0.0
109
- *
110
+ * @since 2.0.0
111
+ * @access public
110
112
* @param array $links The existing array of plugin action links.
111
113
* @return array The updated array of plugin action links, including the settings link.
112
114
*/
@@ -120,7 +122,8 @@ public function add_plugin_action_links( $links )
120
122
/**
121
123
* Adds the plugin settings page to the WordPress dashboard menu.
122
124
*
123
- * @since 2.0.0
125
+ * @since 2.0.0
126
+ * @access public
124
127
*/
125
128
public function admin_menu ()
126
129
{
@@ -137,7 +140,8 @@ public function admin_menu()
137
140
/**
138
141
* Renders the plugin settings page form.
139
142
*
140
- * @since 2.0.0
143
+ * @since 2.0.0
144
+ * @access public
141
145
*/
142
146
public function menu_page ()
143
147
{
@@ -147,7 +151,8 @@ public function menu_page()
147
151
/**
148
152
* Register Plugin Options Via Settings API
149
153
*
150
- * @since 2.0.0
154
+ * @since 2.0.0
155
+ * @access public
151
156
*/
152
157
public function admin_init ()
153
158
{
@@ -163,9 +168,9 @@ public function admin_init()
163
168
/**
164
169
* Returns the settings sections for the plugin settings page.
165
170
*
166
- * @since 2.0.0
167
- *
168
- * @return array An array of settings sections, where each section is an array
171
+ * @since 2.0.0
172
+ * @access public
173
+ * @return array An array of settings sections, where each section is an array
169
174
* with 'id' and 'title' keys.
170
175
*/
171
176
public function get_settings_sections ()
@@ -183,9 +188,9 @@ public function get_settings_sections()
183
188
/**
184
189
* Returns all the settings fields for the plugin settings page.
185
190
*
186
- * @since 2.0.0
187
- *
188
- * @return array An array of settings fields, organized by section ID. Each
191
+ * @since 2.0.0
192
+ * @access public
193
+ * @return array An array of settings fields, organized by section ID. Each
189
194
* section ID is a key in the array, and the value is an array
190
195
* of settings fields for that section. Each settings field is
191
196
* an array with 'name', 'label', 'type', 'desc', and other keys
@@ -217,24 +222,9 @@ public function get_settings_fields()
217
222
'type ' => 'checkbox ' ,
218
223
'desc ' => __ ( 'Checking this box will enable compiling .scss files from themes & plugins folders ' , 'sass-to-css-compiler ' )
219
224
),
220
- array (
221
- 'name ' => 'skip_external ' ,
222
- 'label ' => __ ( 'Ignore External Files ' , 'sass-to-css-compiler ' ),
223
- 'type ' => 'checkbox ' ,
224
- 'always_checked ' => 'on ' ,
225
- 'disabled ' => 'disabled ' ,
226
- 'desc ' => __ ( 'Always Ignore .scss files from CDNs, other domains (external files) and relative paths (built in files) ' , 'sass-to-css-compiler ' )
227
- ),
228
- array (
229
- 'name ' => 'exclude ' ,
230
- 'label ' => __ ( 'Exclude Files From Compiling ' , 'sass-to-css-compiler ' ),
231
- 'type ' => 'text ' ,
232
- 'desc ' => __ ( 'Add comma separated scss files name to exclude it from Compiling ' , 'sass-to-css-compiler ' ),
233
- 'placeholder ' => __ ( 'admin.scss, plugins.scss, backend.scss ' , 'sass-to-css-compiler ' )
234
- ),
235
225
array (
236
226
'name ' => 'include ' ,
237
- 'label ' => __ ( 'Include Files From Compiling ' , 'sass-to-css-compiler ' ),
227
+ 'label ' => __ ( 'Files To Compile ' , 'sass-to-css-compiler ' ),
238
228
'type ' => 'text ' ,
239
229
'desc ' => __ ( 'Add comma separated scss files name to include it while Compiling... Note if added any! only those files will be compiled ' , 'sass-to-css-compiler ' ),
240
230
'placeholder ' => __ ( 'menu.scss, footer.scss ' , 'sass-to-css-compiler ' )
@@ -262,7 +252,8 @@ public function get_settings_fields()
262
252
/**
263
253
* Show plugin notices in the admin area.
264
254
*
265
- * @since 2.0.0
255
+ * @since 2.0.0
256
+ * @access public
266
257
*/
267
258
public function admin_notices ()
268
259
{
@@ -298,23 +289,25 @@ public function admin_notices()
298
289
/**
299
290
* Add a admin node menu item for clearing the cache
300
291
*
301
- * @since 2.0.0
292
+ * @since 2.0.0
293
+ * @access public
302
294
* @param array $wp_admin_bar class WP_Admin_Bar object.
303
295
*/
304
296
public function admin_bar_menu ( $ wp_admin_bar )
305
297
{
298
+ // check if current page is plugin settings page
306
299
// check if the user is logged in as well as admin bar is not disabled
307
- if ( current_user_can ( 'manage_options ' ) && is_admin_bar_showing () )
300
+ if ( function_exists ( ' get_current_screen ' ) && current_user_can ( 'manage_options ' ) && is_admin_bar_showing () && get_current_screen ()-> id == ' toplevel_page_sass-to-css-compiler ' )
308
301
{
309
- $ link = admin_url ( 'admin.php?page=sass-to-css-compiler ' );
302
+ $ link = admin_url ( 'admin.php?page=sass-to-css-compiler ' );
310
303
311
304
// Generate a nonce
312
- $ nonce = wp_create_nonce ( 'sass_to_css_compiler_action ' );
305
+ $ nonce = wp_create_nonce ( 'sass_to_css_compiler_action ' );
313
306
314
307
// Add the nonce to the URL
315
- $ link = add_query_arg ( array ( '_wpnonce ' => $ nonce , 'action ' => 'purge_sass_to_css_compiled_files ' ), $ link );
308
+ $ link = add_query_arg ( array ( '_wpnonce ' => $ nonce , 'action ' => 'purge_sass_to_css_compiled_files ' ), $ link );
316
309
317
- $ args = array (
310
+ $ args = array (
318
311
'id ' => 'sass-to-css-compiler-purge-cache ' ,
319
312
'title ' => sprintf ( '<a href="%s">%s</a> ' , esc_url ( $ link ), __ ( 'Purge Compiled SASS Cache ' , 'sass-to-css-compiler ' ) )
320
313
);
0 commit comments