Version Description
- Copy files from one theme to another
- Simplified settings page
- Tested with WP 5.5
- Fixes and improvements
Download this release
Release Info
Developer | lordspace |
Plugin | Child Theme Creator by Orbisius |
Version | 1.5.2 |
Comparing to | |
See all releases |
Code changes from version 1.5.1 to 1.5.2
- addons/cloud_lib/lib/snippet_lib.php +2 -0
- assets/main.css +57 -13
- assets/main.js +259 -144
- assets/main.min.css +1 -1
- assets/main.min.js +1 -1
- orbisius-child-theme-creator.php +203 -27
- readme.txt +10 -3
addons/cloud_lib/lib/snippet_lib.php
CHANGED
@@ -921,6 +921,8 @@ class orbisius_ctc_cloud_lib {
|
|
921 |
$user_api = orbisius_child_theme_creator_user::get_instance();
|
922 |
$api_key = $user_api->api_key();
|
923 |
?>
|
|
|
|
|
924 |
<div id="orb_cloud_lib_wrapper_<?php echo $place;?>" class="orb_cloud_lib_wrapper orb_cloud_lib_wrapper_<?php echo $place;?>">
|
925 |
<div class="snippet_wrapper">
|
926 |
<h3>Orbisius Cloud Library</h3>
|
921 |
$user_api = orbisius_child_theme_creator_user::get_instance();
|
922 |
$api_key = $user_api->api_key();
|
923 |
?>
|
924 |
+
<br/>
|
925 |
+
<br/>
|
926 |
<div id="orb_cloud_lib_wrapper_<?php echo $place;?>" class="orb_cloud_lib_wrapper orb_cloud_lib_wrapper_<?php echo $place;?>">
|
927 |
<div class="snippet_wrapper">
|
928 |
<h3>Orbisius Cloud Library</h3>
|
assets/main.css
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
/* Product of Orbisius.com. Visit https://orbisius.com/ */
|
|
|
2 |
.orbisius_child_theme_creator_container .app-hide {
|
3 |
display: none;
|
4 |
}
|
@@ -17,6 +18,7 @@
|
|
17 |
}
|
18 |
|
19 |
/* Common */
|
|
|
20 |
.orbisius_child_theme_creator_container .app-alert-error {
|
21 |
background: #D54E21;
|
22 |
border: 1px solid #eee;
|
@@ -63,6 +65,7 @@
|
|
63 |
}
|
64 |
|
65 |
/* dlg button colouring */
|
|
|
66 |
.orbisius_child_theme_creator_container .app-dialog-button-ok {
|
67 |
background: green !important;
|
68 |
color: white !important;
|
@@ -73,7 +76,7 @@
|
|
73 |
color: white !important;
|
74 |
}
|
75 |
|
76 |
-
.orbisius_child_theme_creator_container .app-button-left, .app-align-left{
|
77 |
float: left;
|
78 |
}
|
79 |
|
@@ -82,17 +85,19 @@
|
|
82 |
}
|
83 |
|
84 |
.orbisius_child_theme_creator_container .app-button-container {
|
85 |
-
padding:10px;
|
86 |
background: #ccc;
|
87 |
margin-top: 15px;
|
88 |
margin-bottom: 15px;
|
89 |
}
|
90 |
|
91 |
.orbisius_child_theme_creator_container .available-theme {
|
92 |
-
padding:10px;
|
93 |
-
margin:5px;
|
94 |
-
border: 2px solid white;
|
95 |
-
|
|
|
|
|
96 |
width: 28%;
|
97 |
}
|
98 |
|
@@ -111,6 +116,7 @@
|
|
111 |
}
|
112 |
|
113 |
/* Theme Editor */
|
|
|
114 |
.orbisius_ctc_theme_editor_container .highlight {
|
115 |
background: #FFFF33;
|
116 |
}
|
@@ -126,16 +132,54 @@
|
|
126 |
}
|
127 |
|
128 |
/* The dropdowns move to a new line when files are longer */
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
}
|
133 |
|
134 |
.orbisius_ctc_theme_editor_container .primary_buttons {
|
135 |
-
margin-top:5px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
}
|
137 |
|
138 |
-
.
|
139 |
-
|
140 |
-
border: 1px dashed #D54E21/* !important*/;
|
141 |
}
|
1 |
/* Product of Orbisius.com. Visit https://orbisius.com/ */
|
2 |
+
|
3 |
.orbisius_child_theme_creator_container .app-hide {
|
4 |
display: none;
|
5 |
}
|
18 |
}
|
19 |
|
20 |
/* Common */
|
21 |
+
|
22 |
.orbisius_child_theme_creator_container .app-alert-error {
|
23 |
background: #D54E21;
|
24 |
border: 1px solid #eee;
|
65 |
}
|
66 |
|
67 |
/* dlg button colouring */
|
68 |
+
|
69 |
.orbisius_child_theme_creator_container .app-dialog-button-ok {
|
70 |
background: green !important;
|
71 |
color: white !important;
|
76 |
color: white !important;
|
77 |
}
|
78 |
|
79 |
+
.orbisius_child_theme_creator_container .app-button-left, .app-align-left {
|
80 |
float: left;
|
81 |
}
|
82 |
|
85 |
}
|
86 |
|
87 |
.orbisius_child_theme_creator_container .app-button-container {
|
88 |
+
padding: 10px;
|
89 |
background: #ccc;
|
90 |
margin-top: 15px;
|
91 |
margin-bottom: 15px;
|
92 |
}
|
93 |
|
94 |
.orbisius_child_theme_creator_container .available-theme {
|
95 |
+
padding: 10px;
|
96 |
+
margin: 5px;
|
97 |
+
border: 2px solid white;
|
98 |
+
/* we need this because there is a shift otherwise on hover. */
|
99 |
+
display: inline-block;
|
100 |
+
/* so 3 themes fit on one row */
|
101 |
width: 28%;
|
102 |
}
|
103 |
|
116 |
}
|
117 |
|
118 |
/* Theme Editor */
|
119 |
+
|
120 |
.orbisius_ctc_theme_editor_container .highlight {
|
121 |
background: #FFFF33;
|
122 |
}
|
132 |
}
|
133 |
|
134 |
/* The dropdowns move to a new line when files are longer */
|
135 |
+
|
136 |
+
.orbisius_ctc_theme_editor_container #theme_1, .orbisius_ctc_theme_editor_container #theme_2, .orbisius_ctc_theme_editor_container #theme_1_file, .orbisius_ctc_theme_editor_container #theme_2_file {
|
137 |
+
max-width: 35%;
|
138 |
}
|
139 |
|
140 |
.orbisius_ctc_theme_editor_container .primary_buttons {
|
141 |
+
margin-top: 5px;
|
142 |
+
}
|
143 |
+
|
144 |
+
.orbisius_ctc_theme_editor_theme_1_form .modified_content, .orbisius_ctc_theme_editor_theme_2_form .modified_content {
|
145 |
+
border: 1px dashed #D54E21/* !important*/
|
146 |
+
;
|
147 |
+
}
|
148 |
+
|
149 |
+
.orbisius_files_list {
|
150 |
+
overflow: auto;
|
151 |
+
max-height: 400px;
|
152 |
+
}
|
153 |
+
|
154 |
+
.orbisius_copy_response {
|
155 |
+
padding-bottom: 1em;
|
156 |
+
}
|
157 |
+
|
158 |
+
.orbisius_copy_response.error {
|
159 |
+
color: red;
|
160 |
+
}
|
161 |
+
|
162 |
+
.orbisius_copy_response.success {
|
163 |
+
color: green;
|
164 |
+
}
|
165 |
+
|
166 |
+
.orbisius_folder_list .bold {
|
167 |
+
font-weight: bold;
|
168 |
+
}
|
169 |
+
|
170 |
+
.orbisius_folder .orbisius_folder_list {
|
171 |
+
display: none;
|
172 |
+
}
|
173 |
+
|
174 |
+
.orbisius_folder_list li ul li {
|
175 |
+
padding-left: 1em;
|
176 |
+
}
|
177 |
+
|
178 |
+
.orbisius_folder_list {
|
179 |
+
display: flex;
|
180 |
+
flex-wrap: wrap;
|
181 |
}
|
182 |
|
183 |
+
.orbisius_folder_list li {
|
184 |
+
min-width: 40%;
|
|
|
185 |
}
|
assets/main.js
CHANGED
@@ -14,7 +14,7 @@ var orbisius_child_theme_creator = {
|
|
14 |
* @param str val
|
15 |
* @returns str
|
16 |
*/
|
17 |
-
sanitize_file_name
|
18 |
val = val.replace(/[^\w\-\.\s\/\\]/ig, '');
|
19 |
val = val.replace(/\s+/ig, '-');
|
20 |
val = val.replace(/\.+/ig, '.');
|
@@ -24,7 +24,7 @@ var orbisius_child_theme_creator = {
|
|
24 |
// rm leading/trailing chars
|
25 |
val = val.replace(/^[._-]+/ig, '');
|
26 |
val = val.replace(/[._-]+$/ig, '');
|
27 |
-
|
28 |
val = jQuery.trim(val);
|
29 |
|
30 |
return val;
|
@@ -41,32 +41,36 @@ var orbisius_child_theme_creator = {
|
|
41 |
* @param str form_id
|
42 |
* @returns void
|
43 |
*/
|
44 |
-
delete_file
|
45 |
jQuery.ajax({
|
46 |
-
type
|
47 |
-
url
|
48 |
-
data
|
49 |
|
50 |
-
beforeSend: function() {
|
51 |
orbisius_child_theme_creator.loader(1);
|
52 |
},
|
53 |
|
54 |
-
complete: function() {
|
55 |
orbisius_child_theme_creator.loader(0);
|
56 |
},
|
57 |
|
58 |
-
success
|
59 |
var form_num = form_id.indexOf('theme_1') >= 0 ? 1 : 2;
|
60 |
|
61 |
// theme_1_ or theme_2_
|
62 |
jQuery("#theme_" + form_num + "_file option:selected").remove();
|
63 |
jQuery("#theme_" + form_num + "_file").trigger('change');
|
|
|
|
|
|
|
64 |
}
|
|
|
65 |
});
|
66 |
}
|
67 |
};
|
68 |
|
69 |
-
jQuery(document).ready(function($) {
|
70 |
orbisius_ctc_theme_editor_setup();
|
71 |
});
|
72 |
|
@@ -82,19 +86,19 @@ function orbisius_ctc_theme_editor_setup() {
|
|
82 |
|
83 |
// Let's warn the user if there's unsaved content.
|
84 |
// The browser don't display the actual message I've provided which is stupid.
|
85 |
-
$(window).on('beforeunload', function(e) {
|
86 |
var message = '';
|
87 |
|
88 |
-
if (
|
89 |
message = "Left Editor: Content was modified. Are you sure you want to leave without saving?";
|
90 |
-
} else if (
|
91 |
message = "Right Editor: Content was modified. Are you sure you want to leave without saving?";
|
92 |
}
|
93 |
|
94 |
-
if (
|
95 |
e.returnValue = message;
|
96 |
return message;
|
97 |
-
} else if (
|
98 |
return onbeforeunload_old(e);
|
99 |
}
|
100 |
});
|
@@ -106,24 +110,24 @@ function orbisius_ctc_theme_editor_setup() {
|
|
106 |
app_load('#orbisius_ctc_theme_editor_theme_1_form', 'generate_dropdown', '#theme_1_file', app_handle_theme_change);
|
107 |
}
|
108 |
|
109 |
-
$(
|
110 |
var custm_event_data = {
|
111 |
-
target
|
112 |
-
event
|
113 |
};
|
114 |
|
115 |
-
jQuery(document).trigger('orbisius_child_theme_editor_event_content_updated', [
|
116 |
-
}
|
117 |
|
118 |
-
jQuery(document).on('orbisius_child_theme_editor_event_content_updated', function (
|
119 |
-
jQuery(
|
120 |
-
jQuery(
|
121 |
-
}
|
122 |
|
123 |
-
jQuery(document).on('orbisius_child_theme_editor_event_content_saved', function (
|
124 |
-
jQuery(
|
125 |
-
jQuery(
|
126 |
-
}
|
127 |
|
128 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
129 |
// Delete File #1
|
@@ -165,12 +169,12 @@ function orbisius_ctc_theme_editor_setup() {
|
|
165 |
var ok = 1; // let's by positive by default
|
166 |
|
167 |
// Let's check if that file exists by checking if there is an entry in the options
|
168 |
-
$("#theme_1_file option").each(function() { // idx, val
|
169 |
var cur_val = $(this).val();
|
170 |
|
171 |
if (cur_val == new_file) {
|
172 |
ok = 0;
|
173 |
-
return
|
174 |
}
|
175 |
});
|
176 |
|
@@ -182,6 +186,67 @@ function orbisius_ctc_theme_editor_setup() {
|
|
182 |
}
|
183 |
});
|
184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
/**
|
186 |
* New File: On OK this will hide the form but will add a new element
|
187 |
* to the theme files dropdown.
|
@@ -194,49 +259,49 @@ function orbisius_ctc_theme_editor_setup() {
|
|
194 |
if (val == '') {
|
195 |
alert('Invalid or empty value for filename.');
|
196 |
$('#theme_1_new_file').focus();
|
197 |
-
return
|
198 |
}
|
199 |
|
200 |
var ok = 1; // let's by positive by default
|
201 |
-
|
202 |
// Let's check if that file exists by checking if there is an entry in the options
|
203 |
-
$("#theme_1_file option").each(function() { // idx, val
|
204 |
var cur_val = $(this).val();
|
205 |
|
206 |
if (cur_val == val) {
|
207 |
ok = 0;
|
208 |
-
return
|
209 |
}
|
210 |
});
|
211 |
|
212 |
if (!ok) {
|
213 |
alert('File with that name already exists.');
|
214 |
$('#theme_1_new_file').focus();
|
215 |
-
return
|
216 |
}
|
217 |
|
218 |
// unselects current element from the dropdown.
|
219 |
$("select theme_1_file").prop("selected", false);
|
220 |
var new_option = $('<option></option>').val(val).html(text).prop("selected", true);
|
221 |
|
222 |
-
$('#theme_1_file').append(
|
223 |
$('#theme_1_new_file_container').hide('slow');
|
224 |
$('#theme_1_new_file').val(''); // text box for new file
|
225 |
$('#theme_1_file_contents').val('').focus(); // textarea
|
226 |
|
227 |
var custum_event_data = {
|
228 |
-
file
|
229 |
-
file_selector
|
230 |
-
content_selector
|
231 |
};
|
232 |
-
jQuery(document).trigger(
|
233 |
});
|
234 |
|
235 |
// When the admin creates a new file we'll scroll to the element so he/she can start typing
|
236 |
// https://stackoverflow.com/questions/6682451/animate-scroll-to-id-on-page-load
|
237 |
-
jQuery(document).on(
|
238 |
-
$("html, body").animate({ scrollTop: jQuery(
|
239 |
-
}
|
240 |
|
241 |
// This is when the cancel button is clicked so the user doesn't want a new file.
|
242 |
$('#theme_1_new_file_btn_cancel').on("click", function () {
|
@@ -263,12 +328,12 @@ function orbisius_ctc_theme_editor_setup() {
|
|
263 |
var ok = 1; // let's by positive by default
|
264 |
|
265 |
// Let's check if that file exists by checking if there is an entry in the options
|
266 |
-
$("#theme_2_file option").each(function() { // idx, val
|
267 |
var cur_val = $(this).val();
|
268 |
|
269 |
if (cur_val == new_file) {
|
270 |
ok = 0;
|
271 |
-
return
|
272 |
}
|
273 |
});
|
274 |
|
@@ -292,42 +357,42 @@ function orbisius_ctc_theme_editor_setup() {
|
|
292 |
if (val == '') {
|
293 |
alert('Invalid or empty value for filename.');
|
294 |
$('#theme_2_new_file').focus();
|
295 |
-
return
|
296 |
}
|
297 |
|
298 |
var ok = 1; // let's by positive by default
|
299 |
|
300 |
// Let's check if that file exists by checking if there is an entry in the options
|
301 |
-
$("#theme_2_file option").each(function() { // idx, val
|
302 |
var cur_val = $(this).val();
|
303 |
|
304 |
if (cur_val == val) {
|
305 |
ok = 0;
|
306 |
-
return
|
307 |
}
|
308 |
});
|
309 |
|
310 |
if (!ok) {
|
311 |
alert('File with that name already exists.');
|
312 |
$('#theme_2_new_file').focus();
|
313 |
-
return
|
314 |
}
|
315 |
|
316 |
// unselects current element from the dropdown.
|
317 |
$("select theme_2_file").prop("selected", false);
|
318 |
var new_option = $('<option></option>').val(val).html(text).prop("selected", true);
|
319 |
|
320 |
-
$('#theme_2_file').append(
|
321 |
$('#theme_2_new_file_container').hide('slow');
|
322 |
$('#theme_2_new_file').val(''); // text box for new file
|
323 |
$('#theme_2_file_contents').val('').focus(); // textarea
|
324 |
|
325 |
var custum_event_data = {
|
326 |
-
file
|
327 |
-
file_selector
|
328 |
-
content_selector
|
329 |
};
|
330 |
-
jQuery(document).trigger(
|
331 |
});
|
332 |
|
333 |
// This is when the cancel button is clicked so the user doesn't want a new file.
|
@@ -348,31 +413,35 @@ function orbisius_ctc_theme_editor_setup() {
|
|
348 |
var target_container = '.orbisius_ctc_theme_editor_theme_1_primary_buttons .status';
|
349 |
|
350 |
jQuery(target_container)
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
|
356 |
jQuery.ajax({
|
357 |
-
type
|
358 |
//dataType : "json",
|
359 |
-
url
|
360 |
-
data
|
361 |
|
362 |
-
beforeSend: function() {
|
363 |
orbisius_child_theme_creator.loader(1);
|
364 |
},
|
365 |
|
366 |
-
complete: function() {
|
367 |
orbisius_child_theme_creator.loader(0);
|
368 |
},
|
369 |
|
370 |
-
|
|
|
|
|
|
|
|
|
371 |
jQuery(target_container)
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
|
377 |
if (json.status) { // auto hide on success
|
378 |
setTimeout(function () {
|
@@ -393,31 +462,35 @@ function orbisius_ctc_theme_editor_setup() {
|
|
393 |
var target_container = '.orbisius_ctc_theme_editor_theme_2_primary_buttons .status';
|
394 |
|
395 |
jQuery(target_container)
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
|
401 |
jQuery.ajax({
|
402 |
-
type
|
403 |
//dataType : "json",
|
404 |
-
url
|
405 |
-
data
|
406 |
|
407 |
-
beforeSend: function() {
|
408 |
orbisius_child_theme_creator.loader(1);
|
409 |
},
|
410 |
|
411 |
-
complete: function() {
|
412 |
orbisius_child_theme_creator.loader(0);
|
413 |
},
|
414 |
|
415 |
-
|
|
|
|
|
|
|
|
|
416 |
jQuery(target_container)
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
|
422 |
if (json.status) { // auto hide on success
|
423 |
setTimeout(function () {
|
@@ -458,31 +531,35 @@ function orbisius_ctc_theme_editor_setup() {
|
|
458 |
var target_container = '.orbisius_ctc_theme_editor_theme_1_primary_buttons .status';
|
459 |
|
460 |
jQuery(target_container)
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
|
466 |
jQuery.ajax({
|
467 |
-
type
|
468 |
//dataType : "json",
|
469 |
-
url
|
470 |
-
data
|
471 |
|
472 |
-
beforeSend: function() {
|
473 |
orbisius_child_theme_creator.loader(1);
|
474 |
},
|
475 |
|
476 |
-
complete: function() {
|
477 |
orbisius_child_theme_creator.loader(0);
|
478 |
},
|
479 |
-
|
480 |
-
|
|
|
|
|
|
|
|
|
481 |
jQuery(target_container)
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
|
487 |
if (json.status) { // auto hide on success
|
488 |
setTimeout(function () {
|
@@ -523,31 +600,35 @@ function orbisius_ctc_theme_editor_setup() {
|
|
523 |
var target_container = '.orbisius_ctc_theme_editor_theme_2_primary_buttons .status';
|
524 |
|
525 |
jQuery(target_container)
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
|
531 |
jQuery.ajax({
|
532 |
-
type
|
533 |
//dataType : "json",
|
534 |
-
url
|
535 |
-
data
|
536 |
|
537 |
-
beforeSend: function() {
|
538 |
orbisius_child_theme_creator.loader(1);
|
539 |
},
|
540 |
|
541 |
-
complete: function() {
|
542 |
orbisius_child_theme_creator.loader(0);
|
543 |
},
|
544 |
|
545 |
-
|
|
|
|
|
|
|
|
|
546 |
jQuery(target_container)
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
|
552 |
if (json.status) { // auto hide on success
|
553 |
setTimeout(function () {
|
@@ -582,12 +663,12 @@ function orbisius_ctc_theme_editor_setup() {
|
|
582 |
var ok = 1; // let's by positive by default
|
583 |
|
584 |
// Let's check if that folder exists by checking if there is an entry in the options
|
585 |
-
$("#theme_1_file option").each(function() { // idx, val
|
586 |
var cur_val = $(this).val();
|
587 |
|
588 |
if (cur_val == new_folder) {
|
589 |
ok = 0;
|
590 |
-
return
|
591 |
}
|
592 |
});
|
593 |
|
@@ -607,12 +688,12 @@ function orbisius_ctc_theme_editor_setup() {
|
|
607 |
var ok = 1; // let's by positive by default
|
608 |
|
609 |
// Let's check if that folder exists by checking if there is an entry in the options
|
610 |
-
$("#theme_2_file option").each(function() { // idx, val
|
611 |
var cur_val = $(this).val();
|
612 |
|
613 |
if (cur_val == new_folder) {
|
614 |
ok = 0;
|
615 |
-
return
|
616 |
}
|
617 |
});
|
618 |
|
@@ -637,32 +718,32 @@ function orbisius_ctc_theme_editor_setup() {
|
|
637 |
if (val == '') {
|
638 |
alert('Invalid or empty value for folder name.');
|
639 |
$('#theme_1_new_folder').focus();
|
640 |
-
return
|
641 |
}
|
642 |
|
643 |
var ok = 1; // let's by positive by default
|
644 |
|
645 |
// Let's check if that file exists by checking if there is an entry in the options
|
646 |
-
$("#theme_1_folder option").each(function() { // idx, val
|
647 |
var cur_val = $(this).val();
|
648 |
|
649 |
if (cur_val == val) {
|
650 |
ok = 0;
|
651 |
-
return
|
652 |
}
|
653 |
});
|
654 |
|
655 |
if (!ok) {
|
656 |
alert('File with that name already exists.');
|
657 |
$('#theme_1_new_folder').focus();
|
658 |
-
return
|
659 |
}
|
660 |
|
661 |
// unselects current element from the dropdown.
|
662 |
$("select theme_1_folder").prop("selected", false);
|
663 |
var new_option = $('<option></option>').val(val).html(text).prop("selected", true);
|
664 |
|
665 |
-
$('#theme_1_folder').append(
|
666 |
$('#theme_1_new_folder_container').hide('slow');
|
667 |
$('#theme_1_new_folder').val(''); // text box for new folder
|
668 |
$('#theme_1_folder_contents').val('').focus(); // textarea
|
@@ -689,32 +770,32 @@ function orbisius_ctc_theme_editor_setup() {
|
|
689 |
if (val == '') {
|
690 |
alert('Invalid or empty value for folder name.');
|
691 |
$('#theme_2_new_folder').focus();
|
692 |
-
return
|
693 |
}
|
694 |
|
695 |
var ok = 1; // let's by positive by default
|
696 |
|
697 |
// Let's check if that file exists by checking if there is an entry in the options
|
698 |
-
$("#theme_2_folder option").each(function() { // idx, val
|
699 |
var cur_val = $(this).val();
|
700 |
|
701 |
if (cur_val == val) {
|
702 |
ok = 0;
|
703 |
-
return
|
704 |
}
|
705 |
});
|
706 |
|
707 |
if (!ok) {
|
708 |
alert('File with that name already exists.');
|
709 |
$('#theme_2_new_folder').focus();
|
710 |
-
return
|
711 |
}
|
712 |
|
713 |
// unselects current element from the dropdown.
|
714 |
$("select theme_2_folder").prop("selected", false);
|
715 |
var new_option = $('<option></option>').val(val).html(text).prop("selected", true);
|
716 |
|
717 |
-
$('#theme_2_folder').append(
|
718 |
$('#theme_2_new_folder_container').hide('slow');
|
719 |
$('#theme_2_new_folder').val(''); // text box for new folder
|
720 |
$('#theme_2_folder_contents').val('').focus(); // textarea
|
@@ -731,11 +812,18 @@ function orbisius_ctc_theme_editor_setup() {
|
|
731 |
// Change theme selection
|
732 |
$('#theme_1').on("change", function () {
|
733 |
app_load('#orbisius_ctc_theme_editor_theme_1_form', 'generate_dropdown', '#theme_1_file', app_handle_theme_change);
|
|
|
|
|
|
|
|
|
734 |
});
|
735 |
|
736 |
// Change theme selection
|
737 |
$('#theme_2').on("change", function () {
|
738 |
app_load('#orbisius_ctc_theme_editor_theme_2_form', 'generate_dropdown', '#theme_2_file', app_handle_theme_change);
|
|
|
|
|
|
|
739 |
});
|
740 |
|
741 |
// Submit
|
@@ -782,14 +870,13 @@ function app_handle_theme_change(form_id, action, target_container, result) {
|
|
782 |
form_prefix = '#' + form_prefix + '_'; // jQuery ID prefix. Res: #theme_2_
|
783 |
|
784 |
// Let's notify the extensions (if any)
|
785 |
-
if (
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
OrbisiusChildThemeCreatorExt.Editors.onThemeChange(dropdown_id, jQuery(dropdown_id).val());
|
793 |
}
|
794 |
|
795 |
var cur_file = jQuery(form_prefix + '_file').val();
|
@@ -837,21 +924,45 @@ function app_load(form_id, action, target_container, callback) {
|
|
837 |
}
|
838 |
}
|
839 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
840 |
jQuery.ajax({
|
841 |
-
type
|
842 |
//dataType : "json",
|
843 |
-
url
|
844 |
-
data
|
845 |
|
846 |
-
success
|
847 |
var custm_event_data = {
|
848 |
-
form_id
|
849 |
sub_cmd: action,
|
850 |
-
result
|
851 |
};
|
852 |
|
853 |
// https://stackoverflow.com/questions/2432749/jquery-delay-not-delaying
|
854 |
if (result != '') {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
855 |
if (jQuery(target_container).is("input,textarea")) {
|
856 |
jQuery(target_container).val(result);
|
857 |
|
@@ -872,10 +983,10 @@ function app_load(form_id, action, target_container, callback) {
|
|
872 |
}, 2000);
|
873 |
|
874 |
var custm_event_data = {
|
875 |
-
target
|
876 |
-
event
|
877 |
};
|
878 |
-
jQuery(document).trigger('orbisius_child_theme_editor_event_content_saved', [
|
879 |
|
880 |
}
|
881 |
} else if (is_save_action) { // save action
|
@@ -887,11 +998,11 @@ function app_load(form_id, action, target_container, callback) {
|
|
887 |
}
|
888 |
},
|
889 |
|
890 |
-
beforeSend: function() {
|
891 |
orbisius_child_theme_creator.loader(1);
|
892 |
},
|
893 |
|
894 |
-
complete
|
895 |
orbisius_child_theme_creator.loader(0);
|
896 |
jQuery(target_container).removeClass('saving_action');
|
897 |
|
@@ -900,6 +1011,10 @@ function app_load(form_id, action, target_container, callback) {
|
|
900 |
jQuery(target_container).removeAttr('readonly');
|
901 |
}
|
902 |
}
|
|
|
|
|
|
|
|
|
903 |
}
|
904 |
});
|
905 |
}
|
14 |
* @param str val
|
15 |
* @returns str
|
16 |
*/
|
17 |
+
sanitize_file_name: function (val) {
|
18 |
val = val.replace(/[^\w\-\.\s\/\\]/ig, '');
|
19 |
val = val.replace(/\s+/ig, '-');
|
20 |
val = val.replace(/\.+/ig, '.');
|
24 |
// rm leading/trailing chars
|
25 |
val = val.replace(/^[._-]+/ig, '');
|
26 |
val = val.replace(/[._-]+$/ig, '');
|
27 |
+
|
28 |
val = jQuery.trim(val);
|
29 |
|
30 |
return val;
|
41 |
* @param str form_id
|
42 |
* @returns void
|
43 |
*/
|
44 |
+
delete_file: function (file_name, form_id) {
|
45 |
jQuery.ajax({
|
46 |
+
type: "post",
|
47 |
+
url: ajaxurl, // WP defines it and it contains all the necessary params
|
48 |
+
data: jQuery(form_id).serialize() + '&action=orbisius_ctc_theme_editor_ajax&sub_cmd=' + escape('delete_file'),
|
49 |
|
50 |
+
beforeSend: function () {
|
51 |
orbisius_child_theme_creator.loader(1);
|
52 |
},
|
53 |
|
54 |
+
complete: function () {
|
55 |
orbisius_child_theme_creator.loader(0);
|
56 |
},
|
57 |
|
58 |
+
success: function (result) {
|
59 |
var form_num = form_id.indexOf('theme_1') >= 0 ? 1 : 2;
|
60 |
|
61 |
// theme_1_ or theme_2_
|
62 |
jQuery("#theme_" + form_num + "_file option:selected").remove();
|
63 |
jQuery("#theme_" + form_num + "_file").trigger('change');
|
64 |
+
},
|
65 |
+
error: function () {
|
66 |
+
alert('Cheating?');
|
67 |
}
|
68 |
+
|
69 |
});
|
70 |
}
|
71 |
};
|
72 |
|
73 |
+
jQuery(document).ready(function ($) {
|
74 |
orbisius_ctc_theme_editor_setup();
|
75 |
});
|
76 |
|
86 |
|
87 |
// Let's warn the user if there's unsaved content.
|
88 |
// The browser don't display the actual message I've provided which is stupid.
|
89 |
+
$(window).on('beforeunload', function (e) {
|
90 |
var message = '';
|
91 |
|
92 |
+
if (jQuery('#theme_1_file_contents').data('orb_ctc_modified_content')) {
|
93 |
message = "Left Editor: Content was modified. Are you sure you want to leave without saving?";
|
94 |
+
} else if (jQuery('#theme_2_file_contents').data('orb_ctc_modified_content')) {
|
95 |
message = "Right Editor: Content was modified. Are you sure you want to leave without saving?";
|
96 |
}
|
97 |
|
98 |
+
if (message != '') {
|
99 |
e.returnValue = message;
|
100 |
return message;
|
101 |
+
} else if (typeof onbeforeunload_old != 'undefined') {
|
102 |
return onbeforeunload_old(e);
|
103 |
}
|
104 |
});
|
110 |
app_load('#orbisius_ctc_theme_editor_theme_1_form', 'generate_dropdown', '#theme_1_file', app_handle_theme_change);
|
111 |
}
|
112 |
|
113 |
+
$('#theme_1_file_contents,#theme_2_file_contents').on('keyup keypress input paste', function (e) { // keydown propertychange change click
|
114 |
var custm_event_data = {
|
115 |
+
target: $(this),
|
116 |
+
event: e
|
117 |
};
|
118 |
|
119 |
+
jQuery(document).trigger('orbisius_child_theme_editor_event_content_updated', [custm_event_data]);
|
120 |
+
});
|
121 |
|
122 |
+
jQuery(document).on('orbisius_child_theme_editor_event_content_updated', function (e, ctx_data) {
|
123 |
+
jQuery(ctx_data.target).data('orb_ctc_modified_content', 1);
|
124 |
+
jQuery(ctx_data.target).addClass('modified_content');
|
125 |
+
});
|
126 |
|
127 |
+
jQuery(document).on('orbisius_child_theme_editor_event_content_saved', function (e, ctx_data) {
|
128 |
+
jQuery(ctx_data.target).removeData('orb_ctc_modified_content');
|
129 |
+
jQuery(ctx_data.target).removeClass('modified_content');
|
130 |
+
});
|
131 |
|
132 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
133 |
// Delete File #1
|
169 |
var ok = 1; // let's by positive by default
|
170 |
|
171 |
// Let's check if that file exists by checking if there is an entry in the options
|
172 |
+
$("#theme_1_file option").each(function () { // idx, val
|
173 |
var cur_val = $(this).val();
|
174 |
|
175 |
if (cur_val == new_file) {
|
176 |
ok = 0;
|
177 |
+
return;
|
178 |
}
|
179 |
});
|
180 |
|
186 |
}
|
187 |
});
|
188 |
|
189 |
+
|
190 |
+
$('#theme_1_copy_file_btn').on("click", function () {
|
191 |
+
$('#orbisius_copy_response_theme_1').html('').removeClass('updated').removeClass('error');
|
192 |
+
$('.orbisius_ctc_theme_editor_theme_1_files_list').toggle();
|
193 |
+
if ($('.orbisius_ctc_theme_editor_theme_1_files_list').is(":visible")) {
|
194 |
+
app_load('#orbisius_ctc_theme_editor_theme_1_form', 'get_files', '.orbisius_ctc_theme_editor_theme_1_files_list_container', app_handle_theme_change);
|
195 |
+
}
|
196 |
+
|
197 |
+
});
|
198 |
+
|
199 |
+
$('#theme_2_copy_file_btn').on("click", function () {
|
200 |
+
$('#orbisius_copy_response_theme_2').html('').removeClass('updated').removeClass('error');
|
201 |
+
$('.orbisius_ctc_theme_editor_theme_2_files_list').toggle();
|
202 |
+
if ($('.orbisius_ctc_theme_editor_theme_2_files_list').is(":visible")) {
|
203 |
+
app_load('#orbisius_ctc_theme_editor_theme_2_form', 'get_files', '.orbisius_ctc_theme_editor_theme_2_files_list_container', app_handle_theme_change);
|
204 |
+
}
|
205 |
+
});
|
206 |
+
|
207 |
+
$('#theme_1_copy_files').on("click", function (e) {
|
208 |
+
e.preventDefault();
|
209 |
+
app_load('#orbisius_ctc_theme_editor_theme_1_form', 'copy_files', '#orbisius_copy_response_theme_1');
|
210 |
+
|
211 |
+
});
|
212 |
+
$('#theme_2_copy_files').on("click", function (e) {
|
213 |
+
e.preventDefault();
|
214 |
+
app_load('#orbisius_ctc_theme_editor_theme_2_form', 'copy_files', '#orbisius_copy_response_theme_2');
|
215 |
+
});
|
216 |
+
|
217 |
+
$('#theme_1_copy_files_cancel').on("click", function (e) {
|
218 |
+
e.preventDefault();
|
219 |
+
$('#orbisius_copy_response_theme_1').html('').removeClass('updated').removeClass('error');
|
220 |
+
$('.orbisius_ctc_theme_editor_theme_1_files_list').toggle();
|
221 |
+
});
|
222 |
+
|
223 |
+
$('#theme_2_copy_files_cancel').on("click", function (e) {
|
224 |
+
e.preventDefault();
|
225 |
+
$('#orbisius_copy_response_theme_2').html('').removeClass('updated').removeClass('error');
|
226 |
+
$('.orbisius_ctc_theme_editor_theme_2_files_list').toggle();
|
227 |
+
});
|
228 |
+
|
229 |
+
jQuery('body').on("click", '.orbisius_folder_list input', function (e) {
|
230 |
+
|
231 |
+
// file input
|
232 |
+
if (jQuery(this).parent('.orbisius_file_label').length) {
|
233 |
+
jQuery(this).parent().toggleClass('bold');
|
234 |
+
|
235 |
+
// folder input
|
236 |
+
} else if (jQuery(this).parents('.orbisius_folder').length) {
|
237 |
+
var cur = jQuery(this)[0].checked;
|
238 |
+
var child_labels = jQuery(jQuery(this).parents('.orbisius_folder')[0]).find('label');
|
239 |
+
var child_inputs = jQuery(jQuery(this).parents('.orbisius_folder')[0]).find('input');
|
240 |
+
|
241 |
+
cur ? child_labels.addClass('bold') : child_labels.removeClass('bold');
|
242 |
+
cur ? child_inputs.attr('checked', true) : child_inputs.attr('checked', false);
|
243 |
+
jQuery(this).parents('.orbisius_folder').first().find('.orbisius_folder_list').toggle();
|
244 |
+
|
245 |
+
}
|
246 |
+
|
247 |
+
});
|
248 |
+
|
249 |
+
|
250 |
/**
|
251 |
* New File: On OK this will hide the form but will add a new element
|
252 |
* to the theme files dropdown.
|
259 |
if (val == '') {
|
260 |
alert('Invalid or empty value for filename.');
|
261 |
$('#theme_1_new_file').focus();
|
262 |
+
return;
|
263 |
}
|
264 |
|
265 |
var ok = 1; // let's by positive by default
|
266 |
+
|
267 |
// Let's check if that file exists by checking if there is an entry in the options
|
268 |
+
$("#theme_1_file option").each(function () { // idx, val
|
269 |
var cur_val = $(this).val();
|
270 |
|
271 |
if (cur_val == val) {
|
272 |
ok = 0;
|
273 |
+
return;
|
274 |
}
|
275 |
});
|
276 |
|
277 |
if (!ok) {
|
278 |
alert('File with that name already exists.');
|
279 |
$('#theme_1_new_file').focus();
|
280 |
+
return;
|
281 |
}
|
282 |
|
283 |
// unselects current element from the dropdown.
|
284 |
$("select theme_1_file").prop("selected", false);
|
285 |
var new_option = $('<option></option>').val(val).html(text).prop("selected", true);
|
286 |
|
287 |
+
$('#theme_1_file').append(new_option); // select
|
288 |
$('#theme_1_new_file_container').hide('slow');
|
289 |
$('#theme_1_new_file').val(''); // text box for new file
|
290 |
$('#theme_1_file_contents').val('').focus(); // textarea
|
291 |
|
292 |
var custum_event_data = {
|
293 |
+
file: val,
|
294 |
+
file_selector: '#theme_1_file',
|
295 |
+
content_selector: '#theme_1_file_contents'
|
296 |
};
|
297 |
+
jQuery(document).trigger('orbisius_child_theme_editor_event_new_file', [custum_event_data]);
|
298 |
});
|
299 |
|
300 |
// When the admin creates a new file we'll scroll to the element so he/she can start typing
|
301 |
// https://stackoverflow.com/questions/6682451/animate-scroll-to-id-on-page-load
|
302 |
+
jQuery(document).on('orbisius_child_theme_editor_event_new_file', function (obj, custom_data) {
|
303 |
+
$("html, body").animate({ scrollTop: jQuery(custom_data.file_selector).offset().top - 50 }, 1000);
|
304 |
+
});
|
305 |
|
306 |
// This is when the cancel button is clicked so the user doesn't want a new file.
|
307 |
$('#theme_1_new_file_btn_cancel').on("click", function () {
|
328 |
var ok = 1; // let's by positive by default
|
329 |
|
330 |
// Let's check if that file exists by checking if there is an entry in the options
|
331 |
+
$("#theme_2_file option").each(function () { // idx, val
|
332 |
var cur_val = $(this).val();
|
333 |
|
334 |
if (cur_val == new_file) {
|
335 |
ok = 0;
|
336 |
+
return;
|
337 |
}
|
338 |
});
|
339 |
|
357 |
if (val == '') {
|
358 |
alert('Invalid or empty value for filename.');
|
359 |
$('#theme_2_new_file').focus();
|
360 |
+
return;
|
361 |
}
|
362 |
|
363 |
var ok = 1; // let's by positive by default
|
364 |
|
365 |
// Let's check if that file exists by checking if there is an entry in the options
|
366 |
+
$("#theme_2_file option").each(function () { // idx, val
|
367 |
var cur_val = $(this).val();
|
368 |
|
369 |
if (cur_val == val) {
|
370 |
ok = 0;
|
371 |
+
return;
|
372 |
}
|
373 |
});
|
374 |
|
375 |
if (!ok) {
|
376 |
alert('File with that name already exists.');
|
377 |
$('#theme_2_new_file').focus();
|
378 |
+
return;
|
379 |
}
|
380 |
|
381 |
// unselects current element from the dropdown.
|
382 |
$("select theme_2_file").prop("selected", false);
|
383 |
var new_option = $('<option></option>').val(val).html(text).prop("selected", true);
|
384 |
|
385 |
+
$('#theme_2_file').append(new_option); // select
|
386 |
$('#theme_2_new_file_container').hide('slow');
|
387 |
$('#theme_2_new_file').val(''); // text box for new file
|
388 |
$('#theme_2_file_contents').val('').focus(); // textarea
|
389 |
|
390 |
var custum_event_data = {
|
391 |
+
file: val,
|
392 |
+
file_selector: '#theme_2_file',
|
393 |
+
content_selector: '#theme_2_file_contents'
|
394 |
};
|
395 |
+
jQuery(document).trigger('orbisius_child_theme_editor_event_new_file', [custum_event_data]);
|
396 |
});
|
397 |
|
398 |
// This is when the cancel button is clicked so the user doesn't want a new file.
|
413 |
var target_container = '.orbisius_ctc_theme_editor_theme_1_primary_buttons .status';
|
414 |
|
415 |
jQuery(target_container)
|
416 |
+
.empty()
|
417 |
+
.removeClass('app-alert-success app-alert-error app-alert-notice')
|
418 |
+
.addClass('app-alert-notice')
|
419 |
+
.html('Checking ...');
|
420 |
|
421 |
jQuery.ajax({
|
422 |
+
type: "post",
|
423 |
//dataType : "json",
|
424 |
+
url: ajaxurl, // WP defines it and it contains all the necessary params
|
425 |
+
data: jQuery(form_id).serialize() + '&action=orbisius_ctc_theme_editor_ajax&sub_cmd=' + escape(action),
|
426 |
|
427 |
+
beforeSend: function () {
|
428 |
orbisius_child_theme_creator.loader(1);
|
429 |
},
|
430 |
|
431 |
+
complete: function () {
|
432 |
orbisius_child_theme_creator.loader(0);
|
433 |
},
|
434 |
|
435 |
+
error: function () {
|
436 |
+
alert('Cheating?');
|
437 |
+
},
|
438 |
+
|
439 |
+
success: function (json) {
|
440 |
jQuery(target_container)
|
441 |
+
.empty()
|
442 |
+
.removeClass('app-alert-notice')
|
443 |
+
.html(json.msg)
|
444 |
+
.addClass(json.status ? 'app-alert-success' : 'app-alert-error');
|
445 |
|
446 |
if (json.status) { // auto hide on success
|
447 |
setTimeout(function () {
|
462 |
var target_container = '.orbisius_ctc_theme_editor_theme_2_primary_buttons .status';
|
463 |
|
464 |
jQuery(target_container)
|
465 |
+
.empty()
|
466 |
+
.removeClass('app-alert-success app-alert-error app-alert-notice')
|
467 |
+
.addClass('app-alert-notice')
|
468 |
+
.html('Checking ...');
|
469 |
|
470 |
jQuery.ajax({
|
471 |
+
type: "post",
|
472 |
//dataType : "json",
|
473 |
+
url: ajaxurl, // WP defines it and it contains all the necessary params
|
474 |
+
data: jQuery(form_id).serialize() + '&action=orbisius_ctc_theme_editor_ajax&sub_cmd=' + escape(action),
|
475 |
|
476 |
+
beforeSend: function () {
|
477 |
orbisius_child_theme_creator.loader(1);
|
478 |
},
|
479 |
|
480 |
+
complete: function () {
|
481 |
orbisius_child_theme_creator.loader(0);
|
482 |
},
|
483 |
|
484 |
+
error: function () {
|
485 |
+
alert('Cheating?');
|
486 |
+
},
|
487 |
+
|
488 |
+
success: function (json) {
|
489 |
jQuery(target_container)
|
490 |
+
.empty()
|
491 |
+
.removeClass('app-alert-notice')
|
492 |
+
.html(json.msg)
|
493 |
+
.addClass(json.status ? 'app-alert-success' : 'app-alert-error');
|
494 |
|
495 |
if (json.status) { // auto hide on success
|
496 |
setTimeout(function () {
|
531 |
var target_container = '.orbisius_ctc_theme_editor_theme_1_primary_buttons .status';
|
532 |
|
533 |
jQuery(target_container)
|
534 |
+
.empty()
|
535 |
+
.removeClass('app-alert-success app-alert-error app-alert-notice')
|
536 |
+
.addClass('app-alert-notice')
|
537 |
+
.html('Processing ...');
|
538 |
|
539 |
jQuery.ajax({
|
540 |
+
type: "post",
|
541 |
//dataType : "json",
|
542 |
+
url: ajaxurl, // WP defines it and it contains all the necessary params
|
543 |
+
data: jQuery(form_id).serialize() + '&action=orbisius_ctc_theme_editor_ajax&sub_cmd=' + escape(action),
|
544 |
|
545 |
+
beforeSend: function () {
|
546 |
orbisius_child_theme_creator.loader(1);
|
547 |
},
|
548 |
|
549 |
+
complete: function () {
|
550 |
orbisius_child_theme_creator.loader(0);
|
551 |
},
|
552 |
+
|
553 |
+
error: function () {
|
554 |
+
alert('Cheating?');
|
555 |
+
},
|
556 |
+
|
557 |
+
success: function (json) {
|
558 |
jQuery(target_container)
|
559 |
+
.empty()
|
560 |
+
.removeClass('app-alert-notice')
|
561 |
+
.html(json.msg)
|
562 |
+
.addClass(json.status ? 'app-alert-success' : 'app-alert-error');
|
563 |
|
564 |
if (json.status) { // auto hide on success
|
565 |
setTimeout(function () {
|
600 |
var target_container = '.orbisius_ctc_theme_editor_theme_2_primary_buttons .status';
|
601 |
|
602 |
jQuery(target_container)
|
603 |
+
.empty()
|
604 |
+
.removeClass('app-alert-success app-alert-error app-alert-notice')
|
605 |
+
.addClass('app-alert-notice')
|
606 |
+
.html('Processing ...');
|
607 |
|
608 |
jQuery.ajax({
|
609 |
+
type: "post",
|
610 |
//dataType : "json",
|
611 |
+
url: ajaxurl, // WP defines it and it contains all the necessary params
|
612 |
+
data: jQuery(form_id).serialize() + '&action=orbisius_ctc_theme_editor_ajax&sub_cmd=' + escape(action),
|
613 |
|
614 |
+
beforeSend: function () {
|
615 |
orbisius_child_theme_creator.loader(1);
|
616 |
},
|
617 |
|
618 |
+
complete: function () {
|
619 |
orbisius_child_theme_creator.loader(0);
|
620 |
},
|
621 |
|
622 |
+
error: function () {
|
623 |
+
alert('Cheating?');
|
624 |
+
},
|
625 |
+
|
626 |
+
success: function (json) {
|
627 |
jQuery(target_container)
|
628 |
+
.empty()
|
629 |
+
.removeClass('app-alert-notice')
|
630 |
+
.html(json.msg)
|
631 |
+
.addClass(json.status ? 'app-alert-success' : 'app-alert-error');
|
632 |
|
633 |
if (json.status) { // auto hide on success
|
634 |
setTimeout(function () {
|
663 |
var ok = 1; // let's by positive by default
|
664 |
|
665 |
// Let's check if that folder exists by checking if there is an entry in the options
|
666 |
+
$("#theme_1_file option").each(function () { // idx, val
|
667 |
var cur_val = $(this).val();
|
668 |
|
669 |
if (cur_val == new_folder) {
|
670 |
ok = 0;
|
671 |
+
return;
|
672 |
}
|
673 |
});
|
674 |
|
688 |
var ok = 1; // let's by positive by default
|
689 |
|
690 |
// Let's check if that folder exists by checking if there is an entry in the options
|
691 |
+
$("#theme_2_file option").each(function () { // idx, val
|
692 |
var cur_val = $(this).val();
|
693 |
|
694 |
if (cur_val == new_folder) {
|
695 |
ok = 0;
|
696 |
+
return;
|
697 |
}
|
698 |
});
|
699 |
|
718 |
if (val == '') {
|
719 |
alert('Invalid or empty value for folder name.');
|
720 |
$('#theme_1_new_folder').focus();
|
721 |
+
return;
|
722 |
}
|
723 |
|
724 |
var ok = 1; // let's by positive by default
|
725 |
|
726 |
// Let's check if that file exists by checking if there is an entry in the options
|
727 |
+
$("#theme_1_folder option").each(function () { // idx, val
|
728 |
var cur_val = $(this).val();
|
729 |
|
730 |
if (cur_val == val) {
|
731 |
ok = 0;
|
732 |
+
return;
|
733 |
}
|
734 |
});
|
735 |
|
736 |
if (!ok) {
|
737 |
alert('File with that name already exists.');
|
738 |
$('#theme_1_new_folder').focus();
|
739 |
+
return;
|
740 |
}
|
741 |
|
742 |
// unselects current element from the dropdown.
|
743 |
$("select theme_1_folder").prop("selected", false);
|
744 |
var new_option = $('<option></option>').val(val).html(text).prop("selected", true);
|
745 |
|
746 |
+
$('#theme_1_folder').append(new_option); // select
|
747 |
$('#theme_1_new_folder_container').hide('slow');
|
748 |
$('#theme_1_new_folder').val(''); // text box for new folder
|
749 |
$('#theme_1_folder_contents').val('').focus(); // textarea
|
770 |
if (val == '') {
|
771 |
alert('Invalid or empty value for folder name.');
|
772 |
$('#theme_2_new_folder').focus();
|
773 |
+
return;
|
774 |
}
|
775 |
|
776 |
var ok = 1; // let's by positive by default
|
777 |
|
778 |
// Let's check if that file exists by checking if there is an entry in the options
|
779 |
+
$("#theme_2_folder option").each(function () { // idx, val
|
780 |
var cur_val = $(this).val();
|
781 |
|
782 |
if (cur_val == val) {
|
783 |
ok = 0;
|
784 |
+
return;
|
785 |
}
|
786 |
});
|
787 |
|
788 |
if (!ok) {
|
789 |
alert('File with that name already exists.');
|
790 |
$('#theme_2_new_folder').focus();
|
791 |
+
return;
|
792 |
}
|
793 |
|
794 |
// unselects current element from the dropdown.
|
795 |
$("select theme_2_folder").prop("selected", false);
|
796 |
var new_option = $('<option></option>').val(val).html(text).prop("selected", true);
|
797 |
|
798 |
+
$('#theme_2_folder').append(new_option); // select
|
799 |
$('#theme_2_new_folder_container').hide('slow');
|
800 |
$('#theme_2_new_folder').val(''); // text box for new folder
|
801 |
$('#theme_2_folder_contents').val('').focus(); // textarea
|
812 |
// Change theme selection
|
813 |
$('#theme_1').on("change", function () {
|
814 |
app_load('#orbisius_ctc_theme_editor_theme_1_form', 'generate_dropdown', '#theme_1_file', app_handle_theme_change);
|
815 |
+
if ($('.orbisius_ctc_theme_editor_theme_1_files_list').is(":visible")) {
|
816 |
+
app_load('#orbisius_ctc_theme_editor_theme_1_form', 'get_files', '.orbisius_ctc_theme_editor_theme_1_files_list_container', app_handle_theme_change);
|
817 |
+
|
818 |
+
}
|
819 |
});
|
820 |
|
821 |
// Change theme selection
|
822 |
$('#theme_2').on("change", function () {
|
823 |
app_load('#orbisius_ctc_theme_editor_theme_2_form', 'generate_dropdown', '#theme_2_file', app_handle_theme_change);
|
824 |
+
if ($('.orbisius_ctc_theme_editor_theme_2_files_list').is(":visible")) {
|
825 |
+
app_load('#orbisius_ctc_theme_editor_theme_2_form', 'get_files', '.orbisius_ctc_theme_editor_theme_2_files_list_container', app_handle_theme_change);
|
826 |
+
}
|
827 |
});
|
828 |
|
829 |
// Submit
|
870 |
form_prefix = '#' + form_prefix + '_'; // jQuery ID prefix. Res: #theme_2_
|
871 |
|
872 |
// Let's notify the extensions (if any)
|
873 |
+
if ((typeof OrbisiusChildThemeCreatorExt != 'undefined')
|
874 |
+
&& (typeof OrbisiusChildThemeCreatorExt.Editors != 'undefined')
|
875 |
+
&& (typeof OrbisiusChildThemeCreatorExt.Editors.onThemeChange != 'undefined')) {
|
876 |
+
var dropdown_id = form_prefix;
|
877 |
+
var dropdown_id = dropdown_id.replace(/_+$/g, ''); // rm trailing stuff
|
878 |
+
//var dropdown_id = dropdown_id.replace(/\#+/g, ''); // rm #
|
879 |
+
OrbisiusChildThemeCreatorExt.Editors.onThemeChange(dropdown_id, jQuery(dropdown_id).val());
|
|
|
880 |
}
|
881 |
|
882 |
var cur_file = jQuery(form_prefix + '_file').val();
|
924 |
}
|
925 |
}
|
926 |
|
927 |
+
|
928 |
+
// get form data
|
929 |
+
var data = jQuery(form_id).serialize();
|
930 |
+
|
931 |
+
// prepare files to copy in json format and append it to form data, if copy_files
|
932 |
+
if (action === 'copy_files') {
|
933 |
+
var files = jQuery(target_container).parent().find('.orb_files:checked').map(function () {
|
934 |
+
return jQuery(this).val();
|
935 |
+
}).get();
|
936 |
+
var secondTheme = target_container.substr(-1) === '1' ? '#theme_2' : '#theme_1';
|
937 |
+
|
938 |
+
files = encodeURIComponent(JSON.stringify(files));
|
939 |
+
data += '©=' + files;
|
940 |
+
data += '©_to=' + encodeURIComponent(jQuery(secondTheme).val());
|
941 |
+
}
|
942 |
+
|
943 |
jQuery.ajax({
|
944 |
+
type: "post",
|
945 |
//dataType : "json",
|
946 |
+
url: ajaxurl, // WP defines it and it contains all the necessary params
|
947 |
+
data: data + '&action=orbisius_ctc_theme_editor_ajax&sub_cmd=' + escape(action),
|
948 |
|
949 |
+
success: function (result) {
|
950 |
var custm_event_data = {
|
951 |
+
form_id: form_id,
|
952 |
sub_cmd: action,
|
953 |
+
result: result
|
954 |
};
|
955 |
|
956 |
// https://stackoverflow.com/questions/2432749/jquery-delay-not-delaying
|
957 |
if (result != '') {
|
958 |
+
|
959 |
+
if (action === 'copy_files' && result !== 'Missing data!') {
|
960 |
+
result = JSON.parse(result);
|
961 |
+
var status_class = result.status ? 'updated' : 'error';
|
962 |
+
jQuery(target_container).removeClass('success').removeClass('error').addClass(status_class);
|
963 |
+
jQuery(target_container).html(result.message);
|
964 |
+
return;
|
965 |
+
}
|
966 |
if (jQuery(target_container).is("input,textarea")) {
|
967 |
jQuery(target_container).val(result);
|
968 |
|
983 |
}, 2000);
|
984 |
|
985 |
var custm_event_data = {
|
986 |
+
target: jQuery(target_container),
|
987 |
+
event: {}
|
988 |
};
|
989 |
+
jQuery(document).trigger('orbisius_child_theme_editor_event_content_saved', [custm_event_data]);
|
990 |
|
991 |
}
|
992 |
} else if (is_save_action) { // save action
|
998 |
}
|
999 |
},
|
1000 |
|
1001 |
+
beforeSend: function () {
|
1002 |
orbisius_child_theme_creator.loader(1);
|
1003 |
},
|
1004 |
|
1005 |
+
complete: function (result) { // this is always called
|
1006 |
orbisius_child_theme_creator.loader(0);
|
1007 |
jQuery(target_container).removeClass('saving_action');
|
1008 |
|
1011 |
jQuery(target_container).removeAttr('readonly');
|
1012 |
}
|
1013 |
}
|
1014 |
+
},
|
1015 |
+
|
1016 |
+
error: function () {
|
1017 |
+
alert('Cheating?');
|
1018 |
}
|
1019 |
});
|
1020 |
}
|
assets/main.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.orbisius_child_theme_creator_container .app-hide{display:none}.orbisius_child_theme_creator_container .app-hide-force{display:none!important}.orbisius_child_theme_creator_container .app-form-field-error{border-color:red}.orbisius_child_theme_creator_container .app-serious-notice{color:red;font-weight:700}.orbisius_child_theme_creator_container .app-alert-error{background:#
|
1 |
+
.orbisius_child_theme_creator_container .app-hide{display:none}.orbisius_child_theme_creator_container .app-hide-force{display:none!important}.orbisius_child_theme_creator_container .app-form-field-error{border-color:red}.orbisius_child_theme_creator_container .app-serious-notice{color:red;font-weight:700}.orbisius_child_theme_creator_container .app-alert-error{background:#d54e21;border:1px solid #eee;color:#fff;padding:3px}.orbisius_child_theme_creator_container .app-alert-success{background:green;border:1px solid #eee;color:#fff;padding:3px}.orbisius_child_theme_creator_container .app-alert-error a,.orbisius_child_theme_creator_container .app-alert-success a{color:#fff}.orbisius_child_theme_creator_container .app-alert-notice{background:#ffec8b;border:1px solid #666;padding:3px}.orbisius_child_theme_creator_container .app-button-positive{background:green;color:#fff;padding:3px;text-decoration:none}.orbisius_child_theme_creator_container .app-button-negative{background:red;color:#fff;padding:3px;text-decoration:none}.orbisius_child_theme_creator_container .highlight{background:#ff3}.orbisius_child_theme_creator_container .app-dialog-button-ok{background:green!important;color:#fff!important}.orbisius_child_theme_creator_container .app-dialog-button-cancel{background:red!important;color:#fff!important}.app-align-left,.orbisius_child_theme_creator_container .app-button-left{float:left}.orbisius_child_theme_creator_container .app-align-right,.orbisius_child_theme_creator_container .app-button-right{float:right}.orbisius_child_theme_creator_container .app-button-container{padding:10px;background:#ccc;margin-top:15px;margin-bottom:15px}.orbisius_child_theme_creator_container .available-theme{padding:10px;margin:5px;border:2px solid #fff;display:inline-block;width:28%}.orbisius_child_theme_creator_container .available-theme img.screenshot{max-height:75%;max-width:75%}.orbisius_child_theme_creator_container .available-theme:hover{border:2px solid #aaa;background:#ffc}.orbisius_child_theme_creator_container .saving_action{background:#ccc}.orbisius_ctc_theme_editor_container .highlight{background:#ff3}.orbisius_ctc_theme_editor_container .app-dialog-button-ok{background:green!important;color:#fff!important}.orbisius_ctc_theme_editor_container .app-dialog-button-cancel{background:red!important;color:#fff!important}.orbisius_ctc_theme_editor_container #theme_1,.orbisius_ctc_theme_editor_container #theme_1_file,.orbisius_ctc_theme_editor_container #theme_2,.orbisius_ctc_theme_editor_container #theme_2_file{max-width:35%}.orbisius_ctc_theme_editor_container .primary_buttons{margin-top:5px}.orbisius_ctc_theme_editor_theme_1_form .modified_content,.orbisius_ctc_theme_editor_theme_2_form .modified_content{border:1px dashed #d54e21}.orbisius_files_list{overflow:auto;max-height:400px}.orbisius_copy_response{padding-bottom:1em}.orbisius_copy_response.error{color:red}.orbisius_copy_response.success{color:green}.orbisius_folder_list .bold{font-weight:700}.orbisius_folder .orbisius_folder_list{display:none}.orbisius_folder_list li ul li{padding-left:1em}.orbisius_folder_list{display:flex;flex-wrap:wrap}.orbisius_folder_list li{min-width:40%}
|
assets/main.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
function orbisius_ctc_theme_editor_setup(){var a=jQuery,b=window.onbeforeunload;a(window).on("beforeunload",function(a){var c="";return jQuery("#theme_1_file_contents").data("orb_ctc_modified_content")?c="Left Editor: Content was modified. Are you sure you want to leave without saving?":jQuery("#theme_2_file_contents").data("orb_ctc_modified_content")&&(c="Right Editor: Content was modified. Are you sure you want to leave without saving?"),""!=c?(a.returnValue=c,c):"undefined"!=typeof b?b(a):void 0});var c=a("#theme_1").val();""!=c&&app_load("#orbisius_ctc_theme_editor_theme_1_form","generate_dropdown","#theme_1_file",app_handle_theme_change),a("#theme_1_file_contents,#theme_2_file_contents").on("keyup keypress input paste",function(b){var c={target:a(this),event:b};jQuery(document).trigger("orbisius_child_theme_editor_event_content_updated",[c])}),jQuery(document).on("orbisius_child_theme_editor_event_content_updated",function(a,b){jQuery(b.target).data("orb_ctc_modified_content",1),jQuery(b.target).addClass("modified_content")}),jQuery(document).on("orbisius_child_theme_editor_event_content_saved",function(a,b){jQuery(b.target).removeData("orb_ctc_modified_content"),jQuery(b.target).removeClass("modified_content")}),a("#theme_1_delete_file_btn").on("click",function(){var b=a("#theme_1_file").val();confirm("Delete: ["+b+"] ? Are you sure?","")&&orbisius_child_theme_creator.delete_file(b,"#orbisius_ctc_theme_editor_theme_1_form")}),a("#theme_2_delete_file_btn").on("click",function(){var b=a("#theme_2_file").val();confirm("Delete: ["+b+"] ? Are you sure?","")&&orbisius_child_theme_creator.delete_file(b,"#orbisius_ctc_theme_editor_theme_2_form")}),a("#theme_1_new_file_btn").on("click",function(){a("#theme_1_new_file_container").toggle("slow"),a("#theme_1_new_file").focus()}),a("#theme_1_new_file").on("input",function(b){var c=a("#theme_1_new_file").val();c=orbisius_child_theme_creator.sanitize_file_name(c);var d=1;if(a("#theme_1_file option").each(function(){var b=a(this).val();if(b==c)return void(d=0)}),d)a(".status",a("#theme_1_new_file_container")).text("").removeClass("app-alert-error");else{var e="File with that name already exists.";a(".status",a("#theme_1_new_file_container")).text(e).addClass("app-alert-error")}}),a("#theme_1_new_file_btn_ok").on("click",function(){var b=a("#theme_1_new_file").val();b=orbisius_child_theme_creator.sanitize_file_name(b);var c=b;if(""==b)return alert("Invalid or empty value for filename."),void a("#theme_1_new_file").focus();var d=1;if(a("#theme_1_file option").each(function(){var c=a(this).val();if(c==b)return void(d=0)}),!d)return alert("File with that name already exists."),void a("#theme_1_new_file").focus();a("select theme_1_file").prop("selected",!1);var e=a("<option></option>").val(b).html(c).prop("selected",!0);a("#theme_1_file").append(e),a("#theme_1_new_file_container").hide("slow"),a("#theme_1_new_file").val(""),a("#theme_1_file_contents").val("").focus();var f={file:b,file_selector:"#theme_1_file",content_selector:"#theme_1_file_contents"};jQuery(document).trigger("orbisius_child_theme_editor_event_new_file",[f])}),jQuery(document).on("orbisius_child_theme_editor_event_new_file",function(b,c){a("html, body").animate({scrollTop:jQuery(c.file_selector).offset().top-50},1e3)}),a("#theme_1_new_file_btn_cancel").on("click",function(){a("#theme_1_new_file").val(""),a("#theme_1_new_file_container").hide("slow"),a(".status",a("#theme_1_new_file_container")).text("").removeClass("app-alert-error")}),a("#theme_2_new_file_btn").on("click",function(){a("#theme_2_new_file_container").toggle("slow"),a("#theme_2_new_file").focus()}),a("#theme_2_new_file").on("input",function(b){var c=a("#theme_2_new_file").val();c=orbisius_child_theme_creator.sanitize_file_name(c);var d=1;if(a("#theme_2_file option").each(function(){var b=a(this).val();if(b==c)return void(d=0)}),d)a(".status",a("#theme_2_new_file_container")).text("").removeClass("app-alert-error");else{var e="File with that name already exists.";a(".status",a("#theme_2_new_file_container")).text(e).addClass("app-alert-error")}}),a("#theme_2_new_file_btn_ok").on("click",function(){var b=a("#theme_2_new_file").val();b=orbisius_child_theme_creator.sanitize_file_name(b);var c=b;if(""==b)return alert("Invalid or empty value for filename."),void a("#theme_2_new_file").focus();var d=1;if(a("#theme_2_file option").each(function(){var c=a(this).val();if(c==b)return void(d=0)}),!d)return alert("File with that name already exists."),void a("#theme_2_new_file").focus();a("select theme_2_file").prop("selected",!1);var e=a("<option></option>").val(b).html(c).prop("selected",!0);a("#theme_2_file").append(e),a("#theme_2_new_file_container").hide("slow"),a("#theme_2_new_file").val(""),a("#theme_2_file_contents").val("").focus();var f={file:b,file_selector:"#theme_2_file",content_selector:"#theme_2_file_contents"};jQuery(document).trigger("orbisius_child_theme_editor_event_new_file",[f])}),a("#theme_2_new_file_btn_cancel").on("click",function(){a("#theme_2_new_file").val(""),a("#theme_2_new_file_container").hide("slow"),a(".status",a("#theme_2_new_file_container")).text("").removeClass("app-alert-error")}),a("#theme_1_syntax_chk_btn").on("click",function(){var a="#orbisius_ctc_theme_editor_theme_1_form",b="syntax_check",c=".orbisius_ctc_theme_editor_theme_1_primary_buttons .status";jQuery(c).empty().removeClass("app-alert-success app-alert-error app-alert-notice").addClass("app-alert-notice").html("Checking ..."),jQuery.ajax({type:"post",url:ajaxurl,data:jQuery(a).serialize()+"&action=orbisius_ctc_theme_editor_ajax&sub_cmd="+escape(b),beforeSend:function(){orbisius_child_theme_creator.loader(1)},complete:function(){orbisius_child_theme_creator.loader(0)},success:function(a){jQuery(c).empty().removeClass("app-alert-notice").html(a.msg).addClass(a.status?"app-alert-success":"app-alert-error"),a.status&&setTimeout(function(){jQuery(c).empty().removeClass("app-alert-success app-alert-error")},2e3)}})}),a("#theme_2_syntax_chk_btn").on("click",function(){var a="#orbisius_ctc_theme_editor_theme_2_form",b="syntax_check",c=".orbisius_ctc_theme_editor_theme_2_primary_buttons .status";jQuery(c).empty().removeClass("app-alert-success app-alert-error app-alert-notice").addClass("app-alert-notice").html("Checking ..."),jQuery.ajax({type:"post",url:ajaxurl,data:jQuery(a).serialize()+"&action=orbisius_ctc_theme_editor_ajax&sub_cmd="+escape(b),beforeSend:function(){orbisius_child_theme_creator.loader(1)},complete:function(){orbisius_child_theme_creator.loader(0)},success:function(a){jQuery(c).empty().removeClass("app-alert-notice").html(a.msg).addClass(a.status?"app-alert-success":"app-alert-error"),a.status&&setTimeout(function(){jQuery(c).empty().removeClass("app-alert-success app-alert-error")},2e3)}})}),a("#theme_1_send_btn").on("click",function(){a("#theme_1_send_container").toggle("slow"),a("#theme_1_send_to").focus()}),a("#theme_1_send_btn_cancel").on("click",function(){a("#theme_1_send_container").hide("slow")}),a("#theme_1_send_btn_ok").on("click",function(){var b=jQuery("#theme_1_send_to").val().trim();if(b.indexOf("@")==-1||b.indexOf(".")<1)return alert("Invalid email(s)."),void a("#theme_1_send_to").focus();var c="#orbisius_ctc_theme_editor_theme_1_form",d="send_theme",e=".orbisius_ctc_theme_editor_theme_1_primary_buttons .status";jQuery(e).empty().removeClass("app-alert-success app-alert-error app-alert-notice").addClass("app-alert-notice").html("Processing ..."),jQuery.ajax({type:"post",url:ajaxurl,data:jQuery(c).serialize()+"&action=orbisius_ctc_theme_editor_ajax&sub_cmd="+escape(d),beforeSend:function(){orbisius_child_theme_creator.loader(1)},complete:function(){orbisius_child_theme_creator.loader(0)},success:function(b){jQuery(e).empty().removeClass("app-alert-notice").html(b.msg).addClass(b.status?"app-alert-success":"app-alert-error"),b.status&&setTimeout(function(){jQuery(e).empty().removeClass("app-alert-success app-alert-error"),a("#theme_1_send_btn_cancel").click()},2e3)}})}),a("#theme_2_send_btn").on("click",function(){a("#theme_2_send_container").toggle("slow"),a("#theme_2_send_to").focus()}),a("#theme_2_send_btn_cancel").on("click",function(){a("#theme_2_send_container").hide("slow")}),a("#theme_2_send_btn_ok").on("click",function(){var b=jQuery("#theme_2_send_to").val().trim();if(b.indexOf("@")==-1||b.indexOf(".")<1)return alert("Invalid email(s)."),void a("#theme_2_send_to").focus();var c="#orbisius_ctc_theme_editor_theme_2_form",d="send_theme",e=".orbisius_ctc_theme_editor_theme_2_primary_buttons .status";jQuery(e).empty().removeClass("app-alert-success app-alert-error app-alert-notice").addClass("app-alert-notice").html("Processing ..."),jQuery.ajax({type:"post",url:ajaxurl,data:jQuery(c).serialize()+"&action=orbisius_ctc_theme_editor_ajax&sub_cmd="+escape(d),beforeSend:function(){orbisius_child_theme_creator.loader(1)},complete:function(){orbisius_child_theme_creator.loader(0)},success:function(b){jQuery(e).empty().removeClass("app-alert-notice").html(b.msg).addClass(b.status?"app-alert-success":"app-alert-error"),b.status&&setTimeout(function(){jQuery(e).empty().removeClass("app-alert-success app-alert-error"),a("#theme_2_send_btn_cancel").click()},2e3)}})}),a("#theme_1_new_folder_btn").on("click",function(){a("#theme_1_new_folder_container").toggle("slow"),a("#theme_1_new_folder").focus()}),a("#theme_2_new_folder_btn").on("click",function(){a("#theme_2_new_folder_container").toggle("slow"),a("#theme_2_new_folder").focus()}),a("#theme_1_new_folder").on("input",function(b){var c=a("#theme_1_new_folder").val();c=orbisius_child_theme_creator.sanitize_file_name(c);var d=1;if(a("#theme_1_file option").each(function(){var b=a(this).val();if(b==c)return void(d=0)}),d)a(".status",a("#theme_1_new_folder_container")).text("").removeClass("app-alert-error");else{var e="File/folder with that name already exists.";a(".status",a("#theme_1_new_folder_container")).text(e).addClass("app-alert-error")}}),a("#theme_2_new_folder").on("input",function(b){var c=a("#theme_2_new_folder").val();c=orbisius_child_theme_creator.sanitize_file_name(c);var d=1;if(a("#theme_2_file option").each(function(){var b=a(this).val();if(b==c)return void(d=0)}),d)a(".status",a("#theme_2_new_folder_container")).text("").removeClass("app-alert-error");else{var e="File/folder with that name already exists.";a(".status",a("#theme_2_new_folder_container")).text(e).addClass("app-alert-error")}}),a("#theme_1_new_folder_btn_ok").on("click",function(){var b=a("#theme_1_new_folder").val();b=orbisius_child_theme_creator.sanitize_file_name(b);var c=b;if(""==b)return alert("Invalid or empty value for folder name."),void a("#theme_1_new_folder").focus();var d=1;if(a("#theme_1_folder option").each(function(){var c=a(this).val();if(c==b)return void(d=0)}),!d)return alert("File with that name already exists."),void a("#theme_1_new_folder").focus();a("select theme_1_folder").prop("selected",!1);var e=a("<option></option>").val(b).html(c).prop("selected",!0);a("#theme_1_folder").append(e),a("#theme_1_new_folder_container").hide("slow"),a("#theme_1_new_folder").val(""),a("#theme_1_folder_contents").val("").focus()}),a("#theme_1_new_folder_btn_cancel").on("click",function(){a("#theme_1_new_folder").val(""),a("#theme_1_new_folder_container").hide("slow"),a(".status",a("#theme_1_new_folder_container")).text("").removeClass("app-alert-error")}),a("#theme_2_new_folder_btn_ok").on("click",function(){var b=a("#theme_2_new_folder").val();b=orbisius_child_theme_creator.sanitize_file_name(b);var c=b;if(""==b)return alert("Invalid or empty value for folder name."),void a("#theme_2_new_folder").focus();var d=1;if(a("#theme_2_folder option").each(function(){var c=a(this).val();if(c==b)return void(d=0)}),!d)return alert("File with that name already exists."),void a("#theme_2_new_folder").focus();a("select theme_2_folder").prop("selected",!1);var e=a("<option></option>").val(b).html(c).prop("selected",!0);a("#theme_2_folder").append(e),a("#theme_2_new_folder_container").hide("slow"),a("#theme_2_new_folder").val(""),a("#theme_2_folder_contents").val("").focus()}),a("#theme_2_new_folder_btn_cancel").on("click",function(){a("#theme_2_new_folder").val(""),a("#theme_2_new_folder_container").hide("slow"),a(".status",a("#theme_2_new_folder_container")).text("").removeClass("app-alert-error")}),a("#theme_1").on("change",function(){app_load("#orbisius_ctc_theme_editor_theme_1_form","generate_dropdown","#theme_1_file",app_handle_theme_change)}),a("#theme_2").on("change",function(){app_load("#orbisius_ctc_theme_editor_theme_2_form","generate_dropdown","#theme_2_file",app_handle_theme_change)}),a("#orbisius_ctc_theme_editor_theme_1_form").submit(function(a){return app_load("#orbisius_ctc_theme_editor_theme_1_form","save_file","#theme_1_file_contents"),!1});var c=a("#theme_2").val();""!=c&&app_load("#orbisius_ctc_theme_editor_theme_2_form","generate_dropdown","#theme_2_file",app_handle_theme_change),a("#theme_2").on("change",function(){app_load("#orbisius_ctc_theme_editor_theme_2_form","generate_dropdown","#theme_2_file",app_handle_theme_change)}),a("#orbisius_ctc_theme_editor_theme_2_form").submit(function(){return app_load("#orbisius_ctc_theme_editor_theme_2_form","save_file","#theme_2_file_contents"),!1})}function app_handle_theme_change(a,b,c,d){var e=jQuery(a)?jQuery(a).attr("id"):"";if(e=e||"",""!=e){if(e=e.replace(/.+(theme[-_]*\d+).*/,"$1"),e="#"+e+"_","undefined"!=typeof OrbisiusChildThemeCreatorExt&&"undefined"!=typeof OrbisiusChildThemeCreatorExt.Editors&&"undefined"!=typeof OrbisiusChildThemeCreatorExt.Editors.onThemeChange){var f=e,f=f.replace(/_+$/g,"");OrbisiusChildThemeCreatorExt.Editors.onThemeChange(f,jQuery(f).val())}var g=jQuery(e+"_file").val();""!==g&&app_load(a,"load_file",e+"file_contents"),jQuery(e+"file").on("change",function(){app_load(a,"load_file",e+"file_contents")})}}function app_load(a,b,c,d){var e='<span class="app-alert-notice">Loading...</span>',f="Loading...",h=b.indexOf("save")>=0;h?(jQuery(c).is("input,textarea")&&(jQuery(c).attr("readonly","readonly"),jQuery(c).addClass("saving_action")),jQuery(".status",jQuery(c).parent()).html(e)):jQuery(c).is("input,textarea")?jQuery(c).addClass("saving_action"):jQuery(c).is("select")?jQuery(c+" option").text(f):jQuery(c).html(e),jQuery.ajax({type:"post",url:ajaxurl,data:jQuery(a).serialize()+"&action=orbisius_ctc_theme_editor_ajax&sub_cmd="+escape(b),success:function(e){var f={form_id:a,sub_cmd:b,result:e};if(""!=e){if(jQuery(c).is("input,textarea")?(jQuery(c).val(e),jQuery(c).is("textarea")&&jQuery(c).trigger("orbisius_child_theme_editor_event_file_loaded",f)):(jQuery(c).html(e),jQuery(c).trigger("orbisius_child_theme_editor_event_content_loaded",f)),h){jQuery(".status",jQuery(c).parent()).html("Saved.").addClass("app-alert-success"),setTimeout(function(){jQuery(".status",jQuery(c).parent()).empty().removeClass("app-alert-success app-alert-error")},2e3);var f={target:jQuery(c),event:{}};jQuery(document).trigger("orbisius_child_theme_editor_event_content_saved",[f])}}else h&&jQuery(".status",jQuery(c).parent()).html("Oops. Cannot save.").addClass("app-alert-error");"undefined"!=typeof d&&d(a,b,c,e)},beforeSend:function(){orbisius_child_theme_creator.loader(1)},complete:function(a){orbisius_child_theme_creator.loader(0),jQuery(c).removeClass("saving_action"),h&&jQuery(c).is("input,textarea")&&jQuery(c).removeAttr("readonly")}})}var orbisius_child_theme_creator={loader:function(a){var b=jQuery(".orbisius_child_theme_creator_container .loader");a?jQuery(b).html("Please Wait ...").show():jQuery(b).html("").hide()},sanitize_file_name:function(a){return a=a.replace(/[^\w\-\.\s\/\\]/gi,""),a=a.replace(/\s+/gi,"-"),a=a.replace(/\.+/gi,"."),a=a.replace(/-+/gi,"-"),a=a.replace(/_+/gi,"_"),a=a.replace(/^[._-]+/gi,""),a=a.replace(/[._-]+$/gi,""),a=jQuery.trim(a)},delete_file:function(a,b){jQuery.ajax({type:"post",url:ajaxurl,data:jQuery(b).serialize()+"&action=orbisius_ctc_theme_editor_ajax&sub_cmd="+escape("delete_file"),beforeSend:function(){orbisius_child_theme_creator.loader(1)},complete:function(){orbisius_child_theme_creator.loader(0)},success:function(a){var c=b.indexOf("theme_1")>=0?1:2;jQuery("#theme_"+c+"_file option:selected").remove(),jQuery("#theme_"+c+"_file").trigger("change")}})}};jQuery(document).ready(function(a){orbisius_ctc_theme_editor_setup()});
|
1 |
+
var orbisius_child_theme_creator = { loader: function (e) { var t = jQuery(".orbisius_child_theme_creator_container .loader"); e ? jQuery(t).html("Please Wait ...").show() : jQuery(t).html("").hide() }, sanitize_file_name: function (e) { return e = (e = (e = (e = (e = (e = (e = e.replace(/[^\w\-\.\s\/\\]/gi, "")).replace(/\s+/gi, "-")).replace(/\.+/gi, ".")).replace(/-+/gi, "-")).replace(/_+/gi, "_")).replace(/^[._-]+/gi, "")).replace(/[._-]+$/gi, ""), e = jQuery.trim(e) }, delete_file: function (e, t) { jQuery.ajax({ type: "post", url: ajaxurl, data: jQuery(t).serialize() + "&action=orbisius_ctc_theme_editor_ajax&sub_cmd=" + escape("delete_file"), beforeSend: function () { orbisius_child_theme_creator.loader(1) }, complete: function () { orbisius_child_theme_creator.loader(0) }, success: function (e) { var _ = t.indexOf("theme_1") >= 0 ? 1 : 2; jQuery("#theme_" + _ + "_file option:selected").remove(), jQuery("#theme_" + _ + "_file").trigger("change") }, error: function () { alert("Cheating?") } }) } }; function orbisius_ctc_theme_editor_setup() { var e = jQuery, t = window.onbeforeunload; e(window).on("beforeunload", function (e) { var _ = ""; return jQuery("#theme_1_file_contents").data("orb_ctc_modified_content") ? _ = "Left Editor: Content was modified. Are you sure you want to leave without saving?" : jQuery("#theme_2_file_contents").data("orb_ctc_modified_content") && (_ = "Right Editor: Content was modified. Are you sure you want to leave without saving?"), "" != _ ? (e.returnValue = _, _) : void 0 !== t ? t(e) : void 0 }), "" != e("#theme_1").val() && app_load("#orbisius_ctc_theme_editor_theme_1_form", "generate_dropdown", "#theme_1_file", app_handle_theme_change), e("#theme_1_file_contents,#theme_2_file_contents").on("keyup keypress input paste", function (t) { var _ = { target: e(this), event: t }; jQuery(document).trigger("orbisius_child_theme_editor_event_content_updated", [_]) }), jQuery(document).on("orbisius_child_theme_editor_event_content_updated", function (e, t) { jQuery(t.target).data("orb_ctc_modified_content", 1), jQuery(t.target).addClass("modified_content") }), jQuery(document).on("orbisius_child_theme_editor_event_content_saved", function (e, t) { jQuery(t.target).removeData("orb_ctc_modified_content"), jQuery(t.target).removeClass("modified_content") }), e("#theme_1_delete_file_btn").on("click", function () { var t = e("#theme_1_file").val(); confirm("Delete: [" + t + "] ? Are you sure?", "") && orbisius_child_theme_creator.delete_file(t, "#orbisius_ctc_theme_editor_theme_1_form") }), e("#theme_2_delete_file_btn").on("click", function () { var t = e("#theme_2_file").val(); confirm("Delete: [" + t + "] ? Are you sure?", "") && orbisius_child_theme_creator.delete_file(t, "#orbisius_ctc_theme_editor_theme_2_form") }), e("#theme_1_new_file_btn").on("click", function () { e("#theme_1_new_file_container").toggle("slow"), e("#theme_1_new_file").focus() }), e("#theme_1_new_file").on("input", function (t) { var _ = e("#theme_1_new_file").val(); _ = orbisius_child_theme_creator.sanitize_file_name(_); var r = 1; if (e("#theme_1_file option").each(function () { e(this).val() != _ || (r = 0) }), r) e(".status", e("#theme_1_new_file_container")).text("").removeClass("app-alert-error"); else { e(".status", e("#theme_1_new_file_container")).text("File with that name already exists.").addClass("app-alert-error") } }), e("#theme_1_copy_file_btn").on("click", function () { e("#orbisius_copy_response_theme_1").html("").removeClass("updated").removeClass("error"), e(".orbisius_ctc_theme_editor_theme_1_files_list").toggle(), e(".orbisius_ctc_theme_editor_theme_1_files_list").is(":visible") && app_load("#orbisius_ctc_theme_editor_theme_1_form", "get_files", ".orbisius_ctc_theme_editor_theme_1_files_list_container", app_handle_theme_change) }), e("#theme_2_copy_file_btn").on("click", function () { e("#orbisius_copy_response_theme_2").html("").removeClass("updated").removeClass("error"), e(".orbisius_ctc_theme_editor_theme_2_files_list").toggle(), e(".orbisius_ctc_theme_editor_theme_2_files_list").is(":visible") && app_load("#orbisius_ctc_theme_editor_theme_2_form", "get_files", ".orbisius_ctc_theme_editor_theme_2_files_list_container", app_handle_theme_change) }), e("#theme_1_copy_files").on("click", function (e) { e.preventDefault(), app_load("#orbisius_ctc_theme_editor_theme_1_form", "copy_files", "#orbisius_copy_response_theme_1") }), e("#theme_2_copy_files").on("click", function (e) { e.preventDefault(), app_load("#orbisius_ctc_theme_editor_theme_2_form", "copy_files", "#orbisius_copy_response_theme_2") }), e("#theme_1_copy_files_cancel").on("click", function (t) { t.preventDefault(), e("#orbisius_copy_response_theme_1").html("").removeClass("updated").removeClass("error"), e(".orbisius_ctc_theme_editor_theme_1_files_list").toggle() }), e("#theme_2_copy_files_cancel").on("click", function (t) { t.preventDefault(), e("#orbisius_copy_response_theme_2").html("").removeClass("updated").removeClass("error"), e(".orbisius_ctc_theme_editor_theme_2_files_list").toggle() }), jQuery("body").on("click", ".orbisius_folder_list input", function (e) { if (jQuery(this).parent(".orbisius_file_label").length) jQuery(this).parent().toggleClass("bold"); else if (jQuery(this).parents(".orbisius_folder").length) { var t = jQuery(this)[0].checked, _ = jQuery(jQuery(this).parents(".orbisius_folder")[0]).find("label"), r = jQuery(jQuery(this).parents(".orbisius_folder")[0]).find("input"); t ? _.addClass("bold") : _.removeClass("bold"), t ? r.attr("checked", !0) : r.attr("checked", !1), jQuery(this).parents(".orbisius_folder").first().find(".orbisius_folder_list").toggle() } }), e("#theme_1_new_file_btn_ok").on("click", function () { var t = e("#theme_1_new_file").val(), _ = t = orbisius_child_theme_creator.sanitize_file_name(t); if ("" == t) return alert("Invalid or empty value for filename."), void e("#theme_1_new_file").focus(); var r = 1; if (e("#theme_1_file option").each(function () { e(this).val() != t || (r = 0) }), !r) return alert("File with that name already exists."), void e("#theme_1_new_file").focus(); e("select theme_1_file").prop("selected", !1); var i = e("<option></option>").val(t).html(_).prop("selected", !0); e("#theme_1_file").append(i), e("#theme_1_new_file_container").hide("slow"), e("#theme_1_new_file").val(""), e("#theme_1_file_contents").val("").focus(); var o = { file: t, file_selector: "#theme_1_file", content_selector: "#theme_1_file_contents" }; jQuery(document).trigger("orbisius_child_theme_editor_event_new_file", [o]) }), jQuery(document).on("orbisius_child_theme_editor_event_new_file", function (t, _) { e("html, body").animate({ scrollTop: jQuery(_.file_selector).offset().top - 50 }, 1e3) }), e("#theme_1_new_file_btn_cancel").on("click", function () { e("#theme_1_new_file").val(""), e("#theme_1_new_file_container").hide("slow"), e(".status", e("#theme_1_new_file_container")).text("").removeClass("app-alert-error") }), e("#theme_2_new_file_btn").on("click", function () { e("#theme_2_new_file_container").toggle("slow"), e("#theme_2_new_file").focus() }), e("#theme_2_new_file").on("input", function (t) { var _ = e("#theme_2_new_file").val(); _ = orbisius_child_theme_creator.sanitize_file_name(_); var r = 1; if (e("#theme_2_file option").each(function () { e(this).val() != _ || (r = 0) }), r) e(".status", e("#theme_2_new_file_container")).text("").removeClass("app-alert-error"); else { e(".status", e("#theme_2_new_file_container")).text("File with that name already exists.").addClass("app-alert-error") } }), e("#theme_2_new_file_btn_ok").on("click", function () { var t = e("#theme_2_new_file").val(), _ = t = orbisius_child_theme_creator.sanitize_file_name(t); if ("" == t) return alert("Invalid or empty value for filename."), void e("#theme_2_new_file").focus(); var r = 1; if (e("#theme_2_file option").each(function () { e(this).val() != t || (r = 0) }), !r) return alert("File with that name already exists."), void e("#theme_2_new_file").focus(); e("select theme_2_file").prop("selected", !1); var i = e("<option></option>").val(t).html(_).prop("selected", !0); e("#theme_2_file").append(i), e("#theme_2_new_file_container").hide("slow"), e("#theme_2_new_file").val(""), e("#theme_2_file_contents").val("").focus(); var o = { file: t, file_selector: "#theme_2_file", content_selector: "#theme_2_file_contents" }; jQuery(document).trigger("orbisius_child_theme_editor_event_new_file", [o]) }), e("#theme_2_new_file_btn_cancel").on("click", function () { e("#theme_2_new_file").val(""), e("#theme_2_new_file_container").hide("slow"), e(".status", e("#theme_2_new_file_container")).text("").removeClass("app-alert-error") }), e("#theme_1_syntax_chk_btn").on("click", function () { var e = ".orbisius_ctc_theme_editor_theme_1_primary_buttons .status"; jQuery(e).empty().removeClass("app-alert-success app-alert-error app-alert-notice").addClass("app-alert-notice").html("Checking ..."), jQuery.ajax({ type: "post", url: ajaxurl, data: jQuery("#orbisius_ctc_theme_editor_theme_1_form").serialize() + "&action=orbisius_ctc_theme_editor_ajax&sub_cmd=" + escape("syntax_check"), beforeSend: function () { orbisius_child_theme_creator.loader(1) }, complete: function () { orbisius_child_theme_creator.loader(0) }, error: function () { alert("Cheating?") }, success: function (t) { jQuery(e).empty().removeClass("app-alert-notice").html(t.msg).addClass(t.status ? "app-alert-success" : "app-alert-error"), t.status && setTimeout(function () { jQuery(e).empty().removeClass("app-alert-success app-alert-error") }, 2e3) } }) }), e("#theme_2_syntax_chk_btn").on("click", function () { var e = ".orbisius_ctc_theme_editor_theme_2_primary_buttons .status"; jQuery(e).empty().removeClass("app-alert-success app-alert-error app-alert-notice").addClass("app-alert-notice").html("Checking ..."), jQuery.ajax({ type: "post", url: ajaxurl, data: jQuery("#orbisius_ctc_theme_editor_theme_2_form").serialize() + "&action=orbisius_ctc_theme_editor_ajax&sub_cmd=" + escape("syntax_check"), beforeSend: function () { orbisius_child_theme_creator.loader(1) }, complete: function () { orbisius_child_theme_creator.loader(0) }, error: function () { alert("Cheating?") }, success: function (t) { jQuery(e).empty().removeClass("app-alert-notice").html(t.msg).addClass(t.status ? "app-alert-success" : "app-alert-error"), t.status && setTimeout(function () { jQuery(e).empty().removeClass("app-alert-success app-alert-error") }, 2e3) } }) }), e("#theme_1_send_btn").on("click", function () { e("#theme_1_send_container").toggle("slow"), e("#theme_1_send_to").focus() }), e("#theme_1_send_btn_cancel").on("click", function () { e("#theme_1_send_container").hide("slow") }), e("#theme_1_send_btn_ok").on("click", function () { var t = jQuery("#theme_1_send_to").val().trim(); if (-1 == t.indexOf("@") || t.indexOf(".") < 1) return alert("Invalid email(s)."), void e("#theme_1_send_to").focus(); var _ = ".orbisius_ctc_theme_editor_theme_1_primary_buttons .status"; jQuery(_).empty().removeClass("app-alert-success app-alert-error app-alert-notice").addClass("app-alert-notice").html("Processing ..."), jQuery.ajax({ type: "post", url: ajaxurl, data: jQuery("#orbisius_ctc_theme_editor_theme_1_form").serialize() + "&action=orbisius_ctc_theme_editor_ajax&sub_cmd=" + escape("send_theme"), beforeSend: function () { orbisius_child_theme_creator.loader(1) }, complete: function () { orbisius_child_theme_creator.loader(0) }, error: function () { alert("Cheating?") }, success: function (t) { jQuery(_).empty().removeClass("app-alert-notice").html(t.msg).addClass(t.status ? "app-alert-success" : "app-alert-error"), t.status && setTimeout(function () { jQuery(_).empty().removeClass("app-alert-success app-alert-error"), e("#theme_1_send_btn_cancel").click() }, 2e3) } }) }), e("#theme_2_send_btn").on("click", function () { e("#theme_2_send_container").toggle("slow"), e("#theme_2_send_to").focus() }), e("#theme_2_send_btn_cancel").on("click", function () { e("#theme_2_send_container").hide("slow") }), e("#theme_2_send_btn_ok").on("click", function () { var t = jQuery("#theme_2_send_to").val().trim(); if (-1 == t.indexOf("@") || t.indexOf(".") < 1) return alert("Invalid email(s)."), void e("#theme_2_send_to").focus(); var _ = ".orbisius_ctc_theme_editor_theme_2_primary_buttons .status"; jQuery(_).empty().removeClass("app-alert-success app-alert-error app-alert-notice").addClass("app-alert-notice").html("Processing ..."), jQuery.ajax({ type: "post", url: ajaxurl, data: jQuery("#orbisius_ctc_theme_editor_theme_2_form").serialize() + "&action=orbisius_ctc_theme_editor_ajax&sub_cmd=" + escape("send_theme"), beforeSend: function () { orbisius_child_theme_creator.loader(1) }, complete: function () { orbisius_child_theme_creator.loader(0) }, error: function () { alert("Cheating?") }, success: function (t) { jQuery(_).empty().removeClass("app-alert-notice").html(t.msg).addClass(t.status ? "app-alert-success" : "app-alert-error"), t.status && setTimeout(function () { jQuery(_).empty().removeClass("app-alert-success app-alert-error"), e("#theme_2_send_btn_cancel").click() }, 2e3) } }) }), e("#theme_1_new_folder_btn").on("click", function () { e("#theme_1_new_folder_container").toggle("slow"), e("#theme_1_new_folder").focus() }), e("#theme_2_new_folder_btn").on("click", function () { e("#theme_2_new_folder_container").toggle("slow"), e("#theme_2_new_folder").focus() }), e("#theme_1_new_folder").on("input", function (t) { var _ = e("#theme_1_new_folder").val(); _ = orbisius_child_theme_creator.sanitize_file_name(_); var r = 1; if (e("#theme_1_file option").each(function () { e(this).val() != _ || (r = 0) }), r) e(".status", e("#theme_1_new_folder_container")).text("").removeClass("app-alert-error"); else { e(".status", e("#theme_1_new_folder_container")).text("File/folder with that name already exists.").addClass("app-alert-error") } }), e("#theme_2_new_folder").on("input", function (t) { var _ = e("#theme_2_new_folder").val(); _ = orbisius_child_theme_creator.sanitize_file_name(_); var r = 1; if (e("#theme_2_file option").each(function () { e(this).val() != _ || (r = 0) }), r) e(".status", e("#theme_2_new_folder_container")).text("").removeClass("app-alert-error"); else { e(".status", e("#theme_2_new_folder_container")).text("File/folder with that name already exists.").addClass("app-alert-error") } }), e("#theme_1_new_folder_btn_ok").on("click", function () { var t = e("#theme_1_new_folder").val(), _ = t = orbisius_child_theme_creator.sanitize_file_name(t); if ("" == t) return alert("Invalid or empty value for folder name."), void e("#theme_1_new_folder").focus(); var r = 1; if (e("#theme_1_folder option").each(function () { e(this).val() != t || (r = 0) }), !r) return alert("File with that name already exists."), void e("#theme_1_new_folder").focus(); e("select theme_1_folder").prop("selected", !1); var i = e("<option></option>").val(t).html(_).prop("selected", !0); e("#theme_1_folder").append(i), e("#theme_1_new_folder_container").hide("slow"), e("#theme_1_new_folder").val(""), e("#theme_1_folder_contents").val("").focus() }), e("#theme_1_new_folder_btn_cancel").on("click", function () { e("#theme_1_new_folder").val(""), e("#theme_1_new_folder_container").hide("slow"), e(".status", e("#theme_1_new_folder_container")).text("").removeClass("app-alert-error") }), e("#theme_2_new_folder_btn_ok").on("click", function () { var t = e("#theme_2_new_folder").val(), _ = t = orbisius_child_theme_creator.sanitize_file_name(t); if ("" == t) return alert("Invalid or empty value for folder name."), void e("#theme_2_new_folder").focus(); var r = 1; if (e("#theme_2_folder option").each(function () { e(this).val() != t || (r = 0) }), !r) return alert("File with that name already exists."), void e("#theme_2_new_folder").focus(); e("select theme_2_folder").prop("selected", !1); var i = e("<option></option>").val(t).html(_).prop("selected", !0); e("#theme_2_folder").append(i), e("#theme_2_new_folder_container").hide("slow"), e("#theme_2_new_folder").val(""), e("#theme_2_folder_contents").val("").focus() }), e("#theme_2_new_folder_btn_cancel").on("click", function () { e("#theme_2_new_folder").val(""), e("#theme_2_new_folder_container").hide("slow"), e(".status", e("#theme_2_new_folder_container")).text("").removeClass("app-alert-error") }), e("#theme_1").on("change", function () { app_load("#orbisius_ctc_theme_editor_theme_1_form", "generate_dropdown", "#theme_1_file", app_handle_theme_change), e(".orbisius_ctc_theme_editor_theme_1_files_list").is(":visible") && app_load("#orbisius_ctc_theme_editor_theme_1_form", "get_files", ".orbisius_ctc_theme_editor_theme_1_files_list_container", app_handle_theme_change) }), e("#theme_2").on("change", function () { app_load("#orbisius_ctc_theme_editor_theme_2_form", "generate_dropdown", "#theme_2_file", app_handle_theme_change), e(".orbisius_ctc_theme_editor_theme_2_files_list").is(":visible") && app_load("#orbisius_ctc_theme_editor_theme_2_form", "get_files", ".orbisius_ctc_theme_editor_theme_2_files_list_container", app_handle_theme_change) }), e("#orbisius_ctc_theme_editor_theme_1_form").submit(function (e) { return app_load("#orbisius_ctc_theme_editor_theme_1_form", "save_file", "#theme_1_file_contents"), !1 }), "" != e("#theme_2").val() && app_load("#orbisius_ctc_theme_editor_theme_2_form", "generate_dropdown", "#theme_2_file", app_handle_theme_change), e("#theme_2").on("change", function () { app_load("#orbisius_ctc_theme_editor_theme_2_form", "generate_dropdown", "#theme_2_file", app_handle_theme_change) }), e("#orbisius_ctc_theme_editor_theme_2_form").submit(function () { return app_load("#orbisius_ctc_theme_editor_theme_2_form", "save_file", "#theme_2_file_contents"), !1 }) } function app_handle_theme_change(e, t, _, r) { var i = jQuery(e) ? jQuery(e).attr("id") : ""; if ("" != (i = i || "")) { if (i = "#" + (i = i.replace(/.+(theme[-_]*\d+).*/, "$1")) + "_", "undefined" != typeof OrbisiusChildThemeCreatorExt && void 0 !== OrbisiusChildThemeCreatorExt.Editors && void 0 !== OrbisiusChildThemeCreatorExt.Editors.onThemeChange) { var o = (o = i).replace(/_+$/g, ""); OrbisiusChildThemeCreatorExt.Editors.onThemeChange(o, jQuery(o).val()) } "" !== jQuery(i + "_file").val() && app_load(e, "load_file", i + "file_contents"), jQuery(i + "file").on("change", function () { app_load(e, "load_file", i + "file_contents") }) } } function app_load(e, t, _, r) { var i = '<span class="app-alert-notice">Loading...</span>', o = t.indexOf("save") >= 0; o ? (jQuery(_).is("input,textarea") && (jQuery(_).attr("readonly", "readonly"), jQuery(_).addClass("saving_action")), jQuery(".status", jQuery(_).parent()).html(i)) : jQuery(_).is("input,textarea") ? jQuery(_).addClass("saving_action") : jQuery(_).is("select") ? jQuery(_ + " option").text("Loading...") : jQuery(_).html(i); var a = jQuery(e).serialize(); if ("copy_files" === t) { var n = jQuery(_).parent().find(".orb_files:checked").map(function () { return jQuery(this).val() }).get(), s = "1" === _.substr(-1) ? "#theme_2" : "#theme_1"; a += "©=" + (n = encodeURIComponent(JSON.stringify(n))), a += "©_to=" + encodeURIComponent(jQuery(s).val()) } jQuery.ajax({ type: "post", url: ajaxurl, data: a + "&action=orbisius_ctc_theme_editor_ajax&sub_cmd=" + escape(t), success: function (i) { var a = { form_id: e, sub_cmd: t, result: i }; if ("" != i) { if ("copy_files" === t && "Missing data!" !== i) { var n = (i = JSON.parse(i)).status ? "updated" : "error"; return jQuery(_).removeClass("success").removeClass("error").addClass(n), void jQuery(_).html(i.message) } if (jQuery(_).is("input,textarea") ? (jQuery(_).val(i), jQuery(_).is("textarea") && jQuery(_).trigger("orbisius_child_theme_editor_event_file_loaded", a)) : (jQuery(_).html(i), jQuery(_).trigger("orbisius_child_theme_editor_event_content_loaded", a)), o) { jQuery(".status", jQuery(_).parent()).html("Saved.").addClass("app-alert-success"), setTimeout(function () { jQuery(".status", jQuery(_).parent()).empty().removeClass("app-alert-success app-alert-error") }, 2e3); a = { target: jQuery(_), event: {} }; jQuery(document).trigger("orbisius_child_theme_editor_event_content_saved", [a]) } } else o && jQuery(".status", jQuery(_).parent()).html("Oops. Cannot save.").addClass("app-alert-error"); void 0 !== r && r(e, t, _, i) }, beforeSend: function () { orbisius_child_theme_creator.loader(1) }, complete: function (e) { orbisius_child_theme_creator.loader(0), jQuery(_).removeClass("saving_action"), o && jQuery(_).is("input,textarea") && jQuery(_).removeAttr("readonly") }, error: function () { alert("Cheating?") } }) } jQuery(document).ready(function (e) { orbisius_ctc_theme_editor_setup() });
|
orbisius-child-theme-creator.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Orbisius Child Theme Creator
|
4 |
Plugin URI: https://orbisius.com/products/wordpress-plugins/orbisius-child-theme-creator/
|
5 |
Description: This plugin allows you to quickly create child themes from any theme that you have currently installed on your site/blog.
|
6 |
-
Version: 1.5.
|
7 |
Author: Svetoslav Marinov (Slavi)
|
8 |
Author URI: https://orbisius.com
|
9 |
*/
|
@@ -318,7 +318,11 @@ function orbisius_child_theme_creator_admin_enqueue_scripts($current_page = '')
|
|
318 |
wp_enqueue_script( 'jquery' );
|
319 |
wp_register_script( 'orbisius_child_theme_creator', plugins_url("/assets/main{$suffix}.js", __FILE__), array('jquery', ),
|
320 |
filemtime( plugin_dir_path( __FILE__ ) . "/assets/main{$suffix}.js" ), true);
|
321 |
-
|
|
|
|
|
|
|
|
|
322 |
|
323 |
do_action( 'orbisius_child_theme_creator_admin_enqueue_scripts', array( 'suffix' => $suffix, ) );
|
324 |
}
|
@@ -392,19 +396,8 @@ function orbisius_child_theme_creator_settings_page() {
|
|
392 |
<div id="icon-options-general" class="icon32"></div>
|
393 |
<h2>Orbisius Child Theme Creator</h2>
|
394 |
|
395 |
-
<div class="updated"><p>
|
396 |
-
Some untested themes and plugin may break your site. We have launched a <strong>free</strong> service
|
397 |
-
(<a href="https://qsandbox.com/?utm_source=orbisius-child-theme-creator&utm_medium=settings_screen&utm_campaign=product"
|
398 |
-
target="_blank" title="[new window]">https://qsandbox.com</a>)
|
399 |
-
that allows you to setup a test/sandbox
|
400 |
-
WordPress site in seconds. No technical knowledge is required.
|
401 |
-
<br/>Join today and test themes and plugins before you actually put them on your live site. For more info go to:
|
402 |
-
<a href="https://qsandbox.com/?utm_source=orbisius-child-theme-creator&utm_medium=settings_screen&utm_campaign=product"
|
403 |
-
target="_blank" title="[new window]">https://qsandbox.com</a>
|
404 |
-
</p></div>
|
405 |
-
|
406 |
<div class="updated0"><p>
|
407 |
-
This plugin doesn't currently have any
|
408 |
<a href='<?php echo $just_link;?>'><strong>Appearance → Orbisius Child Theme Creator</strong></a>
|
409 |
</p></div>
|
410 |
|
@@ -420,12 +413,11 @@ function orbisius_child_theme_creator_settings_page() {
|
|
420 |
|
421 |
<div class="postbox">
|
422 |
|
423 |
-
<h3><span>Usage / Help</span></h3>
|
424 |
<div class="inside">
|
425 |
|
426 |
-
<strong>Process</strong><br/>
|
427 |
<ul>
|
428 |
-
<li>Download a
|
429 |
<li>Create a child theme based on it</li>
|
430 |
<li>Activate the child theme</li>
|
431 |
<li>Customize the child theme</li>
|
@@ -437,7 +429,7 @@ function orbisius_child_theme_creator_settings_page() {
|
|
437 |
|
438 |
</div> <!-- .postbox -->
|
439 |
|
440 |
-
<div class="postbox">
|
441 |
<?php
|
442 |
$plugin_data = orbisius_child_theme_creator_get_plugin_data();
|
443 |
|
@@ -577,11 +569,22 @@ function orbisius_child_theme_creator_settings_page() {
|
|
577 |
</div> <!-- .inside -->
|
578 |
</div> <!-- .postbox --> <!-- /quick-contact -->
|
579 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
580 |
<!-- Hire Us -->
|
581 |
<div class="postbox">
|
582 |
<h3><span>Hire Us</span></h3>
|
583 |
<div class="inside">
|
584 |
-
Hire us to create a plugin/web/
|
585 |
<br/><a href="//orbisius.com/page/free-quote/?utm_source=<?php echo str_replace('.php', '', basename(__FILE__));?>&utm_medium=plugin-settings&utm_campaign=product"
|
586 |
title="If you want a custom web/mobile app/plugin developed contact us. This opens in a new window/tab"
|
587 |
class="button-primary" target="_blank">Get a Free Quote</a>
|
@@ -2221,6 +2224,7 @@ class orbisius_child_theme_creator_html {
|
|
2221 |
|
2222 |
// generates HTML select
|
2223 |
public static function html_select($name = '', $sel = null, $options = array(), $attr = '') {
|
|
|
2224 |
$name = trim($name);
|
2225 |
$elem_name = $name;
|
2226 |
$elem_name = strtolower($elem_name);
|
@@ -2259,8 +2263,27 @@ class orbisius_child_theme_creator_html {
|
|
2259 |
|
2260 |
return $html;
|
2261 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2262 |
}
|
2263 |
|
|
|
2264 |
/**
|
2265 |
* This method creates 2 panes that the user is able to use to edit theme files.
|
2266 |
* Everythin happens with AJAX
|
@@ -2346,6 +2369,9 @@ function orbisius_ctc_theme_editor() {
|
|
2346 |
<tr>
|
2347 |
<td width="50%">
|
2348 |
<form id="orbisius_ctc_theme_editor_theme_1_form" class="orbisius_ctc_theme_editor_theme_1_form">
|
|
|
|
|
|
|
2349 |
<strong>Theme #1:</strong>
|
2350 |
<?php echo orbisius_child_theme_creator_html::html_select('theme_1', $theme_1, $html_dropdown_themes); ?>
|
2351 |
|
@@ -2363,17 +2389,29 @@ function orbisius_ctc_theme_editor() {
|
|
2363 |
<div id="theme_1_file_contents_container">
|
2364 |
<textarea id="theme_1_file_contents" name="theme_1_file_contents" rows="16" class="widefat"></textarea>
|
2365 |
</div>
|
|
|
2366 |
|
2367 |
<div class="orbisius_ctc_theme_editor_theme_1_primary_buttons primary_buttons">
|
2368 |
<button type='submit' class='button button-primary' id="theme_1_submit" name="theme_1_submit">Save Changes</button>
|
2369 |
<span class="status"></span>
|
2370 |
</div>
|
|
|
2371 |
</form>
|
2372 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2373 |
|
2374 |
<hr />
|
2375 |
<div class="orbisius_ctc_theme_editor_theme_1_secondary_buttons secondary_buttons">
|
2376 |
<button type="button" class='button' id="theme_1_new_file_btn" name="theme_1_new_file_btn">New File</button>
|
|
|
2377 |
<button type="button" class='button' id="theme_1_syntax_chk_btn" name="theme_1_syntax_chk_btn">PHP Syntax Check</button>
|
2378 |
<button type="button" class='button' id="theme_1_send_btn" name="theme_1_send_btn">Send</button>
|
2379 |
<a href="<?php echo site_url('/');?>" class='button' target="_blank" title="new tab/window"
|
@@ -2468,6 +2506,9 @@ function orbisius_ctc_theme_editor() {
|
|
2468 |
</td>
|
2469 |
<td width="50%">
|
2470 |
<form id="orbisius_ctc_theme_editor_theme_2_form" class="orbisius_ctc_theme_editor_theme_2_form">
|
|
|
|
|
|
|
2471 |
<strong>Theme #2:</strong>
|
2472 |
<?php echo orbisius_child_theme_creator_html::html_select('theme_2', $theme_2, $html_dropdown_themes); ?>
|
2473 |
|
@@ -2490,12 +2531,24 @@ function orbisius_ctc_theme_editor() {
|
|
2490 |
<button type='submit' class='button button-primary' id="theme_2_submit" name="theme_2_submit">Save Changes</button>
|
2491 |
<span class="status"></span>
|
2492 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2493 |
|
2494 |
<hr />
|
2495 |
<div class="orbisius_ctc_theme_editor_theme_2_secondary_buttons secondary_buttons">
|
2496 |
<!-- If you're looking at this code. Slavi says Hi to the curious developer! :) -->
|
2497 |
|
2498 |
<button type="button" class='button' id="theme_2_new_file_btn" name="theme_2_new_file_btn">New File</button>
|
|
|
2499 |
<button type="button" class='button' id="theme_2_syntax_chk_btn" name="theme_2_syntax_chk_btn">PHP Syntax Check</button>
|
2500 |
<button type="button" class='button' id="theme_2_send_btn" name="theme_2_send_btn">Send</button>
|
2501 |
<a href="<?php echo site_url('/');?>" class='button' target="_blank" title="new tab/window"
|
@@ -2531,7 +2584,7 @@ function orbisius_ctc_theme_editor() {
|
|
2531 |
</div>
|
2532 |
<!-- /send -->
|
2533 |
</div>
|
2534 |
-
</form>
|
2535 |
</td>
|
2536 |
</tr>
|
2537 |
</table>
|
@@ -2550,8 +2603,11 @@ function orbisius_ctc_theme_editor_no_auth_ajax() {
|
|
2550 |
* This is called via ajax. Depending on the sub_cmd param a different method will be called.
|
2551 |
*/
|
2552 |
function orbisius_ctc_theme_editor_ajax() {
|
|
|
|
|
|
|
2553 |
$buff = 'INVALID AJAX SUB_CMD';
|
2554 |
-
|
2555 |
$req = orbisius_child_theme_creator_get_request();
|
2556 |
$sub_cmd = empty($req['sub_cmd']) ? '' : $req['sub_cmd'];
|
2557 |
|
@@ -2585,6 +2641,15 @@ function orbisius_ctc_theme_editor_ajax() {
|
|
2585 |
|
2586 |
break;
|
2587 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2588 |
default:
|
2589 |
break;
|
2590 |
}
|
@@ -2758,11 +2823,81 @@ function orbisius_ctc_theme_editor_check_syntax($theme_file_contents) {
|
|
2758 |
* @return string
|
2759 |
*/
|
2760 |
function orbisius_ctc_theme_editor_generate_dropdown() {
|
2761 |
-
$theme_base_dir = $theme_1_file = '';
|
2762 |
$req = orbisius_child_theme_creator_get_request();
|
|
|
|
|
2763 |
|
2764 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2765 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2766 |
if (!empty($req['theme_1'])) {
|
2767 |
$theme_base_dir = empty($req['theme_1']) ? '' : preg_replace('#[^\w-]#si', '', $req['theme_1']);
|
2768 |
$theme_1_file = empty($req['theme_1_file']) ? 'style.css' : $req['theme_1_file'];
|
@@ -2790,10 +2925,7 @@ function orbisius_ctc_theme_editor_generate_dropdown() {
|
|
2790 |
}
|
2791 |
|
2792 |
// we're going to make values to be keys as well.
|
2793 |
-
|
2794 |
-
$buff = orbisius_child_theme_creator_html::html_select($select_name, $theme_1_file, $html_dropdown_theme_1_files);
|
2795 |
-
|
2796 |
-
return $buff;
|
2797 |
}
|
2798 |
|
2799 |
/**
|
@@ -2895,6 +3027,50 @@ function orbisius_ctc_theme_editor_manage_file( $cmd_id = 1 ) {
|
|
2895 |
$buff = json_encode($status_rec);
|
2896 |
}
|
2897 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2898 |
|
2899 |
else {
|
2900 |
|
3 |
Plugin Name: Orbisius Child Theme Creator
|
4 |
Plugin URI: https://orbisius.com/products/wordpress-plugins/orbisius-child-theme-creator/
|
5 |
Description: This plugin allows you to quickly create child themes from any theme that you have currently installed on your site/blog.
|
6 |
+
Version: 1.5.2
|
7 |
Author: Svetoslav Marinov (Slavi)
|
8 |
Author URI: https://orbisius.com
|
9 |
*/
|
318 |
wp_enqueue_script( 'jquery' );
|
319 |
wp_register_script( 'orbisius_child_theme_creator', plugins_url("/assets/main{$suffix}.js", __FILE__), array('jquery', ),
|
320 |
filemtime( plugin_dir_path( __FILE__ ) . "/assets/main{$suffix}.js" ), true);
|
321 |
+
|
322 |
+
if (strpos($current_page, 'orbisius_child_theme_creator_theme_editor_action') !== false) {
|
323 |
+
wp_enqueue_script( 'orbisius_child_theme_creator' );
|
324 |
+
}
|
325 |
+
|
326 |
|
327 |
do_action( 'orbisius_child_theme_creator_admin_enqueue_scripts', array( 'suffix' => $suffix, ) );
|
328 |
}
|
396 |
<div id="icon-options-general" class="icon32"></div>
|
397 |
<h2>Orbisius Child Theme Creator</h2>
|
398 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
399 |
<div class="updated0"><p>
|
400 |
+
This plugin doesn't currently have any options. To use it go to
|
401 |
<a href='<?php echo $just_link;?>'><strong>Appearance → Orbisius Child Theme Creator</strong></a>
|
402 |
</p></div>
|
403 |
|
413 |
|
414 |
<div class="postbox">
|
415 |
|
416 |
+
<h3><span>Usage / Help</span> - <a href='<?php echo $just_link;?>'><strong>Appearance → Orbisius Child Theme Creator</strong></a></h3>
|
417 |
<div class="inside">
|
418 |
|
|
|
419 |
<ul>
|
420 |
+
<li>Download/install a theme that you like</li>
|
421 |
<li>Create a child theme based on it</li>
|
422 |
<li>Activate the child theme</li>
|
423 |
<li>Customize the child theme</li>
|
429 |
|
430 |
</div> <!-- .postbox -->
|
431 |
|
432 |
+
<div class="postbox">
|
433 |
<?php
|
434 |
$plugin_data = orbisius_child_theme_creator_get_plugin_data();
|
435 |
|
569 |
</div> <!-- .inside -->
|
570 |
</div> <!-- .postbox --> <!-- /quick-contact -->
|
571 |
|
572 |
+
<!-- Hire Us -->
|
573 |
+
<div class="postbox">
|
574 |
+
<h3><span>Need a test WordPress site?</span></h3>
|
575 |
+
<div class="inside">
|
576 |
+
Try <a
|
577 |
+
href="https://qsandbox.com/?utm_source=orbisius-child-theme-creator&utm_medium=settings_screen&utm_campaign=product"
|
578 |
+
target="_blank" title="[new window]">qSandbox.com</a> today (has a free plan)
|
579 |
+
</div> <!-- .inside -->
|
580 |
+
</div> <!-- .postbox -->
|
581 |
+
<!-- /Hire Us -->
|
582 |
+
|
583 |
<!-- Hire Us -->
|
584 |
<div class="postbox">
|
585 |
<h3><span>Hire Us</span></h3>
|
586 |
<div class="inside">
|
587 |
+
Hire us to create a plugin/web/SaaS app
|
588 |
<br/><a href="//orbisius.com/page/free-quote/?utm_source=<?php echo str_replace('.php', '', basename(__FILE__));?>&utm_medium=plugin-settings&utm_campaign=product"
|
589 |
title="If you want a custom web/mobile app/plugin developed contact us. This opens in a new window/tab"
|
590 |
class="button-primary" target="_blank">Get a Free Quote</a>
|
2224 |
|
2225 |
// generates HTML select
|
2226 |
public static function html_select($name = '', $sel = null, $options = array(), $attr = '') {
|
2227 |
+
|
2228 |
$name = trim($name);
|
2229 |
$elem_name = $name;
|
2230 |
$elem_name = strtolower($elem_name);
|
2263 |
|
2264 |
return $html;
|
2265 |
}
|
2266 |
+
|
2267 |
+
public static function html_files_tree( $class = '', $files = array() ) {
|
2268 |
+
|
2269 |
+
$html = '<ul class="orbisius_folder_list">';
|
2270 |
+
|
2271 |
+
foreach ( $files as $item => $value ) {
|
2272 |
+
|
2273 |
+
$is_folder = is_array($value) ? true : false;
|
2274 |
+
|
2275 |
+
$folder_checkbox = $is_folder ? '<label class="orbisius_folder_label"><input type="checkbox"name="'.$class.'_folder_checkbox[]" value="'.$item.'" ><span class="dashicons dashicons-category"></span>'.$item.'</label>' : '';
|
2276 |
+
$list_class = $is_folder ? 'orbisius_folder' : 'orbisius_file';
|
2277 |
+
$html .= '<li class="'.$list_class.'">' .$folder_checkbox . ( $is_folder ? orbisius_child_theme_creator_html::html_files_tree($class, $value) : '<label class="orbisius_file_label"><input type="checkbox" class="orb_files" name="'.$class.'_files_checkbox[]" value="'.$value.'" ><span class="dashicons dashicons-text-page"></span>'.$item.'</label>' ) . '</li>';
|
2278 |
+
}
|
2279 |
+
$html .= '</ul>';
|
2280 |
+
|
2281 |
+
return $html;
|
2282 |
+
|
2283 |
+
}
|
2284 |
}
|
2285 |
|
2286 |
+
|
2287 |
/**
|
2288 |
* This method creates 2 panes that the user is able to use to edit theme files.
|
2289 |
* Everythin happens with AJAX
|
2369 |
<tr>
|
2370 |
<td width="50%">
|
2371 |
<form id="orbisius_ctc_theme_editor_theme_1_form" class="orbisius_ctc_theme_editor_theme_1_form">
|
2372 |
+
|
2373 |
+
<?php wp_nonce_field( 'orbisius_ctc_nonce' ); ?>
|
2374 |
+
|
2375 |
<strong>Theme #1:</strong>
|
2376 |
<?php echo orbisius_child_theme_creator_html::html_select('theme_1', $theme_1, $html_dropdown_themes); ?>
|
2377 |
|
2389 |
<div id="theme_1_file_contents_container">
|
2390 |
<textarea id="theme_1_file_contents" name="theme_1_file_contents" rows="16" class="widefat"></textarea>
|
2391 |
</div>
|
2392 |
+
|
2393 |
|
2394 |
<div class="orbisius_ctc_theme_editor_theme_1_primary_buttons primary_buttons">
|
2395 |
<button type='submit' class='button button-primary' id="theme_1_submit" name="theme_1_submit">Save Changes</button>
|
2396 |
<span class="status"></span>
|
2397 |
</div>
|
2398 |
+
|
2399 |
</form>
|
2400 |
|
2401 |
+
<form id="orbisius_ctc_copy_files_theme_1_form" class="orbisius_ctc_copy_files_theme_1_form">
|
2402 |
+
<?php wp_nonce_field( 'orbisius_ctc_nonce' ); ?>
|
2403 |
+
<div class="orbisius_ctc_theme_editor_theme_1_files_list" style="display:none">
|
2404 |
+
<div class="orbisius_ctc_theme_editor_theme_1_files_list_container orbisius_files_list"></div>
|
2405 |
+
<div id="orbisius_copy_response_theme_1" class="orbisius_copy_response"></div>
|
2406 |
+
<button type='submit' class='button button-primary' id="theme_1_copy_files" name="theme_1_copy_files">Copy Files</button>
|
2407 |
+
<button type='submit' class='button' id="theme_1_copy_files_cancel" name="theme_1_copy_files_cancel">Cancel</button>
|
2408 |
+
</div>
|
2409 |
+
</form>
|
2410 |
|
2411 |
<hr />
|
2412 |
<div class="orbisius_ctc_theme_editor_theme_1_secondary_buttons secondary_buttons">
|
2413 |
<button type="button" class='button' id="theme_1_new_file_btn" name="theme_1_new_file_btn">New File</button>
|
2414 |
+
<button type="button" class='button' id="theme_1_copy_file_btn" name="theme_1_copy_file_btn">Browse file(s)</button>
|
2415 |
<button type="button" class='button' id="theme_1_syntax_chk_btn" name="theme_1_syntax_chk_btn">PHP Syntax Check</button>
|
2416 |
<button type="button" class='button' id="theme_1_send_btn" name="theme_1_send_btn">Send</button>
|
2417 |
<a href="<?php echo site_url('/');?>" class='button' target="_blank" title="new tab/window"
|
2506 |
</td>
|
2507 |
<td width="50%">
|
2508 |
<form id="orbisius_ctc_theme_editor_theme_2_form" class="orbisius_ctc_theme_editor_theme_2_form">
|
2509 |
+
|
2510 |
+
<?php wp_nonce_field( 'orbisius_ctc_nonce' ); ?>
|
2511 |
+
|
2512 |
<strong>Theme #2:</strong>
|
2513 |
<?php echo orbisius_child_theme_creator_html::html_select('theme_2', $theme_2, $html_dropdown_themes); ?>
|
2514 |
|
2531 |
<button type='submit' class='button button-primary' id="theme_2_submit" name="theme_2_submit">Save Changes</button>
|
2532 |
<span class="status"></span>
|
2533 |
</div>
|
2534 |
+
</form>
|
2535 |
+
|
2536 |
+
<form id="orbisius_ctc_copy_files_theme_2_form" class="orbisius_ctc_copy_files_theme_2_form">
|
2537 |
+
<?php wp_nonce_field( 'orbisius_ctc_nonce' ); ?>
|
2538 |
+
<div class="orbisius_ctc_theme_editor_theme_2_files_list" style="display:none">
|
2539 |
+
<div class="orbisius_ctc_theme_editor_theme_2_files_list_container orbisius_files_list"></div>
|
2540 |
+
<div id="orbisius_copy_response_theme_2" class="orbisius_copy_response"></div>
|
2541 |
+
<button type='submit' class='button button-primary' id="theme_2_copy_files" name="theme_2_copy_files">Copy Files</button>
|
2542 |
+
<button type='submit' class='button' id="theme_2_copy_files_cancel" name="theme_2_copy_files_cancel">Cancel</button>
|
2543 |
+
</div>
|
2544 |
+
</form>
|
2545 |
|
2546 |
<hr />
|
2547 |
<div class="orbisius_ctc_theme_editor_theme_2_secondary_buttons secondary_buttons">
|
2548 |
<!-- If you're looking at this code. Slavi says Hi to the curious developer! :) -->
|
2549 |
|
2550 |
<button type="button" class='button' id="theme_2_new_file_btn" name="theme_2_new_file_btn">New File</button>
|
2551 |
+
<button type="button" class='button' id="theme_2_copy_file_btn" name="theme_2_copy_file_btn">Browse file(s)</button>
|
2552 |
<button type="button" class='button' id="theme_2_syntax_chk_btn" name="theme_2_syntax_chk_btn">PHP Syntax Check</button>
|
2553 |
<button type="button" class='button' id="theme_2_send_btn" name="theme_2_send_btn">Send</button>
|
2554 |
<a href="<?php echo site_url('/');?>" class='button' target="_blank" title="new tab/window"
|
2584 |
</div>
|
2585 |
<!-- /send -->
|
2586 |
</div>
|
2587 |
+
<!-- </form> -->
|
2588 |
</td>
|
2589 |
</tr>
|
2590 |
</table>
|
2603 |
* This is called via ajax. Depending on the sub_cmd param a different method will be called.
|
2604 |
*/
|
2605 |
function orbisius_ctc_theme_editor_ajax() {
|
2606 |
+
check_ajax_referer( 'orbisius_ctc_nonce' );
|
2607 |
+
|
2608 |
+
|
2609 |
$buff = 'INVALID AJAX SUB_CMD';
|
2610 |
+
|
2611 |
$req = orbisius_child_theme_creator_get_request();
|
2612 |
$sub_cmd = empty($req['sub_cmd']) ? '' : $req['sub_cmd'];
|
2613 |
|
2641 |
|
2642 |
break;
|
2643 |
|
2644 |
+
case 'copy_files':
|
2645 |
+
$buff = orbisius_ctc_theme_editor_manage_file(6);
|
2646 |
+
|
2647 |
+
break;
|
2648 |
+
|
2649 |
+
case 'get_files':
|
2650 |
+
$buff = orbisius_ctc_theme_editor_generate_files_tree();
|
2651 |
+
break;
|
2652 |
+
|
2653 |
default:
|
2654 |
break;
|
2655 |
}
|
2823 |
* @return string
|
2824 |
*/
|
2825 |
function orbisius_ctc_theme_editor_generate_dropdown() {
|
|
|
2826 |
$req = orbisius_child_theme_creator_get_request();
|
2827 |
+
$html_dropdown_theme_1_files = orbisius_ctc_generate_list_of_theme_files($req);
|
2828 |
+
$buff = orbisius_child_theme_creator_html::html_select($select_name, $theme_1_file, $html_dropdown_theme_1_files);
|
2829 |
|
2830 |
+
return $buff;
|
2831 |
+
}
|
2832 |
+
|
2833 |
+
function orbisius_ctc_theme_editor_generate_files_tree() {
|
2834 |
+
|
2835 |
+
$req = orbisius_child_theme_creator_get_request();
|
2836 |
+
|
2837 |
+
$paths = orbisius_ctc_generate_list_of_theme_files($req);
|
2838 |
+
|
2839 |
+
$tree = orbisius_ctc_explode_tree( $paths, "/" );
|
2840 |
|
2841 |
+
if (!empty($req['theme_1'])) {
|
2842 |
+
$name = 'theme_1_files';
|
2843 |
+
} elseif (!empty($req['theme_2'])) {
|
2844 |
+
$name = 'theme_2_files';
|
2845 |
+
}
|
2846 |
+
$buff = orbisius_child_theme_creator_html::html_files_tree($name, $tree);
|
2847 |
+
|
2848 |
+
return $buff;
|
2849 |
+
}
|
2850 |
+
|
2851 |
+
// https://kvz.io/convert-anything-to-tree-structures-in-php.html
|
2852 |
+
function orbisius_ctc_explode_tree($array, $delimiter = '_', $baseval = false) {
|
2853 |
+
if ( !is_array($array) ) return false;
|
2854 |
+
|
2855 |
+
$split = '/' . preg_quote($delimiter, '/') . '/';
|
2856 |
+
$return_array = array();
|
2857 |
+
foreach ($array as $key => $val) {
|
2858 |
+
// Get parent parts and the current leaf
|
2859 |
+
$parts = preg_split($split, $key, -1, PREG_SPLIT_NO_EMPTY);
|
2860 |
+
$leaf = array_pop($parts);
|
2861 |
+
|
2862 |
+
// Build parent structure
|
2863 |
+
// Might be slow for really deep and large structures
|
2864 |
+
$parent_arr = &$return_array;
|
2865 |
+
foreach ($parts as $part) {
|
2866 |
+
if (!isset($parent_arr[$part])) {
|
2867 |
+
$parent_arr[$part] = array();
|
2868 |
+
} elseif (!is_array($parent_arr[$part])) {
|
2869 |
+
if ($baseval) {
|
2870 |
+
$parent_arr[$part] = array('__base_val' => $parent_arr[$part]);
|
2871 |
+
} else {
|
2872 |
+
$parent_arr[$part] = array();
|
2873 |
+
}
|
2874 |
+
}
|
2875 |
+
$parent_arr = &$parent_arr[$part];
|
2876 |
+
}
|
2877 |
+
|
2878 |
+
// Add the final part to the structure
|
2879 |
+
if (empty($parent_arr[$leaf])) {
|
2880 |
+
$parent_arr[$leaf] = $val;
|
2881 |
+
} elseif ($baseval && is_array($parent_arr[$leaf])) {
|
2882 |
+
$parent_arr[$leaf]['__base_val'] = $val;
|
2883 |
+
}
|
2884 |
+
}
|
2885 |
+
|
2886 |
+
return $return_array;
|
2887 |
+
}
|
2888 |
+
|
2889 |
+
|
2890 |
+
/**
|
2891 |
+
* This returns array of theme files
|
2892 |
+
|
2893 |
+
* @return array
|
2894 |
+
*/
|
2895 |
+
function orbisius_ctc_generate_list_of_theme_files($req) {
|
2896 |
+
|
2897 |
+
$theme_base_dir = $theme_1_file = '';
|
2898 |
+
|
2899 |
+
$select_name = 'theme_1_file';
|
2900 |
+
|
2901 |
if (!empty($req['theme_1'])) {
|
2902 |
$theme_base_dir = empty($req['theme_1']) ? '' : preg_replace('#[^\w-]#si', '', $req['theme_1']);
|
2903 |
$theme_1_file = empty($req['theme_1_file']) ? 'style.css' : $req['theme_1_file'];
|
2925 |
}
|
2926 |
|
2927 |
// we're going to make values to be keys as well.
|
2928 |
+
return array_combine($files, $files);
|
|
|
|
|
|
|
2929 |
}
|
2930 |
|
2931 |
/**
|
3027 |
$buff = json_encode($status_rec);
|
3028 |
}
|
3029 |
}
|
3030 |
+
elseif ($cmd_id == 6) { // copy
|
3031 |
+
$status = array(
|
3032 |
+
'status' => 0,
|
3033 |
+
'message' => '',
|
3034 |
+
'files' => array()
|
3035 |
+
);
|
3036 |
+
|
3037 |
+
if ( $req['copy'] === '[]' ) {
|
3038 |
+
$status['message'] = 'No files selected!';
|
3039 |
+
return json_encode($status);
|
3040 |
+
}
|
3041 |
+
|
3042 |
+
if ( empty($req['copy_to']) ) {
|
3043 |
+
$status['message'] = 'Please select destination Theme!';
|
3044 |
+
return json_encode($status);
|
3045 |
+
}
|
3046 |
+
|
3047 |
+
$files = json_decode($req['copy'], true);
|
3048 |
+
|
3049 |
+
$theme_2_base_dir = preg_replace( $theme_dir_regex, '', $req['copy_to']);
|
3050 |
+
$theme_2_dir = $theme_root . trailingslashit($theme_2_base_dir);
|
3051 |
+
|
3052 |
+
foreach ( $files as $file ) {
|
3053 |
+
$src_file = $theme_dir . $file;
|
3054 |
+
$target_file = $theme_2_dir . $file;
|
3055 |
+
$target_dir = dirname($target_file);
|
3056 |
+
$stat = wp_mkdir_p($target_dir);
|
3057 |
+
|
3058 |
+
if ( !copy($src_file, $target_file) ) {
|
3059 |
+
if ( $req['copy'] === '[]' ) {
|
3060 |
+
$status['message'] = 'Cannot copy selected files!';
|
3061 |
+
return json_encode($status);
|
3062 |
+
}
|
3063 |
+
}
|
3064 |
+
}
|
3065 |
+
|
3066 |
+
$status = array(
|
3067 |
+
'status' => 1,
|
3068 |
+
'message' => 'All files have been successfully copied.',
|
3069 |
+
'files' => $files
|
3070 |
+
);
|
3071 |
+
|
3072 |
+
return json_encode($status);
|
3073 |
+
}
|
3074 |
|
3075 |
else {
|
3076 |
|
readme.txt
CHANGED
@@ -3,9 +3,9 @@ Contributors: lordspace,orbisius
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7APYDVPBCSY9A
|
4 |
Tags: theme,child theme,childtheme,childthemes,parent theme,child themes,CSS,styling,resposive design,design,custom themeing, shared hosting,theme editor theme,themes,wp,wordpress,orbisius,theme creator,custom theme,theme generator,css,css editor
|
5 |
Requires at least: 3.4
|
6 |
-
Tested up to: 5.
|
7 |
-
Requires PHP: 5.
|
8 |
-
Stable tag: 1.5.
|
9 |
License: GPLv2 or later
|
10 |
|
11 |
Create Child Themes quickly and easily from any theme that you have currently installed on your site/blog.
|
@@ -31,6 +31,7 @@ It also creates rtl.css if exists in the parent theme.
|
|
31 |
* Edit theme files with our two theme editors.
|
32 |
* Automatically creates rtl.css if it exists in the parent theme
|
33 |
* The plugin uses minified css/js to make sure it loads quicker.
|
|
|
34 |
|
35 |
This plugin allows you to quickly edit theme files from Appearance > Orbisius Theme Editor (entry added by the same plugin)
|
36 |
It features two editors and you can pick snippets from one theme and paste into another.
|
@@ -169,6 +170,12 @@ Todo
|
|
169 |
|
170 |
== Changelog ==
|
171 |
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
= 1.5.1 =
|
173 |
* Updated links to be https
|
174 |
* Tested with WP 5.4
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7APYDVPBCSY9A
|
4 |
Tags: theme,child theme,childtheme,childthemes,parent theme,child themes,CSS,styling,resposive design,design,custom themeing, shared hosting,theme editor theme,themes,wp,wordpress,orbisius,theme creator,custom theme,theme generator,css,css editor
|
5 |
Requires at least: 3.4
|
6 |
+
Tested up to: 5.5
|
7 |
+
Requires PHP: 5.6
|
8 |
+
Stable tag: 1.5.2
|
9 |
License: GPLv2 or later
|
10 |
|
11 |
Create Child Themes quickly and easily from any theme that you have currently installed on your site/blog.
|
31 |
* Edit theme files with our two theme editors.
|
32 |
* Automatically creates rtl.css if it exists in the parent theme
|
33 |
* The plugin uses minified css/js to make sure it loads quicker.
|
34 |
+
* Copy files from one theme to another (Since v1.5.2)
|
35 |
|
36 |
This plugin allows you to quickly edit theme files from Appearance > Orbisius Theme Editor (entry added by the same plugin)
|
37 |
It features two editors and you can pick snippets from one theme and paste into another.
|
170 |
|
171 |
== Changelog ==
|
172 |
|
173 |
+
= 1.5.2 =
|
174 |
+
* Copy files from one theme to another
|
175 |
+
* Simplified settings page
|
176 |
+
* Tested with WP 5.5
|
177 |
+
* Fixes and improvements
|
178 |
+
|
179 |
= 1.5.1 =
|
180 |
* Updated links to be https
|
181 |
* Tested with WP 5.4
|