HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/hcv/wp-content/plugins/wordpress-seo-premium/classes/premium-prominent-words-support.php
<?php
/**
 * WPSEO Premium plugin file.
 *
 * @package WPSEO\Premium
 */

/**
 * Represents the functionality for the prominent words support.
 */
class WPSEO_Premium_Prominent_Words_Support {

	/**
	 * Returns an array with the supported post types.
	 *
	 * @return array The supported post types.
	 */
	public function get_supported_post_types() {
		/**
		 * Filter: 'Yoast\WP\SEO\prominent_words_post_types' - Allows changes for the accessible post types.
		 *
		 * Note: This is a Premium plugin-only hook.
		 *
		 * @since 12.9.0
		 *
		 * @api array The accessible post types.
		 */
		$prominent_words_post_types = apply_filters(
			'Yoast\WP\SEO\prominent_words_post_types',
			WPSEO_Post_Type::get_accessible_post_types()
		);

		if ( ! is_array( $prominent_words_post_types ) || empty( $prominent_words_post_types ) ) {
			$prominent_words_post_types = [];
		}

		$prominent_words_post_types = WPSEO_Post_Type::filter_attachment_post_type( $prominent_words_post_types );
		$prominent_words_post_types = array_filter( $prominent_words_post_types, [ 'WPSEO_Post_Type', 'has_metabox_enabled' ] );

		/*
		 * The above combination of functions results in array looking like this:
		 * [
		 *   `post` => `post`
		 *   `page` => `page`
		 * ]
		 *
		 * This can result in problems downstream when trying to array_merge this twice.
		 * array_values prevents this issue by ensuring numeric keys.
		 */
		$prominent_words_post_types = array_values( $prominent_words_post_types );

		return $prominent_words_post_types;
	}

	/**
	 * Checks if the post type is supported.
	 *
	 * @param string $post_type The post type to look up.
	 *
	 * @return bool True when post type is supported.
	 */
	public function is_post_type_supported( $post_type ) {
		return in_array( $post_type, $this->get_supported_post_types(), true );
	}

	/**
	 * Retrieves a list of taxonomies that are public, viewable and have the metabox enabled.
	 *
	 * @return array The supported taxonomies.
	 */
	public function get_supported_taxonomies() {
		$taxonomies = get_taxonomies( [ 'public' => true ] );
		$taxonomies = array_filter( $taxonomies, 'is_taxonomy_viewable' );

		/**
		 * Filter: 'Yoast\WP\SEO\prominent_words_taxonomies' - Allows to filter from which taxonomies terms are eligible for generating prominent words.
		 *
		 * Note: This is a Premium plugin-only hook.
		 *
		 * @since 14.7.0
		 *
		 * @api array The accessible taxonomies.
		 */
		$prominent_words_taxonomies = apply_filters(
			'Yoast\WP\SEO\prominent_words_taxonomies',
			$taxonomies
		);

		if ( ! is_array( $prominent_words_taxonomies ) || empty( $prominent_words_taxonomies ) ) {
			return [];
		}

		$prominent_words_taxonomies = array_filter(
			$prominent_words_taxonomies,
			static function( $taxonomy ) {
				return (bool) WPSEO_Options::get( 'display-metabox-tax-' . $taxonomy, true );
			}
		);

		return array_values( $prominent_words_taxonomies );
	}

	/**
	 * Checks if the taxonomy is supported.
	 *
	 * @param string $taxonomy The taxonomy to look up.
	 *
	 * @return bool True when taxonomy is supported.
	 */
	public function is_taxonomy_supported( $taxonomy ) {
		return in_array( $taxonomy, $this->get_supported_taxonomies(), true );
	}
}