ACF Content Analysis for Yoast SEO - Version 1.2.4

Version Description

  • Fix filter.
  • Add check for empty content.
Download this release

Release Info

Developer ViktorFroberg
Plugin Icon 128x128 ACF Content Analysis for Yoast SEO
Version 1.2.4
Comparing to
See all releases

Code changes from version 1.2.3 to 1.2.4

readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: ViktorFroberg, marol87, pekz0r, angrycreative
3
  Tags: Angry Creative, Yoast SEO, Yoast, SEO, ACF, Advanced Custom Fields
4
  Requires at least: 4.0
5
- Tested up to: 4.5
6
- Stable tag: 1.2.3
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -18,12 +18,13 @@ Requires version 3.0 or later of Yoast SEO plugin.
18
  = Filters =
19
  `ysacf_exclude_fields`: exclude acf fields from Yoast scoring. Should return array of field names.
20
 
21
- Example: exclude text-color field from Yoast scoring.
22
 
23
  `
24
  add_filter('ysacf_exclude_fields', function(){
25
  return array(
26
  'text_color',
 
27
  );
28
  });
29
  `
@@ -36,6 +37,10 @@ add_filter('ysacf_exclude_fields', function(){
36
 
37
  == Changelog ==
38
 
 
 
 
 
39
  = 1.2.3 =
40
  * Fix PHP warnings.
41
  * Works with WordPress 4.5
2
  Contributors: ViktorFroberg, marol87, pekz0r, angrycreative
3
  Tags: Angry Creative, Yoast SEO, Yoast, SEO, ACF, Advanced Custom Fields
4
  Requires at least: 4.0
5
+ Tested up to: 4.5.2
6
+ Stable tag: 1.2.4
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
18
  = Filters =
19
  `ysacf_exclude_fields`: exclude acf fields from Yoast scoring. Should return array of field names.
20
 
21
+ Example: exclude the text-color and background_image fields from Yoast scoring.
22
 
23
  `
24
  add_filter('ysacf_exclude_fields', function(){
25
  return array(
26
  'text_color',
27
+ 'background_image'
28
  );
29
  });
30
  `
37
 
38
  == Changelog ==
39
 
40
+ = 1.2.4 =
41
+ * Fix filter.
42
+ * Add check for empty content.
43
+
44
  = 1.2.3 =
45
  * Fix PHP warnings.
46
  * Works with WordPress 4.5
yoast-seo-acf-content-analysis.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: ACF-Content Analysis for Yoast SEO
4
  Plugin URI: http://angrycreative.se
5
  Description: Ensure that Yoast SEO analysize all ACF content including Flexible Content and Repeaters.
6
- Version: 1.2.3
7
  Author: ViktorFroberg, marol87, pekz0r, angrycreative
8
  Author URI: http://angrycreative.se
9
  License: GPL
@@ -28,7 +28,7 @@ class AC_Yoast_SEO_ACF_Content_Analysis
28
  * @since 0.1.0
29
  * @var string
30
  */
31
- const VERSION = '1.2.3';
32
  /**
33
  * Unique identifier for the plugin.
34
  * This value is used as the text domain when internationalizing strings of text. It should
@@ -38,7 +38,7 @@ class AC_Yoast_SEO_ACF_Content_Analysis
38
  * @var string
39
  */
40
  public $plugin_slug = 'ysacf';
41
-
42
  /**
43
  * Holds the global `$pagenow` variable's value.
44
  *
@@ -61,15 +61,15 @@ class AC_Yoast_SEO_ACF_Content_Analysis
61
  );
62
 
63
  function __construct(){
64
-
65
  add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
66
  add_action( 'admin_print_scripts-post-new.php', array($this, 'enqueue_admin_scripts') , 999 );
67
  add_action( 'admin_print_scripts-post.php', array($this, 'enqueue_admin_scripts'), 999 );
68
  add_action( 'wp_ajax_' . $this->plugin_slug . '_get_fields', array($this, 'ajax_get_fields') );
69
  if(isset($GLOBALS['pagenow'])) {
70
- $this->pagenow = $GLOBALS['pagenow'];
71
  }
72
-
73
  }
74
  function get_excluded_fields() {
75
  return apply_filters( 'ysacf_exclude_fields', array() );
@@ -82,15 +82,15 @@ class AC_Yoast_SEO_ACF_Content_Analysis
82
  function get_field_data($fields) {
83
 
84
  $data = '';
85
- if($fields) {
86
  foreach($fields as $key =>$item) {
87
 
88
- if(in_array($key, $this->get_excluded_fields()) ){
89
  continue;
90
  } else {
91
  switch(gettype($item)) {
92
  case 'string':
93
- $data = $data.' '.$item;
94
  break;
95
 
96
  case 'array':
@@ -109,14 +109,14 @@ class AC_Yoast_SEO_ACF_Content_Analysis
109
 
110
  $data = $data.' '.$this->get_field_data($item);
111
  }
112
-
113
  break;
114
  }
115
  }
116
- }
117
  }
118
-
119
-
120
  return $data;
121
  }
122
 
@@ -126,7 +126,7 @@ class AC_Yoast_SEO_ACF_Content_Analysis
126
 
127
  $fields = get_fields( $pid );
128
 
129
- wp_send_json( $this->get_field_data( $fields ) );
130
  }
131
 
132
  /**
@@ -156,7 +156,7 @@ class AC_Yoast_SEO_ACF_Content_Analysis
156
  'ajax_action' => $this->plugin_slug . '_get_fields'
157
  ));
158
  }
159
-
160
  }
161
 
162
  }
3
  Plugin Name: ACF-Content Analysis for Yoast SEO
4
  Plugin URI: http://angrycreative.se
5
  Description: Ensure that Yoast SEO analysize all ACF content including Flexible Content and Repeaters.
6
+ Version: 1.2.4
7
  Author: ViktorFroberg, marol87, pekz0r, angrycreative
8
  Author URI: http://angrycreative.se
9
  License: GPL
28
  * @since 0.1.0
29
  * @var string
30
  */
31
+ const VERSION = '1.2.4';
32
  /**
33
  * Unique identifier for the plugin.
34
  * This value is used as the text domain when internationalizing strings of text. It should
38
  * @var string
39
  */
40
  public $plugin_slug = 'ysacf';
41
+
42
  /**
43
  * Holds the global `$pagenow` variable's value.
44
  *
61
  );
62
 
63
  function __construct(){
64
+
65
  add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
66
  add_action( 'admin_print_scripts-post-new.php', array($this, 'enqueue_admin_scripts') , 999 );
67
  add_action( 'admin_print_scripts-post.php', array($this, 'enqueue_admin_scripts'), 999 );
68
  add_action( 'wp_ajax_' . $this->plugin_slug . '_get_fields', array($this, 'ajax_get_fields') );
69
  if(isset($GLOBALS['pagenow'])) {
70
+ $this->pagenow = $GLOBALS['pagenow'];
71
  }
72
+
73
  }
74
  function get_excluded_fields() {
75
  return apply_filters( 'ysacf_exclude_fields', array() );
82
  function get_field_data($fields) {
83
 
84
  $data = '';
85
+ if(!empty($fields)) {
86
  foreach($fields as $key =>$item) {
87
 
88
+ if(in_array((string)$key, $this->get_excluded_fields()) ){
89
  continue;
90
  } else {
91
  switch(gettype($item)) {
92
  case 'string':
93
+ $data = $data.' '.$item;
94
  break;
95
 
96
  case 'array':
109
 
110
  $data = $data.' '.$this->get_field_data($item);
111
  }
112
+
113
  break;
114
  }
115
  }
116
+ }
117
  }
118
+
119
+
120
  return $data;
121
  }
122
 
126
 
127
  $fields = get_fields( $pid );
128
 
129
+ wp_send_json( $this->get_field_data( $fields ) );
130
  }
131
 
132
  /**
156
  'ajax_action' => $this->plugin_slug . '_get_fields'
157
  ));
158
  }
159
+
160
  }
161
 
162
  }
yoast-seo-plugin.js CHANGED
@@ -1,10 +1,10 @@
1
  jQuery(window).on('YoastSEO:ready', function () {
2
  var fieldData = "";
3
  YoastSEO_ACF_Content_Analysis = function() {
4
-
5
  YoastSEO.app.registerPlugin( 'ACF_Content_Analysis', {status: 'loading'} );
6
  this.appendACFFields();
7
- }
8
 
9
  YoastSEO_ACF_Content_Analysis.prototype.appendACFFields = function() {
10
 
@@ -13,7 +13,7 @@ jQuery(window).on('YoastSEO:ready', function () {
13
  url: yoast_acf_settings.ajax_url,
14
  type: 'POST',
15
  dataType: 'JSON',
16
- data: {
17
  postId : yoast_acf_settings.id,
18
  action: yoast_acf_settings.ajax_action
19
  }
@@ -36,7 +36,7 @@ jQuery(window).on('YoastSEO:ready', function () {
36
  };
37
 
38
  YoastSEO_ACF_Content_Analysis.prototype.getFieldData = function( data ) {
39
-
40
  return data + ' ' + fieldData;
41
 
42
  };
1
  jQuery(window).on('YoastSEO:ready', function () {
2
  var fieldData = "";
3
  YoastSEO_ACF_Content_Analysis = function() {
4
+
5
  YoastSEO.app.registerPlugin( 'ACF_Content_Analysis', {status: 'loading'} );
6
  this.appendACFFields();
7
+ };
8
 
9
  YoastSEO_ACF_Content_Analysis.prototype.appendACFFields = function() {
10
 
13
  url: yoast_acf_settings.ajax_url,
14
  type: 'POST',
15
  dataType: 'JSON',
16
+ data: {
17
  postId : yoast_acf_settings.id,
18
  action: yoast_acf_settings.ajax_action
19
  }
36
  };
37
 
38
  YoastSEO_ACF_Content_Analysis.prototype.getFieldData = function( data ) {
39
+
40
  return data + ' ' + fieldData;
41
 
42
  };