Simple Custom CSS and JS - Version 3.18

Version Description

  • 07/13/2018
  • Fix: the default comment for JS for other locales than "en_" was removing the tags
  • Tweak: make the search dialog persistent
  • Tweak: correct the tooltip info for the 'ccs_js_designer' option
Download this release

Release Info

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

Code changes from version 3.17 to 3.18

assets/ccj_admin.js CHANGED
@@ -15,7 +15,10 @@ jQuery(document).ready( function($) {
15
  var options = {
16
  lineNumbers: true,
17
  mode: content_mode,
18
- matchBrackets: true
 
 
 
19
  };
20
  if ( typeof CCJ !== 'undefined' && CCJ.scroll !== '0' ) {
21
  options['scrollbarStyle'] = "simple";
15
  var options = {
16
  lineNumbers: true,
17
  mode: content_mode,
18
+ matchBrackets: true,
19
+ extraKeys: {
20
+ "Ctrl-F": "findPersistent",
21
+ },
22
  };
23
  if ( typeof CCJ !== 'undefined' && CCJ.scroll !== '0' ) {
24
  options['scrollbarStyle'] = "simple";
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.17
7
  * Author: SilkyPress.com
8
  * Author URI: https://www.silkypress.com
9
  * License: GPL2
@@ -50,14 +50,14 @@ final class CustomCSSandJS {
50
  * Cloning is forbidden.
51
  */
52
  public function __clone() {
53
- _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'custom-css-js' ), '1.0' );
54
  }
55
 
56
  /**
57
  * Unserializing instances of this class is forbidden.
58
  */
59
  public function __wakeup() {
60
- _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'custom-css-js' ), '1.0' );
61
  }
62
 
63
  /**
@@ -202,7 +202,7 @@ final class CustomCSSandJS {
202
  function set_constants() {
203
  $dir = wp_upload_dir();
204
  $constants = array(
205
- 'CCJ_VERSION' => '3.17',
206
  'CCJ_UPLOAD_DIR' => $dir['basedir'] . '/custom-css-js',
207
  'CCJ_UPLOAD_URL' => $dir['baseurl'] . '/custom-css-js',
208
  '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.18
7
  * Author: SilkyPress.com
8
  * Author URI: https://www.silkypress.com
9
  * License: GPL2
50
  * Cloning is forbidden.
51
  */
52
  public function __clone() {
53
+ _doing_it_wrong( __FUNCTION__, __( 'An error has occurred. Please reload the page and try again.' ), '1.0' );
54
  }
55
 
56
  /**
57
  * Unserializing instances of this class is forbidden.
58
  */
59
  public function __wakeup() {
60
+ _doing_it_wrong( __FUNCTION__, __( 'An error has occurred. Please reload the page and try again.' ), '1.0' );
61
  }
62
 
63
  /**
202
  function set_constants() {
203
  $dir = wp_upload_dir();
204
  $constants = array(
205
+ 'CCJ_VERSION' => '3.18',
206
  'CCJ_UPLOAD_DIR' => $dir['basedir'] . '/custom-css-js',
207
  'CCJ_UPLOAD_URL' => $dir['baseurl'] . '/custom-css-js',
208
  'CCJ_PLUGIN_FILE' => __FILE__,
includes/admin-config.php CHANGED
@@ -205,23 +205,22 @@ class CustomCSSandJS_AdminConfig {
205
  update_option( 'ccj_settings', $settings );
206
  }
207
 
208
- $title = __('If you want to use an HTML entity in your code (for example '. htmlentities('> or "').'), but the editor keeps on changing them to its equivalent character (> and " for the previous example), then you might want to enable this option.', 'custom-css-js-pro');
209
- $help = '<span class="dashicons dashicons-editor-help" rel="tipsy" title="'.$title.'"></span>';
210
 
211
- $title2 = __('If you use HTML tags in your code (for example '.htmlentities('<input> or <textarea>').') and you notice that they dissapear and the editor looks weird, then you need to enable this option.', 'custom-css-js-pro');
212
- $help2 = '<span class="dashicons dashicons-editor-help" rel="tipsy" title="'.$title2.'"></span>';
213
 
214
  ?>
215
 
216
  <h2><?php echo __('Editor Settings', 'custom-css-js'); ?></h2>
217
  <table class="form-table">
218
  <tr>
219
- <th scope="row"><label for="ccj_htmlentities"><?php _e('Keep the HTML entities, don\'t convert to its character', 'custom-css-js-pro') ?> <?php echo $help; ?></label></th>
 
220
  <td><input type="checkbox" name="ccj_htmlentities" id = "ccj_htmlentities" value="1" <?php checked($settings['ccj_htmlentities'], true); ?> />
221
  </td>
222
  </tr>
223
  <tr>
224
- <th scope="row"><label for="ccj_htmlentities2"><?php _e('Encode the HTML entities', 'custom-css-js-pro') ?> <?php echo $help2; ?></label></th>
225
  <td><input type="checkbox" name="ccj_htmlentities2" id = "ccj_htmlentities2" value="1" <?php checked($settings['ccj_htmlentities2'], true); ?> />
226
  </td>
227
  </tr>
@@ -232,10 +231,11 @@ class CustomCSSandJS_AdminConfig {
232
 
233
 
234
  <?php if ( current_user_can('update_plugins') ) : ?>
 
235
  <h2><?php echo __('General Settings', 'custom-css-js'); ?></h2>
236
  <table class="form-table">
237
  <tr>
238
- <th scope="row"><label for="add_role"><?php _e('Add the "css_js_designer" role', 'custom-css-js-pro') ?> <?php echo $help; ?></label></th>
239
  <td><input type="checkbox" name="add_role" id = "add_role" value="1" <?php checked($settings['add_role'], true); ?> />
240
  </td>
241
  </tr>
205
  update_option( 'ccj_settings', $settings );
206
  }
207
 
208
+ $ccj_htmlentities_help = __('If you want to use an HTML entity in your code (for example '. htmlentities('&gt; or &quot;').'), but the editor keeps on changing them to its equivalent character (&gt; and &quot; for the previous example), then you might want to enable this option.', 'custom-css-js');
 
209
 
210
+ $ccj_htmlentities2_help = __('If you use HTML tags in your code (for example '.htmlentities('<input> or <textarea>').') and you notice that they disappear and the editor looks weird, then you need to enable this option.', 'custom-css-js');
 
211
 
212
  ?>
213
 
214
  <h2><?php echo __('Editor Settings', 'custom-css-js'); ?></h2>
215
  <table class="form-table">
216
  <tr>
217
+ <th scope="row"><label for="ccj_htmlentities"><?php _e('Keep the HTML entities, don\'t convert to its character', 'custom-css-js') ?> <span class="dashicons dashicons-editor-help" rel="tipsy" title="<?php echo $ccj_htmlentities_help; ?>"></span>
218
+ </label></th>
219
  <td><input type="checkbox" name="ccj_htmlentities" id = "ccj_htmlentities" value="1" <?php checked($settings['ccj_htmlentities'], true); ?> />
220
  </td>
221
  </tr>
222
  <tr>
223
+ <th scope="row"><label for="ccj_htmlentities2"><?php _e('Encode the HTML entities', 'custom-css-js') ?> <span class="dashicons dashicons-editor-help" rel="tipsy" title="<?php echo $ccj_htmlentities2_help; ?>"></span></label></th>
224
  <td><input type="checkbox" name="ccj_htmlentities2" id = "ccj_htmlentities2" value="1" <?php checked($settings['ccj_htmlentities2'], true); ?> />
225
  </td>
226
  </tr>
231
 
232
 
233
  <?php if ( current_user_can('update_plugins') ) : ?>
234
+ <?php $add_role_help = esc_html__('By default only the Administrator will be able to publish/edit/delete Custom Codes. By enabling this option there is also a "Web Designer" role created which can be assigned to a non-admin user in order to publish/edit/delete Custom Codes.', 'custom-css-js'); ?>
235
  <h2><?php echo __('General Settings', 'custom-css-js'); ?></h2>
236
  <table class="form-table">
237
  <tr>
238
+ <th scope="row"><label for="add_role"><?php _e('Add the "Web Designer" role', 'custom-css-js') ?> <span class="dashicons dashicons-editor-help" rel="tipsy" title="<?php echo $add_role_help; ?>"></span></label></th>
239
  <td><input type="checkbox" name="add_role" id = "add_role" value="1" <?php checked($settings['add_role'], true); ?> />
240
  </td>
241
  </tr>
includes/admin-screens.php CHANGED
@@ -312,7 +312,7 @@ class CustomCSSandJS_Admin {
312
  $time_diff = time() - $g_time;
313
 
314
  if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) {
315
- $h_time = sprintf( __( '%s ago', 'custom-css-js-pro' ), human_time_diff( $g_time) );
316
  } else {
317
  $h_time = mysql2date( get_option('date_format'), $f_time );
318
  }
@@ -355,6 +355,10 @@ class CustomCSSandJS_Admin {
355
  return $query;
356
  }
357
 
 
 
 
 
358
  if ( 'custom-css-js' !== $query->query['post_type'] ) {
359
  return $query;
360
  }
@@ -1023,9 +1027,15 @@ End of comment */ ', 'custom-css-js') . PHP_EOL . PHP_EOL;
1023
  }
1024
 
1025
  if ( $options['language'] == 'js' ) {
 
1026
  if ( preg_match('@/\* Add your JavaScript code here[\s\S]*?End of comment \*/@im', $_POST['content'] ) ) {
1027
  $_POST['content'] = preg_replace('@/\* Add your JavaScript code here[\s\S]*?End of comment \*/@im', '/* Default comment here */', $_POST['content']);
1028
  }
 
 
 
 
 
1029
  }
1030
 
1031
 
312
  $time_diff = time() - $g_time;
313
 
314
  if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) {
315
+ $h_time = sprintf( __( '%s ago', 'custom-css-js' ), human_time_diff( $g_time) );
316
  } else {
317
  $h_time = mysql2date( get_option('date_format'), $f_time );
318
  }
355
  return $query;
356
  }
357
 
358
+ if ( !isset($query->query['post_type'])) {
359
+ return $query;
360
+ }
361
+
362
  if ( 'custom-css-js' !== $query->query['post_type'] ) {
363
  return $query;
364
  }
1027
  }
1028
 
1029
  if ( $options['language'] == 'js' ) {
1030
+ // Replace the default comment
1031
  if ( preg_match('@/\* Add your JavaScript code here[\s\S]*?End of comment \*/@im', $_POST['content'] ) ) {
1032
  $_POST['content'] = preg_replace('@/\* Add your JavaScript code here[\s\S]*?End of comment \*/@im', '/* Default comment here */', $_POST['content']);
1033
  }
1034
+
1035
+ // For other locales remove all the comments
1036
+ if ( substr( get_locale(), 0, 3) !== 'en_' ) {
1037
+ $_POST['content'] = preg_replace('@/\*[\s\S]*?\*/@', '', $_POST['content']);
1038
+ }
1039
  }
1040
 
1041
 
readme.txt CHANGED
@@ -5,9 +5,10 @@ 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.17
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
 
11
 
12
  Easily add Custom CSS or JS to your website with an awesome editor.
13
 
@@ -114,6 +115,13 @@ $. Add/Edit HTML
114
 
115
  == Changelog ==
116
 
 
 
 
 
 
 
 
117
  = 3.17 =
118
  * 04/25/2018
119
  * Fix: add the add/edit/delete custom post capabilities to the admin and 'css_js_designer' roles on plugin activation
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.18
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
11
+ Requires PHP: 5.2.4
12
 
13
  Easily add Custom CSS or JS to your website with an awesome editor.
14
 
115
 
116
  == Changelog ==
117
 
118
+
119
+ = 3.18 =
120
+ * 07/13/2018
121
+ * Fix: the default comment for JS for other locales than "en_" was removing the <scripts> tags
122
+ * Tweak: make the search dialog persistent
123
+ * Tweak: correct the tooltip info for the 'ccs_js_designer' option
124
+
125
  = 3.17 =
126
  * 04/25/2018
127
  * Fix: add the add/edit/delete custom post capabilities to the admin and 'css_js_designer' roles on plugin activation