Simple Custom CSS and JS - Version 3.17

Version Description

  • 04/25/2018
  • Fix: add the add/edit/delete custom post capabilities to the admin and 'css_js_designer' roles on plugin activation
Download this release

Release Info

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

Code changes from version 3.16 to 3.17

assets/ccj_admin.css CHANGED
@@ -34,7 +34,6 @@
34
  */
35
  .inline.hide-if-no-js{ display: none; }
36
  .view-switch { display: none; }
37
- #modified { width: 140px; }
38
  #type.manage-column { width: 50px; }
39
  .language {
40
  background: #0c73b8;
@@ -56,6 +55,15 @@
56
  .column-active .dashicons { font-size: 17px; }
57
  .column-active a, .column-active a:active, .column-active a:hover, .column-active a:focus { display: block; outline: 0; border: 0; text-decoration: none; }
58
  #active.manage-column { width: 30px; }
 
 
 
 
 
 
 
 
 
59
 
60
 
61
  /**
34
  */
35
  .inline.hide-if-no-js{ display: none; }
36
  .view-switch { display: none; }
 
37
  #type.manage-column { width: 50px; }
38
  .language {
39
  background: #0c73b8;
55
  .column-active .dashicons { font-size: 17px; }
56
  .column-active a, .column-active a:active, .column-active a:hover, .column-active a:focus { display: block; outline: 0; border: 0; text-decoration: none; }
57
  #active.manage-column { width: 30px; }
58
+ th.column-published, th.column-modified {
59
+ width: 15%;
60
+ }
61
+ @media screen and (max-width:782px){
62
+ .wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.check-column) { display: table-cell !important; }
63
+ .wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.check-column)::before { display: none !important; }
64
+ .wp-list-table .toggle-row { display: none !important; }
65
+ }
66
+
67
 
68
 
69
  /**
custom-css-js.php CHANGED
@@ -3,8 +3,8 @@
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.16
7
- * Author: SilkyPres.com
8
  * Author URI: https://www.silkypress.com
9
  * License: GPL2
10
  *
@@ -65,7 +65,11 @@ final class CustomCSSandJS {
65
  * @access public
66
  */
67
  public function __construct() {
68
- add_action( 'init', array( $this, 'register_post_type' ) );
 
 
 
 
69
  $this->set_constants();
70
 
71
  if ( is_admin() ) {
@@ -198,7 +202,7 @@ final class CustomCSSandJS {
198
  function set_constants() {
199
  $dir = wp_upload_dir();
200
  $constants = array(
201
- 'CCJ_VERSION' => '3.16',
202
  'CCJ_UPLOAD_DIR' => $dir['basedir'] . '/custom-css-js',
203
  'CCJ_UPLOAD_URL' => $dir['baseurl'] . '/custom-css-js',
204
  'CCJ_PLUGIN_FILE' => __FILE__,
@@ -210,68 +214,6 @@ final class CustomCSSandJS {
210
  }
211
  }
212
 
213
-
214
- /**
215
- * Create the custom-css-js post type
216
- */
217
- public function register_post_type() {
218
- $labels = array(
219
- 'name' => _x( 'Custom Code', 'post type general name', 'custom-css-js'),
220
- 'singular_name' => _x( 'Custom Code', 'post type singular name', 'custom-css-js'),
221
- 'menu_name' => _x( 'Custom CSS & JS', 'admin menu', 'custom-css-js'),
222
- 'name_admin_bar' => _x( 'Custom Code', 'add new on admin bar', 'custom-css-js'),
223
- 'add_new' => _x( 'Add Custom Code', 'add new', 'custom-css-js'),
224
- 'add_new_item' => __( 'Add Custom Code', 'custom-css-js'),
225
- 'new_item' => __( 'New Custom Code', 'custom-css-js'),
226
- 'edit_item' => __( 'Edit Custom Code', 'custom-css-js'),
227
- 'view_item' => __( 'View Custom Code', 'custom-css-js'),
228
- 'all_items' => __( 'All Custom Code', 'custom-css-js'),
229
- 'search_items' => __( 'Search Custom Code', 'custom-css-js'),
230
- 'parent_item_colon' => __( 'Parent Custom Code:', 'custom-css-js'),
231
- 'not_found' => __( 'No Custom Code found.', 'custom-css-js'),
232
- 'not_found_in_trash' => __( 'No Custom Code found in Trash.', 'custom-css-js')
233
- );
234
-
235
- $capability_type = 'custom_css';
236
- $capabilities = array(
237
- 'edit_post' => "edit_{$capability_type}",
238
- 'read_post' => "read_{$capability_type}",
239
- 'delete_post' => "delete_{$capability_type}",
240
- 'edit_posts' => "edit_{$capability_type}s",
241
- 'edit_others_posts' => "edit_others_{$capability_type}s",
242
- 'publish_posts' => "publish_{$capability_type}s",
243
- 'read' => "read",
244
- 'delete_posts' => "delete_{$capability_type}s",
245
- 'delete_published_posts' => "delete_published_{$capability_type}s",
246
- 'delete_others_posts' => "delete_others_{$capability_type}s",
247
- 'edit_published_posts' => "edit_published_{$capability_type}s",
248
- 'create_posts' => "edit_{$capability_type}s",
249
- );
250
-
251
- $args = array(
252
- 'labels' => $labels,
253
- 'description' => __( 'Custom CSS and JS code', 'custom-css-js' ),
254
- 'public' => false,
255
- 'publicly_queryable' => false,
256
- 'show_ui' => true,
257
- 'show_in_menu' => true,
258
- 'menu_position' => 100,
259
- 'menu_icon' => 'dashicons-plus-alt',
260
- 'query_var' => false,
261
- 'rewrite' => array( 'slug' => 'custom-css-js' ),
262
- 'capability_type' => $capability_type,
263
- 'capabilities' => $capabilities,
264
- 'has_archive' => true,
265
- 'hierarchical' => false,
266
- 'exclude_from_search' => true,
267
- 'menu_position' => null,
268
- 'can_export' => false,
269
- 'supports' => array( 'title' )
270
- );
271
-
272
- register_post_type( 'custom-css-js', $args );
273
- }
274
-
275
 
276
  public function load_plugin_textdomain() {
277
  load_plugin_textdomain( 'custom-css-js', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
@@ -286,16 +228,19 @@ endif;
286
  *
287
  * @return CustomCSSandJS
288
  */
 
289
  function CustomCSSandJS() {
290
  return CustomCSSandJS::instance();
291
  }
292
 
293
  CustomCSSandJS();
 
294
 
295
 
296
  /**
297
  * Plugin action link to Settings page
298
  */
 
299
  function custom_css_js_plugin_action_links( $links ) {
300
 
301
  $settings_link = '<a href="edit.php?post_type=custom-css-js">' .
@@ -305,6 +250,7 @@ function custom_css_js_plugin_action_links( $links ) {
305
 
306
  }
307
  add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'custom_css_js_plugin_action_links' );
 
308
 
309
 
310
 
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
10
  *
65
  * @access public
66
  */
67
  public function __construct() {
68
+
69
+ include_once( 'includes/admin-install.php' );
70
+ register_activation_hook(__FILE__, array('CustomCSSandJS_Install', 'install'));
71
+ add_action( 'init', array( 'CustomCSSandJS_Install', 'register_post_type' ) );
72
+
73
  $this->set_constants();
74
 
75
  if ( is_admin() ) {
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__,
214
  }
215
  }
216
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
 
218
  public function load_plugin_textdomain() {
219
  load_plugin_textdomain( 'custom-css-js', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
228
  *
229
  * @return CustomCSSandJS
230
  */
231
+ if ( ! function_exists('CustomCSSandJS' ) ) {
232
  function CustomCSSandJS() {
233
  return CustomCSSandJS::instance();
234
  }
235
 
236
  CustomCSSandJS();
237
+ }
238
 
239
 
240
  /**
241
  * Plugin action link to Settings page
242
  */
243
+ if ( ! function_exists('custom_css_js_plugin_action_links') ) {
244
  function custom_css_js_plugin_action_links( $links ) {
245
 
246
  $settings_link = '<a href="edit.php?post_type=custom-css-js">' .
250
 
251
  }
252
  add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'custom_css_js_plugin_action_links' );
253
+ }
254
 
255
 
256
 
includes/admin-config.php CHANGED
@@ -101,7 +101,7 @@ class CustomCSSandJS_AdminConfig {
101
  if ( $data['add_role'] !== $settings['add_role'] ) {
102
  // Add the 'css_js_designer' role
103
  if ( $data['add_role'] ) {
104
- $this->create_roles();
105
  }
106
 
107
  // Remove the 'css_js_designer' role
@@ -254,61 +254,6 @@ class CustomCSSandJS_AdminConfig {
254
  <?php
255
  }
256
 
257
-
258
- /**
259
- * Create roles and capabilities.
260
- */
261
- function create_roles() {
262
- global $wp_roles;
263
-
264
-
265
- if ( !current_user_can('update_plugins') )
266
- return;
267
-
268
- if ( ! class_exists( 'WP_Roles' ) ) {
269
- return;
270
- }
271
-
272
- if ( ! isset( $wp_roles ) ) {
273
- $wp_roles = new WP_Roles();
274
- }
275
-
276
- if ( isset($wp_roles->roles['css_js_designer']))
277
- return;
278
-
279
- // Add Web Designer role
280
- add_role( 'css_js_designer', __( 'Web Designer', 'custom-css-js'), array() );
281
-
282
- $capabilities = array();
283
-
284
- $capability_types = array( 'custom_css' );
285
-
286
- foreach ( $capability_types as $capability_type ) {
287
-
288
- $capabilities[ $capability_type ] = array(
289
- // Post type
290
- "edit_{$capability_type}",
291
- "read_{$capability_type}",
292
- "delete_{$capability_type}",
293
- "edit_{$capability_type}s",
294
- "edit_others_{$capability_type}s",
295
- "publish_{$capability_type}s",
296
- "delete_{$capability_type}s",
297
- "delete_published_{$capability_type}s",
298
- "delete_others_{$capability_type}s",
299
- "edit_published_{$capability_type}s",
300
- );
301
- }
302
-
303
- foreach ( $capabilities as $cap_group ) {
304
- foreach ( $cap_group as $cap ) {
305
- $wp_roles->add_cap( 'css_js_designer', $cap );
306
- $wp_roles->add_cap( 'administrator', $cap );
307
- }
308
- }
309
- }
310
-
311
-
312
 
313
  }
314
 
101
  if ( $data['add_role'] !== $settings['add_role'] ) {
102
  // Add the 'css_js_designer' role
103
  if ( $data['add_role'] ) {
104
+ CustomCSSandJS_Install::create_roles();
105
  }
106
 
107
  // Remove the 'css_js_designer' role
254
  <?php
255
  }
256
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
 
258
  }
259
 
includes/admin-install.php ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Custom CSS and JS
4
+ *
5
+ */
6
+
7
+ if ( ! defined( 'ABSPATH' ) ) {
8
+ exit; // Exit if accessed directly
9
+ }
10
+
11
+ /**
12
+ * CustomCSSandJS_Install
13
+ */
14
+ class CustomCSSandJS_Install {
15
+
16
+ public static function install() {
17
+ self::create_roles();
18
+ self::register_post_type();
19
+ flush_rewrite_rules();
20
+ }
21
+
22
+
23
+ /**
24
+ * Create the custom-css-js post type
25
+ */
26
+ public static function register_post_type() {
27
+ $labels = array(
28
+ 'name' => _x( 'Custom Code', 'post type general name', 'custom-css-js'),
29
+ 'singular_name' => _x( 'Custom Code', 'post type singular name', 'custom-css-js'),
30
+ 'menu_name' => _x( 'Custom CSS & JS', 'admin menu', 'custom-css-js'),
31
+ 'name_admin_bar' => _x( 'Custom Code', 'add new on admin bar', 'custom-css-js'),
32
+ 'add_new' => _x( 'Add Custom Code', 'add new', 'custom-css-js'),
33
+ 'add_new_item' => __( 'Add Custom Code', 'custom-css-js'),
34
+ 'new_item' => __( 'New Custom Code', 'custom-css-js'),
35
+ 'edit_item' => __( 'Edit Custom Code', 'custom-css-js'),
36
+ 'view_item' => __( 'View Custom Code', 'custom-css-js'),
37
+ 'all_items' => __( 'All Custom Code', 'custom-css-js'),
38
+ 'search_items' => __( 'Search Custom Code', 'custom-css-js'),
39
+ 'parent_item_colon' => __( 'Parent Custom Code:', 'custom-css-js'),
40
+ 'not_found' => __( 'No Custom Code found.', 'custom-css-js'),
41
+ 'not_found_in_trash' => __( 'No Custom Code found in Trash.', 'custom-css-js')
42
+ );
43
+
44
+ $capability_type = 'custom_css';
45
+ $capabilities = array(
46
+ 'edit_post' => "edit_{$capability_type}",
47
+ 'read_post' => "read_{$capability_type}",
48
+ 'delete_post' => "delete_{$capability_type}",
49
+ 'edit_posts' => "edit_{$capability_type}s",
50
+ 'edit_others_posts' => "edit_others_{$capability_type}s",
51
+ 'publish_posts' => "publish_{$capability_type}s",
52
+ 'read' => "read",
53
+ 'delete_posts' => "delete_{$capability_type}s",
54
+ 'delete_published_posts' => "delete_published_{$capability_type}s",
55
+ 'delete_others_posts' => "delete_others_{$capability_type}s",
56
+ 'edit_published_posts' => "edit_published_{$capability_type}s",
57
+ 'create_posts' => "edit_{$capability_type}s",
58
+ );
59
+
60
+ $args = array(
61
+ 'labels' => $labels,
62
+ 'description' => __( 'Custom CSS and JS code', 'custom-css-js' ),
63
+ 'public' => false,
64
+ 'publicly_queryable' => false,
65
+ 'show_ui' => true,
66
+ 'show_in_menu' => true,
67
+ 'menu_position' => 100,
68
+ 'menu_icon' => 'dashicons-plus-alt',
69
+ 'query_var' => false,
70
+ 'rewrite' => array( 'slug' => 'custom-css-js' ),
71
+ 'capability_type' => $capability_type,
72
+ 'capabilities' => $capabilities,
73
+ 'has_archive' => true,
74
+ 'hierarchical' => false,
75
+ 'exclude_from_search' => true,
76
+ 'menu_position' => null,
77
+ 'can_export' => false,
78
+ 'supports' => array( 'title' )
79
+ );
80
+
81
+ register_post_type( 'custom-css-js', $args );
82
+ }
83
+
84
+
85
+ /**
86
+ * Create roles and capabilities.
87
+ */
88
+ public static function create_roles() {
89
+ global $wp_roles;
90
+
91
+
92
+ if ( !current_user_can('update_plugins') )
93
+ return;
94
+
95
+ if ( ! class_exists( 'WP_Roles' ) ) {
96
+ return;
97
+ }
98
+
99
+ if ( ! isset( $wp_roles ) ) {
100
+ $wp_roles = new WP_Roles();
101
+ }
102
+
103
+ if ( isset($wp_roles->roles['css_js_designer']))
104
+ return;
105
+
106
+ // Add Web Designer role
107
+ add_role( 'css_js_designer', __( 'Web Designer', 'custom-css-js'), array() );
108
+
109
+ $capabilities = array();
110
+
111
+ $capability_types = array( 'custom_css' );
112
+
113
+ foreach ( $capability_types as $capability_type ) {
114
+
115
+ $capabilities[ $capability_type ] = array(
116
+ // Post type
117
+ "edit_{$capability_type}",
118
+ "read_{$capability_type}",
119
+ "delete_{$capability_type}",
120
+ "edit_{$capability_type}s",
121
+ "edit_others_{$capability_type}s",
122
+ "publish_{$capability_type}s",
123
+ "delete_{$capability_type}s",
124
+ "delete_published_{$capability_type}s",
125
+ "delete_others_{$capability_type}s",
126
+ "edit_published_{$capability_type}s",
127
+ );
128
+ }
129
+
130
+ foreach ( $capabilities as $cap_group ) {
131
+ foreach ( $cap_group as $cap ) {
132
+ $wp_roles->add_cap( 'css_js_designer', $cap );
133
+ $wp_roles->add_cap( 'administrator', $cap );
134
+ }
135
+ }
136
+ }
137
+
138
+
139
+
140
+
141
+ }
142
+
143
+ ?>
includes/admin-screens.php CHANGED
@@ -284,7 +284,7 @@ class CustomCSSandJS_Admin {
284
  'type' => __('Type', 'custom-css-js'),
285
  'title' => __('Title', 'custom-css-js'),
286
  'author' => __('Author', 'custom-css-js'),
287
- 'date' => __('Date', 'custom-css-js'),
288
  'modified' => __('Modified', 'custom-css-js'),
289
  );
290
  }
@@ -300,13 +300,13 @@ class CustomCSSandJS_Admin {
300
  echo '<span class="language language-'.$options['language'].'">' . $options['language'] . '</span>';
301
  }
302
 
303
- if ( $column == 'modified' ) {
304
  if ( $column == 'modified' ) {
305
- $f_time = get_the_modified_time( __('Y/m/d g:i:s a'), $post_id );
306
- $g_time = get_the_modified_time( 'G', $post_id );
307
  } else {
308
- $f_time = get_the_time( __('Y/m/d g:i:s a' ) );
309
- $g_time = get_the_time( 'G' );
310
  }
311
 
312
  $time_diff = time() - $g_time;
@@ -341,6 +341,7 @@ class CustomCSSandJS_Admin {
341
  */
342
  function manage_edit_posts_sortable_columns( $columns ) {
343
  $columns['modified'] = 'modified';
 
344
  return $columns;
345
 
346
  }
284
  'type' => __('Type', 'custom-css-js'),
285
  'title' => __('Title', 'custom-css-js'),
286
  'author' => __('Author', 'custom-css-js'),
287
+ 'published' => __('Published', 'custom-css-js'),
288
  'modified' => __('Modified', 'custom-css-js'),
289
  );
290
  }
300
  echo '<span class="language language-'.$options['language'].'">' . $options['language'] . '</span>';
301
  }
302
 
303
+ if ( $column == 'modified' || $column == 'published' ) {
304
  if ( $column == 'modified' ) {
305
+ $f_time = get_post_modified_time( __('Y/m/d g:i:s a'), true, $post_id );
306
+ $g_time = get_post_modified_time( 'G', true, $post_id );
307
  } else {
308
+ $f_time = get_post_time( __('Y/m/d g:i:s a' ), true );
309
+ $g_time = get_post_time( 'G', true );
310
  }
311
 
312
  $time_diff = time() - $g_time;
341
  */
342
  function manage_edit_posts_sortable_columns( $columns ) {
343
  $columns['modified'] = 'modified';
344
+ $columns['published'] = 'published';
345
  return $columns;
346
 
347
  }
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.16
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
11
 
@@ -93,7 +93,7 @@ Yes. You can upload an image to your Media Library, then refer to it by its dire
93
  Yes.
94
 
95
  = Who can publish/edit/delete Custom Codes? =
96
- By default only the Administrator will be able to publish/edit/delete Custom Codes. Check out [this article](https://www.silkypress.com/simple_custom_css_js/user-capabilities-simple-custom-css-js-plugin/) for more details on roles and user capabilities customizations.
97
 
98
  = Compatibility with qTranslate X plugin =
99
  * If the [qTranslate X](https://wordpress.org/plugins/qtranslate-x/) plugin is adding some `[:]` or `[:en]` characters to your code, then you need to remove the `custom-css-js` post type from the qTranslate settings. Check out [this screenshot](https://www.silkypress.com/wp-content/uploads/2016/08/ccj_qtranslate_compatibility.png) on how to do that.
@@ -114,6 +114,10 @@ $. Add/Edit HTML
114
 
115
  == Changelog ==
116
 
 
 
 
 
117
  = 3.16 =
118
  * 04/22/2018
119
  * Fix: "The link you followed has expired" on custom code save if the WP Quads Pro plugin is active
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
 
93
  Yes.
94
 
95
  = Who can publish/edit/delete Custom Codes? =
96
+ By default only the Administrator will be able to publish/edit/delete Custom Codes. On the plugin activation there is a role created called Web Designer. You can assign this role to a non-admin user in order to allow to publish/edit/delete Custom Codes. On the plugin's Settings page there is an option to remove this role.
97
 
98
  = Compatibility with qTranslate X plugin =
99
  * If the [qTranslate X](https://wordpress.org/plugins/qtranslate-x/) plugin is adding some `[:]` or `[:en]` characters to your code, then you need to remove the `custom-css-js` post type from the qTranslate settings. Check out [this screenshot](https://www.silkypress.com/wp-content/uploads/2016/08/ccj_qtranslate_compatibility.png) on how to do that.
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
120
+
121
  = 3.16 =
122
  * 04/22/2018
123
  * Fix: "The link you followed has expired" on custom code save if the WP Quads Pro plugin is active