Import Settings into WordPress SEO by Yoast - Version 1.1.6

Version Description

  • Added ability to import SEO data in a Taxonomy import.
Download this release

Release Info

Developer WPAllImport
Plugin Icon 128x128 Import Settings into WordPress SEO by Yoast
Version 1.1.6
Comparing to
See all releases

Code changes from version 1.1.5 to 1.1.6

Files changed (4) hide show
  1. README.md +20 -20
  2. rapid-addon.php +95 -15
  3. readme.txt +4 -1
  4. yoast-addon.php +340 -177
README.md CHANGED
@@ -1,20 +1,20 @@
1
- #Yoast WordPress SEO Add-On
2
-
3
- ##Custom fields used by plugin:
4
-
5
- | Name | Custom Field | Values |
6
- | -------------------- | ------------------------------------ | ----------------------------------------------------------------------------- |
7
- | Focus Keyword | _yoast_wpseo_focuskw | Text string |
8
- | SEO Title | _yoast_wpseo_title | Text string |
9
- | Meta Description | _yoast_wpseo_metadesc | Text string |
10
- | Meta Robots Index | _yoast_wpseo_meta-robots-noindex | Blank for default, 1 for noindex, or 2 for index |
11
- | Meta Robots Follow | _yoast_wpseo_meta-robots-nofollow | Blank for follow, 1 for nofollow |
12
- | Meta Robots Advanced | _yoast_wpseo_meta-robots-adv | Blank for default, none, noodp, noydir, noimageindex, noarchive, or nosnippet |
13
- | Include in Sitemap | _yoast_wpseo_sitemap-include | Blank for auto, always, or never |
14
- | Sitemap Priority | _yoast_wpseo_sitemap-prio | Blank for auto, 1 to .1 |
15
- | Canonical URL | _yoast_wpseo_canonical | Canonical URL of post |
16
- | 301 Redirect | _yoast_wpseo_redirect | URL to redirect post to |
17
- | Facebook Title | _yoast_wpseo_opengraph-title | Text string |
18
- | Facebook Description | _yoast_wpseo_opengraph | Text string |
19
- | Facebook Image | _yoast_wpseo_opengraph-image | URL to image |
20
-
1
+ #Yoast WordPress SEO Add-On
2
+
3
+ ##Custom fields used by plugin:
4
+
5
+ | Name | Custom Field | Values |
6
+ | -------------------- | ------------------------------------ | ----------------------------------------------------------------------------- |
7
+ | Focus Keyword | _yoast_wpseo_focuskw | Text string |
8
+ | SEO Title | _yoast_wpseo_title | Text string |
9
+ | Meta Description | _yoast_wpseo_metadesc | Text string |
10
+ | Meta Robots Index | _yoast_wpseo_meta-robots-noindex | Blank for default, 1 for noindex, or 2 for index |
11
+ | Meta Robots Follow | _yoast_wpseo_meta-robots-nofollow | Blank for follow, 1 for nofollow |
12
+ | Meta Robots Advanced | _yoast_wpseo_meta-robots-adv | Blank for default, none, noodp, noydir, noimageindex, noarchive, or nosnippet |
13
+ | Include in Sitemap | _yoast_wpseo_sitemap-include | Blank for auto, always, or never |
14
+ | Sitemap Priority | _yoast_wpseo_sitemap-prio | Blank for auto, 1 to .1 |
15
+ | Canonical URL | _yoast_wpseo_canonical | Canonical URL of post |
16
+ | 301 Redirect | _yoast_wpseo_redirect | URL to redirect post to |
17
+ | Facebook Title | _yoast_wpseo_opengraph-title | Text string |
18
+ | Facebook Description | _yoast_wpseo_opengraph | Text string |
19
+ | Facebook Image | _yoast_wpseo_opengraph-image | URL to image |
20
+
rapid-addon.php CHANGED
@@ -1,4 +1,12 @@
1
  <?php
 
 
 
 
 
 
 
 
2
 
3
  if (!class_exists('RapidAddon')) {
4
 
@@ -44,13 +52,17 @@ if (!class_exists('RapidAddon')) {
44
  'auto_set_extension' => 0,
45
  'new_extension' => '',
46
  'do_not_remove_images' => 1,
47
- );
 
 
48
 
49
  function __construct($name, $slug) {
50
 
51
  $this->name = $name;
52
  $this->slug = $slug;
53
-
 
 
54
  }
55
 
56
  function set_import_function($name) {
@@ -150,9 +162,9 @@ if (!class_exists('RapidAddon')) {
150
  }
151
 
152
 
153
- function add_field($field_slug, $field_name, $field_type, $enum_values = null, $tooltip = "", $is_html = true) {
154
 
155
- $field = array("name" => $field_name, "type" => $field_type, "enum_values" => $enum_values, "tooltip" => $tooltip, "is_sub_field" => false, "is_main_field" => false, "slug" => $field_slug, "is_html" => $is_html);
156
 
157
  $this->fields[$field_slug] = $field;
158
 
@@ -180,6 +192,35 @@ if (!class_exists('RapidAddon')) {
180
 
181
  }
182
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  /**
184
  *
185
  * Add an option to WP All Import options list
@@ -197,7 +238,7 @@ if (!class_exists('RapidAddon')) {
197
  $options_list = array();
198
 
199
  foreach ($this->fields as $field_slug => $field_params) {
200
- if (in_array($field_params['type'], array('title', 'plain_text'))) continue;
201
  $default_value = '';
202
  if (!empty($field_params['enum_values'])){
203
  foreach ($field_params['enum_values'] as $key => $value) {
@@ -334,7 +375,7 @@ if (!class_exists('RapidAddon')) {
334
  }
335
 
336
  // apply mapping rules if they exist
337
- if ($import_options['mapping'][$field_slug]) {
338
  $mapping_rules = json_decode($import_options['mapping'][$field_slug], true);
339
 
340
  if (!empty($mapping_rules) and is_array($mapping_rules)) {
@@ -406,8 +447,10 @@ if (!class_exists('RapidAddon')) {
406
  }
407
 
408
  function render_field($field_params, $field_slug, $current_values, $in_the_bottom = false){
409
-
410
- if (!isset($current_values[$this->slug][$field_slug])) { $current_values[$this->slug][$field_slug] = ''; }
 
 
411
 
412
  if ($field_params['type'] == 'text') {
413
 
@@ -417,7 +460,7 @@ if (!class_exists('RapidAddon')) {
417
  array(
418
  'tooltip' => $field_params['tooltip'],
419
  'field_name' => $this->slug."[".$field_slug."]",
420
- 'field_value' => $current_values[$this->slug][$field_slug]
421
  )
422
  );
423
 
@@ -429,7 +472,19 @@ if (!class_exists('RapidAddon')) {
429
  array(
430
  'tooltip' => $field_params['tooltip'],
431
  'field_name' => $this->slug."[".$field_slug."]",
432
- 'field_value' => $current_values[$this->slug][$field_slug]
 
 
 
 
 
 
 
 
 
 
 
 
433
  )
434
  );
435
 
@@ -488,6 +543,16 @@ if (!class_exists('RapidAddon')) {
488
  )
489
  );
490
 
 
 
 
 
 
 
 
 
 
 
491
  } else if($field_params['type'] == 'title'){
492
  ?>
493
  <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>
@@ -524,7 +589,7 @@ if (!class_exists('RapidAddon')) {
524
  foreach ($value as $k => $sub_field) {
525
  if (is_array($sub_field) and ! empty($this->fields[$sub_field['slug']]))
526
  {
527
- $sub_fields[$key][] = $this->convert_field($sub_field, $current_values);
528
  }
529
  }
530
  }
@@ -536,6 +601,9 @@ if (!class_exists('RapidAddon')) {
536
 
537
  function convert_field($sub_field, $current_values){
538
  $field = array();
 
 
 
539
  switch ($this->fields[$sub_field['slug']]['type']) {
540
  case 'text':
541
  $field = array(
@@ -544,7 +612,7 @@ if (!class_exists('RapidAddon')) {
544
  'params' => array(
545
  'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
546
  'field_name' => $this->slug."[".$sub_field['slug']."]",
547
- 'field_value' => $current_values[$this->slug][$sub_field['slug']],
548
  'is_main_field' => $sub_field['is_main_field']
549
  )
550
  );
@@ -556,7 +624,19 @@ if (!class_exists('RapidAddon')) {
556
  'params' => array(
557
  'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
558
  'field_name' => $this->slug."[".$sub_field['slug']."]",
559
- 'field_value' => $current_values[$this->slug][$sub_field['slug']],
 
 
 
 
 
 
 
 
 
 
 
 
560
  'is_main_field' => $sub_field['is_main_field']
561
  )
562
  );
@@ -888,12 +968,12 @@ if (!class_exists('RapidAddon')) {
888
  if ($import->options[$this->slug]['xpaths'][$option_name] == ""){
889
  $count and $this->data[$option_name] = array_fill(0, $count, "");
890
  } else {
891
- $data[$option_name] = XmlImportParser::factory($xml, $cxpath, $import->options[$this->slug]['xpaths'][$option_name], $file)->parse($records);
892
  $tmp_files[] = $file;
893
  }
894
  }
895
  else {
896
- $data[$option_name] = XmlImportParser::factory($xml, $cxpath, $import->options[$this->slug][$option_name], $file)->parse();
897
  $tmp_files[] = $file;
898
  }
899
 
1
  <?php
2
+ /**
3
+ * RapidAddon
4
+ *
5
+ * @package WP All Import RapidAddon
6
+ * @copyright Copyright (c) 2014, Soflyy
7
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
8
+ * @version 1.1.0
9
+ */
10
 
11
  if (!class_exists('RapidAddon')) {
12
 
52
  'auto_set_extension' => 0,
53
  'new_extension' => '',
54
  'do_not_remove_images' => 1,
55
+ );
56
+
57
+ protected $isWizard = true;
58
 
59
  function __construct($name, $slug) {
60
 
61
  $this->name = $name;
62
  $this->slug = $slug;
63
+ if (!empty($_GET['id'])){
64
+ $this->isWizard = false;
65
+ }
66
  }
67
 
68
  function set_import_function($name) {
162
  }
163
 
164
 
165
+ function add_field($field_slug, $field_name, $field_type, $enum_values = null, $tooltip = "", $is_html = true, $default_text = '') {
166
 
167
+ $field = array("name" => $field_name, "type" => $field_type, "enum_values" => $enum_values, "tooltip" => $tooltip, "is_sub_field" => false, "is_main_field" => false, "slug" => $field_slug, "is_html" => $is_html, 'default_text' => $default_text);
168
 
169
  $this->fields[$field_slug] = $field;
170
 
192
 
193
  }
194
 
195
+ function add_acf_field($field){
196
+ $this->fields[$field->post_name] = array(
197
+ 'type' => 'acf',
198
+ 'field_obj' => $field
199
+ );
200
+ }
201
+
202
+ private $acfGroups = array();
203
+
204
+ function use_acf_group($acf_group){
205
+ $this->add_text(
206
+ '<div class="postbox acf_postbox default acf_signle_group rad4">
207
+ <h3 class="hndle" style="margin-top:0;"><span>'.$acf_group['title'].'</span></h3>
208
+ <div class="inside">');
209
+ $acf_fields = get_posts(array('posts_per_page' => -1, 'post_type' => 'acf-field', 'post_parent' => $acf_group['ID'], 'post_status' => 'publish', 'orderby' => 'menu_order', 'order' => 'ASC'));
210
+ if (!empty($acf_fields)){
211
+ foreach ($acf_fields as $field) {
212
+ $this->add_acf_field($field);
213
+ }
214
+ }
215
+ $this->add_text('</div></div>');
216
+ $this->acfGroups[] = $acf_group['ID'];
217
+ add_filter('wp_all_import_acf_is_show_group', array($this, 'acf_is_show_group'), 10, 2);
218
+ }
219
+
220
+ function acf_is_show_group($is_show, $acf_group){
221
+ return (in_array($acf_group['ID'], $this->acfGroups)) ? false : true;
222
+ }
223
+
224
  /**
225
  *
226
  * Add an option to WP All Import options list
238
  $options_list = array();
239
 
240
  foreach ($this->fields as $field_slug => $field_params) {
241
+ if (in_array($field_params['type'], array('title', 'plain_text', 'acf'))) continue;
242
  $default_value = '';
243
  if (!empty($field_params['enum_values'])){
244
  foreach ($field_params['enum_values'] as $key => $value) {
375
  }
376
 
377
  // apply mapping rules if they exist
378
+ if (!empty($import_options['mapping'][$field_slug])) {
379
  $mapping_rules = json_decode($import_options['mapping'][$field_slug], true);
380
 
381
  if (!empty($mapping_rules) and is_array($mapping_rules)) {
447
  }
448
 
449
  function render_field($field_params, $field_slug, $current_values, $in_the_bottom = false){
450
+
451
+ if (!isset($current_values[$this->slug][$field_slug])) {
452
+ $current_values[$this->slug][$field_slug] = isset($field_params['default_text']) ? $field_params['default_text'] : '';
453
+ }
454
 
455
  if ($field_params['type'] == 'text') {
456
 
460
  array(
461
  'tooltip' => $field_params['tooltip'],
462
  'field_name' => $this->slug."[".$field_slug."]",
463
+ 'field_value' => ( $current_values[$this->slug][$field_slug] == '' && $this->isWizard ) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug]
464
  )
465
  );
466
 
472
  array(
473
  'tooltip' => $field_params['tooltip'],
474
  'field_name' => $this->slug."[".$field_slug."]",
475
+ 'field_value' => ( $current_values[$this->slug][$field_slug] == '' && $this->isWizard ) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug]
476
+ )
477
+ );
478
+
479
+ } else if ($field_params['type'] == 'wp_editor') {
480
+
481
+ PMXI_API::add_field(
482
+ 'wp_editor',
483
+ $field_params['name'],
484
+ array(
485
+ 'tooltip' => $field_params['tooltip'],
486
+ 'field_name' => $this->slug."[".$field_slug."]",
487
+ 'field_value' => ( $current_values[$this->slug][$field_slug] == '' && $this->isWizard ) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug]
488
  )
489
  );
490
 
543
  )
544
  );
545
 
546
+ } else if($field_params['type'] == 'acf') {
547
+ $fieldData = (!empty($field_params['field_obj']->post_content)) ? unserialize($field_params['field_obj']->post_content) : array();
548
+ $fieldData['ID'] = $field_params['field_obj']->ID;
549
+ $fieldData['id'] = $field_params['field_obj']->ID;
550
+ $fieldData['label'] = $field_params['field_obj']->post_title;
551
+ $fieldData['key'] = $field_params['field_obj']->post_name;
552
+ if (empty($fieldData['name'])) $fieldData['name'] = $field_params['field_obj']->post_excerpt;
553
+ if (function_exists('pmai_render_field')) {
554
+ echo pmai_render_field($fieldData, ( ! empty($current_values) ) ? $current_values : array() );
555
+ }
556
  } else if($field_params['type'] == 'title'){
557
  ?>
558
  <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>
589
  foreach ($value as $k => $sub_field) {
590
  if (is_array($sub_field) and ! empty($this->fields[$sub_field['slug']]))
591
  {
592
+ $sub_fields[$key][] = $this->convert_field($sub_field, $current_values);
593
  }
594
  }
595
  }
601
 
602
  function convert_field($sub_field, $current_values){
603
  $field = array();
604
+ if (!isset($current_values[$this->slug][$sub_field['slug']])) {
605
+ $current_values[$this->slug][$sub_field['slug']] = isset($sub_field['default_text']) ? $sub_field['default_text'] : '';
606
+ }
607
  switch ($this->fields[$sub_field['slug']]['type']) {
608
  case 'text':
609
  $field = array(
612
  'params' => array(
613
  'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
614
  'field_name' => $this->slug."[".$sub_field['slug']."]",
615
+ 'field_value' => ($current_values[$this->slug][$sub_field['slug']] == '' && $this->isWizard) ? $sub_field['default_text'] : $current_values[$this->slug][$sub_field['slug']],
616
  'is_main_field' => $sub_field['is_main_field']
617
  )
618
  );
624
  'params' => array(
625
  'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
626
  'field_name' => $this->slug."[".$sub_field['slug']."]",
627
+ 'field_value' => ($current_values[$this->slug][$sub_field['slug']] == '' && $this->isWizard) ? $sub_field['default_text'] : $current_values[$this->slug][$sub_field['slug']],
628
+ 'is_main_field' => $sub_field['is_main_field']
629
+ )
630
+ );
631
+ break;
632
+ case 'wp_editor':
633
+ $field = array(
634
+ 'type' => 'wp_editor',
635
+ 'label' => $this->fields[$sub_field['slug']]['name'],
636
+ 'params' => array(
637
+ 'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
638
+ 'field_name' => $this->slug."[".$sub_field['slug']."]",
639
+ 'field_value' => ($current_values[$this->slug][$sub_field['slug']] == '' && $this->isWizard) ? $sub_field['default_text'] : $current_values[$this->slug][$sub_field['slug']],
640
  'is_main_field' => $sub_field['is_main_field']
641
  )
642
  );
968
  if ($import->options[$this->slug]['xpaths'][$option_name] == ""){
969
  $count and $this->data[$option_name] = array_fill(0, $count, "");
970
  } else {
971
+ $data[$option_name] = XmlImportParser::factory($xml, $cxpath, (string) $import->options[$this->slug]['xpaths'][$option_name], $file)->parse($records);
972
  $tmp_files[] = $file;
973
  }
974
  }
975
  else {
976
+ $data[$option_name] = XmlImportParser::factory($xml, $cxpath, (string) $import->options[$this->slug][$option_name], $file)->parse();
977
  $tmp_files[] = $file;
978
  }
979
 
readme.txt CHANGED
@@ -5,7 +5,7 @@ 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.9
8
- Stable tag: 1.1.5
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.1.5 =
70
  * Removed Yoast section from Taxonomy imports
71
 
5
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
6
  Requires at least: 4.1.0
7
  Tested up to: 4.9
8
+ Stable tag: 1.1.6
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.1.6 =
70
+ * Added ability to import SEO data in a Taxonomy import.
71
+
72
  = 1.1.5 =
73
  * Removed Yoast section from Taxonomy imports
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.1.5
8
  Author: Soflyy
9
  */
10
 
@@ -16,218 +16,347 @@ add_action( 'pmxi_saved_post', 'yoast_addon_primary_category', 10, 1 );
16
 
17
  $yoast_addon = new RapidAddon( 'Yoast WordPress SEO Add-On', 'yoast_addon' );
18
 
19
- $yoast_addon->add_field( '_yoast_wpseo_focuskw', 'Focus Keyword', 'text', null, 'Pick the main keyword or keyphrase that this post/page is about.' );
20
-
21
- $yoast_addon->add_field( '_yoast_wpseo_title', 'SEO Title', 'text', null, 'The SEO title defaults to what is generated based on this sites title template for this posttype.' );
22
-
23
- $yoast_addon->add_field( '_yoast_wpseo_metadesc', 'Meta Description', 'text', null, 'The meta description will be limited to 156 chars. It is often shown as the black text under the title in a search result. For this to work it has to contain the keyword that was searched for.' );
24
-
25
- $yoast_addon->add_options(
26
- $yoast_addon->add_field( '_yoast_wpseo_opengraph-title', 'Facebook Title', 'text', null, "If you don't want to use the post title for sharing the post on Facebook but instead want another title there, import it here." ),
27
- 'Facebook Options',
28
- array(
29
- $yoast_addon->add_field( '_yoast_wpseo_opengraph-description', 'Description', 'text', null, "If you don't want to use the meta description for sharing the post on Facebook but want another description there, write it here." ),
30
- $yoast_addon->add_field( '_yoast_wpseo_opengraph-image', 'Image', 'image', null, "If you want to override the image used on Facebook for this post, import one here. The recommended image size for Facebook is 1200 x 628px."),
31
- )
32
- );
33
-
34
- $yoast_addon->add_options(
35
- $yoast_addon->add_field( '_yoast_wpseo_twitter-title', 'Twitter Title', 'text', null, "If you don't want to use the post title for sharing the post on Twitter but instead want another title there, import it here." ),
36
- 'Twitter Options',
37
- array(
38
- $yoast_addon->add_field( '_yoast_wpseo_twitter-description', 'Description', 'text', null, "If you don't want to use the meta description for sharing the post on Twitter but want another description there, import it here." ),
39
- $yoast_addon->add_field( '_yoast_wpseo_twitter-image', 'Image', 'image', null, "If you want to override the image used on Twitter for this post, import one here. The recommended image size for Twitter is 1024 x 512px."),
40
- )
41
- );
42
-
43
- $yoast_addon->add_options(
44
- null,
45
- 'Advanced SEO Options',
46
- array(
47
- $yoast_addon->add_field( '_yoast_wpseo_meta-robots-noindex', 'Meta Robots Index', 'radio',
48
- array(
49
- '' => 'default',
50
- '2' => 'index',
51
- '1' => 'noindex',
52
- ),
53
- "This setting can be overwritten by Yoast WordPress SEO's sitewide privacy settings"
54
- ),
55
- $yoast_addon->add_field( '_yoast_wpseo_meta-robots-nofollow', 'Meta Robots Nofollow', 'radio',
56
  array(
57
- '' => 'Follow',
58
- '1' => 'Nofollow'
59
- ) ),
60
- $yoast_addon->add_field( '_yoast_wpseo_meta-robots-adv', 'Meta Robots Advanced', 'radio',
 
 
 
 
61
  array(
62
- '' => 'default',
63
- 'none' => 'None',
64
- 'noodp' => 'NO ODP',
65
- 'noydir' => 'NO YDIR',
66
- 'noimageindex' => 'No Image Index',
67
- 'noarchive' => 'No Archive',
68
- 'nosnippet' => 'No Snippet'
69
- ),
70
- 'Advanced meta robots settings for this page.'
71
- ),
72
- $yoast_addon->add_field( '_yoast_wpseo_sitemap-include', 'Include in Sitemap', 'radio',
73
  array(
74
- '' => 'Auto detect',
75
- 'always' => 'Always include',
76
- 'never' => 'Never include'
77
- ),
78
- 'Should this page be in the XML Sitemap at all times, regardless of Robots Meta settings?'
79
- ),
80
- $yoast_addon->add_field( '_yoast_wpseo_sitemap-prio', 'Sitemap Priority', 'radio',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  array(
82
- '' => 'Automatic Prioritization',
83
- '1' => '1 - Highest priority',
84
- '0.9' => '0.9',
85
- '0.8' => '0.8 - Default for first tier pages',
86
- '0.7' => '0.7',
87
- '0.6' => '0.6 - Default for second tier pages and posts',
88
- '0.5' => '0.5 - Medium priority',
89
- '0.4' => '0.4',
90
- '0.3' => '0.3',
91
- '0.2' => '0.2',
92
- '0.1' => '0.1 - Lowest priority'
93
- ),
94
- 'The priority given to this page in the XML sitemap. '
95
- ),
96
- $yoast_addon->add_field( '_yoast_wpseo_canonical', 'Canonical URL', 'text', null, 'The canonical URL that this page should point to, leave empty to default to permalink. Cross domain canonical supported too.' ),
97
- $yoast_addon->add_field( '_yoast_wpseo_redirect', '301 Redirect', 'text', null, 'The URL that this page should redirect to.' ),
98
- $yoast_addon->add_field( '_yoast_wpseo_primary_category_addon', 'Primary Category', 'text', null, 'The name or slug of the primary category' )
99
-
100
- )
101
- );
102
-
103
- $yoast_addon->set_import_function( 'yoast_seo_addon_import' );
104
-
105
- if (function_exists('is_plugin_active')) {
106
-
107
- if ( !is_plugin_active( "wordpress-seo/wp-seo.php" ) && !is_plugin_active( "wordpress-seo-premium/wp-seo-premium.php" ) ) {
108
-
109
- $yoast_addon->admin_notice(
110
- 'The Yoast WordPress SEO Add-On requires WP All Import <a href="http://www.wpallimport.com/order-now/?utm_source=free-plugin&utm_medium=dot-org&utm_campaign=yoast" target="_blank">Pro</a> or <a href="http://wordpress.org/plugins/wp-all-import" target="_blank">Free</a>, and the <a href="https://yoast.com/wordpress/plugins/seo/">Yoast WordPress SEO</a> plugin.',
111
  array(
112
- 'plugins' => array('wordpress-seo/wp-seo.php')
 
113
  )
114
  );
115
- }
116
 
117
- if ( is_plugin_active( "wordpress-seo/wp-seo.php" ) || is_plugin_active( "wordpress-seo-premium/wp-seo-premium.php" ) ) {
118
-
119
- $yoast_addon->run();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
 
121
- }
122
- }
123
 
124
- function yoast_seo_addon_import( $post_id, $data, $import_options, $article ) {
125
 
126
- global $yoast_addon;
127
 
128
- // all fields except for slider and image fields
129
- $fields = array(
130
- '_yoast_wpseo_focuskw',
131
- '_yoast_wpseo_title',
132
- '_yoast_wpseo_metadesc',
133
- '_yoast_wpseo_meta-robots-noindex',
134
- '_yoast_wpseo_meta-robots-nofollow',
135
- '_yoast_wpseo_meta-robots-adv',
136
- '_yoast_wpseo_sitemap-include',
137
- '_yoast_wpseo_sitemap-prio',
138
- '_yoast_wpseo_canonical',
139
- '_yoast_wpseo_redirect',
140
- '_yoast_wpseo_opengraph-title',
141
- '_yoast_wpseo_opengraph-description',
142
- '_yoast_wpseo_twitter-title',
143
- '_yoast_wpseo_twitter-description',
144
- '_yoast_wpseo_primary_category_addon'
145
- );
146
-
147
- // image fields
148
- $image_fields = array(
149
- '_yoast_wpseo_opengraph-image',
150
- '_yoast_wpseo_twitter-image'
151
- );
152
-
153
- $fields = array_merge( $fields, $image_fields );
154
-
155
- // update everything in fields arrays
156
- foreach ( $fields as $field ) {
157
- if ( $field == '_yoast_wpseo_primary_category_addon' ) {
158
 
159
- $title = $data[$field];
 
 
 
 
 
 
 
160
 
161
- $cat_slug = sanitize_title( $title ); // Get the slug for the Primary Category so we can match it later
162
 
163
- update_post_meta( $post_id, '_yoast_wpseo_addon_category_slug', $cat_slug );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
 
165
- // Set post metas for regular categories and product categories so we know if we can update them after pmxi_saved_post hook fires.
166
 
167
- if ( empty( $article['ID'] ) or $yoast_addon->can_update_meta( '_yoast_wpseo_primary_category', $import_options ) ) {
168
 
169
- update_post_meta( $post_id, '_yoast_wpseo_primary_category_can_update', 1 );
170
-
171
- } else {
172
 
173
- update_post_meta( $post_id, '_yoast_wpseo_primary_category_can_update', 0 );
174
 
175
- }
176
 
177
- if ( empty( $article['ID'] ) or $yoast_addon->can_update_meta( '_yoast_wpseo_primary_product_cat', $import_options ) ) {
 
 
178
 
179
- update_post_meta( $post_id, '_yoast_wpseo_primary_product_cat_can_update', 1 );
180
 
181
- } else {
182
 
183
- update_post_meta( $post_id, '_yoast_wpseo_primary_product_cat_can_update', 0 );
184
 
185
- }
186
 
187
- } else {
188
 
189
- if ( empty($article['ID']) or $yoast_addon->can_update_meta( $field, $import_options ) ) {
190
 
191
- if ( in_array( $field, $image_fields ) ) {
 
 
192
 
193
- if ( $yoast_addon->can_update_image( $import_options ) ) {
194
 
195
- $id = $data[$field]['attachment_id'];
196
-
197
- $url = wp_get_attachment_url( $id );
198
 
199
- update_post_meta( $post_id, $field, $url );
200
 
201
- }
 
 
202
 
203
- } else {
204
 
205
- if ( $field == '_yoast_wpseo_focuskw' ) {
206
 
207
- update_post_meta( $post_id, $field, $data[$field] );
208
- update_post_meta( $post_id, '_yoast_wpseo_focuskw_text_input', $data[$field] );
209
 
210
- } else {
211
 
212
- update_post_meta( $post_id, $field, $data[$field] );
 
213
 
214
- }
215
- }
216
- }
217
- }
218
- }
219
-
220
- // calculate _yoast_wpseo_linkdex
221
- if ( class_exists( 'WPSEO_Metabox' ) ) {
222
-
223
- wpseo_admin_init();
224
-
225
- $seo = new WPSEO_Metabox();
226
-
227
- $seo->calculate_results( get_post($post_id) );
228
- }
 
 
 
 
 
 
 
 
229
  }
230
 
 
231
  function yoast_addon_primary_category( $post_id ) {
232
 
233
  $product_update = get_post_meta( $post_id, '_yoast_wpseo_primary_product_cat_can_update', true ); // Can we update product primary categories?
@@ -282,8 +411,42 @@ function yoast_addon_primary_category( $post_id ) {
282
  delete_post_meta( $post_id, '_yoast_wpseo_addon_category_slug' );
283
  }
284
 
285
- add_filter( 'rapid_is_active_add_on', 'yoast_addon_is_active_add_on', 10, 3 );
286
- function yoast_addon_is_active_add_on( $is_active, $post_type, $called_by ){
287
- if ( $called_by == 'yoast_addon' && $post_type == 'taxonomies' ) $is_active = false;
288
- return $is_active;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
289
  }
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.1.6
8
  Author: Soflyy
9
  */
10
 
16
 
17
  $yoast_addon = new RapidAddon( 'Yoast WordPress SEO Add-On', 'yoast_addon' );
18
 
19
+ $custom_type = yoast_seo_addon_get_post_type();
20
+
21
+ switch($custom_type) {
22
+
23
+ // When "Taxonomies" is chosen in Step 1
24
+ case "taxonomies":
25
+ $yoast_addon->add_field( 'wpseo_focuskw', 'Focus Keyword', 'text', null, "Pick the main keyword or keyphrase that this post/page is about." );
26
+
27
+ $yoast_addon->add_field( 'wpseo_title', 'SEO Title', 'text', null, "The SEO title defaults to what is generated based on this site's title template for this post type." );
28
+
29
+ $yoast_addon->add_field( 'wpseo_desc', 'Meta Description', 'text', null, "The meta description will be limited to 156 chars. It is often shown as the black text under the title in a search result. For this to work it has to contain the keyword that was searched for." );
30
+
31
+ $yoast_addon->add_options(
32
+ $yoast_addon->add_field( 'wpseo_opengraph-title', 'Facebook Title', 'text', null, "If you don't want to use the post title for sharing the post on Facebook but instead want another title there, import it here." ),
33
+ 'Facebook Options',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  array(
35
+ $yoast_addon->add_field( 'wpseo_opengraph-description', 'Description', 'text', null, "If you don't want to use the meta description for sharing the post on Facebook but want another description there, write it here." ),
36
+ $yoast_addon->add_field( 'wpseo_opengraph-image', 'Image', 'image', null, "If you want to override the image used on Facebook for this post, import one here. The recommended image size for Facebook is 1200 x 628px."),
37
+ )
38
+ );
39
+
40
+ $yoast_addon->add_options(
41
+ $yoast_addon->add_field( 'wpseo_twitter-title', 'Twitter Title', 'text', null, "If you don't want to use the post title for sharing the post on Twitter but instead want another title there, import it here." ),
42
+ 'Twitter Options',
43
  array(
44
+ $yoast_addon->add_field( 'wpseo_twitter-description', 'Description', 'text', null, "If you don't want to use the meta description for sharing the post on Twitter but want another description there, import it here." ),
45
+ $yoast_addon->add_field( 'wpseo_twitter-image', 'Image', 'image', null, "If you want to override the image used on Twitter for this post, import one here. The recommended image size for Twitter is 1024 x 512px."),
46
+ )
47
+ );
48
+
49
+ $yoast_addon->add_options(
50
+ null,
51
+ 'Advanced SEO Options',
 
 
 
52
  array(
53
+ $yoast_addon->add_field( 'wpseo_noindex', 'Meta Robots Index', 'radio',
54
+ array(
55
+ '' => 'default',
56
+ 'index' => 'index',
57
+ 'noindex' => 'noindex',
58
+ ),
59
+ "This setting can be overwritten by Yoast WordPress SEO's sitewide privacy settings"
60
+ ),
61
+ $yoast_addon->add_field( 'wpseo_sitemap_include', 'Include in Sitemap', 'radio',
62
+ array(
63
+ '' => 'Auto detect',
64
+ 'always' => 'Always include',
65
+ 'never' => 'Never include'
66
+ ),
67
+ 'Should this page be in the XML Sitemap at all times, regardless of Robots Meta settings?'
68
+ ),
69
+ $yoast_addon->add_field( 'wpseo_canonical', 'Canonical URL', 'text', null, 'The canonical URL that this page should point to, leave empty to default to permalink. Cross domain canonical supported too.' )
70
+
71
+ )
72
+ );
73
+
74
+ $yoast_addon->set_import_function( 'yoast_seo_addon_import' );
75
+
76
+ if (function_exists('is_plugin_active')) {
77
+
78
+ if ( !is_plugin_active( "wordpress-seo/wp-seo.php" ) && !is_plugin_active( "wordpress-seo-premium/wp-seo-premium.php" ) ) {
79
+
80
+ $yoast_addon->admin_notice(
81
+ 'The Yoast WordPress SEO Add-On requires WP All Import <a href="http://www.wpallimport.com/order-now/?utm_source=free-plugin&utm_medium=dot-org&utm_campaign=yoast" target="_blank">Pro</a> or <a href="http://wordpress.org/plugins/wp-all-import" target="_blank">Free</a>, and the <a href="https://yoast.com/wordpress/plugins/seo/">Yoast WordPress SEO</a> plugin.',
82
+ array(
83
+ 'plugins' => array('wordpress-seo/wp-seo.php')
84
+ )
85
+ );
86
+ }
87
+
88
+ if ( is_plugin_active( "wordpress-seo/wp-seo.php" ) || is_plugin_active( "wordpress-seo-premium/wp-seo-premium.php" ) ) {
89
+
90
+ $yoast_addon->run();
91
+
92
+ }
93
+ }
94
+
95
+ function yoast_seo_addon_import( $term_id, $data, $import_options, $article ) {
96
+
97
+ global $yoast_addon;
98
+
99
+ // all fields except for slider and image fields
100
+ $fields = array(
101
+ 'wpseo_focuskw',
102
+ 'wpseo_title',
103
+ 'wpseo_desc',
104
+ 'wpseo_noindex',
105
+ 'wpseo_sitemap_include',
106
+ 'wpseo_canonical',
107
+ 'wpseo_opengraph-title',
108
+ 'wpseo_opengraph-description',
109
+ 'wpseo_twitter-title',
110
+ 'wpseo_twitter-description',
111
+ );
112
+
113
+ // image fields
114
+ $image_fields = array(
115
+ 'wpseo_opengraph-image',
116
+ 'wpseo_twitter-image'
117
+ );
118
+
119
+ $fields = array_merge( $fields, $image_fields );
120
+
121
+ // Gets the slug for the taxonomy currently being imported into
122
+ $taxonomy_type = $import_options['options']['taxonomy_type'];
123
+
124
+ // Get the current SEO data for taxonomies, and store it in an array
125
+ $meta = get_option("wpseo_taxonomy_meta");
126
+
127
+ foreach ( $fields as $field ) {
128
+
129
+ if ( empty($article['ID']) or $yoast_addon->can_update_meta( $field, $import_options ) ) {
130
+
131
+ if ( in_array( $field, $image_fields ) ) {
132
+
133
+ if ( $yoast_addon->can_update_image( $import_options ) ) {
134
+
135
+ $id = $data[$field]['attachment_id'];
136
+
137
+ $url = wp_get_attachment_url( $id );
138
+
139
+ $meta[$taxonomy_type][$term_id][$field] = $url;
140
+
141
+ }
142
+
143
+ } else {
144
+
145
+ $meta[$taxonomy_type][$term_id][$field] = $data[$field];
146
+
147
+ }
148
+ }
149
+ }
150
+ // Update the option to include our newly imported SEO data for taxonomies
151
+ update_option("wpseo_taxonomy_meta", $meta);
152
+
153
+ }
154
+
155
+ break;
156
+
157
+ case "shop_order":
158
+ case "import_users":
159
+ // Don't show the "Yoast SEO" section for WooCommerce Order & User imports
160
+ break;
161
+
162
+ // When most anything else is being imported...
163
+ default:
164
+
165
+ $yoast_addon->add_field( '_yoast_wpseo_focuskw', 'Focus Keyword', 'text', null, 'Pick the main keyword or keyphrase that this post/page is about.' );
166
+
167
+ $yoast_addon->add_field( '_yoast_wpseo_title', 'SEO Title', 'text', null, 'The SEO title defaults to what is generated based on this sites title template for this posttype.' );
168
+
169
+ $yoast_addon->add_field( '_yoast_wpseo_metadesc', 'Meta Description', 'text', null, 'The meta description will be limited to 156 chars. It is often shown as the black text under the title in a search result. For this to work it has to contain the keyword that was searched for.' );
170
+
171
+ $yoast_addon->add_options(
172
+ $yoast_addon->add_field( '_yoast_wpseo_opengraph-title', 'Facebook Title', 'text', null, "If you don't want to use the post title for sharing the post on Facebook but instead want another title there, import it here." ),
173
+ 'Facebook Options',
174
  array(
175
+ $yoast_addon->add_field( '_yoast_wpseo_opengraph-description', 'Description', 'text', null, "If you don't want to use the meta description for sharing the post on Facebook but want another description there, write it here." ),
176
+ $yoast_addon->add_field( '_yoast_wpseo_opengraph-image', 'Image', 'image', null, "If you want to override the image used on Facebook for this post, import one here. The recommended image size for Facebook is 1200 x 628px."),
177
+ )
178
+ );
179
+
180
+ $yoast_addon->add_options(
181
+ $yoast_addon->add_field( '_yoast_wpseo_twitter-title', 'Twitter Title', 'text', null, "If you don't want to use the post title for sharing the post on Twitter but instead want another title there, import it here." ),
182
+ 'Twitter Options',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  array(
184
+ $yoast_addon->add_field( '_yoast_wpseo_twitter-description', 'Description', 'text', null, "If you don't want to use the meta description for sharing the post on Twitter but want another description there, import it here." ),
185
+ $yoast_addon->add_field( '_yoast_wpseo_twitter-image', 'Image', 'image', null, "If you want to override the image used on Twitter for this post, import one here. The recommended image size for Twitter is 1024 x 512px."),
186
  )
187
  );
 
188
 
189
+ $yoast_addon->add_options(
190
+ null,
191
+ 'Advanced SEO Options',
192
+ array(
193
+ $yoast_addon->add_field( '_yoast_wpseo_meta-robots-noindex', 'Meta Robots Index', 'radio',
194
+ array(
195
+ '' => 'default',
196
+ '2' => 'index',
197
+ '1' => 'noindex',
198
+ ),
199
+ "This setting can be overwritten by Yoast WordPress SEO's sitewide privacy settings"
200
+ ),
201
+ $yoast_addon->add_field( '_yoast_wpseo_meta-robots-nofollow', 'Meta Robots Nofollow', 'radio',
202
+ array(
203
+ '' => 'Follow',
204
+ '1' => 'Nofollow'
205
+ ) ),
206
+ $yoast_addon->add_field( '_yst_is_cornerstone', 'This article is cornerstone content', 'radio',
207
+ array(
208
+ '' => 'No',
209
+ '1' => 'Yes'
210
+ ) ),
211
+ $yoast_addon->add_field( '_yoast_wpseo_meta-robots-adv', 'Meta Robots Advanced', 'radio',
212
+ array(
213
+ '' => 'default',
214
+ 'none' => 'None',
215
+ 'noimageindex' => 'No Image Index',
216
+ 'noarchive' => 'No Archive',
217
+ 'nosnippet' => 'No Snippet'
218
+ ),
219
+ 'Advanced meta robots settings for this page.'
220
+ ),
221
+ $yoast_addon->add_field( '_yoast_wpseo_canonical', 'Canonical URL', 'text', null, 'The canonical URL that this page should point to, leave empty to default to permalink. Cross domain canonical supported too.' ),
222
+ $yoast_addon->add_field( '_yoast_wpseo_primary_category_addon', 'Primary Category', 'text', null, 'The name or slug of the primary category' )
223
+ )
224
+ );
225
 
226
+ $yoast_addon->set_import_function( 'yoast_seo_addon_import' );
 
227
 
228
+ if (function_exists('is_plugin_active')) {
229
 
230
+ if ( !is_plugin_active( "wordpress-seo/wp-seo.php" ) && !is_plugin_active( "wordpress-seo-premium/wp-seo-premium.php" ) ) {
231
 
232
+ $yoast_addon->admin_notice(
233
+ 'The Yoast WordPress SEO Add-On requires WP All Import <a href="http://www.wpallimport.com/order-now/?utm_source=free-plugin&utm_medium=dot-org&utm_campaign=yoast" target="_blank">Pro</a> or <a href="http://wordpress.org/plugins/wp-all-import" target="_blank">Free</a>, and the <a href="https://yoast.com/wordpress/plugins/seo/">Yoast WordPress SEO</a> plugin.',
234
+ array(
235
+ 'plugins' => array('wordpress-seo/wp-seo.php')
236
+ )
237
+ );
238
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
 
240
+ if ( is_plugin_active( "wordpress-seo/wp-seo.php" ) || is_plugin_active( "wordpress-seo-premium/wp-seo-premium.php" ) ) {
241
+
242
+ $yoast_addon->run();
243
+
244
+ }
245
+ }
246
+
247
+ function yoast_seo_addon_import( $post_id, $data, $import_options, $article ) {
248
 
249
+ global $yoast_addon;
250
 
251
+ // all fields except for slider and image fields
252
+ $fields = array(
253
+ '_yoast_wpseo_focuskw',
254
+ '_yoast_wpseo_title',
255
+ '_yoast_wpseo_metadesc',
256
+ '_yoast_wpseo_meta-robots-noindex',
257
+ '_yoast_wpseo_meta-robots-nofollow',
258
+ '_yoast_wpseo_meta-robots-adv',
259
+ '_yoast_wpseo_sitemap-include',
260
+ '_yoast_wpseo_sitemap-prio',
261
+ '_yoast_wpseo_canonical',
262
+ '_yoast_wpseo_redirect',
263
+ '_yoast_wpseo_opengraph-title',
264
+ '_yoast_wpseo_opengraph-description',
265
+ '_yoast_wpseo_twitter-title',
266
+ '_yoast_wpseo_twitter-description',
267
+ '_yoast_wpseo_primary_category_addon',
268
+ '_yst_is_cornerstone'
269
+ );
270
+
271
+ // image fields
272
+ $image_fields = array(
273
+ '_yoast_wpseo_opengraph-image',
274
+ '_yoast_wpseo_twitter-image'
275
+ );
276
+
277
+ $fields = array_merge( $fields, $image_fields );
278
+
279
+ // update everything in fields arrays
280
+ foreach ( $fields as $field ) {
281
+ if ( $field == '_yoast_wpseo_primary_category_addon' ) {
282
 
283
+ $title = $data[$field];
284
 
285
+ $cat_slug = sanitize_title( $title ); // Get the slug for the Primary Category so we can match it later
286
 
287
+ update_post_meta( $post_id, '_yoast_wpseo_addon_category_slug', $cat_slug );
 
 
288
 
289
+ // Set post metas for regular categories and product categories so we know if we can update them after pmxi_saved_post hook fires.
290
 
291
+ if ( empty( $article['ID'] ) or $yoast_addon->can_update_meta( '_yoast_wpseo_primary_category', $import_options ) ) {
292
 
293
+ update_post_meta( $post_id, '_yoast_wpseo_primary_category_can_update', 1 );
294
+
295
+ } else {
296
 
297
+ update_post_meta( $post_id, '_yoast_wpseo_primary_category_can_update', 0 );
298
 
299
+ }
300
 
301
+ if ( empty( $article['ID'] ) or $yoast_addon->can_update_meta( '_yoast_wpseo_primary_product_cat', $import_options ) ) {
302
 
303
+ update_post_meta( $post_id, '_yoast_wpseo_primary_product_cat_can_update', 1 );
304
 
305
+ } else {
306
 
307
+ update_post_meta( $post_id, '_yoast_wpseo_primary_product_cat_can_update', 0 );
308
 
309
+ }
310
+
311
+ } else {
312
 
313
+ if ( empty($article['ID']) or $yoast_addon->can_update_meta( $field, $import_options ) ) {
314
 
315
+ if ( in_array( $field, $image_fields ) ) {
 
 
316
 
317
+ if ( $yoast_addon->can_update_image( $import_options ) ) {
318
 
319
+ $id = $data[$field]['attachment_id'];
320
+
321
+ $url = wp_get_attachment_url( $id );
322
 
323
+ update_post_meta( $post_id, $field, $url );
324
 
325
+ }
326
 
327
+ } else {
 
328
 
329
+ if ( $field == '_yoast_wpseo_focuskw' ) {
330
 
331
+ update_post_meta( $post_id, $field, $data[$field] );
332
+ update_post_meta( $post_id, '_yoast_wpseo_focuskw_text_input', $data[$field] );
333
 
334
+ } elseif ( $field == "_yst_is_cornerstone" && empty( $data[$field] ) ) {
335
+
336
+ if ( empty($article['ID']) ) {
337
+
338
+ // Do nothing
339
+
340
+ } else {
341
+
342
+ delete_post_meta( $post_id, "_yst_is_cornerstone");
343
+
344
+ }
345
+
346
+ } else {
347
+
348
+ update_post_meta( $post_id, $field, $data[$field] );
349
+
350
+ }
351
+ }
352
+ }
353
+ }
354
+ }
355
+
356
+ }
357
  }
358
 
359
+
360
  function yoast_addon_primary_category( $post_id ) {
361
 
362
  $product_update = get_post_meta( $post_id, '_yoast_wpseo_primary_product_cat_can_update', true ); // Can we update product primary categories?
411
  delete_post_meta( $post_id, '_yoast_wpseo_addon_category_slug' );
412
  }
413
 
414
+ function yoast_seo_addon_get_post_type() {
415
+ /**
416
+ * Show fields based on post type
417
+ **/
418
+
419
+ $custom_type = false;
420
+
421
+ // Get import ID from URL or set to 'new'
422
+ if ( isset( $_GET['import_id'] ) ) {
423
+ $import_id = $_GET['import_id'];
424
+ } elseif ( isset( $_GET['id'] ) ) {
425
+ $import_id = $_GET['id'];
426
+ }
427
+
428
+ if ( empty( $import_id ) ) {
429
+ $import_id = 'new';
430
+ }
431
+
432
+ // Declaring $wpdb as global to access database
433
+ global $wpdb;
434
+
435
+ // Get values from import data table
436
+ $imports_table = $wpdb->prefix . 'pmxi_imports';
437
+
438
+ // Get import session from database based on import ID or 'new'
439
+ $import_options = $wpdb->get_row( $wpdb->prepare("SELECT options FROM $imports_table WHERE id = %d", $import_id), ARRAY_A );
440
+
441
+ // If this is an existing import load the custom post type from the array
442
+ if ( ! empty($import_options) ) {
443
+ $import_options_arr = unserialize($import_options['options']);
444
+ $custom_type = $import_options_arr['custom_type'];
445
+ } else {
446
+ // If this is a new import get the custom post type data from the current session
447
+ $import_options = $wpdb->get_row( $wpdb->prepare("SELECT option_name, option_value FROM $wpdb->options WHERE option_name = %s", '_wpallimport_session_' . $import_id . '_'), ARRAY_A );
448
+ $import_options_arr = empty($import_options) ? array() : unserialize($import_options['option_value']);
449
+ $custom_type = empty($import_options_arr['custom_type']) ? '' : $import_options_arr['custom_type'];
450
+ }
451
+ return $custom_type;
452
  }