ACF Content Analysis for Yoast SEO - Version 1.1.0

Version Description

  • Add support for taxonomies
  • Bug fixes and stability improvements
  • Works with WordPress 4.4.1
Download this release

Release Info

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

Code changes from version 1.0 to 1.1.0

README.md CHANGED
@@ -1,4 +1,4 @@
1
- # ACF-Content Analysis for Yoast SEO
2
  This plugin ensures that Yoast SEO analysize all ACF content including FlexiContent and Repeaters
3
 
4
  ## Filters
1
+ # Yoast SEO - ACF Content Analysis
2
  This plugin ensures that Yoast SEO analysize all ACF content including FlexiContent and Repeaters
3
 
4
  ## Filters
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
- === ACF-Content Analysis for Yoast SEO ===
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.3.1
6
- Stable tag: 1.0
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -36,5 +36,10 @@ add_filter('ysacf_exclude_fields', function(){
36
 
37
  == Changelog ==
38
 
 
 
 
 
 
39
  = 1.0.0 =
40
  * First public release
1
+ === Yoast SEO - ACF Content Analysis ===
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.4.1
6
+ Stable tag: 1.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
36
 
37
  == Changelog ==
38
 
39
+ = 1.1.0 =
40
+ * Add support for taxonomies
41
+ * Bug fixes and stability improvements
42
+ * Works with WordPress 4.4.1
43
+
44
  = 1.0.0 =
45
  * First public release
yoast-seo-acf-content-analysis.php CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
  /*
3
- Plugin Name: ACF-Content Analysis for Yoast SEO
4
  Plugin URI: http://angrycreative.se
5
  Description: This plugin ensures that Yoast SEO analysize all ACF content including FlexiContent and Repeaters
6
- Version: 1.0
7
- Author: ViktorFroberg, marol87, AngryCreative
8
  Author URI: http://angrycreative.se
9
  License: GPL
10
  */
@@ -39,15 +39,36 @@ class AC_Yoast_SEO_ACF_Content_Analysis
39
  */
40
  public $plugin_slug = 'ysacf';
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
  function __construct(){
44
 
45
 
46
-
47
  add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
48
  add_action( 'admin_print_scripts-post-new.php', array($this, 'enqueue_admin_scripts') , 999 );
49
  add_action( 'admin_print_scripts-post.php', array($this, 'enqueue_admin_scripts'), 999 );
50
- add_action( 'wp_ajax_' . $plugin_slug . '_get_fields', array($this, 'ajax_get_fields') );
 
 
51
  }
52
  function get_excluded_fields() {
53
  return apply_filters( 'ysacf_exclude_fields', array() );
@@ -77,7 +98,7 @@ class AC_Yoast_SEO_ACF_Content_Analysis
77
 
78
  break;
79
  case 'array':
80
- if($key == 'sizes') {
81
  // put all images in img tags for scoring.
82
  $data = $data.' <img src="'.$item['sizes']['thumbnail'];
83
  } else {
@@ -100,6 +121,7 @@ class AC_Yoast_SEO_ACF_Content_Analysis
100
 
101
  function ajax_get_fields() {
102
  $pid = $_POST['postId'];
 
103
  $fields = get_fields( $pid );
104
 
105
  wp_send_json( $this->get_field_data( $fields ) );
@@ -111,14 +133,27 @@ class AC_Yoast_SEO_ACF_Content_Analysis
111
  * @since 0.1.0
112
  */
113
  public function enqueue_admin_scripts() {
114
- $pid = isset($_GET['post']) ? $_GET['post'] : $post->ID;
115
- wp_enqueue_script($this->plugin_slug, AC_SEO_ACF_ANALYSIS_PLUGIN_URL . 'yoast-seo-plugin.js', array('jquery', 'yoast-seo', 'wp-seo-post-scraper'), self::VERSION);
116
-
117
- wp_localize_script($this->plugin_slug, 'yoast_acf_settings', array(
118
- 'ajax_url' => admin_url( 'admin-ajax.php' ),
119
- 'id' => $pid,
120
- 'ajax_action' => $plugin_slug . '_get_fields'
121
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
122
 
123
  }
124
 
1
  <?php
2
  /*
3
+ Plugin Name: Yoast SEO - ACF Content Analysis
4
  Plugin URI: http://angrycreative.se
5
  Description: This plugin ensures that Yoast SEO analysize all ACF content including FlexiContent and Repeaters
6
+ Version: 1.1
7
+ Author: ViktorFroberg, marol87, pekz0r, angrycreative
8
  Author URI: http://angrycreative.se
9
  License: GPL
10
  */
39
  */
40
  public $plugin_slug = 'ysacf';
41
 
42
+ /**
43
+ * Holds the global `$pagenow` variable's value.
44
+ *
45
+ * @since 1.1.0
46
+ * @var string
47
+ */
48
+ private $pagenow;
49
+
50
+ /**
51
+ * variable containing places where the plugin will fetch acf data
52
+ *
53
+ * @since 1.1.0
54
+ * @var array
55
+ */
56
+ private $analysize_page_types = array(
57
+ 'edit-tags.php',
58
+ 'post.php',
59
+ 'post-new.php',
60
+
61
+ );
62
 
63
  function __construct(){
64
 
65
 
 
66
  add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
67
  add_action( 'admin_print_scripts-post-new.php', array($this, 'enqueue_admin_scripts') , 999 );
68
  add_action( 'admin_print_scripts-post.php', array($this, 'enqueue_admin_scripts'), 999 );
69
+ add_action( 'wp_ajax_' . $this->plugin_slug . '_get_fields', array($this, 'ajax_get_fields') );
70
+
71
+ $this->pagenow = $GLOBALS['pagenow'];
72
  }
73
  function get_excluded_fields() {
74
  return apply_filters( 'ysacf_exclude_fields', array() );
98
 
99
  break;
100
  case 'array':
101
+ if($key === 'sizes') {
102
  // put all images in img tags for scoring.
103
  $data = $data.' <img src="'.$item['sizes']['thumbnail'];
104
  } else {
121
 
122
  function ajax_get_fields() {
123
  $pid = $_POST['postId'];
124
+
125
  $fields = get_fields( $pid );
126
 
127
  wp_send_json( $this->get_field_data( $fields ) );
133
  * @since 0.1.0
134
  */
135
  public function enqueue_admin_scripts() {
136
+
137
+ if( in_array( $this->pagenow, $this->analysize_page_types ) ) {
138
+
139
+ // if this is a taxonomy, get the taxonomy id else get the post id
140
+ if($this->pagenow === 'edit-tags.php' ) {
141
+ $id = $_GET['taxonomy'] . '_' . $_GET['tag_ID'];
142
+ wp_enqueue_script($this->plugin_slug, AC_SEO_ACF_ANALYSIS_PLUGIN_URL . 'yoast-seo-plugin.js', array('jquery', 'yoast-seo', 'wp-seo-term-scraper'), self::VERSION);
143
+ } else {
144
+ global $post;
145
+ $id = $post->ID;
146
+ wp_enqueue_script($this->plugin_slug, AC_SEO_ACF_ANALYSIS_PLUGIN_URL . 'yoast-seo-plugin.js', array('jquery', 'yoast-seo', 'wp-seo-post-scraper'), self::VERSION);
147
+ }
148
+
149
+
150
+
151
+ wp_localize_script($this->plugin_slug, 'yoast_acf_settings', array(
152
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
153
+ 'id' => $id,
154
+ 'ajax_action' => $this->plugin_slug . '_get_fields'
155
+ ));
156
+ }
157
 
158
  }
159
 
yoast-seo-plugin.js CHANGED
@@ -1,6 +1,5 @@
1
  jQuery( document ).ready( function($) {
2
 
3
-
4
  var fieldData = "";
5
  YoastSEO_ACF_Content_Analysis = function() {
6
 
@@ -14,7 +13,6 @@ jQuery( document ).ready( function($) {
14
  YoastSEO_ACF_Content_Analysis.prototype.appendACFFields = function( ) {
15
 
16
  var $this = this;
17
-
18
  $.ajax({
19
  url: yoast_acf_settings.ajax_url,
20
  type: 'POST',
@@ -25,16 +23,14 @@ jQuery( document ).ready( function($) {
25
  }
26
  })
27
  .done(function(acf_fields) {
28
-
29
  $this.setFieldData(acf_fields);
30
 
31
 
32
  })
33
- .fail(function() {
34
  console.log("error");
35
- })
36
- .always(function() {
37
- console.log("complete");
38
  });
39
 
40
  };
1
  jQuery( document ).ready( function($) {
2
 
 
3
  var fieldData = "";
4
  YoastSEO_ACF_Content_Analysis = function() {
5
 
13
  YoastSEO_ACF_Content_Analysis.prototype.appendACFFields = function( ) {
14
 
15
  var $this = this;
 
16
  $.ajax({
17
  url: yoast_acf_settings.ajax_url,
18
  type: 'POST',
23
  }
24
  })
25
  .done(function(acf_fields) {
26
+
27
  $this.setFieldData(acf_fields);
28
 
29
 
30
  })
31
+ .fail(function(data) {
32
  console.log("error");
33
+ console.log(data);
 
 
34
  });
35
 
36
  };