Simple Custom CSS and JS - Version 3.27

Version Description

  • 08/08/2019
  • Compatibility with the "CMSMasters Content Composer" plugin
  • Feature: keep the cursor position after saving
  • Option: remove the comments from the HTML
Download this release

Release Info

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

Code changes from version 3.26 to 3.27

assets/ccj_admin.js CHANGED
@@ -44,7 +44,26 @@ jQuery(document).ready( function($) {
44
  editor.setSize(cm_width, cm_height);
45
  });
46
 
 
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
  }
50
 
44
  editor.setSize(cm_width, cm_height);
45
  });
46
 
47
+ var postID = document.getElementById('post_ID') != null ? document.getElementById('post_ID').value : 0;
48
 
49
+ var getCookie = function (name) {
50
+ var value = '; ' + document.cookie;
51
+ var parts = value.split('; ' + name + '=');
52
+ if (parts.length === 2) return parts.pop().split(';').shift();
53
+ };
54
+
55
+
56
+ // Saving cursor state
57
+ editor.on('cursorActivity', function () {
58
+ var curPos = editor.getCursor();
59
+ document.cookie = 'hesh_plugin_pos=' + postID + ',' + curPos.line + ',' + curPos.ch;
60
+ });
61
+
62
+ // Restoring cursor state
63
+ var curPos = (getCookie('hesh_plugin_pos') || '0,0,0').split(',');
64
+ if (postID === curPos[0]) {
65
+ editor.setCursor(parseFloat(curPos[1]), parseFloat(curPos[2]));
66
+ }
67
 
68
  }
69
 
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.26
7
  * Author: SilkyPress.com
8
  * Author URI: https://www.silkypress.com
9
  * License: GPL2
@@ -12,7 +12,7 @@
12
  * Domain Path: /languages/
13
  *
14
  * WC requires at least: 2.3.0
15
- * WC tested up to: 3.6
16
  */
17
 
18
  if ( ! defined( 'ABSPATH' ) ) {
@@ -29,6 +29,7 @@ final class CustomCSSandJS {
29
 
30
  public $search_tree = false;
31
  protected static $_instance = null;
 
32
 
33
 
34
  /**
@@ -82,6 +83,7 @@ final class CustomCSSandJS {
82
  }
83
 
84
  $this->search_tree = get_option( 'custom-css-js-tree' );
 
85
 
86
  if ( ! $this->search_tree || count( $this->search_tree ) == 0 ) {
87
  return false;
@@ -140,9 +142,13 @@ final class CustomCSSandJS {
140
 
141
  // print the `internal` code
142
  if ( strpos( $function, 'internal' ) !== false ) {
143
-
144
- $before = '<!-- start Simple Custom CSS and JS -->' . PHP_EOL;
145
- $after = '<!-- end Simple Custom CSS and JS -->' . PHP_EOL;
 
 
 
 
146
  if ( strpos( $function, 'css' ) !== false ) {
147
  $before .= '<style type="text/css">' . PHP_EOL;
148
  $after = '</style>' . PHP_EOL . $after;
@@ -155,7 +161,15 @@ final class CustomCSSandJS {
155
 
156
  foreach( $args as $_post_id ) {
157
  if ( strstr( $_post_id, 'css' ) || strstr( $_post_id, 'js' ) ) {
158
- @include_once( CCJ_UPLOAD_DIR . '/' . $_post_id );
 
 
 
 
 
 
 
 
159
  } else {
160
  $post = get_post( $_post_id );
161
  echo $before . $post->post_content . $after;
@@ -204,7 +218,7 @@ final class CustomCSSandJS {
204
  function set_constants() {
205
  $dir = wp_upload_dir();
206
  $constants = array(
207
- 'CCJ_VERSION' => '3.26',
208
  'CCJ_UPLOAD_DIR' => $dir['basedir'] . '/custom-css-js',
209
  'CCJ_UPLOAD_URL' => $dir['baseurl'] . '/custom-css-js',
210
  '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.27
7
  * Author: SilkyPress.com
8
  * Author URI: https://www.silkypress.com
9
  * License: GPL2
12
  * Domain Path: /languages/
13
  *
14
  * WC requires at least: 2.3.0
15
+ * WC tested up to: 3.7
16
  */
17
 
18
  if ( ! defined( 'ABSPATH' ) ) {
29
 
30
  public $search_tree = false;
31
  protected static $_instance = null;
32
+ private $settings = array();
33
 
34
 
35
  /**
83
  }
84
 
85
  $this->search_tree = get_option( 'custom-css-js-tree' );
86
+ $this->settings = get_option('ccj_settings');
87
 
88
  if ( ! $this->search_tree || count( $this->search_tree ) == 0 ) {
89
  return false;
142
 
143
  // print the `internal` code
144
  if ( strpos( $function, 'internal' ) !== false ) {
145
+ if ( isset($this->settings['remove_comments']) && $this->settings['remove_comments'] ) {
146
+ $before = '';
147
+ $after = '';
148
+ } else {
149
+ $before = '<!-- start Simple Custom CSS and JS -->' . PHP_EOL;
150
+ $after = '<!-- end Simple Custom CSS and JS -->' . PHP_EOL;
151
+ }
152
  if ( strpos( $function, 'css' ) !== false ) {
153
  $before .= '<style type="text/css">' . PHP_EOL;
154
  $after = '</style>' . PHP_EOL . $after;
161
 
162
  foreach( $args as $_post_id ) {
163
  if ( strstr( $_post_id, 'css' ) || strstr( $_post_id, 'js' ) ) {
164
+ if ( isset($this->settings['remove_comments']) && $this->settings['remove_comments'] ) {
165
+ ob_start();
166
+ @include_once( CCJ_UPLOAD_DIR . '/' . $_post_id );
167
+ $custom_code = ob_get_clean();
168
+ $custom_code = str_replace(array('<!-- start Simple Custom CSS and JS -->' . PHP_EOL, '<!-- end Simple Custom CSS and JS -->' . PHP_EOL), '', $custom_code);
169
+ echo $custom_code;
170
+ } else {
171
+ @include_once( CCJ_UPLOAD_DIR . '/' . $_post_id );
172
+ }
173
  } else {
174
  $post = get_post( $_post_id );
175
  echo $before . $post->post_content . $after;
218
  function set_constants() {
219
  $dir = wp_upload_dir();
220
  $constants = array(
221
+ 'CCJ_VERSION' => '3.27',
222
  'CCJ_UPLOAD_DIR' => $dir['basedir'] . '/custom-css-js',
223
  'CCJ_UPLOAD_URL' => $dir['baseurl'] . '/custom-css-js',
224
  'CCJ_PLUGIN_FILE' => __FILE__,
includes/admin-config.php CHANGED
@@ -96,6 +96,7 @@ class CustomCSSandJS_AdminConfig {
96
 
97
  $settings = get_option('ccj_settings');
98
  if ( !isset($settings['add_role'] ) ) $settings['add_role'] = false;
 
99
 
100
  // If the "add role" option changed
101
  if ( $data['add_role'] !== $settings['add_role'] && current_user_can('update_plugins')) {
@@ -163,6 +164,7 @@ class CustomCSSandJS_AdminConfig {
163
  'ccj_htmlentities' => false,
164
  'ccj_htmlentities2' => false,
165
  'add_role' => false,
 
166
  ) );
167
  }
168
 
@@ -210,6 +212,8 @@ class CustomCSSandJS_AdminConfig {
210
 
211
  $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');
212
 
 
 
213
  ?>
214
 
215
  <h2><?php echo __('Editor Settings', 'custom-css-js'); ?></h2>
@@ -242,6 +246,14 @@ class CustomCSSandJS_AdminConfig {
242
  </tr>
243
  </table>
244
  <?php endif; ?>
 
 
 
 
 
 
 
 
245
  <table class="form-table">
246
  <tr>
247
  <th>&nbsp;</th>
96
 
97
  $settings = get_option('ccj_settings');
98
  if ( !isset($settings['add_role'] ) ) $settings['add_role'] = false;
99
+ if ( !isset($settings['remove_comments'] ) ) $settings['remove_comments'] = false;
100
 
101
  // If the "add role" option changed
102
  if ( $data['add_role'] !== $settings['add_role'] && current_user_can('update_plugins')) {
164
  'ccj_htmlentities' => false,
165
  'ccj_htmlentities2' => false,
166
  'add_role' => false,
167
+ 'remove_comments' => false,
168
  ) );
169
  }
170
 
212
 
213
  $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');
214
 
215
+ $remove_comments_help = __('In your page\'s HTML there is a comment added before and after the internal CSS or JS in order to help you locate your custom code. Enable this option in order to remove that comment.', 'custom-css-js');
216
+
217
  ?>
218
 
219
  <h2><?php echo __('Editor Settings', 'custom-css-js'); ?></h2>
246
  </tr>
247
  </table>
248
  <?php endif; ?>
249
+ <table class="form-table">
250
+ <tr>
251
+ <th scope="row"><label for="remove_comments"><?php _e('Remove the comments from HTML', 'custom-css-js') ?> <span class="dashicons dashicons-editor-help" rel="tipsy" title="<?php echo $remove_comments_help; ?>"></span></label></th>
252
+ <td><input type="checkbox" name="remove_comments" id = "remove_comments" value="1" <?php checked($settings['remove_comments'], true); ?> />
253
+ </td>
254
+ </tr>
255
+ </table>
256
+
257
  <table class="form-table">
258
  <tr>
259
  <th>&nbsp;</th>
includes/admin-screens.php CHANGED
@@ -1387,6 +1387,8 @@ End of comment */ ', 'custom-css-js') . PHP_EOL . PHP_EOL;
1387
  return false;
1388
 
1389
  remove_filter( 'use_block_editor_for_post', array( 'Classic_Editor', 'choose_editor' ), 100, 2 );
 
 
1390
  }
1391
  }
1392
 
1387
  return false;
1388
 
1389
  remove_filter( 'use_block_editor_for_post', array( 'Classic_Editor', 'choose_editor' ), 100, 2 );
1390
+ add_filter( 'use_block_editor_for_post', '__return_false', 100 );
1391
+ add_filter( 'use_block_editor_for_post_type', '__return_false', 100 );
1392
  }
1393
  }
1394
 
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: 5.2
8
- Stable tag: 3.26
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
11
  Requires PHP: 5.2.4
@@ -105,6 +105,12 @@ $. Add/Edit HTML
105
 
106
  == Changelog ==
107
 
 
 
 
 
 
 
108
  = 3.26 =
109
  * 05/08/2019
110
  * Fix: remove the Codemirror library added from WP Core
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: 5.2
8
+ Stable tag: 3.27
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
11
  Requires PHP: 5.2.4
105
 
106
  == Changelog ==
107
 
108
+ = 3.27 =
109
+ * 08/08/2019
110
+ * Compatibility with the "CMSMasters Content Composer" plugin
111
+ * Feature: keep the cursor position after saving
112
+ * Option: remove the comments from the HTML
113
+
114
  = 3.26 =
115
  * 05/08/2019
116
  * Fix: remove the Codemirror library added from WP Core