Simple Custom CSS and JS - Version 3.15

Version Description

  • 03/27/2018
  • Change: check the option name against an array of allowed values
Download this release

Release Info

Developer diana_burduja
Plugin Icon 128x128 Simple Custom CSS and JS
Version 3.15
Comparing to
See all releases

Code changes from version 3.14 to 3.15

custom-css-js.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Simple Custom CSS and JS
4
  * Plugin URI: https://wordpress.org/plugins/custom-css-js/
5
  * Description: Easily add Custom CSS or JS to your website with an awesome editor.
6
- * Version: 3.14
7
  * Author: Diana Burduja
8
  * Author URI: https://www.silkypress.com/
9
  * License: GPL2
@@ -199,7 +199,7 @@ final class CustomCSSandJS {
199
  function set_constants() {
200
  $dir = wp_upload_dir();
201
  $constants = array(
202
- 'CCJ_VERSION' => '3.14',
203
  'CCJ_UPLOAD_DIR' => $dir['basedir'] . '/custom-css-js',
204
  'CCJ_UPLOAD_URL' => $dir['baseurl'] . '/custom-css-js',
205
  'CCJ_PLUGIN_FILE' => __FILE__,
3
  * Plugin Name: Simple Custom CSS and JS
4
  * Plugin URI: https://wordpress.org/plugins/custom-css-js/
5
  * Description: Easily add Custom CSS or JS to your website with an awesome editor.
6
+ * Version: 3.15
7
  * Author: Diana Burduja
8
  * Author URI: https://www.silkypress.com/
9
  * License: GPL2
199
  function set_constants() {
200
  $dir = wp_upload_dir();
201
  $constants = array(
202
+ 'CCJ_VERSION' => '3.15',
203
  'CCJ_UPLOAD_DIR' => $dir['basedir'] . '/custom-css-js',
204
  'CCJ_UPLOAD_URL' => $dir['baseurl'] . '/custom-css-js',
205
  'CCJ_PLUGIN_FILE' => __FILE__,
includes/admin-notices.php CHANGED
@@ -172,10 +172,10 @@ class CustomCSSandJS_Notices {
172
  <script type='text/javascript'>
173
  jQuery(function($){
174
  $(document).on( 'click', '.<?php echo $p; ?>_notice .dismiss_notice', function() {
175
-
176
  var data = {
177
  action: '<?php echo $p; ?>_notice_dismiss',
178
- option: '<?php echo $option_name; ?>'
 
179
  };
180
  $.post(ajaxurl, data, function(response ) {
181
  $('#<?php echo $p; ?>_notice').fadeOut('slow');
@@ -184,7 +184,7 @@ class CustomCSSandJS_Notices {
184
  });
185
  </script>
186
 
187
- <div id="<?php echo $p; ?>_notice" class="updated notice <?php echo $p; ?>_notice is-dismissible">
188
  <p><?php echo $message ?></p>
189
  <button type="button" class="notice-dismiss">
190
  <span class="screen-reader-text"><?php _e('Dismiss this notice'); ?></span>
@@ -211,6 +211,8 @@ class CustomCSSandJS_Notices {
211
  function notice_dismiss() {
212
  $p = $this->prefix;
213
 
 
 
214
  update_option( $p.'_dismiss_notice', 1 );
215
 
216
  wp_die();
172
  <script type='text/javascript'>
173
  jQuery(function($){
174
  $(document).on( 'click', '.<?php echo $p; ?>_notice .dismiss_notice', function() {
 
175
  var data = {
176
  action: '<?php echo $p; ?>_notice_dismiss',
177
+ option: '<?php echo $option_name; ?>',
178
+ nonce: $(this).parent().parent().data('nonce'),
179
  };
180
  $.post(ajaxurl, data, function(response ) {
181
  $('#<?php echo $p; ?>_notice').fadeOut('slow');
184
  });
185
  </script>
186
 
187
+ <div id="<?php echo $p; ?>_notice" class="updated notice <?php echo $p; ?>_notice is-dismissible" data-nonce="<?php echo wp_create_nonce( $this->prefix .'_notice'); ?>">
188
  <p><?php echo $message ?></p>
189
  <button type="button" class="notice-dismiss">
190
  <span class="screen-reader-text"><?php _e('Dismiss this notice'); ?></span>
211
  function notice_dismiss() {
212
  $p = $this->prefix;
213
 
214
+ check_ajax_referer( $p . '_notice', 'nonce' );
215
+
216
  update_option( $p.'_dismiss_notice', 1 );
217
 
218
  wp_die();
includes/admin-warnings.php CHANGED
@@ -13,6 +13,10 @@ if ( ! defined( 'ABSPATH' ) ) {
13
  */
14
  class CustomCSSandJS_Warnings {
15
 
 
 
 
 
16
  /**
17
  * Constructor
18
  */
@@ -40,7 +44,6 @@ class CustomCSSandJS_Warnings {
40
  $qtranslate_post_type_excluded = get_option('qtranslate_post_type_excluded');
41
 
42
  if ( ! is_array( $qtranslate_post_type_excluded ) || array_search( 'custom-css-js', $qtranslate_post_type_excluded ) === false ) {
43
- var_dump( $qtranslate_post_type_excluded );
44
  add_action( 'admin_notices', array( $this, 'check_qtranslate_notice' ) );
45
  return;
46
  }
@@ -53,8 +56,9 @@ class CustomCSSandJS_Warnings {
53
  $id = 'ccj_dismiss_qtranslate';
54
  $class = 'notice notice-warning is-dismissible';
55
  $message = sprintf(__( 'Please remove the <b>custom-css-js</b> post type from the <b>qTranslate settings</b> in order to avoid some malfunctions in the Simple Custom CSS & JS plugin. Check out <a href="%s" target="_blank">this screenshot</a> for more details on how to do that.', 'custom-css-js'), 'https://www.silkypress.com/wp-content/uploads/2016/08/ccj_qtranslate_compatibility.png' );
 
56
 
57
- printf( '<div class="%1$s" id="%2$s"><p>%3$s</p></div>', $class, $id, $message );
58
 
59
  $this->dismiss_js( $id );
60
 
@@ -71,6 +75,7 @@ class CustomCSSandJS_Warnings {
71
  var data = {
72
  action: 'ccj_dismiss',
73
  option: '<?php echo $slug; ?>',
 
74
  };
75
  $.post(ajaxurl, data, function(response ) {
76
  $('#<?php echo $slug; ?>').fadeOut('slow');
@@ -89,6 +94,12 @@ class CustomCSSandJS_Warnings {
89
 
90
  $option = $_POST['option'];
91
 
 
 
 
 
 
 
92
  update_option( $option, 1 );
93
 
94
  wp_die();
13
  */
14
  class CustomCSSandJS_Warnings {
15
 
16
+ private $allowed_actions = array(
17
+ 'ccj_dismiss_qtranslate',
18
+ );
19
+
20
  /**
21
  * Constructor
22
  */
44
  $qtranslate_post_type_excluded = get_option('qtranslate_post_type_excluded');
45
 
46
  if ( ! is_array( $qtranslate_post_type_excluded ) || array_search( 'custom-css-js', $qtranslate_post_type_excluded ) === false ) {
 
47
  add_action( 'admin_notices', array( $this, 'check_qtranslate_notice' ) );
48
  return;
49
  }
56
  $id = 'ccj_dismiss_qtranslate';
57
  $class = 'notice notice-warning is-dismissible';
58
  $message = sprintf(__( 'Please remove the <b>custom-css-js</b> post type from the <b>qTranslate settings</b> in order to avoid some malfunctions in the Simple Custom CSS & JS plugin. Check out <a href="%s" target="_blank">this screenshot</a> for more details on how to do that.', 'custom-css-js'), 'https://www.silkypress.com/wp-content/uploads/2016/08/ccj_qtranslate_compatibility.png' );
59
+ $nonce = wp_create_nonce( $id );
60
 
61
+ printf( '<div class="%1$s" id="%2$s" data-nonce="%3$s"><p>%4$s</p></div>', $class, $id, $nonce, $message );
62
 
63
  $this->dismiss_js( $id );
64
 
75
  var data = {
76
  action: 'ccj_dismiss',
77
  option: '<?php echo $slug; ?>',
78
+ nonce: $(this).parent().data('nonce'),
79
  };
80
  $.post(ajaxurl, data, function(response ) {
81
  $('#<?php echo $slug; ?>').fadeOut('slow');
94
 
95
  $option = $_POST['option'];
96
 
97
+ if ( ! in_array($option, $this->allowed_actions ) ) {
98
+ return;
99
+ }
100
+
101
+ check_ajax_referer( $option, 'nonce' );
102
+
103
  update_option( $option, 1 );
104
 
105
  wp_die();
readme.txt CHANGED
@@ -5,7 +5,7 @@ Email: diana@burduja.eu
5
  Tags: CSS, JS, javascript, custom CSS, custom JS, custom style, site css, add style, customize theme, custom code, external css, css3, style, styles, stylesheet, theme, editor, design, admin
6
  Requires at least: 3.0.1
7
  Tested up to: 4.9
8
- Stable tag: 3.14
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
11
 
@@ -114,6 +114,10 @@ $. Add/Edit HTML
114
 
115
  == Changelog ==
116
 
 
 
 
 
117
  = 3.14 =
118
  * 02/04/2018
119
  * Feature: permalink slug for custom codes
5
  Tags: CSS, JS, javascript, custom CSS, custom JS, custom style, site css, add style, customize theme, custom code, external css, css3, style, styles, stylesheet, theme, editor, design, admin
6
  Requires at least: 3.0.1
7
  Tested up to: 4.9
8
+ Stable tag: 3.15
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
11
 
114
 
115
  == Changelog ==
116
 
117
+ = 3.15 =
118
+ * 03/27/2018
119
+ * Change: check the option name against an array of allowed values
120
+
121
  = 3.14 =
122
  * 02/04/2018
123
  * Feature: permalink slug for custom codes