Version Description
- 08/01/2016
- Add the "Add CSS Code" and "Add JS Code" buttons next to the page title
- Compatibility with WP 4.6: the "Modified" column in the Codes listing was empty
Download this release
Release Info
Developer | diana_burduja |
Plugin | Simple Custom CSS and JS |
Version | 2.4 |
Comparing to | |
See all releases |
Code changes from version 2.10 to 2.4
- assets/ccj_admin.css +5 -12
- assets/ccj_admin.js +1 -44
- assets/codemirror/addon/dialog.css +0 -32
- assets/codemirror/addon/dialog.js +0 -157
- assets/codemirror/addon/jump-to-line.js +0 -49
- assets/codemirror/addon/matchesonscrollbar.css +0 -8
- assets/codemirror/addon/search.js +0 -249
- assets/codemirror/addon/searchcursor.js +0 -189
- assets/codemirror/mode/xml/xml.js +0 -394
- custom-css-js.php +45 -31
- includes/admin-addons.php +1 -1
- includes/admin-notices.php +17 -26
- includes/admin-screens.php +43 -251
- readme.txt +5 -34
- screenshot-1.jpg +0 -0
- screenshot-2.jpg +0 -0
- screenshot-3.jpg +0 -0
- screenshot-4.jpg +0 -0
assets/ccj_admin.css
CHANGED
@@ -46,11 +46,7 @@
|
|
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; }
|
@@ -62,6 +58,7 @@
|
|
62 |
*/
|
63 |
#content {
|
64 |
width: 100%;
|
|
|
65 |
padding-left: 36px;
|
66 |
border-top: 0;
|
67 |
border-bottom: 0;
|
@@ -70,6 +67,7 @@
|
|
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;
|
@@ -163,10 +161,6 @@ i.ccj-i-fullscreen:before {
|
|
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 |
|
@@ -358,7 +352,7 @@ height: 3px;
|
|
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:
|
362 |
}
|
363 |
.ccj_only_premium a {
|
364 |
color: white; text-decoration: none;
|
@@ -370,10 +364,9 @@ height: 3px;
|
|
370 |
.ccj_only_premium-right {
|
371 |
width: 80px;
|
372 |
margin-left: 130px;
|
373 |
-
margin-top: -
|
374 |
}
|
375 |
.ccj_only_premium-right>div {
|
376 |
-
width:
|
377 |
padding: 10px;
|
378 |
-
margin-left: -110px;
|
379 |
}
|
46 |
}
|
47 |
.language-js { background: #e4a228; }
|
48 |
.language-php { background: #e45126; }
|
|
|
49 |
.widefat td, .widefat th, .type.column-type, .check-column, .column-active { vertical-align: middle !important; }
|
|
|
|
|
|
|
50 |
.column-options span { margin-left: 7px; }
|
51 |
.column-active .dashicons { font-size: 17px; }
|
52 |
.column-active a, .column-active a:active, .column-active a:hover, .column-active a:focus { display: block; outline: 0; border: 0; text-decoration: none; }
|
58 |
*/
|
59 |
#content {
|
60 |
width: 100%;
|
61 |
+
height: 352px;
|
62 |
padding-left: 36px;
|
63 |
border-top: 0;
|
64 |
border-bottom: 0;
|
67 |
#minor-publishing { display: none; }
|
68 |
#post-body #normal-sortables { min-height: 0px; }
|
69 |
.CodeMirror {
|
70 |
+
height: 372px !important;
|
71 |
margin-top: 0px;
|
72 |
border: 1px solid #ddd;
|
73 |
border-bottom: none;
|
161 |
.radio-group { line-height: 30px; padding-left: 10px; }
|
162 |
.radio-group .dashicons-before:before { margin: 7px 3px 0 3px; }
|
163 |
.options_meta_box select { margin-left: 10px; }
|
|
|
|
|
|
|
|
|
164 |
|
165 |
|
166 |
|
352 |
color: white;
|
353 |
}
|
354 |
.ccj_only_premium>div {
|
355 |
+
font-family:sans-serif;font-size:13px;text-align: center; border-radius: 5px; float: left; background-color: rgb(51, 51, 51); color: white; width: 147px; padding: 20px 50px;
|
356 |
}
|
357 |
.ccj_only_premium a {
|
358 |
color: white; text-decoration: none;
|
364 |
.ccj_only_premium-right {
|
365 |
width: 80px;
|
366 |
margin-left: 130px;
|
367 |
+
margin-top: -60px;
|
368 |
}
|
369 |
.ccj_only_premium-right>div {
|
370 |
+
width: 100px;
|
371 |
padding: 10px;
|
|
|
372 |
}
|
assets/ccj_admin.js
CHANGED
@@ -1,60 +1,17 @@
|
|
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:
|
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 |
|
1 |
jQuery(document).ready( function($) {
|
2 |
|
|
|
|
|
3 |
// Initialize the CodeMirror editor
|
4 |
if ( $('#content').length > 0 ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
var options = {
|
6 |
lineNumbers: true,
|
7 |
+
mode: $("#content").attr('mode'),
|
8 |
matchBrackets: true
|
9 |
};
|
10 |
if ( typeof CCJ !== 'undefined' && CCJ.scroll !== '0' ) {
|
11 |
options['scrollbarStyle'] = "simple";
|
12 |
}
|
13 |
|
|
|
|
|
|
|
|
|
14 |
var editor = CodeMirror.fromTextArea(document.getElementById("content"), options);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
});
|
17 |
|
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/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 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
custom-css-js.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Simple Custom CSS and JS
|
4 |
* Plugin URI: https://wordpress.org/plugins/custom-css-js/
|
5 |
* Description: Easily add Custom CSS or JS to your website with an awesome editor.
|
6 |
-
* Version: 2.
|
7 |
* Author: Diana Burduja
|
8 |
* Author URI: https://www.silkypress.com/
|
9 |
* License: GPL2
|
@@ -15,7 +15,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
15 |
}
|
16 |
|
17 |
if ( ! class_exists( 'CustomCSSandJS' ) ) :
|
18 |
-
define( 'CCJ_VERSION', '2.
|
19 |
/**
|
20 |
* Main CustomCSSandJS Class
|
21 |
*
|
@@ -73,9 +73,9 @@ 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 +84,8 @@ final class CustomCSSandJS {
|
|
84 |
return false;
|
85 |
}
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
}
|
90 |
}
|
91 |
|
92 |
/**
|
@@ -94,15 +93,40 @@ final class CustomCSSandJS {
|
|
94 |
*/
|
95 |
function print_code_actions() {
|
96 |
foreach( $this->search_tree as $_key => $_value ) {
|
97 |
-
$action = '
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
}
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
$action .= 'footer';
|
105 |
}
|
|
|
106 |
add_action( $action, array( $this, 'print_' . $_key ) );
|
107 |
}
|
108 |
}
|
@@ -112,7 +136,7 @@ final class CustomCSSandJS {
|
|
112 |
*/
|
113 |
public function __call( $function, $args ) {
|
114 |
|
115 |
-
if (
|
116 |
return false;
|
117 |
}
|
118 |
|
@@ -129,15 +153,15 @@ final class CustomCSSandJS {
|
|
129 |
}
|
130 |
|
131 |
// print the `internal` code
|
132 |
-
if (
|
133 |
|
134 |
$before = '<!-- start Simple Custom CSS and JS -->' . PHP_EOL;
|
135 |
$after = '<!-- end Simple Custom CSS and JS -->' . PHP_EOL;
|
136 |
-
if (
|
137 |
$before .= '<style type="text/css">' . PHP_EOL;
|
138 |
$after = '</style>' . PHP_EOL . $after;
|
139 |
}
|
140 |
-
if (
|
141 |
$before .= '<script type="text/javascript">' . PHP_EOL;
|
142 |
$after = '</script>' . PHP_EOL . $after;
|
143 |
}
|
@@ -154,35 +178,25 @@ final class CustomCSSandJS {
|
|
154 |
}
|
155 |
|
156 |
// link the `external` code
|
157 |
-
if (
|
158 |
$in_footer = false;
|
159 |
-
if (
|
160 |
$in_footer = true;
|
161 |
}
|
162 |
|
163 |
-
if (
|
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 (
|
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 |
/**
|
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.4
|
7 |
* Author: Diana Burduja
|
8 |
* Author URI: https://www.silkypress.com/
|
9 |
* License: GPL2
|
15 |
}
|
16 |
|
17 |
if ( ! class_exists( 'CustomCSSandJS' ) ) :
|
18 |
+
define( 'CCJ_VERSION', '2.4' );
|
19 |
/**
|
20 |
* Main CustomCSSandJS Class
|
21 |
*
|
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-notices.php' );
|
77 |
include_once( 'includes/admin-addons.php' );
|
78 |
include_once( 'includes/admin-warnings.php' );
|
|
|
79 |
}
|
80 |
|
81 |
$this->search_tree = get_option( 'custom-css-js-tree' );
|
84 |
return false;
|
85 |
}
|
86 |
|
87 |
+
$this->print_code_actions();
|
88 |
+
|
|
|
89 |
}
|
90 |
|
91 |
/**
|
93 |
*/
|
94 |
function print_code_actions() {
|
95 |
foreach( $this->search_tree as $_key => $_value ) {
|
96 |
+
$action = '';
|
97 |
+
switch( $_key ) {
|
98 |
+
case 'admin-css-header-external' :
|
99 |
+
case 'admin-js-header-external' :
|
100 |
+
case 'admin-css-header-internal' :
|
101 |
+
case 'admin-js-header-internal' :
|
102 |
+
$action = 'admin_head';
|
103 |
+
break;
|
104 |
+
|
105 |
+
case 'admin-css-footer-external' :
|
106 |
+
case 'admin-js-footer-external' :
|
107 |
+
case 'admin-css-footer-internal' :
|
108 |
+
case 'admin-js-footer-internal' :
|
109 |
+
$action = 'admin_footer';
|
110 |
+
break;
|
111 |
+
|
112 |
+
case 'frontend-css-header-external' :
|
113 |
+
case 'frontend-css-footer-external' :
|
114 |
+
case 'frontend-css-header-internal' :
|
115 |
+
case 'frontend-js-header-internal' :
|
116 |
+
case 'frontend-js-header-external' :
|
117 |
+
$action = 'wp_head';
|
118 |
+
break;
|
119 |
+
case 'frontend-css-footer-internal' :
|
120 |
+
case 'frontend-js-footer-internal' :
|
121 |
+
case 'frontend-js-footer-external' :
|
122 |
+
$action = 'wp_footer';
|
123 |
+
break;
|
124 |
}
|
125 |
+
|
126 |
+
if ( $action == '' ) {
|
127 |
+
continue;
|
|
|
128 |
}
|
129 |
+
|
130 |
add_action( $action, array( $this, 'print_' . $_key ) );
|
131 |
}
|
132 |
}
|
136 |
*/
|
137 |
public function __call( $function, $args ) {
|
138 |
|
139 |
+
if ( strstr( $function, 'print_' ) == false ) {
|
140 |
return false;
|
141 |
}
|
142 |
|
153 |
}
|
154 |
|
155 |
// print the `internal` code
|
156 |
+
if ( strstr( $function, 'internal' ) ) {
|
157 |
|
158 |
$before = '<!-- start Simple Custom CSS and JS -->' . PHP_EOL;
|
159 |
$after = '<!-- end Simple Custom CSS and JS -->' . PHP_EOL;
|
160 |
+
if ( strstr( $function, 'css' ) ) {
|
161 |
$before .= '<style type="text/css">' . PHP_EOL;
|
162 |
$after = '</style>' . PHP_EOL . $after;
|
163 |
}
|
164 |
+
if ( strstr( $function, 'js' ) ) {
|
165 |
$before .= '<script type="text/javascript">' . PHP_EOL;
|
166 |
$after = '</script>' . PHP_EOL . $after;
|
167 |
}
|
178 |
}
|
179 |
|
180 |
// link the `external` code
|
181 |
+
if ( strstr( $function, 'external' ) ) {
|
182 |
$in_footer = false;
|
183 |
+
if ( strstr( $function, 'footer' ) ) {
|
184 |
$in_footer = true;
|
185 |
}
|
186 |
|
187 |
+
if ( strstr( $function, 'js' ) ) {
|
188 |
foreach( $args as $_filename ) {
|
189 |
echo PHP_EOL . "<script type='text/javascript' src='".$this->upload_url . '/' . $_filename."'></script>" . PHP_EOL;
|
190 |
}
|
191 |
}
|
192 |
|
193 |
+
if ( strstr( $function, 'css' ) ) {
|
194 |
foreach( $args as $_filename ) {
|
195 |
$shortfilename = preg_replace( '@\.css\?v=.*$@', '', $_filename );
|
196 |
echo PHP_EOL . "<link rel='stylesheet' id='".$shortfilename ."-css' href='".$this->upload_url . '/' . $_filename ."' type='text/css' media='all' />" . PHP_EOL;
|
197 |
}
|
198 |
}
|
199 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
}
|
201 |
|
202 |
/**
|
includes/admin-addons.php
CHANGED
@@ -39,7 +39,7 @@ class CustomCSSandJS_Addons {
|
|
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
|
43 |
</div>
|
44 |
</div>
|
45 |
<?php
|
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/" target="_blank">Only available in Premium version</a>
|
43 |
</div>
|
44 |
</div>
|
45 |
<?php
|
includes/admin-notices.php
CHANGED
@@ -17,7 +17,7 @@ class CustomCSSandJS_Notices {
|
|
17 |
var $activation_time = '';
|
18 |
var $version = '';
|
19 |
var $dismiss_notice = '';
|
20 |
-
var $expiration_days =
|
21 |
|
22 |
/**
|
23 |
* Constructor
|
@@ -40,17 +40,10 @@ class CustomCSSandJS_Notices {
|
|
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 );
|
@@ -88,16 +81,16 @@ class CustomCSSandJS_Notices {
|
|
88 |
switch ( $days_passed ) {
|
89 |
case 1 : return '1_day';
|
90 |
case 2 : return '2_day';
|
91 |
-
case 3 :
|
92 |
-
case 4 :
|
93 |
-
case 5 :
|
94 |
-
case 6 :
|
95 |
-
case 7 :
|
96 |
-
case 8 :
|
97 |
-
case 9 :
|
98 |
-
case 10 :
|
99 |
-
case 11 :
|
100 |
-
case 12 :
|
101 |
}
|
102 |
}
|
103 |
|
@@ -107,30 +100,28 @@ class CustomCSSandJS_Notices {
|
|
107 |
public function get_message( $notice ) {
|
108 |
|
109 |
$message = '';
|
110 |
-
$percentage = '
|
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
|
121 |
} else {
|
122 |
-
$link = 'https://www.silkypress.com/simple-custom-css-js-pro/?a=' . $this->convert_numbers_letters( $this->activation_time )
|
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
|
126 |
|
127 |
switch ( $notice ) {
|
128 |
case '1_day' :
|
129 |
-
$message = '<div>
|
130 |
break;
|
131 |
|
132 |
case '2_day' :
|
133 |
-
$message = '<div><b>Limited offer ending
|
134 |
break;
|
135 |
|
136 |
case '3_day' :
|
17 |
var $activation_time = '';
|
18 |
var $version = '';
|
19 |
var $dismiss_notice = '';
|
20 |
+
var $expiration_days = 3;
|
21 |
|
22 |
/**
|
23 |
* Constructor
|
40 |
* Hooked from 'admin_notices'
|
41 |
*/
|
42 |
public function admin_notices() {
|
|
|
|
|
|
|
|
|
43 |
|
44 |
if ( ! $notice = $this->choose_notice() )
|
45 |
return;
|
46 |
|
|
|
|
|
|
|
47 |
$message = $this->get_message( $notice );
|
48 |
|
49 |
$this->print_message( $notice, $message );
|
81 |
switch ( $days_passed ) {
|
82 |
case 1 : return '1_day';
|
83 |
case 2 : return '2_day';
|
84 |
+
case 3 : return '3_day';
|
85 |
+
case 4 :
|
86 |
+
case 5 :
|
87 |
+
case 6 :
|
88 |
+
case 7 : return '7_day';
|
89 |
+
case 8 :
|
90 |
+
case 9 :
|
91 |
+
case 10 :
|
92 |
+
case 11 :
|
93 |
+
case 12 : return '12_day';
|
94 |
}
|
95 |
}
|
96 |
|
100 |
public function get_message( $notice ) {
|
101 |
|
102 |
$message = '';
|
103 |
+
$percentage = '40';
|
104 |
$product_name = 'Simple Custom CSS and JS PRO';
|
105 |
|
106 |
$expiration_date = $this->activation_time + ( $this->expiration_days * 86400 );
|
107 |
$expiration_date = date( get_option( 'date_format') , $expiration_date );
|
108 |
|
|
|
|
|
109 |
|
110 |
if ( $notice == '12_days' ) {
|
111 |
+
$link = 'https://www.silkypress.com/simple-custom-css-js-pro-offer/';
|
112 |
} else {
|
113 |
+
$link = 'https://www.silkypress.com/simple-custom-css-js-pro-special-offer/?a=' . $this->convert_numbers_letters( $this->activation_time );
|
114 |
}
|
115 |
|
116 |
+
$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 ' . $product_name, 'Dismiss this notice' );
|
117 |
|
118 |
switch ( $notice ) {
|
119 |
case '1_day' :
|
120 |
+
$message = '<div><b>Limited offer ending on '. $expiration_date .'</b>. '.$percentage.'% Off from '.$product_name.' for our WordPress.org users.</div>' . $lower_part;
|
121 |
break;
|
122 |
|
123 |
case '2_day' :
|
124 |
+
$message = '<div><b>Limited offer ending in 1 day (on '. $expiration_date .')</b>. '.$percentage.'% Off from '.$product_name.' for our WordPress.org users. </div>' . $lower_part;
|
125 |
break;
|
126 |
|
127 |
case '3_day' :
|
includes/admin-screens.php
CHANGED
@@ -95,9 +95,6 @@ class CustomCSSandJS_Admin {
|
|
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 |
}
|
103 |
|
@@ -118,7 +115,7 @@ class CustomCSSandJS_Admin {
|
|
118 |
$cm = $a . '/codemirror';
|
119 |
$v = CCJ_VERSION;
|
120 |
|
121 |
-
wp_register_script( 'ccj_admin', $a . '/ccj_admin.js', array('jquery'
|
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 );
|
@@ -126,30 +123,11 @@ class CustomCSSandJS_Admin {
|
|
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 |
|
@@ -247,7 +225,6 @@ class CustomCSSandJS_Admin {
|
|
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
|
@@ -309,7 +286,7 @@ class CustomCSSandJS_Admin {
|
|
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
|
313 |
}
|
314 |
echo '</a>';
|
315 |
|
@@ -362,7 +339,6 @@ class CustomCSSandJS_Admin {
|
|
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 |
|
@@ -393,7 +369,6 @@ class CustomCSSandJS_Admin {
|
|
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 |
?>
|
@@ -470,37 +445,12 @@ class CustomCSSandJS_Admin {
|
|
470 |
switch ( $language ) {
|
471 |
case 'js' :
|
472 |
if ( $new_post ) {
|
473 |
-
$post->post_content = '/*
|
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;
|
@@ -512,17 +462,9 @@ or the following one for loading the Bootstrap library from MaxCDN:
|
|
512 |
break;
|
513 |
default :
|
514 |
if ( $new_post ) {
|
515 |
-
$post->post_content
|
516 |
-
|
517 |
-
|
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">';
|
@@ -534,7 +476,7 @@ End of comment */ ' . PHP_EOL . PHP_EOL;
|
|
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
|
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 ); ?>" />
|
@@ -554,16 +496,12 @@ End of comment */ ' . PHP_EOL . PHP_EOL;
|
|
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 |
|
@@ -574,13 +512,8 @@ End of comment */ ' . PHP_EOL . PHP_EOL;
|
|
574 |
$output = '';
|
575 |
|
576 |
foreach( $meta as $_key => $a ) {
|
577 |
-
$close_div = false;
|
578 |
|
579 |
-
if (
|
580 |
-
($_key == 'linking' && $options['language'] == 'html') ||
|
581 |
-
$_key == 'priority' ||
|
582 |
-
$_key == 'minify' ) {
|
583 |
-
$close_div = true;
|
584 |
$output .= '<div class="ccj_opaque">';
|
585 |
}
|
586 |
|
@@ -589,11 +522,41 @@ End of comment */ ' . PHP_EOL . PHP_EOL;
|
|
589 |
continue;
|
590 |
}
|
591 |
|
592 |
-
$output .= '<h3>' . $a['title'] . '</h3>' . PHP_EOL;
|
593 |
|
594 |
-
$output .=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
595 |
|
596 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
597 |
$output .= '</div>';
|
598 |
}
|
599 |
|
@@ -611,7 +574,7 @@ End of comment */ ' . PHP_EOL . PHP_EOL;
|
|
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
|
615 |
</div>
|
616 |
</div>
|
617 |
|
@@ -694,113 +657,12 @@ End of comment */ ' . PHP_EOL . PHP_EOL;
|
|
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 |
-
|
804 |
/**
|
805 |
* Save the post and the metadata
|
806 |
*/
|
@@ -832,27 +694,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' ) {
|
@@ -992,61 +839,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 |
|
95 |
$title = __('Add Custom JS');
|
96 |
add_submenu_page( $menu_slug, $title, $title, 'manage_options', $submenu_slug . '&language=js');
|
97 |
|
|
|
|
|
|
|
98 |
remove_submenu_page( $menu_slug, $submenu_slug);
|
99 |
}
|
100 |
|
115 |
$cm = $a . '/codemirror';
|
116 |
$v = CCJ_VERSION;
|
117 |
|
118 |
+
wp_register_script( 'ccj_admin', $a . '/ccj_admin.js', array('jquery'), $v, false );
|
119 |
wp_localize_script( 'ccj_admin', 'CCJ', $this->cm_localize() );
|
120 |
wp_enqueue_script( 'ccj_admin' );
|
121 |
wp_enqueue_style( 'ccj_admin', $a . '/ccj_admin.css', array(), $v );
|
123 |
|
124 |
// Only for the new/edit Code's page
|
125 |
if ( $hook == 'post-new.php' || $hook == 'post.php' ) {
|
|
|
126 |
wp_enqueue_script( 'ccj_codemirror', $cm . '/codemirror-compressed.js', array( 'jquery' ), $v, false);
|
127 |
wp_enqueue_style( 'ccj_codemirror', $cm . '/codemirror-compressed.css', array(), $v );
|
128 |
wp_enqueue_script( 'ccj_admin_url_rules', $a . '/ccj_admin-url_rules.js', array('jquery'), $v, false );
|
129 |
wp_enqueue_script( 'ccj_scrollbars', $cm . '/addon/scroll/simplescrollbars.js', array('ccj_codemirror'), $v, false );
|
130 |
wp_enqueue_style( 'ccj_scrollbars', $cm . '/addon/scroll/simplescrollbars.css', array(), $v );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
}
|
132 |
}
|
133 |
|
225 |
<div class="updated buttons">
|
226 |
<a href="post-new.php?post_type=custom-css-js&language=css" class="custom-btn custom-css-btn">Add CSS code</a>
|
227 |
<a href="post-new.php?post_type=custom-css-js&language=js" class="custom-btn custom-js-btn">Add JS code</a>
|
|
|
228 |
<!-- a href="post-new.php?post_type=custom-css-js&language=php" class="custom-btn custom-php-btn">Add PHP code</a -->
|
229 |
</div>
|
230 |
<?php
|
286 |
if ( $this->is_active( $post_id ) ) {
|
287 |
echo '<span class="dashicons dashicons-star-filled" title="The code is active. Click to inactivate it"></span>';
|
288 |
} else {
|
289 |
+
echo '<span class="dashicons dashicons-star-empty" title="The code is inactive. Click to activate it"></span>';
|
290 |
}
|
291 |
echo '</a>';
|
292 |
|
339 |
var h1 = 'Custom Code ';
|
340 |
h1 += '<a href="post-new.php?post_type=custom-css-js&language=css" class="page-title-action">Add CSS Code</a>';
|
341 |
h1 += '<a href="post-new.php?post_type=custom-css-js&language=js" class="page-title-action">Add JS Code</a>';
|
|
|
342 |
$("#wpbody-content h1").html(h1);
|
343 |
});
|
344 |
|
369 |
if ( $action == 'Edit' ) {
|
370 |
$title .= ' <a href="post-new.php?post_type=custom-css-js&language=css" class="page-title-action">Add CSS Code</a> ';
|
371 |
$title .= '<a href="post-new.php?post_type=custom-css-js&language=js" class="page-title-action">Add JS Code</a>';
|
|
|
372 |
}
|
373 |
|
374 |
?>
|
445 |
switch ( $language ) {
|
446 |
case 'js' :
|
447 |
if ( $new_post ) {
|
448 |
+
$post->post_content = '/* Your code goes here */ ' . PHP_EOL . PHP_EOL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
449 |
}
|
450 |
$code_mirror_mode = 'text/javascript';
|
451 |
$code_mirror_before = '<script type="text/javascript">';
|
452 |
$code_mirror_after = '</script>';
|
453 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
454 |
case 'php' :
|
455 |
if ( $new_post ) {
|
456 |
$post->post_content = '/* The following will be executed as if it were written in functions.php. */' . PHP_EOL . PHP_EOL;
|
462 |
break;
|
463 |
default :
|
464 |
if ( $new_post ) {
|
465 |
+
$post->post_content .= '.example {' . PHP_EOL;
|
466 |
+
$post->post_content .= "\t" . 'color: #eee;' . PHP_EOL;
|
467 |
+
$post->post_content .= '}' . PHP_EOL . PHP_EOL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
468 |
}
|
469 |
$code_mirror_mode = 'text/css';
|
470 |
$code_mirror_before = '<style type="text/css">';
|
476 |
<form style="position: relative; margin-top: .5em;">
|
477 |
|
478 |
<div class="code-mirror-before"><div><?php echo htmlentities( $code_mirror_before );?></div></div>
|
479 |
+
<textarea class="wp-editor-area" id="content" mode="<?php echo htmlentities($code_mirror_mode); ?>" name="content"><?php echo $post->post_content; ?></textarea>
|
480 |
<div class="code-mirror-after"><div><?php echo htmlentities( $code_mirror_after );?></div></div>
|
481 |
|
482 |
<input type="hidden" id="update-post_<?php echo $post->ID ?>" value="<?php echo wp_create_nonce('update-post_'. $post->ID ); ?>" />
|
496 |
if ( ! isset($options['preprocessor'] ) )
|
497 |
$options['preprocessor'] = 'none';
|
498 |
|
499 |
+
$meta = $this->get_options_meta();
|
500 |
|
501 |
if ( isset( $_GET['language'] ) ) {
|
502 |
$options['language'] = $_GET['language'];
|
503 |
}
|
504 |
|
|
|
|
|
|
|
|
|
|
|
505 |
|
506 |
wp_nonce_field( 'options_save_meta_box_data', 'custom-css-js_meta_box_nonce' );
|
507 |
|
512 |
$output = '';
|
513 |
|
514 |
foreach( $meta as $_key => $a ) {
|
|
|
515 |
|
516 |
+
if ( $_key == 'preprocessor' ) {
|
|
|
|
|
|
|
|
|
517 |
$output .= '<div class="ccj_opaque">';
|
518 |
}
|
519 |
|
522 |
continue;
|
523 |
}
|
524 |
|
|
|
525 |
|
526 |
+
$output .= '<h3>' . $a['title'] . '</h3>' . PHP_EOL;
|
527 |
+
$name = 'custom_code_' . $_key;
|
528 |
+
|
529 |
+
// Show radio type options
|
530 |
+
if ( $a['type'] === 'radio' ) {
|
531 |
+
$output .= '<div class="radio-group">' . PHP_EOL;
|
532 |
+
foreach( $a['values'] as $__key => $__value ) {
|
533 |
+
$selected = '';
|
534 |
+
$id = $name . '-' . $__key;
|
535 |
+
$dashicons = isset($__value['dashicon'] ) ? 'dashicons-before dashicons-' . $__value['dashicon'] : '';
|
536 |
+
if ( isset( $a['disabled'] ) && $a['disabled'] ) {
|
537 |
+
$selected = ' disabled="disabled"';
|
538 |
+
}
|
539 |
+
$selected .= ( $__key == $options[$_key] ) ? ' checked="checked" ' : '';
|
540 |
+
$output .= '<input type="radio" '. $selected.'value="'.$__key.'" name="'.$name.'" id="'.$id.'">' . PHP_EOL;
|
541 |
+
$output .= '<label class="'.$dashicons.'" for="'.$id.'"> '.$__value['title'].'</label><br />' . PHP_EOL;
|
542 |
+
}
|
543 |
+
$output .= '</div>' . PHP_EOL;
|
544 |
+
}
|
545 |
|
546 |
+
// Show checkbox type options
|
547 |
+
if ( $a['type'] == 'checkbox' ) {
|
548 |
+
$dashicons = isset($a['dashicon'] ) ? 'dashicons-before dashicons-' . $a['dashicon'] : '';
|
549 |
+
$selected = ( isset($options[$_key]) && $options[$_key] == '1') ? ' checked="checked" ' : '';
|
550 |
+
if ( isset( $a['disabled'] ) && $a['disabled'] ) {
|
551 |
+
$selected .= ' disabled="disabled"';
|
552 |
+
}
|
553 |
+
$output .= '<div class="radio-group">' . PHP_EOL;
|
554 |
+
$output .= '<input type="checkbox" '.$selected.' value="1" name="'.$name.'" id="'.$name.'">' . PHP_EOL;
|
555 |
+
$output .= '<label class="'.$dashicons.'" for="'.$name.'"> '.$a['title'].'</label>';
|
556 |
+
$output .= '</div>' . PHP_EOL;
|
557 |
+
}
|
558 |
+
|
559 |
+
if ( $_key == 'minify' ) {
|
560 |
$output .= '</div>';
|
561 |
}
|
562 |
|
574 |
|
575 |
<div class="ccj_only_premium ccj_only_premium-right">
|
576 |
<div>
|
577 |
+
<a href="https://www.silkypress.com/simple-custom-css-js-pro/" target="_blank">Only available in Premium version</a>
|
578 |
</div>
|
579 |
</div>
|
580 |
|
657 |
'dashicon' => 'editor-contract',
|
658 |
'disabled' => true,
|
659 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
660 |
|
661 |
);
|
662 |
|
663 |
return $options;
|
664 |
}
|
665 |
|
|
|
666 |
/**
|
667 |
* Save the post and the metadata
|
668 |
*/
|
694 |
'language' => 'css',
|
695 |
);
|
696 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
697 |
foreach( $defaults as $_field => $_default ) {
|
698 |
$options[ $_field ] = isset( $_POST['custom_code_'.$_field] ) ? $_POST['custom_code_'.$_field] : $_default;
|
699 |
}
|
700 |
|
701 |
update_post_meta( $post_id, 'options', $options );
|
702 |
|
|
|
|
|
|
|
|
|
|
|
703 |
|
704 |
// Save the Custom Code in a file in `wp-content/uploads/custom-css-js`
|
705 |
if ( $options['linking'] == 'internal' ) {
|
839 |
return str_replace( 'QTags.addButton', '// QTags.addButton', $html );
|
840 |
}
|
841 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
842 |
|
843 |
}
|
844 |
|
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.
|
9 |
-
Stable tag: 2.
|
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 |
-
|
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:
|
@@ -111,39 +113,8 @@ 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
|
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.6
|
9 |
+
Stable tag: 2.4
|
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:
|
113 |
|
114 |
3. Add/Edit CSS
|
115 |
|
|
|
|
|
116 |
== Changelog ==
|
117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
= 2.4 =
|
119 |
* 08/01/2016
|
120 |
* Add the "Add CSS Code" and "Add JS Code" buttons next to the page title
|
screenshot-1.jpg
DELETED
Binary file
|
screenshot-2.jpg
DELETED
Binary file
|
screenshot-3.jpg
DELETED
Binary file
|
screenshot-4.jpg
DELETED
Binary file
|