Version Description
- Fix: https://wordpress.org/support/topic/broken-layout-of-code-snippet-type-color-tag-css-html-js-on-main-list-table/
- Feature: add filter by code type
- Feature: make the 'Modified' column sortable
- Fix: if the default comment remains in the "Add Custom JS", then there was no
Download this release
Release Info
Developer | diana_burduja |
Plugin | Simple Custom CSS and JS |
Version | 3.10 |
Comparing to | |
See all releases |
Code changes from version 3.9 to 3.10
- assets/ccj_admin.css +1 -0
- custom-css-js.php +2 -2
- includes/admin-screens.php +97 -3
- readme.txt +8 -2
assets/ccj_admin.css
CHANGED
@@ -43,6 +43,7 @@
|
|
43 |
font-size: 12px;
|
44 |
padding: 5px 10px !important;
|
45 |
text-decoration: none;
|
|
|
46 |
}
|
47 |
.language-js { background: #e4a228; }
|
48 |
.language-php { background: #e45126; }
|
43 |
font-size: 12px;
|
44 |
padding: 5px 10px !important;
|
45 |
text-decoration: none;
|
46 |
+
word-wrap: normal !important;
|
47 |
}
|
48 |
.language-js { background: #e4a228; }
|
49 |
.language-php { background: #e45126; }
|
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.
|
7 |
* Author: Diana Burduja
|
8 |
* Author URI: https://www.silkypress.com/
|
9 |
* License: GPL2
|
@@ -194,7 +194,7 @@ final class CustomCSSandJS {
|
|
194 |
function set_constants() {
|
195 |
$dir = wp_upload_dir();
|
196 |
$constants = array(
|
197 |
-
'CCJ_VERSION' => '3.
|
198 |
'CCJ_UPLOAD_DIR' => $dir['basedir'] . '/custom-css-js',
|
199 |
'CCJ_UPLOAD_URL' => $dir['baseurl'] . '/custom-css-js',
|
200 |
'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.10
|
7 |
* Author: Diana Burduja
|
8 |
* Author URI: https://www.silkypress.com/
|
9 |
* License: GPL2
|
194 |
function set_constants() {
|
195 |
$dir = wp_upload_dir();
|
196 |
$constants = array(
|
197 |
+
'CCJ_VERSION' => '3.10',
|
198 |
'CCJ_UPLOAD_DIR' => $dir['basedir'] . '/custom-css-js',
|
199 |
'CCJ_UPLOAD_URL' => $dir['baseurl'] . '/custom-css-js',
|
200 |
'CCJ_PLUGIN_FILE' => __FILE__,
|
includes/admin-screens.php
CHANGED
@@ -64,15 +64,17 @@ class CustomCSSandJS_Admin {
|
|
64 |
'wp_loaded' => 'compatibility_shortcoder',
|
65 |
'wp_ajax_ccj_active_code' => 'wp_ajax_ccj_active_code',
|
66 |
'post_submitbox_start' => 'post_submitbox_start',
|
|
|
67 |
);
|
68 |
foreach( $actions as $_key => $_value ) {
|
69 |
add_action( $_key, array( $this, $_value ) );
|
70 |
}
|
71 |
|
72 |
-
|
73 |
// Add some custom actions/filters
|
74 |
add_action( 'manage_custom-css-js_posts_custom_column', array( $this, 'manage_posts_columns' ), 10, 2 );
|
|
|
75 |
add_filter( 'post_row_actions', array( $this, 'post_row_actions' ), 10, 2 );
|
|
|
76 |
}
|
77 |
|
78 |
|
@@ -329,6 +331,71 @@ class CustomCSSandJS_Admin {
|
|
329 |
}
|
330 |
}
|
331 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
/**
|
333 |
* Activate/deactivate a code
|
334 |
*
|
@@ -509,6 +576,24 @@ class CustomCSSandJS_Admin {
|
|
509 |
}
|
510 |
$language = $this->get_language($post_id);
|
511 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
512 |
switch ( $language ) {
|
513 |
case 'js' :
|
514 |
if ( $new_post ) {
|
@@ -922,6 +1007,12 @@ End of comment */ ', 'custom-css-js') . PHP_EOL . PHP_EOL;
|
|
922 |
return;
|
923 |
}
|
924 |
|
|
|
|
|
|
|
|
|
|
|
|
|
925 |
|
926 |
// Save the Custom Code in a file in `wp-content/uploads/custom-css-js`
|
927 |
if ( $options['linking'] == 'internal' ) {
|
@@ -934,8 +1025,11 @@ End of comment */ ', 'custom-css-js') . PHP_EOL . PHP_EOL;
|
|
934 |
}
|
935 |
if ( $options['language'] == 'js' ) {
|
936 |
if ( ! preg_match( '/<script\b[^>]*>([\s\S]*?)<\/script>/im', $_POST['content'] ) ) {
|
937 |
-
|
938 |
-
|
|
|
|
|
|
|
939 |
}
|
940 |
}
|
941 |
}
|
64 |
'wp_loaded' => 'compatibility_shortcoder',
|
65 |
'wp_ajax_ccj_active_code' => 'wp_ajax_ccj_active_code',
|
66 |
'post_submitbox_start' => 'post_submitbox_start',
|
67 |
+
'restrict_manage_posts' => 'restrict_manage_posts',
|
68 |
);
|
69 |
foreach( $actions as $_key => $_value ) {
|
70 |
add_action( $_key, array( $this, $_value ) );
|
71 |
}
|
72 |
|
|
|
73 |
// Add some custom actions/filters
|
74 |
add_action( 'manage_custom-css-js_posts_custom_column', array( $this, 'manage_posts_columns' ), 10, 2 );
|
75 |
+
add_filter( 'manage_edit-custom-css-js_sortable_columns', array( $this, 'manage_edit_posts_sortable_columns' ) );
|
76 |
add_filter( 'post_row_actions', array( $this, 'post_row_actions' ), 10, 2 );
|
77 |
+
add_filter( 'parse_query', array($this, 'parse_query') , 10);
|
78 |
}
|
79 |
|
80 |
|
331 |
}
|
332 |
}
|
333 |
|
334 |
+
|
335 |
+
/**
|
336 |
+
* Make the 'Modified' column sortable
|
337 |
+
*/
|
338 |
+
function manage_edit_posts_sortable_columns( $columns ) {
|
339 |
+
$columns['modified'] = 'modified';
|
340 |
+
return $columns;
|
341 |
+
|
342 |
+
}
|
343 |
+
|
344 |
+
|
345 |
+
/**
|
346 |
+
* List table: Change the query in order to filter by code type
|
347 |
+
*/
|
348 |
+
function parse_query( $query ){
|
349 |
+
if ( !is_admin() || !$query->is_main_query() ){
|
350 |
+
return $query;
|
351 |
+
}
|
352 |
+
|
353 |
+
if ( 'custom-css-js' !== $query->query['post_type'] ) {
|
354 |
+
return $query;
|
355 |
+
}
|
356 |
+
|
357 |
+
$filter = filter_input( INPUT_GET, 'language_filter' );
|
358 |
+
if ( !is_string($filter) || strlen($filter) == 0 ) {
|
359 |
+
return $query;
|
360 |
+
}
|
361 |
+
|
362 |
+
global $wpdb;
|
363 |
+
$post_id_query = "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = %s AND meta_value LIKE %s";
|
364 |
+
$post_ids = $wpdb->get_col( $wpdb->prepare($post_id_query, 'options', '%'.$filter.'%') );
|
365 |
+
if ( !is_array($post_ids) || count($post_ids) == 0 ) {
|
366 |
+
$post_ids = array(-1);
|
367 |
+
}
|
368 |
+
$query->query_vars['post__in'] = $post_ids;
|
369 |
+
|
370 |
+
return $query;
|
371 |
+
}
|
372 |
+
|
373 |
+
|
374 |
+
/**
|
375 |
+
* List table: add a filter by code type
|
376 |
+
*/
|
377 |
+
function restrict_manage_posts( $post_type ) {
|
378 |
+
if('custom-css-js' !== $post_type){
|
379 |
+
return;
|
380 |
+
}
|
381 |
+
|
382 |
+
$languages = array(
|
383 |
+
'css' => __('CSS Codes', 'custom-cs-js'),
|
384 |
+
'js' => __('JS Codes', 'custom-css-js'),
|
385 |
+
'html' => __('HTML Codes', 'custom-css-js'),
|
386 |
+
);
|
387 |
+
|
388 |
+
echo '<label class="screen-reader-text" for="custom-css-js-filter">' . esc_html__( 'Filter Code Type', 'custom-css-js' ) . '</label>';
|
389 |
+
echo '<select name="language_filter" id="custom-css-js-filter">';
|
390 |
+
echo '<option value="">' . __('All Custom Codes', 'custom-css-js'). '</option>';
|
391 |
+
foreach ( $languages as $_lang => $_label ) {
|
392 |
+
$selected = selected( filter_input( INPUT_GET, 'language_filter' ), $_lang, false ); ;
|
393 |
+
echo '<option ' . $selected . ' value="' . $_lang. '">' . $_label . '</option>';
|
394 |
+
}
|
395 |
+
echo '</select>';
|
396 |
+
}
|
397 |
+
|
398 |
+
|
399 |
/**
|
400 |
* Activate/deactivate a code
|
401 |
*
|
576 |
}
|
577 |
$language = $this->get_language($post_id);
|
578 |
|
579 |
+
// Replace the htmlentities (https://wordpress.org/support/topic/annoying-bug-in-text-editor/), but only selectively
|
580 |
+
if ( strstr($post->post_content, '&') ) {
|
581 |
+
|
582 |
+
// First the ampresands
|
583 |
+
$post->post_content = str_replace('&', htmlentities('&'), $post->post_content );
|
584 |
+
|
585 |
+
// Then the rest of the entities
|
586 |
+
$entities = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES | ENT_HTML5 );
|
587 |
+
unset( $entities[ array_search('&', $entities) ]);
|
588 |
+
$regular_expression = str_replace(';', '', '/('.implode('|', $entities).')/i');
|
589 |
+
preg_match_all($regular_expression, $post->post_content, $matches);
|
590 |
+
if ( isset($matches[0]) && count($matches[0]) > 0 ) {
|
591 |
+
foreach($matches[0] as $_entity) {
|
592 |
+
$post->post_content = str_replace($_entity, htmlentities($_entity), $post->post_content);
|
593 |
+
}
|
594 |
+
}
|
595 |
+
}
|
596 |
+
|
597 |
switch ( $language ) {
|
598 |
case 'js' :
|
599 |
if ( $new_post ) {
|
1007 |
return;
|
1008 |
}
|
1009 |
|
1010 |
+
if ( $options['language'] == 'js' ) {
|
1011 |
+
if ( preg_match('@/\* Add your JavaScript code here[\s\S]*?End of comment \*/@im', $_POST['content'] ) ) {
|
1012 |
+
$_POST['content'] = preg_replace('@/\* Add your JavaScript code here[\s\S]*?End of comment \*/@im', '/* Default comment here */', $_POST['content']);
|
1013 |
+
}
|
1014 |
+
}
|
1015 |
+
|
1016 |
|
1017 |
// Save the Custom Code in a file in `wp-content/uploads/custom-css-js`
|
1018 |
if ( $options['linking'] == 'internal' ) {
|
1025 |
}
|
1026 |
if ( $options['language'] == 'js' ) {
|
1027 |
if ( ! preg_match( '/<script\b[^>]*>([\s\S]*?)<\/script>/im', $_POST['content'] ) ) {
|
1028 |
+
$before .= '<script type="text/javascript">' . PHP_EOL;
|
1029 |
+
$after = '</script>' . PHP_EOL . $after;
|
1030 |
+
} else {
|
1031 |
+
// the content has a <script> tag, then remove the comments so they don't show up on the frontend
|
1032 |
+
$_POST['content'] = preg_replace('@/\*[\s\S]*?\*/@', '', $_POST['content']);
|
1033 |
}
|
1034 |
}
|
1035 |
}
|
readme.txt
CHANGED
@@ -6,7 +6,7 @@ Email: diana@burduja.eu
|
|
6 |
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
|
7 |
Requires at least: 3.0.1
|
8 |
Tested up to: 4.9
|
9 |
-
Stable tag: 3.
|
10 |
License: GPLv3
|
11 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
12 |
|
@@ -115,6 +115,12 @@ $. Add/Edit HTML
|
|
115 |
|
116 |
== Changelog ==
|
117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
= 3.9 =
|
119 |
* 12/01/2017
|
120 |
* Feature: add "Last edited ..." information under the editor
|
@@ -127,7 +133,7 @@ $. Add/Edit HTML
|
|
127 |
* Fix: avoid conflicts with other plugins that implement the CodeMirror editor
|
128 |
* Update the CodeMirror library to 5.28 version
|
129 |
|
130 |
-
= 3.7
|
131 |
* 10/06/2017
|
132 |
* Add French and Polish translation
|
133 |
|
6 |
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
|
7 |
Requires at least: 3.0.1
|
8 |
Tested up to: 4.9
|
9 |
+
Stable tag: 3.10
|
10 |
License: GPLv3
|
11 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
12 |
|
115 |
|
116 |
== Changelog ==
|
117 |
|
118 |
+
= 3.10 =
|
119 |
+
* Fix: https://wordpress.org/support/topic/broken-layout-of-code-snippet-type-color-tag-css-html-js-on-main-list-table/
|
120 |
+
* Feature: add filter by code type
|
121 |
+
* Feature: make the 'Modified' column sortable
|
122 |
+
* Fix: if the default comment remains in the "Add Custom JS", then there was no <script> tags added to the code, as the comment contained a <script> tag
|
123 |
+
|
124 |
= 3.9 =
|
125 |
* 12/01/2017
|
126 |
* Feature: add "Last edited ..." information under the editor
|
133 |
* Fix: avoid conflicts with other plugins that implement the CodeMirror editor
|
134 |
* Update the CodeMirror library to 5.28 version
|
135 |
|
136 |
+
= 3.7 =
|
137 |
* 10/06/2017
|
138 |
* Add French and Polish translation
|
139 |
|