woocommerce_helper = $woocommerce_helper; $this->product_helper = $product_helper; $this->addon_manager = $addon_manager; $this->options_helper = $options_helper; } /** * Returns the schema configuration. * * @return array>> */ public function get_configuration(): array { return [ 'isSchemaDisabledProgrammatically' => $this->is_schema_disabled_programmatically(), 'schemaApiIntegrations' => $this->get_schema_api_integrations(), ]; } /** * Gets the schema API integrations status. * * @return array> The schema API integrations status. */ public function get_schema_api_integrations(): array { $woocommerce_seo_file = 'wpseo-woocommerce/wpseo-woocommerce.php'; $woocommerce_active = $this->woocommerce_helper->is_active(); $woocommerce_seo_active = \is_plugin_active( $woocommerce_seo_file ); $woocommerce_seo_installed = $this->addon_manager->is_installed( WPSEO_Addon_Manager::WOOCOMMERCE_SLUG ); $woocommerce_seo_activate_url = \wp_nonce_url( \self_admin_url( 'plugins.php?action=activate&plugin=' . $woocommerce_seo_file ), 'activate-plugin_' . $woocommerce_seo_file, ); $is_premium = $this->product_helper->is_premium(); return [ 'tec' => [ 'isActive' => \class_exists( Events_Schema::class ), ], 'ssp' => [ 'isActive' => \class_exists( PodcastEpisode::class ), ], 'wp-recipe-maker' => [ 'isActive' => \class_exists( WP_Recipe_Maker::class ), ], 'woocommerce' => [ 'isPrerequisiteActive' => $woocommerce_active, 'isActive' => $woocommerce_seo_active, 'isInstalled' => $woocommerce_seo_installed, 'activationLink' => $woocommerce_seo_activate_url, ], 'edd' => [ 'isActive' => \class_exists( Easy_Digital_Downloads::class ), 'isPremium' => $is_premium, ], ]; } /** * Checks if the schema is disabled programmatically via the wpseo_json_ld_output filter. * * Only returns true if schema is enabled via the option (toggle) but disabled by external code. * * @return bool Whether schema is disabled by external code. */ public function is_schema_disabled_programmatically(): bool { $deprecated_data = [ '_deprecated' => 'Please use the "wpseo_schema_*" filters to extend the Yoast SEO schema data - see the WPSEO_Schema class.', ]; /** * Filter documented in Schema_Presenter::present(). */ $filtered_schema = \apply_filters( 'wpseo_json_ld_output', $deprecated_data, '' ); return ( $filtered_schema === [] || $filtered_schema === false ); } }