Simple Custom CSS and JS - Version 1.6

Version Description

  • 04/26/2016
  • Fix: the number of codes were limited because query_posts is automatically inserting a limit
Download this release

Release Info

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

Code changes from version 2.10 to 1.6

assets/ccj_admin-url_rules.js DELETED
@@ -1,294 +0,0 @@
1
-
2
- if (!String.prototype.trim) {(function() {
3
- var r = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
4
- String.prototype.trim = function() {
5
- return this.replace(r, '');
6
- };
7
- })();};
8
-
9
- if (!String.prototype.esc_html) {(function() {
10
- var r = /[&<>"'\/]/g;
11
- var entity_map = {'&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;', '/': '&#x2F;'};
12
- String.prototype.esc_html = function() {
13
- return this.replace(r, function from_entity_map(s) {
14
- return entity_map[s];
15
- });
16
- };
17
- })();};
18
-
19
- if (!String.prototype.capitalize) {
20
- String.prototype.capitalize = function() {
21
- return this.charAt(0).toUpperCase() + this.slice(1);
22
- }
23
- };
24
-
25
-
26
-
27
- ;jQuery(document).ready(function($) {
28
-
29
-
30
-
31
- var elist_index = {};
32
-
33
-
34
-
35
- function elist_arrange(names) {
36
-
37
- var rq = /\%quot\%/g;
38
- var n, name, field, editable, f;
39
- var filters = {
40
- 'contains' : 'Contains',
41
- 'not-contains' : 'Not contains',
42
- 'equal-to' : 'Is equal to',
43
- 'not-equal-to' : 'Not equal to',
44
- 'begins-with' : 'Starts with',
45
- 'ends-by' : 'Ends by',
46
- 'all' : 'All Website',
47
- 'first-page' : 'First page'
48
- };
49
-
50
- for (n in names) {
51
-
52
- name = names[n];
53
- field = $('#wplnst-scan-' + name).val();
54
- field = ('' === field)? [] : JSON.parse(field);
55
- if (!(field instanceof Array) || 0 == field.length)
56
- continue;
57
-
58
- elist_index[name] = field.length;
59
- editable = ('true' == $('#wplnst-elist-' + name).attr('data-editable'));
60
-
61
- if ('anchor-filters' == name) {
62
- for (f in field)
63
- elist_add_row(name, elist_get_row(name, {'value' : field[f]['value'].esc_html().replace(rq, '&quot;'), 'type' : filters[ field[f]['type']].esc_html().replace('-', ' ')}, editable), field[f]['index']);
64
-
65
- }
66
- }
67
- }
68
-
69
-
70
-
71
- function elist_add(name, value, inputs, row) {
72
-
73
- var field = $('#wplnst-scan-' + name).val();
74
- field = ('' === field)? [] : JSON.parse(field);
75
- if (!(field instanceof Array) || field.length > 25)
76
- return;
77
-
78
- (name in elist_index)? elist_index[name]++ : elist_index[name] = 0;
79
- value['index'] = elist_index[name] + 1;
80
- field.push(value);
81
-
82
- $('#wplnst-scan-' + name).val(JSON.stringify(field));
83
-
84
- for (var i = 0; i < inputs.length; i++)
85
- $('#' + inputs[i]).val('');
86
-
87
- elist_add_row(name, row, value['index']);
88
- }
89
-
90
-
91
-
92
- function elist_add_row(name, row, index) {
93
- row = row.replace(/\%class\-index\%/g, 'wplnst-' + name + '-' + index);
94
- row = row.replace('%close%', '<a href="#" class="wplnst-elist-close-link" data-name = "' + name + '" data-index="' + index + '">&nbsp;</a>');
95
- $('#' + 'wplnst-elist-' + name).append(row);
96
- $('#' + 'wplnst-elist-' + name).show();
97
- }
98
-
99
-
100
-
101
- function elist_get_row(name, args, editable) {
102
-
103
- if ('anchor-filters' == name)
104
- return '<tr class="%class-index%"><td class="wplnst-elist-type wplnst-afs-type">' + $('#wplnst-elist-anchor-filters').attr('data-label') + '&nbsp; <strong>' + args['type'] + '</strong></td><td class="wplnst-elist-val wplnst-afs-val">' + args['value'] + '</td><td class="wplnst-elist-close wplnst-afs-close">' + (editable? '%close%' : '') + '</td></tr><tr class="%class-index%"><td colspan="3" class="wplnst-elist-split"></td></tr>';
105
-
106
- return false;
107
- }
108
-
109
-
110
- $('.wplnst-elist').on('click', '.wplnst-elist-close-link', function() {
111
-
112
- var name = $(this).attr('data-name');
113
- var index = $(this).attr('data-index');
114
-
115
- var field = $('#wplnst-scan-' + name).val();
116
- if ('' !== field) {
117
-
118
- field = JSON.parse(field);
119
- if (field instanceof Array) {
120
-
121
- var field_new = [];
122
- for (var i = 0; i < field.length; i++) {
123
- if (index != field[i]['index'])
124
- field_new.push(field[i]);
125
- }
126
-
127
- $('#wplnst-scan-' + name).val(JSON.stringify(field_new));
128
- $('.wplnst-' + name + '-' + index).remove();
129
-
130
- if (0 === field_new.length)
131
- $('#' + 'wplnst-elist-' + name).hide();
132
- }
133
- }
134
-
135
- return false;
136
- });
137
-
138
-
139
-
140
- $('.wplnst-status-level').click(function() {
141
- var level = $(this).attr('id').replace('ck-status-level-', '');
142
- $('.wplnst-code-level-' + level).prop('checked', false);
143
- });
144
-
145
- $('.wplnst-code-level').click(function() {
146
- var level = $(this).attr('id').replace('ck-status-code-', '').charAt(0);
147
- $('#ck-status-level-' + level).prop('checked', false);
148
- });
149
-
150
-
151
-
152
- $('#wplnst-save-and-run').click(function() {
153
- $('#wplnst-scan-run').val('1');
154
- $('#wplnst-form').submit();
155
- });
156
-
157
-
158
-
159
- $('#wplnst-cf-new-add').click(function() {
160
- var name = $('#wplnst-cf-new').val().trim();
161
- if ('' === name)
162
- return;
163
- elist_add('custom-fields', {'name' : name, 'type': $('#wplnst-cf-new-type').val()}, ['wplnst-cf-new'], elist_get_row('custom-fields', {'name' : name.esc_html(), 'type' : $('#wplnst-cf-new-type option:selected').text().esc_html()}, true));
164
- });
165
-
166
- $('#wplnst-cf-new').bind('keypress', function(e) {
167
- if (e.keyCode == 13) {
168
- $('#wplnst-cf-new-add').click();
169
- return false;
170
- }
171
- });
172
-
173
-
174
-
175
- $('#wplnst-af-new-add').click(function() {
176
- var value = $('#wplnst-af-new').val().trim();
177
- var type = $('#wplnst-af-new-type').val();
178
-
179
- if ( type === 'empty' || type === 'all' || type === 'first-page' ) {
180
- value = '';
181
- } else if ( value === '' ) {
182
- return;
183
- }
184
- elist_add('anchor-filters', {'value' : value, 'type': type}, ['wplnst-af-new'], elist_get_row('anchor-filters', {'type' : $('#wplnst-af-new-type option:selected').text().esc_html(), 'value' : value.esc_html() }, true));
185
- });
186
-
187
- $('#wplnst-af-new').bind('keypress', function(e) {
188
- if (e.keyCode == 13) {
189
- $('#wplnst-af-new-add').click();
190
- return false;
191
- }
192
- });
193
-
194
- $('#wplnst-af-new-type').change(function() {
195
- var disabled = ('empty' == $(this).val());
196
- $('#wplnst-af-new').attr('disabled', disabled);
197
- });
198
-
199
-
200
-
201
- $('#wplnst-ius-new-add').click(function() {
202
- var value = $('#wplnst-ius-new').val().trim();
203
- if ('' === value)
204
- return;
205
- elist_add('include-urls', {'value' : value, 'type': $('#wplnst-ius-new-type').val()}, ['wplnst-ius-new'], elist_get_row('include-urls', {'value' : value.esc_html(), 'type' : $('#wplnst-ius-new-type option:selected').text().esc_html()}, true));
206
- });
207
-
208
- $('#wplnst-ius-new').bind('keypress', function(e) {
209
- if (e.keyCode == 13) {
210
- $('#wplnst-ius-new-add').click();
211
- return false;
212
- }
213
- });
214
-
215
-
216
-
217
- $('#wplnst-eus-new-add').click(function() {
218
- var value = $('#wplnst-eus-new').val().trim();
219
- if ('' === value)
220
- return;
221
- elist_add('exclude-urls', {'value' : value, 'type': $('#wplnst-eus-new-type').val()}, ['wplnst-eus-new'], elist_get_row('exclude-urls', {'value' : value.esc_html(), 'type' : $('#wplnst-eus-new-type option:selected').text().esc_html()}, true));
222
- });
223
-
224
- $('#wplnst-eus-new').bind('keypress', function(e) {
225
- if (e.keyCode == 13) {
226
- $('#wplnst-eus-new-add').click();
227
- return false;
228
- }
229
- });
230
-
231
-
232
-
233
- $('#wplnst-hes-new-add').click(function() {
234
-
235
- var att = $('#wplnst-hes-new-att').val().trim();
236
- if ('' === att)
237
- return;
238
-
239
- var element = $('#wplnst-hes-new').val();
240
- var having = $('#wplnst-hes-new-have').val();
241
-
242
- var op = op_text = value = '';
243
- if ('have' == having) {
244
-
245
- var op = $('#wplnst-hes-new-op').val();
246
- var op_text = $('#wplnst-hes-new-op option:selected').text().toLowerCase();
247
- var value = '' + $('#wplnst-hes-new-val').val().trim();
248
-
249
- if ('not-empty' == op || 'empty' == op) {
250
- value = '';
251
- } else if ('' === value) {
252
- return;
253
- }
254
- }
255
-
256
- elist_add(
257
- 'html-attributes',
258
- {'att' : att, 'element' : element, 'having' : having, 'op' : op, 'value' : value},
259
- ['wplnst-hes-new-att', 'wplnst-hes-new-val'],
260
- elist_get_row('html-attributes', {'element' : element.esc_html(), 'having' : $('#wplnst-hes-new-have option:selected').text().toLowerCase().esc_html(), 'att' : att.esc_html(), 'op' : op_text.esc_html(), 'value' : value.esc_html()}, true)
261
- );
262
- });
263
-
264
- $('#wplnst-hes-new-att').bind('keypress', function(e) {
265
- if (e.keyCode == 13) {
266
- $('#wplnst-hes-new-add').click();
267
- return false;
268
- }
269
- });
270
-
271
- $('#wplnst-hes-new-val').bind('keypress', function(e) {
272
- if (e.keyCode == 13) {
273
- $('#wplnst-hes-new-add').click();
274
- return false;
275
- }
276
- });
277
-
278
- $('#wplnst-hes-new-have').change(function() {
279
- var disabled = ('have' != $(this).val());
280
- $('#wplnst-hes-new-op').attr('disabled', disabled);
281
- $('#wplnst-hes-new-val').attr('disabled', disabled);
282
- });
283
-
284
- $('#wplnst-hes-new-op').change(function() {
285
- $('#wplnst-hes-new-val').attr('disabled', ('empty' == $(this).val() || 'not-empty' == $(this).val()));
286
- });
287
-
288
-
289
-
290
- elist_arrange(['anchor-filters']);
291
-
292
-
293
-
294
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/ccj_admin.css DELETED
@@ -1,379 +0,0 @@
1
- /**
2
- * Add Custom Code buttons
3
- */
4
- .updated.buttons {
5
- border: none;
6
- background-color: transparent;
7
- box-shadow: none;
8
- padding: 0;
9
- margin: 15px 0 15px !important;
10
- }
11
- .custom-btn {
12
- background: #0c73b8;
13
- border-radius: 2px;
14
- color: #ffffff;
15
- font-size: 17px;
16
- padding: 10px 20px 10px 20px !important;
17
- text-decoration: none;
18
- }
19
- .custom-btn:hover {
20
- color: #fff;
21
- background: #2eaadd;
22
- text-decoration: none;
23
- }
24
- .custom-js-btn { background: #e4a228; }
25
- .custom-js-btn:hover { background: #eebf31; }
26
- .custom-php-btn { background: #e45126; }
27
- .custom-php-btn:hover { background: #f6652c; }
28
-
29
- .update.notice a { display: none; }
30
-
31
-
32
- /**
33
- * Change the `edit` screen
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;
41
- border-radius: 2px;
42
- color: #ffffff;
43
- font-size: 12px;
44
- padding: 5px 10px !important;
45
- text-decoration: none;
46
- }
47
- .language-js { background: #e4a228; }
48
- .language-php { background: #e45126; }
49
- .language-html { background: #e45126; }
50
- .widefat td, .widefat th, .type.column-type, .check-column, .column-active { vertical-align: middle !important; }
51
- .type.column-type {
52
- text-align: center;
53
- }
54
- .column-options span { margin-left: 7px; }
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
-
59
-
60
- /**
61
- * Code Mirror editor
62
- */
63
- #content {
64
- width: 100%;
65
- padding-left: 36px;
66
- border-top: 0;
67
- border-bottom: 0;
68
- }
69
-
70
- #minor-publishing { display: none; }
71
- #post-body #normal-sortables { min-height: 0px; }
72
- .CodeMirror {
73
- margin-top: 0px;
74
- border: 1px solid #ddd;
75
- border-bottom: none;
76
- border-top: none;
77
- }
78
- .CodeMirror pre { padding-left: 7px; line-height: 1.25; }
79
-
80
- .code-mirror-buttons {
81
- margin-top: 15px;
82
- width: calc(100% - 2px);
83
- background: #f7f7f7;
84
- border: 1px solid #ddd;
85
- border-bottom: none;
86
- height: 36px;
87
- }
88
- .code-mirror-buttons .button-right {
89
- display: block;
90
- float: right;
91
- }
92
- .code-mirror-buttons button {
93
- padding: 2px 3px;
94
- line-height: normal;
95
- font-size: 14px;
96
- cursor: pointer;
97
- color: #333;
98
- text-align: center;
99
- overflow: visible;
100
- margin: 6px 4px;
101
- border: none;
102
- background-color: transparent;
103
- border: 1px solid transparent;
104
- }
105
- .code-mirror-buttons button:hover, .code-mirror-buttons button:focus {
106
- color: #333;
107
- background-color: #e3e3e3;
108
- border: 1px solid #ccc;
109
- border-radius: 1px;
110
- }
111
- .code-mirror-buttons button i {
112
- font: 400 20px/1 dashicons;
113
- vertical-align: middle;
114
- speak: none;
115
- color: #777;
116
- line-height: 20px;
117
- width: 20px;
118
- height: 20px;
119
- }
120
- i.ccj-i-fullscreen:before {
121
- content: "\f211";
122
- }
123
-
124
- .code-mirror-before {
125
- border: 1px solid #ddd;
126
- border-bottom: none;
127
- background-color: #f7f7f7;
128
- margin-top: 24px;
129
- }
130
- .code-mirror-before div {
131
- color: #8F8F8F;
132
- margin-left: 29px;
133
- border-left: 1px solid #ddd;
134
- padding: 3px 8px;
135
- background-color: #fff;
136
- }
137
-
138
- .code-mirror-after {
139
- border: 1px solid #ddd;
140
- border-top: none;
141
- background-color: #f7f7f7;
142
- }
143
- .code-mirror-after div {
144
- color: #8F8F8F;
145
- margin-left: 29px;
146
- border-left: 1px solid #ddd;
147
- padding: 3px 8px;
148
- background-color: #fff;
149
- }
150
- /*
151
- .cm-s-default .cm-atom { color: #549d18; }
152
- .cm-s-default .cm-property { color: #b62625; }
153
- .cm-s-default .cm-qualifier, .cm-s-default .cm-tag { color: #4731E4; }
154
- */
155
-
156
-
157
- /**
158
- * Options meta box
159
- */
160
- .radio-group input { margin-top: 1px; }
161
- .radio-group label { padding: 2px 0; }
162
- .options_meta_box h3 { margin-top: 10px !important; }
163
- .radio-group { line-height: 30px; padding-left: 10px; }
164
- .radio-group .dashicons-before:before { margin: 7px 3px 0 3px; }
165
- .options_meta_box select { margin-left: 10px; }
166
- #custom-code-options .options_meta_box select {
167
- margin-left: 0px;
168
- width: 100%;
169
- }
170
-
171
-
172
-
173
- /**
174
- * Revisions
175
- */
176
- table.revisions {
177
- width: 100%;
178
- max-width: 100%;
179
- background-color: transparent;
180
- border-spacing: 0;
181
- border-collapse: collapse;
182
- border-color: gray;
183
- }
184
- table.revisions thead, table.revisions tbody {
185
- vertical-align: middle;
186
- }
187
- table.revisions tbody tr:hover {
188
- background-color: #f7f7f9;
189
- }
190
- table.revisions thead th {
191
- white-space: nowrap;
192
- text-align: left;
193
- padding: 8px;
194
- line-height: 1.42857143;
195
- vertical-align: bottom;
196
- border-bottom: 2px solid #ddd;
197
- }
198
- table.revisions tbody td {
199
- padding: 8px;
200
- line-height: 1.42857143;
201
- vertical-align: top;
202
- border-top: 1px solid #ddd;
203
- }
204
- tr.current-revision {
205
- background-color: #00ff00;
206
- }
207
- td.revisions-compare, td.revisions-restore, td.revisions-delete {
208
- width: 36px;
209
- }
210
- td.revisions-compare, th.revisions-compare {
211
- text-align: center !important;
212
- }
213
- table.revisions a {
214
- text-decoration: none;
215
- }
216
- table.revisions a:hover {
217
- text-decoration: underline;
218
- }
219
- table.revisions .hidden {
220
- visibility: hidden;
221
- }
222
- div#TB_window {
223
- width: 90% !important;
224
- margin-left: -45% !important;
225
- height: 90% !important;
226
- margin-top: -22% !important;
227
- }
228
- div#TB_window .error {
229
- padding: 15px;
230
- margin-bottom: 20px;
231
- border: 1px solid transparent;
232
- border-radius: 4px;
233
- color: #a94442;
234
- background-color: #f2dede;
235
- border-color: #ebccd1;
236
- }
237
- iframe#TB_iframeContent {
238
- width: 100% !important;
239
- height: 100% !important;
240
- }
241
- #url-rules textarea {
242
- width: 100%;
243
- height: 200px;
244
- }
245
-
246
-
247
- /* URL Rules */
248
- .wplnst-elist-visible { display: block; }
249
- .wplnst-elist-readonly { margin: 0; }
250
-
251
- .wplnst-elist tr {
252
- margin-bottom: 10px;
253
- }
254
-
255
- .wplnst-elist tr td {
256
- margin: 0; padding: 4px 5px;
257
- }
258
-
259
- .wplnst-elist tr td.wplnst-elist-val {
260
- color: #5c5a5a;
261
- background: rgba(0,115,170,0.6);
262
- }
263
-
264
- #wplnst-af-new { width: 361px; }
265
- #wplnst-ius-new { width: 425px; }
266
- #wplnst-eus-new { width: 425px; }
267
-
268
- .wplnst-elist tr td.wplnst-cfs-val { width: 205px; }
269
- .wplnst-elist tr td.wplnst-afs-val { width: 350px; }
270
- .wplnst-elist tr td.wplnst-ius-val { width: 415px; }
271
- .wplnst-elist tr td.wplnst-eus-val { width: 415px; }
272
-
273
- .wplnst-elist tr td.wplnst-elist-type {
274
- color: #6f6f6f;
275
- }
276
-
277
- .wplnst-elist tr td.wplnst-cfs-type { width: 53px; padding-left: 12px; }
278
- .wplnst-elist tr td.wplnst-afs-type { width: 200px; padding-left: 0; }
279
- .wplnst-elist tr td.wplnst-ius-type { width: 121px; padding-left: 14px; }
280
- .wplnst-elist tr td.wplnst-eus-type { width: 121px; padding-left: 14px; }
281
-
282
- .wplnst-elist tr td.wplnst-hes-ele { width: 55px; font-weight: bold; }
283
- .wplnst-elist tr td.wplnst-hes-have { width: 87px; font-weight: bold; }
284
- .wplnst-elist tr td.wplnst-hes-att { width: 125px; }
285
- .wplnst-elist tr td.wplnst-hes-op { width: 112px; padding-left: 15px; font-weight: bold; }
286
- .wplnst-elist tr td.wplnst-hes-val { width: 126px; }
287
-
288
- .wplnst-elist tr td.wplnst-elist-close {
289
- padding-left: 21px;
290
- }
291
-
292
- .wplnst-elist tr td.wplnst-elist-close .wplnst-elist-close-link {
293
- display: block;
294
- width: 16px; height: 16px;
295
- outline: none; border: 0;
296
- text-indent: -9999px;
297
- background: url(images/button-close.png) left top no-repeat;
298
- }
299
-
300
- .wplnst-elist tr td.wplnst-elist-close .wplnst-elist-close-link:hover {
301
- background: url(images/button-close-hover.png) left top no-repeat;
302
- }
303
-
304
- .wplnst-elist tr td.wplnst-elist-split {
305
- height: 3px;
306
- }
307
-
308
-
309
-
310
- #ccj-preview_url {
311
- width: 78%;
312
- }
313
- #ccj-preview {
314
- width: 20%;
315
- text-align: center;
316
- }
317
-
318
- /**
319
- * Settings page
320
- */
321
- #ccj_duration_preview, #ccj_editor_theme {
322
- width: 220px;
323
- }
324
- .custom-css-js_page_custom-css-js-config .CodeMirror {
325
- height: 200px;
326
- }
327
- .role-permissions, .role-permissions2 {
328
- width: 100%;
329
- }
330
- .role-permissions td, .role-permissions th, .role-permissions2 td {
331
- padding: 6px;
332
- text-align: center;
333
- }
334
- .role-permissions td.desc, .role-permissions2 td.desc {
335
- width: 35%;
336
- text-align: right;
337
- padding-right: 20px;
338
- }
339
- .role-permissions2 td {
340
- text-align: left;
341
- }
342
- .custom-css-js_page_custom-css-js-config .dashicons-editor-help {
343
- color: #999;
344
- }
345
-
346
- /**
347
- * Overlay
348
- */
349
- #normal-sortables, .ccj_opaque {
350
- opacity: 0.4;
351
- }
352
- .ccj_only_premium {
353
- z-index:9999;
354
- width: 160px;
355
- height: 60px;
356
- position: absolute;
357
- margin-left: 254px;
358
- color: white;
359
- }
360
- .ccj_only_premium>div {
361
- font-family:sans-serif;font-size:13px;text-align: center; border-radius: 5px; float: left; background-color: rgb(51, 51, 51); color: white; width: 207px; padding: 20px 20px;
362
- }
363
- .ccj_only_premium a {
364
- color: white; text-decoration: none;
365
- transition: color 0.3s;
366
- }
367
- .ccj_only_premium a:hover {
368
- color: #0073aa; text-decoration: none;
369
- }
370
- .ccj_only_premium-right {
371
- width: 80px;
372
- margin-left: 130px;
373
- margin-top: -120px;
374
- }
375
- .ccj_only_premium-right>div {
376
- width: 200px;
377
- padding: 10px;
378
- margin-left: -110px;
379
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/ccj_admin.js DELETED
@@ -1,60 +0,0 @@
1
- jQuery(document).ready( function($) {
2
-
3
- $('.page-title-action').hide();
4
-
5
- // Initialize the CodeMirror editor
6
- if ( $('#content').length > 0 ) {
7
- var content_mode = $("#content").attr('mode');
8
- if ( content_mode == 'html' ) {
9
- var content_mode = {
10
- name: "htmlmixed",
11
- scriptTypes: [{matches: /\/x-handlebars-template|\/x-mustache/i,
12
- mode: null}]
13
- };
14
- }
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";
22
- }
23
-
24
-
25
- var cm_width = $('#title').width() + 16;
26
- var cm_height = 500;
27
-
28
- var editor = CodeMirror.fromTextArea(document.getElementById("content"), options);
29
-
30
- editor.setSize(cm_width, cm_height);
31
-
32
- $('.CodeMirror').resizable({
33
- resize: function() {
34
- editor.setSize($(this).width(), $(this).height());
35
- } ,
36
- maxWidth: cm_width,
37
- minWidth: cm_width,
38
- minHeight: 200
39
-
40
- });
41
-
42
- $(window).resize(function () {
43
- var cm_width = $('#title').width() + 16;
44
- var cm_height = $('.CodeMirror').height();
45
- editor.setSize(cm_width, cm_height);
46
- });
47
-
48
-
49
-
50
- }
51
-
52
- // Make the inactive rows opaque
53
- if ( $('.dashicons-star-empty.ccj_row').length > 0 ) {
54
- $('.dashicons-star-empty.ccj_row').each(function(){
55
- $(this).parent().parent().parent().css('opacity', '0.4');
56
- });
57
- }
58
-
59
- });
60
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/codemirror/addon/dialog.css DELETED
@@ -1,32 +0,0 @@
1
- .CodeMirror-dialog {
2
- position: absolute;
3
- left: 0; right: 0;
4
- background: inherit;
5
- z-index: 15;
6
- padding: .1em .8em;
7
- overflow: hidden;
8
- color: inherit;
9
- }
10
-
11
- .CodeMirror-dialog-top {
12
- border-bottom: 1px solid #eee;
13
- top: 0;
14
- }
15
-
16
- .CodeMirror-dialog-bottom {
17
- border-top: 1px solid #eee;
18
- bottom: 0;
19
- }
20
-
21
- .CodeMirror-dialog input {
22
- border: none;
23
- outline: none;
24
- background: transparent;
25
- width: 20em;
26
- color: inherit;
27
- font-family: monospace;
28
- }
29
-
30
- .CodeMirror-dialog button {
31
- font-size: 70%;
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/codemirror/addon/dialog.js DELETED
@@ -1,157 +0,0 @@
1
- // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
- // Distributed under an MIT license: http://codemirror.net/LICENSE
3
-
4
- // Open simple dialogs on top of an editor. Relies on dialog.css.
5
-
6
- (function(mod) {
7
- if (typeof exports == "object" && typeof module == "object") // CommonJS
8
- mod(require("../../lib/codemirror"));
9
- else if (typeof define == "function" && define.amd) // AMD
10
- define(["../../lib/codemirror"], mod);
11
- else // Plain browser env
12
- mod(CodeMirror);
13
- })(function(CodeMirror) {
14
- function dialogDiv(cm, template, bottom) {
15
- var wrap = cm.getWrapperElement();
16
- var dialog;
17
- dialog = wrap.appendChild(document.createElement("div"));
18
- if (bottom)
19
- dialog.className = "CodeMirror-dialog CodeMirror-dialog-bottom";
20
- else
21
- dialog.className = "CodeMirror-dialog CodeMirror-dialog-top";
22
-
23
- if (typeof template == "string") {
24
- dialog.innerHTML = template;
25
- } else { // Assuming it's a detached DOM element.
26
- dialog.appendChild(template);
27
- }
28
- return dialog;
29
- }
30
-
31
- function closeNotification(cm, newVal) {
32
- if (cm.state.currentNotificationClose)
33
- cm.state.currentNotificationClose();
34
- cm.state.currentNotificationClose = newVal;
35
- }
36
-
37
- CodeMirror.defineExtension("openDialog", function(template, callback, options) {
38
- if (!options) options = {};
39
-
40
- closeNotification(this, null);
41
-
42
- var dialog = dialogDiv(this, template, options.bottom);
43
- var closed = false, me = this;
44
- function close(newVal) {
45
- if (typeof newVal == 'string') {
46
- inp.value = newVal;
47
- } else {
48
- if (closed) return;
49
- closed = true;
50
- dialog.parentNode.removeChild(dialog);
51
- me.focus();
52
-
53
- if (options.onClose) options.onClose(dialog);
54
- }
55
- }
56
-
57
- var inp = dialog.getElementsByTagName("input")[0], button;
58
- if (inp) {
59
- inp.focus();
60
-
61
- if (options.value) {
62
- inp.value = options.value;
63
- if (options.selectValueOnOpen !== false) {
64
- inp.select();
65
- }
66
- }
67
-
68
- if (options.onInput)
69
- CodeMirror.on(inp, "input", function(e) { options.onInput(e, inp.value, close);});
70
- if (options.onKeyUp)
71
- CodeMirror.on(inp, "keyup", function(e) {options.onKeyUp(e, inp.value, close);});
72
-
73
- CodeMirror.on(inp, "keydown", function(e) {
74
- if (options && options.onKeyDown && options.onKeyDown(e, inp.value, close)) { return; }
75
- if (e.keyCode == 27 || (options.closeOnEnter !== false && e.keyCode == 13)) {
76
- inp.blur();
77
- CodeMirror.e_stop(e);
78
- close();
79
- }
80
- if (e.keyCode == 13) callback(inp.value, e);
81
- });
82
-
83
- if (options.closeOnBlur !== false) CodeMirror.on(inp, "blur", close);
84
- } else if (button = dialog.getElementsByTagName("button")[0]) {
85
- CodeMirror.on(button, "click", function() {
86
- close();
87
- me.focus();
88
- });
89
-
90
- if (options.closeOnBlur !== false) CodeMirror.on(button, "blur", close);
91
-
92
- button.focus();
93
- }
94
- return close;
95
- });
96
-
97
- CodeMirror.defineExtension("openConfirm", function(template, callbacks, options) {
98
- closeNotification(this, null);
99
- var dialog = dialogDiv(this, template, options && options.bottom);
100
- var buttons = dialog.getElementsByTagName("button");
101
- var closed = false, me = this, blurring = 1;
102
- function close() {
103
- if (closed) return;
104
- closed = true;
105
- dialog.parentNode.removeChild(dialog);
106
- me.focus();
107
- }
108
- buttons[0].focus();
109
- for (var i = 0; i < buttons.length; ++i) {
110
- var b = buttons[i];
111
- (function(callback) {
112
- CodeMirror.on(b, "click", function(e) {
113
- CodeMirror.e_preventDefault(e);
114
- close();
115
- if (callback) callback(me);
116
- });
117
- })(callbacks[i]);
118
- CodeMirror.on(b, "blur", function() {
119
- --blurring;
120
- setTimeout(function() { if (blurring <= 0) close(); }, 200);
121
- });
122
- CodeMirror.on(b, "focus", function() { ++blurring; });
123
- }
124
- });
125
-
126
- /*
127
- * openNotification
128
- * Opens a notification, that can be closed with an optional timer
129
- * (default 5000ms timer) and always closes on click.
130
- *
131
- * If a notification is opened while another is opened, it will close the
132
- * currently opened one and open the new one immediately.
133
- */
134
- CodeMirror.defineExtension("openNotification", function(template, options) {
135
- closeNotification(this, close);
136
- var dialog = dialogDiv(this, template, options && options.bottom);
137
- var closed = false, doneTimer;
138
- var duration = options && typeof options.duration !== "undefined" ? options.duration : 5000;
139
-
140
- function close() {
141
- if (closed) return;
142
- closed = true;
143
- clearTimeout(doneTimer);
144
- dialog.parentNode.removeChild(dialog);
145
- }
146
-
147
- CodeMirror.on(dialog, 'click', function(e) {
148
- CodeMirror.e_preventDefault(e);
149
- close();
150
- });
151
-
152
- if (duration)
153
- doneTimer = setTimeout(close, duration);
154
-
155
- return close;
156
- });
157
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/codemirror/addon/jump-to-line.js DELETED
@@ -1,49 +0,0 @@
1
- // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
- // Distributed under an MIT license: http://codemirror.net/LICENSE
3
-
4
- // Defines jumpToLine command. Uses dialog.js if present.
5
-
6
- (function(mod) {
7
- if (typeof exports == "object" && typeof module == "object") // CommonJS
8
- mod(require("../../lib/codemirror"), require("../dialog/dialog"));
9
- else if (typeof define == "function" && define.amd) // AMD
10
- define(["../../lib/codemirror", "../dialog/dialog"], mod);
11
- else // Plain browser env
12
- mod(CodeMirror);
13
- })(function(CodeMirror) {
14
- "use strict";
15
-
16
- function dialog(cm, text, shortText, deflt, f) {
17
- if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true});
18
- else f(prompt(shortText, deflt));
19
- }
20
-
21
- var jumpDialog =
22
- 'Jump to line: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use line:column or scroll% syntax)</span>';
23
-
24
- function interpretLine(cm, string) {
25
- var num = Number(string)
26
- if (/^[-+]/.test(string)) return cm.getCursor().line + num
27
- else return num - 1
28
- }
29
-
30
- CodeMirror.commands.jumpToLine = function(cm) {
31
- var cur = cm.getCursor();
32
- dialog(cm, jumpDialog, "Jump to line:", (cur.line + 1) + ":" + cur.ch, function(posStr) {
33
- if (!posStr) return;
34
-
35
- var match;
36
- if (match = /^\s*([\+\-]?\d+)\s*\:\s*(\d+)\s*$/.exec(posStr)) {
37
- cm.setCursor(interpretLine(cm, match[1]), Number(match[2]))
38
- } else if (match = /^\s*([\+\-]?\d+(\.\d+)?)\%\s*/.exec(posStr)) {
39
- var line = Math.round(cm.lineCount() * Number(match[1]) / 100);
40
- if (/^[-+]/.test(match[1])) line = cur.line + line + 1;
41
- cm.setCursor(line - 1, cur.ch);
42
- } else if (match = /^\s*\:?\s*([\+\-]?\d+)\s*/.exec(posStr)) {
43
- cm.setCursor(interpretLine(cm, match[1]), cur.ch);
44
- }
45
- });
46
- };
47
-
48
- CodeMirror.keyMap["default"]["Alt-G"] = "jumpToLine";
49
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/codemirror/addon/matchesonscrollbar.css DELETED
@@ -1,8 +0,0 @@
1
- .CodeMirror-search-match {
2
- background: gold;
3
- border-top: 1px solid orange;
4
- border-bottom: 1px solid orange;
5
- -moz-box-sizing: border-box;
6
- box-sizing: border-box;
7
- opacity: .5;
8
- }
 
 
 
 
 
 
 
 
assets/codemirror/addon/scroll/simplescrollbars.css DELETED
@@ -1,66 +0,0 @@
1
- .CodeMirror-simplescroll-horizontal div, .CodeMirror-simplescroll-vertical div {
2
- position: absolute;
3
- background: #ccc;
4
- -moz-box-sizing: border-box;
5
- box-sizing: border-box;
6
- border: 1px solid #bbb;
7
- border-radius: 2px;
8
- }
9
-
10
- .CodeMirror-simplescroll-horizontal, .CodeMirror-simplescroll-vertical {
11
- position: absolute;
12
- z-index: 6;
13
- background: #eee;
14
- }
15
-
16
- .CodeMirror-simplescroll-horizontal {
17
- bottom: 0; left: 0;
18
- height: 8px;
19
- }
20
- .CodeMirror-simplescroll-horizontal div {
21
- bottom: 0;
22
- height: 100%;
23
- }
24
-
25
- .CodeMirror-simplescroll-vertical {
26
- right: 0; top: 0;
27
- width: 8px;
28
- }
29
- .CodeMirror-simplescroll-vertical div {
30
- right: 0;
31
- width: 100%;
32
- }
33
-
34
-
35
- .CodeMirror-overlayscroll .CodeMirror-scrollbar-filler, .CodeMirror-overlayscroll .CodeMirror-gutter-filler {
36
- display: none;
37
- }
38
-
39
- .CodeMirror-overlayscroll-horizontal div, .CodeMirror-overlayscroll-vertical div {
40
- position: absolute;
41
- background: #bcd;
42
- border-radius: 3px;
43
- }
44
-
45
- .CodeMirror-overlayscroll-horizontal, .CodeMirror-overlayscroll-vertical {
46
- position: absolute;
47
- z-index: 6;
48
- }
49
-
50
- .CodeMirror-overlayscroll-horizontal {
51
- bottom: 0; left: 0;
52
- height: 6px;
53
- }
54
- .CodeMirror-overlayscroll-horizontal div {
55
- bottom: 0;
56
- height: 100%;
57
- }
58
-
59
- .CodeMirror-overlayscroll-vertical {
60
- right: 0; top: 0;
61
- width: 6px;
62
- }
63
- .CodeMirror-overlayscroll-vertical div {
64
- right: 0;
65
- width: 100%;
66
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/codemirror/addon/scroll/simplescrollbars.js DELETED
@@ -1,152 +0,0 @@
1
- // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
- // Distributed under an MIT license: http://codemirror.net/LICENSE
3
-
4
- (function(mod) {
5
- if (typeof exports == "object" && typeof module == "object") // CommonJS
6
- mod(require("../../lib/codemirror"));
7
- else if (typeof define == "function" && define.amd) // AMD
8
- define(["../../lib/codemirror"], mod);
9
- else // Plain browser env
10
- mod(CodeMirror);
11
- })(function(CodeMirror) {
12
- "use strict";
13
-
14
- function Bar(cls, orientation, scroll) {
15
- this.orientation = orientation;
16
- this.scroll = scroll;
17
- this.screen = this.total = this.size = 1;
18
- this.pos = 0;
19
-
20
- this.node = document.createElement("div");
21
- this.node.className = cls + "-" + orientation;
22
- this.inner = this.node.appendChild(document.createElement("div"));
23
-
24
- var self = this;
25
- CodeMirror.on(this.inner, "mousedown", function(e) {
26
- if (e.which != 1) return;
27
- CodeMirror.e_preventDefault(e);
28
- var axis = self.orientation == "horizontal" ? "pageX" : "pageY";
29
- var start = e[axis], startpos = self.pos;
30
- function done() {
31
- CodeMirror.off(document, "mousemove", move);
32
- CodeMirror.off(document, "mouseup", done);
33
- }
34
- function move(e) {
35
- if (e.which != 1) return done();
36
- self.moveTo(startpos + (e[axis] - start) * (self.total / self.size));
37
- }
38
- CodeMirror.on(document, "mousemove", move);
39
- CodeMirror.on(document, "mouseup", done);
40
- });
41
-
42
- CodeMirror.on(this.node, "click", function(e) {
43
- CodeMirror.e_preventDefault(e);
44
- var innerBox = self.inner.getBoundingClientRect(), where;
45
- if (self.orientation == "horizontal")
46
- where = e.clientX < innerBox.left ? -1 : e.clientX > innerBox.right ? 1 : 0;
47
- else
48
- where = e.clientY < innerBox.top ? -1 : e.clientY > innerBox.bottom ? 1 : 0;
49
- self.moveTo(self.pos + where * self.screen);
50
- });
51
-
52
- function onWheel(e) {
53
- var moved = CodeMirror.wheelEventPixels(e)[self.orientation == "horizontal" ? "x" : "y"];
54
- var oldPos = self.pos;
55
- self.moveTo(self.pos + moved);
56
- if (self.pos != oldPos) CodeMirror.e_preventDefault(e);
57
- }
58
- CodeMirror.on(this.node, "mousewheel", onWheel);
59
- CodeMirror.on(this.node, "DOMMouseScroll", onWheel);
60
- }
61
-
62
- Bar.prototype.setPos = function(pos, force) {
63
- if (pos < 0) pos = 0;
64
- if (pos > this.total - this.screen) pos = this.total - this.screen;
65
- if (!force && pos == this.pos) return false;
66
- this.pos = pos;
67
- this.inner.style[this.orientation == "horizontal" ? "left" : "top"] =
68
- (pos * (this.size / this.total)) + "px";
69
- return true
70
- };
71
-
72
- Bar.prototype.moveTo = function(pos) {
73
- if (this.setPos(pos)) this.scroll(pos, this.orientation);
74
- }
75
-
76
- var minButtonSize = 10;
77
-
78
- Bar.prototype.update = function(scrollSize, clientSize, barSize) {
79
- var sizeChanged = this.screen != clientSize || this.total != scrollSize || this.size != barSize
80
- if (sizeChanged) {
81
- this.screen = clientSize;
82
- this.total = scrollSize;
83
- this.size = barSize;
84
- }
85
-
86
- var buttonSize = this.screen * (this.size / this.total);
87
- if (buttonSize < minButtonSize) {
88
- this.size -= minButtonSize - buttonSize;
89
- buttonSize = minButtonSize;
90
- }
91
- this.inner.style[this.orientation == "horizontal" ? "width" : "height"] =
92
- buttonSize + "px";
93
- this.setPos(this.pos, sizeChanged);
94
- };
95
-
96
- function SimpleScrollbars(cls, place, scroll) {
97
- this.addClass = cls;
98
- this.horiz = new Bar(cls, "horizontal", scroll);
99
- place(this.horiz.node);
100
- this.vert = new Bar(cls, "vertical", scroll);
101
- place(this.vert.node);
102
- this.width = null;
103
- }
104
-
105
- SimpleScrollbars.prototype.update = function(measure) {
106
- if (this.width == null) {
107
- var style = window.getComputedStyle ? window.getComputedStyle(this.horiz.node) : this.horiz.node.currentStyle;
108
- if (style) this.width = parseInt(style.height);
109
- }
110
- var width = this.width || 0;
111
-
112
- var needsH = measure.scrollWidth > measure.clientWidth + 1;
113
- var needsV = measure.scrollHeight > measure.clientHeight + 1;
114
- this.vert.node.style.display = needsV ? "block" : "none";
115
- this.horiz.node.style.display = needsH ? "block" : "none";
116
-
117
- if (needsV) {
118
- this.vert.update(measure.scrollHeight, measure.clientHeight,
119
- measure.viewHeight - (needsH ? width : 0));
120
- this.vert.node.style.bottom = needsH ? width + "px" : "0";
121
- }
122
- if (needsH) {
123
- this.horiz.update(measure.scrollWidth, measure.clientWidth,
124
- measure.viewWidth - (needsV ? width : 0) - measure.barLeft);
125
- this.horiz.node.style.right = needsV ? width + "px" : "0";
126
- this.horiz.node.style.left = measure.barLeft + "px";
127
- }
128
-
129
- return {right: needsV ? width : 0, bottom: needsH ? width : 0};
130
- };
131
-
132
- SimpleScrollbars.prototype.setScrollTop = function(pos) {
133
- this.vert.setPos(pos);
134
- };
135
-
136
- SimpleScrollbars.prototype.setScrollLeft = function(pos) {
137
- this.horiz.setPos(pos);
138
- };
139
-
140
- SimpleScrollbars.prototype.clear = function() {
141
- var parent = this.horiz.node.parentNode;
142
- parent.removeChild(this.horiz.node);
143
- parent.removeChild(this.vert.node);
144
- };
145
-
146
- CodeMirror.scrollbarModel.simple = function(place, scroll) {
147
- return new SimpleScrollbars("CodeMirror-simplescroll", place, scroll);
148
- };
149
- CodeMirror.scrollbarModel.overlay = function(place, scroll) {
150
- return new SimpleScrollbars("CodeMirror-overlayscroll", place, scroll);
151
- };
152
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/codemirror/addon/search.js DELETED
@@ -1,249 +0,0 @@
1
- // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
- // Distributed under an MIT license: http://codemirror.net/LICENSE
3
-
4
- // Define search commands. Depends on dialog.js or another
5
- // implementation of the openDialog method.
6
-
7
- // Replace works a little oddly -- it will do the replace on the next
8
- // Ctrl-G (or whatever is bound to findNext) press. You prevent a
9
- // replace by making sure the match is no longer selected when hitting
10
- // Ctrl-G.
11
-
12
- (function(mod) {
13
- if (typeof exports == "object" && typeof module == "object") // CommonJS
14
- mod(require("../../lib/codemirror"), require("./searchcursor"), require("../dialog/dialog"));
15
- else if (typeof define == "function" && define.amd) // AMD
16
- define(["../../lib/codemirror", "./searchcursor", "../dialog/dialog"], mod);
17
- else // Plain browser env
18
- mod(CodeMirror);
19
- })(function(CodeMirror) {
20
- "use strict";
21
-
22
- function searchOverlay(query, caseInsensitive) {
23
- if (typeof query == "string")
24
- query = new RegExp(query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), caseInsensitive ? "gi" : "g");
25
- else if (!query.global)
26
- query = new RegExp(query.source, query.ignoreCase ? "gi" : "g");
27
-
28
- return {token: function(stream) {
29
- query.lastIndex = stream.pos;
30
- var match = query.exec(stream.string);
31
- if (match && match.index == stream.pos) {
32
- stream.pos += match[0].length || 1;
33
- return "searching";
34
- } else if (match) {
35
- stream.pos = match.index;
36
- } else {
37
- stream.skipToEnd();
38
- }
39
- }};
40
- }
41
-
42
- function SearchState() {
43
- this.posFrom = this.posTo = this.lastQuery = this.query = null;
44
- this.overlay = null;
45
- }
46
-
47
- function getSearchState(cm) {
48
- return cm.state.search || (cm.state.search = new SearchState());
49
- }
50
-
51
- function queryCaseInsensitive(query) {
52
- return typeof query == "string" && query == query.toLowerCase();
53
- }
54
-
55
- function getSearchCursor(cm, query, pos) {
56
- // Heuristic: if the query string is all lowercase, do a case insensitive search.
57
- return cm.getSearchCursor(query, pos, queryCaseInsensitive(query));
58
- }
59
-
60
- function persistentDialog(cm, text, deflt, onEnter, onKeyDown) {
61
- cm.openDialog(text, onEnter, {
62
- value: deflt,
63
- selectValueOnOpen: true,
64
- closeOnEnter: false,
65
- onClose: function() { clearSearch(cm); },
66
- onKeyDown: onKeyDown
67
- });
68
- }
69
-
70
- function dialog(cm, text, shortText, deflt, f) {
71
- if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true});
72
- else f(prompt(shortText, deflt));
73
- }
74
-
75
- function confirmDialog(cm, text, shortText, fs) {
76
- if (cm.openConfirm) cm.openConfirm(text, fs);
77
- else if (confirm(shortText)) fs[0]();
78
- }
79
-
80
- function parseString(string) {
81
- return string.replace(/\\(.)/g, function(_, ch) {
82
- if (ch == "n") return "\n"
83
- if (ch == "r") return "\r"
84
- return ch
85
- })
86
- }
87
-
88
- function parseQuery(query) {
89
- var isRE = query.match(/^\/(.*)\/([a-z]*)$/);
90
- if (isRE) {
91
- try { query = new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i"); }
92
- catch(e) {} // Not a regular expression after all, do a string search
93
- } else {
94
- query = parseString(query)
95
- }
96
- if (typeof query == "string" ? query == "" : query.test(""))
97
- query = /x^/;
98
- return query;
99
- }
100
-
101
- var queryDialog =
102
- 'Search: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>';
103
-
104
- function startSearch(cm, state, query) {
105
- state.queryText = query;
106
- state.query = parseQuery(query);
107
- cm.removeOverlay(state.overlay, queryCaseInsensitive(state.query));
108
- state.overlay = searchOverlay(state.query, queryCaseInsensitive(state.query));
109
- cm.addOverlay(state.overlay);
110
- if (cm.showMatchesOnScrollbar) {
111
- if (state.annotate) { state.annotate.clear(); state.annotate = null; }
112
- state.annotate = cm.showMatchesOnScrollbar(state.query, queryCaseInsensitive(state.query));
113
- }
114
- }
115
-
116
- function doSearch(cm, rev, persistent, immediate) {
117
- var state = getSearchState(cm);
118
- if (state.query) return findNext(cm, rev);
119
- var q = cm.getSelection() || state.lastQuery;
120
- if (persistent && cm.openDialog) {
121
- var hiding = null
122
- var searchNext = function(query, event) {
123
- CodeMirror.e_stop(event);
124
- if (!query) return;
125
- if (query != state.queryText) {
126
- startSearch(cm, state, query);
127
- state.posFrom = state.posTo = cm.getCursor();
128
- }
129
- if (hiding) hiding.style.opacity = 1
130
- findNext(cm, event.shiftKey, function(_, to) {
131
- var dialog
132
- if (to.line < 3 && document.querySelector &&
133
- (dialog = cm.display.wrapper.querySelector(".CodeMirror-dialog")) &&
134
- dialog.getBoundingClientRect().bottom - 4 > cm.cursorCoords(to, "window").top)
135
- (hiding = dialog).style.opacity = .4
136
- })
137
- };
138
- persistentDialog(cm, queryDialog, q, searchNext, function(event, query) {
139
- var cmd = CodeMirror.keyMap[cm.getOption("keyMap")][CodeMirror.keyName(event)];
140
- if (cmd == "findNext" || cmd == "findPrev") {
141
- CodeMirror.e_stop(event);
142
- startSearch(cm, getSearchState(cm), query);
143
- cm.execCommand(cmd);
144
- } else if (cmd == "find" || cmd == "findPersistent") {
145
- CodeMirror.e_stop(event);
146
- searchNext(query, event);
147
- }
148
- });
149
- if (immediate) {
150
- startSearch(cm, state, q);
151
- findNext(cm, rev);
152
- }
153
- } else {
154
- dialog(cm, queryDialog, "Search for:", q, function(query) {
155
- if (query && !state.query) cm.operation(function() {
156
- startSearch(cm, state, query);
157
- state.posFrom = state.posTo = cm.getCursor();
158
- findNext(cm, rev);
159
- });
160
- });
161
- }
162
- }
163
-
164
- function findNext(cm, rev, callback) {cm.operation(function() {
165
- var state = getSearchState(cm);
166
- var cursor = getSearchCursor(cm, state.query, rev ? state.posFrom : state.posTo);
167
- if (!cursor.find(rev)) {
168
- cursor = getSearchCursor(cm, state.query, rev ? CodeMirror.Pos(cm.lastLine()) : CodeMirror.Pos(cm.firstLine(), 0));
169
- if (!cursor.find(rev)) return;
170
- }
171
- cm.setSelection(cursor.from(), cursor.to());
172
- cm.scrollIntoView({from: cursor.from(), to: cursor.to()}, 20);
173
- state.posFrom = cursor.from(); state.posTo = cursor.to();
174
- if (callback) callback(cursor.from(), cursor.to())
175
- });}
176
-
177
- function clearSearch(cm) {cm.operation(function() {
178
- var state = getSearchState(cm);
179
- state.lastQuery = state.query;
180
- if (!state.query) return;
181
- state.query = state.queryText = null;
182
- cm.removeOverlay(state.overlay);
183
- if (state.annotate) { state.annotate.clear(); state.annotate = null; }
184
- });}
185
-
186
- var replaceQueryDialog =
187
- ' <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>';
188
- var replacementQueryDialog = 'With: <input type="text" style="width: 10em" class="CodeMirror-search-field"/>';
189
- var doReplaceConfirm = "Replace? <button>Yes</button> <button>No</button> <button>All</button> <button>Stop</button>";
190
-
191
- function replaceAll(cm, query, text) {
192
- cm.operation(function() {
193
- for (var cursor = getSearchCursor(cm, query); cursor.findNext();) {
194
- if (typeof query != "string") {
195
- var match = cm.getRange(cursor.from(), cursor.to()).match(query);
196
- cursor.replace(text.replace(/\$(\d)/g, function(_, i) {return match[i];}));
197
- } else cursor.replace(text);
198
- }
199
- });
200
- }
201
-
202
- function replace(cm, all) {
203
- if (cm.getOption("readOnly")) return;
204
- var query = cm.getSelection() || getSearchState(cm).lastQuery;
205
- var dialogText = all ? "Replace all:" : "Replace:"
206
- dialog(cm, dialogText + replaceQueryDialog, dialogText, query, function(query) {
207
- if (!query) return;
208
- query = parseQuery(query);
209
- dialog(cm, replacementQueryDialog, "Replace with:", "", function(text) {
210
- text = parseString(text)
211
- if (all) {
212
- replaceAll(cm, query, text)
213
- } else {
214
- clearSearch(cm);
215
- var cursor = getSearchCursor(cm, query, cm.getCursor("from"));
216
- var advance = function() {
217
- var start = cursor.from(), match;
218
- if (!(match = cursor.findNext())) {
219
- cursor = getSearchCursor(cm, query);
220
- if (!(match = cursor.findNext()) ||
221
- (start && cursor.from().line == start.line && cursor.from().ch == start.ch)) return;
222
- }
223
- cm.setSelection(cursor.from(), cursor.to());
224
- cm.scrollIntoView({from: cursor.from(), to: cursor.to()});
225
- confirmDialog(cm, doReplaceConfirm, "Replace?",
226
- [function() {doReplace(match);}, advance,
227
- function() {replaceAll(cm, query, text)}]);
228
- };
229
- var doReplace = function(match) {
230
- cursor.replace(typeof query == "string" ? text :
231
- text.replace(/\$(\d)/g, function(_, i) {return match[i];}));
232
- advance();
233
- };
234
- advance();
235
- }
236
- });
237
- });
238
- }
239
-
240
- CodeMirror.commands.find = function(cm) {clearSearch(cm); doSearch(cm);};
241
- CodeMirror.commands.findPersistent = function(cm) {clearSearch(cm); doSearch(cm, false, true);};
242
- CodeMirror.commands.findPersistentNext = function(cm) {doSearch(cm, false, true, true);};
243
- CodeMirror.commands.findPersistentPrev = function(cm) {doSearch(cm, true, true, true);};
244
- CodeMirror.commands.findNext = doSearch;
245
- CodeMirror.commands.findPrev = function(cm) {doSearch(cm, true);};
246
- CodeMirror.commands.clearSearch = clearSearch;
247
- CodeMirror.commands.replace = replace;
248
- CodeMirror.commands.replaceAll = function(cm) {replace(cm, true);};
249
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/codemirror/addon/searchcursor.js DELETED
@@ -1,189 +0,0 @@
1
- // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
- // Distributed under an MIT license: http://codemirror.net/LICENSE
3
-
4
- (function(mod) {
5
- if (typeof exports == "object" && typeof module == "object") // CommonJS
6
- mod(require("../../lib/codemirror"));
7
- else if (typeof define == "function" && define.amd) // AMD
8
- define(["../../lib/codemirror"], mod);
9
- else // Plain browser env
10
- mod(CodeMirror);
11
- })(function(CodeMirror) {
12
- "use strict";
13
- var Pos = CodeMirror.Pos;
14
-
15
- function SearchCursor(doc, query, pos, caseFold) {
16
- this.atOccurrence = false; this.doc = doc;
17
- if (caseFold == null && typeof query == "string") caseFold = false;
18
-
19
- pos = pos ? doc.clipPos(pos) : Pos(0, 0);
20
- this.pos = {from: pos, to: pos};
21
-
22
- // The matches method is filled in based on the type of query.
23
- // It takes a position and a direction, and returns an object
24
- // describing the next occurrence of the query, or null if no
25
- // more matches were found.
26
- if (typeof query != "string") { // Regexp match
27
- if (!query.global) query = new RegExp(query.source, query.ignoreCase ? "ig" : "g");
28
- this.matches = function(reverse, pos) {
29
- if (reverse) {
30
- query.lastIndex = 0;
31
- var line = doc.getLine(pos.line).slice(0, pos.ch), cutOff = 0, match, start;
32
- for (;;) {
33
- query.lastIndex = cutOff;
34
- var newMatch = query.exec(line);
35
- if (!newMatch) break;
36
- match = newMatch;
37
- start = match.index;
38
- cutOff = match.index + (match[0].length || 1);
39
- if (cutOff == line.length) break;
40
- }
41
- var matchLen = (match && match[0].length) || 0;
42
- if (!matchLen) {
43
- if (start == 0 && line.length == 0) {match = undefined;}
44
- else if (start != doc.getLine(pos.line).length) {
45
- matchLen++;
46
- }
47
- }
48
- } else {
49
- query.lastIndex = pos.ch;
50
- var line = doc.getLine(pos.line), match = query.exec(line);
51
- var matchLen = (match && match[0].length) || 0;
52
- var start = match && match.index;
53
- if (start + matchLen != line.length && !matchLen) matchLen = 1;
54
- }
55
- if (match && matchLen)
56
- return {from: Pos(pos.line, start),
57
- to: Pos(pos.line, start + matchLen),
58
- match: match};
59
- };
60
- } else { // String query
61
- var origQuery = query;
62
- if (caseFold) query = query.toLowerCase();
63
- var fold = caseFold ? function(str){return str.toLowerCase();} : function(str){return str;};
64
- var target = query.split("\n");
65
- // Different methods for single-line and multi-line queries
66
- if (target.length == 1) {
67
- if (!query.length) {
68
- // Empty string would match anything and never progress, so
69
- // we define it to match nothing instead.
70
- this.matches = function() {};
71
- } else {
72
- this.matches = function(reverse, pos) {
73
- if (reverse) {
74
- var orig = doc.getLine(pos.line).slice(0, pos.ch), line = fold(orig);
75
- var match = line.lastIndexOf(query);
76
- if (match > -1) {
77
- match = adjustPos(orig, line, match);
78
- return {from: Pos(pos.line, match), to: Pos(pos.line, match + origQuery.length)};
79
- }
80
- } else {
81
- var orig = doc.getLine(pos.line).slice(pos.ch), line = fold(orig);
82
- var match = line.indexOf(query);
83
- if (match > -1) {
84
- match = adjustPos(orig, line, match) + pos.ch;
85
- return {from: Pos(pos.line, match), to: Pos(pos.line, match + origQuery.length)};
86
- }
87
- }
88
- };
89
- }
90
- } else {
91
- var origTarget = origQuery.split("\n");
92
- this.matches = function(reverse, pos) {
93
- var last = target.length - 1;
94
- if (reverse) {
95
- if (pos.line - (target.length - 1) < doc.firstLine()) return;
96
- if (fold(doc.getLine(pos.line).slice(0, origTarget[last].length)) != target[target.length - 1]) return;
97
- var to = Pos(pos.line, origTarget[last].length);
98
- for (var ln = pos.line - 1, i = last - 1; i >= 1; --i, --ln)
99
- if (target[i] != fold(doc.getLine(ln))) return;
100
- var line = doc.getLine(ln), cut = line.length - origTarget[0].length;
101
- if (fold(line.slice(cut)) != target[0]) return;
102
- return {from: Pos(ln, cut), to: to};
103
- } else {
104
- if (pos.line + (target.length - 1) > doc.lastLine()) return;
105
- var line = doc.getLine(pos.line), cut = line.length - origTarget[0].length;
106
- if (fold(line.slice(cut)) != target[0]) return;
107
- var from = Pos(pos.line, cut);
108
- for (var ln = pos.line + 1, i = 1; i < last; ++i, ++ln)
109
- if (target[i] != fold(doc.getLine(ln))) return;
110
- if (fold(doc.getLine(ln).slice(0, origTarget[last].length)) != target[last]) return;
111
- return {from: from, to: Pos(ln, origTarget[last].length)};
112
- }
113
- };
114
- }
115
- }
116
- }
117
-
118
- SearchCursor.prototype = {
119
- findNext: function() {return this.find(false);},
120
- findPrevious: function() {return this.find(true);},
121
-
122
- find: function(reverse) {
123
- var self = this, pos = this.doc.clipPos(reverse ? this.pos.from : this.pos.to);
124
- function savePosAndFail(line) {
125
- var pos = Pos(line, 0);
126
- self.pos = {from: pos, to: pos};
127
- self.atOccurrence = false;
128
- return false;
129
- }
130
-
131
- for (;;) {
132
- if (this.pos = this.matches(reverse, pos)) {
133
- this.atOccurrence = true;
134
- return this.pos.match || true;
135
- }
136
- if (reverse) {
137
- if (!pos.line) return savePosAndFail(0);
138
- pos = Pos(pos.line-1, this.doc.getLine(pos.line-1).length);
139
- }
140
- else {
141
- var maxLine = this.doc.lineCount();
142
- if (pos.line == maxLine - 1) return savePosAndFail(maxLine);
143
- pos = Pos(pos.line + 1, 0);
144
- }
145
- }
146
- },
147
-
148
- from: function() {if (this.atOccurrence) return this.pos.from;},
149
- to: function() {if (this.atOccurrence) return this.pos.to;},
150
-
151
- replace: function(newText, origin) {
152
- if (!this.atOccurrence) return;
153
- var lines = CodeMirror.splitLines(newText);
154
- this.doc.replaceRange(lines, this.pos.from, this.pos.to, origin);
155
- this.pos.to = Pos(this.pos.from.line + lines.length - 1,
156
- lines[lines.length - 1].length + (lines.length == 1 ? this.pos.from.ch : 0));
157
- }
158
- };
159
-
160
- // Maps a position in a case-folded line back to a position in the original line
161
- // (compensating for codepoints increasing in number during folding)
162
- function adjustPos(orig, folded, pos) {
163
- if (orig.length == folded.length) return pos;
164
- for (var pos1 = Math.min(pos, orig.length);;) {
165
- var len1 = orig.slice(0, pos1).toLowerCase().length;
166
- if (len1 < pos) ++pos1;
167
- else if (len1 > pos) --pos1;
168
- else return pos1;
169
- }
170
- }
171
-
172
- CodeMirror.defineExtension("getSearchCursor", function(query, pos, caseFold) {
173
- return new SearchCursor(this.doc, query, pos, caseFold);
174
- });
175
- CodeMirror.defineDocExtension("getSearchCursor", function(query, pos, caseFold) {
176
- return new SearchCursor(this, query, pos, caseFold);
177
- });
178
-
179
- CodeMirror.defineExtension("selectMatches", function(query, caseFold) {
180
- var ranges = [];
181
- var cur = this.getSearchCursor(query, this.getCursor("from"), caseFold);
182
- while (cur.findNext()) {
183
- if (CodeMirror.cmpPos(cur.to(), this.getCursor("to")) > 0) break;
184
- ranges.push({anchor: cur.from(), head: cur.to()});
185
- }
186
- if (ranges.length)
187
- this.setSelections(ranges, 0);
188
- });
189
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/codemirror/mode/xml/xml.js DELETED
@@ -1,394 +0,0 @@
1
- // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
- // Distributed under an MIT license: http://codemirror.net/LICENSE
3
-
4
- (function(mod) {
5
- if (typeof exports == "object" && typeof module == "object") // CommonJS
6
- mod(require("../../lib/codemirror"));
7
- else if (typeof define == "function" && define.amd) // AMD
8
- define(["../../lib/codemirror"], mod);
9
- else // Plain browser env
10
- mod(CodeMirror);
11
- })(function(CodeMirror) {
12
- "use strict";
13
-
14
- var htmlConfig = {
15
- autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
16
- 'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
17
- 'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
18
- 'track': true, 'wbr': true, 'menuitem': true},
19
- implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
20
- 'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
21
- 'th': true, 'tr': true},
22
- contextGrabbers: {
23
- 'dd': {'dd': true, 'dt': true},
24
- 'dt': {'dd': true, 'dt': true},
25
- 'li': {'li': true},
26
- 'option': {'option': true, 'optgroup': true},
27
- 'optgroup': {'optgroup': true},
28
- 'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
29
- 'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
30
- 'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
31
- 'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
32
- 'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
33
- 'rp': {'rp': true, 'rt': true},
34
- 'rt': {'rp': true, 'rt': true},
35
- 'tbody': {'tbody': true, 'tfoot': true},
36
- 'td': {'td': true, 'th': true},
37
- 'tfoot': {'tbody': true},
38
- 'th': {'td': true, 'th': true},
39
- 'thead': {'tbody': true, 'tfoot': true},
40
- 'tr': {'tr': true}
41
- },
42
- doNotIndent: {"pre": true},
43
- allowUnquoted: true,
44
- allowMissing: true,
45
- caseFold: true
46
- }
47
-
48
- var xmlConfig = {
49
- autoSelfClosers: {},
50
- implicitlyClosed: {},
51
- contextGrabbers: {},
52
- doNotIndent: {},
53
- allowUnquoted: false,
54
- allowMissing: false,
55
- caseFold: false
56
- }
57
-
58
- CodeMirror.defineMode("xml", function(editorConf, config_) {
59
- var indentUnit = editorConf.indentUnit
60
- var config = {}
61
- var defaults = config_.htmlMode ? htmlConfig : xmlConfig
62
- for (var prop in defaults) config[prop] = defaults[prop]
63
- for (var prop in config_) config[prop] = config_[prop]
64
-
65
- // Return variables for tokenizers
66
- var type, setStyle;
67
-
68
- function inText(stream, state) {
69
- function chain(parser) {
70
- state.tokenize = parser;
71
- return parser(stream, state);
72
- }
73
-
74
- var ch = stream.next();
75
- if (ch == "<") {
76
- if (stream.eat("!")) {
77
- if (stream.eat("[")) {
78
- if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>"));
79
- else return null;
80
- } else if (stream.match("--")) {
81
- return chain(inBlock("comment", "-->"));
82
- } else if (stream.match("DOCTYPE", true, true)) {
83
- stream.eatWhile(/[\w\._\-]/);
84
- return chain(doctype(1));
85
- } else {
86
- return null;
87
- }
88
- } else if (stream.eat("?")) {
89
- stream.eatWhile(/[\w\._\-]/);
90
- state.tokenize = inBlock("meta", "?>");
91
- return "meta";
92
- } else {
93
- type = stream.eat("/") ? "closeTag" : "openTag";
94
- state.tokenize = inTag;
95
- return "tag bracket";
96
- }
97
- } else if (ch == "&") {
98
- var ok;
99
- if (stream.eat("#")) {
100
- if (stream.eat("x")) {
101
- ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
102
- } else {
103
- ok = stream.eatWhile(/[\d]/) && stream.eat(";");
104
- }
105
- } else {
106
- ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";");
107
- }
108
- return ok ? "atom" : "error";
109
- } else {
110
- stream.eatWhile(/[^&<]/);
111
- return null;
112
- }
113
- }
114
- inText.isInText = true;
115
-
116
- function inTag(stream, state) {
117
- var ch = stream.next();
118
- if (ch == ">" || (ch == "/" && stream.eat(">"))) {
119
- state.tokenize = inText;
120
- type = ch == ">" ? "endTag" : "selfcloseTag";
121
- return "tag bracket";
122
- } else if (ch == "=") {
123
- type = "equals";
124
- return null;
125
- } else if (ch == "<") {
126
- state.tokenize = inText;
127
- state.state = baseState;
128
- state.tagName = state.tagStart = null;
129
- var next = state.tokenize(stream, state);
130
- return next ? next + " tag error" : "tag error";
131
- } else if (/[\'\"]/.test(ch)) {
132
- state.tokenize = inAttribute(ch);
133
- state.stringStartCol = stream.column();
134
- return state.tokenize(stream, state);
135
- } else {
136
- stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/);
137
- return "word";
138
- }
139
- }
140
-
141
- function inAttribute(quote) {
142
- var closure = function(stream, state) {
143
- while (!stream.eol()) {
144
- if (stream.next() == quote) {
145
- state.tokenize = inTag;
146
- break;
147
- }
148
- }
149
- return "string";
150
- };
151
- closure.isInAttribute = true;
152
- return closure;
153
- }
154
-
155
- function inBlock(style, terminator) {
156
- return function(stream, state) {
157
- while (!stream.eol()) {
158
- if (stream.match(terminator)) {
159
- state.tokenize = inText;
160
- break;
161
- }
162
- stream.next();
163
- }
164
- return style;
165
- };
166
- }
167
- function doctype(depth) {
168
- return function(stream, state) {
169
- var ch;
170
- while ((ch = stream.next()) != null) {
171
- if (ch == "<") {
172
- state.tokenize = doctype(depth + 1);
173
- return state.tokenize(stream, state);
174
- } else if (ch == ">") {
175
- if (depth == 1) {
176
- state.tokenize = inText;
177
- break;
178
- } else {
179
- state.tokenize = doctype(depth - 1);
180
- return state.tokenize(stream, state);
181
- }
182
- }
183
- }
184
- return "meta";
185
- };
186
- }
187
-
188
- function Context(state, tagName, startOfLine) {
189
- this.prev = state.context;
190
- this.tagName = tagName;
191
- this.indent = state.indented;
192
- this.startOfLine = startOfLine;
193
- if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent))
194
- this.noIndent = true;
195
- }
196
- function popContext(state) {
197
- if (state.context) state.context = state.context.prev;
198
- }
199
- function maybePopContext(state, nextTagName) {
200
- var parentTagName;
201
- while (true) {
202
- if (!state.context) {
203
- return;
204
- }
205
- parentTagName = state.context.tagName;
206
- if (!config.contextGrabbers.hasOwnProperty(parentTagName) ||
207
- !config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
208
- return;
209
- }
210
- popContext(state);
211
- }
212
- }
213
-
214
- function baseState(type, stream, state) {
215
- if (type == "openTag") {
216
- state.tagStart = stream.column();
217
- return tagNameState;
218
- } else if (type == "closeTag") {
219
- return closeTagNameState;
220
- } else {
221
- return baseState;
222
- }
223
- }
224
- function tagNameState(type, stream, state) {
225
- if (type == "word") {
226
- state.tagName = stream.current();
227
- setStyle = "tag";
228
- return attrState;
229
- } else {
230
- setStyle = "error";
231
- return tagNameState;
232
- }
233
- }
234
- function closeTagNameState(type, stream, state) {
235
- if (type == "word") {
236
- var tagName = stream.current();
237
- if (state.context && state.context.tagName != tagName &&
238
- config.implicitlyClosed.hasOwnProperty(state.context.tagName))
239
- popContext(state);
240
- if ((state.context && state.context.tagName == tagName) || config.matchClosing === false) {
241
- setStyle = "tag";
242
- return closeState;
243
- } else {
244
- setStyle = "tag error";
245
- return closeStateErr;
246
- }
247
- } else {
248
- setStyle = "error";
249
- return closeStateErr;
250
- }
251
- }
252
-
253
- function closeState(type, _stream, state) {
254
- if (type != "endTag") {
255
- setStyle = "error";
256
- return closeState;
257
- }
258
- popContext(state);
259
- return baseState;
260
- }
261
- function closeStateErr(type, stream, state) {
262
- setStyle = "error";
263
- return closeState(type, stream, state);
264
- }
265
-
266
- function attrState(type, _stream, state) {
267
- if (type == "word") {
268
- setStyle = "attribute";
269
- return attrEqState;
270
- } else if (type == "endTag" || type == "selfcloseTag") {
271
- var tagName = state.tagName, tagStart = state.tagStart;
272
- state.tagName = state.tagStart = null;
273
- if (type == "selfcloseTag" ||
274
- config.autoSelfClosers.hasOwnProperty(tagName)) {
275
- maybePopContext(state, tagName);
276
- } else {
277
- maybePopContext(state, tagName);
278
- state.context = new Context(state, tagName, tagStart == state.indented);
279
- }
280
- return baseState;
281
- }
282
- setStyle = "error";
283
- return attrState;
284
- }
285
- function attrEqState(type, stream, state) {
286
- if (type == "equals") return attrValueState;
287
- if (!config.allowMissing) setStyle = "error";
288
- return attrState(type, stream, state);
289
- }
290
- function attrValueState(type, stream, state) {
291
- if (type == "string") return attrContinuedState;
292
- if (type == "word" && config.allowUnquoted) {setStyle = "string"; return attrState;}
293
- setStyle = "error";
294
- return attrState(type, stream, state);
295
- }
296
- function attrContinuedState(type, stream, state) {
297
- if (type == "string") return attrContinuedState;
298
- return attrState(type, stream, state);
299
- }
300
-
301
- return {
302
- startState: function(baseIndent) {
303
- var state = {tokenize: inText,
304
- state: baseState,
305
- indented: baseIndent || 0,
306
- tagName: null, tagStart: null,
307
- context: null}
308
- if (baseIndent != null) state.baseIndent = baseIndent
309
- return state
310
- },
311
-
312
- token: function(stream, state) {
313
- if (!state.tagName && stream.sol())
314
- state.indented = stream.indentation();
315
-
316
- if (stream.eatSpace()) return null;
317
- type = null;
318
- var style = state.tokenize(stream, state);
319
- if ((style || type) && style != "comment") {
320
- setStyle = null;
321
- state.state = state.state(type || style, stream, state);
322
- if (setStyle)
323
- style = setStyle == "error" ? style + " error" : setStyle;
324
- }
325
- return style;
326
- },
327
-
328
- indent: function(state, textAfter, fullLine) {
329
- var context = state.context;
330
- // Indent multi-line strings (e.g. css).
331
- if (state.tokenize.isInAttribute) {
332
- if (state.tagStart == state.indented)
333
- return state.stringStartCol + 1;
334
- else
335
- return state.indented + indentUnit;
336
- }
337
- if (context && context.noIndent) return CodeMirror.Pass;
338
- if (state.tokenize != inTag && state.tokenize != inText)
339
- return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
340
- // Indent the starts of attribute names.
341
- if (state.tagName) {
342
- if (config.multilineTagIndentPastTag !== false)
343
- return state.tagStart + state.tagName.length + 2;
344
- else
345
- return state.tagStart + indentUnit * (config.multilineTagIndentFactor || 1);
346
- }
347
- if (config.alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
348
- var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter);
349
- if (tagAfter && tagAfter[1]) { // Closing tag spotted
350
- while (context) {
351
- if (context.tagName == tagAfter[2]) {
352
- context = context.prev;
353
- break;
354
- } else if (config.implicitlyClosed.hasOwnProperty(context.tagName)) {
355
- context = context.prev;
356
- } else {
357
- break;
358
- }
359
- }
360
- } else if (tagAfter) { // Opening tag spotted
361
- while (context) {
362
- var grabbers = config.contextGrabbers[context.tagName];
363
- if (grabbers && grabbers.hasOwnProperty(tagAfter[2]))
364
- context = context.prev;
365
- else
366
- break;
367
- }
368
- }
369
- while (context && context.prev && !context.startOfLine)
370
- context = context.prev;
371
- if (context) return context.indent + indentUnit;
372
- else return state.baseIndent || 0;
373
- },
374
-
375
- electricInput: /<\/[\s\w:]+>$/,
376
- blockCommentStart: "<!--",
377
- blockCommentEnd: "-->",
378
-
379
- configuration: config.htmlMode ? "html" : "xml",
380
- helperType: config.htmlMode ? "html" : "xml",
381
-
382
- skipAttribute: function(state) {
383
- if (state.state == attrValueState)
384
- state.state = attrState
385
- }
386
- };
387
- });
388
-
389
- CodeMirror.defineMIME("text/xml", "xml");
390
- CodeMirror.defineMIME("application/xml", "xml");
391
- if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
392
- CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
393
-
394
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/images/button-close-hover.png DELETED
Binary file
assets/images/button-close.png DELETED
Binary file
custom-css-js.php CHANGED
@@ -3,9 +3,9 @@
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: 2.10
7
  * Author: Diana Burduja
8
- * Author URI: https://www.silkypress.com/
9
  * License: GPL2
10
  *
11
  */
@@ -15,13 +15,13 @@ if ( ! defined( 'ABSPATH' ) ) {
15
  }
16
 
17
  if ( ! class_exists( 'CustomCSSandJS' ) ) :
18
- define( 'CCJ_VERSION', '2.10' );
19
  /**
20
  * Main CustomCSSandJS Class
21
  *
22
  * @class CustomCSSandJS
23
  */
24
  final class CustomCSSandJS {
 
25
  public $plugins_url = '';
26
  public $plugin_dir_path = '';
27
  public $plugin_file = __FILE__;
@@ -73,9 +73,6 @@ final class CustomCSSandJS {
73
  $this->upload_url = $wp_upload_dir['baseurl'] . '/custom-css-js';
74
  if ( is_admin() ) {
75
  include_once( 'includes/admin-screens.php' );
76
- include_once( 'includes/admin-addons.php' );
77
- include_once( 'includes/admin-warnings.php' );
78
- include_once( 'includes/admin-notices.php' );
79
  }
80
 
81
  $this->search_tree = get_option( 'custom-css-js-tree' );
@@ -84,9 +81,8 @@ final class CustomCSSandJS {
84
  return false;
85
  }
86
 
87
- if ( is_null( self::$_instance ) ) {
88
- $this->print_code_actions();
89
- }
90
  }
91
 
92
  /**
@@ -94,15 +90,40 @@ final class CustomCSSandJS {
94
  */
95
  function print_code_actions() {
96
  foreach( $this->search_tree as $_key => $_value ) {
97
- $action = 'wp_';
98
- if ( strpos( $_key, 'admin' ) !== false ) {
99
- $action = 'admin_';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  }
101
- if ( strpos( $_key, 'header' ) !== false ) {
102
- $action .= 'head';
103
- } else {
104
- $action .= 'footer';
105
  }
 
106
  add_action( $action, array( $this, 'print_' . $_key ) );
107
  }
108
  }
@@ -112,7 +133,7 @@ final class CustomCSSandJS {
112
  */
113
  public function __call( $function, $args ) {
114
 
115
- if ( strpos( $function, 'print_' ) === false ) {
116
  return false;
117
  }
118
 
@@ -129,15 +150,15 @@ final class CustomCSSandJS {
129
  }
130
 
131
  // print the `internal` code
132
- if ( strpos( $function, 'internal' ) !== false ) {
133
 
134
  $before = '<!-- start Simple Custom CSS and JS -->' . PHP_EOL;
135
  $after = '<!-- end Simple Custom CSS and JS -->' . PHP_EOL;
136
- if ( strpos( $function, 'css' ) !== false ) {
137
  $before .= '<style type="text/css">' . PHP_EOL;
138
  $after = '</style>' . PHP_EOL . $after;
139
  }
140
- if ( strpos( $function, 'js' ) !== false ) {
141
  $before .= '<script type="text/javascript">' . PHP_EOL;
142
  $after = '</script>' . PHP_EOL . $after;
143
  }
@@ -154,35 +175,24 @@ final class CustomCSSandJS {
154
  }
155
 
156
  // link the `external` code
157
- if ( strpos( $function, 'external' ) !== false) {
158
  $in_footer = false;
159
- if ( strpos( $function, 'footer' ) !== false ) {
160
  $in_footer = true;
161
  }
162
 
163
- if ( strpos( $function, 'js' ) !== false ) {
164
  foreach( $args as $_filename ) {
165
  echo PHP_EOL . "<script type='text/javascript' src='".$this->upload_url . '/' . $_filename."'></script>" . PHP_EOL;
166
  }
167
  }
168
 
169
- if ( strpos( $function, 'css' ) !== false ) {
170
  foreach( $args as $_filename ) {
171
- $shortfilename = preg_replace( '@\.css\?v=.*$@', '', $_filename );
172
- echo PHP_EOL . "<link rel='stylesheet' id='".$shortfilename ."-css' href='".$this->upload_url . '/' . $_filename ."' type='text/css' media='all' />" . PHP_EOL;
173
  }
174
  }
175
  }
176
-
177
- // link the HTML code
178
- if ( strpos( $function, 'html' ) !== false ) {
179
- foreach( $args as $_post_id ) {
180
- $_post_id = str_replace('.html', '', $_post_id);
181
- $post = get_post( $_post_id );
182
- echo $post->post_content . PHP_EOL;
183
- }
184
-
185
- }
186
  }
187
 
188
  /**
@@ -246,6 +256,48 @@ function CustomCSSandJS() {
246
  CustomCSSandJS();
247
 
248
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  /**
250
  * Plugin action link to Settings page
251
  */
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: 1.6
7
  * Author: Diana Burduja
8
+ * Author URI: http://www.silkypress.com/
9
  * License: GPL2
10
  *
11
  */
15
  }
16
 
17
  if ( ! class_exists( 'CustomCSSandJS' ) ) :
 
18
  /**
19
  * Main CustomCSSandJS Class
20
  *
21
  * @class CustomCSSandJS
22
  */
23
  final class CustomCSSandJS {
24
+ public $version = '1.6';
25
  public $plugins_url = '';
26
  public $plugin_dir_path = '';
27
  public $plugin_file = __FILE__;
73
  $this->upload_url = $wp_upload_dir['baseurl'] . '/custom-css-js';
74
  if ( is_admin() ) {
75
  include_once( 'includes/admin-screens.php' );
 
 
 
76
  }
77
 
78
  $this->search_tree = get_option( 'custom-css-js-tree' );
81
  return false;
82
  }
83
 
84
+ $this->print_code_actions();
85
+
 
86
  }
87
 
88
  /**
90
  */
91
  function print_code_actions() {
92
  foreach( $this->search_tree as $_key => $_value ) {
93
+ $action = '';
94
+ switch( $_key ) {
95
+ case 'admin-css-header-external' :
96
+ case 'admin-js-header-external' :
97
+ case 'admin-css-header-internal' :
98
+ case 'admin-js-header-internal' :
99
+ $action = 'admin_head';
100
+ break;
101
+
102
+ case 'admin-css-footer-external' :
103
+ case 'admin-js-footer-external' :
104
+ case 'admin-css-footer-internal' :
105
+ case 'admin-js-footer-internal' :
106
+ $action = 'admin_footer';
107
+ break;
108
+
109
+ case 'frontend-css-header-external' :
110
+ case 'frontend-css-footer-external' :
111
+ case 'frontend-css-header-internal' :
112
+ case 'frontend-js-header-internal' :
113
+ case 'frontend-js-header-external' :
114
+ $action = 'wp_head';
115
+ break;
116
+ case 'frontend-css-footer-internal' :
117
+ case 'frontend-js-footer-internal' :
118
+ case 'frontend-js-footer-external' :
119
+ $action = 'wp_footer';
120
+ break;
121
  }
122
+
123
+ if ( $action == '' ) {
124
+ continue;
 
125
  }
126
+
127
  add_action( $action, array( $this, 'print_' . $_key ) );
128
  }
129
  }
133
  */
134
  public function __call( $function, $args ) {
135
 
136
+ if ( strstr( $function, 'print_' ) == false ) {
137
  return false;
138
  }
139
 
150
  }
151
 
152
  // print the `internal` code
153
+ if ( strstr( $function, 'internal' ) ) {
154
 
155
  $before = '<!-- start Simple Custom CSS and JS -->' . PHP_EOL;
156
  $after = '<!-- end Simple Custom CSS and JS -->' . PHP_EOL;
157
+ if ( strstr( $function, 'css' ) ) {
158
  $before .= '<style type="text/css">' . PHP_EOL;
159
  $after = '</style>' . PHP_EOL . $after;
160
  }
161
+ if ( strstr( $function, 'js' ) ) {
162
  $before .= '<script type="text/javascript">' . PHP_EOL;
163
  $after = '</script>' . PHP_EOL . $after;
164
  }
175
  }
176
 
177
  // link the `external` code
178
+ if ( strstr( $function, 'external' ) ) {
179
  $in_footer = false;
180
+ if ( strstr( $function, 'footer' ) ) {
181
  $in_footer = true;
182
  }
183
 
184
+ if ( strstr( $function, 'js' ) ) {
185
  foreach( $args as $_filename ) {
186
  echo PHP_EOL . "<script type='text/javascript' src='".$this->upload_url . '/' . $_filename."'></script>" . PHP_EOL;
187
  }
188
  }
189
 
190
+ if ( strstr( $function, 'css' ) ) {
191
  foreach( $args as $_filename ) {
192
+ echo PHP_EOL . "<link rel='stylesheet' id='".$_filename."-css' href='".$this->upload_url . '/' . $_filename ."' type='text/css' media='all' />" . PHP_EOL;
 
193
  }
194
  }
195
  }
 
 
 
 
 
 
 
 
 
 
196
  }
197
 
198
  /**
256
  CustomCSSandJS();
257
 
258
 
259
+ /**
260
+ * Delete options, posts and files on uninstall
261
+ */
262
+ function custom_css_js_uninstall() {
263
+
264
+ delete_option( 'custom-css-js-tree' );
265
+
266
+ $wp_upload_dir = wp_upload_dir();
267
+ $upload_dir = $wp_upload_dir['basedir'] . '/custom-css-js';
268
+ @array_map( 'unlink', $upload_dir . '/*' );
269
+ @unlink( $upload_dir );
270
+
271
+ $posts = query_posts( 'post_type=custom-css-js' );
272
+
273
+ if ( ! is_array( $posts ) || count( $posts ) == 0 ) {
274
+ return false;
275
+ }
276
+
277
+ foreach ( $posts as $_post ) {
278
+ wp_delete_post( $_post, true );
279
+ }
280
+
281
+ }
282
+ register_uninstall_hook( __FILE__, 'custom_css_js_uninstall' );
283
+
284
+
285
+ /**
286
+ * Create the upload directory on install
287
+ */
288
+ function custom_css_js_install() {
289
+ $wp_upload_dir = wp_upload_dir();
290
+ $upload_dir = $wp_upload_dir['basedir'] . '/custom-css-js';
291
+ wp_mkdir_p( $upload_dir );
292
+
293
+ // Top level blank index.php
294
+ if ( ! file_exists( $upload_dir . '/index.php' ) && wp_is_writable( $upload_dir ) ) {
295
+ $content = '<?php' . PHP_EOL . '// Silence is golden.';
296
+ @file_put_contents( $upload_dir . '/index.php', $content );
297
+ }
298
+ }
299
+ register_activation_hook( __FILE__, 'custom_css_js_install' );
300
+
301
  /**
302
  * Plugin action link to Settings page
303
  */
includes/admin-addons.php DELETED
@@ -1,186 +0,0 @@
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_Addons
13
- */
14
- class CustomCSSandJS_Addons {
15
-
16
- /**
17
- * Constructor
18
- */
19
- public function __construct() {
20
-
21
- // Add actions
22
- $actions = array(
23
- 'add_meta_boxes' => 'add_meta_boxes',
24
- 'edit_form_advanced' => 'only_premium',
25
- );
26
- foreach( $actions as $_key => $_value ) {
27
- add_action( $_key, array( $this, $_value ) );
28
- }
29
-
30
- }
31
-
32
- function only_premium() {
33
- $current_screen = get_current_screen();
34
-
35
- if ( $current_screen->post_type != 'custom-css-js' ) {
36
- return false;
37
- }
38
-
39
- ?>
40
- <div class="ccj_only_premium ccj_only_premium-first">
41
- <div>
42
- <a href="https://www.silkypress.com/simple-custom-css-js-pro/?utm_source=wordpress&utm_campaign=ccj_free&utm_medium=banner" target="_blank">Available only in <br />Simple Custom CSS and JS Pro</a>
43
- </div>
44
- </div>
45
- <?php
46
- }
47
-
48
-
49
- /**
50
- * Add the URL Preview meta box
51
- */
52
- function add_meta_boxes() {
53
-
54
- add_meta_box( 'previewdiv', __('Preview'), array( $this, 'previews_meta_box_callback' ), 'custom-css-js', 'normal' );
55
- add_meta_box( 'url-rules', __('Apply only on these URLs'), array( $this, 'url_rules_meta_box_callback' ), 'custom-css-js', 'normal' );
56
- add_meta_box( 'revisionsdiv', __('Code Revisions'), array( $this, 'revisions_meta_box_callback' ), 'custom-css-js', 'normal' );
57
- }
58
-
59
-
60
- /**
61
- * The Preview meta box content
62
- */
63
- function previews_meta_box_callback( $post ) {
64
- ?>
65
- <div id="preview-action">
66
- <div>
67
- <input type="text" name="preview_url" id="ccj-preview_url" placeholder="Full URL on which to preview the changes ..." disabled="disabled" />
68
- <a class="preview button button-primary button-large" id="ccj-preview">Preview Changes</a>
69
- </div>
70
- </div>
71
- <?php
72
-
73
- }
74
-
75
-
76
- /**
77
- * Show the URL Rules metabox
78
- */
79
- function url_rules_meta_box_callback( $post ) {
80
-
81
- $filters = array(
82
- 'all' => __('All Website'),
83
- 'first-page' => __('First page'),
84
- 'contains' => __('Contains'),
85
- 'not-contains' => __('Not contains'),
86
- 'equal-to' => __('Is equal to'),
87
- 'not-equal-to' => __('Not equal to'),
88
- 'begins-with' => __('Starts with'),
89
- 'ends-by' => __('Ends by'),
90
- );
91
- $filters_html = '';
92
- foreach( $filters as $_key => $_value ) {
93
- $filters_html .= '<option value="'.$_key.'">' . $_value . '</option>';
94
- }
95
-
96
- $applied_filters = '[{"value":"","type":"all","index":1}]';
97
-
98
- ?>
99
- <input type="hidden" name="scan_anchor_filters" id="wplnst-scan-anchor-filters" value='<?php echo $applied_filters; ?>' />
100
- <table id="wplnst-elist-anchor-filters" class="wplnst-elist" cellspacing="0" cellpadding="0" border="0" data-editable="true" data-label="<?php _e('URL'); ?>"></table>
101
- <?php _e('URL'); ?> <select id="wplnst-af-new-type"><?php echo $filters_html ?></select>&nbsp;
102
- <input id="wplnst-af-new" type="text" class="regular-text" value="" placeholder="<?php _e('Text filter'); ?>" />&nbsp;
103
- <input class="button button-primary" type="button" id="wplnst-af-new-add" value="<?php _e('Add'); ?>" /></td>
104
-
105
- <?php
106
- }
107
-
108
-
109
-
110
- /**
111
- * Output the revisions
112
- */
113
- function revisions_meta_box_callback( $post ) {
114
- $datef = _x( 'F j, Y @ H:i:s', 'revision date format' );
115
- $users = get_users(array('number' => 3));
116
- $revisions = array(
117
- array(
118
- 'ID' => 1,
119
- 'post_author' => $users[0]->display_name,
120
- 'title' => date_i18n( $datef, time() - 86400 ),
121
- ),
122
- array(
123
- 'ID' => 2,
124
- 'post_author' => isset($users[1]) ? $users[1]->display_name : $users[0]->display_name,
125
- 'title' => date_i18n( $datef, time() - 87639),
126
- ),
127
- array(
128
- 'ID' => 3,
129
- 'post_author' => isset($users[2]) ? $users[2]->display_name : $users[0]->display_name,
130
- 'title' => date_i18n( $datef, time() - 97639),
131
- ),
132
- );
133
- ?>
134
- <table class="revisions">
135
- <thead><tr>
136
- <th class="revisions-compare">Compare</th>
137
- <th>Revision</th>
138
- <th>Author</th>
139
- <th><input type="checkbox" name="delete[]" value="all" id="ccj-delete-checkbox" /> Delete</th>
140
- <th>Restore</th>
141
- </tr></thead>
142
- <tbody>
143
- <?php foreach( $revisions as $revision ) : ?>
144
- <?php
145
-
146
- $restore_url = '#';
147
-
148
- $delete_disabled = '';
149
- $delete_tooltip = '';
150
- $class = '';
151
- ?>
152
- <tr class="<?php echo $class; ?>" id="<?php echo 'revision-row-' . $revision['ID']; ?>">
153
- <td class="revisions-compare">
154
- <input type="radio" name="compare_left" value="<?php echo $revision['ID']; ?>" />
155
- <input type="radio" name="compare_right" value="<?php echo $revision['ID']; ?>" />
156
- </td>
157
- <td><?php echo $revision['title']; ?></td>
158
- <td><?php echo $revision['post_author']; ?></td>
159
- <td class="revisions-delete">
160
- <input type="checkbox" name="delete[]" value="<?php echo $revision['ID']; ?>" <?php echo $delete_disabled . $delete_tooltip; ?>/>
161
- </td>
162
- <td class="revisions-restore">
163
- <a href="<?php echo $restore_url; ?>"><?php _e('Restore'); ?></a>
164
- </td>
165
- </tr>
166
- <?php endforeach; ?>
167
- <tr>
168
- <td>
169
- <input type="button" class="button-secondary" value="<?php esc_attr_e('Compare'); ?>" id="revisions-compare-button" />
170
- </td>
171
- <td colspan="2"> &nbsp;</td>
172
- <td>
173
- <input type="button" class="button-secondary" value="<?php esc_attr_e('Delete'); ?>" id="revisions-delete-button" />
174
- </td>
175
- <td> &nbsp; </td>
176
- </tr>
177
- </tbody>
178
- </table>
179
- <?php
180
- }
181
-
182
-
183
-
184
- }
185
-
186
- return new CustomCSSandJS_Addons();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/admin-notices.php DELETED
@@ -1,221 +0,0 @@
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_Notices
13
- */
14
- class CustomCSSandJS_Notices {
15
-
16
- var $prefix = 'ccj_';
17
- var $activation_time = '';
18
- var $version = '';
19
- var $dismiss_notice = '';
20
- var $expiration_days = 2;
21
-
22
- /**
23
- * Constructor
24
- */
25
- public function __construct() {
26
-
27
- $this->set_variables();
28
-
29
- if ( $this->dismiss_notice == 1 ) {
30
- return;
31
- }
32
-
33
- $p = $this->prefix;
34
-
35
- add_action( 'admin_notices', array( $this, 'admin_notices' ) );
36
- add_action( 'wp_ajax_'.$p.'_notice_dismiss', array( $this, 'notice_dismiss' ) );
37
- }
38
-
39
- /**
40
- * Hooked from 'admin_notices'
41
- */
42
- public function admin_notices() {
43
- $screen = get_current_screen();
44
-
45
- if ( !isset($screen->post_type) || $screen->post_type !== 'custom-css-js' )
46
- return;
47
-
48
- if ( ! $notice = $this->choose_notice() )
49
- return;
50
-
51
- if ( time() - $this->activation_time <= 3600 )
52
- return;
53
-
54
- $message = $this->get_message( $notice );
55
-
56
- $this->print_message( $notice, $message );
57
-
58
- }
59
-
60
- /**
61
- * Get the options from the database or set them on install or upgrade
62
- */
63
- public function set_variables() {
64
- $now = time();
65
- $p = $this->prefix;
66
-
67
- $this->activation_time = get_option( $p . '_activation_time', '' );
68
- $this->version = get_option( $p.'_version', '' );
69
- $this->dismiss_notice = get_option( $p.'_dismiss_notice', false );
70
-
71
- if ( empty( $this->activation_time ) || version_compare( $this->version, CCJ_VERSION, '<' ) ) {
72
- $this->activation_time = $now;
73
- update_option( $p.'_activation_time', $now );
74
- update_option( $p.'_version', CCJ_VERSION );
75
- update_option( $p.'_dismiss_notice', false );
76
- }
77
-
78
- }
79
-
80
- /**
81
- * Choose which notice to be shown
82
- */
83
- public function choose_notice() {
84
- $now = time();
85
-
86
- $days_passed = ceil( ( $now - $this->activation_time ) / 86400 );
87
-
88
- switch ( $days_passed ) {
89
- case 1 : return '1_day';
90
- case 2 : return '2_day';
91
- case 3 : break; //return '3_day';
92
- case 4 : break;
93
- case 5 : break;
94
- case 6 : break;
95
- case 7 : break; // return '7_day';
96
- case 8 : break;
97
- case 9 : break;
98
- case 10 : break;
99
- case 11 : break;
100
- case 12 : break; //return '12_day';
101
- }
102
- }
103
-
104
- /**
105
- * Get the text of the message
106
- */
107
- public function get_message( $notice ) {
108
-
109
- $message = '';
110
- $percentage = '30';
111
- $product_name = 'Simple Custom CSS and JS PRO';
112
-
113
- $expiration_date = $this->activation_time + ( $this->expiration_days * 86400 );
114
- $expiration_date = date( get_option( 'date_format') , $expiration_date );
115
-
116
- $expiration_period = date('j M', $this->activation_time - 3*86400 ) . ' - ' . date('j M', $this->activation_time + 2*86400 );
117
-
118
-
119
- if ( $notice == '12_days' ) {
120
- $link = 'https://www.silkypress.com/simple-custom-css-js-pro/?utm_source=wordpress&utm_campaign=ccj_free&utm_medium=banner';
121
- } else {
122
- $link = 'https://www.silkypress.com/simple-custom-css-js-pro/?a=' . $this->convert_numbers_letters( $this->activation_time ) . '&utm_source=wordpress&utm_campaign=ccj_free&utm_medium=banner';
123
- }
124
-
125
- $lower_part = sprintf( '<div style="margin-top: 7px;"><a href="%s" target="_blank">%s</a> | <a href="#" class="dismiss_notice" target="_parent">%s</a></div>', $link, 'Get your discount now', 'Dismiss this notice' );
126
-
127
- switch ( $notice ) {
128
- case '1_day' :
129
- $message = '<div>Only between '. $expiration_period .': <b>'.$percentage.'% Off from <a href="'.$link.'" target="_blank">'.$product_name.'</a></b> for our WordPress.org users.</div>' . $lower_part;
130
- break;
131
-
132
- case '2_day' :
133
- $message = '<div><b>Limited offer ending today</b>. '.$percentage.'% Off from <a href="'.$link.'" target="_blank">'.$product_name.'</a> for our WordPress.org users. </div>' . $lower_part;
134
- break;
135
-
136
- case '3_day' :
137
- $message = '<div><b>Limited offer ending today</b>. '.$percentage.'% Off from '.$product_name.' for our WordPress.org users. </div>' . $lower_part;
138
- break;
139
-
140
- case '7_day' :
141
- $message = '';
142
- break;
143
-
144
- case '12_day' :
145
- $message = '<div><b>Special Offer</b>: 30% Off from '.$product_name.' for our WordPress.org users.</div>' . $lower_part;
146
- break;
147
- }
148
-
149
- return $message;
150
- }
151
-
152
-
153
-
154
- /**
155
- * Print the message
156
- */
157
- public function print_message( $option_name = '', $message = '' ) {
158
- if ( empty( $message ) || empty( $option_name ) )
159
- return;
160
-
161
- $p = $this->prefix;
162
-
163
- ?>
164
- <style type="text/css">
165
- .<?php echo $p; ?>_note{ color: #bc1117; }
166
- #<?php echo $p; ?>_notice { display: block; padding: }
167
- #<?php echo $p; ?>_notice b { color: #bc1117; }
168
- #<?php echo $p; ?>_notice a { text-decoration: none; font-weight: bold; }
169
- #<?php echo $p; ?>_notice a.dismiss_notice { font-weight: normal; }
170
- </style>
171
-
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');
182
- });
183
- });
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>
191
- </button>
192
- </div>
193
- <?php
194
-
195
- }
196
-
197
- function convert_numbers_letters( $text, $from = 'numbers' ) {
198
- $alphabet = str_split('abcdefghij');
199
- $numbers = str_split('0123456789');
200
-
201
- if ( $from == 'numbers' ) {
202
- return str_replace( $numbers, $alphabet, $text );
203
- } else {
204
- return str_replace( $alphabet, $numbers, $text );
205
- }
206
- }
207
-
208
- /**
209
- * Ajax response for `notice_dismiss` action
210
- */
211
- function notice_dismiss() {
212
- $p = $this->prefix;
213
-
214
- update_option( $p.'_dismiss_notice', 1 );
215
-
216
- wp_die();
217
- }
218
- }
219
-
220
-
221
- return new CustomCSSandJS_Notices();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/admin-screens.php CHANGED
@@ -38,50 +38,22 @@ class CustomCSSandJS_Admin {
38
  * Constructor
39
  */
40
  public function __construct() {
41
-
42
- $this->add_functions();
 
 
 
 
 
 
 
 
 
 
43
 
44
  $this->main = CustomCSSandJS();
45
  }
46
 
47
- /**
48
- * Add actions and filters
49
- */
50
- function add_functions() {
51
-
52
- // Add filters
53
- $filters = array(
54
- 'manage_custom-css-js_posts_columns' => 'manage_custom_posts_columns',
55
- );
56
- foreach( $filters as $_key => $_value ) {
57
- add_filter( $_key, array( $this, $_value ) );
58
- }
59
-
60
- // Add actions
61
- $actions = array(
62
- 'admin_menu' => 'admin_menu',
63
- 'admin_enqueue_scripts' => 'admin_enqueue_scripts',
64
- 'current_screen' => 'current_screen',
65
- 'admin_notices' => 'create_uploads_directory',
66
- 'edit_form_after_title' => 'codemirror_editor',
67
- 'add_meta_boxes' => 'add_meta_boxes',
68
- 'save_post' => 'options_save_meta_box_data',
69
- 'trashed_post' => 'trash_post',
70
- 'untrashed_post' => 'trash_post',
71
- 'admin_post_ccj-autosave' => 'ajax_autosave',
72
- 'wp_loaded' => 'compatibility_shortcoder',
73
- 'wp_ajax_ccj_active_code' => 'wp_ajax_ccj_active_code',
74
- );
75
- foreach( $actions as $_key => $_value ) {
76
- add_action( $_key, array( $this, $_value ) );
77
- }
78
-
79
-
80
- // Add some custom actions
81
- add_action( 'manage_custom-css-js_posts_custom_column', array( $this, 'manage_posts_columns' ), 10, 2 );
82
- }
83
-
84
-
85
  /**
86
  * Add submenu pages
87
  */
@@ -89,14 +61,9 @@ class CustomCSSandJS_Admin {
89
  $menu_slug = 'edit.php?post_type=custom-css-js';
90
  $submenu_slug = 'post-new.php?post_type=custom-css-js';
91
 
92
- $title = __('Add Custom CSS');
93
- add_submenu_page( $menu_slug, $title, $title, 'manage_options', $submenu_slug .'&language=css');
94
 
95
- $title = __('Add Custom JS');
96
- add_submenu_page( $menu_slug, $title, $title, 'manage_options', $submenu_slug . '&language=js');
97
-
98
- $title = __('Add Custom HTML');
99
- add_submenu_page( $menu_slug, $title, $title, 'manage_options', $submenu_slug . '&language=html');
100
 
101
  remove_submenu_page( $menu_slug, $submenu_slug);
102
  }
@@ -106,82 +73,24 @@ class CustomCSSandJS_Admin {
106
  * Enqueue the scripts and styles
107
  */
108
  public function admin_enqueue_scripts( $hook ) {
 
 
109
 
110
  $screen = get_current_screen();
111
 
112
- // Only for custom-css-js post type
113
- if ( $screen->post_type != 'custom-css-js' )
114
  return false;
115
 
116
- // Some handy variables
117
- $a = plugins_url( '/', $this->main->plugin_file ). 'assets';
118
- $cm = $a . '/codemirror';
119
- $v = CCJ_VERSION;
120
-
121
- wp_register_script( 'ccj_admin', $a . '/ccj_admin.js', array('jquery', 'jquery-ui-resizable'), $v, false );
122
- wp_localize_script( 'ccj_admin', 'CCJ', $this->cm_localize() );
123
- wp_enqueue_script( 'ccj_admin' );
124
- wp_enqueue_style( 'ccj_admin', $a . '/ccj_admin.css', array(), $v );
125
-
126
-
127
- // Only for the new/edit Code's page
128
- if ( $hook == 'post-new.php' || $hook == 'post.php' ) {
129
- wp_enqueue_style( 'jquery-ui', 'https://code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css', array(), $v );
130
- wp_enqueue_script( 'ccj_codemirror', $cm . '/codemirror-compressed.js', array( 'jquery' ), $v, false);
131
- wp_enqueue_style( 'ccj_codemirror', $cm . '/codemirror-compressed.css', array(), $v );
132
- wp_enqueue_script( 'ccj_admin_url_rules', $a . '/ccj_admin-url_rules.js', array('jquery'), $v, false );
133
- wp_enqueue_script( 'ccj_scrollbars', $cm . '/addon/scroll/simplescrollbars.js', array('ccj_codemirror'), $v, false );
134
- wp_enqueue_style( 'ccj_scrollbars', $cm . '/addon/scroll/simplescrollbars.css', array(), $v );
135
-
136
- // Add the language modes
137
- $cmm = $cm . '/mode/';
138
- wp_enqueue_script('cm-xml', $cmm . 'xml/xml.js', array('ccj_codemirror'), $v, false);
139
- wp_enqueue_script('cm-js', $cmm . 'javascript/javascript.js', array('ccj_codemirror'), $v, false);
140
- wp_enqueue_script('cm-css', $cmm . 'css/css.js', array('ccj_codemirror'), $v, false);
141
- wp_enqueue_script('cm-htmlmixed', $cmm . 'htmlmixed/htmlmixed.js', array('ccj_codemirror'), $v, false);
142
-
143
- $cma = $cm . '/addon/';
144
- wp_enqueue_script('cm-dialog', $cma . 'dialog.js', array('ccj_codemirror'), $v, false);
145
- wp_enqueue_script('cm-search', $cma . 'search.js', array('ccj_codemirror'), $v, false);
146
- wp_enqueue_script('cm-searchcursor', $cma . 'searchcursor.js',array('ccj_codemirror'), $v, false);
147
- wp_enqueue_script('cm-jump-to-line', $cma . 'jump-to-line.js', array('ccj_codemirror'), $v, false);
148
- wp_enqueue_style('cm-matchesonscrollbar', $cma . 'matchesonscrollbar.css', array(), $v );
149
- wp_enqueue_style('cm-dialog', $cma . 'dialog.css', array(), $v );
150
- wp_enqueue_style('cm-matchesonscrollbar', $cma . 'matchesonscrollbar.css', array(), $v );
151
-
152
-
153
- }
154
- }
155
-
156
 
157
- /**
158
- * Send variables to the ccj_admin.js script
159
- */
160
- public function cm_localize() {
161
 
162
- $vars = array(
163
- 'scroll' => '1'
164
- );
165
-
166
- if ( ! function_exists( 'is_plugin_active' ) ) {
167
- require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
168
- }
169
 
170
- // Plugins which conflict with the CodeMirror editor
171
- $conflicting_plugins = array(
172
- 'types/wpcf.php',
173
- 'advanced-ads-code-highlighter/advanced-ads-code-highlighter.php',
174
- 'wp-custom-backend-css/wp-custom-backend-css.php',
175
- 'custom-css-whole-site-and-per-post/h5ab-custom-styling.php',
176
- );
177
 
178
- foreach( $conflicting_plugins as $_plugin ) {
179
- if ( is_plugin_active( $_plugin ) ) {
180
- $vars['scroll'] = '0';
181
- }
182
- }
183
 
184
- return $vars;
185
  }
186
 
187
  public function add_meta_boxes() {
@@ -221,15 +130,15 @@ class CustomCSSandJS_Admin {
221
  return false;
222
  }
223
 
224
- if ( $current_screen->base == 'post' ) {
225
- add_action( 'admin_head', array( $this, 'current_screen_post' ) );
226
- }
227
 
228
- if ( $current_screen->base == 'edit' ) {
229
  add_action( 'admin_head', array( $this, 'current_screen_edit' ) );
230
  }
231
 
232
- wp_deregister_script( 'autosave' );
 
 
233
  }
234
 
235
 
@@ -240,20 +149,73 @@ class CustomCSSandJS_Admin {
240
  function add_new_buttons() {
241
  $current_screen = get_current_screen();
242
 
243
- if ( (isset($current_screen->action ) && $current_screen->action == 'add') || $current_screen->post_type != 'custom-css-js' ) {
244
  return false;
245
  }
246
  ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  <div class="updated buttons">
248
  <a href="post-new.php?post_type=custom-css-js&language=css" class="custom-btn custom-css-btn">Add CSS code</a>
249
  <a href="post-new.php?post_type=custom-css-js&language=js" class="custom-btn custom-js-btn">Add JS code</a>
250
- <a href="post-new.php?post_type=custom-css-js&language=html" class="custom-btn custom-js-btn">Add HTML code</a>
251
  <!-- a href="post-new.php?post_type=custom-css-js&language=php" class="custom-btn custom-php-btn">Add PHP code</a -->
252
  </div>
253
  <?php
254
  }
255
 
256
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
 
258
  /**
259
  * Add new columns in the `edit` screen
@@ -261,7 +223,6 @@ class CustomCSSandJS_Admin {
261
  function manage_custom_posts_columns( $columns ) {
262
  return array(
263
  'cb' => '<input type="checkbox" />',
264
- 'active' => '<span class="ccj-dashicons dashicons dashicons-star-empty" title="Active"></span>',
265
  'type' => 'Type',
266
  'title' => 'Title',
267
  'author' => 'Author',
@@ -282,16 +243,7 @@ class CustomCSSandJS_Admin {
282
  }
283
 
284
  if ( $column == 'modified' ) {
285
- if ( ! isset( $wp_version ) ) {
286
- include( ABSPATH . WPINC . '/version.php' );
287
- }
288
-
289
- if ( version_compare( $wp_version, '4.6', '>=' ) ) {
290
- $m_time = get_the_modified_time( 'G', $post_id );
291
- } else {
292
- $m_time = get_the_modified_time( 'G', false, $post_id );
293
- }
294
-
295
  $time_diff = time() - $m_time;
296
 
297
  if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) {
@@ -302,72 +254,6 @@ class CustomCSSandJS_Admin {
302
 
303
  echo $h_time;
304
  }
305
-
306
- if ( $column == 'active' ) {
307
- $url = wp_nonce_url( admin_url( 'admin-ajax.php?action=ccj_active_code&code_id=' . $post_id ), 'ccj-active-code' );
308
- echo '<a href="' . esc_url( $url ) . '" title="'. __( 'Toggle active' ) . '">';
309
- if ( $this->is_active( $post_id ) ) {
310
- echo '<span class="dashicons dashicons-star-filled" title="The code is active. Click to inactivate it"></span>';
311
- } else {
312
- echo '<span class="dashicons dashicons-star-empty ccj_row" title="The code is inactive. Click to activate it"></span>';
313
- }
314
- echo '</a>';
315
-
316
- }
317
- }
318
-
319
- /**
320
- * Activate/deactivate a code
321
- *
322
- * @return void
323
- */
324
- function wp_ajax_ccj_active_code() {
325
- if ( ! isset( $_GET['code_id'] ) ) die();
326
-
327
- if ( check_admin_referer( 'ccj-active-code' ) ) {
328
- $code_id = absint( $_GET['code_id'] );
329
-
330
- if ( 'custom-css-js' === get_post_type( $code_id ) ) {
331
- $active = get_post_meta($code_id, '_active', true );
332
- if ( $active === false || $active === '' ) {
333
- $active = 'yes';
334
- }
335
- update_post_meta( $code_id, '_active', $active === 'yes' ? 'no' : 'yes' );
336
-
337
- $this->build_search_tree();
338
- }
339
- }
340
-
341
- wp_safe_redirect( wp_get_referer() ? remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'ids' ), wp_get_referer() ) : admin_url( 'edit.php?post_type=custom-css-js' ) );
342
- die();
343
- }
344
-
345
- /**
346
- * Check if a code is active
347
- *
348
- * @return bool
349
- */
350
- function is_active( $post_id ) {
351
- return get_post_meta( $post_id, '_active', true ) !== 'no';
352
- }
353
-
354
- /**
355
- * Reformat the `edit` screen
356
- */
357
- function current_screen_edit() {
358
- ?>
359
- <script type="text/javascript">
360
- /* <![CDATA[ */
361
- jQuery(window).ready(function($){
362
- var h1 = 'Custom Code ';
363
- h1 += '<a href="post-new.php?post_type=custom-css-js&language=css" class="page-title-action">Add CSS Code</a>';
364
- h1 += '<a href="post-new.php?post_type=custom-css-js&language=js" class="page-title-action">Add JS Code</a>';
365
- h1 += '<a href="post-new.php?post_type=custom-css-js&language=html" class="page-title-action">Add HTML Code</a>';
366
- $("#wpbody-content h1").html(h1);
367
- });
368
-
369
- </script>
370
- <?php
371
  }
372
 
373
 
@@ -376,8 +262,6 @@ class CustomCSSandJS_Admin {
376
  * Reformat the `post` screen
377
  */
378
  function current_screen_post() {
379
-
380
- $this->remove_unallowed_metaboxes();
381
 
382
  if ( isset( $_GET['post'] ) ) {
383
  $action = 'Edit';
@@ -390,62 +274,22 @@ class CustomCSSandJS_Admin {
390
 
391
  $title = $action . ' ' . strtoupper( $language ) . ' code';
392
 
393
- if ( $action == 'Edit' ) {
394
- $title .= ' <a href="post-new.php?post_type=custom-css-js&language=css" class="page-title-action">Add CSS Code</a> ';
395
- $title .= '<a href="post-new.php?post_type=custom-css-js&language=js" class="page-title-action">Add JS Code</a>';
396
- $title .= '<a href="post-new.php?post_type=custom-css-js&language=html" class="page-title-action">Add HTML Code</a>';
397
- }
398
-
399
  ?>
400
  <script type="text/javascript">
401
  /* <![CDATA[ */
402
  jQuery(window).ready(function($){
403
- $("#wpbody-content h1").html('<?php echo $title; ?>');
404
  $("#message.updated.notice").html('<p>Code updated</p>');
405
-
406
- var from_top = -$("#normal-sortables").height();
407
- if ( from_top != 0 ) {
408
- $(".ccj_only_premium-first").css('margin-top', from_top.toString() + 'px' );
409
- } else {
410
- $(".ccj_only_premium-first").hide();
411
- }
412
-
413
- /*
414
- $("#normal-sortables").mouseenter(function() {
415
- $(".ccj_only_premium-first div").css('display', 'block');
416
- }).mouseleave(function() {
417
- $(".ccj_only_premium-first div").css('display', 'none');
418
- });
419
- */
420
  });
421
  /* ]]> */
422
  </script>
 
 
 
423
  <?php
424
  }
425
 
426
 
427
- /**
428
- * Remove unallowed metaboxes from custom-css-js edit page
429
- *
430
- * Use the custom-css-js-meta-boxes filter to add/remove allowed metaboxdes on the page
431
- */
432
- function remove_unallowed_metaboxes() {
433
- global $wp_meta_boxes;
434
-
435
- $allowed = array( 'submitdiv', 'custom-code-options' );
436
-
437
- $allowed = apply_filters( 'custom-css-js-meta-boxes', $allowed );
438
-
439
- foreach( $wp_meta_boxes['custom-css-js']['side'] as $_priority => $_boxes ) {
440
- foreach( $_boxes as $_key => $_value ) {
441
- if ( ! in_array( $_key, $allowed ) ) {
442
- unset( $wp_meta_boxes['custom-css-js']['side'][$_priority][$_key] );
443
- }
444
- }
445
- }
446
- }
447
-
448
-
449
 
450
  /**
451
  * Add the codemirror editor in the `post` screen
@@ -470,59 +314,26 @@ class CustomCSSandJS_Admin {
470
  switch ( $language ) {
471
  case 'js' :
472
  if ( $new_post ) {
473
- $post->post_content = '/* Add your JavaScript code here.
474
-
475
- If you are using the jQuery library, then don\'t forget to wrap your code inside jQuery.ready() as follows:
476
-
477
- jQuery(document).ready(function( $ ){
478
- // Your code in here
479
- });
480
-
481
- End of comment */ ' . PHP_EOL . PHP_EOL;
482
  }
483
  $code_mirror_mode = 'text/javascript';
484
  $code_mirror_before = '<script type="text/javascript">';
485
  $code_mirror_after = '</script>';
486
  break;
487
- case 'html' :
488
- if ( $new_post ) {
489
- $post->post_content = '<!-- Add HTML code to the header or the footer.
490
-
491
- For example, you can use the following code for loading the jQuery library from Google CDN:
492
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
493
-
494
- or the following one for loading the Bootstrap library from MaxCDN:
495
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
496
-
497
- -- End of the comment --> ' . PHP_EOL . PHP_EOL;
498
- }
499
- $code_mirror_mode = 'html';
500
- $code_mirror_before = '';
501
- $code_mirror_after = '';
502
- break;
503
-
504
  case 'php' :
505
  if ( $new_post ) {
506
  $post->post_content = '/* The following will be executed as if it were written in functions.php. */' . PHP_EOL . PHP_EOL;
507
  }
508
- $code_mirror_mode = 'php';
509
  $code_mirror_before = '<?php';
510
  $code_mirror_after = '?>';
511
 
512
  break;
513
  default :
514
  if ( $new_post ) {
515
- $post->post_content = '/* Add your CSS code here.
516
-
517
- For example:
518
- .example {
519
- color: red;
520
- }
521
-
522
- For brushing up on your CSS knowledge, check out http://www.w3schools.com/css/css_syntax.asp
523
-
524
- End of comment */ ' . PHP_EOL . PHP_EOL;
525
-
526
  }
527
  $code_mirror_mode = 'text/css';
528
  $code_mirror_before = '<style type="text/css">';
@@ -531,15 +342,65 @@ End of comment */ ' . PHP_EOL . PHP_EOL;
531
  }
532
 
533
  ?>
534
- <form style="position: relative; margin-top: .5em;">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
535
 
536
- <div class="code-mirror-before"><div><?php echo htmlentities( $code_mirror_before );?></div></div>
537
- <textarea class="wp-editor-area" id="content" mode="<?php echo htmlentities($code_mirror_mode); ?>" name="content"><?php echo htmlentities($post->post_content); ?></textarea>
538
- <div class="code-mirror-after"><div><?php echo htmlentities( $code_mirror_after );?></div></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
539
 
540
- <input type="hidden" id="update-post_<?php echo $post->ID ?>" value="<?php echo wp_create_nonce('update-post_'. $post->ID ); ?>" />
 
 
541
  </form>
542
- <?php
 
 
 
 
 
 
 
 
 
543
 
544
  }
545
 
@@ -551,253 +412,99 @@ End of comment */ ' . PHP_EOL . PHP_EOL;
551
  function custom_code_options_meta_box_callback( $post ) {
552
 
553
  $options = $this->get_options( $post->ID );
554
- if ( ! isset($options['preprocessor'] ) )
555
- $options['preprocessor'] = 'none';
556
-
557
 
558
  if ( isset( $_GET['language'] ) ) {
559
  $options['language'] = $_GET['language'];
560
  }
561
 
562
- $meta = $this->get_options_meta();
563
- if ( $options['language'] == 'html' ) {
564
- $meta = $this->get_options_meta_html();
 
 
 
 
 
 
 
 
 
 
 
 
 
565
  }
566
 
 
 
 
567
 
568
- wp_nonce_field( 'options_save_meta_box_data', 'custom-css-js_meta_box_nonce' );
 
 
569
 
 
570
  ?>
 
 
 
 
 
 
 
 
 
 
571
  <div class="options_meta_box">
572
- <?php
 
 
 
 
573
 
574
- $output = '';
575
-
576
- foreach( $meta as $_key => $a ) {
577
- $close_div = false;
578
-
579
- if ( ($_key == 'preprocessor' && $options['language'] == 'css') ||
580
- ($_key == 'linking' && $options['language'] == 'html') ||
581
- $_key == 'priority' ||
582
- $_key == 'minify' ) {
583
- $close_div = true;
584
- $output .= '<div class="ccj_opaque">';
585
- }
586
 
587
- // Don't show Pre-processors for JavaScript Codes
588
- if ( $options['language'] == 'js' && $_key == 'preprocessor' ) {
589
- continue;
590
- }
 
591
 
592
- $output .= '<h3>' . $a['title'] . '</h3>' . PHP_EOL;
593
 
594
- $output .= $this->render_input( $_key, $a, $options );
 
 
 
595
 
596
- if ( $close_div ) {
597
- $output .= '</div>';
 
 
 
 
598
  }
599
 
 
600
  }
601
 
602
- echo $output;
603
-
604
  ?>
 
 
 
605
 
606
- <input type="hidden" name="custom_code_language" value="<?php echo $options['language']; ?>" />
607
-
608
- <div style="clear: both;"></div>
609
 
610
- </div>
611
 
612
- <div class="ccj_only_premium ccj_only_premium-right">
613
- <div>
614
- <a href="https://www.silkypress.com/simple-custom-css-js-pro/?utm_source=wordpress&utm_campaign=ccj_free&utm_medium=banner" target="_blank">Available only in <br />Simple Custom CSS and JS Pro</a>
615
- </div>
616
  </div>
617
 
 
618
 
619
- <?php
620
- }
621
-
622
-
623
- /**
624
- * Get an array with all the information for building the code's options
625
- */
626
- function get_options_meta() {
627
- $options = array(
628
- 'linking' => array(
629
- 'title' => 'Linking type',
630
- 'type' => 'radio',
631
- 'default' => 'internal',
632
- 'values' => array(
633
- 'external' => array(
634
- 'title' => 'External File',
635
- 'dashicon' => 'media-code',
636
- ),
637
- 'internal' => array(
638
- 'title' => 'Internal',
639
- 'dashicon' => 'editor-alignleft',
640
- ),
641
- ),
642
- ),
643
- 'type' => array(
644
- 'title' => 'Where on page',
645
- 'type' => 'radio',
646
- 'default' => 'header',
647
- 'values' => array(
648
- 'header' => array(
649
- 'title' => 'Header',
650
- 'dashicon' => 'arrow-up-alt2',
651
- ),
652
- 'footer' => array(
653
- 'title' => 'Footer',
654
- 'dashicon' => 'arrow-down-alt2',
655
- ),
656
- ),
657
- ),
658
- 'side' => array(
659
- 'title' => 'Where in site',
660
- 'type' => 'radio',
661
- 'default' => 'frontend',
662
- 'values' => array(
663
- 'frontend' => array(
664
- 'title' => 'In Frontend',
665
- 'dashicon' => 'tagcloud',
666
- ),
667
- 'admin' => array(
668
- 'title' => 'In Admin',
669
- 'dashicon' => 'id',
670
- ),
671
- ),
672
- ),
673
- 'preprocessor' => array(
674
- 'title' => 'CSS Preprocessor',
675
- 'type' => 'radio',
676
- 'default' => 'none',
677
- 'values' => array(
678
- 'none' => array(
679
- 'title' => 'None',
680
- ),
681
- 'less' => array(
682
- 'title' => 'Less',
683
- ),
684
- 'sass' => array(
685
- 'title' => 'SASS (only SCSS syntax)',
686
- ),
687
- ),
688
- 'disabled' => true,
689
- ),
690
- 'minify' => array(
691
- 'title' => 'Minify the code',
692
- 'type' => 'checkbox',
693
- 'default' => false,
694
- 'dashicon' => 'editor-contract',
695
- 'disabled' => true,
696
- ),
697
- 'priority' => array(
698
- 'title' => 'Priority',
699
- 'type' => 'select',
700
- 'default' => 5,
701
- 'dashicon' => 'sort',
702
- 'values' => array(
703
- 1 => '1 (highest)',
704
- 2 => '2',
705
- 3 => '3',
706
- 4 => '4',
707
- 5 => '5',
708
- 6 => '6',
709
- 7 => '7',
710
- 8 => '8',
711
- 9 => '9',
712
- 10 => '10 (lowest)',
713
- ),
714
- 'disabled' => true,
715
- ),
716
- );
717
-
718
- return $options;
719
- }
720
-
721
-
722
- /**
723
- * Get an array with all the information for building the code's options
724
- */
725
- function get_options_meta_html() {
726
- $options = array(
727
- 'type' => array(
728
- 'title' => 'Where on page',
729
- 'type' => 'radio',
730
- 'default' => 'header',
731
- 'values' => array(
732
- 'header' => array(
733
- 'title' => 'Header',
734
- 'dashicon' => 'arrow-up-alt2',
735
- ),
736
- 'footer' => array(
737
- 'title' => 'Footer',
738
- 'dashicon' => 'arrow-down-alt2',
739
- ),
740
- ),
741
- ),
742
- 'side' => array(
743
- 'title' => 'Where in site',
744
- 'type' => 'radio',
745
- 'default' => 'frontend',
746
- 'values' => array(
747
- 'frontend' => array(
748
- 'title' => 'In Frontend',
749
- 'dashicon' => 'tagcloud',
750
- ),
751
- 'admin' => array(
752
- 'title' => 'In Admin',
753
- 'dashicon' => 'id',
754
- ),
755
- ),
756
- ),
757
- 'linking' => array(
758
- 'title' => 'On which device',
759
- 'type' => 'radio',
760
- 'default' => 'both',
761
- 'dashicon' => '',
762
- 'values' => array(
763
- 'desktop' => array(
764
- 'title' => 'Desktop',
765
- 'dashicon' => 'desktop',
766
- ),
767
- 'mobile' => array(
768
- 'title' => 'Mobile',
769
- 'dashicon' => 'smartphone',
770
- ),
771
- 'both' => array(
772
- 'title' => 'Both',
773
- 'dashicon' => 'tablet',
774
- ),
775
- ),
776
- 'disabled' => true,
777
- ),
778
- 'priority' => array(
779
- 'title' => 'Priority',
780
- 'type' => 'select',
781
- 'default' => 5,
782
- 'dashicon' => 'sort',
783
- 'values' => array(
784
- 1 => '1 (highest)',
785
- 2 => '2',
786
- 3 => '3',
787
- 4 => '4',
788
- 5 => '5',
789
- 6 => '6',
790
- 7 => '7',
791
- 8 => '8',
792
- 9 => '9',
793
- 10 => '10 (lowest)',
794
- ),
795
- 'disabled' => true,
796
- ),
797
 
798
- );
799
 
800
- return $options;
801
  }
802
 
803
 
@@ -806,6 +513,7 @@ End of comment */ ' . PHP_EOL . PHP_EOL;
806
  */
807
  function options_save_meta_box_data( $post_id ) {
808
 
 
809
  // The usual checks
810
  if ( ! isset( $_POST['custom-css-js_meta_box_nonce'] ) ) {
811
  return;
@@ -832,27 +540,12 @@ End of comment */ ' . PHP_EOL . PHP_EOL;
832
  'language' => 'css',
833
  );
834
 
835
- if ( $_POST['custom_code_language'] == 'html' ) {
836
- $defaults = array(
837
- 'type' => 'header',
838
- 'linking' => 'both',
839
- 'side' => 'frontend',
840
- 'language' => 'html',
841
- 'priority' => 5,
842
- );
843
- }
844
-
845
  foreach( $defaults as $_field => $_default ) {
846
  $options[ $_field ] = isset( $_POST['custom_code_'.$_field] ) ? $_POST['custom_code_'.$_field] : $_default;
847
  }
848
 
849
  update_post_meta( $post_id, 'options', $options );
850
 
851
- if ( $options['language'] == 'html' ) {
852
- $this->build_search_tree();
853
- return;
854
- }
855
-
856
 
857
  // Save the Custom Code in a file in `wp-content/uploads/custom-css-js`
858
  if ( $options['linking'] == 'internal' ) {
@@ -864,10 +557,8 @@ End of comment */ ' . PHP_EOL . PHP_EOL;
864
  $after = '</style>' . PHP_EOL . $after;
865
  }
866
  if ( $options['language'] == 'js' ) {
867
- if ( ! preg_match( '/<script\b[^>]*>([\s\S]*?)<\/script>/im', $_POST['content'] ) ) {
868
  $before .= '<script type="text/javascript">' . PHP_EOL;
869
  $after = '</script>' . PHP_EOL . $after;
870
- }
871
  }
872
  }
873
 
@@ -881,93 +572,34 @@ End of comment */ ' . PHP_EOL . PHP_EOL;
881
  $file_name = $post_id . '.' . $options['language'];
882
  $file_content = $before . stripslashes($_POST['content']) . $after;
883
  @file_put_contents( $this->main->upload_dir . '/' . $file_name , $file_content );
884
- }
885
-
886
-
887
- $this->build_search_tree();
888
- }
889
-
890
- /**
891
- * Create the custom-css-js dir in uploads directory
892
- *
893
- * Show a message if the directory is not writable
894
- *
895
- * Create an empty index.php file inside
896
- */
897
- function create_uploads_directory() {
898
- $current_screen = get_current_screen();
899
-
900
- // Check if we are editing a custom-css-js post
901
- if ( $current_screen->base != 'post' || $current_screen->post_type != 'custom-css-js' ) {
902
- return false;
903
- }
904
-
905
- $dir = $this->main->upload_dir;
906
-
907
- // Create the dir if it doesn't exist
908
- if ( ! file_exists( $dir ) ) {
909
- wp_mkdir_p( $dir );
910
  }
911
 
912
- // Show a message if it couldn't create the dir
913
- if ( ! file_exists( $dir ) ) : ?>
914
- <div class="notice notice-error is-dismissible">
915
- <p>The <b>custom-css-js</b> directory could not be created</p>
916
- <p>Please run the following commands in order to make the directory: <br /><strong>mkdir <?php echo $dir; ?>; </strong><br /><strong>chmod 777 <?php echo $dir; ?>;</strong></p>
917
- </div>
918
- <?php return; endif;
919
-
920
-
921
- // Show a message if the dir is not writable
922
- if ( ! wp_is_writable( $dir ) ) : ?>
923
- <div class="notice notice-error is-dismissible">
924
- <p>The <b><?php echo $dir; ?></b> directory is not writable, therefore the CSS and JS files cannot be saved.</p>
925
- <p>Please run the following command to make the directory writable:<br /><strong>chmod 777 <?php echo $dir; ?> </strong></p>
926
- </div>
927
- <?php return; endif;
928
-
929
 
930
- // Write a blank index.php
931
- if ( ! file_exists( $dir. '/index.php' ) ) {
932
- $content = '<?php' . PHP_EOL . '// Silence is golden.';
933
- @file_put_contents( $dir. '/index.php', $content );
934
- }
935
  }
936
 
937
 
938
  /**
939
  * Build a tree where you can quickly find the needed custom-css-js posts
940
- *
941
- * @return void
942
  */
943
  private function build_search_tree() {
944
 
945
- // Retrieve all the custom-css-js codes
946
  $posts = query_posts( 'post_type=custom-css-js&post_status=publish&nopaging=true' );
947
 
 
 
 
 
948
  $tree = array();
949
  foreach ( $posts as $_post ) {
950
- if ( ! $this->is_active( $_post->ID ) ) {
951
- continue;
952
- }
953
-
954
  $options = $this->get_options( $_post->ID );
955
 
956
- // Get the branch name, example: frontend-css-header-external
957
  $tree_branch = $options['side'] . '-' .$options['language'] . '-' . $options['type'] . '-' . $options['linking'];
958
 
959
- $filename = $_post->ID . '.' . $options['language'];
960
-
961
- if ( $options['linking'] == 'external' ) {
962
- $filename .= '?v=' . rand(1, 10000);
963
- }
964
-
965
- // Add the code file to the tree branch
966
- $tree[ $tree_branch ][] = $filename;
967
 
968
  }
969
 
970
- // Save the tree in the database
971
  update_option( 'custom-css-js-tree', $tree );
972
  }
973
 
@@ -992,61 +624,6 @@ End of comment */ ' . PHP_EOL . PHP_EOL;
992
  return str_replace( 'QTags.addButton', '// QTags.addButton', $html );
993
  }
994
 
995
- /**
996
- * Render the checkboxes, radios, selects and inputs
997
- */
998
- function render_input( $_key, $a, $options ) {
999
- $name = 'custom_code_' . $_key;
1000
- $output = '';
1001
-
1002
- // Show radio type options
1003
- if ( $a['type'] === 'radio' ) {
1004
- $output .= '<div class="radio-group">' . PHP_EOL;
1005
- foreach( $a['values'] as $__key => $__value ) {
1006
- $selected = '';
1007
- $id = $name . '-' . $__key;
1008
- $dashicons = isset($__value['dashicon'] ) ? 'dashicons-before dashicons-' . $__value['dashicon'] : '';
1009
- if ( isset( $a['disabled'] ) && $a['disabled'] ) {
1010
- $selected = ' disabled="disabled"';
1011
- }
1012
- $selected .= ( $__key == $options[$_key] ) ? ' checked="checked" ' : '';
1013
- $output .= '<input type="radio" '. $selected.'value="'.$__key.'" name="'.$name.'" id="'.$id.'">' . PHP_EOL;
1014
- $output .= '<label class="'.$dashicons.'" for="'.$id.'"> '.$__value['title'].'</label><br />' . PHP_EOL;
1015
- }
1016
- $output .= '</div>' . PHP_EOL;
1017
- }
1018
-
1019
- // Show checkbox type options
1020
- if ( $a['type'] == 'checkbox' ) {
1021
- $dashicons = isset($a['dashicon'] ) ? 'dashicons-before dashicons-' . $a['dashicon'] : '';
1022
- $selected = ( isset($options[$_key]) && $options[$_key] == '1') ? ' checked="checked" ' : '';
1023
- if ( isset( $a['disabled'] ) && $a['disabled'] ) {
1024
- $selected .= ' disabled="disabled"';
1025
- }
1026
- $output .= '<div class="radio-group">' . PHP_EOL;
1027
- $output .= '<input type="checkbox" '.$selected.' value="1" name="'.$name.'" id="'.$name.'">' . PHP_EOL;
1028
- $output .= '<label class="'.$dashicons.'" for="'.$name.'"> '.$a['title'].'</label>';
1029
- $output .= '</div>' . PHP_EOL;
1030
- }
1031
-
1032
-
1033
- // Show select type options
1034
- if ( $a['type'] == 'select' ) {
1035
- $output .= '<div class="radio-group">' . PHP_EOL;
1036
- $output .= '<select name="'.$name.'" id="'.$name.'">' . PHP_EOL;
1037
- foreach( $a['values'] as $__key => $__value ) {
1038
- $selected = ( isset($options[$_key]) && $options[$_key] == $__key) ? ' selected="selected"' : '';
1039
- $output .= '<option value="'.$__key.'"'.$selected.'>' . $__value . '</option>' . PHP_EOL;
1040
- }
1041
- $output .= '</select>' . PHP_EOL;
1042
- $output .= '</div>' . PHP_EOL;
1043
- }
1044
-
1045
-
1046
- return $output;
1047
-
1048
- }
1049
-
1050
 
1051
  }
1052
 
38
  * Constructor
39
  */
40
  public function __construct() {
41
+ add_action( 'admin_menu', array( $this, 'admin_menu' ) );
42
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
43
+ add_action( 'current_screen', array( $this, 'current_screen' ) );
44
+ add_action( 'admin_notices', array( $this, 'add_new_buttons' ) );
45
+ add_filter( 'manage_custom-css-js_posts_columns', array( $this, 'manage_custom_posts_columns' ) );
46
+ add_action( 'manage_custom-css-js_posts_custom_column', array( $this, 'manage_posts_columns' ), 10, 2 );
47
+ add_action( 'edit_form_after_title', array( $this, 'codemirror_editor' ) );
48
+ add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
49
+ add_action( 'save_post', array( $this, 'options_save_meta_box_data' ) );
50
+ add_action( 'trashed_post', array( $this, 'trash_post') );
51
+ add_action( 'untrashed_post', array( $this, 'trash_post') );
52
+ add_action( 'wp_loaded', array( $this, 'compatibility_shortcoder' ) );
53
 
54
  $this->main = CustomCSSandJS();
55
  }
56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  /**
58
  * Add submenu pages
59
  */
61
  $menu_slug = 'edit.php?post_type=custom-css-js';
62
  $submenu_slug = 'post-new.php?post_type=custom-css-js';
63
 
64
+ add_submenu_page( $menu_slug, __('Add Custom CSS'), __('Add Custom CSS'), 'manage_options', $submenu_slug .'&language=css');
 
65
 
66
+ add_submenu_page( $menu_slug, __('Add Custom JS'), __('Add Custom JS'), 'manage_options', $submenu_slug . '&language=js');
 
 
 
 
67
 
68
  remove_submenu_page( $menu_slug, $submenu_slug);
69
  }
73
  * Enqueue the scripts and styles
74
  */
75
  public function admin_enqueue_scripts( $hook ) {
76
+ if ( $hook != 'post-new.php' && $hook != 'post.php' )
77
+ return false;
78
 
79
  $screen = get_current_screen();
80
 
81
+ if ( $screen->post_type != 'custom-css-js' )
 
82
  return false;
83
 
84
+ $cm = plugins_url( '/', $this->main->plugin_file ). 'assets/codemirror/';
85
+ $version = $this->main->version;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
 
87
+ wp_enqueue_script( 'codemirror', $cm . 'codemirror-compressed.js', array('jquery'), $version, false );
 
 
 
88
 
 
 
 
 
 
 
 
89
 
90
+ wp_enqueue_style( 'codemirror', $cm . 'codemirror-compressed.css' , array(), $version );
91
+ //wp_enqueue_style( 'codemirror_theme', $cm . 'theme/3024-night.css' , array(), $version );
 
 
 
 
 
92
 
 
 
 
 
 
93
 
 
94
  }
95
 
96
  public function add_meta_boxes() {
130
  return false;
131
  }
132
 
133
+ wp_deregister_script( 'autosave' );
 
 
134
 
135
+ if ( $current_screen->base == 'edit' ) {
136
  add_action( 'admin_head', array( $this, 'current_screen_edit' ) );
137
  }
138
 
139
+ if ( $current_screen->base == 'post' ) {
140
+ add_action( 'admin_head', array( $this, 'current_screen_post' ) );
141
+ }
142
  }
143
 
144
 
149
  function add_new_buttons() {
150
  $current_screen = get_current_screen();
151
 
152
+ if ( $current_screen->base != 'edit' || $current_screen->post_type != 'custom-css-js' ) {
153
  return false;
154
  }
155
  ?>
156
+ <style type="text/css">
157
+ .updated.buttons {
158
+ border: none;
159
+ background-color: transparent;
160
+ box-shadow: none;
161
+ padding: 0;
162
+ margin: 15px 0 15px !important;
163
+ }
164
+ .custom-btn {
165
+ background: #0c73b8;
166
+ border-radius: 2px;
167
+ color: #ffffff;
168
+ font-size: 17px;
169
+ padding: 10px 20px 10px 20px !important;
170
+ text-decoration: none;
171
+ }
172
+ .custom-btn:hover {
173
+ color: #fff;
174
+ background: #2eaadd;
175
+ text-decoration: none;
176
+ }
177
+ .custom-js-btn { background: #e4a228; }
178
+ .custom-js-btn:hover { background: #eebf31; }
179
+ .custom-php-btn { background: #e45126; }
180
+ .custom-php-btn:hover { background: #f6652c; }
181
+ </style>
182
  <div class="updated buttons">
183
  <a href="post-new.php?post_type=custom-css-js&language=css" class="custom-btn custom-css-btn">Add CSS code</a>
184
  <a href="post-new.php?post_type=custom-css-js&language=js" class="custom-btn custom-js-btn">Add JS code</a>
 
185
  <!-- a href="post-new.php?post_type=custom-css-js&language=php" class="custom-btn custom-php-btn">Add PHP code</a -->
186
  </div>
187
  <?php
188
  }
189
 
190
 
191
+ /**
192
+ * Reformat the `edit` screen
193
+ */
194
+ function current_screen_edit() {
195
+ ?>
196
+ <style type="text/css">
197
+ h1 .page-title-action { display: none; }
198
+ .inline.hide-if-no-js{ display: none; }
199
+ .view-switch { display: none; }
200
+ #modified { width: 140px; }
201
+ #type.manage-column { width: 50px; }
202
+ .language {
203
+ background: #0c73b8;
204
+ border-radius: 2px;
205
+ color: #ffffff;
206
+ font-size: 12px;
207
+ padding: 5px 10px !important;
208
+ text-decoration: none;
209
+ }
210
+ .language-js { background: #e4a228; }
211
+ .language-php { background: #e45126; }
212
+ .type.column-type, .check-column { vertical-align: middle !important; }
213
+
214
+ </style>
215
+ <?php
216
+ }
217
+
218
+
219
 
220
  /**
221
  * Add new columns in the `edit` screen
223
  function manage_custom_posts_columns( $columns ) {
224
  return array(
225
  'cb' => '<input type="checkbox" />',
 
226
  'type' => 'Type',
227
  'title' => 'Title',
228
  'author' => 'Author',
243
  }
244
 
245
  if ( $column == 'modified' ) {
246
+ $m_time = get_the_modified_time( 'G', true, get_post( $post_id ) );
 
 
 
 
 
 
 
 
 
247
  $time_diff = time() - $m_time;
248
 
249
  if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) {
254
 
255
  echo $h_time;
256
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  }
258
 
259
 
262
  * Reformat the `post` screen
263
  */
264
  function current_screen_post() {
 
 
265
 
266
  if ( isset( $_GET['post'] ) ) {
267
  $action = 'Edit';
274
 
275
  $title = $action . ' ' . strtoupper( $language ) . ' code';
276
 
 
 
 
 
 
 
277
  ?>
278
  <script type="text/javascript">
279
  /* <![CDATA[ */
280
  jQuery(window).ready(function($){
281
+ $("#wpbody-content h1").text('<?php echo $title; ?>');
282
  $("#message.updated.notice").html('<p>Code updated</p>');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
  });
284
  /* ]]> */
285
  </script>
286
+ <style type="text/css">
287
+ .update.notice a { display: none; }
288
+ </style>
289
  <?php
290
  }
291
 
292
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
293
 
294
  /**
295
  * Add the codemirror editor in the `post` screen
314
  switch ( $language ) {
315
  case 'js' :
316
  if ( $new_post ) {
317
+ $post->post_content = '/* Your code goes here */ ' . PHP_EOL . PHP_EOL;
 
 
 
 
 
 
 
 
318
  }
319
  $code_mirror_mode = 'text/javascript';
320
  $code_mirror_before = '<script type="text/javascript">';
321
  $code_mirror_after = '</script>';
322
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
  case 'php' :
324
  if ( $new_post ) {
325
  $post->post_content = '/* The following will be executed as if it were written in functions.php. */' . PHP_EOL . PHP_EOL;
326
  }
327
+ $code_mirror_mode = 'text/php';
328
  $code_mirror_before = '<?php';
329
  $code_mirror_after = '?>';
330
 
331
  break;
332
  default :
333
  if ( $new_post ) {
334
+ $post->post_content .= '.example {' . PHP_EOL;
335
+ $post->post_content .= "\t" . 'color: #eee;' . PHP_EOL;
336
+ $post->post_content .= '}' . PHP_EOL . PHP_EOL;
 
 
 
 
 
 
 
 
337
  }
338
  $code_mirror_mode = 'text/css';
339
  $code_mirror_before = '<style type="text/css">';
342
  }
343
 
344
  ?>
345
+ <style type="text/css">
346
+ .page-title-action { display: none; }
347
+ #minor-publishing { display: none; }
348
+ #post-body #normal-sortables { min-height: 0px; }
349
+ .CodeMirror {
350
+ height: 384px;
351
+ margin-top: 0px;
352
+ border: 1px solid #ddd;
353
+ border-bottom: none;
354
+ border-top: none;
355
+ }
356
+ .CodeMirror pre { padding-left: 7px; line-height: 1.25; }
357
+
358
+ .CodeMirrorBefore {
359
+ margin-top: 15px;
360
+ border: 1px solid #ddd;
361
+ border-bottom: none;
362
+ background-color: #f7f7f7;
363
+ }
364
+ .CodeMirrorBefore div {
365
+ color: #8F8F8F;
366
+ margin-left: 29px;
367
+ border-left: 1px solid #ddd;
368
+ padding: 3px 8px;
369
+ background-color: #fff;
370
+ }
371
 
372
+ .CodeMirrorAfter {
373
+ border: 1px solid #ddd;
374
+ border-top: none;
375
+ background-color: #f7f7f7;
376
+ }
377
+ .CodeMirrorAfter div {
378
+ color: #8F8F8F;
379
+ margin-left: 29px;
380
+ border-left: 1px solid #ddd;
381
+ padding: 3px 8px;
382
+ background-color: #fff;
383
+ }
384
+ .cm-s-default .cm-atom { color: #549d18; }
385
+ .cm-s-default .cm-property { color: #b62625; }
386
+ .cm-s-default .cm-qualifier, .cm-s-default .cm-tag { color: #4731E4; }
387
+ </style>
388
+ <form style="position: relative; margin-top: .5em;">
389
 
390
+ <div class="CodeMirrorBefore"><div><?php echo htmlentities( $code_mirror_before );?></div></div>
391
+ <textarea id="custom-code" name="content"><?php echo $post->post_content; ?></textarea>
392
+ <div class="CodeMirrorAfter"><div><?php echo htmlentities( $code_mirror_after );?></div></div>
393
  </form>
394
+ <script>
395
+ window.onload = function() {
396
+ var editor = CodeMirror.fromTextArea(document.getElementById("custom-code"), {
397
+ lineNumbers: true,
398
+ mode: "<?php echo $code_mirror_mode; ?>",
399
+ matchBrackets: true
400
+ });
401
+ }
402
+ </script>
403
+ <?php
404
 
405
  }
406
 
412
  function custom_code_options_meta_box_callback( $post ) {
413
 
414
  $options = $this->get_options( $post->ID );
 
 
 
415
 
416
  if ( isset( $_GET['language'] ) ) {
417
  $options['language'] = $_GET['language'];
418
  }
419
 
420
+ $selected = array(
421
+ 'header' => '',
422
+ 'footer' => '',
423
+ 'internal' => '',
424
+ 'external' => '',
425
+ 'priority' => 5,
426
+ 'frontend' => '',
427
+ 'admin' => '',
428
+ );
429
+
430
+ if ( isset( $options['priority'] ) ) {
431
+ $selected['priority'] = $options['priority'];
432
+ }
433
+
434
+ if ( isset( $options['type'] ) ) {
435
+ $selected[ $options['type'] ] = ' checked="checked"';
436
  }
437
 
438
+ if ( isset( $options['linking'] ) ) {
439
+ $selected[ $options['linking'] ] = ' checked="checked"';
440
+ }
441
 
442
+ if ( isset( $options['side'] ) ) {
443
+ $selected[ $options['side'] ] = ' checked="checked"';
444
+ }
445
 
446
+ wp_nonce_field( 'options_save_meta_box_data', 'custom-css-js_meta_box_nonce' );
447
  ?>
448
+ <style type="text/css">
449
+ .radio-group input { margin-top: 1px; }
450
+ .radio-group label { padding: 2px 0; }
451
+ .options_meta_box h3 { margin-top: 10px !important; }
452
+ .radio-group { line-height: 30px; padding-left: 10px; }
453
+ .radio-group .dashicons-before:before { margin: 7px 3px 0 3px; }
454
+ .options_meta_box select { margin-left: 10px; }
455
+ </style>
456
+
457
+
458
  <div class="options_meta_box">
459
+ <h3>Linking type</h3>
460
+ <div class="radio-group">
461
+ <input type="radio" <?php echo $selected['internal']; ?>value="internal" name="custom_code_linking" id="custom_code_linking-internal"><label class="dashicons-before dashicons-editor-alignleft" for="custom_code_linking-internal"> In the HTML Document</label><br />
462
+ <input type="radio" <?php echo $selected['external']; ?>value="external" name="custom_code_linking" id="custom_code_linking-external"><label class="dashicons-before dashicons-media-code" for="custom_code_linking-external"> External File</label><br />
463
+ </div>
464
 
 
 
 
 
 
 
 
 
 
 
 
 
465
 
466
+ <h3>Where on page</h3>
467
+ <div class="radio-group">
468
+ <input type="radio" <?php echo $selected['header']; ?>value="header" name="custom_code_type" id="custom_code_type-header"><label class="dashicons-before dashicons-arrow-up-alt2" for="custom_code_type-header"> Header</label><br />
469
+ <input type="radio" <?php echo $selected['footer']; ?>value="footer" name="custom_code_type" id="custom_code_type-footer"><label class="dashicons-before dashicons-arrow-down-alt2" for="custom_code_type-footer"> Footer</label><br />
470
+ </div>
471
 
 
472
 
473
+ <?php /*
474
+ <h3>Priority</h3>
475
+ <select name="custom_code_priority">
476
+ <?php
477
 
478
+ $priorities = array( 1 => '1 highest', '2', '3', '4', '5 default', '6', '7', '8', '9', '10 lowest');
479
+
480
+ foreach( $priorities as $_key => $_value ) {
481
+ $checked = '';
482
+ if ( $_key == $selected['priority'] ) {
483
+ $checked = 'selected="selected" ';
484
  }
485
 
486
+ echo "\t" . '<option value="'.$_key.'"'.$checked .'>'.$_value.'</option>' . PHP_EOL;
487
  }
488
 
 
 
489
  ?>
490
+ </select>
491
+ */ ?>
492
+ <input type="hidden" name="custom_code_priority" value="5" />
493
 
 
 
 
494
 
 
495
 
496
+ <h3>Where in site</h3>
497
+ <div class="radio-group">
498
+ <input type="radio" <?php echo $selected['frontend']; ?>value="frontend" name="custom_code_side" id="custom_code_side-frontend"><label class="dashicons-before dashicons-tagcloud" for="custom_code_side-frontend"> In Frontend</label><br />
499
+ <input type="radio" <?php echo $selected['admin']; ?>value="admin" name="custom_code_side" id="custom_code_side-admin"><label class="dashicons-before dashicons-id" for="custom_code_side-admin"> In Admin</label><br />
500
  </div>
501
 
502
+ <input type="hidden" name="custom_code_language" value="<?php echo $options['language']; ?>" />
503
 
504
+ <div style="clear: both;"></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
505
 
 
506
 
507
+ <?php
508
  }
509
 
510
 
513
  */
514
  function options_save_meta_box_data( $post_id ) {
515
 
516
+
517
  // The usual checks
518
  if ( ! isset( $_POST['custom-css-js_meta_box_nonce'] ) ) {
519
  return;
540
  'language' => 'css',
541
  );
542
 
 
 
 
 
 
 
 
 
 
 
543
  foreach( $defaults as $_field => $_default ) {
544
  $options[ $_field ] = isset( $_POST['custom_code_'.$_field] ) ? $_POST['custom_code_'.$_field] : $_default;
545
  }
546
 
547
  update_post_meta( $post_id, 'options', $options );
548
 
 
 
 
 
 
549
 
550
  // Save the Custom Code in a file in `wp-content/uploads/custom-css-js`
551
  if ( $options['linking'] == 'internal' ) {
557
  $after = '</style>' . PHP_EOL . $after;
558
  }
559
  if ( $options['language'] == 'js' ) {
 
560
  $before .= '<script type="text/javascript">' . PHP_EOL;
561
  $after = '</script>' . PHP_EOL . $after;
 
562
  }
563
  }
564
 
572
  $file_name = $post_id . '.' . $options['language'];
573
  $file_content = $before . stripslashes($_POST['content']) . $after;
574
  @file_put_contents( $this->main->upload_dir . '/' . $file_name , $file_content );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
575
  }
576
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
577
 
578
+ $this->build_search_tree();
 
 
 
 
579
  }
580
 
581
 
582
  /**
583
  * Build a tree where you can quickly find the needed custom-css-js posts
 
 
584
  */
585
  private function build_search_tree() {
586
 
 
587
  $posts = query_posts( 'post_type=custom-css-js&post_status=publish&nopaging=true' );
588
 
589
+ if ( ! is_array( $posts ) || count( $posts ) == 0 ) {
590
+ return false;
591
+ }
592
+
593
  $tree = array();
594
  foreach ( $posts as $_post ) {
 
 
 
 
595
  $options = $this->get_options( $_post->ID );
596
 
 
597
  $tree_branch = $options['side'] . '-' .$options['language'] . '-' . $options['type'] . '-' . $options['linking'];
598
 
599
+ $tree[ $tree_branch ][] = $_post->ID . '.' . $options['language'] ;
 
 
 
 
 
 
 
600
 
601
  }
602
 
 
603
  update_option( 'custom-css-js-tree', $tree );
604
  }
605
 
624
  return str_replace( 'QTags.addButton', '// QTags.addButton', $html );
625
  }
626
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
627
 
628
  }
629
 
includes/admin-warnings.php DELETED
@@ -1,100 +0,0 @@
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_Warnings
13
- */
14
- class CustomCSSandJS_Warnings {
15
-
16
- /**
17
- * Constructor
18
- */
19
- public function __construct() {
20
-
21
- if ( ! function_exists( 'is_plugin_active' ) ) {
22
- require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
23
- }
24
-
25
- $this->check_qtranslatex();
26
- add_action( 'wp_ajax_ccj_dismiss', array( $this, 'notice_dismiss' ) );
27
- }
28
-
29
- /**
30
- * Check if qTranslate plugin is active and doesn't have the custom-css-js removed from the settings
31
- */
32
- function check_qtranslatex() {
33
-
34
- if ( ! is_plugin_active( 'qtranslate-x/qtranslate.php' ) ) return false;
35
-
36
- if ( get_option('ccj_dismiss_qtranslate') !== false ) {
37
- return;
38
- }
39
-
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
- }
47
- }
48
-
49
- /**
50
- * Show a warning about qTranslate
51
- */
52
- function check_qtranslate_notice() {
53
- $id = 'ccj_dismiss_qtranslate';
54
- $class = 'notice notice-warning is-dismissible';
55
- $message = __( '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="https://www.silkypress.com/wp-content/uploads/2016/08/ccj_qtranslate_compatibility.png" target="_blank">this screenshot</a> for more details on how to do that.' );
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
-
61
- }
62
-
63
- /**
64
- * Allow the dismiss button to remove the notice
65
- */
66
- function dismiss_js( $slug ) {
67
- ?>
68
- <script type='text/javascript'>
69
- jQuery(function($){
70
- $(document).on( 'click', '#<?php echo $slug; ?> .notice-dismiss', function() {
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');
77
- });
78
- });
79
- });
80
- </script>
81
- <?php
82
- }
83
-
84
-
85
- /**
86
- * Ajax response for `notice_dismiss` action
87
- */
88
- function notice_dismiss() {
89
-
90
- $option = $_POST['option'];
91
-
92
- update_option( $option, 1 );
93
-
94
- wp_die();
95
- }
96
-
97
- }
98
-
99
-
100
- return new CustomCSSandJS_Warnings();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -5,8 +5,8 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=diana
5
  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.7
9
- Stable tag: 2.10
10
  License: GPLv3
11
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
12
 
@@ -25,6 +25,8 @@ Customize your WordPress site's appearance by easily adding custom CSS and JS co
25
  * Keep your changes also when you change the theme
26
 
27
  = Frequently Asked Questions =
 
 
28
 
29
  * **What if I want to add multiple external CSS codes?**
30
  If you write multiple codes of the same type (for example: two external CSS codes), then all of them will be printed one after another
@@ -48,7 +50,7 @@ Yes.
48
  The CSS and JS are independent of the theme and they will persist through a theme change. This is particularly useful if you apply CSS and JS for modifying a plugin's output.
49
 
50
  * **Can I use a CSS preprocesor like LESS or Sass?**
51
- For the moment only plain CSS is supported, but you can check out the [Pro version](https://www.silkypress.com/simple-custom-css-js-pro/?utm_source=wordpress&utm_campaign=ccj_free&utm_medium=banner) in case you need a CSS preprocessor.
52
 
53
  * **Can I upload images for use with my CSS?**
54
  Yes. You can upload an image to your Media Library, then refer to it by its direct URL from within the CSS stylesheet. For example:
@@ -100,9 +102,6 @@ PHP >= 5.3
100
  * Internet Explorer - version 8 and up
101
  * Opera - version 9 and up
102
 
103
- = Small incompatibilities =
104
- * 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.
105
-
106
  == Screenshots ==
107
 
108
  1. Manage Custom Codes
@@ -111,69 +110,10 @@ PHP >= 5.3
111
 
112
  3. Add/Edit CSS
113
 
114
- $. Add/Edit HTML
115
-
116
  == Changelog ==
117
 
118
- = 2.10 =
119
- * 02/05/2016
120
- * Feature: circumvent external file caching by adding a GET parameter
121
- * Add special offer for Simple Custom CSS and JS pro
122
-
123
- = 2.9 =
124
- * 12/05/2016
125
- * Compatibility with WP4.7. The "custom HTML code" was not showing up anymore
126
-
127
- = 2.8 =
128
- * 10/09/2016
129
- * Feature: add search within the editor accessible with Ctrl+F
130
- * Feature: make the inactive rows opaque
131
-
132
- = 2.7 =
133
- * 09/04/2016
134
- * Fix: there was a space in the htmlmixed.%20js url
135
- * Feature: make the editor resizable
136
-
137
- = 2.6 =
138
- * 08/31/2016
139
- * Feature: add HTML code
140
- * Fix: add htmlentities when showing them in the editor
141
- * Feature: when adding a code, show more explanations as comments
142
-
143
- = 2.5 =
144
- * 08/25/2016
145
- * Fix: compatibility with other plugins that interfere with the CodeMirror editor
146
-
147
- = 2.4 =
148
- * 08/01/2016
149
- * Add the "Add CSS Code" and "Add JS Code" buttons next to the page title
150
- * Compatibility with WP 4.6: the "Modified" column in the Codes listing was empty
151
-
152
- = 2.3 =
153
- * 06/22/2016
154
- * Add the includes/admin-notices.php and includes/admin-addons.php
155
- * Feature: change the editor's scrollbar so it can be caught with the mouse
156
-
157
- = 2.2 =
158
- * 06/22/2016
159
- * Check compatibility WordPress 4.5.3
160
- * Add special offer for Simple Custom CSS and JS pro
161
-
162
- = 2.1 =
163
- * 04/24/2016
164
- * Fix: on multisite installs have to create the custom-css-js folder in the upload dir for each site
165
- * Fix: the `deactivate code` star wasn't working when first time clicked
166
- * Fix: In the add/edit Code page filter which meta boxes are allowed
167
- * Fix: If the custom-css-js folder is not created of is not writable, issue an admin notice.
168
-
169
- = 2.0 =
170
- * 04/11/2016
171
- * Feature: enable/disable codes
172
- * Feature: add a GET parameter at the end of external files in order to over circumvent caching
173
- * Fix: don't add the "<script>" tag from the code if already present.
174
-
175
  = 1.6 =
176
- * 03/26/2016
177
  * Fix: the number of codes were limited because query_posts is automatically inserting a limit
178
 
179
  = 1.5 =
5
  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.4.2
9
+ Stable tag: 1.6
10
  License: GPLv3
11
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
12
 
25
  * Keep your changes also when you change the theme
26
 
27
  = Frequently Asked Questions =
28
+ * **Can I recover the codes if I previous uninstalled the plugin?**
29
+ No, on the `Custom CSS and JS` plugin's uninstall all the added code will be removed. Before uninstalling make sure you don't need the codes anymore.
30
 
31
  * **What if I want to add multiple external CSS codes?**
32
  If you write multiple codes of the same type (for example: two external CSS codes), then all of them will be printed one after another
50
  The CSS and JS are independent of the theme and they will persist through a theme change. This is particularly useful if you apply CSS and JS for modifying a plugin's output.
51
 
52
  * **Can I use a CSS preprocesor like LESS or Sass?**
53
+ No, for the moment only plain CSS is supported.
54
 
55
  * **Can I upload images for use with my CSS?**
56
  Yes. You can upload an image to your Media Library, then refer to it by its direct URL from within the CSS stylesheet. For example:
102
  * Internet Explorer - version 8 and up
103
  * Opera - version 9 and up
104
 
 
 
 
105
  == Screenshots ==
106
 
107
  1. Manage Custom Codes
110
 
111
  3. Add/Edit CSS
112
 
 
 
113
  == Changelog ==
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  = 1.6 =
116
+ * 04/26/2016
117
  * Fix: the number of codes were limited because query_posts is automatically inserting a limit
118
 
119
  = 1.5 =
screenshot-1.jpg DELETED
Binary file
screenshot-2.jpg DELETED
Binary file
screenshot-3.jpg DELETED
Binary file
screenshot-4.jpg DELETED
Binary file