Import Settings into WordPress SEO by Yoast - Version 1.1.1

Version Description

  • Added primary category setting
Download this release

Release Info

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

Code changes from version 1.1.0 to 1.1.1

Files changed (3) hide show
  1. README.md +21 -16
  2. readme.txt +5 -2
  3. yoast-addon.php +77 -6
README.md CHANGED
@@ -2,19 +2,24 @@
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
-
 
 
 
 
 
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
+ | Primary Category | _yoast_wpseo_primary_category | Primary Category ID |
21
+ | Primary Category for Products | _yoast_wpseo_primary_product_cat | Primary WooCommerce Product Category ID |
22
+ | Primary Category Add-On Field | _yoast_wpseo_primary_category_addon | Name or Slug of Primary Category |
23
+ | Primary Category Update Option | _yoast_wpseo_primary_category_can_update | 1 (true) or empty |
24
+ | Primary Product Category Update Option | _yoast_wpseo_primary_product_cat_can_update | 1 (true) or empty |
25
+ | Primary Category Slug | _yoast_wpseo_addon_category_slug | The slug of the Primary Category |
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.3.1
8
- Stable tag: 1.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.1.0 =
70
  * Bug fixes related to cron imports
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.5.2
8
+ Stable tag: 1.1.1
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.1 =
70
+ * Added primary category setting
71
+
72
  = 1.1.0 =
73
  * Bug fixes related to cron 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.0
8
  Author: Soflyy
9
  */
10
 
@@ -12,6 +12,8 @@ include "rapid-addon.php";
12
 
13
  include_once(ABSPATH.'wp-admin/includes/plugin.php');
14
 
 
 
15
  $yoast_addon = new RapidAddon( 'Yoast WordPress SEO Add-On', 'yoast_addon' );
16
 
17
  $yoast_addon->add_field( '_yoast_wpseo_focuskw', 'Focus Keyword', 'text', null, 'Pick the main keyword or keyphrase that this post/page is about.' );
@@ -92,7 +94,8 @@ $yoast_addon->add_options(
92
  'The priority given to this page in the XML sitemap. '
93
  ),
94
  $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.' ),
95
- $yoast_addon->add_field( '_yoast_wpseo_redirect', '301 Redirect', 'text', null, 'The URL that this page should redirect to.' )
 
96
 
97
  )
98
  );
@@ -137,7 +140,8 @@ function yoast_seo_addon_import( $post_id, $data, $import_options ) {
137
  '_yoast_wpseo_opengraph-title',
138
  '_yoast_wpseo_opengraph-description',
139
  '_yoast_wpseo_twitter-title',
140
- '_yoast_wpseo_twitter-description'
 
141
 
142
  );
143
 
@@ -168,13 +172,29 @@ function yoast_seo_addon_import( $post_id, $data, $import_options ) {
168
 
169
  } else {
170
 
171
- update_post_meta( $post_id, $field, $data[$field] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
 
 
173
  }
174
  }
175
  }
176
-
177
- // calculate _yoast_wpseo_linkdex
178
  if ( class_exists( 'WPSEO_Metabox' ) ) {
179
 
180
  wpseo_admin_init();
@@ -183,4 +203,55 @@ function yoast_seo_addon_import( $post_id, $data, $import_options ) {
183
 
184
  $seo->calculate_results( get_post($post_id) );
185
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  }
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.1
8
  Author: Soflyy
9
  */
10
 
12
 
13
  include_once(ABSPATH.'wp-admin/includes/plugin.php');
14
 
15
+ 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.' );
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
  );
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
 
172
 
173
  } else {
174
 
175
+ if ( $field == '_yoast_wpseo_primary_category_addon' ) {
176
+
177
+ $title = $data[$field];
178
+
179
+ $cat_slug = sanitize_title( $title ); // Get the slug for the Primary Category so we can match it later
180
+
181
+ update_post_meta( $post_id, '_yoast_wpseo_addon_category_slug', $cat_slug );
182
+
183
+ // Set post metas for regular categories and product categories so we know if we can update them after pmxi_saved_post hook fires.
184
+
185
+ update_post_meta( $post_id, '_yoast_wpseo_primary_category_can_update', $yoast_addon->can_update_meta( '_yoast_wpseo_primary_category', $import_options ) );
186
+
187
+ update_post_meta( $post_id, '_yoast_wpseo_primary_product_cat_can_update', $yoast_addon->can_update_meta( '_yoast_wpseo_primary_product_cat', $import_options ) );
188
+
189
+ } else {
190
+
191
+ update_post_meta( $post_id, $field, $data[$field] );
192
 
193
+ }
194
  }
195
  }
196
  }
197
+ // calculate _yoast_wpseo_linkdex
 
198
  if ( class_exists( 'WPSEO_Metabox' ) ) {
199
 
200
  wpseo_admin_init();
203
 
204
  $seo->calculate_results( get_post($post_id) );
205
  }
206
+ }
207
+
208
+ function yoast_addon_primary_category( $post_id ) {
209
+
210
+ $product_update = get_post_meta( $post_id, '_yoast_wpseo_primary_product_cat_can_update', true ); // Can we update product primary categories?
211
+
212
+ $post_update = get_post_meta( $post_id, '_yoast_wpseo_primary_category_can_update', true ); // Can we update post primary categories?
213
+
214
+ // Only proceed if we have permission to update one of them.
215
+
216
+ if ( $post_update == 1 or $product_update == 1 ) {
217
+
218
+ $cat_slug = get_post_meta( $post_id, '_yoast_wpseo_addon_category_slug', true );
219
+
220
+ if ( !empty( $cat_slug ) ) {
221
+
222
+ $post_type = get_post_type( $post_id );
223
+
224
+ if ( !empty( $cat_slug ) and !empty( $post_type ) ) {
225
+
226
+ if ( $post_type == 'product' and $product_update == 1 ) { // Products use 'product_cat' instead of 'categories'.
227
+
228
+ $cat = get_term_by( 'slug', $cat_slug, 'product_cat' );
229
+
230
+ $cat_id = $cat->term_id;
231
+
232
+ if ( !empty( $cat_id ) ) {
233
+
234
+ update_post_meta( $post_id, '_yoast_wpseo_primary_product_cat', $cat_id );
235
+
236
+
237
+ }
238
+
239
+ } else {
240
+
241
+ if ( $post_update == 1 ) {
242
+
243
+ $cat = get_term_by( 'slug', $cat_slug, 'category' );
244
+
245
+ $cat_id = $cat->term_id;
246
+
247
+ if ( !empty( $cat_id ) ) {
248
+
249
+ update_post_meta( $post_id, '_yoast_wpseo_primary_category', $cat_id );
250
+
251
+ }
252
+ }
253
+ }
254
+ }
255
+ }
256
+ }
257
  }