add_dependency( new Yoast_ACF_Analysis_Dependency_Yoast_SEO() ); $dependencies->add_dependency( new Yoast_ACF_Analysis_Dependency_ACF() ); if ( ! $dependencies->are_met() ) { return; } $this->boot(); if ( defined( 'AC_YOAST_ACF_ANALYSIS_ENVIRONMENT' ) && 'development' === AC_YOAST_ACF_ANALYSIS_ENVIRONMENT ) { $this->boot_dev(); } $this->register_config_filters(); $assets = new Yoast_ACF_Analysis_Assets(); $assets->init(); } /** * Boots the plugin. */ public function boot() { $registry = Yoast_ACF_Analysis_Facade::get_registry(); $configuration = $registry->get( 'config' ); if ( null !== $configuration && $configuration instanceof Yoast_ACF_Analysis_Configuration ) { return; } $configuration = new Yoast_ACF_Analysis_Configuration( $this->get_blacklist_type(), $this->get_blacklist_name(), $this->get_field_selectors() ); /** * Filters the plugin configuration instance. * * You can replace the whole plugin configuration with a custom instance. * Only use this as a last resort as there are multiple more specific filters in the default configuration. * * @see Yoast_ACF_Analysis_Configuration * * @since 2.0.0 * * @param Yoast_ACF_Analysis_Configuration $configuration Plugin configuration instance */ $custom_configuration = apply_filters( Yoast_ACF_Analysis_Facade::get_filter_name( 'config' ), $configuration ); if ( $custom_configuration instanceof Yoast_ACF_Analysis_Configuration ) { $configuration = $custom_configuration; } $registry->add( 'config', $configuration ); } /** * Boots the plugin for dev environment. */ public function boot_dev() { $version = ( -1 === version_compare( get_option( 'acf_version' ), 5 ) ) ? '4' : '5'; require_once AC_SEO_ACF_ANALYSIS_PLUGIN_PATH . '/tests/js/system/data/acf' . $version . '.php'; } /** * Filters the Scraper Configuration to add the headlines configuration for the text scraper. */ protected function register_config_filters() { add_filter( Yoast_ACF_Analysis_Facade::get_filter_name( 'scraper_config' ), array( $this, 'filter_scraper_config') ); } /** * Enhances the scraper config with headlines configuration. * * @param array $scraper_config Scraper configuration. * * @return array Enhanched scraper config. */ public function filter_scraper_config( $scraper_config ) { $scraper_config['text'] = array( /** * Filters which ACF text fields are to be treated as a headline by the text scraper. * * The array has the ACF field key as the array key and the value should be an integer from 1 to 6 * that corresponds to the 6 possible HTML tags