Version Description
- Update WP All Import add-on API
Download this release
Release Info
Developer | WPAllImport |
Plugin | Import Settings into WordPress SEO by Yoast |
Version | 1.0.2 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.0.2
- rapid-addon.php +259 -207
- readme.txt +5 -2
- yoast-addon.php +1 -1
rapid-addon.php
CHANGED
@@ -11,8 +11,10 @@ if (!class_exists('RapidAddon')) {
|
|
11 |
public $accordions = array();
|
12 |
public $image_sections = array();
|
13 |
public $import_function;
|
|
|
14 |
public $notice_text;
|
15 |
public $logger = null;
|
|
|
16 |
public $image_options = array(
|
17 |
'download_images' => 'yes',
|
18 |
'download_featured_delim' => ',',
|
@@ -51,11 +53,15 @@ if (!class_exists('RapidAddon')) {
|
|
51 |
$this->import_function = $name;
|
52 |
}
|
53 |
|
|
|
|
|
|
|
|
|
54 |
function is_active_addon($post_type = null) {
|
55 |
|
56 |
$addon_active = false;
|
57 |
|
58 |
-
if ($post_type
|
59 |
if (@in_array($post_type, $this->active_post_types) or empty($this->active_post_types)) {
|
60 |
$addon_active = true;
|
61 |
}
|
@@ -64,9 +70,18 @@ if (!class_exists('RapidAddon')) {
|
|
64 |
if ($addon_active){
|
65 |
|
66 |
$current_theme = wp_get_theme();
|
|
|
|
|
|
|
67 |
$theme_name = $current_theme->get('Name');
|
68 |
|
69 |
$addon_active = (@in_array($theme_name, $this->active_themes) or empty($this->active_themes)) ? true : false;
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
if ( $addon_active and ! empty($this->active_plugins) ){
|
72 |
|
@@ -109,10 +124,11 @@ if (!class_exists('RapidAddon')) {
|
|
109 |
add_filter('pmxi_addons', array($this, 'wpai_api_register'));
|
110 |
add_filter('wp_all_import_addon_parse', array($this, 'wpai_api_parse'));
|
111 |
add_filter('wp_all_import_addon_import', array($this, 'wpai_api_import'));
|
|
|
112 |
add_filter('pmxi_options_options', array($this, 'wpai_api_options'));
|
113 |
add_filter('wp_all_import_image_sections', array($this, 'additional_sections'), 10, 1);
|
114 |
-
add_action('pmxi_extend_options_featured', array($this, 'wpai_api_metabox'), 10,
|
115 |
-
add_action('admin_init', array($this, 'admin_notice_ignore'));
|
116 |
|
117 |
}
|
118 |
|
@@ -171,8 +187,16 @@ if (!class_exists('RapidAddon')) {
|
|
171 |
$options_list = array();
|
172 |
|
173 |
foreach ($this->fields as $field_slug => $field_params) {
|
174 |
-
$
|
175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
|
177 |
if ( ! empty($this->options) ){
|
178 |
foreach ($this->options as $slug => $value) {
|
@@ -180,7 +204,8 @@ if (!class_exists('RapidAddon')) {
|
|
180 |
}
|
181 |
}
|
182 |
|
183 |
-
$options_arr[$this->slug]
|
|
|
184 |
|
185 |
return $options_arr;
|
186 |
|
@@ -213,6 +238,11 @@ if (!class_exists('RapidAddon')) {
|
|
213 |
|
214 |
}
|
215 |
|
|
|
|
|
|
|
|
|
|
|
216 |
|
217 |
function wpai_api_import($functions) {
|
218 |
|
@@ -221,7 +251,12 @@ if (!class_exists('RapidAddon')) {
|
|
221 |
|
222 |
}
|
223 |
|
|
|
224 |
|
|
|
|
|
|
|
|
|
225 |
|
226 |
function import($importData, $parsedData) {
|
227 |
|
@@ -244,28 +279,49 @@ if (!class_exists('RapidAddon')) {
|
|
244 |
|
245 |
foreach ($this->fields as $field_slug => $field_params) {
|
246 |
|
247 |
-
if ($field_params['type']
|
248 |
|
249 |
-
|
250 |
|
251 |
-
|
|
|
|
|
252 |
|
253 |
-
|
254 |
|
255 |
-
|
256 |
|
257 |
-
|
258 |
-
"attachment_id" => $uploaded_image,
|
259 |
-
"image_url_or_path" => $image_url_or_path,
|
260 |
-
"download" => $download
|
261 |
-
);
|
262 |
|
263 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
264 |
|
265 |
-
|
266 |
-
$data[$field_slug] = $parsedData[$field_slug][$index];
|
267 |
|
268 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
|
270 |
// apply mapping rules if they exist
|
271 |
if ($import_options['mapping'][$field_slug]) {
|
@@ -285,13 +341,13 @@ if (!class_exists('RapidAddon')) {
|
|
285 |
|
286 |
}
|
287 |
|
288 |
-
call_user_func($this->import_function, $post_id, $data, $importData['import']);
|
289 |
}
|
290 |
|
291 |
}
|
292 |
|
293 |
|
294 |
-
function wpai_api_metabox($post_type) {
|
295 |
|
296 |
if (!$this->is_active_addon($post_type)) {
|
297 |
return;
|
@@ -299,8 +355,6 @@ if (!class_exists('RapidAddon')) {
|
|
299 |
|
300 |
echo $this->helper_metabox_top($this->name);
|
301 |
|
302 |
-
$current_values = $this->helper_current_field_values();
|
303 |
-
|
304 |
$visible_fields = 0;
|
305 |
|
306 |
foreach ($this->fields as $field_slug => $field_params) {
|
@@ -326,13 +380,16 @@ if (!class_exists('RapidAddon')) {
|
|
326 |
echo $this->helper_metabox_bottom();
|
327 |
|
328 |
if ( ! empty($this->image_sections) ){
|
329 |
-
|
330 |
-
foreach ($this->image_sections as $section) {
|
331 |
$section_options = array();
|
332 |
foreach ($this->image_options as $slug => $value) {
|
333 |
$section_options[$section['slug'] . $slug] = $value;
|
334 |
}
|
335 |
-
|
|
|
|
|
|
|
336 |
}
|
337 |
}
|
338 |
|
@@ -364,10 +421,10 @@ if (!class_exists('RapidAddon')) {
|
|
364 |
)
|
365 |
);
|
366 |
|
367 |
-
} else if ($field_params['type'] == 'image') {
|
368 |
|
369 |
PMXI_API::add_field(
|
370 |
-
'
|
371 |
$field_params['name'],
|
372 |
array(
|
373 |
'tooltip' => $field_params['tooltip'],
|
@@ -414,185 +471,145 @@ if (!class_exists('RapidAddon')) {
|
|
414 |
)
|
415 |
);
|
416 |
|
417 |
-
}
|
|
|
|
|
|
|
418 |
|
|
|
419 |
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
* Helper function for nested radio fields
|
424 |
-
*
|
425 |
-
*/
|
426 |
-
function get_sub_fields($field_params, $field_slug, $current_values){
|
427 |
-
$sub_fields = array();
|
428 |
-
if ( ! empty($field_params['enum_values']) ){
|
429 |
-
foreach ($field_params['enum_values'] as $key => $value) {
|
430 |
-
$sub_fields[$key] = array();
|
431 |
-
if (is_array($value)){
|
432 |
-
if ($field_params['type'] == 'accordion'){
|
433 |
-
$sub_fields[$key][] = $this->convert_field($value, $current_values);
|
434 |
-
}
|
435 |
-
else
|
436 |
-
{
|
437 |
-
foreach ($value as $k => $sub_field) {
|
438 |
-
if (is_array($sub_field) and ! empty($this->fields[$sub_field['slug']]))
|
439 |
-
{
|
440 |
-
$sub_fields[$key][] = $this->convert_field($sub_field, $current_values);
|
441 |
-
}
|
442 |
-
}
|
443 |
-
}
|
444 |
-
}
|
445 |
-
}
|
446 |
-
}
|
447 |
-
return $sub_fields;
|
448 |
-
}
|
449 |
|
450 |
-
function convert_field($sub_field, $current_values){
|
451 |
-
$field = array();
|
452 |
-
switch ($this->fields[$sub_field['slug']]['type']) {
|
453 |
-
case 'text':
|
454 |
-
$field = array(
|
455 |
-
'type' => 'simple',
|
456 |
-
'label' => $this->fields[$sub_field['slug']]['name'],
|
457 |
-
'params' => array(
|
458 |
-
'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
|
459 |
-
'field_name' => $this->slug."[".$sub_field['slug']."]",
|
460 |
-
'field_value' => $current_values[$this->slug][$sub_field['slug']],
|
461 |
-
'is_main_field' => $sub_field['is_main_field']
|
462 |
-
)
|
463 |
-
);
|
464 |
-
break;
|
465 |
-
case 'textarea':
|
466 |
-
$field = array(
|
467 |
-
'type' => 'textarea',
|
468 |
-
'label' => $this->fields[$sub_field['slug']]['name'],
|
469 |
-
'params' => array(
|
470 |
-
'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
|
471 |
-
'field_name' => $this->slug."[".$sub_field['slug']."]",
|
472 |
-
'field_value' => $current_values[$this->slug][$sub_field['slug']],
|
473 |
-
'is_main_field' => $sub_field['is_main_field']
|
474 |
-
)
|
475 |
-
);
|
476 |
-
break;
|
477 |
-
case 'image':
|
478 |
-
$field = array(
|
479 |
-
'type' => 'image',
|
480 |
-
'label' => $this->fields[$sub_field['slug']]['name'],
|
481 |
-
'params' => array(
|
482 |
-
'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
|
483 |
-
'field_name' => $this->slug."[".$sub_field['slug']."]",
|
484 |
-
'field_value' => $current_values[$this->slug][$sub_field['slug']],
|
485 |
-
'download_image' => $current_values[$this->slug]['download_image'][$sub_field['slug']],
|
486 |
-
'field_key' => $sub_field['slug'],
|
487 |
-
'addon_prefix' => $this->slug,
|
488 |
-
'is_main_field' => $sub_field['is_main_field']
|
489 |
-
)
|
490 |
-
);
|
491 |
-
break;
|
492 |
-
case 'radio':
|
493 |
-
$field = array(
|
494 |
-
'type' => 'enum',
|
495 |
-
'label' => $this->fields[$sub_field['slug']]['name'],
|
496 |
-
'params' => array(
|
497 |
-
'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
|
498 |
-
'field_name' => $this->slug."[".$sub_field['slug']."]",
|
499 |
-
'field_value' => $current_values[$this->slug][$sub_field['slug']],
|
500 |
-
'enum_values' => $this->fields[$sub_field['slug']]['enum_values'],
|
501 |
-
'mapping' => true,
|
502 |
-
'field_key' => $sub_field['slug'],
|
503 |
-
'mapping_rules' => $current_values[$this->slug]['mapping'][$sub_field['slug']],
|
504 |
-
'xpath' => $current_values[$this->slug]['xpaths'][$sub_field['slug']],
|
505 |
-
'addon_prefix' => $this->slug,
|
506 |
-
'sub_fields' => $this->get_sub_fields($this->fields[$sub_field['slug']], $sub_field['slug'], $current_values),
|
507 |
-
'is_main_field' => $sub_field['is_main_field']
|
508 |
-
)
|
509 |
-
);
|
510 |
-
break;
|
511 |
-
case 'accordion':
|
512 |
-
$field = array(
|
513 |
-
'type' => 'accordion',
|
514 |
-
'label' => $this->fields[$sub_field['slug']]['name'],
|
515 |
-
'params' => array(
|
516 |
-
'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
|
517 |
-
'field_name' => $this->slug."[".$sub_field['slug']."]",
|
518 |
-
'field_key' => $sub_field['slug'],
|
519 |
-
'addon_prefix' => $this->slug,
|
520 |
-
'sub_fields' => $this->get_sub_fields($this->fields[$sub_field['slug']], $sub_field['slug'], $current_values),
|
521 |
-
'in_the_bottom' => false
|
522 |
-
)
|
523 |
-
);
|
524 |
-
break;
|
525 |
-
default:
|
526 |
-
# code...
|
527 |
-
break;
|
528 |
-
}
|
529 |
-
return $field;
|
530 |
}
|
531 |
|
532 |
-
|
533 |
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
)
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
551 |
}
|
552 |
}
|
553 |
}
|
554 |
-
|
555 |
-
$default = array($this->slug => $options);
|
556 |
-
|
557 |
-
}
|
558 |
-
|
559 |
-
$input = new PMXI_Input();
|
560 |
-
|
561 |
-
$id = $input->get('id');
|
562 |
-
|
563 |
-
$import = new PMXI_Import_Record();
|
564 |
-
if ( ! $id or $import->getById($id)->isEmpty()) { // specified import is not found
|
565 |
-
$post = $input->post(
|
566 |
-
$default
|
567 |
-
);
|
568 |
}
|
569 |
-
|
570 |
-
|
571 |
-
$import->options
|
572 |
-
+ $default
|
573 |
-
);
|
574 |
-
}
|
575 |
-
|
576 |
-
$is_loaded_template = (!empty(PMXI_Plugin::$session->is_loaded_template)) ? PMXI_Plugin::$session->is_loaded_template : false;
|
577 |
-
|
578 |
-
$load_options = $input->post('load_template');
|
579 |
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
$
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
591 |
}
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
}
|
596 |
|
597 |
/**
|
598 |
*
|
@@ -616,7 +633,23 @@ if (!class_exists('RapidAddon')) {
|
|
616 |
|
617 |
}
|
618 |
|
619 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
620 |
|
621 |
function helper_metabox_top($name) {
|
622 |
|
@@ -646,7 +679,8 @@ if (!class_exists('RapidAddon')) {
|
|
646 |
}
|
647 |
|
648 |
.wpallimport-plugin .wpallimport-addon .wpallimport-sub-options {
|
649 |
-
margin-bottom: 15px;
|
|
|
650 |
}
|
651 |
.wpallimport-plugin .wpallimport-addon .wpallimport-sub-options .wpallimport-content-section{
|
652 |
padding-bottom: 8px;
|
@@ -690,6 +724,20 @@ if (!class_exists('RapidAddon')) {
|
|
690 |
border: 1px solid #ddd;
|
691 |
border-top: none;
|
692 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
693 |
</style>
|
694 |
<div class="wpallimport-collapsed wpallimport-section wpallimport-addon '.$this->slug.' closed">
|
695 |
<div class="wpallimport-content-section">
|
@@ -813,10 +861,10 @@ if (!class_exists('RapidAddon')) {
|
|
813 |
|
814 |
$cxpath = $xpath_prefix . $import->xpath;
|
815 |
|
816 |
-
|
817 |
-
|
818 |
-
if ( ! empty($import->options[$this->slug][$option_name]) ) {
|
819 |
|
|
|
|
|
820 |
if ($import->options[$this->slug][$option_name] == "xpath") {
|
821 |
if ($import->options[$this->slug]['xpaths'][$option_name] == ""){
|
822 |
$count and $this->data[$option_name] = array_fill(0, $count, "");
|
@@ -895,14 +943,14 @@ if (!class_exists('RapidAddon')) {
|
|
895 |
$notice_text = $this->name.' requires WP All Import <a href="http://www.wpallimport.com/" target="_blank">Pro</a> or <a href="http://wordpress.org/plugins/wp-all-import" target="_blank">Free</a>.';
|
896 |
}
|
897 |
|
898 |
-
if (!get_option($this->slug.'
|
899 |
|
900 |
?>
|
901 |
|
902 |
-
<div class="error">
|
903 |
<p><?php _e(
|
904 |
sprintf(
|
905 |
-
$notice_text
|
906 |
'?'.$this->slug.'_ignore=0'
|
907 |
),
|
908 |
'rapid_addon_'.$this->slug
|
@@ -934,11 +982,17 @@ if (!class_exists('RapidAddon')) {
|
|
934 |
if ( ! $is_show_notice and ! empty($conditions['themes']) ){
|
935 |
|
936 |
$themeInfo = wp_get_theme();
|
|
|
937 |
$currentTheme = $themeInfo->get('Name');
|
938 |
|
939 |
$is_show_notice = in_array($currentTheme, $conditions['themes']) ? false : true;
|
940 |
|
941 |
-
|
|
|
|
|
|
|
|
|
|
|
942 |
|
943 |
// Required Plugins
|
944 |
if ( ! $is_show_notice and ! empty($conditions['plugins']) ){
|
@@ -974,5 +1028,3 @@ if (!class_exists('RapidAddon')) {
|
|
974 |
|
975 |
}
|
976 |
|
977 |
-
|
978 |
-
|
11 |
public $accordions = array();
|
12 |
public $image_sections = array();
|
13 |
public $import_function;
|
14 |
+
public $post_saved_function;
|
15 |
public $notice_text;
|
16 |
public $logger = null;
|
17 |
+
public $when_to_run = false;
|
18 |
public $image_options = array(
|
19 |
'download_images' => 'yes',
|
20 |
'download_featured_delim' => ',',
|
53 |
$this->import_function = $name;
|
54 |
}
|
55 |
|
56 |
+
function set_post_saved_function($name) {
|
57 |
+
$this->post_saved_function = $name;
|
58 |
+
}
|
59 |
+
|
60 |
function is_active_addon($post_type = null) {
|
61 |
|
62 |
$addon_active = false;
|
63 |
|
64 |
+
if ($post_type !== null) {
|
65 |
if (@in_array($post_type, $this->active_post_types) or empty($this->active_post_types)) {
|
66 |
$addon_active = true;
|
67 |
}
|
70 |
if ($addon_active){
|
71 |
|
72 |
$current_theme = wp_get_theme();
|
73 |
+
|
74 |
+
$parent_theme = $current_theme->parent();
|
75 |
+
|
76 |
$theme_name = $current_theme->get('Name');
|
77 |
|
78 |
$addon_active = (@in_array($theme_name, $this->active_themes) or empty($this->active_themes)) ? true : false;
|
79 |
+
|
80 |
+
if ( ! $addon_active and $parent_theme ){
|
81 |
+
$parent_theme_name = $parent_theme->get('Name');
|
82 |
+
$addon_active = (@in_array($parent_theme_name, $this->active_themes) or empty($this->active_themes)) ? true : false;
|
83 |
+
|
84 |
+
}
|
85 |
|
86 |
if ( $addon_active and ! empty($this->active_plugins) ){
|
87 |
|
124 |
add_filter('pmxi_addons', array($this, 'wpai_api_register'));
|
125 |
add_filter('wp_all_import_addon_parse', array($this, 'wpai_api_parse'));
|
126 |
add_filter('wp_all_import_addon_import', array($this, 'wpai_api_import'));
|
127 |
+
add_filter('wp_all_import_addon_saved_post', array($this, 'wpai_api_post_saved'));
|
128 |
add_filter('pmxi_options_options', array($this, 'wpai_api_options'));
|
129 |
add_filter('wp_all_import_image_sections', array($this, 'additional_sections'), 10, 1);
|
130 |
+
add_action('pmxi_extend_options_featured', array($this, 'wpai_api_metabox'), 10, 2);
|
131 |
+
add_action('admin_init', array($this, 'admin_notice_ignore'));
|
132 |
|
133 |
}
|
134 |
|
187 |
$options_list = array();
|
188 |
|
189 |
foreach ($this->fields as $field_slug => $field_params) {
|
190 |
+
if (in_array($field_params['type'], array('title', 'plain_text'))) continue;
|
191 |
+
$default_value = '';
|
192 |
+
if (!empty($field_params['enum_values'])){
|
193 |
+
foreach ($field_params['enum_values'] as $key => $value) {
|
194 |
+
$default_value = $key;
|
195 |
+
break;
|
196 |
+
}
|
197 |
+
}
|
198 |
+
$options_list[$field_slug] = $default_value;
|
199 |
+
}
|
200 |
|
201 |
if ( ! empty($this->options) ){
|
202 |
foreach ($this->options as $slug => $value) {
|
204 |
}
|
205 |
}
|
206 |
|
207 |
+
$options_arr[$this->slug] = $options_list;
|
208 |
+
$options_arr['rapid_addon'] = plugin_basename( __FILE__ );
|
209 |
|
210 |
return $options_arr;
|
211 |
|
238 |
|
239 |
}
|
240 |
|
241 |
+
function wpai_api_post_saved($functions){
|
242 |
+
$functions[$this->slug] = array($this, 'post_saved');
|
243 |
+
return $functions;
|
244 |
+
}
|
245 |
+
|
246 |
|
247 |
function wpai_api_import($functions) {
|
248 |
|
251 |
|
252 |
}
|
253 |
|
254 |
+
function post_saved( $importData ){
|
255 |
|
256 |
+
if (is_callable($this->post_saved_function))
|
257 |
+
call_user_func($this->post_saved_function, $importData['pid'], $importData['import'], $importData['logger']);
|
258 |
+
|
259 |
+
}
|
260 |
|
261 |
function import($importData, $parsedData) {
|
262 |
|
279 |
|
280 |
foreach ($this->fields as $field_slug => $field_params) {
|
281 |
|
282 |
+
if (in_array($field_params['type'], array('title', 'plain_text'))) continue;
|
283 |
|
284 |
+
switch ($field_params['type']) {
|
285 |
|
286 |
+
case 'image':
|
287 |
+
|
288 |
+
// import the specified image, then set the value of the field to the image ID in the media library
|
289 |
|
290 |
+
$image_url_or_path = $parsedData[$field_slug][$index];
|
291 |
|
292 |
+
$download = $import_options['download_image'][$field_slug];
|
293 |
|
294 |
+
$uploaded_image = PMXI_API::upload_image($post_id, $image_url_or_path, $download, $importData['logger'], true);
|
|
|
|
|
|
|
|
|
295 |
|
296 |
+
$data[$field_slug] = array(
|
297 |
+
"attachment_id" => $uploaded_image,
|
298 |
+
"image_url_or_path" => $image_url_or_path,
|
299 |
+
"download" => $download
|
300 |
+
);
|
301 |
+
|
302 |
+
break;
|
303 |
|
304 |
+
case 'file':
|
|
|
305 |
|
306 |
+
$image_url_or_path = $parsedData[$field_slug][$index];
|
307 |
+
|
308 |
+
$download = $import_options['download_image'][$field_slug];
|
309 |
+
|
310 |
+
$uploaded_file = PMXI_API::upload_image($post_id, $image_url_or_path, $download, $importData['logger'], true, "", "files");
|
311 |
+
|
312 |
+
$data[$field_slug] = array(
|
313 |
+
"attachment_id" => $uploaded_file,
|
314 |
+
"image_url_or_path" => $image_url_or_path,
|
315 |
+
"download" => $download
|
316 |
+
);
|
317 |
+
|
318 |
+
break;
|
319 |
+
|
320 |
+
default:
|
321 |
+
// set the field data to the value of the field after it's been parsed
|
322 |
+
$data[$field_slug] = $parsedData[$field_slug][$index];
|
323 |
+
break;
|
324 |
+
}
|
325 |
|
326 |
// apply mapping rules if they exist
|
327 |
if ($import_options['mapping'][$field_slug]) {
|
341 |
|
342 |
}
|
343 |
|
344 |
+
call_user_func($this->import_function, $post_id, $data, $importData['import'], $importData['articleData'], $importData['logger']);
|
345 |
}
|
346 |
|
347 |
}
|
348 |
|
349 |
|
350 |
+
function wpai_api_metabox($post_type, $current_values) {
|
351 |
|
352 |
if (!$this->is_active_addon($post_type)) {
|
353 |
return;
|
355 |
|
356 |
echo $this->helper_metabox_top($this->name);
|
357 |
|
|
|
|
|
358 |
$visible_fields = 0;
|
359 |
|
360 |
foreach ($this->fields as $field_slug => $field_params) {
|
380 |
echo $this->helper_metabox_bottom();
|
381 |
|
382 |
if ( ! empty($this->image_sections) ){
|
383 |
+
$is_images_section_enabled = apply_filters('wp_all_import_is_images_section_enabled', true, $post_type);
|
384 |
+
foreach ($this->image_sections as $k => $section) {
|
385 |
$section_options = array();
|
386 |
foreach ($this->image_options as $slug => $value) {
|
387 |
$section_options[$section['slug'] . $slug] = $value;
|
388 |
}
|
389 |
+
if ( ! $is_images_section_enabled and ! $k ){
|
390 |
+
$section_options[$section['slug'] . 'is_featured'] = 1;
|
391 |
+
}
|
392 |
+
PMXI_API::add_additional_images_section($section['title'], $section['slug'], $current_values, '', true, false, $section['type']);
|
393 |
}
|
394 |
}
|
395 |
|
421 |
)
|
422 |
);
|
423 |
|
424 |
+
} else if ($field_params['type'] == 'image' or $field_params['type'] == 'file') {
|
425 |
|
426 |
PMXI_API::add_field(
|
427 |
+
$field_params['type'],
|
428 |
$field_params['name'],
|
429 |
array(
|
430 |
'tooltip' => $field_params['tooltip'],
|
471 |
)
|
472 |
);
|
473 |
|
474 |
+
} else if($field_params['type'] == 'title'){
|
475 |
+
?>
|
476 |
+
<h4 class="wpallimport-add-on-options-title"><?php _e($field_params['name'], 'wp_all_import_plugin'); ?><?php if ( ! empty($field_params['tooltip'])): ?><a href="#help" class="wpallimport-help" title="<?php echo $field_params['tooltip']; ?>" style="position:relative; top: -1px;">?</a><?php endif; ?></h4>
|
477 |
+
<?php
|
478 |
|
479 |
+
} else if($field_params['type'] == 'plain_text'){
|
480 |
|
481 |
+
?>
|
482 |
+
<p style="margin: 0 0 12px 0;"><?php echo $field_params['name'];?></p>
|
483 |
+
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
484 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
485 |
}
|
486 |
|
|
|
487 |
|
488 |
+
}
|
489 |
+
/**
|
490 |
+
*
|
491 |
+
* Helper function for nested radio fields
|
492 |
+
*
|
493 |
+
*/
|
494 |
+
function get_sub_fields($field_params, $field_slug, $current_values){
|
495 |
+
$sub_fields = array();
|
496 |
+
if ( ! empty($field_params['enum_values']) ){
|
497 |
+
foreach ($field_params['enum_values'] as $key => $value) {
|
498 |
+
$sub_fields[$key] = array();
|
499 |
+
if (is_array($value)){
|
500 |
+
if ($field_params['type'] == 'accordion'){
|
501 |
+
$sub_fields[$key][] = $this->convert_field($value, $current_values);
|
502 |
+
}
|
503 |
+
else
|
504 |
+
{
|
505 |
+
foreach ($value as $k => $sub_field) {
|
506 |
+
if (is_array($sub_field) and ! empty($this->fields[$sub_field['slug']]))
|
507 |
+
{
|
508 |
+
$sub_fields[$key][] = $this->convert_field($sub_field, $current_values);
|
509 |
+
}
|
510 |
+
}
|
511 |
}
|
512 |
}
|
513 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
514 |
}
|
515 |
+
return $sub_fields;
|
516 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
517 |
|
518 |
+
function convert_field($sub_field, $current_values){
|
519 |
+
$field = array();
|
520 |
+
switch ($this->fields[$sub_field['slug']]['type']) {
|
521 |
+
case 'text':
|
522 |
+
$field = array(
|
523 |
+
'type' => 'simple',
|
524 |
+
'label' => $this->fields[$sub_field['slug']]['name'],
|
525 |
+
'params' => array(
|
526 |
+
'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
|
527 |
+
'field_name' => $this->slug."[".$sub_field['slug']."]",
|
528 |
+
'field_value' => $current_values[$this->slug][$sub_field['slug']],
|
529 |
+
'is_main_field' => $sub_field['is_main_field']
|
530 |
+
)
|
531 |
+
);
|
532 |
+
break;
|
533 |
+
case 'textarea':
|
534 |
+
$field = array(
|
535 |
+
'type' => 'textarea',
|
536 |
+
'label' => $this->fields[$sub_field['slug']]['name'],
|
537 |
+
'params' => array(
|
538 |
+
'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
|
539 |
+
'field_name' => $this->slug."[".$sub_field['slug']."]",
|
540 |
+
'field_value' => $current_values[$this->slug][$sub_field['slug']],
|
541 |
+
'is_main_field' => $sub_field['is_main_field']
|
542 |
+
)
|
543 |
+
);
|
544 |
+
break;
|
545 |
+
case 'image':
|
546 |
+
$field = array(
|
547 |
+
'type' => 'image',
|
548 |
+
'label' => $this->fields[$sub_field['slug']]['name'],
|
549 |
+
'params' => array(
|
550 |
+
'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
|
551 |
+
'field_name' => $this->slug."[".$sub_field['slug']."]",
|
552 |
+
'field_value' => $current_values[$this->slug][$sub_field['slug']],
|
553 |
+
'download_image' => $current_values[$this->slug]['download_image'][$sub_field['slug']],
|
554 |
+
'field_key' => $sub_field['slug'],
|
555 |
+
'addon_prefix' => $this->slug,
|
556 |
+
'is_main_field' => $sub_field['is_main_field']
|
557 |
+
)
|
558 |
+
);
|
559 |
+
case 'file':
|
560 |
+
$field = array(
|
561 |
+
'type' => 'file',
|
562 |
+
'label' => $this->fields[$sub_field['slug']]['name'],
|
563 |
+
'params' => array(
|
564 |
+
'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
|
565 |
+
'field_name' => $this->slug."[".$sub_field['slug']."]",
|
566 |
+
'field_value' => $current_values[$this->slug][$sub_field['slug']],
|
567 |
+
'download_image' => $current_values[$this->slug]['download_image'][$sub_field['slug']],
|
568 |
+
'field_key' => $sub_field['slug'],
|
569 |
+
'addon_prefix' => $this->slug,
|
570 |
+
'is_main_field' => $sub_field['is_main_field']
|
571 |
+
)
|
572 |
+
);
|
573 |
+
break;
|
574 |
+
case 'radio':
|
575 |
+
$field = array(
|
576 |
+
'type' => 'enum',
|
577 |
+
'label' => $this->fields[$sub_field['slug']]['name'],
|
578 |
+
'params' => array(
|
579 |
+
'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
|
580 |
+
'field_name' => $this->slug."[".$sub_field['slug']."]",
|
581 |
+
'field_value' => $current_values[$this->slug][$sub_field['slug']],
|
582 |
+
'enum_values' => $this->fields[$sub_field['slug']]['enum_values'],
|
583 |
+
'mapping' => true,
|
584 |
+
'field_key' => $sub_field['slug'],
|
585 |
+
'mapping_rules' => $current_values[$this->slug]['mapping'][$sub_field['slug']],
|
586 |
+
'xpath' => $current_values[$this->slug]['xpaths'][$sub_field['slug']],
|
587 |
+
'addon_prefix' => $this->slug,
|
588 |
+
'sub_fields' => $this->get_sub_fields($this->fields[$sub_field['slug']], $sub_field['slug'], $current_values),
|
589 |
+
'is_main_field' => $sub_field['is_main_field']
|
590 |
+
)
|
591 |
+
);
|
592 |
+
break;
|
593 |
+
case 'accordion':
|
594 |
+
$field = array(
|
595 |
+
'type' => 'accordion',
|
596 |
+
'label' => $this->fields[$sub_field['slug']]['name'],
|
597 |
+
'params' => array(
|
598 |
+
'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
|
599 |
+
'field_name' => $this->slug."[".$sub_field['slug']."]",
|
600 |
+
'field_key' => $sub_field['slug'],
|
601 |
+
'addon_prefix' => $this->slug,
|
602 |
+
'sub_fields' => $this->get_sub_fields($this->fields[$sub_field['slug']], $sub_field['slug'], $current_values),
|
603 |
+
'in_the_bottom' => false
|
604 |
+
)
|
605 |
+
);
|
606 |
+
break;
|
607 |
+
default:
|
608 |
+
# code...
|
609 |
+
break;
|
610 |
}
|
611 |
+
return $field;
|
612 |
+
}
|
|
|
|
|
613 |
|
614 |
/**
|
615 |
*
|
633 |
|
634 |
}
|
635 |
|
636 |
+
}
|
637 |
+
|
638 |
+
function add_title($title = '', $tooltip = ''){
|
639 |
+
|
640 |
+
if (empty($title)) return;
|
641 |
+
|
642 |
+
return $this->add_field(sanitize_key($title) . time(), $title, 'title', null, $tooltip);
|
643 |
+
|
644 |
+
}
|
645 |
+
|
646 |
+
function add_text($text = ''){
|
647 |
+
|
648 |
+
if (empty($text)) return;
|
649 |
+
|
650 |
+
return $this->add_field(sanitize_key($text) . time(), $text, 'plain_text');
|
651 |
+
|
652 |
+
}
|
653 |
|
654 |
function helper_metabox_top($name) {
|
655 |
|
679 |
}
|
680 |
|
681 |
.wpallimport-plugin .wpallimport-addon .wpallimport-sub-options {
|
682 |
+
margin-bottom: 15px;
|
683 |
+
margin-top: -16px;
|
684 |
}
|
685 |
.wpallimport-plugin .wpallimport-addon .wpallimport-sub-options .wpallimport-content-section{
|
686 |
padding-bottom: 8px;
|
724 |
border: 1px solid #ddd;
|
725 |
border-top: none;
|
726 |
}
|
727 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-full-with-bottom{
|
728 |
+
margin-left: -25px;
|
729 |
+
margin-right: -25px;
|
730 |
+
}
|
731 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-full-with-not-bottom{
|
732 |
+
margin: 25px -1px 25px 1px;
|
733 |
+
}
|
734 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-full-with-not-bottom .wpallimport-content-section{
|
735 |
+
border: 1px solid #ddd;
|
736 |
+
}
|
737 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-add-on-options-title{
|
738 |
+
font-size: 14px;
|
739 |
+
margin: 45px 0 15px 0;
|
740 |
+
}
|
741 |
</style>
|
742 |
<div class="wpallimport-collapsed wpallimport-section wpallimport-addon '.$this->slug.' closed">
|
743 |
<div class="wpallimport-content-section">
|
861 |
|
862 |
$cxpath = $xpath_prefix . $import->xpath;
|
863 |
|
864 |
+
$tmp_files = array();
|
|
|
|
|
865 |
|
866 |
+
foreach ($options[$this->slug] as $option_name => $option_value) {
|
867 |
+
if ( isset($import->options[$this->slug][$option_name]) and $import->options[$this->slug][$option_name] != '') {
|
868 |
if ($import->options[$this->slug][$option_name] == "xpath") {
|
869 |
if ($import->options[$this->slug]['xpaths'][$option_name] == ""){
|
870 |
$count and $this->data[$option_name] = array_fill(0, $count, "");
|
943 |
$notice_text = $this->name.' requires WP All Import <a href="http://www.wpallimport.com/" target="_blank">Pro</a> or <a href="http://wordpress.org/plugins/wp-all-import" target="_blank">Free</a>.';
|
944 |
}
|
945 |
|
946 |
+
if (!get_option(sanitize_key($this->slug).'_notice_ignore')) {
|
947 |
|
948 |
?>
|
949 |
|
950 |
+
<div class="error notice is-dismissible wpallimport-dismissible" style="margin-top: 10px;" rel="<?php echo sanitize_key($this->slug); ?>">
|
951 |
<p><?php _e(
|
952 |
sprintf(
|
953 |
+
$notice_text,
|
954 |
'?'.$this->slug.'_ignore=0'
|
955 |
),
|
956 |
'rapid_addon_'.$this->slug
|
982 |
if ( ! $is_show_notice and ! empty($conditions['themes']) ){
|
983 |
|
984 |
$themeInfo = wp_get_theme();
|
985 |
+
$parentInfo = $themeInfo->parent();
|
986 |
$currentTheme = $themeInfo->get('Name');
|
987 |
|
988 |
$is_show_notice = in_array($currentTheme, $conditions['themes']) ? false : true;
|
989 |
|
990 |
+
if ( $is_show_notice and $parentInfo ){
|
991 |
+
$parent_theme = $parentInfo->get('Name');
|
992 |
+
$is_show_notice = in_array($parent_theme, $conditions['themes']) ? false : true;
|
993 |
+
}
|
994 |
+
|
995 |
+
}
|
996 |
|
997 |
// Required Plugins
|
998 |
if ( ! $is_show_notice and ! empty($conditions['plugins']) ){
|
1028 |
|
1029 |
}
|
1030 |
|
|
|
|
readme.txt
CHANGED
@@ -4,8 +4,8 @@ Tags: seo, import seo, search engine optimization, import search engine optimiza
|
|
4 |
License: GPLv2 or later
|
5 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
6 |
Requires at least: 4.1.0
|
7 |
-
Tested up to: 4.
|
8 |
-
Stable tag: 1.0.
|
9 |
|
10 |
Easily import SEO settings from any XML or CSV file to Yoast WordPress SEO with the Yoast WordPress SEO Add-On for WP All Import.
|
11 |
|
@@ -66,6 +66,9 @@ The Yoast WordPress SEO Add-On will appear in the Step 3 of WP All Import.
|
|
66 |
|
67 |
== Changelog ==
|
68 |
|
|
|
|
|
|
|
69 |
= 1.0.0 =
|
70 |
* Initial release on WP.org.
|
71 |
|
4 |
License: GPLv2 or later
|
5 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
6 |
Requires at least: 4.1.0
|
7 |
+
Tested up to: 4.3
|
8 |
+
Stable tag: 1.0.2
|
9 |
|
10 |
Easily import SEO settings from any XML or CSV file to Yoast WordPress SEO with the Yoast WordPress SEO Add-On for WP All Import.
|
11 |
|
66 |
|
67 |
== Changelog ==
|
68 |
|
69 |
+
= 1.0.2 =
|
70 |
+
* Update WP All Import add-on API
|
71 |
+
|
72 |
= 1.0.0 =
|
73 |
* Initial release on WP.org.
|
74 |
|
yoast-addon.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin Name: WP All Import - Yoast WordPress SEO Add-On
|
5 |
Plugin URI: http://www.wpallimport.com/
|
6 |
Description: Import data into Yoast WordPress SEO with WP All Import.
|
7 |
-
Version: 1.0.
|
8 |
Author: Soflyy
|
9 |
*/
|
10 |
|
4 |
Plugin Name: WP All Import - Yoast WordPress SEO Add-On
|
5 |
Plugin URI: http://www.wpallimport.com/
|
6 |
Description: Import data into Yoast WordPress SEO with WP All Import.
|
7 |
+
Version: 1.0.2
|
8 |
Author: Soflyy
|
9 |
*/
|
10 |
|