Your IP : 216.73.216.162


Current Path : /home/x/b/o/xbodynamge/namtation/wp-content/
Upload File :
Current File : /home/x/b/o/xbodynamge/namtation/wp-content/conditionals.tar

wp-robots-conditional.php000066600000000525151123032010011504 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Class that checks if wp_robots exists.
 */
class WP_Robots_Conditional implements Conditional {

	/**
	 * Checks if the wp_robots function exists.
	 *
	 * @return bool True when the wp_robots function exists.
	 */
	public function is_met() {
		return \function_exists( 'wp_robots' );
	}
}
web-stories-conditional.php000066600000000670151123032010012014 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Conditional that is only met when Web Stories are active.
 */
class Web_Stories_Conditional implements Conditional {

	/**
	 * Returns `true` when the Web Stories plugins is installed and active.
	 *
	 * @return bool `true` when the Web Stories plugins is installed and active.
	 */
	public function is_met() {
		return \function_exists( '\Google\Web_Stories\get_plugin_instance' );
	}
}
no-tool-selected-conditional.php000066600000000775151123032010012734 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Conditional that is only met when current page is not a specific tool's page.
 */
class No_Tool_Selected_Conditional implements Conditional {

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- We just check whether a URL parameter does not exist.
		return ! isset( $_GET['tool'] );
	}
}
conditional-interface.php000066600000000452151123032010011507 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Conditional interface, used to prevent integrations from loading.
 */
interface Conditional {

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met();
}
wincher-enabled-conditional.php000066600000001343151123032010012576 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

use Yoast\WP\SEO\Helpers\Options_Helper;

/**
 * Conditional that is only met when the Wincher integration is enabled.
 */
class Wincher_Enabled_Conditional implements Conditional {

	/**
	 * The options helper.
	 *
	 * @var Options_Helper
	 */
	private $options;

	/**
	 * Wincher_Enabled_Conditional constructor.
	 *
	 * @param Options_Helper $options The options helper.
	 */
	public function __construct( Options_Helper $options ) {
		$this->options = $options;
	}

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		return $this->options->get( 'wincher_integration_active', false );
	}
}
updated-importer-framework-conditional.php000066600000000637151123032010015034 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Feature flag conditional for the updated importer framework.
 */
class Updated_Importer_Framework_Conditional extends Feature_Flag_Conditional {

	/**
	 * Returns the name of the updated importer framework feature flag.
	 *
	 * @return string The name of the feature flag.
	 */
	protected function get_feature_flag() {
		return 'UPDATED_IMPORTER_FRAMEWORK';
	}
}
the-events-calendar-conditional.php000066600000000573151123032010013404 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Conditional that is only met when The Events Calendar exists.
 */
class The_Events_Calendar_Conditional implements Conditional {

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		return \defined( 'TRIBE_EVENTS_FILE' );
	}
}
get-request-conditional.php000066600000000722151123032010012014 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Conditional that is only met when the current request uses the GET method.
 */
class Get_Request_Conditional implements Conditional {

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] === 'GET' ) {
			return true;
		}

		return false;
	}
}
new-settings-ui-conditional.php000066600000000543151123032010012612 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Feature flag conditional for the new settings UI.
 */
class New_Settings_Ui_Conditional extends Feature_Flag_Conditional {

	/**
	 * Returns the name of the feature flag.
	 *
	 * @return string The name of the feature flag.
	 */
	protected function get_feature_flag() {
		return 'NEW_SETTINGS_UI';
	}
}
xmlrpc-conditional.php000066600000000670151123032010011056 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Conditional that is met when the current request is an XML-RPC request.
 */
class XMLRPC_Conditional implements Conditional {

	/**
	 * Returns whether the current request is an XML-RPC request.
	 *
	 * @return bool `true` when the current request is an XML-RPC request, `false` if not.
	 */
	public function is_met() {
		return ( \defined( 'XMLRPC_REQUEST' ) && \XMLRPC_REQUEST );
	}
}

jetpack-conditional.php000066600000000637151123032010011175 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Conditional that is only met when Jetpack exists.
 */
class Jetpack_Conditional implements Conditional {

	/**
	 * Returns `true` when the Jetpack plugin exists on this
	 * WordPress installation.
	 *
	 * @return bool `true` when the Jetpack plugin exists on this WordPress installation.
	 */
	public function is_met() {
		return \class_exists( 'Jetpack' );
	}
}
admin/post-conditional.php000066600000001340151123032010011621 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals\Admin;

use Yoast\WP\SEO\Conditionals\Conditional;

/**
 * Conditional that is only met when on a post edit or new post page.
 */
class Post_Conditional implements Conditional {

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		global $pagenow;

		// Current page is the creation of a new post (type, i.e. post, page, custom post or attachment).
		if ( $pagenow === 'post-new.php' ) {
			return true;
		}

		// Current page is the edit page of an existing post (type, i.e. post, page, custom post or attachment).
		if ( $pagenow === 'post.php' ) {
			return true;
		}

		return false;
	}
}
admin/doing-post-quick-edit-save-conditional.php000066600000001771151123032010015720 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals\Admin;

use Yoast\WP\SEO\Conditionals\Conditional;

/**
 * Checks if the post is saved by inline-save. This is the case when doing quick edit.
 *
 * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded -- Base class can't be written shorter without abbreviating.
 */
class Doing_Post_Quick_Edit_Save_Conditional implements Conditional {

	/**
	 * Checks if the current request is ajax and the action is inline-save.
	 *
	 * @return bool True when the quick edit action is executed.
	 */
	public function is_met() {
		if ( ! \wp_doing_ajax() ) {
			return false;
		}

		// Do the same nonce check as is done in wp_ajax_inline_save because we hook into that request.
		if ( ! \check_ajax_referer( 'inlineeditnonce', '_inline_edit', false ) ) {
			return false;
		}

		if ( ! isset( $_POST['action'] ) ) {
			return false;
		}

		$sanitized_action = \sanitize_text_field( \wp_unslash( $_POST['action'] ) );

		return ( $sanitized_action === 'inline-save' );
	}
}
admin/licenses-page-conditional.php000066600000001212151123032010013351 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals\Admin;

use Yoast\WP\SEO\Conditionals\Conditional;

/**
 * Conditional that is only met when current page is the tools page.
 */
class Licenses_Page_Conditional implements Conditional {

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		global $pagenow;

		if ( $pagenow !== 'admin.php' ) {
			return false;
		}

		// phpcs:ignore WordPress.Security.NonceVerification -- This is not a form.
		if ( isset( $_GET['page'] ) && $_GET['page'] === 'wpseo_licenses' ) {
			return true;
		}

		return false;
	}
}
admin/posts-overview-or-ajax-conditional.php000066600000000746151123032010015220 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals\Admin;

use Yoast\WP\SEO\Conditionals\Conditional;

/**
 * Conditional that is only met when on a post overview page or during an ajax request.
 */
class Posts_Overview_Or_Ajax_Conditional implements Conditional {

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		global $pagenow;
		return $pagenow === 'edit.php' || \wp_doing_ajax();
	}
}
admin/estimated-reading-time-conditional.php000066600000003112151123032010015155 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals\Admin;

use Yoast\WP\SEO\Conditionals\Conditional;
use Yoast\WP\SEO\Helpers\Input_Helper;

/**
 * Conditional that is only when we want the Estimated Reading Time.
 */
class Estimated_Reading_Time_Conditional implements Conditional {

	/**
	 * The Post Conditional.
	 *
	 * @var Post_Conditional
	 */
	protected $post_conditional;

	/**
	 * The Input Helper.
	 *
	 * @var Input_Helper
	 */
	protected $input_helper;

	/**
	 * Constructs the Estimated Reading Time Conditional.
	 *
	 * @param Post_Conditional $post_conditional The post conditional.
	 * @param Input_Helper     $input_helper     The input helper.
	 */
	public function __construct( Post_Conditional $post_conditional, Input_Helper $input_helper ) {
		$this->post_conditional = $post_conditional;
		$this->input_helper     = $input_helper;
	}

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		// Check if we are in our Elementor ajax request (for saving).
		if ( \wp_doing_ajax() ) {
			$post_action = $this->input_helper->filter( \INPUT_POST, 'action', \FILTER_SANITIZE_STRING );
			if ( $post_action === 'wpseo_elementor_save' ) {
				return true;
			}
		}

		if ( ! $this->post_conditional->is_met() ) {
			return false;
		}

		// We don't support Estimated Reading Time on the attachment post type.
		$post_id = (int) $this->input_helper->filter( \INPUT_GET, 'post', \FILTER_SANITIZE_NUMBER_INT );
		if ( \get_post_type( $post_id ) === 'attachment' ) {
			return false;
		}

		return true;
	}
}
import-tool-selected-conditional.php000066600000001050151123032010013615 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Conditional that is only met when current page is not a specific tool's page.
 */
class Import_Tool_Selected_Conditional implements Conditional {

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- We just check whether a URL parameter does not exist.
		return ( isset( $_GET['tool'] ) && $_GET['tool'] === 'import-export' );
	}
}
migrations-conditional.php000066600000001457151123032010011731 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

use Yoast\WP\SEO\Config\Migration_Status;

/**
 * Class for integrations that depend on having all migrations run.
 */
class Migrations_Conditional implements Conditional {

	/**
	 * The migration status.
	 *
	 * @var Migration_Status
	 */
	protected $migration_status;

	/**
	 * Migrations_Conditional constructor.
	 *
	 * @param Migration_Status $migration_status The migration status object.
	 */
	public function __construct( Migration_Status $migration_status ) {
		$this->migration_status = $migration_status;
	}

	/**
	 * Returns `true` when all database migrations have been run.
	 *
	 * @return bool `true` when all database migrations have been run.
	 */
	public function is_met() {
		return $this->migration_status->is_version( 'free', \WPSEO_VERSION );
	}
}
yoast-tools-page-conditional.php000066600000001176151123032010012762 0ustar00<?php // phpcs:ignore Yoast.Files.FileName.InvalidClassFileName -- Reason: this explicitly concerns the Yoast tools page.

namespace Yoast\WP\SEO\Conditionals;

/**
 * Conditional that is only met when current page is the tools page.
 */
class Yoast_Tools_Page_Conditional implements Conditional {

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		global $pagenow;

		if ( $pagenow !== 'admin.php' ) {
			return false;
		}

		if ( isset( $_GET['page'] ) && $_GET['page'] === 'wpseo_tools' ) {
			return true;
		}

		return false;
	}
}
non-multisite-conditional.php000066600000000564151123032010012362 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Conditional that is only met when we aren't in a multisite setup.
 */
class Non_Multisite_Conditional implements Conditional {

	/**
	 * Returns `true` when we aren't in a multisite setup.
	 *
	 * @return bool `true` when we aren't in a multisite setup.
	 */
	public function is_met() {
		return ! \is_multisite();
	}
}
robots-txt-conditional.php000066600000003312151123032010011672 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Conditional that is only met when on the front end or Yoast file editor page.
 */
class Robots_Txt_Conditional implements Conditional {

	/**
	 * Holds the Front_End_Conditional instance.
	 *
	 * @var Front_End_Conditional
	 */
	protected $front_end_conditional;

	/**
	 * Constructs the class.
	 *
	 * @param Front_End_Conditional $front_end_conditional The front end conditional.
	 */
	public function __construct( Front_End_Conditional $front_end_conditional ) {
		$this->front_end_conditional = $front_end_conditional;
	}

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		return $this->front_end_conditional->is_met() || $this->is_file_editor_page();
	}

	/**
	 * Returns whether the current page is the file editor page.
	 *
	 * This checks for two locations:
	 * - Multisite network admin file editor page
	 * - Single site file editor page (under tools)
	 *
	 * @return bool
	 */
	protected function is_file_editor_page() {
		global $pagenow;

		if ( $pagenow !== 'admin.php' ) {
			return false;
		}

		// phpcs:ignore WordPress.Security.NonceVerification -- This is not a form.
		if ( isset( $_GET['page'] ) && $_GET['page'] === 'wpseo_files' && \is_multisite() && \is_network_admin() ) {
			return true;
		}

		// phpcs:ignore WordPress.Security.NonceVerification -- This is not a form.
		if ( ! ( isset( $_GET['page'] ) && $_GET['page'] === 'wpseo_tools' ) ) {
			return false;
		}

		// phpcs:ignore WordPress.Security.NonceVerification -- This is not a form.
		if ( isset( $_GET['tool'] ) && $_GET['tool'] === 'file-editor' ) {
			return true;
		}

		return false;
	}
}
third-party/elementor-edit-conditional.php000066600000001612151123032010014732 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals\Third_Party;

use Yoast\WP\SEO\Conditionals\Conditional;

/**
 * Conditional that is only met when on an Elementor edit page or when the current
 * request is an ajax request for saving our post meta data.
 */
class Elementor_Edit_Conditional implements Conditional {

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		global $pagenow;

		// Check if we are on an Elementor edit page.
		$get_action = \filter_input( \INPUT_GET, 'action', \FILTER_SANITIZE_STRING );
		if ( $pagenow === 'post.php' && $get_action === 'elementor' ) {
			return true;
		}

		// Check if we are in our Elementor ajax request.
		$post_action = \filter_input( \INPUT_POST, 'action', \FILTER_SANITIZE_STRING );
		return \wp_doing_ajax() && $post_action === 'wpseo_elementor_save';
	}
}
third-party/wpml-wpseo-conditional.php000066600000001301151123032010014122 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals\Third_Party;

use Yoast\WP\SEO\Conditionals\Conditional;

/**
 * Conditional that is met when the Yoast SEO Multilingual plugin,
 * a glue plugin developed by and for WPML, is active.
 */
class WPML_WPSEO_Conditional implements Conditional {

	/**
	 * Path to the Yoast SEO Multilingual plugin file.
	 *
	 * @internal
	 */
	const PATH_TO_WPML_WPSEO_PLUGIN_FILE = 'wp-seo-multilingual/plugin.php';

	/**
	 * Returns whether or not the Yoast SEO Multilingual plugin is active.
	 *
	 * @return bool Whether or not the Yoast SEO Multilingual plugin is active.
	 */
	public function is_met() {
		return \is_plugin_active( self::PATH_TO_WPML_WPSEO_PLUGIN_FILE );
	}
}
third-party/wordproof-plugin-inactive-conditional.php000066600000000751151123032010017135 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals\Third_Party;

use Yoast\WP\SEO\Conditionals\Conditional;

/**
 * Conditional that is met when the WordProof Timestamp plugin is inactive.
 */
class Wordproof_Plugin_Inactive_Conditional implements Conditional {

	/**
	 * Returns whether or not the WordProof Timestamp plugin is active.
	 *
	 * @return bool Whether or not the WordProof Timestamp plugin is active.
	 */
	public function is_met() {
		return ! \defined( 'WORDPROOF_VERSION' );
	}
}
third-party/w3-total-cache-conditional.php000066600000000747151123032010014540 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals\Third_Party;

use Yoast\WP\SEO\Conditionals\Conditional;

/**
 * Conditional that is only met when in the admin.
 */
class W3_Total_Cache_Conditional implements Conditional {

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		if ( ! \defined( 'W3TC_DIR' ) ) {
			return false;
		}

		return \function_exists( 'w3tc_objectcache_flush' );
	}
}
third-party/coauthors-plus-activated-conditional.php000066600000000775151123032010016760 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals\Third_Party;

use Yoast\WP\SEO\Conditionals\Conditional;

/**
 * Conditional that is met when the CoAuthors Plus plugin is installed and activated.
 */
class CoAuthors_Plus_Activated_Conditional implements Conditional {

	/**
	 * Checks if the CoAuthors Plus plugin is installed and activated.
	 *
	 * @return bool `true` when the CoAuthors Plus plugin is installed and activated.
	 */
	public function is_met() {
		return \defined( 'COAUTHORS_PLUS_VERSION' );
	}
}
third-party/elementor-activated-conditional.php000066600000000745151123032010015757 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals\Third_Party;

use Yoast\WP\SEO\Conditionals\Conditional;

/**
 * Conditional that is met when the Elementor plugin is installed and activated.
 */
class Elementor_Activated_Conditional implements Conditional {

	/**
	 * Checks if the Elementor plugins is installed and activated.
	 *
	 * @return bool `true` when the Elementor plugin is installed and activated.
	 */
	public function is_met() {
		return \defined( 'ELEMENTOR__FILE__' );
	}
}
third-party/polylang-conditional.php000066600000000666151123032010013652 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals\Third_Party;

use Yoast\WP\SEO\Conditionals\Conditional;

/**
 * Conditional that is only met when the Polylang plugin is active.
 */
class Polylang_Conditional implements Conditional {

	/**
	 * Checks whether the Polylang plugin is installed and active.
	 *
	 * @return bool Whether Polylang is installed and active.
	 */
	public function is_met() {
		return \defined( 'POLYLANG_FILE' );
	}
}
third-party/coauthors-plus-flag-conditional.php000066600000000721151123032010015714 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals\Third_Party;

use Yoast\WP\SEO\Conditionals\Feature_Flag_Conditional;

/**
 * Feature flag conditional for the CoAuthors Plus integration.
 */
class CoAuthors_Plus_Flag_Conditional extends Feature_Flag_Conditional {

	/**
	 * Returns the name of the CoAuthors Plus integration feature flag.
	 *
	 * @return string The name of the feature flag.
	 */
	protected function get_feature_flag() {
		return 'COAUTHORS_PLUS';
	}
}
third-party/wordproof-integration-active-conditional.php000066600000001516151123032010017633 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals\Third_Party;

use Yoast\WP\SEO\Conditionals\Conditional;
use Yoast\WP\SEO\Helpers\Wordproof_Helper;

/**
 * Conditional that is met when the WordProof integration is toggled on.
 */
class Wordproof_Integration_Active_Conditional implements Conditional {

	/**
	 * The WordProof helper.
	 *
	 * @var Wordproof_Helper
	 */
	private $wordproof;

	/**
	 * WordProof integration active constructor.
	 *
	 * @param Wordproof_Helper $wordproof The options helper.
	 */
	public function __construct( Wordproof_Helper $wordproof ) {
		$this->wordproof = $wordproof;
	}

	/**
	 * Returns whether or not the WordProof Timestamp plugin is active.
	 *
	 * @return bool Whether or not the WordProof Timestamp plugin is active.
	 */
	public function is_met() {
		return $this->wordproof->integration_is_active();
	}
}
third-party/wpml-conditional.php000066600000000627151123032010013001 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals\Third_Party;

use Yoast\WP\SEO\Conditionals\Conditional;

/**
 * Conditional that is only met when WPML is active.
 */
class WPML_Conditional implements Conditional {

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		return \defined( 'WPML_PLUGIN_FILE' );
	}
}
third-party/translatepress-conditional.php000066600000000710151123032010015065 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals\Third_Party;

use Yoast\WP\SEO\Conditionals\Conditional;

/**
 * Conditional that is only met when the TranslatePress plugin is active.
 */
class TranslatePress_Conditional implements Conditional {

	/**
	 * Checks whether the TranslatePress plugin is active.
	 *
	 * @return bool Whether the TranslatePress plugin is active.
	 */
	public function is_met() {
		return \class_exists( 'TRP_Translate_Press' );
	}
}
front-end-conditional.php000066600000000512151123032010011440 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Conditional that is only met when NOT in the admin.
 */
class Front_End_Conditional implements Conditional {

	/**
	 * Returns `true` when NOT on an admin page.
	 *
	 * @return bool `true` when NOT on an admin page.
	 */
	public function is_met() {
		return ! \is_admin();
	}
}
woocommerce-conditional.php000066600000000634151123032010012070 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Conditional that is only met when WooCommerce is active.
 */
class WooCommerce_Conditional implements Conditional {

	/**
	 * Returns `true` when the WooCommerce plugin is installed and activated.
	 *
	 * @return bool `true` when the WooCommerce plugin is installed and activated.
	 */
	public function is_met() {
		return \class_exists( 'WooCommerce' );
	}
}
primary-category-conditional.php000066600000002620151123032010013044 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

use Yoast\WP\SEO\Helpers\Current_Page_Helper;

/**
 * Conditional that is only met when in frontend or page is a post overview or post add/edit form.
 */
class Primary_Category_Conditional implements Conditional {

	/**
	 * The current page helper.
	 *
	 * @var Current_Page_Helper
	 */
	private $current_page;

	/**
	 * Primary_Category_Conditional constructor.
	 *
	 * @param Current_Page_Helper $current_page The current page helper.
	 */
	public function __construct( Current_Page_Helper $current_page ) {
		$this->current_page = $current_page;
	}

	/**
	 * Returns `true` when on the frontend,
	 * or when on the post overview, post edit or new post admin page,
	 * or when on additional admin pages, allowed by filter.
	 *
	 * @return bool `true` when on the frontend, or when on the post overview,
	 *          post edit, new post admin page or additional admin pages, allowed by filter.
	 */
	public function is_met() {
		if ( ! \is_admin() ) {
			return true;
		}
		/**
		 * Filter: Adds the possibility to use primary category at additional admin pages.
		 *
		 * @param array $admin_pages List of additional admin pages.
		 */
		$additional_pages = \apply_filters( 'wpseo_primary_category_admin_pages', [] );
		return \in_array( $this->current_page->get_current_admin_page(), \array_merge( [ 'edit.php', 'post.php', 'post-new.php' ], $additional_pages ), true );
	}
}
wincher-conditional.php000066600000000240151123032010011201 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Conditional for the Wincher integration.
 */
class Wincher_Conditional extends Non_Multisite_Conditional {}
no-conditionals-trait.php000066600000000575151123032010011475 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Trait for integrations that do not have any conditionals.
 */
trait No_Conditionals {

	/**
	 * Returns an empty array, meaning no conditionals are required to load whatever uses this trait.
	 *
	 * @return array The conditionals that must be met to load this.
	 */
	public static function get_conditionals() {
		return [];
	}
}
should-index-links-conditional.php000066600000002014151123032010013264 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

use Yoast\WP\SEO\Helpers\Options_Helper;

/**
 * Should_Index_Links_Conditional class.
 */
class Should_Index_Links_Conditional implements Conditional {

	/**
	 * The options helper.
	 *
	 * @var Options_Helper
	 */
	protected $options_helper;

	/**
	 * Should_Index_Links_Conditional constructor.
	 *
	 * @param Options_Helper $options_helper The options helper.
	 */
	public function __construct( Options_Helper $options_helper ) {
		$this->options_helper = $options_helper;
	}

	/**
	 * Returns `true` when the links on this website should be indexed.
	 *
	 * @return bool `true` when the links on this website should be indexed.
	 */
	public function is_met() {
		$should_index_links = $this->options_helper->get( 'enable_text_link_counter' );

		/**
		 * Filter: 'wpseo_should_index_links' - Allows disabling of Yoast's links indexation.
		 *
		 * @api bool To disable the indexation, return false.
		 */
		return \apply_filters( 'wpseo_should_index_links', $should_index_links );
	}
}
premium-inactive-conditional.php000066600000000611151123032010013022 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Abstract class for creating conditionals based on feature flags.
 */
class Premium_Inactive_Conditional implements Conditional {

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		return ! \YoastSEO()->helpers->product->is_premium();
	}
}
feature-flag-conditional.php000066600000001617151123032010012115 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Abstract class for creating conditionals based on feature flags.
 */
abstract class Feature_Flag_Conditional implements Conditional {

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		$feature_flag = \strtoupper( $this->get_feature_flag() );

		return \defined( 'YOAST_SEO_' . $feature_flag ) && \constant( 'YOAST_SEO_' . $feature_flag ) === true;
	}

	/**
	 * Returns the name of the feature flag.
	 * 'YOAST_SEO_' is automatically prepended to it and it will be uppercased.
	 *
	 * @return string the name of the feature flag.
	 */
	abstract protected function get_feature_flag();

	/**
	 * Returns the feature name.
	 *
	 * @return string the name of the feature flag.
	 */
	public function get_feature_name() {
		return $this->get_feature_flag();
	}
}
settings-conditional.php000066600000002703151123032010011410 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Class Settings_Conditional.
 */
class Settings_Conditional implements Conditional {

	/**
	 * Holds New_Settings_Ui_Conditional.
	 *
	 * @var New_Settings_Ui_Conditional
	 */
	protected $new_settings_ui_conditional;

	/**
	 * Holds User_Can_Manage_Wpseo_Options_Conditional.
	 *
	 * @var User_Can_Manage_Wpseo_Options_Conditional
	 */
	protected $user_can_manage_wpseo_options_conditional;

	/**
	 * Constructs Settings_Conditional.
	 *
	 * @param New_Settings_Ui_Conditional               $new_settings_ui_conditional               The New_Settings_Ui_Conditional.
	 * @param User_Can_Manage_Wpseo_Options_Conditional $user_can_manage_wpseo_options_conditional The User_Can_Manage_Wpseo_Options_Conditional.
	 */
	public function __construct(
		New_Settings_Ui_Conditional $new_settings_ui_conditional,
		User_Can_Manage_Wpseo_Options_Conditional $user_can_manage_wpseo_options_conditional
	) {
		$this->new_settings_ui_conditional               = $new_settings_ui_conditional;
		$this->user_can_manage_wpseo_options_conditional = $user_can_manage_wpseo_options_conditional;
	}

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		if ( ! $this->new_settings_ui_conditional->is_met() ) {
			return false;
		}
		if ( ! $this->user_can_manage_wpseo_options_conditional->is_met() ) {
			return false;
		}

		return true;
	}
}
admin-conditional.php000066600000000513151123032010010635 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Conditional that is only met when in the admin.
 */
class Admin_Conditional implements Conditional {

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		return \is_admin();
	}
}
indexables-page-conditional.php000066600000000547151123032010012604 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Feature flag conditional for the new indexables page.
 */
class Indexables_Page_Conditional extends Feature_Flag_Conditional {

	/**
	 * Returns the name of the feature flag.
	 *
	 * @return string The name of the feature flag.
	 */
	protected function get_feature_flag() {
		return 'INDEXABLES_PAGE';
	}
}
schema-blocks-conditional.php000066600000000661151123032010012264 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Checks if the YOAST_SEO_SCHEMA_BLOCKS constant is set.
 */
class Schema_Blocks_Conditional extends Feature_Flag_Conditional {

	/**
	 * Returns the name of the feature flag.
	 * 'YOAST_SEO_' is automatically prepended to it and it will be uppercased.
	 *
	 * @return string the name of the feature flag.
	 */
	protected function get_feature_flag() {
		return 'SCHEMA_BLOCKS';
	}
}
development-conditional.php000066600000000601151123032010012065 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

use WPSEO_Utils;

/**
 * Conditional that is only met when in development mode.
 */
class Development_Conditional implements Conditional {

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		return WPSEO_Utils::is_development_mode();
	}
}
not-admin-ajax-conditional.php000066600000000556151123032010012363 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Conditional that is only met when not in a admin-ajax request.
 */
class Not_Admin_Ajax_Conditional implements Conditional {

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		return ( ! \wp_doing_ajax() );
	}
}
wincher-token-conditional.php000066600000001250151123032010012321 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

use Yoast\WP\SEO\Config\Wincher_Client;

/**
 * Conditional that is only met when the Wincher token is set.
 */
class Wincher_Token_Conditional implements Conditional {

	/**
	 * The Wincher client.
	 *
	 * @var Wincher_Client
	 */
	private $client;

	/**
	 * Wincher_Token_Conditional constructor.
	 *
	 * @param Wincher_Client $client The Wincher client.
	 */
	public function __construct( Wincher_Client $client ) {
		$this->client = $client;
	}

	/**
	 * Returns whether this conditional is met.
	 *
	 * @return bool Whether the conditional is met.
	 */
	public function is_met() {
		return $this->client->has_valid_tokens();
	}
}
wincher-automatically-track-conditional.php000066600000001367151123032010015164 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

use Yoast\WP\SEO\Helpers\Options_Helper;

/**
 * Conditional that is only met when the Wincher automatic tracking is enabled.
 */
class Wincher_Automatically_Track_Conditional implements Conditional {

	/**
	 * The options helper.
	 *
	 * @var Options_Helper
	 */
	private $options;

	/**
	 * Wincher_Automatically_Track_Conditional constructor.
	 *
	 * @param Options_Helper $options The options helper.
	 */
	public function __construct( Options_Helper $options ) {
		$this->options = $options;
	}

	/**
	 * Returns whether this conditional is met.
	 *
	 * @return bool Whether the conditional is met.
	 */
	public function is_met() {
		return $this->options->get( 'wincher_automatically_add_keyphrases' );
	}
}
user-can-publish-posts-and-pages-conditional.php000066600000001036151123032010015732 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Conditional that is only met when the current user has the `wpseo_manage_options` capability.
 *
 * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded
 */
class User_Can_Publish_Posts_And_Pages_Conditional implements Conditional {

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		return \current_user_can( 'publish_posts' ) && \current_user_can( 'publish_pages' );
	}
}
yoast-admin-and-dashboard-conditional.php000066600000003170151123032010014461 0ustar00<?php // phpcs:ignore Yoast.Files.FileName.InvalidClassFileName -- Reason: this explicitly concerns the Yoast admin and dashboard.

namespace Yoast\WP\SEO\Conditionals;

/**
 * Conditional that is only met when in the admin dashboard, update or Yoast SEO pages.
 */
class Yoast_Admin_And_Dashboard_Conditional implements Conditional {

	/**
	 * Returns `true` when on the admin dashboard, update or Yoast SEO pages.
	 *
	 * @return bool `true` when on the admin dashboard, update or Yoast SEO pages.
	 */
	public function is_met() {
		global $pagenow;

		// Bail out early if we're not on the front-end.
		if ( ! \is_admin() ) {
			return false;
		}

		// Do not output on plugin / theme upgrade pages or when WordPress is upgrading.
		if ( ( \defined( 'IFRAME_REQUEST' ) && \IFRAME_REQUEST ) || $this->on_upgrade_page() || \wp_installing() ) {
			return false;
		}

		if ( $pagenow === 'admin.php' && isset( $_GET['page'] ) && \strpos( $_GET['page'], 'wpseo' ) === 0 ) {
			return true;
		}

		$target_pages = [
			'index.php',
			'plugins.php',
			'update-core.php',
			'options-permalink.php',
		];

		return \in_array( $pagenow, $target_pages, true );
	}

	/**
	 * Checks if we are on a theme or plugin upgrade page.
	 *
	 * @return bool Whether we are on a theme or plugin upgrade page.
	 */
	private function on_upgrade_page() {
		/*
		 * IFRAME_REQUEST is not defined on these pages,
		 * though these action pages do show when upgrading themes or plugins.
		 */
		$actions = [ 'do-theme-upgrade', 'do-plugin-upgrade', 'do-core-upgrade', 'do-core-reinstall' ];
		return isset( $_GET['action'] ) && \in_array( $_GET['action'], $actions, true );
	}
}
user-can-manage-wpseo-options-conditional.php000066600000000772151123032010015343 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Conditional that is only met when the current user has the `wpseo_manage_options` capability.
 *
 * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded
 */
class User_Can_Manage_Wpseo_Options_Conditional implements Conditional {

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		return \current_user_can( 'wpseo_manage_options' );
	}
}
headless-rest-endpoints-enabled-conditional.php000066600000001457151123032010015711 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

use Yoast\WP\SEO\Helpers\Options_Helper;

/**
 * Conditional that is only met when the headless rest endpoints are enabled.
 */
class Headless_Rest_Endpoints_Enabled_Conditional implements Conditional {

	/**
	 * The options helper.
	 *
	 * @var Options_Helper
	 */
	private $options;

	/**
	 * Headless_Rest_Endpoints_Enabled_Conditional constructor.
	 *
	 * @param Options_Helper $options The options helper.
	 */
	public function __construct( Options_Helper $options ) {
		$this->options = $options;
	}

	/**
	 * Returns `true` whether the headless REST endpoints have been enabled.
	 *
	 * @return bool `true` when the headless REST endpoints have been enabled.
	 */
	public function is_met() {
		return $this->options->get( 'enable_headless_rest_endpoints' );
	}
}
premium-active-conditional.php000066600000000546151123032010012502 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Class Premium_Active_Conditional.
 */
class Premium_Active_Conditional implements Conditional {

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		return \YoastSEO()->helpers->product->is_premium();
	}
}
addon-installation-conditional.php000066600000000666151123032010013342 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Checks if the Addon_Installation constant is set.
 */
class Addon_Installation_Conditional extends Feature_Flag_Conditional {

	/**
	 * Returns the name of the feature flag.
	 * 'YOAST_SEO_' is automatically prepended to it and it will be uppercased.
	 *
	 * @return string the name of the feature flag.
	 */
	protected function get_feature_flag() {
		return 'ADDON_INSTALLATION';
	}
}
news-conditional.php000066600000000550151123032010010522 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Conditional that is only met when news SEO is activated.
 */
class News_Conditional implements Conditional {

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		return \defined( 'WPSEO_NEWS_VERSION' );
	}
}
open-graph-conditional.php000066600000001330151123032010011603 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

use Yoast\WP\SEO\Helpers\Options_Helper;

/**
 * Conditional that is only met when the Open Graph feature is enabled.
 */
class Open_Graph_Conditional implements Conditional {

	/**
	 * The options helper.
	 *
	 * @var Options_Helper
	 */
	private $options;

	/**
	 * Open_Graph_Conditional constructor.
	 *
	 * @param Options_Helper $options The options helper.
	 */
	public function __construct( Options_Helper $options ) {
		$this->options = $options;
	}

	/**
	 * Returns `true` when the Open Graph feature is enabled.
	 *
	 * @return bool `true` when the Open Graph feature is enabled.
	 */
	public function is_met() {
		return $this->options->get( 'opengraph' ) === true;
	}
}
semrush-enabled-conditional.php000066600000001343151123032010012625 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

use Yoast\WP\SEO\Helpers\Options_Helper;

/**
 * Conditional that is only met when the SEMrush integration is enabled.
 */
class SEMrush_Enabled_Conditional implements Conditional {

	/**
	 * The options helper.
	 *
	 * @var Options_Helper
	 */
	private $options;

	/**
	 * SEMrush_Enabled_Conditional constructor.
	 *
	 * @param Options_Helper $options The options helper.
	 */
	public function __construct( Options_Helper $options ) {
		$this->options = $options;
	}

	/**
	 * Returns whether or not this conditional is met.
	 *
	 * @return bool Whether or not the conditional is met.
	 */
	public function is_met() {
		return $this->options->get( 'semrush_integration_active', false );
	}
}
text-formality-conditional.php000066600000000661151123032010012541 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Checks if the YOAST_SEO_TEXT_FORMALITY constant is set.
 */
class Text_Formality_Conditional extends Feature_Flag_Conditional {

	/**
	 * Returns the name of the feature flag.
	 * 'YOAST_SEO_' is automatically prepended to it and it will be uppercased.
	 *
	 * @return string the name of the feature flag.
	 */
	public function get_feature_flag() {
		return 'TEXT_FORMALITY';
	}
}
norwegian-readability-conditional.php000066600000001132151140066630014041 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Checks if the YOAST_SEO_NORWEGIAN_READABILITY constant is set.
 *
 * @deprecated 16.8
 * @codeCoverageIgnore
 */
class Norwegian_Readability_Conditional extends Feature_Flag_Conditional {

	/**
	 * Returns the name of the feature flag.
	 * 'YOAST_SEO_' is automatically prepended to it and it will be uppercased.
	 *
	 * @deprecated 16.8
	 * @codeCoverageIgnore
	 *
	 * @return string the name of the feature flag.
	 */
	public function get_feature_flag() {
		\_deprecated_function( __METHOD__, 'WPSEO 16.8' );
		return 'NORWEGIAN_READABILITY';
	}
}
greek-support-conditional.php000066600000001102151140066630012365 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Checks if the YOAST_SEO_GREEK_SUPPORT constant is set.
 *
 * @deprecated 17.5
 * @codeCoverageIgnore
 */
class Greek_Support_Conditional extends Feature_Flag_Conditional {

	/**
	 * Returns the name of the feature flag.
	 * 'YOAST_SEO_' is automatically prepended to it and it will be uppercased.
	 *
	 * @deprecated 17.5
	 * @codeCoverageIgnore
	 *
	 * @return string the name of the feature flag.
	 */
	public function get_feature_flag() {
		\_deprecated_function( __METHOD__, 'WPSEO 17.5' );
		return 'GREEK_SUPPORT';
	}
}
farsi-support-conditional.php000066600000001102151140066630012374 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Checks if the YOAST_SEO_FARSI_SUPPORT constant is set.
 *
 * @deprecated 17.2
 * @codeCoverageIgnore
 */
class Farsi_Support_Conditional extends Feature_Flag_Conditional {

	/**
	 * Returns the name of the feature flag.
	 * 'YOAST_SEO_' is automatically prepended to it and it will be uppercased.
	 *
	 * @deprecated 17.2
	 * @codeCoverageIgnore
	 *
	 * @return string the name of the feature flag.
	 */
	public function get_feature_flag() {
		\_deprecated_function( __METHOD__, 'WPSEO 17.2' );
		return 'FARSI_SUPPORT';
	}
}
japanese-support-conditional.php000066600000001113151140066630013060 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Checks if the YOAST_SEO_JAPANESE_SUPPORT constant is set.
 *
 * @deprecated 17.9
 * @codeCoverageIgnore
 */
class Japanese_Support_Conditional extends Feature_Flag_Conditional {

	/**
	 * Returns the name of the feature flag.
	 * 'YOAST_SEO_' is automatically prepended to it and it will be uppercased.
	 *
	 * @deprecated 17.9
	 * @codeCoverageIgnore
	 *
	 * @return string the name of the feature flag.
	 */
	public function get_feature_flag() {
		\_deprecated_function( __METHOD__, 'WPSEO 17.9' );
		return 'JAPANESE_SUPPORT';
	}
}
front-end-inspector-conditional.php000066600000000724151140066630013467 0ustar00<?php

namespace Yoast\WP\SEO\Conditionals;

/**
 * Feature flag conditional for the front-end inspector.
 *
 * @deprecated 19.5
 */
class Front_End_Inspector_Conditional extends Feature_Flag_Conditional {

	/**
	 * Returns the name of the feature flag.
	 *
	 * @deprecated 19.5
	 *
	 * @return string The name of the feature flag.
	 */
	protected function get_feature_flag() {
		\_deprecated_function( __METHOD__, 'WPSEO 19.5' );
		return 'FRONT_END_INSPECTOR';
	}
}
.htaccess000066600000000424151145133020006341 0ustar00<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>admin/.htaccess000066600000000424151145411240007434 0ustar00<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>third-party/.htaccess000066600000000424151145411240010613 0ustar00<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>