diff --git a/inc/class-yoast-acf-analysis-assets.php b/inc/class-yoast-acf-analysis-assets.php index 5fc424e6..1522962c 100755 --- a/inc/class-yoast-acf-analysis-assets.php +++ b/inc/class-yoast-acf-analysis-assets.php @@ -15,7 +15,7 @@ class Yoast_ACF_Analysis_Assets { public function init() { $this->plugin_data = get_plugin_data( AC_SEO_ACF_ANALYSIS_PLUGIN_FILE ); - add_filter( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); + add_filter( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 ); } /** @@ -28,27 +28,30 @@ public function enqueue_scripts() { $config = Yoast_ACF_Analysis_Facade::get_registry()->get( 'config' ); // Post page enqueue. - if ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) { + if ( wp_script_is( WPSEO_Admin_Asset_Manager::PREFIX . 'post-scraper' ) ) { wp_enqueue_script( 'yoast-acf-analysis-post', plugins_url( '/js/yoast-acf-analysis.js', AC_SEO_ACF_ANALYSIS_PLUGIN_FILE ), - array( 'jquery', 'yoast-seo-post-scraper', 'underscore' ), - $this->plugin_data['Version'] + array( 'jquery', WPSEO_Admin_Asset_Manager::PREFIX . 'post-scraper', 'underscore' ), + $this->plugin_data['Version'], + true ); wp_localize_script( 'yoast-acf-analysis-post', 'YoastACFAnalysisConfig', $config->to_array() ); } // Term page enqueue. - if ( 'term.php' === $pagenow ) { + if ( wp_script_is( WPSEO_Admin_Asset_Manager::PREFIX . 'term-scraper' ) ) { wp_enqueue_script( 'yoast-acf-analysis-term', plugins_url( '/js/yoast-acf-analysis.js', AC_SEO_ACF_ANALYSIS_PLUGIN_FILE ), - array( 'jquery', 'yoast-seo-term-scraper' ), - $this->plugin_data['Version'] + array( 'jquery', WPSEO_Admin_Asset_Manager::PREFIX . 'term-scraper' ), + $this->plugin_data['Version'], + true ); wp_localize_script( 'yoast-acf-analysis-term', 'YoastACFAnalysisConfig', $config->to_array() ); } } + } diff --git a/js/src/app.js b/js/src/app.js index ebf5b4ec..3ac6fcce 100644 --- a/js/src/app.js +++ b/js/src/app.js @@ -22,7 +22,7 @@ App.prototype.bindListeners = function(){ if(helper.acf_version >= 5){ - acf.add_action('ready', function () { + jQuery(function(){ replaceVars.updateReplaceVars(collect); diff --git a/js/yoast-acf-analysis.js b/js/yoast-acf-analysis.js index 3af79ead..3df6c386 100644 --- a/js/yoast-acf-analysis.js +++ b/js/yoast-acf-analysis.js @@ -23,7 +23,7 @@ App.prototype.bindListeners = function(){ if(helper.acf_version >= 5){ - acf.add_action('ready', function () { + jQuery(function(){ replaceVars.updateReplaceVars(collect);