Version Description
- 2020-06-22 =
- Added : Shortcode support
- Added : Meta post id support
- Added : Gutentor import support
- Added : Elementor import support
- Added : Post type array order
- Added : Default Post and Page move to trash
Download this release
Release Info
Developer | addonspress |
Plugin | Advanced Import : One Click Import for WordPress or Theme Demo Data |
Version | 1.2.3 |
Comparing to | |
See all releases |
Code changes from version 1.2.0 to 1.2.3
- admin/class-advanced-import-admin.php +185 -78
- admin/class-elementor-import.php +109 -0
- advanced-import.php +2 -2
- assets/css/advanced-import-admin.min.css +1 -1
- includes/class-advanced-import.php +1 -0
- readme.txt +19 -4
admin/class-advanced-import-admin.php
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
|
|
3 |
/**
|
4 |
* The admin-specific functionality of the plugin.
|
5 |
*
|
@@ -184,15 +186,20 @@ class Advanced_Import_Admin {
|
|
184 |
*/
|
185 |
public function is_template_available( $item ){
|
186 |
$is_available = false;
|
187 |
-
|
|
|
|
|
188 |
$is_available = true;
|
189 |
}
|
190 |
-
|
191 |
-
|
|
|
192 |
}
|
193 |
-
|
|
|
194 |
$is_available = true;
|
195 |
}
|
|
|
196 |
return (boolean) apply_filters( 'advanced_import_is_template_available', $is_available );
|
197 |
}
|
198 |
|
@@ -999,6 +1006,28 @@ class Advanced_Import_Admin {
|
|
999 |
);
|
1000 |
}
|
1001 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1002 |
/*check if there is files*/
|
1003 |
$widget_data = $this->get_widgets_json();
|
1004 |
if( !empty( $widget_data ) ){
|
@@ -1048,8 +1077,10 @@ class Advanced_Import_Admin {
|
|
1048 |
}
|
1049 |
check_admin_referer( 'advanced-import' );
|
1050 |
|
1051 |
-
|
1052 |
-
|
|
|
|
|
1053 |
|
1054 |
do_action('advanced_import_before_content_screen');
|
1055 |
|
@@ -1115,9 +1146,20 @@ class Advanced_Import_Admin {
|
|
1115 |
)
|
1116 |
);
|
1117 |
}
|
|
|
|
|
|
|
|
|
1118 |
|
1119 |
-
|
1120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1121 |
|
1122 |
$content_slug = isset( $_POST['content'] )? sanitize_title( $_POST['content'] ): '';
|
1123 |
|
@@ -1284,7 +1326,7 @@ class Advanced_Import_Admin {
|
|
1284 |
|
1285 |
/*set and get imported_post_ids
|
1286 |
return mix*/
|
1287 |
-
|
1288 |
if ( is_array( $original_id ) || is_object( $original_id ) ) {
|
1289 |
return false;
|
1290 |
}
|
@@ -1342,14 +1384,6 @@ class Advanced_Import_Admin {
|
|
1342 |
}
|
1343 |
|
1344 |
|
1345 |
-
/*return the difference in length between two strings
|
1346 |
-
https://www.w3schools.com/php/func_array_uksort.asp
|
1347 |
-
used in method parse_content_for_shortcode_image_etc
|
1348 |
-
*/
|
1349 |
-
public function uksort_strlen( $a, $b ) {
|
1350 |
-
return strlen( $b ) - strlen( $a );
|
1351 |
-
}
|
1352 |
-
|
1353 |
/*Important Function
|
1354 |
Import single Post/Content
|
1355 |
*/
|
@@ -1563,7 +1597,10 @@ class Advanced_Import_Admin {
|
|
1563 |
}
|
1564 |
}
|
1565 |
}
|
1566 |
-
|
|
|
|
|
|
|
1567 |
|
1568 |
/*replace menu data
|
1569 |
work out what we're replacing. a tax, page, term etc..*/
|
@@ -1630,8 +1667,9 @@ class Advanced_Import_Admin {
|
|
1630 |
}
|
1631 |
}
|
1632 |
|
1633 |
-
/*post content parser
|
1634 |
-
|
|
|
1635 |
|
1636 |
$replace_tax_id_keys = array(
|
1637 |
'taxonomies',
|
@@ -1733,7 +1771,25 @@ class Advanced_Import_Admin {
|
|
1733 |
foreach ( $terms_to_set as $tax => $ids ) {
|
1734 |
wp_set_post_terms( $post_id, $ids, $tax );
|
1735 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1736 |
}
|
|
|
1737 |
}
|
1738 |
break;
|
1739 |
}
|
@@ -1741,64 +1797,113 @@ class Advanced_Import_Admin {
|
|
1741 |
return true;
|
1742 |
}
|
1743 |
|
1744 |
-
/*
|
1745 |
-
return modified content*/
|
1746 |
-
private function parse_content_for_shortcode_image_etc( $content ){
|
1747 |
-
/*we have to format the post content. rewriting images and gallery stuff*/
|
1748 |
-
$replace = $this->imported_post_id();
|
1749 |
-
|
1750 |
-
/*filters urls for replace*/
|
1751 |
-
$urls_replace = array();
|
1752 |
-
foreach ( $replace as $key => $val ) {
|
1753 |
-
if ( $key && $val && ! is_numeric( $key ) && ! is_numeric( $val ) ) {
|
1754 |
-
$urls_replace[ $key ] = $val;
|
1755 |
-
}
|
1756 |
-
}
|
1757 |
-
/*replace image/file urls*/
|
1758 |
-
if ( $urls_replace ) {
|
1759 |
-
uksort( $urls_replace, array( &$this, 'uksort_strlen' ) );
|
1760 |
-
foreach ( $urls_replace as $from_url => $to_url ) {
|
1761 |
-
$content = str_replace( $from_url, $to_url, $content );
|
1762 |
-
}
|
1763 |
-
}
|
1764 |
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
if ( ! $new_id ) {
|
1773 |
-
unset( $ids[ $key ] );
|
1774 |
-
}
|
1775 |
-
else {
|
1776 |
-
$ids[ $key ] = $new_id;
|
1777 |
-
}
|
1778 |
-
}
|
1779 |
-
$new_ids = implode( ',', $ids );
|
1780 |
-
$content = str_replace( $ids_matches[0], 'ids="' . $new_ids . '"', $content );
|
1781 |
-
}
|
1782 |
-
}
|
1783 |
-
}
|
1784 |
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1802 |
|
1803 |
/*update parent page id for child page*/
|
1804 |
private function processpost_orphans() {
|
@@ -1956,7 +2061,9 @@ class Advanced_Import_Admin {
|
|
1956 |
'woocommerce_myaccount_page_id',
|
1957 |
'woocommerce_edit_address_page_id',
|
1958 |
'woocommerce_view_order_page_id',
|
1959 |
-
'woocommerce_terms_page_id'
|
|
|
|
|
1960 |
)
|
1961 |
);
|
1962 |
|
1 |
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
exit;
|
4 |
+
}
|
5 |
/**
|
6 |
* The admin-specific functionality of the plugin.
|
7 |
*
|
186 |
*/
|
187 |
public function is_template_available( $item ){
|
188 |
$is_available = false;
|
189 |
+
|
190 |
+
/*if pro active everything is available*/
|
191 |
+
if( $this->is_pro_active ){
|
192 |
$is_available = true;
|
193 |
}
|
194 |
+
/*if is_pro not set the $item is available*/
|
195 |
+
elseif( !isset($item['is_pro'] ) ){
|
196 |
+
$is_available = true;/*template available since */
|
197 |
}
|
198 |
+
/*if is_pro not set but it is false, it will be free and avialable*/
|
199 |
+
elseif( isset( $item['is_pro'] ) && !$item['is_pro'] ){
|
200 |
$is_available = true;
|
201 |
}
|
202 |
+
|
203 |
return (boolean) apply_filters( 'advanced_import_is_template_available', $is_available );
|
204 |
}
|
205 |
|
1006 |
);
|
1007 |
}
|
1008 |
}
|
1009 |
+
/*array adjustment
|
1010 |
+
TODO : Remove it after adjustment on Advanced Import
|
1011 |
+
*/
|
1012 |
+
/*Put post 3nd last*/
|
1013 |
+
$post = isset( $content['post'] ) ? $content['post'] : array();
|
1014 |
+
if ( $post ) {
|
1015 |
+
unset( $content['post'] );
|
1016 |
+
$content['post'] = $post;
|
1017 |
+
}
|
1018 |
+
/*Put page 2nd last*/
|
1019 |
+
$page = isset( $content['page'] ) ? $content['page'] : array();
|
1020 |
+
if ( $page ) {
|
1021 |
+
unset( $content['page'] );
|
1022 |
+
$content['page'] = $page;
|
1023 |
+
|
1024 |
+
}
|
1025 |
+
/*Put nav last*/
|
1026 |
+
$nav = isset( $content['nav_menu_item'] ) ? $content['nav_menu_item'] : array();
|
1027 |
+
if ( $nav ) {
|
1028 |
+
unset( $content['nav_menu_item'] );
|
1029 |
+
$content['nav_menu_item'] = $nav;
|
1030 |
+
}
|
1031 |
/*check if there is files*/
|
1032 |
$widget_data = $this->get_widgets_json();
|
1033 |
if( !empty( $widget_data ) ){
|
1077 |
}
|
1078 |
check_admin_referer( 'advanced-import' );
|
1079 |
|
1080 |
+
if( isset($_POST['template_url'] )){
|
1081 |
+
$this->current_template_url = is_array( $_POST['template_url'] )? (array) $_POST['template_url'] : sanitize_text_field( $_POST['template_url'] );
|
1082 |
+
$this->current_template_type = sanitize_text_field( $_POST['template_type'] );
|
1083 |
+
}
|
1084 |
|
1085 |
do_action('advanced_import_before_content_screen');
|
1086 |
|
1146 |
)
|
1147 |
);
|
1148 |
}
|
1149 |
+
if( isset($_POST['template_url'] )){
|
1150 |
+
$this->current_template_url = is_array( $_POST['template_url'] )? (array) $_POST['template_url'] : sanitize_text_field( $_POST['template_url'] );
|
1151 |
+
$this->current_template_type = sanitize_text_field ( $_POST['template_type'] );
|
1152 |
+
}
|
1153 |
|
1154 |
+
/*Move to Trash default page and post*/
|
1155 |
+
$sample_page = get_page_by_title('Sample Page', OBJECT, 'page');
|
1156 |
+
$hello_world_post = get_page_by_title('Hello world!', OBJECT, 'post');
|
1157 |
+
if( is_object( $sample_page ) ) {
|
1158 |
+
wp_trash_post( $sample_page->ID );
|
1159 |
+
}
|
1160 |
+
if( is_object( $hello_world_post ) ) {
|
1161 |
+
wp_trash_post( $hello_world_post->ID );
|
1162 |
+
}
|
1163 |
|
1164 |
$content_slug = isset( $_POST['content'] )? sanitize_title( $_POST['content'] ): '';
|
1165 |
|
1326 |
|
1327 |
/*set and get imported_post_ids
|
1328 |
return mix*/
|
1329 |
+
public function imported_post_id( $original_id = false, $new_id = false ) {
|
1330 |
if ( is_array( $original_id ) || is_object( $original_id ) ) {
|
1331 |
return false;
|
1332 |
}
|
1384 |
}
|
1385 |
|
1386 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1387 |
/*Important Function
|
1388 |
Import single Post/Content
|
1389 |
*/
|
1597 |
}
|
1598 |
}
|
1599 |
}
|
1600 |
+
|
1601 |
+
array_walk_recursive( $post_data['meta'], array( advanced_import_elementor(), 'elementor_id_import' ) );
|
1602 |
+
|
1603 |
+
/*todo gutenberg and page builders*/
|
1604 |
|
1605 |
/*replace menu data
|
1606 |
work out what we're replacing. a tax, page, term etc..*/
|
1667 |
}
|
1668 |
}
|
1669 |
|
1670 |
+
/*post content parser
|
1671 |
+
for shortcode post id replacement*/
|
1672 |
+
$post_data['post_content'] = $this->parse_shortcode_meta_content( $post_data['post_content'] );
|
1673 |
|
1674 |
$replace_tax_id_keys = array(
|
1675 |
'taxonomies',
|
1771 |
foreach ( $terms_to_set as $tax => $ids ) {
|
1772 |
wp_set_post_terms( $post_id, $ids, $tax );
|
1773 |
}
|
1774 |
+
|
1775 |
+
if ( (isset( $post_data['meta']['_elementor_data'] ) && !empty($post_data['meta']['_elementor_data'])) ||
|
1776 |
+
(isset($post_data['meta']['_elementor_css']) && !!empty($post_data['meta']['_elementor_css']))
|
1777 |
+
) {
|
1778 |
+
advanced_import_elementor()->elementor_post( $post_id );
|
1779 |
+
}
|
1780 |
+
|
1781 |
+
/*Gutentor*/
|
1782 |
+
$post = get_post( $post_id );
|
1783 |
+
$content = $post->post_content;
|
1784 |
+
if ( preg_match_all( '/data-gpid="(.*?)\" /', $content, $matches ) ) {
|
1785 |
+
foreach ( $matches[0] as $match_id => $string ) {
|
1786 |
+
$content = str_replace( $matches[0][$match_id], 'data-gpid="' . $post_id . '" ', $content );
|
1787 |
+
}
|
1788 |
+
}
|
1789 |
+
$post->post_content = $content;
|
1790 |
+
wp_update_post( $post );
|
1791 |
}
|
1792 |
+
|
1793 |
}
|
1794 |
break;
|
1795 |
}
|
1797 |
return true;
|
1798 |
}
|
1799 |
|
1800 |
+
/*Shortcode/Meta/Post Ids fixed start*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1801 |
|
1802 |
+
/*
|
1803 |
+
* since 1.2.3
|
1804 |
+
* return the difference in length between two strings
|
1805 |
+
* */
|
1806 |
+
public function strlen_diff( $a, $b ) {
|
1807 |
+
return strlen( $b ) - strlen( $a );
|
1808 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1809 |
|
1810 |
+
|
1811 |
+
/*
|
1812 |
+
* since 1.2.3
|
1813 |
+
* helper function to parse url, shortcode, post ids form provided content
|
1814 |
+
* * currently uses on meta and post content
|
1815 |
+
* */
|
1816 |
+
public function parse_shortcode_meta_content( $content ){
|
1817 |
+
/*we have to format the post content. rewriting images and gallery stuff*/
|
1818 |
+
$replace = $this->imported_post_id();
|
1819 |
+
|
1820 |
+
/*filters urls for replace*/
|
1821 |
+
$urls_replace = array();
|
1822 |
+
foreach ( $replace as $key => $val ) {
|
1823 |
+
if ( $key && $val && ! is_numeric( $key ) && ! is_numeric( $val ) ) {
|
1824 |
+
$urls_replace[ $key ] = $val;
|
1825 |
+
}
|
1826 |
+
}
|
1827 |
+
/*replace image/file urls*/
|
1828 |
+
if ( $urls_replace ) {
|
1829 |
+
uksort( $urls_replace, array( &$this, 'strlen_diff' ) );
|
1830 |
+
foreach ( $urls_replace as $from_url => $to_url ) {
|
1831 |
+
$content = str_replace( $from_url, $to_url, $content );
|
1832 |
+
}
|
1833 |
+
}
|
1834 |
+
|
1835 |
+
/*gallery fixed*/
|
1836 |
+
if ( preg_match_all( '#\[gallery[^\]]*\]#', $content, $matches ) ) {
|
1837 |
+
foreach ( $matches[0] as $match_id => $string ) {
|
1838 |
+
if ( preg_match( '#ids="([^"]+)"#', $string, $ids_matches ) ) {
|
1839 |
+
$ids = explode( ',', $ids_matches[1] );
|
1840 |
+
foreach ( $ids as $key => $val ) {
|
1841 |
+
$new_id = $val ? $this->imported_post_id( $val ) : false;
|
1842 |
+
if ( ! $new_id ) {
|
1843 |
+
unset( $ids[ $key ] );
|
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 |
+
else {
|
1864 |
+
/*no imported ID found. remove this entry.*/
|
1865 |
+
$content = str_replace( $matches[0], '(insert contact form here)', $content );
|
1866 |
+
}
|
1867 |
+
}
|
1868 |
+
}
|
1869 |
+
}
|
1870 |
+
|
1871 |
+
/*Gutentor*/
|
1872 |
+
if ( preg_match_all( '/\"pTaxTerm"(.*?)\]/', $content, $matches ) ) {
|
1873 |
+
foreach ( $matches[0] as $match_id => $string ) {
|
1874 |
+
if ( preg_match_all( '/\"value":(.*?)\}/', $string, $matches1 ) ) {
|
1875 |
+
foreach ( $matches1[0] as $match_id1 => $string1 ) {
|
1876 |
+
$new_id = $this->imported_term_id( $matches1[1][$match_id1] );
|
1877 |
+
$content = str_replace( $string1, '"value":' . $new_id . '}', $content );
|
1878 |
+
}
|
1879 |
+
}
|
1880 |
+
}
|
1881 |
+
}
|
1882 |
+
if ( preg_match_all( '/\"e14TaxTerm"(.*?)\]/', $content, $matches ) ) {
|
1883 |
+
foreach ( $matches[0] as $match_id => $string ) {
|
1884 |
+
if ( preg_match_all( '/\"value":(.*?)\}/', $string, $matches1 ) ) {
|
1885 |
+
foreach ( $matches1[0] as $match_id1 => $string1 ) {
|
1886 |
+
$new_id = $this->imported_term_id( $matches1[1][$match_id1] );
|
1887 |
+
$content = str_replace( $string1, '"value":' . $new_id . '}', $content );
|
1888 |
+
}
|
1889 |
+
}
|
1890 |
+
}
|
1891 |
+
}
|
1892 |
+
if ( preg_match_all( '/data-gpid="(.*?)\" /', $content, $matches ) ) {
|
1893 |
+
foreach ( $matches[0] as $match_id => $string ) {
|
1894 |
+
$new_id = $this->imported_post_id( $matches[1][$match_id] );
|
1895 |
+
$content = str_replace( $matches[0][$match_id], 'data-gpid="' . $new_id . '" ', $content );
|
1896 |
+
}
|
1897 |
+
}
|
1898 |
+
if ( preg_match_all( '/\"p4PostId"(.*?)\,/', $content, $matches ) ) {
|
1899 |
+
foreach ( $matches[0] as $match_id => $string ) {
|
1900 |
+
$new_id = $this->imported_post_id( $matches[1][$match_id] );
|
1901 |
+
$content = str_replace( $matches[0][$match_id], '"p4PostId":' . $new_id . ',', $content );
|
1902 |
+
}
|
1903 |
+
}
|
1904 |
+
return $content;
|
1905 |
+
}
|
1906 |
+
/*Shortcode/Meta/Post Ids fixed end*/
|
1907 |
|
1908 |
/*update parent page id for child page*/
|
1909 |
private function processpost_orphans() {
|
2061 |
'woocommerce_myaccount_page_id',
|
2062 |
'woocommerce_edit_address_page_id',
|
2063 |
'woocommerce_view_order_page_id',
|
2064 |
+
'woocommerce_terms_page_id',
|
2065 |
+
/*gutentor*/
|
2066 |
+
'wp_block_id'
|
2067 |
)
|
2068 |
);
|
2069 |
|
admin/class-elementor-import.php
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
exit;
|
4 |
+
}
|
5 |
+
|
6 |
+
/**
|
7 |
+
* The elementor import functionality of the plugin.
|
8 |
+
*
|
9 |
+
*
|
10 |
+
* @package Advanced_Import
|
11 |
+
* @subpackage Advanced_Import/admin/Advanced_Import_Elementor
|
12 |
+
* @author Addons Press <addonspress.com>
|
13 |
+
*/
|
14 |
+
if ( ! class_exists( 'Advanced_Import_Elementor' ) ) {
|
15 |
+
/**
|
16 |
+
* Advanced_Import_Elementor
|
17 |
+
*/
|
18 |
+
class Advanced_Import_Elementor {
|
19 |
+
/**
|
20 |
+
* Main Advanced_Import_Elementor Instance
|
21 |
+
* Initialize the class and set its properties.
|
22 |
+
*
|
23 |
+
* @since 1.0.0
|
24 |
+
* @return object $instance Advanced_Import_Elementor Instance
|
25 |
+
*/
|
26 |
+
public static function instance() {
|
27 |
+
|
28 |
+
// Store the instance locally to avoid private static replication
|
29 |
+
static $instance = null;
|
30 |
+
|
31 |
+
// Only run these methods if they haven't been ran previously
|
32 |
+
if ( null === $instance ) {
|
33 |
+
$instance = new self();
|
34 |
+
}
|
35 |
+
|
36 |
+
// Always return the instance
|
37 |
+
return $instance;
|
38 |
+
}
|
39 |
+
|
40 |
+
public function elementor_id_import( &$item, $key ) {
|
41 |
+
if ( $key == 'id' && ! empty( $item ) && is_numeric( $item ) ) {
|
42 |
+
// check if this has been imported before
|
43 |
+
$new_meta_val = advanced_import_admin()->imported_post_id( $item );
|
44 |
+
if ( $new_meta_val ) {
|
45 |
+
$item = $new_meta_val;
|
46 |
+
}
|
47 |
+
}
|
48 |
+
if ( $key == 'page' && ! empty( $item ) ) {
|
49 |
+
|
50 |
+
if ( false !== strpos( $item, 'p.' ) ) {
|
51 |
+
$new_id = str_replace('p.', '', $item);
|
52 |
+
// check if this has been imported before
|
53 |
+
$new_meta_val = advanced_import_admin()->imported_post_id( $new_id );
|
54 |
+
if ( $new_meta_val ) {
|
55 |
+
$item = 'p.' . $new_meta_val;
|
56 |
+
}
|
57 |
+
}else if(is_numeric($item)){
|
58 |
+
// check if this has been imported before
|
59 |
+
$new_meta_val = advanced_import_admin()->imported_post_id( $item );
|
60 |
+
if ( $new_meta_val ) {
|
61 |
+
$item = $new_meta_val;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
}
|
65 |
+
if ( $key == 'post_id' && ! empty( $item ) && is_numeric( $item ) ) {
|
66 |
+
// check if this has been imported before
|
67 |
+
$new_meta_val = advanced_import_admin()->imported_post_id( $item );
|
68 |
+
if ( $new_meta_val ) {
|
69 |
+
$item = $new_meta_val;
|
70 |
+
}
|
71 |
+
}
|
72 |
+
if ( $key == 'url' && ! empty( $item ) && strstr( $item, 'ocalhost' ) ) {
|
73 |
+
// check if this has been imported before
|
74 |
+
$new_meta_val = advanced_import_admin()->imported_post_id( $item );
|
75 |
+
if ( $new_meta_val ) {
|
76 |
+
$item = $new_meta_val;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
if ( ($key == 'shortcode' || $key == 'editor') && ! empty( $item ) ) {
|
80 |
+
// we have to fix the [contact-form-7 id=133] shortcode issue.
|
81 |
+
$item = advanced_import_admin()->parse_shortcode_meta_content($item);
|
82 |
+
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
public function elementor_post( $post_id = false ) {
|
87 |
+
|
88 |
+
// regenerate the CSS for this Elementor post
|
89 |
+
if( class_exists( 'Elementor\Core\Files\CSS\Post' ) ) {
|
90 |
+
$post_css = new Elementor\Core\Files\CSS\Post($post_id);
|
91 |
+
$post_css->update();
|
92 |
+
}
|
93 |
+
}
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Begins execution of the plugin.
|
100 |
+
*
|
101 |
+
* Since everything within the plugin is registered via hooks,
|
102 |
+
* then kicking off the plugin from this point in the file does
|
103 |
+
* not affect the page life cycle.
|
104 |
+
*
|
105 |
+
* @since 1.0.0
|
106 |
+
*/
|
107 |
+
function advanced_import_elementor( ) {
|
108 |
+
return Advanced_Import_Elementor::instance();
|
109 |
+
}
|
advanced-import.php
CHANGED
@@ -14,7 +14,7 @@ if ( ! defined( 'WPINC' ) ) {
|
|
14 |
* Plugin Name: Advanced Import
|
15 |
* Plugin URI: https://addonspress.com/item/advanced-import
|
16 |
* Description: Easily import demo data starter site packages or Migrate your site data
|
17 |
-
* Version: 1.2.
|
18 |
* Author: AddonsPress
|
19 |
* Author URI: https://addonspress.com/
|
20 |
* License: GPL-2.0+
|
@@ -24,7 +24,7 @@ if ( ! defined( 'WPINC' ) ) {
|
|
24 |
*/
|
25 |
|
26 |
/*Define Constants for this plugin*/
|
27 |
-
define( 'ADVANCED_IMPORT_VERSION', '1.2.
|
28 |
define( 'ADVANCED_IMPORT_PLUGIN_NAME', 'advanced-import' );
|
29 |
define( 'ADVANCED_IMPORT_PATH', plugin_dir_path( __FILE__ ) );
|
30 |
define( 'ADVANCED_IMPORT_URL', plugin_dir_url( __FILE__ ) );
|
14 |
* Plugin Name: Advanced Import
|
15 |
* Plugin URI: https://addonspress.com/item/advanced-import
|
16 |
* Description: Easily import demo data starter site packages or Migrate your site data
|
17 |
+
* Version: 1.2.3
|
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.3' );
|
28 |
define( 'ADVANCED_IMPORT_PLUGIN_NAME', 'advanced-import' );
|
29 |
define( 'ADVANCED_IMPORT_PATH', plugin_dir_path( __FILE__ ) );
|
30 |
define( 'ADVANCED_IMPORT_URL', plugin_dir_url( __FILE__ ) );
|
assets/css/advanced-import-admin.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.ai-body{margin:40px 15px 0}.ai-body img{max-width:100%;height:auto}.ai-header{margin-bottom:40px}.ai-filter-tabs{display:flex;align-items:center;background:#fff;padding:10px 20px;margin-bottom: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:
|
1 |
+
.ai-body{margin:40px 15px 0}.ai-body img{max-width:100%;height:auto}.ai-header{margin-bottom:40px}.ai-filter-tabs{display:flex;align-items:center;background:#fff;padding:10px 20px;margin-bottom: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}
|
includes/class-advanced-import.php
CHANGED
@@ -180,6 +180,7 @@ class Advanced_Import {
|
|
180 |
* The class responsible for defining all actions that occur in the admin area.
|
181 |
*/
|
182 |
require_once ADVANCED_IMPORT_PATH . 'admin/class-advanced-import-admin.php';
|
|
|
183 |
|
184 |
/**
|
185 |
* The class responsible for WordPress rset
|
180 |
* The class responsible for defining all actions that occur in the admin area.
|
181 |
*/
|
182 |
require_once ADVANCED_IMPORT_PATH . 'admin/class-advanced-import-admin.php';
|
183 |
+
require_once ADVANCED_IMPORT_PATH . 'admin/class-elementor-import.php';
|
184 |
|
185 |
/**
|
186 |
* The class responsible for WordPress rset
|
readme.txt
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
=== Advanced Import : One Click Import for WordPress or Theme Demo Data ===
|
2 |
|
3 |
-
Contributors: addonspress
|
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.4
|
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 |
|
@@ -86,7 +86,7 @@ Technically, if you check to include media, the zip files content media files. H
|
|
86 |
|
87 |
First of all, you need to Export your theme demo data from your live demo site using [Advanced Export](https://wordpress.org/plugins/advanced-export/) plugin.
|
88 |
Export the zip file, it should contain 3 files content.json, options.json and widgets.json.
|
89 |
-
If you are submitting theme on WordPress dot org, you have to create a separate plugin for your theme/company. We would like to highly recommend to create a single plugin for your all themes. For other platforms, you may add code on your theme.
|
90 |
Code Example :
|
91 |
`
|
92 |
function prefix_demo_import_lists(){
|
@@ -223,6 +223,21 @@ Advanced Import is generally one-time use plugin, it is meant to be used for Dem
|
|
223 |
|
224 |
== Changelog ==
|
225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
= 1.2.0 - 2020-03-12 =
|
227 |
* Added : Premium demo support
|
228 |
* Added : Readme documentation
|
1 |
=== Advanced Import : One Click Import for WordPress or Theme Demo Data ===
|
2 |
|
3 |
+
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.4.2
|
8 |
Requires PHP: 5.6.20
|
9 |
+
Stable tag: 1.2.3
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
|
86 |
|
87 |
First of all, you need to Export your theme demo data from your live demo site using [Advanced Export](https://wordpress.org/plugins/advanced-export/) plugin.
|
88 |
Export the zip file, it should contain 3 files content.json, options.json and widgets.json.
|
89 |
+
If you are submitting theme on WordPress dot org, you are not allowed to include Demo files ( XML, JSON, ZIP), You have to create a separate plugin for your theme/company. We would like to highly recommend to create a single plugin for your all themes. For other platforms, you may add code on your theme.
|
90 |
Code Example :
|
91 |
`
|
92 |
function prefix_demo_import_lists(){
|
223 |
|
224 |
== Changelog ==
|
225 |
|
226 |
+
= 1.2.3 - 2020-06-22 =
|
227 |
+
* Added : Shortcode support
|
228 |
+
* Added : Meta post id support
|
229 |
+
* Added : Gutentor import support
|
230 |
+
* Added : Elementor import support
|
231 |
+
* Added : Post type array order
|
232 |
+
* Added : Default Post and Page move to trash
|
233 |
+
|
234 |
+
= 1.2.2 - 2020-04-06 =
|
235 |
+
* Updated : Contributors
|
236 |
+
* Fixed : Some Design Issue
|
237 |
+
|
238 |
+
= 1.2.1 - 2020-03-16 =
|
239 |
+
* Fixed : Premium demo support
|
240 |
+
|
241 |
= 1.2.0 - 2020-03-12 =
|
242 |
* Added : Premium demo support
|
243 |
* Added : Readme documentation
|