Version Description
- 2020-11-11 =
- Updated : Hook attributes, control each demo import. Now developer can provide user template kit separately. View Example : CosmosWP Template kits
- Updated : PHPCS
- Updated : Some minor design
- Updated : Minor changes
Download this release
Release Info
Developer | addonspress |
Plugin | Advanced Import : One Click Import for WordPress or Theme Demo Data |
Version | 1.2.5 |
Comparing to | |
See all releases |
Code changes from version 1.2.4 to 1.2.5
- admin/class-advanced-import-admin.php +2515 -2507
- admin/class-elementor-import.php +115 -109
- admin/class-reset.php +206 -205
- admin/index.php +1 -1
- advanced-import.php +15 -15
- assets/css/advanced-import-admin.min.css +1 -1
- example.php +83 -80
- includes/class-advanced-import-deactivator.php +1 -1
- includes/class-advanced-import-i18n.php +1 -1
- includes/class-advanced-import-loader.php +18 -18
- includes/class-advanced-import.php +13 -14
- includes/class-theme-template-library-base.php +32 -32
- includes/functions-advanced-import.php +29 -29
- includes/index.php +1 -1
- includes/theme-template-library/acmethemes.php +108 -103
- includes/theme-template-library/cosmoswp.php +119 -114
- index.php +1 -1
- readme.txt +11 -2
- uninstall.php +1 -1
admin/class-advanced-import-admin.php
CHANGED
@@ -1,2507 +1,2515 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
*
|
7 |
-
*
|
8 |
-
* @
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
/**
|
16 |
-
* The admin-specific functionality of the plugin.
|
17 |
-
*
|
18 |
-
* Defines the plugin name, version, and two examples hooks for how to
|
19 |
-
* enqueue the admin-specific stylesheet and JavaScript.
|
20 |
-
*
|
21 |
-
* @package Advanced_Import
|
22 |
-
* @subpackage Advanced_Import/admin
|
23 |
-
* @author Addons Press <addonspress.com>
|
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 |
-
* 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 |
-
|
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 |
-
$is_available = true
|
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 |
-
<a class="button
|
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 |
-
<p
|
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 |
-
elseif ( $demo_file_type == 'url' ){
|
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 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
</
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
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 |
-
<th class="
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
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 |
-
$this->
|
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 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
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 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
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 |
-
else {
|
1846 |
-
$ids[ $key ] = $new_id;
|
1847 |
-
}
|
1848 |
-
}
|
1849 |
-
$new_ids = implode( ',', $ids );
|
1850 |
-
$content = str_replace( $ids_matches[0], 'ids="' . $new_ids . '"', $content );
|
1851 |
-
}
|
1852 |
-
}
|
1853 |
-
}
|
1854 |
-
|
1855 |
-
/*contact form 7 id fixes.*/
|
1856 |
-
if ( preg_match_all( '#\[contact-form-7[^\]]*\]#', $content, $matches ) ) {
|
1857 |
-
foreach ( $matches[0] as $match_id => $string ) {
|
1858 |
-
if ( preg_match( '#id="(\d+)"#', $string, $id_match ) ) {
|
1859 |
-
$new_id = $this->imported_post_id( $id_match[1] );
|
1860 |
-
if ( $new_id ) {
|
1861 |
-
$content = str_replace( $id_match[0], 'id="' . $new_id . '"', $content );
|
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 |
-
|
2505 |
-
|
2506 |
-
|
2507 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php // phpcs:ignore WordPress.Files.FileName
|
2 |
+
/**
|
3 |
+
* Advanced Import Admin class
|
4 |
+
*
|
5 |
+
* Collection of admin hooks
|
6 |
+
*
|
7 |
+
* @package Advanced_Import
|
8 |
+
* @since 1.0.0
|
9 |
+
*/
|
10 |
+
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
+
exit;
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* The admin-specific functionality of the plugin.
|
17 |
+
*
|
18 |
+
* Defines the plugin name, version, and two examples hooks for how to
|
19 |
+
* enqueue the admin-specific stylesheet and JavaScript.
|
20 |
+
*
|
21 |
+
* @package Advanced_Import
|
22 |
+
* @subpackage Advanced_Import/admin
|
23 |
+
* @author Addons Press <addonspress.com>
|
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 ) {
|
338 |
+
$add_mimes = array(
|
339 |
+
'json' => 'text/plain',
|
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 );
|
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 );
|
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 );
|
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 |
+
<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 |
+
echo isset( $demo_list['categories'] ) ? esc_attr( implode( ' ', $demo_list['categories'] ) ) : '';
|
760 |
+
echo isset( $demo_list['type'] ) ? ' ' . esc_attr( $demo_list['type'] ) : '';
|
761 |
+
echo $this->is_template_available( $demo_list ) ? '' : ' ai-pro-item'
|
762 |
+
?>
|
763 |
+
"
|
764 |
+
<?php echo $this->is_template_available( $demo_list ) ? $data_template . ' ' . $data_template_type : ''; ?>
|
765 |
+
>
|
766 |
+
<?php
|
767 |
+
wp_nonce_field( 'advanced-import' );
|
768 |
+
?>
|
769 |
+
<div class="ai-item-preview">
|
770 |
+
<div class="ai-item-screenshot">
|
771 |
+
<img src="<?php echo esc_url( $demo_list['screenshot_url'] ); ?>">
|
772 |
+
|
773 |
+
</div>
|
774 |
+
<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>
|
775 |
+
<div class="ai-details"><?php esc_html_e( 'Details', 'advanced-import' ); ?></div>
|
776 |
+
<?php
|
777 |
+
if ( isset( $demo_list['is_pro'] ) && $demo_list['is_pro'] ) {
|
778 |
+
?>
|
779 |
+
<span class="ai-premium-label"><?php esc_html_e( 'Premium', 'advanced-import' ); ?></span>
|
780 |
+
<?php
|
781 |
+
}
|
782 |
+
?>
|
783 |
+
</div>
|
784 |
+
<div class="ai-item-footer">
|
785 |
+
<div class="ai-item-footer_meta">
|
786 |
+
<h3 class="theme-name"><?php echo esc_html( $demo_list['title'] ); ?></h3>
|
787 |
+
<div class="ai-item-footer-actions">
|
788 |
+
<a class="button ai-item-demo-link" href="<?php echo esc_url( $demo_list['demo_url'] ); ?>" target="_blank">
|
789 |
+
<span class="dashicons dashicons-visibility"></span><?php esc_html_e( 'Preview', 'advanced-import' ); ?>
|
790 |
+
</a>
|
791 |
+
<?php
|
792 |
+
echo $this->template_button( $demo_list );
|
793 |
+
?>
|
794 |
+
</div>
|
795 |
+
<?php
|
796 |
+
$keywords = isset( $demo_list['keywords'] ) ? $demo_list['keywords'] : array();
|
797 |
+
if ( ! empty( $keywords ) ) {
|
798 |
+
echo '<ul class="ai-keywords hidden">';
|
799 |
+
foreach ( $keywords as $cat_index => $single_keywords ) {
|
800 |
+
?>
|
801 |
+
<li class="<?php echo strtolower( esc_attr( $single_keywords ) ); ?>"><?php echo ucfirst( esc_html( $single_keywords ) ); ?></li>
|
802 |
+
<?php
|
803 |
+
}
|
804 |
+
echo '</ul>';
|
805 |
+
}
|
806 |
+
?>
|
807 |
+
|
808 |
+
</div>
|
809 |
+
|
810 |
+
</div>
|
811 |
+
</div>
|
812 |
+
<?php
|
813 |
+
}
|
814 |
+
?>
|
815 |
+
</div>
|
816 |
+
</div>
|
817 |
+
<?php
|
818 |
+
}
|
819 |
+
|
820 |
+
/**
|
821 |
+
* List Demo Form
|
822 |
+
*
|
823 |
+
* @return void
|
824 |
+
*/
|
825 |
+
|
826 |
+
public function demo_import_form( $total_demo = 0 ) {
|
827 |
+
?>
|
828 |
+
<div class="ai-form <?php echo $total_demo > 0 ? 'hidden' : ''; ?>">
|
829 |
+
<form action="" method="post" enctype="multipart/form-data" id="ai-upload-zip-form">
|
830 |
+
<h3 class="media-title"><?php esc_html_e( 'Upload a zip file containing demo content', 'advanced-import' ); ?> </h3>
|
831 |
+
<div class="input-file"><input type="file" name="ai-upload-zip-archive" id="ai-upload-zip-archive" size="50" /></div>
|
832 |
+
<p>
|
833 |
+
<?php
|
834 |
+
wp_nonce_field( 'advanced-import' );
|
835 |
+
printf( __( 'Maximum upload file size: %s', 'advanced-import' ), size_format( wp_max_upload_size() ) );
|
836 |
+
?>
|
837 |
+
</p>
|
838 |
+
<div id='ai-empty-file' class="error hidden">
|
839 |
+
<p>
|
840 |
+
<?php esc_html_e( 'Select File and Try Again!', 'advanced-import' ); ?>
|
841 |
+
</p>
|
842 |
+
</div>
|
843 |
+
<p class="ai-form-import-actions step">
|
844 |
+
<button class="button-primary button button-large button-upload-demo" type="submit">
|
845 |
+
<?php esc_html_e( 'Upload Demo Zip', 'advanced-import' ); ?>
|
846 |
+
</button>
|
847 |
+
<a href="<?php echo esc_url( wp_get_referer() && ! strpos( wp_get_referer(), 'update.php' ) ? wp_get_referer() : admin_url( '' ) ); ?>" class="button button-large">
|
848 |
+
<?php esc_html_e( 'Not right now', 'advanced-import' ); ?>
|
849 |
+
</a>
|
850 |
+
</p>
|
851 |
+
<div id='ai-ajax-install-result'></div>
|
852 |
+
</form>
|
853 |
+
</div>
|
854 |
+
<?php
|
855 |
+
}
|
856 |
+
|
857 |
+
/**
|
858 |
+
* 1st step of demo import view
|
859 |
+
* Upload Zip file
|
860 |
+
* Demo List
|
861 |
+
*/
|
862 |
+
public function init_demo_import() {
|
863 |
+
|
864 |
+
global $pagenow;
|
865 |
+
$total_demo = 0;
|
866 |
+
if ( $pagenow != 'tools.php' ) {
|
867 |
+
$this->demo_lists = apply_filters( 'advanced_import_demo_lists', array() );
|
868 |
+
$this->is_pro_active = apply_filters( 'advanced_import_is_pro_active', $this->is_pro_active );
|
869 |
+
$demo_lists = $this->demo_lists;
|
870 |
+
|
871 |
+
$total_demo = count( $demo_lists );
|
872 |
+
if ( $total_demo >= 1 ) {
|
873 |
+
$this->demo_list( $demo_lists, $total_demo );
|
874 |
+
}
|
875 |
+
}
|
876 |
+
|
877 |
+
$this->demo_import_form( $total_demo );
|
878 |
+
}
|
879 |
+
|
880 |
+
/**
|
881 |
+
* 2nd step Plugin Installation step View
|
882 |
+
* return void || boolean
|
883 |
+
*/
|
884 |
+
public function plugin_screen() {
|
885 |
+
|
886 |
+
/*check for security*/
|
887 |
+
if ( ! current_user_can( 'upload_files' ) ) {
|
888 |
+
wp_send_json_error(
|
889 |
+
array(
|
890 |
+
'message' => esc_html__( 'Sorry, you are not allowed to install demo on this site.', 'advanced-import' ),
|
891 |
+
)
|
892 |
+
);
|
893 |
+
}
|
894 |
+
|
895 |
+
check_admin_referer( 'advanced-import' );
|
896 |
+
|
897 |
+
/*for safety.*/
|
898 |
+
delete_transient( 'content.json' );
|
899 |
+
delete_transient( 'widgets.json' );
|
900 |
+
delete_transient( 'options.json' );
|
901 |
+
|
902 |
+
do_action( 'advanced_import_before_plugin_screen' );
|
903 |
+
?>
|
904 |
+
<div class="ai-notification-title">
|
905 |
+
<p><?php esc_html_e( 'Your website needs a few essential plugins. We are installing them...', 'advanced-import' ); ?></p>
|
906 |
+
</div>
|
907 |
+
<ul class="ai-plugins-wrap hidden">
|
908 |
+
<?php
|
909 |
+
$recommended_plugins = (array) $_POST['recommendedPlugins'];
|
910 |
+
if ( count( $recommended_plugins ) ) {
|
911 |
+
foreach ( $recommended_plugins as $index => $recommended_plugin ) {
|
912 |
+
?>
|
913 |
+
<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' ); ?>">
|
914 |
+
<?php echo esc_html( $recommended_plugin['name'] ); ?>
|
915 |
+
</li>
|
916 |
+
<?php
|
917 |
+
}
|
918 |
+
} else {
|
919 |
+
?>
|
920 |
+
<li id="ai-no-recommended-plugins"><?php esc_html_e( 'No Recommended Plugins', 'advanced-import' ); ?></li>
|
921 |
+
<?php
|
922 |
+
}
|
923 |
+
?>
|
924 |
+
</ul>
|
925 |
+
<?php
|
926 |
+
do_action( 'advanced_import_after_plugin_screen' );
|
927 |
+
exit;
|
928 |
+
}
|
929 |
+
|
930 |
+
/**
|
931 |
+
* 3rd steps helper functions
|
932 |
+
* Get json from json file
|
933 |
+
*
|
934 |
+
* @param string $file file url.
|
935 |
+
* @return mixed
|
936 |
+
*/
|
937 |
+
public function get_json_data_from_file( $file ) {
|
938 |
+
|
939 |
+
if ( get_transient( $file ) ) {
|
940 |
+
return get_transient( $file );
|
941 |
+
}
|
942 |
+
|
943 |
+
if ( $this->current_template_type == 'array' ) {
|
944 |
+
$type = strtok( $file, '.' );
|
945 |
+
if ( isset( $this->current_template_url[ $type ] ) ) {
|
946 |
+
$request = wp_remote_get( $this->current_template_url[ $type ] );
|
947 |
+
$response = wp_remote_retrieve_body( $request );
|
948 |
+
$result = json_decode( $response, true );
|
949 |
+
set_transient( $file, $result, 1000 );
|
950 |
+
return $result;
|
951 |
+
}
|
952 |
+
return array();
|
953 |
+
}
|
954 |
+
|
955 |
+
if ( is_file( ADVANCED_IMPORT_TEMP . basename( $file ) ) ) {
|
956 |
+
require_once ABSPATH . 'wp-admin/includes/file.php';
|
957 |
+
WP_Filesystem();
|
958 |
+
global $wp_filesystem;
|
959 |
+
$file_name = ADVANCED_IMPORT_TEMP . basename( $file );
|
960 |
+
if ( file_exists( $file_name ) ) {
|
961 |
+
$result = json_decode( $wp_filesystem->get_contents( $file_name ), true );
|
962 |
+
set_transient( $file, $result, 1000 );
|
963 |
+
return $result;
|
964 |
+
}
|
965 |
+
}
|
966 |
+
return array();
|
967 |
+
}
|
968 |
+
|
969 |
+
public function get_main_content_json() {
|
970 |
+
return $this->get_json_data_from_file( 'content.json' );
|
971 |
+
}
|
972 |
+
public function get_widgets_json() {
|
973 |
+
return $this->get_json_data_from_file( 'widgets.json' );
|
974 |
+
}
|
975 |
+
|
976 |
+
public function get_theme_options_json() {
|
977 |
+
return $this->get_json_data_from_file( 'options.json' );
|
978 |
+
}
|
979 |
+
|
980 |
+
/*
|
981 |
+
* return array
|
982 |
+
*/
|
983 |
+
private function advanced_import_setup_content_steps() {
|
984 |
+
|
985 |
+
$content = array();
|
986 |
+
|
987 |
+
/*check if there is files*/
|
988 |
+
$content_data = $this->get_main_content_json();
|
989 |
+
foreach ( $content_data as $post_type => $post_data ) {
|
990 |
+
if ( count( $post_data ) ) {
|
991 |
+
$first = current( $post_data );
|
992 |
+
$post_type_title = ! empty( $first['type_title'] ) ? $first['type_title'] : ucwords( $post_type ) . 's';
|
993 |
+
$content[ $post_type ] = array(
|
994 |
+
'title' => $post_type_title,
|
995 |
+
'description' => sprintf( esc_html__( 'This will create default %s as seen in the demo.', 'advanced-import' ), $post_type_title ),
|
996 |
+
'pending' => esc_html__( 'Pending.', 'advanced-import' ),
|
997 |
+
'installing' => esc_html__( 'Installing.', 'advanced-import' ),
|
998 |
+
'success' => esc_html__( 'Success.', 'advanced-import' ),
|
999 |
+
'install_callback' => array( $this, 'import_content_post_type_data' ),
|
1000 |
+
'checked' => $this->is_possible_upgrade() ? 0 : 1,
|
1001 |
+
// dont check if already have content installed.
|
1002 |
+
);
|
1003 |
+
}
|
1004 |
+
}
|
1005 |
+
/*
|
1006 |
+
array adjustment
|
1007 |
+
TODO : Remove it after adjustment on Advanced Import
|
1008 |
+
*/
|
1009 |
+
/*Put post 3nd last*/
|
1010 |
+
$post = isset( $content['post'] ) ? $content['post'] : array();
|
1011 |
+
if ( $post ) {
|
1012 |
+
unset( $content['post'] );
|
1013 |
+
$content['post'] = $post;
|
1014 |
+
}
|
1015 |
+
/*Put page 2nd last*/
|
1016 |
+
$page = isset( $content['page'] ) ? $content['page'] : array();
|
1017 |
+
if ( $page ) {
|
1018 |
+
unset( $content['page'] );
|
1019 |
+
$content['page'] = $page;
|
1020 |
+
|
1021 |
+
}
|
1022 |
+
/*Put nav last*/
|
1023 |
+
$nav = isset( $content['nav_menu_item'] ) ? $content['nav_menu_item'] : array();
|
1024 |
+
if ( $nav ) {
|
1025 |
+
unset( $content['nav_menu_item'] );
|
1026 |
+
$content['nav_menu_item'] = $nav;
|
1027 |
+
}
|
1028 |
+
/*check if there is files*/
|
1029 |
+
$widget_data = $this->get_widgets_json();
|
1030 |
+
if ( ! empty( $widget_data ) ) {
|
1031 |
+
$content['widgets'] = array(
|
1032 |
+
'title' => esc_html__( 'Widgets', 'advanced-import' ),
|
1033 |
+
'description' => esc_html__( 'Insert default sidebar widgets as seen in the demo.', 'advanced-import' ),
|
1034 |
+
'pending' => esc_html__( 'Pending.', 'advanced-import' ),
|
1035 |
+
'installing' => esc_html__( 'Installing Default Widgets.', 'advanced-import' ),
|
1036 |
+
'success' => esc_html__( 'Success.', 'advanced-import' ),
|
1037 |
+
'install_callback' => array( $this, 'import_content_widgets_data' ),
|
1038 |
+
'checked' => $this->is_possible_upgrade() ? 0 : 1,
|
1039 |
+
// dont check if already have content installed.
|
1040 |
+
);
|
1041 |
+
}
|
1042 |
+
$options_data = $this->get_theme_options_json();
|
1043 |
+
if ( ! empty( $options_data ) ) {
|
1044 |
+
$content['settings'] = array(
|
1045 |
+
'title' => esc_html__( 'Settings', 'advanced-import' ),
|
1046 |
+
'description' => esc_html__( 'Configure default settings.', 'advanced-import' ),
|
1047 |
+
'pending' => esc_html__( 'Pending.', 'advanced-import' ),
|
1048 |
+
'installing' => esc_html__( 'Installing Default Settings.', 'advanced-import' ),
|
1049 |
+
'success' => esc_html__( 'Success.', 'advanced-import' ),
|
1050 |
+
'install_callback' => array( $this, 'import_menu_and_options' ),
|
1051 |
+
'checked' => $this->is_possible_upgrade() ? 0 : 1,
|
1052 |
+
// dont check if already have content installed.
|
1053 |
+
);
|
1054 |
+
}
|
1055 |
+
$content = apply_filters( $this->theme_name . '_theme_view_setup_step_content', $content );
|
1056 |
+
|
1057 |
+
return $content;
|
1058 |
+
|
1059 |
+
}
|
1060 |
+
|
1061 |
+
/**
|
1062 |
+
* 3rd Step Step for content, widget, setting import
|
1063 |
+
* Page setup
|
1064 |
+
*/
|
1065 |
+
public function content_screen() {
|
1066 |
+
|
1067 |
+
/*check for security*/
|
1068 |
+
if ( ! current_user_can( 'upload_files' ) ) {
|
1069 |
+
wp_send_json_error(
|
1070 |
+
array(
|
1071 |
+
'message' => esc_html__( 'Sorry, you are not allowed to install demo on this site.', 'advanced-import' ),
|
1072 |
+
)
|
1073 |
+
);
|
1074 |
+
}
|
1075 |
+
check_admin_referer( 'advanced-import' );
|
1076 |
+
|
1077 |
+
if ( isset( $_POST['template_url'] ) ) {
|
1078 |
+
$this->current_template_url = is_array( $_POST['template_url'] ) ? (array) $_POST['template_url'] : sanitize_text_field( $_POST['template_url'] );
|
1079 |
+
$this->current_template_type = sanitize_text_field( $_POST['template_type'] );
|
1080 |
+
}
|
1081 |
+
|
1082 |
+
do_action( 'advanced_import_before_content_screen' );
|
1083 |
+
|
1084 |
+
?>
|
1085 |
+
<div class="ai-notification-title">
|
1086 |
+
<p>
|
1087 |
+
<?php
|
1088 |
+
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. ' )
|
1089 |
+
?>
|
1090 |
+
</p>
|
1091 |
+
</div>
|
1092 |
+
|
1093 |
+
<table class="ai-pages hidden">
|
1094 |
+
<thead>
|
1095 |
+
<tr>
|
1096 |
+
<th class="check"></th>
|
1097 |
+
<th class="item"><?php esc_html_e( 'Item', 'advanced-import' ); ?></th>
|
1098 |
+
<th class="description"><?php esc_html_e( 'Description', 'advanced-import' ); ?></th>
|
1099 |
+
<th class="status"><?php esc_html_e( 'Status', 'advanced-import' ); ?></th>
|
1100 |
+
</tr>
|
1101 |
+
</thead>
|
1102 |
+
<tbody>
|
1103 |
+
<?php
|
1104 |
+
$setup_content_steps = $this->advanced_import_setup_content_steps();
|
1105 |
+
foreach ( $setup_content_steps as $slug => $default ) {
|
1106 |
+
?>
|
1107 |
+
<tr class="ai-available-content" data-content="<?php echo esc_attr( $slug ); ?>">
|
1108 |
+
<td>
|
1109 |
+
<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' : ''; ?>>
|
1110 |
+
</td>
|
1111 |
+
<td>
|
1112 |
+
<label for="import_content_<?php echo esc_attr( $slug ); ?>">
|
1113 |
+
<?php echo esc_html( $default['title'] ); ?>
|
1114 |
+
</label>
|
1115 |
+
</td>
|
1116 |
+
<td class="description">
|
1117 |
+
<?php echo esc_html( $default['description'] ); ?>
|
1118 |
+
</td>
|
1119 |
+
<td class="status">
|
1120 |
+
<span>
|
1121 |
+
<?php echo esc_html( $default['pending'] ); ?>
|
1122 |
+
</span>
|
1123 |
+
</td>
|
1124 |
+
</tr>
|
1125 |
+
<?php } ?>
|
1126 |
+
</tbody>
|
1127 |
+
</table>
|
1128 |
+
<?php
|
1129 |
+
do_action( 'advanced_import_after_content_screen' );
|
1130 |
+
|
1131 |
+
exit;
|
1132 |
+
}
|
1133 |
+
|
1134 |
+
/*
|
1135 |
+
* import ajax content
|
1136 |
+
* return JSON
|
1137 |
+
*/
|
1138 |
+
public function import_content() {
|
1139 |
+
|
1140 |
+
/*check for security*/
|
1141 |
+
if ( ! current_user_can( 'upload_files' ) ) {
|
1142 |
+
wp_send_json_error(
|
1143 |
+
array(
|
1144 |
+
'message' => esc_html__( 'Sorry, you are not allowed to install demo on this site.', 'advanced-import' ),
|
1145 |
+
)
|
1146 |
+
);
|
1147 |
+
}
|
1148 |
+
if ( isset( $_POST['template_url'] ) ) {
|
1149 |
+
$this->current_template_url = is_array( $_POST['template_url'] ) ? (array) $_POST['template_url'] : sanitize_text_field( $_POST['template_url'] );
|
1150 |
+
$this->current_template_type = sanitize_text_field( $_POST['template_type'] );
|
1151 |
+
}
|
1152 |
+
|
1153 |
+
/*Move to Trash default page and post*/
|
1154 |
+
$sample_page = get_page_by_title( 'Sample Page', OBJECT, 'page' );
|
1155 |
+
$hello_world_post = get_page_by_title( 'Hello world!', OBJECT, 'post' );
|
1156 |
+
if ( is_object( $sample_page ) ) {
|
1157 |
+
wp_trash_post( $sample_page->ID );
|
1158 |
+
}
|
1159 |
+
if ( is_object( $hello_world_post ) ) {
|
1160 |
+
wp_trash_post( $hello_world_post->ID );
|
1161 |
+
}
|
1162 |
+
|
1163 |
+
$content_slug = isset( $_POST['content'] ) ? sanitize_title( $_POST['content'] ) : '';
|
1164 |
+
|
1165 |
+
$content = $this->advanced_import_setup_content_steps();
|
1166 |
+
|
1167 |
+
/*check for security again*/
|
1168 |
+
if ( ! check_ajax_referer( 'advanced_import_nonce', 'wpnonce' ) || empty( $content_slug ) || ! isset( $content[ $content_slug ] ) ) {
|
1169 |
+
wp_send_json_error(
|
1170 |
+
array(
|
1171 |
+
'error' => 1,
|
1172 |
+
'message' => esc_html__( 'No content Found', 'advanced-import' ),
|
1173 |
+
)
|
1174 |
+
);
|
1175 |
+
}
|
1176 |
+
|
1177 |
+
$json = false;
|
1178 |
+
$this_content = $content[ $content_slug ];
|
1179 |
+
|
1180 |
+
if ( isset( $_POST['proceed'] ) ) {
|
1181 |
+
|
1182 |
+
/*install the content*/
|
1183 |
+
$this->log( esc_html__( 'Starting import for ', 'advanced-import' ) . $content_slug );
|
1184 |
+
|
1185 |
+
/*init delayed posts from transient.*/
|
1186 |
+
$this->delay_posts = get_transient( 'delayed_posts' );
|
1187 |
+
if ( ! is_array( $this->delay_posts ) ) {
|
1188 |
+
$this->delay_posts = array();
|
1189 |
+
}
|
1190 |
+
|
1191 |
+
if ( ! empty( $this_content['install_callback'] ) ) {
|
1192 |
+
/*
|
1193 |
+
install_callback includes following functions
|
1194 |
+
* import_content_post_type_data
|
1195 |
+
* import_content_widgets_data
|
1196 |
+
* import_menu_and_options
|
1197 |
+
* */
|
1198 |
+
if ( $result = call_user_func( $this_content['install_callback'] ) ) {
|
1199 |
+
|
1200 |
+
$this->log( esc_html__( 'Finish writing ', 'advanced-import' ) . count( $this->delay_posts, COUNT_RECURSIVE ) . esc_html__( ' delayed posts to transient ', 'advanced-import' ) );
|
1201 |
+
set_transient( 'delayed_posts', $this->delay_posts, 60 * 60 * 24 );
|
1202 |
+
|
1203 |
+
/*
|
1204 |
+
if there is retry, retry it
|
1205 |
+
or finish it*/
|
1206 |
+
if ( is_array( $result ) && isset( $result['retry'] ) ) {
|
1207 |
+
/*we split the stuff up again.*/
|
1208 |
+
$json = array(
|
1209 |
+
'url' => admin_url( 'admin-ajax.php' ),
|
1210 |
+
'action' => 'import_content',
|
1211 |
+
'proceed' => 'true',
|
1212 |
+
'retry' => time(),
|
1213 |
+
'retry_count' => $result['retry_count'],
|
1214 |
+
'content' => $content_slug,
|
1215 |
+
'_wpnonce' => wp_create_nonce( 'advanced_import_nonce' ),
|
1216 |
+
'message' => $this_content['installing'],
|
1217 |
+
'logs' => $this->logs,
|
1218 |
+
'errors' => $this->errors,
|
1219 |
+
'template_url' => $this->current_template_url,
|
1220 |
+
'template_type' => $this->current_template_type,
|
1221 |
+
|
1222 |
+
);
|
1223 |
+
} else {
|
1224 |
+
$json = array(
|
1225 |
+
'done' => 1,
|
1226 |
+
'message' => $this_content['success'],
|
1227 |
+
'debug' => $result,
|
1228 |
+
'logs' => $this->logs,
|
1229 |
+
'errors' => $this->errors,
|
1230 |
+
);
|
1231 |
+
}
|
1232 |
+
}
|
1233 |
+
}
|
1234 |
+
} else {
|
1235 |
+
|
1236 |
+
$json = array(
|
1237 |
+
'url' => admin_url( 'admin-ajax.php' ),
|
1238 |
+
'action' => 'import_content',
|
1239 |
+
'proceed' => 'true',
|
1240 |
+
'content' => $content_slug,
|
1241 |
+
'_wpnonce' => wp_create_nonce( 'advanced_import_nonce' ),
|
1242 |
+
'message' => $this_content['installing'],
|
1243 |
+
'logs' => $this->logs,
|
1244 |
+
'errors' => $this->errors,
|
1245 |
+
'template_url' => $this->current_template_url,
|
1246 |
+
'template_type' => $this->current_template_type,
|
1247 |
+
);
|
1248 |
+
}
|
1249 |
+
|
1250 |
+
if ( $json ) {
|
1251 |
+
$json['hash'] = md5( serialize( $json ) ); /*used for checking if duplicates happen, move to next plugin*/
|
1252 |
+
wp_send_json( $json );
|
1253 |
+
} else {
|
1254 |
+
wp_send_json_error(
|
1255 |
+
array(
|
1256 |
+
'message' => esc_html__( 'Error', 'advanced-import' ),
|
1257 |
+
'logs' => $this->logs,
|
1258 |
+
'errors' => $this->errors,
|
1259 |
+
)
|
1260 |
+
);
|
1261 |
+
}
|
1262 |
+
exit;
|
1263 |
+
}
|
1264 |
+
|
1265 |
+
/*
|
1266 |
+
callback function to importing post type
|
1267 |
+
* all post type is imported from here
|
1268 |
+
* return mix
|
1269 |
+
* */
|
1270 |
+
private function import_content_post_type_data() {
|
1271 |
+
$post_type = ! empty( $_POST['content'] ) ? sanitize_text_field( $_POST['content'] ) : false;
|
1272 |
+
$all_data = $this->get_main_content_json();
|
1273 |
+
if ( ! $post_type || ! isset( $all_data[ $post_type ] ) ) {
|
1274 |
+
return false;
|
1275 |
+
}
|
1276 |
+
|
1277 |
+
/*Import 10 posts at a time*/
|
1278 |
+
$limit = 10 + ( isset( $_REQUEST['retry_count'] ) ? (int) $_REQUEST['retry_count'] : 0 );
|
1279 |
+
|
1280 |
+
$limit = apply_filters( 'advanced_import_limit_at_time', $limit );
|
1281 |
+
$x = 0;
|
1282 |
+
foreach ( $all_data[ $post_type ] as $post_data ) {
|
1283 |
+
|
1284 |
+
$this->process_import_single_post( $post_type, $post_data );
|
1285 |
+
|
1286 |
+
if ( $x ++ > $limit ) {
|
1287 |
+
return array(
|
1288 |
+
'retry' => 1,
|
1289 |
+
'retry_count' => $limit,
|
1290 |
+
);
|
1291 |
+
}
|
1292 |
+
}
|
1293 |
+
|
1294 |
+
/*processed delayed posts*/
|
1295 |
+
$this->process_delayed_posts();
|
1296 |
+
|
1297 |
+
/*process child posts*/
|
1298 |
+
$this->processpost_orphans();
|
1299 |
+
|
1300 |
+
return true;
|
1301 |
+
|
1302 |
+
}
|
1303 |
+
|
1304 |
+
/*
|
1305 |
+
set and get transient imported_term_ids
|
1306 |
+
return mix*/
|
1307 |
+
public function imported_term_id( $original_term_id, $new_term_id = false ) {
|
1308 |
+
$terms = get_transient( 'imported_term_ids' );
|
1309 |
+
if ( ! is_array( $terms ) ) {
|
1310 |
+
$terms = array();
|
1311 |
+
}
|
1312 |
+
if ( $new_term_id ) {
|
1313 |
+
if ( ! isset( $terms[ $original_term_id ] ) ) {
|
1314 |
+
$this->log( esc_html__( 'Insert old TERM ID ', 'advanced-import' ) . $original_term_id . esc_html__( ' as new TERM ID: ', 'advanced-import' ) . $new_term_id );
|
1315 |
+
} elseif ( $terms[ $original_term_id ] != $new_term_id ) {
|
1316 |
+
$this->error( 'Replacement OLD TERM ID ' . $original_term_id . ' overwritten by new TERM ID: ' . $new_term_id );
|
1317 |
+
}
|
1318 |
+
$terms[ $original_term_id ] = $new_term_id;
|
1319 |
+
set_transient( 'imported_term_ids', $terms, 60 * 60 * 24 );
|
1320 |
+
} elseif ( $original_term_id && isset( $terms[ $original_term_id ] ) ) {
|
1321 |
+
return $terms[ $original_term_id ];
|
1322 |
+
}
|
1323 |
+
|
1324 |
+
return false;
|
1325 |
+
}
|
1326 |
+
|
1327 |
+
/*
|
1328 |
+
set and get imported_post_ids
|
1329 |
+
return mix*/
|
1330 |
+
public function imported_post_id( $original_id = false, $new_id = false ) {
|
1331 |
+
if ( is_array( $original_id ) || is_object( $original_id ) ) {
|
1332 |
+
return false;
|
1333 |
+
}
|
1334 |
+
$post_ids = get_transient( 'imported_post_ids' );
|
1335 |
+
if ( ! is_array( $post_ids ) ) {
|
1336 |
+
$post_ids = array();
|
1337 |
+
}
|
1338 |
+
if ( $new_id ) {
|
1339 |
+
if ( ! isset( $post_ids[ $original_id ] ) ) {
|
1340 |
+
$this->log( esc_html__( 'Insert old ID ', 'advanced-import' ) . $original_id . esc_html__( ' as new ID: ', 'advanced-import' ) . $new_id );
|
1341 |
+
} elseif ( $post_ids[ $original_id ] != $new_id ) {
|
1342 |
+
$this->error( esc_html__( 'Replacement OLD ID ', 'advanced-import' ) . $original_id . ' overwritten by new ID: ' . $new_id );
|
1343 |
+
}
|
1344 |
+
$post_ids[ $original_id ] = $new_id;
|
1345 |
+
set_transient( 'imported_post_ids', $post_ids, 60 * 60 * 24 );
|
1346 |
+
} elseif ( $original_id && isset( $post_ids[ $original_id ] ) ) {
|
1347 |
+
return $post_ids[ $original_id ];
|
1348 |
+
} elseif ( $original_id === false ) {
|
1349 |
+
return $post_ids;
|
1350 |
+
}
|
1351 |
+
return false;
|
1352 |
+
}
|
1353 |
+
|
1354 |
+
/*
|
1355 |
+
set and get post_orphans/post parent
|
1356 |
+
if parent is not already imported the child will be orphan
|
1357 |
+
return mix*/
|
1358 |
+
private function post_orphans( $original_id = false, $missing_parent_id = false ) {
|
1359 |
+
$post_ids = get_transient( 'post_orphans' );
|
1360 |
+
if ( ! is_array( $post_ids ) ) {
|
1361 |
+
$post_ids = array();
|
1362 |
+
}
|
1363 |
+
if ( $missing_parent_id ) {
|
1364 |
+
$post_ids[ $original_id ] = $missing_parent_id;
|
1365 |
+
set_transient( 'post_orphans', $post_ids, 60 * 60 * 24 );
|
1366 |
+
} elseif ( $original_id && isset( $post_ids[ $original_id ] ) ) {
|
1367 |
+
return $post_ids[ $original_id ];
|
1368 |
+
} elseif ( $original_id === false ) {
|
1369 |
+
return $post_ids;
|
1370 |
+
}
|
1371 |
+
return false;
|
1372 |
+
}
|
1373 |
+
|
1374 |
+
|
1375 |
+
/*set delayed post for later process*/
|
1376 |
+
private function delay_post_process( $post_type, $post_data ) {
|
1377 |
+
if ( ! isset( $this->delay_posts[ $post_type ] ) ) {
|
1378 |
+
$this->delay_posts[ $post_type ] = array();
|
1379 |
+
}
|
1380 |
+
$this->delay_posts[ $post_type ][ $post_data['post_id'] ] = $post_data;
|
1381 |
+
}
|
1382 |
+
|
1383 |
+
|
1384 |
+
/*
|
1385 |
+
Important Function
|
1386 |
+
Import single Post/Content
|
1387 |
+
*/
|
1388 |
+
private function process_import_single_post( $post_type, $post_data, $delayed = 0 ) {
|
1389 |
+
|
1390 |
+
$this->log( esc_html__( 'Processing ', 'advanced-import' ) . $post_type . ' ' . $post_data['post_id'] );
|
1391 |
+
$original_post_data = $post_data;
|
1392 |
+
|
1393 |
+
/*if there is not post type return false*/
|
1394 |
+
if ( ! post_type_exists( $post_type ) ) {
|
1395 |
+
return false;
|
1396 |
+
}
|
1397 |
+
|
1398 |
+
/*if it is aready imported return*/
|
1399 |
+
if ( $this->imported_post_id( $post_data['post_id'] ) ) {
|
1400 |
+
return true; /*already done*/
|
1401 |
+
}
|
1402 |
+
|
1403 |
+
/*set post_name id for empty post name/title*/
|
1404 |
+
if ( empty( $post_data['post_title'] ) && empty( $post_data['post_name'] ) ) {
|
1405 |
+
$post_data['post_name'] = $post_data['post_id'];
|
1406 |
+
}
|
1407 |
+
|
1408 |
+
/*set post_type on $post_data*/
|
1409 |
+
$post_data['post_type'] = $post_type;
|
1410 |
+
|
1411 |
+
/*post_orphans/post parent management */
|
1412 |
+
$post_parent = isset( $post_data['post_parent'] ) ? absint( $post_data['post_parent'] ) : false;
|
1413 |
+
if ( $post_parent ) {
|
1414 |
+
/*if we already know the parent, map it to the new local imported ID*/
|
1415 |
+
if ( $this->imported_post_id( $post_parent ) ) {
|
1416 |
+
$post_data['post_parent'] = $this->imported_post_id( $post_parent );
|
1417 |
+
} else {
|
1418 |
+
/*if there is not parent imported, child will be orphans*/
|
1419 |
+
$this->post_orphans( absint( $post_data['post_id'] ), $post_parent );
|
1420 |
+
$post_data['post_parent'] = 0;
|
1421 |
+
}
|
1422 |
+
}
|
1423 |
+
|
1424 |
+
/*check if already exists by post_name*/
|
1425 |
+
if ( empty( $post_data['post_title'] ) && ! empty( $post_data['post_name'] ) ) {
|
1426 |
+
global $wpdb;
|
1427 |
+
$sql = "
|
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 |
+
$pages = $wpdb->get_results(
|
1434 |
+
$wpdb->prepare(
|
1435 |
+
$sql,
|
1436 |
+
array(
|
1437 |
+
$post_data['post_name'],
|
1438 |
+
$post_type,
|
1439 |
+
)
|
1440 |
+
),
|
1441 |
+
OBJECT_K
|
1442 |
+
);
|
1443 |
+
|
1444 |
+
$foundid = 0;
|
1445 |
+
foreach ( (array) $pages as $page ) {
|
1446 |
+
if ( $page->post_name == $post_data['post_name'] && empty( $page->post_title ) ) {
|
1447 |
+
$foundid = $page->ID;
|
1448 |
+
}
|
1449 |
+
}
|
1450 |
+
|
1451 |
+
/*if we have found id by post_name, imported_post_id and return*/
|
1452 |
+
if ( $foundid ) {
|
1453 |
+
$this->imported_post_id( $post_data['post_id'], $foundid );
|
1454 |
+
return true;
|
1455 |
+
}
|
1456 |
+
}
|
1457 |
+
|
1458 |
+
/*
|
1459 |
+
check if already exists by post_name and post_title*/
|
1460 |
+
/*don't use post_exists because it will dupe up on media with same name but different slug*/
|
1461 |
+
if ( ! empty( $post_data['post_title'] ) && ! empty( $post_data['post_name'] ) ) {
|
1462 |
+
global $wpdb;
|
1463 |
+
$sql = "
|
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 |
+
$pages = $wpdb->get_results(
|
1471 |
+
$wpdb->prepare(
|
1472 |
+
$sql,
|
1473 |
+
array(
|
1474 |
+
$post_data['post_name'],
|
1475 |
+
$post_data['post_title'],
|
1476 |
+
$post_type,
|
1477 |
+
)
|
1478 |
+
),
|
1479 |
+
OBJECT_K
|
1480 |
+
);
|
1481 |
+
|
1482 |
+
$foundid = 0;
|
1483 |
+
foreach ( (array) $pages as $page ) {
|
1484 |
+
if ( $page->post_name == $post_data['post_name'] ) {
|
1485 |
+
$foundid = $page->ID;
|
1486 |
+
}
|
1487 |
+
}
|
1488 |
+
|
1489 |
+
/*if we have found id by post_name and post_title, imported_post_id and return*/
|
1490 |
+
if ( $foundid ) {
|
1491 |
+
$this->imported_post_id( $post_data['post_id'], $foundid );
|
1492 |
+
return true;
|
1493 |
+
}
|
1494 |
+
}
|
1495 |
+
|
1496 |
+
/*
|
1497 |
+
* todo it may not required
|
1498 |
+
* backwards compat with old import format.*/
|
1499 |
+
if ( isset( $post_data['meta'] ) ) {
|
1500 |
+
foreach ( $post_data['meta'] as $key => $meta ) {
|
1501 |
+
if ( is_array( $meta ) && count( $meta ) == 1 ) {
|
1502 |
+
$single_meta = current( $meta );
|
1503 |
+
if ( ! is_array( $single_meta ) ) {
|
1504 |
+
$post_data['meta'][ $key ] = $single_meta;
|
1505 |
+
}
|
1506 |
+
}
|
1507 |
+
}
|
1508 |
+
}
|
1509 |
+
|
1510 |
+
/*finally process*/
|
1511 |
+
switch ( $post_type ) {
|
1512 |
+
|
1513 |
+
/*case attachment*/
|
1514 |
+
case 'attachment':
|
1515 |
+
/*import media via url*/
|
1516 |
+
if ( isset( $post_data['guid'] ) && ! empty( $post_data['guid'] ) ) {
|
1517 |
+
|
1518 |
+
/*check if this has already been imported.*/
|
1519 |
+
$old_guid = $post_data['guid'];
|
1520 |
+
if ( $this->imported_post_id( $old_guid ) ) {
|
1521 |
+
return true; /*already done*/
|
1522 |
+
}
|
1523 |
+
|
1524 |
+
// ignore post parent, we haven't imported those yet.
|
1525 |
+
// $file_data = wp_remote_get($post_data['guid']);
|
1526 |
+
$remote_url = $post_data['guid'];
|
1527 |
+
|
1528 |
+
$post_data['upload_date'] = date( 'Y/m', strtotime( $post_data['post_date_gmt'] ) );
|
1529 |
+
|
1530 |
+
if ( isset( $post_data['meta'] ) ) {
|
1531 |
+
foreach ( $post_data['meta'] as $key => $meta ) {
|
1532 |
+
if ( $key == '_wp_attached_file' ) {
|
1533 |
+
foreach ( (array) $meta as $meta_val ) {
|
1534 |
+
if ( preg_match( '%^[0-9]{4}/[0-9]{2}%', $meta_val, $matches ) ) {
|
1535 |
+
$post_data['upload_date'] = $matches[0];
|
1536 |
+
}
|
1537 |
+
}
|
1538 |
+
}
|
1539 |
+
}
|
1540 |
+
}
|
1541 |
+
|
1542 |
+
/*upload the file*/
|
1543 |
+
$upload = $this->import_image_and_file( $remote_url, $post_data );
|
1544 |
+
|
1545 |
+
/*if error on upload*/
|
1546 |
+
if ( ! is_array( $upload ) || is_wp_error( $upload ) ) {
|
1547 |
+
/*todo: error*/
|
1548 |
+
return false;
|
1549 |
+
}
|
1550 |
+
|
1551 |
+
/*check file type, if file type not found return false*/
|
1552 |
+
if ( $info = wp_check_filetype( $upload['file'] ) ) {
|
1553 |
+
$post_data['post_mime_type'] = $info['type'];
|
1554 |
+
} else {
|
1555 |
+
return false;
|
1556 |
+
}
|
1557 |
+
|
1558 |
+
/*set guid file url*/
|
1559 |
+
$post_data['guid'] = $upload['url'];
|
1560 |
+
|
1561 |
+
/*
|
1562 |
+
* insert attachment
|
1563 |
+
*https://developer.wordpress.org/reference/functions/wp_insert_attachment/
|
1564 |
+
* */
|
1565 |
+
$attach_id = wp_insert_attachment( $post_data, $upload['file'] );
|
1566 |
+
if ( $attach_id ) {
|
1567 |
+
|
1568 |
+
/*update meta*/
|
1569 |
+
if ( ! empty( $post_data['meta'] ) ) {
|
1570 |
+
foreach ( $post_data['meta'] as $meta_key => $meta_val ) {
|
1571 |
+
if ( $meta_key != '_wp_attached_file' && ! empty( $meta_val ) ) {
|
1572 |
+
update_post_meta( $attach_id, $meta_key, $meta_val );
|
1573 |
+
}
|
1574 |
+
}
|
1575 |
+
}
|
1576 |
+
/* Update metadata for an attachment.*/
|
1577 |
+
wp_update_attachment_metadata( $attach_id, wp_generate_attachment_metadata( $attach_id, $upload['file'] ) );
|
1578 |
+
|
1579 |
+
/*remap resized image URLs, works by stripping the extension and remapping the URL stub.*/
|
1580 |
+
if ( preg_match( '!^image/!', $info['type'] ) ) {
|
1581 |
+
$parts = pathinfo( $remote_url );
|
1582 |
+
$name = basename( $parts['basename'], ".{$parts['extension']}" ); // PATHINFO_FILENAME in PHP 5.2
|
1583 |
+
|
1584 |
+
$parts_new = pathinfo( $upload['url'] );
|
1585 |
+
$name_new = basename( $parts_new['basename'], ".{$parts_new['extension']}" );
|
1586 |
+
|
1587 |
+
$this->imported_post_id( $parts['dirname'] . '/' . $name, $parts_new['dirname'] . '/' . $name_new );
|
1588 |
+
}
|
1589 |
+
$this->imported_post_id( $post_data['post_id'], $attach_id );
|
1590 |
+
}
|
1591 |
+
}
|
1592 |
+
break;
|
1593 |
+
|
1594 |
+
default:
|
1595 |
+
/*Process Post Meta*/
|
1596 |
+
if ( ! empty( $post_data['meta'] ) && is_array( $post_data['meta'] ) ) {
|
1597 |
+
|
1598 |
+
/*fix for double json encoded stuff*/
|
1599 |
+
foreach ( $post_data['meta'] as $meta_key => $meta_val ) {
|
1600 |
+
if ( is_string( $meta_val ) && strlen( $meta_val ) && $meta_val[0] == '[' ) {
|
1601 |
+
$test_json = @json_decode( $meta_val, true );
|
1602 |
+
if ( is_array( $test_json ) ) {
|
1603 |
+
$post_data['meta'][ $meta_key ] = $test_json;
|
1604 |
+
}
|
1605 |
+
}
|
1606 |
+
}
|
1607 |
+
|
1608 |
+
array_walk_recursive( $post_data['meta'], array( advanced_import_elementor(), 'elementor_id_import' ) );
|
1609 |
+
|
1610 |
+
/*todo gutenberg and page builders*/
|
1611 |
+
|
1612 |
+
/*
|
1613 |
+
replace menu data
|
1614 |
+
work out what we're replacing. a tax, page, term etc..*/
|
1615 |
+
if ( isset( $post_data['meta']['_menu_item_menu_item_parent'] ) && 0 != $post_data['meta']['_menu_item_menu_item_parent'] ) {
|
1616 |
+
$new_parent_id = $this->imported_post_id( $post_data['meta']['_menu_item_menu_item_parent'] );
|
1617 |
+
if ( ! $new_parent_id ) {
|
1618 |
+
if ( $delayed ) {
|
1619 |
+
/*already delayed, unable to find this meta value, skip inserting it*/
|
1620 |
+
$this->error( esc_html__( 'Unable to find replacement. Continue anyway.... content will most likely break..', 'advanced-import' ) );
|
1621 |
+
} else {
|
1622 |
+
/*not found , delay it*/
|
1623 |
+
$this->error( esc_html__( 'Unable to find replacement. Delaying....', 'advanced-import' ) );
|
1624 |
+
$this->delay_post_process( $post_type, $original_post_data );
|
1625 |
+
return false;
|
1626 |
+
}
|
1627 |
+
}
|
1628 |
+
$post_data['meta']['_menu_item_menu_item_parent'] = $new_parent_id;
|
1629 |
+
}
|
1630 |
+
|
1631 |
+
/*if _menu_item_type*/
|
1632 |
+
if ( isset( $post_data['meta']['_menu_item_type'] ) ) {
|
1633 |
+
|
1634 |
+
switch ( $post_data['meta']['_menu_item_type'] ) {
|
1635 |
+
case 'post_type':
|
1636 |
+
if ( ! empty( $post_data['meta']['_menu_item_object_id'] ) ) {
|
1637 |
+
$new_parent_id = $this->imported_post_id( $post_data['meta']['_menu_item_object_id'] );
|
1638 |
+
if ( ! $new_parent_id ) {
|
1639 |
+
if ( $delayed ) {
|
1640 |
+
/*already delayed, unable to find this meta value, skip inserting it*/
|
1641 |
+
$this->error( esc_html__( 'Unable to find replacement. Continue anyway.... content will most likely break..', 'advanced-import' ) );
|
1642 |
+
} else {
|
1643 |
+
/*not found , delay it*/
|
1644 |
+
$this->error( esc_html__( 'Unable to find replacement. Delaying....', 'advanced-import' ) );
|
1645 |
+
$this->delay_post_process( $post_type, $original_post_data );
|
1646 |
+
return false;
|
1647 |
+
}
|
1648 |
+
}
|
1649 |
+
$post_data['meta']['_menu_item_object_id'] = $new_parent_id;
|
1650 |
+
}
|
1651 |
+
break;
|
1652 |
+
|
1653 |
+
case 'taxonomy':
|
1654 |
+
if ( ! empty( $post_data['meta']['_menu_item_object_id'] ) ) {
|
1655 |
+
$new_parent_id = $this->imported_term_id( $post_data['meta']['_menu_item_object_id'] );
|
1656 |
+
if ( ! $new_parent_id ) {
|
1657 |
+
if ( $delayed ) {
|
1658 |
+
/*already delayed, unable to find this meta value, skip inserting it*/
|
1659 |
+
$this->error( esc_html__( 'Unable to find replacement. Continue anyway.... content will most likely break..', 'advanced-import' ) );
|
1660 |
+
} else {
|
1661 |
+
/*not found , delay it*/
|
1662 |
+
$this->error( esc_html__( 'Unable to find replacement. Delaying....', 'advanced-import' ) );
|
1663 |
+
$this->delay_post_process( $post_type, $original_post_data );
|
1664 |
+
return false;
|
1665 |
+
}
|
1666 |
+
}
|
1667 |
+
$post_data['meta']['_menu_item_object_id'] = $new_parent_id;
|
1668 |
+
}
|
1669 |
+
break;
|
1670 |
+
}
|
1671 |
+
}
|
1672 |
+
}
|
1673 |
+
|
1674 |
+
/*
|
1675 |
+
post content parser
|
1676 |
+
for shortcode post id replacement*/
|
1677 |
+
$post_data['post_content'] = $this->parse_shortcode_meta_content( $post_data['post_content'] );
|
1678 |
+
|
1679 |
+
$replace_tax_id_keys = array(
|
1680 |
+
'taxonomies',
|
1681 |
+
);
|
1682 |
+
foreach ( $replace_tax_id_keys as $replace_key ) {
|
1683 |
+
if ( preg_match_all( '# ' . $replace_key . '="(\d+)"#', $post_data['post_content'], $matches ) ) {
|
1684 |
+
foreach ( $matches[0] as $match_id => $string ) {
|
1685 |
+
$new_id = $this->imported_term_id( $matches[1][ $match_id ] );
|
1686 |
+
if ( $new_id ) {
|
1687 |
+
$post_data['post_content'] = str_replace( $string, ' ' . $replace_key . '="' . $new_id . '"', $post_data['post_content'] );
|
1688 |
+
} else {
|
1689 |
+
$this->error( esc_html__( 'Unable to find TAXONOMY replacement for ', 'advanced-import' ) . $replace_key . '="' . $matches[1][ $match_id ] . esc_html__( 'in content.', 'advanced-import' ) );
|
1690 |
+
if ( $delayed ) {
|
1691 |
+
/*already delayed, unable to find this meta value, skip inserting it*/
|
1692 |
+
$this->error( esc_html__( 'Unable to find replacement. Continue anyway.... content will most likely break..', 'advanced-import' ) );
|
1693 |
+
} else {
|
1694 |
+
/*not found , delay it*/
|
1695 |
+
$this->delay_post_process( $post_type, $original_post_data );
|
1696 |
+
return false;
|
1697 |
+
}
|
1698 |
+
}
|
1699 |
+
}
|
1700 |
+
}
|
1701 |
+
}
|
1702 |
+
|
1703 |
+
/*do further filter if you need*/
|
1704 |
+
$post_data = apply_filters( 'advanced_import_post_data', $post_data );
|
1705 |
+
|
1706 |
+
/*finally insert post data*/
|
1707 |
+
$post_id = wp_insert_post( $post_data, true );
|
1708 |
+
if ( ! is_wp_error( $post_id ) ) {
|
1709 |
+
|
1710 |
+
/*set id on imported_post_id*/
|
1711 |
+
$this->imported_post_id( $post_data['post_id'], $post_id );
|
1712 |
+
|
1713 |
+
/*add/update post meta*/
|
1714 |
+
if ( ! empty( $post_data['meta'] ) ) {
|
1715 |
+
foreach ( $post_data['meta'] as $meta_key => $meta_val ) {
|
1716 |
+
/*if the post has a featured image, take note of this in case of remap*/
|
1717 |
+
if ( '_thumbnail_id' == $meta_key ) {
|
1718 |
+
/*find this inserted id and use that instead.*/
|
1719 |
+
$inserted_id = $this->imported_post_id( intval( $meta_val ) );
|
1720 |
+
if ( $inserted_id ) {
|
1721 |
+
$meta_val = $inserted_id;
|
1722 |
+
}
|
1723 |
+
}
|
1724 |
+
/*update meta*/
|
1725 |
+
update_post_meta( $post_id, $meta_key, $meta_val );
|
1726 |
+
}
|
1727 |
+
}
|
1728 |
+
|
1729 |
+
if ( ! empty( $post_data['terms'] ) ) {
|
1730 |
+
$terms_to_set = array();
|
1731 |
+
foreach ( $post_data['terms'] as $term_slug => $terms ) {
|
1732 |
+
foreach ( $terms as $term ) {
|
1733 |
+
$taxonomy = $term['taxonomy'];
|
1734 |
+
if ( taxonomy_exists( $taxonomy ) ) {
|
1735 |
+
$term_exists = term_exists( $term['slug'], $taxonomy );
|
1736 |
+
$term_id = is_array( $term_exists ) ? $term_exists['term_id'] : $term_exists;
|
1737 |
+
if ( ! $term_id ) {
|
1738 |
+
if ( ! empty( $term['parent'] ) ) {
|
1739 |
+
/*see if we have imported this yet?*/
|
1740 |
+
$term['parent'] = $this->imported_term_id( $term['parent'] );
|
1741 |
+
}
|
1742 |
+
$term_id_tax_id = wp_insert_term( $term['name'], $taxonomy, $term );
|
1743 |
+
if ( ! is_wp_error( $term_id_tax_id ) ) {
|
1744 |
+
$term_id = $term_id_tax_id['term_id'];
|
1745 |
+
} else {
|
1746 |
+
// todo - error
|
1747 |
+
continue;
|
1748 |
+
}
|
1749 |
+
}
|
1750 |
+
/*set term_id on imported_term_id*/
|
1751 |
+
$this->imported_term_id( $term['term_id'], $term_id );
|
1752 |
+
|
1753 |
+
/*add the term meta.*/
|
1754 |
+
if ( $term_id && ! empty( $term['meta'] ) && is_array( $term['meta'] ) ) {
|
1755 |
+
foreach ( $term['meta'] as $meta_key => $meta_val ) {
|
1756 |
+
// we have to replace certain meta_key/meta_val
|
1757 |
+
// e.g. thumbnail id from woocommerce product categories.
|
1758 |
+
switch ( $meta_key ) {
|
1759 |
+
case 'thumbnail_id':
|
1760 |
+
if ( $new_meta_val = $this->imported_post_id( $meta_val ) ) {
|
1761 |
+
/*use this new id.*/
|
1762 |
+
$meta_val = $new_meta_val;
|
1763 |
+
}
|
1764 |
+
break;
|
1765 |
+
}
|
1766 |
+
update_term_meta( $term_id, $meta_key, $meta_val );
|
1767 |
+
}
|
1768 |
+
}
|
1769 |
+
$terms_to_set[ $taxonomy ][] = intval( $term_id );
|
1770 |
+
}
|
1771 |
+
}
|
1772 |
+
}
|
1773 |
+
foreach ( $terms_to_set as $tax => $ids ) {
|
1774 |
+
wp_set_post_terms( $post_id, $ids, $tax );
|
1775 |
+
}
|
1776 |
+
|
1777 |
+
if ( ( isset( $post_data['meta']['_elementor_data'] ) && ! empty( $post_data['meta']['_elementor_data'] ) ) ||
|
1778 |
+
( isset( $post_data['meta']['_elementor_css'] ) && ! ! empty( $post_data['meta']['_elementor_css'] ) )
|
1779 |
+
) {
|
1780 |
+
advanced_import_elementor()->elementor_post( $post_id );
|
1781 |
+
}
|
1782 |
+
|
1783 |
+
/*Gutentor*/
|
1784 |
+
$post = get_post( $post_id );
|
1785 |
+
$content = $post->post_content;
|
1786 |
+
if ( preg_match_all( '/data-gpid="(.*?)\" /', $content, $matches ) ) {
|
1787 |
+
foreach ( $matches[0] as $match_id => $string ) {
|
1788 |
+
$content = str_replace( $matches[0][ $match_id ], 'data-gpid="' . $post_id . '" ', $content );
|
1789 |
+
}
|
1790 |
+
}
|
1791 |
+
$post->post_content = $content;
|
1792 |
+
wp_update_post( $post );
|
1793 |
+
}
|
1794 |
+
}
|
1795 |
+
break;
|
1796 |
+
}
|
1797 |
+
|
1798 |
+
return true;
|
1799 |
+
}
|
1800 |
+
|
1801 |
+
/*Shortcode/Meta/Post Ids fixed start*/
|
1802 |
+
|
1803 |
+
/*
|
1804 |
+
* since 1.2.3
|
1805 |
+
* return the difference in length between two strings
|
1806 |
+
* */
|
1807 |
+
public function strlen_diff( $a, $b ) {
|
1808 |
+
return strlen( $b ) - strlen( $a );
|
1809 |
+
}
|
1810 |
+
|
1811 |
+
|
1812 |
+
/*
|
1813 |
+
* since 1.2.3
|
1814 |
+
* helper function to parse url, shortcode, post ids form provided content
|
1815 |
+
* * currently uses on meta and post content
|
1816 |
+
* */
|
1817 |
+
public function parse_shortcode_meta_content( $content ) {
|
1818 |
+
/*we have to format the post content. rewriting images and gallery stuff*/
|
1819 |
+
$replace = $this->imported_post_id();
|
1820 |
+
|
1821 |
+
/*filters urls for replace*/
|
1822 |
+
$urls_replace = array();
|
1823 |
+
foreach ( $replace as $key => $val ) {
|
1824 |
+
if ( $key && $val && ! is_numeric( $key ) && ! is_numeric( $val ) ) {
|
1825 |
+
$urls_replace[ $key ] = $val;
|
1826 |
+
}
|
1827 |
+
}
|
1828 |
+
/*replace image/file urls*/
|
1829 |
+
if ( $urls_replace ) {
|
1830 |
+
uksort( $urls_replace, array( &$this, 'strlen_diff' ) );
|
1831 |
+
foreach ( $urls_replace as $from_url => $to_url ) {
|
1832 |
+
$content = str_replace( $from_url, $to_url, $content );
|
1833 |
+
}
|
1834 |
+
}
|
1835 |
+
|
1836 |
+
/*gallery fixed*/
|
1837 |
+
if ( preg_match_all( '#\[gallery[^\]]*\]#', $content, $matches ) ) {
|
1838 |
+
foreach ( $matches[0] as $match_id => $string ) {
|
1839 |
+
if ( preg_match( '#ids="([^"]+)"#', $string, $ids_matches ) ) {
|
1840 |
+
$ids = explode( ',', $ids_matches[1] );
|
1841 |
+
foreach ( $ids as $key => $val ) {
|
1842 |
+
$new_id = $val ? $this->imported_post_id( $val ) : false;
|
1843 |
+
if ( ! $new_id ) {
|
1844 |
+
unset( $ids[ $key ] );
|
1845 |
+
} else {
|
1846 |
+
$ids[ $key ] = $new_id;
|
1847 |
+
}
|
1848 |
+
}
|
1849 |
+
$new_ids = implode( ',', $ids );
|
1850 |
+
$content = str_replace( $ids_matches[0], 'ids="' . $new_ids . '"', $content );
|
1851 |
+
}
|
1852 |
+
}
|
1853 |
+
}
|
1854 |
+
|
1855 |
+
/*contact form 7 id fixes.*/
|
1856 |
+
if ( preg_match_all( '#\[contact-form-7[^\]]*\]#', $content, $matches ) ) {
|
1857 |
+
foreach ( $matches[0] as $match_id => $string ) {
|
1858 |
+
if ( preg_match( '#id="(\d+)"#', $string, $id_match ) ) {
|
1859 |
+
$new_id = $this->imported_post_id( $id_match[1] );
|
1860 |
+
if ( $new_id ) {
|
1861 |
+
$content = str_replace( $id_match[0], 'id="' . $new_id . '"', $content );
|
1862 |
+
} else {
|
1863 |
+
/*no imported ID found. remove this entry.*/
|
1864 |
+
$content = str_replace( $matches[0], '(insert contact form here)', $content );
|
1865 |
+
}
|
1866 |
+
}
|
1867 |
+
}
|
1868 |
+
}
|
1869 |
+
|
1870 |
+
/*Gutentor*/
|
1871 |
+
if ( preg_match_all( '/\"pTaxTerm"(.*?)\]/', $content, $matches ) ) {
|
1872 |
+
foreach ( $matches[0] as $match_id => $string ) {
|
1873 |
+
if ( preg_match_all( '/\"value":(.*?)\}/', $string, $matches1 ) ) {
|
1874 |
+
foreach ( $matches1[0] as $match_id1 => $string1 ) {
|
1875 |
+
$new_id = $this->imported_term_id( $matches1[1][ $match_id1 ] );
|
1876 |
+
$content = str_replace( $string1, '"value":' . $new_id . '}', $content );
|
1877 |
+
}
|
1878 |
+
}
|
1879 |
+
}
|
1880 |
+
}
|
1881 |
+
if ( preg_match_all( '/\"e14TaxTerm"(.*?)\]/', $content, $matches ) ) {
|
1882 |
+
foreach ( $matches[0] as $match_id => $string ) {
|
1883 |
+
if ( preg_match_all( '/\"value":(.*?)\}/', $string, $matches1 ) ) {
|
1884 |
+
foreach ( $matches1[0] as $match_id1 => $string1 ) {
|
1885 |
+
$new_id = $this->imported_term_id( $matches1[1][ $match_id1 ] );
|
1886 |
+
$content = str_replace( $string1, '"value":' . $new_id . '}', $content );
|
1887 |
+
}
|
1888 |
+
}
|
1889 |
+
}
|
1890 |
+
}
|
1891 |
+
if ( preg_match_all( '/data-gpid="(.*?)\" /', $content, $matches ) ) {
|
1892 |
+
foreach ( $matches[0] as $match_id => $string ) {
|
1893 |
+
$new_id = $this->imported_post_id( $matches[1][ $match_id ] );
|
1894 |
+
$content = str_replace( $matches[0][ $match_id ], 'data-gpid="' . $new_id . '" ', $content );
|
1895 |
+
}
|
1896 |
+
}
|
1897 |
+
if ( preg_match_all( '/\"p4PostId"(.*?)\,/', $content, $matches ) ) {
|
1898 |
+
foreach ( $matches[0] as $match_id => $string ) {
|
1899 |
+
$new_id = $this->imported_post_id( $matches[1][ $match_id ] );
|
1900 |
+
$content = str_replace( $matches[0][ $match_id ], '"p4PostId":' . $new_id . ',', $content );
|
1901 |
+
}
|
1902 |
+
}
|
1903 |
+
return $content;
|
1904 |
+
}
|
1905 |
+
/*Shortcode/Meta/Post Ids fixed end*/
|
1906 |
+
|
1907 |
+
/*update parent page id for child page*/
|
1908 |
+
private function processpost_orphans() {
|
1909 |
+
|
1910 |
+
/*get post orphans to find it parent*/
|
1911 |
+
$orphans = $this->post_orphans();
|
1912 |
+
foreach ( $orphans as $original_post_id => $original_post_parent_id ) {
|
1913 |
+
if ( $original_post_parent_id ) {
|
1914 |
+
if ( $this->imported_post_id( $original_post_id ) && $this->imported_post_id( $original_post_parent_id ) ) {
|
1915 |
+
$post_data = array();
|
1916 |
+
$post_data['ID'] = $this->imported_post_id( $original_post_id );
|
1917 |
+
$post_data['post_parent'] = $this->imported_post_id( $original_post_parent_id );
|
1918 |
+
wp_update_post( $post_data );
|
1919 |
+
$this->post_orphans( $original_post_id, 0 ); /*ignore future*/
|
1920 |
+
}
|
1921 |
+
}
|
1922 |
+
}
|
1923 |
+
}
|
1924 |
+
|
1925 |
+
/*
|
1926 |
+
Process delayed post
|
1927 |
+
*/
|
1928 |
+
private function process_delayed_posts( $last_delay = false ) {
|
1929 |
+
|
1930 |
+
$this->log( esc_html__( 'Processing ', 'advanced-import' ) . count( $this->delay_posts, COUNT_RECURSIVE ) . esc_html__( 'delayed posts', 'advanced-import' ) );
|
1931 |
+
for ( $x = 1; $x < 4; $x ++ ) {
|
1932 |
+
foreach ( $this->delay_posts as $delayed_post_type => $delayed_post_data_s ) {
|
1933 |
+
foreach ( $delayed_post_data_s as $delayed_post_id => $delayed_post_data ) {
|
1934 |
+
|
1935 |
+
/*already processed*/
|
1936 |
+
if ( $this->imported_post_id( $delayed_post_data['post_id'] ) ) {
|
1937 |
+
$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' ) );
|
1938 |
+
|
1939 |
+
/*already processed, remove it from delay_posts*/
|
1940 |
+
unset( $this->delay_posts[ $delayed_post_type ][ $delayed_post_id ] );
|
1941 |
+
$this->log( esc_html__( ' ( ', 'advanced-import' ) . count( $this->delay_posts, COUNT_RECURSIVE ) . esc_html__( ' delayed posts remain ) ', 'advanced-import' ) );
|
1942 |
+
}
|
1943 |
+
/*Process it*/
|
1944 |
+
elseif ( $this->process_import_single_post( $delayed_post_type, $delayed_post_data, $last_delay ) ) {
|
1945 |
+
$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'] );
|
1946 |
+
|
1947 |
+
/*successfully 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 |
+
} else {
|
1951 |
+
$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'] );
|
1952 |
+
}
|
1953 |
+
}
|
1954 |
+
}
|
1955 |
+
}
|
1956 |
+
}
|
1957 |
+
|
1958 |
+
/*Get file from url , download it and add to local*/
|
1959 |
+
private function import_image_and_file( $url, $post ) {
|
1960 |
+
|
1961 |
+
/*extract the file name and extension from the url*/
|
1962 |
+
$file_name = basename( $url );
|
1963 |
+
$local_file = ADVANCED_IMPORT_TEMP_UPLOADS . $file_name;
|
1964 |
+
$upload = false;
|
1965 |
+
|
1966 |
+
/*
|
1967 |
+
if file is already on local, return file information
|
1968 |
+
It means media is on local, while exporting media*/
|
1969 |
+
if ( is_file( $local_file ) && filesize( $local_file ) > 0 ) {
|
1970 |
+
require_once ABSPATH . 'wp-admin/includes/file.php';
|
1971 |
+
WP_Filesystem();
|
1972 |
+
global $wp_filesystem;
|
1973 |
+
$file_data = $wp_filesystem->get_contents( $local_file );
|
1974 |
+
$upload = wp_upload_bits( $file_name, 0, $file_data, $post['upload_date'] );
|
1975 |
+
if ( $upload['error'] ) {
|
1976 |
+
return new WP_Error( 'upload_dir_error', $upload['error'] );
|
1977 |
+
}
|
1978 |
+
}
|
1979 |
+
|
1980 |
+
/*if there is no file on local or error on local file need to fetch it*/
|
1981 |
+
if ( ! $upload || $upload['error'] ) {
|
1982 |
+
|
1983 |
+
/*get placeholder file in the upload dir with a unique, sanitized filename*/
|
1984 |
+
$upload = wp_upload_bits( $file_name, 0, '', $post['upload_date'] );
|
1985 |
+
if ( $upload['error'] ) {
|
1986 |
+
return new WP_Error( 'upload_dir_error', $upload['error'] );
|
1987 |
+
}
|
1988 |
+
|
1989 |
+
$max_size = (int) apply_filters( 'import_attachment_size_limit', 0 );
|
1990 |
+
|
1991 |
+
/*finally fetch the file from remote*/
|
1992 |
+
$response = wp_remote_get( $url );
|
1993 |
+
if ( is_array( $response ) && ! empty( $response['body'] ) && $response['response']['code'] == '200' ) {
|
1994 |
+
require_once ABSPATH . 'wp-admin/includes/file.php';
|
1995 |
+
$headers = $response['headers'];
|
1996 |
+
WP_Filesystem();
|
1997 |
+
global $wp_filesystem;
|
1998 |
+
$wp_filesystem->put_contents( $upload['file'], $response['body'] );
|
1999 |
+
} else {
|
2000 |
+
/*required to download file failed.*/
|
2001 |
+
wp_delete_file( $upload['file'] );
|
2002 |
+
return new WP_Error( 'import_file_error', esc_html__( 'Remote server did not respond', 'advanced-import' ) );
|
2003 |
+
}
|
2004 |
+
|
2005 |
+
$file_size = filesize( $upload['file'] );
|
2006 |
+
|
2007 |
+
/*check for size*/
|
2008 |
+
if ( isset( $headers['content-length'] ) && $file_size != $headers['content-length'] ) {
|
2009 |
+
wp_delete_file( $upload['file'] );
|
2010 |
+
return new WP_Error( 'import_file_error', esc_html__( 'Remote file is incorrect size', 'advanced-import' ) );
|
2011 |
+
}
|
2012 |
+
|
2013 |
+
/*if file size is 0*/
|
2014 |
+
if ( 0 == $file_size ) {
|
2015 |
+
wp_delete_file( $upload['file'] );
|
2016 |
+
return new WP_Error( 'import_file_error', esc_html__( 'Zero size file downloaded', 'advanced-import' ) );
|
2017 |
+
}
|
2018 |
+
|
2019 |
+
/*if file is too large*/
|
2020 |
+
if ( ! empty( $max_size ) && $file_size > $max_size ) {
|
2021 |
+
wp_delete_file( $upload['file'] );
|
2022 |
+
return new WP_Error( 'import_file_error', sprintf( esc_html__( 'Remote file is too large, limit is %s', 'advanced-import' ), size_format( $max_size ) ) );
|
2023 |
+
}
|
2024 |
+
}
|
2025 |
+
|
2026 |
+
/*keep track of the old and new urls so we can substitute them later*/
|
2027 |
+
$this->imported_post_id( $url, $upload['url'] );
|
2028 |
+
$this->imported_post_id( $post['guid'], $upload['url'] );
|
2029 |
+
|
2030 |
+
/*keep track of the destination if the remote url is redirected somewhere else*/
|
2031 |
+
if ( isset( $headers['x-final-location'] ) && $headers['x-final-location'] != $url ) {
|
2032 |
+
$this->imported_post_id( $headers['x-final-location'], $upload['url'] );
|
2033 |
+
}
|
2034 |
+
return $upload;
|
2035 |
+
}
|
2036 |
+
|
2037 |
+
/*
|
2038 |
+
Replace necessary ID by Local imported ID
|
2039 |
+
*/
|
2040 |
+
private function replace_old_id_to_new( $option_value, $index_key = false ) {
|
2041 |
+
|
2042 |
+
/*Post IDS*/
|
2043 |
+
$replace_post_ids = apply_filters(
|
2044 |
+
'advanced_import_replace_post_ids',
|
2045 |
+
array(
|
2046 |
+
'page_id',
|
2047 |
+
'post_id',
|
2048 |
+
'image_id',
|
2049 |
+
'selectpage',
|
2050 |
+
'page_on_front',
|
2051 |
+
'page_for_posts',
|
2052 |
+
'first_page_id',
|
2053 |
+
'second_page_id',
|
2054 |
+
/*woocommerce pages*/
|
2055 |
+
'woocommerce_shop_page_id',
|
2056 |
+
'woocommerce_cart_page_id',
|
2057 |
+
'woocommerce_checkout_page_id',
|
2058 |
+
'woocommerce_pay_page_id',
|
2059 |
+
'woocommerce_thanks_page_id',
|
2060 |
+
'woocommerce_myaccount_page_id',
|
2061 |
+
'woocommerce_edit_address_page_id',
|
2062 |
+
'woocommerce_view_order_page_id',
|
2063 |
+
'woocommerce_terms_page_id',
|
2064 |
+
/*gutentor*/
|
2065 |
+
'wp_block_id',
|
2066 |
+
)
|
2067 |
+
);
|
2068 |
+
|
2069 |
+
/*Terms IDS*/
|
2070 |
+
$replace_term_ids = apply_filters(
|
2071 |
+
'advanced_import_replace_term_ids',
|
2072 |
+
array(
|
2073 |
+
'cat_id',
|
2074 |
+
'nav_menu',
|
2075 |
+
'online-shop-feature-product-cat',
|
2076 |
+
'online_shop_featured_cats',
|
2077 |
+
'online_shop_wc_product_cat',
|
2078 |
+
'online_shop_wc_product_tag',
|
2079 |
+
)
|
2080 |
+
);
|
2081 |
+
|
2082 |
+
/*replace terms in keys*/
|
2083 |
+
|
2084 |
+
if ( is_array( $option_value ) ) {
|
2085 |
+
foreach ( $option_value as $key => $replace_old_value ) {
|
2086 |
+
|
2087 |
+
if ( is_array( $replace_old_value ) && ! is_null( $replace_old_value ) ) {
|
2088 |
+
$option_value[ $key ] = $this->replace_old_id_to_new( $replace_old_value );
|
2089 |
+
} elseif ( $this->isJson( $replace_old_value ) && is_string( $replace_old_value ) && ! is_null( $replace_old_value ) ) {
|
2090 |
+
$value_array = json_decode( $replace_old_value, true );
|
2091 |
+
if ( is_array( $value_array ) ) {
|
2092 |
+
$option_value[ $key ] = wp_json_encode( $this->replace_old_id_to_new( $value_array ) );
|
2093 |
+
} else {
|
2094 |
+
if ( in_array( $key, $replace_post_ids ) && $key !== 0 ) {
|
2095 |
+
$new_id = $this->imported_post_id( $replace_old_value );
|
2096 |
+
if ( $new_id ) {
|
2097 |
+
$option_value[ $key ] = $new_id;
|
2098 |
+
}
|
2099 |
+
} elseif ( in_array( $key, $replace_term_ids ) && $key !== 0 ) {
|
2100 |
+
$new_id = $this->imported_term_id( $replace_old_value );
|
2101 |
+
if ( $new_id ) {
|
2102 |
+
$option_value[ $key ] = $new_id;
|
2103 |
+
}
|
2104 |
+
} else {
|
2105 |
+
$option_value[ $key ] = $replace_old_value;
|
2106 |
+
}
|
2107 |
+
}
|
2108 |
+
} else {
|
2109 |
+
|
2110 |
+
if ( in_array( $key, $replace_post_ids ) && $key !== 0 ) {
|
2111 |
+
|
2112 |
+
$new_id = $this->imported_post_id( $replace_old_value );
|
2113 |
+
if ( ! $new_id ) {
|
2114 |
+
/**/
|
2115 |
+
} else {
|
2116 |
+
$option_value[ $key ] = $new_id;
|
2117 |
+
}
|
2118 |
+
} elseif ( in_array( $key, $replace_term_ids ) && $key !== 0 ) {
|
2119 |
+
$new_id = $this->imported_term_id( $replace_old_value );
|
2120 |
+
if ( $new_id ) {
|
2121 |
+
$option_value[ $key ] = $new_id;
|
2122 |
+
}
|
2123 |
+
} else {
|
2124 |
+
$option_value[ $key ] = $replace_old_value;
|
2125 |
+
}
|
2126 |
+
}
|
2127 |
+
}
|
2128 |
+
} elseif ( is_numeric( $option_value ) && $index_key ) {
|
2129 |
+
|
2130 |
+
if ( in_array( $index_key, $replace_post_ids ) && $index_key !== 0 ) {
|
2131 |
+
|
2132 |
+
$new_id = $this->imported_post_id( $option_value );
|
2133 |
+
if ( ! $new_id ) {
|
2134 |
+
/**/
|
2135 |
+
} else {
|
2136 |
+
$option_value = $new_id;
|
2137 |
+
}
|
2138 |
+
} elseif ( in_array( $index_key, $replace_term_ids ) && $index_key !== 0 ) {
|
2139 |
+
$new_id = $this->imported_term_id( $option_value );
|
2140 |
+
if ( $new_id ) {
|
2141 |
+
$option_value = $new_id;
|
2142 |
+
}
|
2143 |
+
}
|
2144 |
+
}
|
2145 |
+
|
2146 |
+
return $option_value;
|
2147 |
+
}
|
2148 |
+
|
2149 |
+
/*
|
2150 |
+
* Callback function to importing widgets data
|
2151 |
+
* all widgets data is imported from here
|
2152 |
+
* return mix
|
2153 |
+
* */
|
2154 |
+
private function import_content_widgets_data() {
|
2155 |
+
$import_widget_data = $this->get_widgets_json();
|
2156 |
+
$import_widget_positions = $import_widget_data['widget_positions'];
|
2157 |
+
$import_widget_options = $import_widget_data['widget_options'];
|
2158 |
+
|
2159 |
+
/* get sidebars_widgets */
|
2160 |
+
$widget_positions = get_option( 'sidebars_widgets' );
|
2161 |
+
if ( ! is_array( $widget_positions ) ) {
|
2162 |
+
$widget_positions = array();
|
2163 |
+
}
|
2164 |
+
|
2165 |
+
foreach ( $import_widget_options as $widget_name => $widget_options ) {
|
2166 |
+
|
2167 |
+
/*replace $widget_options elements with updated imported entries.*/
|
2168 |
+
foreach ( $widget_options as $widget_option_id => $widget_option ) {
|
2169 |
+
$widget_options[ $widget_option_id ] = $this->replace_old_id_to_new( $widget_option, $widget_option_id );
|
2170 |
+
}
|
2171 |
+
$existing_options = get_option( 'widget_' . $widget_name, array() );
|
2172 |
+
if ( ! is_array( $existing_options ) ) {
|
2173 |
+
$existing_options = array();
|
2174 |
+
}
|
2175 |
+
$new_options = $widget_options + $existing_options;
|
2176 |
+
|
2177 |
+
$new_options = apply_filters( 'advanced_import_new_options', $new_options );
|
2178 |
+
|
2179 |
+
update_option( 'widget_' . $widget_name, $new_options );
|
2180 |
+
}
|
2181 |
+
|
2182 |
+
$sidebars_widgets = array_merge( $widget_positions, $import_widget_positions );
|
2183 |
+
$sidebars_widgets = apply_filters( 'advanced_import_sidebars_widgets', $sidebars_widgets, $this );
|
2184 |
+
update_option( 'sidebars_widgets', $sidebars_widgets );
|
2185 |
+
|
2186 |
+
return true;
|
2187 |
+
|
2188 |
+
}
|
2189 |
+
|
2190 |
+
/*check if string is json*/
|
2191 |
+
function isJson( $string ) {
|
2192 |
+
$test_json = @json_decode( $string, true );
|
2193 |
+
if ( is_array( $test_json ) ) {
|
2194 |
+
return true;
|
2195 |
+
}
|
2196 |
+
return false;
|
2197 |
+
}
|
2198 |
+
|
2199 |
+
/*
|
2200 |
+
callback function to importing menus and options data
|
2201 |
+
* all menus and import data is imported from here
|
2202 |
+
* return mix
|
2203 |
+
* */
|
2204 |
+
public function import_menu_and_options() {
|
2205 |
+
|
2206 |
+
/*final wrap up of delayed posts.*/
|
2207 |
+
$this->process_delayed_posts( true );
|
2208 |
+
|
2209 |
+
/*it includes options and menu data*/
|
2210 |
+
$theme_options = $this->get_theme_options_json();
|
2211 |
+
|
2212 |
+
/*options data*/
|
2213 |
+
$custom_options = $theme_options['options'];
|
2214 |
+
|
2215 |
+
/*menu data*/
|
2216 |
+
$menu_ids = $theme_options['menu'];
|
2217 |
+
|
2218 |
+
/*we also want to update the widget area manager options.*/
|
2219 |
+
if ( is_array( $custom_options ) ) {
|
2220 |
+
foreach ( $custom_options as $option => $value ) {
|
2221 |
+
/*replace old entries with updated imported entries.*/
|
2222 |
+
$value = $this->replace_old_id_to_new( $value, $option );
|
2223 |
+
|
2224 |
+
/*we have to update widget page numbers with imported page numbers.*/
|
2225 |
+
if (
|
2226 |
+
preg_match( '#(wam__position_)(\d+)_#', $option, $matches ) ||
|
2227 |
+
preg_match( '#(wam__area_)(\d+)_#', $option, $matches )
|
2228 |
+
) {
|
2229 |
+
$new_page_id = $this->imported_post_id( $matches[2] );
|
2230 |
+
if ( $new_page_id ) {
|
2231 |
+
// we have a new page id for this one. import the new setting value.
|
2232 |
+
$option = str_replace( $matches[1] . $matches[2] . '_', $matches[1] . $new_page_id . '_', $option );
|
2233 |
+
}
|
2234 |
+
}
|
2235 |
+
else if ( $value && ! empty( $value['custom_logo'] ) ) {
|
2236 |
+
$new_logo_id = $this->imported_post_id( $value['custom_logo'] );
|
2237 |
+
if ( $new_logo_id ) {
|
2238 |
+
$value['custom_logo'] = $new_logo_id;
|
2239 |
+
}
|
2240 |
+
}
|
2241 |
+
/** For Gutentor */
|
2242 |
+
else if ( strpos( $option, 'gutentor-cat' ) !== false ) {
|
2243 |
+
$cat_id = substr($option, strrpos($option, '-') + 1);
|
2244 |
+
if( 'child' !== $cat_id ){
|
2245 |
+
$new_cat_id = $this->imported_term_id( $cat_id );
|
2246 |
+
$option = str_replace($cat_id,$new_cat_id,$option);
|
2247 |
+
}
|
2248 |
+
}
|
2249 |
+
update_option( $option, $value );
|
2250 |
+
}
|
2251 |
+
}
|
2252 |
+
|
2253 |
+
/*
|
2254 |
+
Options completed
|
2255 |
+
Menu Start*/
|
2256 |
+
$save = array();
|
2257 |
+
foreach ( $menu_ids as $menu_id => $term_id ) {
|
2258 |
+
$new_term_id = $this->imported_term_id( $term_id );
|
2259 |
+
if ( $new_term_id ) {
|
2260 |
+
$save[ $menu_id ] = $new_term_id;
|
2261 |
+
}
|
2262 |
+
}
|
2263 |
+
|
2264 |
+
if ( $save ) {
|
2265 |
+
set_theme_mod( 'nav_menu_locations', array_map( 'absint', $save ) );
|
2266 |
+
}
|
2267 |
+
|
2268 |
+
global $wp_rewrite;
|
2269 |
+
$wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
|
2270 |
+
update_option( 'rewrite_rules', false );
|
2271 |
+
$wp_rewrite->flush_rules( true );
|
2272 |
+
|
2273 |
+
return true;
|
2274 |
+
}
|
2275 |
+
|
2276 |
+
public function log( $message ) {
|
2277 |
+
$this->logs[] = $message;
|
2278 |
+
}
|
2279 |
+
|
2280 |
+
|
2281 |
+
public function error( $message ) {
|
2282 |
+
$this->logs[] = esc_html__( 'ERROR!!!! ', 'advanced-import' ) . $message;
|
2283 |
+
}
|
2284 |
+
|
2285 |
+
/*
|
2286 |
+
Callback function to completed
|
2287 |
+
* Show Completed Message
|
2288 |
+
* */
|
2289 |
+
public function complete_screen() {
|
2290 |
+
|
2291 |
+
/*check for security*/
|
2292 |
+
if ( ! current_user_can( 'upload_files' ) ) {
|
2293 |
+
wp_send_json_error(
|
2294 |
+
array(
|
2295 |
+
'message' => esc_html__( 'Sorry, you are not allowed to install demo on this site.', 'advanced-import' ),
|
2296 |
+
)
|
2297 |
+
);
|
2298 |
+
}
|
2299 |
+
|
2300 |
+
require_once ABSPATH . 'wp-admin/includes/file.php';
|
2301 |
+
WP_Filesystem();
|
2302 |
+
global $wp_filesystem;
|
2303 |
+
$wp_filesystem->rmdir( ADVANCED_IMPORT_TEMP, true );
|
2304 |
+
|
2305 |
+
set_theme_mod( 'advanced_import_setup_complete', time() );
|
2306 |
+
/*delete_transient();*/
|
2307 |
+
delete_transient( 'content.json' );
|
2308 |
+
delete_transient( 'widgets.json' );
|
2309 |
+
delete_transient( 'options.json' );
|
2310 |
+
|
2311 |
+
$message = '<div class="ai-notification-title">';
|
2312 |
+
$message .= '<p>' . esc_html__( 'Your Website is Ready!', 'advanced-import' ) . '</p>';
|
2313 |
+
$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>';
|
2314 |
+
$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>';
|
2315 |
+
$message .= '</div>';
|
2316 |
+
|
2317 |
+
apply_filters( 'advanced_import_complete_message', $message );
|
2318 |
+
|
2319 |
+
do_action( 'advanced_import_before_complete_screen' );
|
2320 |
+
echo $message;
|
2321 |
+
do_action( 'advanced_import_after_complete_screen' );
|
2322 |
+
exit;
|
2323 |
+
}
|
2324 |
+
|
2325 |
+
|
2326 |
+
/*
|
2327 |
+
callback function for wp_ajax_install_plugin
|
2328 |
+
* Install plugin
|
2329 |
+
* */
|
2330 |
+
function install_plugin() {
|
2331 |
+
|
2332 |
+
/*check for security*/
|
2333 |
+
if ( ! current_user_can( 'install_plugins' ) ) {
|
2334 |
+
$status['errorMessage'] = __( 'Sorry, you are not allowed to install plugins on this site.', 'advanced-import' );
|
2335 |
+
wp_send_json_error( $status );
|
2336 |
+
}
|
2337 |
+
|
2338 |
+
if ( empty( $_POST['plugin'] ) || empty( $_POST['slug'] ) ) {
|
2339 |
+
wp_send_json_error(
|
2340 |
+
array(
|
2341 |
+
'slug' => '',
|
2342 |
+
'errorCode' => 'no_plugin_specified',
|
2343 |
+
'errorMessage' => __( 'No plugin specified.', 'advanced-import' ),
|
2344 |
+
)
|
2345 |
+
);
|
2346 |
+
}
|
2347 |
+
|
2348 |
+
$slug = sanitize_key( wp_unslash( $_POST['slug'] ) );
|
2349 |
+
$plugin = plugin_basename( sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) );
|
2350 |
+
|
2351 |
+
if ( is_plugin_active_for_network( $plugin ) || is_plugin_active( $plugin ) ) {
|
2352 |
+
// Plugin is activated
|
2353 |
+
wp_send_json_success();
|
2354 |
+
|
2355 |
+
}
|
2356 |
+
$status = array(
|
2357 |
+
'install' => 'plugin',
|
2358 |
+
'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ),
|
2359 |
+
);
|
2360 |
+
|
2361 |
+
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
2362 |
+
include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
|
2363 |
+
|
2364 |
+
// Looks like a plugin is installed, but not active.
|
2365 |
+
if ( file_exists( WP_PLUGIN_DIR . '/' . $slug ) ) {
|
2366 |
+
$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
|
2367 |
+
$status['plugin'] = $plugin;
|
2368 |
+
$status['pluginName'] = $plugin_data['Name'];
|
2369 |
+
|
2370 |
+
if ( current_user_can( 'activate_plugin', $plugin ) && is_plugin_inactive( $plugin ) ) {
|
2371 |
+
$result = activate_plugin( $plugin );
|
2372 |
+
|
2373 |
+
if ( is_wp_error( $result ) ) {
|
2374 |
+
$status['errorCode'] = $result->get_error_code();
|
2375 |
+
$status['errorMessage'] = $result->get_error_message();
|
2376 |
+
wp_send_json_error( $status );
|
2377 |
+
}
|
2378 |
+
|
2379 |
+
wp_send_json_success( $status );
|
2380 |
+
}
|
2381 |
+
}
|
2382 |
+
|
2383 |
+
$api = plugins_api(
|
2384 |
+
'plugin_information',
|
2385 |
+
array(
|
2386 |
+
'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ),
|
2387 |
+
'fields' => array(
|
2388 |
+
'sections' => false,
|
2389 |
+
),
|
2390 |
+
)
|
2391 |
+
);
|
2392 |
+
|
2393 |
+
if ( is_wp_error( $api ) ) {
|
2394 |
+
$status['errorMessage'] = $api->get_error_message();
|
2395 |
+
wp_send_json_error( $status );
|
2396 |
+
}
|
2397 |
+
|
2398 |
+
$status['pluginName'] = $api->name;
|
2399 |
+
|
2400 |
+
$skin = new WP_Ajax_Upgrader_Skin();
|
2401 |
+
$upgrader = new Plugin_Upgrader( $skin );
|
2402 |
+
$result = $upgrader->install( $api->download_link );
|
2403 |
+
|
2404 |
+
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
|
2405 |
+
$status['debug'] = $skin->get_upgrade_messages();
|
2406 |
+
}
|
2407 |
+
|
2408 |
+
if ( is_wp_error( $result ) ) {
|
2409 |
+
$status['errorCode'] = $result->get_error_code();
|
2410 |
+
$status['errorMessage'] = $result->get_error_message();
|
2411 |
+
wp_send_json_error( $status );
|
2412 |
+
} elseif ( is_wp_error( $skin->result ) ) {
|
2413 |
+
$status['errorCode'] = $skin->result->get_error_code();
|
2414 |
+
$status['errorMessage'] = $skin->result->get_error_message();
|
2415 |
+
wp_send_json_error( $status );
|
2416 |
+
} elseif ( $skin->get_errors()->get_error_code() ) {
|
2417 |
+
$status['errorMessage'] = $skin->get_error_messages();
|
2418 |
+
wp_send_json_error( $status );
|
2419 |
+
} elseif ( is_null( $result ) ) {
|
2420 |
+
require_once ABSPATH . 'wp-admin/includes/file.php';
|
2421 |
+
WP_Filesystem();
|
2422 |
+
global $wp_filesystem;
|
2423 |
+
|
2424 |
+
$status['errorCode'] = 'unable_to_connect_to_filesystem';
|
2425 |
+
$status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.', 'advanced-import' );
|
2426 |
+
|
2427 |
+
// Pass through the error from WP_Filesystem if one was raised.
|
2428 |
+
if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
|
2429 |
+
$status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() );
|
2430 |
+
}
|
2431 |
+
|
2432 |
+
wp_send_json_error( $status );
|
2433 |
+
}
|
2434 |
+
|
2435 |
+
$install_status = install_plugin_install_status( $api );
|
2436 |
+
|
2437 |
+
if ( current_user_can( 'activate_plugin', $install_status['file'] ) && is_plugin_inactive( $install_status['file'] ) ) {
|
2438 |
+
$result = activate_plugin( $install_status['file'] );
|
2439 |
+
|
2440 |
+
if ( is_wp_error( $result ) ) {
|
2441 |
+
$status['errorCode'] = $result->get_error_code();
|
2442 |
+
$status['errorMessage'] = $result->get_error_message();
|
2443 |
+
wp_send_json_error( $status );
|
2444 |
+
}
|
2445 |
+
}
|
2446 |
+
|
2447 |
+
wp_send_json_success( $status );
|
2448 |
+
}
|
2449 |
+
|
2450 |
+
/*
|
2451 |
+
callback function to current_screen
|
2452 |
+
* Add help Text
|
2453 |
+
* @param $screen object screen
|
2454 |
+
* */
|
2455 |
+
public function help_tabs( $screen ) {
|
2456 |
+
if ( ! is_array( $this->hook_suffix ) || ! in_array( $screen->base, $this->hook_suffix ) ) {
|
2457 |
+
return;
|
2458 |
+
}
|
2459 |
+
$current_url = advanced_import_current_url();
|
2460 |
+
|
2461 |
+
$screen->add_help_tab(
|
2462 |
+
array(
|
2463 |
+
'id' => 'ai_help_tab_info',
|
2464 |
+
'title' => __( 'Information', 'advanced-import' ),
|
2465 |
+
'content' =>
|
2466 |
+
'<h2>' . __( 'Information', 'advanced-import' ) . '</h2>' .
|
2467 |
+
'<p>' . sprintf(
|
2468 |
+
__( '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' ),
|
2469 |
+
'https://wordpress.org/plugins/advanced-export/'
|
2470 |
+
) . '</p>' .
|
2471 |
+
'<p>' . sprintf(
|
2472 |
+
__( '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' ),
|
2473 |
+
'https://wordpress.org/support/plugin/advanced-export',
|
2474 |
+
'https://wordpress.org/support/plugin/advanced-import'
|
2475 |
+
) . '</p>' .
|
2476 |
+
'<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>',
|
2477 |
+
)
|
2478 |
+
);
|
2479 |
+
|
2480 |
+
$reset_url = wp_nonce_url(
|
2481 |
+
add_query_arg( 'ai_reset_wordpress', 'true', $current_url ),
|
2482 |
+
'ai_reset_wordpress',
|
2483 |
+
'ai_reset_wordpress_nonce'
|
2484 |
+
);
|
2485 |
+
$screen->add_help_tab(
|
2486 |
+
array(
|
2487 |
+
'id' => 'ai_help_tab_reset',
|
2488 |
+
'title' => __( 'Reset wizard', 'advanced-import' ),
|
2489 |
+
'content' =>
|
2490 |
+
'<h2>' . __( '<strong>WordPress Reset</strong>', 'advanced-import' ) . '</h2>' .
|
2491 |
+
'<p>' . __( 'If no important data on your site. You can reset the WordPress back to default again!', 'advanced-import' ) . '</p>' .
|
2492 |
+
'<p class="submit"><a href="' . esc_url( $reset_url ) . '" class="button button-primary ai-wp-reset">' . __( 'Run the Reset Wizard', 'advanced-import' ) . '</a></p>',
|
2493 |
+
)
|
2494 |
+
);
|
2495 |
+
|
2496 |
+
$screen->set_help_sidebar(
|
2497 |
+
'<p><strong>' . __( 'More information:', 'advanced-import' ) . '</strong></p>' .
|
2498 |
+
'<p><a href="' . 'https://wordpress.org/plugins/advanced-export/' . '" target="_blank">' . __( 'Advanced Export', 'advanced-import' ) . '</a></p>' .
|
2499 |
+
'<p><a href="' . 'https://wordpress.org/plugins/advanced-import/' . '" target="_blank">' . __( 'Advanced Import', 'advanced-import' ) . '</a></p>'
|
2500 |
+
);
|
2501 |
+
}
|
2502 |
+
}
|
2503 |
+
|
2504 |
+
/**
|
2505 |
+
* Begins execution of the plugin.
|
2506 |
+
*
|
2507 |
+
* Since everything within the plugin is registered via hooks,
|
2508 |
+
* then kicking off the plugin from this point in the file does
|
2509 |
+
* not affect the page life cycle.
|
2510 |
+
*
|
2511 |
+
* @since 1.0.0
|
2512 |
+
*/
|
2513 |
+
function advanced_import_admin() {
|
2514 |
+
return Advanced_Import_Admin::instance();
|
2515 |
+
}
|
admin/class-elementor-import.php
CHANGED
@@ -1,109 +1,115 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
-
|
4 |
-
}
|
5 |
-
|
6 |
-
/**
|
7 |
-
* The elementor import functionality of the plugin.
|
8 |
-
*
|
9 |
-
*
|
10 |
-
* @
|
11 |
-
* @
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
exit;
|
4 |
+
}
|
5 |
+
|
6 |
+
/**
|
7 |
+
* The elementor import functionality of the plugin.
|
8 |
+
*
|
9 |
+
* @package Advanced_Import
|
10 |
+
* @subpackage Advanced_Import/admin/Advanced_Import_Elementor
|
11 |
+
* @author Addons Press <addonspress.com>
|
12 |
+
*/
|
13 |
+
if ( ! class_exists( 'Advanced_Import_Elementor' ) ) {
|
14 |
+
/**
|
15 |
+
* Advanced_Import_Elementor
|
16 |
+
*/
|
17 |
+
class Advanced_Import_Elementor {
|
18 |
+
/**
|
19 |
+
* Main Advanced_Import_Elementor Instance
|
20 |
+
* Initialize the class and set its properties.
|
21 |
+
*
|
22 |
+
* @since 1.0.0
|
23 |
+
* @return object $instance Advanced_Import_Elementor Instance
|
24 |
+
*/
|
25 |
+
public static function instance() {
|
26 |
+
|
27 |
+
// Store the instance locally to avoid private static replication.
|
28 |
+
static $instance = null;
|
29 |
+
|
30 |
+
// Only run these methods if they haven't been ran previously.
|
31 |
+
if ( null === $instance ) {
|
32 |
+
$instance = new self();
|
33 |
+
}
|
34 |
+
|
35 |
+
// Always return the instance.
|
36 |
+
return $instance;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Change post id related to elementor to new id
|
41 |
+
*
|
42 |
+
* @param array $item current array of demo list.
|
43 |
+
* @param string $key
|
44 |
+
* @return void
|
45 |
+
*/
|
46 |
+
public function elementor_id_import( &$item, $key ) {
|
47 |
+
if ( $key == 'id' && ! empty( $item ) && is_numeric( $item ) ) {
|
48 |
+
// check if this has been imported before
|
49 |
+
$new_meta_val = advanced_import_admin()->imported_post_id( $item );
|
50 |
+
if ( $new_meta_val ) {
|
51 |
+
$item = $new_meta_val;
|
52 |
+
}
|
53 |
+
}
|
54 |
+
if ( $key == 'page' && ! empty( $item ) ) {
|
55 |
+
|
56 |
+
if ( false !== strpos( $item, 'p.' ) ) {
|
57 |
+
$new_id = str_replace( 'p.', '', $item );
|
58 |
+
// check if this has been imported before
|
59 |
+
$new_meta_val = advanced_import_admin()->imported_post_id( $new_id );
|
60 |
+
if ( $new_meta_val ) {
|
61 |
+
$item = 'p.' . $new_meta_val;
|
62 |
+
}
|
63 |
+
} elseif ( is_numeric( $item ) ) {
|
64 |
+
// check if this has been imported before
|
65 |
+
$new_meta_val = advanced_import_admin()->imported_post_id( $item );
|
66 |
+
if ( $new_meta_val ) {
|
67 |
+
$item = $new_meta_val;
|
68 |
+
}
|
69 |
+
}
|
70 |
+
}
|
71 |
+
if ( $key == 'post_id' && ! empty( $item ) && is_numeric( $item ) ) {
|
72 |
+
// check if this has been imported before
|
73 |
+
$new_meta_val = advanced_import_admin()->imported_post_id( $item );
|
74 |
+
if ( $new_meta_val ) {
|
75 |
+
$item = $new_meta_val;
|
76 |
+
}
|
77 |
+
}
|
78 |
+
if ( $key == 'url' && ! empty( $item ) && strstr( $item, 'ocalhost' ) ) {
|
79 |
+
// check if this has been imported before
|
80 |
+
$new_meta_val = advanced_import_admin()->imported_post_id( $item );
|
81 |
+
if ( $new_meta_val ) {
|
82 |
+
$item = $new_meta_val;
|
83 |
+
}
|
84 |
+
}
|
85 |
+
if ( ( $key == 'shortcode' || $key == 'editor' ) && ! empty( $item ) ) {
|
86 |
+
// we have to fix the [contact-form-7 id=133] shortcode issue.
|
87 |
+
$item = advanced_import_admin()->parse_shortcode_meta_content( $item );
|
88 |
+
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
public function elementor_post( $post_id = false ) {
|
93 |
+
|
94 |
+
// regenerate the CSS for this Elementor post
|
95 |
+
if ( class_exists( 'Elementor\Core\Files\CSS\Post' ) ) {
|
96 |
+
$post_css = new Elementor\Core\Files\CSS\Post( $post_id );
|
97 |
+
$post_css->update();
|
98 |
+
}
|
99 |
+
}
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Begins execution of the plugin.
|
106 |
+
*
|
107 |
+
* Since everything within the plugin is registered via hooks,
|
108 |
+
* then kicking off the plugin from this point in the file does
|
109 |
+
* not affect the page life cycle.
|
110 |
+
*
|
111 |
+
* @since 1.0.0
|
112 |
+
*/
|
113 |
+
function advanced_import_elementor() {
|
114 |
+
return Advanced_Import_Elementor::instance();
|
115 |
+
}
|
admin/class-reset.php
CHANGED
@@ -1,205 +1,206 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Reset WordPress
|
5 |
-
*
|
6 |
-
* @link https://addonspress.com/
|
7 |
-
* @since 1.0.0
|
8 |
-
*
|
9 |
-
* @package Advanced_Import
|
10 |
-
* @subpackage Advanced_Import/admin
|
11 |
-
*/
|
12 |
-
|
13 |
-
/**
|
14 |
-
* The admin-specific functionality of the plugin.
|
15 |
-
* Reset WordPress
|
16 |
-
*
|
17 |
-
* @
|
18 |
-
* @
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
*
|
25 |
-
*
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
*
|
32 |
-
*
|
33 |
-
*
|
34 |
-
* @
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
if
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
return
|
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 |
-
<p
|
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 |
-
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Reset WordPress
|
5 |
+
*
|
6 |
+
* @link https://addonspress.com/
|
7 |
+
* @since 1.0.0
|
8 |
+
*
|
9 |
+
* @package Advanced_Import
|
10 |
+
* @subpackage Advanced_Import/admin
|
11 |
+
*/
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The admin-specific functionality of the plugin.
|
15 |
+
* Reset WordPress
|
16 |
+
*
|
17 |
+
* @package Advanced_Import
|
18 |
+
* @subpackage Advanced_Import/admin
|
19 |
+
* @author Addons Press <addonspress.com>
|
20 |
+
*/
|
21 |
+
class Advanced_Import_Reset_WordPress {
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Initialize the class and set its properties.
|
25 |
+
*
|
26 |
+
* @since 1.0.0
|
27 |
+
*/
|
28 |
+
public function __construct() {}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Main Advanced_Import_Reset_WordPress Instance
|
32 |
+
* Initialize the class and set its properties.
|
33 |
+
*
|
34 |
+
* @since 1.0.0
|
35 |
+
* @return object $instance Advanced_Import_Reset_WordPress Instance
|
36 |
+
*/
|
37 |
+
public static function instance() {
|
38 |
+
|
39 |
+
// Store the instance locally to avoid private static replication
|
40 |
+
static $instance = null;
|
41 |
+
|
42 |
+
// Only run these methods if they haven't been ran previously
|
43 |
+
if ( null === $instance ) {
|
44 |
+
$instance = new Advanced_Import_Reset_WordPress();
|
45 |
+
|
46 |
+
}
|
47 |
+
|
48 |
+
// Always return the instance
|
49 |
+
return $instance;
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Hide a notice if the GET variable is set.
|
54 |
+
*/
|
55 |
+
public function hide_reset_notice() {
|
56 |
+
if ( isset( $_GET['advanced-import-hide-notice'] ) && isset( $_GET['_advanced_import_notice_nonce'] ) ) {
|
57 |
+
/*Security*/
|
58 |
+
if ( ! wp_verify_nonce( $_GET['_advanced_import_notice_nonce'], 'advanced_import_hide_notice_nonce' ) ) {
|
59 |
+
wp_die( __( 'Action failed. Please refresh the page and retry.', 'advanced-import' ) );
|
60 |
+
}
|
61 |
+
|
62 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
63 |
+
wp_die( __( 'Cheatin’ huh?', 'advanced-import' ) );
|
64 |
+
}
|
65 |
+
|
66 |
+
$hide_notice = sanitize_text_field( $_GET['advanced-import-hide-notice'] );
|
67 |
+
|
68 |
+
if ( ! empty( $hide_notice ) && 'reset_notice' == $hide_notice ) {
|
69 |
+
update_option( 'advanced_import_reset_notice', 1 );
|
70 |
+
}
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Reset actions when a reset button is clicked.
|
76 |
+
*/
|
77 |
+
public function reset_wizard_actions() {
|
78 |
+
global $wpdb, $current_user;
|
79 |
+
|
80 |
+
if ( ! empty( $_GET['ai_reset_wordpress'] ) && ! empty( $_GET['ai_reset_wordpress_nonce'] ) ) {
|
81 |
+
/*Security*/
|
82 |
+
if ( ! wp_verify_nonce( wp_unslash( $_GET['ai_reset_wordpress_nonce'] ), 'ai_reset_wordpress' ) ) { // WPCS: input var ok, sanitization ok.
|
83 |
+
wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'advanced-import' ) );
|
84 |
+
}
|
85 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
86 |
+
wp_die( esc_html__( 'No permission to reset WordPress', 'advanced-import' ) );
|
87 |
+
}
|
88 |
+
|
89 |
+
require_once ABSPATH . '/wp-admin/includes/upgrade.php';
|
90 |
+
|
91 |
+
$template = get_option( 'template' );
|
92 |
+
$blogname = get_option( 'blogname' );
|
93 |
+
$admin_email = get_option( 'admin_email' );
|
94 |
+
$blog_public = get_option( 'blog_public' );
|
95 |
+
|
96 |
+
$current_url = advanced_import_current_url();
|
97 |
+
|
98 |
+
if ( 'admin' != $current_user->user_login ) {
|
99 |
+
$user = get_user_by( 'login', 'admin' );
|
100 |
+
}
|
101 |
+
|
102 |
+
if ( empty( $user->user_level ) || $user->user_level < 10 ) {
|
103 |
+
$user = $current_user;
|
104 |
+
}
|
105 |
+
|
106 |
+
// Drop tables.
|
107 |
+
$drop_tables = $wpdb->get_col( sprintf( "SHOW TABLES LIKE '%s%%'", str_replace( '_', '\_', $wpdb->prefix ) ) );
|
108 |
+
foreach ( $drop_tables as $table ) {
|
109 |
+
$wpdb->query( "DROP TABLE IF EXISTS $table" );
|
110 |
+
}
|
111 |
+
|
112 |
+
// Installs the site.
|
113 |
+
$result = wp_install( $blogname, $user->user_login, $user->user_email, $blog_public );
|
114 |
+
|
115 |
+
// Updates the user password with a old one.
|
116 |
+
$wpdb->update(
|
117 |
+
$wpdb->users,
|
118 |
+
array(
|
119 |
+
'user_pass' => $user->user_pass,
|
120 |
+
'user_activation_key' => '',
|
121 |
+
),
|
122 |
+
array( 'ID' => $result['user_id'] )
|
123 |
+
);
|
124 |
+
|
125 |
+
// Set up the Password change nag.
|
126 |
+
$default_password_nag = get_user_option( 'default_password_nag', $result['user_id'] );
|
127 |
+
if ( $default_password_nag ) {
|
128 |
+
update_user_option( $result['user_id'], 'default_password_nag', false, true );
|
129 |
+
}
|
130 |
+
|
131 |
+
// Switch current theme.
|
132 |
+
$current_theme = wp_get_theme( $template );
|
133 |
+
if ( $current_theme->exists() ) {
|
134 |
+
switch_theme( $template );
|
135 |
+
}
|
136 |
+
|
137 |
+
// Activate required plugins.
|
138 |
+
$required_plugins = (array) apply_filters( 'advanced_import_' . $template . '_required_plugins', array() );
|
139 |
+
if ( is_array( $required_plugins ) ) {
|
140 |
+
if ( ! in_array( plugin_basename( ADVANCED_IMPORT_PATH . '/advanced-import.php' ), $required_plugins ) ) {
|
141 |
+
$required_plugins = array_merge( $required_plugins, array( ADVANCED_IMPORT_PATH . '/advanced-import.php' ) );
|
142 |
+
}
|
143 |
+
activate_plugins( $required_plugins, '', is_network_admin(), true );
|
144 |
+
}
|
145 |
+
|
146 |
+
// Update the cookies.
|
147 |
+
wp_clear_auth_cookie();
|
148 |
+
wp_set_auth_cookie( $result['user_id'] );
|
149 |
+
|
150 |
+
// Redirect to demo importer page to display reset success notice.
|
151 |
+
wp_safe_redirect( $current_url . '&reset=true&from=ai-reset-wp' );
|
152 |
+
exit();
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Reset wizard notice.
|
158 |
+
*/
|
159 |
+
public function reset_wizard_notice() {
|
160 |
+
|
161 |
+
$screen = get_current_screen();
|
162 |
+
if ( ! in_array( $screen->base, advanced_import_admin()->hook_suffix ) ) {
|
163 |
+
return;
|
164 |
+
}
|
165 |
+
$current_url = advanced_import_current_url();
|
166 |
+
$reset_url = wp_nonce_url(
|
167 |
+
add_query_arg( 'ai_reset_wordpress', 'true', $current_url ),
|
168 |
+
'ai_reset_wordpress',
|
169 |
+
'ai_reset_wordpress_nonce'
|
170 |
+
);
|
171 |
+
|
172 |
+
$demo_notice_dismiss = get_option( 'advanced_import_reset_notice' );
|
173 |
+
|
174 |
+
// Output reset wizard notice.
|
175 |
+
if ( ! $demo_notice_dismiss ) {
|
176 |
+
?>
|
177 |
+
<div id="message" class="updated ai-import-message">
|
178 |
+
<p><?php _e( '<strong>WordPress Reset</strong> – If no important data on your site. You can reset the WordPress back to default again!', 'advanced-import' ); ?></p>
|
179 |
+
<p class="submit"><a href="<?php echo esc_url( $reset_url ); ?>" class="button button-primary ai-wp-reset"><?php esc_html_e( 'Run the Reset Wizard', 'advanced-import' ); ?></a> <a class="button-secondary skip" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'advanced-import-hide-notice', 'reset_notice', $current_url ), 'advanced_import_hide_notice_nonce', '_advanced_import_notice_nonce' ) ); ?>"><?php esc_attr_e( 'Hide this notice', 'advanced-import' ); ?></a></p>
|
180 |
+
</div>
|
181 |
+
<?php
|
182 |
+
} elseif ( isset( $_GET['reset'] ) && 'true' === $_GET['reset'] ) {
|
183 |
+
$user = get_user_by( 'id', 1 );
|
184 |
+
?>
|
185 |
+
<div id="message" class="notice notice-info is-dismissible">
|
186 |
+
<p><?php printf( __( 'WordPress has been reset back to defaults. The user <strong>"%1$s"</strong> was recreated with its previous password.', 'advanced-import' ), $user->user_login ); ?></p>
|
187 |
+
</div>
|
188 |
+
<?php
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Begins execution of the plugin.
|
197 |
+
*
|
198 |
+
* Since everything within the plugin is registered via hooks,
|
199 |
+
* then kicking off the plugin from this point in the file does
|
200 |
+
* not affect the page life cycle.
|
201 |
+
*
|
202 |
+
* @since 1.0.0
|
203 |
+
*/
|
204 |
+
function advanced_import_reset_wordpress() {
|
205 |
+
return Advanced_Import_Reset_WordPress::instance();
|
206 |
+
}
|
admin/index.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php // Silence is golden
|
1 |
+
<?php // Silence is golden
|
advanced-import.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
<?php
|
2 |
// If this file is called directly, abort.
|
3 |
if ( ! defined( 'WPINC' ) ) {
|
4 |
-
|
5 |
-
|
6 |
}
|
7 |
/**
|
8 |
*
|
@@ -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.2.
|
18 |
* Author: AddonsPress
|
19 |
* Author URI: https://addonspress.com/
|
20 |
* License: GPL-2.0+
|
@@ -24,16 +24,16 @@ if ( ! defined( 'WPINC' ) ) {
|
|
24 |
*/
|
25 |
|
26 |
/*Define Constants for this plugin*/
|
27 |
-
define( 'ADVANCED_IMPORT_VERSION', '1.2.
|
28 |
define( 'ADVANCED_IMPORT_PLUGIN_NAME', 'advanced-import' );
|
29 |
-
define( 'ADVANCED_IMPORT_PATH',
|
30 |
define( 'ADVANCED_IMPORT_URL', plugin_dir_url( __FILE__ ) );
|
31 |
define( 'ADVANCED_IMPORT_SCRIPT_PREFIX', ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '.min' : '.min' );
|
32 |
|
33 |
-
$upload_dir
|
34 |
-
$advanced_import_temp
|
35 |
-
$advanced_import_temp_zip
|
36 |
-
$advanced_import_temp_uploads =
|
37 |
|
38 |
define( 'ADVANCED_IMPORT_TEMP', $advanced_import_temp );
|
39 |
define( 'ADVANCED_IMPORT_TEMP_ZIP', $advanced_import_temp_zip );
|
@@ -44,8 +44,8 @@ define( 'ADVANCED_IMPORT_TEMP_UPLOADS', $advanced_import_temp_uploads );
|
|
44 |
* This action is documented in includes/class-advanced-import-activator.php
|
45 |
*/
|
46 |
function activate_advanced_import() {
|
47 |
-
|
48 |
-
|
49 |
}
|
50 |
|
51 |
/**
|
@@ -53,8 +53,8 @@ function activate_advanced_import() {
|
|
53 |
* This action is documented in includes/class-advanced-import-deactivator.php
|
54 |
*/
|
55 |
function deactivate_advanced_import() {
|
56 |
-
|
57 |
-
|
58 |
}
|
59 |
|
60 |
register_activation_hook( __FILE__, 'activate_advanced_import' );
|
@@ -76,6 +76,6 @@ require ADVANCED_IMPORT_PATH . 'includes/class-advanced-import.php';
|
|
76 |
* @since 1.0.0
|
77 |
*/
|
78 |
function advanced_import() {
|
79 |
-
|
80 |
}
|
81 |
-
advanced_import();
|
1 |
<?php
|
2 |
// If this file is called directly, abort.
|
3 |
if ( ! defined( 'WPINC' ) ) {
|
4 |
+
echo 'Hi there! I\'m just a plugin, not much I can do when called directly.';
|
5 |
+
exit;
|
6 |
}
|
7 |
/**
|
8 |
*
|
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.2.5
|
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.2.5' );
|
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__ ) );
|
31 |
define( 'ADVANCED_IMPORT_SCRIPT_PREFIX', ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '.min' : '.min' );
|
32 |
|
33 |
+
$upload_dir = wp_upload_dir();
|
34 |
+
$advanced_import_temp = $upload_dir['basedir'] . '/advanced-import-temp/';
|
35 |
+
$advanced_import_temp_zip = $upload_dir['basedir'] . '/advanced-import-temp-zip/';
|
36 |
+
$advanced_import_temp_uploads = $advanced_import_temp . '/uploads/';
|
37 |
|
38 |
define( 'ADVANCED_IMPORT_TEMP', $advanced_import_temp );
|
39 |
define( 'ADVANCED_IMPORT_TEMP_ZIP', $advanced_import_temp_zip );
|
44 |
* This action is documented in includes/class-advanced-import-activator.php
|
45 |
*/
|
46 |
function activate_advanced_import() {
|
47 |
+
require_once ADVANCED_IMPORT_PATH . 'includes/class-advanced-import-activator.php';
|
48 |
+
Advanced_Import_Activator::activate();
|
49 |
}
|
50 |
|
51 |
/**
|
53 |
* This action is documented in includes/class-advanced-import-deactivator.php
|
54 |
*/
|
55 |
function deactivate_advanced_import() {
|
56 |
+
require_once ADVANCED_IMPORT_PATH . 'includes/class-advanced-import-deactivator.php';
|
57 |
+
Advanced_Import_Deactivator::deactivate();
|
58 |
}
|
59 |
|
60 |
register_activation_hook( __FILE__, 'activate_advanced_import' );
|
76 |
* @since 1.0.0
|
77 |
*/
|
78 |
function advanced_import() {
|
79 |
+
return Advanced_Import::instance();
|
80 |
}
|
81 |
+
advanced_import();
|
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:
|
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}
|
example.php
CHANGED
@@ -1,80 +1,83 @@
|
|
1 |
-
<?php
|
2 |
-
function prefix_demo_import_lists(){
|
3 |
-
$demo_lists = array(
|
4 |
-
'demo1' =>array(
|
5 |
-
'title'
|
6 |
-
'is_pro'
|
7 |
-
'type'
|
8 |
-
'author'
|
9 |
-
'keywords'
|
10 |
-
'categories'
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
'screenshot_url' => 'full-url-path/screenshot.png?ver=1.6'
|
17 |
-
'demo_url'
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
'
|
23 |
-
|
24 |
-
|
25 |
-
|
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 |
-
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
function prefix_demo_import_lists() {
|
3 |
+
$demo_lists = array(
|
4 |
+
'demo1' => array(
|
5 |
+
'title' => __( 'Title 1', 'text-domain' ), /*Title*/
|
6 |
+
'is_pro' => false, /*Is Premium*/
|
7 |
+
'type' => 'gutentor', /*Optional eg gutentor, elementor or other page builders or type*/
|
8 |
+
'author' => __( 'Gutentor', 'text-domain' ), /*Author Name*/
|
9 |
+
'keywords' => array( 'medical', 'multipurpose' ), /*Search keyword*/
|
10 |
+
'categories' => array( 'medical', 'multipurpose' ), /*Categories*/
|
11 |
+
'template_url' => array(
|
12 |
+
'content' => 'full-url-path/content.json', /*Full URL Path to content.json*/
|
13 |
+
'options' => 'full-url-path/master/options.json', /*Full URL Path to options.json*/
|
14 |
+
'widgets' => 'full-url-path/widgets.json', /*Full URL Path to widgets.json*/
|
15 |
+
),
|
16 |
+
'screenshot_url' => 'full-url-path/screenshot.png?ver=1.6', /*Full URL Path to demo screenshot image*/
|
17 |
+
'demo_url' => 'https://www.demo.cosmoswp.com/', /*
|
18 |
+
Full URL Path to Live Demo*/
|
19 |
+
/* Recommended plugin for this demo */
|
20 |
+
'plugins' => array(
|
21 |
+
array(
|
22 |
+
'name' => __( 'Gutentor', 'text-domain' ),
|
23 |
+
'slug' => 'gutentor',
|
24 |
+
),
|
25 |
+
),
|
26 |
+
),
|
27 |
+
'demo2' => array(
|
28 |
+
'title' => __( 'Title 2', 'text-domain' ), /*Title*/
|
29 |
+
'is_pro' => false, /*Is Premium*/
|
30 |
+
'type' => 'gutentor', /*Optional eg gutentor, elementor or other page builders or type*/
|
31 |
+
'author' => __( 'Gutentor', 'text-domain' ), /*Author Name*/
|
32 |
+
'keywords' => array( 'about-block', 'about 3' ), /*Search keyword*/
|
33 |
+
'categories' => array( 'contact', 'multipurpose', 'woocommerce' ), /*Categories*/
|
34 |
+
'template_url' => array(
|
35 |
+
'content' => 'full-url-path/content.json', /*Full URL Path to content.json*/
|
36 |
+
'options' => 'full-url-path/master/options.json', /*Full URL Path to options.json*/
|
37 |
+
'widgets' => 'full-url-path/widgets.json', /*Full URL Path to widgets.json*/
|
38 |
+
),
|
39 |
+
'screenshot_url' => 'full-url-path/screenshot.png?ver=1.6', /*Full URL Path to demo screenshot image*/
|
40 |
+
'demo_url' => 'https://www.demo.cosmoswp.com/', /*
|
41 |
+
Full URL Path to Live Demo*/
|
42 |
+
/* Recommended plugin for this demo */
|
43 |
+
'plugins' => array(
|
44 |
+
array(
|
45 |
+
'name' => __( 'Gutentor', 'text-domain' ),
|
46 |
+
'slug' => 'gutentor',
|
47 |
+
),
|
48 |
+
array(
|
49 |
+
'name' => __( 'Contact Form 7', 'text-domain' ),
|
50 |
+
'slug' => 'contact-form-7',
|
51 |
+
'main_file' => 'wp-contact-form-7.php', /*the main plugin file of contact form 7 is different from plugin slug */
|
52 |
+
),
|
53 |
+
),
|
54 |
+
),
|
55 |
+
'demo3' => array(
|
56 |
+
'title' => __( 'Title 1', 'text-domain' ), /*Title*/
|
57 |
+
'is_pro' => true, /*Is Premium : Support Premium Version*/
|
58 |
+
'pro_url' => 'https://www.cosmoswp.com/pricing/', /*Premium version/Pricing Url*/
|
59 |
+
'type' => 'gutentor', /*Optional eg gutentor, elementor or other page builders or type*/
|
60 |
+
'author' => __( 'Gutentor', 'text-domain' ), /*Author Name*/
|
61 |
+
'keywords' => array( 'woocommerce', 'shop' ), /*Search keyword*/
|
62 |
+
'categories' => array( 'woocommerce', 'multipurpose' ), /*Categories*/
|
63 |
+
'template_url' => array(/* Optional for premium theme, you can add your own logic by hook*/
|
64 |
+
'content' => 'full-url-path/content.json', /*Full URL Path to content.json*/
|
65 |
+
'options' => 'full-url-path/master/options.json', /*Full URL Path to options.json*/
|
66 |
+
'widgets' => 'full-url-path/widgets.json', /*Full URL Path to widgets.json*/
|
67 |
+
),
|
68 |
+
'screenshot_url' => 'full-url-path/screenshot.png?ver=1.6', /*Full URL Path to demo screenshot image*/
|
69 |
+
'demo_url' => 'https://www.demo.cosmoswp.com/', /*
|
70 |
+
Full URL Path to Live Demo*/
|
71 |
+
/* Recommended plugin for this demo */
|
72 |
+
'plugins' => array(
|
73 |
+
array(
|
74 |
+
'name' => __( 'Gutentor', 'text-domain' ),
|
75 |
+
'slug' => 'gutentor',
|
76 |
+
),
|
77 |
+
),
|
78 |
+
),
|
79 |
+
/*and so on ............................*/
|
80 |
+
);
|
81 |
+
return $demo_lists;
|
82 |
+
}
|
83 |
+
add_filter( 'advanced_import_demo_lists', 'prefix_demo_import_lists' );
|
includes/class-advanced-import-deactivator.php
CHANGED
@@ -33,4 +33,4 @@ class Advanced_Import_Deactivator {
|
|
33 |
|
34 |
}
|
35 |
|
36 |
-
}
|
33 |
|
34 |
}
|
35 |
|
36 |
+
}
|
includes/class-advanced-import-i18n.php
CHANGED
@@ -41,4 +41,4 @@ class Advanced_Import_i18n {
|
|
41 |
);
|
42 |
|
43 |
}
|
44 |
-
}
|
41 |
);
|
42 |
|
43 |
}
|
44 |
+
}
|
includes/class-advanced-import-loader.php
CHANGED
@@ -57,11 +57,11 @@ class Advanced_Import_Loader {
|
|
57 |
* Add a new action to the collection to be registered with WordPress.
|
58 |
*
|
59 |
* @since 1.0.0
|
60 |
-
* @param string
|
61 |
-
* @param object
|
62 |
-
* @param string
|
63 |
-
* @param int
|
64 |
-
* @param int
|
65 |
*/
|
66 |
public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
67 |
$this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args );
|
@@ -71,11 +71,11 @@ class Advanced_Import_Loader {
|
|
71 |
* Add a new filter to the collection to be registered with WordPress.
|
72 |
*
|
73 |
* @since 1.0.0
|
74 |
-
* @param string
|
75 |
-
* @param object
|
76 |
-
* @param string
|
77 |
-
* @param int
|
78 |
-
* @param int
|
79 |
*/
|
80 |
public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
81 |
$this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
|
@@ -87,12 +87,12 @@ class Advanced_Import_Loader {
|
|
87 |
*
|
88 |
* @since 1.0.0
|
89 |
* @access private
|
90 |
-
* @param array
|
91 |
-
* @param string
|
92 |
-
* @param object
|
93 |
-
* @param string
|
94 |
-
* @param int
|
95 |
-
* @param int
|
96 |
* @return array The collection of actions and filters registered with WordPress.
|
97 |
*/
|
98 |
private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
|
@@ -102,7 +102,7 @@ class Advanced_Import_Loader {
|
|
102 |
'component' => $component,
|
103 |
'callback' => $callback,
|
104 |
'priority' => $priority,
|
105 |
-
'accepted_args' => $accepted_args
|
106 |
);
|
107 |
|
108 |
return $hooks;
|
@@ -126,4 +126,4 @@ class Advanced_Import_Loader {
|
|
126 |
|
127 |
}
|
128 |
|
129 |
-
}
|
57 |
* Add a new action to the collection to be registered with WordPress.
|
58 |
*
|
59 |
* @since 1.0.0
|
60 |
+
* @param string $hook The name of the WordPress action that is being registered.
|
61 |
+
* @param object $component A reference to the instance of the object on which the action is defined.
|
62 |
+
* @param string $callback The name of the function definition on the $component.
|
63 |
+
* @param int $priority Optional. The priority at which the function should be fired. Default is 10.
|
64 |
+
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
|
65 |
*/
|
66 |
public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
67 |
$this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args );
|
71 |
* Add a new filter to the collection to be registered with WordPress.
|
72 |
*
|
73 |
* @since 1.0.0
|
74 |
+
* @param string $hook The name of the WordPress filter that is being registered.
|
75 |
+
* @param object $component A reference to the instance of the object on which the filter is defined.
|
76 |
+
* @param string $callback The name of the function definition on the $component.
|
77 |
+
* @param int $priority Optional. The priority at which the function should be fired. Default is 10.
|
78 |
+
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1
|
79 |
*/
|
80 |
public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
81 |
$this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
|
87 |
*
|
88 |
* @since 1.0.0
|
89 |
* @access private
|
90 |
+
* @param array $hooks The collection of hooks that is being registered (that is, actions or filters).
|
91 |
+
* @param string $hook The name of the WordPress filter that is being registered.
|
92 |
+
* @param object $component A reference to the instance of the object on which the filter is defined.
|
93 |
+
* @param string $callback The name of the function definition on the $component.
|
94 |
+
* @param int $priority The priority at which the function should be fired.
|
95 |
+
* @param int $accepted_args The number of arguments that should be passed to the $callback.
|
96 |
* @return array The collection of actions and filters registered with WordPress.
|
97 |
*/
|
98 |
private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
|
102 |
'component' => $component,
|
103 |
'callback' => $callback,
|
104 |
'priority' => $priority,
|
105 |
+
'accepted_args' => $accepted_args,
|
106 |
);
|
107 |
|
108 |
return $hooks;
|
126 |
|
127 |
}
|
128 |
|
129 |
+
}
|
includes/class-advanced-import.php
CHANGED
@@ -98,7 +98,7 @@ class Advanced_Import {
|
|
98 |
|
99 |
// Only run these methods if they haven't been ran previously
|
100 |
if ( null === $instance ) {
|
101 |
-
$instance = new Advanced_Import;
|
102 |
|
103 |
$instance->setup_globals();
|
104 |
$instance->load_dependencies();
|
@@ -128,18 +128,18 @@ class Advanced_Import {
|
|
128 |
*/
|
129 |
private function setup_globals() {
|
130 |
|
131 |
-
$this->version
|
132 |
$this->plugin_name = ADVANCED_IMPORT_PLUGIN_NAME;
|
133 |
|
134 |
-
//The array of actions and filters registered with this plugins.
|
135 |
$this->actions = array();
|
136 |
$this->filters = array();
|
137 |
|
138 |
// Misc
|
139 |
-
$this->domain
|
140 |
-
$this->errors
|
141 |
}
|
142 |
-
|
143 |
/**
|
144 |
* Load the required dependencies for this plugin.
|
145 |
*
|
@@ -188,13 +188,12 @@ class Advanced_Import {
|
|
188 |
require_once ADVANCED_IMPORT_PATH . 'admin/class-reset.php';
|
189 |
|
190 |
/*Theme Specific Setting*/
|
191 |
-
|
192 |
-
|
193 |
-
require_once ADVANCED_IMPORT_PATH . 'includes/theme-template-library/cosmoswp.php'; /*cosmoswp*/
|
194 |
-
require_once ADVANCED_IMPORT_PATH . 'includes/theme-template-library/acmethemes.php'; /*acmethemes*/
|
195 |
|
|
|
|
|
196 |
|
197 |
-
|
198 |
|
199 |
}
|
200 |
|
@@ -246,9 +245,9 @@ class Advanced_Import {
|
|
246 |
$this->loader->add_action( 'wp_ajax_complete_screen', $this->admin, 'complete_screen' );
|
247 |
|
248 |
/*Reset Process*/
|
249 |
-
$this->loader->add_action( 'wp_loaded', advanced_import_reset_wordpress(), 'hide_reset_notice'
|
250 |
$this->loader->add_action( 'admin_init', advanced_import_reset_wordpress(), 'reset_wizard_actions', -1 );
|
251 |
-
$this->loader->add_action( 'admin_notices', advanced_import_reset_wordpress(), 'reset_wizard_notice'
|
252 |
|
253 |
}
|
254 |
|
@@ -291,4 +290,4 @@ class Advanced_Import {
|
|
291 |
public function get_version() {
|
292 |
return $this->version;
|
293 |
}
|
294 |
-
}
|
98 |
|
99 |
// Only run these methods if they haven't been ran previously
|
100 |
if ( null === $instance ) {
|
101 |
+
$instance = new Advanced_Import();
|
102 |
|
103 |
$instance->setup_globals();
|
104 |
$instance->load_dependencies();
|
128 |
*/
|
129 |
private function setup_globals() {
|
130 |
|
131 |
+
$this->version = defined( 'ADVANCED_IMPORT_VERSION' ) ? ADVANCED_IMPORT_VERSION : '1.0.0';
|
132 |
$this->plugin_name = ADVANCED_IMPORT_PLUGIN_NAME;
|
133 |
|
134 |
+
// The array of actions and filters registered with this plugins.
|
135 |
$this->actions = array();
|
136 |
$this->filters = array();
|
137 |
|
138 |
// Misc
|
139 |
+
$this->domain = 'advanced-import'; // Unique identifier for retrieving translated strings
|
140 |
+
$this->errors = new WP_Error(); // errors
|
141 |
}
|
142 |
+
|
143 |
/**
|
144 |
* Load the required dependencies for this plugin.
|
145 |
*
|
188 |
require_once ADVANCED_IMPORT_PATH . 'admin/class-reset.php';
|
189 |
|
190 |
/*Theme Specific Setting*/
|
191 |
+
require_once ADVANCED_IMPORT_PATH . 'includes/class-theme-template-library-base.php';
|
|
|
|
|
|
|
192 |
|
193 |
+
require_once ADVANCED_IMPORT_PATH . 'includes/theme-template-library/cosmoswp.php'; /*cosmoswp*/
|
194 |
+
require_once ADVANCED_IMPORT_PATH . 'includes/theme-template-library/acmethemes.php'; /*acmethemes*/
|
195 |
|
196 |
+
$this->loader = new Advanced_Import_Loader();
|
197 |
|
198 |
}
|
199 |
|
245 |
$this->loader->add_action( 'wp_ajax_complete_screen', $this->admin, 'complete_screen' );
|
246 |
|
247 |
/*Reset Process*/
|
248 |
+
$this->loader->add_action( 'wp_loaded', advanced_import_reset_wordpress(), 'hide_reset_notice', -1 );
|
249 |
$this->loader->add_action( 'admin_init', advanced_import_reset_wordpress(), 'reset_wizard_actions', -1 );
|
250 |
+
$this->loader->add_action( 'admin_notices', advanced_import_reset_wordpress(), 'reset_wizard_notice', -1 );
|
251 |
|
252 |
}
|
253 |
|
290 |
public function get_version() {
|
291 |
return $this->version;
|
292 |
}
|
293 |
+
}
|
includes/class-theme-template-library-base.php
CHANGED
@@ -1,32 +1,32 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
|
5 |
-
}
|
6 |
-
|
7 |
-
if ( ! class_exists( 'Advanced_Import_Theme_Template_Library_Base' ) ) {
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
if ( ! class_exists( 'Advanced_Import_Theme_Template_Library_Base' ) ) {
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Base Class For CosmosWP for common functions
|
11 |
+
*
|
12 |
+
* @package Advanced Import
|
13 |
+
* @subpackage Advanced Import Template Library
|
14 |
+
* @since 1.0.0
|
15 |
+
*/
|
16 |
+
class Advanced_Import_Theme_Template_Library_Base {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Run Block
|
20 |
+
*
|
21 |
+
* @access public
|
22 |
+
* @since 1.0.0
|
23 |
+
* @return void
|
24 |
+
*/
|
25 |
+
public function run() {
|
26 |
+
|
27 |
+
if ( method_exists( $this, 'add_template_library' ) ) {
|
28 |
+
add_filter( 'advanced_import_demo_lists', array( $this, 'add_template_library' ) );
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
+
}
|
includes/functions-advanced-import.php
CHANGED
@@ -1,29 +1,29 @@
|
|
1 |
-
<?php
|
2 |
-
function advanced_import_allowed_html
|
3 |
-
$allowed_html = wp_kses_allowed_html('post');
|
4 |
-
$output
|
5 |
-
return $output;
|
6 |
-
}
|
7 |
-
|
8 |
-
function advanced_import_current_url
|
9 |
-
global $pagenow;
|
10 |
-
$current_url = $pagenow == 'tools.php'?admin_url( 'tools.php?page=advanced-import-tool'):admin_url( 'themes.php?page=advanced-import');
|
11 |
-
return $current_url;
|
12 |
-
}
|
13 |
-
|
14 |
-
function advanced_import_get_current_theme_author(){
|
15 |
-
|
16 |
-
|
17 |
-
}
|
18 |
-
function advanced_import_get_current_theme_slug(){
|
19 |
-
|
20 |
-
|
21 |
-
}
|
22 |
-
function advanced_import_get_theme_screenshot(){
|
23 |
-
|
24 |
-
|
25 |
-
}
|
26 |
-
function advanced_import_get_theme_name(){
|
27 |
-
|
28 |
-
|
29 |
-
}
|
1 |
+
<?php
|
2 |
+
function advanced_import_allowed_html( $input ) {
|
3 |
+
$allowed_html = wp_kses_allowed_html( 'post' );
|
4 |
+
$output = wp_kses( $input, $allowed_html );
|
5 |
+
return $output;
|
6 |
+
}
|
7 |
+
|
8 |
+
function advanced_import_current_url() {
|
9 |
+
global $pagenow;
|
10 |
+
$current_url = $pagenow == 'tools.php' ? admin_url( 'tools.php?page=advanced-import-tool' ) : admin_url( 'themes.php?page=advanced-import' );
|
11 |
+
return $current_url;
|
12 |
+
}
|
13 |
+
|
14 |
+
function advanced_import_get_current_theme_author() {
|
15 |
+
$current_theme = wp_get_theme();
|
16 |
+
return $current_theme->get( 'Author' );
|
17 |
+
}
|
18 |
+
function advanced_import_get_current_theme_slug() {
|
19 |
+
$current_theme = wp_get_theme();
|
20 |
+
return $current_theme->stylesheet;
|
21 |
+
}
|
22 |
+
function advanced_import_get_theme_screenshot() {
|
23 |
+
$current_theme = wp_get_theme();
|
24 |
+
return $current_theme->get_screenshot();
|
25 |
+
}
|
26 |
+
function advanced_import_get_theme_name() {
|
27 |
+
$current_theme = wp_get_theme();
|
28 |
+
return $current_theme->get( 'Name' );
|
29 |
+
}
|
includes/index.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php // Silence is golden
|
1 |
+
<?php // Silence is golden
|
includes/theme-template-library/acmethemes.php
CHANGED
@@ -1,103 +1,108 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
-
|
4 |
-
}
|
5 |
-
|
6 |
-
if ( ! class_exists( 'Advanced_Import_Theme_Acmethemes' ) ) {
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
*
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
exit;
|
4 |
+
}
|
5 |
+
|
6 |
+
if ( ! class_exists( 'Advanced_Import_Theme_Acmethemes' ) ) {
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Functions related to About Block
|
10 |
+
*
|
11 |
+
* @package Advanced Import
|
12 |
+
* @subpackage Advanced_Import_Theme_Acmethemes
|
13 |
+
* @since 1.0.5
|
14 |
+
*/
|
15 |
+
|
16 |
+
class Advanced_Import_Theme_Acmethemes extends Advanced_Import_Theme_Template_Library_Base {
|
17 |
+
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Theme author
|
21 |
+
* This class is created for acmethemes theme
|
22 |
+
* Check for author
|
23 |
+
*
|
24 |
+
* @since 1.0.5
|
25 |
+
* @access private
|
26 |
+
*/
|
27 |
+
private $theme_author = 'acmethemes';
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Gets an instance of this object.
|
31 |
+
* Prevents duplicate instances which avoid artefacts and improves performance.
|
32 |
+
*
|
33 |
+
* @static
|
34 |
+
* @access public
|
35 |
+
* @since 1.0.5
|
36 |
+
* @return object
|
37 |
+
*/
|
38 |
+
public static function get_instance() {
|
39 |
+
|
40 |
+
// Store the instance locally to avoid private static replication
|
41 |
+
static $instance = null;
|
42 |
+
|
43 |
+
// Only run these methods if they haven't been ran previously
|
44 |
+
if ( null === $instance ) {
|
45 |
+
$instance = new self();
|
46 |
+
}
|
47 |
+
|
48 |
+
// Always return the instance
|
49 |
+
return $instance;
|
50 |
+
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Load block library
|
55 |
+
* Used for blog template loading
|
56 |
+
*
|
57 |
+
* @since 1.0.5
|
58 |
+
* @package Acmethemes
|
59 |
+
* @author Acmethemes <info@acmethemes.com>
|
60 |
+
*
|
61 |
+
* @param$current_demo_list array
|
62 |
+
* @return array
|
63 |
+
*/
|
64 |
+
public function add_template_library( $current_demo_list ) {
|
65 |
+
/*common check*/
|
66 |
+
if ( advanced_import_get_current_theme_author() != $this->theme_author ) {
|
67 |
+
return $current_demo_list;
|
68 |
+
}
|
69 |
+
|
70 |
+
/*
|
71 |
+
for acmethemes only
|
72 |
+
check if acmethemes template library function exist*/
|
73 |
+
if ( function_exists( 'run_acme_demo_setup' ) ) {
|
74 |
+
return $current_demo_list;
|
75 |
+
}
|
76 |
+
|
77 |
+
/*finally fetch template library data from live*/
|
78 |
+
$templates_list = array();
|
79 |
+
|
80 |
+
$url = 'https://www.acmeit.org/wp-json/acmethemes-demo-api/v1/fetch_templates/?theme-slug=' . esc_attr( advanced_import_get_current_theme_slug() );
|
81 |
+
$body_args = array(
|
82 |
+
/*API version*/
|
83 |
+
'api_version' => wp_get_theme()['Version'],
|
84 |
+
/*lang*/
|
85 |
+
'site_lang' => get_bloginfo( 'language' ),
|
86 |
+
);
|
87 |
+
$raw_json = wp_safe_remote_get(
|
88 |
+
$url,
|
89 |
+
array(
|
90 |
+
'timeout' => 100,
|
91 |
+
'body' => $body_args,
|
92 |
+
)
|
93 |
+
);
|
94 |
+
|
95 |
+
if ( ! is_wp_error( $raw_json ) ) {
|
96 |
+
$demo_server = json_decode( wp_remote_retrieve_body( $raw_json ), true );
|
97 |
+
if ( json_last_error() === JSON_ERROR_NONE ) {
|
98 |
+
if ( is_array( $demo_server ) ) {
|
99 |
+
$templates_list = $demo_server;
|
100 |
+
}
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
return array_merge( $current_demo_list, $templates_list );
|
105 |
+
}
|
106 |
+
}
|
107 |
+
}
|
108 |
+
Advanced_Import_Theme_Acmethemes::get_instance()->run();
|
includes/theme-template-library/cosmoswp.php
CHANGED
@@ -1,114 +1,119 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
-
|
4 |
-
}
|
5 |
-
|
6 |
-
if ( ! class_exists( 'Advanced_Import_Theme_CosmosWP' ) ) {
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
exit;
|
4 |
+
}
|
5 |
+
|
6 |
+
if ( ! class_exists( 'Advanced_Import_Theme_CosmosWP' ) ) {
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Functions related to About Block
|
10 |
+
*
|
11 |
+
* @package Advanced Import
|
12 |
+
* @subpackage Advanced_Import_Theme_CosmosWP
|
13 |
+
* @since 1.0.5
|
14 |
+
*/
|
15 |
+
|
16 |
+
class Advanced_Import_Theme_CosmosWP extends Advanced_Import_Theme_Template_Library_Base {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Theme name
|
20 |
+
* This class is crated for cosmoswp theme
|
21 |
+
*
|
22 |
+
* @since 1.0.5
|
23 |
+
* @access private
|
24 |
+
*/
|
25 |
+
private $theme = 'cosmoswp';
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Theme author
|
29 |
+
* This class is crated for cosmoswp theme
|
30 |
+
* Double check for author
|
31 |
+
*
|
32 |
+
* @since 1.0.5
|
33 |
+
* @access private
|
34 |
+
*/
|
35 |
+
private $theme_author = 'cosmoswp';
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Gets an instance of this object.
|
39 |
+
* Prevents duplicate instances which avoid artefacts and improves performance.
|
40 |
+
*
|
41 |
+
* @static
|
42 |
+
* @access public
|
43 |
+
* @since 1.0.5
|
44 |
+
* @return object
|
45 |
+
*/
|
46 |
+
public static function get_instance() {
|
47 |
+
|
48 |
+
// Store the instance locally to avoid private static replication
|
49 |
+
static $instance = null;
|
50 |
+
|
51 |
+
// Only run these methods if they haven't been ran previously
|
52 |
+
if ( null === $instance ) {
|
53 |
+
$instance = new self();
|
54 |
+
}
|
55 |
+
|
56 |
+
// Always return the instance
|
57 |
+
return $instance;
|
58 |
+
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Load block library
|
63 |
+
* Used for blog template loading
|
64 |
+
*
|
65 |
+
* @since 1.0.5
|
66 |
+
* @package CosmosWP
|
67 |
+
* @author CosmosWP <info@cosmoswp.com>
|
68 |
+
*
|
69 |
+
* @param$current_demo_list array
|
70 |
+
* @return array
|
71 |
+
*/
|
72 |
+
public function add_template_library( $current_demo_list ) {
|
73 |
+
/*common check*/
|
74 |
+
if ( strtolower( advanced_import_get_current_theme_author() ) != $this->theme_author ) {
|
75 |
+
return $current_demo_list;
|
76 |
+
}
|
77 |
+
if ( advanced_import_get_current_theme_slug() != $this->theme ) {
|
78 |
+
return $current_demo_list;
|
79 |
+
}
|
80 |
+
|
81 |
+
/*
|
82 |
+
For cosmoswp only.
|
83 |
+
check if cosmoswp template library function exist*/
|
84 |
+
if ( function_exists( 'run_cosmoswp_template_library' ) ) {
|
85 |
+
return $current_demo_list;
|
86 |
+
}
|
87 |
+
|
88 |
+
/*finally fetch template library data from live*/
|
89 |
+
$templates_list = array();
|
90 |
+
|
91 |
+
$url = 'https://www.demo.cosmoswp.com/wp-json/cosmoswp-demo-api/v1/fetch_templates/';
|
92 |
+
$body_args = array(
|
93 |
+
/*API version*/
|
94 |
+
'api_version' => wp_get_theme()['Version'],
|
95 |
+
/*lang*/
|
96 |
+
'site_lang' => get_bloginfo( 'language' ),
|
97 |
+
);
|
98 |
+
$raw_json = wp_safe_remote_get(
|
99 |
+
$url,
|
100 |
+
array(
|
101 |
+
'timeout' => 100,
|
102 |
+
'body' => $body_args,
|
103 |
+
)
|
104 |
+
);
|
105 |
+
|
106 |
+
if ( ! is_wp_error( $raw_json ) ) {
|
107 |
+
$demo_server = json_decode( wp_remote_retrieve_body( $raw_json ), true );
|
108 |
+
if ( json_last_error() === JSON_ERROR_NONE ) {
|
109 |
+
if ( is_array( $demo_server ) ) {
|
110 |
+
$templates_list = $demo_server;
|
111 |
+
}
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
return array_merge( $current_demo_list, $templates_list );
|
116 |
+
}
|
117 |
+
}
|
118 |
+
}
|
119 |
+
Advanced_Import_Theme_CosmosWP::get_instance()->run();
|
index.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php // Silence is golden
|
1 |
+
<?php // Silence is golden
|
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.2.
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
|
@@ -22,6 +22,8 @@ It is designed specially for theme developer who wants to provide demo data to t
|
|
22 |
|
23 |
While you use Demo Import features of themes, Advanced Import may fetches screenshots, images and templates(demo) JSON files from a respective theme site. This helps you to import your site with a single click. You must accept the terms and privacy of the themes you are using to use Demo Import ( Starter Sites Template Library ) Features.
|
24 |
|
|
|
|
|
25 |
Some listed features of Advanced Import are given below :
|
26 |
|
27 |
* Import demo starter sites very easily
|
@@ -223,6 +225,13 @@ Advanced Import is generally one-time use plugin, it is meant to be used for Dem
|
|
223 |
|
224 |
== Changelog ==
|
225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
= 1.2.4 - 2020-06-22 =
|
227 |
* Updated : API Url
|
228 |
|
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.5.3
|
8 |
Requires PHP: 5.6.20
|
9 |
+
Stable tag: 1.2.5
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
|
22 |
|
23 |
While you use Demo Import features of themes, Advanced Import may fetches screenshots, images and templates(demo) JSON files from a respective theme site. This helps you to import your site with a single click. You must accept the terms and privacy of the themes you are using to use Demo Import ( Starter Sites Template Library ) Features.
|
24 |
|
25 |
+
View [Advanced Import](https://www.addonspress.com/wordpress-plugins/advanced-import/) Details and Documentation
|
26 |
+
|
27 |
Some listed features of Advanced Import are given below :
|
28 |
|
29 |
* Import demo starter sites very easily
|
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/)
|
231 |
+
* Updated : PHPCS
|
232 |
+
* Updated : Some minor design
|
233 |
+
* Updated : Minor changes
|
234 |
+
|
235 |
= 1.2.4 - 2020-06-22 =
|
236 |
* Updated : API Url
|
237 |
|
uninstall.php
CHANGED
@@ -22,4 +22,4 @@
|
|
22 |
// If uninstall not called from WordPress, then exit.
|
23 |
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
24 |
exit;
|
25 |
-
}
|
22 |
// If uninstall not called from WordPress, then exit.
|
23 |
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
24 |
exit;
|
25 |
+
}
|