Version Description
- 2021-01-26 =
- Added : All, Free and Pro Tab
- Updated : Tested up to 5.6 WordPress
- Updated : PHPCS
- Updated : Some minor design
- Updated : Minor changes
- Fixed : File Type Check
Download this release
Release Info
Developer | addonspress |
Plugin | Advanced Import : One Click Import for WordPress or Theme Demo Data |
Version | 1.3.0 |
Comparing to | |
See all releases |
Code changes from version 1.2.5 to 1.3.0
- admin/class-advanced-import-admin.php +2468 -2461
- advanced-import.php +2 -2
- assets/css/advanced-import-admin.min.css +1 -1
- assets/js/advanced-import-admin.min.js +1 -1
- readme.txt +10 -2
admin/class-advanced-import-admin.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
*/
|
10 |
|
11 |
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
-
|
13 |
}
|
14 |
|
15 |
/**
|
@@ -24,2481 +24,2488 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
24 |
*/
|
25 |
class Advanced_Import_Admin {
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
<?php
|
675 |
-
$types = array_column( $demo_lists, 'type' );
|
676 |
-
$unique_types = array_unique( $types );
|
677 |
-
foreach ( $unique_types as $cat_index => $single_type ) {
|
678 |
-
?>
|
679 |
-
<li class="ai-filter-btn" data-filter=".<?php echo strtolower( esc_attr( $single_type ) ); ?>">
|
680 |
-
<?php echo ucfirst( esc_html( $single_type ) ); ?>
|
681 |
-
<span class="ai-count"></span>
|
682 |
-
|
683 |
-
</li>
|
684 |
-
<?php
|
685 |
-
}
|
686 |
-
?>
|
687 |
-
</ul>
|
688 |
-
<div class="ai-search-control">
|
689 |
-
<input id="ai-filter-search-input" class="ai-search-filter" type="text" placeholder="<?php esc_attr_e( 'Search...', 'advanced-import' ); ?>">
|
690 |
-
</div>
|
691 |
-
<ul class="ai-form-type">
|
692 |
-
<li class="ai-form-file-import">
|
693 |
-
<?php esc_html_e( 'Upload zip', 'advanced-import' ); ?>
|
694 |
-
</li>
|
695 |
-
</ul>
|
696 |
-
</div>
|
697 |
-
</div>
|
698 |
-
<div class="ai-filter-content" id="ai-filter-content">
|
699 |
-
<div class="ai-actions ai-sidebar">
|
700 |
-
<div class="ai-import-available-categories">
|
701 |
-
<h3><?php esc_html_e( 'Categories', 'advanced-import' ); ?></h3>
|
702 |
-
<ul class="ai-import-available-categories-lists ai-filter-group" data-filter-group="primary">
|
703 |
-
<li class="ai-filter-btn-active ai-filter-btn" data-filter="*">
|
704 |
-
<?php esc_html_e( 'All Categories', 'advanced-import' ); ?>
|
705 |
-
<span class="ai-count"></span>
|
706 |
-
</li>
|
707 |
-
<?php
|
708 |
-
$categories = array_column( $demo_lists, 'categories' );
|
709 |
-
$unique_categories = array();
|
710 |
-
if ( is_array( $categories ) && ! empty( $categories ) ) {
|
711 |
-
foreach ( $categories as $demo_index => $demo_cats ) {
|
712 |
-
foreach ( $demo_cats as $cat_index => $single_cat ) {
|
713 |
-
if ( in_array( $single_cat, $unique_categories ) ) {
|
714 |
-
continue;
|
715 |
-
}
|
716 |
-
$unique_categories[] = $single_cat;
|
717 |
-
?>
|
718 |
-
<li class="ai-filter-btn" data-filter=".<?php echo strtolower( esc_attr( $single_cat ) ); ?>">
|
719 |
-
<?php echo ucfirst( esc_html( $single_cat ) ); ?>
|
720 |
-
<span class="ai-count"></span>
|
721 |
-
</li>
|
722 |
-
<?php
|
723 |
-
}
|
724 |
-
}
|
725 |
-
}
|
726 |
-
?>
|
727 |
-
</ul>
|
728 |
-
</div>
|
729 |
-
|
730 |
-
</div>
|
731 |
-
<div class="ai-filter-content-wrapper">
|
732 |
-
<?php
|
733 |
-
foreach ( $demo_lists as $key => $demo_list ) {
|
734 |
-
|
735 |
-
/*Check for required fields*/
|
736 |
-
if ( ! isset( $demo_list['title'] ) || ! isset( $demo_list['screenshot_url'] ) || ! isset( $demo_list['demo_url'] ) ) {
|
737 |
-
continue;
|
738 |
-
}
|
739 |
-
|
740 |
-
$template_url = isset( $demo_list['template_url'] ) ? $demo_list['template_url'] : '';
|
741 |
-
if ( is_array( $template_url ) ) {
|
742 |
-
$data_template = 'data-template_url="' . esc_attr( wp_json_encode( $template_url ) ) . '"';
|
743 |
-
$data_template_type = 'data-template_type="array"';
|
744 |
-
} elseif ( $template_url ) {
|
745 |
-
$data_template = 'data-template_url="' . esc_attr( $template_url ) . '"';
|
746 |
-
if ( is_file( $template_url ) && filesize( $template_url ) > 0 ) {
|
747 |
-
$data_template_type = 'data-template_type="file"';
|
748 |
-
} else {
|
749 |
-
$data_template_type = 'data-template_type="url"';
|
750 |
-
}
|
751 |
-
} else {
|
752 |
-
$data_template = 'data-template_url="' . esc_attr( wp_json_encode( $template_url ) ) . '"';
|
753 |
-
$data_template_type = 'data-template_type="array"';
|
754 |
-
}
|
755 |
-
?>
|
756 |
-
<div aria-label="<?php echo esc_attr( $demo_list['title'] ); ?>"
|
757 |
-
class="ai-item
|
758 |
<?php
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
763 |
"
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
<span>
|
1121 |
<?php echo esc_html( $default['pending'] ); ?>
|
1122 |
</span>
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
SELECT ID, post_name, post_parent, post_type
|
1429 |
FROM $wpdb->posts
|
1430 |
WHERE post_name = %s
|
1431 |
AND post_type = %s
|
1432 |
";
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
SELECT ID, post_name, post_parent, post_type
|
1465 |
FROM $wpdb->posts
|
1466 |
WHERE post_name = %s
|
1467 |
AND post_title = %s
|
1468 |
AND post_type = %s
|
1469 |
";
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
-
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
-
|
1585 |
-
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
1602 |
-
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
|
1607 |
-
|
1608 |
-
|
1609 |
-
|
1610 |
-
|
1611 |
-
|
1612 |
-
|
1613 |
-
|
1614 |
-
|
1615 |
-
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
|
1831 |
-
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
|
1837 |
-
|
1838 |
-
|
1839 |
-
|
1840 |
-
|
1841 |
-
|
1842 |
-
|
1843 |
-
|
1844 |
-
|
1845 |
-
|
1846 |
-
|
1847 |
-
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
-
|
1898 |
-
|
1899 |
-
|
1900 |
-
|
1901 |
-
|
1902 |
-
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
1907 |
-
|
1908 |
-
|
1909 |
-
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
|
1925 |
-
|
1926 |
-
|
1927 |
-
|
1928 |
-
|
1929 |
-
|
1930 |
-
|
1931 |
-
|
1932 |
-
|
1933 |
-
|
1934 |
-
|
1935 |
-
|
1936 |
-
|
1937 |
-
|
1938 |
-
|
1939 |
-
|
1940 |
-
|
1941 |
-
|
1942 |
-
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
1947 |
-
|
1948 |
-
|
1949 |
-
|
1950 |
-
|
1951 |
-
|
1952 |
-
|
1953 |
-
|
1954 |
-
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
1958 |
-
|
1959 |
-
|
1960 |
-
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
1968 |
-
|
1969 |
-
|
1970 |
-
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
|
1975 |
-
|
1976 |
-
|
1977 |
-
|
1978 |
-
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
1986 |
-
|
1987 |
-
|
1988 |
-
|
1989 |
-
|
1990 |
-
|
1991 |
-
|
1992 |
-
|
1993 |
-
|
1994 |
-
|
1995 |
-
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
-
|
2001 |
-
|
2002 |
-
|
2003 |
-
|
2004 |
-
|
2005 |
-
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
|
2014 |
-
|
2015 |
-
|
2016 |
-
|
2017 |
-
|
2018 |
-
|
2019 |
-
|
2020 |
-
|
2021 |
-
|
2022 |
-
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
2026 |
-
|
2027 |
-
|
2028 |
-
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
|
2043 |
-
|
2044 |
-
|
2045 |
-
|
2046 |
-
|
2047 |
-
|
2048 |
-
|
2049 |
-
|
2050 |
-
|
2051 |
-
|
2052 |
-
|
2053 |
-
|
2054 |
-
|
2055 |
-
|
2056 |
-
|
2057 |
-
|
2058 |
-
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
|
2063 |
-
|
2064 |
-
|
2065 |
-
|
2066 |
-
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
2071 |
-
|
2072 |
-
|
2073 |
-
|
2074 |
-
|
2075 |
-
|
2076 |
-
|
2077 |
-
|
2078 |
-
|
2079 |
-
|
2080 |
-
|
2081 |
-
|
2082 |
-
|
2083 |
-
|
2084 |
-
|
2085 |
-
|
2086 |
-
|
2087 |
-
|
2088 |
-
|
2089 |
-
|
2090 |
-
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
|
2096 |
-
|
2097 |
-
|
2098 |
-
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
2102 |
-
|
2103 |
-
|
2104 |
-
|
2105 |
-
|
2106 |
-
|
2107 |
-
|
2108 |
-
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
2112 |
-
|
2113 |
-
|
2114 |
-
|
2115 |
-
|
2116 |
-
|
2117 |
-
|
2118 |
-
|
2119 |
-
|
2120 |
-
|
2121 |
-
|
2122 |
-
|
2123 |
-
|
2124 |
-
|
2125 |
-
|
2126 |
-
|
2127 |
-
|
2128 |
-
|
2129 |
-
|
2130 |
-
|
2131 |
-
|
2132 |
-
|
2133 |
-
|
2134 |
-
|
2135 |
-
|
2136 |
-
|
2137 |
-
|
2138 |
-
|
2139 |
-
|
2140 |
-
|
2141 |
-
|
2142 |
-
|
2143 |
-
|
2144 |
-
|
2145 |
-
|
2146 |
-
|
2147 |
-
|
2148 |
-
|
2149 |
-
|
2150 |
-
|
2151 |
-
|
2152 |
-
|
2153 |
-
|
2154 |
-
|
2155 |
-
|
2156 |
-
|
2157 |
-
|
2158 |
-
|
2159 |
-
|
2160 |
-
|
2161 |
-
|
2162 |
-
|
2163 |
-
|
2164 |
-
|
2165 |
-
|
2166 |
-
|
2167 |
-
|
2168 |
-
|
2169 |
-
|
2170 |
-
|
2171 |
-
|
2172 |
-
|
2173 |
-
|
2174 |
-
|
2175 |
-
|
2176 |
-
|
2177 |
-
|
2178 |
-
|
2179 |
-
|
2180 |
-
|
2181 |
-
|
2182 |
-
|
2183 |
-
|
2184 |
-
|
2185 |
-
|
2186 |
-
|
2187 |
-
|
2188 |
-
|
2189 |
-
|
2190 |
-
|
2191 |
-
|
2192 |
-
|
2193 |
-
|
2194 |
-
|
2195 |
-
|
2196 |
-
|
2197 |
-
|
2198 |
-
|
2199 |
-
|
2200 |
-
|
2201 |
-
|
2202 |
-
|
2203 |
-
|
2204 |
-
|
2205 |
-
|
2206 |
-
|
2207 |
-
|
2208 |
-
|
2209 |
-
|
2210 |
-
|
2211 |
-
|
2212 |
-
|
2213 |
-
|
2214 |
-
|
2215 |
-
|
2216 |
-
|
2217 |
-
|
2218 |
-
|
2219 |
-
|
2220 |
-
|
2221 |
-
|
2222 |
-
|
2223 |
-
|
2224 |
-
|
2225 |
-
|
2226 |
-
|
2227 |
-
|
2228 |
-
|
2229 |
-
|
2230 |
-
|
2231 |
-
|
2232 |
-
|
2233 |
-
|
2234 |
-
|
2235 |
-
|
2236 |
-
|
2237 |
-
|
2238 |
-
|
2239 |
-
|
2240 |
-
|
2241 |
-
|
2242 |
-
|
2243 |
-
|
2244 |
-
|
2245 |
-
|
2246 |
-
|
2247 |
-
|
2248 |
-
|
2249 |
-
|
2250 |
-
|
2251 |
-
|
2252 |
-
|
2253 |
-
|
2254 |
-
|
2255 |
-
|
2256 |
-
|
2257 |
-
|
2258 |
-
|
2259 |
-
|
2260 |
-
|
2261 |
-
|
2262 |
-
|
2263 |
-
|
2264 |
-
|
2265 |
-
|
2266 |
-
|
2267 |
-
|
2268 |
-
|
2269 |
-
|
2270 |
-
|
2271 |
-
|
2272 |
-
|
2273 |
-
|
2274 |
-
|
2275 |
-
|
2276 |
-
|
2277 |
-
|
2278 |
-
|
2279 |
-
|
2280 |
-
|
2281 |
-
|
2282 |
-
|
2283 |
-
|
2284 |
-
|
2285 |
-
|
2286 |
-
|
2287 |
-
|
2288 |
-
|
2289 |
-
|
2290 |
-
|
2291 |
-
|
2292 |
-
|
2293 |
-
|
2294 |
-
|
2295 |
-
|
2296 |
-
|
2297 |
-
|
2298 |
-
|
2299 |
-
|
2300 |
-
|
2301 |
-
|
2302 |
-
|
2303 |
-
|
2304 |
-
|
2305 |
-
|
2306 |
-
|
2307 |
-
|
2308 |
-
|
2309 |
-
|
2310 |
-
|
2311 |
-
|
2312 |
-
|
2313 |
-
|
2314 |
-
|
2315 |
-
|
2316 |
-
|
2317 |
-
|
2318 |
-
|
2319 |
-
|
2320 |
-
|
2321 |
-
|
2322 |
-
|
2323 |
-
|
2324 |
-
|
2325 |
-
|
2326 |
-
|
2327 |
-
|
2328 |
-
|
2329 |
-
|
2330 |
-
|
2331 |
-
|
2332 |
-
|
2333 |
-
|
2334 |
-
|
2335 |
-
|
2336 |
-
|
2337 |
-
|
2338 |
-
|
2339 |
-
|
2340 |
-
|
2341 |
-
|
2342 |
-
|
2343 |
-
|
2344 |
-
|
2345 |
-
|
2346 |
-
|
2347 |
-
|
2348 |
-
|
2349 |
-
|
2350 |
-
|
2351 |
-
|
2352 |
-
|
2353 |
-
|
2354 |
-
|
2355 |
-
|
2356 |
-
|
2357 |
-
|
2358 |
-
|
2359 |
-
|
2360 |
-
|
2361 |
-
|
2362 |
-
|
2363 |
-
|
2364 |
-
|
2365 |
-
|
2366 |
-
|
2367 |
-
|
2368 |
-
|
2369 |
-
|
2370 |
-
|
2371 |
-
|
2372 |
-
|
2373 |
-
|
2374 |
-
|
2375 |
-
|
2376 |
-
|
2377 |
-
|
2378 |
-
|
2379 |
-
|
2380 |
-
|
2381 |
-
|
2382 |
-
|
2383 |
-
|
2384 |
-
|
2385 |
-
|
2386 |
-
|
2387 |
-
|
2388 |
-
|
2389 |
-
|
2390 |
-
|
2391 |
-
|
2392 |
-
|
2393 |
-
|
2394 |
-
|
2395 |
-
|
2396 |
-
|
2397 |
-
|
2398 |
-
|
2399 |
-
|
2400 |
-
|
2401 |
-
|
2402 |
-
|
2403 |
-
|
2404 |
-
|
2405 |
-
|
2406 |
-
|
2407 |
-
|
2408 |
-
|
2409 |
-
|
2410 |
-
|
2411 |
-
|
2412 |
-
|
2413 |
-
|
2414 |
-
|
2415 |
-
|
2416 |
-
|
2417 |
-
|
2418 |
-
|
2419 |
-
|
2420 |
-
|
2421 |
-
|
2422 |
-
|
2423 |
-
|
2424 |
-
|
2425 |
-
|
2426 |
-
|
2427 |
-
|
2428 |
-
|
2429 |
-
|
2430 |
-
|
2431 |
-
|
2432 |
-
|
2433 |
-
|
2434 |
-
|
2435 |
-
|
2436 |
-
|
2437 |
-
|
2438 |
-
|
2439 |
-
|
2440 |
-
|
2441 |
-
|
2442 |
-
|
2443 |
-
|
2444 |
-
|
2445 |
-
|
2446 |
-
|
2447 |
-
|
2448 |
-
|
2449 |
-
|
2450 |
-
|
2451 |
-
|
2452 |
-
|
2453 |
-
|
2454 |
-
|
2455 |
-
|
2456 |
-
|
2457 |
-
|
2458 |
-
|
2459 |
-
|
2460 |
-
|
2461 |
-
|
2462 |
-
|
2463 |
-
|
2464 |
-
|
2465 |
-
|
2466 |
-
|
2467 |
-
|
2468 |
-
|
2469 |
-
|
2470 |
-
|
2471 |
-
|
2472 |
-
|
2473 |
-
|
2474 |
-
|
2475 |
-
|
2476 |
-
|
2477 |
-
|
2478 |
-
|
2479 |
-
|
2480 |
-
|
2481 |
-
|
2482 |
-
|
2483 |
-
|
2484 |
-
|
2485 |
-
|
2486 |
-
|
2487 |
-
|
2488 |
-
|
2489 |
-
|
2490 |
-
|
2491 |
-
|
2492 |
-
|
2493 |
-
|
2494 |
-
|
2495 |
-
|
2496 |
-
|
2497 |
-
|
2498 |
-
|
2499 |
-
|
2500 |
-
|
2501 |
-
}
|
2502 |
}
|
2503 |
|
2504 |
/**
|
@@ -2511,5 +2518,5 @@ class Advanced_Import_Admin {
|
|
2511 |
* @since 1.0.0
|
2512 |
*/
|
2513 |
function advanced_import_admin() {
|
2514 |
-
|
2515 |
}
|
9 |
*/
|
10 |
|
11 |
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
+
exit;
|
13 |
}
|
14 |
|
15 |
/**
|
24 |
*/
|
25 |
class Advanced_Import_Admin {
|
26 |
|
27 |
+
/**
|
28 |
+
* The Name of this plugin.
|
29 |
+
*
|
30 |
+
* @since 1.0.0
|
31 |
+
* @access private
|
32 |
+
* @var string $plugin_name The ID of this plugin.
|
33 |
+
*/
|
34 |
+
private $plugin_name;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* The version of this plugin.
|
38 |
+
*
|
39 |
+
* @since 1.0.0
|
40 |
+
* @access private
|
41 |
+
* @var string $version The current version of this plugin.
|
42 |
+
*/
|
43 |
+
private $version;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* The Current theme name
|
47 |
+
*
|
48 |
+
* @since 1.0.0
|
49 |
+
* @access public
|
50 |
+
* @var string $theme_name The Current theme name.
|
51 |
+
*/
|
52 |
+
public $theme_name = '';
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Current step
|
56 |
+
*
|
57 |
+
* @since 1.0.0
|
58 |
+
* @access protected
|
59 |
+
* @var string $step Current step.
|
60 |
+
*/
|
61 |
+
protected $step = '';
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Array of steps
|
65 |
+
*
|
66 |
+
* @since 1.0.0
|
67 |
+
* @access public
|
68 |
+
* @var array $steps Array of steps.
|
69 |
+
*/
|
70 |
+
protected $steps = array();
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Demo lists
|
74 |
+
*
|
75 |
+
* @since 1.0.0
|
76 |
+
* @access public
|
77 |
+
* @var array $demo_lists Array of demo lists.
|
78 |
+
*/
|
79 |
+
protected $demo_lists = array();
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Demo lists
|
83 |
+
*
|
84 |
+
* @since 1.0.0
|
85 |
+
* @access public
|
86 |
+
* @var array $demo_lists Array of demo lists.
|
87 |
+
*/
|
88 |
+
protected $is_pro_active = false;
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Array of delayed post for late process
|
92 |
+
*
|
93 |
+
* @since 1.0.0
|
94 |
+
* @access public
|
95 |
+
* @var array $delay_posts Array of delayed post for late process.
|
96 |
+
*/
|
97 |
+
private $delay_posts = array();
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Store logs and errors
|
101 |
+
*
|
102 |
+
* @since 1.0.0
|
103 |
+
* @access public
|
104 |
+
* @var array $logs Store logs and errors.
|
105 |
+
*/
|
106 |
+
public $logs = array();
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Store errors
|
110 |
+
*
|
111 |
+
* @since 1.0.0
|
112 |
+
* @access public
|
113 |
+
* @var array $errors Store errors.
|
114 |
+
*/
|
115 |
+
public $errors = array();
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Current added Menu hook_suffix
|
119 |
+
*
|
120 |
+
* @since 1.0.0
|
121 |
+
* @access public
|
122 |
+
* @var array $logs Store logs and errors.
|
123 |
+
*/
|
124 |
+
public $hook_suffix;
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Slug of the import page
|
128 |
+
*
|
129 |
+
* @since 1.0.0
|
130 |
+
* @access public
|
131 |
+
* @var string $logs Store logs and errors.
|
132 |
+
*/
|
133 |
+
private $current_template_type;
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Slug of the import page
|
137 |
+
*
|
138 |
+
* @since 1.0.0
|
139 |
+
* @access public
|
140 |
+
* @var string $logs Store logs and errors.
|
141 |
+
*/
|
142 |
+
private $current_template_url;
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Initialize the class and set its properties.
|
146 |
+
*
|
147 |
+
* @since 1.0.0
|
148 |
+
*/
|
149 |
+
public function __construct() {}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Main Advanced_Import_Admin Instance
|
153 |
+
* Initialize the class and set its properties.
|
154 |
+
*
|
155 |
+
* @since 1.0.0
|
156 |
+
* @return object $instance Advanced_Import_Admin Instance
|
157 |
+
*/
|
158 |
+
public static function instance() {
|
159 |
+
|
160 |
+
// Store the instance locally to avoid private static replication.
|
161 |
+
static $instance = null;
|
162 |
+
|
163 |
+
// Only run these methods if they haven't been ran previously.
|
164 |
+
if ( null === $instance ) {
|
165 |
+
$instance = new Advanced_Import_Admin();
|
166 |
+
$instance->plugin_name = ADVANCED_IMPORT_PLUGIN_NAME;
|
167 |
+
$instance->version = ADVANCED_IMPORT_VERSION;
|
168 |
+
|
169 |
+
/*page slug using theme name */
|
170 |
+
$instance->theme_name = sanitize_key( get_option( 'template' ) );
|
171 |
+
|
172 |
+
}
|
173 |
+
|
174 |
+
// Always return the instance.
|
175 |
+
return $instance;
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Check if template is available to import
|
180 |
+
*
|
181 |
+
* @since 1.0.8
|
182 |
+
* @param array $item current array of demo list.
|
183 |
+
* @return boolean
|
184 |
+
*/
|
185 |
+
public function is_template_available( $item ) {
|
186 |
+
$is_available = false;
|
187 |
+
|
188 |
+
/*if pro active everything is available*/
|
189 |
+
if ( $this->is_pro_active ) {
|
190 |
+
$is_available = true;
|
191 |
+
} elseif ( ! isset( $item['is_pro'] ) ) {/*if is_pro not set the $item is available*/
|
192 |
+
$is_available = true;/*template available since */
|
193 |
+
} elseif ( isset( $item['is_pro'] ) && ! $item['is_pro'] ) {/*if is_pro not set but it is false, it will be free and avialable*/
|
194 |
+
$is_available = true;
|
195 |
+
}
|
196 |
+
|
197 |
+
return (bool) apply_filters( 'advanced_import_is_template_available', $is_available, $item );
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Return Template Button
|
202 |
+
*
|
203 |
+
* @since 1.0.8
|
204 |
+
* @param array $item current array of demo list.
|
205 |
+
* @return string
|
206 |
+
*/
|
207 |
+
public function template_button( $item ) {
|
208 |
+
/*Start buffering*/
|
209 |
+
ob_start();
|
210 |
+
|
211 |
+
if ( $this->is_template_available( $item ) ) {
|
212 |
+
$plugins = isset( $item['plugins'] ) && is_array( $item['plugins'] ) ? ' data-plugins="' . esc_attr( wp_json_encode( $item['plugins'] ) ) . '"' : '';
|
213 |
+
?>
|
214 |
+
<a class="button ai-demo-import ai-item-import is-button is-default is-primary is-large button-primary" href="#" aria-label="<?php esc_attr_e( 'Import', 'advanced-import' ); ?>" <?php echo $plugins; ?>>
|
215 |
+
<span class="dashicons dashicons-download"></span><?php esc_html_e( 'Import', 'advanced-import' ); ?>
|
216 |
+
</a>
|
217 |
+
<?php
|
218 |
+
} else {
|
219 |
+
?>
|
220 |
+
<a class="button is-button is-default is-primary is-large button-primary"
|
221 |
+
href="<?php echo esc_url( isset( $item['pro_url'] ) ? $item['pro_url'] : '#' ); ?>"
|
222 |
+
target="_blank"
|
223 |
+
aria-label="<?php esc_attr_e( 'View Pro', 'advanced-import' ); ?>">
|
224 |
+
<span class="dashicons dashicons-awards"></span><?php esc_html_e( 'View Pro', 'advanced-import' ); ?>
|
225 |
+
</a>
|
226 |
+
<?php
|
227 |
+
}
|
228 |
+
|
229 |
+
/*removes the buffer (without printing it), and returns its content.*/
|
230 |
+
$render_button = ob_get_clean();
|
231 |
+
|
232 |
+
$render_button = apply_filters( 'advanced_import_template_import_button', $render_button, $item );
|
233 |
+
return $render_button;
|
234 |
+
|
235 |
+
}
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Register the stylesheets for the admin area.
|
239 |
+
*
|
240 |
+
* @since 1.0.8
|
241 |
+
* @param string $hook_suffix current hook.
|
242 |
+
* @return void
|
243 |
+
*/
|
244 |
+
public function enqueue_styles( $hook_suffix ) {
|
245 |
+
if ( ! is_array( $this->hook_suffix ) || ! in_array( $hook_suffix, $this->hook_suffix ) ) {
|
246 |
+
return;
|
247 |
+
}
|
248 |
+
wp_enqueue_style( $this->plugin_name, ADVANCED_IMPORT_URL . 'assets/css/advanced-import-admin' . ADVANCED_IMPORT_SCRIPT_PREFIX . '.css', array( 'wp-admin', 'dashicons' ), $this->version, 'all' );
|
249 |
+
wp_enqueue_media();
|
250 |
+
}
|
251 |
+
|
252 |
+
/**
|
253 |
+
* Register the JavaScript for the admin area.
|
254 |
+
*
|
255 |
+
* @since 1.0.8
|
256 |
+
* @param string $hook_suffix current hook.
|
257 |
+
* @return void
|
258 |
+
*/
|
259 |
+
public function enqueue_scripts( $hook_suffix ) {
|
260 |
+
if ( ! is_array( $this->hook_suffix ) || ! in_array( $hook_suffix, $this->hook_suffix ) ) {
|
261 |
+
return;
|
262 |
+
}
|
263 |
+
|
264 |
+
// Isotope Js.
|
265 |
+
wp_enqueue_script(
|
266 |
+
'isotope', // Handle.
|
267 |
+
ADVANCED_IMPORT_URL . '/assets/library/isotope/isotope.pkgd' . ADVANCED_IMPORT_SCRIPT_PREFIX . '.js',
|
268 |
+
array( 'jquery' ), // Dependencies, defined above.
|
269 |
+
'3.0.6', // Version: File modification time.
|
270 |
+
true // Enqueue the script in the footer.
|
271 |
+
);
|
272 |
+
|
273 |
+
// sweetalert2 Js.
|
274 |
+
wp_enqueue_script(
|
275 |
+
'sweetalert2', // Handle.
|
276 |
+
ADVANCED_IMPORT_URL . '/assets/library/sweetalert2/sweetalert2.all' . ADVANCED_IMPORT_SCRIPT_PREFIX . '.js',
|
277 |
+
array( 'jquery' ), // Dependencies, defined above.
|
278 |
+
'3.0.6', // Version: File modification time.
|
279 |
+
true // Enqueue the script in the footer.
|
280 |
+
);
|
281 |
+
|
282 |
+
wp_enqueue_script( $this->plugin_name, ADVANCED_IMPORT_URL . 'assets/js/advanced-import-admin' . ADVANCED_IMPORT_SCRIPT_PREFIX . '.js', array( 'jquery', 'masonry' ), $this->version, true );
|
283 |
+
wp_localize_script(
|
284 |
+
$this->plugin_name,
|
285 |
+
'advanced_import_object',
|
286 |
+
array(
|
287 |
+
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
288 |
+
'wpnonce' => wp_create_nonce( 'advanced_import_nonce' ),
|
289 |
+
'text' => array(
|
290 |
+
'failed' => esc_html__( 'Failed', 'advanced-import' ),
|
291 |
+
'error' => esc_html__( 'Error', 'advanced-import' ),
|
292 |
+
'skip' => esc_html__( 'Skipping', 'advanced-import' ),
|
293 |
+
'confirmImport' => array(
|
294 |
+
'title' => esc_html__( 'Advanced Import! Just a step away', 'advanced-import' ),
|
295 |
+
'html' => sprintf(
|
296 |
+
/* translators: 1: message 1, 2: message 2., 3: message 3., 4: message 4. */
|
297 |
+
__( 'Importing demo data is the easiest way to setup your theme. It will allow you to quickly edit everything instead of creating content from scratch. Also, read following points before importing the demo: %1$s %2$s %3$s %4$s', 'advanced-import' ),
|
298 |
+
'<ol><li class="warning">' . __( 'It is highly recommended to import demo on fresh WordPress installation to exactly replicate the theme demo. If no important data on your site, you can reset it from Reset Wizard at the top', 'advanced-import' ) . '</li>',
|
299 |
+
'<li>' . __( 'No existing posts, pages, categories, images, custom post types or any other data will be deleted or modified.', 'advanced-import' ) . '</li>',
|
300 |
+
'<li>' . __( 'It will install the plugins required for demo and activate them. Also posts, pages, images, widgets, & other data will get imported.', 'advanced-import' ) . '</li>',
|
301 |
+
'<li>' . __( 'Please click on the Import button and wait, it will take some time to import the data.', 'advanced-import' ) . '</li></ol>'
|
302 |
+
),
|
303 |
+
'confirmButtonText' => esc_html__( 'Yes, Import Demo!', 'advanced-import' ),
|
304 |
+
'cancelButtonText' => esc_html__( 'Cancel', 'advanced-import' ),
|
305 |
+
),
|
306 |
+
'confirmReset' => array(
|
307 |
+
'title' => esc_html__( 'Are you sure?', 'advanced-import' ),
|
308 |
+
'text' => __( "You won't be able to revert this!", 'advanced-import' ),
|
309 |
+
'confirmButtonText' => esc_html__( 'Yes, Reset', 'advanced-import' ),
|
310 |
+
'cancelButtonText' => esc_html__( 'Cancel', 'advanced-import' ),
|
311 |
+
),
|
312 |
+
'resetSuccess' => array(
|
313 |
+
'title' => esc_html__( 'Reset Successful', 'advanced-import' ),
|
314 |
+
'confirmButtonText' => esc_html__( 'Ok', 'advanced-import' ),
|
315 |
+
),
|
316 |
+
'failedImport' => array(
|
317 |
+
'code' => __( 'Error Code:', 'advanced-import' ),
|
318 |
+
'text' => __( 'Contact theme author or try again', 'advanced-import' ),
|
319 |
+
),
|
320 |
+
'successImport' => array(
|
321 |
+
'confirmButtonText' => esc_html__( 'Visit My Site', 'advanced-import' ),
|
322 |
+
'cancelButtonText' => esc_html__( 'Okay', 'advanced-import' ),
|
323 |
+
),
|
324 |
+
),
|
325 |
+
)
|
326 |
+
);
|
327 |
+
}
|
328 |
+
|
329 |
+
/**
|
330 |
+
* Adding new mime types.
|
331 |
+
*
|
332 |
+
* @access public
|
333 |
+
* @since 1.0.0
|
334 |
+
* @param array $mimes existing mime types.
|
335 |
+
* @return array
|
336 |
+
*/
|
337 |
+
public function mime_types( $mimes = array() ) {
|
338 |
+
$add_mimes = array(
|
339 |
+
'json' => 'application/json',
|
340 |
+
);
|
341 |
+
|
342 |
+
return array_merge( $mimes, $add_mimes );
|
343 |
+
}
|
344 |
+
|
345 |
+
/**
|
346 |
+
* Determine if the user already has theme content installed.
|
347 |
+
*
|
348 |
+
* @access public
|
349 |
+
*/
|
350 |
+
public function is_possible_upgrade() {
|
351 |
+
return false;
|
352 |
+
}
|
353 |
+
|
354 |
+
/**
|
355 |
+
* Add admin menus
|
356 |
+
*
|
357 |
+
* @access public
|
358 |
+
*/
|
359 |
+
public function import_menu() {
|
360 |
+
$this->hook_suffix[] = add_theme_page( esc_html__( 'Demo Import ', 'advanced-import' ), esc_html__( 'Demo Import' ), 'manage_options', 'advanced-import', array( $this, 'demo_import_screen' ) );
|
361 |
+
$this->hook_suffix[] = add_management_page( esc_html__( 'Advanced Import', 'advanced-import' ), esc_html__( 'Advanced Import', 'advanced-import' ), 'manage_options', 'advanced-import-tool', array( $this, 'demo_import_screen' ) );
|
362 |
+
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Show the setup
|
367 |
+
*
|
368 |
+
* @access public
|
369 |
+
* @return void
|
370 |
+
*/
|
371 |
+
public function demo_import_screen() {
|
372 |
+
do_action( 'advanced_import_before_demo_import_screen' );
|
373 |
+
|
374 |
+
$this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) );
|
375 |
+
|
376 |
+
echo '<div class="ai-body">';
|
377 |
+
|
378 |
+
$this->get_header();
|
379 |
+
|
380 |
+
echo '<div class="ai-content">';
|
381 |
+
echo '<div class="ai-content-blocker hidden">';
|
382 |
+
echo '<div class="ai-notification-title"><p>' . esc_html__( 'Processing... Please do not refresh this page or do not go to other url!', 'advanced-import' ) . '</p></div>';
|
383 |
+
echo '<div id="ai-demo-popup"></div>';
|
384 |
+
echo '</div>';
|
385 |
+
$this->init_demo_import();
|
386 |
+
echo '</div>';
|
387 |
+
echo '</div>';/*ai-body*/
|
388 |
+
do_action( 'advanced_import_after_demo_import_screen' );
|
389 |
+
|
390 |
+
}
|
391 |
+
|
392 |
+
/**
|
393 |
+
* Get header of setup
|
394 |
+
*
|
395 |
+
* @access public
|
396 |
+
* @return void
|
397 |
+
*/
|
398 |
+
public function get_header() {
|
399 |
+
global $pagenow;
|
400 |
+
|
401 |
+
$welcome_msg = "<div class='ai-header'>";
|
402 |
+
/* translators: 1: current theme */
|
403 |
+
$welcome_msg .= '<h1>' . sprintf( esc_html__( 'Welcome to the Advanced Import for %s.', 'advanced-import' ), wp_get_theme() ) . '</h1>';
|
404 |
+
if ( $pagenow != 'tools.php' ) {
|
405 |
+
/* translators: 1: current theme */
|
406 |
+
$welcome_msg .= ' <p>' . sprintf( esc_html__( 'Thank you for choosing the %s theme. This quick demo import setup will help you configure your new website like theme demo. It will install the required WordPress plugins, default content and tell you a little about Help & Support options. It should only take less than 5 minutes.', 'advanced-import' ), wp_get_theme() ) . '</p>';
|
407 |
+
}
|
408 |
+
$welcome_msg .= '</div>';
|
409 |
+
echo advanced_import_allowed_html( apply_filters( 'advanced_import_welcome_message', $welcome_msg ) );
|
410 |
+
|
411 |
+
if ( get_theme_mod( 'advanced_import_setup_complete', false ) && $pagenow != 'tools.php' ) {
|
412 |
+
?>
|
413 |
+
<p><?php esc_html_e( 'It looks like you have already run the demo import for this theme.', 'advanced-import' ); ?></p>
|
414 |
+
<?php
|
415 |
+
}
|
416 |
+
}
|
417 |
+
|
418 |
+
/**
|
419 |
+
* Handle the demo content upload and called to process
|
420 |
+
* Ajax callback
|
421 |
+
*
|
422 |
+
* @return void
|
423 |
+
*/
|
424 |
+
public function upload_zip() {
|
425 |
+
if ( isset( $_FILES['ai-upload-zip-archive']['name'] ) && ! empty( $_FILES['ai-upload-zip-archive']['name'] ) ) {
|
426 |
+
/*check for security*/
|
427 |
+
if ( ! current_user_can( 'upload_files' ) ) {
|
428 |
+
wp_send_json_error(
|
429 |
+
array(
|
430 |
+
'message' => esc_html__( 'Sorry, you are not allowed to install demo on this site.', 'advanced-import' ),
|
431 |
+
)
|
432 |
+
);
|
433 |
+
}
|
434 |
+
check_admin_referer( 'advanced-import' );
|
435 |
+
|
436 |
+
/*file process*/
|
437 |
+
require_once ABSPATH . 'wp-admin/includes/file.php';
|
438 |
+
WP_Filesystem();
|
439 |
+
global $wp_filesystem;
|
440 |
+
$wp_filesystem->rmdir( ADVANCED_IMPORT_TEMP, true );
|
441 |
+
$upload_zip_archive = $_FILES['ai-upload-zip-archive'];
|
442 |
+
$unzipfile = unzip_file( $upload_zip_archive['tmp_name'], ADVANCED_IMPORT_TEMP );
|
443 |
+
if ( is_wp_error( $unzipfile ) ) {
|
444 |
+
wp_send_json_error(
|
445 |
+
array(
|
446 |
+
'message' => esc_html__( 'Error on unzipping, Please try again', 'advanced-import' ),
|
447 |
+
)
|
448 |
+
);
|
449 |
+
}
|
450 |
+
/*(check) Zip should contain json file and uploads folder only*/
|
451 |
+
$dirlist = $wp_filesystem->dirlist( ADVANCED_IMPORT_TEMP );
|
452 |
+
foreach ( (array) $dirlist as $filename => $fileinfo ) {
|
453 |
+
if ( $fileinfo['type'] == 'd' ) {
|
454 |
+
if ( $filename == 'uploads' ) {
|
455 |
+
continue;
|
456 |
+
} else {
|
457 |
+
$wp_filesystem->rmdir( ADVANCED_IMPORT_TEMP, true );
|
458 |
+
wp_send_json_error(
|
459 |
+
array(
|
460 |
+
'message' => esc_html__( 'Invalid Zip File', 'advanced-import' ),
|
461 |
+
)
|
462 |
+
);
|
463 |
+
}
|
464 |
+
} else {
|
465 |
+
$filetype = wp_check_filetype( $filename, $this->mime_types() );
|
466 |
+
if ( empty( $filetype['ext'] ) || $filetype['ext'] != 'json' ) {
|
467 |
+
$wp_filesystem->rmdir( ADVANCED_IMPORT_TEMP, true );
|
468 |
+
wp_send_json_error(
|
469 |
+
array(
|
470 |
+
'message' => esc_html__( 'Invalid Zip File', 'advanced-import' ),
|
471 |
+
)
|
472 |
+
);
|
473 |
+
}
|
474 |
+
}
|
475 |
+
}
|
476 |
+
wp_send_json_success(
|
477 |
+
array(
|
478 |
+
'message' => esc_html__( 'Success', 'advanced-import' ),
|
479 |
+
)
|
480 |
+
);
|
481 |
+
}
|
482 |
+
wp_send_json_error(
|
483 |
+
array(
|
484 |
+
'message' => esc_html__( 'No Zip File Found', 'advanced-import' ),
|
485 |
+
)
|
486 |
+
);
|
487 |
+
}
|
488 |
+
|
489 |
+
/**
|
490 |
+
* Download Zip file/ Move it to temp import folder
|
491 |
+
* Ajax callback
|
492 |
+
*
|
493 |
+
* @return mixed
|
494 |
+
*/
|
495 |
+
public function demo_download_and_unzip() {
|
496 |
+
|
497 |
+
/*check for security*/
|
498 |
+
if ( ! current_user_can( 'upload_files' ) ) {
|
499 |
+
wp_send_json_error(
|
500 |
+
array(
|
501 |
+
'message' => esc_html__( 'Sorry, you are not allowed to install demo on this site.', 'advanced-import' ),
|
502 |
+
)
|
503 |
+
);
|
504 |
+
}
|
505 |
+
check_admin_referer( 'advanced-import' );
|
506 |
+
|
507 |
+
/*get file and what should do*/
|
508 |
+
$demo_file = is_array( $_POST['demo_file'] ) ? (array) $_POST['demo_file'] : sanitize_text_field( $_POST['demo_file'] );
|
509 |
+
$demo_file_type = sanitize_text_field( $_POST['demo_file_type'] );
|
510 |
+
|
511 |
+
/*from file*/
|
512 |
+
if ( $demo_file_type == 'file' ) {
|
513 |
+
require_once ABSPATH . 'wp-admin/includes/file.php';
|
514 |
+
WP_Filesystem();
|
515 |
+
global $wp_filesystem;
|
516 |
+
$wp_filesystem->rmdir( ADVANCED_IMPORT_TEMP, true );
|
517 |
+
$unzipfile = unzip_file( $demo_file, ADVANCED_IMPORT_TEMP );
|
518 |
+
if ( is_wp_error( $unzipfile ) ) {
|
519 |
+
wp_send_json_error(
|
520 |
+
array(
|
521 |
+
'message' => esc_html__( 'Error on unzipping, Please try again', 'advanced-import' ),
|
522 |
+
)
|
523 |
+
);
|
524 |
+
}
|
525 |
+
/*(check) Zip should contain json file and uploads folder only*/
|
526 |
+
$dirlist = $wp_filesystem->dirlist( ADVANCED_IMPORT_TEMP );
|
527 |
+
foreach ( (array) $dirlist as $filename => $fileinfo ) {
|
528 |
+
if ( $fileinfo['type'] == 'd' ) {
|
529 |
+
if ( $filename == 'uploads' ) {
|
530 |
+
continue;
|
531 |
+
} else {
|
532 |
+
$wp_filesystem->rmdir( ADVANCED_IMPORT_TEMP, true );
|
533 |
+
wp_send_json_error(
|
534 |
+
array(
|
535 |
+
'message' => esc_html__( 'Invalid Zip File', 'advanced-import' ),
|
536 |
+
)
|
537 |
+
);
|
538 |
+
}
|
539 |
+
} else {
|
540 |
+
$filetype = wp_check_filetype( $filename, $this->mime_types() );
|
541 |
+
if ( empty( $filetype['ext'] ) || $filetype['ext'] != 'json' ) {
|
542 |
+
$wp_filesystem->rmdir( ADVANCED_IMPORT_TEMP, true );
|
543 |
+
wp_send_json_error(
|
544 |
+
array(
|
545 |
+
'message' => esc_html__( 'Invalid Zip File', 'advanced-import' ),
|
546 |
+
)
|
547 |
+
);
|
548 |
+
}
|
549 |
+
}
|
550 |
+
}
|
551 |
+
wp_send_json_success(
|
552 |
+
array(
|
553 |
+
'message' => esc_html__( 'Success', 'advanced-import' ),
|
554 |
+
)
|
555 |
+
);
|
556 |
+
} elseif ( $demo_file_type == 'url' ) {
|
557 |
+
|
558 |
+
/*finally fetch the file from remote*/
|
559 |
+
$response = wp_remote_get( $demo_file );
|
560 |
+
|
561 |
+
if ( is_array( $response ) && ! empty( $response['body'] ) && $response['response']['code'] == '200' ) {
|
562 |
+
require_once ABSPATH . 'wp-admin/includes/file.php';
|
563 |
+
WP_Filesystem();
|
564 |
+
global $wp_filesystem;
|
565 |
+
$file_permission = 0777;
|
566 |
+
if ( ! file_exists( ADVANCED_IMPORT_TEMP_ZIP ) ) {
|
567 |
+
$wp_filesystem->mkdir( ADVANCED_IMPORT_TEMP_ZIP, $file_permission, true );
|
568 |
+
}
|
569 |
+
$temp_import_zip = trailingslashit( ADVANCED_IMPORT_TEMP_ZIP ) . 'temp-import.zip';
|
570 |
+
$wp_filesystem->put_contents( $temp_import_zip, $response['body'], 0777 );
|
571 |
+
|
572 |
+
} else {
|
573 |
+
/*required to download file failed.*/
|
574 |
+
wp_send_json_error(
|
575 |
+
array(
|
576 |
+
'error' => 1,
|
577 |
+
'message' => esc_html__( 'Remote server did not respond, Contact to Theme Author', 'advanced-import' ),
|
578 |
+
)
|
579 |
+
);
|
580 |
+
}
|
581 |
+
|
582 |
+
$file_size = filesize( $temp_import_zip );
|
583 |
+
|
584 |
+
/*if file size is 0*/
|
585 |
+
if ( 0 == $file_size ) {
|
586 |
+
$wp_filesystem->rmdir( ADVANCED_IMPORT_TEMP_ZIP, true );
|
587 |
+
wp_send_json_error(
|
588 |
+
array(
|
589 |
+
'error' => 1,
|
590 |
+
'message' => esc_html__( 'Zero size file downloaded, Contact to Theme Author', 'advanced-import' ),
|
591 |
+
)
|
592 |
+
);
|
593 |
+
}
|
594 |
+
|
595 |
+
/*if file is too large*/
|
596 |
+
if ( ! empty( $max_size ) && $file_size > $max_size ) {
|
597 |
+
$wp_filesystem->rmdir( ADVANCED_IMPORT_TEMP_ZIP, true );
|
598 |
+
wp_send_json_error(
|
599 |
+
array(
|
600 |
+
'error' => 1,
|
601 |
+
'message' => sprintf( esc_html__( 'Remote file is too large, limit is %s', 'advanced-import' ), size_format( $max_size ) ),
|
602 |
+
)
|
603 |
+
);
|
604 |
+
}
|
605 |
+
|
606 |
+
/*if we are here then unzip file*/
|
607 |
+
$unzipfile = unzip_file( $temp_import_zip, ADVANCED_IMPORT_TEMP );
|
608 |
+
if ( is_wp_error( $unzipfile ) ) {
|
609 |
+
wp_send_json_error(
|
610 |
+
array(
|
611 |
+
'error' => 1,
|
612 |
+
'message' => esc_html__( 'Error on unzipping, Please try again', 'advanced-import' ),
|
613 |
+
)
|
614 |
+
);
|
615 |
+
}
|
616 |
+
$wp_filesystem->rmdir( ADVANCED_IMPORT_TEMP_ZIP, true );
|
617 |
+
|
618 |
+
/*(check) Zip should contain json file and uploads folder only*/
|
619 |
+
$dirlist = $wp_filesystem->dirlist( ADVANCED_IMPORT_TEMP );
|
620 |
+
foreach ( (array) $dirlist as $filename => $fileinfo ) {
|
621 |
+
if ( $fileinfo['type'] == 'd' ) {
|
622 |
+
if ( $filename == 'uploads' ) {
|
623 |
+
continue;
|
624 |
+
} else {
|
625 |
+
$wp_filesystem->rmdir( ADVANCED_IMPORT_TEMP, true );
|
626 |
+
wp_send_json_error(
|
627 |
+
array(
|
628 |
+
'message' => esc_html__( 'Invalid Zip File', 'advanced-import' ),
|
629 |
+
)
|
630 |
+
);
|
631 |
+
}
|
632 |
+
} else {
|
633 |
+
$filetype = wp_check_filetype( $filename, $this->mime_types() );
|
634 |
+
if ( empty( $filetype['ext'] ) || $filetype['ext'] != 'json' ) {
|
635 |
+
$wp_filesystem->rmdir( ADVANCED_IMPORT_TEMP, true );
|
636 |
+
wp_send_json_error(
|
637 |
+
array(
|
638 |
+
'message' => esc_html__( 'Invalid Zip File', 'advanced-import' ),
|
639 |
+
)
|
640 |
+
);
|
641 |
+
}
|
642 |
+
}
|
643 |
+
}
|
644 |
+
wp_send_json_success(
|
645 |
+
array(
|
646 |
+
'message' => esc_html__( 'Success', 'advanced-import' ),
|
647 |
+
)
|
648 |
+
);
|
649 |
+
|
650 |
+
} else {
|
651 |
+
wp_send_json_error(
|
652 |
+
array(
|
653 |
+
'error' => 1,
|
654 |
+
'message' => esc_html__( 'File not allowed', 'advanced-import' ),
|
655 |
+
)
|
656 |
+
);
|
657 |
+
}
|
658 |
+
}
|
659 |
+
|
660 |
+
/**
|
661 |
+
* List Demo List
|
662 |
+
*
|
663 |
+
* @return void
|
664 |
+
*/
|
665 |
+
public function demo_list( $demo_lists, $total_demo ) {
|
666 |
+
?>
|
667 |
+
<div class="ai-filter-header">
|
668 |
+
<div class="ai-filter-tabs">
|
669 |
+
<ul class="ai-types ai-filter-group" data-filter-group="secondary">
|
670 |
+
<li class="ai-filter-btn-active ai-filter-btn" data-filter="*">
|
671 |
+
<?php esc_html_e( 'All', 'advanced-import' ); ?>
|
672 |
+
<span class="ai-count"></span>
|
673 |
+
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
674 |
<?php
|
675 |
+
$types = array_column( $demo_lists, 'type' );
|
676 |
+
$unique_types = array_unique( $types );
|
677 |
+
foreach ( $unique_types as $cat_index => $single_type ) {
|
678 |
+
?>
|
679 |
+
<li class="ai-filter-btn" data-filter=".<?php echo strtolower( esc_attr( $single_type ) ); ?>">
|
680 |
+
<?php echo ucfirst( esc_html( $single_type ) ); ?>
|
681 |
+
<span class="ai-count"></span>
|
682 |
+
|
683 |
+
</li>
|
684 |
+
<?php
|
685 |
+
}
|
686 |
+
?>
|
687 |
+
</ul>
|
688 |
+
<div class="ai-search-control">
|
689 |
+
<input id="ai-filter-search-input" class="ai-search-filter" type="text" placeholder="<?php esc_attr_e( 'Search...', 'advanced-import' ); ?>">
|
690 |
+
</div>
|
691 |
+
<ul class="ai-form-type">
|
692 |
+
<li class="ai-form-file-import">
|
693 |
+
<?php esc_html_e( 'Upload zip', 'advanced-import' ); ?>
|
694 |
+
</li>
|
695 |
+
</ul>
|
696 |
+
</div>
|
697 |
+
</div>
|
698 |
+
<div class="ai-filter-content" id="ai-filter-content">
|
699 |
+
<div class="ai-actions ai-sidebar">
|
700 |
+
<div class="ai-import-available-categories">
|
701 |
+
<h3><?php esc_html_e( 'Categories', 'advanced-import' ); ?></h3>
|
702 |
+
<div class="ai-import-fp-wrap">
|
703 |
+
<ul class="ai-import-fp-lists ai-filter-group" data-filter-group="pricing">
|
704 |
+
<li class="ai-fp-filter ai-filter-btn ai-filter-btn-active" data-filter="*">All</li>
|
705 |
+
<li class="ai-fp-filter ai-filter-btn" data-filter=".ai-fp-filter-free">Free</li>
|
706 |
+
<li class="ai-fp-filter ai-filter-btn" data-filter=".ai-fp-filter-pro">Pro</li>
|
707 |
+
</ul>
|
708 |
+
</div>
|
709 |
+
<ul class="ai-import-available-categories-lists ai-filter-group" data-filter-group="primary">
|
710 |
+
<li class="ai-filter-btn-active ai-filter-btn" data-filter="*">
|
711 |
+
<?php esc_html_e( 'All Categories', 'advanced-import' ); ?>
|
712 |
+
<span class="ai-count"></span>
|
713 |
+
</li>
|
714 |
+
<?php
|
715 |
+
$categories = array_column( $demo_lists, 'categories' );
|
716 |
+
$unique_categories = array();
|
717 |
+
if ( is_array( $categories ) && ! empty( $categories ) ) {
|
718 |
+
foreach ( $categories as $demo_index => $demo_cats ) {
|
719 |
+
foreach ( $demo_cats as $cat_index => $single_cat ) {
|
720 |
+
if ( in_array( $single_cat, $unique_categories ) ) {
|
721 |
+
continue;
|
722 |
+
}
|
723 |
+
$unique_categories[] = $single_cat;
|
724 |
+
?>
|
725 |
+
<li class="ai-filter-btn" data-filter=".<?php echo strtolower( esc_attr( $single_cat ) ); ?>">
|
726 |
+
<?php echo ucfirst( esc_html( $single_cat ) ); ?>
|
727 |
+
<span class="ai-count"></span>
|
728 |
+
</li>
|
729 |
+
<?php
|
730 |
+
}
|
731 |
+
}
|
732 |
+
}
|
733 |
+
?>
|
734 |
+
</ul>
|
735 |
+
</div>
|
736 |
+
|
737 |
+
</div>
|
738 |
+
<div class="ai-filter-content-wrapper">
|
739 |
+
<?php
|
740 |
+
foreach ( $demo_lists as $key => $demo_list ) {
|
741 |
+
|
742 |
+
/*Check for required fields*/
|
743 |
+
if ( ! isset( $demo_list['title'] ) || ! isset( $demo_list['screenshot_url'] ) || ! isset( $demo_list['demo_url'] ) ) {
|
744 |
+
continue;
|
745 |
+
}
|
746 |
+
|
747 |
+
$template_url = isset( $demo_list['template_url'] ) ? $demo_list['template_url'] : '';
|
748 |
+
if ( is_array( $template_url ) ) {
|
749 |
+
$data_template = 'data-template_url="' . esc_attr( wp_json_encode( $template_url ) ) . '"';
|
750 |
+
$data_template_type = 'data-template_type="array"';
|
751 |
+
} elseif ( $template_url ) {
|
752 |
+
$data_template = 'data-template_url="' . esc_attr( $template_url ) . '"';
|
753 |
+
if ( is_file( $template_url ) && filesize( $template_url ) > 0 ) {
|
754 |
+
$data_template_type = 'data-template_type="file"';
|
755 |
+
} else {
|
756 |
+
$data_template_type = 'data-template_type="url"';
|
757 |
+
}
|
758 |
+
} else {
|
759 |
+
$data_template = 'data-template_url="' . esc_attr( wp_json_encode( $template_url ) ) . '"';
|
760 |
+
$data_template_type = 'data-template_type="array"';
|
761 |
+
}
|
762 |
+
?>
|
763 |
+
<div aria-label="<?php echo esc_attr( $demo_list['title'] ); ?>"
|
764 |
+
class="ai-item
|
765 |
+
<?php
|
766 |
+
echo isset( $demo_list['categories'] ) ? esc_attr( implode( ' ', $demo_list['categories'] ) ) : '';
|
767 |
+
echo isset( $demo_list['type'] ) ? ' ' . esc_attr( $demo_list['type'] ) : '';
|
768 |
+
echo isset( $demo_list['is_pro'] ) ? ' ai-fp-filter-pro' : ' ai-fp-filter-free';
|
769 |
+
echo $this->is_template_available( $demo_list ) ? '' : ' ai-pro-item'
|
770 |
+
?>
|
771 |
"
|
772 |
+
<?php echo $this->is_template_available( $demo_list ) ? $data_template . ' ' . $data_template_type : ''; ?>
|
773 |
+
>
|
774 |
+
<?php
|
775 |
+
wp_nonce_field( 'advanced-import' );
|
776 |
+
?>
|
777 |
+
<div class="ai-item-preview">
|
778 |
+
<div class="ai-item-screenshot">
|
779 |
+
<img src="<?php echo esc_url( $demo_list['screenshot_url'] ); ?>">
|
780 |
+
|
781 |
+
</div>
|
782 |
+
<h4 class="ai-author-info"><?php esc_html_e( 'Author: ', 'advanced-import' ); ?><?php echo esc_html( isset( $demo_list['author'] ) ? $demo_list['author'] : wp_get_theme()->get( 'Author' ) ); ?></h4>
|
783 |
+
<div class="ai-details"><?php esc_html_e( 'Details', 'advanced-import' ); ?></div>
|
784 |
+
<?php
|
785 |
+
if ( isset( $demo_list['is_pro'] ) && $demo_list['is_pro'] ) {
|
786 |
+
?>
|
787 |
+
<span class="ai-premium-label"><?php esc_html_e( 'Premium', 'advanced-import' ); ?></span>
|
788 |
+
<?php
|
789 |
+
}
|
790 |
+
?>
|
791 |
+
</div>
|
792 |
+
<div class="ai-item-footer">
|
793 |
+
<div class="ai-item-footer_meta">
|
794 |
+
<h3 class="theme-name"><?php echo esc_html( $demo_list['title'] ); ?></h3>
|
795 |
+
<div class="ai-item-footer-actions">
|
796 |
+
<a class="button ai-item-demo-link" href="<?php echo esc_url( $demo_list['demo_url'] ); ?>" target="_blank">
|
797 |
+
<span class="dashicons dashicons-visibility"></span><?php esc_html_e( 'Preview', 'advanced-import' ); ?>
|
798 |
+
</a>
|
799 |
+
<?php
|
800 |
+
echo $this->template_button( $demo_list );
|
801 |
+
?>
|
802 |
+
</div>
|
803 |
+
<?php
|
804 |
+
$keywords = isset( $demo_list['keywords'] ) ? $demo_list['keywords'] : array();
|
805 |
+
if ( ! empty( $keywords ) ) {
|
806 |
+
echo '<ul class="ai-keywords hidden">';
|
807 |
+
foreach ( $keywords as $cat_index => $single_keywords ) {
|
808 |
+
?>
|
809 |
+
<li class="<?php echo strtolower( esc_attr( $single_keywords ) ); ?>"><?php echo ucfirst( esc_html( $single_keywords ) ); ?></li>
|
810 |
+
<?php
|
811 |
+
}
|
812 |
+
echo '</ul>';
|
813 |
+
}
|
814 |
+
?>
|
815 |
+
|
816 |
+
</div>
|
817 |
+
|
818 |
+
</div>
|
819 |
+
</div>
|
820 |
+
<?php
|
821 |
+
}
|
822 |
+
?>
|
823 |
+
</div>
|
824 |
+
</div>
|
825 |
+
<?php
|
826 |
+
}
|
827 |
+
|
828 |
+
/**
|
829 |
+
* List Demo Form
|
830 |
+
*
|
831 |
+
* @return void
|
832 |
+
*/
|
833 |
+
|
834 |
+
public function demo_import_form( $total_demo = 0 ) {
|
835 |
+
?>
|
836 |
+
<div class="ai-form <?php echo $total_demo > 0 ? 'hidden' : ''; ?>">
|
837 |
+
<form action="" method="post" enctype="multipart/form-data" id="ai-upload-zip-form">
|
838 |
+
<h3 class="media-title"><?php esc_html_e( 'Upload a zip file containing demo content', 'advanced-import' ); ?> </h3>
|
839 |
+
<div class="input-file"><input type="file" name="ai-upload-zip-archive" id="ai-upload-zip-archive" size="50" /></div>
|
840 |
+
<p>
|
841 |
+
<?php
|
842 |
+
wp_nonce_field( 'advanced-import' );
|
843 |
+
printf( __( 'Maximum upload file size: %s', 'advanced-import' ), size_format( wp_max_upload_size() ) );
|
844 |
+
?>
|
845 |
+
</p>
|
846 |
+
<div id='ai-empty-file' class="error hidden">
|
847 |
+
<p>
|
848 |
+
<?php esc_html_e( 'Select File and Try Again!', 'advanced-import' ); ?>
|
849 |
+
</p>
|
850 |
+
</div>
|
851 |
+
<p class="ai-form-import-actions step">
|
852 |
+
<button class="button-primary button button-large button-upload-demo" type="submit">
|
853 |
+
<?php esc_html_e( 'Upload Demo Zip', 'advanced-import' ); ?>
|
854 |
+
</button>
|
855 |
+
<a href="<?php echo esc_url( wp_get_referer() && ! strpos( wp_get_referer(), 'update.php' ) ? wp_get_referer() : admin_url( '' ) ); ?>" class="button button-large">
|
856 |
+
<?php esc_html_e( 'Not right now', 'advanced-import' ); ?>
|
857 |
+
</a>
|
858 |
+
</p>
|
859 |
+
<div id='ai-ajax-install-result'></div>
|
860 |
+
</form>
|
861 |
+
</div>
|
862 |
+
<?php
|
863 |
+
}
|
864 |
+
|
865 |
+
/**
|
866 |
+
* 1st step of demo import view
|
867 |
+
* Upload Zip file
|
868 |
+
* Demo List
|
869 |
+
*/
|
870 |
+
public function init_demo_import() {
|
871 |
+
|
872 |
+
global $pagenow;
|
873 |
+
$total_demo = 0;
|
874 |
+
if ( $pagenow != 'tools.php' ) {
|
875 |
+
$this->demo_lists = apply_filters( 'advanced_import_demo_lists', array() );
|
876 |
+
$this->is_pro_active = apply_filters( 'advanced_import_is_pro_active', $this->is_pro_active );
|
877 |
+
$demo_lists = $this->demo_lists;
|
878 |
+
|
879 |
+
$total_demo = count( $demo_lists );
|
880 |
+
if ( $total_demo >= 1 ) {
|
881 |
+
$this->demo_list( $demo_lists, $total_demo );
|
882 |
+
}
|
883 |
+
}
|
884 |
+
|
885 |
+
$this->demo_import_form( $total_demo );
|
886 |
+
}
|
887 |
+
|
888 |
+
/**
|
889 |
+
* 2nd step Plugin Installation step View
|
890 |
+
* return void || boolean
|
891 |
+
*/
|
892 |
+
public function plugin_screen() {
|
893 |
+
|
894 |
+
/*check for security*/
|
895 |
+
if ( ! current_user_can( 'upload_files' ) ) {
|
896 |
+
wp_send_json_error(
|
897 |
+
array(
|
898 |
+
'message' => esc_html__( 'Sorry, you are not allowed to install demo on this site.', 'advanced-import' ),
|
899 |
+
)
|
900 |
+
);
|
901 |
+
}
|
902 |
+
|
903 |
+
check_admin_referer( 'advanced-import' );
|
904 |
+
|
905 |
+
/*for safety.*/
|
906 |
+
delete_transient( 'content.json' );
|
907 |
+
delete_transient( 'widgets.json' );
|
908 |
+
delete_transient( 'options.json' );
|
909 |
+
|
910 |
+
do_action( 'advanced_import_before_plugin_screen' );
|
911 |
+
?>
|
912 |
+
<div class="ai-notification-title">
|
913 |
+
<p><?php esc_html_e( 'Your website needs a few essential plugins. We are installing them...', 'advanced-import' ); ?></p>
|
914 |
+
</div>
|
915 |
+
<ul class="ai-plugins-wrap hidden">
|
916 |
+
<?php
|
917 |
+
$recommended_plugins = (array) $_POST['recommendedPlugins'];
|
918 |
+
if ( count( $recommended_plugins ) ) {
|
919 |
+
foreach ( $recommended_plugins as $index => $recommended_plugin ) {
|
920 |
+
?>
|
921 |
+
<li data-slug="<?php echo esc_attr( $recommended_plugin['slug'] ); ?>" data-main_file ="<?php echo esc_attr( isset( $recommended_plugin['main_file'] ) ? $recommended_plugin['main_file'] : $recommended_plugin['slug'] . '.php' ); ?>">
|
922 |
+
<?php echo esc_html( $recommended_plugin['name'] ); ?>
|
923 |
+
</li>
|
924 |
+
<?php
|
925 |
+
}
|
926 |
+
} else {
|
927 |
+
?>
|
928 |
+
<li id="ai-no-recommended-plugins"><?php esc_html_e( 'No Recommended Plugins', 'advanced-import' ); ?></li>
|
929 |
+
<?php
|
930 |
+
}
|
931 |
+
?>
|
932 |
+
</ul>
|
933 |
+
<?php
|
934 |
+
do_action( 'advanced_import_after_plugin_screen' );
|
935 |
+
exit;
|
936 |
+
}
|
937 |
+
|
938 |
+
/**
|
939 |
+
* 3rd steps helper functions
|
940 |
+
* Get json from json file
|
941 |
+
*
|
942 |
+
* @param string $file file url.
|
943 |
+
* @return mixed
|
944 |
+
*/
|
945 |
+
public function get_json_data_from_file( $file ) {
|
946 |
+
|
947 |
+
if ( get_transient( $file ) ) {
|
948 |
+
return get_transient( $file );
|
949 |
+
}
|
950 |
+
|
951 |
+
if ( $this->current_template_type == 'array' ) {
|
952 |
+
$type = strtok( $file, '.' );
|
953 |
+
if ( isset( $this->current_template_url[ $type ] ) ) {
|
954 |
+
$request = wp_remote_get( $this->current_template_url[ $type ] );
|
955 |
+
$response = wp_remote_retrieve_body( $request );
|
956 |
+
$result = json_decode( $response, true );
|
957 |
+
set_transient( $file, $result, 1000 );
|
958 |
+
return $result;
|
959 |
+
}
|
960 |
+
return array();
|
961 |
+
}
|
962 |
+
|
963 |
+
if ( is_file( ADVANCED_IMPORT_TEMP . basename( $file ) ) ) {
|
964 |
+
require_once ABSPATH . 'wp-admin/includes/file.php';
|
965 |
+
WP_Filesystem();
|
966 |
+
global $wp_filesystem;
|
967 |
+
$file_name = ADVANCED_IMPORT_TEMP . basename( $file );
|
968 |
+
if ( file_exists( $file_name ) ) {
|
969 |
+
$result = json_decode( $wp_filesystem->get_contents( $file_name ), true );
|
970 |
+
set_transient( $file, $result, 1000 );
|
971 |
+
return $result;
|
972 |
+
}
|
973 |
+
}
|
974 |
+
return array();
|
975 |
+
}
|
976 |
+
|
977 |
+
public function get_main_content_json() {
|
978 |
+
return $this->get_json_data_from_file( 'content.json' );
|
979 |
+
}
|
980 |
+
public function get_widgets_json() {
|
981 |
+
return $this->get_json_data_from_file( 'widgets.json' );
|
982 |
+
}
|
983 |
+
|
984 |
+
public function get_theme_options_json() {
|
985 |
+
return $this->get_json_data_from_file( 'options.json' );
|
986 |
+
}
|
987 |
+
|
988 |
+
/*
|
989 |
+
* return array
|
990 |
+
*/
|
991 |
+
private function advanced_import_setup_content_steps() {
|
992 |
+
|
993 |
+
$content = array();
|
994 |
+
|
995 |
+
/*check if there is files*/
|
996 |
+
$content_data = $this->get_main_content_json();
|
997 |
+
foreach ( $content_data as $post_type => $post_data ) {
|
998 |
+
if ( count( $post_data ) ) {
|
999 |
+
$first = current( $post_data );
|
1000 |
+
$post_type_title = ! empty( $first['type_title'] ) ? $first['type_title'] : ucwords( $post_type ) . 's';
|
1001 |
+
$content[ $post_type ] = array(
|
1002 |
+
'title' => $post_type_title,
|
1003 |
+
'description' => sprintf( esc_html__( 'This will create default %s as seen in the demo.', 'advanced-import' ), $post_type_title ),
|
1004 |
+
'pending' => esc_html__( 'Pending.', 'advanced-import' ),
|
1005 |
+
'installing' => esc_html__( 'Installing.', 'advanced-import' ),
|
1006 |
+
'success' => esc_html__( 'Success.', 'advanced-import' ),
|
1007 |
+
'install_callback' => array( $this, 'import_content_post_type_data' ),
|
1008 |
+
'checked' => $this->is_possible_upgrade() ? 0 : 1,
|
1009 |
+
// dont check if already have content installed.
|
1010 |
+
);
|
1011 |
+
}
|
1012 |
+
}
|
1013 |
+
/*
|
1014 |
+
array adjustment
|
1015 |
+
TODO : Remove it after adjustment on Advanced Import
|
1016 |
+
*/
|
1017 |
+
/*Put post 3nd last*/
|
1018 |
+
$post = isset( $content['post'] ) ? $content['post'] : array();
|
1019 |
+
if ( $post ) {
|
1020 |
+
unset( $content['post'] );
|
1021 |
+
$content['post'] = $post;
|
1022 |
+
}
|
1023 |
+
/*Put page 2nd last*/
|
1024 |
+
$page = isset( $content['page'] ) ? $content['page'] : array();
|
1025 |
+
if ( $page ) {
|
1026 |
+
unset( $content['page'] );
|
1027 |
+
$content['page'] = $page;
|
1028 |
+
|
1029 |
+
}
|
1030 |
+
/*Put nav last*/
|
1031 |
+
$nav = isset( $content['nav_menu_item'] ) ? $content['nav_menu_item'] : array();
|
1032 |
+
if ( $nav ) {
|
1033 |
+
unset( $content['nav_menu_item'] );
|
1034 |
+
$content['nav_menu_item'] = $nav;
|
1035 |
+
}
|
1036 |
+
/*check if there is files*/
|
1037 |
+
$widget_data = $this->get_widgets_json();
|
1038 |
+
if ( ! empty( $widget_data ) ) {
|
1039 |
+
$content['widgets'] = array(
|
1040 |
+
'title' => esc_html__( 'Widgets', 'advanced-import' ),
|
1041 |
+
'description' => esc_html__( 'Insert default sidebar widgets as seen in the demo.', 'advanced-import' ),
|
1042 |
+
'pending' => esc_html__( 'Pending.', 'advanced-import' ),
|
1043 |
+
'installing' => esc_html__( 'Installing Default Widgets.', 'advanced-import' ),
|
1044 |
+
'success' => esc_html__( 'Success.', 'advanced-import' ),
|
1045 |
+
'install_callback' => array( $this, 'import_content_widgets_data' ),
|
1046 |
+
'checked' => $this->is_possible_upgrade() ? 0 : 1,
|
1047 |
+
// dont check if already have content installed.
|
1048 |
+
);
|
1049 |
+
}
|
1050 |
+
$options_data = $this->get_theme_options_json();
|
1051 |
+
if ( ! empty( $options_data ) ) {
|
1052 |
+
$content['settings'] = array(
|
1053 |
+
'title' => esc_html__( 'Settings', 'advanced-import' ),
|
1054 |
+
'description' => esc_html__( 'Configure default settings.', 'advanced-import' ),
|
1055 |
+
'pending' => esc_html__( 'Pending.', 'advanced-import' ),
|
1056 |
+
'installing' => esc_html__( 'Installing Default Settings.', 'advanced-import' ),
|
1057 |
+
'success' => esc_html__( 'Success.', 'advanced-import' ),
|
1058 |
+
'install_callback' => array( $this, 'import_menu_and_options' ),
|
1059 |
+
'checked' => $this->is_possible_upgrade() ? 0 : 1,
|
1060 |
+
// dont check if already have content installed.
|
1061 |
+
);
|
1062 |
+
}
|
1063 |
+
$content = apply_filters( $this->theme_name . '_theme_view_setup_step_content', $content );
|
1064 |
+
|
1065 |
+
return $content;
|
1066 |
+
|
1067 |
+
}
|
1068 |
+
|
1069 |
+
/**
|
1070 |
+
* 3rd Step Step for content, widget, setting import
|
1071 |
+
* Page setup
|
1072 |
+
*/
|
1073 |
+
public function content_screen() {
|
1074 |
+
|
1075 |
+
/*check for security*/
|
1076 |
+
if ( ! current_user_can( 'upload_files' ) ) {
|
1077 |
+
wp_send_json_error(
|
1078 |
+
array(
|
1079 |
+
'message' => esc_html__( 'Sorry, you are not allowed to install demo on this site.', 'advanced-import' ),
|
1080 |
+
)
|
1081 |
+
);
|
1082 |
+
}
|
1083 |
+
check_admin_referer( 'advanced-import' );
|
1084 |
+
|
1085 |
+
if ( isset( $_POST['template_url'] ) ) {
|
1086 |
+
$this->current_template_url = is_array( $_POST['template_url'] ) ? (array) $_POST['template_url'] : sanitize_text_field( $_POST['template_url'] );
|
1087 |
+
$this->current_template_type = sanitize_text_field( $_POST['template_type'] );
|
1088 |
+
}
|
1089 |
+
|
1090 |
+
do_action( 'advanced_import_before_content_screen' );
|
1091 |
+
|
1092 |
+
?>
|
1093 |
+
<div class="ai-notification-title">
|
1094 |
+
<p>
|
1095 |
+
<?php
|
1096 |
+
esc_html_e( 'It\'s time to insert some demo content for your new WordPress Site. Once inserted, this content can be managed from the WordPress admin dashboard. ' )
|
1097 |
+
?>
|
1098 |
+
</p>
|
1099 |
+
</div>
|
1100 |
+
|
1101 |
+
<table class="ai-pages hidden">
|
1102 |
+
<thead>
|
1103 |
+
<tr>
|
1104 |
+
<th class="check"></th>
|
1105 |
+
<th class="item"><?php esc_html_e( 'Item', 'advanced-import' ); ?></th>
|
1106 |
+
<th class="description"><?php esc_html_e( 'Description', 'advanced-import' ); ?></th>
|
1107 |
+
<th class="status"><?php esc_html_e( 'Status', 'advanced-import' ); ?></th>
|
1108 |
+
</tr>
|
1109 |
+
</thead>
|
1110 |
+
<tbody>
|
1111 |
+
<?php
|
1112 |
+
$setup_content_steps = $this->advanced_import_setup_content_steps();
|
1113 |
+
foreach ( $setup_content_steps as $slug => $default ) {
|
1114 |
+
?>
|
1115 |
+
<tr class="ai-available-content" data-content="<?php echo esc_attr( $slug ); ?>">
|
1116 |
+
<td>
|
1117 |
+
<input type="checkbox" name="import_content[<?php echo esc_attr( $slug ); ?>]" class="ai-available-content" id="import_content_<?php echo esc_attr( $slug ); ?>" value="1" <?php echo ( ! isset( $default['checked'] ) || $default['checked'] ) ? ' checked' : ''; ?>>
|
1118 |
+
</td>
|
1119 |
+
<td>
|
1120 |
+
<label for="import_content_<?php echo esc_attr( $slug ); ?>">
|
1121 |
+
<?php echo esc_html( $default['title'] ); ?>
|
1122 |
+
</label>
|
1123 |
+
</td>
|
1124 |
+
<td class="description">
|
1125 |
+
<?php echo esc_html( $default['description'] ); ?>
|
1126 |
+
</td>
|
1127 |
+
<td class="status">
|
1128 |
<span>
|
1129 |
<?php echo esc_html( $default['pending'] ); ?>
|
1130 |
</span>
|
1131 |
+
</td>
|
1132 |
+
</tr>
|
1133 |
+
<?php } ?>
|
1134 |
+
</tbody>
|
1135 |
+
</table>
|
1136 |
+
<?php
|
1137 |
+
do_action( 'advanced_import_after_content_screen' );
|
1138 |
+
|
1139 |
+
exit;
|
1140 |
+
}
|
1141 |
+
|
1142 |
+
/*
|
1143 |
+
* import ajax content
|
1144 |
+
* return JSON
|
1145 |
+
*/
|
1146 |
+
public function import_content() {
|
1147 |
+
|
1148 |
+
/*check for security*/
|
1149 |
+
if ( ! current_user_can( 'upload_files' ) ) {
|
1150 |
+
wp_send_json_error(
|
1151 |
+
array(
|
1152 |
+
'message' => esc_html__( 'Sorry, you are not allowed to install demo on this site.', 'advanced-import' ),
|
1153 |
+
)
|
1154 |
+
);
|
1155 |
+
}
|
1156 |
+
if ( isset( $_POST['template_url'] ) ) {
|
1157 |
+
$this->current_template_url = is_array( $_POST['template_url'] ) ? (array) $_POST['template_url'] : sanitize_text_field( $_POST['template_url'] );
|
1158 |
+
$this->current_template_type = sanitize_text_field( $_POST['template_type'] );
|
1159 |
+
}
|
1160 |
+
|
1161 |
+
/*Move to Trash default page and post*/
|
1162 |
+
$sample_page = get_page_by_title( 'Sample Page', OBJECT, 'page' );
|
1163 |
+
$hello_world_post = get_page_by_title( 'Hello world!', OBJECT, 'post' );
|
1164 |
+
if ( is_object( $sample_page ) ) {
|
1165 |
+
wp_trash_post( $sample_page->ID );
|
1166 |
+
}
|
1167 |
+
if ( is_object( $hello_world_post ) ) {
|
1168 |
+
wp_trash_post( $hello_world_post->ID );
|
1169 |
+
}
|
1170 |
+
|
1171 |
+
$content_slug = isset( $_POST['content'] ) ? sanitize_title( $_POST['content'] ) : '';
|
1172 |
+
|
1173 |
+
$content = $this->advanced_import_setup_content_steps();
|
1174 |
+
|
1175 |
+
/*check for security again*/
|
1176 |
+
if ( ! check_ajax_referer( 'advanced_import_nonce', 'wpnonce' ) || empty( $content_slug ) || ! isset( $content[ $content_slug ] ) ) {
|
1177 |
+
wp_send_json_error(
|
1178 |
+
array(
|
1179 |
+
'error' => 1,
|
1180 |
+
'message' => esc_html__( 'No content Found', 'advanced-import' ),
|
1181 |
+
)
|
1182 |
+
);
|
1183 |
+
}
|
1184 |
+
|
1185 |
+
$json = false;
|
1186 |
+
$this_content = $content[ $content_slug ];
|
1187 |
+
|
1188 |
+
if ( isset( $_POST['proceed'] ) ) {
|
1189 |
+
|
1190 |
+
/*install the content*/
|
1191 |
+
$this->log( esc_html__( 'Starting import for ', 'advanced-import' ) . $content_slug );
|
1192 |
+
|
1193 |
+
/*init delayed posts from transient.*/
|
1194 |
+
$this->delay_posts = get_transient( 'delayed_posts' );
|
1195 |
+
if ( ! is_array( $this->delay_posts ) ) {
|
1196 |
+
$this->delay_posts = array();
|
1197 |
+
}
|
1198 |
+
|
1199 |
+
if ( ! empty( $this_content['install_callback'] ) ) {
|
1200 |
+
/*
|
1201 |
+
install_callback includes following functions
|
1202 |
+
* import_content_post_type_data
|
1203 |
+
* import_content_widgets_data
|
1204 |
+
* import_menu_and_options
|
1205 |
+
* */
|
1206 |
+
if ( $result = call_user_func( $this_content['install_callback'] ) ) {
|
1207 |
+
|
1208 |
+
$this->log( esc_html__( 'Finish writing ', 'advanced-import' ) . count( $this->delay_posts, COUNT_RECURSIVE ) . esc_html__( ' delayed posts to transient ', 'advanced-import' ) );
|
1209 |
+
set_transient( 'delayed_posts', $this->delay_posts, 60 * 60 * 24 );
|
1210 |
+
|
1211 |
+
/*
|
1212 |
+
if there is retry, retry it
|
1213 |
+
or finish it*/
|
1214 |
+
if ( is_array( $result ) && isset( $result['retry'] ) ) {
|
1215 |
+
/*we split the stuff up again.*/
|
1216 |
+
$json = array(
|
1217 |
+
'url' => admin_url( 'admin-ajax.php' ),
|
1218 |
+
'action' => 'import_content',
|
1219 |
+
'proceed' => 'true',
|
1220 |
+
'retry' => time(),
|
1221 |
+
'retry_count' => $result['retry_count'],
|
1222 |
+
'content' => $content_slug,
|
1223 |
+
'_wpnonce' => wp_create_nonce( 'advanced_import_nonce' ),
|
1224 |
+
'message' => $this_content['installing'],
|
1225 |
+
'logs' => $this->logs,
|
1226 |
+
'errors' => $this->errors,
|
1227 |
+
'template_url' => $this->current_template_url,
|
1228 |
+
'template_type' => $this->current_template_type,
|
1229 |
+
|
1230 |
+
);
|
1231 |
+
} else {
|
1232 |
+
$json = array(
|
1233 |
+
'done' => 1,
|
1234 |
+
'message' => $this_content['success'],
|
1235 |
+
'debug' => $result,
|
1236 |
+
'logs' => $this->logs,
|
1237 |
+
'errors' => $this->errors,
|
1238 |
+
);
|
1239 |
+
}
|
1240 |
+
}
|
1241 |
+
}
|
1242 |
+
} else {
|
1243 |
+
|
1244 |
+
$json = array(
|
1245 |
+
'url' => admin_url( 'admin-ajax.php' ),
|
1246 |
+
'action' => 'import_content',
|
1247 |
+
'proceed' => 'true',
|
1248 |
+
'content' => $content_slug,
|
1249 |
+
'_wpnonce' => wp_create_nonce( 'advanced_import_nonce' ),
|
1250 |
+
'message' => $this_content['installing'],
|
1251 |
+
'logs' => $this->logs,
|
1252 |
+
'errors' => $this->errors,
|
1253 |
+
'template_url' => $this->current_template_url,
|
1254 |
+
'template_type' => $this->current_template_type,
|
1255 |
+
);
|
1256 |
+
}
|
1257 |
+
|
1258 |
+
if ( $json ) {
|
1259 |
+
$json['hash'] = md5( serialize( $json ) ); /*used for checking if duplicates happen, move to next plugin*/
|
1260 |
+
wp_send_json( $json );
|
1261 |
+
} else {
|
1262 |
+
wp_send_json_error(
|
1263 |
+
array(
|
1264 |
+
'message' => esc_html__( 'Error', 'advanced-import' ),
|
1265 |
+
'logs' => $this->logs,
|
1266 |
+
'errors' => $this->errors,
|
1267 |
+
)
|
1268 |
+
);
|
1269 |
+
}
|
1270 |
+
exit;
|
1271 |
+
}
|
1272 |
+
|
1273 |
+
/*
|
1274 |
+
callback function to importing post type
|
1275 |
+
* all post type is imported from here
|
1276 |
+
* return mix
|
1277 |
+
* */
|
1278 |
+
private function import_content_post_type_data() {
|
1279 |
+
$post_type = ! empty( $_POST['content'] ) ? sanitize_text_field( $_POST['content'] ) : false;
|
1280 |
+
$all_data = $this->get_main_content_json();
|
1281 |
+
if ( ! $post_type || ! isset( $all_data[ $post_type ] ) ) {
|
1282 |
+
return false;
|
1283 |
+
}
|
1284 |
+
|
1285 |
+
/*Import 10 posts at a time*/
|
1286 |
+
$limit = 10 + ( isset( $_REQUEST['retry_count'] ) ? (int) $_REQUEST['retry_count'] : 0 );
|
1287 |
+
|
1288 |
+
$limit = apply_filters( 'advanced_import_limit_at_time', $limit );
|
1289 |
+
$x = 0;
|
1290 |
+
foreach ( $all_data[ $post_type ] as $post_data ) {
|
1291 |
+
|
1292 |
+
$this->process_import_single_post( $post_type, $post_data );
|
1293 |
+
|
1294 |
+
if ( $x ++ > $limit ) {
|
1295 |
+
return array(
|
1296 |
+
'retry' => 1,
|
1297 |
+
'retry_count' => $limit,
|
1298 |
+
);
|
1299 |
+
}
|
1300 |
+
}
|
1301 |
+
|
1302 |
+
/*processed delayed posts*/
|
1303 |
+
$this->process_delayed_posts();
|
1304 |
+
|
1305 |
+
/*process child posts*/
|
1306 |
+
$this->processpost_orphans();
|
1307 |
+
|
1308 |
+
return true;
|
1309 |
+
|
1310 |
+
}
|
1311 |
+
|
1312 |
+
/*
|
1313 |
+
set and get transient imported_term_ids
|
1314 |
+
return mix*/
|
1315 |
+
public function imported_term_id( $original_term_id, $new_term_id = false ) {
|
1316 |
+
$terms = get_transient( 'imported_term_ids' );
|
1317 |
+
if ( ! is_array( $terms ) ) {
|
1318 |
+
$terms = array();
|
1319 |
+
}
|
1320 |
+
if ( $new_term_id ) {
|
1321 |
+
if ( ! isset( $terms[ $original_term_id ] ) ) {
|
1322 |
+
$this->log( esc_html__( 'Insert old TERM ID ', 'advanced-import' ) . $original_term_id . esc_html__( ' as new TERM ID: ', 'advanced-import' ) . $new_term_id );
|
1323 |
+
} elseif ( $terms[ $original_term_id ] != $new_term_id ) {
|
1324 |
+
$this->error( 'Replacement OLD TERM ID ' . $original_term_id . ' overwritten by new TERM ID: ' . $new_term_id );
|
1325 |
+
}
|
1326 |
+
$terms[ $original_term_id ] = $new_term_id;
|
1327 |
+
set_transient( 'imported_term_ids', $terms, 60 * 60 * 24 );
|
1328 |
+
} elseif ( $original_term_id && isset( $terms[ $original_term_id ] ) ) {
|
1329 |
+
return $terms[ $original_term_id ];
|
1330 |
+
}
|
1331 |
+
|
1332 |
+
return false;
|
1333 |
+
}
|
1334 |
+
|
1335 |
+
/*
|
1336 |
+
set and get imported_post_ids
|
1337 |
+
return mix*/
|
1338 |
+
public function imported_post_id( $original_id = false, $new_id = false ) {
|
1339 |
+
if ( is_array( $original_id ) || is_object( $original_id ) ) {
|
1340 |
+
return false;
|
1341 |
+
}
|
1342 |
+
$post_ids = get_transient( 'imported_post_ids' );
|
1343 |
+
if ( ! is_array( $post_ids ) ) {
|
1344 |
+
$post_ids = array();
|
1345 |
+
}
|
1346 |
+
if ( $new_id ) {
|
1347 |
+
if ( ! isset( $post_ids[ $original_id ] ) ) {
|
1348 |
+
$this->log( esc_html__( 'Insert old ID ', 'advanced-import' ) . $original_id . esc_html__( ' as new ID: ', 'advanced-import' ) . $new_id );
|
1349 |
+
} elseif ( $post_ids[ $original_id ] != $new_id ) {
|
1350 |
+
$this->error( esc_html__( 'Replacement OLD ID ', 'advanced-import' ) . $original_id . ' overwritten by new ID: ' . $new_id );
|
1351 |
+
}
|
1352 |
+
$post_ids[ $original_id ] = $new_id;
|
1353 |
+
set_transient( 'imported_post_ids', $post_ids, 60 * 60 * 24 );
|
1354 |
+
} elseif ( $original_id && isset( $post_ids[ $original_id ] ) ) {
|
1355 |
+
return $post_ids[ $original_id ];
|
1356 |
+
} elseif ( $original_id === false ) {
|
1357 |
+
return $post_ids;
|
1358 |
+
}
|
1359 |
+
return false;
|
1360 |
+
}
|
1361 |
+
|
1362 |
+
/*
|
1363 |
+
set and get post_orphans/post parent
|
1364 |
+
if parent is not already imported the child will be orphan
|
1365 |
+
return mix*/
|
1366 |
+
private function post_orphans( $original_id = false, $missing_parent_id = false ) {
|
1367 |
+
$post_ids = get_transient( 'post_orphans' );
|
1368 |
+
if ( ! is_array( $post_ids ) ) {
|
1369 |
+
$post_ids = array();
|
1370 |
+
}
|
1371 |
+
if ( $missing_parent_id ) {
|
1372 |
+
$post_ids[ $original_id ] = $missing_parent_id;
|
1373 |
+
set_transient( 'post_orphans', $post_ids, 60 * 60 * 24 );
|
1374 |
+
} elseif ( $original_id && isset( $post_ids[ $original_id ] ) ) {
|
1375 |
+
return $post_ids[ $original_id ];
|
1376 |
+
} elseif ( $original_id === false ) {
|
1377 |
+
return $post_ids;
|
1378 |
+
}
|
1379 |
+
return false;
|
1380 |
+
}
|
1381 |
+
|
1382 |
+
|
1383 |
+
/*set delayed post for later process*/
|
1384 |
+
private function delay_post_process( $post_type, $post_data ) {
|
1385 |
+
if ( ! isset( $this->delay_posts[ $post_type ] ) ) {
|
1386 |
+
$this->delay_posts[ $post_type ] = array();
|
1387 |
+
}
|
1388 |
+
$this->delay_posts[ $post_type ][ $post_data['post_id'] ] = $post_data;
|
1389 |
+
}
|
1390 |
+
|
1391 |
+
|
1392 |
+
/*
|
1393 |
+
Important Function
|
1394 |
+
Import single Post/Content
|
1395 |
+
*/
|
1396 |
+
private function process_import_single_post( $post_type, $post_data, $delayed = 0 ) {
|
1397 |
+
|
1398 |
+
$this->log( esc_html__( 'Processing ', 'advanced-import' ) . $post_type . ' ' . $post_data['post_id'] );
|
1399 |
+
$original_post_data = $post_data;
|
1400 |
+
|
1401 |
+
/*if there is not post type return false*/
|
1402 |
+
if ( ! post_type_exists( $post_type ) ) {
|
1403 |
+
return false;
|
1404 |
+
}
|
1405 |
+
|
1406 |
+
/*if it is aready imported return*/
|
1407 |
+
if ( $this->imported_post_id( $post_data['post_id'] ) ) {
|
1408 |
+
return true; /*already done*/
|
1409 |
+
}
|
1410 |
+
|
1411 |
+
/*set post_name id for empty post name/title*/
|
1412 |
+
if ( empty( $post_data['post_title'] ) && empty( $post_data['post_name'] ) ) {
|
1413 |
+
$post_data['post_name'] = $post_data['post_id'];
|
1414 |
+
}
|
1415 |
+
|
1416 |
+
/*set post_type on $post_data*/
|
1417 |
+
$post_data['post_type'] = $post_type;
|
1418 |
+
|
1419 |
+
/*post_orphans/post parent management */
|
1420 |
+
$post_parent = isset( $post_data['post_parent'] ) ? absint( $post_data['post_parent'] ) : false;
|
1421 |
+
if ( $post_parent ) {
|
1422 |
+
/*if we already know the parent, map it to the new local imported ID*/
|
1423 |
+
if ( $this->imported_post_id( $post_parent ) ) {
|
1424 |
+
$post_data['post_parent'] = $this->imported_post_id( $post_parent );
|
1425 |
+
} else {
|
1426 |
+
/*if there is not parent imported, child will be orphans*/
|
1427 |
+
$this->post_orphans( absint( $post_data['post_id'] ), $post_parent );
|
1428 |
+
$post_data['post_parent'] = 0;
|
1429 |
+
}
|
1430 |
+
}
|
1431 |
+
|
1432 |
+
/*check if already exists by post_name*/
|
1433 |
+
if ( empty( $post_data['post_title'] ) && ! empty( $post_data['post_name'] ) ) {
|
1434 |
+
global $wpdb;
|
1435 |
+
$sql = "
|
1436 |
SELECT ID, post_name, post_parent, post_type
|
1437 |
FROM $wpdb->posts
|
1438 |
WHERE post_name = %s
|
1439 |
AND post_type = %s
|
1440 |
";
|
1441 |
+
$pages = $wpdb->get_results(
|
1442 |
+
$wpdb->prepare(
|
1443 |
+
$sql,
|
1444 |
+
array(
|
1445 |
+
$post_data['post_name'],
|
1446 |
+
$post_type,
|
1447 |
+
)
|
1448 |
+
),
|
1449 |
+
OBJECT_K
|
1450 |
+
);
|
1451 |
+
|
1452 |
+
$foundid = 0;
|
1453 |
+
foreach ( (array) $pages as $page ) {
|
1454 |
+
if ( $page->post_name == $post_data['post_name'] && empty( $page->post_title ) ) {
|
1455 |
+
$foundid = $page->ID;
|
1456 |
+
}
|
1457 |
+
}
|
1458 |
+
|
1459 |
+
/*if we have found id by post_name, imported_post_id and return*/
|
1460 |
+
if ( $foundid ) {
|
1461 |
+
$this->imported_post_id( $post_data['post_id'], $foundid );
|
1462 |
+
return true;
|
1463 |
+
}
|
1464 |
+
}
|
1465 |
+
|
1466 |
+
/*
|
1467 |
+
check if already exists by post_name and post_title*/
|
1468 |
+
/*don't use post_exists because it will dupe up on media with same name but different slug*/
|
1469 |
+
if ( ! empty( $post_data['post_title'] ) && ! empty( $post_data['post_name'] ) ) {
|
1470 |
+
global $wpdb;
|
1471 |
+
$sql = "
|
1472 |
SELECT ID, post_name, post_parent, post_type
|
1473 |
FROM $wpdb->posts
|
1474 |
WHERE post_name = %s
|
1475 |
AND post_title = %s
|
1476 |
AND post_type = %s
|
1477 |
";
|
1478 |
+
$pages = $wpdb->get_results(
|
1479 |
+
$wpdb->prepare(
|
1480 |
+
$sql,
|
1481 |
+
array(
|
1482 |
+
$post_data['post_name'],
|
1483 |
+
$post_data['post_title'],
|
1484 |
+
$post_type,
|
1485 |
+
)
|
1486 |
+
),
|
1487 |
+
OBJECT_K
|
1488 |
+
);
|
1489 |
+
|
1490 |
+
$foundid = 0;
|
1491 |
+
foreach ( (array) $pages as $page ) {
|
1492 |
+
if ( $page->post_name == $post_data['post_name'] ) {
|
1493 |
+
$foundid = $page->ID;
|
1494 |
+
}
|
1495 |
+
}
|
1496 |
+
|
1497 |
+
/*if we have found id by post_name and post_title, imported_post_id and return*/
|
1498 |
+
if ( $foundid ) {
|
1499 |
+
$this->imported_post_id( $post_data['post_id'], $foundid );
|
1500 |
+
return true;
|
1501 |
+
}
|
1502 |
+
}
|
1503 |
+
|
1504 |
+
/*
|
1505 |
+
* todo it may not required
|
1506 |
+
* backwards compat with old import format.*/
|
1507 |
+
if ( isset( $post_data['meta'] ) ) {
|
1508 |
+
foreach ( $post_data['meta'] as $key => $meta ) {
|
1509 |
+
if ( is_array( $meta ) && count( $meta ) == 1 ) {
|
1510 |
+
$single_meta = current( $meta );
|
1511 |
+
if ( ! is_array( $single_meta ) ) {
|
1512 |
+
$post_data['meta'][ $key ] = $single_meta;
|
1513 |
+
}
|
1514 |
+
}
|
1515 |
+
}
|
1516 |
+
}
|
1517 |
+
|
1518 |
+
/*finally process*/
|
1519 |
+
switch ( $post_type ) {
|
1520 |
+
|
1521 |
+
/*case attachment*/
|
1522 |
+
case 'attachment':
|
1523 |
+
/*import media via url*/
|
1524 |
+
if ( isset( $post_data['guid'] ) && ! empty( $post_data['guid'] ) ) {
|
1525 |
+
|
1526 |
+
/*check if this has already been imported.*/
|
1527 |
+
$old_guid = $post_data['guid'];
|
1528 |
+
if ( $this->imported_post_id( $old_guid ) ) {
|
1529 |
+
return true; /*already done*/
|
1530 |
+
}
|
1531 |
+
|
1532 |
+
// ignore post parent, we haven't imported those yet.
|
1533 |
+
// $file_data = wp_remote_get($post_data['guid']);
|
1534 |
+
$remote_url = $post_data['guid'];
|
1535 |
+
|
1536 |
+
$post_data['upload_date'] = date( 'Y/m', strtotime( $post_data['post_date_gmt'] ) );
|
1537 |
+
|
1538 |
+
if ( isset( $post_data['meta'] ) ) {
|
1539 |
+
foreach ( $post_data['meta'] as $key => $meta ) {
|
1540 |
+
if ( $key == '_wp_attached_file' ) {
|
1541 |
+
foreach ( (array) $meta as $meta_val ) {
|
1542 |
+
if ( preg_match( '%^[0-9]{4}/[0-9]{2}%', $meta_val, $matches ) ) {
|
1543 |
+
$post_data['upload_date'] = $matches[0];
|
1544 |
+
}
|
1545 |
+
}
|
1546 |
+
}
|
1547 |
+
}
|
1548 |
+
}
|
1549 |
+
|
1550 |
+
/*upload the file*/
|
1551 |
+
$upload = $this->import_image_and_file( $remote_url, $post_data );
|
1552 |
+
|
1553 |
+
/*if error on upload*/
|
1554 |
+
if ( ! is_array( $upload ) || is_wp_error( $upload ) ) {
|
1555 |
+
/*todo: error*/
|
1556 |
+
return false;
|
1557 |
+
}
|
1558 |
+
|
1559 |
+
/*check file type, if file type not found return false*/
|
1560 |
+
if ( $info = wp_check_filetype( $upload['file'] ) ) {
|
1561 |
+
$post_data['post_mime_type'] = $info['type'];
|
1562 |
+
} else {
|
1563 |
+
return false;
|
1564 |
+
}
|
1565 |
+
|
1566 |
+
/*set guid file url*/
|
1567 |
+
$post_data['guid'] = $upload['url'];
|
1568 |
+
|
1569 |
+
/*
|
1570 |
+
* insert attachment
|
1571 |
+
*https://developer.wordpress.org/reference/functions/wp_insert_attachment/
|
1572 |
+
* */
|
1573 |
+
$attach_id = wp_insert_attachment( $post_data, $upload['file'] );
|
1574 |
+
if ( $attach_id ) {
|
1575 |
+
|
1576 |
+
/*update meta*/
|
1577 |
+
if ( ! empty( $post_data['meta'] ) ) {
|
1578 |
+
foreach ( $post_data['meta'] as $meta_key => $meta_val ) {
|
1579 |
+
if ( $meta_key != '_wp_attached_file' && ! empty( $meta_val ) ) {
|
1580 |
+
update_post_meta( $attach_id, $meta_key, $meta_val );
|
1581 |
+
}
|
1582 |
+
}
|
1583 |
+
}
|
1584 |
+
/* Update metadata for an attachment.*/
|
1585 |
+
wp_update_attachment_metadata( $attach_id, wp_generate_attachment_metadata( $attach_id, $upload['file'] ) );
|
1586 |
+
|
1587 |
+
/*remap resized image URLs, works by stripping the extension and remapping the URL stub.*/
|
1588 |
+
if ( preg_match( '!^image/!', $info['type'] ) ) {
|
1589 |
+
$parts = pathinfo( $remote_url );
|
1590 |
+
$name = basename( $parts['basename'], ".{$parts['extension']}" ); // PATHINFO_FILENAME in PHP 5.2
|
1591 |
+
|
1592 |
+
$parts_new = pathinfo( $upload['url'] );
|
1593 |
+
$name_new = basename( $parts_new['basename'], ".{$parts_new['extension']}" );
|
1594 |
+
|
1595 |
+
$this->imported_post_id( $parts['dirname'] . '/' . $name, $parts_new['dirname'] . '/' . $name_new );
|
1596 |
+
}
|
1597 |
+
$this->imported_post_id( $post_data['post_id'], $attach_id );
|
1598 |
+
}
|
1599 |
+
}
|
1600 |
+
break;
|
1601 |
+
|
1602 |
+
default:
|
1603 |
+
/*Process Post Meta*/
|
1604 |
+
if ( ! empty( $post_data['meta'] ) && is_array( $post_data['meta'] ) ) {
|
1605 |
+
|
1606 |
+
/*fix for double json encoded stuff*/
|
1607 |
+
foreach ( $post_data['meta'] as $meta_key => $meta_val ) {
|
1608 |
+
if ( is_string( $meta_val ) && strlen( $meta_val ) && $meta_val[0] == '[' ) {
|
1609 |
+
$test_json = @json_decode( $meta_val, true );
|
1610 |
+
if ( is_array( $test_json ) ) {
|
1611 |
+
$post_data['meta'][ $meta_key ] = $test_json;
|
1612 |
+
}
|
1613 |
+
}
|
1614 |
+
}
|
1615 |
+
|
1616 |
+
array_walk_recursive( $post_data['meta'], array( advanced_import_elementor(), 'elementor_id_import' ) );
|
1617 |
+
|
1618 |
+
/*todo gutenberg and page builders*/
|
1619 |
+
|
1620 |
+
/*
|
1621 |
+
replace menu data
|
1622 |
+
work out what we're replacing. a tax, page, term etc..*/
|
1623 |
+
if ( isset( $post_data['meta']['_menu_item_menu_item_parent'] ) && 0 != $post_data['meta']['_menu_item_menu_item_parent'] ) {
|
1624 |
+
$new_parent_id = $this->imported_post_id( $post_data['meta']['_menu_item_menu_item_parent'] );
|
1625 |
+
if ( ! $new_parent_id ) {
|
1626 |
+
if ( $delayed ) {
|
1627 |
+
/*already delayed, unable to find this meta value, skip inserting it*/
|
1628 |
+
$this->error( esc_html__( 'Unable to find replacement. Continue anyway.... content will most likely break..', 'advanced-import' ) );
|
1629 |
+
} else {
|
1630 |
+
/*not found , delay it*/
|
1631 |
+
$this->error( esc_html__( 'Unable to find replacement. Delaying....', 'advanced-import' ) );
|
1632 |
+
$this->delay_post_process( $post_type, $original_post_data );
|
1633 |
+
return false;
|
1634 |
+
}
|
1635 |
+
}
|
1636 |
+
$post_data['meta']['_menu_item_menu_item_parent'] = $new_parent_id;
|
1637 |
+
}
|
1638 |
+
|
1639 |
+
/*if _menu_item_type*/
|
1640 |
+
if ( isset( $post_data['meta']['_menu_item_type'] ) ) {
|
1641 |
+
|
1642 |
+
switch ( $post_data['meta']['_menu_item_type'] ) {
|
1643 |
+
case 'post_type':
|
1644 |
+
if ( ! empty( $post_data['meta']['_menu_item_object_id'] ) ) {
|
1645 |
+
$new_parent_id = $this->imported_post_id( $post_data['meta']['_menu_item_object_id'] );
|
1646 |
+
if ( ! $new_parent_id ) {
|
1647 |
+
if ( $delayed ) {
|
1648 |
+
/*already delayed, unable to find this meta value, skip inserting it*/
|
1649 |
+
$this->error( esc_html__( 'Unable to find replacement. Continue anyway.... content will most likely break..', 'advanced-import' ) );
|
1650 |
+
} else {
|
1651 |
+
/*not found , delay it*/
|
1652 |
+
$this->error( esc_html__( 'Unable to find replacement. Delaying....', 'advanced-import' ) );
|
1653 |
+
$this->delay_post_process( $post_type, $original_post_data );
|
1654 |
+
return false;
|
1655 |
+
}
|
1656 |
+
}
|
1657 |
+
$post_data['meta']['_menu_item_object_id'] = $new_parent_id;
|
1658 |
+
}
|
1659 |
+
break;
|
1660 |
+
|
1661 |
+
case 'taxonomy':
|
1662 |
+
if ( ! empty( $post_data['meta']['_menu_item_object_id'] ) ) {
|
1663 |
+
$new_parent_id = $this->imported_term_id( $post_data['meta']['_menu_item_object_id'] );
|
1664 |
+
if ( ! $new_parent_id ) {
|
1665 |
+
if ( $delayed ) {
|
1666 |
+
/*already delayed, unable to find this meta value, skip inserting it*/
|
1667 |
+
$this->error( esc_html__( 'Unable to find replacement. Continue anyway.... content will most likely break..', 'advanced-import' ) );
|
1668 |
+
} else {
|
1669 |
+
/*not found , delay it*/
|
1670 |
+
$this->error( esc_html__( 'Unable to find replacement. Delaying....', 'advanced-import' ) );
|
1671 |
+
$this->delay_post_process( $post_type, $original_post_data );
|
1672 |
+
return false;
|
1673 |
+
}
|
1674 |
+
}
|
1675 |
+
$post_data['meta']['_menu_item_object_id'] = $new_parent_id;
|
1676 |
+
}
|
1677 |
+
break;
|
1678 |
+
}
|
1679 |
+
}
|
1680 |
+
}
|
1681 |
+
|
1682 |
+
/*
|
1683 |
+
post content parser
|
1684 |
+
for shortcode post id replacement*/
|
1685 |
+
$post_data['post_content'] = $this->parse_shortcode_meta_content( $post_data['post_content'] );
|
1686 |
+
|
1687 |
+
$replace_tax_id_keys = array(
|
1688 |
+
'taxonomies',
|
1689 |
+
);
|
1690 |
+
foreach ( $replace_tax_id_keys as $replace_key ) {
|
1691 |
+
if ( preg_match_all( '# ' . $replace_key . '="(\d+)"#', $post_data['post_content'], $matches ) ) {
|
1692 |
+
foreach ( $matches[0] as $match_id => $string ) {
|
1693 |
+
$new_id = $this->imported_term_id( $matches[1][ $match_id ] );
|
1694 |
+
if ( $new_id ) {
|
1695 |
+
$post_data['post_content'] = str_replace( $string, ' ' . $replace_key . '="' . $new_id . '"', $post_data['post_content'] );
|
1696 |
+
} else {
|
1697 |
+
$this->error( esc_html__( 'Unable to find TAXONOMY replacement for ', 'advanced-import' ) . $replace_key . '="' . $matches[1][ $match_id ] . esc_html__( 'in content.', 'advanced-import' ) );
|
1698 |
+
if ( $delayed ) {
|
1699 |
+
/*already delayed, unable to find this meta value, skip inserting it*/
|
1700 |
+
$this->error( esc_html__( 'Unable to find replacement. Continue anyway.... content will most likely break..', 'advanced-import' ) );
|
1701 |
+
} else {
|
1702 |
+
/*not found , delay it*/
|
1703 |
+
$this->delay_post_process( $post_type, $original_post_data );
|
1704 |
+
return false;
|
1705 |
+
}
|
1706 |
+
}
|
1707 |
+
}
|
1708 |
+
}
|
1709 |
+
}
|
1710 |
+
|
1711 |
+
/*do further filter if you need*/
|
1712 |
+
$post_data = apply_filters( 'advanced_import_post_data', $post_data );
|
1713 |
+
|
1714 |
+
/*finally insert post data*/
|
1715 |
+
$post_id = wp_insert_post( $post_data, true );
|
1716 |
+
if ( ! is_wp_error( $post_id ) ) {
|
1717 |
+
|
1718 |
+
/*set id on imported_post_id*/
|
1719 |
+
$this->imported_post_id( $post_data['post_id'], $post_id );
|
1720 |
+
|
1721 |
+
/*add/update post meta*/
|
1722 |
+
if ( ! empty( $post_data['meta'] ) ) {
|
1723 |
+
foreach ( $post_data['meta'] as $meta_key => $meta_val ) {
|
1724 |
+
/*if the post has a featured image, take note of this in case of remap*/
|
1725 |
+
if ( '_thumbnail_id' == $meta_key ) {
|
1726 |
+
/*find this inserted id and use that instead.*/
|
1727 |
+
$inserted_id = $this->imported_post_id( intval( $meta_val ) );
|
1728 |
+
if ( $inserted_id ) {
|
1729 |
+
$meta_val = $inserted_id;
|
1730 |
+
}
|
1731 |
+
}
|
1732 |
+
/*update meta*/
|
1733 |
+
update_post_meta( $post_id, $meta_key, $meta_val );
|
1734 |
+
}
|
1735 |
+
}
|
1736 |
+
|
1737 |
+
if ( ! empty( $post_data['terms'] ) ) {
|
1738 |
+
$terms_to_set = array();
|
1739 |
+
foreach ( $post_data['terms'] as $term_slug => $terms ) {
|
1740 |
+
foreach ( $terms as $term ) {
|
1741 |
+
$taxonomy = $term['taxonomy'];
|
1742 |
+
if ( taxonomy_exists( $taxonomy ) ) {
|
1743 |
+
$term_exists = term_exists( $term['slug'], $taxonomy );
|
1744 |
+
$term_id = is_array( $term_exists ) ? $term_exists['term_id'] : $term_exists;
|
1745 |
+
if ( ! $term_id ) {
|
1746 |
+
if ( ! empty( $term['parent'] ) ) {
|
1747 |
+
/*see if we have imported this yet?*/
|
1748 |
+
$term['parent'] = $this->imported_term_id( $term['parent'] );
|
1749 |
+
}
|
1750 |
+
$term_id_tax_id = wp_insert_term( $term['name'], $taxonomy, $term );
|
1751 |
+
if ( ! is_wp_error( $term_id_tax_id ) ) {
|
1752 |
+
$term_id = $term_id_tax_id['term_id'];
|
1753 |
+
} else {
|
1754 |
+
// todo - error
|
1755 |
+
continue;
|
1756 |
+
}
|
1757 |
+
}
|
1758 |
+
/*set term_id on imported_term_id*/
|
1759 |
+
$this->imported_term_id( $term['term_id'], $term_id );
|
1760 |
+
|
1761 |
+
/*add the term meta.*/
|
1762 |
+
if ( $term_id && ! empty( $term['meta'] ) && is_array( $term['meta'] ) ) {
|
1763 |
+
foreach ( $term['meta'] as $meta_key => $meta_val ) {
|
1764 |
+
// we have to replace certain meta_key/meta_val
|
1765 |
+
// e.g. thumbnail id from woocommerce product categories.
|
1766 |
+
switch ( $meta_key ) {
|
1767 |
+
case 'thumbnail_id':
|
1768 |
+
if ( $new_meta_val = $this->imported_post_id( $meta_val ) ) {
|
1769 |
+
/*use this new id.*/
|
1770 |
+
$meta_val = $new_meta_val;
|
1771 |
+
}
|
1772 |
+
break;
|
1773 |
+
}
|
1774 |
+
update_term_meta( $term_id, $meta_key, $meta_val );
|
1775 |
+
}
|
1776 |
+
}
|
1777 |
+
$terms_to_set[ $taxonomy ][] = intval( $term_id );
|
1778 |
+
}
|
1779 |
+
}
|
1780 |
+
}
|
1781 |
+
foreach ( $terms_to_set as $tax => $ids ) {
|
1782 |
+
wp_set_post_terms( $post_id, $ids, $tax );
|
1783 |
+
}
|
1784 |
+
|
1785 |
+
if ( ( isset( $post_data['meta']['_elementor_data'] ) && ! empty( $post_data['meta']['_elementor_data'] ) ) ||
|
1786 |
+
( isset( $post_data['meta']['_elementor_css'] ) && ! ! empty( $post_data['meta']['_elementor_css'] ) )
|
1787 |
+
) {
|
1788 |
+
advanced_import_elementor()->elementor_post( $post_id );
|
1789 |
+
}
|
1790 |
+
|
1791 |
+
/*Gutentor*/
|
1792 |
+
$post = get_post( $post_id );
|
1793 |
+
$content = $post->post_content;
|
1794 |
+
if ( preg_match_all( '/data-gpid="(.*?)\" /', $content, $matches ) ) {
|
1795 |
+
foreach ( $matches[0] as $match_id => $string ) {
|
1796 |
+
$content = str_replace( $matches[0][ $match_id ], 'data-gpid="' . $post_id . '" ', $content );
|
1797 |
+
}
|
1798 |
+
}
|
1799 |
+
$post->post_content = $content;
|
1800 |
+
wp_update_post( $post );
|
1801 |
+
}
|
1802 |
+
}
|
1803 |
+
break;
|
1804 |
+
}
|
1805 |
+
|
1806 |
+
return true;
|
1807 |
+
}
|
1808 |
+
|
1809 |
+
/*Shortcode/Meta/Post Ids fixed start*/
|
1810 |
+
|
1811 |
+
/*
|
1812 |
+
* since 1.2.3
|
1813 |
+
* return the difference in length between two strings
|
1814 |
+
* */
|
1815 |
+
public function strlen_diff( $a, $b ) {
|
1816 |
+
return strlen( $b ) - strlen( $a );
|
1817 |
+
}
|
1818 |
+
|
1819 |
+
|
1820 |
+
/*
|
1821 |
+
* since 1.2.3
|
1822 |
+
* helper function to parse url, shortcode, post ids form provided content
|
1823 |
+
* * currently uses on meta and post content
|
1824 |
+
* */
|
1825 |
+
public function parse_shortcode_meta_content( $content ) {
|
1826 |
+
/*we have to format the post content. rewriting images and gallery stuff*/
|
1827 |
+
$replace = $this->imported_post_id();
|
1828 |
+
|
1829 |
+
/*filters urls for replace*/
|
1830 |
+
$urls_replace = array();
|
1831 |
+
foreach ( $replace as $key => $val ) {
|
1832 |
+
if ( $key && $val && ! is_numeric( $key ) && ! is_numeric( $val ) ) {
|
1833 |
+
$urls_replace[ $key ] = $val;
|
1834 |
+
}
|
1835 |
+
}
|
1836 |
+
/*replace image/file urls*/
|
1837 |
+
if ( $urls_replace ) {
|
1838 |
+
uksort( $urls_replace, array( &$this, 'strlen_diff' ) );
|
1839 |
+
foreach ( $urls_replace as $from_url => $to_url ) {
|
1840 |
+
$content = str_replace( $from_url, $to_url, $content );
|
1841 |
+
}
|
1842 |
+
}
|
1843 |
+
|
1844 |
+
/*gallery fixed*/
|
1845 |
+
if ( preg_match_all( '#\[gallery[^\]]*\]#', $content, $matches ) ) {
|
1846 |
+
foreach ( $matches[0] as $match_id => $string ) {
|
1847 |
+
if ( preg_match( '#ids="([^"]+)"#', $string, $ids_matches ) ) {
|
1848 |
+
$ids = explode( ',', $ids_matches[1] );
|
1849 |
+
foreach ( $ids as $key => $val ) {
|
1850 |
+
$new_id = $val ? $this->imported_post_id( $val ) : false;
|
1851 |
+
if ( ! $new_id ) {
|
1852 |
+
unset( $ids[ $key ] );
|
1853 |
+
} else {
|
1854 |
+
$ids[ $key ] = $new_id;
|
1855 |
+
}
|
1856 |
+
}
|
1857 |
+
$new_ids = implode( ',', $ids );
|
1858 |
+
$content = str_replace( $ids_matches[0], 'ids="' . $new_ids . '"', $content );
|
1859 |
+
}
|
1860 |
+
}
|
1861 |
+
}
|
1862 |
+
|
1863 |
+
/*contact form 7 id fixes.*/
|
1864 |
+
if ( preg_match_all( '#\[contact-form-7[^\]]*\]#', $content, $matches ) ) {
|
1865 |
+
foreach ( $matches[0] as $match_id => $string ) {
|
1866 |
+
if ( preg_match( '#id="(\d+)"#', $string, $id_match ) ) {
|
1867 |
+
$new_id = $this->imported_post_id( $id_match[1] );
|
1868 |
+
if ( $new_id ) {
|
1869 |
+
$content = str_replace( $id_match[0], 'id="' . $new_id . '"', $content );
|
1870 |
+
} else {
|
1871 |
+
/*no imported ID found. remove this entry.*/
|
1872 |
+
$content = str_replace( $matches[0], '(insert contact form here)', $content );
|
1873 |
+
}
|
1874 |
+
}
|
1875 |
+
}
|
1876 |
+
}
|
1877 |
+
|
1878 |
+
/*Gutentor*/
|
1879 |
+
if ( preg_match_all( '/\"pTaxTerm"(.*?)\]/', $content, $matches ) ) {
|
1880 |
+
foreach ( $matches[0] as $match_id => $string ) {
|
1881 |
+
if ( preg_match_all( '/\"value":(.*?)\}/', $string, $matches1 ) ) {
|
1882 |
+
foreach ( $matches1[0] as $match_id1 => $string1 ) {
|
1883 |
+
$new_id = $this->imported_term_id( $matches1[1][ $match_id1 ] );
|
1884 |
+
$content = str_replace( $string1, '"value":' . $new_id . '}', $content );
|
1885 |
+
}
|
1886 |
+
}
|
1887 |
+
}
|
1888 |
+
}
|
1889 |
+
if ( preg_match_all( '/\"e14TaxTerm"(.*?)\]/', $content, $matches ) ) {
|
1890 |
+
foreach ( $matches[0] as $match_id => $string ) {
|
1891 |
+
if ( preg_match_all( '/\"value":(.*?)\}/', $string, $matches1 ) ) {
|
1892 |
+
foreach ( $matches1[0] as $match_id1 => $string1 ) {
|
1893 |
+
$new_id = $this->imported_term_id( $matches1[1][ $match_id1 ] );
|
1894 |
+
$content = str_replace( $string1, '"value":' . $new_id . '}', $content );
|
1895 |
+
}
|
1896 |
+
}
|
1897 |
+
}
|
1898 |
+
}
|
1899 |
+
if ( preg_match_all( '/data-gpid="(.*?)\" /', $content, $matches ) ) {
|
1900 |
+
foreach ( $matches[0] as $match_id => $string ) {
|
1901 |
+
$new_id = $this->imported_post_id( $matches[1][ $match_id ] );
|
1902 |
+
$content = str_replace( $matches[0][ $match_id ], 'data-gpid="' . $new_id . '" ', $content );
|
1903 |
+
}
|
1904 |
+
}
|
1905 |
+
if ( preg_match_all( '/\"p4PostId"(.*?)\,/', $content, $matches ) ) {
|
1906 |
+
foreach ( $matches[0] as $match_id => $string ) {
|
1907 |
+
$new_id = $this->imported_post_id( $matches[1][ $match_id ] );
|
1908 |
+
$content = str_replace( $matches[0][ $match_id ], '"p4PostId":' . $new_id . ',', $content );
|
1909 |
+
}
|
1910 |
+
}
|
1911 |
+
return $content;
|
1912 |
+
}
|
1913 |
+
/*Shortcode/Meta/Post Ids fixed end*/
|
1914 |
+
|
1915 |
+
/*update parent page id for child page*/
|
1916 |
+
private function processpost_orphans() {
|
1917 |
+
|
1918 |
+
/*get post orphans to find it parent*/
|
1919 |
+
$orphans = $this->post_orphans();
|
1920 |
+
foreach ( $orphans as $original_post_id => $original_post_parent_id ) {
|
1921 |
+
if ( $original_post_parent_id ) {
|
1922 |
+
if ( $this->imported_post_id( $original_post_id ) && $this->imported_post_id( $original_post_parent_id ) ) {
|
1923 |
+
$post_data = array();
|
1924 |
+
$post_data['ID'] = $this->imported_post_id( $original_post_id );
|
1925 |
+
$post_data['post_parent'] = $this->imported_post_id( $original_post_parent_id );
|
1926 |
+
wp_update_post( $post_data );
|
1927 |
+
$this->post_orphans( $original_post_id, 0 ); /*ignore future*/
|
1928 |
+
}
|
1929 |
+
}
|
1930 |
+
}
|
1931 |
+
}
|
1932 |
+
|
1933 |
+
/*
|
1934 |
+
Process delayed post
|
1935 |
+
*/
|
1936 |
+
private function process_delayed_posts( $last_delay = false ) {
|
1937 |
+
|
1938 |
+
$this->log( esc_html__( 'Processing ', 'advanced-import' ) . count( $this->delay_posts, COUNT_RECURSIVE ) . esc_html__( 'delayed posts', 'advanced-import' ) );
|
1939 |
+
for ( $x = 1; $x < 4; $x ++ ) {
|
1940 |
+
foreach ( $this->delay_posts as $delayed_post_type => $delayed_post_data_s ) {
|
1941 |
+
foreach ( $delayed_post_data_s as $delayed_post_id => $delayed_post_data ) {
|
1942 |
+
|
1943 |
+
/*already processed*/
|
1944 |
+
if ( $this->imported_post_id( $delayed_post_data['post_id'] ) ) {
|
1945 |
+
$this->log( $x . esc_html__( '- Successfully processed ', 'advanced-import' ) . $delayed_post_type . esc_html__( ' ID ', 'advanced-import' ) . $delayed_post_data['post_id'] . esc_html__( ' previously.', 'advanced-import' ) );
|
1946 |
+
|
1947 |
+
/*already processed, remove it from delay_posts*/
|
1948 |
+
unset( $this->delay_posts[ $delayed_post_type ][ $delayed_post_id ] );
|
1949 |
+
$this->log( esc_html__( ' ( ', 'advanced-import' ) . count( $this->delay_posts, COUNT_RECURSIVE ) . esc_html__( ' delayed posts remain ) ', 'advanced-import' ) );
|
1950 |
+
}
|
1951 |
+
/*Process it*/
|
1952 |
+
elseif ( $this->process_import_single_post( $delayed_post_type, $delayed_post_data, $last_delay ) ) {
|
1953 |
+
$this->log( $x . esc_html__( ' - Successfully found delayed replacement for ', 'advanced-import' ) . $delayed_post_type . esc_html__( ' ID ', 'advanced-import' ) . $delayed_post_data['post_id'] );
|
1954 |
+
|
1955 |
+
/*successfully processed, remove it from delay_posts*/
|
1956 |
+
unset( $this->delay_posts[ $delayed_post_type ][ $delayed_post_id ] );
|
1957 |
+
$this->log( esc_html__( ' ( ', 'advanced-import' ) . count( $this->delay_posts, COUNT_RECURSIVE ) . esc_html__( ' delayed posts remain ) ', 'advanced-import' ) );
|
1958 |
+
} else {
|
1959 |
+
$this->log( $x . esc_html__( ' - Not found delayed replacement for ', 'advanced-import' ) . $delayed_post_type . esc_html__( ' ID ', 'advanced-import' ) . $delayed_post_data['post_id'] );
|
1960 |
+
}
|
1961 |
+
}
|
1962 |
+
}
|
1963 |
+
}
|
1964 |
+
}
|
1965 |
+
|
1966 |
+
/*Get file from url , download it and add to local*/
|
1967 |
+
private function import_image_and_file( $url, $post ) {
|
1968 |
+
|
1969 |
+
/*extract the file name and extension from the url*/
|
1970 |
+
$file_name = basename( $url );
|
1971 |
+
$local_file = ADVANCED_IMPORT_TEMP_UPLOADS . $file_name;
|
1972 |
+
$upload = false;
|
1973 |
+
|
1974 |
+
/*
|
1975 |
+
if file is already on local, return file information
|
1976 |
+
It means media is on local, while exporting media*/
|
1977 |
+
if ( is_file( $local_file ) && filesize( $local_file ) > 0 ) {
|
1978 |
+
require_once ABSPATH . 'wp-admin/includes/file.php';
|
1979 |
+
WP_Filesystem();
|
1980 |
+
global $wp_filesystem;
|
1981 |
+
$file_data = $wp_filesystem->get_contents( $local_file );
|
1982 |
+
$upload = wp_upload_bits( $file_name, 0, $file_data, $post['upload_date'] );
|
1983 |
+
if ( $upload['error'] ) {
|
1984 |
+
return new WP_Error( 'upload_dir_error', $upload['error'] );
|
1985 |
+
}
|
1986 |
+
}
|
1987 |
+
|
1988 |
+
/*if there is no file on local or error on local file need to fetch it*/
|
1989 |
+
if ( ! $upload || $upload['error'] ) {
|
1990 |
+
|
1991 |
+
/*get placeholder file in the upload dir with a unique, sanitized filename*/
|
1992 |
+
$upload = wp_upload_bits( $file_name, 0, '', $post['upload_date'] );
|
1993 |
+
if ( $upload['error'] ) {
|
1994 |
+
return new WP_Error( 'upload_dir_error', $upload['error'] );
|
1995 |
+
}
|
1996 |
+
|
1997 |
+
$max_size = (int) apply_filters( 'import_attachment_size_limit', 0 );
|
1998 |
+
|
1999 |
+
/*finally fetch the file from remote*/
|
2000 |
+
$response = wp_remote_get( $url );
|
2001 |
+
if ( is_array( $response ) && ! empty( $response['body'] ) && $response['response']['code'] == '200' ) {
|
2002 |
+
require_once ABSPATH . 'wp-admin/includes/file.php';
|
2003 |
+
$headers = $response['headers'];
|
2004 |
+
WP_Filesystem();
|
2005 |
+
global $wp_filesystem;
|
2006 |
+
$wp_filesystem->put_contents( $upload['file'], $response['body'] );
|
2007 |
+
} else {
|
2008 |
+
/*required to download file failed.*/
|
2009 |
+
wp_delete_file( $upload['file'] );
|
2010 |
+
return new WP_Error( 'import_file_error', esc_html__( 'Remote server did not respond', 'advanced-import' ) );
|
2011 |
+
}
|
2012 |
+
|
2013 |
+
$file_size = filesize( $upload['file'] );
|
2014 |
+
|
2015 |
+
/*check for size*/
|
2016 |
+
if ( isset( $headers['content-length'] ) && $file_size != $headers['content-length'] ) {
|
2017 |
+
wp_delete_file( $upload['file'] );
|
2018 |
+
return new WP_Error( 'import_file_error', esc_html__( 'Remote file is incorrect size', 'advanced-import' ) );
|
2019 |
+
}
|
2020 |
+
|
2021 |
+
/*if file size is 0*/
|
2022 |
+
if ( 0 == $file_size ) {
|
2023 |
+
wp_delete_file( $upload['file'] );
|
2024 |
+
return new WP_Error( 'import_file_error', esc_html__( 'Zero size file downloaded', 'advanced-import' ) );
|
2025 |
+
}
|
2026 |
+
|
2027 |
+
/*if file is too large*/
|
2028 |
+
if ( ! empty( $max_size ) && $file_size > $max_size ) {
|
2029 |
+
wp_delete_file( $upload['file'] );
|
2030 |
+
return new WP_Error( 'import_file_error', sprintf( esc_html__( 'Remote file is too large, limit is %s', 'advanced-import' ), size_format( $max_size ) ) );
|
2031 |
+
}
|
2032 |
+
}
|
2033 |
+
|
2034 |
+
/*keep track of the old and new urls so we can substitute them later*/
|
2035 |
+
$this->imported_post_id( $url, $upload['url'] );
|
2036 |
+
$this->imported_post_id( $post['guid'], $upload['url'] );
|
2037 |
+
|
2038 |
+
/*keep track of the destination if the remote url is redirected somewhere else*/
|
2039 |
+
if ( isset( $headers['x-final-location'] ) && $headers['x-final-location'] != $url ) {
|
2040 |
+
$this->imported_post_id( $headers['x-final-location'], $upload['url'] );
|
2041 |
+
}
|
2042 |
+
return $upload;
|
2043 |
+
}
|
2044 |
+
|
2045 |
+
/*
|
2046 |
+
Replace necessary ID by Local imported ID
|
2047 |
+
*/
|
2048 |
+
private function replace_old_id_to_new( $option_value, $index_key = false ) {
|
2049 |
+
|
2050 |
+
/*Post IDS*/
|
2051 |
+
$replace_post_ids = apply_filters(
|
2052 |
+
'advanced_import_replace_post_ids',
|
2053 |
+
array(
|
2054 |
+
'page_id',
|
2055 |
+
'post_id',
|
2056 |
+
'image_id',
|
2057 |
+
'selectpage',
|
2058 |
+
'page_on_front',
|
2059 |
+
'page_for_posts',
|
2060 |
+
'first_page_id',
|
2061 |
+
'second_page_id',
|
2062 |
+
/*woocommerce pages*/
|
2063 |
+
'woocommerce_shop_page_id',
|
2064 |
+
'woocommerce_cart_page_id',
|
2065 |
+
'woocommerce_checkout_page_id',
|
2066 |
+
'woocommerce_pay_page_id',
|
2067 |
+
'woocommerce_thanks_page_id',
|
2068 |
+
'woocommerce_myaccount_page_id',
|
2069 |
+
'woocommerce_edit_address_page_id',
|
2070 |
+
'woocommerce_view_order_page_id',
|
2071 |
+
'woocommerce_terms_page_id',
|
2072 |
+
/*gutentor*/
|
2073 |
+
'wp_block_id',
|
2074 |
+
)
|
2075 |
+
);
|
2076 |
+
|
2077 |
+
/*Terms IDS*/
|
2078 |
+
$replace_term_ids = apply_filters(
|
2079 |
+
'advanced_import_replace_term_ids',
|
2080 |
+
array(
|
2081 |
+
'cat_id',
|
2082 |
+
'nav_menu',
|
2083 |
+
'online-shop-feature-product-cat',
|
2084 |
+
'online_shop_featured_cats',
|
2085 |
+
'online_shop_wc_product_cat',
|
2086 |
+
'online_shop_wc_product_tag',
|
2087 |
+
)
|
2088 |
+
);
|
2089 |
+
|
2090 |
+
/*replace terms in keys*/
|
2091 |
+
|
2092 |
+
if ( is_array( $option_value ) ) {
|
2093 |
+
foreach ( $option_value as $key => $replace_old_value ) {
|
2094 |
+
|
2095 |
+
if ( is_array( $replace_old_value ) && ! is_null( $replace_old_value ) ) {
|
2096 |
+
$option_value[ $key ] = $this->replace_old_id_to_new( $replace_old_value );
|
2097 |
+
} elseif ( $this->isJson( $replace_old_value ) && is_string( $replace_old_value ) && ! is_null( $replace_old_value ) ) {
|
2098 |
+
$value_array = json_decode( $replace_old_value, true );
|
2099 |
+
if ( is_array( $value_array ) ) {
|
2100 |
+
$option_value[ $key ] = wp_json_encode( $this->replace_old_id_to_new( $value_array ) );
|
2101 |
+
} else {
|
2102 |
+
if ( in_array( $key, $replace_post_ids ) && $key !== 0 ) {
|
2103 |
+
$new_id = $this->imported_post_id( $replace_old_value );
|
2104 |
+
if ( $new_id ) {
|
2105 |
+
$option_value[ $key ] = $new_id;
|
2106 |
+
}
|
2107 |
+
} elseif ( in_array( $key, $replace_term_ids ) && $key !== 0 ) {
|
2108 |
+
$new_id = $this->imported_term_id( $replace_old_value );
|
2109 |
+
if ( $new_id ) {
|
2110 |
+
$option_value[ $key ] = $new_id;
|
2111 |
+
}
|
2112 |
+
} else {
|
2113 |
+
$option_value[ $key ] = $replace_old_value;
|
2114 |
+
}
|
2115 |
+
}
|
2116 |
+
} else {
|
2117 |
+
|
2118 |
+
if ( in_array( $key, $replace_post_ids ) && $key !== 0 ) {
|
2119 |
+
|
2120 |
+
$new_id = $this->imported_post_id( $replace_old_value );
|
2121 |
+
if ( ! $new_id ) {
|
2122 |
+
/**/
|
2123 |
+
} else {
|
2124 |
+
$option_value[ $key ] = $new_id;
|
2125 |
+
}
|
2126 |
+
} elseif ( in_array( $key, $replace_term_ids ) && $key !== 0 ) {
|
2127 |
+
$new_id = $this->imported_term_id( $replace_old_value );
|
2128 |
+
if ( $new_id ) {
|
2129 |
+
$option_value[ $key ] = $new_id;
|
2130 |
+
}
|
2131 |
+
} else {
|
2132 |
+
$option_value[ $key ] = $replace_old_value;
|
2133 |
+
}
|
2134 |
+
}
|
2135 |
+
}
|
2136 |
+
} elseif ( is_numeric( $option_value ) && $index_key ) {
|
2137 |
+
|
2138 |
+
if ( in_array( $index_key, $replace_post_ids ) && $index_key !== 0 ) {
|
2139 |
+
|
2140 |
+
$new_id = $this->imported_post_id( $option_value );
|
2141 |
+
if ( ! $new_id ) {
|
2142 |
+
/**/
|
2143 |
+
} else {
|
2144 |
+
$option_value = $new_id;
|
2145 |
+
}
|
2146 |
+
} elseif ( in_array( $index_key, $replace_term_ids ) && $index_key !== 0 ) {
|
2147 |
+
$new_id = $this->imported_term_id( $option_value );
|
2148 |
+
if ( $new_id ) {
|
2149 |
+
$option_value = $new_id;
|
2150 |
+
}
|
2151 |
+
}
|
2152 |
+
}
|
2153 |
+
|
2154 |
+
return $option_value;
|
2155 |
+
}
|
2156 |
+
|
2157 |
+
/*
|
2158 |
+
* Callback function to importing widgets data
|
2159 |
+
* all widgets data is imported from here
|
2160 |
+
* return mix
|
2161 |
+
* */
|
2162 |
+
private function import_content_widgets_data() {
|
2163 |
+
$import_widget_data = $this->get_widgets_json();
|
2164 |
+
$import_widget_positions = $import_widget_data['widget_positions'];
|
2165 |
+
$import_widget_options = $import_widget_data['widget_options'];
|
2166 |
+
|
2167 |
+
/* get sidebars_widgets */
|
2168 |
+
$widget_positions = get_option( 'sidebars_widgets' );
|
2169 |
+
if ( ! is_array( $widget_positions ) ) {
|
2170 |
+
$widget_positions = array();
|
2171 |
+
}
|
2172 |
+
|
2173 |
+
foreach ( $import_widget_options as $widget_name => $widget_options ) {
|
2174 |
+
|
2175 |
+
/*replace $widget_options elements with updated imported entries.*/
|
2176 |
+
foreach ( $widget_options as $widget_option_id => $widget_option ) {
|
2177 |
+
$widget_options[ $widget_option_id ] = $this->replace_old_id_to_new( $widget_option, $widget_option_id );
|
2178 |
+
}
|
2179 |
+
$existing_options = get_option( 'widget_' . $widget_name, array() );
|
2180 |
+
if ( ! is_array( $existing_options ) ) {
|
2181 |
+
$existing_options = array();
|
2182 |
+
}
|
2183 |
+
$new_options = $widget_options + $existing_options;
|
2184 |
+
|
2185 |
+
$new_options = apply_filters( 'advanced_import_new_options', $new_options );
|
2186 |
+
|
2187 |
+
update_option( 'widget_' . $widget_name, $new_options );
|
2188 |
+
}
|
2189 |
+
|
2190 |
+
$sidebars_widgets = array_merge( $widget_positions, $import_widget_positions );
|
2191 |
+
$sidebars_widgets = apply_filters( 'advanced_import_sidebars_widgets', $sidebars_widgets, $this );
|
2192 |
+
update_option( 'sidebars_widgets', $sidebars_widgets );
|
2193 |
+
|
2194 |
+
return true;
|
2195 |
+
|
2196 |
+
}
|
2197 |
+
|
2198 |
+
/*check if string is json*/
|
2199 |
+
function isJson( $string ) {
|
2200 |
+
$test_json = @json_decode( $string, true );
|
2201 |
+
if ( is_array( $test_json ) ) {
|
2202 |
+
return true;
|
2203 |
+
}
|
2204 |
+
return false;
|
2205 |
+
}
|
2206 |
+
|
2207 |
+
/*
|
2208 |
+
callback function to importing menus and options data
|
2209 |
+
* all menus and import data is imported from here
|
2210 |
+
* return mix
|
2211 |
+
* */
|
2212 |
+
public function import_menu_and_options() {
|
2213 |
+
|
2214 |
+
/*final wrap up of delayed posts.*/
|
2215 |
+
$this->process_delayed_posts( true );
|
2216 |
+
|
2217 |
+
/*it includes options and menu data*/
|
2218 |
+
$theme_options = $this->get_theme_options_json();
|
2219 |
+
|
2220 |
+
/*options data*/
|
2221 |
+
$custom_options = $theme_options['options'];
|
2222 |
+
|
2223 |
+
/*menu data*/
|
2224 |
+
$menu_ids = $theme_options['menu'];
|
2225 |
+
|
2226 |
+
/*we also want to update the widget area manager options.*/
|
2227 |
+
if ( is_array( $custom_options ) ) {
|
2228 |
+
foreach ( $custom_options as $option => $value ) {
|
2229 |
+
/*replace old entries with updated imported entries.*/
|
2230 |
+
$value = $this->replace_old_id_to_new( $value, $option );
|
2231 |
+
|
2232 |
+
/*we have to update widget page numbers with imported page numbers.*/
|
2233 |
+
if (
|
2234 |
+
preg_match( '#(wam__position_)(\d+)_#', $option, $matches ) ||
|
2235 |
+
preg_match( '#(wam__area_)(\d+)_#', $option, $matches )
|
2236 |
+
) {
|
2237 |
+
$new_page_id = $this->imported_post_id( $matches[2] );
|
2238 |
+
if ( $new_page_id ) {
|
2239 |
+
// we have a new page id for this one. import the new setting value.
|
2240 |
+
$option = str_replace( $matches[1] . $matches[2] . '_', $matches[1] . $new_page_id . '_', $option );
|
2241 |
+
}
|
2242 |
+
} elseif ( $value && ! empty( $value['custom_logo'] ) ) {
|
2243 |
+
$new_logo_id = $this->imported_post_id( $value['custom_logo'] );
|
2244 |
+
if ( $new_logo_id ) {
|
2245 |
+
$value['custom_logo'] = $new_logo_id;
|
2246 |
+
}
|
2247 |
+
}
|
2248 |
+
/** For Gutentor */
|
2249 |
+
elseif ( strpos( $option, 'gutentor-cat' ) !== false ) {
|
2250 |
+
$cat_id = substr( $option, strrpos( $option, '-' ) + 1 );
|
2251 |
+
if ( 'child' !== $cat_id ) {
|
2252 |
+
$new_cat_id = $this->imported_term_id( $cat_id );
|
2253 |
+
$option = str_replace( $cat_id, $new_cat_id, $option );
|
2254 |
+
}
|
2255 |
+
}
|
2256 |
+
update_option( $option, $value );
|
2257 |
+
}
|
2258 |
+
}
|
2259 |
+
|
2260 |
+
/*
|
2261 |
+
Options completed
|
2262 |
+
Menu Start*/
|
2263 |
+
$save = array();
|
2264 |
+
foreach ( $menu_ids as $menu_id => $term_id ) {
|
2265 |
+
$new_term_id = $this->imported_term_id( $term_id );
|
2266 |
+
if ( $new_term_id ) {
|
2267 |
+
$save[ $menu_id ] = $new_term_id;
|
2268 |
+
}
|
2269 |
+
}
|
2270 |
+
|
2271 |
+
if ( $save ) {
|
2272 |
+
set_theme_mod( 'nav_menu_locations', array_map( 'absint', $save ) );
|
2273 |
+
}
|
2274 |
+
|
2275 |
+
global $wp_rewrite;
|
2276 |
+
$wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
|
2277 |
+
update_option( 'rewrite_rules', false );
|
2278 |
+
$wp_rewrite->flush_rules( true );
|
2279 |
+
|
2280 |
+
return true;
|
2281 |
+
}
|
2282 |
+
|
2283 |
+
public function log( $message ) {
|
2284 |
+
$this->logs[] = $message;
|
2285 |
+
}
|
2286 |
+
|
2287 |
+
|
2288 |
+
public function error( $message ) {
|
2289 |
+
$this->logs[] = esc_html__( 'ERROR!!!! ', 'advanced-import' ) . $message;
|
2290 |
+
}
|
2291 |
+
|
2292 |
+
/*
|
2293 |
+
Callback function to completed
|
2294 |
+
* Show Completed Message
|
2295 |
+
* */
|
2296 |
+
public function complete_screen() {
|
2297 |
+
|
2298 |
+
/*check for security*/
|
2299 |
+
if ( ! current_user_can( 'upload_files' ) ) {
|
2300 |
+
wp_send_json_error(
|
2301 |
+
array(
|
2302 |
+
'message' => esc_html__( 'Sorry, you are not allowed to install demo on this site.', 'advanced-import' ),
|
2303 |
+
)
|
2304 |
+
);
|
2305 |
+
}
|
2306 |
+
|
2307 |
+
require_once ABSPATH . 'wp-admin/includes/file.php';
|
2308 |
+
WP_Filesystem();
|
2309 |
+
global $wp_filesystem;
|
2310 |
+
$wp_filesystem->rmdir( ADVANCED_IMPORT_TEMP, true );
|
2311 |
+
|
2312 |
+
set_theme_mod( 'advanced_import_setup_complete', time() );
|
2313 |
+
/*delete_transient();*/
|
2314 |
+
delete_transient( 'content.json' );
|
2315 |
+
delete_transient( 'widgets.json' );
|
2316 |
+
delete_transient( 'options.json' );
|
2317 |
+
|
2318 |
+
$message = '<div class="ai-notification-title">';
|
2319 |
+
$message .= '<p>' . esc_html__( 'Your Website is Ready!', 'advanced-import' ) . '</p>';
|
2320 |
+
$message .= '<p class="ai-actions-buttons">' . sprintf( esc_html__( ' %1$sVisit your Site%2$s ', 'advanced-import' ), '<a target="_blank" href="' . esc_url( home_url( '/' ) ) . '">', '</a>' ) . '</p>';
|
2321 |
+
$message .= '<p>' . sprintf( esc_html__( 'Congratulations! All Data is imported successfully. From %1$s WordPress dashboard%2$s you can make changes and modify any of the default content to suit your needs.', 'advanced-import' ), '<a href="' . esc_url( admin_url() ) . '">', '</a>' ) . '</p>';
|
2322 |
+
$message .= '</div>';
|
2323 |
+
|
2324 |
+
apply_filters( 'advanced_import_complete_message', $message );
|
2325 |
+
|
2326 |
+
do_action( 'advanced_import_before_complete_screen' );
|
2327 |
+
echo $message;
|
2328 |
+
do_action( 'advanced_import_after_complete_screen' );
|
2329 |
+
exit;
|
2330 |
+
}
|
2331 |
+
|
2332 |
+
|
2333 |
+
/*
|
2334 |
+
callback function for wp_ajax_install_plugin
|
2335 |
+
* Install plugin
|
2336 |
+
* */
|
2337 |
+
function install_plugin() {
|
2338 |
+
|
2339 |
+
/*check for security*/
|
2340 |
+
if ( ! current_user_can( 'install_plugins' ) ) {
|
2341 |
+
$status['errorMessage'] = __( 'Sorry, you are not allowed to install plugins on this site.', 'advanced-import' );
|
2342 |
+
wp_send_json_error( $status );
|
2343 |
+
}
|
2344 |
+
|
2345 |
+
if ( empty( $_POST['plugin'] ) || empty( $_POST['slug'] ) ) {
|
2346 |
+
wp_send_json_error(
|
2347 |
+
array(
|
2348 |
+
'slug' => '',
|
2349 |
+
'errorCode' => 'no_plugin_specified',
|
2350 |
+
'errorMessage' => __( 'No plugin specified.', 'advanced-import' ),
|
2351 |
+
)
|
2352 |
+
);
|
2353 |
+
}
|
2354 |
+
|
2355 |
+
$slug = sanitize_key( wp_unslash( $_POST['slug'] ) );
|
2356 |
+
$plugin = plugin_basename( sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) );
|
2357 |
+
|
2358 |
+
if ( is_plugin_active_for_network( $plugin ) || is_plugin_active( $plugin ) ) {
|
2359 |
+
// Plugin is activated
|
2360 |
+
wp_send_json_success();
|
2361 |
+
|
2362 |
+
}
|
2363 |
+
$status = array(
|
2364 |
+
'install' => 'plugin',
|
2365 |
+
'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ),
|
2366 |
+
);
|
2367 |
+
|
2368 |
+
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
2369 |
+
include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
|
2370 |
+
|
2371 |
+
// Looks like a plugin is installed, but not active.
|
2372 |
+
if ( file_exists( WP_PLUGIN_DIR . '/' . $slug ) ) {
|
2373 |
+
$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
|
2374 |
+
$status['plugin'] = $plugin;
|
2375 |
+
$status['pluginName'] = $plugin_data['Name'];
|
2376 |
+
|
2377 |
+
if ( current_user_can( 'activate_plugin', $plugin ) && is_plugin_inactive( $plugin ) ) {
|
2378 |
+
$result = activate_plugin( $plugin );
|
2379 |
+
|
2380 |
+
if ( is_wp_error( $result ) ) {
|
2381 |
+
$status['errorCode'] = $result->get_error_code();
|
2382 |
+
$status['errorMessage'] = $result->get_error_message();
|
2383 |
+
wp_send_json_error( $status );
|
2384 |
+
}
|
2385 |
+
|
2386 |
+
wp_send_json_success( $status );
|
2387 |
+
}
|
2388 |
+
}
|
2389 |
+
|
2390 |
+
$api = plugins_api(
|
2391 |
+
'plugin_information',
|
2392 |
+
array(
|
2393 |
+
'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ),
|
2394 |
+
'fields' => array(
|
2395 |
+
'sections' => false,
|
2396 |
+
),
|
2397 |
+
)
|
2398 |
+
);
|
2399 |
+
|
2400 |
+
if ( is_wp_error( $api ) ) {
|
2401 |
+
$status['errorMessage'] = $api->get_error_message();
|
2402 |
+
wp_send_json_error( $status );
|
2403 |
+
}
|
2404 |
+
|
2405 |
+
$status['pluginName'] = $api->name;
|
2406 |
+
|
2407 |
+
$skin = new WP_Ajax_Upgrader_Skin();
|
2408 |
+
$upgrader = new Plugin_Upgrader( $skin );
|
2409 |
+
$result = $upgrader->install( $api->download_link );
|
2410 |
+
|
2411 |
+
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
|
2412 |
+
$status['debug'] = $skin->get_upgrade_messages();
|
2413 |
+
}
|
2414 |
+
|
2415 |
+
if ( is_wp_error( $result ) ) {
|
2416 |
+
$status['errorCode'] = $result->get_error_code();
|
2417 |
+
$status['errorMessage'] = $result->get_error_message();
|
2418 |
+
wp_send_json_error( $status );
|
2419 |
+
} elseif ( is_wp_error( $skin->result ) ) {
|
2420 |
+
$status['errorCode'] = $skin->result->get_error_code();
|
2421 |
+
$status['errorMessage'] = $skin->result->get_error_message();
|
2422 |
+
wp_send_json_error( $status );
|
2423 |
+
} elseif ( $skin->get_errors()->get_error_code() ) {
|
2424 |
+
$status['errorMessage'] = $skin->get_error_messages();
|
2425 |
+
wp_send_json_error( $status );
|
2426 |
+
} elseif ( is_null( $result ) ) {
|
2427 |
+
require_once ABSPATH . 'wp-admin/includes/file.php';
|
2428 |
+
WP_Filesystem();
|
2429 |
+
global $wp_filesystem;
|
2430 |
+
|
2431 |
+
$status['errorCode'] = 'unable_to_connect_to_filesystem';
|
2432 |
+
$status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.', 'advanced-import' );
|
2433 |
+
|
2434 |
+
// Pass through the error from WP_Filesystem if one was raised.
|
2435 |
+
if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
|
2436 |
+
$status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() );
|
2437 |
+
}
|
2438 |
+
|
2439 |
+
wp_send_json_error( $status );
|
2440 |
+
}
|
2441 |
+
|
2442 |
+
$install_status = install_plugin_install_status( $api );
|
2443 |
+
|
2444 |
+
if ( current_user_can( 'activate_plugin', $install_status['file'] ) && is_plugin_inactive( $install_status['file'] ) ) {
|
2445 |
+
$result = activate_plugin( $install_status['file'] );
|
2446 |
+
|
2447 |
+
if ( is_wp_error( $result ) ) {
|
2448 |
+
$status['errorCode'] = $result->get_error_code();
|
2449 |
+
$status['errorMessage'] = $result->get_error_message();
|
2450 |
+
wp_send_json_error( $status );
|
2451 |
+
}
|
2452 |
+
}
|
2453 |
+
|
2454 |
+
wp_send_json_success( $status );
|
2455 |
+
}
|
2456 |
+
|
2457 |
+
/*
|
2458 |
+
callback function to current_screen
|
2459 |
+
* Add help Text
|
2460 |
+
* @param $screen object screen
|
2461 |
+
* */
|
2462 |
+
public function help_tabs( $screen ) {
|
2463 |
+
if ( ! is_array( $this->hook_suffix ) || ! in_array( $screen->base, $this->hook_suffix ) ) {
|
2464 |
+
return;
|
2465 |
+
}
|
2466 |
+
$current_url = advanced_import_current_url();
|
2467 |
+
|
2468 |
+
$screen->add_help_tab(
|
2469 |
+
array(
|
2470 |
+
'id' => 'ai_help_tab_info',
|
2471 |
+
'title' => __( 'Information', 'advanced-import' ),
|
2472 |
+
'content' =>
|
2473 |
+
'<h2>' . __( 'Information', 'advanced-import' ) . '</h2>' .
|
2474 |
+
'<p>' . sprintf(
|
2475 |
+
__( 'Export you content via, <a href="%s" target="_blank">Advanced Export</a>. You can import export content, widget, customizer and media files too.', 'advanced-import' ),
|
2476 |
+
'https://wordpress.org/plugins/advanced-export/'
|
2477 |
+
) . '</p>' .
|
2478 |
+
'<p>' . sprintf(
|
2479 |
+
__( 'The zip file exported via <a href="%1$s" target="_blank">Advanced Export</a>. can be imported from this plugin <a href="%2$s">Advanced Import</a>.', 'advanced-import' ),
|
2480 |
+
'https://wordpress.org/support/plugin/advanced-export',
|
2481 |
+
'https://wordpress.org/support/plugin/advanced-import'
|
2482 |
+
) . '</p>' .
|
2483 |
+
'<p><a href="' . 'https://wordpress.org/support/plugin/advanced-import' . '" class="button button-primary" target="_blank">' . __( 'Community forum', 'advanced-import' ) . '</a> <a href="' . 'https://www.addonspress.com/' . '" class="button" target="_blank">' . __( 'Author', 'advanced-import' ) . '</a></p>',
|
2484 |
+
)
|
2485 |
+
);
|
2486 |
+
|
2487 |
+
$reset_url = wp_nonce_url(
|
2488 |
+
add_query_arg( 'ai_reset_wordpress', 'true', $current_url ),
|
2489 |
+
'ai_reset_wordpress',
|
2490 |
+
'ai_reset_wordpress_nonce'
|
2491 |
+
);
|
2492 |
+
$screen->add_help_tab(
|
2493 |
+
array(
|
2494 |
+
'id' => 'ai_help_tab_reset',
|
2495 |
+
'title' => __( 'Reset wizard', 'advanced-import' ),
|
2496 |
+
'content' =>
|
2497 |
+
'<h2>' . __( '<strong>WordPress Reset</strong>', 'advanced-import' ) . '</h2>' .
|
2498 |
+
'<p>' . __( 'If no important data on your site. You can reset the WordPress back to default again!', 'advanced-import' ) . '</p>' .
|
2499 |
+
'<p class="submit"><a href="' . esc_url( $reset_url ) . '" class="button button-primary ai-wp-reset">' . __( 'Run the Reset Wizard', 'advanced-import' ) . '</a></p>',
|
2500 |
+
)
|
2501 |
+
);
|
2502 |
+
|
2503 |
+
$screen->set_help_sidebar(
|
2504 |
+
'<p><strong>' . __( 'More information:', 'advanced-import' ) . '</strong></p>' .
|
2505 |
+
'<p><a href="' . 'https://wordpress.org/plugins/advanced-export/' . '" target="_blank">' . __( 'Advanced Export', 'advanced-import' ) . '</a></p>' .
|
2506 |
+
'<p><a href="' . 'https://wordpress.org/plugins/advanced-import/' . '" target="_blank">' . __( 'Advanced Import', 'advanced-import' ) . '</a></p>'
|
2507 |
+
);
|
2508 |
+
}
|
|
|
2509 |
}
|
2510 |
|
2511 |
/**
|
2518 |
* @since 1.0.0
|
2519 |
*/
|
2520 |
function advanced_import_admin() {
|
2521 |
+
return Advanced_Import_Admin::instance();
|
2522 |
}
|
advanced-import.php
CHANGED
@@ -14,7 +14,7 @@ if ( ! defined( 'WPINC' ) ) {
|
|
14 |
* Plugin Name: Advanced Import
|
15 |
* Plugin URI: https://addonspress.com/item/advanced-import
|
16 |
* Description: Easily import demo data starter site packages or Migrate your site data
|
17 |
-
* Version: 1.
|
18 |
* Author: AddonsPress
|
19 |
* Author URI: https://addonspress.com/
|
20 |
* License: GPL-2.0+
|
@@ -24,7 +24,7 @@ if ( ! defined( 'WPINC' ) ) {
|
|
24 |
*/
|
25 |
|
26 |
/*Define Constants for this plugin*/
|
27 |
-
define( 'ADVANCED_IMPORT_VERSION', '1.
|
28 |
define( 'ADVANCED_IMPORT_PLUGIN_NAME', 'advanced-import' );
|
29 |
define( 'ADVANCED_IMPORT_PATH', plugin_dir_path( __FILE__ ) );
|
30 |
define( 'ADVANCED_IMPORT_URL', plugin_dir_url( __FILE__ ) );
|
14 |
* Plugin Name: Advanced Import
|
15 |
* Plugin URI: https://addonspress.com/item/advanced-import
|
16 |
* Description: Easily import demo data starter site packages or Migrate your site data
|
17 |
+
* Version: 1.3.0
|
18 |
* Author: AddonsPress
|
19 |
* Author URI: https://addonspress.com/
|
20 |
* License: GPL-2.0+
|
24 |
*/
|
25 |
|
26 |
/*Define Constants for this plugin*/
|
27 |
+
define( 'ADVANCED_IMPORT_VERSION', '1.3.0' );
|
28 |
define( 'ADVANCED_IMPORT_PLUGIN_NAME', 'advanced-import' );
|
29 |
define( 'ADVANCED_IMPORT_PATH', plugin_dir_path( __FILE__ ) );
|
30 |
define( 'ADVANCED_IMPORT_URL', plugin_dir_url( __FILE__ ) );
|
assets/css/advanced-import-admin.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.ai-body{margin:40px 15px 0}.ai-body img{max-width:100%;height:auto}.ai-header{margin-bottom:30px;padding:20px;background:#fff;border-left-color:#46b450;border-width:0 0 0 4px;border-style:solid;box-shadow:0 1px 1px rgba(0,0,0,.04)}.ai-header h1{margin-top:0}.ai-header p{margin-bottom:0}.ai-filter-tabs{display:flex;align-items:center;background:#fff;padding:10px 20px;margin-bottom:20px;margin-top:20px;box-shadow:0 1px 1px rgba(0,0,0,.04);border:1px solid #e5e5e5}.ai-filter-tabs ul{margin-top:0;margin-bottom:0}.ai-filter-tabs ul li{font-size:14px;cursor:pointer;font-weight:600}.ai-count{background:#ca4a1f;display:inline-block;padding:2px 10px;border-radius:50px;margin-left:5px;color:#fff;font-size:12px}.ai-types{display:flex}.ai-types li{margin:0 5px;padding:5px}.ai-form-file-import{cursor:pointer;background:#efefef;padding:8px 25px;margin:0;border-radius:3px;background:#0085ba;border-color:#0073aa #006799 #006799;box-shadow:0 1px 0 #006799;color:#fff;text-decoration:none;text-shadow:0 -1px 1px #006799,1px 0 1px #006799,0 1px 1px #006799,-1px 0 1px #006799}.ai-form-file-import:focus,.ai-form-file-import:hover{background:#0073aa;border-color:#006799}.ai-filter-content{background:#f8f8f8;display:flex}.ai-filter-content.hidden{display:none}.ai-sidebar{flex-basis:250px;min-width:270px;background:#f9f9f9;color:#999;padding-top:30px;border-right:1px solid #ddd;box-shadow:10px 0 10px -3px rgba(0,0,0,.1)}.ai-import-available-categories{margin-top:20px;overflow-y:auto;overflow-x:hidden;max-height:calc(100% - 23px)}.ai-import-available-categories h3{padding-left:30px;padding-right:30px}.ai-import-available-categories ul{margin-top:20px}.ai-import-available-categories ul li{cursor:pointer;font-weight:600;font-size:14px;padding:15px 30px;position:relative;z-index:1;margin:0;border-bottom:1px solid #f1f1f1}.ai-import-available-categories ul li:after{position:absolute;left:0;top:0;background:#f1f1f1;width:0;content:'';height:100%;z-index:-1;transition:all .5s ease-in-out 0s}.ai-import-available-categories ul li:focus,.ai-import-available-categories ul li:hover{border-color:#f1f1f1;color:#444}.ai-import-available-categories ul li span{float:right}.ai-import-available-categories ul li.ai-filter-btn-active{color:#444;border-color:#f1f1f1}.ai-import-available-categories ul li.ai-filter-btn-active:focus,.ai-import-available-categories ul li.ai-filter-btn-active:hover{border-color:#f1f1f1}.ai-import-available-categories ul li.ai-filter-btn-active:focus:after,.ai-import-available-categories ul li.ai-filter-btn-active:hover:after{width:100%}.ai-import-available-categories ul li.ai-filter-btn-active:after{width:100%;transition:all .5s ease-in-out 0s}.ai-search-control{margin-left:auto;margin-right:20px;width:200px}.ai-search-control .ai-search-filter{padding-left:10px;padding-right:10px}.ai-search-filter{height:36px;width:100%}.ai-filter-content-wrapper{flex-basis:calc(100% - 250px);padding:15px}.ai-item-preview{position:relative;z-index:1;line-height:0;border-top-right-radius:4px;border-top-left-radius:4px;background:#fff}.ai-item-preview:after{content:'';width:100%;height:100%;position:absolute;left:0;top:0;box-shadow:0 -130px 70px -42px rgba(0,0,0,.8) inset;z-index:2;opacity:0;visibility:hidden;transition:all .5s ease-in-out 0s}.ai-item-preview .ai-item-screenshot{border-top-right-radius:4px;border-top-left-radius:4px;overflow:hidden}.ai-item-preview .ai-author-info{position:absolute;left:0;right:0;bottom:-100px;width:100%;z-index:3;margin:0;padding:20px;color:#fff;font-size:16px;opacity:0;visibility:hidden;transition:opacity .5s ease-in-out 0s,visibility .9s ease-in-out 0s}.ai-item-preview .ai-details{position:absolute;left:0;right:0;margin:0 auto;top:50%;width:130px;margin:0 auto;background:rgba(0,0,0,.8);height:40px;line-height:40px;text-align:center;z-index:5;font-size:15px;font-weight:600;color:#fff;opacity:0;visibility:hidden;transition:all .5s ease-in-out 0s;transform:translateY(-50%)}.ai-item-preview .ai-premium-label{position:absolute;right:-10px;top:20px;background:#ca4a1f;display:block;z-index:3;line-height:16px;padding:10px 20px;height:16px;font-weight:600;color:#fff}.ai-item-preview .ai-premium-label:before{position:absolute;left:-18px;top:0;height:0;width:0;content:"";border-top:18px solid #ca4a1f;border-left:18px solid transparent;border-bottom:18px solid #ca4a1f}.ai-item-preview .ai-premium-label:after{position:absolute;right:0;content:"";bottom:-10px;width:0;height:0;border-top:10px solid #ca4a1f;border-right:10px solid transparent}.ai-item{display:inline-block;max-width:calc(100% / 3 - 40px);margin:15px;box-shadow:0 2px 15px -3px rgba(0,0,0,.2)}@media (min-width:1600px){.ai-item{max-width:calc(100% / 4 - 40px)}}.ai-item:hover .ai-item-preview:after{visibility:visible;opacity:1}.ai-item:hover .ai-author-info{bottom:10px;visibility:visible;opacity:1}.ai-item:hover .ai-details,.ai-item:hover .ai-item-footer-actions{visibility:visible;opacity:1}.ai-item-footer{padding:20px;background:#fff;position:relative;border-bottom-right-radius:4px;border-bottom-left-radius:4px}.ai-item-footer .theme-name{margin:0;white-space:nowrap;width:98%;overflow:hidden;text-overflow:ellipsis;line-height:24px}.ai-item-footer-actions{position:absolute;right:0;text-align:center;z-index:4;top:0;height:calc(100% - 22px);background:red;padding:11px;opacity:0;transition:all .1s ease-in-out;visibility:hidden;background:rgba(244,244,244,.7);border-left:1px solid rgba(0,0,0,.05)}.ai-item-footer-actions .button{line-height:32px;height:35px}.ai-item-footer-actions .button .dashicons:not(.dashicons-update){width:10px;height:10px;font-size:14px;vertical-align:middle;margin-right:10px;margin-top:-5px}.ai-item-footer-actions .button .dashicons.ai-update{animation:dashicons-spin 1s linear infinite;margin:17px 0 0 10px;width:auto;height:auto;font-size:16px}.ai-item-footer-actions .button .dashicons.dashicons-visibility{font-size:12px}.ai-form{padding:40px;background:#fff}.ai-form .media-title{margin-top:0}.ai-form .input-file{padding:100px;border:1px dashed #cdcdcd;margin:40px 0;background:#f8f8f8;text-align:center;clear:both}.ai-item.ai-action-importing .ai-item-preview:after{visibility:visible;opacity:1}.ai-item.ai-action-importing .ai-author-info{bottom:10px}.ai-item.ai-action-importing .ai-item-footer-actions{top:50%;transform:translateY(-50%)}.ai-item.ai-action-importing .ai-demo-import{padding-right:0}.ai-item.ai-action-importing .ai-item-footer-actions{opacity:1;visibility:visible}@keyframes dashicons-spin{0%{transform:translate3d(-50%,-50%,0) rotate(0)}100%{transform:translate3d(-50%,-50%,0) rotate(360deg)}}.ai-confirm-import-content #swal2-content{text-align:left!important;margin-top:20px}.swal2-actions{width:auto!important}#swal2-content p{padding-left:20px;padding-right:13px}
|
1 |
+
.ai-body{margin:40px 15px 0}.ai-body img{max-width:100%;height:auto}.ai-header{margin-bottom:30px;padding:20px;background:#fff;border-left-color:#46b450;border-width:0 0 0 4px;border-style:solid;box-shadow:0 1px 1px rgba(0,0,0,.04)}.ai-header h1{margin-top:0}.ai-header p{margin-bottom:0}.ai-filter-tabs{display:flex;align-items:center;background:#fff;padding:10px 20px;margin-bottom:20px;margin-top:20px;box-shadow:0 1px 1px rgba(0,0,0,.04);border:1px solid #e5e5e5}.ai-filter-tabs ul{margin-top:0;margin-bottom:0}.ai-filter-tabs ul li{font-size:14px;cursor:pointer;font-weight:600}.ai-count{background:#ca4a1f;display:inline-block;padding:2px 10px;border-radius:50px;margin-left:5px;color:#fff;font-size:12px}.ai-types{display:flex}.ai-types li{margin:0 5px;padding:5px}.ai-form-file-import{cursor:pointer;background:#efefef;padding:8px 25px;margin:0;border-radius:3px;background:#0085ba;border-color:#0073aa #006799 #006799;box-shadow:0 1px 0 #006799;color:#fff;text-decoration:none;text-shadow:0 -1px 1px #006799,1px 0 1px #006799,0 1px 1px #006799,-1px 0 1px #006799}.ai-form-file-import:focus,.ai-form-file-import:hover{background:#0073aa;border-color:#006799}.ai-filter-content{background:#f8f8f8;display:flex}.ai-filter-content.hidden{display:none}.ai-sidebar{flex-basis:250px;min-width:270px;background:#f9f9f9;color:#999;padding-top:30px;border-right:1px solid #ddd;box-shadow:10px 0 10px -3px rgba(0,0,0,.1)}.ai-import-available-categories{margin-top:20px;overflow-y:auto;overflow-x:hidden;max-height:calc(100% - 23px)}.ai-import-available-categories h3{padding-left:30px;padding-right:30px}.ai-import-available-categories ul{margin-top:20px}.ai-import-available-categories ul li{cursor:pointer;font-weight:600;font-size:14px;padding:15px 30px;position:relative;z-index:1;margin:0;border-bottom:1px solid #f1f1f1}.ai-import-available-categories ul li:after{position:absolute;left:0;top:0;background:#f1f1f1;width:0;content:'';height:100%;z-index:-1;transition:all .5s ease-in-out 0s}.ai-import-available-categories ul li:focus,.ai-import-available-categories ul li:hover{border-color:#f1f1f1;color:#444}.ai-import-available-categories ul li span{float:right}.ai-import-available-categories ul li.ai-filter-btn-active{color:#444;border-color:#f1f1f1}.ai-import-available-categories ul li.ai-filter-btn-active:focus,.ai-import-available-categories ul li.ai-filter-btn-active:hover{border-color:#f1f1f1}.ai-import-available-categories ul li.ai-filter-btn-active:focus:after,.ai-import-available-categories ul li.ai-filter-btn-active:hover:after{width:100%}.ai-import-available-categories ul li.ai-filter-btn-active:after{width:100%;transition:all .5s ease-in-out 0s}.ai-import-available-categories ul.ai-import-fp-lists{border-bottom:1px solid #ddd;text-align:center}.ai-import-available-categories ul.ai-import-fp-lists li.ai-fp-filter{display:inline-block;border:1px solid transparent;margin-bottom:-2px;padding:10px 24px;border-radius:2px 2px 0 0}.ai-import-available-categories ul.ai-import-fp-lists li.ai-fp-filter.ai-filter-btn-active{background:#fff;border-width:1px 1px 0 1px;border-style:solid;border-color:#ddd;color:#444}.ai-import-available-categories ul.ai-import-fp-lists li.ai-fp-filter.ai-filter-btn-active::after{display:none}.ai-search-control{margin-left:auto;margin-right:20px;width:200px}.ai-search-control .ai-search-filter{padding-left:10px;padding-right:10px}.ai-search-filter{height:36px;width:100%}.ai-filter-content-wrapper{flex-basis:calc(100% - 250px);padding:15px}.ai-item-preview{position:relative;z-index:1;line-height:0;border-top-right-radius:4px;border-top-left-radius:4px;background:#fff}.ai-item-preview:after{content:'';width:100%;height:100%;position:absolute;left:0;top:0;box-shadow:0 -130px 70px -42px rgba(0,0,0,.8) inset;z-index:2;opacity:0;visibility:hidden;transition:all .5s ease-in-out 0s}.ai-item-preview .ai-item-screenshot{border-top-right-radius:4px;border-top-left-radius:4px;overflow:hidden}.ai-item-preview .ai-author-info{position:absolute;left:0;right:0;bottom:-100px;width:100%;z-index:3;margin:0;padding:20px;color:#fff;font-size:16px;opacity:0;visibility:hidden;transition:opacity .5s ease-in-out 0s,visibility .9s ease-in-out 0s}.ai-item-preview .ai-details{position:absolute;left:0;right:0;margin:0 auto;top:50%;width:130px;margin:0 auto;background:rgba(0,0,0,.8);height:40px;line-height:40px;text-align:center;z-index:5;font-size:15px;font-weight:600;color:#fff;opacity:0;visibility:hidden;transition:all .5s ease-in-out 0s;transform:translateY(-50%)}.ai-item-preview .ai-premium-label{position:absolute;right:-10px;top:20px;background:#ca4a1f;display:block;z-index:3;line-height:16px;padding:10px 20px;height:16px;font-weight:600;color:#fff}.ai-item-preview .ai-premium-label:before{position:absolute;left:-18px;top:0;height:0;width:0;content:"";border-top:18px solid #ca4a1f;border-left:18px solid transparent;border-bottom:18px solid #ca4a1f}.ai-item-preview .ai-premium-label:after{position:absolute;right:0;content:"";bottom:-10px;width:0;height:0;border-top:10px solid #ca4a1f;border-right:10px solid transparent}.ai-item{display:inline-block;max-width:calc(100% / 3 - 40px);margin:15px;box-shadow:0 2px 15px -3px rgba(0,0,0,.2)}@media (min-width:1600px){.ai-item{max-width:calc(100% / 4 - 40px)}}.ai-item:hover .ai-item-preview:after{visibility:visible;opacity:1}.ai-item:hover .ai-author-info{bottom:10px;visibility:visible;opacity:1}.ai-item:hover .ai-details,.ai-item:hover .ai-item-footer-actions{visibility:visible;opacity:1}.ai-item-footer{padding:20px;background:#fff;position:relative;border-bottom-right-radius:4px;border-bottom-left-radius:4px}.ai-item-footer .theme-name{margin:0;white-space:nowrap;width:98%;overflow:hidden;text-overflow:ellipsis;line-height:24px}.ai-item-footer-actions{position:absolute;right:0;text-align:center;z-index:4;top:0;height:calc(100% - 22px);background:red;padding:11px;opacity:0;transition:all .1s ease-in-out;visibility:hidden;background:rgba(244,244,244,.7);border-left:1px solid rgba(0,0,0,.05)}.ai-item-footer-actions .button{line-height:32px;height:35px}.ai-item-footer-actions .button .dashicons:not(.dashicons-update){width:10px;height:10px;font-size:14px;vertical-align:middle;margin-right:10px;margin-top:-5px}.ai-item-footer-actions .button .dashicons.ai-update{animation:dashicons-spin 1s linear infinite;margin:17px 0 0 10px;width:auto;height:auto;font-size:16px}.ai-item-footer-actions .button .dashicons.dashicons-visibility{font-size:12px}.ai-form{padding:40px;background:#fff}.ai-form .media-title{margin-top:0}.ai-form .input-file{padding:100px;border:1px dashed #cdcdcd;margin:40px 0;background:#f8f8f8;text-align:center;clear:both}.ai-item.ai-action-importing .ai-item-preview:after{visibility:visible;opacity:1}.ai-item.ai-action-importing .ai-author-info{bottom:10px}.ai-item.ai-action-importing .ai-item-footer-actions{top:50%;transform:translateY(-50%)}.ai-item.ai-action-importing .ai-demo-import{padding-right:0}.ai-item.ai-action-importing .ai-item-footer-actions{opacity:1;visibility:visible}@keyframes dashicons-spin{0%{transform:translate3d(-50%,-50%,0) rotate(0)}100%{transform:translate3d(-50%,-50%,0) rotate(360deg)}}.ai-confirm-import-content #swal2-content{text-align:left!important;margin-top:20px}.swal2-actions{width:auto!important}#swal2-content p{padding-left:20px;padding-right:13px}
|
assets/js/advanced-import-admin.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(t){let e,n,i,o,a=t(document),r=!1,c=!1;const l=function(t){let e,n,i=window.location.search.substring(1).split("&");for(n=0;n<i.length;n++)if((e=i[n].split("="))[0]===t)return void 0===e[1]||decodeURIComponent(e[1])},u=Swal.mixin({position:"bottom-end",showConfirmButton:!1,allowOutsideClick:!1,allowEscapeKey:!1,toast:!0}),d=function(e){t("#ai-demo-popup").html(e),u.fire({type:"info",html:t("#ai-demo-popup .ai-notification-title").html()}),u.showLoading()},p=function(t=null,e=null,n=null,i=null){let o=advanced_import_object.text.failedImport.text;o+=t||e||n||i?"<br/>"+advanced_import_object.text.failedImport.code:"",o+=t||"",o+=e||"",o+=n||"",o+=i||"",u.fire({type:"error",html:o}),f()},s=function(e=!1){u.fire({type:"info",html:t(".ai-notification-title").html()}),u.showLoading(),r=!0,m(e)},f=function(){r=!1,_()},m=function(t){return!!t&&(!c&&((c=t).append('<span class="ai-update dashicons dashicons-update"></span>'),c.attr("disabled",!0),void c.closest(".ai-item").addClass("ai-action-importing")))},_=function(){if(!c)return!1;c.children(".ai-update").remove(),c.attr("disabled",!1),c.closest(".ai-item").removeClass("ai-action-importing"),c=!1};function h(){return t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"content_screen",_wpnonce:e.val(),_wp_http_referer:n.val(),template_url:o,template_type:i}}).done(function(e){d(e),(new function(){let e,n=0,a="",r="";function c(n){"object"==typeof n&&void 0!==n.message?(e.find("span").text(n.message),void 0!==n.url?n.hash===r?(e.find("span").text(advanced_import_object.text.failed),l()):(r=n.hash,t.ajax({type:"POST",url:n.url,data:n}).done(c).fail(c)):(n.done,l())):(e.find("span").text(advanced_import_object.text.error),l())}function l(){e&&(e.data("done-item")||(n++,e.attr("data-done-item",1)),e.find(".spinner").remove());let r=!1,u=t("tr.ai-available-content");u.each(function(){let n=t(this);""===a||r?(a=n.data("content"),e=n,function(){if(a){let n=e.find("input:checkbox");n.is(":checked")?t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"import_content",wpnonce:advanced_import_object.wpnonce,content:a,template_url:o,template_type:i}}).done(c).fail(c):(e.find("span").text(advanced_import_object.text.skip),setTimeout(l,300))}}(),r=!1):n.data("content")===a&&(r=!0)}),n>=u.length&&complete()}return{init:function(){let e=t(".ai-pages");e.addClass("installing"),e.find("input").prop("disabled",!0),complete=function(){return t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"complete_screen"}}).done(function(e){return t("#ai-demo-popup").html(e),Swal.fire({title:"Success",html:t("#ai-demo-popup .ai-notification-title").html(),type:"success",allowOutsideClick:!1,showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:advanced_import_object.text.successImport.confirmButtonText,cancelButtonText:advanced_import_object.text.successImport.cancelButtonText}).then(e=>{e.value&&window.open(t("#ai-demo-popup .ai-actions-buttons a").attr("href"),"_blank")}),f(),!1}).fail(function(t,e,n){console.log(t+" :: "+e+" :: "+n)}),!1},l()}}}).init()}).fail(function(t,e,n){return p("",t,e,n),!1}),!1}function v(i){return t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"plugin_screen",_wpnonce:e.val(),_wp_http_referer:n.val(),recommendedPlugins:i}}).done(function(i){d(i),u.showLoading(),t("#ai-demo-popup .ai-plugins-wrap").find("li").each(function(){return function i(o){if("ai-no-recommended-plugins"===o.attr("id"))return h(),!1;t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"install_plugin",_wpnonce:e.val(),_wp_http_referer:n.val(),slug:o.data("slug"),plugin:o.data("slug")+"/"+o.data("main_file")}}).done(function(t){if("object"==typeof t&&void 0!==t.success){if(o.attr("data-completed",1),!o.next("li").length)return h(),!1;setTimeout(i(o.next("li")),1e3)}else setTimeout(i(o),1e3)}).fail(function(t,e,n){return p("",t,e,n),!1})}(t(this)),!1})}).fail(function(t,e,n){return p("",t,e,n),!1}),!1}a.ready(function(){a.on("submit","#ai-upload-zip-form",function(i){if(i.preventDefault(),r)return!1;!function(i){if(void 0===window.FormData)return!0;let o=new FormData,a=i.find("#ai-upload-zip-archive"),r=t("#ai-empty-file");if(!a.val())return r.show(),p(r.html()),!1;r.hide(),s();let c=a[0].files[0];e=i.find("input[name=_wpnonce]"),n=i.find("input[name=_wp_http_referer]"),o.append("ai-upload-zip-archive",c),o.append("action","advanced_import_ajax_setup"),o.append("_wpnonce",e.val()),o.append("_wp_http_referer",n.val()),a.val(""),t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:o,cache:!1,contentType:!1,processData:!1}).done(function(t){return"object"!=typeof t&&(t=JSON.parse(t)),t.success?(h(),!1):(p(t.data.message),!1)}).fail(function(t,e,n){return p("",t,e,n),!1})}(t(this))}),a.on("click",".ai-item .ai-demo-import",function(a){if(a.preventDefault(),r)return!1;let c=t(this),l=t(this).data("plugins");Swal.fire({title:advanced_import_object.text.confirmImport.title,html:advanced_import_object.text.confirmImport.html,width:"64rem",customClass:{content:"ai-confirm-import-content"},allowOutsideClick:!1,showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:advanced_import_object.text.confirmImport.confirmButtonText,cancelButtonText:advanced_import_object.text.confirmImport.cancelButtonText}).then(a=>{a.value&&(s(c),function(a,r){let c=a.closest(".ai-item");i=c.data("template_type"),o=c.data("template_url"),e=c.find("input[name=_wpnonce]"),n=c.find("input[name=_wp_http_referer]"),"array"===i?v(r):t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"demo_download_and_unzip",_wpnonce:e.val(),_wp_http_referer:n.val(),demo_file:o,demo_file_type:i}}).done(function(t){return t.success?(v(r),!1):(p("",jqXHR,textStatus,errorThrown),!1)}).fail(function(t,e,n){return p("",t,e,n),!1})}(c,l))})}),a.on("click",".ai-wp-reset",function(e){e.preventDefault(),Swal.fire({title:advanced_import_object.text.confirmReset.title,text:advanced_import_object.text.confirmReset.text,type:"warning",allowOutsideClick:!1,showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:advanced_import_object.text.confirmReset.confirmButtonText,cancelButtonText:advanced_import_object.text.confirmReset.cancelButtonText}).then(e=>{e.value&&(window.location.href=t(".ai-wp-reset").attr("href"))})}),a.on("click",".ai-filter-tabs li",function(e){if(e.preventDefault(),r)return!1;t(this).hasClass("ai-form-file-import")?(t(".ai-filter-content").addClass("hidden"),t(".ai-form").removeClass("hidden")):(t(".ai-form").addClass("hidden"),t(".ai-filter-content").removeClass("hidden"))});let c,u,d={};setTimeout(function(){let e=t(".ai-filter-content-wrapper").isotope({itemSelector:".ai-item",filter:function(){let e=t(this),n=!u||e.text().match(u),i=!c||e.is(c);return n&&i}});function n(){let n=e.isotope("getFilteredItemElements"),i=t(n);t(".ai-filter-btn").each(function(e,n){let o=t(n),a=o.attr("data-filter");if(!a)return;let r=i.filter(a).length;o.find(".ai-count").text(r)})}e.imagesLoaded().progress(function(){e.isotope("layout")}),n(),t(".ai-filter-group").on("click",".ai-filter-btn",function(){t(this).
|
1 |
+
!function(t){let e,n,i,o,a=t(document),r=!1,c=!1;const l=function(t){let e,n,i=window.location.search.substring(1).split("&");for(n=0;n<i.length;n++)if((e=i[n].split("="))[0]===t)return void 0===e[1]||decodeURIComponent(e[1])},u=Swal.mixin({position:"bottom-end",showConfirmButton:!1,allowOutsideClick:!1,allowEscapeKey:!1,toast:!0}),d=function(e){t("#ai-demo-popup").html(e),u.fire({type:"info",html:t("#ai-demo-popup .ai-notification-title").html()}),u.showLoading()},p=function(t=null,e=null,n=null,i=null){let o=advanced_import_object.text.failedImport.text;o+=t||e||n||i?"<br/>"+advanced_import_object.text.failedImport.code:"",o+=t||"",o+=e||"",o+=n||"",o+=i||"",u.fire({type:"error",html:o}),f()},s=function(e=!1){u.fire({type:"info",html:t(".ai-notification-title").html()}),u.showLoading(),r=!0,m(e)},f=function(){r=!1,_()},m=function(t){return!!t&&(!c&&((c=t).append('<span class="ai-update dashicons dashicons-update"></span>'),c.attr("disabled",!0),void c.closest(".ai-item").addClass("ai-action-importing")))},_=function(){if(!c)return!1;c.children(".ai-update").remove(),c.attr("disabled",!1),c.closest(".ai-item").removeClass("ai-action-importing"),c=!1};function h(){return t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"content_screen",_wpnonce:e.val(),_wp_http_referer:n.val(),template_url:o,template_type:i}}).done(function(e){d(e),(new function(){let e,n=0,a="",r="";function c(n){"object"==typeof n&&void 0!==n.message?(e.find("span").text(n.message),void 0!==n.url?n.hash===r?(e.find("span").text(advanced_import_object.text.failed),l()):(r=n.hash,t.ajax({type:"POST",url:n.url,data:n}).done(c).fail(c)):(n.done,l())):(e.find("span").text(advanced_import_object.text.error),l())}function l(){e&&(e.data("done-item")||(n++,e.attr("data-done-item",1)),e.find(".spinner").remove());let r=!1,u=t("tr.ai-available-content");u.each(function(){let n=t(this);""===a||r?(a=n.data("content"),e=n,function(){if(a){let n=e.find("input:checkbox");n.is(":checked")?t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"import_content",wpnonce:advanced_import_object.wpnonce,content:a,template_url:o,template_type:i}}).done(c).fail(c):(e.find("span").text(advanced_import_object.text.skip),setTimeout(l,300))}}(),r=!1):n.data("content")===a&&(r=!0)}),n>=u.length&&complete()}return{init:function(){let e=t(".ai-pages");e.addClass("installing"),e.find("input").prop("disabled",!0),complete=function(){return t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"complete_screen"}}).done(function(e){return t("#ai-demo-popup").html(e),Swal.fire({title:"Success",html:t("#ai-demo-popup .ai-notification-title").html(),type:"success",allowOutsideClick:!1,showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:advanced_import_object.text.successImport.confirmButtonText,cancelButtonText:advanced_import_object.text.successImport.cancelButtonText}).then(e=>{e.value&&window.open(t("#ai-demo-popup .ai-actions-buttons a").attr("href"),"_blank")}),f(),!1}).fail(function(t,e,n){console.log(t+" :: "+e+" :: "+n)}),!1},l()}}}).init()}).fail(function(t,e,n){return p("",t,e,n),!1}),!1}function v(i){return t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"plugin_screen",_wpnonce:e.val(),_wp_http_referer:n.val(),recommendedPlugins:i}}).done(function(i){d(i),u.showLoading(),t("#ai-demo-popup .ai-plugins-wrap").find("li").each(function(){return function i(o){if("ai-no-recommended-plugins"===o.attr("id"))return h(),!1;t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"install_plugin",_wpnonce:e.val(),_wp_http_referer:n.val(),slug:o.data("slug"),plugin:o.data("slug")+"/"+o.data("main_file")}}).done(function(t){if("object"==typeof t&&void 0!==t.success){if(o.attr("data-completed",1),!o.next("li").length)return h(),!1;setTimeout(i(o.next("li")),1e3)}else setTimeout(i(o),1e3)}).fail(function(t,e,n){return p("",t,e,n),!1})}(t(this)),!1})}).fail(function(t,e,n){return p("",t,e,n),!1}),!1}a.ready(function(){a.on("submit","#ai-upload-zip-form",function(i){if(i.preventDefault(),r)return!1;!function(i){if(void 0===window.FormData)return!0;let o=new FormData,a=i.find("#ai-upload-zip-archive"),r=t("#ai-empty-file");if(!a.val())return r.show(),p(r.html()),!1;r.hide(),s();let c=a[0].files[0];e=i.find("input[name=_wpnonce]"),n=i.find("input[name=_wp_http_referer]"),o.append("ai-upload-zip-archive",c),o.append("action","advanced_import_ajax_setup"),o.append("_wpnonce",e.val()),o.append("_wp_http_referer",n.val()),a.val(""),t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:o,cache:!1,contentType:!1,processData:!1}).done(function(t){return"object"!=typeof t&&(t=JSON.parse(t)),t.success?(h(),!1):(p(t.data.message),!1)}).fail(function(t,e,n){return p("",t,e,n),!1})}(t(this))}),a.on("click",".ai-item .ai-demo-import",function(a){if(a.preventDefault(),r)return!1;let c=t(this),l=t(this).data("plugins");Swal.fire({title:advanced_import_object.text.confirmImport.title,html:advanced_import_object.text.confirmImport.html,width:"64rem",customClass:{content:"ai-confirm-import-content"},allowOutsideClick:!1,showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:advanced_import_object.text.confirmImport.confirmButtonText,cancelButtonText:advanced_import_object.text.confirmImport.cancelButtonText}).then(a=>{a.value&&(s(c),function(a,r){let c=a.closest(".ai-item");i=c.data("template_type"),o=c.data("template_url"),e=c.find("input[name=_wpnonce]"),n=c.find("input[name=_wp_http_referer]"),"array"===i?v(r):t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"demo_download_and_unzip",_wpnonce:e.val(),_wp_http_referer:n.val(),demo_file:o,demo_file_type:i}}).done(function(t){return t.success?(v(r),!1):(p("",jqXHR,textStatus,errorThrown),!1)}).fail(function(t,e,n){return p("",t,e,n),!1})}(c,l))})}),a.on("click",".ai-wp-reset",function(e){e.preventDefault(),Swal.fire({title:advanced_import_object.text.confirmReset.title,text:advanced_import_object.text.confirmReset.text,type:"warning",allowOutsideClick:!1,showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:advanced_import_object.text.confirmReset.confirmButtonText,cancelButtonText:advanced_import_object.text.confirmReset.cancelButtonText}).then(e=>{e.value&&(window.location.href=t(".ai-wp-reset").attr("href"))})}),a.on("click",".ai-filter-tabs li",function(e){if(e.preventDefault(),r)return!1;t(this).hasClass("ai-form-file-import")?(t(".ai-filter-content").addClass("hidden"),t(".ai-form").removeClass("hidden")):(t(".ai-form").addClass("hidden"),t(".ai-filter-content").removeClass("hidden"))});let c,u,d={};setTimeout(function(){let e=t(".ai-filter-content-wrapper").isotope({itemSelector:".ai-item",filter:function(){let e=t(this),n=!u||e.text().match(u),i=!c||e.is(c);return n&&i}});function n(){let n=e.isotope("getFilteredItemElements"),i=t(n);t(".ai-filter-btn").each(function(e,n){let o=t(n),a=o.attr("data-filter");if(!a)return;let r=i.filter(a).length;o.find(".ai-count").text(r)})}e.imagesLoaded().progress(function(){e.isotope("layout")}),n(),t(".ai-filter-group").on("click",".ai-filter-btn",function(){let i=t(this),o=i.parents(".ai-filter-group").attr("data-filter-group");i.siblings().removeClass("ai-filter-btn-active"),i.addClass("ai-filter-btn-active"),d[o]=i.attr("data-filter"),c=function(t){let e="";for(let n in t)e+=t[n];return e}(d),setTimeout(function(){e.isotope(),i.hasClass("ai-fp-filter")&&n()},300)});let i=t(".ai-search-filter").keyup(function(t,e){let n;return e=e||100,function(){clearTimeout(n);let i=arguments,o=this;n=setTimeout(function(){t.apply(o,i)},e)}}(function(){u=new RegExp(i.val(),"gi"),e.isotope(),n()}))},1),function(){let t=l("reset"),e=l("from");"true"===t&&"ai-reset-wp"===e&&Swal.fire({title:advanced_import_object.text.resetSuccess.title,type:"success",allowOutsideClick:!1,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:advanced_import_object.text.resetSuccess.confirmButtonText})}()})}(jQuery);
|
readme.txt
CHANGED
@@ -4,9 +4,9 @@ Contributors: addonspress, codersantosh, acmeit
|
|
4 |
Donate link: https://addonspress.com/
|
5 |
Tags: import, advanced import, demo import, theme import, widget import, customizer import
|
6 |
Requires at least: 4.5
|
7 |
-
Tested up to: 5.
|
8 |
Requires PHP: 5.6.20
|
9 |
-
Stable tag: 1.
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
|
@@ -225,6 +225,14 @@ Advanced Import is generally one-time use plugin, it is meant to be used for Dem
|
|
225 |
|
226 |
== Changelog ==
|
227 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
= 1.2.5 - 2020-11-11 =
|
229 |
* Updated : Hook attributes, control each demo import.
|
230 |
Now developer can provide user template kit separately. View Example : [CosmosWP Template kits](https://www.cosmoswp.com/template-kits/)
|
4 |
Donate link: https://addonspress.com/
|
5 |
Tags: import, advanced import, demo import, theme import, widget import, customizer import
|
6 |
Requires at least: 4.5
|
7 |
+
Tested up to: 5.6
|
8 |
Requires PHP: 5.6.20
|
9 |
+
Stable tag: 1.3.0
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
|
225 |
|
226 |
== Changelog ==
|
227 |
|
228 |
+
= 1.3.0 - 2021-01-26 =
|
229 |
+
* Added : All, Free and Pro Tab
|
230 |
+
* Updated : Tested up to 5.6 WordPress
|
231 |
+
* Updated : PHPCS
|
232 |
+
* Updated : Some minor design
|
233 |
+
* Updated : Minor changes
|
234 |
+
* Fixed : File Type Check
|
235 |
+
|
236 |
= 1.2.5 - 2020-11-11 =
|
237 |
* Updated : Hook attributes, control each demo import.
|
238 |
Now developer can provide user template kit separately. View Example : [CosmosWP Template kits](https://www.cosmoswp.com/template-kits/)
|