Version Description
- load ini_set only on plugin pages
- fixed saving import template
Download this release
Release Info
Developer | soflyy |
Plugin | Import any XML or CSV File to WordPress |
Version | 3.2.9 |
Comparing to | |
See all releases |
Code changes from version 3.2.8 to 3.2.9
- classes/api.php +222 -117
- controllers/admin/import.php +23 -19
- models/import/record.php +473 -359
- plugin.php +2 -2
- readme.txt +5 -1
- static/css/admin.css +29 -0
- static/js/admin.js +7 -0
- views/admin/import/options/_reimport_options.php +3 -0
- views/admin/import/preview_images.php +3 -3
- views/admin/import/template.php +5 -2
- views/admin/import/template/_featured_template.php +67 -73
classes/api.php
CHANGED
@@ -27,38 +27,87 @@ class PMXI_API
|
|
27 |
'xpath' => '',
|
28 |
'field_name' => '',
|
29 |
'field_value' => '',
|
30 |
-
'addon_prefix' => ''
|
|
|
|
|
|
|
31 |
);
|
32 |
|
33 |
ob_start();
|
34 |
-
if ($label != ""){
|
35 |
?>
|
36 |
<label for="<?php echo sanitize_title($params['field_name']); ?>"><?php echo $label;?></label>
|
37 |
<?php
|
38 |
}
|
39 |
if ( ! empty($params['tooltip'])){
|
40 |
?>
|
41 |
-
<a href="#help" class="wpallimport-help" title="<?php echo $params['tooltip']; ?>" style="position: relative; top: -2px;">?</a>
|
42 |
<?php
|
43 |
}
|
|
|
|
|
44 |
?>
|
45 |
<div class="input">
|
46 |
<?php
|
|
|
|
|
47 |
switch ($field_type){
|
|
|
48 |
case 'simple':
|
49 |
?>
|
50 |
<input type="text" name="<?php echo $params['field_name']; ?>" id="<?php echo sanitize_title($params['field_name']); ?>" value="<?php echo $params['field_value']; ?>" style="width:100%;"/>
|
51 |
<?php
|
52 |
break;
|
|
|
53 |
case 'enum':
|
54 |
-
?>
|
55 |
|
56 |
-
|
57 |
-
|
58 |
-
<
|
59 |
-
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
<div class="form-field wpallimport-radio-field">
|
63 |
<input type="radio" id="<?php echo sanitize_title($params['field_name']); ?>_xpath" class="switcher" name="<?php echo $params['field_name']; ?>" value="xpath" <?php echo 'xpath' == $params['field_value'] ? 'checked="checked"': '' ?>/>
|
64 |
<label for="<?php echo sanitize_title($params['field_name']); ?>_xpath"><?php _e('Set with XPath', 'wp_all_import_plugin' )?></label>
|
@@ -71,132 +120,136 @@ class PMXI_API
|
|
71 |
<input type="text" class="smaller-text" name="<?php echo $params['addon_prefix'];?>[xpaths][<?php echo $params['field_key']; ?>]" value="<?php echo esc_attr($params['xpath']) ?>"/>
|
72 |
</td>
|
73 |
<td class="action">
|
|
|
74 |
<?php if ($params['mapping']): ?>
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
$k = $key;
|
103 |
-
|
104 |
-
if (is_array($value)){
|
105 |
-
$keys = array_keys($value);
|
106 |
-
$k = $keys[0];
|
107 |
-
}
|
108 |
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
<
|
118 |
-
<
|
119 |
-
|
120 |
-
|
121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
}
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
</
|
138 |
-
|
139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
}
|
141 |
-
} else {
|
142 |
-
?>
|
143 |
-
<tr class="form-field">
|
144 |
-
<td>
|
145 |
-
<input type="text" class="mapping_from widefat">
|
146 |
-
</td>
|
147 |
-
<td>
|
148 |
-
<input type="text" class="mapping_to widefat">
|
149 |
-
</td>
|
150 |
-
<td class="action remove">
|
151 |
-
<a href="#remove" style="right:-10px;"></a>
|
152 |
-
</td>
|
153 |
-
</tr>
|
154 |
-
<?php
|
155 |
}
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
</
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
</
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
</
|
179 |
-
</
|
180 |
-
</
|
181 |
-
</
|
182 |
-
|
183 |
-
|
184 |
-
</
|
185 |
-
</div>
|
186 |
<?php endif; ?>
|
187 |
</td>
|
188 |
</tr>
|
189 |
</table>
|
190 |
</span>
|
191 |
</div>
|
192 |
-
</div>
|
|
|
193 |
<?php
|
194 |
break;
|
|
|
195 |
case 'textarea':
|
196 |
?>
|
197 |
<textarea name="<?php echo $params['field_name']; ?>" id="<?php echo sanitize_title($params['field_name']); ?>" class="rad4 newline" style="height: 70px;margin: 5px 0;padding-top: 5px;width: 70%;"><?php echo $params['field_value']; ?></textarea>
|
198 |
<?php
|
199 |
break;
|
|
|
200 |
case 'image':
|
201 |
?>
|
202 |
<div class="input">
|
@@ -216,13 +269,65 @@ class PMXI_API
|
|
216 |
</div>
|
217 |
<?php
|
218 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
}
|
|
|
220 |
?>
|
221 |
</div>
|
222 |
<?php
|
|
|
223 |
echo ob_get_clean();
|
224 |
}
|
225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
public static function upload_image($pid, $img_url, $download_images, $logger, $create_image = false, $image_name = ""){
|
227 |
|
228 |
$url = str_replace(" ", "%20", trim($img_url));
|
27 |
'xpath' => '',
|
28 |
'field_name' => '',
|
29 |
'field_value' => '',
|
30 |
+
'addon_prefix' => '',
|
31 |
+
'sub_fields' => array(),
|
32 |
+
'is_main_field' => false,
|
33 |
+
'in_the_bottom' => false
|
34 |
);
|
35 |
|
36 |
ob_start();
|
37 |
+
if ($label != "" and $field_type != "accordion"){
|
38 |
?>
|
39 |
<label for="<?php echo sanitize_title($params['field_name']); ?>"><?php echo $label;?></label>
|
40 |
<?php
|
41 |
}
|
42 |
if ( ! empty($params['tooltip'])){
|
43 |
?>
|
44 |
+
<a href="#help" class="wpallimport-help" title="<?php echo esc_attr($params['tooltip']); ?>" style="position: relative; top: -2px;">?</a>
|
45 |
<?php
|
46 |
}
|
47 |
+
|
48 |
+
if ( ! $params['in_the_bottom'] ){
|
49 |
?>
|
50 |
<div class="input">
|
51 |
<?php
|
52 |
+
}
|
53 |
+
|
54 |
switch ($field_type){
|
55 |
+
|
56 |
case 'simple':
|
57 |
?>
|
58 |
<input type="text" name="<?php echo $params['field_name']; ?>" id="<?php echo sanitize_title($params['field_name']); ?>" value="<?php echo $params['field_value']; ?>" style="width:100%;"/>
|
59 |
<?php
|
60 |
break;
|
61 |
+
|
62 |
case 'enum':
|
|
|
63 |
|
64 |
+
$is_set_with_xpath_visible = true;
|
65 |
+
foreach ($params['enum_values'] as $key => $value): ?>
|
66 |
+
<div class="form-field wpallimport-radio-field">
|
67 |
+
<input type="radio" id="<?php echo sanitize_title($params['field_name']); ?>_<?php echo $key; ?>" class="switcher" name="<?php echo $params['field_name']; ?>" value="<?php echo $key; ?>" <?php echo $key == $params['field_value'] ? 'checked="checked"': '' ?>/>
|
68 |
+
<?php
|
69 |
+
$label = '';
|
70 |
+
$tooltip = '';
|
71 |
+
if (is_array($value)){
|
72 |
+
$label = array_shift($value);
|
73 |
+
}
|
74 |
+
else{
|
75 |
+
$label = $value;
|
76 |
+
}
|
77 |
+
?>
|
78 |
+
<label for="<?php echo sanitize_title($params['field_name']); ?>_<?php echo $key; ?>"><?php echo $label; ?></label>
|
79 |
+
<?php
|
80 |
+
if (is_array($value) and ! empty($value)){
|
81 |
+
foreach ($value as $k => $p) {
|
82 |
+
if ( ! is_array($p)){
|
83 |
+
?>
|
84 |
+
<a href="#help" class="wpallimport-help" title="<?php echo esc_attr($p); ?>" style="position: relative; top: -2px;">?</a>
|
85 |
+
<?php
|
86 |
+
break;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
}
|
90 |
+
?>
|
91 |
+
<?php
|
92 |
+
if (! empty($params['sub_fields'][$key])){
|
93 |
+
?>
|
94 |
+
<div class="switcher-target-<?php echo sanitize_title($params['field_name']); ?>_<?php echo $key; ?>">
|
95 |
+
<div class="input sub_input">
|
96 |
+
<?php
|
97 |
+
foreach ($params['sub_fields'][$key] as $sub_field) {
|
98 |
+
PMXI_API::add_field($sub_field['type'], $sub_field['label'], $sub_field['params']);
|
99 |
+
}
|
100 |
+
?>
|
101 |
+
</div>
|
102 |
+
</div>
|
103 |
+
<?php
|
104 |
+
$is_set_with_xpath_visible = false;
|
105 |
+
}
|
106 |
+
?>
|
107 |
+
|
108 |
+
</div>
|
109 |
+
<?php endforeach;?>
|
110 |
+
<?php if ( $is_set_with_xpath_visible ): ?>
|
111 |
<div class="form-field wpallimport-radio-field">
|
112 |
<input type="radio" id="<?php echo sanitize_title($params['field_name']); ?>_xpath" class="switcher" name="<?php echo $params['field_name']; ?>" value="xpath" <?php echo 'xpath' == $params['field_value'] ? 'checked="checked"': '' ?>/>
|
113 |
<label for="<?php echo sanitize_title($params['field_name']); ?>_xpath"><?php _e('Set with XPath', 'wp_all_import_plugin' )?></label>
|
120 |
<input type="text" class="smaller-text" name="<?php echo $params['addon_prefix'];?>[xpaths][<?php echo $params['field_key']; ?>]" value="<?php echo esc_attr($params['xpath']) ?>"/>
|
121 |
</td>
|
122 |
<td class="action">
|
123 |
+
|
124 |
<?php if ($params['mapping']): ?>
|
125 |
|
126 |
+
<?php $custom_mapping_rules = (!empty($params['mapping_rules'])) ? json_decode($params['mapping_rules'], true) : false; ?>
|
127 |
+
|
128 |
+
<div class="input wpallimport-custom-fields-actions">
|
129 |
+
<a href="javascript:void(0);" class="wpallimport-cf-options"><?php _e('Field Options...', 'wp_all_import_plugin'); ?></a>
|
130 |
+
<ul id="wpallimport-cf-menu-<?php echo sanitize_title($params['field_name']);?>" class="wpallimport-cf-menu">
|
131 |
+
<li class="<?php echo ( ! empty($custom_mapping_rules) ) ? 'active' : ''; ?>">
|
132 |
+
<a href="javascript:void(0);" class="set_mapping pmxi_cf_mapping" rel="cf_mapping_<?php echo sanitize_title($params['field_name']); ?>"><?php _e('Mapping', 'wp_all_import_plugin'); ?></a>
|
133 |
+
</li>
|
134 |
+
</ul>
|
135 |
+
</div>
|
136 |
+
<div id="cf_mapping_<?php echo sanitize_title($params['field_name']); ?>" class="custom_type" rel="mapping" style="display:none;">
|
137 |
+
<fieldset>
|
138 |
+
<table cellpadding="0" cellspacing="5" class="cf-form-table" rel="cf_mapping_<?php echo sanitize_title($params['field_name']); ?>">
|
139 |
+
<thead>
|
140 |
+
<tr>
|
141 |
+
<td><?php _e('In Your File', 'wp_all_import_plugin') ?></td>
|
142 |
+
<td><?php _e('Translated To', 'wp_all_import_plugin') ?></td>
|
143 |
+
<td> </td>
|
144 |
+
</tr>
|
145 |
+
</thead>
|
146 |
+
<tbody>
|
147 |
+
<?php
|
148 |
+
if ( ! empty($custom_mapping_rules) and is_array($custom_mapping_rules)){
|
149 |
+
|
150 |
+
foreach ($custom_mapping_rules as $key => $value) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
|
152 |
+
$k = $key;
|
153 |
+
|
154 |
+
if (is_array($value)){
|
155 |
+
$keys = array_keys($value);
|
156 |
+
$k = $keys[0];
|
157 |
+
}
|
158 |
+
|
159 |
+
?>
|
160 |
+
<tr class="form-field">
|
161 |
+
<td>
|
162 |
+
<input type="text" class="mapping_from widefat" value="<?php echo esc_textarea($k); ?>">
|
163 |
+
</td>
|
164 |
+
<td>
|
165 |
+
<input type="text" class="mapping_to widefat" value="<?php echo esc_textarea((is_array($value)) ? $value[$k] : $value); ?>">
|
166 |
+
</td>
|
167 |
+
<td class="action remove">
|
168 |
+
<a href="#remove" style="right:-10px;"></a>
|
169 |
+
</td>
|
170 |
+
</tr>
|
171 |
+
<?php
|
172 |
+
}
|
173 |
}
|
174 |
+
else{
|
175 |
+
if ( ! empty($params['enum_values']) and is_array($params['enum_values'])){
|
176 |
+
foreach ($params['enum_values'] as $key => $value){
|
177 |
+
?>
|
178 |
+
<tr class="form-field">
|
179 |
+
<td>
|
180 |
+
<input type="text" class="mapping_from widefat">
|
181 |
+
</td>
|
182 |
+
<td>
|
183 |
+
<input type="text" class="mapping_to widefat" value="<?php echo $key; ?>">
|
184 |
+
</td>
|
185 |
+
<td class="action remove">
|
186 |
+
<a href="#remove" style="right:-10px;"></a>
|
187 |
+
</td>
|
188 |
+
</tr>
|
189 |
+
<?php
|
190 |
+
}
|
191 |
+
} else {
|
192 |
+
?>
|
193 |
+
<tr class="form-field">
|
194 |
+
<td>
|
195 |
+
<input type="text" class="mapping_from widefat">
|
196 |
+
</td>
|
197 |
+
<td>
|
198 |
+
<input type="text" class="mapping_to widefat">
|
199 |
+
</td>
|
200 |
+
<td class="action remove">
|
201 |
+
<a href="#remove" style="right:-10px;"></a>
|
202 |
+
</td>
|
203 |
+
</tr>
|
204 |
+
<?php
|
205 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
}
|
207 |
+
?>
|
208 |
+
<tr class="form-field template">
|
209 |
+
<td>
|
210 |
+
<input type="text" class="mapping_from widefat">
|
211 |
+
</td>
|
212 |
+
<td>
|
213 |
+
<input type="text" class="mapping_to widefat">
|
214 |
+
</td>
|
215 |
+
<td class="action remove">
|
216 |
+
<a href="#remove" style="right:-10px;"></a>
|
217 |
+
</td>
|
218 |
+
</tr>
|
219 |
+
<tr>
|
220 |
+
<td colspan="3">
|
221 |
+
<a href="javascript:void(0);" title="<?php _e('Add Another', 'wp_all_import_plugin')?>" class="action add-new-key add-new-entry"><?php _e('Add Another', 'wp_all_import_plugin') ?></a>
|
222 |
+
</td>
|
223 |
+
</tr>
|
224 |
+
<tr>
|
225 |
+
<td colspan="3">
|
226 |
+
<div class="wrap" style="position:relative;">
|
227 |
+
<a class="save_popup save_mr" href="javascript:void(0);"><?php _e('Save Rules', 'wp_all_import_plugin'); ?></a>
|
228 |
+
</div>
|
229 |
+
</td>
|
230 |
+
</tr>
|
231 |
+
</tbody>
|
232 |
+
</table>
|
233 |
+
<input type="hidden" class="pmre_mapping_rules" name="<?php echo $params['addon_prefix'];?>[mapping][<?php echo $params['field_key']; ?>]" value="<?php if (!empty($params['mapping_rules'])) echo esc_html($params['mapping_rules']); ?>"/>
|
234 |
+
</fieldset>
|
235 |
+
</div>
|
|
|
236 |
<?php endif; ?>
|
237 |
</td>
|
238 |
</tr>
|
239 |
</table>
|
240 |
</span>
|
241 |
</div>
|
242 |
+
</div>
|
243 |
+
<?php endif; ?>
|
244 |
<?php
|
245 |
break;
|
246 |
+
|
247 |
case 'textarea':
|
248 |
?>
|
249 |
<textarea name="<?php echo $params['field_name']; ?>" id="<?php echo sanitize_title($params['field_name']); ?>" class="rad4 newline" style="height: 70px;margin: 5px 0;padding-top: 5px;width: 70%;"><?php echo $params['field_value']; ?></textarea>
|
250 |
<?php
|
251 |
break;
|
252 |
+
|
253 |
case 'image':
|
254 |
?>
|
255 |
<div class="input">
|
269 |
</div>
|
270 |
<?php
|
271 |
break;
|
272 |
+
|
273 |
+
case 'accordion':
|
274 |
+
|
275 |
+
$is_full_width = true;
|
276 |
+
if ( ! empty($params['sub_fields']) ){
|
277 |
+
foreach ($params['sub_fields'] as $sub_field) {
|
278 |
+
if ($sub_field[0]['params']['is_main_field']){
|
279 |
+
PMXI_API::add_field($sub_field[0]['type'], $sub_field[0]['label'], $sub_field[0]['params']);
|
280 |
+
$is_full_width = false;
|
281 |
+
break;
|
282 |
+
}
|
283 |
+
}
|
284 |
+
}
|
285 |
+
|
286 |
+
$in_the_bottom = $params['in_the_bottom'];
|
287 |
+
|
288 |
+
$styles = ($is_full_width) ? 'margin-left: -25px; margin-right: -25px;' : 'margin-top: -16px;';
|
289 |
+
|
290 |
+
if ( ! $in_the_bottom and $is_full_width ) $styles .= 'margin-top: 25px; margin-bottom: 25px;';
|
291 |
+
|
292 |
+
?>
|
293 |
+
<div class="wpallimport-collapsed closed wpallimport-section <?php echo (($in_the_bottom and $is_full_width) ? 'wpallimport-sub-options-full-width' : 'wpallimport-sub-options'); echo ((!$is_full_width) ? ' wpallimport-dependent-options' : '');?> " style="<?php echo $styles; ?>">
|
294 |
+
<div class="wpallimport-content-section <?php echo (($is_full_width and !$in_the_bottom) ? 'rad0' : 'wpallimport-bottom-radius');?> ">
|
295 |
+
<div class="wpallimport-collapsed-header">
|
296 |
+
<h3 style="color:#40acad;"><?php echo $label; ?></h3>
|
297 |
+
</div>
|
298 |
+
<div class="wpallimport-collapsed-content" style="padding: 0;">
|
299 |
+
<div class="wpallimport-collapsed-content-inner">
|
300 |
+
|
301 |
+
<?php
|
302 |
+
if ( ! empty($params['sub_fields']) ){
|
303 |
+
foreach ($params['sub_fields'] as $sub_field) {
|
304 |
+
if ( ! $sub_field[0]['params']['is_main_field'])
|
305 |
+
PMXI_API::add_field($sub_field[0]['type'], $sub_field[0]['label'], $sub_field[0]['params']);
|
306 |
+
}
|
307 |
+
}
|
308 |
+
?>
|
309 |
+
|
310 |
+
</div>
|
311 |
+
</div>
|
312 |
+
</div>
|
313 |
+
</div>
|
314 |
+
<?php
|
315 |
+
break;
|
316 |
}
|
317 |
+
if ( ! $params['in_the_bottom'] ){
|
318 |
?>
|
319 |
</div>
|
320 |
<?php
|
321 |
+
}
|
322 |
echo ob_get_clean();
|
323 |
}
|
324 |
|
325 |
+
public static function add_additional_images_section( $section_title, $section_slug, $post, $post_type = '', $section_is_show_hints = true, $section_is_show_warning = false, $section_type = 'images'){
|
326 |
+
|
327 |
+
include( WP_ALL_IMPORT_ROOT_DIR . '/views/admin/import/template/_featured_template.php' );
|
328 |
+
|
329 |
+
}
|
330 |
+
|
331 |
public static function upload_image($pid, $img_url, $download_images, $logger, $create_image = false, $image_name = ""){
|
332 |
|
333 |
$url = str_replace(" ", "%20", trim($img_url));
|
controllers/admin/import.php
CHANGED
@@ -914,12 +914,16 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
914 |
|
915 |
if ( ! $this->errors->get_error_codes()) {
|
916 |
|
|
|
|
|
|
|
|
|
917 |
$post = $this->data['post'] = $this->input->post(array(
|
918 |
-
'download_images' => 'no',
|
919 |
-
'download_featured_delim' => '',
|
920 |
-
'featured_delim' => '',
|
921 |
-
'download_featured_image' => '',
|
922 |
-
'featured_image' => '',
|
923 |
'import_encoding' => 'UTF-8',
|
924 |
'tagno' => 0
|
925 |
));
|
@@ -993,7 +997,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
993 |
|
994 |
// validate
|
995 |
try {
|
996 |
-
$featured_image = ( 'yes' == $post['download_images']) ? $post['download_featured_image'] : $post['featured_image'];
|
997 |
if (empty($xml)){
|
998 |
$this->errors->add('form-validation', __('WP All Import lost track of where you are.<br/><br/>Maybe you cleared your cookies or maybe it is just a temporary issue on your web host\'s end.<br/>If you can\'t do an import without seeing this error, change your session settings on the All Import -> Settings page.', 'wp_all_import_plugin'));
|
999 |
} elseif (empty($featured_image)){
|
@@ -1368,18 +1372,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
1368 |
$this->warnings->add('2', __('<strong>Warning:</strong> your content is blank.', 'wp_all_import_plugin'));
|
1369 |
}
|
1370 |
|
1371 |
-
if ( ! $this->errors->get_error_codes()) {
|
1372 |
-
|
1373 |
-
if ( ! empty($post['name']) and !empty($post['save_template_as']) ) { // save template in database
|
1374 |
-
$template->getByName($post['name'])->set(array(
|
1375 |
-
'name' => $post['name'],
|
1376 |
-
'is_keep_linebreaks' => $post['is_keep_linebreaks'],
|
1377 |
-
'is_leave_html' => $post['is_leave_html'],
|
1378 |
-
'fix_characters' => $post['fix_characters'],
|
1379 |
-
'options' => $post
|
1380 |
-
))->save();
|
1381 |
-
PMXI_Plugin::$session->set('saved_template', $template->id);
|
1382 |
-
}
|
1383 |
|
1384 |
// Attributes fields logic
|
1385 |
$post = apply_filters('pmxi_save_options', $post);
|
@@ -1447,7 +1440,18 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
|
|
1447 |
// assign some defaults
|
1448 |
'' !== $post['date'] or $post['date'] = 'now';
|
1449 |
'' !== $post['date_start'] or $post['date_start'] = 'now';
|
1450 |
-
'' !== $post['date_end'] or $post['date_end'] = 'now';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1451 |
|
1452 |
if ($this->isWizard) {
|
1453 |
PMXI_Plugin::$session->set('options', $post);
|
914 |
|
915 |
if ( ! $this->errors->get_error_codes()) {
|
916 |
|
917 |
+
$get = $this->data['get'] = $this->input->get(array(
|
918 |
+
'slug' => ''
|
919 |
+
));
|
920 |
+
|
921 |
$post = $this->data['post'] = $this->input->post(array(
|
922 |
+
$get['slug'] . 'download_images' => 'no',
|
923 |
+
$get['slug'] . 'download_featured_delim' => '',
|
924 |
+
$get['slug'] . 'featured_delim' => '',
|
925 |
+
$get['slug'] . 'download_featured_image' => '',
|
926 |
+
$get['slug'] . 'featured_image' => '',
|
927 |
'import_encoding' => 'UTF-8',
|
928 |
'tagno' => 0
|
929 |
));
|
997 |
|
998 |
// validate
|
999 |
try {
|
1000 |
+
$featured_image = ( 'yes' == $post[$get['slug'] . 'download_images']) ? $post[$get['slug'] . 'download_featured_image'] : $post[$get['slug'] . 'featured_image'];
|
1001 |
if (empty($xml)){
|
1002 |
$this->errors->add('form-validation', __('WP All Import lost track of where you are.<br/><br/>Maybe you cleared your cookies or maybe it is just a temporary issue on your web host\'s end.<br/>If you can\'t do an import without seeing this error, change your session settings on the All Import -> Settings page.', 'wp_all_import_plugin'));
|
1003 |
} elseif (empty($featured_image)){
|
1372 |
$this->warnings->add('2', __('<strong>Warning:</strong> your content is blank.', 'wp_all_import_plugin'));
|
1373 |
}
|
1374 |
|
1375 |
+
if ( ! $this->errors->get_error_codes()) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1376 |
|
1377 |
// Attributes fields logic
|
1378 |
$post = apply_filters('pmxi_save_options', $post);
|
1440 |
// assign some defaults
|
1441 |
'' !== $post['date'] or $post['date'] = 'now';
|
1442 |
'' !== $post['date_start'] or $post['date_start'] = 'now';
|
1443 |
+
'' !== $post['date_end'] or $post['date_end'] = 'now';
|
1444 |
+
|
1445 |
+
if ( ! empty($post['name']) and !empty($post['save_template_as']) ) { // save template in database
|
1446 |
+
$template->getByName($post['name'])->set(array(
|
1447 |
+
'name' => $post['name'],
|
1448 |
+
'is_keep_linebreaks' => $post['is_keep_linebreaks'],
|
1449 |
+
'is_leave_html' => $post['is_leave_html'],
|
1450 |
+
'fix_characters' => $post['fix_characters'],
|
1451 |
+
'options' => $post
|
1452 |
+
))->save();
|
1453 |
+
PMXI_Plugin::$session->set('saved_template', $template->id);
|
1454 |
+
}
|
1455 |
|
1456 |
if ($this->isWizard) {
|
1457 |
PMXI_Plugin::$session->set('options', $post);
|
models/import/record.php
CHANGED
@@ -549,98 +549,126 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
549 |
}
|
550 |
endforeach;
|
551 |
endif;
|
552 |
-
// [/custom taxonomies]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
553 |
|
554 |
-
// Composing featured images
|
555 |
if ( ! (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
|
556 |
$logger and call_user_func($logger, __('<b>WARNING</b>', 'wp_all_import_plugin') . ': ' . $uploads['error']);
|
557 |
$logger and call_user_func($logger, __('<b>WARNING</b>: No featured images will be created. Uploads folder is not found.', 'wp_all_import_plugin'));
|
558 |
$logger and !$is_cron and PMXI_Plugin::$session->warnings++;
|
559 |
} else {
|
560 |
-
$
|
561 |
-
$
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
567 |
}
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
574 |
}
|
575 |
-
}
|
576 |
-
}
|
577 |
-
|
578 |
-
// Composing images meta titles
|
579 |
-
if ( $this->options['set_image_meta_title'] ){
|
580 |
-
$chunk == 1 and $logger and call_user_func($logger, __('Composing image meta data (titles)...', 'wp_all_import_plugin'));
|
581 |
-
$image_meta_titles = array();
|
582 |
|
583 |
-
|
584 |
-
$
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
589 |
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
|
|
|
|
600 |
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
|
|
|
|
611 |
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
|
|
|
|
|
|
622 |
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
|
|
633 |
|
634 |
-
|
635 |
-
|
636 |
-
$auto_extensions = array();
|
637 |
-
if ( $this->options['auto_set_extension'] and ! empty($this->options['new_extension'])){
|
638 |
-
$auto_extensions = XmlImportParser::factory($xml, $cxpath, $this->options['new_extension'], $file)->parse($records); $tmp_files[] = $file;
|
639 |
-
}
|
640 |
-
else{
|
641 |
-
count($titles) and $auto_extensions = array_fill(0, count($titles), '');
|
642 |
-
}
|
643 |
-
}
|
644 |
|
645 |
// Composing attachments
|
646 |
if ( ! (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
|
@@ -1199,344 +1227,430 @@ class PMXI_Import_Record extends PMXI_Model_Record {
|
|
1199 |
}
|
1200 |
|
1201 |
// [featured image]
|
1202 |
-
|
|
|
|
|
1203 |
|
1204 |
-
if (!empty($
|
1205 |
|
1206 |
-
$
|
1207 |
-
$targetUrl = $uploads['url'];
|
1208 |
-
|
1209 |
-
$logger and call_user_func($logger, __('<b>IMAGES:</b>', 'wp_all_import_plugin'));
|
1210 |
-
|
1211 |
-
if ( ! @is_writable($targetDir) ){
|
1212 |
-
|
1213 |
-
$logger and call_user_func($logger, sprintf(__('<b>ERROR</b>: Target directory %s is not writable', 'wp_all_import_plugin'), $targetDir));
|
1214 |
-
|
1215 |
-
}
|
1216 |
-
else{
|
1217 |
|
1218 |
-
|
1219 |
|
1220 |
-
$
|
1221 |
-
$gallery_attachment_ids = array();
|
1222 |
-
$imgs = array();
|
1223 |
-
|
1224 |
-
$featured_delim = ( "yes" == $this->options['download_images'] ) ? $this->options['download_featured_delim'] : $this->options['featured_delim'];
|
1225 |
|
1226 |
-
$
|
1227 |
-
if ( ! empty($line_imgs) )
|
1228 |
-
foreach ($line_imgs as $line_img)
|
1229 |
-
$imgs = array_merge($imgs, ( ! empty($featured_delim) ) ? str_getcsv($line_img, $featured_delim) : array($line_img) );
|
1230 |
|
1231 |
-
|
1232 |
-
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"){
|
1233 |
-
|
1234 |
-
$logger and call_user_func($logger, __('- Keep existing and add newest images ...', 'wp_all_import_plugin'));
|
1235 |
|
1236 |
-
$
|
|
|
1237 |
|
1238 |
-
|
1239 |
-
$gallery_attachment_ids = array_filter(explode(",", get_post_meta($pid, '_product_image_gallery', true)));
|
1240 |
|
1241 |
-
if ( $
|
1242 |
-
foreach ( $attachment_imgs as $attachment_img ) {
|
1243 |
-
$post_thumbnail_id = get_post_thumbnail_id( $pid );
|
1244 |
-
if ( empty($post_thumbnail_id) and $this->options['is_featured'] ) {
|
1245 |
-
set_post_thumbnail($pid, $attachment_img->ID);
|
1246 |
-
}
|
1247 |
-
elseif(!in_array($attachment_img->ID, $gallery_attachment_ids) and $post_thumbnail_id != $attachment_img->ID) {
|
1248 |
-
$gallery_attachment_ids[] = $attachment_img->ID;
|
1249 |
-
}
|
1250 |
-
}
|
1251 |
-
$success_images = true;
|
1252 |
-
}
|
1253 |
|
1254 |
-
|
1255 |
-
foreach ($gallery_attachment_ids as $aid){
|
1256 |
-
do_action( 'pmxi_gallery_image', $pid, $aid, '');
|
1257 |
-
}
|
1258 |
-
}
|
1259 |
-
}
|
1260 |
-
|
1261 |
-
if ( ! empty($imgs) ) {
|
1262 |
-
|
1263 |
-
if ( $this->options['set_image_meta_title'] ){
|
1264 |
-
$img_titles = array();
|
1265 |
-
$line_img_titles = explode("\n", $image_meta_titles[$i]);
|
1266 |
-
if ( ! empty($line_img_titles) )
|
1267 |
-
foreach ($line_img_titles as $line_img_title)
|
1268 |
-
$img_titles = array_merge($img_titles, ( ! empty($this->options['image_meta_title_delim']) ) ? str_getcsv($line_img_title, $this->options['image_meta_title_delim']) : array($line_img_title) );
|
1269 |
-
|
1270 |
-
}
|
1271 |
-
if ( $this->options['set_image_meta_caption'] ){
|
1272 |
-
$img_captions = array();
|
1273 |
-
$line_img_captions = explode("\n", $image_meta_captions[$i]);
|
1274 |
-
if ( ! empty($line_img_captions) )
|
1275 |
-
foreach ($line_img_captions as $line_img_caption)
|
1276 |
-
$img_captions = array_merge($img_captions, ( ! empty($this->options['image_meta_caption_delim']) ) ? str_getcsv($line_img_caption, $this->options['image_meta_caption_delim']) : array($line_img_caption) );
|
1277 |
|
1278 |
}
|
1279 |
-
|
1280 |
-
$img_alts = array();
|
1281 |
-
$line_img_alts = explode("\n", $image_meta_alts[$i]);
|
1282 |
-
if ( ! empty($line_img_alts) )
|
1283 |
-
foreach ($line_img_alts as $line_img_alt)
|
1284 |
-
$img_alts = array_merge($img_alts, ( ! empty($this->options['image_meta_alt_delim']) ) ? str_getcsv($line_img_alt, $this->options['image_meta_alt_delim']) : array($line_img_alt) );
|
1285 |
|
1286 |
-
|
1287 |
-
if ( $this->options['set_image_meta_description'] ){
|
1288 |
-
$img_descriptions = array();
|
1289 |
-
$line_img_descriptions = explode("\n", $image_meta_descriptions[$i]);
|
1290 |
-
if ( ! empty($line_img_descriptions) )
|
1291 |
-
foreach ($line_img_descriptions as $line_img_description)
|
1292 |
-
$img_descriptions = array_merge($img_descriptions, ( ! empty($this->options['image_meta_description_delim']) ) ? str_getcsv($line_img_description, $this->options['image_meta_description_delim']) : array($line_img_description) );
|
1293 |
-
|
1294 |
-
}
|
1295 |
-
|
1296 |
-
foreach ($imgs as $k => $img_url) { if (empty($img_url)) continue;
|
1297 |
-
|
1298 |
-
$attid = false;
|
1299 |
-
|
1300 |
-
$attch = null;
|
1301 |
-
|
1302 |
-
$url = str_replace(" ", "%20", trim($img_url));
|
1303 |
-
$bn = basename($url);
|
1304 |
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
else {
|
1309 |
-
$img_ext = pmxi_getExtensionFromStr($url);
|
1310 |
-
$default_extension = pmxi_getExtension($bn);
|
1311 |
|
1312 |
-
|
1313 |
-
}
|
1314 |
|
1315 |
-
$
|
|
|
|
|
|
|
1316 |
|
1317 |
-
//
|
1318 |
-
|
1319 |
-
|
1320 |
-
// if wizard store image data to custom field
|
1321 |
-
$create_image = false;
|
1322 |
-
$download_image = true;
|
1323 |
-
|
1324 |
-
if (base64_decode($url, true) !== false){
|
1325 |
-
$img = @imagecreatefromstring(base64_decode($url));
|
1326 |
-
if($img)
|
1327 |
-
{
|
1328 |
-
$logger and call_user_func($logger, __('- Founded base64_encoded image', 'wp_all_import_plugin'));
|
1329 |
-
|
1330 |
-
$image_filename = md5(time()) . '.jpg';
|
1331 |
-
$image_filepath = $targetDir . '/' . $image_filename;
|
1332 |
-
imagejpeg($img, $image_filepath);
|
1333 |
-
if( ! ($image_info = @getimagesize($image_filepath)) or ! in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
|
1334 |
-
$logger and call_user_func($logger, sprintf(__('- <b>WARNING</b>: File %s is not a valid image and cannot be set as featured one', 'wp_all_import_plugin'), $image_filepath));
|
1335 |
-
$logger and !$is_cron and PMXI_Plugin::$session->warnings++;
|
1336 |
-
} else {
|
1337 |
-
$create_image = true;
|
1338 |
-
}
|
1339 |
-
}
|
1340 |
-
}
|
1341 |
-
else {
|
1342 |
|
1343 |
-
$
|
1344 |
-
$image_filepath = $targetDir . '/' . $image_filename;
|
1345 |
|
1346 |
-
|
1347 |
-
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"){
|
1348 |
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
|
|
|
|
1352 |
$post_thumbnail_id = get_post_thumbnail_id( $pid );
|
1353 |
-
if ( $post_thumbnail_id
|
1354 |
-
|
1355 |
-
elseif (file_exists($targetDir . '/' . $image_name)){
|
1356 |
-
if (($img_meta = wp_read_image_metadata($targetDir . '/' . $image_name))) {
|
1357 |
-
if (trim($img_meta['title']) && ! is_numeric(sanitize_title($img_meta['title']))){
|
1358 |
-
$img_title = $img_meta['title'];
|
1359 |
-
$attch = $this->wpdb->get_row( $this->wpdb->prepare( "SELECT * FROM " . $this->wpdb->posts . " WHERE post_title = %s AND post_type = %s AND post_parent = %d;", $img_title, "attachment", $pid ) );
|
1360 |
-
if ( $attch != null ){
|
1361 |
-
$post_thumbnail_id = get_post_thumbnail_id( $pid );
|
1362 |
-
if ( $post_thumbnail_id == $attch->ID or in_array($attch->ID, $gallery_attachment_ids) ) continue;
|
1363 |
-
}
|
1364 |
-
}
|
1365 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1366 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1367 |
|
1368 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1369 |
|
1370 |
-
// search existing attachment
|
1371 |
-
if ($this->options['search_existing_images']){
|
1372 |
-
|
1373 |
-
$image_filename = $image_name;
|
1374 |
-
|
1375 |
-
$attch = $this->wpdb->get_row( $this->wpdb->prepare( "SELECT * FROM " . $this->wpdb->posts . " WHERE (post_title = %s OR post_title = %s OR post_name = %s) AND post_type = %s;", $image_name, preg_replace('/\\.[^.\\s]{3,4}$/', '', $image_name), sanitize_title($image_name), "attachment" ) );
|
1376 |
-
|
1377 |
-
if ( $attch != null ){
|
1378 |
-
$download_image = false;
|
1379 |
-
$attid = $attch->ID;
|
1380 |
-
}
|
1381 |
-
elseif (@file_exists($targetDir . '/' . $image_name)){
|
1382 |
-
if (($img_meta = wp_read_image_metadata($targetDir . '/' . $image_name))) {
|
1383 |
-
if (trim($img_meta['title']) && ! is_numeric(sanitize_title($img_meta['title']))){
|
1384 |
-
$img_title = $img_meta['title'];
|
1385 |
-
$attch = $this->wpdb->get_row( $this->wpdb->prepare( "SELECT * FROM " . $this->wpdb->posts . " WHERE post_title = %s AND post_type = %s AND post_parent = %d;", $img_title, "attachment", $pid ) );
|
1386 |
-
if ( $attch != null ){
|
1387 |
-
$download_image = false;
|
1388 |
-
$attid = $attch->ID;
|
1389 |
-
}
|
1390 |
-
}
|
1391 |
-
}
|
1392 |
-
}
|
1393 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1394 |
|
1395 |
-
|
1396 |
|
1397 |
-
|
1398 |
-
if ( "yes" != $this->options['download_images'] ){
|
1399 |
|
1400 |
-
|
1401 |
-
$image_filepath = $targetDir . '/' . $image_filename;
|
1402 |
-
|
1403 |
-
$wpai_uploads = $uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::FILES_DIRECTORY . DIRECTORY_SEPARATOR;
|
1404 |
-
$wpai_image_path = $wpai_uploads . str_replace('%20', ' ', $url);
|
1405 |
|
1406 |
-
|
1407 |
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1411 |
$logger and call_user_func($logger, sprintf(__('- <b>WARNING</b>: File %s is not a valid image and cannot be set as featured one', 'wp_all_import_plugin'), $image_filepath));
|
1412 |
$logger and !$is_cron and PMXI_Plugin::$session->warnings++;
|
1413 |
-
@unlink($image_filepath);
|
1414 |
} else {
|
1415 |
$create_image = true;
|
1416 |
-
$logger and call_user_func($logger, sprintf(__('- Image `%s` has been successfully founded', 'wp_all_import_plugin'), $wpai_image_path));
|
1417 |
}
|
1418 |
-
|
1419 |
-
}
|
1420 |
-
else {
|
1421 |
|
1422 |
-
$
|
|
|
1423 |
|
1424 |
-
|
|
|
1425 |
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1434 |
|
1435 |
-
|
|
|
|
|
|
|
1436 |
|
1437 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1438 |
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
$
|
1445 |
-
$
|
1446 |
-
|
1447 |
-
|
1448 |
-
$
|
1449 |
-
|
1450 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1451 |
}
|
1452 |
-
}
|
1453 |
-
}
|
1454 |
-
}
|
1455 |
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1473 |
|
1474 |
-
|
1475 |
|
1476 |
-
|
1477 |
-
$logger and call_user_func($logger, __('- <b>WARNING</b>', 'wp_all_import_plugin') . ': ' . $attid->get_error_message());
|
1478 |
-
$logger and !$is_cron and PMXI_Plugin::$session->warnings++;
|
1479 |
-
} else {
|
1480 |
-
// you must first include the image.php file
|
1481 |
-
// for the function wp_generate_attachment_metadata() to work
|
1482 |
-
require_once(ABSPATH . 'wp-admin/includes/image.php');
|
1483 |
-
wp_update_attachment_metadata($attid, wp_generate_attachment_metadata($attid, $image_filepath));
|
1484 |
-
|
1485 |
-
$update_attachment_meta = array();
|
1486 |
-
if ( $this->options['set_image_meta_title'] and ! empty($img_titles[$k]) ) $update_attachment_meta['post_title'] = $img_titles[$k];
|
1487 |
-
if ( $this->options['set_image_meta_caption'] and ! empty($img_captions[$k]) ) $update_attachment_meta['post_excerpt'] = $img_captions[$k];
|
1488 |
-
if ( $this->options['set_image_meta_description'] and ! empty($img_descriptions[$k]) ) $update_attachment_meta['post_content'] = $img_descriptions[$k];
|
1489 |
-
if ( $this->options['set_image_meta_alt'] and ! empty($img_alts[$k]) ) update_post_meta($attid, '_wp_attachment_image_alt', $img_alts[$k]);
|
1490 |
-
|
1491 |
-
if ( ! empty($update_attachment_meta)) $this->wpdb->update( $this->wpdb->posts, $update_attachment_meta, array('ID' => $attid) );
|
1492 |
-
}
|
1493 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1494 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1495 |
|
1496 |
-
|
1497 |
|
1498 |
-
|
1499 |
-
wp_update_post(
|
1500 |
-
array(
|
1501 |
-
'ID' => $attch->ID,
|
1502 |
-
'post_parent' => $pid
|
1503 |
-
)
|
1504 |
-
);
|
1505 |
-
}
|
1506 |
|
1507 |
-
|
1508 |
-
do_action( 'pmxi_gallery_image', $pid, $attid, $image_filepath);
|
1509 |
|
1510 |
-
|
1511 |
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
elseif(!in_array($attid, $gallery_attachment_ids) and $post_thumbnail_id != $attid){
|
1517 |
-
$gallery_attachment_ids[] = $attid;
|
1518 |
-
}
|
1519 |
|
1520 |
-
|
1521 |
-
|
1522 |
-
}
|
1523 |
}
|
1524 |
-
|
1525 |
-
// Set product gallery images
|
1526 |
-
if ( $post_type[$i] == "product" )
|
1527 |
-
update_post_meta($pid, '_product_image_gallery', (!empty($gallery_attachment_ids)) ? implode(',', $gallery_attachment_ids) : '');
|
1528 |
-
// Create entry as Draft if no images are downloaded successfully
|
1529 |
-
if ( ! $success_images and "yes" == $this->options['create_draft'] ) {
|
1530 |
-
$this->wpdb->update( $this->wpdb->posts, array('post_status' => 'draft'), array('ID' => $pid) );
|
1531 |
-
$logger and call_user_func($logger, sprintf(__('- Post `%s` saved as Draft, because no images are downloaded successfully', 'wp_all_import_plugin'), $articleData['post_title']));
|
1532 |
}
|
1533 |
-
|
1534 |
-
}
|
1535 |
-
else{
|
1536 |
-
// Create entry as Draft if no images are downloaded successfully
|
1537 |
-
if ( "yes" == $this->options['create_draft'] ){
|
1538 |
-
$this->wpdb->update( $this->wpdb->posts, array('post_status' => 'draft'), array('ID' => $pid) );
|
1539 |
-
$logger and call_user_func($logger, sprintf(__('Post `%s` saved as Draft, because no images are downloaded successfully', 'wp_all_import_plugin'), $articleData['post_title']));
|
1540 |
}
|
1541 |
}
|
1542 |
}
|
549 |
}
|
550 |
endforeach;
|
551 |
endif;
|
552 |
+
// [/custom taxonomies]
|
553 |
+
|
554 |
+
// Composing featured images
|
555 |
+
$image_sections = apply_filters('wp_all_import_image_sections', array(
|
556 |
+
array(
|
557 |
+
'slug' => '',
|
558 |
+
'title' => __('Images', 'wp_all_import_plugin'),
|
559 |
+
'type' => 'images'
|
560 |
+
)
|
561 |
+
));
|
562 |
|
|
|
563 |
if ( ! (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
|
564 |
$logger and call_user_func($logger, __('<b>WARNING</b>', 'wp_all_import_plugin') . ': ' . $uploads['error']);
|
565 |
$logger and call_user_func($logger, __('<b>WARNING</b>: No featured images will be created. Uploads folder is not found.', 'wp_all_import_plugin'));
|
566 |
$logger and !$is_cron and PMXI_Plugin::$session->warnings++;
|
567 |
} else {
|
568 |
+
$images_bundle = array();
|
569 |
+
foreach ($image_sections as $section) {
|
570 |
+
$chunk == 1 and $logger and call_user_func($logger, __('Composing URLs for ' . strtolower($section['title']) . '...', 'wp_all_import_plugin'));
|
571 |
+
$featured_images = array();
|
572 |
+
if ( "no" == $this->options[$section['slug'] . 'download_images']){
|
573 |
+
if ($this->options[$section['slug'] . 'featured_image']) {
|
574 |
+
$featured_images = XmlImportParser::factory($xml, $cxpath, $this->options[$section['slug'] . 'featured_image'], $file)->parse($records); $tmp_files[] = $file;
|
575 |
+
} else {
|
576 |
+
count($titles) and $featured_images = array_fill(0, count($titles), '');
|
577 |
+
}
|
578 |
+
}
|
579 |
+
else{
|
580 |
+
if ($this->options[$section['slug'] . 'download_featured_image']) {
|
581 |
+
$featured_images = XmlImportParser::factory($xml, $cxpath, $this->options[$section['slug'] . 'download_featured_image'], $file)->parse($records); $tmp_files[] = $file;
|
582 |
+
} else {
|
583 |
+
count($titles) and $featured_images = array_fill(0, count($titles), '');
|
584 |
+
}
|
585 |
}
|
586 |
+
|
587 |
+
$images_bundle[ empty($section['slug']) ? 'pmxi_gallery_image' : $section['slug']] = array(
|
588 |
+
'type' => $section['type'],
|
589 |
+
'files' => $featured_images
|
590 |
+
);
|
591 |
+
|
592 |
+
// Composing images meta titles
|
593 |
+
$image_meta_titles_bundle = array();
|
594 |
+
if ( $this->options[$section['slug'] . 'set_image_meta_title'] ){
|
595 |
+
$chunk == 1 and $logger and call_user_func($logger, __('Composing ' . strtolower($section['title']) . ' meta data (titles)...', 'wp_all_import_plugin'));
|
596 |
+
$image_meta_titles = array();
|
597 |
+
if ($this->options[$section['slug'] . 'image_meta_title']) {
|
598 |
+
$image_meta_titles = XmlImportParser::factory($xml, $cxpath, $this->options[$section['slug'] . 'image_meta_title'], $file)->parse($records); $tmp_files[] = $file;
|
599 |
+
} else {
|
600 |
+
count($titles) and $image_meta_titles = array_fill(0, count($titles), '');
|
601 |
+
}
|
602 |
+
$image_meta_titles_bundle[ empty($section['slug']) ? 'pmxi_gallery_image' : $section['slug']] = $image_meta_titles;
|
603 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
604 |
|
605 |
+
// Composing images meta captions
|
606 |
+
$image_meta_captions_bundle = array();
|
607 |
+
if ( $this->options[$section['slug'] . 'set_image_meta_caption'] ){
|
608 |
+
$chunk == 1 and $logger and call_user_func($logger, __('Composing ' . strtolower($section['title']) . ' meta data (captions)...', 'wp_all_import_plugin'));
|
609 |
+
$image_meta_captions = array();
|
610 |
+
if ($this->options[$section['slug'] . 'image_meta_caption']) {
|
611 |
+
$image_meta_captions = XmlImportParser::factory($xml, $cxpath, $this->options[$section['slug'] . 'image_meta_caption'], $file)->parse($records); $tmp_files[] = $file;
|
612 |
+
} else {
|
613 |
+
count($titles) and $image_meta_captions = array_fill(0, count($titles), '');
|
614 |
+
}
|
615 |
+
$image_meta_captions_bundle[ empty($section['slug']) ? 'pmxi_gallery_image' : $section['slug']] = $image_meta_captions;
|
616 |
+
}
|
617 |
|
618 |
+
// Composing images meta alt text
|
619 |
+
$image_meta_alts_bundle = array();
|
620 |
+
if ( $this->options[$section['slug'] . 'set_image_meta_alt'] ){
|
621 |
+
$chunk == 1 and $logger and call_user_func($logger, __('Composing ' . strtolower($section['title']) . ' meta data (alt text)...', 'wp_all_import_plugin'));
|
622 |
+
$image_meta_alts = array();
|
623 |
+
if ($this->options[$section['slug'] . 'image_meta_alt']) {
|
624 |
+
$image_meta_alts = XmlImportParser::factory($xml, $cxpath, $this->options[$section['slug'] . 'image_meta_alt'], $file)->parse($records); $tmp_files[] = $file;
|
625 |
+
} else {
|
626 |
+
count($titles) and $image_meta_alts = array_fill(0, count($titles), '');
|
627 |
+
}
|
628 |
+
$image_meta_alts_bundle[ empty($section['slug']) ? 'pmxi_gallery_image' : $section['slug']] = $image_meta_alts;
|
629 |
+
}
|
630 |
|
631 |
+
// Composing images meta description
|
632 |
+
$image_meta_descriptions_bundle = array();
|
633 |
+
if ( $this->options[$section['slug'] . 'set_image_meta_description'] ){
|
634 |
+
$chunk == 1 and $logger and call_user_func($logger, __('Composing ' . strtolower($section['title']) . ' meta data (description)...', 'wp_all_import_plugin'));
|
635 |
+
$image_meta_descriptions = array();
|
636 |
+
if ($this->options[$section['slug'] . 'image_meta_description']) {
|
637 |
+
$image_meta_descriptions = XmlImportParser::factory($xml, $cxpath, $this->options[$section['slug'] . 'image_meta_description'], $file)->parse($records); $tmp_files[] = $file;
|
638 |
+
} else {
|
639 |
+
count($titles) and $image_meta_descriptions = array_fill(0, count($titles), '');
|
640 |
+
}
|
641 |
+
$image_meta_descriptions_bundle[ empty($section['slug']) ? 'pmxi_gallery_image' : $section['slug']] = $image_meta_descriptions;
|
642 |
+
}
|
643 |
|
644 |
+
$auto_rename_images_bundle = array();
|
645 |
+
$auto_extensions_bundle = array();
|
646 |
+
if ( "yes" == $this->options[$section['slug'] . 'download_images'] ){
|
647 |
+
// Composing images suffix
|
648 |
+
$chunk == 1 and $this->options[$section['slug'] . 'auto_rename_images'] and $logger and call_user_func($logger, __('Composing ' . strtolower($section['title']) . ' suffix...', 'wp_all_import_plugin'));
|
649 |
+
$auto_rename_images = array();
|
650 |
+
if ( $this->options[$section['slug'] . 'auto_rename_images'] and ! empty($this->options[$section['slug'] . 'auto_rename_images_suffix'])){
|
651 |
+
$auto_rename_images = XmlImportParser::factory($xml, $cxpath, $this->options[$section['slug'] . 'auto_rename_images_suffix'], $file)->parse($records); $tmp_files[] = $file;
|
652 |
+
}
|
653 |
+
else{
|
654 |
+
count($titles) and $auto_rename_images = array_fill(0, count($titles), '');
|
655 |
+
}
|
656 |
+
$auto_rename_images_bundle[ empty($section['slug']) ? 'pmxi_gallery_image' : $section['slug']] = $auto_rename_images;
|
657 |
|
658 |
+
// Composing images extensions
|
659 |
+
$chunk == 1 and $this->options[$section['slug'] . 'auto_set_extension'] and $logger and call_user_func($logger, __('Composing ' . strtolower($section['title']) . ' extensions...', 'wp_all_import_plugin'));
|
660 |
+
$auto_extensions = array();
|
661 |
+
if ( $this->options[$section['slug'] . 'auto_set_extension'] and ! empty($this->options[$section['slug'] . 'new_extension'])){
|
662 |
+
$auto_extensions = XmlImportParser::factory($xml, $cxpath, $this->options[$section['slug'] . 'new_extension'], $file)->parse($records); $tmp_files[] = $file;
|
663 |
+
}
|
664 |
+
else{
|
665 |
+
count($titles) and $auto_extensions = array_fill(0, count($titles), '');
|
666 |
+
}
|
667 |
+
$auto_extensions_bundle[ empty($section['slug']) ? 'pmxi_gallery_image' : $section['slug']] = $auto_extensions;
|
668 |
+
}
|
669 |
|
670 |
+
}
|
671 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
672 |
|
673 |
// Composing attachments
|
674 |
if ( ! (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
|
1227 |
}
|
1228 |
|
1229 |
// [featured image]
|
1230 |
+
$is_allow_import_images = apply_filters('wp_all_import_is_allow_import_images', false, $articleData['post_type']);
|
1231 |
+
|
1232 |
+
if ( ! empty($uploads) and false === $uploads['error'] and ($articleData['post_type'] == "product" and class_exists('PMWI_Plugin') or $is_allow_import_images) and (empty($articleData['ID']) or $this->options['update_all_data'] == "yes" or ( $this->options['update_all_data'] == "no" and $this->options['is_update_images']))) {
|
1233 |
|
1234 |
+
if ( ! empty($images_bundle) ){
|
1235 |
|
1236 |
+
$is_show_add_new_images = apply_filters('wp_all_import_is_show_add_new_images', true, $post_type[$i]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1237 |
|
1238 |
+
foreach ($images_bundle as $slug => $bundle_data) {
|
1239 |
|
1240 |
+
$featured_images = $bundle_data['files'];
|
|
|
|
|
|
|
|
|
1241 |
|
1242 |
+
$option_slug = ($slug == 'pmxi_gallery_image') ? '' : $slug;
|
|
|
|
|
|
|
1243 |
|
1244 |
+
if ( ! empty($featured_images[$i]) ){
|
|
|
|
|
|
|
1245 |
|
1246 |
+
$targetDir = $uploads['path'];
|
1247 |
+
$targetUrl = $uploads['url'];
|
1248 |
|
1249 |
+
$logger and call_user_func($logger, __('<b>IMAGES:</b>', 'wp_all_import_plugin'));
|
|
|
1250 |
|
1251 |
+
if ( ! @is_writable($targetDir) ){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1252 |
|
1253 |
+
$logger and call_user_func($logger, sprintf(__('<b>ERROR</b>: Target directory %s is not writable', 'wp_all_import_plugin'), $targetDir));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1254 |
|
1255 |
}
|
1256 |
+
else{
|
|
|
|
|
|
|
|
|
|
|
1257 |
|
1258 |
+
require_once(ABSPATH . 'wp-admin/includes/image.php');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1259 |
|
1260 |
+
$success_images = false;
|
1261 |
+
$gallery_attachment_ids = array();
|
1262 |
+
$imgs = array();
|
|
|
|
|
|
|
1263 |
|
1264 |
+
$featured_delim = ( "yes" == $this->options[$option_slug . 'download_images'] ) ? $this->options[$option_slug . 'download_featured_delim'] : $this->options[$option_slug . 'featured_delim'];
|
|
|
1265 |
|
1266 |
+
$line_imgs = explode("\n", $featured_images[$i]);
|
1267 |
+
if ( ! empty($line_imgs) )
|
1268 |
+
foreach ($line_imgs as $line_img)
|
1269 |
+
$imgs = array_merge($imgs, ( ! empty($featured_delim) ) ? str_getcsv($line_img, $featured_delim) : array($line_img) );
|
1270 |
|
1271 |
+
// keep existing and add newest images
|
1272 |
+
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" and $is_show_add_new_images){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1273 |
|
1274 |
+
$logger and call_user_func($logger, __('- Keep existing and add newest images ...', 'wp_all_import_plugin'));
|
|
|
1275 |
|
1276 |
+
$attachment_imgs = get_attached_media( 'image', $pid );
|
|
|
1277 |
|
1278 |
+
if ( $post_type[$i] == "product" )
|
1279 |
+
$gallery_attachment_ids = array_filter(explode(",", get_post_meta($pid, '_product_image_gallery', true)));
|
1280 |
+
|
1281 |
+
if ( $attachment_imgs ) {
|
1282 |
+
foreach ( $attachment_imgs as $attachment_img ) {
|
1283 |
$post_thumbnail_id = get_post_thumbnail_id( $pid );
|
1284 |
+
if ( empty($post_thumbnail_id) and $this->options[$option_slug . 'is_featured'] ) {
|
1285 |
+
set_post_thumbnail($pid, $attachment_img->ID);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1286 |
}
|
1287 |
+
elseif(!in_array($attachment_img->ID, $gallery_attachment_ids) and $post_thumbnail_id != $attachment_img->ID) {
|
1288 |
+
$gallery_attachment_ids[] = $attachment_img->ID;
|
1289 |
+
}
|
1290 |
+
}
|
1291 |
+
$success_images = true;
|
1292 |
+
}
|
1293 |
+
|
1294 |
+
if ( ! empty($gallery_attachment_ids) ){
|
1295 |
+
foreach ($gallery_attachment_ids as $aid){
|
1296 |
+
do_action( $slug, $pid, $aid, wp_get_attachment_url($aid), 'update_images');
|
1297 |
}
|
1298 |
+
}
|
1299 |
+
}
|
1300 |
+
|
1301 |
+
if ( ! empty($imgs) ) {
|
1302 |
+
|
1303 |
+
if ( $this->options[$option_slug . 'set_image_meta_title'] and !empty($image_meta_titles_bundle[$slug])){
|
1304 |
+
$img_titles = array();
|
1305 |
+
$line_img_titles = explode("\n", $image_meta_titles_bundle[$slug][$i]);
|
1306 |
+
if ( ! empty($line_img_titles) )
|
1307 |
+
foreach ($line_img_titles as $line_img_title)
|
1308 |
+
$img_titles = array_merge($img_titles, ( ! empty($this->options[$option_slug . 'image_meta_title_delim']) ) ? str_getcsv($line_img_title, $this->options[$option_slug . 'image_meta_title_delim']) : array($line_img_title) );
|
1309 |
+
|
1310 |
+
}
|
1311 |
+
if ( $this->options[$option_slug . 'set_image_meta_caption'] and !empty($image_meta_captions_bundle[$slug])){
|
1312 |
+
$img_captions = array();
|
1313 |
+
$line_img_captions = explode("\n", $image_meta_captions_bundle[$slug][$i]);
|
1314 |
+
if ( ! empty($line_img_captions) )
|
1315 |
+
foreach ($line_img_captions as $line_img_caption)
|
1316 |
+
$img_captions = array_merge($img_captions, ( ! empty($this->options[$option_slug . 'image_meta_caption_delim']) ) ? str_getcsv($line_img_caption, $this->options[$option_slug . 'image_meta_caption_delim']) : array($line_img_caption) );
|
1317 |
|
1318 |
}
|
1319 |
+
if ( $this->options[$option_slug . 'set_image_meta_alt'] and !empty($image_meta_alts_bundle[$slug])){
|
1320 |
+
$img_alts = array();
|
1321 |
+
$line_img_alts = explode("\n", $image_meta_alts_bundle[$slug][$i]);
|
1322 |
+
if ( ! empty($line_img_alts) )
|
1323 |
+
foreach ($line_img_alts as $line_img_alt)
|
1324 |
+
$img_alts = array_merge($img_alts, ( ! empty($this->options[$option_slug . 'image_meta_alt_delim']) ) ? str_getcsv($line_img_alt, $this->options[$option_slug . 'image_meta_alt_delim']) : array($line_img_alt) );
|
1325 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1326 |
}
|
1327 |
+
if ( $this->options[$option_slug . 'set_image_meta_description'] and !empty($image_meta_descriptions_bundle[$slug])){
|
1328 |
+
$img_descriptions = array();
|
1329 |
+
$line_img_descriptions = explode("\n", $image_meta_descriptions_bundle[$slug][$i]);
|
1330 |
+
if ( ! empty($line_img_descriptions) )
|
1331 |
+
foreach ($line_img_descriptions as $line_img_description)
|
1332 |
+
$img_descriptions = array_merge($img_descriptions, ( ! empty($this->options[$option_slug . 'image_meta_description_delim']) ) ? str_getcsv($line_img_description, $this->options[$option_slug . 'image_meta_description_delim']) : array($line_img_description) );
|
1333 |
|
1334 |
+
}
|
1335 |
|
1336 |
+
$is_keep_existing_images = ( ! empty($articleData['ID']) and $this->options['is_update_images'] and $this->options['update_images_logic'] == "add_new" and $this->options['update_all_data'] == "no" and $is_show_add_new_images);
|
|
|
1337 |
|
1338 |
+
foreach ($imgs as $k => $img_url) { if (empty($img_url)) continue;
|
|
|
|
|
|
|
|
|
1339 |
|
1340 |
+
$attid = false;
|
1341 |
|
1342 |
+
$attch = null;
|
1343 |
+
|
1344 |
+
$url = str_replace(" ", "%20", trim($img_url));
|
1345 |
+
$bn = basename($url);
|
1346 |
+
|
1347 |
+
if ( "yes" == $this->options[$option_slug . 'download_images'] and ! empty($auto_extensions_bundle[$slug][$i]) and preg_match('%^(jpg|jpeg|png|gif)$%i', $auto_extensions_bundle[$slug][$i])){
|
1348 |
+
$img_ext = $auto_extensions_bundle[$slug][$i];
|
1349 |
+
}
|
1350 |
+
else {
|
1351 |
+
$img_ext = pmxi_getExtensionFromStr($url);
|
1352 |
+
$default_extension = pmxi_getExtension($bn);
|
1353 |
+
|
1354 |
+
if ($img_ext == "") $img_ext = pmxi_get_remote_image_ext($url);
|
1355 |
+
}
|
1356 |
+
|
1357 |
+
$logger and call_user_func($logger, sprintf(__('- Importing image `%s` for `%s` ...', 'wp_all_import_plugin'), $img_url, $articleData['post_title']));
|
1358 |
+
|
1359 |
+
// generate local file name
|
1360 |
+
$image_name = urldecode(($this->options[$option_slug . 'auto_rename_images'] and !empty($auto_rename_images_bundle[$slug][$i])) ? sanitize_file_name(($img_ext) ? str_replace("." . $default_extension, "", $auto_rename_images_bundle[$slug][$i]) : $auto_rename_images_bundle[$slug][$i]) : sanitize_file_name((($img_ext) ? str_replace("." . $default_extension, "", $bn) : $bn))) . (("" != $img_ext) ? '.' . $img_ext : '');
|
1361 |
+
|
1362 |
+
// if wizard store image data to custom field
|
1363 |
+
$create_image = false;
|
1364 |
+
$download_image = true;
|
1365 |
+
$wp_filetype = false;
|
1366 |
+
|
1367 |
+
if ($bundle_data['type'] == 'images' and base64_decode($url, true) !== false){
|
1368 |
+
$img = @imagecreatefromstring(base64_decode($url));
|
1369 |
+
if($img)
|
1370 |
+
{
|
1371 |
+
$logger and call_user_func($logger, __('- Founded base64_encoded image', 'wp_all_import_plugin'));
|
1372 |
+
|
1373 |
+
$image_filename = md5(time()) . '.jpg';
|
1374 |
+
$image_filepath = $targetDir . '/' . $image_filename;
|
1375 |
+
imagejpeg($img, $image_filepath);
|
1376 |
+
if( ! ($image_info = @getimagesize($image_filepath)) or ! in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
|
1377 |
$logger and call_user_func($logger, sprintf(__('- <b>WARNING</b>: File %s is not a valid image and cannot be set as featured one', 'wp_all_import_plugin'), $image_filepath));
|
1378 |
$logger and !$is_cron and PMXI_Plugin::$session->warnings++;
|
|
|
1379 |
} else {
|
1380 |
$create_image = true;
|
|
|
1381 |
}
|
1382 |
+
}
|
1383 |
+
}
|
1384 |
+
else {
|
1385 |
|
1386 |
+
$image_filename = wp_unique_filename($targetDir, $image_name);
|
1387 |
+
$image_filepath = $targetDir . '/' . $image_filename;
|
1388 |
|
1389 |
+
// keep existing and add newest images
|
1390 |
+
if ( $is_keep_existing_images ){
|
1391 |
|
1392 |
+
$attch = $this->wpdb->get_row( $this->wpdb->prepare( "SELECT * FROM " . $this->wpdb->posts . " WHERE (post_title = %s OR post_title = %s OR post_name = %s) AND post_type = %s AND post_parent = %d;", $image_name, preg_replace('/\\.[^.\\s]{3,4}$/', '', $image_name), sanitize_title($image_name), "attachment", $pid ) );
|
1393 |
+
|
1394 |
+
if ( $attch != null ){
|
1395 |
+
$post_thumbnail_id = get_post_thumbnail_id( $pid );
|
1396 |
+
if ( $post_thumbnail_id == $attch->ID or in_array($attch->ID, $gallery_attachment_ids) ) continue;
|
1397 |
+
}
|
1398 |
+
elseif (file_exists($targetDir . '/' . $image_name)){
|
1399 |
+
if ($bundle_data['type'] == 'images' and ($img_meta = wp_read_image_metadata($targetDir . '/' . $image_name))) {
|
1400 |
+
if (trim($img_meta['title']) && ! is_numeric(sanitize_title($img_meta['title']))){
|
1401 |
+
$img_title = $img_meta['title'];
|
1402 |
+
$attch = $this->wpdb->get_row( $this->wpdb->prepare( "SELECT * FROM " . $this->wpdb->posts . " WHERE post_title = %s AND post_type = %s AND post_parent = %d;", $img_title, "attachment", $pid ) );
|
1403 |
+
if ( $attch != null ){
|
1404 |
+
$post_thumbnail_id = get_post_thumbnail_id( $pid );
|
1405 |
+
if ( $post_thumbnail_id == $attch->ID or in_array($attch->ID, $gallery_attachment_ids) ) continue;
|
1406 |
+
}
|
1407 |
+
}
|
1408 |
+
}
|
1409 |
+
}
|
1410 |
|
1411 |
+
}
|
1412 |
+
|
1413 |
+
// search existing attachment
|
1414 |
+
if ($this->options[$option_slug . 'search_existing_images']){
|
1415 |
|
1416 |
+
$image_filename = $image_name;
|
1417 |
+
|
1418 |
+
$attch = $this->wpdb->get_row( $this->wpdb->prepare( "SELECT * FROM " . $this->wpdb->posts . " WHERE (post_title = %s OR post_title = %s OR post_name = %s) AND post_type = %s;", $image_name, preg_replace('/\\.[^.\\s]{3,4}$/', '', $image_name), sanitize_title($image_name), "attachment" ) );
|
1419 |
+
|
1420 |
+
if ( $attch != null ){
|
1421 |
+
$download_image = false;
|
1422 |
+
$attid = $attch->ID;
|
1423 |
+
}
|
1424 |
+
elseif (@file_exists($targetDir . '/' . $image_name)){
|
1425 |
+
if ($bundle_data['type'] == 'images' and ($img_meta = wp_read_image_metadata($targetDir . '/' . $image_name))) {
|
1426 |
+
if (trim($img_meta['title']) && ! is_numeric(sanitize_title($img_meta['title']))){
|
1427 |
+
$img_title = $img_meta['title'];
|
1428 |
+
$attch = $this->wpdb->get_row( $this->wpdb->prepare( "SELECT * FROM " . $this->wpdb->posts . " WHERE post_title = %s AND post_type = %s AND post_parent = %d;", $img_title, "attachment", $pid ) );
|
1429 |
+
if ( $attch != null ){
|
1430 |
+
$download_image = false;
|
1431 |
+
$attid = $attch->ID;
|
1432 |
+
}
|
1433 |
+
}
|
1434 |
+
}
|
1435 |
+
}
|
1436 |
+
}
|
1437 |
|
1438 |
+
if ($download_image){
|
1439 |
+
|
1440 |
+
// do not download images
|
1441 |
+
if ( "yes" != $this->options[$option_slug . 'download_images'] ){
|
1442 |
+
|
1443 |
+
$image_filename = $image_name;
|
1444 |
+
$image_filepath = $targetDir . '/' . $image_filename;
|
1445 |
+
|
1446 |
+
$wpai_uploads = $uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::FILES_DIRECTORY . DIRECTORY_SEPARATOR;
|
1447 |
+
$wpai_image_path = $wpai_uploads . str_replace('%20', ' ', $url);
|
1448 |
+
|
1449 |
+
$logger and call_user_func($logger, sprintf(__('- Searching for existing image `%s` in `%s` folder', 'wp_all_import_plugin'), $wpai_image_path, $wpai_uploads));
|
1450 |
+
|
1451 |
+
if ( @file_exists($wpai_image_path) and @copy( $wpai_image_path, $image_filepath )){
|
1452 |
+
$download_image = false;
|
1453 |
+
// valdate import attachments
|
1454 |
+
if ($bundle_data['type'] == 'files'){
|
1455 |
+
if( ! $wp_filetype = wp_check_filetype(basename($image_filepath), null )) {
|
1456 |
+
$logger and call_user_func($logger, sprintf(__('- <b>WARNING</b>: Can\'t detect attachment file type %s', 'wp_all_import_plugin'), trim($image_filepath)));
|
1457 |
+
$logger and !$is_cron and PMXI_Plugin::$session->warnings++;
|
1458 |
+
@unlink($image_filepath);
|
1459 |
+
}
|
1460 |
+
else {
|
1461 |
+
$create_image = true;
|
1462 |
+
$logger and call_user_func($logger, sprintf(__('- File `%s` has been successfully founded', 'wp_all_import_plugin'), $wpai_image_path));
|
1463 |
+
}
|
1464 |
+
}
|
1465 |
+
// validate import images
|
1466 |
+
elseif($bundle_data['type'] == 'images'){
|
1467 |
+
if( ! ($image_info = @getimagesize($image_filepath)) or ! in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
|
1468 |
+
$logger and call_user_func($logger, sprintf(__('- <b>WARNING</b>: File %s is not a valid image and cannot be set as featured one', 'wp_all_import_plugin'), $image_filepath));
|
1469 |
+
$logger and !$is_cron and PMXI_Plugin::$session->warnings++;
|
1470 |
+
@unlink($image_filepath);
|
1471 |
+
} else {
|
1472 |
+
$create_image = true;
|
1473 |
+
$logger and call_user_func($logger, sprintf(__('- Image `%s` has been successfully founded', 'wp_all_import_plugin'), $wpai_image_path));
|
1474 |
+
}
|
1475 |
+
}
|
1476 |
+
}
|
1477 |
+
}
|
1478 |
+
else {
|
1479 |
+
|
1480 |
+
$logger and call_user_func($logger, sprintf(__('- Downloading image from `%s`', 'wp_all_import_plugin'), $url));
|
1481 |
+
|
1482 |
+
$request = get_file_curl($url, $image_filepath);
|
1483 |
+
|
1484 |
+
if ( (is_wp_error($request) or $request === false) and ! @file_put_contents($image_filepath, @file_get_contents($url))) {
|
1485 |
+
@unlink($image_filepath); // delete file since failed upload may result in empty file created
|
1486 |
+
} else{
|
1487 |
+
|
1488 |
+
if($bundle_data['type'] == 'images'){
|
1489 |
+
if( ($image_info = @getimagesize($image_filepath)) and in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
|
1490 |
+
$create_image = true;
|
1491 |
+
$logger and call_user_func($logger, sprintf(__('- Image `%s` has been successfully downloaded', 'wp_all_import_plugin'), $url));
|
1492 |
+
}
|
1493 |
+
}
|
1494 |
+
elseif($bundle_data['type'] == 'files'){
|
1495 |
+
if( $wp_filetype = wp_check_filetype(basename($image_filepath), null )) {
|
1496 |
+
$create_image = true;
|
1497 |
+
$logger and call_user_func($logger, sprintf(__('- File `%s` has been successfully downloaded', 'wp_all_import_plugin'), $url));
|
1498 |
+
}
|
1499 |
+
}
|
1500 |
+
|
1501 |
+
}
|
1502 |
+
|
1503 |
+
if ( ! $create_image ){
|
1504 |
+
|
1505 |
+
$url = str_replace(" ", "%20", trim(pmxi_convert_encoding($img_url)));
|
1506 |
+
|
1507 |
+
$request = get_file_curl($url, $image_filepath);
|
1508 |
+
|
1509 |
+
if ( (is_wp_error($request) or $request === false) and ! @file_put_contents($image_filepath, @file_get_contents($url))) {
|
1510 |
+
$logger and call_user_func($logger, sprintf(__('- <b>WARNING</b>: File %s cannot be saved locally as %s', 'wp_all_import_plugin'), $url, $image_filepath));
|
1511 |
+
$logger and !$is_cron and PMXI_Plugin::$session->warnings++;
|
1512 |
+
@unlink($image_filepath); // delete file since failed upload may result in empty file created
|
1513 |
+
}
|
1514 |
+
else{
|
1515 |
+
if($bundle_data['type'] == 'images'){
|
1516 |
+
if( ! ($image_info = @getimagesize($image_filepath)) or ! in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
|
1517 |
+
$logger and call_user_func($logger, sprintf(__('- <b>WARNING</b>: File %s is not a valid image and cannot be set as featured one', 'wp_all_import_plugin'), $url));
|
1518 |
+
$logger and !$is_cron and PMXI_Plugin::$session->warnings++;
|
1519 |
+
@unlink($image_filepath);
|
1520 |
+
} else {
|
1521 |
+
$create_image = true;
|
1522 |
+
$logger and call_user_func($logger, sprintf(__('- Image `%s` has been successfully downloaded', 'wp_all_import_plugin'), $url));
|
1523 |
+
}
|
1524 |
+
}
|
1525 |
+
elseif($bundle_data['type'] == 'files'){
|
1526 |
+
if( ! $wp_filetype = wp_check_filetype(basename($image_filepath), null )) {
|
1527 |
+
$logger and call_user_func($logger, sprintf(__('- <b>WARNING</b>: Can\'t detect attachment file type %s', 'wp_all_import_plugin'), trim($url)));
|
1528 |
+
$logger and !$is_cron and PMXI_Plugin::$session->warnings++;
|
1529 |
+
@unlink($image_filepath);
|
1530 |
+
}
|
1531 |
+
else {
|
1532 |
+
$create_image = true;
|
1533 |
+
$logger and call_user_func($logger, sprintf(__('- File `%s` has been successfully founded', 'wp_all_import_plugin'), $url));
|
1534 |
+
}
|
1535 |
+
}
|
1536 |
+
}
|
1537 |
+
}
|
1538 |
+
}
|
1539 |
}
|
1540 |
+
}
|
|
|
|
|
1541 |
|
1542 |
+
if ($create_image){
|
1543 |
+
|
1544 |
+
$logger and call_user_func($logger, sprintf(__('- Creating an attachment for image `%s`', 'wp_all_import_plugin'), $targetUrl . '/' . $image_filename));
|
1545 |
+
|
1546 |
+
$attachment = array(
|
1547 |
+
'post_mime_type' => ($bundle_data['type'] == 'images') ? image_type_to_mime_type($image_info[2]) : $wp_filetype['type'],
|
1548 |
+
'guid' => $targetUrl . '/' . $image_filename,
|
1549 |
+
'post_title' => $image_name,
|
1550 |
+
'post_content' => '',
|
1551 |
+
'post_author' => $post_author[$i],
|
1552 |
+
);
|
1553 |
+
if ($bundle_data['type'] == 'images' and ($image_meta = wp_read_image_metadata($image_filepath))) {
|
1554 |
+
if (trim($image_meta['title']) && ! is_numeric(sanitize_title($image_meta['title'])))
|
1555 |
+
$attachment['post_title'] = $image_meta['title'];
|
1556 |
+
if (trim($image_meta['caption']))
|
1557 |
+
$attachment['post_content'] = $image_meta['caption'];
|
1558 |
+
}
|
1559 |
+
|
1560 |
+
$attid = wp_insert_attachment($attachment, $image_filepath, $pid);
|
1561 |
+
|
1562 |
+
if (is_wp_error($attid)) {
|
1563 |
+
$logger and call_user_func($logger, __('- <b>WARNING</b>', 'wp_all_import_plugin') . ': ' . $attid->get_error_message());
|
1564 |
+
$logger and !$is_cron and PMXI_Plugin::$session->warnings++;
|
1565 |
+
} else {
|
1566 |
+
// you must first include the image.php file
|
1567 |
+
// for the function wp_generate_attachment_metadata() to work
|
1568 |
+
require_once(ABSPATH . 'wp-admin/includes/image.php');
|
1569 |
+
wp_update_attachment_metadata($attid, wp_generate_attachment_metadata($attid, $image_filepath));
|
1570 |
+
|
1571 |
+
$update_attachment_meta = array();
|
1572 |
+
if ( $this->options[$option_slug . 'set_image_meta_title'] and ! empty($img_titles[$k]) ) $update_attachment_meta['post_title'] = $img_titles[$k];
|
1573 |
+
if ( $this->options[$option_slug . 'set_image_meta_caption'] and ! empty($img_captions[$k]) ) $update_attachment_meta['post_excerpt'] = $img_captions[$k];
|
1574 |
+
if ( $this->options[$option_slug . 'set_image_meta_description'] and ! empty($img_descriptions[$k]) ) $update_attachment_meta['post_content'] = $img_descriptions[$k];
|
1575 |
+
if ( $this->options[$option_slug . 'set_image_meta_alt'] and ! empty($img_alts[$k]) ) update_post_meta($attid, '_wp_attachment_image_alt', $img_alts[$k]);
|
1576 |
+
|
1577 |
+
if ( ! empty($update_attachment_meta)) $this->wpdb->update( $this->wpdb->posts, $update_attachment_meta, array('ID' => $attid) );
|
1578 |
+
}
|
1579 |
|
1580 |
+
}
|
1581 |
|
1582 |
+
if ($attid){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1583 |
|
1584 |
+
if ($attch != null and empty($attch->post_parent)){
|
1585 |
+
wp_update_post(
|
1586 |
+
array(
|
1587 |
+
'ID' => $attch->ID,
|
1588 |
+
'post_parent' => $pid
|
1589 |
+
)
|
1590 |
+
);
|
1591 |
+
}
|
1592 |
+
|
1593 |
+
$logger and call_user_func($logger, __('- <b>ACTION</b>: ' . $slug, 'wp_all_import_plugin'));
|
1594 |
+
do_action( $slug, $pid, $attid, $image_filepath, $is_keep_existing_images ? 'add_images' : 'update_images');
|
1595 |
+
|
1596 |
+
$success_images = true;
|
1597 |
+
|
1598 |
+
$post_thumbnail_id = get_post_thumbnail_id( $pid );
|
1599 |
+
if ($bundle_data['type'] == 'images' and empty($post_thumbnail_id) and $this->options[$option_slug . 'is_featured'] ) {
|
1600 |
+
set_post_thumbnail($pid, $attid);
|
1601 |
+
}
|
1602 |
+
elseif(!in_array($attid, $gallery_attachment_ids) and $post_thumbnail_id != $attid){
|
1603 |
+
$gallery_attachment_ids[] = $attid;
|
1604 |
+
}
|
1605 |
+
|
1606 |
+
$logger and call_user_func($logger, sprintf(__('- Attachment has been successfully created for image `%s`', 'wp_all_import_plugin'), $targetUrl . '/' . $image_filename));
|
1607 |
+
|
1608 |
+
}
|
1609 |
+
}
|
1610 |
+
}
|
1611 |
+
// Set product gallery images
|
1612 |
+
if ( $post_type[$i] == "product" )
|
1613 |
+
update_post_meta($pid, '_product_image_gallery', (!empty($gallery_attachment_ids)) ? implode(',', $gallery_attachment_ids) : '');
|
1614 |
+
// Create entry as Draft if no images are downloaded successfully
|
1615 |
+
if ( ! $success_images and "yes" == $this->options[$option_slug . 'create_draft'] ) {
|
1616 |
+
$this->wpdb->update( $this->wpdb->posts, array('post_status' => 'draft'), array('ID' => $pid) );
|
1617 |
+
$logger and call_user_func($logger, sprintf(__('- Post `%s` saved as Draft, because no images are downloaded successfully', 'wp_all_import_plugin'), $articleData['post_title']));
|
1618 |
}
|
1619 |
+
}
|
1620 |
+
}
|
1621 |
+
else{
|
1622 |
+
// Create entry as Draft if no images are downloaded successfully
|
1623 |
+
if ( "yes" == $this->options[$option_slug . 'create_draft'] ){
|
1624 |
+
$this->wpdb->update( $this->wpdb->posts, array('post_status' => 'draft'), array('ID' => $pid) );
|
1625 |
+
$logger and call_user_func($logger, sprintf(__('Post `%s` saved as Draft, because no images are downloaded successfully', 'wp_all_import_plugin'), $articleData['post_title']));
|
1626 |
+
}
|
1627 |
+
}
|
1628 |
+
}
|
1629 |
+
}
|
1630 |
+
}
|
1631 |
+
else
|
1632 |
+
{
|
1633 |
+
if ( ! empty($images_bundle) ){
|
1634 |
|
1635 |
+
foreach ($images_bundle as $slug => $bundle_data) {
|
1636 |
|
1637 |
+
if ( ! empty($bundle_data['images'][$i]) ){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1638 |
|
1639 |
+
$imgs = array();
|
|
|
1640 |
|
1641 |
+
$featured_delim = ( "yes" == $this->options[$option_slug . 'download_images'] ) ? $this->options[$option_slug . 'download_featured_delim'] : $this->options[$option_slug . 'featured_delim'];
|
1642 |
|
1643 |
+
$line_imgs = explode("\n", $bundle_data['images'][$i]);
|
1644 |
+
if ( ! empty($line_imgs) )
|
1645 |
+
foreach ($line_imgs as $line_img)
|
1646 |
+
$imgs = array_merge($imgs, ( ! empty($featured_delim) ) ? str_getcsv($line_img, $featured_delim) : array($line_img) );
|
|
|
|
|
|
|
1647 |
|
1648 |
+
foreach ($imgs as $img) {
|
1649 |
+
do_action( $slug, $pid, false, $img, false);
|
|
|
1650 |
}
|
1651 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1652 |
}
|
1653 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
1654 |
}
|
1655 |
}
|
1656 |
}
|
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.2.
|
7 |
Author: Soflyy
|
8 |
*/
|
9 |
|
@@ -25,7 +25,7 @@ define('WP_ALL_IMPORT_ROOT_URL', rtrim(plugin_dir_url(__FILE__), '/'));
|
|
25 |
*/
|
26 |
define('WP_ALL_IMPORT_PREFIX', 'pmxi_');
|
27 |
|
28 |
-
define('PMXI_VERSION', '3.2.
|
29 |
|
30 |
define('PMXI_EDITION', 'free');
|
31 |
|
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.2.9
|
7 |
Author: Soflyy
|
8 |
*/
|
9 |
|
25 |
*/
|
26 |
define('WP_ALL_IMPORT_PREFIX', 'pmxi_');
|
27 |
|
28 |
+
define('PMXI_VERSION', '3.2.9');
|
29 |
|
30 |
define('PMXI_EDITION', 'free');
|
31 |
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Contributors: soflyy, wpallimport
|
3 |
Requires at least: 3.6.1
|
4 |
Tested up to: 4.2.2
|
5 |
-
Stable tag: 3.2.
|
6 |
Tags: wordpress csv import, wordpress xml import, xml, csv, datafeed, import, migrate, import csv to wordpress, import xml to wordpress, advanced xml import, advanced csv import, bulk csv import, bulk xml import, bulk data import, xml to custom post type, csv to custom post type, woocommerce csv import, woocommerce xml import, csv import, import csv, xml import, import xml, csv importer
|
7 |
|
8 |
WP All Import is an extremely powerful importer that makes it easy to import any XML or CSV file to WordPress.
|
@@ -103,6 +103,10 @@ Does it work with special character encoding like Hebrew, Arabic, Chinese, etc?
|
|
103 |
|
104 |
== Changelog ==
|
105 |
|
|
|
|
|
|
|
|
|
106 |
= 3.2.8 =
|
107 |
* fixed Apply mapping rules before splitting via separator symbol for manual hierarchy
|
108 |
* fixed path equal or less than
|
2 |
Contributors: soflyy, wpallimport
|
3 |
Requires at least: 3.6.1
|
4 |
Tested up to: 4.2.2
|
5 |
+
Stable tag: 3.2.9
|
6 |
Tags: wordpress csv import, wordpress xml import, xml, csv, datafeed, import, migrate, import csv to wordpress, import xml to wordpress, advanced xml import, advanced csv import, bulk csv import, bulk xml import, bulk data import, xml to custom post type, csv to custom post type, woocommerce csv import, woocommerce xml import, csv import, import csv, xml import, import xml, csv importer
|
7 |
|
8 |
WP All Import is an extremely powerful importer that makes it easy to import any XML or CSV file to WordPress.
|
103 |
|
104 |
== Changelog ==
|
105 |
|
106 |
+
= 3.2.9 =
|
107 |
+
* load ini_set only on plugin pages
|
108 |
+
* fixed saving import template
|
109 |
+
|
110 |
= 3.2.8 =
|
111 |
* fixed Apply mapping rules before splitting via separator symbol for manual hierarchy
|
112 |
* fixed path equal or less than
|
static/css/admin.css
CHANGED
@@ -1129,6 +1129,35 @@
|
|
1129 |
-moz-border-radius-bottomleft: 4px;
|
1130 |
-webkit-border-bottom-left-radius: 4px;
|
1131 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1132 |
.wpallimport-plugin .wpallimport-choose-post-type{ padding-top: 40px; }
|
1133 |
.wpallimport-plugin .wpallimport-file-upload-result{ padding-top: 30px; overflow: hidden; }
|
1134 |
.wpallimport-plugin .wpallimport-upload-resource-step-one{ padding-bottom: 40px; }
|
1129 |
-moz-border-radius-bottomleft: 4px;
|
1130 |
-webkit-border-bottom-left-radius: 4px;
|
1131 |
}
|
1132 |
+
.wpallimport-plugin .wpallimport-bottom-radius{
|
1133 |
+
border-bottom-left-radius: 4px;
|
1134 |
+
border-bottom-right-radius: 4px;
|
1135 |
+
-moz-border-radius-bottomleft: 4px;
|
1136 |
+
-moz-border-radius-bottomright: 4px;
|
1137 |
+
-webkit-border-bottom-left-radius: 4px;
|
1138 |
+
-webkit-border-bottom-right-radius: 4px;
|
1139 |
+
border-top-left-radius: 0px;
|
1140 |
+
border-top-right-radius: 0px;
|
1141 |
+
-moz-border-radius-topleft: 0px;
|
1142 |
+
-moz-border-radius-topright: 0px;
|
1143 |
+
-webkit-border-top-left-radius: 0px;
|
1144 |
+
-webkit-border-top-right-radius: 0px;
|
1145 |
+
}
|
1146 |
+
|
1147 |
+
.wpallimport-plugin .wpallimport-top-radius{
|
1148 |
+
border-bottom-left-radius: 0px !important;
|
1149 |
+
border-bottom-right-radius: 0px !important;
|
1150 |
+
-moz-border-radius-bottomleft: 0px !important;
|
1151 |
+
-moz-border-radius-bottomright: 0px !important;
|
1152 |
+
-webkit-border-bottom-left-radius: 0px !important;
|
1153 |
+
-webkit-border-bottom-right-radius: 0px !important;
|
1154 |
+
border-top-left-radius: 4px !important;
|
1155 |
+
border-top-right-radius: 4px !important;
|
1156 |
+
-moz-border-radius-topleft: 4px !important;
|
1157 |
+
-moz-border-radius-topright: 4px !important;
|
1158 |
+
-webkit-border-top-left-radius: 4px !important;
|
1159 |
+
-webkit-border-top-right-radius: 4px !important;
|
1160 |
+
}
|
1161 |
.wpallimport-plugin .wpallimport-choose-post-type{ padding-top: 40px; }
|
1162 |
.wpallimport-plugin .wpallimport-file-upload-result{ padding-top: 30px; overflow: hidden; }
|
1163 |
.wpallimport-plugin .wpallimport-upload-resource-step-one{ padding-bottom: 40px; }
|
static/js/admin.js
CHANGED
@@ -468,12 +468,15 @@
|
|
468 |
|
469 |
$form.find('.preview, .preview_images, .preview_taxonomies, .preview_prices').click(function () {
|
470 |
var $preview_type = $(this).attr('rel');
|
|
|
471 |
|
472 |
if ($preview_type == 'preview_taxonomies') serialize_ctx_mapping();
|
473 |
|
474 |
var $URL = 'admin.php?page=pmxi-admin-import&action=' + $preview_type + ((typeof import_id != "undefined") ? '&id=' + import_id : '');
|
475 |
var $tagURL = 'admin.php?page=pmxi-admin-import&action=tag' + ((typeof import_id != "undefined") ? '&id=' + import_id : '');
|
476 |
|
|
|
|
|
477 |
$('.wpallimport-overlay').show();
|
478 |
|
479 |
var $ths = $(this);
|
@@ -1683,6 +1686,10 @@
|
|
1683 |
}
|
1684 |
});
|
1685 |
|
|
|
|
|
|
|
|
|
1686 |
var fix_tag_position = function(){
|
1687 |
if ($('.wpallimport-layout').length && $('.tag').length){
|
1688 |
var offset = $('.wpallimport-layout').offset();
|
468 |
|
469 |
$form.find('.preview, .preview_images, .preview_taxonomies, .preview_prices').click(function () {
|
470 |
var $preview_type = $(this).attr('rel');
|
471 |
+
var $options_slug = $(this).parent('div').find('.wp_all_import_section_slug').val();
|
472 |
|
473 |
if ($preview_type == 'preview_taxonomies') serialize_ctx_mapping();
|
474 |
|
475 |
var $URL = 'admin.php?page=pmxi-admin-import&action=' + $preview_type + ((typeof import_id != "undefined") ? '&id=' + import_id : '');
|
476 |
var $tagURL = 'admin.php?page=pmxi-admin-import&action=tag' + ((typeof import_id != "undefined") ? '&id=' + import_id : '');
|
477 |
|
478 |
+
if ($options_slug != undefined) $URL += '&slug=' + $options_slug;
|
479 |
+
|
480 |
$('.wpallimport-overlay').show();
|
481 |
|
482 |
var $ths = $(this);
|
1686 |
}
|
1687 |
});
|
1688 |
|
1689 |
+
$('.wpallimport-dependent-options').each(function(){
|
1690 |
+
$(this).prev('div.input').find('input[type=text]:last, textarea:last').addClass('wpallimport-top-radius');
|
1691 |
+
});
|
1692 |
+
|
1693 |
var fix_tag_position = function(){
|
1694 |
if ($('.wpallimport-layout').length && $('.tag').length){
|
1695 |
var offset = $('.wpallimport-layout').offset();
|
views/admin/import/options/_reimport_options.php
CHANGED
@@ -128,10 +128,13 @@
|
|
128 |
<input type="radio" id="update_images_logic_full_update" name="update_images_logic" value="full_update" <?php echo ( "full_update" == $post['update_images_logic'] ) ? 'checked="checked"': '' ?> />
|
129 |
<label for="update_images_logic_full_update"><?php _e('Update all images', 'wp_all_import_plugin') ?></label>
|
130 |
</div>
|
|
|
|
|
131 |
<div class="input" style="margin-bottom:3px;">
|
132 |
<input type="radio" id="update_images_logic_add_new" name="update_images_logic" value="add_new" <?php echo ( "add_new" == $post['update_images_logic'] ) ? 'checked="checked"': '' ?> />
|
133 |
<label for="update_images_logic_add_new"><?php _e('Don\'t touch existing images, append new images', 'wp_all_import_plugin') ?></label>
|
134 |
</div>
|
|
|
135 |
</div>
|
136 |
</div>
|
137 |
<div class="input">
|
128 |
<input type="radio" id="update_images_logic_full_update" name="update_images_logic" value="full_update" <?php echo ( "full_update" == $post['update_images_logic'] ) ? 'checked="checked"': '' ?> />
|
129 |
<label for="update_images_logic_full_update"><?php _e('Update all images', 'wp_all_import_plugin') ?></label>
|
130 |
</div>
|
131 |
+
<?php $is_show_add_new_images = apply_filters('wp_all_import_is_show_add_new_images', true, $post_type); ?>
|
132 |
+
<?php if ($is_show_add_new_images): ?>
|
133 |
<div class="input" style="margin-bottom:3px;">
|
134 |
<input type="radio" id="update_images_logic_add_new" name="update_images_logic" value="add_new" <?php echo ( "add_new" == $post['update_images_logic'] ) ? 'checked="checked"': '' ?> />
|
135 |
<label for="update_images_logic_add_new"><?php _e('Don\'t touch existing images, append new images', 'wp_all_import_plugin') ?></label>
|
136 |
</div>
|
137 |
+
<?php endif; ?>
|
138 |
</div>
|
139 |
</div>
|
140 |
<div class="input">
|
views/admin/import/preview_images.php
CHANGED
@@ -23,11 +23,11 @@
|
|
23 |
?>
|
24 |
<p><?php _e('Click to test button to have WP All Import ensure it can import your images.', 'wp_all_import_plugin'); ?></p>
|
25 |
|
26 |
-
<a class="test_images" href="javascript:void(0);" style="margin-left:0;" rel="<?php echo $post['download_images']; ?>"><?php _e('Test', 'wp_all_import_plugin'); ?></a>
|
27 |
|
28 |
<?php
|
29 |
|
30 |
-
$featured_delim = ( "yes" == $post['download_images'] ) ? $post['download_featured_delim'] : $post['featured_delim'];
|
31 |
$imgs = array();
|
32 |
|
33 |
$line_imgs = explode("\n", $featured_images);
|
@@ -37,7 +37,7 @@
|
|
37 |
|
38 |
$imgs = array_filter($imgs);
|
39 |
|
40 |
-
if ( "yes" == $post['download_images']):
|
41 |
|
42 |
?>
|
43 |
<div class="test_progress">
|
23 |
?>
|
24 |
<p><?php _e('Click to test button to have WP All Import ensure it can import your images.', 'wp_all_import_plugin'); ?></p>
|
25 |
|
26 |
+
<a class="test_images" href="javascript:void(0);" style="margin-left:0;" rel="<?php echo $post[$get['slug'] . 'download_images']; ?>"><?php _e('Test', 'wp_all_import_plugin'); ?></a>
|
27 |
|
28 |
<?php
|
29 |
|
30 |
+
$featured_delim = ( "yes" == $post[$get['slug'] . 'download_images'] ) ? $post[$get['slug'] . 'download_featured_delim'] : $post[ $get['slug'] . 'featured_delim'];
|
31 |
$imgs = array();
|
32 |
|
33 |
$line_imgs = explode("\n", $featured_images);
|
37 |
|
38 |
$imgs = array_filter($imgs);
|
39 |
|
40 |
+
if ( "yes" == $post[$get['slug'] . 'download_images']):
|
41 |
|
42 |
?>
|
43 |
<div class="test_progress">
|
views/admin/import/template.php
CHANGED
@@ -31,7 +31,7 @@
|
|
31 |
<?php $this->warning() ?>
|
32 |
<?php endif ?>
|
33 |
|
34 |
-
<?php $post_type = $post['custom_type']
|
35 |
|
36 |
<?php if ( in_array('caption', $visible_sections) ): ?>
|
37 |
|
@@ -107,7 +107,10 @@
|
|
107 |
if ( in_array('main', $visible_sections) ) do_action('pmxi_extend_options_main', $post_type, $post);
|
108 |
|
109 |
if ( in_array('featured', $visible_sections) ) {
|
110 |
-
|
|
|
|
|
|
|
111 |
do_action('pmxi_extend_options_featured', $post_type, $post);
|
112 |
}
|
113 |
|
31 |
<?php $this->warning() ?>
|
32 |
<?php endif ?>
|
33 |
|
34 |
+
<?php $post_type = $post['custom_type']; ?>
|
35 |
|
36 |
<?php if ( in_array('caption', $visible_sections) ): ?>
|
37 |
|
107 |
if ( in_array('main', $visible_sections) ) do_action('pmxi_extend_options_main', $post_type, $post);
|
108 |
|
109 |
if ( in_array('featured', $visible_sections) ) {
|
110 |
+
$is_images_section_enabled = apply_filters('wp_all_import_is_images_section_enabled', true, $post_type);
|
111 |
+
if ( $is_images_section_enabled ) {
|
112 |
+
PMXI_API::add_additional_images_section(__('Images', 'wp_all_import_plugin'), '', $post, $post_type, true, true);
|
113 |
+
}
|
114 |
do_action('pmxi_extend_options_featured', $post_type, $post);
|
115 |
}
|
116 |
|
views/admin/import/template/_featured_template.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
<div class="wpallimport-collapsed closed wpallimport-section wpallimport-featured-images">
|
2 |
<div class="wpallimport-content-section" style="padding-bottom: 0;">
|
3 |
<div class="wpallimport-collapsed-header" style="margin-bottom: 15px;">
|
4 |
-
<h3><?php
|
5 |
</div>
|
6 |
<div class="wpallimport-collapsed-content" style="padding: 0;">
|
7 |
<div class="wpallimport-collapsed-content-inner">
|
8 |
-
<?php if ($post_type != "product" or ! class_exists('PMWI_Plugin')):?>
|
9 |
|
10 |
<div class="wpallimport-free-edition-notice" style="text-align:center; margin-top:-15px; margin-bottom: 40px;">
|
11 |
<a href="http://www.wpallimport.com/upgrade-to-pro/?utm_source=free-plugin&utm_medium=in-plugin&utm_campaign=images" target="_blank" class="upgrade_link"><?php _e('Upgrade to the professional edition of WP All Import to import images.', 'pmxi_plugin');?></a>
|
@@ -17,47 +17,50 @@
|
|
17 |
<td colspan="3">
|
18 |
<div class="input">
|
19 |
<div class="input">
|
20 |
-
<input type="radio" name="download_images" value="yes" class="switcher" id="download_images_yes" <?php echo ("yes" == $post['download_images']) ? 'checked="checked"' : '';?>/>
|
21 |
-
<label for="download_images_yes"><?php _e('Download image(s) hosted elsewhere'); ?></label>
|
22 |
<a href="#help" class="wpallimport-help" title="<?php _e('http:// or https://', 'wp_all_import_plugin') ?>" style="position: relative; top: -2px;">?</a>
|
23 |
</div>
|
24 |
-
<div class="switcher-target
|
25 |
-
<label for="download_featured_delim"><?php _e('Enter image URL one per line, or separate them with a ', 'wp_all_import_plugin');?></label>
|
26 |
-
<input type="text" class="small" id="download_featured_delim" name="download_featured_delim" value="<?php echo esc_attr($post['download_featured_delim']) ?>" style="width:5%; text-align:center;"/>
|
27 |
-
<textarea name="download_featured_image" class="newline rad4" style="clear: both; display:block;" placeholder=""><?php echo esc_attr($post['download_featured_image']) ?></textarea>
|
28 |
</div>
|
29 |
<div class="input">
|
30 |
<?php $wp_uploads = wp_upload_dir(); ?>
|
31 |
-
<input type="radio" name="download_images" value="no" class="switcher" id="download_images_no" <?php echo ("yes" != $post['download_images']) ? 'checked="checked"' : '';?>/>
|
32 |
-
<label for="download_images_no"><?php printf(__('Use image(s) currently uploaded in %s', 'wp_all_import_plugin'), $wp_uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::FILES_DIRECTORY . DIRECTORY_SEPARATOR); ?></label>
|
33 |
</div>
|
34 |
-
<div class="switcher-target
|
35 |
-
<label for="featured_delim"><?php _e('Enter image filenames one per line, or separate them with a ', 'wp_all_import_plugin');?></label>
|
36 |
-
<input type="text" class="small" id="featured_delim" name="featured_delim" value="<?php echo esc_attr($post['featured_delim']) ?>" style="width:5%; text-align:center;"/>
|
37 |
-
<textarea name="featured_image" class="newline rad4" style="clear: both; display:block; "><?php echo esc_attr($post['featured_image']) ?></textarea>
|
38 |
</div>
|
39 |
</div>
|
40 |
<div class="input" style="margin:3px;">
|
41 |
-
<input type="hidden" name="search_existing_images" value="0" />
|
42 |
-
<input type="checkbox" id="search_existing_images" name="search_existing_images" value="1" <?php echo $post['search_existing_images'] ? 'checked="checked"' : '' ?> class="fix_checkbox"/>
|
43 |
-
<label for="search_existing_images"><?php _e('Search through the Media Library for existing images before importing new images','wp_all_import_plugin');?> </label>
|
44 |
<a href="#help" class="wpallimport-help" title="<?php _e('If an image with the same file name is found in the Media Library then that image will be attached to this record instead of importing a new image. Disable this setting if your import has different images with the same file name.', 'wp_all_import_plugin') ?>" style="position: relative; top: -2px;">?</a>
|
45 |
</div>
|
|
|
46 |
<div class="input">
|
|
|
47 |
<a class="preview_images" href="javascript:void(0);" rel="preview_images"><?php _e('Preview & Test', 'wp_all_import_plugin'); ?></a>
|
48 |
</div>
|
49 |
<h4><?php _e('Featured Image', 'wp_all_import_plugin'); ?></h4>
|
50 |
<div class="input" style="margin:3px 0px;">
|
51 |
-
<input type="hidden" name="is_featured" value="0" />
|
52 |
-
<input type="checkbox" id="is_featured" name="is_featured" value="1" <?php echo $post['is_featured'] ? 'checked="checked"' : '' ?> class="fix_checkbox"/>
|
53 |
-
<label for="is_featured"><?php _e('Set the first image to the Featured Image (_thumbnail_id)','wp_all_import_plugin');?> </label>
|
54 |
</div>
|
55 |
<h4><?php _e('Other', 'wp_all_import_plugin'); ?></h4>
|
56 |
<div class="input">
|
57 |
-
<input type="hidden" name="create_draft" value="no" />
|
58 |
-
<input type="checkbox" id="create_draft" name="create_draft" value="yes" <?php echo 'yes' == $post['create_draft'] ? 'checked="checked"' : '' ?> class="fix_checkbox"/>
|
59 |
-
<label for="create_draft"><?php _e('If no images are downloaded successfully, create entry as Draft.', 'wp_all_import_plugin') ?></label>
|
60 |
-
</div>
|
|
|
61 |
</td>
|
62 |
</tr>
|
63 |
</table>
|
@@ -76,71 +79,70 @@
|
|
76 |
<td colspan="3">
|
77 |
<h4><?php _e('Meta Data', 'wp_all_import_plugin'); ?></h4>
|
78 |
<div class="input">
|
79 |
-
<input type="hidden" name="set_image_meta_title" value="0" />
|
80 |
-
<input type="checkbox" id="set_image_meta_title" name="set_image_meta_title" value="1" <?php echo $post['set_image_meta_title'] ? 'checked="checked"' : '' ?> class="switcher fix_checkbox"/>
|
81 |
-
<label for="set_image_meta_title"><?php _e('Set Title(s)','wp_all_import_plugin');?></label>
|
82 |
-
<div class="switcher-target
|
83 |
-
<label for="image_meta_title_delim"><?php _e('Enter one per line, or separate them with a ', 'wp_all_import_plugin');?></label>
|
84 |
-
<input type="text" class="small" id="image_meta_title_delim" name="image_meta_title_delim" value="<?php echo esc_attr($post['image_meta_title_delim']) ?>" style="width:5%; text-align:center;"/>
|
85 |
<p style="margin-bottom:5px;"><?php _e('The first title will be linked to the first image, the second title will be linked to the second image, ...', 'wp_all_import_plugin');?></p>
|
86 |
-
<textarea name="image_meta_title" class="newline rad4"><?php echo esc_attr($post['image_meta_title']) ?></textarea>
|
87 |
</div>
|
88 |
</div>
|
89 |
<div class="input">
|
90 |
-
<input type="hidden" name="set_image_meta_caption" value="0" />
|
91 |
-
<input type="checkbox" id="set_image_meta_caption" name="set_image_meta_caption" value="1" <?php echo $post['set_image_meta_caption'] ? 'checked="checked"' : '' ?> class="switcher fix_checkbox"/>
|
92 |
-
<label for="set_image_meta_caption"><?php _e('Set Caption(s)','wp_all_import_plugin');?></label>
|
93 |
-
<div class="switcher-target
|
94 |
-
<label for="image_meta_caption_delim"><?php _e('Enter one per line, or separate them with a ', 'wp_all_import_plugin');?></label>
|
95 |
-
<input type="text" class="small" id="image_meta_caption_delim" name="image_meta_caption_delim" value="<?php echo esc_attr($post['image_meta_caption_delim']) ?>" style="width:5%; text-align:center;"/>
|
96 |
<p style="margin-bottom:5px;"><?php _e('The first caption will be linked to the first image, the second caption will be linked to the second image, ...', 'wp_all_import_plugin');?></p>
|
97 |
-
<textarea name="image_meta_caption" class="newline rad4"><?php echo esc_attr($post['image_meta_caption']) ?></textarea>
|
98 |
</div>
|
99 |
</div>
|
100 |
<div class="input">
|
101 |
-
<input type="hidden" name="set_image_meta_alt" value="0" />
|
102 |
-
<input type="checkbox" id="set_image_meta_alt" name="set_image_meta_alt" value="1" <?php echo $post['set_image_meta_alt'] ? 'checked="checked"' : '' ?> class="switcher fix_checkbox"/>
|
103 |
-
<label for="set_image_meta_alt"><?php _e('Set Alt Text(s)','wp_all_import_plugin');?></label>
|
104 |
-
<div class="switcher-target
|
105 |
-
<label for="image_meta_alt_delim"><?php _e('Enter one per line, or separate them with a ', 'wp_all_import_plugin');?></label>
|
106 |
-
<input type="text" class="small" id="image_meta_alt_delim" name="image_meta_alt_delim" value="<?php echo esc_attr($post['image_meta_alt_delim']) ?>" style="width:5%; text-align:center;"/>
|
107 |
<p style="margin-bottom:5px;"><?php _e('The first alt text will be linked to the first image, the second alt text will be linked to the second image, ...', 'wp_all_import_plugin');?></p>
|
108 |
-
<textarea name="image_meta_alt" class="newline rad4"><?php echo esc_attr($post['image_meta_alt']) ?></textarea>
|
109 |
</div>
|
110 |
</div>
|
111 |
<div class="input">
|
112 |
-
<input type="hidden" name="set_image_meta_description" value="0" />
|
113 |
-
<input type="checkbox" id="set_image_meta_description" name="set_image_meta_description" value="1" <?php echo $post['set_image_meta_description'] ? 'checked="checked"' : '' ?> class="switcher fix_checkbox"/>
|
114 |
-
<label for="set_image_meta_description"><?php _e('Set Description(s)','wp_all_import_plugin');?></label>
|
115 |
-
<div class="switcher-target
|
116 |
-
<label for="image_meta_description_delim"><?php _e('Enter one per line, or separate them with a ', 'wp_all_import_plugin');?></label>
|
117 |
-
<input type="text" class="small" id="image_meta_description_delim" name="image_meta_description_delim" value="<?php echo esc_attr($post['image_meta_description_delim']) ?>" style="width:5%; text-align:center;"/>
|
118 |
<p style="margin-bottom:5px;"><?php _e('The first description will be linked to the first image, the second description will be linked to the second image, ...', 'wp_all_import_plugin');?></p>
|
119 |
-
<textarea name="image_meta_description" class="newline rad4"><?php echo esc_attr($post['image_meta_description']) ?></textarea>
|
120 |
</div>
|
121 |
-
</div>
|
122 |
-
|
123 |
<h4><?php _e('Files', 'wp_all_import_plugin'); ?></h4>
|
124 |
<div id="advanced_options_files">
|
125 |
<p style="font-style:italic; display:none;"><?php _e('These options only available if Download image(s) hosted elsewhere is selected above.', 'wp_all_import_plugin'); ?></p>
|
126 |
<div class="input" style="margin:3px 0px;">
|
127 |
-
<input type="hidden" name="auto_rename_images" value="0" />
|
128 |
-
<input type="checkbox" id="auto_rename_images" name="auto_rename_images" value="1" <?php echo $post['auto_rename_images'] ? 'checked="checked"' : '' ?> class="switcher fix_checkbox"/>
|
129 |
-
<label for="auto_rename_images"><?php _e('Change image file names to','wp_all_import_plugin');?> </label>
|
130 |
-
<div class="input switcher-target
|
131 |
-
<input type="text" id="auto_rename_images_suffix" name="auto_rename_images_suffix" value="<?php echo esc_attr($post['auto_rename_images_suffix']) ?>" style="width:480px;"/>
|
132 |
<p class="note"><?php _e('Multiple image will have numbers appended, i.e. image-name-1.jpg, image-name-2.jpg '); ?></p>
|
133 |
</div>
|
134 |
</div>
|
135 |
<div class="input" style="margin:3px 0px;">
|
136 |
-
<input type="hidden" name="auto_set_extension" value="0" />
|
137 |
-
<input type="checkbox" id="auto_set_extension" name="auto_set_extension" value="1" <?php echo $post['auto_set_extension'] ? 'checked="checked"' : '' ?> class="switcher fix_checkbox"/>
|
138 |
-
<label for="auto_set_extension"><?php _e('Change image file extensions','wp_all_import_plugin');?> </label>
|
139 |
-
<div class="input switcher-target
|
140 |
-
<input type="text" id="new_extension" name="new_extension" value="<?php echo esc_attr($post['new_extension']) ?>" placeholder="jpg" style="width:480px;"/>
|
141 |
</div>
|
142 |
</div>
|
143 |
-
</div>
|
144 |
</td>
|
145 |
</tr>
|
146 |
</table>
|
@@ -150,12 +152,4 @@
|
|
150 |
</div>
|
151 |
</div>
|
152 |
</div>
|
153 |
-
</div>
|
154 |
-
<div id="images_hints" style="display:none;">
|
155 |
-
<ul>
|
156 |
-
<li><?php _e('WP All Import will automatically ignore elements with blank image URLs/filenames.', 'wp_all_import_plugin'); ?></li>
|
157 |
-
<li><?php _e('WP All Import must download the images to your server. You can\'t have images in a Gallery that are referenced by external URL. That\'s just how WordPress works.', 'wp_all_import_plugin'); ?></li>
|
158 |
-
<li><?php printf(__('Importing a variable number of images can be done using a <a href="%s" target="_blank">FOREACH LOOP</a>', 'wp_all_import_plugin'), 'http://www.wpallimport.com/documentation/step-3/template-syntax/'); ?></li>
|
159 |
-
<li><?php printf(__('For more information check out our <a href="%s" target="_blank">comprehensive documentation</a>', 'wp_all_import_plugin'), 'http://www.wpallimport.com/documentation/'); ?></li>
|
160 |
-
</ul>
|
161 |
</div>
|
1 |
<div class="wpallimport-collapsed closed wpallimport-section wpallimport-featured-images">
|
2 |
<div class="wpallimport-content-section" style="padding-bottom: 0;">
|
3 |
<div class="wpallimport-collapsed-header" style="margin-bottom: 15px;">
|
4 |
+
<h3><?php echo $section_title;?></h3>
|
5 |
</div>
|
6 |
<div class="wpallimport-collapsed-content" style="padding: 0;">
|
7 |
<div class="wpallimport-collapsed-content-inner">
|
8 |
+
<?php if ($section_is_show_warning and ( $post_type != "product" or ! class_exists('PMWI_Plugin'))):?>
|
9 |
|
10 |
<div class="wpallimport-free-edition-notice" style="text-align:center; margin-top:-15px; margin-bottom: 40px;">
|
11 |
<a href="http://www.wpallimport.com/upgrade-to-pro/?utm_source=free-plugin&utm_medium=in-plugin&utm_campaign=images" target="_blank" class="upgrade_link"><?php _e('Upgrade to the professional edition of WP All Import to import images.', 'pmxi_plugin');?></a>
|
17 |
<td colspan="3">
|
18 |
<div class="input">
|
19 |
<div class="input">
|
20 |
+
<input type="radio" name="<?php echo $section_slug; ?>download_images" value="yes" class="switcher" id="<?php echo $section_slug; ?>download_images_yes" <?php echo ("yes" == $post[$section_slug . 'download_images']) ? 'checked="checked"' : '';?>/>
|
21 |
+
<label for="<?php echo $section_slug; ?>download_images_yes"><?php _e('Download image(s) hosted elsewhere'); ?></label>
|
22 |
<a href="#help" class="wpallimport-help" title="<?php _e('http:// or https://', 'wp_all_import_plugin') ?>" style="position: relative; top: -2px;">?</a>
|
23 |
</div>
|
24 |
+
<div class="switcher-target-<?php echo $section_slug; ?>download_images_yes" style="padding-left:27px;">
|
25 |
+
<label for="<?php echo $section_slug; ?>download_featured_delim"><?php _e('Enter image URL one per line, or separate them with a ', 'wp_all_import_plugin');?></label>
|
26 |
+
<input type="text" class="small" id="<?php echo $section_slug; ?>download_featured_delim" name="<?php echo $section_slug; ?>download_featured_delim" value="<?php echo esc_attr($post[$section_slug . 'download_featured_delim']) ?>" style="width:5%; text-align:center;"/>
|
27 |
+
<textarea name="<?php echo $section_slug; ?>download_featured_image" class="newline rad4" style="clear: both; display:block;" placeholder=""><?php echo esc_attr($post[$section_slug . 'download_featured_image']) ?></textarea>
|
28 |
</div>
|
29 |
<div class="input">
|
30 |
<?php $wp_uploads = wp_upload_dir(); ?>
|
31 |
+
<input type="radio" name="<?php echo $section_slug; ?>download_images" value="no" class="switcher" id="<?php echo $section_slug; ?>download_images_no" <?php echo ("yes" != $post[$section_slug . 'download_images']) ? 'checked="checked"' : '';?>/>
|
32 |
+
<label for="<?php echo $section_slug; ?>download_images_no"><?php printf(__('Use image(s) currently uploaded in %s', 'wp_all_import_plugin'), $wp_uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::FILES_DIRECTORY . DIRECTORY_SEPARATOR); ?></label>
|
33 |
</div>
|
34 |
+
<div class="switcher-target-<?php echo $section_slug; ?>download_images_no" style="padding-left:27px;">
|
35 |
+
<label for="<?php echo $section_slug; ?>featured_delim"><?php _e('Enter image filenames one per line, or separate them with a ', 'wp_all_import_plugin');?></label>
|
36 |
+
<input type="text" class="small" id="<?php echo $section_slug; ?>featured_delim" name="<?php echo $section_slug; ?>featured_delim" value="<?php echo esc_attr($post[$section_slug . 'featured_delim']) ?>" style="width:5%; text-align:center;"/>
|
37 |
+
<textarea name="<?php echo $section_slug; ?>featured_image" class="newline rad4" style="clear: both; display:block; "><?php echo esc_attr($post[$section_slug . 'featured_image']) ?></textarea>
|
38 |
</div>
|
39 |
</div>
|
40 |
<div class="input" style="margin:3px;">
|
41 |
+
<input type="hidden" name="<?php echo $section_slug; ?>search_existing_images" value="0" />
|
42 |
+
<input type="checkbox" id="<?php echo $section_slug; ?>search_existing_images" name="<?php echo $section_slug; ?>search_existing_images" value="1" <?php echo $post[$section_slug . 'search_existing_images'] ? 'checked="checked"' : '' ?> class="fix_checkbox"/>
|
43 |
+
<label for="<?php echo $section_slug; ?>search_existing_images"><?php _e('Search through the Media Library for existing images before importing new images','wp_all_import_plugin');?> </label>
|
44 |
<a href="#help" class="wpallimport-help" title="<?php _e('If an image with the same file name is found in the Media Library then that image will be attached to this record instead of importing a new image. Disable this setting if your import has different images with the same file name.', 'wp_all_import_plugin') ?>" style="position: relative; top: -2px;">?</a>
|
45 |
</div>
|
46 |
+
<?php if ($section_type == 'images'): ?>
|
47 |
<div class="input">
|
48 |
+
<input type="hidden" value="<?php echo $section_slug; ?>" class="wp_all_import_section_slug"/>
|
49 |
<a class="preview_images" href="javascript:void(0);" rel="preview_images"><?php _e('Preview & Test', 'wp_all_import_plugin'); ?></a>
|
50 |
</div>
|
51 |
<h4><?php _e('Featured Image', 'wp_all_import_plugin'); ?></h4>
|
52 |
<div class="input" style="margin:3px 0px;">
|
53 |
+
<input type="hidden" name="<?php echo $section_slug; ?>is_featured" value="0" />
|
54 |
+
<input type="checkbox" id="<?php echo $section_slug; ?>is_featured" name="<?php echo $section_slug; ?>is_featured" value="1" <?php echo $post[$section_slug . 'is_featured'] ? 'checked="checked"' : '' ?> class="fix_checkbox"/>
|
55 |
+
<label for="<?php echo $section_slug; ?>is_featured"><?php _e('Set the first image to the Featured Image (_thumbnail_id)','wp_all_import_plugin');?> </label>
|
56 |
</div>
|
57 |
<h4><?php _e('Other', 'wp_all_import_plugin'); ?></h4>
|
58 |
<div class="input">
|
59 |
+
<input type="hidden" name="<?php echo $section_slug; ?>create_draft" value="no" />
|
60 |
+
<input type="checkbox" id="<?php echo $section_slug; ?>create_draft" name="<?php echo $section_slug; ?>create_draft" value="yes" <?php echo 'yes' == $post[$section_slug . 'create_draft'] ? 'checked="checked"' : '' ?> class="fix_checkbox"/>
|
61 |
+
<label for="<?php echo $section_slug; ?>create_draft"><?php _e('If no images are downloaded successfully, create entry as Draft.', 'wp_all_import_plugin') ?></label>
|
62 |
+
</div>
|
63 |
+
<?php endif; ?>
|
64 |
</td>
|
65 |
</tr>
|
66 |
</table>
|
79 |
<td colspan="3">
|
80 |
<h4><?php _e('Meta Data', 'wp_all_import_plugin'); ?></h4>
|
81 |
<div class="input">
|
82 |
+
<input type="hidden" name="<?php echo $section_slug; ?>set_image_meta_title" value="0" />
|
83 |
+
<input type="checkbox" id="<?php echo $section_slug; ?>set_image_meta_title" name="<?php echo $section_slug; ?>set_image_meta_title" value="1" <?php echo $post[$section_slug . 'set_image_meta_title'] ? 'checked="checked"' : '' ?> class="switcher fix_checkbox"/>
|
84 |
+
<label for="<?php echo $section_slug; ?>set_image_meta_title"><?php _e('Set Title(s)','wp_all_import_plugin');?></label>
|
85 |
+
<div class="switcher-target-<?php echo $section_slug; ?>set_image_meta_title" style="padding-left:23px;">
|
86 |
+
<label for="<?php echo $section_slug; ?>image_meta_title_delim"><?php _e('Enter one per line, or separate them with a ', 'wp_all_import_plugin');?></label>
|
87 |
+
<input type="text" class="small" id="<?php echo $section_slug; ?>image_meta_title_delim" name="<?php echo $section_slug; ?>image_meta_title_delim" value="<?php echo esc_attr($post[$section_slug . 'image_meta_title_delim']) ?>" style="width:5%; text-align:center;"/>
|
88 |
<p style="margin-bottom:5px;"><?php _e('The first title will be linked to the first image, the second title will be linked to the second image, ...', 'wp_all_import_plugin');?></p>
|
89 |
+
<textarea name="<?php echo $section_slug; ?>image_meta_title" class="newline rad4"><?php echo esc_attr($post[$section_slug . 'image_meta_title']) ?></textarea>
|
90 |
</div>
|
91 |
</div>
|
92 |
<div class="input">
|
93 |
+
<input type="hidden" name="<?php echo $section_slug; ?>set_image_meta_caption" value="0" />
|
94 |
+
<input type="checkbox" id="<?php echo $section_slug; ?>set_image_meta_caption" name="<?php echo $section_slug; ?>set_image_meta_caption" value="1" <?php echo $post[$section_slug . 'set_image_meta_caption'] ? 'checked="checked"' : '' ?> class="switcher fix_checkbox"/>
|
95 |
+
<label for="<?php echo $section_slug; ?>set_image_meta_caption"><?php _e('Set Caption(s)','wp_all_import_plugin');?></label>
|
96 |
+
<div class="switcher-target-<?php echo $section_slug; ?>set_image_meta_caption" style="padding-left:23px;">
|
97 |
+
<label for="<?php echo $section_slug; ?>image_meta_caption_delim"><?php _e('Enter one per line, or separate them with a ', 'wp_all_import_plugin');?></label>
|
98 |
+
<input type="text" class="small" id="<?php echo $section_slug; ?>image_meta_caption_delim" name="<?php echo $section_slug; ?>image_meta_caption_delim" value="<?php echo esc_attr($post[$section_slug . 'image_meta_caption_delim']) ?>" style="width:5%; text-align:center;"/>
|
99 |
<p style="margin-bottom:5px;"><?php _e('The first caption will be linked to the first image, the second caption will be linked to the second image, ...', 'wp_all_import_plugin');?></p>
|
100 |
+
<textarea name="<?php echo $section_slug; ?>image_meta_caption" class="newline rad4"><?php echo esc_attr($post[$section_slug . 'image_meta_caption']) ?></textarea>
|
101 |
</div>
|
102 |
</div>
|
103 |
<div class="input">
|
104 |
+
<input type="hidden" name="<?php echo $section_slug; ?>set_image_meta_alt" value="0" />
|
105 |
+
<input type="checkbox" id="<?php echo $section_slug; ?>set_image_meta_alt" name="<?php echo $section_slug; ?>set_image_meta_alt" value="1" <?php echo $post[$section_slug . 'set_image_meta_alt'] ? 'checked="checked"' : '' ?> class="switcher fix_checkbox"/>
|
106 |
+
<label for="<?php echo $section_slug; ?>set_image_meta_alt"><?php _e('Set Alt Text(s)','wp_all_import_plugin');?></label>
|
107 |
+
<div class="switcher-target-<?php echo $section_slug; ?>set_image_meta_alt" style="padding-left:23px;">
|
108 |
+
<label for="<?php echo $section_slug; ?>image_meta_alt_delim"><?php _e('Enter one per line, or separate them with a ', 'wp_all_import_plugin');?></label>
|
109 |
+
<input type="text" class="small" id="<?php echo $section_slug; ?>image_meta_alt_delim" name="<?php echo $section_slug; ?>image_meta_alt_delim" value="<?php echo esc_attr($post[$section_slug . 'image_meta_alt_delim']) ?>" style="width:5%; text-align:center;"/>
|
110 |
<p style="margin-bottom:5px;"><?php _e('The first alt text will be linked to the first image, the second alt text will be linked to the second image, ...', 'wp_all_import_plugin');?></p>
|
111 |
+
<textarea name="<?php echo $section_slug; ?>image_meta_alt" class="newline rad4"><?php echo esc_attr($post[$section_slug . 'image_meta_alt']) ?></textarea>
|
112 |
</div>
|
113 |
</div>
|
114 |
<div class="input">
|
115 |
+
<input type="hidden" name="<?php echo $section_slug; ?>set_image_meta_description" value="0" />
|
116 |
+
<input type="checkbox" id="<?php echo $section_slug; ?>set_image_meta_description" name="<?php echo $section_slug; ?>set_image_meta_description" value="1" <?php echo $post[$section_slug . 'set_image_meta_description'] ? 'checked="checked"' : '' ?> class="switcher fix_checkbox"/>
|
117 |
+
<label for="<?php echo $section_slug; ?>set_image_meta_description"><?php _e('Set Description(s)','wp_all_import_plugin');?></label>
|
118 |
+
<div class="switcher-target-<?php echo $section_slug; ?>set_image_meta_description" style="padding-left:23px;">
|
119 |
+
<label for="<?php echo $section_slug; ?>image_meta_description_delim"><?php _e('Enter one per line, or separate them with a ', 'wp_all_import_plugin');?></label>
|
120 |
+
<input type="text" class="small" id="<?php echo $section_slug; ?>image_meta_description_delim" name="<?php echo $section_slug; ?>image_meta_description_delim" value="<?php echo esc_attr($post[$section_slug . 'image_meta_description_delim']) ?>" style="width:5%; text-align:center;"/>
|
121 |
<p style="margin-bottom:5px;"><?php _e('The first description will be linked to the first image, the second description will be linked to the second image, ...', 'wp_all_import_plugin');?></p>
|
122 |
+
<textarea name="<?php echo $section_slug; ?>image_meta_description" class="newline rad4"><?php echo esc_attr($post[$section_slug . 'image_meta_description']) ?></textarea>
|
123 |
</div>
|
124 |
+
</div>
|
|
|
125 |
<h4><?php _e('Files', 'wp_all_import_plugin'); ?></h4>
|
126 |
<div id="advanced_options_files">
|
127 |
<p style="font-style:italic; display:none;"><?php _e('These options only available if Download image(s) hosted elsewhere is selected above.', 'wp_all_import_plugin'); ?></p>
|
128 |
<div class="input" style="margin:3px 0px;">
|
129 |
+
<input type="hidden" name="<?php echo $section_slug; ?>auto_rename_images" value="0" />
|
130 |
+
<input type="checkbox" id="<?php echo $section_slug; ?>auto_rename_images" name="<?php echo $section_slug; ?>auto_rename_images" value="1" <?php echo $post[$section_slug . 'auto_rename_images'] ? 'checked="checked"' : '' ?> class="switcher fix_checkbox"/>
|
131 |
+
<label for="<?php echo $section_slug; ?>auto_rename_images"><?php _e('Change image file names to','wp_all_import_plugin');?> </label>
|
132 |
+
<div class="input switcher-target-<?php echo $section_slug; ?>auto_rename_images" style="padding-left:23px;">
|
133 |
+
<input type="text" id="<?php echo $section_slug; ?>auto_rename_images_suffix" name="<?php echo $section_slug; ?>auto_rename_images_suffix" value="<?php echo esc_attr($post[$section_slug . 'auto_rename_images_suffix']) ?>" style="width:480px;"/>
|
134 |
<p class="note"><?php _e('Multiple image will have numbers appended, i.e. image-name-1.jpg, image-name-2.jpg '); ?></p>
|
135 |
</div>
|
136 |
</div>
|
137 |
<div class="input" style="margin:3px 0px;">
|
138 |
+
<input type="hidden" name="<?php echo $section_slug; ?>auto_set_extension" value="0" />
|
139 |
+
<input type="checkbox" id="<?php echo $section_slug; ?>auto_set_extension" name="<?php echo $section_slug; ?>auto_set_extension" value="1" <?php echo $post[$section_slug . 'auto_set_extension'] ? 'checked="checked"' : '' ?> class="switcher fix_checkbox"/>
|
140 |
+
<label for="<?php echo $section_slug; ?>auto_set_extension"><?php _e('Change image file extensions','wp_all_import_plugin');?> </label>
|
141 |
+
<div class="input switcher-target-<?php echo $section_slug; ?>auto_set_extension" style="padding-left:23px;">
|
142 |
+
<input type="text" id="<?php echo $section_slug; ?>new_extension" name="<?php echo $section_slug; ?>new_extension" value="<?php echo esc_attr($post[$section_slug . 'new_extension']) ?>" placeholder="jpg" style="width:480px;"/>
|
143 |
</div>
|
144 |
</div>
|
145 |
+
</div>
|
146 |
</td>
|
147 |
</tr>
|
148 |
</table>
|
152 |
</div>
|
153 |
</div>
|
154 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
</div>
|