Version Description
- added compatibility with WP 3.9
- added autodetect session mode
- updated convertation CSV to XML with XMLWriter
- fixed import *.zip files
- fixed xpath helper on step 2
- fixed showing zeros in XML tree
- fixed deleting history files
- fixed autodetect image extensions
- fixed increasing SQL query length
- allow post content to be empty on step 3
- delete deprecated settings "my csv contain html code" and "case sensitivity"
Download this release
Release Info
Developer | soflyy |
Plugin | Import any XML or CSV File to WordPress |
Version | 3.1.2 |
Comparing to | |
See all releases |
Code changes from version 3.1.1 to 3.1.2
- actions/admin_init.php +1 -1
- actions/admin_menu.php +14 -6
- actions/admin_notices.php +5 -4
- actions/plugins_loaded.php +1 -4
- actions/wp_loaded.php +3 -1
- classes/arrayaccess.php +1 -2
- classes/chunk.php +23 -45
- classes/session.php +4 -0
- config/options.php +4 -2
- controllers/admin/addons.php +71 -27
- controllers/admin/import.php +106 -87
- controllers/admin/manage.php +19 -18
- controllers/admin/settings.php +8 -5
- controllers/controller/admin.php +1 -1
- helpers/get_file_curl.php +47 -12
- helpers/import_custom_meta_box.php +1 -2
- helpers/is_exists_term.php +1 -2
- helpers/pmxi_findDuplicates.php +4 -5
- helpers/pmxi_functions.php +109 -54
- helpers/pmxi_insert_attachment.php +0 -1
- helpers/pmxi_insert_post.php +1 -3
- helpers/pmxi_recursion_taxes.php +7 -7
- helpers/reverse_taxonomies_html.php +8 -7
- helpers/wp_delete_attachments.php +4 -1
- libraries/XmlImportCsvParse.php +74 -105
- libraries/XmlImportParser.php +2 -3
- libraries/XmlImportTemplate.php +2 -2
- libraries/XmlImportTemplateCodeGenerator.php +12 -10
- libraries/XmlImportTemplateParser.php +6 -5
- libraries/XmlImportTemplateScanner.php +7 -3
- libraries/pclzip.lib.php +17 -0
- models/import/record.php +406 -390
- models/model.php +1 -2
- models/model/record.php +4 -4
- plugin.php +33 -7
- readme.txt +21 -6
- schema.php +3 -2
- static/css/admin-wp-3.8.css +5 -0
- static/css/admin.css +31 -11
- static/js/admin.js +120 -86
- static/js/jquery/jquery.mjs.nestedSortable.js +1 -1
- static/js/pmxi.js +1 -1
- views/admin/addons/index.php +2 -0
- views/admin/import/element.php +1 -0
- views/admin/import/evaluate_variations.php +1 -0
- views/admin/import/index.php +4 -4
- views/admin/import/options.php +68 -125
- views/admin/import/options/_buttons_template.php +3 -3
- views/admin/import/options/_categories_template.php +43 -35
- views/admin/import/options/_custom_fields_template.php +221 -36
- views/admin/import/options/_featured_template.php +2 -3
- views/admin/import/options/_main_options_template.php +4 -4
- views/admin/import/options/_reimport_template.php +37 -35
- views/admin/import/options/_settings_template.php +1 -1
- views/admin/import/options/_taxonomies_template.php +31 -26
- views/admin/import/process.php +3 -2
- views/admin/import/template.php +2 -1
- views/admin/manage/index.php +67 -12
- views/admin/settings/index.php +1 -9
actions/admin_init.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?php
|
2 |
|
3 |
function pmxi_admin_init(){
|
4 |
-
wp_enqueue_script('pmxi-script', PMXI_ROOT_URL . '/static/js/pmxi.js', array('jquery'), PMXI_VERSION);
|
5 |
}
|
1 |
<?php
|
2 |
|
3 |
function pmxi_admin_init(){
|
4 |
+
wp_enqueue_script('pmxi-script', PMXI_ROOT_URL . '/static/js/pmxi.js', array('jquery'), PMXI_VERSION);
|
5 |
}
|
actions/admin_menu.php
CHANGED
@@ -8,14 +8,22 @@ function pmxi_admin_menu() {
|
|
8 |
|
9 |
if (current_user_can('manage_options')) { // admin management options
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
add_menu_page(__('WP All Import', 'pmxi_plugin'), __('All Import', 'pmxi_plugin'), 'manage_options', 'pmxi-admin-home', array(PMXI_Plugin::getInstance(), 'adminDispatcher'), PMXI_Plugin::ROOT_URL . '/static/img/xmlicon.png');
|
12 |
// workaround to rename 1st option to `Home`
|
13 |
-
$submenu['pmxi-admin-home'] = array();
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
//add_submenu_page('pmxi-admin-home', __('Scheduled Imports', 'pmxi_plugin') . ' ‹ ' . __('WP All Import', 'pmxi_plugin'), __('Scheduled Imports', 'pmxi_plugin'), 'manage_options', 'pmxi-admin-cron', array(PMXI_Plugin::getInstance(), 'adminDispatcher'));
|
19 |
|
20 |
}
|
21 |
}
|
8 |
|
9 |
if (current_user_can('manage_options')) { // admin management options
|
10 |
|
11 |
+
$wpai_menu = array(
|
12 |
+
array('pmxi-admin-import', __('New Import', 'pmxi_plugin')),
|
13 |
+
array('pmxi-admin-manage' , __('Manage Imports', 'pmxi_plugin')),
|
14 |
+
array('pmxi-admin-settings', __('Settings', 'pmxi_plugin')),
|
15 |
+
array('pmxi-admin-help', __('Support', 'pmxi_plugin'))
|
16 |
+
);
|
17 |
+
|
18 |
+
$wpai_menu = apply_filters('pmxi_admin_menu', $wpai_menu);
|
19 |
+
|
20 |
add_menu_page(__('WP All Import', 'pmxi_plugin'), __('All Import', 'pmxi_plugin'), 'manage_options', 'pmxi-admin-home', array(PMXI_Plugin::getInstance(), 'adminDispatcher'), PMXI_Plugin::ROOT_URL . '/static/img/xmlicon.png');
|
21 |
// workaround to rename 1st option to `Home`
|
22 |
+
$submenu['pmxi-admin-home'] = array();
|
23 |
+
|
24 |
+
foreach ($wpai_menu as $key => $value) {
|
25 |
+
add_submenu_page('pmxi-admin-home', $value[1], $value[1], 'manage_options', $value[0], array(PMXI_Plugin::getInstance(), 'adminDispatcher'));
|
26 |
+
}
|
|
|
27 |
|
28 |
}
|
29 |
}
|
actions/admin_notices.php
CHANGED
@@ -25,9 +25,9 @@ function pmxi_admin_notices() {
|
|
25 |
) ?>
|
26 |
</p></div>
|
27 |
<?php
|
28 |
-
}
|
29 |
|
30 |
-
if ( class_exists( 'PMWI_Plugin' ) and ( version_compare(PMWI_VERSION, '1.2.
|
31 |
?>
|
32 |
<div class="error"><p>
|
33 |
<?php printf(
|
@@ -36,8 +36,8 @@ function pmxi_admin_notices() {
|
|
36 |
) ?>
|
37 |
</p></div>
|
38 |
<?php
|
39 |
-
|
40 |
-
if (PMWI_EDITION == 'paid')
|
41 |
{
|
42 |
deactivate_plugins( PMWI_ROOT_DIR . '/plugin.php');
|
43 |
}
|
@@ -45,6 +45,7 @@ function pmxi_admin_notices() {
|
|
45 |
{
|
46 |
deactivate_plugins( PMWI_FREE_ROOT_DIR . '/plugin.php');
|
47 |
}
|
|
|
48 |
}
|
49 |
|
50 |
$input = new PMXI_Input();
|
25 |
) ?>
|
26 |
</p></div>
|
27 |
<?php
|
28 |
+
}
|
29 |
|
30 |
+
if ( class_exists( 'PMWI_Plugin' ) and ( defined('PMWI_VERSION') and version_compare(PMWI_VERSION, '1.2.8') <= 0 and PMWI_EDITION == 'paid' or defined('PMWI_FREE_VERSION') and version_compare(PMWI_FREE_VERSION, '1.1.1') <= 0 and PMWI_EDITION == 'free') ) {
|
31 |
?>
|
32 |
<div class="error"><p>
|
33 |
<?php printf(
|
36 |
) ?>
|
37 |
</p></div>
|
38 |
<?php
|
39 |
+
|
40 |
+
if (defined('PMWI_EDITION') and PMWI_EDITION == 'paid')
|
41 |
{
|
42 |
deactivate_plugins( PMWI_ROOT_DIR . '/plugin.php');
|
43 |
}
|
45 |
{
|
46 |
deactivate_plugins( PMWI_FREE_ROOT_DIR . '/plugin.php');
|
47 |
}
|
48 |
+
|
49 |
}
|
50 |
|
51 |
$input = new PMXI_Input();
|
actions/plugins_loaded.php
CHANGED
@@ -1,9 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
function pmxi_plugins_loaded() {
|
4 |
-
|
5 |
-
PMXI_Plugin::$session = PMXI_Session::get_instance();
|
6 |
-
do_action( 'pmxi_session_start' );
|
7 |
|
8 |
-
return PMXI_Plugin::$session->session_started();
|
9 |
}
|
1 |
<?php
|
2 |
|
3 |
function pmxi_plugins_loaded() {
|
4 |
+
|
|
|
|
|
5 |
|
|
|
6 |
}
|
actions/wp_loaded.php
CHANGED
@@ -2,5 +2,7 @@
|
|
2 |
|
3 |
function pmxi_wp_loaded() {
|
4 |
|
5 |
-
|
|
|
|
|
6 |
}
|
2 |
|
3 |
function pmxi_wp_loaded() {
|
4 |
|
5 |
+
@ini_set("max_input_time", PMXI_Plugin::getInstance()->getOption('max_input_time'));
|
6 |
+
@ini_set("max_execution_time", PMXI_Plugin::getInstance()->getOption('max_execution_time'));
|
7 |
+
|
8 |
}
|
classes/arrayaccess.php
CHANGED
@@ -137,5 +137,4 @@ class PMXI_ArrayAccess implements ArrayAccess {
|
|
137 |
|
138 |
$this->dirty = true;
|
139 |
}
|
140 |
-
}
|
141 |
-
?>
|
137 |
|
138 |
$this->dirty = true;
|
139 |
}
|
140 |
+
}
|
|
classes/chunk.php
CHANGED
@@ -76,10 +76,16 @@ class PMXI_Chunk {
|
|
76 |
$this->file = $file;
|
77 |
|
78 |
if (empty($this->options['element'])){
|
79 |
-
$founded_tags = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
$reader = new XMLReader();
|
82 |
-
$reader->open($
|
83 |
$reader->setParserProperty(XMLReader::VALIDATE, false);
|
84 |
while ( @$reader->read()) {
|
85 |
switch ($reader->nodeType) {
|
@@ -92,8 +98,8 @@ class PMXI_Chunk {
|
|
92 |
break;
|
93 |
}
|
94 |
}
|
95 |
-
unset($reader);
|
96 |
-
|
97 |
if (!empty($founded_tags)) {
|
98 |
$element_counts = array_count_values($founded_tags);
|
99 |
if (!empty($element_counts)){
|
@@ -107,7 +113,7 @@ class PMXI_Chunk {
|
|
107 |
|
108 |
if (!empty($this->cloud)){
|
109 |
|
110 |
-
$main_elements = array('node', 'product', 'job', 'deal', 'entry', 'item', 'property', 'listing', 'hotel', 'record', 'article');
|
111 |
|
112 |
foreach ($this->cloud as $element_name => $value) {
|
113 |
if ( in_array(strtolower($element_name), $main_elements) ){
|
@@ -115,8 +121,7 @@ class PMXI_Chunk {
|
|
115 |
break;
|
116 |
}
|
117 |
}
|
118 |
-
if (empty($this->options['element'])){
|
119 |
-
//if (count($element_counts) > 1) array_shift($element_counts);
|
120 |
foreach ($element_counts as $el => $count) {
|
121 |
$this->options['element'] = $el;
|
122 |
break;
|
@@ -125,43 +130,16 @@ class PMXI_Chunk {
|
|
125 |
}
|
126 |
}
|
127 |
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
fseek($this->handle, 0);
|
135 |
-
$this->reading = true;
|
136 |
-
// read in the whole doc, cos we don't know what's wanted
|
137 |
-
while ($this->reading) {
|
138 |
-
$c = @fread($this->handle, $this->options['chunkSize']);
|
139 |
-
|
140 |
-
$enc = @preg_match("/<\?xml[^<]*\?>/i", $c, $enc_matches);
|
141 |
-
if ($enc)
|
142 |
-
$this->options['encoding'] = $enc_matches[0];
|
143 |
-
|
144 |
-
$this->reading = false;
|
145 |
-
}
|
146 |
-
if ($this->handle) @fclose($this->handle);
|
147 |
-
}
|
148 |
-
|
149 |
-
$encoding = '';
|
150 |
-
|
151 |
-
if (empty($this->options['encoding']) or strpos($this->options['encoding'], 'encoding') === false)
|
152 |
-
$encoding = "UTF-8";
|
153 |
-
else
|
154 |
-
preg_match('~encoding=["|\']{1}([-a-z0-9_]+)["|\']{1}~i', $this->options['encoding'], $encoding);
|
155 |
-
|
156 |
-
$this->options['encoding'] = (is_array($encoding)) ? $encoding[1] : $encoding; */
|
157 |
-
|
158 |
-
/*stream_filter_register("removecolons", "removecolons_filter");
|
159 |
-
|
160 |
-
$path = 'php://filter/read=removecolons/resource=' . $this->file;*/
|
161 |
|
162 |
-
$this->reader = new XMLReader();
|
163 |
-
$this->reader->open($
|
164 |
$this->reader->setParserProperty(XMLReader::VALIDATE, false);
|
|
|
165 |
|
166 |
}
|
167 |
|
@@ -218,7 +196,7 @@ class PMXI_Chunk {
|
|
218 |
}
|
219 |
} catch (XmlImportException $e) {
|
220 |
$xml = false;
|
221 |
-
}
|
222 |
|
223 |
return ( ! empty($xml) ) ? $this->removeColonsFromRSS(preg_replace('%xmlns.*=\s*([\'"]).*\1%sU', '', $xml)) : false;
|
224 |
|
@@ -247,12 +225,12 @@ class PMXI_Chunk {
|
|
247 |
|
248 |
}
|
249 |
|
250 |
-
class
|
251 |
|
252 |
function filter($in, $out, &$consumed, $closing)
|
253 |
{
|
254 |
while ($bucket = stream_bucket_make_writeable($in)) {
|
255 |
-
|
256 |
$consumed += $bucket->datalen;
|
257 |
stream_bucket_append($out, $bucket);
|
258 |
}
|
76 |
$this->file = $file;
|
77 |
|
78 |
if (empty($this->options['element'])){
|
79 |
+
$founded_tags = array();
|
80 |
+
|
81 |
+
if (function_exists('stream_filter_register')){
|
82 |
+
stream_filter_register('preprocessxml', 'preprocessXml_filter');
|
83 |
+
$path = 'php://filter/read=preprocessxml/resource=' . $this->file;
|
84 |
+
}
|
85 |
+
else $path = $this->file;
|
86 |
|
87 |
$reader = new XMLReader();
|
88 |
+
$reader->open($path);
|
89 |
$reader->setParserProperty(XMLReader::VALIDATE, false);
|
90 |
while ( @$reader->read()) {
|
91 |
switch ($reader->nodeType) {
|
98 |
break;
|
99 |
}
|
100 |
}
|
101 |
+
unset($reader);
|
102 |
+
|
103 |
if (!empty($founded_tags)) {
|
104 |
$element_counts = array_count_values($founded_tags);
|
105 |
if (!empty($element_counts)){
|
113 |
|
114 |
if (!empty($this->cloud)){
|
115 |
|
116 |
+
$main_elements = array('node', 'product', 'job', 'deal', 'entry', 'item', 'property', 'listing', 'hotel', 'record', 'article', 'post');
|
117 |
|
118 |
foreach ($this->cloud as $element_name => $value) {
|
119 |
if ( in_array(strtolower($element_name), $main_elements) ){
|
121 |
break;
|
122 |
}
|
123 |
}
|
124 |
+
if (empty($this->options['element'])){
|
|
|
125 |
foreach ($element_counts as $el => $count) {
|
126 |
$this->options['element'] = $el;
|
127 |
break;
|
130 |
}
|
131 |
}
|
132 |
|
133 |
+
if (function_exists('stream_filter_register')){
|
134 |
+
stream_filter_register('preprocessxml', 'preprocessXml_filter');
|
135 |
+
$path = 'php://filter/read=preprocessxml/resource=' . $this->file;
|
136 |
+
}
|
137 |
+
else $path = $this->file;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
|
139 |
+
$this->reader = new XMLReader();
|
140 |
+
$this->reader->open($path);
|
141 |
$this->reader->setParserProperty(XMLReader::VALIDATE, false);
|
142 |
+
|
143 |
|
144 |
}
|
145 |
|
196 |
}
|
197 |
} catch (XmlImportException $e) {
|
198 |
$xml = false;
|
199 |
+
}
|
200 |
|
201 |
return ( ! empty($xml) ) ? $this->removeColonsFromRSS(preg_replace('%xmlns.*=\s*([\'"]).*\1%sU', '', $xml)) : false;
|
202 |
|
225 |
|
226 |
}
|
227 |
|
228 |
+
class preprocessXml_filter extends php_user_filter {
|
229 |
|
230 |
function filter($in, $out, &$consumed, $closing)
|
231 |
{
|
232 |
while ($bucket = stream_bucket_make_writeable($in)) {
|
233 |
+
PMXI_Import_Record::preprocessXml($bucket->data);
|
234 |
$consumed += $bucket->datalen;
|
235 |
stream_bucket_append($out, $bucket);
|
236 |
}
|
classes/session.php
CHANGED
@@ -72,6 +72,10 @@ final class PMXI_Session extends PMXI_ArrayAccess implements Iterator, Countable
|
|
72 |
* @uses apply_filters Calls `wp_session_expiration` to determine how long until sessions expire.
|
73 |
*/
|
74 |
protected function __construct() {
|
|
|
|
|
|
|
|
|
75 |
|
76 |
$this->session_mode = PMXI_Plugin::getInstance()->getOption('session_mode');
|
77 |
|
72 |
* @uses apply_filters Calls `wp_session_expiration` to determine how long until sessions expire.
|
73 |
*/
|
74 |
protected function __construct() {
|
75 |
+
|
76 |
+
if ( (version_compare(phpversion(), '5.4.0') >= 0 and session_status() == PHP_SESSION_DISABLED) or ('default' == PMXI_Plugin::getInstance()->getOption('session_mode') and !session_id() and !@session_start())){
|
77 |
+
PMXI_Plugin::getInstance()->updateOption(array('session_mode' => 'files'));
|
78 |
+
}
|
79 |
|
80 |
$this->session_mode = PMXI_Plugin::getInstance()->getOption('session_mode');
|
81 |
|
config/options.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* List of plugin optins, contains only default values, actual values are stored in database
|
4 |
* and can be changed by corresponding wordpress function calls
|
5 |
*/
|
6 |
-
$config = array(
|
7 |
"history_file_count" => 10000,
|
8 |
"history_file_age" => 365,
|
9 |
"highlight_limit" => 10000,
|
@@ -23,5 +23,7 @@ $config = array(
|
|
23 |
"case_sensitive" => 1,
|
24 |
"session_mode" => 'default',
|
25 |
"enable_ftp_import" => 0,
|
26 |
-
"large_feed_limit" => 1000
|
|
|
|
|
27 |
);
|
3 |
* List of plugin optins, contains only default values, actual values are stored in database
|
4 |
* and can be changed by corresponding wordpress function calls
|
5 |
*/
|
6 |
+
$config = array(
|
7 |
"history_file_count" => 10000,
|
8 |
"history_file_age" => 365,
|
9 |
"highlight_limit" => 10000,
|
23 |
"case_sensitive" => 1,
|
24 |
"session_mode" => 'default',
|
25 |
"enable_ftp_import" => 0,
|
26 |
+
"large_feed_limit" => 1000,
|
27 |
+
"enable_cron_processing_time_limit" => 0,
|
28 |
+
"cron_processing_time_limit" => 120
|
29 |
);
|
controllers/admin/addons.php
CHANGED
@@ -6,57 +6,81 @@
|
|
6 |
*/
|
7 |
class PMXI_Admin_Addons extends PMXI_Controller_Admin {
|
8 |
|
9 |
-
public static $addons = array('PMWI_Plugin' => 0, 'PMAI_Plugin' => 0, 'PMWITabs_Plugin' => 0, 'PMLI_Plugin' => 0); // inactive by default
|
10 |
|
11 |
-
public
|
12 |
-
|
13 |
-
parent::__construct();
|
14 |
|
15 |
-
|
16 |
|
17 |
-
public function
|
18 |
|
19 |
-
|
20 |
-
|
|
|
|
|
21 |
'title' => __("WooCommerce Addon",'pmxi_plugin'),
|
22 |
'description' => __("Import Products from any XML or CSV to WooCommerce",'pmxi_plugin'),
|
23 |
'thumbnail' => 'http://placehold.it/220x220',
|
24 |
-
'active' => (class_exists('PMWI_Plugin') and PMWI_EDITION == 'paid'),
|
25 |
-
'free_installed' => (class_exists('PMWI_Plugin') and PMWI_EDITION == 'free'),
|
26 |
'required_plugins' => false,
|
27 |
'url' => 'http://www.wpallimport.com/woocommerce-product-import'
|
28 |
);
|
29 |
-
|
|
|
|
|
30 |
'title' => __("ACF Addon",'pmxi_plugin'),
|
31 |
'description' => __("Import to advanced custom fields",'pmxi_plugin'),
|
32 |
'thumbnail' => 'http://placehold.it/220x220',
|
33 |
-
'active' => class_exists('PMAI_Plugin'),
|
34 |
-
'free_installed' => (class_exists('PMAI_Plugin') and PMAI_EDITION == 'free'),
|
35 |
'required_plugins' => array('Advanced Custom Fields' => class_exists('acf')),
|
36 |
-
'url' => 'http://www.wpallimport.com'
|
37 |
);
|
38 |
-
|
|
|
|
|
39 |
'title' => __("WPML Addon",'pmxi_plugin'),
|
40 |
'description' => __("Import to WPML",'pmxi_plugin'),
|
41 |
'thumbnail' => 'http://placehold.it/220x220',
|
42 |
-
'active' => class_exists('PMLI_Plugin'),
|
43 |
-
'free_installed' => (class_exists('PMLI_Plugin') and PMLI_EDITION == 'free'),
|
44 |
'required_plugins' => array('WPML' => class_exists('SitePress')),
|
45 |
-
'url' => 'http://www.wpallimport.com'
|
46 |
-
);
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
'title' => __("WooCommerce Addon - free edition",'pmxi_plugin'),
|
51 |
'description' => __("Import Products from any XML or CSV to WooCommerce",'pmxi_plugin'),
|
52 |
'thumbnail' => 'http://placehold.it/220x220',
|
53 |
-
'active' => (class_exists('PMWI_Plugin') and PMWI_EDITION == 'free'),
|
54 |
-
'paid_installed' => (class_exists('PMWI_Plugin') and PMWI_EDITION == 'paid'),
|
55 |
'required_plugins' => false,
|
56 |
'url' => 'http://wordpress.org/plugins/woocommerce-xml-csv-product-import'
|
57 |
);
|
58 |
-
|
59 |
-
$this->data['free']['PMWITabs_Plugin'] = array(
|
60 |
'title' => __("WooCommerce Tabs Addon",'pmxi_plugin'),
|
61 |
'description' => __("Import data to WooCommerce tabs",'pmxi_plugin'),
|
62 |
'thumbnail' => 'http://placehold.it/220x220',
|
@@ -64,14 +88,34 @@ class PMXI_Admin_Addons extends PMXI_Controller_Admin {
|
|
64 |
'paid_installed' => false,
|
65 |
'required_plugins' => array('WooCommerce Addon' => class_exists('PMWI_Plugin')),
|
66 |
'url' => 'http://www.wpallimport.com'
|
67 |
-
);
|
|
|
|
|
|
|
|
|
|
|
68 |
|
|
|
|
|
|
|
|
|
69 |
$this->render();
|
70 |
}
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
protected static function set_addons_status(){
|
73 |
foreach (self::$addons as $class => $active)
|
74 |
self::$addons[$class] = class_exists($class);
|
|
|
|
|
|
|
75 |
}
|
76 |
|
77 |
public static function get_all_addons(){
|
6 |
*/
|
7 |
class PMXI_Admin_Addons extends PMXI_Controller_Admin {
|
8 |
|
9 |
+
public static $addons = array('PMWI_Plugin' => 0, 'PMAI_Plugin' => 0, 'PMWITabs_Plugin' => 0, 'PMLI_Plugin' => 0, 'PMLCA_Plugin' => 0, 'PMUI_Plugin' => 0); // inactive by default
|
10 |
|
11 |
+
public static $premium = array();
|
|
|
|
|
12 |
|
13 |
+
public static $free = array();
|
14 |
|
15 |
+
public function __construct() {
|
16 |
|
17 |
+
parent::__construct();
|
18 |
+
|
19 |
+
// Woocommerce add-on
|
20 |
+
self::$premium['PMWI_Plugin'] = array(
|
21 |
'title' => __("WooCommerce Addon",'pmxi_plugin'),
|
22 |
'description' => __("Import Products from any XML or CSV to WooCommerce",'pmxi_plugin'),
|
23 |
'thumbnail' => 'http://placehold.it/220x220',
|
24 |
+
'active' => (class_exists('PMWI_Plugin') and defined('PMWI_EDITION') and PMWI_EDITION == 'paid'),
|
25 |
+
'free_installed' => (class_exists('PMWI_Plugin') and defined('PMWI_EDITION') and PMWI_EDITION == 'free'),
|
26 |
'required_plugins' => false,
|
27 |
'url' => 'http://www.wpallimport.com/woocommerce-product-import'
|
28 |
);
|
29 |
+
|
30 |
+
// ACF add-on
|
31 |
+
self::$premium['PMAI_Plugin'] = array(
|
32 |
'title' => __("ACF Addon",'pmxi_plugin'),
|
33 |
'description' => __("Import to advanced custom fields",'pmxi_plugin'),
|
34 |
'thumbnail' => 'http://placehold.it/220x220',
|
35 |
+
'active' => (class_exists('PMAI_Plugin') and defined('PMAI_EDITION') and PMAI_EDITION == 'paid'),
|
36 |
+
'free_installed' => (class_exists('PMAI_Plugin') and defined('PMAI_EDITION') and PMAI_EDITION == 'free'),
|
37 |
'required_plugins' => array('Advanced Custom Fields' => class_exists('acf')),
|
38 |
+
'url' => 'http://www.wpallimport.com/advanced-custom-fields/'
|
39 |
);
|
40 |
+
|
41 |
+
// WPML add-on
|
42 |
+
self::$premium['PMLI_Plugin'] = array(
|
43 |
'title' => __("WPML Addon",'pmxi_plugin'),
|
44 |
'description' => __("Import to WPML",'pmxi_plugin'),
|
45 |
'thumbnail' => 'http://placehold.it/220x220',
|
46 |
+
'active' => (class_exists('PMLI_Plugin') and defined('PMLI_EDITION') and PMLI_EDITION == 'paid'),
|
47 |
+
'free_installed' => (class_exists('PMLI_Plugin') and defined('PMLI_EDITION') and PMLI_EDITION == 'free'),
|
48 |
'required_plugins' => array('WPML' => class_exists('SitePress')),
|
49 |
+
'url' => 'http://www.wpallimport.com/add-ons/wpml/'
|
50 |
+
);
|
51 |
+
|
52 |
+
// User add-on
|
53 |
+
self::$premium['PMUI_Plugin'] = array(
|
54 |
+
'title' => __("User Addon",'pmxi_plugin'),
|
55 |
+
'description' => __("Import Users",'pmxi_plugin'),
|
56 |
+
'thumbnail' => 'http://placehold.it/220x220',
|
57 |
+
'active' => (class_exists('PMUI_Plugin') and defined('PMUI_EDITION') and PMUI_EDITION == 'paid'),
|
58 |
+
'free_installed' => (class_exists('PMUI_Plugin') and defined('PMUI_EDITION') and PMUI_EDITION == 'free'),
|
59 |
+
'required_plugins' => false,
|
60 |
+
'url' => 'http://www.wpallimport.com/add-ons/user-import/'
|
61 |
+
);
|
62 |
+
|
63 |
+
// Affiliate link cloaking add-on
|
64 |
+
self::$premium['PMLCA_Plugin'] = array(
|
65 |
+
'title' => __("Link cloaking Addon",'pmxi_plugin'),
|
66 |
+
'description' => __("Affiliate link cloaking",'pmxi_plugin'),
|
67 |
+
'thumbnail' => 'http://placehold.it/220x220',
|
68 |
+
'active' => (class_exists('PMLCA_Plugin') and defined('PMLCA_EDITION') and PMLCA_EDITION == 'paid'),
|
69 |
+
'free_installed' => (class_exists('PMLCA_Plugin') and defined('PMLCA_EDITION') and PMLCA_EDITION == 'free'),
|
70 |
+
'required_plugins' => false,
|
71 |
+
'url' => 'http://www.wpallimport.com/add-ons/link-cloaking/'
|
72 |
+
);
|
73 |
+
|
74 |
+
self::$free['PMWI_Plugin'] = array(
|
75 |
'title' => __("WooCommerce Addon - free edition",'pmxi_plugin'),
|
76 |
'description' => __("Import Products from any XML or CSV to WooCommerce",'pmxi_plugin'),
|
77 |
'thumbnail' => 'http://placehold.it/220x220',
|
78 |
+
'active' => (class_exists('PMWI_Plugin') and defined('PMWI_EDITION') and PMWI_EDITION == 'free'),
|
79 |
+
'paid_installed' => (class_exists('PMWI_Plugin') and defined('PMWI_EDITION') and PMWI_EDITION == 'paid'),
|
80 |
'required_plugins' => false,
|
81 |
'url' => 'http://wordpress.org/plugins/woocommerce-xml-csv-product-import'
|
82 |
);
|
83 |
+
self::$free['PMWITabs_Plugin'] = array(
|
|
|
84 |
'title' => __("WooCommerce Tabs Addon",'pmxi_plugin'),
|
85 |
'description' => __("Import data to WooCommerce tabs",'pmxi_plugin'),
|
86 |
'thumbnail' => 'http://placehold.it/220x220',
|
88 |
'paid_installed' => false,
|
89 |
'required_plugins' => array('WooCommerce Addon' => class_exists('PMWI_Plugin')),
|
90 |
'url' => 'http://www.wpallimport.com'
|
91 |
+
);
|
92 |
+
|
93 |
+
|
94 |
+
}
|
95 |
+
|
96 |
+
public function index() {
|
97 |
|
98 |
+
$this->data['premium'] = self::$premium;
|
99 |
+
|
100 |
+
$this->data['free'] = self::$free;
|
101 |
+
|
102 |
$this->render();
|
103 |
}
|
104 |
|
105 |
+
public function get_premium_addons(){
|
106 |
+
return self::$premium;
|
107 |
+
}
|
108 |
+
|
109 |
+
public function get_free_addons(){
|
110 |
+
return self::$free;
|
111 |
+
}
|
112 |
+
|
113 |
protected static function set_addons_status(){
|
114 |
foreach (self::$addons as $class => $active)
|
115 |
self::$addons[$class] = class_exists($class);
|
116 |
+
|
117 |
+
self::$addons = apply_filters('pmxi_addons', self::$addons);
|
118 |
+
|
119 |
}
|
120 |
|
121 |
public static function get_all_addons(){
|
controllers/admin/import.php
CHANGED
@@ -12,6 +12,11 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
12 |
protected function init() {
|
13 |
parent::init();
|
14 |
|
|
|
|
|
|
|
|
|
|
|
15 |
if ('PMXI_Admin_Manage' == PMXI_Plugin::getInstance()->getAdminCurrentScreen()->base) { // prereqisites are not checked when flow control is deligated
|
16 |
$id = $this->input->get('id');
|
17 |
$this->data['import'] = $import = new PMXI_Import_Record();
|
@@ -56,17 +61,17 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
56 |
$this->data['update_previous'] = $update_previous = new PMXI_Import_Record();
|
57 |
$old = libxml_use_internal_errors(true);
|
58 |
|
59 |
-
$xml = $this->get_xml();
|
60 |
|
61 |
if (empty($xml) and in_array($action, array('process')) ){
|
62 |
! empty(PMXI_Plugin::$session->data['pmxi_import']['update_previous']) and $update_previous->getById(PMXI_Plugin::$session->data['pmxi_import']['update_previous']);
|
63 |
return true;
|
64 |
-
}
|
65 |
|
66 |
if (empty(PMXI_Plugin::$session->data['pmxi_import'])
|
67 |
-
or ! @$dom->loadXML($xml)// FIX: libxml xpath doesn't handle default namespace properly, so remove it upon XML load
|
68 |
-
//or empty(PMXI_Plugin::$session['pmxi_import']['source'])
|
69 |
or ! empty(PMXI_Plugin::$session->data['pmxi_import']['update_previous']) and $update_previous->getById(PMXI_Plugin::$session->data['pmxi_import']['update_previous'])->isEmpty()
|
|
|
|
|
70 |
) {
|
71 |
if (!PMXI_Plugin::is_ajax()){
|
72 |
$this->errors->add('form-validation', __('Can not create DOM object for provided feed.', 'pmxi_plugin'));
|
@@ -110,7 +115,8 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
110 |
|
111 |
$this->data['reimported_import'] = $import = new PMXI_Import_Record();
|
112 |
$this->data['id'] = $id = $this->input->get('id');
|
113 |
-
$this->data['parent_import'] = $parent_import = $this->input->get('parent_import', 0);
|
|
|
114 |
if ($id and $import->getById($id)->isEmpty()) { // update requested but corresponding import is not found
|
115 |
wp_redirect(remove_query_arg('id', $this->baseUrl)); die();
|
116 |
}
|
@@ -123,8 +129,8 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
123 |
'file' => '',
|
124 |
'reimport' => '',
|
125 |
'is_update_previous' => $id ? 1 : 0,
|
126 |
-
'update_previous' => $id,
|
127 |
-
'xpath' => '/',
|
128 |
'filepath' => '',
|
129 |
'root_element' => ''
|
130 |
));
|
@@ -225,24 +231,31 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
225 |
|
226 |
} elseif(preg_match('%\W(gz)$%i', trim($post['filepath']))){ // If gz file uploaded
|
227 |
$fileInfo = pmxi_gzfile_get_contents($post['filepath']);
|
228 |
-
$filePath = $fileInfo['localPath'];
|
229 |
-
|
230 |
-
// Detect if file is very large
|
231 |
-
$source = array(
|
232 |
-
'name' => basename($post['filepath']),
|
233 |
-
'type' => 'upload',
|
234 |
-
'path' => $post['filepath'],
|
235 |
-
);
|
236 |
|
237 |
-
|
238 |
-
|
|
|
239 |
|
240 |
-
|
241 |
-
$
|
242 |
-
|
243 |
-
|
244 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
}
|
|
|
|
|
246 |
} else { // If XML file uploaded
|
247 |
|
248 |
// Detect if file is very large
|
@@ -253,7 +266,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
253 |
'path' => $filePath,
|
254 |
);
|
255 |
}
|
256 |
-
}
|
257 |
elseif ($this->input->post('is_submitted')){
|
258 |
|
259 |
$this->errors->add('form-validation', __('Upgrade to the paid edition of WP All Import to use this feature.', 'pmxi_plugin'));
|
@@ -283,7 +296,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
283 |
|
284 |
if ( @file_exists($path) ){
|
285 |
|
286 |
-
$file = new PMXI_Chunk($path, array('element' => $post['root_element']));
|
287 |
|
288 |
if ( ! empty($file->options['element']) ) {
|
289 |
$xpath = "/".$file->options['element'];
|
@@ -294,14 +307,14 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
294 |
|
295 |
}
|
296 |
else $this->errors->add('form-validation', __('Unable to download feed resource.', 'pmxi_plugin'));
|
297 |
-
}
|
298 |
|
299 |
if ( ! $this->errors->get_error_codes() ) {
|
300 |
|
301 |
// xml is valid
|
302 |
$source['root_element'] = $file->options['element'];
|
303 |
$source['first_import'] = date("Y-m-d H:i:s");
|
304 |
-
pmxi_session_unset();
|
305 |
|
306 |
PMXI_Plugin::$session['pmxi_import'] = array(
|
307 |
'filePath' => $filePath,
|
@@ -340,18 +353,17 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
340 |
pmxi_session_commit();
|
341 |
|
342 |
$xml = $this->get_xml();
|
|
|
343 |
if (empty($xml))
|
344 |
{
|
345 |
-
$this->errors->add('form-validation', __('Please confirm you are importing a valid feed.<br/> Often, feed providers distribute feeds with invalid data, improperly wrapped HTML, line breaks where they should not be, faulty character encodings, syntax errors in the XML, and other issues.<br/><br/>WP All Import has checks in place to automatically fix some of the most common problems, but we can’t catch every single one.<br/><br/>It is also possible that there is a bug in WP All Import, and the problem is not with the feed.<br/><br/>If you need assistance, please contact support – <a href="mailto:support@soflyy.com">support@soflyy.com</a> – with your XML/CSV file. We will identify the problem and release a bug fix if necessary.', 'pmxi_plugin'));
|
346 |
-
if ( "" != PMXI_Plugin::$is_csv) $this->errors->add('form-validation', __('Probably your CSV feed contains HTML code. In this case, you can enable the <strong>"My CSV feed contains HTML code"</strong> option on the settings screen.', 'pmxi_plugin'));
|
347 |
}
|
348 |
else{
|
349 |
wp_redirect(add_query_arg('action', 'element', $this->baseUrl)); die();
|
350 |
}
|
351 |
|
352 |
} else {
|
353 |
-
$this->errors->add('form-validation', __('Please confirm you are importing a valid feed.<br/> Often, feed providers distribute feeds with invalid data, improperly wrapped HTML, line breaks where they should not be, faulty character encodings, syntax errors in the XML, and other issues.<br/><br/>WP All Import has checks in place to automatically fix some of the most common problems, but we can’t catch every single one.<br/><br/>It is also possible that there is a bug in WP All Import, and the problem is not with the feed.<br/><br/>If you need assistance, please contact support – <a href="mailto:support@soflyy.com">support@soflyy.com</a> – with your XML/CSV file. We will identify the problem and release a bug fix if necessary.', 'pmxi_plugin'));
|
354 |
-
if ( "" != PMXI_Plugin::$is_csv) $this->errors->add('form-validation', __('Probably your CSV feed contains HTML code. In this case, you can enable the <strong>"My CSV feed contains HTML code"</strong> option on the settings screen.', 'pmxi_plugin'));
|
355 |
}
|
356 |
|
357 |
do_action("pmxi_get_file", $filePath);
|
@@ -397,7 +409,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
397 |
|
398 |
if ( ! $this->errors->get_error_codes()) {
|
399 |
|
400 |
-
wp_redirect(add_query_arg('action', 'template', $this->baseUrl)); die();
|
401 |
|
402 |
}
|
403 |
|
@@ -578,7 +590,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
578 |
wp_redirect(add_query_arg('action', 'element', $this->baseUrl)); die();
|
579 |
}
|
580 |
|
581 |
-
$post = $this->input->post(array('xpath' => '', 'show_element' => 1, 'root_element' => PMXI_Plugin::$session->data['pmxi_import']['source']['root_element'], 'tagno' => 0, 'parent_tagno' => 1));
|
582 |
$wp_uploads = wp_upload_dir();
|
583 |
|
584 |
$this->get_xml( $post['parent_tagno'] );
|
@@ -590,8 +602,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
590 |
if ('' == $post['xpath']) {
|
591 |
$this->errors->add('form-validation', __('No elements selected', 'pmxi_plugin'));
|
592 |
} else {
|
593 |
-
$post['xpath'] = '/' . ((!empty($this->data['update_previous']->root_element)) ? $this->data['update_previous']->root_element : PMXI_Plugin::$session->data['pmxi_import']['source']['root_element']) .'/'. ltrim(trim(str_replace("[*]","",$post['xpath']),'{}'), '/');
|
594 |
-
|
595 |
// in default mode
|
596 |
$this->data['variation_elements'] = $elements = @ $xpath->query($post['xpath']); // prevent parsing warning to be displayed
|
597 |
$this->data['variation_list_count'] = $elements->length;
|
@@ -651,7 +662,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
651 |
apply_filters('pmxi_template_options', $this->data['import']->template
|
652 |
+ $default, $this->isWizard)
|
653 |
);
|
654 |
-
}
|
655 |
|
656 |
if (($load_template = $this->input->post('load_template'))) { // init form with template selected
|
657 |
if ( ! $template->getById($load_template)->isEmpty()) {
|
@@ -676,12 +687,13 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
676 |
}
|
677 |
|
678 |
if (empty($post['content'])) {
|
679 |
-
$
|
|
|
680 |
} else {
|
681 |
$this->_validate_template($post['content'], 'Post content');
|
682 |
-
}
|
683 |
|
684 |
-
if ( ! $this->errors->get_error_codes()) {
|
685 |
if ( ! empty($post['name'])) { // save template in database
|
686 |
$template->getByName($post['name'])->set($post)->save();
|
687 |
PMXI_Plugin::$session['pmxi_import']['saved_template'] = $template->id;
|
@@ -843,8 +855,9 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
843 |
}
|
844 |
|
845 |
$file = new PMXI_Chunk($path, array('element' => (!empty($this->data['update_previous']->root_element)) ? $this->data['update_previous']->root_element : PMXI_Plugin::$session->data['pmxi_import']['source']['root_element'], 'encoding' => $post['import_encoding']));
|
|
|
846 |
// loop through the file until all lines are read
|
847 |
-
while ($xml = $file->read()) {
|
848 |
if (!empty($xml))
|
849 |
{
|
850 |
PMXI_Import_Record::preprocessXml($xml);
|
@@ -893,7 +906,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
893 |
$this->errors->add('form-validation', __('Error parsing content: String could not be parsed as XML', 'pmxi_plugin'));
|
894 |
} elseif (empty($post['content'])) {
|
895 |
$this->errors->add('form-validation', __('Post content is empty', 'pmxi_plugin'));
|
896 |
-
} else {
|
897 |
list($this->data['content']) = XmlImportParser::factory($post['is_keep_linebreaks'] ? $xml : preg_replace('%\r\n?|\n%', ' ', $xml), $xpath, $post['content'], $file)->parse(); unlink($file);
|
898 |
if ( ! isset($this->data['content']) or '' == strval(trim(strip_tags($this->data['content'], '<img><input><textarea><iframe><object><embed>')))) {
|
899 |
$this->errors->add('xml-parsing', __('<strong>Warning</strong>: resulting post content is empty', 'pmxi_plugin'));
|
@@ -924,16 +937,16 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
924 |
// auto searching ID element
|
925 |
if (!empty($this->data['dom'])){
|
926 |
$this->find_unique_key($this->data['dom']->documentElement);
|
927 |
-
if (!empty($this->_unique_key)){
|
928 |
foreach ($keys_black_list as $key => $value) {
|
929 |
$default['unique_key'] = str_replace('{' . $value . '[1]}', "", $default['unique_key']);
|
930 |
-
}
|
931 |
foreach ($this->_unique_key as $key) {
|
932 |
if (stripos($key, 'id') !== false) {
|
933 |
$default['unique_key'] .= ' - {'.$key.'[1]}';
|
934 |
break;
|
935 |
}
|
936 |
-
}
|
937 |
foreach ($this->_unique_key as $key) {
|
938 |
if (stripos($key, 'url') !== false or stripos($key, 'sku') !== false or stripos($key, 'ref') !== false) {
|
939 |
if ( ! in_array($key, $keys_black_list) ){
|
@@ -941,26 +954,29 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
941 |
break;
|
942 |
}
|
943 |
}
|
944 |
-
}
|
945 |
}
|
946 |
}
|
947 |
|
948 |
$DefaultOptions = (isset(PMXI_Plugin::$session->data['pmxi_import']['options']) ? PMXI_Plugin::$session->data['pmxi_import']['options'] : array()) + $default;
|
949 |
-
foreach (PMXI_Admin_Addons::get_active_addons() as $class)
|
950 |
-
$DefaultOptions += call_user_func(array($class, "get_default_import_options"));
|
|
|
951 |
|
952 |
$post = $this->input->post( apply_filters('pmxi_options_options', $DefaultOptions, $this->isWizard) );
|
953 |
-
|
954 |
} else {
|
955 |
$this->data['source_type'] = $this->data['import']->type;
|
956 |
$DefaultOptions = $this->data['import']->options + $default;
|
957 |
-
foreach (PMXI_Admin_Addons::get_active_addons() as $class)
|
958 |
-
$DefaultOptions += call_user_func(array($class, "get_default_import_options"));
|
|
|
959 |
|
960 |
$post = $this->input->post( apply_filters( 'pmxi_options_options', $DefaultOptions, $this->isWizard) );
|
961 |
-
}
|
962 |
|
963 |
-
|
|
|
|
|
964 |
|
965 |
// Get All meta keys in the system
|
966 |
$this->data['meta_keys'] = $keys = new PMXI_Model_List();
|
@@ -982,21 +998,23 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
982 |
}
|
983 |
endif;
|
984 |
}
|
985 |
-
}
|
986 |
|
987 |
$load_template = $this->input->post('load_template');
|
988 |
-
if ($load_template) { // init form with template selected
|
989 |
PMXI_Plugin::$session['pmxi_import']['is_loaded_template'] = $load_template;
|
990 |
$template = new PMXI_Template_Record();
|
991 |
if ( ! $template->getById($load_template)->isEmpty()) {
|
992 |
-
$post = (!empty($template->options) ? $template->options : array()) + $default;
|
993 |
}
|
994 |
-
}
|
995 |
-
PMXI_Plugin::$session['pmxi_import']['is_loaded_template'] = 0;
|
996 |
|
997 |
-
|
998 |
|
999 |
-
|
|
|
|
|
|
|
1000 |
|
1001 |
check_admin_referer('options', '_wpnonce_options');
|
1002 |
|
@@ -1026,16 +1044,17 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
1026 |
$post['custom_value'] = array_intersect_key($post['custom_value'], $not_empty);
|
1027 |
|
1028 |
// validate
|
1029 |
-
if (array_keys(array_filter($post['custom_name'], 'strlen')) != array_keys(array_filter($post['custom_value'], 'strlen'))) {
|
1030 |
$this->errors->add('form-validation', __('Both name and value must be set for all custom parameters', 'pmxi_plugin'));
|
1031 |
} else {
|
1032 |
-
foreach ($post['custom_name'] as $custom_name) {
|
1033 |
$this->_validate_template($custom_name, __('Custom Field Name', 'pmxi_plugin'));
|
1034 |
}
|
1035 |
-
foreach ($post['custom_value'] as $custom_value) {
|
1036 |
-
|
|
|
1037 |
}
|
1038 |
-
}
|
1039 |
|
1040 |
if ( $post['type'] == "post" and $post['custom_type'] == "product" and class_exists('PMWI_Plugin')){
|
1041 |
// remove entires where both custom_name and custom_value are empty
|
@@ -1064,14 +1083,6 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
1064 |
if ('post' == $post['type']) {
|
1065 |
/*'' == $post['categories'] or $this->_validate_template($post['categories'], __('Categories', 'pmxi_plugin'));*/
|
1066 |
'' == $post['tags'] or $this->_validate_template($post['tags'], __('Tags', 'pmxi_plugin'));
|
1067 |
-
if ( "" != $post['custom_type']) {
|
1068 |
-
if ($post['custom_type'] != 'product'){
|
1069 |
-
$this->_validate_template($post['custom_type'], __('Custom post type is not supported', 'pmxi_plugin'));
|
1070 |
-
}
|
1071 |
-
elseif ( ! class_exists('PMWI_Plugin') ){
|
1072 |
-
$this->_validate_template($post['custom_type'], __('Custom post type is not supported', 'pmxi_plugin'));
|
1073 |
-
}
|
1074 |
-
}
|
1075 |
}
|
1076 |
if ('specific' == $post['date_type']) {
|
1077 |
'' == $post['date'] or $this->_validate_template($post['date'], __('Date', 'pmxi_plugin'));
|
@@ -1110,7 +1121,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
1110 |
$this->errors->add('form-validation', __('Custom field value must be specified.', 'pmxi_plugin'));
|
1111 |
}
|
1112 |
|
1113 |
-
apply_filters('pmxi_options_validation', $this->errors, $post, $this->data['import']);
|
1114 |
|
1115 |
if ( ! $this->errors->get_error_codes()) { // no validation errors found
|
1116 |
// assign some defaults
|
@@ -1128,7 +1139,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
1128 |
}
|
1129 |
|
1130 |
if ($this->isWizard) {
|
1131 |
-
PMXI_Plugin::$session['pmxi_import']['options'] = $post;
|
1132 |
|
1133 |
pmxi_session_commit();
|
1134 |
|
@@ -1188,10 +1199,11 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
1188 |
*/
|
1189 |
public function process($save_history = true)
|
1190 |
{
|
|
|
1191 |
$wp_uploads = wp_upload_dir();
|
1192 |
|
1193 |
$import = $this->data['update_previous'];
|
1194 |
-
$logger = create_function('$m', 'echo "<div class=\\"progress-msg\\">$m</div>\\n"; if ( "" != strip_tags(pmxi_strip_tags_content($m))) { PMXI_Plugin::$session[\'pmxi_import\'][\'log\'] .= "<p>".strip_tags(pmxi_strip_tags_content($m))."</p>"; flush(); }');
|
1195 |
|
1196 |
if ( ! PMXI_Plugin::is_ajax() ) {
|
1197 |
|
@@ -1207,7 +1219,8 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
1207 |
'parent_import_id' => ($this->data['update_previous']->isEmpty()) ? PMXI_Plugin::$session->data['pmxi_import']['parent_import_id'] : $this->data['update_previous']->parent_import_id,
|
1208 |
'queue_chunk_number' => 0,
|
1209 |
'triggered' => 0,
|
1210 |
-
'processing' => 0,
|
|
|
1211 |
)
|
1212 |
)->save();
|
1213 |
|
@@ -1217,8 +1230,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
1217 |
'imported' => 0,
|
1218 |
'created' => 0,
|
1219 |
'updated' => 0,
|
1220 |
-
'skipped' => 0
|
1221 |
-
'current_post_ids' => ''
|
1222 |
))->update();
|
1223 |
}
|
1224 |
|
@@ -1371,7 +1383,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
1371 |
pmxi_session_commit();
|
1372 |
break;
|
1373 |
}
|
1374 |
-
|
1375 |
$file = new PMXI_Chunk($path, array('element' => $import->root_element, 'encoding' => $import->options['encoding'], 'pointer' => PMXI_Plugin::$session->data['pmxi_import']['pointer']));
|
1376 |
// loop through the file until all lines are read
|
1377 |
while ($xml = $file->read()) {
|
@@ -1406,11 +1418,11 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
1406 |
|
1407 |
if ( $loop == $records_per_request or $processed_records + $loop == $records_to_import or $processed_records == $records_to_import) {
|
1408 |
|
1409 |
-
$feed .= "</pmxi_records>";
|
1410 |
$import->process($feed, $logger, PMXI_Plugin::$session->data['pmxi_import']['chunk_number'], false, '/pmxi_records');
|
1411 |
unset($dom, $xpath);
|
1412 |
|
1413 |
-
if ( ! $ajax_processing ){
|
1414 |
$feed = "<?xml version=\"1.0\" encoding=\"". $import->options['encoding'] ."\"?>" . "\n" . "<pmxi_records>";
|
1415 |
$loop = 0;
|
1416 |
} else {
|
@@ -1442,7 +1454,8 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
1442 |
array_shift(PMXI_Plugin::$session->data['pmxi_import']['local_paths']);
|
1443 |
PMXI_Plugin::$session['pmxi_import']['local_paths'] = PMXI_Plugin::$session->data['pmxi_import']['local_paths'];
|
1444 |
pmxi_session_commit();
|
1445 |
-
}
|
|
|
1446 |
}
|
1447 |
}
|
1448 |
}
|
@@ -1629,7 +1642,7 @@ COMPLETE;
|
|
1629 |
}
|
1630 |
protected function render_xml_text($text, $shorten = false, $is_render_collapsed = false)
|
1631 |
{
|
1632 |
-
if (empty($text)) {
|
1633 |
return; // do not display empty text nodes
|
1634 |
}
|
1635 |
if (preg_match('%\[more:(\d+)\]%', $text, $mtch)) {
|
@@ -1773,10 +1786,16 @@ COMPLETE;
|
|
1773 |
|
1774 |
if ( ! empty(PMXI_Plugin::$session->data['pmxi_import']['update_previous'])) $update_previous->getById(PMXI_Plugin::$session->data['pmxi_import']['update_previous']);
|
1775 |
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1780 |
|
1781 |
if ( @file_exists($path) ){
|
1782 |
|
@@ -1810,7 +1829,7 @@ COMPLETE;
|
|
1810 |
|
1811 |
}
|
1812 |
}
|
1813 |
-
}
|
1814 |
return $xml;
|
1815 |
}
|
1816 |
}
|
12 |
protected function init() {
|
13 |
parent::init();
|
14 |
|
15 |
+
error_reporting(0);
|
16 |
+
|
17 |
+
PMXI_Plugin::$session = PMXI_Session::get_instance();
|
18 |
+
PMXI_Plugin::$session->session_started();
|
19 |
+
|
20 |
if ('PMXI_Admin_Manage' == PMXI_Plugin::getInstance()->getAdminCurrentScreen()->base) { // prereqisites are not checked when flow control is deligated
|
21 |
$id = $this->input->get('id');
|
22 |
$this->data['import'] = $import = new PMXI_Import_Record();
|
61 |
$this->data['update_previous'] = $update_previous = new PMXI_Import_Record();
|
62 |
$old = libxml_use_internal_errors(true);
|
63 |
|
64 |
+
$xml = $this->get_xml();
|
65 |
|
66 |
if (empty($xml) and in_array($action, array('process')) ){
|
67 |
! empty(PMXI_Plugin::$session->data['pmxi_import']['update_previous']) and $update_previous->getById(PMXI_Plugin::$session->data['pmxi_import']['update_previous']);
|
68 |
return true;
|
69 |
+
}
|
70 |
|
71 |
if (empty(PMXI_Plugin::$session->data['pmxi_import'])
|
|
|
|
|
72 |
or ! empty(PMXI_Plugin::$session->data['pmxi_import']['update_previous']) and $update_previous->getById(PMXI_Plugin::$session->data['pmxi_import']['update_previous'])->isEmpty()
|
73 |
+
or ! @$dom->loadXML($xml)// FIX: libxml xpath doesn't handle default namespace properly, so remove it upon XML load
|
74 |
+
//or empty(PMXI_Plugin::$session['pmxi_import']['source'])
|
75 |
) {
|
76 |
if (!PMXI_Plugin::is_ajax()){
|
77 |
$this->errors->add('form-validation', __('Can not create DOM object for provided feed.', 'pmxi_plugin'));
|
115 |
|
116 |
$this->data['reimported_import'] = $import = new PMXI_Import_Record();
|
117 |
$this->data['id'] = $id = $this->input->get('id');
|
118 |
+
$this->data['parent_import'] = $parent_import = $this->input->get('parent_import', 0);
|
119 |
+
|
120 |
if ($id and $import->getById($id)->isEmpty()) { // update requested but corresponding import is not found
|
121 |
wp_redirect(remove_query_arg('id', $this->baseUrl)); die();
|
122 |
}
|
129 |
'file' => '',
|
130 |
'reimport' => '',
|
131 |
'is_update_previous' => $id ? 1 : 0,
|
132 |
+
'update_previous' => $id,
|
133 |
+
'xpath' => '/',
|
134 |
'filepath' => '',
|
135 |
'root_element' => ''
|
136 |
));
|
231 |
|
232 |
} elseif(preg_match('%\W(gz)$%i', trim($post['filepath']))){ // If gz file uploaded
|
233 |
$fileInfo = pmxi_gzfile_get_contents($post['filepath']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
|
235 |
+
if ( ! is_wp_error($fileInfo) ){
|
236 |
+
|
237 |
+
$filePath = $fileInfo['localPath'];
|
238 |
|
239 |
+
// Detect if file is very large
|
240 |
+
$source = array(
|
241 |
+
'name' => basename($post['filepath']),
|
242 |
+
'type' => 'upload',
|
243 |
+
'path' => $post['filepath'],
|
244 |
+
);
|
245 |
+
|
246 |
+
// detect CSV or XML
|
247 |
+
if ( $fileInfo['type'] == 'csv') { // it is CSV file
|
248 |
+
|
249 |
+
include_once(PMXI_Plugin::ROOT_DIR.'/libraries/XmlImportCsvParse.php');
|
250 |
+
$csv = new PMXI_CsvParser($filePath, true); // create chunks
|
251 |
+
$filePath = $csv->xml_path;
|
252 |
+
$post['root_element'] = 'node';
|
253 |
+
|
254 |
+
}
|
255 |
+
|
256 |
}
|
257 |
+
else $this->errors->add('form-validation', $fileInfo->get_error_message());
|
258 |
+
|
259 |
} else { // If XML file uploaded
|
260 |
|
261 |
// Detect if file is very large
|
266 |
'path' => $filePath,
|
267 |
);
|
268 |
}
|
269 |
+
}
|
270 |
elseif ($this->input->post('is_submitted')){
|
271 |
|
272 |
$this->errors->add('form-validation', __('Upgrade to the paid edition of WP All Import to use this feature.', 'pmxi_plugin'));
|
296 |
|
297 |
if ( @file_exists($path) ){
|
298 |
|
299 |
+
$file = new PMXI_Chunk($path, array('element' => $post['root_element']));
|
300 |
|
301 |
if ( ! empty($file->options['element']) ) {
|
302 |
$xpath = "/".$file->options['element'];
|
307 |
|
308 |
}
|
309 |
else $this->errors->add('form-validation', __('Unable to download feed resource.', 'pmxi_plugin'));
|
310 |
+
}
|
311 |
|
312 |
if ( ! $this->errors->get_error_codes() ) {
|
313 |
|
314 |
// xml is valid
|
315 |
$source['root_element'] = $file->options['element'];
|
316 |
$source['first_import'] = date("Y-m-d H:i:s");
|
317 |
+
pmxi_session_unset();
|
318 |
|
319 |
PMXI_Plugin::$session['pmxi_import'] = array(
|
320 |
'filePath' => $filePath,
|
353 |
pmxi_session_commit();
|
354 |
|
355 |
$xml = $this->get_xml();
|
356 |
+
|
357 |
if (empty($xml))
|
358 |
{
|
359 |
+
$this->errors->add('form-validation', __('Please confirm you are importing a valid feed.<br/> Often, feed providers distribute feeds with invalid data, improperly wrapped HTML, line breaks where they should not be, faulty character encodings, syntax errors in the XML, and other issues.<br/><br/>WP All Import has checks in place to automatically fix some of the most common problems, but we can’t catch every single one.<br/><br/>It is also possible that there is a bug in WP All Import, and the problem is not with the feed.<br/><br/>If you need assistance, please contact support – <a href="mailto:support@soflyy.com">support@soflyy.com</a> – with your XML/CSV file. We will identify the problem and release a bug fix if necessary.', 'pmxi_plugin'));
|
|
|
360 |
}
|
361 |
else{
|
362 |
wp_redirect(add_query_arg('action', 'element', $this->baseUrl)); die();
|
363 |
}
|
364 |
|
365 |
} else {
|
366 |
+
$this->errors->add('form-validation', __('Please confirm you are importing a valid feed.<br/> Often, feed providers distribute feeds with invalid data, improperly wrapped HTML, line breaks where they should not be, faulty character encodings, syntax errors in the XML, and other issues.<br/><br/>WP All Import has checks in place to automatically fix some of the most common problems, but we can’t catch every single one.<br/><br/>It is also possible that there is a bug in WP All Import, and the problem is not with the feed.<br/><br/>If you need assistance, please contact support – <a href="mailto:support@soflyy.com">support@soflyy.com</a> – with your XML/CSV file. We will identify the problem and release a bug fix if necessary.', 'pmxi_plugin'));
|
|
|
367 |
}
|
368 |
|
369 |
do_action("pmxi_get_file", $filePath);
|
409 |
|
410 |
if ( ! $this->errors->get_error_codes()) {
|
411 |
|
412 |
+
wp_redirect(apply_filters('pmxi_element_redirect' , add_query_arg('action', 'template', $this->baseUrl))); die();
|
413 |
|
414 |
}
|
415 |
|
590 |
wp_redirect(add_query_arg('action', 'element', $this->baseUrl)); die();
|
591 |
}
|
592 |
|
593 |
+
$post = $this->input->post(array('xpath' => '', 'show_element' => 1, 'root_element' => (!empty(PMXI_Plugin::$session->data['pmxi_import']['source']['root_element'])) ? PMXI_Plugin::$session->data['pmxi_import']['source']['root_element'] : '', 'tagno' => 0, 'parent_tagno' => 1));
|
594 |
$wp_uploads = wp_upload_dir();
|
595 |
|
596 |
$this->get_xml( $post['parent_tagno'] );
|
602 |
if ('' == $post['xpath']) {
|
603 |
$this->errors->add('form-validation', __('No elements selected', 'pmxi_plugin'));
|
604 |
} else {
|
605 |
+
$post['xpath'] = '/' . ((!empty($this->data['update_previous']->root_element)) ? $this->data['update_previous']->root_element : PMXI_Plugin::$session->data['pmxi_import']['source']['root_element']) .'/'. ltrim(trim(str_replace("[*]","",$post['xpath']),'{}'), '/');
|
|
|
606 |
// in default mode
|
607 |
$this->data['variation_elements'] = $elements = @ $xpath->query($post['xpath']); // prevent parsing warning to be displayed
|
608 |
$this->data['variation_list_count'] = $elements->length;
|
662 |
apply_filters('pmxi_template_options', $this->data['import']->template
|
663 |
+ $default, $this->isWizard)
|
664 |
);
|
665 |
+
}
|
666 |
|
667 |
if (($load_template = $this->input->post('load_template'))) { // init form with template selected
|
668 |
if ( ! $template->getById($load_template)->isEmpty()) {
|
687 |
}
|
688 |
|
689 |
if (empty($post['content'])) {
|
690 |
+
$post['content'] = ' ';
|
691 |
+
$this->_validate_template($post['content'], 'Post content');
|
692 |
} else {
|
693 |
$this->_validate_template($post['content'], 'Post content');
|
694 |
+
}
|
695 |
|
696 |
+
if ( ! $this->errors->get_error_codes()) {
|
697 |
if ( ! empty($post['name'])) { // save template in database
|
698 |
$template->getByName($post['name'])->set($post)->save();
|
699 |
PMXI_Plugin::$session['pmxi_import']['saved_template'] = $template->id;
|
855 |
}
|
856 |
|
857 |
$file = new PMXI_Chunk($path, array('element' => (!empty($this->data['update_previous']->root_element)) ? $this->data['update_previous']->root_element : PMXI_Plugin::$session->data['pmxi_import']['source']['root_element'], 'encoding' => $post['import_encoding']));
|
858 |
+
|
859 |
// loop through the file until all lines are read
|
860 |
+
while ($xml = $file->read()) {
|
861 |
if (!empty($xml))
|
862 |
{
|
863 |
PMXI_Import_Record::preprocessXml($xml);
|
906 |
$this->errors->add('form-validation', __('Error parsing content: String could not be parsed as XML', 'pmxi_plugin'));
|
907 |
} elseif (empty($post['content'])) {
|
908 |
$this->errors->add('form-validation', __('Post content is empty', 'pmxi_plugin'));
|
909 |
+
} else {
|
910 |
list($this->data['content']) = XmlImportParser::factory($post['is_keep_linebreaks'] ? $xml : preg_replace('%\r\n?|\n%', ' ', $xml), $xpath, $post['content'], $file)->parse(); unlink($file);
|
911 |
if ( ! isset($this->data['content']) or '' == strval(trim(strip_tags($this->data['content'], '<img><input><textarea><iframe><object><embed>')))) {
|
912 |
$this->errors->add('xml-parsing', __('<strong>Warning</strong>: resulting post content is empty', 'pmxi_plugin'));
|
937 |
// auto searching ID element
|
938 |
if (!empty($this->data['dom'])){
|
939 |
$this->find_unique_key($this->data['dom']->documentElement);
|
940 |
+
if (!empty($this->_unique_key)){
|
941 |
foreach ($keys_black_list as $key => $value) {
|
942 |
$default['unique_key'] = str_replace('{' . $value . '[1]}', "", $default['unique_key']);
|
943 |
+
}
|
944 |
foreach ($this->_unique_key as $key) {
|
945 |
if (stripos($key, 'id') !== false) {
|
946 |
$default['unique_key'] .= ' - {'.$key.'[1]}';
|
947 |
break;
|
948 |
}
|
949 |
+
}
|
950 |
foreach ($this->_unique_key as $key) {
|
951 |
if (stripos($key, 'url') !== false or stripos($key, 'sku') !== false or stripos($key, 'ref') !== false) {
|
952 |
if ( ! in_array($key, $keys_black_list) ){
|
954 |
break;
|
955 |
}
|
956 |
}
|
957 |
+
}
|
958 |
}
|
959 |
}
|
960 |
|
961 |
$DefaultOptions = (isset(PMXI_Plugin::$session->data['pmxi_import']['options']) ? PMXI_Plugin::$session->data['pmxi_import']['options'] : array()) + $default;
|
962 |
+
foreach (PMXI_Admin_Addons::get_active_addons() as $class) {
|
963 |
+
if (class_exists($class)) $DefaultOptions += call_user_func(array($class, "get_default_import_options"));
|
964 |
+
}
|
965 |
|
966 |
$post = $this->input->post( apply_filters('pmxi_options_options', $DefaultOptions, $this->isWizard) );
|
967 |
+
|
968 |
} else {
|
969 |
$this->data['source_type'] = $this->data['import']->type;
|
970 |
$DefaultOptions = $this->data['import']->options + $default;
|
971 |
+
foreach (PMXI_Admin_Addons::get_active_addons() as $class) {
|
972 |
+
if (class_exists($class)) $DefaultOptions += call_user_func(array($class, "get_default_import_options"));
|
973 |
+
}
|
974 |
|
975 |
$post = $this->input->post( apply_filters( 'pmxi_options_options', $DefaultOptions, $this->isWizard) );
|
|
|
976 |
|
977 |
+
}
|
978 |
+
|
979 |
+
$this->data['post'] =& $post;
|
980 |
|
981 |
// Get All meta keys in the system
|
982 |
$this->data['meta_keys'] = $keys = new PMXI_Model_List();
|
998 |
}
|
999 |
endif;
|
1000 |
}
|
1001 |
+
}
|
1002 |
|
1003 |
$load_template = $this->input->post('load_template');
|
1004 |
+
if ($load_template) { // init form with template selected
|
1005 |
PMXI_Plugin::$session['pmxi_import']['is_loaded_template'] = $load_template;
|
1006 |
$template = new PMXI_Template_Record();
|
1007 |
if ( ! $template->getById($load_template)->isEmpty()) {
|
1008 |
+
$post = (!empty($template->options) ? $template->options : array()) + $default;
|
1009 |
}
|
1010 |
+
}
|
|
|
1011 |
|
1012 |
+
$this->data['get'] = $this->input->get(array('pmxi-cpt' => (( ! empty($post['custom_type']) ) ? $post['custom_type'] : $post['type'])));
|
1013 |
|
1014 |
+
if ($load_template == -1){
|
1015 |
+
PMXI_Plugin::$session['pmxi_import']['is_loaded_template'] = 0;
|
1016 |
+
$post = $default;
|
1017 |
+
} elseif ($this->input->post('is_submitted')) {
|
1018 |
|
1019 |
check_admin_referer('options', '_wpnonce_options');
|
1020 |
|
1044 |
$post['custom_value'] = array_intersect_key($post['custom_value'], $not_empty);
|
1045 |
|
1046 |
// validate
|
1047 |
+
if (array_keys(array_filter($post['custom_name'], 'strlen')) != array_keys(array_filter($post['custom_value'], 'strlen')) and ! count(array_filter($post['custom_format'])) ) {
|
1048 |
$this->errors->add('form-validation', __('Both name and value must be set for all custom parameters', 'pmxi_plugin'));
|
1049 |
} else {
|
1050 |
+
foreach ($post['custom_name'] as $custom_name) {
|
1051 |
$this->_validate_template($custom_name, __('Custom Field Name', 'pmxi_plugin'));
|
1052 |
}
|
1053 |
+
foreach ($post['custom_value'] as $key => $custom_value) {
|
1054 |
+
if ( empty($post['custom_format'][$key]) )
|
1055 |
+
$this->_validate_template($custom_value, __('Custom Field Value', 'pmxi_plugin'));
|
1056 |
}
|
1057 |
+
}
|
1058 |
|
1059 |
if ( $post['type'] == "post" and $post['custom_type'] == "product" and class_exists('PMWI_Plugin')){
|
1060 |
// remove entires where both custom_name and custom_value are empty
|
1083 |
if ('post' == $post['type']) {
|
1084 |
/*'' == $post['categories'] or $this->_validate_template($post['categories'], __('Categories', 'pmxi_plugin'));*/
|
1085 |
'' == $post['tags'] or $this->_validate_template($post['tags'], __('Tags', 'pmxi_plugin'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1086 |
}
|
1087 |
if ('specific' == $post['date_type']) {
|
1088 |
'' == $post['date'] or $this->_validate_template($post['date'], __('Date', 'pmxi_plugin'));
|
1121 |
$this->errors->add('form-validation', __('Custom field value must be specified.', 'pmxi_plugin'));
|
1122 |
}
|
1123 |
|
1124 |
+
$this->errors = apply_filters('pmxi_options_validation', $this->errors, $post, $this->data['import']);
|
1125 |
|
1126 |
if ( ! $this->errors->get_error_codes()) { // no validation errors found
|
1127 |
// assign some defaults
|
1139 |
}
|
1140 |
|
1141 |
if ($this->isWizard) {
|
1142 |
+
PMXI_Plugin::$session['pmxi_import']['options'] = $post;
|
1143 |
|
1144 |
pmxi_session_commit();
|
1145 |
|
1199 |
*/
|
1200 |
public function process($save_history = true)
|
1201 |
{
|
1202 |
+
|
1203 |
$wp_uploads = wp_upload_dir();
|
1204 |
|
1205 |
$import = $this->data['update_previous'];
|
1206 |
+
$logger = create_function('$m', 'echo "<div class=\\"progress-msg\\">$m</div>\\n"; if ( "" != strip_tags(pmxi_strip_tags_content($m)) and !empty(PMXI_Plugin::$session[\'pmxi_import\'][\'log\'])) { PMXI_Plugin::$session[\'pmxi_import\'][\'log\'] .= "<p>".strip_tags(pmxi_strip_tags_content($m))."</p>"; flush(); }');
|
1207 |
|
1208 |
if ( ! PMXI_Plugin::is_ajax() ) {
|
1209 |
|
1219 |
'parent_import_id' => ($this->data['update_previous']->isEmpty()) ? PMXI_Plugin::$session->data['pmxi_import']['parent_import_id'] : $this->data['update_previous']->parent_import_id,
|
1220 |
'queue_chunk_number' => 0,
|
1221 |
'triggered' => 0,
|
1222 |
+
'processing' => 0,
|
1223 |
+
'iteration' => ( ! empty($import->iteration) ) ? $import->iteration : 0
|
1224 |
)
|
1225 |
)->save();
|
1226 |
|
1230 |
'imported' => 0,
|
1231 |
'created' => 0,
|
1232 |
'updated' => 0,
|
1233 |
+
'skipped' => 0
|
|
|
1234 |
))->update();
|
1235 |
}
|
1236 |
|
1383 |
pmxi_session_commit();
|
1384 |
break;
|
1385 |
}
|
1386 |
+
|
1387 |
$file = new PMXI_Chunk($path, array('element' => $import->root_element, 'encoding' => $import->options['encoding'], 'pointer' => PMXI_Plugin::$session->data['pmxi_import']['pointer']));
|
1388 |
// loop through the file until all lines are read
|
1389 |
while ($xml = $file->read()) {
|
1418 |
|
1419 |
if ( $loop == $records_per_request or $processed_records + $loop == $records_to_import or $processed_records == $records_to_import) {
|
1420 |
|
1421 |
+
$feed .= "</pmxi_records>";
|
1422 |
$import->process($feed, $logger, PMXI_Plugin::$session->data['pmxi_import']['chunk_number'], false, '/pmxi_records');
|
1423 |
unset($dom, $xpath);
|
1424 |
|
1425 |
+
if ( ! $ajax_processing ){
|
1426 |
$feed = "<?xml version=\"1.0\" encoding=\"". $import->options['encoding'] ."\"?>" . "\n" . "<pmxi_records>";
|
1427 |
$loop = 0;
|
1428 |
} else {
|
1454 |
array_shift(PMXI_Plugin::$session->data['pmxi_import']['local_paths']);
|
1455 |
PMXI_Plugin::$session['pmxi_import']['local_paths'] = PMXI_Plugin::$session->data['pmxi_import']['local_paths'];
|
1456 |
pmxi_session_commit();
|
1457 |
+
}
|
1458 |
+
else break;
|
1459 |
}
|
1460 |
}
|
1461 |
}
|
1642 |
}
|
1643 |
protected function render_xml_text($text, $shorten = false, $is_render_collapsed = false)
|
1644 |
{
|
1645 |
+
if (empty($text) and 0 !== (int)$text) {
|
1646 |
return; // do not display empty text nodes
|
1647 |
}
|
1648 |
if (preg_match('%\[more:(\d+)\]%', $text, $mtch)) {
|
1786 |
|
1787 |
if ( ! empty(PMXI_Plugin::$session->data['pmxi_import']['update_previous'])) $update_previous->getById(PMXI_Plugin::$session->data['pmxi_import']['update_previous']);
|
1788 |
|
1789 |
+
$local_paths = (!empty(PMXI_Plugin::$session->data['pmxi_import']['local_paths'])) ? PMXI_Plugin::$session->data['pmxi_import']['local_paths'] : array();
|
1790 |
+
|
1791 |
+
if (empty($local_paths) and ! $update_previous->isEmpty()){
|
1792 |
+
$history_file = new PMXI_File_Record();
|
1793 |
+
$history_file->getBy(array('import_id' => $update_previous->id), 'id DESC');
|
1794 |
+
$local_paths = ( ! $history_file->isEmpty()) ? array($history_file->path) : array();
|
1795 |
+
}
|
1796 |
+
if ( ! empty($local_paths)) {
|
1797 |
+
$loop = 0;
|
1798 |
+
foreach ($local_paths as $key => $path) {
|
1799 |
|
1800 |
if ( @file_exists($path) ){
|
1801 |
|
1829 |
|
1830 |
}
|
1831 |
}
|
1832 |
+
}
|
1833 |
return $xml;
|
1834 |
}
|
1835 |
}
|
controllers/admin/manage.php
CHANGED
@@ -35,7 +35,7 @@ class PMXI_Admin_Manage extends PMXI_Controller_Admin {
|
|
35 |
$by = array('parent_import_id' => 0);
|
36 |
if ('' != $s) {
|
37 |
$like = '%' . preg_replace('%\s+%', '%', preg_replace('/[%?]/', '\\\\$0', $s)) . '%';
|
38 |
-
$by[] = array(array('name LIKE' => $like, 'type LIKE' => $like, 'path LIKE' => $like), 'OR');
|
39 |
}
|
40 |
|
41 |
$this->data['list'] = $list->join($post->getTable(), $list->getTable() . '.id = ' . $post->getTable() . '.import_id', 'LEFT')
|
@@ -113,13 +113,13 @@ class PMXI_Admin_Manage extends PMXI_Controller_Admin {
|
|
113 |
|
114 |
pmxi_session_unset();
|
115 |
|
|
|
|
|
116 |
if ($this->input->post('is_confirmed')) {
|
117 |
|
118 |
check_admin_referer('update-import', '_wpnonce_update-import');
|
119 |
|
120 |
-
$uploads = wp_upload_dir();
|
121 |
-
|
122 |
-
$chunks = 0;
|
123 |
|
124 |
if ( empty(PMXI_Plugin::$session->data['pmxi_import']['chunk_number']) ) {
|
125 |
|
@@ -181,21 +181,24 @@ class PMXI_Admin_Manage extends PMXI_Controller_Admin {
|
|
181 |
} elseif ( preg_match('%\W(csv|txt|dat|psv)$%i', trim($item->path))) { // If CSV file uploaded
|
182 |
if($uploads['error']){
|
183 |
$this->errors->add('form-validation', __('Can not create upload folder. Permision denied', 'pmxi_plugin'));
|
184 |
-
}
|
185 |
-
$filePath = $post['filepath'];
|
186 |
include_once(PMXI_Plugin::ROOT_DIR.'/libraries/XmlImportCsvParse.php');
|
187 |
$csv = new PMXI_CsvParser($item->path, true, '', ( ! empty($item->options['delimiter']) ) ? $item->options['delimiter'] : '', ( ! empty($item->options['encoding']) ) ? $item->options['encoding'] : '');
|
188 |
$filePath = $csv->xml_path;
|
189 |
|
190 |
} elseif(preg_match('%\W(gz)$%i', trim($item->path))){ // If gz file uploaded
|
191 |
$fileInfo = pmxi_gzfile_get_contents($item->path);
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
|
|
|
|
198 |
}
|
|
|
|
|
199 |
} else { // If XML file uploaded
|
200 |
|
201 |
$filePath = $item->path;
|
@@ -204,8 +207,7 @@ class PMXI_Admin_Manage extends PMXI_Controller_Admin {
|
|
204 |
|
205 |
}
|
206 |
|
207 |
-
@set_time_limit(0);
|
208 |
-
|
209 |
$local_paths = !empty($local_paths) ? $local_paths : array($filePath);
|
210 |
|
211 |
foreach ($local_paths as $key => $path) {
|
@@ -266,8 +268,7 @@ class PMXI_Admin_Manage extends PMXI_Controller_Admin {
|
|
266 |
'encoding' => (!empty($item->options['encoding'])) ? $item->options['encoding'] : 'UTF-8',
|
267 |
'is_csv' => (!empty($item->options['delimiter'])) ? $item->options['delimiter'] : PMXI_Plugin::$is_csv,
|
268 |
'csv_path' => PMXI_Plugin::$csv_path,
|
269 |
-
'scheduled' => $item->scheduled,
|
270 |
-
'current_post_ids' => '',
|
271 |
'chunk_number' => 1,
|
272 |
'log' => '',
|
273 |
'warnings' => 0,
|
@@ -305,9 +306,9 @@ class PMXI_Admin_Manage extends PMXI_Controller_Admin {
|
|
305 |
|
306 |
if ($this->input->post('is_confirmed')) {
|
307 |
check_admin_referer('delete-import', '_wpnonce_delete-import');
|
308 |
-
|
309 |
-
do_action('pmxi_before_import_delete', $item, $this->input->post('is_delete_posts'));
|
310 |
|
|
|
|
|
311 |
$item->delete( ! $this->input->post('is_delete_posts'));
|
312 |
wp_redirect(add_query_arg('pmxi_nt', urlencode(__('Import deleted', 'pmxi_plugin')), $this->baseUrl)); die();
|
313 |
}
|
35 |
$by = array('parent_import_id' => 0);
|
36 |
if ('' != $s) {
|
37 |
$like = '%' . preg_replace('%\s+%', '%', preg_replace('/[%?]/', '\\\\$0', $s)) . '%';
|
38 |
+
$by[] = array(array('name LIKE' => $like, 'type LIKE' => $like, 'path LIKE' => $like, 'friendly_name LIKE' => $like), 'OR');
|
39 |
}
|
40 |
|
41 |
$this->data['list'] = $list->join($post->getTable(), $list->getTable() . '.id = ' . $post->getTable() . '.import_id', 'LEFT')
|
113 |
|
114 |
pmxi_session_unset();
|
115 |
|
116 |
+
$chunks = 0;
|
117 |
+
|
118 |
if ($this->input->post('is_confirmed')) {
|
119 |
|
120 |
check_admin_referer('update-import', '_wpnonce_update-import');
|
121 |
|
122 |
+
$uploads = wp_upload_dir();
|
|
|
|
|
123 |
|
124 |
if ( empty(PMXI_Plugin::$session->data['pmxi_import']['chunk_number']) ) {
|
125 |
|
181 |
} elseif ( preg_match('%\W(csv|txt|dat|psv)$%i', trim($item->path))) { // If CSV file uploaded
|
182 |
if($uploads['error']){
|
183 |
$this->errors->add('form-validation', __('Can not create upload folder. Permision denied', 'pmxi_plugin'));
|
184 |
+
}
|
|
|
185 |
include_once(PMXI_Plugin::ROOT_DIR.'/libraries/XmlImportCsvParse.php');
|
186 |
$csv = new PMXI_CsvParser($item->path, true, '', ( ! empty($item->options['delimiter']) ) ? $item->options['delimiter'] : '', ( ! empty($item->options['encoding']) ) ? $item->options['encoding'] : '');
|
187 |
$filePath = $csv->xml_path;
|
188 |
|
189 |
} elseif(preg_match('%\W(gz)$%i', trim($item->path))){ // If gz file uploaded
|
190 |
$fileInfo = pmxi_gzfile_get_contents($item->path);
|
191 |
+
if ( ! is_wp_error($fileInfo) ){
|
192 |
+
$filePath = $fileInfo['localPath'];
|
193 |
+
// detect CSV or XML
|
194 |
+
if ( $fileInfo['type'] == 'csv') { // it is CSV file
|
195 |
+
include_once(PMXI_Plugin::ROOT_DIR.'/libraries/XmlImportCsvParse.php');
|
196 |
+
$csv = new PMXI_CsvParser($filePath, true, '', ( ! empty($item->options['delimiter']) ) ? $item->options['delimiter'] : '', ( ! empty($item->options['encoding']) ) ? $item->options['encoding'] : ''); // create chunks
|
197 |
+
$filePath = $csv->xml_path;
|
198 |
+
}
|
199 |
}
|
200 |
+
else $this->errors->add('form-validation', $fileInfo->get_error_message());
|
201 |
+
|
202 |
} else { // If XML file uploaded
|
203 |
|
204 |
$filePath = $item->path;
|
207 |
|
208 |
}
|
209 |
|
210 |
+
@set_time_limit(0);
|
|
|
211 |
$local_paths = !empty($local_paths) ? $local_paths : array($filePath);
|
212 |
|
213 |
foreach ($local_paths as $key => $path) {
|
268 |
'encoding' => (!empty($item->options['encoding'])) ? $item->options['encoding'] : 'UTF-8',
|
269 |
'is_csv' => (!empty($item->options['delimiter'])) ? $item->options['delimiter'] : PMXI_Plugin::$is_csv,
|
270 |
'csv_path' => PMXI_Plugin::$csv_path,
|
271 |
+
'scheduled' => $item->scheduled,
|
|
|
272 |
'chunk_number' => 1,
|
273 |
'log' => '',
|
274 |
'warnings' => 0,
|
306 |
|
307 |
if ($this->input->post('is_confirmed')) {
|
308 |
check_admin_referer('delete-import', '_wpnonce_delete-import');
|
|
|
|
|
309 |
|
310 |
+
do_action('pmxi_before_import_delete', $item, $this->input->post('is_delete_posts'));
|
311 |
+
|
312 |
$item->delete( ! $this->input->post('is_delete_posts'));
|
313 |
wp_redirect(add_query_arg('pmxi_nt', urlencode(__('Import deleted', 'pmxi_plugin')), $this->baseUrl)); die();
|
314 |
}
|
controllers/admin/settings.php
CHANGED
@@ -113,7 +113,7 @@ class PMXI_Admin_Settings extends PMXI_Controller_Admin {
|
|
113 |
|
114 |
exit('OK');
|
115 |
}
|
116 |
-
|
117 |
public function dismiss_manage_top(){
|
118 |
|
119 |
PMXI_Plugin::getInstance()->updateOption("dismiss_manage_top", 1);
|
@@ -140,15 +140,18 @@ class PMXI_Admin_Settings extends PMXI_Controller_Admin {
|
|
140 |
WHERE postmeta.meta_key='".$meta_key."'
|
141 |
", ARRAY_A);
|
142 |
|
143 |
-
$html = '<
|
144 |
-
|
145 |
if (!empty($r)){
|
146 |
-
$html
|
147 |
foreach ($r as $key => $value) { if (empty($value['meta_value'])) continue;
|
148 |
-
$html .= '<option value="'
|
149 |
}
|
150 |
$html .= '</select>';
|
151 |
}
|
|
|
|
|
|
|
152 |
|
153 |
echo $html;
|
154 |
}
|
113 |
|
114 |
exit('OK');
|
115 |
}
|
116 |
+
|
117 |
public function dismiss_manage_top(){
|
118 |
|
119 |
PMXI_Plugin::getInstance()->updateOption("dismiss_manage_top", 1);
|
140 |
WHERE postmeta.meta_key='".$meta_key."'
|
141 |
", ARRAY_A);
|
142 |
|
143 |
+
$html = '<div class="input ex_values">';
|
144 |
+
|
145 |
if (!empty($r)){
|
146 |
+
$html .= '<select class="existing_meta_values"><option value="">'.__('Existing Values...','pmxi_plugin').'</option>';
|
147 |
foreach ($r as $key => $value) { if (empty($value['meta_value'])) continue;
|
148 |
+
$html .= '<option value="'.esc_html($value['meta_value']).'">'.$value['meta_value'].'</option>';
|
149 |
}
|
150 |
$html .= '</select>';
|
151 |
}
|
152 |
+
else $html .= '<p>' . __('No existing values were found for this field.','pmxi_plugin') . '</p>';
|
153 |
+
|
154 |
+
$html .= '</div>';
|
155 |
|
156 |
echo $html;
|
157 |
}
|
controllers/controller/admin.php
CHANGED
@@ -49,7 +49,7 @@ abstract class PMXI_Controller_Admin extends PMXI_Controller {
|
|
49 |
$wp_styles->add_data('pmxi-admin-style-ie', 'conditional', 'lte IE 7');
|
50 |
wp_enqueue_style('wp-pointer');
|
51 |
|
52 |
-
if ( version_compare(get_bloginfo('version'), '3.8-RC1') >= 0 ){
|
53 |
wp_enqueue_style('pmxi-admin-style-wp-3.8', PMXI_ROOT_URL . '/static/css/admin-wp-3.8.css');
|
54 |
}
|
55 |
|
49 |
$wp_styles->add_data('pmxi-admin-style-ie', 'conditional', 'lte IE 7');
|
50 |
wp_enqueue_style('wp-pointer');
|
51 |
|
52 |
+
if ( version_compare(get_bloginfo('version'), '3.8-RC1') >= 0 ){
|
53 |
wp_enqueue_style('pmxi-admin-style-wp-3.8', PMXI_ROOT_URL . '/static/css/admin-wp-3.8.css');
|
54 |
}
|
55 |
|
helpers/get_file_curl.php
CHANGED
@@ -2,21 +2,56 @@
|
|
2 |
|
3 |
if ( ! function_exists('get_file_curl') ):
|
4 |
|
5 |
-
function get_file_curl($url, $fullpath, $to_variable = false) {
|
6 |
|
7 |
-
$
|
|
|
|
|
8 |
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
-
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
-
return ($to_variable) ? $rawdata : true;
|
20 |
}
|
21 |
|
22 |
endif;
|
@@ -52,7 +87,7 @@ if ( ! function_exists('curl_exec_follow') ):
|
|
52 |
|
53 |
function curl_exec_follow($ch, &$maxredirect = null) {
|
54 |
|
55 |
-
$mr = $maxredirect === null ?
|
56 |
|
57 |
if (ini_get('open_basedir') == '' && ini_get('safe_mode' == 'Off')) {
|
58 |
|
@@ -83,7 +118,6 @@ if ( ! function_exists('curl_exec_follow') ):
|
|
83 |
$code = 0;
|
84 |
} else {
|
85 |
$code = curl_getinfo($rch, CURLINFO_HTTP_CODE);
|
86 |
-
|
87 |
if ($code == 301 || $code == 302) {
|
88 |
preg_match('/Location:(.*?)\n/', $header, $matches);
|
89 |
$newurl = trim(array_pop($matches));
|
@@ -113,4 +147,5 @@ if ( ! function_exists('curl_exec_follow') ):
|
|
113 |
}
|
114 |
return curl_exec($ch);
|
115 |
}
|
|
|
116 |
endif;
|
2 |
|
3 |
if ( ! function_exists('get_file_curl') ):
|
4 |
|
5 |
+
function get_file_curl($url, $fullpath, $to_variable = false, $iteration = 0) {
|
6 |
|
7 |
+
$request = wp_remote_get($url);
|
8 |
+
|
9 |
+
if ( ! is_wp_error($request) ){
|
10 |
|
11 |
+
$rawdata = wp_remote_retrieve_body( $request );
|
12 |
+
|
13 |
+
if (empty($rawdata)){
|
14 |
+
$result = pmxi_curl_download($url, $fullpath, $to_variable);
|
15 |
+
if ( ! $result and ! $iteration){
|
16 |
+
$url = pmxi_translate_uri($url);
|
17 |
+
return get_file_curl($url, $fullpath, $to_variable, 1);
|
18 |
+
}
|
19 |
+
return $result;
|
20 |
+
}
|
21 |
+
|
22 |
+
if ( ! @file_put_contents($fullpath, $rawdata) ) {
|
23 |
+
$fp = fopen($fullpath,'w');
|
24 |
+
fwrite($fp, $rawdata);
|
25 |
+
fclose($fp);
|
26 |
+
}
|
27 |
+
|
28 |
+
if ( preg_match('%\W(jpg|jpeg|gif|png)$%i', basename($fullpath)) and ( ! ($image_info = @getimagesize($fullpath)) or ! in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG)) ) )
|
29 |
+
{
|
30 |
+
$result = pmxi_curl_download($url, $fullpath, $to_variable);
|
31 |
+
if ( ! $result and ! $iteration){
|
32 |
+
$url = pmxi_translate_uri($url);
|
33 |
+
return get_file_curl($url, $fullpath, $to_variable, 1);
|
34 |
+
}
|
35 |
+
return $result;
|
36 |
+
}
|
37 |
|
38 |
+
return ($to_variable) ? $rawdata : true;
|
39 |
|
40 |
+
}
|
41 |
+
else{
|
42 |
+
|
43 |
+
$curl = pmxi_curl_download($url, $fullpath, $to_variable);
|
44 |
+
|
45 |
+
if ($curl === false and ! $iteration){
|
46 |
+
$url = pmxi_translate_uri($url);
|
47 |
+
return get_file_curl($url, $fullpath, $to_variable, 1);
|
48 |
+
|
49 |
+
}
|
50 |
+
|
51 |
+
return ($curl === false) ? $request : $curl;
|
52 |
+
|
53 |
+
}
|
54 |
|
|
|
55 |
}
|
56 |
|
57 |
endif;
|
87 |
|
88 |
function curl_exec_follow($ch, &$maxredirect = null) {
|
89 |
|
90 |
+
$mr = $maxredirect === null ? 5 : intval($maxredirect);
|
91 |
|
92 |
if (ini_get('open_basedir') == '' && ini_get('safe_mode' == 'Off')) {
|
93 |
|
118 |
$code = 0;
|
119 |
} else {
|
120 |
$code = curl_getinfo($rch, CURLINFO_HTTP_CODE);
|
|
|
121 |
if ($code == 301 || $code == 302) {
|
122 |
preg_match('/Location:(.*?)\n/', $header, $matches);
|
123 |
$newurl = trim(array_pop($matches));
|
147 |
}
|
148 |
return curl_exec($ch);
|
149 |
}
|
150 |
+
|
151 |
endif;
|
helpers/import_custom_meta_box.php
CHANGED
@@ -25,5 +25,4 @@ if (!function_exists('import_custom_meta_box')){
|
|
25 |
<p><?php _e('Custom fields can be used to add extra metadata to a post that you can <a href="http://codex.wordpress.org/Using_Custom_Fields" target="_blank">use in your theme</a>.'); ?></p>
|
26 |
<?php
|
27 |
}
|
28 |
-
}
|
29 |
-
?>
|
25 |
<p><?php _e('Custom fields can be used to add extra metadata to a post that you can <a href="http://codex.wordpress.org/Using_Custom_Fields" target="_blank">use in your theme</a>.'); ?></p>
|
26 |
<?php
|
27 |
}
|
28 |
+
}
|
|
helpers/is_exists_term.php
CHANGED
@@ -6,5 +6,4 @@ if (!function_exists('is_exists_term')){
|
|
6 |
return term_exists( $name, $tx_name, $parent_id );
|
7 |
|
8 |
}
|
9 |
-
}
|
10 |
-
?>
|
6 |
return term_exists( $name, $tx_name, $parent_id );
|
7 |
|
8 |
}
|
9 |
+
}
|
|
helpers/pmxi_findDuplicates.php
CHANGED
@@ -10,8 +10,9 @@ function pmxi_findDuplicates($articleData, $custom_duplicate_name = '', $custom_
|
|
10 |
if ('custom field' == $duplicate_indicator){
|
11 |
$duplicate_ids = array();
|
12 |
$args = array(
|
13 |
-
'post_type'
|
14 |
-
'
|
|
|
15 |
array(
|
16 |
'key' => $custom_duplicate_name,
|
17 |
'value' => $custom_duplicate_value,
|
@@ -57,6 +58,4 @@ function pmxi_findDuplicates($articleData, $custom_duplicate_name = '', $custom_
|
|
57 |
preg_replace('%[ \\t\\n]%', '', $articleData[$field])
|
58 |
));
|
59 |
}
|
60 |
-
}
|
61 |
-
|
62 |
-
?>
|
10 |
if ('custom field' == $duplicate_indicator){
|
11 |
$duplicate_ids = array();
|
12 |
$args = array(
|
13 |
+
'post_type' => ((class_exists('PMWI_Plugin') and $articleData['post_type'] == 'product') ? array('product', 'product_variation') : $articleData['post_type']),
|
14 |
+
'post_status' => array('draft', 'publish', 'trash', 'pending', 'future', 'private'),
|
15 |
+
'meta_query' => array(
|
16 |
array(
|
17 |
'key' => $custom_duplicate_name,
|
18 |
'value' => $custom_duplicate_value,
|
58 |
preg_replace('%[ \\t\\n]%', '', $articleData[$field])
|
59 |
));
|
60 |
}
|
61 |
+
}
|
|
|
|
helpers/pmxi_functions.php
CHANGED
@@ -162,7 +162,7 @@
|
|
162 |
$response = wp_remote_get($filePath);
|
163 |
$headers = wp_remote_retrieve_headers( $response );
|
164 |
|
165 |
-
if (preg_match("/filename=\".*\"/i", $headers['content-disposition'], $matches)){
|
166 |
$remote_file_name = str_replace(array('filename=','"'), '', $matches[0]);
|
167 |
if (!empty($remote_file_name)){
|
168 |
$type = (preg_match('%\W(csv)$%i', basename($remote_file_name))) ? 'csv' : false;
|
@@ -180,14 +180,13 @@
|
|
180 |
if ( ! function_exists('pmxi_get_remote_image_ext')){
|
181 |
|
182 |
function pmxi_get_remote_image_ext($filePath){
|
183 |
-
|
184 |
-
|
185 |
-
if ("" != $ext) return $ext;
|
186 |
$response = wp_remote_get($filePath);
|
187 |
$headers = wp_remote_retrieve_headers( $response );
|
188 |
-
$content_type = explode('/'
|
|
|
|
|
189 |
|
190 |
-
return (!empty($content_type[1])) ? $content_type[1] : '';
|
191 |
}
|
192 |
}
|
193 |
|
@@ -198,18 +197,18 @@
|
|
198 |
if (!$i) return "";
|
199 |
$l = strlen($str) - $i;
|
200 |
$ext = substr($str,$i+1,$l);
|
201 |
-
return ($
|
202 |
}
|
203 |
}
|
204 |
|
205 |
-
if ( ! function_exists('
|
206 |
function pmxi_getExtensionFromStr($str)
|
207 |
{
|
208 |
$i = strrpos($str,".");
|
209 |
-
if (
|
210 |
$l = strlen($str) - $i;
|
211 |
-
$ext = substr($str,$i+1,$l);
|
212 |
-
return (preg_match('
|
213 |
}
|
214 |
}
|
215 |
|
@@ -221,22 +220,20 @@
|
|
221 |
if ( ! function_exists('pmxi_copy_url_file')){
|
222 |
|
223 |
function pmxi_copy_url_file($filePath, $detect = false){
|
224 |
-
/*$ctx = stream_context_create();
|
225 |
-
stream_context_set_params($ctx, array("notification" => "stream_notification_callback"));*/
|
226 |
|
227 |
$type = (preg_match('%\W(csv|txt|dat|psv)$%i', basename($filePath))) ? 'csv' : false;
|
228 |
if (!$type) $type = (preg_match('%\W(xml)$%i', basename($filePath))) ? 'xml' : false;
|
229 |
|
230 |
$uploads = wp_upload_dir();
|
231 |
$tmpname = wp_unique_filename($uploads['path'], ($type and strlen(basename($filePath)) < 30) ? basename($filePath) : time());
|
232 |
-
$localPath = $uploads['path'] .'/'.
|
233 |
|
234 |
$file = @fopen($filePath, "rb");
|
235 |
|
236 |
if (is_resource($file)){
|
237 |
$fp = @fopen($localPath, 'w');
|
238 |
$first_chunk = true;
|
239 |
-
while (!feof($file)) {
|
240 |
$chunk = @fread($file, 1024);
|
241 |
if (!$type and $first_chunk and strpos($chunk, "<") !== false) $type = 'xml'; elseif (!$type and $first_chunk) $type = 'csv'; // if it's a 1st chunk, then chunk <? symbols to detect XML file
|
242 |
$first_chunk = false;
|
@@ -246,51 +243,92 @@
|
|
246 |
@fclose($fp);
|
247 |
}
|
248 |
|
249 |
-
if (!file_exists($localPath)) {
|
250 |
|
251 |
-
get_file_curl($filePath, $localPath);
|
252 |
-
|
253 |
-
if (
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
|
|
|
|
|
|
|
|
259 |
}
|
260 |
-
@fclose($file);
|
261 |
}
|
|
|
262 |
|
263 |
-
}
|
264 |
-
|
265 |
-
$newpath = str_replace("." . $type, "", $localPath) . '.' . $type;
|
266 |
|
267 |
-
|
|
|
|
|
|
|
268 |
|
269 |
return ($detect) ? array('type' => $type, 'localPath' => $localPath) : $localPath;
|
270 |
}
|
271 |
}
|
272 |
|
273 |
if ( ! function_exists('pmxi_gzfile_get_contents')){
|
274 |
-
function pmxi_gzfile_get_contents($filename, $use_include_path = 0) {
|
275 |
|
276 |
$type = 'csv';
|
277 |
-
$uploads = wp_upload_dir();
|
278 |
-
$tmpname = wp_unique_filename($uploads['path'], (strlen(basename($filename)) < 30) ? basename($filename) : time());
|
279 |
-
$localPath = $uploads['path'] .'/'. url_title($tmpname);
|
280 |
|
281 |
-
$
|
|
|
282 |
|
|
|
283 |
$file = @gzopen($filename, 'rb', $use_include_path);
|
|
|
284 |
if ($file) {
|
285 |
$first_chunk = true;
|
286 |
while (!gzeof($file)) {
|
287 |
-
$chunk = gzread($file, 1024);
|
288 |
if ($first_chunk and strpos($chunk, "<?") !== false) { $type = 'xml'; $first_chunk = false; } // if it's a 1st chunk, then chunk <? symbols to detect XML file
|
289 |
@fwrite($fp, $chunk);
|
290 |
}
|
291 |
gzclose($file);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
292 |
}
|
293 |
@fclose($fp);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
294 |
|
295 |
return array('type' => $type, 'localPath' => $localPath);
|
296 |
}
|
@@ -317,26 +355,33 @@
|
|
317 |
return $text;
|
318 |
}
|
319 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
320 |
|
321 |
-
/*
|
322 |
-
* $value = {property/type[1]}
|
323 |
-
* Would return Rent if $value is 1, $Buy if $value is 2, Unavailable if $value is 3.
|
324 |
-
*/
|
325 |
-
if ( ! function_exists('wpai_util_map')){
|
326 |
-
|
327 |
-
function wpai_util_map($orig, $change, $value) {
|
328 |
-
|
329 |
-
$orig_array = explode(',', $orig);
|
330 |
-
|
331 |
-
if ( empty($orig_array) ) return "";
|
332 |
-
|
333 |
-
$change_array = explode(',', $change);
|
334 |
-
|
335 |
-
if ( empty($change_array) or count($orig_array) != count($change_array)) return "";
|
336 |
-
|
337 |
-
return str_replace(array_map('trim', $orig_array), array_map('trim', $change_array), $value);
|
338 |
-
|
339 |
-
}
|
340 |
}
|
341 |
|
342 |
if ( ! function_exists('pmxi_convert_encoding')){
|
@@ -370,6 +415,16 @@
|
|
370 |
}
|
371 |
}
|
372 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
373 |
if ( ! function_exists('pmxi_imageurlencode')){
|
374 |
|
375 |
function pmxi_imageurlencode($url){
|
162 |
$response = wp_remote_get($filePath);
|
163 |
$headers = wp_remote_retrieve_headers( $response );
|
164 |
|
165 |
+
if (!empty($headers['content-disposition']) and preg_match("/filename=\".*\"/i", $headers['content-disposition'], $matches)){
|
166 |
$remote_file_name = str_replace(array('filename=','"'), '', $matches[0]);
|
167 |
if (!empty($remote_file_name)){
|
168 |
$type = (preg_match('%\W(csv)$%i', basename($remote_file_name))) ? 'csv' : false;
|
180 |
if ( ! function_exists('pmxi_get_remote_image_ext')){
|
181 |
|
182 |
function pmxi_get_remote_image_ext($filePath){
|
183 |
+
|
|
|
|
|
184 |
$response = wp_remote_get($filePath);
|
185 |
$headers = wp_remote_retrieve_headers( $response );
|
186 |
+
$content_type = (!empty($headers['content-type'])) ? explode('/', $headers['content-type']) : false;
|
187 |
+
|
188 |
+
return ( ! empty($content_type[1]) ) ? $content_type[1] : '';
|
189 |
|
|
|
190 |
}
|
191 |
}
|
192 |
|
197 |
if (!$i) return "";
|
198 |
$l = strlen($str) - $i;
|
199 |
$ext = substr($str,$i+1,$l);
|
200 |
+
return (strlen($ext) <= 4) ? $ext : "";
|
201 |
}
|
202 |
}
|
203 |
|
204 |
+
if ( ! function_exists('pmxi_getExtensionFromStr')){
|
205 |
function pmxi_getExtensionFromStr($str)
|
206 |
{
|
207 |
$i = strrpos($str,".");
|
208 |
+
if ($i === false) return "";
|
209 |
$l = strlen($str) - $i;
|
210 |
+
$ext = substr($str,$i+1,$l);
|
211 |
+
return (preg_match('%(jpg|jpeg|gif|png)$%i', $ext) and strlen($ext) <= 4) ? $ext : "";
|
212 |
}
|
213 |
}
|
214 |
|
220 |
if ( ! function_exists('pmxi_copy_url_file')){
|
221 |
|
222 |
function pmxi_copy_url_file($filePath, $detect = false){
|
|
|
|
|
223 |
|
224 |
$type = (preg_match('%\W(csv|txt|dat|psv)$%i', basename($filePath))) ? 'csv' : false;
|
225 |
if (!$type) $type = (preg_match('%\W(xml)$%i', basename($filePath))) ? 'xml' : false;
|
226 |
|
227 |
$uploads = wp_upload_dir();
|
228 |
$tmpname = wp_unique_filename($uploads['path'], ($type and strlen(basename($filePath)) < 30) ? basename($filePath) : time());
|
229 |
+
$localPath = $uploads['path'] .'/'. urldecode(sanitize_file_name($tmpname)) . ((!$type) ? '.tmp' : '');
|
230 |
|
231 |
$file = @fopen($filePath, "rb");
|
232 |
|
233 |
if (is_resource($file)){
|
234 |
$fp = @fopen($localPath, 'w');
|
235 |
$first_chunk = true;
|
236 |
+
while ( ! @feof($file) ) {
|
237 |
$chunk = @fread($file, 1024);
|
238 |
if (!$type and $first_chunk and strpos($chunk, "<") !== false) $type = 'xml'; elseif (!$type and $first_chunk) $type = 'csv'; // if it's a 1st chunk, then chunk <? symbols to detect XML file
|
239 |
$first_chunk = false;
|
243 |
@fclose($fp);
|
244 |
}
|
245 |
|
246 |
+
if ( ! file_exists($localPath) ) {
|
247 |
|
248 |
+
$request = get_file_curl($filePath, $localPath);
|
249 |
+
|
250 |
+
if ( ! is_wp_error($request) ){
|
251 |
+
|
252 |
+
if ( ! $type ){
|
253 |
+
$file = @fopen($localPath, "rb");
|
254 |
+
while (!@feof($file)) {
|
255 |
+
$chunk = @fread($file, 1024);
|
256 |
+
if (strpos($chunk, "<?") !== false) $type = 'xml'; else $type = 'csv'; // if it's a 1st chunk, then chunk <? symbols to detect XML file
|
257 |
+
break;
|
258 |
+
}
|
259 |
+
@fclose($file);
|
260 |
}
|
|
|
261 |
}
|
262 |
+
else return $request;
|
263 |
|
264 |
+
}
|
|
|
|
|
265 |
|
266 |
+
if ( ! preg_match('%\W('. $type .')$%i', basename($localPath)) ){
|
267 |
+
if (@rename($localPath, $localPath . '.' . $type))
|
268 |
+
$localPath = $localPath . '.' . $type;
|
269 |
+
}
|
270 |
|
271 |
return ($detect) ? array('type' => $type, 'localPath' => $localPath) : $localPath;
|
272 |
}
|
273 |
}
|
274 |
|
275 |
if ( ! function_exists('pmxi_gzfile_get_contents')){
|
276 |
+
function pmxi_gzfile_get_contents($filename, $use_include_path = 0) {
|
277 |
|
278 |
$type = 'csv';
|
279 |
+
$uploads = wp_upload_dir();
|
|
|
|
|
280 |
|
281 |
+
$tmpname = wp_unique_filename($uploads['path'], (strlen(basename($filename)) < 30) ? basename($filename) : time() );
|
282 |
+
$localPath = $uploads['path'] .'/'. urldecode(sanitize_file_name($tmpname));
|
283 |
|
284 |
+
$fp = @fopen($localPath, 'w');
|
285 |
$file = @gzopen($filename, 'rb', $use_include_path);
|
286 |
+
|
287 |
if ($file) {
|
288 |
$first_chunk = true;
|
289 |
while (!gzeof($file)) {
|
290 |
+
$chunk = gzread($file, 1024);
|
291 |
if ($first_chunk and strpos($chunk, "<?") !== false) { $type = 'xml'; $first_chunk = false; } // if it's a 1st chunk, then chunk <? symbols to detect XML file
|
292 |
@fwrite($fp, $chunk);
|
293 |
}
|
294 |
gzclose($file);
|
295 |
+
}
|
296 |
+
else{
|
297 |
+
|
298 |
+
$tmpname = wp_unique_filename($uploads['path'], (strlen(basename($filename)) < 30) ? basename($filename) : time() );
|
299 |
+
$localGZpath = $uploads['path'] .'/'. urldecode(sanitize_file_name($tmpname));
|
300 |
+
$request = get_file_curl($filename, $localGZpath, false, true);
|
301 |
+
|
302 |
+
if ( ! is_wp_error($request) ){
|
303 |
+
|
304 |
+
$file = @gzopen($localGZpath, 'rb', $use_include_path);
|
305 |
+
|
306 |
+
if ($file) {
|
307 |
+
$first_chunk = true;
|
308 |
+
while (!gzeof($file)) {
|
309 |
+
$chunk = gzread($file, 1024);
|
310 |
+
if ($first_chunk and strpos($chunk, "<?") !== false) { $type = 'xml'; $first_chunk = false; } // if it's a 1st chunk, then chunk <? symbols to detect XML file
|
311 |
+
@fwrite($fp, $chunk);
|
312 |
+
}
|
313 |
+
gzclose($file);
|
314 |
+
}
|
315 |
+
|
316 |
+
@unlink($localGZpath);
|
317 |
+
|
318 |
+
}
|
319 |
+
else return $request;
|
320 |
+
|
321 |
}
|
322 |
@fclose($fp);
|
323 |
+
|
324 |
+
if (preg_match('%\W(gz)$%i', basename($localPath))){
|
325 |
+
if (@rename($localPath, str_replace('.gz', '.' . $type, $localPath)))
|
326 |
+
$localPath = str_replace('.gz', '.' . $type, $localPath);
|
327 |
+
}
|
328 |
+
else{
|
329 |
+
if (@rename($localPath, $localPath . '.' . $type))
|
330 |
+
$localPath = $localPath . '.' . $type;
|
331 |
+
}
|
332 |
|
333 |
return array('type' => $type, 'localPath' => $localPath);
|
334 |
}
|
355 |
return $text;
|
356 |
}
|
357 |
}
|
358 |
+
|
359 |
+
if( !function_exists('wpai_util_map') ){
|
360 |
+
|
361 |
+
function wpai_util_map( $orig, $change, $source ){
|
362 |
+
|
363 |
+
$orig = html_entity_decode($orig);
|
364 |
+
$change = html_entity_decode($change);
|
365 |
+
$source = html_entity_decode($source);
|
366 |
+
$original_array = array_map('trim',explode(',',$orig));
|
367 |
+
|
368 |
+
if ( empty($original_array) ) return "";
|
369 |
+
|
370 |
+
$change_array = array_map('trim',explode(',',$change));
|
371 |
+
|
372 |
+
if ( empty($change_array) or count($original_array) != count($change_array)) return "";
|
373 |
+
|
374 |
+
if( count($change_array) == count($original_array) ){
|
375 |
+
$replacement = array();
|
376 |
+
foreach ($original_array as $key => $el){
|
377 |
+
$replacement[$el] = $change_array[$key];
|
378 |
+
}
|
379 |
+
$result = strtr($source,$replacement);
|
380 |
+
}
|
381 |
+
return $result;
|
382 |
+
|
383 |
+
}
|
384 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
385 |
}
|
386 |
|
387 |
if ( ! function_exists('pmxi_convert_encoding')){
|
415 |
}
|
416 |
}
|
417 |
|
418 |
+
if ( ! function_exists('pmxi_translate_uri') ){
|
419 |
+
function pmxi_translate_uri($uri) {
|
420 |
+
$parts = explode('/', $uri);
|
421 |
+
for ($i = 1; $i < count($parts); $i++) {
|
422 |
+
$parts[$i] = rawurlencode($parts[$i]);
|
423 |
+
}
|
424 |
+
return implode('/', $parts);
|
425 |
+
}
|
426 |
+
}
|
427 |
+
|
428 |
if ( ! function_exists('pmxi_imageurlencode')){
|
429 |
|
430 |
function pmxi_imageurlencode($url){
|
helpers/pmxi_insert_attachment.php
CHANGED
@@ -128,4 +128,3 @@ function pmxi_insert_attachment($object, $file = false, $parent = 0) {
|
|
128 |
|
129 |
return $post_ID;
|
130 |
}
|
131 |
-
?>
|
128 |
|
129 |
return $post_ID;
|
130 |
}
|
|
helpers/pmxi_insert_post.php
CHANGED
@@ -183,6 +183,4 @@ function pmxi_insert_post($postarr, $wp_error = false){
|
|
183 |
$wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post_ID ) ), $where );
|
184 |
|
185 |
return $post_ID;
|
186 |
-
}
|
187 |
-
|
188 |
-
?>
|
183 |
$wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post_ID ) ), $where );
|
184 |
|
185 |
return $post_ID;
|
186 |
+
}
|
|
|
|
helpers/pmxi_recursion_taxes.php
CHANGED
@@ -24,7 +24,7 @@ function pmxi_recursion_taxes($parent, $tx_name, $txes, $key){
|
|
24 |
$term = wp_insert_term(
|
25 |
$parent, // the term
|
26 |
$tx_name, // the taxonomy
|
27 |
-
array('parent'=> (!empty($parent_id)) ? $parent_id : 0)
|
28 |
);
|
29 |
}
|
30 |
return ( ! is_wp_error($term)) ? $term['term_id'] : 0;
|
@@ -32,19 +32,20 @@ function pmxi_recursion_taxes($parent, $tx_name, $txes, $key){
|
|
32 |
}
|
33 |
else{
|
34 |
|
35 |
-
if ( !empty($txes[$key - 1]) and !empty($txes[$key - 1]['parent']) and $parent != $txes[$key - 1]['parent']) {
|
|
|
36 |
$parent_id = pmxi_recursion_taxes($txes[$key - 1]['parent'], $tx_name, $txes, $key - 1);
|
37 |
|
38 |
$term = is_exists_term($tx_name, $parent, (int)$parent_id);
|
39 |
-
|
40 |
-
if ( empty($term) and !is_wp_error($term) ){
|
41 |
$term = wp_insert_term(
|
42 |
$parent, // the term
|
43 |
$tx_name, // the taxonomy
|
44 |
-
array('parent'=> (!empty($parent_id)) ? $parent_id : 0)
|
45 |
);
|
46 |
}
|
47 |
-
return ( ! is_wp_error($term)) ? $term['term_id'] : 0;
|
48 |
}
|
49 |
else{
|
50 |
|
@@ -60,4 +61,3 @@ function pmxi_recursion_taxes($parent, $tx_name, $txes, $key){
|
|
60 |
}
|
61 |
|
62 |
}
|
63 |
-
?>
|
24 |
$term = wp_insert_term(
|
25 |
$parent, // the term
|
26 |
$tx_name, // the taxonomy
|
27 |
+
array('parent'=> (!empty($parent_id)) ? (int)$parent_id : 0)
|
28 |
);
|
29 |
}
|
30 |
return ( ! is_wp_error($term)) ? $term['term_id'] : 0;
|
32 |
}
|
33 |
else{
|
34 |
|
35 |
+
if ( !empty($txes[$key - 1]) and !empty($txes[$key - 1]['parent']) and $parent != $txes[$key - 1]['parent']) {
|
36 |
+
|
37 |
$parent_id = pmxi_recursion_taxes($txes[$key - 1]['parent'], $tx_name, $txes, $key - 1);
|
38 |
|
39 |
$term = is_exists_term($tx_name, $parent, (int)$parent_id);
|
40 |
+
|
41 |
+
if ( empty($term) and ! is_wp_error($term) ){
|
42 |
$term = wp_insert_term(
|
43 |
$parent, // the term
|
44 |
$tx_name, // the taxonomy
|
45 |
+
array('parent'=> (!empty($parent_id)) ? (int)$parent_id : 0)
|
46 |
);
|
47 |
}
|
48 |
+
return ( ! is_wp_error($term) ) ? $term['term_id'] : 0;
|
49 |
}
|
50 |
else{
|
51 |
|
61 |
}
|
62 |
|
63 |
}
|
|
helpers/reverse_taxonomies_html.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
if ( ! function_exists('reverse_taxonomies_html') ) {
|
4 |
|
5 |
-
function reverse_taxonomies_html($post_taxonomies, $item_id, &$i){
|
6 |
$childs = array();
|
7 |
foreach ($post_taxonomies as $j => $cat) if ($cat->parent_id == $item_id) { $childs[] = $cat; }
|
8 |
|
@@ -13,13 +13,16 @@ if ( ! function_exists('reverse_taxonomies_html') ) {
|
|
13 |
foreach ($childs as $child_cat){
|
14 |
$i++;
|
15 |
?>
|
16 |
-
<li id="item_<?php echo $i; ?>">
|
17 |
<div class="drag-element">
|
18 |
<input type="checkbox" class="assign_post" <?php if ($child_cat->assign): ?>checked="checked"<?php endif; ?> title="<?php _e('Assign post to the taxonomy.','pmxi_plugin');?>"/>
|
19 |
-
<input class="widefat" type="text" value="<?php echo esc_attr($child_cat->xpath); ?>"/>
|
|
|
|
|
|
|
20 |
</div>
|
21 |
<a href="javascript:void(0);" class="icon-item remove-ico"></a>
|
22 |
-
<?php echo reverse_taxonomies_html($post_taxonomies, $child_cat->item_id, $i); ?>
|
23 |
</li>
|
24 |
<?php
|
25 |
}
|
@@ -28,6 +31,4 @@ if ( ! function_exists('reverse_taxonomies_html') ) {
|
|
28 |
<?php
|
29 |
}
|
30 |
}
|
31 |
-
}
|
32 |
-
|
33 |
-
?>
|
2 |
|
3 |
if ( ! function_exists('reverse_taxonomies_html') ) {
|
4 |
|
5 |
+
function reverse_taxonomies_html($post_taxonomies, $item_id, &$i, $ctx_name, $entry){
|
6 |
$childs = array();
|
7 |
foreach ($post_taxonomies as $j => $cat) if ($cat->parent_id == $item_id) { $childs[] = $cat; }
|
8 |
|
13 |
foreach ($childs as $child_cat){
|
14 |
$i++;
|
15 |
?>
|
16 |
+
<li id="item_<?php echo $i; ?>" class="dragging">
|
17 |
<div class="drag-element">
|
18 |
<input type="checkbox" class="assign_post" <?php if ($child_cat->assign): ?>checked="checked"<?php endif; ?> title="<?php _e('Assign post to the taxonomy.','pmxi_plugin');?>"/>
|
19 |
+
<input class="widefat xpath_field" type="text" value="<?php echo esc_attr($child_cat->xpath); ?>"/>
|
20 |
+
|
21 |
+
<?php do_action('pmxi_category_view', $cat, $i, $ctx_name, $entry); ?>
|
22 |
+
|
23 |
</div>
|
24 |
<a href="javascript:void(0);" class="icon-item remove-ico"></a>
|
25 |
+
<?php echo reverse_taxonomies_html($post_taxonomies, $child_cat->item_id, $i, $ctx_name, $entry); ?>
|
26 |
</li>
|
27 |
<?php
|
28 |
}
|
31 |
<?php
|
32 |
}
|
33 |
}
|
34 |
+
}
|
|
|
|
helpers/wp_delete_attachments.php
CHANGED
@@ -4,11 +4,14 @@
|
|
4 |
* @param int $parent_id Parent id of post to delete attachments for
|
5 |
*/
|
6 |
function wp_delete_attachments($parent_id, $unlink = true, $type = '') {
|
|
|
|
|
|
|
7 |
foreach (get_posts(array('post_parent' => $parent_id, 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null)) as $attach) {
|
8 |
if ($type == 'files' and ! wp_attachment_is_image( $attach->ID ) ){
|
9 |
wp_delete_attachment($attach->ID, true);
|
10 |
}
|
11 |
-
elseif ( ($type == 'images' and wp_attachment_is_image( $attach->ID )) or "" == $type){
|
12 |
|
13 |
if ($unlink or ! wp_attachment_is_image( $attach->ID )){
|
14 |
wp_delete_attachment($attach->ID, true);
|
4 |
* @param int $parent_id Parent id of post to delete attachments for
|
5 |
*/
|
6 |
function wp_delete_attachments($parent_id, $unlink = true, $type = '') {
|
7 |
+
|
8 |
+
if ( $type == 'images' and has_post_thumbnail($parent_id) ) delete_post_thumbnail($parent_id);
|
9 |
+
|
10 |
foreach (get_posts(array('post_parent' => $parent_id, 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null)) as $attach) {
|
11 |
if ($type == 'files' and ! wp_attachment_is_image( $attach->ID ) ){
|
12 |
wp_delete_attachment($attach->ID, true);
|
13 |
}
|
14 |
+
elseif ( ($type == 'images' and wp_attachment_is_image( $attach->ID )) or "" == $type){
|
15 |
|
16 |
if ($unlink or ! wp_attachment_is_image( $attach->ID )){
|
17 |
wp_delete_attachment($attach->ID, true);
|
libraries/XmlImportCsvParse.php
CHANGED
@@ -25,7 +25,7 @@ class PMXI_CsvParser
|
|
25 |
|
26 |
$large_import = false,
|
27 |
|
28 |
-
$htmlentities = false,
|
29 |
|
30 |
$xml_path = '',
|
31 |
|
@@ -92,6 +92,8 @@ class PMXI_CsvParser
|
|
92 |
|
93 |
unset($file_params);
|
94 |
|
|
|
|
|
95 |
$this->load($filename);
|
96 |
}
|
97 |
|
@@ -811,17 +813,21 @@ class PMXI_CsvParser
|
|
811 |
|
812 |
// Fixes the encoding to uf8
|
813 |
function fixEncoding($in_str)
|
814 |
-
{
|
|
|
815 |
if (function_exists('mb_detect_encoding') and function_exists('mb_check_encoding')){
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
|
|
|
|
|
|
|
|
821 |
}
|
822 |
|
823 |
return $in_str;
|
824 |
-
|
825 |
|
826 |
} // fixEncoding
|
827 |
|
@@ -896,28 +902,45 @@ class PMXI_CsvParser
|
|
896 |
{
|
897 |
if (!$this->validates()) {
|
898 |
return false;
|
899 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
900 |
|
901 |
$c = 0;
|
902 |
$d = ( "" != $this->delimiter ) ? $this->delimiter : $this->settings['delimiter'];
|
903 |
$e = $this->settings['escape'];
|
904 |
$l = $this->settings['length'];
|
905 |
|
906 |
-
PMXI_Plugin::$is_csv = $d;
|
|
|
|
|
907 |
|
908 |
-
$
|
|
|
|
|
|
|
|
|
|
|
909 |
|
910 |
-
$wp_uploads = wp_upload_dir();
|
911 |
-
if ($this->large_import){
|
912 |
-
$tmpname = wp_unique_filename($wp_uploads['path'], str_replace("csv", "xml", basename($this->_filename)));
|
913 |
-
if ('' == $this->xml_path) $this->xml_path = $wp_uploads['path'] .'/'. url_title($tmpname);
|
914 |
-
$fp = fopen($this->xml_path, 'w');
|
915 |
-
fwrite($fp, "<?xml version=\"1.0\" encoding=\"".$this->csv_encoding."\"?><data>");
|
916 |
-
}
|
917 |
$create_new_headers = false;
|
918 |
-
|
919 |
-
$legacy_special_character_handling = PMXI_Plugin::getInstance()->getOption('legacy_special_character_handling');
|
920 |
-
|
921 |
while ($keys = fgetcsv($res, $l, $d, $e)) {
|
922 |
|
923 |
if ($c == 0) {
|
@@ -925,7 +948,7 @@ class PMXI_CsvParser
|
|
925 |
foreach ($keys as $key => $value) {
|
926 |
if (!$create_new_headers and (preg_match('%\W(http:|https:|ftp:)$%i', $value) or is_numeric($value))) $create_new_headers = true;
|
927 |
$value = trim(strtolower(preg_replace('/^[0-9]{1}/','el_', preg_replace('/[^a-z0-9_]/i', '', $value))));
|
928 |
-
$keys[$key] = (!empty($value)) ? $value : 'undefined'
|
929 |
}
|
930 |
$this->headers = $keys;
|
931 |
if ($create_new_headers){
|
@@ -934,35 +957,44 @@ class PMXI_CsvParser
|
|
934 |
}
|
935 |
}
|
936 |
|
937 |
-
if ($c or $create_new_headers) {
|
|
|
938 |
if (!empty($keys)){
|
939 |
|
940 |
$chunk = array();
|
941 |
|
942 |
-
foreach ($this->headers as $key => $header)
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
954 |
}
|
955 |
}
|
956 |
}
|
957 |
|
958 |
$c ++;
|
959 |
}
|
960 |
-
fwrite($fp, '</data>');
|
961 |
-
fclose($fp);
|
962 |
fclose($res);
|
963 |
-
|
|
|
|
|
|
|
|
|
|
|
964 |
|
965 |
-
return true;
|
966 |
}
|
967 |
|
968 |
/**
|
@@ -1061,12 +1093,7 @@ class PMXI_CsvParser
|
|
1061 |
{
|
1062 |
$this->rows = array();
|
1063 |
$this->headers = array();
|
1064 |
-
}
|
1065 |
-
|
1066 |
-
public function toXml() {
|
1067 |
-
$this->symmetrize();
|
1068 |
-
return ArrayToXML::toXml($this->getRawArray());
|
1069 |
-
}
|
1070 |
|
1071 |
function analyse_file($file, $capture_limit_in_kb = 10) {
|
1072 |
// capture starting memory usage
|
@@ -1076,7 +1103,7 @@ class PMXI_CsvParser
|
|
1076 |
$output['read_kb'] = $capture_limit_in_kb;
|
1077 |
|
1078 |
// read in file
|
1079 |
-
$fh = fopen($file, 'r');
|
1080 |
$contents = fgets($fh);
|
1081 |
fclose($fh);
|
1082 |
|
@@ -1137,68 +1164,10 @@ class PMXI_CsvParser
|
|
1137 |
|
1138 |
// capture ending memory usage
|
1139 |
$output['peak_mem']['end'] = memory_get_peak_usage(true);
|
1140 |
-
return $output;
|
1141 |
-
}
|
1142 |
|
1143 |
-
|
1144 |
-
|
1145 |
-
class ArrayToXML
|
1146 |
-
{
|
1147 |
-
/**
|
1148 |
-
* The main function for converting to an XML document.
|
1149 |
-
* Pass in a multi dimensional array and this recrusively loops through and builds up an XML document.
|
1150 |
-
*
|
1151 |
-
* @param array $data
|
1152 |
-
* @param string $rootNodeName - what you want the root node to be - defaultsto data.
|
1153 |
-
* @param SimpleXMLElement $xml - should only be used recursively
|
1154 |
-
* @return string XML
|
1155 |
-
*/
|
1156 |
-
public static function toXml($data, $rootNodeName = 'data', $xml=null)
|
1157 |
-
{
|
1158 |
-
// turn off compatibility mode as simple xml throws a wobbly if you don't.
|
1159 |
-
if (ini_get('zend.ze1_compatibility_mode') == 1)
|
1160 |
-
{
|
1161 |
-
ini_set ('zend.ze1_compatibility_mode', 0);
|
1162 |
-
}
|
1163 |
-
|
1164 |
-
if ($xml == null)
|
1165 |
-
{
|
1166 |
-
$xml = simplexml_load_string('<?xml version="1.0" encoding="utf-8"?><'.$rootNodeName .'/>');
|
1167 |
-
}
|
1168 |
-
|
1169 |
-
// loop through the data passed in.
|
1170 |
-
foreach($data as $key => $value)
|
1171 |
-
{
|
1172 |
-
// no numeric keys in our xml please!
|
1173 |
-
if (is_numeric($key))
|
1174 |
-
{
|
1175 |
-
// make string key...
|
1176 |
-
$key = "node";
|
1177 |
-
}
|
1178 |
-
|
1179 |
-
// replace anything not alpha numeric
|
1180 |
-
$key = preg_replace('/[^a-z0-9_]/i', '', $key);
|
1181 |
-
|
1182 |
-
// if there is another array found recrusively call this function
|
1183 |
-
if (is_array($value) or is_object($value))
|
1184 |
-
{
|
1185 |
-
$node = $xml->addChild($key);
|
1186 |
-
// recrusive call.
|
1187 |
-
ArrayToXML::toXml($value, $rootNodeName, $node);
|
1188 |
-
}
|
1189 |
-
else
|
1190 |
-
{
|
1191 |
-
// add single node.
|
1192 |
-
$value = htmlspecialchars($value);
|
1193 |
-
$xml->addChild($key,$value);
|
1194 |
-
}
|
1195 |
-
|
1196 |
-
}
|
1197 |
-
// pass back as string. or simple xml object if you want!
|
1198 |
-
return $xml->asXML();
|
1199 |
}
|
1200 |
|
1201 |
-
|
1202 |
}
|
1203 |
|
1204 |
?>
|
25 |
|
26 |
$large_import = false,
|
27 |
|
28 |
+
$htmlentities = false,
|
29 |
|
30 |
$xml_path = '',
|
31 |
|
92 |
|
93 |
unset($file_params);
|
94 |
|
95 |
+
//stream_filter_register('msaccessxml', 'MSAccessXmlFilter');
|
96 |
+
|
97 |
$this->load($filename);
|
98 |
}
|
99 |
|
813 |
|
814 |
// Fixes the encoding to uf8
|
815 |
function fixEncoding($in_str)
|
816 |
+
{
|
817 |
+
|
818 |
if (function_exists('mb_detect_encoding') and function_exists('mb_check_encoding')){
|
819 |
+
|
820 |
+
$cur_encoding = mb_detect_encoding($in_str) ;
|
821 |
+
|
822 |
+
if ( $cur_encoding == "UTF-8" && mb_check_encoding($in_str,"UTF-8") ){
|
823 |
+
return $in_str;
|
824 |
+
}
|
825 |
+
else
|
826 |
+
return utf8_encode($in_str);
|
827 |
+
|
828 |
}
|
829 |
|
830 |
return $in_str;
|
|
|
831 |
|
832 |
} // fixEncoding
|
833 |
|
902 |
{
|
903 |
if (!$this->validates()) {
|
904 |
return false;
|
905 |
+
}
|
906 |
+
|
907 |
+
$wp_uploads = wp_upload_dir();
|
908 |
+
|
909 |
+
$tmpname = wp_unique_filename($wp_uploads['path'], str_replace("csv", "xml", basename($this->_filename)));
|
910 |
+
if ("" == $this->xml_path) $this->xml_path = $wp_uploads['path'] .'/'. url_title($tmpname);
|
911 |
+
|
912 |
+
$this->toXML(true);
|
913 |
+
|
914 |
+
/*$file = new PMXI_Chunk($this->xml_path, array('element' => 'node'));
|
915 |
+
|
916 |
+
if ( empty($file->options['element']) ){
|
917 |
+
$this->toXML(true); // Remove non ASCII symbols and write CDATA
|
918 |
+
}*/
|
919 |
+
|
920 |
+
return true;
|
921 |
+
|
922 |
+
}
|
923 |
+
|
924 |
+
function toXML( $fixBrokenSymbols = false ){
|
925 |
|
926 |
$c = 0;
|
927 |
$d = ( "" != $this->delimiter ) ? $this->delimiter : $this->settings['delimiter'];
|
928 |
$e = $this->settings['escape'];
|
929 |
$l = $this->settings['length'];
|
930 |
|
931 |
+
PMXI_Plugin::$is_csv = $d;
|
932 |
+
|
933 |
+
$res = fopen($this->_filename, 'rb');
|
934 |
|
935 |
+
$xmlWriter = new XMLWriter();
|
936 |
+
$xmlWriter->openURI($this->xml_path);
|
937 |
+
$xmlWriter->setIndent(true);
|
938 |
+
$xmlWriter->setIndentString("\t");
|
939 |
+
$xmlWriter->startDocument('1.0', $this->csv_encoding);
|
940 |
+
$xmlWriter->startElement('data');
|
941 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
942 |
$create_new_headers = false;
|
943 |
+
|
|
|
|
|
944 |
while ($keys = fgetcsv($res, $l, $d, $e)) {
|
945 |
|
946 |
if ($c == 0) {
|
948 |
foreach ($keys as $key => $value) {
|
949 |
if (!$create_new_headers and (preg_match('%\W(http:|https:|ftp:)$%i', $value) or is_numeric($value))) $create_new_headers = true;
|
950 |
$value = trim(strtolower(preg_replace('/^[0-9]{1}/','el_', preg_replace('/[^a-z0-9_]/i', '', $value))));
|
951 |
+
$keys[$key] = (!empty($value)) ? $value : 'undefined' . $key;
|
952 |
}
|
953 |
$this->headers = $keys;
|
954 |
if ($create_new_headers){
|
957 |
}
|
958 |
}
|
959 |
|
960 |
+
if ( $c or $create_new_headers ) {
|
961 |
+
|
962 |
if (!empty($keys)){
|
963 |
|
964 |
$chunk = array();
|
965 |
|
966 |
+
foreach ($this->headers as $key => $header) $chunk[$header] = $this->fixEncoding( $keys[$key] );
|
967 |
+
|
968 |
+
if ( ! empty($chunk) )
|
969 |
+
{
|
970 |
+
$xmlWriter->startElement('node');
|
971 |
+
foreach ($chunk as $header => $value)
|
972 |
+
{
|
973 |
+
$xmlWriter->startElement($header);
|
974 |
+
if ($fixBrokenSymbols){
|
975 |
+
// Remove non ASCII symbols and write CDATA
|
976 |
+
$xmlWriter->writeCData(preg_replace('/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', ' ', $value));
|
977 |
+
}
|
978 |
+
else{
|
979 |
+
$xmlWriter->writeCData($value);
|
980 |
+
}
|
981 |
+
$xmlWriter->endElement();
|
982 |
+
}
|
983 |
+
$xmlWriter->endElement();
|
984 |
}
|
985 |
}
|
986 |
}
|
987 |
|
988 |
$c ++;
|
989 |
}
|
|
|
|
|
990 |
fclose($res);
|
991 |
+
|
992 |
+
$xmlWriter->endElement();
|
993 |
+
|
994 |
+
$xmlWriter->flush(true);
|
995 |
+
|
996 |
+
return true;
|
997 |
|
|
|
998 |
}
|
999 |
|
1000 |
/**
|
1093 |
{
|
1094 |
$this->rows = array();
|
1095 |
$this->headers = array();
|
1096 |
+
}
|
|
|
|
|
|
|
|
|
|
|
1097 |
|
1098 |
function analyse_file($file, $capture_limit_in_kb = 10) {
|
1099 |
// capture starting memory usage
|
1103 |
$output['read_kb'] = $capture_limit_in_kb;
|
1104 |
|
1105 |
// read in file
|
1106 |
+
$fh = fopen($file, 'r');
|
1107 |
$contents = fgets($fh);
|
1108 |
fclose($fh);
|
1109 |
|
1164 |
|
1165 |
// capture ending memory usage
|
1166 |
$output['peak_mem']['end'] = memory_get_peak_usage(true);
|
|
|
|
|
1167 |
|
1168 |
+
return $output;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1169 |
}
|
1170 |
|
|
|
1171 |
}
|
1172 |
|
1173 |
?>
|
libraries/XmlImportParser.php
CHANGED
@@ -83,12 +83,11 @@ class XmlImportParser {
|
|
83 |
|
84 |
for ($i = 0; $i < count($rootNodes); $i++) {
|
85 |
if (empty($records) or in_array($i + 1, $records)) {
|
86 |
-
$rootNode = $rootNodes[$i];
|
87 |
$template = new XmlImportTemplate($rootNode, $this->cachedTemplate);
|
88 |
$result[] = $template->parse();
|
89 |
}
|
90 |
-
}
|
91 |
-
|
92 |
return $result;
|
93 |
}
|
94 |
|
83 |
|
84 |
for ($i = 0; $i < count($rootNodes); $i++) {
|
85 |
if (empty($records) or in_array($i + 1, $records)) {
|
86 |
+
$rootNode = $rootNodes[$i];
|
87 |
$template = new XmlImportTemplate($rootNode, $this->cachedTemplate);
|
88 |
$result[] = $template->parse();
|
89 |
}
|
90 |
+
}
|
|
|
91 |
return $result;
|
92 |
}
|
93 |
|
libraries/XmlImportTemplate.php
CHANGED
@@ -64,11 +64,11 @@ class XmlImportTemplate {
|
|
64 |
|
65 |
if (is_array($xpath) && count($xpath) > 0) {
|
66 |
$result = array();
|
67 |
-
foreach ($xpath as $xp) { // cancatenate multiple elements into 1 string
|
68 |
ob_start();
|
69 |
echo $xp;
|
70 |
$result[] = trim(ob_get_clean());
|
71 |
-
}
|
72 |
return implode(XmlImportConfig::getInstance()->getMultiGlue(), $result);
|
73 |
} else {
|
74 |
// return null if nothing found
|
64 |
|
65 |
if (is_array($xpath) && count($xpath) > 0) {
|
66 |
$result = array();
|
67 |
+
foreach ($xpath as $xp) { // cancatenate multiple elements into 1 string
|
68 |
ob_start();
|
69 |
echo $xp;
|
70 |
$result[] = trim(ob_get_clean());
|
71 |
+
}
|
72 |
return implode(XmlImportConfig::getInstance()->getMultiGlue(), $result);
|
73 |
} else {
|
74 |
// return null if nothing found
|
libraries/XmlImportTemplateCodeGenerator.php
CHANGED
@@ -122,6 +122,7 @@ class XmlImportTemplateCodeGenerator
|
|
122 |
{
|
123 |
array_push($this->sequenceStack, $sequence);
|
124 |
$result = '';
|
|
|
125 |
if (count($sequence->getVariableDefinitions()) > 0)
|
126 |
{
|
127 |
$result .= $this->openPhpTag();
|
@@ -132,7 +133,7 @@ class XmlImportTemplateCodeGenerator
|
|
132 |
$result .= PHP_EOL;
|
133 |
}
|
134 |
foreach ($sequence->getStatements() as $statement)
|
135 |
-
{
|
136 |
$result .= $this->generateForStatement($statement);
|
137 |
}
|
138 |
array_pop($this->sequenceStack);
|
@@ -182,9 +183,9 @@ class XmlImportTemplateCodeGenerator
|
|
182 |
}
|
183 |
elseif ($statement instanceof XmlImportAstForeach)
|
184 |
{
|
185 |
-
$var = '$x' . $this->xmlVariableNumber++;
|
186 |
-
$result .= PHP_EOL . 'foreach (' . $this->generateForExpression($statement->getXPath()) .
|
187 |
-
' as ' . $var . ') :' . PHP_EOL;
|
188 |
array_push($this->xmlStack, $var);
|
189 |
$result .= $this->generateForSequence($statement->getBody());
|
190 |
$result .= $this->openPhpTag() . PHP_EOL . 'endforeach;' . PHP_EOL;
|
@@ -194,13 +195,14 @@ class XmlImportTemplateCodeGenerator
|
|
194 |
{
|
195 |
$result .= PHP_EOL . 'if (' . $this->generateForExpression($statement->getCondition()) . ') :' . PHP_EOL;
|
196 |
$result .= $this->generateForSequence($statement->getIfBody());
|
|
|
197 |
foreach ($statement->getElseIfs() as $elseif)
|
198 |
{
|
199 |
$result .= $this->openPhpTag() . PHP_EOL . 'elseif (' . $this->generateForExpression($elseif->getCondition()) . ') :' . PHP_EOL;
|
200 |
$result .= $this->generateForSequence($elseif->getBody());
|
201 |
}
|
202 |
if (!is_null($body = $statement->getElseBody()))
|
203 |
-
{
|
204 |
$result .= $this->openPhpTag() . PHP_EOL . 'else :' . PHP_EOL;
|
205 |
$result .= $this->generateForSequence($body);
|
206 |
}
|
@@ -224,7 +226,7 @@ class XmlImportTemplateCodeGenerator
|
|
224 |
|
225 |
switch (get_class($expression))
|
226 |
{
|
227 |
-
case 'XmlImportAstString':
|
228 |
$result = '"' . $this->getEscapedValue($expression->getValue()) . '"';
|
229 |
break;
|
230 |
|
@@ -235,18 +237,18 @@ class XmlImportTemplateCodeGenerator
|
|
235 |
|
236 |
case 'XmlImportAstXPath':
|
237 |
if ($inPrint)
|
238 |
-
{
|
239 |
$variables = $this->sequenceStack[count($this->sequenceStack) - 1]->getVariables();
|
240 |
$result = '$this->getValue(' . $variables[$expression->getValue()] . ')';
|
241 |
}
|
242 |
else
|
243 |
{
|
244 |
-
$variables = $this->sequenceStack[count($this->sequenceStack) - 1]->getVariables();
|
245 |
$result = $variables[$expression->getValue()];
|
246 |
}
|
247 |
break;
|
248 |
|
249 |
-
case 'XmlImportAstFunction':
|
250 |
$result = $this->generateForFunction($expression);
|
251 |
break;
|
252 |
|
@@ -268,7 +270,7 @@ class XmlImportTemplateCodeGenerator
|
|
268 |
* @return string
|
269 |
*/
|
270 |
private function generateForFunction(XmlImportAstFunction $function)
|
271 |
-
{
|
272 |
$result = $function->getName() . '(';
|
273 |
$arguments = $function->getArguments();
|
274 |
|
122 |
{
|
123 |
array_push($this->sequenceStack, $sequence);
|
124 |
$result = '';
|
125 |
+
|
126 |
if (count($sequence->getVariableDefinitions()) > 0)
|
127 |
{
|
128 |
$result .= $this->openPhpTag();
|
133 |
$result .= PHP_EOL;
|
134 |
}
|
135 |
foreach ($sequence->getStatements() as $statement)
|
136 |
+
{
|
137 |
$result .= $this->generateForStatement($statement);
|
138 |
}
|
139 |
array_pop($this->sequenceStack);
|
183 |
}
|
184 |
elseif ($statement instanceof XmlImportAstForeach)
|
185 |
{
|
186 |
+
$var = '$x' . $this->xmlVariableNumber++;
|
187 |
+
$result .= PHP_EOL . 'foreach (' . $this->generateForExpression($statement->getXPath(), false) .
|
188 |
+
' as ' . $var . ') :' . PHP_EOL;
|
189 |
array_push($this->xmlStack, $var);
|
190 |
$result .= $this->generateForSequence($statement->getBody());
|
191 |
$result .= $this->openPhpTag() . PHP_EOL . 'endforeach;' . PHP_EOL;
|
195 |
{
|
196 |
$result .= PHP_EOL . 'if (' . $this->generateForExpression($statement->getCondition()) . ') :' . PHP_EOL;
|
197 |
$result .= $this->generateForSequence($statement->getIfBody());
|
198 |
+
|
199 |
foreach ($statement->getElseIfs() as $elseif)
|
200 |
{
|
201 |
$result .= $this->openPhpTag() . PHP_EOL . 'elseif (' . $this->generateForExpression($elseif->getCondition()) . ') :' . PHP_EOL;
|
202 |
$result .= $this->generateForSequence($elseif->getBody());
|
203 |
}
|
204 |
if (!is_null($body = $statement->getElseBody()))
|
205 |
+
{
|
206 |
$result .= $this->openPhpTag() . PHP_EOL . 'else :' . PHP_EOL;
|
207 |
$result .= $this->generateForSequence($body);
|
208 |
}
|
226 |
|
227 |
switch (get_class($expression))
|
228 |
{
|
229 |
+
case 'XmlImportAstString':
|
230 |
$result = '"' . $this->getEscapedValue($expression->getValue()) . '"';
|
231 |
break;
|
232 |
|
237 |
|
238 |
case 'XmlImportAstXPath':
|
239 |
if ($inPrint)
|
240 |
+
{
|
241 |
$variables = $this->sequenceStack[count($this->sequenceStack) - 1]->getVariables();
|
242 |
$result = '$this->getValue(' . $variables[$expression->getValue()] . ')';
|
243 |
}
|
244 |
else
|
245 |
{
|
246 |
+
$variables = $this->sequenceStack[count($this->sequenceStack) - 1]->getVariables();
|
247 |
$result = $variables[$expression->getValue()];
|
248 |
}
|
249 |
break;
|
250 |
|
251 |
+
case 'XmlImportAstFunction':
|
252 |
$result = $this->generateForFunction($expression);
|
253 |
break;
|
254 |
|
270 |
* @return string
|
271 |
*/
|
272 |
private function generateForFunction(XmlImportAstFunction $function)
|
273 |
+
{
|
274 |
$result = $function->getName() . '(';
|
275 |
$arguments = $function->getArguments();
|
276 |
|
libraries/XmlImportTemplateParser.php
CHANGED
@@ -199,7 +199,7 @@ class XmlImportTemplateParser
|
|
199 |
return $this->parseSpintax();
|
200 |
}
|
201 |
elseif ($this->tokens[$this->index + 1]->getKind() == XmlImportToken::KIND_XPATH)
|
202 |
-
{
|
203 |
$xpath = new XmlImportAstXPath($this->tokens[++$this->index]->getValue());
|
204 |
$this->sequenceStack[count($this->sequenceStack) - 1]->addVariable($xpath);
|
205 |
return $xpath;
|
@@ -347,7 +347,7 @@ class XmlImportTemplateParser
|
|
347 |
if ($this->tokens[$this->index + 1]->getKind() == XmlImportToken::KIND_XPATH)
|
348 |
{
|
349 |
$xpath = new XmlImportAstXPath($this->tokens[++$this->index]->getValue());
|
350 |
-
$this->sequenceStack[count($this->sequenceStack) - 1]->addVariable($xpath);
|
351 |
}
|
352 |
else
|
353 |
throw new XmlImportException("XPath expression expected instead of " . $this->tokens[$this->index + 1]->getKind());
|
@@ -406,8 +406,9 @@ class XmlImportTemplateParser
|
|
406 |
if ($this->tokens[$this->index + 1]->getKind() == XmlImportToken::KIND_CLOSE)
|
407 |
$this->index++;
|
408 |
else
|
409 |
-
throw new XmlImportException("Close brace expected instead of " . $this->tokens[$this->index + 1]->getKind());
|
410 |
$if->addIfBody($this->parseSequence());
|
|
|
411 |
if ($this->index + 1 != count($this->tokens))
|
412 |
{
|
413 |
while ($this->tokens[$this->index + 1]->getKind() == XmlImportToken::KIND_ELSEIF)
|
@@ -426,10 +427,10 @@ class XmlImportTemplateParser
|
|
426 |
$if->addElseif($elseif);
|
427 |
if ($this->index + 1 == count($this->tokens))
|
428 |
break;
|
429 |
-
}
|
430 |
if ($this->index + 1 < count($this->tokens) && $this->tokens[$this->index + 1]->getKind() == XmlImportToken::KIND_ELSE)
|
431 |
{
|
432 |
-
$this->index++;
|
433 |
$if->addElseBody($this->parseSequence());
|
434 |
}
|
435 |
}
|
199 |
return $this->parseSpintax();
|
200 |
}
|
201 |
elseif ($this->tokens[$this->index + 1]->getKind() == XmlImportToken::KIND_XPATH)
|
202 |
+
{
|
203 |
$xpath = new XmlImportAstXPath($this->tokens[++$this->index]->getValue());
|
204 |
$this->sequenceStack[count($this->sequenceStack) - 1]->addVariable($xpath);
|
205 |
return $xpath;
|
347 |
if ($this->tokens[$this->index + 1]->getKind() == XmlImportToken::KIND_XPATH)
|
348 |
{
|
349 |
$xpath = new XmlImportAstXPath($this->tokens[++$this->index]->getValue());
|
350 |
+
$this->sequenceStack[count($this->sequenceStack) - 1]->addVariable($xpath);
|
351 |
}
|
352 |
else
|
353 |
throw new XmlImportException("XPath expression expected instead of " . $this->tokens[$this->index + 1]->getKind());
|
406 |
if ($this->tokens[$this->index + 1]->getKind() == XmlImportToken::KIND_CLOSE)
|
407 |
$this->index++;
|
408 |
else
|
409 |
+
throw new XmlImportException("Close brace expected instead of " . $this->tokens[$this->index + 1]->getKind());
|
410 |
$if->addIfBody($this->parseSequence());
|
411 |
+
|
412 |
if ($this->index + 1 != count($this->tokens))
|
413 |
{
|
414 |
while ($this->tokens[$this->index + 1]->getKind() == XmlImportToken::KIND_ELSEIF)
|
427 |
$if->addElseif($elseif);
|
428 |
if ($this->index + 1 == count($this->tokens))
|
429 |
break;
|
430 |
+
}
|
431 |
if ($this->index + 1 < count($this->tokens) && $this->tokens[$this->index + 1]->getKind() == XmlImportToken::KIND_ELSE)
|
432 |
{
|
433 |
+
$this->index++;
|
434 |
$if->addElseBody($this->parseSequence());
|
435 |
}
|
436 |
}
|
libraries/XmlImportTemplateScanner.php
CHANGED
@@ -259,21 +259,25 @@ final class XmlImportTemplateScanner
|
|
259 |
private function scanName(XmlImportReaderInterface $input)
|
260 |
{
|
261 |
$accum = $input->read();
|
262 |
-
while (preg_match('/[_a-z0-9]/i', $input->peek()))
|
263 |
{
|
264 |
$accum .= $input->read();
|
265 |
if ($input->peek() === false)
|
266 |
throw new XmlImportException("Unexpected end of function or keyword name \"$accum\"");
|
267 |
}
|
|
|
|
|
|
|
|
|
268 |
if (in_array(strtoupper($accum), $this->keywords))
|
269 |
{
|
270 |
return new XmlImportToken(strtoupper($accum));
|
271 |
}
|
272 |
else
|
273 |
-
{
|
274 |
if ($this->isLangBegin)
|
275 |
{
|
276 |
-
$this->isLangBegin = false;
|
277 |
return array(new XmlImportToken(XmlImportToken::KIND_PRINT), new XmlImportToken(XmlImportToken::KIND_FUNCTION, $accum));
|
278 |
}
|
279 |
else
|
259 |
private function scanName(XmlImportReaderInterface $input)
|
260 |
{
|
261 |
$accum = $input->read();
|
262 |
+
while (preg_match('/[_a-z0-9=\s"]/i', $input->peek()))
|
263 |
{
|
264 |
$accum .= $input->read();
|
265 |
if ($input->peek() === false)
|
266 |
throw new XmlImportException("Unexpected end of function or keyword name \"$accum\"");
|
267 |
}
|
268 |
+
if (strpos($accum, "=") !== false or shortcode_exists($accum)){
|
269 |
+
$this->isLangBegin = false;
|
270 |
+
return new XmlImportToken(XmlImportToken::KIND_TEXT, '[' . trim(trim($accum, "["), "]") . ']');
|
271 |
+
}
|
272 |
if (in_array(strtoupper($accum), $this->keywords))
|
273 |
{
|
274 |
return new XmlImportToken(strtoupper($accum));
|
275 |
}
|
276 |
else
|
277 |
+
{
|
278 |
if ($this->isLangBegin)
|
279 |
{
|
280 |
+
$this->isLangBegin = false;
|
281 |
return array(new XmlImportToken(XmlImportToken::KIND_PRINT), new XmlImportToken(XmlImportToken::KIND_FUNCTION, $accum));
|
282 |
}
|
283 |
else
|
libraries/pclzip.lib.php
CHANGED
@@ -190,6 +190,8 @@
|
|
190 |
// extract() : Extract the content of the archive
|
191 |
// properties() : List the properties of the archive
|
192 |
// --------------------------------------------------------------------------------
|
|
|
|
|
193 |
class PclZip
|
194 |
{
|
195 |
// ----- Filename of the zip file
|
@@ -5387,6 +5389,8 @@
|
|
5387 |
// --------------------------------------------------------------------------------
|
5388 |
|
5389 |
}
|
|
|
|
|
5390 |
// End of class
|
5391 |
// --------------------------------------------------------------------------------
|
5392 |
|
@@ -5396,6 +5400,7 @@
|
|
5396 |
// Parameters :
|
5397 |
// Return Values :
|
5398 |
// --------------------------------------------------------------------------------
|
|
|
5399 |
function PclZipUtilPathReduction($p_dir)
|
5400 |
{
|
5401 |
$v_result = "";
|
@@ -5460,6 +5465,8 @@
|
|
5460 |
// ----- Return
|
5461 |
return $v_result;
|
5462 |
}
|
|
|
|
|
5463 |
// --------------------------------------------------------------------------------
|
5464 |
|
5465 |
// --------------------------------------------------------------------------------
|
@@ -5477,6 +5484,7 @@
|
|
5477 |
// 1 if $p_path is inside directory $p_dir
|
5478 |
// 2 if $p_path is exactly the same as $p_dir
|
5479 |
// --------------------------------------------------------------------------------
|
|
|
5480 |
function PclZipUtilPathInclusion($p_dir, $p_path)
|
5481 |
{
|
5482 |
$v_result = 1;
|
@@ -5541,6 +5549,7 @@
|
|
5541 |
// ----- Return
|
5542 |
return $v_result;
|
5543 |
}
|
|
|
5544 |
// --------------------------------------------------------------------------------
|
5545 |
|
5546 |
// --------------------------------------------------------------------------------
|
@@ -5554,6 +5563,7 @@
|
|
5554 |
// 3 : src & dest gzip
|
5555 |
// Return Values :
|
5556 |
// --------------------------------------------------------------------------------
|
|
|
5557 |
function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
|
5558 |
{
|
5559 |
$v_result = 1;
|
@@ -5602,6 +5612,7 @@
|
|
5602 |
// ----- Return
|
5603 |
return $v_result;
|
5604 |
}
|
|
|
5605 |
// --------------------------------------------------------------------------------
|
5606 |
|
5607 |
// --------------------------------------------------------------------------------
|
@@ -5616,6 +5627,7 @@
|
|
5616 |
// Return Values :
|
5617 |
// 1 on success, 0 on failure.
|
5618 |
// --------------------------------------------------------------------------------
|
|
|
5619 |
function PclZipUtilRename($p_src, $p_dest)
|
5620 |
{
|
5621 |
$v_result = 1;
|
@@ -5635,6 +5647,7 @@
|
|
5635 |
// ----- Return
|
5636 |
return $v_result;
|
5637 |
}
|
|
|
5638 |
// --------------------------------------------------------------------------------
|
5639 |
|
5640 |
// --------------------------------------------------------------------------------
|
@@ -5646,6 +5659,7 @@
|
|
5646 |
// Return Values :
|
5647 |
// The option text value.
|
5648 |
// --------------------------------------------------------------------------------
|
|
|
5649 |
function PclZipUtilOptionText($p_option)
|
5650 |
{
|
5651 |
|
@@ -5664,6 +5678,7 @@
|
|
5664 |
|
5665 |
return $v_result;
|
5666 |
}
|
|
|
5667 |
// --------------------------------------------------------------------------------
|
5668 |
|
5669 |
// --------------------------------------------------------------------------------
|
@@ -5677,6 +5692,7 @@
|
|
5677 |
// Return Values :
|
5678 |
// The path translated.
|
5679 |
// --------------------------------------------------------------------------------
|
|
|
5680 |
function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true)
|
5681 |
{
|
5682 |
if (stristr(php_uname(), 'windows')) {
|
@@ -5691,6 +5707,7 @@
|
|
5691 |
}
|
5692 |
return $p_path;
|
5693 |
}
|
|
|
5694 |
// --------------------------------------------------------------------------------
|
5695 |
|
5696 |
|
190 |
// extract() : Extract the content of the archive
|
191 |
// properties() : List the properties of the archive
|
192 |
// --------------------------------------------------------------------------------
|
193 |
+
if (!class_exists('PclZip')):
|
194 |
+
|
195 |
class PclZip
|
196 |
{
|
197 |
// ----- Filename of the zip file
|
5389 |
// --------------------------------------------------------------------------------
|
5390 |
|
5391 |
}
|
5392 |
+
|
5393 |
+
endif;
|
5394 |
// End of class
|
5395 |
// --------------------------------------------------------------------------------
|
5396 |
|
5400 |
// Parameters :
|
5401 |
// Return Values :
|
5402 |
// --------------------------------------------------------------------------------
|
5403 |
+
if (!function_exists('PclZipUtilPathReduction')):
|
5404 |
function PclZipUtilPathReduction($p_dir)
|
5405 |
{
|
5406 |
$v_result = "";
|
5465 |
// ----- Return
|
5466 |
return $v_result;
|
5467 |
}
|
5468 |
+
endif;
|
5469 |
+
|
5470 |
// --------------------------------------------------------------------------------
|
5471 |
|
5472 |
// --------------------------------------------------------------------------------
|
5484 |
// 1 if $p_path is inside directory $p_dir
|
5485 |
// 2 if $p_path is exactly the same as $p_dir
|
5486 |
// --------------------------------------------------------------------------------
|
5487 |
+
if (!function_exists('PclZipUtilPathInclusion')):
|
5488 |
function PclZipUtilPathInclusion($p_dir, $p_path)
|
5489 |
{
|
5490 |
$v_result = 1;
|
5549 |
// ----- Return
|
5550 |
return $v_result;
|
5551 |
}
|
5552 |
+
endif;
|
5553 |
// --------------------------------------------------------------------------------
|
5554 |
|
5555 |
// --------------------------------------------------------------------------------
|
5563 |
// 3 : src & dest gzip
|
5564 |
// Return Values :
|
5565 |
// --------------------------------------------------------------------------------
|
5566 |
+
if (!function_exists('PclZipUtilCopyBlock')):
|
5567 |
function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
|
5568 |
{
|
5569 |
$v_result = 1;
|
5612 |
// ----- Return
|
5613 |
return $v_result;
|
5614 |
}
|
5615 |
+
endif;
|
5616 |
// --------------------------------------------------------------------------------
|
5617 |
|
5618 |
// --------------------------------------------------------------------------------
|
5627 |
// Return Values :
|
5628 |
// 1 on success, 0 on failure.
|
5629 |
// --------------------------------------------------------------------------------
|
5630 |
+
if (!function_exists('PclZipUtilRename')):
|
5631 |
function PclZipUtilRename($p_src, $p_dest)
|
5632 |
{
|
5633 |
$v_result = 1;
|
5647 |
// ----- Return
|
5648 |
return $v_result;
|
5649 |
}
|
5650 |
+
endif;
|
5651 |
// --------------------------------------------------------------------------------
|
5652 |
|
5653 |
// --------------------------------------------------------------------------------
|
5659 |
// Return Values :
|
5660 |
// The option text value.
|
5661 |
// --------------------------------------------------------------------------------
|
5662 |
+
if (!function_exists('PclZipUtilOptionText')):
|
5663 |
function PclZipUtilOptionText($p_option)
|
5664 |
{
|
5665 |
|
5678 |
|
5679 |
return $v_result;
|
5680 |
}
|
5681 |
+
endif;
|
5682 |
// --------------------------------------------------------------------------------
|
5683 |
|
5684 |
// --------------------------------------------------------------------------------
|
5692 |
// Return Values :
|
5693 |
// The path translated.
|
5694 |
// --------------------------------------------------------------------------------
|
5695 |
+
if (!function_exists('PclZipUtilTranslateWinPath')):
|
5696 |
function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true)
|
5697 |
{
|
5698 |
if (stristr(php_uname(), 'windows')) {
|
5707 |
}
|
5708 |
return $p_path;
|
5709 |
}
|
5710 |
+
endif;
|
5711 |
// --------------------------------------------------------------------------------
|
5712 |
|
5713 |
|
models/import/record.php
CHANGED
@@ -8,12 +8,12 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
8 |
*/
|
9 |
public static function preprocessXml( & $xml) {
|
10 |
|
11 |
-
$xml = str_replace("&", "&", str_replace("&","&", $xml));
|
12 |
|
13 |
}
|
14 |
|
15 |
/**
|
16 |
-
* Validate XML to be valid for
|
17 |
* @param string $xml
|
18 |
* @param WP_Error[optional] $errors
|
19 |
* @return bool Validation status
|
@@ -78,7 +78,6 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
78 |
$this->options += PMXI_Plugin::get_default_import_options(); // make sure all options are defined
|
79 |
|
80 |
$avoid_pingbacks = PMXI_Plugin::getInstance()->getOption('pingbacks');
|
81 |
-
$legacy_handling = PMXI_Plugin::getInstance()->getOption('legacy_special_character_handling');
|
82 |
|
83 |
if ( $avoid_pingbacks and ! defined( 'WP_IMPORTING' ) ) define( 'WP_IMPORTING', true );
|
84 |
|
@@ -87,6 +86,8 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
87 |
$tmp_files = array();
|
88 |
// compose records to import
|
89 |
$records = array();
|
|
|
|
|
90 |
|
91 |
try {
|
92 |
|
@@ -100,7 +101,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
100 |
}
|
101 |
else{
|
102 |
count($titles) and $post_excerpt = array_fill(0, count($titles), '');
|
103 |
-
}
|
104 |
|
105 |
if ( "xpath" == $this->options['status'] ){
|
106 |
$chunk == 1 and $logger and call_user_func($logger, __('Composing statuses...', 'pmxi_plugin'));
|
@@ -120,7 +121,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
120 |
if (!empty($this->options['author'])){
|
121 |
$post_author = XmlImportParser::factory($xml, $cxpath, $this->options['author'], $file)->parse($records); $tmp_files[] = $file;
|
122 |
foreach ($post_author as $key => $author) {
|
123 |
-
$user = get_user_by('login', $author) or $user = get_user_by('slug', $author) or $user = get_user_by('email', $author) or ctype_digit($author) and $user = get_user_by('id', $author);
|
124 |
$post_author[$key] = (!empty($user)) ? $user->ID : $current_user->ID;
|
125 |
}
|
126 |
}
|
@@ -139,7 +140,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
139 |
|
140 |
$chunk == 1 and $logger and call_user_func($logger, __('Composing contents...', 'pmxi_plugin'));
|
141 |
$contents = XmlImportParser::factory(
|
142 |
-
(intval($this->template['is_keep_linebreaks']) ? $xml : preg_replace('%\r\n?|\n%', ' ', $xml)),
|
143 |
$cxpath,
|
144 |
$this->template['content'],
|
145 |
$file)->parse($records
|
@@ -223,18 +224,26 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
223 |
if ($value->item_id == $category->parent_id and !empty($value->cat_ids[$i])){
|
224 |
foreach ($value->cat_ids[$i] as $parent) {
|
225 |
if (!$j or !$this->options['categories_auto_nested']){
|
226 |
-
|
|
|
227 |
'name' => trim($cc),
|
228 |
'parent' => (is_array($parent)) ? $parent['name'] : $parent, // if parent taxonomy exists then return ID else return TITLE
|
229 |
'assign' => $category->assign
|
230 |
-
);
|
|
|
|
|
|
|
231 |
}
|
232 |
elseif($this->options['categories_auto_nested']){
|
233 |
-
|
|
|
234 |
'name' => trim($cc),
|
235 |
-
'parent' => (!empty($delimeted_categories[$j - 1])) ? trim($delimeted_categories[$j - 1]) : false, // if parent taxonomy exists then return ID else return TITLE
|
236 |
'assign' => $category->assign
|
237 |
-
);
|
|
|
|
|
|
|
238 |
}
|
239 |
}
|
240 |
}
|
@@ -242,23 +251,31 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
242 |
}
|
243 |
else {
|
244 |
if (!$j or !$this->options['categories_auto_nested']){
|
245 |
-
|
|
|
246 |
'name' => trim($cc),
|
247 |
'parent' => false,
|
248 |
'assign' => $category->assign
|
249 |
-
);
|
|
|
|
|
|
|
250 |
}
|
251 |
elseif ($this->options['categories_auto_nested']){
|
252 |
-
|
|
|
253 |
'name' => trim($cc),
|
254 |
-
'parent' => (!empty($delimeted_categories[$j - 1])) ? trim($delimeted_categories[$j - 1]) : false,
|
255 |
'assign' => $category->assign
|
256 |
-
);
|
|
|
|
|
|
|
257 |
}
|
258 |
|
259 |
}
|
260 |
}
|
261 |
-
if ($count_cats < count($cats[$i])) $categories_hierarchy[$k]->cat_ids[$i][] = $cats[$i][count($cats[$i]) - 1];
|
262 |
}
|
263 |
endforeach;
|
264 |
} else{
|
@@ -305,18 +322,26 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
305 |
if ($value->item_id == $taxonomy->parent_id and !empty($value->txn_names[$i])){
|
306 |
foreach ($value->txn_names[$i] as $parent) {
|
307 |
if (!$j or !$taxonomy->auto_nested){
|
308 |
-
|
|
|
309 |
'name' => trim($cc),
|
310 |
'parent' => $parent,
|
311 |
'assign' => $taxonomy->assign
|
312 |
-
);
|
|
|
|
|
|
|
313 |
}
|
314 |
elseif ($taxonomy->auto_nested){
|
315 |
-
|
|
|
316 |
'name' => trim($cc),
|
317 |
-
'parent' => (!empty($delimeted_taxonomies[$j - 1])) ? trim($delimeted_taxonomies[$j - 1]) : false,
|
318 |
'assign' => $taxonomy->assign
|
319 |
-
);
|
|
|
|
|
|
|
320 |
}
|
321 |
}
|
322 |
}
|
@@ -325,62 +350,51 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
325 |
}
|
326 |
else {
|
327 |
if (!$j or !$taxonomy->auto_nested){
|
328 |
-
|
|
|
329 |
'name' => trim($cc),
|
330 |
'parent' => false,
|
331 |
'assign' => $taxonomy->assign
|
332 |
-
);
|
|
|
|
|
|
|
333 |
}
|
334 |
elseif ($taxonomy->auto_nested) {
|
335 |
-
|
|
|
336 |
'name' => trim($cc),
|
337 |
-
'parent' => (!empty($delimeted_taxonomies[$j - 1])) ? trim($delimeted_taxonomies[$j - 1]) : false,
|
338 |
'assign' => $taxonomy->assign
|
339 |
-
);
|
|
|
|
|
|
|
340 |
}
|
341 |
}
|
342 |
}
|
343 |
-
if ($count_cats < count($taxonomies[$tx_name][$i])) $taxonomies_hierarchy[$k]->txn_names[$i][] = $taxonomies[$tx_name][$i][count($taxonomies[$tx_name][$i]) - 1];
|
344 |
}
|
345 |
}
|
346 |
}
|
347 |
}; endif;
|
348 |
-
// [/custom taxonomies]
|
349 |
|
350 |
// serialized featured images
|
351 |
if ( ! (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
|
352 |
$logger and call_user_func($logger, __('<b>WARNING</b>', 'pmxi_plugin') . ': ' . $uploads['error']);
|
353 |
$logger and call_user_func($logger, __('<b>WARNING</b>: No featured images will be created', 'pmxi_plugin'));
|
354 |
-
PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
|
355 |
} else {
|
356 |
$chunk == 1 and $logger and call_user_func($logger, __('Composing URLs for featured images...', 'pmxi_plugin'));
|
357 |
$featured_images = array();
|
358 |
-
if ($this->options['featured_image']) {
|
359 |
-
|
360 |
-
$imgs = ( "" == $this->options['featured_delim']) ? explode("\n", $this->options['featured_image']) : explode(',',$this->options['featured_image']);
|
361 |
-
if (!empty($imgs)){
|
362 |
-
$parse_multiple = true;
|
363 |
-
foreach($imgs as $img) if (!preg_match("/{.*}/", trim($img))) $parse_multiple = false;
|
364 |
-
|
365 |
-
if ($parse_multiple)
|
366 |
-
{
|
367 |
-
foreach($imgs as $img)
|
368 |
-
{
|
369 |
-
$posts_images = XmlImportParser::factory($xml, $cxpath, trim($img), $file)->parse($records); $tmp_files[] = $file;
|
370 |
-
foreach($posts_images as $i => $val) $featured_images[$i][] = $val;
|
371 |
-
}
|
372 |
-
}
|
373 |
-
else
|
374 |
-
{
|
375 |
-
$featured_images = XmlImportParser::factory($xml, $cxpath, $this->options['featured_image'], $file)->parse($records); $tmp_files[] = $file;
|
376 |
-
}
|
377 |
-
}
|
378 |
-
|
379 |
} else {
|
380 |
count($titles) and $featured_images = array_fill(0, count($titles), '');
|
381 |
}
|
382 |
}
|
383 |
-
|
384 |
// serialized images meta data
|
385 |
if ( $this->options['set_image_meta_data'] ){
|
386 |
$uploads = wp_upload_dir();
|
@@ -389,28 +403,8 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
389 |
$chunk == 1 and $logger and call_user_func($logger, __('Composing image meta data (titles)...', 'pmxi_plugin'));
|
390 |
$image_meta_titles = array();
|
391 |
|
392 |
-
if ($this->options['image_meta_title']) {
|
393 |
-
|
394 |
-
$imgs = ( "" == $this->options['image_meta_title_delim']) ? explode("\n",$this->options['image_meta_title']) : explode(',',$this->options['image_meta_title']);
|
395 |
-
|
396 |
-
if (!empty($imgs)){
|
397 |
-
$parse_multiple = true;
|
398 |
-
foreach($imgs as $img) if (!preg_match("/{.*}/", trim($img))) $parse_multiple = false;
|
399 |
-
|
400 |
-
if ($parse_multiple)
|
401 |
-
{
|
402 |
-
foreach($imgs as $img)
|
403 |
-
{
|
404 |
-
$posts_images = XmlImportParser::factory($xml, $cxpath, trim($img), $file)->parse($records); $tmp_files[] = $file;
|
405 |
-
foreach($posts_images as $i => $val) $image_meta_titles[$i][] = $val;
|
406 |
-
}
|
407 |
-
}
|
408 |
-
else
|
409 |
-
{
|
410 |
-
$image_meta_titles = XmlImportParser::factory($xml, $cxpath, $this->options['image_meta_title'], $file)->parse($records); $tmp_files[] = $file;
|
411 |
-
}
|
412 |
-
}
|
413 |
-
|
414 |
} else {
|
415 |
count($titles) and $image_meta_titles = array_fill(0, count($titles), '');
|
416 |
}
|
@@ -418,81 +412,24 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
418 |
// serialized images meta captions
|
419 |
$chunk == 1 and $logger and call_user_func($logger, __('Composing image meta data (captions)...', 'pmxi_plugin'));
|
420 |
$image_meta_captions = array();
|
421 |
-
if ($this->options['image_meta_caption']) {
|
422 |
-
|
423 |
-
$imgs = ( "" == $this->options['image_meta_caption_delim']) ? explode("\n",$this->options['image_meta_caption']) : explode(',',$this->options['image_meta_caption']);
|
424 |
-
if (!empty($imgs)){
|
425 |
-
$parse_multiple = true;
|
426 |
-
foreach($imgs as $img) if (!preg_match("/{.*}/", trim($img))) $parse_multiple = false;
|
427 |
-
|
428 |
-
if ($parse_multiple)
|
429 |
-
{
|
430 |
-
foreach($imgs as $img)
|
431 |
-
{
|
432 |
-
$posts_images = XmlImportParser::factory($xml, $cxpath, trim($img), $file)->parse($records); $tmp_files[] = $file;
|
433 |
-
foreach($posts_images as $i => $val) $image_meta_captions[$i][] = $val;
|
434 |
-
}
|
435 |
-
}
|
436 |
-
else
|
437 |
-
{
|
438 |
-
$image_meta_captions = XmlImportParser::factory($xml, $cxpath, $this->options['image_meta_caption'], $file)->parse($records); $tmp_files[] = $file;
|
439 |
-
}
|
440 |
-
}
|
441 |
-
|
442 |
} else {
|
443 |
count($titles) and $image_meta_captions = array_fill(0, count($titles), '');
|
444 |
}
|
445 |
// serialized images meta alt text
|
446 |
$chunk == 1 and $logger and call_user_func($logger, __('Composing image meta data (alt text)...', 'pmxi_plugin'));
|
447 |
$image_meta_alts = array();
|
448 |
-
if ($this->options['image_meta_alt']) {
|
449 |
-
|
450 |
-
$imgs = ( "" == $this->options['image_meta_alt_delim']) ? explode("\n",$this->options['image_meta_alt']) : explode(',',$this->options['image_meta_alt']);
|
451 |
-
if (!empty($imgs)){
|
452 |
-
$parse_multiple = true;
|
453 |
-
foreach($imgs as $img) if (!preg_match("/{.*}/", trim($img))) $parse_multiple = false;
|
454 |
-
|
455 |
-
if ($parse_multiple)
|
456 |
-
{
|
457 |
-
foreach($imgs as $img)
|
458 |
-
{
|
459 |
-
$posts_images = XmlImportParser::factory($xml, $cxpath, trim($img), $file)->parse($records); $tmp_files[] = $file;
|
460 |
-
foreach($posts_images as $i => $val) $image_meta_alts[$i][] = $val;
|
461 |
-
}
|
462 |
-
}
|
463 |
-
else
|
464 |
-
{
|
465 |
-
$image_meta_alts = XmlImportParser::factory($xml, $cxpath, $this->options['image_meta_alt'], $file)->parse($records); $tmp_files[] = $file;
|
466 |
-
}
|
467 |
-
}
|
468 |
-
|
469 |
} else {
|
470 |
count($titles) and $image_meta_alts = array_fill(0, count($titles), '');
|
471 |
}
|
472 |
// serialized images meta description
|
473 |
$chunk == 1 and $logger and call_user_func($logger, __('Composing image meta data (description)...', 'pmxi_plugin'));
|
474 |
$image_meta_descriptions = array();
|
475 |
-
if ($this->options['image_meta_description']) {
|
476 |
-
|
477 |
-
$imgs = ( "" == $this->options['image_meta_description_delim']) ? explode("\n",$this->options['image_meta_description']) : explode(',',$this->options['image_meta_description']);
|
478 |
-
if (!empty($imgs)){
|
479 |
-
$parse_multiple = true;
|
480 |
-
foreach($imgs as $img) if (!preg_match("/{.*}/", trim($img))) $parse_multiple = false;
|
481 |
-
|
482 |
-
if ($parse_multiple)
|
483 |
-
{
|
484 |
-
foreach($imgs as $img)
|
485 |
-
{
|
486 |
-
$posts_images = XmlImportParser::factory($xml, $cxpath, trim($img), $file)->parse($records); $tmp_files[] = $file;
|
487 |
-
foreach($posts_images as $i => $val) $image_meta_descriptions[$i][] = $val;
|
488 |
-
}
|
489 |
-
}
|
490 |
-
else
|
491 |
-
{
|
492 |
-
$image_meta_descriptions = XmlImportParser::factory($xml, $cxpath, $this->options['image_meta_description'], $file)->parse($records); $tmp_files[] = $file;
|
493 |
-
}
|
494 |
-
}
|
495 |
-
|
496 |
} else {
|
497 |
count($titles) and $image_meta_descriptions = array_fill(0, count($titles), '');
|
498 |
}
|
@@ -558,23 +495,27 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
558 |
$addons_data = array();
|
559 |
|
560 |
// data parsing for WP All Import add-ons
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
);
|
571 |
-
|
572 |
-
|
573 |
-
|
|
|
|
|
|
|
|
|
|
|
574 |
}
|
575 |
|
576 |
-
// save current import state to variables before import
|
577 |
-
$current_post_ids = (!empty($this->current_post_ids)) ? json_decode($this->current_post_ids, true) : array();
|
578 |
$created = $this->created;
|
579 |
$updated = $this->updated;
|
580 |
$skipped = $this->skipped;
|
@@ -591,7 +532,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
591 |
}
|
592 |
}
|
593 |
|
594 |
-
}
|
595 |
|
596 |
foreach ($titles as $i => $void) {
|
597 |
|
@@ -600,33 +541,33 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
600 |
do_action('pmxi_before_post_import', $this->id);
|
601 |
|
602 |
if (empty($titles[$i])) {
|
603 |
-
if ($addons_data['PMWI_Plugin'] and !empty($addons_data['PMWI_Plugin']['single_product_parent_ID'][$i])){
|
604 |
$titles[$i] = $addons_data['PMWI_Plugin']['single_product_parent_ID'][$i] . ' Product Variation';
|
605 |
}
|
606 |
else{
|
607 |
$skipped++;
|
608 |
$logger and call_user_func($logger, __('<b>SKIPPED</b>: by empty title', 'pmxi_plugin'));
|
609 |
-
PMXI_Plugin::$session['pmxi_import']['chunk_number'] = ++PMXI_Plugin::$session->data['pmxi_import']['chunk_number'];
|
610 |
-
PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
|
611 |
pmxi_session_commit();
|
612 |
continue;
|
613 |
}
|
614 |
}
|
615 |
-
|
616 |
$articleData = array(
|
617 |
'post_type' => $post_type,
|
618 |
'post_status' => ("xpath" == $this->options['status']) ? $post_status[$i] : $this->options['status'],
|
619 |
'comment_status' => $this->options['comment_status'],
|
620 |
'ping_status' => $this->options['ping_status'],
|
621 |
-
'post_title' => ($this->template['is_leave_html']) ? html_entity_decode($titles[$i]) : $titles[$i],
|
622 |
-
'post_excerpt' => ($this->template['is_leave_html']) ? html_entity_decode($post_excerpt[$i]) : $post_excerpt[$i],
|
623 |
'post_name' => $post_slug[$i],
|
624 |
-
'post_content' => ($this->template['is_leave_html']) ? html_entity_decode($contents[$i]) : $contents[$i],
|
625 |
'post_date' => $dates[$i],
|
626 |
'post_date_gmt' => get_gmt_from_date($dates[$i]),
|
627 |
'post_author' => $post_author[$i],
|
628 |
'tags_input' => $tags[$i]
|
629 |
-
);
|
630 |
|
631 |
if ('post' != $articleData['post_type']){
|
632 |
$articleData += array(
|
@@ -641,13 +582,13 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
641 |
// if Auto Matching re-import option selected
|
642 |
if ("manual" != $this->options['duplicate_matching']){
|
643 |
|
644 |
-
// find corresponding article among previously imported
|
645 |
-
|
646 |
$postRecord->clear();
|
647 |
$postRecord->getBy(array(
|
648 |
'unique_key' => $unique_keys[$i],
|
649 |
'import_id' => $this->id,
|
650 |
));
|
|
|
651 |
if ( ! $postRecord->isEmpty() )
|
652 |
$post_to_update = get_post($post_to_update_id = $postRecord->post_id);
|
653 |
|
@@ -666,22 +607,25 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
666 |
$custom_duplicate_name = XmlImportParser::factory($xml, $cxpath, $this->options['custom_duplicate_name'], $file)->parse($records); $tmp_files[] = $file;
|
667 |
}
|
668 |
else{
|
669 |
-
count($titles) and $custom_duplicate_name = $custom_duplicate_value = array_fill(0, count($titles), '');
|
670 |
}
|
671 |
|
672 |
// handle duplicates according to import settings
|
673 |
if ($duplicates = pmxi_findDuplicates($articleData, $custom_duplicate_name[$i], $custom_duplicate_value[$i], $this->options['duplicate_indicator'])) {
|
674 |
$duplicate_id = array_shift($duplicates);
|
|
|
675 |
if ($duplicate_id) {
|
676 |
$post_to_update = get_post($post_to_update_id = $duplicate_id);
|
677 |
}
|
678 |
-
}
|
679 |
}
|
680 |
|
681 |
if (!empty($specified_records)){
|
682 |
if ( ! in_array($created + $updated + $skipped + 1, $specified_records) ){
|
683 |
-
|
684 |
-
if ( !
|
|
|
|
|
685 |
$logger and call_user_func($logger, __('<b>SKIPPED</b>: by specified records option', 'pmxi_plugin'));
|
686 |
$logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
|
687 |
$logger and PMXI_Plugin::$session['pmxi_import']['chunk_number'] = ++PMXI_Plugin::$session->data['pmxi_import']['chunk_number'];
|
@@ -694,13 +638,12 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
694 |
if ($post_to_update){
|
695 |
|
696 |
// Do not update already existing records option selected
|
697 |
-
if ("yes" == $this->options['is_keep_former_posts']) {
|
698 |
-
|
699 |
-
if ( !
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
$skipped++;
|
705 |
$logger and call_user_func($logger, sprintf(__('<b>SKIPPED</b>: Previously imported record found for `%s`', 'pmxi_plugin'), $articleData['post_title']));
|
706 |
$logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
|
@@ -709,7 +652,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
709 |
continue;
|
710 |
}
|
711 |
|
712 |
-
$articleData['ID'] = $post_to_update_id;
|
713 |
// Choose which data to update
|
714 |
if ( $this->options['update_all_data'] == 'no' ){
|
715 |
// preserve date of already existing article when duplicate is found
|
@@ -810,13 +753,17 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
810 |
|
811 |
// no new records are created. it will only update posts it finds matching duplicates for
|
812 |
if ( ! $this->options['create_new_records'] and empty($articleData['ID'])){
|
|
|
|
|
|
|
|
|
813 |
$logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
|
814 |
$logger and PMXI_Plugin::$session['pmxi_import']['chunk_number'] = ++PMXI_Plugin::$session->data['pmxi_import']['chunk_number'];
|
815 |
$skipped++;
|
816 |
pmxi_session_commit();
|
817 |
continue;
|
818 |
}
|
819 |
-
|
820 |
// cloak urls with `WP Wizard Cloak` if corresponding option is set
|
821 |
if ( ! empty($this->options['is_cloak']) and class_exists('PMLC_Plugin')) {
|
822 |
if (preg_match_all('%<a\s[^>]*href=(?(?=")"([^"]*)"|(?(?=\')\'([^\']*)\'|([^\s>]*)))%is', $articleData['post_content'], $matches, PREG_PATTERN_ORDER)) {
|
@@ -892,26 +839,26 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
892 |
}
|
893 |
}
|
894 |
}
|
895 |
-
}
|
896 |
|
897 |
// insert article being imported
|
898 |
$pid = ($this->options['is_fast_mode']) ? pmxi_insert_post($articleData, true) : wp_insert_post($articleData, true);
|
899 |
-
|
900 |
if (is_wp_error($pid)) {
|
901 |
$logger and call_user_func($logger, __('<b>ERROR</b>', 'pmxi_plugin') . ': ' . $pid->get_error_message());
|
902 |
$logger and PMXI_Plugin::$session['pmxi_import']['errors'] = ++PMXI_Plugin::$session->data['pmxi_import']['errors'];
|
903 |
} else {
|
904 |
-
|
905 |
-
if ( ! in_array($pid, $current_post_ids) ) $current_post_ids[] = $pid;
|
906 |
-
|
907 |
if ("manual" != $this->options['duplicate_matching'] or empty($articleData['ID'])){
|
908 |
-
// associate post with import
|
909 |
$postRecord->isEmpty() and $postRecord->set(array(
|
910 |
'post_id' => $pid,
|
911 |
'import_id' => $this->id,
|
912 |
'unique_key' => $unique_keys[$i],
|
913 |
-
'product_key' => ($post_type == "product" and PMXI_Admin_Addons::get_addon('PMWI_Plugin')) ? $addons_data['PMWI_Plugin']['single_product_ID'][$i] : ''
|
914 |
))->insert();
|
|
|
|
|
915 |
}
|
916 |
|
917 |
// [post format]
|
@@ -955,6 +902,36 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
955 |
|
956 |
}
|
957 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
958 |
|
959 |
}
|
960 |
// [/custom fields]
|
@@ -974,7 +951,15 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
974 |
);
|
975 |
|
976 |
// deligate operation to addons
|
977 |
-
foreach (PMXI_Admin_Addons::get_active_addons() as $class)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
978 |
|
979 |
// [/addons import]
|
980 |
|
@@ -984,141 +969,117 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
984 |
// [featured image]
|
985 |
if ( ! empty($uploads) and false === $uploads['error'] and !empty($featured_images[$i]) and (empty($articleData['ID']) or $this->options['update_all_data'] == "yes" or ( $this->options['update_all_data'] == "no" and $this->options['is_update_images']))) {
|
986 |
|
987 |
-
require_once(ABSPATH . 'wp-admin/includes/image.php');
|
988 |
-
|
989 |
-
if ( ! is_array($featured_images[$i]) ) $featured_images[$i] = array($featured_images[$i]);
|
990 |
-
if ( ! is_array($image_meta_titles[$i]) ) $image_meta_titles[$i] = array($image_meta_titles[$i]);
|
991 |
-
if ( ! is_array($image_meta_captions[$i]) ) $image_meta_captions[$i] = array($image_meta_captions[$i]);
|
992 |
-
if ( ! is_array($image_meta_descriptions[$i]) ) $image_meta_descriptions[$i] = array($image_meta_descriptions[$i]);
|
993 |
|
994 |
$success_images = false;
|
995 |
$gallery_attachment_ids = array();
|
996 |
|
997 |
$_pmxi_images = array();
|
|
|
|
|
|
|
|
|
998 |
|
999 |
-
foreach ($featured_images[$i] as $k => $featured_image)
|
1000 |
-
{
|
1001 |
-
$imgs = ( ! empty($this->options['featured_delim']) ) ? str_getcsv($featured_image, $this->options['featured_delim']) : explode("\n", $featured_image);
|
1002 |
if ( $this->options['set_image_meta_data'] ){
|
1003 |
-
$img_titles = ( ! empty($this->options['image_meta_title_delim']) ) ? str_getcsv($image_meta_titles[$i]
|
1004 |
-
$img_captions = ( ! empty($this->options['image_meta_caption_delim']) ) ? str_getcsv($image_meta_captions[$i]
|
1005 |
-
$img_alts = ( ! empty($this->options['image_meta_alt_delim']) ) ? str_getcsv($image_meta_alts[$i]
|
1006 |
-
$img_descriptions = ( ! empty($this->options['image_meta_description_delim']) ) ? str_getcsv($image_meta_descriptions[$i]
|
1007 |
-
}
|
1008 |
-
if (!empty($imgs)) {
|
1009 |
-
|
1010 |
-
foreach ($imgs as $img_key => $img_url) { if (empty($img_url)) continue;
|
1011 |
|
1012 |
-
|
1013 |
-
$img_ext = pmxi_getExtensionFromStr($url);
|
1014 |
-
if ($img_ext == "") $img_ext = pmxi_get_remote_image_ext($url);
|
1015 |
|
1016 |
-
|
|
|
|
|
|
|
|
|
1017 |
|
1018 |
-
|
1019 |
-
$
|
1020 |
-
$download_image = true;
|
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 |
-
$download_image = false;
|
1055 |
-
$success_images = true;
|
1056 |
-
if ( ! has_post_thumbnail($pid) )
|
1057 |
-
set_post_thumbnail($pid, $attachment_img->ID);
|
1058 |
-
else
|
1059 |
-
$gallery_attachment_ids[] = $attachment_img->ID;
|
1060 |
-
|
1061 |
-
$logger and call_user_func($logger, sprintf(__('<b>Image SKIPPED</b>: The image %s is always exists for the %s', 'pmxi_plugin'), basename($attachment_img->guid), $articleData['post_title']));
|
1062 |
-
}
|
1063 |
-
}
|
1064 |
-
}
|
1065 |
|
|
|
|
|
|
|
1066 |
}
|
1067 |
|
1068 |
-
|
1069 |
-
|
1070 |
-
// do not download images
|
1071 |
-
if ( ! $this->options['download_images'] ){
|
1072 |
|
1073 |
-
|
1074 |
-
$image_filepath = $uploads['path'] . '/' . url_title( $image_filename );
|
1075 |
-
|
1076 |
-
$existing_attachment = $this->wpdb->get_row( $this->wpdb->prepare( "SELECT * FROM " . $this->wpdb->prefix ."posts WHERE guid = '%s'", $image_filepath ) );
|
1077 |
|
1078 |
-
|
|
|
1079 |
|
1080 |
-
|
1081 |
-
|
|
|
|
|
|
|
|
|
1082 |
|
1083 |
-
|
1084 |
-
|
1085 |
-
else
|
1086 |
-
$gallery_attachment_ids[] = $existing_attachment->ID;
|
1087 |
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
$download_image = false;
|
1093 |
-
if( ! ($image_info = @getimagesize($image_filepath)) or ! in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
|
1094 |
-
$logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: File %s is not a valid image and cannot be set as featured one', 'pmxi_plugin'), $image_filepath));
|
1095 |
-
$logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
|
1096 |
-
@unlink($image_filepath);
|
1097 |
-
} else {
|
1098 |
-
$create_image = true;
|
1099 |
-
}
|
1100 |
-
}
|
1101 |
-
}
|
1102 |
-
}
|
1103 |
|
1104 |
-
|
1105 |
|
1106 |
-
|
1107 |
-
|
1108 |
-
} elseif( ($image_info = @getimagesize($image_filepath)) and in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
|
1109 |
-
$create_image = true;
|
1110 |
-
}
|
1111 |
|
1112 |
-
if (
|
1113 |
-
|
1114 |
-
$
|
1115 |
-
|
1116 |
-
if ( ! get_file_curl($url, $image_filepath) and ! @file_put_contents($image_filepath, @file_get_contents($url))) {
|
1117 |
-
$logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: File %s cannot be saved locally as %s', 'pmxi_plugin'), $url, $image_filepath));
|
1118 |
-
$logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
|
1119 |
-
@unlink($image_filepath); // delete file since failed upload may result in empty file created
|
1120 |
-
} elseif( ! ($image_info = @getimagesize($image_filepath)) or ! in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
|
1121 |
-
$logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: File %s is not a valid image and cannot be set as featured one', 'pmxi_plugin'), $url));
|
1122 |
$logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
|
1123 |
@unlink($image_filepath);
|
1124 |
} else {
|
@@ -1126,57 +1087,88 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
1126 |
}
|
1127 |
}
|
1128 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1129 |
}
|
1130 |
}
|
|
|
1131 |
|
1132 |
-
|
1133 |
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
|
|
1146 |
|
1147 |
-
|
1148 |
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1157 |
|
1158 |
-
if ( $this->
|
1159 |
-
|
1160 |
-
|
1161 |
-
if ( ! empty($img_captions[$img_key]) ) $update_attachment_meta['post_excerpt'] = $img_captions[$img_key];
|
1162 |
-
if ( ! empty($img_descriptions[$img_key]) ) $update_attachment_meta['post_content'] = $img_descriptions[$img_key];
|
1163 |
-
if ( ! empty($img_alts[$img_key]) ) update_post_meta($attid, '_wp_attachment_image_alt', $img_alts[$img_key]);
|
1164 |
-
|
1165 |
-
if ( ! empty($update_attachment_meta)) $this->wpdb->update( $this->wpdb->posts, $update_attachment_meta, array('ID' => $attid) );
|
1166 |
-
|
1167 |
-
}
|
1168 |
|
1169 |
-
|
1170 |
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
}
|
1180 |
}
|
1181 |
// Set product gallery images
|
1182 |
if ( $post_type == "product" and !empty($gallery_attachment_ids) )
|
@@ -1200,13 +1192,18 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
1200 |
$atchs = str_getcsv($attachment, $this->options['atch_delim']);
|
1201 |
|
1202 |
if (!empty($atchs)) {
|
1203 |
-
foreach ($atchs as $atch_url) { if (empty($atch_url)) continue;
|
1204 |
|
1205 |
-
$
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
|
|
|
|
|
|
|
|
1209 |
$logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Attachment file %s cannot be saved locally as %s', 'pmxi_plugin'), trim($atch_url), $attachment_filepath));
|
|
|
1210 |
$logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
|
1211 |
unlink($attachment_filepath); // delete file since failed upload may result in empty file created
|
1212 |
} elseif( ! $wp_filetype = wp_check_filetype(basename($attachment_filename), null )) {
|
@@ -1219,7 +1216,8 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
1219 |
'post_mime_type' => $wp_filetype['type'],
|
1220 |
'post_title' => preg_replace('/\.[^.]+$/', '', basename($attachment_filepath)),
|
1221 |
'post_content' => '',
|
1222 |
-
'post_status' => 'inherit'
|
|
|
1223 |
);
|
1224 |
$attach_id = ($this->options['is_fast_mode']) ? pmxi_insert_attachment( $attachment_data, $attachment_filepath, $pid ) : wp_insert_attachment( $attachment_data, $attachment_filepath, $pid );
|
1225 |
|
@@ -1359,14 +1357,13 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
1359 |
$parent_id = (!empty($single_cat['parent'])) ? pmxi_recursion_taxes($single_cat['parent'], 'category', $cats[$i], $key) : '';
|
1360 |
|
1361 |
$term = is_exists_term('category', $single_cat['name'], (int)$parent_id);
|
1362 |
-
|
1363 |
-
if ( empty($term) and !is_wp_error($term) ){
|
1364 |
-
$term_attr = array('parent'=> (!empty($parent_id)) ? $parent_id : 0);
|
1365 |
$term = wp_insert_term(
|
1366 |
$single_cat['name'], // the term
|
1367 |
'category', // the taxonomy
|
1368 |
-
$
|
1369 |
-
);
|
1370 |
}
|
1371 |
|
1372 |
if ( is_wp_error($term) ){
|
@@ -1419,7 +1416,15 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
1419 |
);
|
1420 |
|
1421 |
// deligate operation to addons
|
1422 |
-
foreach (PMXI_Admin_Addons::get_active_addons() as $class)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1423 |
|
1424 |
// [/addons import]
|
1425 |
|
@@ -1437,19 +1442,16 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
1437 |
do_action('pmxi_after_post_import', $this->id);
|
1438 |
|
1439 |
$logger and PMXI_Plugin::$session['pmxi_import']['chunk_number'] = ++PMXI_Plugin::$session->data['pmxi_import']['chunk_number'];
|
1440 |
-
}
|
1441 |
-
|
1442 |
-
wp_cache_flush();
|
1443 |
|
1444 |
-
|
1445 |
|
1446 |
$this->set(array(
|
1447 |
'imported' => $created + $updated,
|
1448 |
'created' => $created,
|
1449 |
'updated' => $updated,
|
1450 |
'skipped' => $skipped,
|
1451 |
-
'queue_chunk_number' => $created + $updated + $skipped
|
1452 |
-
'current_post_ids' => json_encode(array_unique(array_merge($current_ids, $current_post_ids)))
|
1453 |
))->update();
|
1454 |
|
1455 |
if ( ! $is_cron ){
|
@@ -1461,43 +1463,56 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
1461 |
$is_import_complete = ($records_count == $this->count);
|
1462 |
|
1463 |
// Delete posts that are no longer present in your file
|
1464 |
-
if ( $is_import_complete and ! empty($this->options['is_delete_missing'])) {
|
1465 |
|
1466 |
$logger and call_user_func($logger, 'Removing previously imported posts which are no longer actual...');
|
1467 |
-
$postList = new PMXI_Post_List();
|
1468 |
-
$current_post_ids = (empty($this->current_post_ids)) ? array() : json_decode($this->current_post_ids, true);
|
1469 |
|
1470 |
$missing_ids = array();
|
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 |
// Delete posts from database
|
1503 |
if (!empty($missing_ids) && is_array($missing_ids) and ! $this->options['is_update_missing_cf'] and ! $this->options['set_missing_to_draft']){
|
@@ -1522,23 +1537,24 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
1522 |
|
1523 |
$logger and call_user_func($logger, 'Update stock status previously imported posts which are no longer actual...');
|
1524 |
$postList = new PMXI_Post_List();
|
1525 |
-
$
|
1526 |
-
|
1527 |
-
|
1528 |
-
|
|
|
|
|
1529 |
}
|
1530 |
-
|
1531 |
}
|
1532 |
}
|
1533 |
|
1534 |
} catch (XmlImportException $e) {
|
1535 |
$logger and call_user_func($logger, __('<b>ERROR</b>', 'pmxi_plugin') . ': ' . $e->getMessage());
|
1536 |
-
PMXI_Plugin::$session['pmxi_import']['errors'] = ++PMXI_Plugin::$session->data['pmxi_import']['errors'];
|
1537 |
}
|
1538 |
|
1539 |
$logger and $is_import_complete and call_user_func($logger, __('Cleaning temporary data...', 'pmxi_plugin'));
|
1540 |
foreach ($tmp_files as $file) { // remove all temporary files created
|
1541 |
-
unlink($file);
|
1542 |
}
|
1543 |
|
1544 |
if (($is_cron or $is_import_complete) and $this->options['is_delete_source']) {
|
@@ -1571,9 +1587,9 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
1571 |
$this->set(array(
|
1572 |
'processing' => 0, // unlock cron requests
|
1573 |
'triggered' => 0,
|
1574 |
-
'queue_chunk_number' => 0,
|
1575 |
-
'
|
1576 |
-
'
|
1577 |
))->update();
|
1578 |
|
1579 |
$logger and call_user_func($logger, 'Done');
|
8 |
*/
|
9 |
public static function preprocessXml( & $xml) {
|
10 |
|
11 |
+
if ( empty(PMXI_Plugin::$session->data['pmxi_import']['is_csv']) and empty(PMXI_Plugin::$is_csv)) $xml = str_replace("&", "&", str_replace("&","&", $xml));
|
12 |
|
13 |
}
|
14 |
|
15 |
/**
|
16 |
+
* Validate XML to be valid for import
|
17 |
* @param string $xml
|
18 |
* @param WP_Error[optional] $errors
|
19 |
* @return bool Validation status
|
78 |
$this->options += PMXI_Plugin::get_default_import_options(); // make sure all options are defined
|
79 |
|
80 |
$avoid_pingbacks = PMXI_Plugin::getInstance()->getOption('pingbacks');
|
|
|
81 |
|
82 |
if ( $avoid_pingbacks and ! defined( 'WP_IMPORTING' ) ) define( 'WP_IMPORTING', true );
|
83 |
|
86 |
$tmp_files = array();
|
87 |
// compose records to import
|
88 |
$records = array();
|
89 |
+
|
90 |
+
$is_import_complete = false;
|
91 |
|
92 |
try {
|
93 |
|
101 |
}
|
102 |
else{
|
103 |
count($titles) and $post_excerpt = array_fill(0, count($titles), '');
|
104 |
+
}
|
105 |
|
106 |
if ( "xpath" == $this->options['status'] ){
|
107 |
$chunk == 1 and $logger and call_user_func($logger, __('Composing statuses...', 'pmxi_plugin'));
|
121 |
if (!empty($this->options['author'])){
|
122 |
$post_author = XmlImportParser::factory($xml, $cxpath, $this->options['author'], $file)->parse($records); $tmp_files[] = $file;
|
123 |
foreach ($post_author as $key => $author) {
|
124 |
+
$user = get_user_by('login', $author) or $user = get_user_by('slug', $author) or $user = get_user_by('email', $author) or ctype_digit($author) and $user = get_user_by('id', $author);
|
125 |
$post_author[$key] = (!empty($user)) ? $user->ID : $current_user->ID;
|
126 |
}
|
127 |
}
|
140 |
|
141 |
$chunk == 1 and $logger and call_user_func($logger, __('Composing contents...', 'pmxi_plugin'));
|
142 |
$contents = XmlImportParser::factory(
|
143 |
+
((!empty($this->template['is_keep_linebreaks']) and intval($this->template['is_keep_linebreaks'])) ? $xml : preg_replace('%\r\n?|\n%', ' ', $xml)),
|
144 |
$cxpath,
|
145 |
$this->template['content'],
|
146 |
$file)->parse($records
|
224 |
if ($value->item_id == $category->parent_id and !empty($value->cat_ids[$i])){
|
225 |
foreach ($value->cat_ids[$i] as $parent) {
|
226 |
if (!$j or !$this->options['categories_auto_nested']){
|
227 |
+
|
228 |
+
$filtered_cats = apply_filters('pmxi_single_category', array(array(
|
229 |
'name' => trim($cc),
|
230 |
'parent' => (is_array($parent)) ? $parent['name'] : $parent, // if parent taxonomy exists then return ID else return TITLE
|
231 |
'assign' => $category->assign
|
232 |
+
)), $category);
|
233 |
+
foreach ($filtered_cats as $filtered_cat)
|
234 |
+
$cats[$i][] = $filtered_cat;
|
235 |
+
|
236 |
}
|
237 |
elseif($this->options['categories_auto_nested']){
|
238 |
+
|
239 |
+
$filtered_cats = apply_filters('pmxi_single_category', array(array(
|
240 |
'name' => trim($cc),
|
241 |
+
'parent' => (!empty($delimeted_categories[$j - 1])) ? apply_filters('pmxi_parent_category', trim($delimeted_categories[$j - 1]), $category) : false, // if parent taxonomy exists then return ID else return TITLE
|
242 |
'assign' => $category->assign
|
243 |
+
)), $category);
|
244 |
+
foreach ($filtered_cats as $filtered_cat)
|
245 |
+
$cats[$i][] = $filtered_cat;
|
246 |
+
|
247 |
}
|
248 |
}
|
249 |
}
|
251 |
}
|
252 |
else {
|
253 |
if (!$j or !$this->options['categories_auto_nested']){
|
254 |
+
|
255 |
+
$filtered_cats = apply_filters('pmxi_single_category', array(array(
|
256 |
'name' => trim($cc),
|
257 |
'parent' => false,
|
258 |
'assign' => $category->assign
|
259 |
+
)), $category);
|
260 |
+
foreach ($filtered_cats as $filtered_cat)
|
261 |
+
$cats[$i][] = $filtered_cat;
|
262 |
+
|
263 |
}
|
264 |
elseif ($this->options['categories_auto_nested']){
|
265 |
+
|
266 |
+
$filtered_cats = apply_filters('pmxi_single_category', array(array(
|
267 |
'name' => trim($cc),
|
268 |
+
'parent' => (!empty($delimeted_categories[$j - 1])) ? apply_filters('pmxi_parent_category', trim($delimeted_categories[$j - 1]), $category) : false,
|
269 |
'assign' => $category->assign
|
270 |
+
)), $category);
|
271 |
+
foreach ($filtered_cats as $filtered_cat)
|
272 |
+
$cats[$i][] = $filtered_cat;
|
273 |
+
|
274 |
}
|
275 |
|
276 |
}
|
277 |
}
|
278 |
+
if ($count_cats < count($cats[$i])) $categories_hierarchy[$k]->cat_ids[$i][] = apply_filters('pmxi_single_category', $cats[$i][count($cats[$i]) - 1], $categories_hierarchy[$k]);
|
279 |
}
|
280 |
endforeach;
|
281 |
} else{
|
322 |
if ($value->item_id == $taxonomy->parent_id and !empty($value->txn_names[$i])){
|
323 |
foreach ($value->txn_names[$i] as $parent) {
|
324 |
if (!$j or !$taxonomy->auto_nested){
|
325 |
+
|
326 |
+
$filtered_txs = apply_filters('pmxi_single_category', array(array(
|
327 |
'name' => trim($cc),
|
328 |
'parent' => $parent,
|
329 |
'assign' => $taxonomy->assign
|
330 |
+
)), $taxonomy);
|
331 |
+
foreach ($filtered_txs as $filtered_tx)
|
332 |
+
$taxonomies[$tx_name][$i][] = $filtered_tx;
|
333 |
+
|
334 |
}
|
335 |
elseif ($taxonomy->auto_nested){
|
336 |
+
|
337 |
+
$filtered_txs = apply_filters('pmxi_single_category', array(array(
|
338 |
'name' => trim($cc),
|
339 |
+
'parent' => (!empty($delimeted_taxonomies[$j - 1])) ? apply_filters('pmxi_parent_category', trim($delimeted_taxonomies[$j - 1]), $taxonomy) : false,
|
340 |
'assign' => $taxonomy->assign
|
341 |
+
)), $taxonomy);
|
342 |
+
foreach ($filtered_txs as $filtered_tx)
|
343 |
+
$taxonomies[$tx_name][$i][] = $filtered_tx;
|
344 |
+
|
345 |
}
|
346 |
}
|
347 |
}
|
350 |
}
|
351 |
else {
|
352 |
if (!$j or !$taxonomy->auto_nested){
|
353 |
+
|
354 |
+
$filtered_txs = apply_filters('pmxi_single_category', array(array(
|
355 |
'name' => trim($cc),
|
356 |
'parent' => false,
|
357 |
'assign' => $taxonomy->assign
|
358 |
+
)), $taxonomy);
|
359 |
+
foreach ($filtered_txs as $filtered_tx)
|
360 |
+
$taxonomies[$tx_name][$i][] = $filtered_tx;
|
361 |
+
|
362 |
}
|
363 |
elseif ($taxonomy->auto_nested) {
|
364 |
+
|
365 |
+
$filtered_txs = apply_filters('pmxi_single_category', array(array(
|
366 |
'name' => trim($cc),
|
367 |
+
'parent' => (!empty($delimeted_taxonomies[$j - 1])) ? apply_filters('pmxi_parent_category', trim($delimeted_taxonomies[$j - 1]), $taxonomy) : false,
|
368 |
'assign' => $taxonomy->assign
|
369 |
+
)), $taxonomy);
|
370 |
+
foreach ($filtered_txs as $filtered_tx)
|
371 |
+
$taxonomies[$tx_name][$i][] = $filtered_tx;
|
372 |
+
|
373 |
}
|
374 |
}
|
375 |
}
|
376 |
+
if ($count_cats < count($taxonomies[$tx_name][$i])) $taxonomies_hierarchy[$k]->txn_names[$i][] = apply_filters('pmxi_single_category', $taxonomies[$tx_name][$i][count($taxonomies[$tx_name][$i]) - 1], $taxonomies_hierarchy[$k]);
|
377 |
}
|
378 |
}
|
379 |
}
|
380 |
}; endif;
|
381 |
+
// [/custom taxonomies]
|
382 |
|
383 |
// serialized featured images
|
384 |
if ( ! (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
|
385 |
$logger and call_user_func($logger, __('<b>WARNING</b>', 'pmxi_plugin') . ': ' . $uploads['error']);
|
386 |
$logger and call_user_func($logger, __('<b>WARNING</b>: No featured images will be created', 'pmxi_plugin'));
|
387 |
+
$logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
|
388 |
} else {
|
389 |
$chunk == 1 and $logger and call_user_func($logger, __('Composing URLs for featured images...', 'pmxi_plugin'));
|
390 |
$featured_images = array();
|
391 |
+
if ($this->options['featured_image']) {
|
392 |
+
$featured_images = XmlImportParser::factory($xml, $cxpath, $this->options['featured_image'], $file)->parse($records); $tmp_files[] = $file;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
393 |
} else {
|
394 |
count($titles) and $featured_images = array_fill(0, count($titles), '');
|
395 |
}
|
396 |
}
|
397 |
+
|
398 |
// serialized images meta data
|
399 |
if ( $this->options['set_image_meta_data'] ){
|
400 |
$uploads = wp_upload_dir();
|
403 |
$chunk == 1 and $logger and call_user_func($logger, __('Composing image meta data (titles)...', 'pmxi_plugin'));
|
404 |
$image_meta_titles = array();
|
405 |
|
406 |
+
if ($this->options['image_meta_title']) {
|
407 |
+
$image_meta_titles = XmlImportParser::factory($xml, $cxpath, $this->options['image_meta_title'], $file)->parse($records); $tmp_files[] = $file;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
408 |
} else {
|
409 |
count($titles) and $image_meta_titles = array_fill(0, count($titles), '');
|
410 |
}
|
412 |
// serialized images meta captions
|
413 |
$chunk == 1 and $logger and call_user_func($logger, __('Composing image meta data (captions)...', 'pmxi_plugin'));
|
414 |
$image_meta_captions = array();
|
415 |
+
if ($this->options['image_meta_caption']) {
|
416 |
+
$image_meta_captions = XmlImportParser::factory($xml, $cxpath, $this->options['image_meta_caption'], $file)->parse($records); $tmp_files[] = $file;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
417 |
} else {
|
418 |
count($titles) and $image_meta_captions = array_fill(0, count($titles), '');
|
419 |
}
|
420 |
// serialized images meta alt text
|
421 |
$chunk == 1 and $logger and call_user_func($logger, __('Composing image meta data (alt text)...', 'pmxi_plugin'));
|
422 |
$image_meta_alts = array();
|
423 |
+
if ($this->options['image_meta_alt']) {
|
424 |
+
$image_meta_alts = XmlImportParser::factory($xml, $cxpath, $this->options['image_meta_alt'], $file)->parse($records); $tmp_files[] = $file;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
425 |
} else {
|
426 |
count($titles) and $image_meta_alts = array_fill(0, count($titles), '');
|
427 |
}
|
428 |
// serialized images meta description
|
429 |
$chunk == 1 and $logger and call_user_func($logger, __('Composing image meta data (description)...', 'pmxi_plugin'));
|
430 |
$image_meta_descriptions = array();
|
431 |
+
if ($this->options['image_meta_description']) {
|
432 |
+
$image_meta_descriptions = XmlImportParser::factory($xml, $cxpath, $this->options['image_meta_description'], $file)->parse($records); $tmp_files[] = $file;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
433 |
} else {
|
434 |
count($titles) and $image_meta_descriptions = array_fill(0, count($titles), '');
|
435 |
}
|
495 |
$addons_data = array();
|
496 |
|
497 |
// data parsing for WP All Import add-ons
|
498 |
+
$parsingData = array(
|
499 |
+
'import' => $this,
|
500 |
+
'count' => count($titles),
|
501 |
+
'xml' => $xml,
|
502 |
+
'logger' => $logger,
|
503 |
+
'chunk' => $chunk,
|
504 |
+
'xpath_prefix' => $xpath_prefix
|
505 |
+
);
|
506 |
+
foreach (PMXI_Admin_Addons::get_active_addons() as $class) {
|
507 |
+
$model_class = str_replace("_Plugin", "_Import_Record", $class);
|
508 |
+
if (class_exists($model_class)){
|
509 |
+
$addons[$class] = new $model_class();
|
510 |
+
$addons_data[$class] = ( method_exists($addons[$class], 'parse') ) ? $addons[$class]->parse($parsingData) : false;
|
511 |
+
}
|
512 |
+
else{
|
513 |
+
$parse_func = $class . '_parse';
|
514 |
+
if (function_exists($parse_func)) $addons_data[$class] = call_user_func($parse_func, $parsingData);
|
515 |
+
}
|
516 |
}
|
517 |
|
518 |
+
// save current import state to variables before import
|
|
|
519 |
$created = $this->created;
|
520 |
$updated = $this->updated;
|
521 |
$skipped = $this->skipped;
|
532 |
}
|
533 |
}
|
534 |
|
535 |
+
}
|
536 |
|
537 |
foreach ($titles as $i => $void) {
|
538 |
|
541 |
do_action('pmxi_before_post_import', $this->id);
|
542 |
|
543 |
if (empty($titles[$i])) {
|
544 |
+
if (!empty($addons_data['PMWI_Plugin']) and !empty($addons_data['PMWI_Plugin']['single_product_parent_ID'][$i])){
|
545 |
$titles[$i] = $addons_data['PMWI_Plugin']['single_product_parent_ID'][$i] . ' Product Variation';
|
546 |
}
|
547 |
else{
|
548 |
$skipped++;
|
549 |
$logger and call_user_func($logger, __('<b>SKIPPED</b>: by empty title', 'pmxi_plugin'));
|
550 |
+
$logger and PMXI_Plugin::$session['pmxi_import']['chunk_number'] = ++PMXI_Plugin::$session->data['pmxi_import']['chunk_number'];
|
551 |
+
$logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
|
552 |
pmxi_session_commit();
|
553 |
continue;
|
554 |
}
|
555 |
}
|
556 |
+
|
557 |
$articleData = array(
|
558 |
'post_type' => $post_type,
|
559 |
'post_status' => ("xpath" == $this->options['status']) ? $post_status[$i] : $this->options['status'],
|
560 |
'comment_status' => $this->options['comment_status'],
|
561 |
'ping_status' => $this->options['ping_status'],
|
562 |
+
'post_title' => (!empty($this->template['is_leave_html'])) ? html_entity_decode($titles[$i]) : $titles[$i],
|
563 |
+
'post_excerpt' => apply_filters('pmxi_the_excerpt', ((!empty($this->template['is_leave_html'])) ? html_entity_decode($post_excerpt[$i]) : $post_excerpt[$i]), $this->id),
|
564 |
'post_name' => $post_slug[$i],
|
565 |
+
'post_content' => apply_filters('pmxi_the_content', ((!empty($this->template['is_leave_html'])) ? html_entity_decode($contents[$i]) : $contents[$i]), $this->id),
|
566 |
'post_date' => $dates[$i],
|
567 |
'post_date_gmt' => get_gmt_from_date($dates[$i]),
|
568 |
'post_author' => $post_author[$i],
|
569 |
'tags_input' => $tags[$i]
|
570 |
+
);
|
571 |
|
572 |
if ('post' != $articleData['post_type']){
|
573 |
$articleData += array(
|
582 |
// if Auto Matching re-import option selected
|
583 |
if ("manual" != $this->options['duplicate_matching']){
|
584 |
|
585 |
+
// find corresponding article among previously imported
|
|
|
586 |
$postRecord->clear();
|
587 |
$postRecord->getBy(array(
|
588 |
'unique_key' => $unique_keys[$i],
|
589 |
'import_id' => $this->id,
|
590 |
));
|
591 |
+
|
592 |
if ( ! $postRecord->isEmpty() )
|
593 |
$post_to_update = get_post($post_to_update_id = $postRecord->post_id);
|
594 |
|
607 |
$custom_duplicate_name = XmlImportParser::factory($xml, $cxpath, $this->options['custom_duplicate_name'], $file)->parse($records); $tmp_files[] = $file;
|
608 |
}
|
609 |
else{
|
610 |
+
count($titles) and $custom_duplicate_name = $custom_duplicate_value = array_fill(0, count($titles), '');
|
611 |
}
|
612 |
|
613 |
// handle duplicates according to import settings
|
614 |
if ($duplicates = pmxi_findDuplicates($articleData, $custom_duplicate_name[$i], $custom_duplicate_value[$i], $this->options['duplicate_indicator'])) {
|
615 |
$duplicate_id = array_shift($duplicates);
|
616 |
+
|
617 |
if ($duplicate_id) {
|
618 |
$post_to_update = get_post($post_to_update_id = $duplicate_id);
|
619 |
}
|
620 |
+
}
|
621 |
}
|
622 |
|
623 |
if (!empty($specified_records)){
|
624 |
if ( ! in_array($created + $updated + $skipped + 1, $specified_records) ){
|
625 |
+
|
626 |
+
if ( ! $postRecord->isEmpty() ) $postRecord->set(array('iteration' => $this->iteration))->update();
|
627 |
+
|
628 |
+
$skipped++;
|
629 |
$logger and call_user_func($logger, __('<b>SKIPPED</b>: by specified records option', 'pmxi_plugin'));
|
630 |
$logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
|
631 |
$logger and PMXI_Plugin::$session['pmxi_import']['chunk_number'] = ++PMXI_Plugin::$session->data['pmxi_import']['chunk_number'];
|
638 |
if ($post_to_update){
|
639 |
|
640 |
// Do not update already existing records option selected
|
641 |
+
if ("yes" == $this->options['is_keep_former_posts']) {
|
642 |
+
|
643 |
+
if ( ! $postRecord->isEmpty() ) $postRecord->set(array('iteration' => $this->iteration))->update();
|
644 |
+
|
645 |
+
do_action('pmxi_do_not_update_existing', $post_to_update_id, $this->id, $this->iteration);
|
646 |
+
|
|
|
647 |
$skipped++;
|
648 |
$logger and call_user_func($logger, sprintf(__('<b>SKIPPED</b>: Previously imported record found for `%s`', 'pmxi_plugin'), $articleData['post_title']));
|
649 |
$logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
|
652 |
continue;
|
653 |
}
|
654 |
|
655 |
+
$articleData['ID'] = $post_to_update_id;
|
656 |
// Choose which data to update
|
657 |
if ( $this->options['update_all_data'] == 'no' ){
|
658 |
// preserve date of already existing article when duplicate is found
|
753 |
|
754 |
// no new records are created. it will only update posts it finds matching duplicates for
|
755 |
if ( ! $this->options['create_new_records'] and empty($articleData['ID'])){
|
756 |
+
|
757 |
+
if ( ! $postRecord->isEmpty() ) $postRecord->set(array('iteration' => $this->iteration))->update();
|
758 |
+
|
759 |
+
$logger and call_user_func($logger, __('<b>SKIPPED</b>: by do not create new posts option.', 'pmxi_plugin'));
|
760 |
$logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
|
761 |
$logger and PMXI_Plugin::$session['pmxi_import']['chunk_number'] = ++PMXI_Plugin::$session->data['pmxi_import']['chunk_number'];
|
762 |
$skipped++;
|
763 |
pmxi_session_commit();
|
764 |
continue;
|
765 |
}
|
766 |
+
|
767 |
// cloak urls with `WP Wizard Cloak` if corresponding option is set
|
768 |
if ( ! empty($this->options['is_cloak']) and class_exists('PMLC_Plugin')) {
|
769 |
if (preg_match_all('%<a\s[^>]*href=(?(?=")"([^"]*)"|(?(?=\')\'([^\']*)\'|([^\s>]*)))%is', $articleData['post_content'], $matches, PREG_PATTERN_ORDER)) {
|
839 |
}
|
840 |
}
|
841 |
}
|
842 |
+
}
|
843 |
|
844 |
// insert article being imported
|
845 |
$pid = ($this->options['is_fast_mode']) ? pmxi_insert_post($articleData, true) : wp_insert_post($articleData, true);
|
846 |
+
|
847 |
if (is_wp_error($pid)) {
|
848 |
$logger and call_user_func($logger, __('<b>ERROR</b>', 'pmxi_plugin') . ': ' . $pid->get_error_message());
|
849 |
$logger and PMXI_Plugin::$session['pmxi_import']['errors'] = ++PMXI_Plugin::$session->data['pmxi_import']['errors'];
|
850 |
} else {
|
851 |
+
|
|
|
|
|
852 |
if ("manual" != $this->options['duplicate_matching'] or empty($articleData['ID'])){
|
853 |
+
// associate post with import
|
854 |
$postRecord->isEmpty() and $postRecord->set(array(
|
855 |
'post_id' => $pid,
|
856 |
'import_id' => $this->id,
|
857 |
'unique_key' => $unique_keys[$i],
|
858 |
+
'product_key' => (($post_type == "product" and PMXI_Admin_Addons::get_addon('PMWI_Plugin')) ? $addons_data['PMWI_Plugin']['single_product_ID'][$i] : '')
|
859 |
))->insert();
|
860 |
+
|
861 |
+
$postRecord->set(array('iteration' => $this->iteration))->update();
|
862 |
}
|
863 |
|
864 |
// [post format]
|
902 |
|
903 |
}
|
904 |
}
|
905 |
+
|
906 |
+
$encoded_meta = array();
|
907 |
+
|
908 |
+
foreach ($serialized_meta as $m_key => $values) {
|
909 |
+
|
910 |
+
if (!empty($articleData['ID'])){
|
911 |
+
|
912 |
+
if ($this->options['update_all_data'] != 'yes'){
|
913 |
+
|
914 |
+
$field_to_update = false;
|
915 |
+
|
916 |
+
if ($this->options['is_update_custom_fields'] and $this->options['update_custom_fields_logic'] == "only" and ! empty($this->options['custom_fields_list']) and is_array($this->options['custom_fields_list']) and in_array($m_key, $this->options['custom_fields_list']) ) $field_to_update = true;
|
917 |
+
if ($this->options['is_update_custom_fields'] and $this->options['update_custom_fields_logic'] == "all_except" and ( empty($this->options['custom_fields_list']) or ! in_array($m_key, $this->options['custom_fields_list']) )) $field_to_update = true;
|
918 |
+
|
919 |
+
if ( $this->options['update_custom_fields_logic'] == "full_update" ) $field_to_update = true;
|
920 |
+
|
921 |
+
// apply addons filters
|
922 |
+
$field_to_update = apply_filters('pmxi_custom_field_to_update', $field_to_update, $post_type, $this->options, $m_key);
|
923 |
+
|
924 |
+
if ( ! $field_to_update ) continue;
|
925 |
+
|
926 |
+
}
|
927 |
+
|
928 |
+
}
|
929 |
+
|
930 |
+
update_post_meta($pid, $m_key, apply_filters('pmxi_custom_field', (is_serialized($values[$i])) ? unserialize($values[$i]) : $values[$i], $this->id));
|
931 |
+
|
932 |
+
do_action( 'pmxi_update_post_meta', $pid, $m_key, (is_serialized($values[$i])) ? unserialize($values[$i]) : $values[$i]); // hook that was triggered after post meta data updated
|
933 |
+
|
934 |
+
}
|
935 |
|
936 |
}
|
937 |
// [/custom fields]
|
951 |
);
|
952 |
|
953 |
// deligate operation to addons
|
954 |
+
foreach (PMXI_Admin_Addons::get_active_addons() as $class){
|
955 |
+
if (class_exists($class)){
|
956 |
+
if ( method_exists($addons[$class], 'import') ) $addons[$class]->import($importData);
|
957 |
+
}
|
958 |
+
else{
|
959 |
+
$import_func = $class . '_import';
|
960 |
+
if (function_exists($import_func)) call_user_func($import_func, $importData, $addons_data[$class]);
|
961 |
+
}
|
962 |
+
}
|
963 |
|
964 |
// [/addons import]
|
965 |
|
969 |
// [featured image]
|
970 |
if ( ! empty($uploads) and false === $uploads['error'] and !empty($featured_images[$i]) and (empty($articleData['ID']) or $this->options['update_all_data'] == "yes" or ( $this->options['update_all_data'] == "no" and $this->options['is_update_images']))) {
|
971 |
|
972 |
+
require_once(ABSPATH . 'wp-admin/includes/image.php');
|
|
|
|
|
|
|
|
|
|
|
973 |
|
974 |
$success_images = false;
|
975 |
$gallery_attachment_ids = array();
|
976 |
|
977 |
$_pmxi_images = array();
|
978 |
+
|
979 |
+
$imgs = ( ! empty($this->options['featured_delim']) ) ? str_getcsv($featured_images[$i], $this->options['featured_delim']) : explode("\n", $featured_images[$i]);
|
980 |
+
|
981 |
+
if (!empty($imgs)) {
|
982 |
|
|
|
|
|
|
|
983 |
if ( $this->options['set_image_meta_data'] ){
|
984 |
+
$img_titles = ( ! empty($this->options['image_meta_title_delim']) ) ? str_getcsv($image_meta_titles[$i], $this->options['image_meta_title_delim']) : explode("\n", $image_meta_titles[$i]);
|
985 |
+
$img_captions = ( ! empty($this->options['image_meta_caption_delim']) ) ? str_getcsv($image_meta_captions[$i], $this->options['image_meta_caption_delim']) : explode("\n", $image_meta_captions[$i]);
|
986 |
+
$img_alts = ( ! empty($this->options['image_meta_alt_delim']) ) ? str_getcsv($image_meta_alts[$i], $this->options['image_meta_alt_delim']) : explode("\n", $image_meta_alts[$i]);
|
987 |
+
$img_descriptions = ( ! empty($this->options['image_meta_description_delim']) ) ? str_getcsv($image_meta_descriptions[$i], $this->options['image_meta_description_delim']) : explode("\n", $image_meta_descriptions[$i]);
|
988 |
+
}
|
|
|
|
|
|
|
989 |
|
990 |
+
foreach ($imgs as $k => $img_url) { if (empty($img_url)) continue;
|
|
|
|
|
991 |
|
992 |
+
$url = str_replace(" ", "%20", trim($img_url));
|
993 |
+
$bn = preg_replace('/[\\?|&].*/', '', basename($url));
|
994 |
+
|
995 |
+
$img_ext = pmxi_getExtensionFromStr($url);
|
996 |
+
$default_extension = pmxi_getExtension($bn);
|
997 |
|
998 |
+
if ($img_ext == "")
|
999 |
+
$img_ext = pmxi_get_remote_image_ext($url);
|
|
|
1000 |
|
1001 |
+
// generate local file name
|
1002 |
+
$image_name = urldecode(($this->options['auto_rename_images'] and "" != $auto_rename_images[$i]) ? sanitize_file_name($auto_rename_images[$i] . '_' . (($img_ext) ? str_replace("." . $default_extension, "", $bn) : $bn)) : sanitize_file_name((($img_ext) ? str_replace("." . $default_extension, "", $bn) : $bn))) . (("" != $img_ext) ? '.' . $img_ext : '');
|
1003 |
+
|
1004 |
+
// if wizard store image data to custom field
|
1005 |
+
$create_image = false;
|
1006 |
+
$download_image = true;
|
1007 |
+
|
1008 |
+
if (base64_decode($url, true) !== false){
|
1009 |
+
$img = @imagecreatefromstring(base64_decode($url));
|
1010 |
+
if($img)
|
1011 |
+
{
|
1012 |
+
$image_filename = md5(time()) . '.jpg';
|
1013 |
+
$image_filepath = $uploads['path'] . '/' . $image_filename;
|
1014 |
+
imagejpeg($img, $image_filepath);
|
1015 |
+
if( ! ($image_info = @getimagesize($image_filepath)) or ! in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
|
1016 |
+
$logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: File %s is not a valid image and cannot be set as featured one', 'pmxi_plugin'), $image_filepath));
|
1017 |
+
$logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
|
1018 |
+
} else {
|
1019 |
+
$create_image = true;
|
1020 |
+
}
|
1021 |
+
}
|
1022 |
+
}
|
1023 |
+
else {
|
1024 |
+
|
1025 |
+
$image_filename = wp_unique_filename($uploads['path'], $image_name);
|
1026 |
+
$image_filepath = $uploads['path'] . '/' . $image_filename;
|
1027 |
+
|
1028 |
+
// keep existing and add newest images
|
1029 |
+
if ( ! empty($articleData['ID']) and $this->options['is_update_images'] and $this->options['update_images_logic'] == "add_new" and $this->options['update_all_data'] == "no"){
|
1030 |
|
1031 |
+
$attachment_imgs = get_posts( array(
|
1032 |
+
'post_type' => 'attachment',
|
1033 |
+
'posts_per_page' => -1,
|
1034 |
+
'post_parent' => $pid,
|
1035 |
+
) );
|
1036 |
+
|
1037 |
+
if ( $attachment_imgs ) {
|
1038 |
+
foreach ( $attachment_imgs as $attachment_img ) {
|
1039 |
+
if ($attachment_img->guid == $uploads['url'] . '/' . $image_name){
|
1040 |
+
$download_image = false;
|
1041 |
+
$success_images = true;
|
1042 |
+
if ( ! has_post_thumbnail($pid) )
|
1043 |
+
set_post_thumbnail($pid, $attachment_img->ID);
|
1044 |
+
else
|
1045 |
+
$gallery_attachment_ids[] = $attachment_img->ID;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1046 |
|
1047 |
+
$logger and call_user_func($logger, sprintf(__('<b>Image SKIPPED</b>: The image %s is always exists for the %s', 'pmxi_plugin'), basename($attachment_img->guid), $articleData['post_title']));
|
1048 |
+
}
|
1049 |
+
}
|
1050 |
}
|
1051 |
|
1052 |
+
}
|
|
|
|
|
|
|
1053 |
|
1054 |
+
if ($download_image){
|
|
|
|
|
|
|
1055 |
|
1056 |
+
// do not download images
|
1057 |
+
if ( ! $this->options['download_images'] ){
|
1058 |
|
1059 |
+
$image_filename = $image_name;
|
1060 |
+
$image_filepath = $uploads['path'] . '/' . $image_filename;
|
1061 |
+
|
1062 |
+
$existing_attachment = $this->wpdb->get_row( $this->wpdb->prepare( "SELECT * FROM " . $this->wpdb->prefix ."posts WHERE guid = '%s'", $uploads['url'] . '/' . $image_filename ) );
|
1063 |
+
|
1064 |
+
if ( ! empty($existing_attachment->ID) ){
|
1065 |
|
1066 |
+
$download_image = false;
|
1067 |
+
$create_image = false;
|
|
|
|
|
1068 |
|
1069 |
+
if ( ! has_post_thumbnail($pid) )
|
1070 |
+
set_post_thumbnail($pid, $existing_attachment->ID);
|
1071 |
+
else
|
1072 |
+
$gallery_attachment_ids[] = $existing_attachment->ID;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1073 |
|
1074 |
+
do_action( 'pmxi_gallery_image', $pid, $existing_attachment->ID, $image_filepath);
|
1075 |
|
1076 |
+
}
|
1077 |
+
else{
|
|
|
|
|
|
|
1078 |
|
1079 |
+
if ( @file_exists($image_filepath) ){
|
1080 |
+
$download_image = false;
|
1081 |
+
if( ! ($image_info = @getimagesize($image_filepath)) or ! in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
|
1082 |
+
$logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: File %s is not a valid image and cannot be set as featured one', 'pmxi_plugin'), $image_filepath));
|
|
|
|
|
|
|
|
|
|
|
|
|
1083 |
$logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
|
1084 |
@unlink($image_filepath);
|
1085 |
} else {
|
1087 |
}
|
1088 |
}
|
1089 |
}
|
1090 |
+
}
|
1091 |
+
|
1092 |
+
if ($download_image){
|
1093 |
+
|
1094 |
+
$request = get_file_curl($url, $image_filepath);
|
1095 |
+
|
1096 |
+
if ( (is_wp_error($request) or $request === false) and ! @file_put_contents($image_filepath, @file_get_contents($url))) {
|
1097 |
+
@unlink($image_filepath); // delete file since failed upload may result in empty file created
|
1098 |
+
} elseif( ($image_info = @getimagesize($image_filepath)) and in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
|
1099 |
+
$create_image = true;
|
1100 |
+
}
|
1101 |
+
|
1102 |
+
if ( ! $create_image ){
|
1103 |
+
|
1104 |
+
$url = str_replace(" ", "%20", trim(pmxi_convert_encoding($img_url)));
|
1105 |
+
|
1106 |
+
$request = get_file_curl($url, $image_filepath);
|
1107 |
+
|
1108 |
+
if ( (is_wp_error($request) or $request === false) and ! @file_put_contents($image_filepath, @file_get_contents($url))) {
|
1109 |
+
$logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: File %s cannot be saved locally as %s', 'pmxi_plugin'), $url, $image_filepath));
|
1110 |
+
$logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
|
1111 |
+
@unlink($image_filepath); // delete file since failed upload may result in empty file created
|
1112 |
+
} elseif( ! ($image_info = @getimagesize($image_filepath)) or ! in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
|
1113 |
+
$logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: File %s is not a valid image and cannot be set as featured one', 'pmxi_plugin'), $url));
|
1114 |
+
$logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
|
1115 |
+
@unlink($image_filepath);
|
1116 |
+
} else {
|
1117 |
+
$create_image = true;
|
1118 |
+
}
|
1119 |
+
}
|
1120 |
}
|
1121 |
}
|
1122 |
+
}
|
1123 |
|
1124 |
+
if ($create_image){
|
1125 |
|
1126 |
+
$attachment = array(
|
1127 |
+
'post_mime_type' => image_type_to_mime_type($image_info[2]),
|
1128 |
+
'guid' => $uploads['url'] . '/' . $image_filename,
|
1129 |
+
'post_title' => $image_filename,
|
1130 |
+
'post_content' => '',
|
1131 |
+
'post_author' => $post_author[$i],
|
1132 |
+
);
|
1133 |
+
if (($image_meta = wp_read_image_metadata($image_filepath))) {
|
1134 |
+
if (trim($image_meta['title']) && ! is_numeric(sanitize_title($image_meta['title'])))
|
1135 |
+
$attachment['post_title'] = $image_meta['title'];
|
1136 |
+
if (trim($image_meta['caption']))
|
1137 |
+
$attachment['post_content'] = $image_meta['caption'];
|
1138 |
+
}
|
1139 |
|
1140 |
+
$attid = ($this->options['is_fast_mode']) ? pmxi_insert_attachment($attachment, $image_filepath, $pid) : wp_insert_attachment($attachment, $image_filepath, $pid);
|
1141 |
|
1142 |
+
if (is_wp_error($attid)) {
|
1143 |
+
$logger and call_user_func($logger, __('<b>WARNING</b>', 'pmxi_plugin') . ': ' . $attid->get_error_message());
|
1144 |
+
$logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
|
1145 |
+
} else {
|
1146 |
+
// you must first include the image.php file
|
1147 |
+
// for the function wp_generate_attachment_metadata() to work
|
1148 |
+
require_once(ABSPATH . 'wp-admin/includes/image.php');
|
1149 |
+
wp_update_attachment_metadata($attid, wp_generate_attachment_metadata($attid, $image_filepath));
|
1150 |
+
|
1151 |
+
if ( $this->options['set_image_meta_data'] ){
|
1152 |
+
$update_attachment_meta = array();
|
1153 |
+
if ( ! empty($img_titles[$k]) ) $update_attachment_meta['post_title'] = $img_titles[$k];
|
1154 |
+
if ( ! empty($img_captions[$k]) ) $update_attachment_meta['post_excerpt'] = $img_captions[$k];
|
1155 |
+
if ( ! empty($img_descriptions[$k]) ) $update_attachment_meta['post_content'] = $img_descriptions[$k];
|
1156 |
+
if ( ! empty($img_alts[$k]) ) update_post_meta($attid, '_wp_attachment_image_alt', $img_alts[$k]);
|
1157 |
|
1158 |
+
if ( ! empty($update_attachment_meta)) $this->wpdb->update( $this->wpdb->posts, $update_attachment_meta, array('ID' => $attid) );
|
1159 |
+
|
1160 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1161 |
|
1162 |
+
do_action( 'pmxi_gallery_image', $pid, $attid, $image_filepath);
|
1163 |
|
1164 |
+
$success_images = true;
|
1165 |
+
if ( ! has_post_thumbnail($pid) )
|
1166 |
+
set_post_thumbnail($pid, $attid);
|
1167 |
+
else
|
1168 |
+
$gallery_attachment_ids[] = $attid;
|
1169 |
+
}
|
1170 |
+
}
|
1171 |
+
}
|
|
|
1172 |
}
|
1173 |
// Set product gallery images
|
1174 |
if ( $post_type == "product" and !empty($gallery_attachment_ids) )
|
1192 |
$atchs = str_getcsv($attachment, $this->options['atch_delim']);
|
1193 |
|
1194 |
if (!empty($atchs)) {
|
1195 |
+
foreach ($atchs as $atch_url) { if (empty($atch_url)) continue;
|
1196 |
|
1197 |
+
$atch_url = str_replace(" ", "%20", trim($atch_url));
|
1198 |
+
|
1199 |
+
$attachment_filename = wp_unique_filename($uploads['path'], urldecode(basename(parse_url(trim($atch_url), PHP_URL_PATH))));
|
1200 |
+
$attachment_filepath = $uploads['path'] . '/' . sanitize_file_name($attachment_filename);
|
1201 |
+
|
1202 |
+
$request = get_file_curl(trim($atch_url), $attachment_filepath);
|
1203 |
+
|
1204 |
+
if ( (is_wp_error($request) or $request === false) and ! @file_put_contents($attachment_filepath, @file_get_contents(trim($atch_url)))) {
|
1205 |
$logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Attachment file %s cannot be saved locally as %s', 'pmxi_plugin'), trim($atch_url), $attachment_filepath));
|
1206 |
+
is_wp_error($request) and $logger and call_user_func($logger, sprintf(__('<b>WP Error</b>: %s', 'pmxi_plugin'), $request->get_error_message()));
|
1207 |
$logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
|
1208 |
unlink($attachment_filepath); // delete file since failed upload may result in empty file created
|
1209 |
} elseif( ! $wp_filetype = wp_check_filetype(basename($attachment_filename), null )) {
|
1216 |
'post_mime_type' => $wp_filetype['type'],
|
1217 |
'post_title' => preg_replace('/\.[^.]+$/', '', basename($attachment_filepath)),
|
1218 |
'post_content' => '',
|
1219 |
+
'post_status' => 'inherit',
|
1220 |
+
'post_author' => $post_author[$i],
|
1221 |
);
|
1222 |
$attach_id = ($this->options['is_fast_mode']) ? pmxi_insert_attachment( $attachment_data, $attachment_filepath, $pid ) : wp_insert_attachment( $attachment_data, $attachment_filepath, $pid );
|
1223 |
|
1357 |
$parent_id = (!empty($single_cat['parent'])) ? pmxi_recursion_taxes($single_cat['parent'], 'category', $cats[$i], $key) : '';
|
1358 |
|
1359 |
$term = is_exists_term('category', $single_cat['name'], (int)$parent_id);
|
1360 |
+
|
1361 |
+
if ( empty($term) and ! is_wp_error($term) ){
|
|
|
1362 |
$term = wp_insert_term(
|
1363 |
$single_cat['name'], // the term
|
1364 |
'category', // the taxonomy
|
1365 |
+
array('parent' => ((!empty($parent_id)) ? (int)$parent_id : 0))
|
1366 |
+
);
|
1367 |
}
|
1368 |
|
1369 |
if ( is_wp_error($term) ){
|
1416 |
);
|
1417 |
|
1418 |
// deligate operation to addons
|
1419 |
+
foreach (PMXI_Admin_Addons::get_active_addons() as $class){
|
1420 |
+
if (class_exists($class)){
|
1421 |
+
if ( method_exists($addons[$class], 'saved_post') ) $addons[$class]->saved_post($importData);
|
1422 |
+
}
|
1423 |
+
else{
|
1424 |
+
$saved_func = $class . '_saved_post';
|
1425 |
+
if (function_exists($saved_func)) call_user_func($saved_func, $importData);
|
1426 |
+
}
|
1427 |
+
}
|
1428 |
|
1429 |
// [/addons import]
|
1430 |
|
1442 |
do_action('pmxi_after_post_import', $this->id);
|
1443 |
|
1444 |
$logger and PMXI_Plugin::$session['pmxi_import']['chunk_number'] = ++PMXI_Plugin::$session->data['pmxi_import']['chunk_number'];
|
1445 |
+
}
|
|
|
|
|
1446 |
|
1447 |
+
wp_cache_flush();
|
1448 |
|
1449 |
$this->set(array(
|
1450 |
'imported' => $created + $updated,
|
1451 |
'created' => $created,
|
1452 |
'updated' => $updated,
|
1453 |
'skipped' => $skipped,
|
1454 |
+
'queue_chunk_number' => $created + $updated + $skipped
|
|
|
1455 |
))->update();
|
1456 |
|
1457 |
if ( ! $is_cron ){
|
1463 |
$is_import_complete = ($records_count == $this->count);
|
1464 |
|
1465 |
// Delete posts that are no longer present in your file
|
1466 |
+
if ( $is_import_complete and ! empty($this->options['is_delete_missing']) and $this->options['duplicate_matching'] == 'auto') {
|
1467 |
|
1468 |
$logger and call_user_func($logger, 'Removing previously imported posts which are no longer actual...');
|
1469 |
+
$postList = new PMXI_Post_List();
|
|
|
1470 |
|
1471 |
$missing_ids = array();
|
1472 |
+
$missingPosts = $postList->getBy(array('import_id' => $this->id, 'iteration !=' => $this->iteration));
|
1473 |
+
|
1474 |
+
if ( ! $missingPosts->isEmpty() ):
|
1475 |
+
|
1476 |
+
foreach ($missingPosts as $missingPost) {
|
1477 |
|
1478 |
+
$missing_ids[] = $missingPost['post_id'];
|
1479 |
|
1480 |
+
// Instead of deletion, set Custom Field
|
1481 |
+
if ($this->options['is_update_missing_cf']){
|
1482 |
+
update_post_meta( $missingPost['post_id'], $this->options['update_missing_cf_name'], $this->options['update_missing_cf_value'] );
|
1483 |
+
}
|
1484 |
|
1485 |
+
// Instead of deletion, change post status to Draft
|
1486 |
+
if ($this->options['set_missing_to_draft']) $this->wpdb->update( $this->wpdb->posts, array('post_status' => 'draft'), array('ID' => $missingPost['post_id']) );
|
1487 |
|
1488 |
+
// Delete posts that are no longer present in your file
|
1489 |
+
if ( ! $this->options['is_update_missing_cf'] and ! $this->options['set_missing_to_draft']){
|
1490 |
|
1491 |
+
// Remove attachments
|
1492 |
+
empty($this->options['is_keep_attachments']) and wp_delete_attachments($missingPost['post_id'], true, 'files');
|
1493 |
+
// Remove images
|
1494 |
+
empty($this->options['is_keep_imgs']) and wp_delete_attachments($missingPost['post_id'], $this->options['download_images']);
|
1495 |
|
1496 |
+
if ( ! empty($missingPost['id'])){
|
1497 |
+
// Delete record form pmxi_posts
|
1498 |
+
$missingRecord = new PMXI_Post_Record();
|
1499 |
+
$missingRecord->getById($missingPost['id'])->delete();
|
1500 |
+
}
|
1501 |
+
else {
|
1502 |
+
$sql = "DELETE FROM " . PMXI_Plugin::getInstance()->getTablePrefix() . "posts WHERE post_id = " . $missingPost['post_id'] . " AND import_id = " . $missingPost['import_id'];
|
1503 |
+
$this->wpdb->query(
|
1504 |
+
$this->wpdb->prepare($sql, '')
|
1505 |
+
);
|
1506 |
+
}
|
1507 |
|
1508 |
+
// Clear post's relationships
|
1509 |
+
wp_delete_object_term_relationships($missingPost['post_id'], get_object_taxonomies('' != $this->options['custom_type'] ? $this->options['custom_type'] : 'post'));
|
1510 |
|
1511 |
+
}
|
1512 |
+
|
1513 |
}
|
1514 |
+
|
1515 |
+
endif;
|
1516 |
|
1517 |
// Delete posts from database
|
1518 |
if (!empty($missing_ids) && is_array($missing_ids) and ! $this->options['is_update_missing_cf'] and ! $this->options['set_missing_to_draft']){
|
1537 |
|
1538 |
$logger and call_user_func($logger, 'Update stock status previously imported posts which are no longer actual...');
|
1539 |
$postList = new PMXI_Post_List();
|
1540 |
+
$missingPosts = $postList->getBy(array('import_id' => $this->id, 'iteration !=' => $this->iteration));
|
1541 |
+
if ( ! $missingPosts->isEmpty() ){
|
1542 |
+
foreach ($missingPosts as $missingPost) {
|
1543 |
+
update_post_meta( $missingPost['post_id'], '_stock_status', 'outofstock' );
|
1544 |
+
update_post_meta( $missingPost['post_id'], '_stock', 0 );
|
1545 |
+
}
|
1546 |
}
|
|
|
1547 |
}
|
1548 |
}
|
1549 |
|
1550 |
} catch (XmlImportException $e) {
|
1551 |
$logger and call_user_func($logger, __('<b>ERROR</b>', 'pmxi_plugin') . ': ' . $e->getMessage());
|
1552 |
+
$logger and PMXI_Plugin::$session['pmxi_import']['errors'] = ++PMXI_Plugin::$session->data['pmxi_import']['errors'];
|
1553 |
}
|
1554 |
|
1555 |
$logger and $is_import_complete and call_user_func($logger, __('Cleaning temporary data...', 'pmxi_plugin'));
|
1556 |
foreach ($tmp_files as $file) { // remove all temporary files created
|
1557 |
+
@unlink($file);
|
1558 |
}
|
1559 |
|
1560 |
if (($is_cron or $is_import_complete) and $this->options['is_delete_source']) {
|
1587 |
$this->set(array(
|
1588 |
'processing' => 0, // unlock cron requests
|
1589 |
'triggered' => 0,
|
1590 |
+
'queue_chunk_number' => 0,
|
1591 |
+
'registered_on' => date('Y-m-d H:i:s'),
|
1592 |
+
'iteration' => ++$this->iteration
|
1593 |
))->update();
|
1594 |
|
1595 |
$logger and call_user_func($logger, 'Done');
|
models/model.php
CHANGED
@@ -148,8 +148,7 @@ abstract class PMXI_Model extends ArrayObject {
|
|
148 |
}
|
149 |
return implode(" $operator ", $where);
|
150 |
}
|
151 |
-
|
152 |
-
|
153 |
/**
|
154 |
* Return associative array with record data
|
155 |
* @param bool[optional] $serialize Whether returned fields should be serialized
|
148 |
}
|
149 |
return implode(" $operator ", $where);
|
150 |
}
|
151 |
+
|
|
|
152 |
/**
|
153 |
* Return associative array with record data
|
154 |
* @param bool[optional] $serialize Whether returned fields should be serialized
|
models/model/record.php
CHANGED
@@ -39,7 +39,7 @@ class PMXI_Model_Record extends PMXI_Model {
|
|
39 |
}
|
40 |
return $this;
|
41 |
}
|
42 |
-
|
43 |
/**
|
44 |
* Ger records related to current one
|
45 |
* @param string $model Class name of model of related records
|
@@ -69,12 +69,12 @@ class PMXI_Model_Record extends PMXI_Model {
|
|
69 |
* @return PMXI_Model_Record
|
70 |
*/
|
71 |
public function insert() {
|
72 |
-
if ($this->wpdb->insert($this->table, $this->toArray(TRUE))) {
|
73 |
if (isset($this->auto_increment)) {
|
74 |
$this[$this->primary[0]] = $this->wpdb->insert_id;
|
75 |
-
}
|
76 |
return $this;
|
77 |
-
} else {
|
78 |
throw new Exception($this->wpdb->last_error);
|
79 |
}
|
80 |
}
|
39 |
}
|
40 |
return $this;
|
41 |
}
|
42 |
+
|
43 |
/**
|
44 |
* Ger records related to current one
|
45 |
* @param string $model Class name of model of related records
|
69 |
* @return PMXI_Model_Record
|
70 |
*/
|
71 |
public function insert() {
|
72 |
+
if ($this->wpdb->insert($this->table, $this->toArray(TRUE))) {
|
73 |
if (isset($this->auto_increment)) {
|
74 |
$this[$this->primary[0]] = $this->wpdb->insert_id;
|
75 |
+
}
|
76 |
return $this;
|
77 |
+
} else {
|
78 |
throw new Exception($this->wpdb->last_error);
|
79 |
}
|
80 |
}
|
plugin.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: WP All Import
|
4 |
Plugin URI: http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=plugins-page&utm_campaign=free+plugin
|
5 |
Description: The most powerful solution for importing XML and CSV files to WordPress. Create Posts and Pages with content from any XML or CSV file. A paid upgrade to WP All Import Pro is available for support and additional features.
|
6 |
-
Version: 3.1.
|
7 |
Author: Soflyy
|
8 |
*/
|
9 |
|
@@ -28,7 +28,7 @@ define('PMXI_ROOT_URL', rtrim(plugin_dir_url(__FILE__), '/'));
|
|
28 |
*/
|
29 |
define('PMXI_PREFIX', 'pmxi_');
|
30 |
|
31 |
-
define('PMXI_VERSION', '3.1.
|
32 |
|
33 |
define('PMXI_EDITION', 'free');
|
34 |
|
@@ -83,7 +83,8 @@ final class PMXI_Plugin {
|
|
83 |
|
84 |
public static $is_csv = false;
|
85 |
|
86 |
-
public static $csv_path = false;
|
|
|
87 |
/**
|
88 |
* Return singletone instance
|
89 |
* @return PMXI_Plugin
|
@@ -358,7 +359,13 @@ final class PMXI_Plugin {
|
|
358 |
throw new Exception('There is no previousely buffered content to display.');
|
359 |
}
|
360 |
} else {
|
361 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
$actionName = str_replace('-', '_', $action);
|
363 |
if (method_exists($controllerName, $actionName)) {
|
364 |
$this->_admin_current_screen = (object)array(
|
@@ -384,7 +391,7 @@ final class PMXI_Plugin {
|
|
384 |
} elseif ( ! $controller->isInline) {
|
385 |
ob_start();
|
386 |
$controller->$action();
|
387 |
-
$buffer = ob_get_clean();
|
388 |
} else {
|
389 |
$buffer_callback = array($controller, $action);
|
390 |
}
|
@@ -394,6 +401,10 @@ final class PMXI_Plugin {
|
|
394 |
}
|
395 |
}
|
396 |
|
|
|
|
|
|
|
|
|
397 |
protected $_admin_current_screen = NULL;
|
398 |
public function getAdminCurrentScreen()
|
399 |
{
|
@@ -570,14 +581,27 @@ final class PMXI_Plugin {
|
|
570 |
global $wpdb;
|
571 |
$tablefields = $wpdb->get_results("DESCRIBE {$table};");
|
572 |
$parent_import_id = false;
|
573 |
-
|
|
|
574 |
// Check if field exists
|
575 |
foreach ($tablefields as $tablefield) {
|
576 |
if ('parent_import_id' == $tablefield->Field) $parent_import_id = true;
|
|
|
577 |
}
|
578 |
|
579 |
if (!$parent_import_id) $wpdb->query("ALTER TABLE {$table} ADD `parent_import_id` BIGINT(20) NOT NULL DEFAULT 0;");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
580 |
|
|
|
581 |
}
|
582 |
|
583 |
/**
|
@@ -607,6 +631,8 @@ final class PMXI_Plugin {
|
|
607 |
'date_end' => 'now',
|
608 |
'custom_name' => array(),
|
609 |
'custom_value' => array(),
|
|
|
|
|
610 |
'comment_status' => 'open',
|
611 |
'ping_status' => 'open',
|
612 |
'create_draft' => 'no',
|
@@ -685,7 +711,7 @@ final class PMXI_Plugin {
|
|
685 |
'update_all_data' => 'yes',
|
686 |
'is_fast_mode' => 0,
|
687 |
'chuncking' => 1,
|
688 |
-
'import_processing' => 'ajax'
|
689 |
);
|
690 |
}
|
691 |
|
3 |
Plugin Name: WP All Import
|
4 |
Plugin URI: http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=plugins-page&utm_campaign=free+plugin
|
5 |
Description: The most powerful solution for importing XML and CSV files to WordPress. Create Posts and Pages with content from any XML or CSV file. A paid upgrade to WP All Import Pro is available for support and additional features.
|
6 |
+
Version: 3.1.2
|
7 |
Author: Soflyy
|
8 |
*/
|
9 |
|
28 |
*/
|
29 |
define('PMXI_PREFIX', 'pmxi_');
|
30 |
|
31 |
+
define('PMXI_VERSION', '3.1.2');
|
32 |
|
33 |
define('PMXI_EDITION', 'free');
|
34 |
|
83 |
|
84 |
public static $is_csv = false;
|
85 |
|
86 |
+
public static $csv_path = false;
|
87 |
+
|
88 |
/**
|
89 |
* Return singletone instance
|
90 |
* @return PMXI_Plugin
|
359 |
throw new Exception('There is no previousely buffered content to display.');
|
360 |
}
|
361 |
} else {
|
362 |
+
// capitalize prefix and first letters of class name parts
|
363 |
+
if (function_exists('preg_replace_callback')){
|
364 |
+
$controllerName = preg_replace_callback('%(^' . preg_quote(self::PREFIX, '%') . '|_).%', array($this, "replace_callback"),str_replace('-', '_', $page));
|
365 |
+
}
|
366 |
+
else{
|
367 |
+
$controllerName = preg_replace('%(^' . preg_quote(self::PREFIX, '%') . '|_).%e', 'strtoupper("$0")', str_replace('-', '_', $page));
|
368 |
+
}
|
369 |
$actionName = str_replace('-', '_', $action);
|
370 |
if (method_exists($controllerName, $actionName)) {
|
371 |
$this->_admin_current_screen = (object)array(
|
391 |
} elseif ( ! $controller->isInline) {
|
392 |
ob_start();
|
393 |
$controller->$action();
|
394 |
+
$buffer = ob_get_clean();
|
395 |
} else {
|
396 |
$buffer_callback = array($controller, $action);
|
397 |
}
|
401 |
}
|
402 |
}
|
403 |
|
404 |
+
public function replace_callback($matches){
|
405 |
+
return strtoupper($matches[0]);
|
406 |
+
}
|
407 |
+
|
408 |
protected $_admin_current_screen = NULL;
|
409 |
public function getAdminCurrentScreen()
|
410 |
{
|
581 |
global $wpdb;
|
582 |
$tablefields = $wpdb->get_results("DESCRIBE {$table};");
|
583 |
$parent_import_id = false;
|
584 |
+
$iteration = false;
|
585 |
+
|
586 |
// Check if field exists
|
587 |
foreach ($tablefields as $tablefield) {
|
588 |
if ('parent_import_id' == $tablefield->Field) $parent_import_id = true;
|
589 |
+
if ('iteration' == $tablefield->Field) $iteration = true;
|
590 |
}
|
591 |
|
592 |
if (!$parent_import_id) $wpdb->query("ALTER TABLE {$table} ADD `parent_import_id` BIGINT(20) NOT NULL DEFAULT 0;");
|
593 |
+
if (!$iteration) $wpdb->query("ALTER TABLE {$table} ADD `iteration` BIGINT(20) NOT NULL DEFAULT 0;");
|
594 |
+
|
595 |
+
$table = $this->getTablePrefix() . 'posts';
|
596 |
+
$tablefields = $wpdb->get_results("DESCRIBE {$table};");
|
597 |
+
$iteration = false;
|
598 |
+
|
599 |
+
// Check if field exists
|
600 |
+
foreach ($tablefields as $tablefield) {
|
601 |
+
if ('iteration' == $tablefield->Field) $iteration = true;
|
602 |
+
}
|
603 |
|
604 |
+
if (!$iteration) $wpdb->query("ALTER TABLE {$table} ADD `iteration` BIGINT(20) NOT NULL DEFAULT 0;");
|
605 |
}
|
606 |
|
607 |
/**
|
631 |
'date_end' => 'now',
|
632 |
'custom_name' => array(),
|
633 |
'custom_value' => array(),
|
634 |
+
'custom_format' => array(),
|
635 |
+
'serialized_values' => array(),
|
636 |
'comment_status' => 'open',
|
637 |
'ping_status' => 'open',
|
638 |
'create_draft' => 'no',
|
711 |
'update_all_data' => 'yes',
|
712 |
'is_fast_mode' => 0,
|
713 |
'chuncking' => 1,
|
714 |
+
'import_processing' => 'ajax'
|
715 |
);
|
716 |
}
|
717 |
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: soflyy
|
3 |
Tags: wordpress, xml, csv, datafeed, import
|
4 |
Requires at least: 3.6.1
|
5 |
-
Tested up to: 3.
|
6 |
-
Stable tag: 3.1.
|
7 |
|
8 |
WP All Import is an extremely powerful plugin that makes it easy to import any XML or CSV file to WordPress.
|
9 |
|
@@ -43,10 +43,6 @@ Our YouTube channel has many [videos showing WP All Import in action.](http://ww
|
|
43 |
|
44 |
Need to [import XML and CSV to WooCommerce?](http://wordpress.org/plugins/woocommerce-xml-csv-product-import/) Check out our WooCommerce add-on.
|
45 |
|
46 |
-
Follow [@WPAllImport](http://twitter.com/WPAllImport) on Twitter.
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
== Premium Support ==
|
51 |
Upgrade to the professional edition of WP All Import for premium support.
|
52 |
|
@@ -91,6 +87,25 @@ Does it work with special character encoding like Hebrew, Arabic, Chinese, etc?
|
|
91 |
|
92 |
== Changelog ==
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
= 3.1.0 =
|
95 |
* Compatibility with WP 3.8
|
96 |
* Compatibility with WPAI WooCommerce add-on (paid) 1.2.4
|
2 |
Contributors: soflyy
|
3 |
Tags: wordpress, xml, csv, datafeed, import
|
4 |
Requires at least: 3.6.1
|
5 |
+
Tested up to: 3.9
|
6 |
+
Stable tag: 3.1.2
|
7 |
|
8 |
WP All Import is an extremely powerful plugin that makes it easy to import any XML or CSV file to WordPress.
|
9 |
|
43 |
|
44 |
Need to [import XML and CSV to WooCommerce?](http://wordpress.org/plugins/woocommerce-xml-csv-product-import/) Check out our WooCommerce add-on.
|
45 |
|
|
|
|
|
|
|
|
|
46 |
== Premium Support ==
|
47 |
Upgrade to the professional edition of WP All Import for premium support.
|
48 |
|
87 |
|
88 |
== Changelog ==
|
89 |
|
90 |
+
= 3.1.2 =
|
91 |
+
* added compatibility with WP 3.9
|
92 |
+
* added autodetect session mode
|
93 |
+
* updated convertation CSV to XML with XMLWriter
|
94 |
+
* fixed import *.zip files
|
95 |
+
* fixed xpath helper on step 2
|
96 |
+
* fixed showing zeros in XML tree
|
97 |
+
* fixed deleting history files
|
98 |
+
* fixed autodetect image extensions
|
99 |
+
* fixed increasing SQL query length
|
100 |
+
* allow post content to be empty on step 3
|
101 |
+
* delete deprecated settings "my csv contain html code" and "case sensitivity"
|
102 |
+
|
103 |
+
= 3.1.1 =
|
104 |
+
* Fixed compatibility with addons
|
105 |
+
* Fixed "download image" option for import products
|
106 |
+
* Fixed CSS for WP 3.8
|
107 |
+
* Fixed dismiss links
|
108 |
+
|
109 |
= 3.1.0 =
|
110 |
* Compatibility with WP 3.8
|
111 |
* Compatibility with WPAI WooCommerce add-on (paid) 1.2.4
|
schema.php
CHANGED
@@ -55,14 +55,14 @@ CREATE TABLE {$table_prefix}imports (
|
|
55 |
root_element VARCHAR(255) DEFAULT '',
|
56 |
processing BOOL NOT NULL DEFAULT 0,
|
57 |
triggered BOOL NOT NULL DEFAULT 0,
|
58 |
-
queue_chunk_number BIGINT(20) NOT NULL DEFAULT 0,
|
59 |
-
current_post_ids LONGBLOB,
|
60 |
first_import TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
61 |
count BIGINT(20) NOT NULL DEFAULT 0,
|
62 |
imported BIGINT(20) NOT NULL DEFAULT 0,
|
63 |
created BIGINT(20) NOT NULL DEFAULT 0,
|
64 |
updated BIGINT(20) NOT NULL DEFAULT 0,
|
65 |
skipped BIGINT(20) NOT NULL DEFAULT 0,
|
|
|
66 |
PRIMARY KEY (id)
|
67 |
) $charset_collate;
|
68 |
CREATE TABLE {$table_prefix}posts (
|
@@ -71,6 +71,7 @@ CREATE TABLE {$table_prefix}posts (
|
|
71 |
import_id BIGINT(20) UNSIGNED NOT NULL,
|
72 |
unique_key TEXT,
|
73 |
product_key TEXT,
|
|
|
74 |
PRIMARY KEY (id)
|
75 |
) $charset_collate;
|
76 |
CREATE TABLE {$table_prefix}files (
|
55 |
root_element VARCHAR(255) DEFAULT '',
|
56 |
processing BOOL NOT NULL DEFAULT 0,
|
57 |
triggered BOOL NOT NULL DEFAULT 0,
|
58 |
+
queue_chunk_number BIGINT(20) NOT NULL DEFAULT 0,
|
|
|
59 |
first_import TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
60 |
count BIGINT(20) NOT NULL DEFAULT 0,
|
61 |
imported BIGINT(20) NOT NULL DEFAULT 0,
|
62 |
created BIGINT(20) NOT NULL DEFAULT 0,
|
63 |
updated BIGINT(20) NOT NULL DEFAULT 0,
|
64 |
skipped BIGINT(20) NOT NULL DEFAULT 0,
|
65 |
+
iteration BIGINT(20) NOT NULL DEFAULT 0,
|
66 |
PRIMARY KEY (id)
|
67 |
) $charset_collate;
|
68 |
CREATE TABLE {$table_prefix}posts (
|
71 |
import_id BIGINT(20) UNSIGNED NOT NULL,
|
72 |
unique_key TEXT,
|
73 |
product_key TEXT,
|
74 |
+
iteration BIGINT(20) NOT NULL DEFAULT 0,
|
75 |
PRIMARY KEY (id)
|
76 |
) $charset_collate;
|
77 |
CREATE TABLE {$table_prefix}files (
|
static/css/admin-wp-3.8.css
CHANGED
@@ -16,4 +16,9 @@
|
|
16 |
}
|
17 |
.pmxi_plugin #titlediv #title{
|
18 |
color: #444 !important;
|
|
|
|
|
|
|
|
|
|
|
19 |
}
|
16 |
}
|
17 |
.pmxi_plugin #titlediv #title{
|
18 |
color: #444 !important;
|
19 |
+
}
|
20 |
+
.pmxi_plugin h2.woo-nav-tab-wrapper{
|
21 |
+
padding-bottom: 0;
|
22 |
+
border-bottom: 1px solid #ccc;
|
23 |
+
margin-bottom: 10px;
|
24 |
}
|
static/css/admin.css
CHANGED
@@ -65,7 +65,7 @@
|
|
65 |
border-radius: 4px;
|
66 |
border-style: solid;
|
67 |
border-width: 1px;
|
68 |
-
font-family: "Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif
|
69 |
text-decoration: none;
|
70 |
}
|
71 |
.pmxi_plugin a.add-new:hover {
|
@@ -278,7 +278,7 @@
|
|
278 |
.pmxi_plugin table.form-table.custom-params input {
|
279 |
margin-left: 0;
|
280 |
}
|
281 |
-
.pmxi_plugin table.form-table tr.template {
|
282 |
display: none;
|
283 |
}
|
284 |
/*@*/
|
@@ -542,18 +542,23 @@ table.xml table {
|
|
542 |
list-style: none;
|
543 |
}
|
544 |
.pmxi_plugin .no-margin{ margin:0px; }
|
545 |
-
.pmxi_plugin .icon-item, .pmxi_plugin .add-new-custom{
|
546 |
display: inline-block;
|
547 |
width: 16px;
|
548 |
height: 16px;
|
549 |
margin: 0px 3px;
|
550 |
}
|
551 |
-
.pmxi_plugin .add-new-ico, .pmxi_plugin .add-new-custom{
|
552 |
background: url("../img/ico-add-new.png") no-repeat 0px 4px;
|
553 |
width:70px;
|
554 |
height:25px;
|
555 |
-
padding-left:
|
556 |
color:#21759B;
|
|
|
|
|
|
|
|
|
|
|
557 |
}
|
558 |
|
559 |
.pmxi_plugin .remove-ico{
|
@@ -809,6 +814,7 @@ table.xml table {
|
|
809 |
height: 16px;
|
810 |
position: absolute;
|
811 |
right: 20px;
|
|
|
812 |
width: 16px;
|
813 |
}
|
814 |
.pmxi_plugin .switcher-target-is_keep_former_posts{
|
@@ -989,7 +995,7 @@ table.xml table {
|
|
989 |
border: 1px solid #C5DBEC;*/
|
990 |
height: 40px;
|
991 |
line-height: 39px;
|
992 |
-
margin-left: 10px;
|
993 |
/*width: 90px;*/
|
994 |
}
|
995 |
.pmxi_plugin .drag-element .assign_post{
|
@@ -1016,7 +1022,9 @@ table.xml table {
|
|
1016 |
width: 50%;
|
1017 |
}
|
1018 |
.pmxi_plugin .custom-params tr td.action{
|
1019 |
-
width:100% !important;
|
|
|
|
|
1020 |
}
|
1021 |
.pmxi_plugin .load_options{
|
1022 |
height: 0;
|
@@ -1330,6 +1338,21 @@ table.xml table {
|
|
1330 |
margin-right: 5px;
|
1331 |
padding: 5px 0;
|
1332 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1333 |
|
1334 |
.pmxi_plugin .pmxi_stars{
|
1335 |
display: inline-block;
|
@@ -1352,7 +1375,4 @@ table.xml table {
|
|
1352 |
.pmxi_plugin .upgrade_link{
|
1353 |
color: #21759B;
|
1354 |
font-size: 1.3em;
|
1355 |
-
}
|
1356 |
-
.pmxi_plugin .ui-progressbar{
|
1357 |
-
height: 32px;
|
1358 |
-
}
|
65 |
border-radius: 4px;
|
66 |
border-style: solid;
|
67 |
border-width: 1px;
|
68 |
+
/*font-family: "Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;*/
|
69 |
text-decoration: none;
|
70 |
}
|
71 |
.pmxi_plugin a.add-new:hover {
|
278 |
.pmxi_plugin table.form-table.custom-params input {
|
279 |
margin-left: 0;
|
280 |
}
|
281 |
+
.pmxi_plugin table.form-table tr.template, .pmxi_plugin table.form-table ol li.template {
|
282 |
display: none;
|
283 |
}
|
284 |
/*@*/
|
542 |
list-style: none;
|
543 |
}
|
544 |
.pmxi_plugin .no-margin{ margin:0px; }
|
545 |
+
.pmxi_plugin .icon-item, .pmxi_plugin .add-new-custom, .pmxi_plugin .add-new-key{
|
546 |
display: inline-block;
|
547 |
width: 16px;
|
548 |
height: 16px;
|
549 |
margin: 0px 3px;
|
550 |
}
|
551 |
+
.pmxi_plugin .add-new-ico, .pmxi_plugin .add-new-custom, .pmxi_plugin .add-new-key{
|
552 |
background: url("../img/ico-add-new.png") no-repeat 0px 4px;
|
553 |
width:70px;
|
554 |
height:25px;
|
555 |
+
padding-left: 20px;
|
556 |
color:#21759B;
|
557 |
+
font-family: "Open Sans",sans-serif;
|
558 |
+
padding-top: 2px;
|
559 |
+
text-decoration: underline;
|
560 |
+
display: block;
|
561 |
+
margin: 0 auto;
|
562 |
}
|
563 |
|
564 |
.pmxi_plugin .remove-ico{
|
814 |
height: 16px;
|
815 |
position: absolute;
|
816 |
right: 20px;
|
817 |
+
top:0;
|
818 |
width: 16px;
|
819 |
}
|
820 |
.pmxi_plugin .switcher-target-is_keep_former_posts{
|
995 |
border: 1px solid #C5DBEC;*/
|
996 |
height: 40px;
|
997 |
line-height: 39px;
|
998 |
+
margin-left: 10px;
|
999 |
/*width: 90px;*/
|
1000 |
}
|
1001 |
.pmxi_plugin .drag-element .assign_post{
|
1022 |
width: 50%;
|
1023 |
}
|
1024 |
.pmxi_plugin .custom-params tr td.action{
|
1025 |
+
width:100% !important;
|
1026 |
+
position: relative;
|
1027 |
+
display: block;
|
1028 |
}
|
1029 |
.pmxi_plugin .load_options{
|
1030 |
height: 0;
|
1338 |
margin-right: 5px;
|
1339 |
padding: 5px 0;
|
1340 |
}
|
1341 |
+
.pmxi_plugin .to_the_left{
|
1342 |
+
margin-top: 5px;
|
1343 |
+
margin-left: 12px;
|
1344 |
+
text-align: left;
|
1345 |
+
}
|
1346 |
+
.pmxi_plugin .to_the_left label{
|
1347 |
+
margin: 0 10px 0 0 !important;
|
1348 |
+
}
|
1349 |
+
.pmxi_plugin .custom_type table{
|
1350 |
+
width: 80%;
|
1351 |
+
margin: 0 auto;
|
1352 |
+
}
|
1353 |
+
.pmxi_plugin span.remove{
|
1354 |
+
position: static !important;
|
1355 |
+
}
|
1356 |
|
1357 |
.pmxi_plugin .pmxi_stars{
|
1358 |
display: inline-block;
|
1375 |
.pmxi_plugin .upgrade_link{
|
1376 |
color: #21759B;
|
1377 |
font-size: 1.3em;
|
1378 |
+
}
|
|
|
|
|
|
static/js/admin.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
* plugin admin area javascript
|
3 |
*/
|
4 |
(function($){$(function () {
|
5 |
-
if ( ! $('body.pmxi_plugin').length) return; // do not execute any code if we are not on plugin page
|
6 |
|
7 |
// fix layout position
|
8 |
setTimeout(function () {
|
@@ -32,63 +32,8 @@
|
|
32 |
}).each(function () { // fix tipsy title for IE
|
33 |
$(this).attr('original-title', $(this).attr('title'));
|
34 |
$(this).removeAttr('title');
|
35 |
-
});
|
36 |
-
|
37 |
-
if ($('#pmxi_tabs').length){
|
38 |
-
if ($('form.options').length){
|
39 |
-
$('.nav-tab').removeClass('nav-tab-active');
|
40 |
-
if ($('#selected_post_type').val() != ''){
|
41 |
-
var post_type_founded = false;
|
42 |
-
$('.pmxi_tab').hide();
|
43 |
-
$('input[name=custom_type]').each(function(i){
|
44 |
-
if ($(this).val() == $('#selected_post_type').val()) {
|
45 |
-
$('.nav-tab[rel='+ $(this).val() +']').addClass('nav-tab-active');
|
46 |
-
$(this).parents('.pmxi_tab:first').show();
|
47 |
-
post_type_founded = true;
|
48 |
-
}
|
49 |
-
});
|
50 |
-
if ( ! post_type_founded){
|
51 |
-
if ($('#selected_type').val() == 'post'){
|
52 |
-
$('.nav-tab[rel=posts]').addClass('nav-tab-active');
|
53 |
-
$('div#posts').show();
|
54 |
-
}
|
55 |
-
else{
|
56 |
-
$('.nav-tab[rel=pages]').addClass('nav-tab-active');
|
57 |
-
$('div#pages').show();
|
58 |
-
}
|
59 |
-
}
|
60 |
-
}
|
61 |
-
else if ($('#selected_type').val() != ''){
|
62 |
-
if ($('#selected_type').val() == 'post'){
|
63 |
-
$('.nav-tab[rel=posts]').addClass('nav-tab-active');
|
64 |
-
$('div#posts').show();
|
65 |
-
}
|
66 |
-
else{
|
67 |
-
$('.nav-tab[rel=pages]').addClass('nav-tab-active');
|
68 |
-
$('div#pages').show();
|
69 |
-
}
|
70 |
-
}
|
71 |
-
$('.nav-tab-wrapper').show();
|
72 |
-
}
|
73 |
-
else
|
74 |
-
$('#pmxi_tabs').tabs().show();
|
75 |
-
}
|
76 |
-
|
77 |
-
$('.pmxi_plugin').find('.nav-tab').click(function(){
|
78 |
-
$('.nav-tab').removeClass('nav-tab-active');
|
79 |
-
$(this).addClass('nav-tab-active');
|
80 |
-
$('.pmxi_tab').hide();
|
81 |
-
$('div#' + $(this).attr('rel')).fadeIn();
|
82 |
-
|
83 |
-
if ( parseInt($('div#' + $(this).attr('rel')).find('.is_disabled').val()) ) {
|
84 |
-
$('div#' + $(this).attr('rel')).find('input, select, textarea').attr('disabled','disabled');
|
85 |
-
}
|
86 |
-
/*else {
|
87 |
-
$('div#' + $(this).attr('rel')).find('input, select, textarea').removeAttr('readonly');
|
88 |
-
}*/
|
89 |
-
|
90 |
});
|
91 |
-
|
92 |
// swither show/hide logic
|
93 |
$('input.switcher').live('change', function (e) {
|
94 |
|
@@ -201,6 +146,8 @@
|
|
201 |
}
|
202 |
});
|
203 |
$form.find('.preview').click(function () {
|
|
|
|
|
204 |
$modal.addClass('loading').empty().dialog('open').dialog('option', 'position', 'center');
|
205 |
if (tinyMCE != undefined) tinyMCE.triggerSave(false, false);
|
206 |
$.post('admin.php?page=pmxi-admin-import&action=preview', $form.serialize(), function (response) {
|
@@ -292,7 +239,8 @@
|
|
292 |
var $template = $(this).parents('table').first().find('tr.template');
|
293 |
$template.clone(true).insertBefore($template).css('display', 'none').removeClass('template').fadeIn();
|
294 |
return false;
|
295 |
-
});
|
|
|
296 |
// options form: auto submit when `load options` checkbox is checked
|
297 |
$('input[name="load_options"]').click(function () {
|
298 |
if ($(this).is(':checked')) $(this).parents('form').submit();
|
@@ -420,7 +368,7 @@
|
|
420 |
}
|
421 |
});
|
422 |
|
423 |
-
if ($('#content').length && window.tinymce != undefined) tinymce.dom.Event.add('wp-content-editor-container', 'click', function(e) {
|
424 |
if (dblclickbuf.selected)
|
425 |
{
|
426 |
tinyMCE.activeEditor.selection.setContent(dblclickbuf.value);
|
@@ -428,7 +376,7 @@
|
|
428 |
dblclickbuf.value = '';
|
429 |
dblclickbuf.selected = false;
|
430 |
}
|
431 |
-
})
|
432 |
|
433 |
this.find('.xml-tag.opening > .xml-tag-name, .xml-attr-name').each(function () {
|
434 |
var $this = $(this);
|
@@ -639,7 +587,7 @@
|
|
639 |
|
640 |
switch (condition){
|
641 |
case 'equals':
|
642 |
-
filter += ' = %s';
|
643 |
break;
|
644 |
case 'greater':
|
645 |
filter += ' > %s';
|
@@ -656,6 +604,9 @@
|
|
656 |
case 'contains':
|
657 |
filter += '[contains(.,"%s")]';
|
658 |
break;
|
|
|
|
|
|
|
659 |
case 'is_empty':
|
660 |
filter += '[not(text())]';
|
661 |
break;
|
@@ -767,10 +718,10 @@
|
|
767 |
|
768 |
/* Categories hierarchy */
|
769 |
|
770 |
-
$('.sortable').nestedSortable({
|
771 |
handle: 'div',
|
772 |
-
items: 'li',
|
773 |
-
toleranceElement: '> div',
|
774 |
update: function () {
|
775 |
$(this).parents('td:first').find('.hierarhy-output').val(window.JSON.stringify($(this).nestedSortable('toArray', {startDepthCount: 0})));
|
776 |
if ($(this).parents('td:first').find('input:first').val() == '') $(this).parents('td:first').find('.hierarhy-output').val('');
|
@@ -778,22 +729,22 @@
|
|
778 |
});
|
779 |
|
780 |
$('.drag-element').find('input').live('blur', function(){
|
781 |
-
$(this).parents('td:first').find('.hierarhy-output').val(window.JSON.stringify($(this).parents('.sortable:first').nestedSortable('toArray', {startDepthCount: 0})));
|
782 |
if ($(this).parents('td:first').find('input:first').val() == '') $(this).parents('td:first').find('.hierarhy-output').val('');
|
783 |
});
|
784 |
|
785 |
$('.drag-element').find('input').live('change', function(){
|
786 |
-
$(this).parents('td:first').find('.hierarhy-output').val(window.JSON.stringify($(this).parents('.sortable:first').nestedSortable('toArray', {startDepthCount: 0})));
|
787 |
if ($(this).parents('td:first').find('input:first').val() == '') $(this).parents('td:first').find('.hierarhy-output').val('');
|
788 |
});
|
789 |
|
790 |
$('.drag-element').find('input').live('hover', function(){},function(){
|
791 |
-
$(this).parents('td:first').find('.hierarhy-output').val(window.JSON.stringify($(this).parents('.sortable:first').nestedSortable('toArray', {startDepthCount: 0})));
|
792 |
if ($(this).parents('td:first').find('input:first').val() == '') $(this).parents('td:first').find('.hierarhy-output').val('');
|
793 |
});
|
794 |
|
795 |
$('.taxonomy_auto_nested').live('click', function(){
|
796 |
-
$(this).parents('td:first').find('.hierarhy-output').val(window.JSON.stringify($(this).parents('td:first').find('.sortable:first').nestedSortable('toArray', {startDepthCount: 0})));
|
797 |
if ($(this).parents('td:first').find('input:first').val() == '') $(this).parents('td:first').find('.hierarhy-output').val('');
|
798 |
});
|
799 |
|
@@ -805,34 +756,109 @@
|
|
805 |
parent_td.find('ol.sortable:first').find('li').each(function(i, e){
|
806 |
$(this).attr({'id':'item_'+ (i+1)});
|
807 |
});
|
808 |
-
parent_td.find('.hierarhy-output').val(window.JSON.stringify(parent_td.find('.sortable:first').nestedSortable('toArray', {startDepthCount: 0})));
|
809 |
if (parent_td.find('input:first').val() == '') parent_td.find('.hierarhy-output').val('');
|
810 |
});
|
811 |
|
812 |
-
$('.add-new-ico').live('click', function(){
|
813 |
-
var count = $(this).parents('tr:first').find('ol.sortable').find('li').length + 1;
|
814 |
-
|
815 |
-
$(this).
|
816 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
817 |
$('.widefat').bind('focus', insertxpath );
|
|
|
|
|
|
|
|
|
|
|
818 |
});
|
819 |
|
820 |
$('form.options').find('input[type=submit]').click(function(e){
|
|
|
821 |
e.preventDefault();
|
822 |
|
823 |
-
$('.hierarhy-output').each(function(){
|
824 |
-
$(this).
|
825 |
-
if (
|
|
|
|
|
|
|
826 |
});
|
827 |
if ($(this).attr('name') == 'btn_save_only') $('.save_only').val('1');
|
828 |
|
829 |
-
$('input[name^=in_variations], input[name^=is_visible], input[name^=is_taxonomy], input[name^=create_taxonomy_in_not_exists], input[name^=variable_create_taxonomy_in_not_exists], input[name^=variable_in_variations], input[name^=variable_is_visible], input[name^=variable_is_taxonomy]').each(function(){
|
830 |
if ( ! $(this).is(':checked') && ! $(this).parents('.form-field:first').hasClass('template')){
|
831 |
$(this).val('0').attr('checked','checked');
|
832 |
}
|
833 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
834 |
|
835 |
$(this).parents('form:first').submit();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
836 |
});
|
837 |
|
838 |
/* END Categories hierarchy */
|
@@ -888,15 +914,17 @@
|
|
888 |
|
889 |
// Step 4 - custom meta keys helper
|
890 |
$('.existing_meta_keys').change(function(){
|
891 |
-
|
|
|
892 |
var key = $(this).find('option:selected').val();
|
893 |
|
894 |
if ("" != $(this).val()) {
|
|
|
895 |
parent_fieldset.find('input[name^=custom_name]:visible').each(function(){
|
896 |
-
if ("" == $(this).val()) $(this).parents('tr
|
897 |
});
|
898 |
-
parent_fieldset.find('a.
|
899 |
-
parent_fieldset.find('input[name^=custom_name]:visible
|
900 |
|
901 |
$(this).prop('selectedIndex',0);
|
902 |
|
@@ -910,13 +938,15 @@
|
|
910 |
|
911 |
}, 'html');
|
912 |
}
|
|
|
913 |
});
|
914 |
|
915 |
$('input[name^=custom_name]').live('change', function(){
|
|
|
916 |
var $ths = $(this);
|
917 |
$ths.parents('fieldset:first').addClass('loading');
|
918 |
$.post('admin.php?page=pmxi-admin-settings&action=meta_values', {key: $ths.val()}, function (data) {
|
919 |
-
$ths.
|
920 |
$ths.after(data);
|
921 |
$ths.parents('fieldset:first').removeClass('loading');
|
922 |
}, 'html');
|
@@ -985,7 +1015,7 @@
|
|
985 |
|
986 |
$('.pmxi_choosen').each(function(){
|
987 |
$(this).find(".choosen_input").select2({tags: $(this).find('.choosen_values').html().split(',')});
|
988 |
-
});
|
989 |
|
990 |
$('.pmxi_tips_pointer').click(function(){
|
991 |
$(this).pointer({
|
@@ -1002,6 +1032,10 @@
|
|
1002 |
});
|
1003 |
}
|
1004 |
}).pointer('open');
|
1005 |
-
});
|
|
|
|
|
|
|
|
|
1006 |
|
1007 |
});})(jQuery);
|
2 |
* plugin admin area javascript
|
3 |
*/
|
4 |
(function($){$(function () {
|
5 |
+
if ( ! $('body.pmxi_plugin').length) return; // do not execute any code if we are not on plugin page
|
6 |
|
7 |
// fix layout position
|
8 |
setTimeout(function () {
|
32 |
}).each(function () { // fix tipsy title for IE
|
33 |
$(this).attr('original-title', $(this).attr('title'));
|
34 |
$(this).removeAttr('title');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
});
|
36 |
+
|
37 |
// swither show/hide logic
|
38 |
$('input.switcher').live('change', function (e) {
|
39 |
|
146 |
}
|
147 |
});
|
148 |
$form.find('.preview').click(function () {
|
149 |
+
$preview.find('input[name="tagno"]').die();
|
150 |
+
$preview.find('.navigation a').die('click');
|
151 |
$modal.addClass('loading').empty().dialog('open').dialog('option', 'position', 'center');
|
152 |
if (tinyMCE != undefined) tinyMCE.triggerSave(false, false);
|
153 |
$.post('admin.php?page=pmxi-admin-import&action=preview', $form.serialize(), function (response) {
|
239 |
var $template = $(this).parents('table').first().find('tr.template');
|
240 |
$template.clone(true).insertBefore($template).css('display', 'none').removeClass('template').fadeIn();
|
241 |
return false;
|
242 |
+
});
|
243 |
+
|
244 |
// options form: auto submit when `load options` checkbox is checked
|
245 |
$('input[name="load_options"]').click(function () {
|
246 |
if ($(this).is(':checked')) $(this).parents('form').submit();
|
368 |
}
|
369 |
});
|
370 |
|
371 |
+
/*if ($('#content').length && window.tinymce != undefined) tinymce.dom.Event.add('wp-content-editor-container', 'click', function(e) {
|
372 |
if (dblclickbuf.selected)
|
373 |
{
|
374 |
tinyMCE.activeEditor.selection.setContent(dblclickbuf.value);
|
376 |
dblclickbuf.value = '';
|
377 |
dblclickbuf.selected = false;
|
378 |
}
|
379 |
+
});*/
|
380 |
|
381 |
this.find('.xml-tag.opening > .xml-tag-name, .xml-attr-name').each(function () {
|
382 |
var $this = $(this);
|
587 |
|
588 |
switch (condition){
|
589 |
case 'equals':
|
590 |
+
filter += ' = "%s"';
|
591 |
break;
|
592 |
case 'greater':
|
593 |
filter += ' > %s';
|
604 |
case 'contains':
|
605 |
filter += '[contains(.,"%s")]';
|
606 |
break;
|
607 |
+
case 'not_contains':
|
608 |
+
filter += '[not(contains(.,"%s"))]';
|
609 |
+
break;
|
610 |
case 'is_empty':
|
611 |
filter += '[not(text())]';
|
612 |
break;
|
718 |
|
719 |
/* Categories hierarchy */
|
720 |
|
721 |
+
$('ol.sortable').nestedSortable({
|
722 |
handle: 'div',
|
723 |
+
items: 'li.dragging',
|
724 |
+
toleranceElement: '> div',
|
725 |
update: function () {
|
726 |
$(this).parents('td:first').find('.hierarhy-output').val(window.JSON.stringify($(this).nestedSortable('toArray', {startDepthCount: 0})));
|
727 |
if ($(this).parents('td:first').find('input:first').val() == '') $(this).parents('td:first').find('.hierarhy-output').val('');
|
729 |
});
|
730 |
|
731 |
$('.drag-element').find('input').live('blur', function(){
|
732 |
+
$(this).parents('td:first').find('.hierarhy-output').val(window.JSON.stringify($(this).parents('.ui-sortable:first').nestedSortable('toArray', {startDepthCount: 0})));
|
733 |
if ($(this).parents('td:first').find('input:first').val() == '') $(this).parents('td:first').find('.hierarhy-output').val('');
|
734 |
});
|
735 |
|
736 |
$('.drag-element').find('input').live('change', function(){
|
737 |
+
$(this).parents('td:first').find('.hierarhy-output').val(window.JSON.stringify($(this).parents('.ui-sortable:first').nestedSortable('toArray', {startDepthCount: 0})));
|
738 |
if ($(this).parents('td:first').find('input:first').val() == '') $(this).parents('td:first').find('.hierarhy-output').val('');
|
739 |
});
|
740 |
|
741 |
$('.drag-element').find('input').live('hover', function(){},function(){
|
742 |
+
$(this).parents('td:first').find('.hierarhy-output').val(window.JSON.stringify($(this).parents('.ui-sortable:first').nestedSortable('toArray', {startDepthCount: 0})));
|
743 |
if ($(this).parents('td:first').find('input:first').val() == '') $(this).parents('td:first').find('.hierarhy-output').val('');
|
744 |
});
|
745 |
|
746 |
$('.taxonomy_auto_nested').live('click', function(){
|
747 |
+
$(this).parents('td:first').find('.hierarhy-output').val(window.JSON.stringify($(this).parents('td:first').find('.ui-sortable:first').nestedSortable('toArray', {startDepthCount: 0})));
|
748 |
if ($(this).parents('td:first').find('input:first').val() == '') $(this).parents('td:first').find('.hierarhy-output').val('');
|
749 |
});
|
750 |
|
756 |
parent_td.find('ol.sortable:first').find('li').each(function(i, e){
|
757 |
$(this).attr({'id':'item_'+ (i+1)});
|
758 |
});
|
759 |
+
parent_td.find('.hierarhy-output').val(window.JSON.stringify(parent_td.find('.ui-sortable:first').nestedSortable('toArray', {startDepthCount: 0})));
|
760 |
if (parent_td.find('input:first').val() == '') parent_td.find('.hierarhy-output').val('');
|
761 |
});
|
762 |
|
763 |
+
$('.add-new-ico').live('click', function(){
|
764 |
+
var count = $(this).parents('tr:first').find('ol.sortable').find('li.dragging').length + 1;
|
765 |
+
|
766 |
+
var $template = $(this).prev('ol').children('li.template');
|
767 |
+
$clone = $template.clone(true);
|
768 |
+
$clone.addClass('dragging').attr({'id': $clone.attr('id') + '_' + count}).find('input[type=checkbox][name^=categories_mapping]').each(function(){
|
769 |
+
$(this).attr({'id': $(this).attr('id') + '_' + count});
|
770 |
+
$(this).next('label').attr({'for':$(this).next('label').attr('for') + '_' + count});
|
771 |
+
$(this).next('label').next('div').addClass($(this).next('label').next('div').attr('rel') + '_' + count);
|
772 |
+
});
|
773 |
+
$clone.insertBefore($template).css('display', 'none').removeClass('template').fadeIn().find('input.switcher').change();
|
774 |
+
|
775 |
+
var sortable = $(this).parents('.ui-sortable:first');
|
776 |
+
if (sortable.length){
|
777 |
+
$(this).parents('td:first').find('.hierarhy-output').val(window.JSON.stringify(sortable.nestedSortable('toArray', {startDepthCount: 0})));
|
778 |
+
if ($(this).parents('td:first').find('input:first').val() == '') $(this).parents('td:first').find('.hierarhy-output').val('');
|
779 |
+
}
|
780 |
$('.widefat').bind('focus', insertxpath );
|
781 |
+
|
782 |
+
});
|
783 |
+
|
784 |
+
$('ol.sortable').each(function(){
|
785 |
+
if ( ! $(this).children('li').not('.template').length ) $(this).next('.add-new-ico').click();
|
786 |
});
|
787 |
|
788 |
$('form.options').find('input[type=submit]').click(function(e){
|
789 |
+
|
790 |
e.preventDefault();
|
791 |
|
792 |
+
$('.hierarhy-output').each(function(){
|
793 |
+
var sortable = $(this).parents('td:first').find('.ui-sortable:first');
|
794 |
+
if (sortable.length){
|
795 |
+
$(this).val(window.JSON.stringify(sortable.nestedSortable('toArray', {startDepthCount: 0})));
|
796 |
+
if ($(this).parents('td:first').find('input:first').val() == '') $(this).val('');
|
797 |
+
}
|
798 |
});
|
799 |
if ($(this).attr('name') == 'btn_save_only') $('.save_only').val('1');
|
800 |
|
801 |
+
$('input[name^=in_variations], input[name^=is_visible], input[name^=is_taxonomy], input[name^=create_taxonomy_in_not_exists], input[name^=variable_create_taxonomy_in_not_exists], input[name^=variable_in_variations], input[name^=variable_is_visible], input[name^=variable_is_taxonomy], input[name^=custom_format]').each(function(){
|
802 |
if ( ! $(this).is(':checked') && ! $(this).parents('.form-field:first').hasClass('template')){
|
803 |
$(this).val('0').attr('checked','checked');
|
804 |
}
|
805 |
+
});
|
806 |
+
|
807 |
+
$('.custom_type[rel=serialized]:visible').each(function(){
|
808 |
+
var values = new Array();
|
809 |
+
$(this).find('.form-field').each(function(){
|
810 |
+
if ($(this).find('.serialized_value').val() != "")
|
811 |
+
{
|
812 |
+
var skey = $(this).find('.serialized_key').val();
|
813 |
+
if ('' == skey){
|
814 |
+
values.push($(this).find('.serialized_value').val());
|
815 |
+
}
|
816 |
+
else
|
817 |
+
{
|
818 |
+
var obj = {};
|
819 |
+
obj[skey] = $(this).find('.serialized_value').val();
|
820 |
+
values.push(obj);
|
821 |
+
}
|
822 |
+
//values[skey] = $(this).find('.serialized_value').val();
|
823 |
+
|
824 |
+
}
|
825 |
+
});
|
826 |
+
$(this).find('input[name^=serialized_values]').val(window.JSON.stringify(values));
|
827 |
+
});
|
828 |
|
829 |
$(this).parents('form:first').submit();
|
830 |
+
|
831 |
+
});
|
832 |
+
|
833 |
+
$('.add-new-custom').click(function(){
|
834 |
+
var $template = $(this).parents('table').first().children('tbody').children('tr.template');
|
835 |
+
$number = $(this).parents('table').first().children('tbody').children('tr').length - 2;
|
836 |
+
$clone = $template.clone(true);
|
837 |
+
$clone.find('input[name^=custom_format]').each(function(){
|
838 |
+
$(this).attr({'id': $(this).attr('id') + '_' + $number});
|
839 |
+
});
|
840 |
+
$clone.find('label').each(function(){
|
841 |
+
$(this).attr({'for': $(this).attr('for') + '_' + $number});
|
842 |
+
});
|
843 |
+
$clone.insertBefore($template).css('display', 'none').removeClass('template').fadeIn();
|
844 |
+
return false;
|
845 |
+
});
|
846 |
+
|
847 |
+
$('.add-new-key').live('click', function(){
|
848 |
+
var $template = $(this).parents('table').first().find('tr.template');
|
849 |
+
$template.clone(true).insertBefore($template).css('display', 'none').removeClass('template').fadeIn();
|
850 |
+
});
|
851 |
+
|
852 |
+
$('input[name^=custom_format]').live('click', function(){
|
853 |
+
|
854 |
+
$(this).parents('.form-field:first').find('.custom_type').hide();
|
855 |
+
if ($(this).is(':checked')){
|
856 |
+
$(this).parents('.form-field:first').find('div[rel=serialized]').show();
|
857 |
+
}
|
858 |
+
else{
|
859 |
+
$(this).parents('.form-field:first').find('div[rel=default]').show();
|
860 |
+
}
|
861 |
+
|
862 |
});
|
863 |
|
864 |
/* END Categories hierarchy */
|
914 |
|
915 |
// Step 4 - custom meta keys helper
|
916 |
$('.existing_meta_keys').change(function(){
|
917 |
+
|
918 |
+
var parent_fieldset = $(this).parents('fieldset').first();
|
919 |
var key = $(this).find('option:selected').val();
|
920 |
|
921 |
if ("" != $(this).val()) {
|
922 |
+
|
923 |
parent_fieldset.find('input[name^=custom_name]:visible').each(function(){
|
924 |
+
if ("" == $(this).val()) $(this).parents('tr').first().remove();
|
925 |
});
|
926 |
+
parent_fieldset.find('a.add-new-custom').click();
|
927 |
+
parent_fieldset.find('input[name^=custom_name]:visible').last().val($(this).val());
|
928 |
|
929 |
$(this).prop('selectedIndex',0);
|
930 |
|
938 |
|
939 |
}, 'html');
|
940 |
}
|
941 |
+
|
942 |
});
|
943 |
|
944 |
$('input[name^=custom_name]').live('change', function(){
|
945 |
+
|
946 |
var $ths = $(this);
|
947 |
$ths.parents('fieldset:first').addClass('loading');
|
948 |
$.post('admin.php?page=pmxi-admin-settings&action=meta_values', {key: $ths.val()}, function (data) {
|
949 |
+
$ths.parents('td:first').find('.ex_values').remove();
|
950 |
$ths.after(data);
|
951 |
$ths.parents('fieldset:first').removeClass('loading');
|
952 |
}, 'html');
|
1015 |
|
1016 |
$('.pmxi_choosen').each(function(){
|
1017 |
$(this).find(".choosen_input").select2({tags: $(this).find('.choosen_values').html().split(',')});
|
1018 |
+
});
|
1019 |
|
1020 |
$('.pmxi_tips_pointer').click(function(){
|
1021 |
$(this).pointer({
|
1032 |
});
|
1033 |
}
|
1034 |
}).pointer('open');
|
1035 |
+
});
|
1036 |
+
|
1037 |
+
if ($('#pmxi_tabs').length && parseInt($('#pmxi_tabs').find('.is_disabled').val()) ) {
|
1038 |
+
$('form.options').find('input, select, textarea').attr('disabled','disabled');
|
1039 |
+
}
|
1040 |
|
1041 |
});})(jQuery);
|
static/js/jquery/jquery.mjs.nestedSortable.js
CHANGED
@@ -345,7 +345,7 @@
|
|
345 |
}
|
346 |
|
347 |
if (id) {
|
348 |
-
ret.push({"item_id": id[2], "parent_id": pid, "delim": $(item).parents('.post_taxonomy:first').find('input.tax_delim').val(), "left": left, "right": right, "xpath":$(item).find('input.
|
349 |
}
|
350 |
|
351 |
left = right + 1;
|
345 |
}
|
346 |
|
347 |
if (id) {
|
348 |
+
ret.push({"item_id": id[2], "parent_id": pid, "delim": $(item).parents('.post_taxonomy:first').find('input.tax_delim').val(), "left": left, "right": right, "xpath":$(item).find('input.xpath_field').val(), "assign":$(item).find('input.assign_post:first').is(':checked'), "auto_nested":$(item).parents('.post_taxonomy:first').find('input.taxonomy_auto_nested').is(':checked'), "mapping":$(item).parents('.post_taxonomy:first').find('input[type=checkbox][name=categories_mapping]').is(':checked'), "mapping_rules":$(item).parents('.post_taxonomy:first').find('input[name=mapping_rules]').val()});
|
349 |
}
|
350 |
|
351 |
left = right + 1;
|
static/js/pmxi.js
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
|
11 |
}, 'html');
|
12 |
});
|
13 |
-
|
14 |
$('#dismiss_manage_top').click(function(){
|
15 |
|
16 |
$(this).parents('div.updated:first').slideUp();
|
10 |
|
11 |
}, 'html');
|
12 |
});
|
13 |
+
|
14 |
$('#dismiss_manage_top').click(function(){
|
15 |
|
16 |
$(this).parents('div.updated:first').slideUp();
|
views/admin/addons/index.php
CHANGED
@@ -5,6 +5,7 @@
|
|
5 |
<div id="pmxi-add-ons" class="clear">
|
6 |
|
7 |
<div class="pmxi-add-on-group clear">
|
|
|
8 |
<?php foreach( $premium as $addon ): ?>
|
9 |
<div class="pmxi-add-on wp-box <?php if( $addon['active'] ): ?>pmxi-add-on-active<?php endif; ?>">
|
10 |
<a target="_blank" href="<?php echo $addon['url']; ?>">
|
@@ -45,6 +46,7 @@
|
|
45 |
</div>
|
46 |
|
47 |
<div class="pmxi-add-on-group clear">
|
|
|
48 |
<?php foreach( $free as $addon ): ?>
|
49 |
<div class="pmxi-add-on wp-box <?php if( $addon['active'] ): ?>pmxi-add-on-active<?php endif; ?>">
|
50 |
<a target="_blank" href="<?php echo $addon['url']; ?>">
|
5 |
<div id="pmxi-add-ons" class="clear">
|
6 |
|
7 |
<div class="pmxi-add-on-group clear">
|
8 |
+
<h3><?php _e('Premium Add-ons', 'pmxi_plugin'); ?></h3>
|
9 |
<?php foreach( $premium as $addon ): ?>
|
10 |
<div class="pmxi-add-on wp-box <?php if( $addon['active'] ): ?>pmxi-add-on-active<?php endif; ?>">
|
11 |
<a target="_blank" href="<?php echo $addon['url']; ?>">
|
46 |
</div>
|
47 |
|
48 |
<div class="pmxi-add-on-group clear">
|
49 |
+
<h3><?php _e('Free Add-ons', 'pmxi_plugin'); ?></h3>
|
50 |
<?php foreach( $free as $addon ): ?>
|
51 |
<div class="pmxi-add-on wp-box <?php if( $addon['active'] ): ?>pmxi-add-on-active<?php endif; ?>">
|
52 |
<a target="_blank" href="<?php echo $addon['url']; ?>">
|
views/admin/import/element.php
CHANGED
@@ -74,6 +74,7 @@
|
|
74 |
<option value="less"><?php _e('less than', 'pmxi_plugin'); ?></option>
|
75 |
<option value="equals_or_less"><?php _e('equals or less than', 'pmxi_plugin'); ?></option>
|
76 |
<option value="contains"><?php _e('contains', 'pmxi_plugin'); ?></option>
|
|
|
77 |
<option value="is_empty"><?php _e('is empty', 'pmxi_plugin'); ?></option>
|
78 |
<option value="is_not_empty"><?php _e('is not empty', 'pmxi_plugin'); ?></option>
|
79 |
</select>
|
74 |
<option value="less"><?php _e('less than', 'pmxi_plugin'); ?></option>
|
75 |
<option value="equals_or_less"><?php _e('equals or less than', 'pmxi_plugin'); ?></option>
|
76 |
<option value="contains"><?php _e('contains', 'pmxi_plugin'); ?></option>
|
77 |
+
<option value="not_contains"><?php _e('not contains', 'pmxi_plugin'); ?></option>
|
78 |
<option value="is_empty"><?php _e('is empty', 'pmxi_plugin'); ?></option>
|
79 |
<option value="is_not_empty"><?php _e('is not empty', 'pmxi_plugin'); ?></option>
|
80 |
</select>
|
views/admin/import/evaluate_variations.php
CHANGED
@@ -24,6 +24,7 @@
|
|
24 |
(function($){
|
25 |
var paths = <?php echo json_encode($paths) ?>;
|
26 |
var $xml = $('#variations_xml');
|
|
|
27 |
$xml.html($('#current_xml').html()).css({'visibility':'visible'});
|
28 |
for (var i = 0; i < paths.length; i++) {
|
29 |
$xml.find('.xml-element[title="' + paths[i] + '"]').addClass('selected').parents('.xml-element').find('> .xml-content.collapsed').removeClass('collapsed').parent().find('> .xml-expander').html('-');
|
24 |
(function($){
|
25 |
var paths = <?php echo json_encode($paths) ?>;
|
26 |
var $xml = $('#variations_xml');
|
27 |
+
|
28 |
$xml.html($('#current_xml').html()).css({'visibility':'visible'});
|
29 |
for (var i = 0; i < paths.length; i++) {
|
30 |
$xml.find('.xml-element[title="' + paths[i] + '"]').addClass('selected').parents('.xml-element').find('> .xml-content.collapsed').removeClass('collapsed').parent().find('> .xml-expander').html('-');
|
views/admin/import/index.php
CHANGED
@@ -39,7 +39,7 @@ $l10n = array(
|
|
39 |
<?php
|
40 |
if ( ! $reimported_import->isEmpty()):
|
41 |
?>
|
42 |
-
<div
|
43 |
<p><?php _e( 'You are importing a new file for: <b>' . $reimported_import->name . '</b>' , 'pmxi_plugin' );?></p>
|
44 |
<p><span><?php _e( 'Last imported on ' . date("m-d-Y H:i:s", strtotime($reimported_import->registered_on)) , 'pmxi_plugin' ); ?></span></p>
|
45 |
</div>
|
@@ -47,9 +47,9 @@ $l10n = array(
|
|
47 |
endif;
|
48 |
?>
|
49 |
<?php do_action('pmxi_choose_file_header'); ?>
|
50 |
-
<form method="post" class="choose-file
|
51 |
<input type="hidden" name="is_submitted" value="1" />
|
52 |
-
<?php wp_nonce_field('upload-xml', '_wpnonce_upload-xml') ?>
|
53 |
<div class="file-type-container">
|
54 |
<h3>
|
55 |
<input type="radio" id="type_upload" name="type" value="upload" checked="checked" />
|
@@ -102,7 +102,7 @@ $l10n = array(
|
|
102 |
<a href="http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=step-1&utm_campaign=free+plugin" target="_blank" class="upgrade_link">Upgrade to the professional edition of WP All Import to use this feature.</a>
|
103 |
</div>
|
104 |
</div>
|
105 |
-
<div id="url_upload_status"></div>
|
106 |
<p class="submit-buttons">
|
107 |
<input type="hidden" name="is_submitted" value="1" />
|
108 |
<?php wp_nonce_field('choose-file', '_wpnonce_choose-file') ?>
|
39 |
<?php
|
40 |
if ( ! $reimported_import->isEmpty()):
|
41 |
?>
|
42 |
+
<div class="reimported_notify">
|
43 |
<p><?php _e( 'You are importing a new file for: <b>' . $reimported_import->name . '</b>' , 'pmxi_plugin' );?></p>
|
44 |
<p><span><?php _e( 'Last imported on ' . date("m-d-Y H:i:s", strtotime($reimported_import->registered_on)) , 'pmxi_plugin' ); ?></span></p>
|
45 |
</div>
|
47 |
endif;
|
48 |
?>
|
49 |
<?php do_action('pmxi_choose_file_header'); ?>
|
50 |
+
<form method="post" class="choose-file enter-submit" enctype="multipart/form-data" autocomplete="off">
|
51 |
<input type="hidden" name="is_submitted" value="1" />
|
52 |
+
<?php wp_nonce_field('upload-xml', '_wpnonce_upload-xml') ?>
|
53 |
<div class="file-type-container">
|
54 |
<h3>
|
55 |
<input type="radio" id="type_upload" name="type" value="upload" checked="checked" />
|
102 |
<a href="http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=step-1&utm_campaign=free+plugin" target="_blank" class="upgrade_link">Upgrade to the professional edition of WP All Import to use this feature.</a>
|
103 |
</div>
|
104 |
</div>
|
105 |
+
<div id="url_upload_status"></div>
|
106 |
<p class="submit-buttons">
|
107 |
<input type="hidden" name="is_submitted" value="1" />
|
108 |
<?php wp_nonce_field('choose-file', '_wpnonce_choose-file') ?>
|
views/admin/import/options.php
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
$custom_types = get_post_types(array('_builtin' => false), 'objects');
|
|
|
|
|
|
|
4 |
$isWizard = $this->isWizard;
|
5 |
$baseUrl = $this->baseUrl;
|
6 |
|
@@ -41,143 +44,83 @@
|
|
41 |
</select>
|
42 |
</div>
|
43 |
</form>
|
44 |
-
<h2 class="
|
45 |
-
<a class="nav-tab nav-tab-active" rel="posts" href="javascript:void(0);"><?php _e('Posts','pmxi_plugin');?></a>
|
46 |
-
<a class="nav-tab" rel="pages" href="javascript:void(0);"><?php _e('Pages','pmxi_plugin');?></a>
|
47 |
<?php $custom_types = apply_filters( 'pmxi_custom_types', $custom_types );?>
|
48 |
<?php if (count($custom_types)): ?>
|
49 |
<?php foreach ($custom_types as $key => $ct):?>
|
50 |
-
<a class="nav-tab" rel="<?php echo $key; ?>" href="
|
51 |
<?php endforeach ?>
|
52 |
<?php endif ?>
|
53 |
<?php do_action('pmxi_custom_menu_item'); ?>
|
54 |
</h2>
|
55 |
<div id="pmxi_tabs">
|
56 |
<div class="left">
|
57 |
-
|
58 |
-
<!-- Post Options -->
|
59 |
-
|
60 |
-
<div id="posts" class="pmxi_tab"> <!-- Basic -->
|
61 |
-
<form class="options <?php echo ! $isWizard ? 'edit' : '' ?>" method="post">
|
62 |
-
<input type="hidden" name="type" value="post"/>
|
63 |
-
<input type="hidden" name="custom_type" value=""/>
|
64 |
-
<div class="post-type-options">
|
65 |
-
<table class="form-table" style="max-width:none;">
|
66 |
-
<?php
|
67 |
-
$post_type = 'post';
|
68 |
-
$entry = 'post';
|
69 |
-
|
70 |
-
include( 'options/_main_options_template.php' );
|
71 |
-
do_action('pmxi_extend_options_main', $entry);
|
72 |
-
include( 'options/_taxonomies_template.php' );
|
73 |
-
do_action('pmxi_extend_options_taxonomies', $entry);
|
74 |
-
include( 'options/_categories_template.php' );
|
75 |
-
do_action('pmxi_extend_options_categories', $entry);
|
76 |
-
include( 'options/_custom_fields_template.php' );
|
77 |
-
do_action('pmxi_extend_options_custom_fields', $entry);
|
78 |
-
include( 'options/_featured_template.php' );
|
79 |
-
do_action('pmxi_extend_options_featured', $entry);
|
80 |
-
include( 'options/_author_template.php' );
|
81 |
-
do_action('pmxi_extend_options_author', $entry);
|
82 |
-
include( 'options/_reimport_template.php' );
|
83 |
-
include( 'options/_settings_template.php' );
|
84 |
-
?>
|
85 |
-
</table>
|
86 |
-
</div>
|
87 |
-
|
88 |
-
<?php include( 'options/_buttons_template.php' ); ?>
|
89 |
-
|
90 |
-
</form>
|
91 |
-
</div>
|
92 |
-
|
93 |
-
<!-- Page Options -->
|
94 |
-
|
95 |
-
<div id="pages" class="pmxi_tab">
|
96 |
-
<form class="options <?php echo ! $isWizard ? 'edit' : '' ?>" method="post">
|
97 |
-
<input type="hidden" name="type" value="page"/>
|
98 |
-
<input type="hidden" name="custom_type" value=""/>
|
99 |
-
<div class="post-type-options">
|
100 |
-
<table class="form-table" style="max-width:none;">
|
101 |
-
|
102 |
-
<?php
|
103 |
-
$post_type = 'post';
|
104 |
-
$entry = 'page';
|
105 |
-
include( 'options/_main_options_template.php' );
|
106 |
-
?>
|
107 |
-
|
108 |
-
<tr>
|
109 |
-
<td align="center" width="33%">
|
110 |
-
<label><?php _e('Page Template', 'pmxi_plugin') ?></label> <br>
|
111 |
-
<select name="page_template" id="page_template">
|
112 |
-
<option value='default'><?php _e('Default', 'pmxi_plugin') ?></option>
|
113 |
-
<?php page_template_dropdown($post['page_template']); ?>
|
114 |
-
</select>
|
115 |
-
</td>
|
116 |
-
<td align="center" width="33%">
|
117 |
-
<label><?php _e('Parent Page', 'pmxi_plugin') ?></label> <br>
|
118 |
-
<?php wp_dropdown_pages(array('post_type' => 'page', 'selected' => $post['parent'], 'name' => 'parent', 'show_option_none' => __('(no parent)', 'pmxi_plugin'), 'sort_column'=> 'menu_order, post_title',)) ?>
|
119 |
-
</td>
|
120 |
-
<td align="center" width="33%">
|
121 |
-
<label><?php _e('Order', 'pmxi_plugin') ?></label> <br>
|
122 |
-
<input type="text" class="" name="order" value="<?php echo esc_attr($post['order']) ?>" />
|
123 |
-
</td>
|
124 |
-
</tr>
|
125 |
-
<?php
|
126 |
-
do_action('pmxi_extend_options_main', $entry);
|
127 |
-
include( 'options/_custom_fields_template.php' );
|
128 |
-
do_action('pmxi_extend_options_custom_fields', $entry);
|
129 |
-
include( 'options/_taxonomies_template.php' );
|
130 |
-
do_action('pmxi_extend_options_taxonomies', $entry);
|
131 |
-
include( 'options/_featured_template.php' );
|
132 |
-
do_action('pmxi_extend_options_featured', $entry);
|
133 |
-
include( 'options/_author_template.php' );
|
134 |
-
do_action('pmxi_extend_options_author', $entry);
|
135 |
-
include( 'options/_reimport_template.php' );
|
136 |
-
include( 'options/_settings_template.php' );
|
137 |
-
?>
|
138 |
-
</table>
|
139 |
-
</div>
|
140 |
-
|
141 |
-
<?php include( 'options/_buttons_template.php' ); ?>
|
142 |
-
|
143 |
-
</form>
|
144 |
-
</div>
|
145 |
-
|
146 |
<!-- Custom Post Types -->
|
147 |
-
|
148 |
<?php
|
149 |
if (count($custom_types)): ?>
|
150 |
<?php foreach ($custom_types as $key => $ct):?>
|
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 |
<?php endforeach ?>
|
182 |
<?php endif ?>
|
183 |
|
1 |
<?php
|
2 |
|
3 |
+
$custom_types = get_post_types(array('_builtin' => true), 'objects') + get_post_types(array('_builtin' => false), 'objects');
|
4 |
+
foreach ($custom_types as $key => $ct) {
|
5 |
+
if (in_array($key, array('attachment', 'revision', 'nav_menu_item'))) unset($custom_types[$key]);
|
6 |
+
}
|
7 |
$isWizard = $this->isWizard;
|
8 |
$baseUrl = $this->baseUrl;
|
9 |
|
44 |
</select>
|
45 |
</div>
|
46 |
</form>
|
47 |
+
<h2 class="woo-nav-tab-wrapper">
|
|
|
|
|
48 |
<?php $custom_types = apply_filters( 'pmxi_custom_types', $custom_types );?>
|
49 |
<?php if (count($custom_types)): ?>
|
50 |
<?php foreach ($custom_types as $key => $ct):?>
|
51 |
+
<a class="nav-tab <?php if ($key == $get['pmxi-cpt']) echo 'nav-tab-active'; ?>" rel="<?php echo $key; ?>" href="<?php echo add_query_arg(array('action' => 'options', 'pmxi-cpt' => $key), $this->baseUrl); ?>"><?php echo $ct->labels->name ?></a>
|
52 |
<?php endforeach ?>
|
53 |
<?php endif ?>
|
54 |
<?php do_action('pmxi_custom_menu_item'); ?>
|
55 |
</h2>
|
56 |
<div id="pmxi_tabs">
|
57 |
<div class="left">
|
58 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
<!-- Custom Post Types -->
|
|
|
60 |
<?php
|
61 |
if (count($custom_types)): ?>
|
62 |
<?php foreach ($custom_types as $key => $ct):?>
|
63 |
+
<?php if ( $key == $get['pmxi-cpt'] ): ?>
|
64 |
+
<div id="<?php echo $key;?>" class="">
|
65 |
+
<form class="options <?php echo ! $isWizard ? 'edit' : '' ?>" method="post">
|
66 |
+
<input type="hidden" name="custom_type" value="<?php echo $key; ?>"/>
|
67 |
+
<input type="hidden" name="type" value="post"/>
|
68 |
+
<div class="post-type-options">
|
69 |
+
<table class="form-table" style="max-width:none;">
|
70 |
+
<?php
|
71 |
+
$post_type = $entry = $key;
|
72 |
+
include( 'options/_main_options_template.php' );
|
73 |
+
|
74 |
+
if ( 'page' == $key ):
|
75 |
+
|
76 |
+
$entry = 'page';
|
77 |
+
?>
|
78 |
+
<tr>
|
79 |
+
<td align="center" width="33%" style="padding-bottom:20px;">
|
80 |
+
<label><?php _e('Page Template', 'pmxi_plugin') ?></label> <br>
|
81 |
+
<select name="page_template" id="page_template">
|
82 |
+
<option value='default'><?php _e('Default', 'pmxi_plugin') ?></option>
|
83 |
+
<?php page_template_dropdown($post['page_template']); ?>
|
84 |
+
</select>
|
85 |
+
</td>
|
86 |
+
<td align="center" width="33%">
|
87 |
+
<label><?php _e('Parent Page', 'pmxi_plugin') ?></label> <br>
|
88 |
+
<?php wp_dropdown_pages(array('post_type' => 'page', 'selected' => $post['parent'], 'name' => 'parent', 'show_option_none' => __('(no parent)', 'pmxi_plugin'), 'sort_column'=> 'menu_order, post_title',)) ?>
|
89 |
+
</td>
|
90 |
+
<td align="center" width="33%">
|
91 |
+
<label><?php _e('Order', 'pmxi_plugin') ?></label> <br>
|
92 |
+
<input type="text" class="" name="order" value="<?php echo esc_attr($post['order']) ?>" />
|
93 |
+
</td>
|
94 |
+
</tr>
|
95 |
+
<?php
|
96 |
+
endif;
|
97 |
+
|
98 |
+
do_action('pmxi_extend_options_main', $entry);
|
99 |
+
include( 'options/_taxonomies_template.php' );
|
100 |
+
do_action('pmxi_extend_options_taxonomies', $entry);
|
101 |
+
|
102 |
+
if ( ! in_array($entry, array('page', 'product')) ){
|
103 |
+
include( 'options/_categories_template.php' );
|
104 |
+
do_action('pmxi_extend_options_categories', $entry);
|
105 |
+
}
|
106 |
+
|
107 |
+
include( 'options/_custom_fields_template.php' );
|
108 |
+
do_action('pmxi_extend_options_custom_fields', $entry);
|
109 |
+
include( 'options/_featured_template.php' );
|
110 |
+
do_action('pmxi_extend_options_featured', $entry);
|
111 |
+
include( 'options/_author_template.php' );
|
112 |
+
do_action('pmxi_extend_options_author', $entry);
|
113 |
+
include( 'options/_reimport_template.php' );
|
114 |
+
include( 'options/_settings_template.php' );
|
115 |
+
?>
|
116 |
+
</table>
|
117 |
+
</div>
|
118 |
+
|
119 |
+
<?php include( 'options/_buttons_template.php' ); ?>
|
120 |
+
|
121 |
+
</form>
|
122 |
+
</div>
|
123 |
+
<?php endif ?>
|
124 |
<?php endforeach ?>
|
125 |
<?php endif ?>
|
126 |
|
views/admin/import/options/_buttons_template.php
CHANGED
@@ -5,9 +5,9 @@
|
|
5 |
|
6 |
<?php if ($isWizard): ?>
|
7 |
|
8 |
-
<a href="<?php echo add_query_arg('action', 'template', $baseUrl) ?>" class="back"><?php _e('Back', 'pmxi_plugin') ?></a>
|
9 |
|
10 |
-
<?php if (in_array($source_type, array('url', 'ftp', 'file'))): ?>
|
11 |
<input type="hidden" class="save_only" value="0" name="save_only"/>
|
12 |
<input type="submit" name="btn_save_only" class="button button-primary button-hero large_button" value="<?php _e('Save Only', 'pmxi_plugin') ?>" />
|
13 |
<?php endif ?>
|
@@ -15,7 +15,7 @@
|
|
15 |
<input type="submit" class="button button-primary button-hero large_button" value="<?php _e('Finish', 'pmxi_plugin') ?>" />
|
16 |
|
17 |
<?php else: ?>
|
18 |
-
<a href="<?php echo remove_query_arg('id', remove_query_arg('action', $baseUrl)); ?>" class="back"><?php _e('Back', 'pmxi_plugin') ?></a>
|
19 |
<input type="submit" class="button button-primary button-hero large_button" value="<?php _e('Save', 'pmxi_plugin') ?>" />
|
20 |
<?php endif ?>
|
21 |
</p>
|
5 |
|
6 |
<?php if ($isWizard): ?>
|
7 |
|
8 |
+
<a href="<?php echo apply_filters('pmxi_options_back_link', add_query_arg('action', 'template', $this->baseUrl), $isWizard); ?>" class="back"><?php _e('Back', 'pmxi_plugin') ?></a>
|
9 |
|
10 |
+
<?php if (isset($source_type) and in_array($source_type, array('url', 'ftp', 'file'))): ?>
|
11 |
<input type="hidden" class="save_only" value="0" name="save_only"/>
|
12 |
<input type="submit" name="btn_save_only" class="button button-primary button-hero large_button" value="<?php _e('Save Only', 'pmxi_plugin') ?>" />
|
13 |
<?php endif ?>
|
15 |
<input type="submit" class="button button-primary button-hero large_button" value="<?php _e('Finish', 'pmxi_plugin') ?>" />
|
16 |
|
17 |
<?php else: ?>
|
18 |
+
<a href="<?php echo apply_filters('pmxi_options_back_link', remove_query_arg('id', remove_query_arg('action', $this->baseUrl)), $isWizard); ?>" class="back"><?php _e('Back', 'pmxi_plugin') ?></a>
|
19 |
<input type="submit" class="button button-primary button-hero large_button" value="<?php _e('Save', 'pmxi_plugin') ?>" />
|
20 |
<?php endif ?>
|
21 |
</p>
|
views/admin/import/options/_categories_template.php
CHANGED
@@ -1,57 +1,65 @@
|
|
1 |
<tr>
|
2 |
<td colspan="3">
|
3 |
-
<div class="col2">
|
4 |
<fieldset style="margin-left:0px;">
|
5 |
<legend><?php _e('Categories', 'pmxi_plugin') ?> <a href="#help" class="help" title="<?php _e('Uncheck a box and the category will still be created, but the post will not be assigned to it.', 'pmxi_plugin') ?>">?</a></legend>
|
6 |
<ol class="sortable no-margin">
|
7 |
-
<?php
|
8 |
-
|
9 |
-
|
|
|
10 |
|
11 |
-
if (empty($categories)
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
}
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
<?php
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
</ol>
|
44 |
<a href="javascript:void(0);" class="icon-item add-new-ico"><?php _e('Add more', 'pmxi_plugin');?></a> <br><br>
|
45 |
<input type="hidden" class="hierarhy-output" name="categories" value="<?php echo esc_attr($post['categories']) ?>"/>
|
46 |
<div class="hidden" id="dialog-confirm-category-removing" title="Delete categories?"><?php _e('Remove only current category or current category with subcategories?', 'pmxi_plugin');?></div>
|
|
|
47 |
<div class="delim">
|
48 |
<label><?php _e('Separated by', 'pmxi_plugin'); ?></label>
|
49 |
<input type="text" class="small" name="categories_delim" value="<?php echo ( ! empty($post['categories_delim']) ) ? str_replace("&","&", htmlentities(htmlentities($post['categories_delim']))) : ',' ; ?>" />
|
50 |
<label for="categories_auto_nested"><?php _e('Enable Auto Nest', 'pmxi_plugin');?></label>
|
51 |
<input type="hidden" name="categories_auto_nested" value="0"/>
|
52 |
<input type="checkbox" id="categories_auto_nested" name="categories_auto_nested" <?php if ($post['categories_auto_nested']):?>checked="checked"<?php endif; ?>/>
|
53 |
-
<a href="#help" class="help" title="<?php _e('If this box is checked, a category hierarchy will be created. For example, if your <code>{category}</code> value is <code>Mens > Shoes > Diesel</code>, enter <code>></code> as the separator and enable <code>Auto Nest</code> to create <code>Diesel</code> as a child category of <code>Shoes</code> and <code>Shoes</code> as a child category of <code>Mens.</code>', 'pmxi_plugin') ?>">?</a>
|
|
|
54 |
</div>
|
|
|
55 |
</fieldset>
|
56 |
</div>
|
57 |
<div class="col2">
|
1 |
<tr>
|
2 |
<td colspan="3">
|
3 |
+
<div class="col2 post_taxonomy">
|
4 |
<fieldset style="margin-left:0px;">
|
5 |
<legend><?php _e('Categories', 'pmxi_plugin') ?> <a href="#help" class="help" title="<?php _e('Uncheck a box and the category will still be created, but the post will not be assigned to it.', 'pmxi_plugin') ?>">?</a></legend>
|
6 |
<ol class="sortable no-margin">
|
7 |
+
<?php
|
8 |
+
if ( ! empty($post['categories']) ):
|
9 |
+
|
10 |
+
$categories = json_decode($post['categories']);
|
11 |
|
12 |
+
if ( ! empty($categories) and is_array($categories)):
|
13 |
|
14 |
+
$i = 0;
|
15 |
+
foreach ($categories as $cat) { $i++;
|
16 |
+
if (is_null($cat->parent_id) or empty($cat->parent_id)){
|
17 |
+
?>
|
18 |
+
<li id="item_<?php echo $i; ?>" class="dragging">
|
19 |
+
<div class="drag-element">
|
20 |
+
<input type="checkbox" class="assign_post" <?php if ($cat->assign): ?>checked="checked"<?php endif; ?> title="<?php _e('Assign post to the taxonomy.','pmxi_plugin');?>"/>
|
21 |
+
<input type="text" class="widefat xpath_field" value="<?php echo (is_object($cat)) ? esc_attr($cat->xpath) : esc_attr($cat); ?>"/>
|
22 |
+
|
23 |
+
<?php do_action('pmxi_category_view', $cat, $i, 'category', $entry); ?>
|
24 |
+
|
25 |
+
</div>
|
26 |
+
<?php if ($i > 1):?><a href="javascript:void(0);" class="icon-item remove-ico"></a><?php endif;?>
|
27 |
+
<?php if ( is_object($cat) ) echo reverse_taxonomies_html($categories, $cat->item_id, $i, 'category', $entry); ?>
|
28 |
+
</li>
|
29 |
+
<?php
|
30 |
+
}
|
31 |
}
|
32 |
+
|
33 |
+
endif;
|
34 |
+
|
35 |
+
endif; ?>
|
36 |
+
|
37 |
+
<li id="item" class="template">
|
38 |
+
<div class="drag-element">
|
39 |
+
<input type="checkbox" class="assign_post" checked="checked" title="<?php _e('Assign post to the taxonomy.','pmxi_plugin');?>"/>
|
40 |
+
<input type="text" class="widefat xpath_field" value=""/>
|
41 |
+
|
42 |
+
<?php do_action('pmxi_category_view', false, false, 'category', $entry); ?>
|
43 |
+
|
44 |
+
</div>
|
45 |
+
<a href="javascript:void(0);" class="icon-item remove-ico"></a>
|
46 |
+
</li>
|
47 |
+
|
48 |
</ol>
|
49 |
<a href="javascript:void(0);" class="icon-item add-new-ico"><?php _e('Add more', 'pmxi_plugin');?></a> <br><br>
|
50 |
<input type="hidden" class="hierarhy-output" name="categories" value="<?php echo esc_attr($post['categories']) ?>"/>
|
51 |
<div class="hidden" id="dialog-confirm-category-removing" title="Delete categories?"><?php _e('Remove only current category or current category with subcategories?', 'pmxi_plugin');?></div>
|
52 |
+
<?php do_action('pmxi_category_options_view', ((!empty($post['categories'])) ? $post['categories'] : false), 'category', $entry, __('Categories', 'pmxi_plugin')); ?>
|
53 |
<div class="delim">
|
54 |
<label><?php _e('Separated by', 'pmxi_plugin'); ?></label>
|
55 |
<input type="text" class="small" name="categories_delim" value="<?php echo ( ! empty($post['categories_delim']) ) ? str_replace("&","&", htmlentities(htmlentities($post['categories_delim']))) : ',' ; ?>" />
|
56 |
<label for="categories_auto_nested"><?php _e('Enable Auto Nest', 'pmxi_plugin');?></label>
|
57 |
<input type="hidden" name="categories_auto_nested" value="0"/>
|
58 |
<input type="checkbox" id="categories_auto_nested" name="categories_auto_nested" <?php if ($post['categories_auto_nested']):?>checked="checked"<?php endif; ?>/>
|
59 |
+
<a href="#help" class="help" style="position:relative; top:-1px; left: -5px;" title="<?php _e('If this box is checked, a category hierarchy will be created. For example, if your <code>{category}</code> value is <code>Mens > Shoes > Diesel</code>, enter <code>></code> as the separator and enable <code>Auto Nest</code> to create <code>Diesel</code> as a child category of <code>Shoes</code> and <code>Shoes</code> as a child category of <code>Mens.</code>', 'pmxi_plugin') ?>">?</a>
|
60 |
+
<?php do_action('pmxi_category_options', ((!empty($post['categories'])) ? $post['categories'] : false), 'category', $entry); ?>
|
61 |
</div>
|
62 |
+
|
63 |
</fieldset>
|
64 |
</div>
|
65 |
<div class="col2">
|
views/admin/import/options/_custom_fields_template.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<td colspan="3" style="padding-top:20px;">
|
3 |
<fieldset class="optionsset" style="text-align:center;">
|
4 |
<legend><?php _e('Custom Fields','pmxi_plugin');?></legend>
|
5 |
-
|
6 |
<center>
|
7 |
|
8 |
<h3>Please upgrade to the professional edition of WP All Import to import data to Custom Fields.</h3>
|
@@ -13,45 +13,230 @@
|
|
13 |
|
14 |
</center>
|
15 |
|
16 |
-
|
17 |
<table class="form-table custom-params" style="max-width:none; border:none;">
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
<tr class="form-field">
|
28 |
-
<td
|
29 |
-
|
30 |
-
<
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
</tr>
|
34 |
-
<?php
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
</tr>
|
43 |
-
|
44 |
-
<tr class="form-field template">
|
45 |
-
<td><input type="text" name="custom_name[]" value="" disabled="disabled"/></td>
|
46 |
-
<td class="action remove">
|
47 |
-
<textarea name="custom_value[]" disabled="disabled"></textarea>
|
48 |
-
<a href="#remove"></a>
|
49 |
-
</td>
|
50 |
-
</tr>
|
51 |
-
<tr>
|
52 |
-
<td colspan="2"><a href="#add" title="<?php _e('add', 'pmxi_plugin')?>" class="action add-new-custom"><?php _e('Add more', 'pmxi_plugin') ?></a></td>
|
53 |
-
</tr>
|
54 |
-
</tbody>
|
55 |
</table>
|
56 |
<select class="existing_meta_keys">
|
57 |
<option value=""><?php _e('Existing Custom Fields...','pmxi_plugin');?></option>
|
2 |
<td colspan="3" style="padding-top:20px;">
|
3 |
<fieldset class="optionsset" style="text-align:center;">
|
4 |
<legend><?php _e('Custom Fields','pmxi_plugin');?></legend>
|
5 |
+
|
6 |
<center>
|
7 |
|
8 |
<h3>Please upgrade to the professional edition of WP All Import to import data to Custom Fields.</h3>
|
13 |
|
14 |
</center>
|
15 |
|
|
|
16 |
<table class="form-table custom-params" style="max-width:none; border:none;">
|
17 |
+
<thead>
|
18 |
+
<tr>
|
19 |
+
<td><?php _e('Name', 'pmxi_plugin') ?></td>
|
20 |
+
<td><?php _e('Value', 'pmxi_plugin') ?></td>
|
21 |
+
</tr>
|
22 |
+
</thead>
|
23 |
+
<tbody>
|
24 |
+
<?php if (!empty($post['custom_name'])):?>
|
25 |
+
<?php foreach ($post['custom_name'] as $i => $name): ?>
|
26 |
+
<tr class="form-field">
|
27 |
+
<td>
|
28 |
+
<input type="text" name="custom_name[]" value="<?php echo esc_attr($name) ?>" class="widefat" disabled="disabled"/>
|
29 |
+
<div class="input to_the_left">
|
30 |
+
<input id="custom_format_<?php echo $i; ?>" type="checkbox" name="custom_format[]" <?php if ( ! empty($post['custom_format'][$i]) ): ?>checked="checked"<?php endif; ?> style="width:12px;" value="1"/>
|
31 |
+
<label for="custom_format_<?php echo $i; ?>"><?php _e('Serialized format', 'pmxi_plugin') ?></label>
|
32 |
+
</div>
|
33 |
+
</td>
|
34 |
+
<td class="action">
|
35 |
+
<div class="custom_type" rel="default" <?php if ( ! empty($post['custom_format'][$i]) ): ?>style="display:none;"<?php endif; ?>>
|
36 |
+
<textarea name="custom_value[]" class="widefat" disabled="disabled"><?php echo esc_html($post['custom_value'][$i]) ?></textarea>
|
37 |
+
</div>
|
38 |
+
<div class="custom_type" rel="serialized" <?php if ( empty($post['custom_format'][$i]) ): ?>style="display:none;"<?php endif; ?>>
|
39 |
+
<table cellpadding="0" cellspacing="5">
|
40 |
+
<thead>
|
41 |
+
<tr>
|
42 |
+
<td><?php _e('Key', 'pmxi_plugin') ?></td>
|
43 |
+
<td><?php _e('Value', 'pmxi_plugin') ?></td>
|
44 |
+
<td> </td>
|
45 |
+
</tr>
|
46 |
+
</thead>
|
47 |
+
<tbody>
|
48 |
+
<?php
|
49 |
+
$serialized_values = (!empty($post['serialized_values'][$i])) ? json_decode($post['serialized_values'][$i], true) : false;
|
50 |
+
|
51 |
+
if (!empty($serialized_values) and is_array($serialized_values)){
|
52 |
+
foreach ($serialized_values as $key => $value) {
|
53 |
+
|
54 |
+
$k = $key;
|
55 |
+
|
56 |
+
if (is_array($value)){
|
57 |
+
$keys = array_keys($value);
|
58 |
+
$k = $keys[0];
|
59 |
+
}
|
60 |
+
|
61 |
+
?>
|
62 |
+
<tr class="form-field">
|
63 |
+
<td>
|
64 |
+
<input type="text" class="serialized_key widefat" value="<?php echo $k; ?>" disabled="disabled">
|
65 |
+
</td>
|
66 |
+
<td>
|
67 |
+
<input type="text" class="serialized_value widefat" value="<?php echo (is_array($value)) ? $value[$k] : $value; ?>" disabled="disabled">
|
68 |
+
</td>
|
69 |
+
<td class="action remove">
|
70 |
+
<a href="#remove" style="right:-10px;"></a>
|
71 |
+
</td>
|
72 |
+
</tr>
|
73 |
+
<?php
|
74 |
+
}
|
75 |
+
}
|
76 |
+
else{
|
77 |
+
?>
|
78 |
+
<tr class="form-field">
|
79 |
+
<td>
|
80 |
+
<input type="text" class="serialized_key widefat" disabled="disabled">
|
81 |
+
</td>
|
82 |
+
<td>
|
83 |
+
<input type="text" class="serialized_value widefat" disabled="disabled">
|
84 |
+
</td>
|
85 |
+
<td class="action remove">
|
86 |
+
<a href="#remove" style="right:-10px;"></a>
|
87 |
+
</td>
|
88 |
+
</tr>
|
89 |
+
<?php
|
90 |
+
}
|
91 |
+
?>
|
92 |
+
<tr class="form-field template">
|
93 |
+
<td>
|
94 |
+
<input type="text" class="serialized_key widefat" disabled="disabled">
|
95 |
+
</td>
|
96 |
+
<td>
|
97 |
+
<input type="text" class="serialized_value widefat" disabled="disabled">
|
98 |
+
</td>
|
99 |
+
<td class="action remove">
|
100 |
+
<a href="#remove" style="right:-10px;"></a>
|
101 |
+
</td>
|
102 |
+
</tr>
|
103 |
+
<tr>
|
104 |
+
<td colspan="3">
|
105 |
+
<a href="javascript:void(0);" title="<?php _e('add', 'pmxi_plugin')?>" class="action add-new-key"><?php _e('Add more', 'pmxi_plugin') ?></a>
|
106 |
+
</td>
|
107 |
+
</tr>
|
108 |
+
</tbody>
|
109 |
+
</table>
|
110 |
+
<input type="hidden" name="serialized_values[]" value="<?php if (!empty($post['serialized_values'][$i])) echo esc_html($post['serialized_values'][$i]); ?>"/>
|
111 |
+
</div>
|
112 |
+
<span class="action remove">
|
113 |
+
<a href="#remove"></a>
|
114 |
+
</span>
|
115 |
+
</td>
|
116 |
+
</tr>
|
117 |
+
<?php endforeach ?>
|
118 |
+
<?php else: ?>
|
119 |
<tr class="form-field">
|
120 |
+
<td>
|
121 |
+
<input type="text" name="custom_name[]" value="" class="widefat" disabled="disabled"/>
|
122 |
+
<div class="input to_the_left">
|
123 |
+
<input id="custom_format_0" type="checkbox" name="custom_format[]" style="width:12px;" value="1"/>
|
124 |
+
<label for="custom_format_0"><?php _e('Serialized format', 'pmxi_plugin') ?></label>
|
125 |
+
</div>
|
126 |
+
</td>
|
127 |
+
<td class="action">
|
128 |
+
<div class="custom_type" rel="default">
|
129 |
+
<textarea name="custom_value[]" class="widefat" disabled="disabled"></textarea>
|
130 |
+
</div>
|
131 |
+
<div class="custom_type" rel="serialized" style="display:none;">
|
132 |
+
<table cellpadding="0" cellspacing="5">
|
133 |
+
<thead>
|
134 |
+
<tr>
|
135 |
+
<td><?php _e('Key', 'pmxi_plugin') ?></td>
|
136 |
+
<td><?php _e('Value', 'pmxi_plugin') ?></td>
|
137 |
+
<td> </td>
|
138 |
+
</tr>
|
139 |
+
</thead>
|
140 |
+
<tbody>
|
141 |
+
<tr class="form-field">
|
142 |
+
<td>
|
143 |
+
<input type="text" class="serialized_key widefat" disabled="disabled">
|
144 |
+
</td>
|
145 |
+
<td>
|
146 |
+
<input type="text" class="serialized_value widefat" disabled="disabled">
|
147 |
+
</td>
|
148 |
+
<td class="action remove">
|
149 |
+
<a href="#remove" style="right:-10px;"></a>
|
150 |
+
</td>
|
151 |
+
</tr>
|
152 |
+
<tr class="form-field template">
|
153 |
+
<td>
|
154 |
+
<input type="text" class="serialized_key widefat" disabled="disabled">
|
155 |
+
</td>
|
156 |
+
<td>
|
157 |
+
<input type="text" class="serialized_value widefat" disabled="disabled">
|
158 |
+
</td>
|
159 |
+
<td class="action remove">
|
160 |
+
<a href="#remove" style="right:-10px;"></a>
|
161 |
+
</td>
|
162 |
+
</tr>
|
163 |
+
<tr>
|
164 |
+
<td colspan="3">
|
165 |
+
<a href="javascript:void(0);" title="<?php _e('add', 'pmxi_plugin')?>" class="action add-new-key"><?php _e('Add more', 'pmxi_plugin') ?></a>
|
166 |
+
</td>
|
167 |
+
</tr>
|
168 |
+
</tbody>
|
169 |
+
</table>
|
170 |
+
<input type="hidden" name="serialized_values[]" value=""/>
|
171 |
+
</div>
|
172 |
+
<span class="action remove">
|
173 |
+
<a href="#remove"></a>
|
174 |
+
</span>
|
175 |
+
</td>
|
176 |
</tr>
|
177 |
+
<?php endif;?>
|
178 |
+
<tr class="form-field template">
|
179 |
+
<td>
|
180 |
+
<input type="text" name="custom_name[]" value="" class="widefat" disabled="disabled"/>
|
181 |
+
<div class="input to_the_left">
|
182 |
+
<input type="checkbox" id="custom_format" name="custom_format[]" style="width:12px;" value="1"/>
|
183 |
+
<label for="custom_format"><?php _e('Serialized format', 'pmxi_plugin') ?></label>
|
184 |
+
</div>
|
185 |
+
</td>
|
186 |
+
<td class="action">
|
187 |
+
<div class="custom_type" rel="default">
|
188 |
+
<textarea name="custom_value[]" class="widefat" disabled="disabled"></textarea>
|
189 |
+
</div>
|
190 |
+
<div class="custom_type" rel="serialized" style="display:none;">
|
191 |
+
<table cellpadding="0" cellspacing="5">
|
192 |
+
<thead>
|
193 |
+
<tr>
|
194 |
+
<td><?php _e('Key', 'pmxi_plugin') ?></td>
|
195 |
+
<td><?php _e('Value', 'pmxi_plugin') ?></td>
|
196 |
+
<td> </td>
|
197 |
+
</tr>
|
198 |
+
</thead>
|
199 |
+
<tbody>
|
200 |
+
<tr class="form-field">
|
201 |
+
<td>
|
202 |
+
<input type="text" class="serialized_key widefat" disabled="disabled">
|
203 |
+
</td>
|
204 |
+
<td>
|
205 |
+
<input type="text" class="serialized_value widefat" disabled="disabled">
|
206 |
+
</td>
|
207 |
+
<td class="action remove">
|
208 |
+
<a href="#remove" style="right:-10px;"></a>
|
209 |
+
</td>
|
210 |
+
</tr>
|
211 |
+
<tr class="form-field template">
|
212 |
+
<td>
|
213 |
+
<input type="text" class="serialized_key widefat" disabled="disabled">
|
214 |
+
</td>
|
215 |
+
<td>
|
216 |
+
<input type="text" class="serialized_value widefat" disabled="disabled">
|
217 |
+
</td>
|
218 |
+
<td class="action remove">
|
219 |
+
<a href="#remove" style="right:-10px;"></a>
|
220 |
+
</td>
|
221 |
+
</tr>
|
222 |
+
<tr>
|
223 |
+
<td colspan="3">
|
224 |
+
<a href="javascript:void(0);" title="<?php _e('add', 'pmxi_plugin')?>" class="action add-new-key"><?php _e('Add more', 'pmxi_plugin') ?></a>
|
225 |
+
</td>
|
226 |
+
</tr>
|
227 |
+
</tbody>
|
228 |
+
</table>
|
229 |
+
<input type="hidden" name="serialized_values[]" value=""/>
|
230 |
+
</div>
|
231 |
+
<span class="action remove">
|
232 |
+
<a href="#remove"></a>
|
233 |
+
</span>
|
234 |
+
</td>
|
235 |
+
</tr>
|
236 |
+
<tr>
|
237 |
+
<td colspan="2"><a href="javascript:void(0);" title="<?php _e('add', 'pmxi_plugin')?>" class="action add-new-custom"><?php _e('Add more', 'pmxi_plugin') ?></a></td>
|
238 |
</tr>
|
239 |
+
</tbody>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
</table>
|
241 |
<select class="existing_meta_keys">
|
242 |
<option value=""><?php _e('Existing Custom Fields...','pmxi_plugin');?></option>
|
views/admin/import/options/_featured_template.php
CHANGED
@@ -32,7 +32,7 @@
|
|
32 |
<input type="hidden" name="download_images" value="0" />
|
33 |
<input type="checkbox" id="download_images_<?php echo $entry; ?>" name="download_images" value="1" <?php echo $post['download_images'] ? 'checked="checked"' : '' ?> class="fix_checkbox" <?php if ($post_type != "product" or ! class_exists('PMWI_Plugin')):?>disabled="disabled"<?php endif; ?>/>
|
34 |
<label for="download_images_<?php echo $entry;?>"><?php _e('Download images','pmxi_plugin');?> </label>
|
35 |
-
<a href="#help" class="help" title="<?php _e('
|
36 |
</div>
|
37 |
<div class="input" style="margin:3px 0px;">
|
38 |
<input type="hidden" name="auto_rename_images" value="0" />
|
@@ -70,8 +70,7 @@
|
|
70 |
<label for="image_meta_description_delim_<?php echo $entry;?>"><?php _e('Separated by', 'pmxi_plugin');?></label>
|
71 |
<input type="text" class="small" id="image_meta_description_delim_<?php echo $entry;?>" name="image_meta_description_delim" value="<?php echo esc_attr($post['image_meta_description_delim']) ?>" style="width:5%; text-align:center;" <?php if ($post_type != "product" or ! class_exists('PMWI_Plugin')):?>disabled="disabled"<?php endif; ?>/> <span>(<?php _e('or newline','pmxi_plugin');?>)</span>
|
72 |
</div>
|
73 |
-
</div>
|
74 |
-
|
75 |
</fieldset>
|
76 |
</td>
|
77 |
</tr>
|
32 |
<input type="hidden" name="download_images" value="0" />
|
33 |
<input type="checkbox" id="download_images_<?php echo $entry; ?>" name="download_images" value="1" <?php echo $post['download_images'] ? 'checked="checked"' : '' ?> class="fix_checkbox" <?php if ($post_type != "product" or ! class_exists('PMWI_Plugin')):?>disabled="disabled"<?php endif; ?>/>
|
34 |
<label for="download_images_<?php echo $entry;?>"><?php _e('Download images','pmxi_plugin');?> </label>
|
35 |
+
<a href="#help" class="help" title="<?php _e('Enable this option and WP All Import will download images into the Uploads folder. If this option is disabled, then WP All Import will search for files in the <strong>/wp-content/uploads/'.date("Y/m").'</strong> folder, and if no matching image is found, only then will WP All Import attempt to download it', 'pmxi_plugin') ?>">?</a>
|
36 |
</div>
|
37 |
<div class="input" style="margin:3px 0px;">
|
38 |
<input type="hidden" name="auto_rename_images" value="0" />
|
70 |
<label for="image_meta_description_delim_<?php echo $entry;?>"><?php _e('Separated by', 'pmxi_plugin');?></label>
|
71 |
<input type="text" class="small" id="image_meta_description_delim_<?php echo $entry;?>" name="image_meta_description_delim" value="<?php echo esc_attr($post['image_meta_description_delim']) ?>" style="width:5%; text-align:center;" <?php if ($post_type != "product" or ! class_exists('PMWI_Plugin')):?>disabled="disabled"<?php endif; ?>/> <span>(<?php _e('or newline','pmxi_plugin');?>)</span>
|
72 |
</div>
|
73 |
+
</div>
|
|
|
74 |
</fieldset>
|
75 |
</td>
|
76 |
</tr>
|
views/admin/import/options/_main_options_template.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<tr>
|
2 |
<td style="border-bottom:1px solid #ccc;" colspan="3">
|
3 |
|
4 |
-
<?php if ($post_type != "post"):?>
|
5 |
|
6 |
<?php if ($post_type == "product" and class_exists('PMWI_Plugin')):?>
|
7 |
|
@@ -43,7 +43,7 @@
|
|
43 |
<label for="status_xpath_<?php echo $entry; ?>"><?php _e('Set with XPath', 'pmxi_plugin' )?></label> <br>
|
44 |
<div class="switcher-target-status_xpath_<?php echo $entry; ?> set_xpath">
|
45 |
<div class="input">
|
46 |
-
<input type="text" class="smaller-text" name="status_xpath" style="width:150px; float:left;" value="<?php echo esc_attr($post['status_xpath']) ?>"/>
|
47 |
<a href="#help" class="help" title="<?php _e('The value of presented XPath should be one of the following: (\'publish\', \'draft\', \'trash\').', 'pmxi_plugin') ?>" style="position:relative; top:2px;">?</a>
|
48 |
</div>
|
49 |
</div>
|
@@ -60,7 +60,7 @@
|
|
60 |
<label for="ping_status_<?php echo $entry; ?>"><?php _e('Allow Trackbacks and Pingbacks', 'pmxi_plugin') ?></label>
|
61 |
</div>
|
62 |
</div>
|
63 |
-
</div>
|
64 |
<?php if ($is_support_post_format):?>
|
65 |
<div class="col3">
|
66 |
<h3><?php _e('Post Format', 'pmxi_plugin') ?></h3>
|
@@ -103,7 +103,7 @@
|
|
103 |
<label for="date_type_random_<?php echo $entry; ?>">
|
104 |
<?php _e('Random dates', 'pmxi_plugin') ?><a href="#help" class="help" title="<?php _e('Posts will be randomly assigned dates in this range. WordPress ensures posts with dates in the future will not appear until their date has been reached.', 'pmxi_plugin') ?>">?</a>
|
105 |
</label> <br>
|
106 |
-
<span class="switcher-target-date_type_random_<?php echo $entry; ?>" style="vertical-align:middle">
|
107 |
<input type="text" class="datepicker" name="date_start" value="<?php echo esc_attr($post['date_start']) ?>" />
|
108 |
<?php _e('and', 'pmxi_plugin') ?>
|
109 |
<input type="text" class="datepicker" name="date_end" value="<?php echo esc_attr($post['date_end']) ?>" />
|
1 |
<tr>
|
2 |
<td style="border-bottom:1px solid #ccc;" colspan="3">
|
3 |
|
4 |
+
<?php if ($post_type != "post" and $post_type != 'page'):?>
|
5 |
|
6 |
<?php if ($post_type == "product" and class_exists('PMWI_Plugin')):?>
|
7 |
|
43 |
<label for="status_xpath_<?php echo $entry; ?>"><?php _e('Set with XPath', 'pmxi_plugin' )?></label> <br>
|
44 |
<div class="switcher-target-status_xpath_<?php echo $entry; ?> set_xpath">
|
45 |
<div class="input">
|
46 |
+
<input type="text" class="smaller-text" name="status_xpath" style="width:150px; float:left; margin-left:10px;" value="<?php echo esc_attr($post['status_xpath']) ?>"/>
|
47 |
<a href="#help" class="help" title="<?php _e('The value of presented XPath should be one of the following: (\'publish\', \'draft\', \'trash\').', 'pmxi_plugin') ?>" style="position:relative; top:2px;">?</a>
|
48 |
</div>
|
49 |
</div>
|
60 |
<label for="ping_status_<?php echo $entry; ?>"><?php _e('Allow Trackbacks and Pingbacks', 'pmxi_plugin') ?></label>
|
61 |
</div>
|
62 |
</div>
|
63 |
+
</div>
|
64 |
<?php if ($is_support_post_format):?>
|
65 |
<div class="col3">
|
66 |
<h3><?php _e('Post Format', 'pmxi_plugin') ?></h3>
|
103 |
<label for="date_type_random_<?php echo $entry; ?>">
|
104 |
<?php _e('Random dates', 'pmxi_plugin') ?><a href="#help" class="help" title="<?php _e('Posts will be randomly assigned dates in this range. WordPress ensures posts with dates in the future will not appear until their date has been reached.', 'pmxi_plugin') ?>">?</a>
|
105 |
</label> <br>
|
106 |
+
<span class="switcher-target-date_type_random_<?php echo $entry; ?>" style="vertical-align:middle; display:inline-block; margin-top:10px;">
|
107 |
<input type="text" class="datepicker" name="date_start" value="<?php echo esc_attr($post['date_start']) ?>" />
|
108 |
<?php _e('and', 'pmxi_plugin') ?>
|
109 |
<input type="text" class="datepicker" name="date_end" value="<?php echo esc_attr($post['date_end']) ?>" />
|
views/admin/import/options/_reimport_template.php
CHANGED
@@ -39,45 +39,47 @@
|
|
39 |
<input type="checkbox" id="create_new_records_<?php echo $entry; ?>" name="create_new_records" value="1" <?php echo $post['create_new_records'] ? 'checked="checked"' : '' ?> />
|
40 |
<label for="create_new_records_<?php echo $entry; ?>"><?php _e('Create new posts from records newly present in your file', 'pmxi_plugin') ?></label>
|
41 |
</div>
|
42 |
-
<div class="
|
43 |
-
<input type="hidden" name="is_delete_missing" value="0" />
|
44 |
-
<input type="checkbox" id="is_delete_missing_<?php echo $entry; ?>" name="is_delete_missing" value="1" <?php echo $post['is_delete_missing'] ? 'checked="checked"': '' ?> class="switcher"/>
|
45 |
-
<label for="is_delete_missing_<?php echo $entry; ?>"><?php _e('Delete posts that are no longer present in your file', 'pmxi_plugin') ?></label>
|
46 |
-
<a href="#help" class="help" title="<?php _e('Check this option if you want to delete posts from the previous import operation which are not found among newly imported set.', 'pmxi_plugin') ?>">?</a>
|
47 |
-
</div>
|
48 |
-
<div class="switcher-target-is_delete_missing_<?php echo $entry; ?>" style="padding-left:17px;">
|
49 |
<div class="input">
|
50 |
-
<input type="hidden" name="
|
51 |
-
<input type="checkbox" id="
|
52 |
-
<label for="
|
53 |
-
<a href="#help" class="help" title="<?php _e('Check this option if you want
|
54 |
</div>
|
55 |
-
<div class="
|
56 |
-
<
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
<
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
</div>
|
73 |
</div>
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
</div>
|
80 |
-
</div>
|
81 |
<div class="input">
|
82 |
<input type="hidden" id="is_keep_former_posts_<?php echo $entry; ?>" name="is_keep_former_posts" value="yes" />
|
83 |
<input type="checkbox" id="is_not_keep_former_posts_<?php echo $entry; ?>" name="is_keep_former_posts" value="no" <?php echo "yes" != $post['is_keep_former_posts'] ? 'checked="checked"': '' ?> class="switcher" />
|
39 |
<input type="checkbox" id="create_new_records_<?php echo $entry; ?>" name="create_new_records" value="1" <?php echo $post['create_new_records'] ? 'checked="checked"' : '' ?> />
|
40 |
<label for="create_new_records_<?php echo $entry; ?>"><?php _e('Create new posts from records newly present in your file', 'pmxi_plugin') ?></label>
|
41 |
</div>
|
42 |
+
<div class="switcher-target-auto_matching_<?php echo $entry; ?>">
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
<div class="input">
|
44 |
+
<input type="hidden" name="is_delete_missing" value="0" />
|
45 |
+
<input type="checkbox" id="is_delete_missing_<?php echo $entry; ?>" name="is_delete_missing" value="1" <?php echo $post['is_delete_missing'] ? 'checked="checked"': '' ?> class="switcher"/>
|
46 |
+
<label for="is_delete_missing_<?php echo $entry; ?>"><?php _e('Delete posts that are no longer present in your file', 'pmxi_plugin') ?></label>
|
47 |
+
<a href="#help" class="help" title="<?php _e('Check this option if you want to delete posts from the previous import operation which are not found among newly imported set.', 'pmxi_plugin') ?>">?</a>
|
48 |
</div>
|
49 |
+
<div class="switcher-target-is_delete_missing_<?php echo $entry; ?>" style="padding-left:17px;">
|
50 |
+
<div class="input">
|
51 |
+
<input type="hidden" name="is_keep_attachments" value="0" />
|
52 |
+
<input type="checkbox" id="is_keep_attachments_<?php echo $entry; ?>" name="is_keep_attachments" value="1" <?php echo $post['is_keep_attachments'] ? 'checked="checked"': '' ?> />
|
53 |
+
<label for="is_keep_attachments_<?php echo $entry; ?>"><?php _e('Do not remove attachments', 'pmxi_plugin') ?></label>
|
54 |
+
<a href="#help" class="help" title="<?php _e('Check this option if you want attachments like *.pdf or *.doc files to be kept in media library after parent post or page is removed or replaced during reimport operation.', 'pmxi_plugin') ?>">?</a>
|
55 |
+
</div>
|
56 |
+
<div class="input">
|
57 |
+
<input type="hidden" name="is_keep_imgs" value="0" />
|
58 |
+
<input type="checkbox" id="is_keep_imgs_<?php echo $entry; ?>" name="is_keep_imgs" value="1" <?php echo $post['is_keep_imgs'] ? 'checked="checked"': '' ?> />
|
59 |
+
<label for="is_keep_imgs_<?php echo $entry; ?>"><?php _e('Do not remove images', 'pmxi_plugin') ?></label>
|
60 |
+
<a href="#help" class="help" title="<?php _e('Check this option if you want images like featured image to be kept in media library after parent post or page is removed or replaced during reimport operation.', 'pmxi_plugin') ?>">?</a>
|
61 |
+
</div>
|
62 |
+
<div class="input">
|
63 |
+
<input type="hidden" name="is_update_missing_cf" value="0" />
|
64 |
+
<input type="checkbox" id="is_update_missing_cf_<?php echo $entry; ?>" name="is_update_missing_cf" value="1" <?php echo $post['is_update_missing_cf'] ? 'checked="checked"': '' ?> class="switcher"/>
|
65 |
+
<label for="is_update_missing_cf_<?php echo $entry; ?>"><?php _e('Instead of deletion, set Custom Field', 'pmxi_plugin') ?></label>
|
66 |
+
<a href="#help" class="help" title="<?php _e('Check this option if you want to update posts custom fields from the previous import operation which are not found among newly imported set.', 'pmxi_plugin') ?>">?</a>
|
67 |
+
<div class="switcher-target-is_update_missing_cf_<?php echo $entry; ?>" style="padding-left:17px;">
|
68 |
+
<div class="input">
|
69 |
+
<?php _e('Name', 'pmxi_plugin') ?>
|
70 |
+
<input type="text" name="update_missing_cf_name" value="<?php echo esc_attr($post['update_missing_cf_name']) ?>" />
|
71 |
+
<?php _e('Value', 'pmxi_plugin') ?>
|
72 |
+
<input type="text" name="update_missing_cf_value" value="<?php echo esc_attr($post['update_missing_cf_value']) ?>" />
|
73 |
+
</div>
|
74 |
</div>
|
75 |
</div>
|
76 |
+
<div class="input">
|
77 |
+
<input type="hidden" name="set_missing_to_draft" value="0" />
|
78 |
+
<input type="checkbox" id="set_missing_to_draft_<?php echo $entry; ?>" name="set_missing_to_draft" value="1" <?php echo $post['set_missing_to_draft'] ? 'checked="checked"': '' ?> />
|
79 |
+
<label for="set_missing_to_draft_<?php echo $entry; ?>"><?php _e('Instead of deletion, change post status to Draft', 'pmxi_plugin') ?></label>
|
80 |
+
</div>
|
81 |
+
</div>
|
82 |
+
</div>
|
83 |
<div class="input">
|
84 |
<input type="hidden" id="is_keep_former_posts_<?php echo $entry; ?>" name="is_keep_former_posts" value="yes" />
|
85 |
<input type="checkbox" id="is_not_keep_former_posts_<?php echo $entry; ?>" name="is_keep_former_posts" value="no" <?php echo "yes" != $post['is_keep_former_posts'] ? 'checked="checked"': '' ?> class="switcher" />
|
views/admin/import/options/_settings_template.php
CHANGED
@@ -45,7 +45,7 @@
|
|
45 |
</span>
|
46 |
</div>
|
47 |
</p>
|
48 |
-
<?php if (in_array($source_type, array('ftp', 'file'))): ?>
|
49 |
<p>
|
50 |
<div class="input">
|
51 |
<input type="hidden" name="is_delete_source" value="0" />
|
45 |
</span>
|
46 |
</div>
|
47 |
</p>
|
48 |
+
<?php if (isset($source_type) and in_array($source_type, array('ftp', 'file'))): ?>
|
49 |
<p>
|
50 |
<div class="input">
|
51 |
<input type="hidden" name="is_delete_source" value="0" />
|
views/admin/import/options/_taxonomies_template.php
CHANGED
@@ -1,7 +1,5 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$exclude_taxonomies = (class_exists('PMWI_Plugin')) ? array('category', 'post_tag', 'post_format', 'product_type') : array('category', 'post_format', 'post_tag');
|
4 |
-
|
5 |
$post_taxonomies = array_diff_key(get_taxonomies_by_object_type(array($post_type), 'object'), array_flip($exclude_taxonomies));
|
6 |
if ( ! empty($post_taxonomies)): ?>
|
7 |
<tr>
|
@@ -20,46 +18,54 @@
|
|
20 |
<ol class="sortable no-margin">
|
21 |
<?php
|
22 |
if (!empty($post['post_taxonomies'][$ctx->name])):
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
25 |
if (is_null($cat->parent_id) or empty($cat->parent_id))
|
26 |
{
|
27 |
?>
|
28 |
-
<li id="item_<?php echo $i; ?>">
|
29 |
<div class="drag-element">
|
30 |
<input type="checkbox" class="assign_post" <?php if ($cat->assign): ?>checked="checked"<?php endif; ?> title="<?php _e('Assign post to the taxonomy.','pmxi_plugin');?>"/>
|
31 |
-
<input type="text" class="widefat" value="<?php echo esc_attr($cat->xpath); ?>"/>
|
|
|
|
|
|
|
32 |
</div>
|
33 |
<?php if ($i>1):?><a href="javascript:void(0);" class="icon-item remove-ico"></a><?php endif;?>
|
34 |
-
<?php echo reverse_taxonomies_html($taxonomies_hierarchy, $cat->item_id, $i); ?>
|
35 |
</li>
|
36 |
<?php
|
37 |
}
|
38 |
-
}
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
<?php endif;
|
46 |
-
else: ?>
|
47 |
-
<li id="item_1">
|
48 |
<div class="drag-element">
|
49 |
<input type="checkbox" class="assign_post" checked="checked" title="<?php _e('Assign post to the taxonomy.','pmxi_plugin');?>"/>
|
50 |
-
<input type="text" class="widefat" value=""/>
|
|
|
51 |
</div>
|
|
|
52 |
</li>
|
53 |
-
|
54 |
</ol>
|
55 |
-
<
|
|
|
|
|
56 |
<div class="delim">
|
57 |
<label><?php _e('Separated by', 'pmxi_plugin'); ?></label>
|
58 |
<input type="text" class="small tax_delim" value="<?php echo (!empty($taxonomies_hierarchy) and $taxonomies_hierarchy[0]->delim) ? str_replace("&","&", htmlentities(htmlentities($taxonomies_hierarchy[0]->delim))) : ',' ?>" />
|
59 |
<label for="nested_<?php echo $ctx->name;?>"><?php _e('Enable Auto Nest', 'pmxi_plugin');?></label>
|
60 |
<input id="nested_<?php echo $ctx->name;?>" type="checkbox" class="taxonomy_auto_nested" <?php if (!empty($taxonomies_hierarchy) and $taxonomies_hierarchy[0]->auto_nested):?>checked="checked"<?php endif; ?>/>
|
61 |
-
<a href="#help" class="help" title="<?php _e('If this box is checked, a category hierarchy will be created. For example, if your <code>{category}</code> value is <code>Mens > Shoes > Diesel</code>, enter <code>></code> as the separator and enable <code>Auto Nest</code> to create <code>Diesel</code> as a child category of <code>Shoes</code> and <code>Shoes</code> as a child category of <code>Mens.</code>', 'pmxi_plugin') ?>">?</a>
|
62 |
-
|
63 |
</div>
|
64 |
</div>
|
65 |
</div>
|
@@ -70,5 +76,4 @@
|
|
70 |
</fieldset>
|
71 |
</td>
|
72 |
</tr>
|
73 |
-
|
74 |
-
?>
|
1 |
+
<?php
|
2 |
+
$exclude_taxonomies = (class_exists('PMWI_Plugin')) ? array('category', 'post_tag', 'post_format', 'product_type') : array('category', 'post_format', 'post_tag');
|
|
|
|
|
3 |
$post_taxonomies = array_diff_key(get_taxonomies_by_object_type(array($post_type), 'object'), array_flip($exclude_taxonomies));
|
4 |
if ( ! empty($post_taxonomies)): ?>
|
5 |
<tr>
|
18 |
<ol class="sortable no-margin">
|
19 |
<?php
|
20 |
if (!empty($post['post_taxonomies'][$ctx->name])):
|
21 |
+
|
22 |
+
$taxonomies_hierarchy = json_decode($post['post_taxonomies'][$ctx->name]);
|
23 |
+
|
24 |
+
if (!empty($taxonomies_hierarchy) and is_array($taxonomies_hierarchy)): $i = 0;
|
25 |
+
|
26 |
+
foreach ($taxonomies_hierarchy as $cat) { $i++;
|
27 |
if (is_null($cat->parent_id) or empty($cat->parent_id))
|
28 |
{
|
29 |
?>
|
30 |
+
<li id="item_<?php echo $i; ?>" class="dragging">
|
31 |
<div class="drag-element">
|
32 |
<input type="checkbox" class="assign_post" <?php if ($cat->assign): ?>checked="checked"<?php endif; ?> title="<?php _e('Assign post to the taxonomy.','pmxi_plugin');?>"/>
|
33 |
+
<input type="text" class="widefat xpath_field" value="<?php echo esc_attr($cat->xpath); ?>"/>
|
34 |
+
|
35 |
+
<?php do_action('pmxi_category_view', $cat, $i, $ctx->name, $entry); ?>
|
36 |
+
|
37 |
</div>
|
38 |
<?php if ($i>1):?><a href="javascript:void(0);" class="icon-item remove-ico"></a><?php endif;?>
|
39 |
+
<?php echo reverse_taxonomies_html($taxonomies_hierarchy, $cat->item_id, $i, $ctx->name, $entry); ?>
|
40 |
</li>
|
41 |
<?php
|
42 |
}
|
43 |
+
}
|
44 |
+
|
45 |
+
endif;
|
46 |
+
|
47 |
+
endif;?>
|
48 |
+
|
49 |
+
<li id="item" class="template">
|
|
|
|
|
|
|
50 |
<div class="drag-element">
|
51 |
<input type="checkbox" class="assign_post" checked="checked" title="<?php _e('Assign post to the taxonomy.','pmxi_plugin');?>"/>
|
52 |
+
<input type="text" class="widefat xpath_field" value=""/>
|
53 |
+
<?php do_action('pmxi_category_view', false, false, $ctx->name, $entry); ?>
|
54 |
</div>
|
55 |
+
<a href="javascript:void(0);" class="icon-item remove-ico"></a>
|
56 |
</li>
|
57 |
+
|
58 |
</ol>
|
59 |
+
<a href="javascript:void(0);" class="icon-item add-new-ico"><?php _e('Add more','pmxi_plugin');?></a>
|
60 |
+
<input type="hidden" class="hierarhy-output" name="post_taxonomies[<?php echo $ctx->name ?>]" value="<?php echo esc_attr($post['post_taxonomies'][$ctx->name]) ?>"/>
|
61 |
+
<?php do_action('pmxi_category_options_view', ((!empty($post['post_taxonomies'][$ctx->name])) ? $post['post_taxonomies'][$ctx->name] : false), $ctx->name, $entry, $ctx->labels->name); ?>
|
62 |
<div class="delim">
|
63 |
<label><?php _e('Separated by', 'pmxi_plugin'); ?></label>
|
64 |
<input type="text" class="small tax_delim" value="<?php echo (!empty($taxonomies_hierarchy) and $taxonomies_hierarchy[0]->delim) ? str_replace("&","&", htmlentities(htmlentities($taxonomies_hierarchy[0]->delim))) : ',' ?>" />
|
65 |
<label for="nested_<?php echo $ctx->name;?>"><?php _e('Enable Auto Nest', 'pmxi_plugin');?></label>
|
66 |
<input id="nested_<?php echo $ctx->name;?>" type="checkbox" class="taxonomy_auto_nested" <?php if (!empty($taxonomies_hierarchy) and $taxonomies_hierarchy[0]->auto_nested):?>checked="checked"<?php endif; ?>/>
|
67 |
+
<a href="#help" class="help" style="position:relative; top:-1px; left: -5px;" title="<?php _e('If this box is checked, a category hierarchy will be created. For example, if your <code>{category}</code> value is <code>Mens > Shoes > Diesel</code>, enter <code>></code> as the separator and enable <code>Auto Nest</code> to create <code>Diesel</code> as a child category of <code>Shoes</code> and <code>Shoes</code> as a child category of <code>Mens.</code>', 'pmxi_plugin') ?>">?</a>
|
68 |
+
<?php do_action('pmxi_category_options', ((!empty($post['post_taxonomies'][$ctx->name])) ? $post['post_taxonomies'][$ctx->name] : false), $ctx->name, $entry); ?>
|
69 |
</div>
|
70 |
</div>
|
71 |
</div>
|
76 |
</fieldset>
|
77 |
</td>
|
78 |
</tr>
|
79 |
+
<?php endif; ?>
|
|
views/admin/import/process.php
CHANGED
@@ -133,8 +133,9 @@
|
|
133 |
}
|
134 |
else parse_element();
|
135 |
|
136 |
-
}, 'json').fail(function() {
|
137 |
-
|
|
|
138 |
$('#process_notice').hide();
|
139 |
$('#download_log').show();
|
140 |
$('#download_log_separator').show();
|
133 |
}
|
134 |
else parse_element();
|
135 |
|
136 |
+
}, 'json').fail(function(data) {
|
137 |
+
|
138 |
+
$('#loglist').append(data.responseText);
|
139 |
$('#process_notice').hide();
|
140 |
$('#download_log').show();
|
141 |
$('#download_log_separator').show();
|
views/admin/import/template.php
CHANGED
@@ -32,7 +32,8 @@
|
|
32 |
<div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
|
33 |
|
34 |
<?php wp_editor($post['content'], 'content', array(
|
35 |
-
'teeny' => true,
|
|
|
36 |
'editor_height' => 360));
|
37 |
?>
|
38 |
<table id="post-status-info" cellspacing="0">
|
32 |
<div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
|
33 |
|
34 |
<?php wp_editor($post['content'], 'content', array(
|
35 |
+
'teeny' => true,
|
36 |
+
'media_buttons' => false,
|
37 |
'editor_height' => 360));
|
38 |
?>
|
39 |
<table id="post-status-info" cellspacing="0">
|
views/admin/manage/index.php
CHANGED
@@ -125,7 +125,7 @@ $columns = apply_filters('pmxi_manage_imports_columns', $columns);
|
|
125 |
?>
|
126 |
<?php foreach ($list as $item): ?>
|
127 |
<?php $class = ('alternate' == $class) ? '' : 'alternate'; ?>
|
128 |
-
<tr class="<?php echo $class; ?>" valign="middle">
|
129 |
<th scope="row" class="check-column">
|
130 |
<input type="checkbox" id="item_<?php echo $item['id'] ?>" name="items[]" value="<?php echo esc_attr($item['id']) ?>" />
|
131 |
</th>
|
@@ -194,20 +194,75 @@ $columns = apply_filters('pmxi_manage_imports_columns', $columns);
|
|
194 |
|
195 |
<?php do_action('pmxi_import_menu', $item['id'], $this->baseUrl); ?>
|
196 |
|
197 |
-
|
198 |
-
<span class="edit"><a class="edit" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'options'), $this->baseUrl)) ?>"><?php _e('Edit Options', 'pmxi_plugin') ?></a></span> |
|
199 |
-
<span class="update"><a class="update" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'update'), $this->baseUrl)) ?>"><?php _e('Re-Run Import', 'pmxi_plugin') ?></a></span> |
|
200 |
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
<?php if ( ($item['imported'] + $item['skipped']) < $item['count'] and ! $item['options']['is_import_specified'] and ! (int) $item['triggered'] ):?>
|
209 |
| <span class="update"><a class="update" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'update', 'type' => 'continue'), $this->baseUrl)) ?>"><?php _e('Continue import', 'pmxi_plugin') ?></a></span>
|
210 |
<?php endif; ?>
|
|
|
211 |
</div>
|
212 |
</td>
|
213 |
<?php
|
@@ -236,7 +291,7 @@ $columns = apply_filters('pmxi_manage_imports_columns', $columns);
|
|
236 |
endswitch;
|
237 |
?>
|
238 |
<?php endforeach; ?>
|
239 |
-
</tr>
|
240 |
<?php do_action('pmxi_manage_imports', $item, $class); ?>
|
241 |
<?php endforeach; ?>
|
242 |
<?php endif ?>
|
125 |
?>
|
126 |
<?php foreach ($list as $item): ?>
|
127 |
<?php $class = ('alternate' == $class) ? '' : 'alternate'; ?>
|
128 |
+
<tr class="<?php echo $class; ?>" valign="middle">
|
129 |
<th scope="row" class="check-column">
|
130 |
<input type="checkbox" id="item_<?php echo $item['id'] ?>" name="items[]" value="<?php echo esc_attr($item['id']) ?>" />
|
131 |
</th>
|
194 |
|
195 |
<?php do_action('pmxi_import_menu', $item['id'], $this->baseUrl); ?>
|
196 |
|
197 |
+
<?php
|
|
|
|
|
198 |
|
199 |
+
$import_actions = array(
|
200 |
+
'edit_template' => array(
|
201 |
+
'url' => add_query_arg(array('id' => $item['id'], 'action' => 'edit'), $this->baseUrl),
|
202 |
+
'title' => __('Edit Template', 'pmxi_plugin'),
|
203 |
+
'class' => 'edit'
|
204 |
+
),
|
205 |
+
'edit_options' => array(
|
206 |
+
'url' => add_query_arg(array('id' => $item['id'], 'action' => 'options'), $this->baseUrl),
|
207 |
+
'title' => __('Edit Options', 'pmxi_plugin'),
|
208 |
+
'class' => 'edit'
|
209 |
+
),
|
210 |
+
're_run' => array(
|
211 |
+
'url' => add_query_arg(array('id' => $item['id'], 'action' => 'update'), $this->baseUrl),
|
212 |
+
'title' => __('Re-Run Import', 'pmxi_plugin'),
|
213 |
+
'class' => 'update'
|
214 |
+
),
|
215 |
+
'scheduling' => array(
|
216 |
+
'url' => add_query_arg(array('id' => $item['id'], 'action' => 'scheduling'), $this->baseUrl),
|
217 |
+
'title' => __('Cron Scheduling', 'pmxi_plugin'),
|
218 |
+
'class' => 'edit'
|
219 |
+
),
|
220 |
+
're_run_with_new_file' => array(
|
221 |
+
'url' => add_query_arg(array('page' => 'pmxi-admin-import', 'id' => $item['id']), admin_url('admin.php')),
|
222 |
+
'title' => __('Re-Run With New File', 'pmxi_plugin'),
|
223 |
+
'class' => 'update'
|
224 |
+
),
|
225 |
+
'log' => array(
|
226 |
+
'url' => add_query_arg(array('id' => $item['id'], 'action' => 'log'), $this->baseUrl),
|
227 |
+
'title' => __('Download Log', 'pmxi_plugin'),
|
228 |
+
'class' => 'update'
|
229 |
+
),
|
230 |
+
'delete' => array(
|
231 |
+
'url' => add_query_arg(array('id' => $item['id'], 'action' => 'delete'), $this->baseUrl),
|
232 |
+
'title' => __('Delete', 'pmxi_plugin'),
|
233 |
+
'class' => 'delete'
|
234 |
+
),
|
235 |
+
);
|
236 |
+
|
237 |
+
$import_actions = apply_filters('pmxi_import_actions', $import_actions, $item );
|
238 |
+
|
239 |
+
$ai = 1;
|
240 |
+
foreach ($import_actions as $key => $action) {
|
241 |
+
switch ($key) {
|
242 |
+
case 'scheduling':
|
243 |
+
if ( in_array($item['type'], array('url', 'ftp', 'file'))):
|
244 |
+
?>
|
245 |
+
<span class="<?php echo $action['class']; ?>"><a class="<?php echo $action['class']; ?>" href="<?php echo esc_url($action['url']); ?>"><?php echo $action['title']; ?></a></span> <?php if ($ai != count($import_actions)): ?>|<?php endif; ?>
|
246 |
+
<?php
|
247 |
+
endif;
|
248 |
+
|
249 |
+
break;
|
250 |
+
|
251 |
+
default:
|
252 |
+
?>
|
253 |
+
<span class="<?php echo $action['class']; ?>"><a class="<?php echo $action['class']; ?>" href="<?php echo esc_url($action['url']); ?>"><?php echo $action['title']; ?></a></span> <?php if ($ai != count($import_actions)): ?>|<?php endif; ?>
|
254 |
+
<?php
|
255 |
+
break;
|
256 |
+
}
|
257 |
+
$ai++;
|
258 |
+
}
|
259 |
+
|
260 |
+
?>
|
261 |
+
|
262 |
<?php if ( ($item['imported'] + $item['skipped']) < $item['count'] and ! $item['options']['is_import_specified'] and ! (int) $item['triggered'] ):?>
|
263 |
| <span class="update"><a class="update" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'update', 'type' => 'continue'), $this->baseUrl)) ?>"><?php _e('Continue import', 'pmxi_plugin') ?></a></span>
|
264 |
<?php endif; ?>
|
265 |
+
|
266 |
</div>
|
267 |
</td>
|
268 |
<?php
|
291 |
endswitch;
|
292 |
?>
|
293 |
<?php endforeach; ?>
|
294 |
+
</tr>
|
295 |
<?php do_action('pmxi_manage_imports', $item, $class); ?>
|
296 |
<?php endforeach; ?>
|
297 |
<?php endif ?>
|
views/admin/settings/index.php
CHANGED
@@ -46,15 +46,7 @@
|
|
46 |
|
47 |
<h3><?php _e('Import Settings', 'pmxi_plugin') ?></h3>
|
48 |
<p>
|
49 |
-
<?php printf(__('Create XML chunks, when feed contains more than %s (records)', 'pmxi_plugin'), '<input type="text" name="large_feed_limit" value="' . esc_attr($post['large_feed_limit']) . '"/>')
|
50 |
-
<p>
|
51 |
-
<input type="hidden" name="legacy_special_character_handling" value="0"/>
|
52 |
-
<?php printf(__('%s <label for="legacy_special_character_handling">My CSV files contain HTML code</label>', 'pmxi_plugin'), '<input type="checkbox" name="legacy_special_character_handling" id="legacy_special_character_handling" value="1" style="position:relative; top:-2px;" '. (($post['legacy_special_character_handling']) ? 'checked="checked"' : '') .'/>') ?>
|
53 |
-
<a href="#help" class="help" title="<?php _e('By default WP All Import does not encode the content of a CSV feed using htmlspecialchars(). Enable this option, and WP All Import will use htmlspecialchars() on the CSV content. Try this option if you get errors when importing CSV files in Step 1.', 'pmxi_plugin') ?>">?</a>
|
54 |
-
</p>
|
55 |
-
<p>
|
56 |
-
<input type="hidden" name="case_sensitive" value="0"/>
|
57 |
-
<?php printf(__('%s <label for="case_sensitive">Enable case-sensitivity mode</label>', 'pmxi_plugin'), '<input type="checkbox" name="case_sensitive" id="case_sensitive" value="1" style="position:relative; top:-2px;" '. (($post['case_sensitive']) ? 'checked="checked"' : '') .'/>') ?>
|
58 |
</p>
|
59 |
<p>
|
60 |
<input type="hidden" name="pingbacks" value="0"/>
|
46 |
|
47 |
<h3><?php _e('Import Settings', 'pmxi_plugin') ?></h3>
|
48 |
<p>
|
49 |
+
<?php printf(__('Create XML chunks, when feed contains more than %s (records)', 'pmxi_plugin'), '<input type="text" name="large_feed_limit" value="' . esc_attr($post['large_feed_limit']) . '"/>') ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
</p>
|
51 |
<p>
|
52 |
<input type="hidden" name="pingbacks" value="0"/>
|