Import Settings into WordPress SEO by Yoast - Version 1.1.8

Version Description

  • bug fix: deprecated field _yoast_wpseo_redirect in import field list
  • improvement: update rapid add-on api
Download this release

Release Info

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

Code changes from version 1.1.7 to 1.1.8

Files changed (3) hide show
  1. rapid-addon.php +206 -77
  2. readme.txt +6 -2
  3. yoast-addon.php +1 -2
rapid-addon.php CHANGED
@@ -52,19 +52,19 @@ if (!class_exists('RapidAddon')) {
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) {
69
  $this->import_function = $name;
70
  }
@@ -146,11 +146,13 @@ if (!class_exists('RapidAddon')) {
146
  add_filter('wp_all_import_addon_import', array($this, 'wpai_api_import'));
147
  add_filter('wp_all_import_addon_saved_post', array($this, 'wpai_api_post_saved'));
148
  add_filter('pmxi_options_options', array($this, 'wpai_api_options'));
149
- add_filter('wp_all_import_image_sections', array($this, 'additional_sections'), 10, 1);
 
 
 
150
  add_action('pmxi_extend_options_featured', array($this, 'wpai_api_metabox'), 10, 2);
151
- add_action('admin_init', array($this, 'admin_notice_ignore'));
152
-
153
- }
154
 
155
  function parse($data) {
156
 
@@ -235,19 +237,23 @@ if (!class_exists('RapidAddon')) {
235
 
236
  function options_array() {
237
 
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) {
245
- $default_value = $key;
246
- break;
247
- }
248
- }
249
- $options_list[$field_slug] = $default_value;
250
- }
 
 
251
 
252
  if ( ! empty($this->options) ){
253
  foreach ($this->options as $slug => $value) {
@@ -327,70 +333,68 @@ if (!class_exists('RapidAddon')) {
327
 
328
  $post_id = $importData['pid'];
329
  $index = $importData['i'];
 
 
 
 
 
330
 
331
- foreach ($this->fields as $field_slug => $field_params) {
332
-
333
- if (in_array($field_params['type'], array('title', 'plain_text'))) continue;
334
-
335
- switch ($field_params['type']) {
336
-
337
- case 'image':
338
-
339
- // import the specified image, then set the value of the field to the image ID in the media library
340
 
341
- $image_url_or_path = $parsedData[$field_slug][$index];
342
 
343
- $download = $import_options['download_image'][$field_slug];
344
 
345
- $uploaded_image = PMXI_API::upload_image($post_id, $image_url_or_path, $download, $importData['logger'], true);
346
 
347
- $data[$field_slug] = array(
348
- "attachment_id" => $uploaded_image,
349
- "image_url_or_path" => $image_url_or_path,
350
- "download" => $download
351
- );
352
 
353
- break;
354
 
355
- case 'file':
356
 
357
- $image_url_or_path = $parsedData[$field_slug][$index];
358
 
359
- $download = $import_options['download_image'][$field_slug];
360
 
361
- $uploaded_file = PMXI_API::upload_image($post_id, $image_url_or_path, $download, $importData['logger'], true, "", "files");
362
 
363
- $data[$field_slug] = array(
364
- "attachment_id" => $uploaded_file,
365
- "image_url_or_path" => $image_url_or_path,
366
- "download" => $download
367
- );
368
 
369
- break;
370
-
371
- default:
372
- // set the field data to the value of the field after it's been parsed
373
- $data[$field_slug] = $parsedData[$field_slug][$index];
374
- break;
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)) {
382
- foreach ($mapping_rules as $rule_number => $map_to) {
383
- if (isset($map_to[trim($data[$field_slug])])){
384
- $data[$field_slug] = trim($map_to[trim($data[$field_slug])]);
385
- break;
 
386
  }
387
  }
388
  }
 
389
  }
390
- // --------------------
391
-
392
-
393
- }
394
 
395
  call_user_func($this->import_function, $post_id, $data, $importData['import'], $importData['articleData'], $importData['logger']);
396
  }
@@ -649,12 +653,17 @@ if (!class_exists('RapidAddon')) {
649
  'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
650
  'field_name' => $this->slug."[".$sub_field['slug']."]",
651
  'field_value' => $current_values[$this->slug][$sub_field['slug']],
652
- 'download_image' => $current_values[$this->slug]['download_image'][$sub_field['slug']],
653
  'field_key' => $sub_field['slug'],
654
  'addon_prefix' => $this->slug,
655
  'is_main_field' => $sub_field['is_main_field']
656
  )
657
  );
 
 
 
 
 
658
  case 'file':
659
  $field = array(
660
  'type' => 'file',
@@ -663,12 +672,17 @@ if (!class_exists('RapidAddon')) {
663
  'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
664
  'field_name' => $this->slug."[".$sub_field['slug']."]",
665
  'field_value' => $current_values[$this->slug][$sub_field['slug']],
666
- 'download_image' => $current_values[$this->slug]['download_image'][$sub_field['slug']],
667
  'field_key' => $sub_field['slug'],
668
  'addon_prefix' => $this->slug,
669
  'is_main_field' => $sub_field['is_main_field']
670
  )
671
  );
 
 
 
 
 
672
  break;
673
  case 'radio':
674
  $field = array(
@@ -681,8 +695,8 @@ if (!class_exists('RapidAddon')) {
681
  'enum_values' => $this->fields[$sub_field['slug']]['enum_values'],
682
  'mapping' => true,
683
  'field_key' => $sub_field['slug'],
684
- 'mapping_rules' => $current_values[$this->slug]['mapping'][$sub_field['slug']],
685
- 'xpath' => $current_values[$this->slug]['xpaths'][$sub_field['slug']],
686
  'addon_prefix' => $this->slug,
687
  'sub_fields' => $this->get_sub_fields($this->fields[$sub_field['slug']], $sub_field['slug'], $current_values),
688
  'is_main_field' => $sub_field['is_main_field']
@@ -746,7 +760,9 @@ if (!class_exists('RapidAddon')) {
746
 
747
  if (empty($text)) return;
748
 
749
- return $this->add_field(sanitize_key($text) . time() . uniqid() . count($this->fields), $text, 'plain_text', null, "", $is_html);
 
 
750
 
751
  }
752
 
@@ -968,7 +984,7 @@ if (!class_exists('RapidAddon')) {
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
  }
@@ -1143,8 +1159,121 @@ if (!class_exists('RapidAddon')) {
1143
 
1144
  $m and $this->logger and call_user_func($this->logger, $m);
1145
 
1146
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1147
  }
1148
-
1149
- }
1150
-
52
  'auto_set_extension' => 0,
53
  'new_extension' => '',
54
  'do_not_remove_images' => 1,
55
+ 'search_existing_images_logic' => 'by_url'
56
  );
57
 
58
  protected $isWizard = true;
59
 
60
  function __construct($name, $slug) {
 
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) {
69
  $this->import_function = $name;
70
  }
146
  add_filter('wp_all_import_addon_import', array($this, 'wpai_api_import'));
147
  add_filter('wp_all_import_addon_saved_post', array($this, 'wpai_api_post_saved'));
148
  add_filter('pmxi_options_options', array($this, 'wpai_api_options'));
149
+ add_filter('wp_all_import_image_sections', array($this, 'additional_sections'), 10, 1);
150
+ add_filter('pmxi_custom_types', array($this, 'filter_post_types'), 10, 2);
151
+ add_filter('pmxi_post_list_order', array($this,'sort_post_types'), 10, 1);
152
+ add_filter('wp_all_import_post_type_image', array($this, 'post_type_image'), 10, 1 );
153
  add_action('pmxi_extend_options_featured', array($this, 'wpai_api_metabox'), 10, 2);
154
+ add_action('admin_init', array($this, 'admin_notice_ignore'));
155
+ }
 
156
 
157
  function parse($data) {
158
 
237
 
238
  function options_array() {
239
 
240
+ $options_list = array();
241
+
242
+ if ( ! empty( $this->fields ) ) {
243
 
244
+ foreach ($this->fields as $field_slug => $field_params) {
245
+ if (in_array($field_params['type'], array('title', 'plain_text', 'acf'))) continue;
246
+ $default_value = '';
247
+ if (!empty($field_params['enum_values'])){
248
+ foreach ($field_params['enum_values'] as $key => $value) {
249
+ $default_value = $key;
250
+ break;
251
+ }
252
+ }
253
+ $options_list[$field_slug] = $default_value;
254
+ }
255
+
256
+ }
257
 
258
  if ( ! empty($this->options) ){
259
  foreach ($this->options as $slug => $value) {
333
 
334
  $post_id = $importData['pid'];
335
  $index = $importData['i'];
336
+ $data = array();
337
+ if (!empty($this->fields)){
338
+ foreach ($this->fields as $field_slug => $field_params) {
339
+ if (in_array($field_params['type'], array('title', 'plain_text'))) continue;
340
+ switch ($field_params['type']) {
341
 
342
+ case 'image':
343
+
344
+ // import the specified image, then set the value of the field to the image ID in the media library
 
 
 
 
 
 
345
 
346
+ $image_url_or_path = $parsedData[$field_slug][$index];
347
 
348
+ $download = $import_options['download_image'][$field_slug];
349
 
350
+ $uploaded_image = PMXI_API::upload_image($post_id, $image_url_or_path, $download, $importData['logger'], true, "", "images", true, $importData['articleData']);
351
 
352
+ $data[$field_slug] = array(
353
+ "attachment_id" => $uploaded_image,
354
+ "image_url_or_path" => $image_url_or_path,
355
+ "download" => $download
356
+ );
357
 
358
+ break;
359
 
360
+ case 'file':
361
 
362
+ $image_url_or_path = $parsedData[$field_slug][$index];
363
 
364
+ $download = $import_options['download_image'][$field_slug];
365
 
366
+ $uploaded_file = PMXI_API::upload_image($post_id, $image_url_or_path, $download, $importData['logger'], true, "", "files", true, $importData['articleData']);
367
 
368
+ $data[$field_slug] = array(
369
+ "attachment_id" => $uploaded_file,
370
+ "image_url_or_path" => $image_url_or_path,
371
+ "download" => $download
372
+ );
373
 
374
+ break;
375
+
376
+ default:
377
+ // set the field data to the value of the field after it's been parsed
378
+ $data[$field_slug] = $parsedData[$field_slug][$index];
379
+ break;
380
+ }
381
+
382
+ // apply mapping rules if they exist
383
+ if (!empty($import_options['mapping'][$field_slug])) {
384
+ $mapping_rules = json_decode($import_options['mapping'][$field_slug], true);
385
+
386
+ if (!empty($mapping_rules) and is_array($mapping_rules)) {
387
+ foreach ($mapping_rules as $rule_number => $map_to) {
388
+ if (isset($map_to[trim($data[$field_slug])])){
389
+ $data[$field_slug] = trim($map_to[trim($data[$field_slug])]);
390
+ break;
391
+ }
392
  }
393
  }
394
  }
395
+ // --------------------
396
  }
397
+ }
 
 
 
398
 
399
  call_user_func($this->import_function, $post_id, $data, $importData['import'], $importData['articleData'], $importData['logger']);
400
  }
653
  'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
654
  'field_name' => $this->slug."[".$sub_field['slug']."]",
655
  'field_value' => $current_values[$this->slug][$sub_field['slug']],
656
+ 'download_image' => null,
657
  'field_key' => $sub_field['slug'],
658
  'addon_prefix' => $this->slug,
659
  'is_main_field' => $sub_field['is_main_field']
660
  )
661
  );
662
+
663
+ if ( array_key_exists( 'download_image', $current_values[$this->slug] ) ) {
664
+ $field['params']['download_image'] = $current_values[$this->slug]['download_image'][$sub_field['slug']];
665
+ }
666
+
667
  case 'file':
668
  $field = array(
669
  'type' => 'file',
672
  'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
673
  'field_name' => $this->slug."[".$sub_field['slug']."]",
674
  'field_value' => $current_values[$this->slug][$sub_field['slug']],
675
+ 'download_image' => null,
676
  'field_key' => $sub_field['slug'],
677
  'addon_prefix' => $this->slug,
678
  'is_main_field' => $sub_field['is_main_field']
679
  )
680
  );
681
+
682
+ if ( array_key_exists( 'download_image', $current_values[$this->slug] ) ) {
683
+ $field['params']['download_image'] = $current_values[$this->slug]['download_image'][$sub_field['slug']];
684
+ }
685
+
686
  break;
687
  case 'radio':
688
  $field = array(
695
  'enum_values' => $this->fields[$sub_field['slug']]['enum_values'],
696
  'mapping' => true,
697
  'field_key' => $sub_field['slug'],
698
+ 'mapping_rules' => isset($current_values[$this->slug]['mapping'][$sub_field['slug']]) ? $current_values[$this->slug]['mapping'][$sub_field['slug']] : array(),
699
+ 'xpath' => isset($current_values[$this->slug]['xpaths'][$sub_field['slug']]) ? $current_values[$this->slug]['xpaths'][$sub_field['slug']] : '',
700
  'addon_prefix' => $this->slug,
701
  'sub_fields' => $this->get_sub_fields($this->fields[$sub_field['slug']], $sub_field['slug'], $current_values),
702
  'is_main_field' => $sub_field['is_main_field']
760
 
761
  if (empty($text)) return;
762
 
763
+ $count = is_array($this->fields) ? count($this->fields) : 0;
764
+
765
+ return $this->add_field(sanitize_key($text) . time() . uniqid() . $count, $text, 'plain_text', null, "", $is_html);
766
 
767
  }
768
 
984
  if ($import->options[$this->slug]['xpaths'][$option_name] == ""){
985
  $count and $this->data[$option_name] = array_fill(0, $count, "");
986
  } else {
987
+ $data[$option_name] = XmlImportParser::factory($xml, $cxpath, (string) $import->options[$this->slug]['xpaths'][$option_name], $file)->parse();
988
  $tmp_files[] = $file;
989
  }
990
  }
1159
 
1160
  $m and $this->logger and call_user_func($this->logger, $m);
1161
 
1162
+ }
1163
+
1164
+ public function remove_post_type( $type = '' ) {
1165
+ if ( ! empty( $type ) ) {
1166
+ $this->add_option( 'post_types_to_remove', $type );
1167
+ }
1168
+ }
1169
+
1170
+ public function filter_post_types( $custom_types = '', $custom_type = '' ) {
1171
+ $options = $this->options_array();
1172
+ $option_key = 'post_types_to_remove';
1173
+
1174
+ if ( array_key_exists( $option_key, $options ) ) {
1175
+ $type = $options[ $option_key ];
1176
+
1177
+ if ( ! empty( $type ) ) {
1178
+ if ( ! is_array( $type ) ) {
1179
+ if ( array_key_exists( $type, $custom_types ) ) {
1180
+ unset( $custom_types[ $type ] );
1181
+ }
1182
+ } else {
1183
+ foreach ( $type as $key => $post_type ) {
1184
+ if ( array_key_exists( $post_type, $custom_types ) ) {
1185
+ unset( $custom_types[ $post_type ] );
1186
+ }
1187
+ }
1188
+ }
1189
+ }
1190
+ }
1191
+ return $custom_types;
1192
+ }
1193
+
1194
+ public function sort_post_types( array $order ) {
1195
+ $options = $this->options_array();
1196
+ $option_key = 'post_type_move';
1197
+
1198
+ if ( array_key_exists( $option_key, $options ) ) {
1199
+ $move_rules = maybe_unserialize( $options[ $option_key ] );
1200
+
1201
+ foreach ( $move_rules as $rule ) {
1202
+ $move_this = $rule['move_this'];
1203
+ $move_to = $rule['move_to'];
1204
+ if ( $move_to > count( $order ) ) {
1205
+ if ( ( $rm_key = array_search( $move_this, $order ) ) !== false ) {
1206
+ unset( $order[ $rm_key ] );
1207
+ }
1208
+ array_push( $order, $move_this );
1209
+ } else {
1210
+ if ( ( $rm_key = array_search( $move_this, $order ) ) !== false ) {
1211
+ unset( $order[ $rm_key ] );
1212
+ }
1213
+ array_splice( $order, $move_to, 0, $move_this );
1214
+ }
1215
+ }
1216
+
1217
+ return $order;
1218
+ }
1219
+
1220
+ return $order;
1221
+ }
1222
+
1223
+ public function move_post_type( $move_this = null, $move_to = null ) {
1224
+ $move_rules = array();
1225
+
1226
+ if ( ! is_array( $move_this ) && ! is_array( $move_to ) ) {
1227
+ $move_rules[] = array(
1228
+ 'move_this' => $move_this,
1229
+ 'move_to' => $move_to
1230
+ );
1231
+ } else {
1232
+ foreach ( $move_this as $key => $move_post ) {
1233
+ $move_rules[] = array(
1234
+ 'move_this' => $move_post,
1235
+ 'move_to' => $move_to[ $key ]
1236
+ );
1237
+ }
1238
+ }
1239
+
1240
+ $this->add_option( 'post_type_move', $move_rules );
1241
+ }
1242
+
1243
+ public function set_post_type_image( $post_type = null, $image = null ) {
1244
+ $post_type_image_rules = array();
1245
+
1246
+ if ( ! is_array( $post_type ) ) {
1247
+
1248
+ $post_type_image_rules[ $post_type ] = array(
1249
+ 'post_type' => $post_type,
1250
+ 'image' => $image
1251
+ );
1252
+
1253
+ } else {
1254
+
1255
+ if ( count( $post_type ) == count( $image ) ) {
1256
+
1257
+ foreach ( $post_type as $key => $post_name ) {
1258
+ $post_type_image_rules[ $post_name ] = array(
1259
+ 'post_type' => $post_name,
1260
+ 'image' => $image[ $key ]
1261
+ );
1262
+ }
1263
+ }
1264
+ }
1265
+
1266
+ $this->add_option( 'post_type_image', $post_type_image_rules );
1267
+ }
1268
+
1269
+ public function post_type_image( $image ) {
1270
+ $options = $this->options_array();
1271
+ $option_key = 'post_type_image';
1272
+ if ( array_key_exists( $option_key, $options ) ) {
1273
+ $post_type_image_rules = maybe_unserialize( $options[ $option_key ] );
1274
+ return $post_type_image_rules;
1275
+ }
1276
+ return $image;
1277
+ }
1278
  }
1279
+ }
 
 
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: 5.0
8
- Stable tag: 1.1.7
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,10 @@ The Yoast WordPress SEO Add-On will appear in the Step 3 of WP All Import.
66
 
67
  == Changelog ==
68
 
 
 
 
 
69
  = 1.1.7 =
70
  * Remove deprecated fields to fix issue with WooCommerce API.
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: 5.2
8
+ Stable tag: 1.1.8
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.8 =
70
+ * bug fix: deprecated field _yoast_wpseo_redirect in import field list
71
+ * improvement: update rapid add-on api
72
+
73
  = 1.1.7 =
74
  * Remove deprecated fields to fix issue with WooCommerce API.
75
 
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.7
8
  Author: Soflyy
9
  */
10
 
@@ -257,7 +257,6 @@ switch($custom_type) {
257
  '_yoast_wpseo_meta-robots-nofollow',
258
  '_yoast_wpseo_meta-robots-adv',
259
  '_yoast_wpseo_canonical',
260
- '_yoast_wpseo_redirect',
261
  '_yoast_wpseo_opengraph-title',
262
  '_yoast_wpseo_opengraph-description',
263
  '_yoast_wpseo_twitter-title',
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.8
8
  Author: Soflyy
9
  */
10
 
257
  '_yoast_wpseo_meta-robots-nofollow',
258
  '_yoast_wpseo_meta-robots-adv',
259
  '_yoast_wpseo_canonical',
 
260
  '_yoast_wpseo_opengraph-title',
261
  '_yoast_wpseo_opengraph-description',
262
  '_yoast_wpseo_twitter-title',