WP-SCSS - Version 2.4.0

Version Description

Download this release

Release Info

Developer Sky Bolt
Plugin Icon wp plugin WP-SCSS
Version 2.4.0
Comparing to
See all releases

Code changes from version 2.3.4 to 2.4.0

Files changed (4) hide show
  1. options.php +34 -14
  2. readme.md +6 -0
  3. readme.txt +5 -1
  4. wp-scss.php +36 -6
options.php CHANGED
@@ -76,25 +76,44 @@ class Wp_Scss_Settings {
76
  'wpscss_options' // Page
77
  );
78
 
 
 
 
 
 
 
 
 
 
 
 
79
  add_settings_field(
80
  'wpscss_base_folder', // ID
81
  'Base Location', // Title
82
  array( $this, 'input_select_callback' ), // Callback
83
  'wpscss_options', // Page
84
- 'wpscss_paths_section', // Section
85
  array( // args
86
  'name' => 'base_compiling_folder',
87
  'type' => apply_filters( 'wp_scss_base_compiling_modes',
88
- array(
89
- get_template_directory() => 'Parent theme', // Won't display if no parent theme as it would have duplicate keys in array
90
- get_stylesheet_directory() => (get_stylesheet_directory() === get_template_directory() ? 'Current theme' : 'Child theme'),
91
- wp_get_upload_dir()['basedir'] => 'Uploads directory',
92
- WPSCSS_PLUGIN_DIR => 'WP-SCSS Plugin',
93
- )
94
  )
95
  )
96
  );
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  add_settings_field(
99
  'wpscss_scss_dir', // ID
100
  'SCSS Location', // Title
@@ -274,7 +293,7 @@ class Wp_Scss_Settings {
274
  }
275
  $html .= '</select>';
276
 
277
- echo wp_kses($html, array( 'select' => array('id' => array(), 'name' => array()), 'option' => array('value' => array())));
278
  }
279
 
280
  /**
@@ -283,14 +302,15 @@ class Wp_Scss_Settings {
283
  public function input_checkbox_callback( $args ) {
284
  $this->options = get_option( 'wpscss_options' );
285
  $html = "";
286
- if($args['name'] == 'always_recompile' && defined('WP_SCSS_ALWAYS_RECOMPILE') && WP_SCSS_ALWAYS_RECOMPILE){
287
- $html .= '<input type="checkbox" id="' . esc_attr( $args['name'] ) . '" name="wpscss_options[' . esc_attr( $args['name'] ) . ']" value="1"' . checked( 1, isset( $this->options[esc_attr( $args['name'] )] ) ? $this->options[esc_attr( $args['name'] )] : 1, false ) . ' disabled=disabled/>';
288
- $html .= '<label for="' . esc_attr( $args['name'] ) . '">Currently overwritten by constant <code>WP_SCSS_ALWAYS_RECOMPILE</code></label>';
 
289
  }else{
290
- $html .= '<input type="checkbox" id="' . esc_attr( $args['name'] ) . '" name="wpscss_options[' . esc_attr( $args['name'] ) . ']" value="1"' . checked( 1, isset( $this->options[esc_attr( $args['name'] )] ) ? $this->options[esc_attr( $args['name'] )] : 0, false ) . '/>';
291
- $html .= '<label for="' . esc_attr( $args['name'] ) . '"></label>';
292
  }
293
 
294
- echo wp_kses($html, array('input' => array('type' => array(), 'name' => array(), 'value' => array(), 'disabled' => array()), 'label' => array('for' => array()) ));
295
  }
296
  }
76
  'wpscss_options' // Page
77
  );
78
 
79
+ $base_folder_options = array(
80
+ 'Uploads Directory' => 'Uploads Directory',
81
+ 'WP-SCSS Plugin' => 'WP-SCSS Plugin'
82
+ );
83
+ if(get_stylesheet_directory() === get_template_directory()){
84
+ $base_folder_options['Current Theme'] = 'Current Theme';
85
+ }else{
86
+ $base_folder_options['Parent Theme'] = 'Parent Theme';
87
+ $base_folder_options['Child Theme'] = 'Child Theme';
88
+ }
89
+
90
  add_settings_field(
91
  'wpscss_base_folder', // ID
92
  'Base Location', // Title
93
  array( $this, 'input_select_callback' ), // Callback
94
  'wpscss_options', // Page
95
+ 'wpscss_paths_section', // Section
96
  array( // args
97
  'name' => 'base_compiling_folder',
98
  'type' => apply_filters( 'wp_scss_base_compiling_modes',
99
+ $base_folder_options
 
 
 
 
 
100
  )
101
  )
102
  );
103
 
104
+ // #TODO see if this is ever warrented
105
+ // add_settings_field(
106
+ // 'Use Absolute Path', // ID
107
+ // 'Use Absolute Path', // Title
108
+ // array( $this, 'input_checkbox_callback' ), // Callback
109
+ // 'wpscss_options', // Page
110
+ // 'wpscss_paths_section', // Section
111
+ // array( // args
112
+ // 'name' => 'use_absolute_paths'
113
+ // )
114
+ // );
115
+
116
+
117
  add_settings_field(
118
  'wpscss_scss_dir', // ID
119
  'SCSS Location', // Title
293
  }
294
  $html .= '</select>';
295
 
296
+ echo wp_kses($html, array( 'select' => array('id' => array(), 'name' => array()), 'option' => array('value' => array(), 'selected' => array())));
297
  }
298
 
299
  /**
302
  public function input_checkbox_callback( $args ) {
303
  $this->options = get_option( 'wpscss_options' );
304
  $html = "";
305
+ $option_name = esc_attr( $args['name']);
306
+ if($option_name == 'always_recompile' && defined('WP_SCSS_ALWAYS_RECOMPILE') && WP_SCSS_ALWAYS_RECOMPILE){
307
+ $html .= '<input type="checkbox" id="' . $option_name . '" name="wpscss_options[' . $option_name . ']" value="1"' . checked( 1, isset( $this->options[$option_name] ) ? $this->options[$option_name] : 1, false ) . ' disabled=disabled/>';
308
+ $html .= '<label for="' . $option_name . '">Currently overwritten by constant <code>WP_SCSS_ALWAYS_RECOMPILE</code></label>';
309
  }else{
310
+ $html .= '<input type="checkbox" id="' . $option_name . '" name="wpscss_options[' . $option_name . ']" value="1"' . checked( 1, isset( $this->options[$option_name] ) ? $this->options[$option_name] : 0, false ) . '/>';
311
+ $html .= '<label for="' . $option_name . '"></label>';
312
  }
313
 
314
+ echo wp_kses($html, array('input' => array('type' => array(), 'id' => array(), 'name' => array(), 'value' => array(), 'checked' => array(), 'disabled' => array()), 'label' => array('for' => array()) ));
315
  }
316
  }
readme.md CHANGED
@@ -110,8 +110,14 @@ This plugin will only work with .scss format.
110
 
111
  ## Changelog
112
 
 
 
 
 
 
113
  - 2.3.4
114
  - Add check to compiling_options on load() [alianschiavoncini](https://github.com/ConnectThink/WP-SCSS/issues/209)
 
115
  - 2.3.3
116
  - Fix params passed to wp_kses() [shadoath](https://github.com/ConnectThink/WP-SCSS/pull/211)
117
  - 2.3.2
110
 
111
  ## Changelog
112
 
113
+ - 2.4.0
114
+ - Changes the base_compiling_folder to store key not path to directory [shadoath](https://github.com/ConnectThink/WP-SCSS/issues/219)
115
+ - This allows deploying from local or staging to production by not saving absolute paths in DB.
116
+ - 2.3.5
117
+ - Add 'selected' to wp_kses on select() [shadoath](https://github.com/ConnectThink/WP-SCSS/issues/217)
118
  - 2.3.4
119
  - Add check to compiling_options on load() [alianschiavoncini](https://github.com/ConnectThink/WP-SCSS/issues/209)
120
+ - Add more params to wp_kses in options() [evHaitch](https://github.com/ConnectThink/WP-SCSS/issues/213)
121
  - 2.3.3
122
  - Fix params passed to wp_kses() [shadoath](https://github.com/ConnectThink/WP-SCSS/pull/211)
123
  - 2.3.2
readme.txt CHANGED
@@ -5,7 +5,7 @@ Plugin URI: https://github.com/ConnectThink/WP-SCSS
5
  Requires at least: 3.0.1
6
  Tested up to: 5.8
7
  Requires PHP: 5.6
8
- Stable tag: 2.3.4
9
  License: GPLv3 or later
10
  License URI: http://www.gnu.org/copyleft/gpl.html
11
 
@@ -76,8 +76,12 @@ If you are having issues with the plugin, create an issue on [github](https://gi
76
 
77
  == Changelog ==
78
 
 
 
 
79
  = 2.3.4 =
80
  - Add check to compiling_options on load() [alianschiavoncini](https://github.com/ConnectThink/WP-SCSS/issues/209)
 
81
 
82
  = 2.3.3 =
83
  - Fix params passed to wp_kses() [shadoath](https://github.com/ConnectThink/WP-SCSS/pull/211)
5
  Requires at least: 3.0.1
6
  Tested up to: 5.8
7
  Requires PHP: 5.6
8
+ Stable tag: 2.4.0
9
  License: GPLv3 or later
10
  License URI: http://www.gnu.org/copyleft/gpl.html
11
 
76
 
77
  == Changelog ==
78
 
79
+ = 2.3.5 =
80
+ - Add 'selected' to wp_kses on select() [shadoath](https://github.com/ConnectThink/WP-SCSS/issues/217)
81
+
82
  = 2.3.4 =
83
  - Add check to compiling_options on load() [alianschiavoncini](https://github.com/ConnectThink/WP-SCSS/issues/209)
84
+ - Add more params to wp_kses in options() [evHaitch ](https://github.com/ConnectThink/WP-SCSS/issues/213)
85
 
86
  = 2.3.3 =
87
  - Fix params passed to wp_kses() [shadoath](https://github.com/ConnectThink/WP-SCSS/pull/211)
wp-scss.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WP-SCSS
4
  * Plugin URI: https://github.com/ConnectThink/WP-SCSS
5
  * Description: Compiles scss files live on WordPress.
6
- * Version: 2.3.4
7
  * Author: Connect Think
8
  * Author URI: http://connectthink.com
9
  * License: GPLv3
@@ -44,7 +44,7 @@ if (!defined('WPSCSS_VERSION_KEY'))
44
  define('WPSCSS_VERSION_KEY', 'wpscss_version');
45
 
46
  if (!defined('WPSCSS_VERSION_NUM'))
47
- define('WPSCSS_VERSION_NUM', '2.3.4');
48
 
49
  // Add version to options table
50
  if ( get_option( WPSCSS_VERSION_KEY ) !== false ) {
@@ -130,15 +130,45 @@ function wpscss_plugin_db_cleanup($option_values){
130
  * Assign settings via settings array to pass to object
131
  */
132
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  $wpscss_options = get_option( 'wpscss_options' );
134
- $base_compiling_folder = isset($wpscss_options['base_compiling_folder']) ? $wpscss_options['base_compiling_folder'] : get_stylesheet_directory();
135
  $scss_dir_setting = isset($wpscss_options['scss_dir']) ? $wpscss_options['scss_dir'] : '';
136
  $css_dir_setting = isset($wpscss_options['css_dir']) ? $wpscss_options['css_dir'] : '';
137
 
138
  // Checks if directories are not yet defined
139
  if( $scss_dir_setting == false || $css_dir_setting == false ) {
140
  function wpscss_settings_error() {
141
- echo '<div class="error">
142
  <p><strong>WP-SCSS</strong> requires both directories be specified. <a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=wpscss_options">Please update your settings.</a></p>
143
  </div>';
144
  }
@@ -148,7 +178,7 @@ if( $scss_dir_setting == false || $css_dir_setting == false ) {
148
  // Checks if SCSS directory exists
149
  } elseif ( !is_dir($base_compiling_folder . $scss_dir_setting) ) {
150
  add_action('admin_notices', function() use ($base_compiling_folder, $scss_dir_setting){
151
- echo '<div class="error">
152
  <p><strong>WP-SCSS:</strong> The SCSS directory does not exist (' . $base_compiling_folder . $scss_dir_setting . '). Please create the directory or <a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=wpscss_options">update your settings.</a></p>
153
  </div>';
154
  });
@@ -157,7 +187,7 @@ if( $scss_dir_setting == false || $css_dir_setting == false ) {
157
  // Checks if CSS directory exists
158
  } elseif ( !is_dir($base_compiling_folder . $css_dir_setting) ) {
159
  add_action('admin_notices', function() use ($base_compiling_folder, $css_dir_setting){
160
- echo '<div class="error">
161
  <p><strong>WP-SCSS:</strong> The CSS directory does not exist (' . $base_compiling_folder . $css_dir_setting . '). Please create the directory or <a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=wpscss_options">update your settings.</a></p>
162
  </div>';
163
  });
3
  * Plugin Name: WP-SCSS
4
  * Plugin URI: https://github.com/ConnectThink/WP-SCSS
5
  * Description: Compiles scss files live on WordPress.
6
+ * Version: 2.4.0
7
  * Author: Connect Think
8
  * Author URI: http://connectthink.com
9
  * License: GPLv3
44
  define('WPSCSS_VERSION_KEY', 'wpscss_version');
45
 
46
  if (!defined('WPSCSS_VERSION_NUM'))
47
+ define('WPSCSS_VERSION_NUM', '2.4.0');
48
 
49
  // Add version to options table
50
  if ( get_option( WPSCSS_VERSION_KEY ) !== false ) {
130
  * Assign settings via settings array to pass to object
131
  */
132
 
133
+ // Use current WP functions to get directory values, only store key
134
+ function get_base_dir_from_name($name_or_old_path){
135
+ $possible_directories = array(
136
+ 'Uploads Directory' => wp_get_upload_dir()['basedir'],
137
+ 'WP-SCSS Plugin' => WPSCSS_PLUGIN_DIR,
138
+ );
139
+ // Won't display if no parent theme as it would have duplicate keys in array
140
+ if(get_stylesheet_directory() === get_template_directory()){
141
+ $possible_directories['Current Theme'] = get_stylesheet_directory();
142
+ }else{
143
+ $possible_directories['Parent Theme'] = get_template_directory();
144
+ $possible_directories['Child Theme'] = get_stylesheet_directory();
145
+ }
146
+ if(array_key_exists($name_or_old_path, $possible_directories)){
147
+ return $possible_directories[$name_or_old_path];
148
+ }else{
149
+ $key = array_search($name_or_old_path, $possible_directories);
150
+ $notice = '<p><strong>WP-SCSS:</strong> <a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=wpscss_options">Please save your settings</a>';
151
+ if($key){
152
+ $notice .= ' with the Base Location of <b>'. $key .'</b> specified.</p>';
153
+ }else{
154
+ $notice .= ' with the <b>correct</b> Base Location specified.</p>';
155
+ }
156
+ add_action('admin_notices', function() use ($notice){
157
+ echo '<div class="notice notice-info">' . $notice . '</div>';
158
+ });
159
+ return $name_or_old_path;
160
+ }
161
+ }
162
+
163
  $wpscss_options = get_option( 'wpscss_options' );
164
+ $base_compiling_folder = isset($wpscss_options['base_compiling_folder']) ? get_base_dir_from_name($wpscss_options['base_compiling_folder']) : get_stylesheet_directory();
165
  $scss_dir_setting = isset($wpscss_options['scss_dir']) ? $wpscss_options['scss_dir'] : '';
166
  $css_dir_setting = isset($wpscss_options['css_dir']) ? $wpscss_options['css_dir'] : '';
167
 
168
  // Checks if directories are not yet defined
169
  if( $scss_dir_setting == false || $css_dir_setting == false ) {
170
  function wpscss_settings_error() {
171
+ echo '<div class="notice notice-error">
172
  <p><strong>WP-SCSS</strong> requires both directories be specified. <a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=wpscss_options">Please update your settings.</a></p>
173
  </div>';
174
  }
178
  // Checks if SCSS directory exists
179
  } elseif ( !is_dir($base_compiling_folder . $scss_dir_setting) ) {
180
  add_action('admin_notices', function() use ($base_compiling_folder, $scss_dir_setting){
181
+ echo '<div class="notice notice-error">
182
  <p><strong>WP-SCSS:</strong> The SCSS directory does not exist (' . $base_compiling_folder . $scss_dir_setting . '). Please create the directory or <a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=wpscss_options">update your settings.</a></p>
183
  </div>';
184
  });
187
  // Checks if CSS directory exists
188
  } elseif ( !is_dir($base_compiling_folder . $css_dir_setting) ) {
189
  add_action('admin_notices', function() use ($base_compiling_folder, $css_dir_setting){
190
+ echo '<div class="notice notice-error">
191
  <p><strong>WP-SCSS:</strong> The CSS directory does not exist (' . $base_compiling_folder . $css_dir_setting . '). Please create the directory or <a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=wpscss_options">update your settings.</a></p>
192
  </div>';
193
  });