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/health-check.tar

health-check.php000066600000004657151131531610007612 0ustar00<?php

namespace Yoast\WP\SEO\Services\Health_Check;

/**
 * Abstract class for all health checks. Provides a uniform interface for the Health_Check_Integration.
 */
abstract class Health_Check {

	/**
	 * The prefix to add to the test identifier. Used to differentiate between Yoast's health checks, and other health checks.
	 */
	const TEST_IDENTIFIER_PREFIX = 'yoast-';

	/**
	 * The object that runs the actual health check.
	 *
	 * @var Runner_Interface
	 */
	private $runner;

	/**
	 * The health check implementation sets the runner so this class can start a health check.
	 *
	 * @param  Runner_Interface $runner The health check runner.
	 * @return void
	 */
	protected function set_runner( $runner ) {
		$this->runner = $runner;
	}

	/**
	 * Returns the identifier of health check implementation. WordPress needs this to manage the health check (https://developer.wordpress.org/reference/hooks/site_status_tests/).
	 *
	 * @return string The identifier that WordPress requires.
	 */
	public function get_test_identifier() {
		$full_class_name            = \get_class( $this );
		$class_name_backslash_index = \strrpos( $full_class_name, '\\' );

		$class_name = $full_class_name;
		if ( $class_name_backslash_index ) {
			$class_name_index = ( $class_name_backslash_index + 1 );
			$class_name       = \substr( $full_class_name, $class_name_index );
		}

		$lowercase            = \strtolower( $class_name );
		$whitespace_as_dashes = \str_replace( '_', '-', $lowercase );
		$with_prefix          = self::TEST_IDENTIFIER_PREFIX . $whitespace_as_dashes;
		return $with_prefix;
	}

	/**
	 * Returns the name of health check implementation that the user can see. WordPress needs this to manage the health check (https://developer.wordpress.org/reference/hooks/site_status_tests/).
	 *
	 * @return string A human-readable label for the health check.
	 */
	abstract public function get_test_label();

	/**
	 * Runs the health check, and returns its result in the format that WordPress requires to show the results to the user (https://developer.wordpress.org/reference/hooks/site_status_test_result/).
	 *
	 * @return string[] The array containing a WordPress site status report.
	 */
	public function run_and_get_result() {
		$this->runner->run();
		return $this->get_result();
	}

	/**
	 * Gets the result from the health check implementation.
	 *
	 * @return string[] The array containing a WordPress site status report.
	 */
	abstract protected function get_result();
}
links-table-runner.php000066600000004000151131531610010764 0ustar00<?php

namespace Yoast\WP\SEO\Services\Health_Check;

use Yoast\WP\SEO\Config\Migration_Status;
use Yoast\WP\SEO\Helpers\Options_Helper;

/**
 * Runs the Links_Table health check.
 */
class Links_Table_Runner implements Runner_Interface {

	/**
	 * Is set to true when the links table is accessible.
	 *
	 * @var bool
	 */
	private $links_table_accessible = false;

	/**
	 * The Migration_Status object used to determine whether the links table is accessible.
	 *
	 * @var Migration_Status
	 */
	private $migration_status;

	/**
	 * The Options_Helper object used to determine whether the health check should run or not.
	 *
	 * @var Options_Helper
	 */
	private $options_helper;

	/**
	 * Constructor.
	 *
	 * @param Migration_Status $migration_status Object used to determine whether the links table is accessible.
	 * @param Options_Helper   $options_helper   Object used to determine whether the health check should run.
	 */
	public function __construct(
		Migration_Status $migration_status,
		Options_Helper $options_helper
	) {
		$this->migration_status = $migration_status;
		$this->options_helper   = $options_helper;
	}

	/**
	 * Runs the health check. Checks if the tagline is set to WordPress' default tagline, or to its set translation.
	 *
	 * @return void
	 */
	public function run() {
		if ( ! $this->should_run() ) {
			return;
		}

		$this->links_table_accessible = $this->migration_status->is_version( 'free', \WPSEO_VERSION );
	}

	/**
	 * Determines whether the health check should run or not.
	 *
	 * @return bool True if the text link counter feature is enabled.
	 */
	public function should_run() {
		$text_link_counter_enabled = $this->options_helper->get( 'enable_text_link_counter' );

		if ( ! \is_bool( $text_link_counter_enabled ) ) {
			return false;
		}

		return $text_link_counter_enabled;
	}

	/**
	 * Returns true if the links table is accessible
	 *
	 * @return bool The boolean indicating if the health check was succesful.
	 */
	public function is_successful() {
		return $this->links_table_accessible;
	}
}
default-tagline-check.php000066600000002702151131531610011377 0ustar00<?php

namespace Yoast\WP\SEO\Services\Health_Check;

/**
 * Passes when the tagline is set to something other than the WordPress default tagline.
 */
class Default_Tagline_Check extends Health_Check {

	/**
	 * Runs the health check.
	 *
	 * @var Default_Tagline_Runner
	 */
	private $runner;

	/**
	 * Generates WordPress-friendly health check results.
	 *
	 * @var Default_Tagline_Reports
	 */
	private $reports;

	/**
	 * Constructor.
	 *
	 * @param  Default_Tagline_Runner  $runner  The object that implements the actual health check.
	 * @param  Default_Tagline_Reports $reports The object that generates WordPress-friendly results.
	 * @return void
	 */
	public function __construct(
		Default_Tagline_Runner $runner,
		Default_Tagline_Reports $reports
	) {
		$this->runner  = $runner;
		$this->reports = $reports;
		$this->reports->set_test_identifier( $this->get_test_identifier() );

		$this->set_runner( $this->runner );
	}

	/**
	 * Returns a human-readable label for this health check.
	 *
	 * @return string The human-readable label.
	 */
	public function get_test_label() {
		return \__( 'Default tagline', 'wordpress-seo' );
	}

	/**
	 * Returns the WordPress-friendly health check result.
	 *
	 * @return string[] The WordPress-friendly health check result.
	 */
	protected function get_result() {
		if ( $this->runner->is_successful() ) {
			return $this->reports->get_success_result();
		}

		return $this->reports->get_has_default_tagline_result();
	}
}
postname-permalink-reports.php000066600000005247151131531610012570 0ustar00<?php

namespace Yoast\WP\SEO\Services\Health_Check;

/**
 * Presents a set of different messages for the Postname_Permalink health check.
 */
class Postname_Permalink_Reports {

	use Reports_Trait;

	/**
	 * Constructor.
	 *
	 * @param  Report_Builder_Factory $report_builder_factory The factory for result builder objects.
	 *                                                        This class uses the report builder to generate WordPress-friendly
	 *                                                        health check results.
	 */
	public function __construct( Report_Builder_Factory $report_builder_factory ) {
		$this->report_builder_factory = $report_builder_factory;
	}

	/**
	 * Returns the report for when permalinks are set to contain the post name.
	 *
	 * @return string[] The message as a WordPress site status report.
	 */
	public function get_success_result() {
		return $this->get_report_builder()
			->set_label( \esc_html__( 'Your permalink structure includes the post name', 'wordpress-seo' ) )
			->set_status_good()
			->set_description( \__( 'You do have your postname in the URL of your posts and pages.', 'wordpress-seo' ) )
			->build();
	}

	/**
	 * Returns the report for when permalinks are not set to contain the post name.
	 *
	 * @return string[] The message as a WordPress site status report.
	 */
	public function get_has_no_postname_in_permalink_result() {
		return $this->get_report_builder()
			->set_label( \__( 'You do not have your postname in the URL of your posts and pages', 'wordpress-seo' ) )
			->set_status_recommended()
			->set_description( $this->get_has_no_postname_in_permalink_description() )
			->set_actions( $this->get_has_no_postname_in_permalink_actions() )
			->build();
	}

	/**
	 * Returns the description for when permalinks are not set to contain the post name.
	 *
	 * @return string The description as a string.
	 */
	private function get_has_no_postname_in_permalink_description() {
		return \sprintf(
			/* translators: %s expands to '/%postname%/' */
			\__( 'It\'s highly recommended to have your postname in the URL of your posts and pages. Consider setting your permalink structure to %s.', 'wordpress-seo' ),
			'<strong>/%postname%/</strong>'
		);
	}

	/**
	 * Returns the actions for when permalinks are not set to contain the post name.
	 *
	 * @return string The actions as a string.
	 */
	private function get_has_no_postname_in_permalink_actions() {
		return \sprintf(
			/* translators: %1$s is a link start tag to the permalink settings page, %2$s is the link closing tag. */
			\__( 'You can fix this on the %1$sPermalink settings page%2$s.', 'wordpress-seo' ),
			'<a href="' . \admin_url( 'options-permalink.php' ) . '">',
			'</a>'
		);
	}
}
runner-interface.php000066600000000425151131531610010526 0ustar00<?php

namespace Yoast\WP\SEO\Services\Health_Check;

/**
 * Interface for the health check runner. The abstract Health_Check uses this to run a health check.
 */
interface Runner_Interface {

	/**
	 * Runs the health check.
	 *
	 * @return void
	 */
	public function run();
}
postname-permalink-runner.php000066600000001615151131531610012376 0ustar00<?php

namespace Yoast\WP\SEO\Services\Health_Check;

/**
 * Runs the Postname_Permalink health check.
 */
class Postname_Permalink_Runner implements Runner_Interface {

	/**
	 * Is set to true when permalinks are set to contain the post name
	 *
	 * @var bool
	 */
	private $permalinks_contain_postname;

	/**
	 * Constructor.
	 */
	public function __construct() {
		$this->permalinks_contain_postname = false;
	}

	/**
	 * Runs the health check. Checks if permalinks are set to contain the post name.
	 *
	 * @return void
	 */
	public function run() {
		$this->permalinks_contain_postname = ( \strpos( \get_option( 'permalink_structure' ), '%postname%' ) !== false );
	}

	/**
	 * Returns true if permalinks are set to contain the post name.
	 *
	 * @return bool True if permalinks are set to contain the post name.
	 */
	public function is_successful() {
		return $this->permalinks_contain_postname;
	}
}

page-comments-runner.php000066600000001504151131531610011324 0ustar00<?php

namespace Yoast\WP\SEO\Services\Health_Check;

/**
 * Runs the Page_Comments health check.
 */
class Page_Comments_Runner implements Runner_Interface {

	/**
	 * Is set to true when comments are set to display on a single page.
	 *
	 * @var bool
	 */
	private $comments_on_single_page;

	/**
	 * Constructor.
	 */
	public function __construct() {
		$this->comments_on_single_page = false;
	}

	/**
	 * Runs the health check. Checks if comments are displayed on a single page.
	 *
	 * @return void
	 */
	public function run() {
		$this->comments_on_single_page = \get_option( 'page_comments' ) !== '1';
	}

	/**
	 * Returns true if comments are displayed on a single page.
	 *
	 * @return bool True if comments are displayed on a single page.
	 */
	public function is_successful() {
		return $this->comments_on_single_page;
	}
}

report-builder.php000066600000011642151131531610010221 0ustar00<?php

namespace Yoast\WP\SEO\Services\Health_Check;

/**
 * Provides an interface to build WordPress-friendly health check results.
 */
class Report_Builder {

	/**
	 * Passed health check.
	 */
	const STATUS_GOOD = 'good';

	/**
	 * Changes are recommended but not necessary.
	 */
	const STATUS_RECOMMENDED = 'recommended';

	/**
	 * Significant issues that the user should consider fixing.
	 */
	const STATUS_CRITICAL = 'critical';

	/**
	 * The user-facing label.
	 *
	 * @var string
	 */
	private $label = '';

	/**
	 * The identifier that WordPress uses for the health check.
	 *
	 * @var string
	 */
	private $test_identifier = '';

	/**
	 * The test status (good, recommended, critical).
	 *
	 * @var string
	 */
	private $status = '';

	/**
	 * The short description for the result.
	 *
	 * @var string
	 */
	private $description = '';

	/**
	 * Actions that the user can take to solve the health check result.
	 *
	 * @var string
	 */
	private $actions = '';

	/**
	 * Sets the label for the health check that the user can see.
	 *
	 * @param  string $label The label that the user can see.
	 * @return Report_Builder This builder.
	 */
	public function set_label( $label ) {
		$this->label = $label;
		return $this;
	}

	/**
	 * Sets the name for the test that the plugin uses to identify the test.
	 *
	 * @param  string $test_identifier The identifier for the health check.
	 * @return Report_Builder This builder.
	 */
	public function set_test_identifier( $test_identifier ) {
		$this->test_identifier = $test_identifier;
		return $this;
	}

	/**
	 * Sets the status of the test result to GOOD (green label).
	 *
	 * @return Report_Builder This builder.
	 */
	public function set_status_good() {
		$this->status = self::STATUS_GOOD;
		return $this;
	}

	/**
	 * Sets the status of the test result to RECOMMENDED (orange label).
	 *
	 * @return Report_Builder This builder.
	 */
	public function set_status_recommended() {
		$this->status = self::STATUS_RECOMMENDED;
		return $this;
	}

	/**
	 * Sets the status of the test result to CRITICAL (red label).
	 *
	 * @return Report_Builder This builder.
	 */
	public function set_status_critical() {
		$this->status = self::STATUS_CRITICAL;
		return $this;
	}

	/**
	 * Sets a description for the test result. This will be the heading for the result in the user interface.
	 *
	 * @param  string $description The description for the test result.
	 * @return Report_Builder This builder.
	 */
	public function set_description( $description ) {
		$this->description = $description;
		return $this;
	}

	/**
	 * Sets a text that describes how the user can solve the failed health check.
	 *
	 * @param  string $actions The descriptive text.
	 * @return Report_Builder This builder.
	 */
	public function set_actions( $actions ) {
		$this->actions = $actions;
		return $this;
	}

	/**
	 * Builds an array of strings in the format that WordPress uses to display health checks (https://developer.wordpress.org/reference/hooks/site_status_test_result/).
	 *
	 * @return array The report in WordPress' site status report format.
	 */
	public function build() {
		return [
			'label'       => $this->label,
			'status'      => $this->status,
			'badge'       => $this->get_badge(),
			'description' => $this->description,
			'actions'     => $this->get_actions_with_signature(),
			'test'        => $this->test_identifier,
		];
	}

	/**
	 * Generates a badge that the user can see.
	 *
	 * @return string[] The badge.
	 */
	private function get_badge() {
		return [
			'label' => $this->get_badge_label(),
			'color' => $this->get_badge_color(),
		];
	}

	/**
	 * Generates the label for a badge.
	 *
	 * @return string The badge label.
	 */
	private function get_badge_label() {
		return \__( 'SEO', 'wordpress-seo' );
	}

	/**
	 * Generates the color for the badge using the current status.
	 *
	 * @return string The color for the badge's outline.
	 */
	private function get_badge_color() {
		if ( $this->status === self::STATUS_CRITICAL || $this->status === self::STATUS_RECOMMENDED ) {
			return 'red';
		}

		return 'blue';
	}

	/**
	 * Concatenates the set actions with Yoast's signature.
	 *
	 * @return string A string containing the set actions and Yoast's signature.
	 */
	private function get_actions_with_signature() {
		return $this->actions . $this->get_signature();
	}

	/**
	 * Generates Yoast's signature that's displayed at the bottom of the health check result.
	 *
	 * @return string Yoast's signature as an HTML string.
	 */
	private function get_signature() {
		return \sprintf(
			/* translators: 1: Start of a paragraph beginning with the Yoast icon, 2: Expands to 'Yoast SEO', 3: Paragraph closing tag. */
			\esc_html__( '%1$sThis was reported by the %2$s plugin%3$s', 'wordpress-seo' ),
			'<p class="yoast-site-health__signature"><img src="' . \esc_url( \plugin_dir_url( \WPSEO_FILE ) . 'packages/js/images/Yoast_SEO_Icon.svg' ) . '" alt="" height="20" width="20" class="yoast-site-health__signature-icon">',
			'Yoast SEO',
			'</p>'
		);
	}
}
page-comments-check.php000066600000002635151131531610011076 0ustar00<?php

namespace Yoast\WP\SEO\Services\Health_Check;

/**
 * Paasses when comments are set to be on a single page.
 */
class Page_Comments_Check extends Health_Check {

	/**
	 * Runs the health check.
	 *
	 * @var Page_Comments_Runner
	 */
	private $runner;

	/**
	 * Generates WordPress-friendly health check results.
	 *
	 * @var Page_Comments_Reports
	 */
	private $reports;

	/**
	 * Constructor.
	 *
	 * @param  Page_Comments_Runner  $runner  The object that implements the actual health check.
	 * @param  Page_Comments_Reports $reports The object that generates WordPress-friendly results.
	 * @return void
	 */
	public function __construct(
		Page_Comments_Runner $runner,
		Page_Comments_Reports $reports
	) {
		$this->runner  = $runner;
		$this->reports = $reports;
		$this->reports->set_test_identifier( $this->get_test_identifier() );

		$this->set_runner( $this->runner );
	}

	/**
	 * Returns a human-readable label for this health check.
	 *
	 * @return string The human-readable label.
	 */
	public function get_test_label() {
		return \__( 'Page comments', 'wordpress-seo' );
	}

	/**
	 * Returns the WordPress-friendly health check result.
	 *
	 * @return string[] The WordPress-friendly health check result.
	 */
	protected function get_result() {
		if ( $this->runner->is_successful() ) {
			return $this->reports->get_success_result();
		}

		return $this->reports->get_has_comments_on_multiple_pages_result();
	}
}
myyoast-api-request-factory.php000066600000000751151131531610012670 0ustar00<?php

namespace Yoast\WP\SEO\Services\Health_Check;

use WPSEO_MyYoast_Api_Request;

/**
 * Creates WPSEO_MyYoast_Api_Request objects.
 */
class MyYoast_Api_Request_Factory {

	/**
	 * Creates a new WPSEO_MyYoast_API_Request.
	 *
	 * @param string $url  The URL for the request.
	 * @param array  $args Optional arguments for the request.
	 * @return WPSEO_MyYoast_Api_Request
	 */
	public function create( $url, $args = [] ) {
		return new WPSEO_MyYoast_Api_Request( $url, $args );
	}
}
default-tagline-runner.php000066600000002156151131531610011636 0ustar00<?php

namespace Yoast\WP\SEO\Services\Health_Check;

/**
 * Runs the Default_Tagline health check.
 */
class Default_Tagline_Runner implements Runner_Interface {

	/**
	 * The default WordPress tagline.
	 */
	const DEFAULT_BLOG_DESCRIPTION = 'Just another WordPress site';

	/**
	 * Is set to true when the default tagline is set.
	 *
	 * @var bool
	 */
	private $has_default_tagline = true;

	/**
	 * Runs the health check. Checks if the tagline is set to WordPress' default tagline, or to its set translation.
	 *
	 * @return void
	 */
	public function run() {
		$blog_description = \get_option( 'blogdescription' );

		// We are using the WordPress internal translation.
		$translated_blog_description = \__( 'Just another WordPress site', 'default' );

		$this->has_default_tagline = $translated_blog_description === $blog_description || $blog_description === self::DEFAULT_BLOG_DESCRIPTION;
	}

	/**
	 * Returns true if the tagline is set to a non-default tagline.
	 *
	 * @return bool The boolean indicating if the health check was succesful.
	 */
	public function is_successful() {
		return ! $this->has_default_tagline;
	}
}
page-comments-reports.php000066600000004611151131531610011513 0ustar00<?php

namespace Yoast\WP\SEO\Services\Health_Check;

/**
 * Presents a set of different messages for the Page_Comments health check.
 */
class Page_Comments_Reports {

	use Reports_Trait;

	/**
	 * Constructor.
	 *
	 * @param  Report_Builder_Factory $report_builder_factory The factory for result builder objects.
	 *                                                        This class uses the report builder to generate WordPress-friendly
	 *                                                        health check results.
	 */
	public function __construct( Report_Builder_Factory $report_builder_factory ) {
		$this->report_builder_factory = $report_builder_factory;
	}

	/**
	 * Returns the report for when comments are set to be all on one page.
	 *
	 * @return string[] The message as a WordPress site status report.
	 */
	public function get_success_result() {
		return $this->get_report_builder()
			->set_label( \esc_html__( 'Comments are displayed on a single page', 'wordpress-seo' ) )
			->set_status_good()
			->set_description( \__( 'Comments on your posts are displayed on a single page. This is just like we\'d suggest it. You\'re doing well!', 'wordpress-seo' ) )
			->build();
	}

	/**
	 * Returns the report for when comments are set to be broken up across multiple pages.
	 *
	 * @return string[] The message as a WordPress site status report.
	 */
	public function get_has_comments_on_multiple_pages_result() {
		return $this->get_report_builder()
			->set_label( \__( 'Comments break into multiple pages', 'wordpress-seo' ) )
			->set_status_recommended()
			->set_description( \__( 'Comments on your posts break into multiple pages. As this is not needed in 999 out of 1000 cases, we recommend you disable it. To fix this, uncheck "Break comments into pages..." on the Discussion Settings page.', 'wordpress-seo' ) )
			->set_actions( $this->get_has_comments_on_multiple_pages_actions() )
			->build();
	}

	/**
	 * Returns the actions for when the comments are set to be broken up across multiple pages.
	 *
	 * @return string The actions as a string.
	 */
	private function get_has_comments_on_multiple_pages_actions() {
		return \sprintf(
			/* translators: 1: Opening tag of the link to the discussion settings page, 2: Link closing tag. */
			\esc_html__( '%1$sGo to the Discussion Settings page%2$s', 'wordpress-seo' ),
			'<a href="' . \esc_url( \admin_url( 'options-discussion.php' ) ) . '">',
			'</a>'
		);
	}
}
links-table-check.php000066600000002670151131531610010543 0ustar00<?php

namespace Yoast\WP\SEO\Services\Health_Check;

/**
 * Passes when the links table is accessible.
 */
class Links_Table_Check extends Health_Check {

	/**
	 * Runs the health check.
	 *
	 * @var Links_Table_Runner
	 */
	private $runner;

	/**
	 * Generates WordPress-friendly health check results.
	 *
	 * @var Links_Table_Reports
	 */
	private $reports;

	/**
	 * Constructor.
	 *
	 * @param Links_Table_Runner  $runner  The object that implements the actual health check.
	 * @param Links_Table_Reports $reports The object that generates WordPress-friendly results.
	 * @return void
	 */
	public function __construct(
		Links_Table_Runner $runner,
		Links_Table_Reports $reports
	) {
		$this->runner  = $runner;
		$this->reports = $reports;
		$this->reports->set_test_identifier( $this->get_test_identifier() );

		$this->set_runner( $this->runner );
	}

	/**
	 * Returns a human-readable label for this health check.
	 *
	 * @return string The human-readable label.
	 */
	public function get_test_label() {
		return \__( 'Links table', 'wordpress-seo' );
	}

	/**
	 * Returns the WordPress-friendly health check result.
	 *
	 * @return string[] The WordPress-friendly health check result.
	 */
	protected function get_result() {
		if ( ! $this->runner->should_run() ) {
			return [];
		}

		if ( $this->runner->is_successful() ) {
			return $this->reports->get_success_result();
		}

		return $this->reports->get_links_table_not_accessible_result();
	}
}
postname-permalink-check.php000066600000002707151131531610012145 0ustar00<?php

namespace Yoast\WP\SEO\Services\Health_Check;

/**
 * Paasses when permalinks are set to contain the post name.
 */
class Postname_Permalink_Check extends Health_Check {

	/**
	 * Runs the health check.
	 *
	 * @var Postname_Permalink_Runner
	 */
	private $runner;

	/**
	 * Generates WordPress-friendly health check results.
	 *
	 * @var Postname_Permalink_Reports
	 */
	private $reports;

	/**
	 * Constructor.
	 *
	 * @param  Postname_Permalink_Runner  $runner  The object that implements the actual health check.
	 * @param  Postname_Permalink_Reports $reports The object that generates WordPress-friendly results.
	 * @return void
	 */
	public function __construct(
		Postname_Permalink_Runner $runner,
		Postname_Permalink_Reports $reports
	) {
		$this->runner  = $runner;
		$this->reports = $reports;
		$this->reports->set_test_identifier( $this->get_test_identifier() );

		$this->set_runner( $this->runner );
	}

	/**
	 * Returns a human-readable label for this health check.
	 *
	 * @return string The human-readable label.
	 */
	public function get_test_label() {
		return \__( 'Postname permalink', 'wordpress-seo' );
	}

	/**
	 * Returns the WordPress-friendly health check result.
	 *
	 * @return string[] The WordPress-friendly health check result.
	 */
	protected function get_result() {
		if ( $this->runner->is_successful() ) {
			return $this->reports->get_success_result();
		}

		return $this->reports->get_has_no_postname_in_permalink_result();
	}
}
reports-trait.php000066600000001637151131531610010104 0ustar00<?php

namespace Yoast\WP\SEO\Services\Health_Check;

/**
 * Used by classes that use a health check Report_Builder.
 */
trait Reports_Trait {

	/**
	 * The factory for the builder object that generates WordPress-friendly test results.
	 *
	 * @var Report_Builder_Factory
	 */
	private $report_builder_factory;

	/**
	 * The test identifier that's set on the Report_Builder.
	 *
	 * @var string
	 */
	private $test_identifier = '';

	/**
	 * Sets the name that WordPress uses to identify this health check.
	 *
	 * @param  string $test_identifier The identifier.
	 * @return void
	 */
	public function set_test_identifier( $test_identifier ) {
		$this->test_identifier = $test_identifier;
	}

	/**
	 * Returns a new Report_Builder instance using the set test identifier.
	 *
	 * @return Report_Builder
	 */
	private function get_report_builder() {
		return $this->report_builder_factory->create( $this->test_identifier );
	}
}
links-table-reports.php000066600000006671151131531610011171 0ustar00<?php

namespace Yoast\WP\SEO\Services\Health_Check;

use WPSEO_Admin_Utils;
use WPSEO_Shortlinker;

/**
 * Presents a set of different messages for the Links_Table health check.
 */
class Links_Table_Reports {

	use Reports_Trait;

	/**
	 * Shortlinker object used to create short links for reports.
	 *
	 * @var WPSEO_Shortlinker
	 */
	private $shortlinker;

	/**
	 * Constructor
	 *
	 * @param  Report_Builder_Factory $report_builder_factory The factory for result builder objects.
	 *                                                        This class uses the report builder to generate WordPress-friendly
	 *                                                        health check results.
	 * @param  WPSEO_Shortlinker      $shortlinker            Object used to add short links to the report description.
	 * @return void
	 */
	public function __construct(
		Report_Builder_Factory $report_builder_factory,
		WPSEO_Shortlinker $shortlinker
	) {
		$this->report_builder_factory = $report_builder_factory;
		$this->shortlinker            = $shortlinker;
	}

	/**
	 * Returns the message for a successful health check.
	 *
	 * @return string[] The message as a WordPress site status report.
	 */
	public function get_success_result() {
		return $this->get_report_builder()
			->set_label( \__( 'The text link counter is working as expected', 'wordpress-seo' ) )
			->set_status_good()
			->set_description( $this->get_success_description() )
			->build();
	}

	/**
	 * Returns the message for a failed health check.
	 *
	 * @return string[] The message as a WordPress site status report.
	 */
	public function get_links_table_not_accessible_result() {
		return $this->get_report_builder()
			->set_label( \__( 'The text link counter feature is not working as expected', 'wordpress-seo' ) )
			->set_status_recommended()
			->set_description( $this->get_links_table_not_accessible_description() )
			->set_actions( $this->get_actions() )
			->build();
	}

	/**
	 * Returns the description for when the health check was successful.
	 *
	 * @return string The description as a string.
	 */
	private function get_success_description() {
		return \sprintf(
			/* translators: 1: Link to the Yoast SEO blog, 2: Link closing tag. */
			\esc_html__( 'The text link counter helps you improve your site structure. %1$sFind out how the text link counter can enhance your SEO%2$s.', 'wordpress-seo' ),
			'<a href="' . $this->shortlinker->get( 'https://yoa.st/3zw' ) . '" target="_blank">',
			WPSEO_Admin_Utils::get_new_tab_message() . '</a>'
		);
	}

	/**
	 * Returns the description for when the health couldn't access the links table.
	 *
	 * @return string The description as a string.
	 */
	private function get_links_table_not_accessible_description() {
		return \sprintf(
			/* translators: 1: Yoast SEO. */
			\__( 'For this feature to work, %1$s needs to create a table in your database. We were unable to create this table automatically.', 'wordpress-seo' ),
			'Yoast SEO'
		);
	}

	/**
	 * Returns the actions that the user should take when the links table is not accessible.
	 *
	 * @return string The actions as a string.
	 */
	private function get_actions() {
		return \sprintf(
			/* translators: 1: Link to the Yoast help center, 2: Link closing tag. */
			\esc_html__( '%1$sFind out how to solve this problem on our help center%2$s.', 'wordpress-seo' ),
			'<a href="' . $this->shortlinker->get( 'https://yoa.st/3zv' ) . '" target="_blank">',
			WPSEO_Admin_Utils::get_new_tab_message() . '</a>'
		);
	}
}
report-builder-factory.php000066600000000720151131531610011661 0ustar00<?php

namespace Yoast\WP\SEO\Services\Health_Check;

/**
 * Creates Report_Builder instances.
 */
class Report_Builder_Factory {

	/**
	 * Creates a new Report_Builder instance.
	 *
	 * @param string $test_identifier The test identifier as a string.
	 * @return Report_Builder The new Report_Builder instance.
	 */
	public function create( $test_identifier ) {
		$instance = new Report_Builder();
		return $instance->set_test_identifier( $test_identifier );
	}
}
default-tagline-reports.php000066600000004431151131531610012021 0ustar00<?php

namespace Yoast\WP\SEO\Services\Health_Check;

/**
 * Presents a set of different messages for the Default_Tagline health check.
 */
class Default_Tagline_Reports {

	use Reports_Trait;

	/**
	 * Constructor
	 *
	 * @param  Report_Builder_Factory $report_builder_factory The factory for result builder objects.
	 *                                                        This class uses the report builder to generate WordPress-friendly
	 *                                                        health check results.
	 * @return void
	 */
	public function __construct( Report_Builder_Factory $report_builder_factory ) {
		$this->report_builder_factory = $report_builder_factory;
	}

	/**
	 * Returns the message for a successful health check.
	 *
	 * @return string[] The message as a WordPress site status report.
	 */
	public function get_success_result() {
		return $this->get_report_builder()
			->set_label( \__( 'You changed the default WordPress tagline', 'wordpress-seo' ) )
			->set_status_good()
			->set_description( \__( 'You are using a custom tagline or an empty one.', 'wordpress-seo' ) )
			->build();
	}

	/**
	 * Returns the message for a failed health check. In this case, when the user still has the default WordPress tagline set.
	 *
	 * @return string[] The message as a WordPress site status report.
	 */
	public function get_has_default_tagline_result() {
		return $this->get_report_builder()
			->set_label( \__( 'You should change the default WordPress tagline', 'wordpress-seo' ) )
			->set_status_recommended()
			->set_description( \__( 'You still have the default WordPress tagline. Even an empty one is probably better.', 'wordpress-seo' ) )
			->set_actions( $this->get_actions() )
			->build();
	}

	/**
	 * Returns the actions that the user should take when his tagline is still set to the WordPress default.
	 *
	 * @return string The actions as an HTML string.
	 */
	private function get_actions() {
		$query_args    = [
			'autofocus[control]' => 'blogdescription',
		];
		$customize_url = \add_query_arg( $query_args, \wp_customize_url() );

		return \sprintf(
			/* translators: 1: link open tag; 2: link close tag. */
			\esc_html__( '%1$sYou can change the tagline in the customizer%2$s.', 'wordpress-seo' ),
			'<a href="' . \esc_url( $customize_url ) . '">',
			'</a>'
		);
	}
}
curl-runner.php000066600000005524151132347460007551 0ustar00<?php

namespace Yoast\WP\SEO\Services\Health_Check;

use WPSEO_Addon_Manager;
use Yoast\WP\SEO\Helpers\Curl_Helper;

/**
 * Runs the Curl health check.
 *
 * @deprecated 19.7.2
 * @codeCoverageIgnore
 */
class Curl_Runner implements Runner_Interface {

	/**
	 * Sets the minimum cURL version for this health check to pass.
	 */
	const MINIMUM_CURL_VERSION = '7.34.0';

	/**
	 * Sets the target URL for testing whether the MyYoast API is reachable.
	 */
	const MYYOAST_API_REQUEST_URL = 'sites/current';

	/**
	 * Constructor.
	 *
	 * @deprecated 19.7.2
	 * @codeCoverageIgnore
	 *
	 * @psalm-suppress InvalidClass MyYoast is a product name, so it's an exception to the class naming conventions.
	 * @param WPSEO_Addon_Manager         $addon_manager                The add-on manager.
	 * @param MyYoast_Api_Request_Factory $my_yoast_api_request_factory A MyYoast API request object.
	 * @param Curl_Helper                 $curl_helper                  A cURL helper object for obtaining
	 *                                                                  cURL installation information.
	 */
	public function __construct(
		WPSEO_Addon_Manager $addon_manager,
		MyYoast_Api_Request_Factory $my_yoast_api_request_factory,
		Curl_Helper $curl_helper
	) {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.7.2' );
	}

	/**
	 * Runs the health check. Checks if cURL is installed and up to date, and if it's able to reach the MyYoast API
	 *
	 * @deprecated 19.7.2
	 * @codeCoverageIgnore
	 *
	 * @return void
	 */
	public function run() {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.7.2' );
	}

	/**
	 * Returns whether the health check was successful.
	 *
	 * @deprecated 19.7.2
	 * @codeCoverageIgnore
	 *
	 * @return bool True if all the routines for this health check were successful.
	 */
	public function is_successful() {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.7.2' );

		return true;
	}

	/**
	 * Returns whether there are premium plugins installed.
	 *
	 * @deprecated 19.7.2
	 * @codeCoverageIgnore
	 *
	 * @return bool True if there are premium plugins installed.
	 */
	public function has_premium_plugins_installed() {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.7.2' );

		return false;
	}

	/**
	 * Returns whether cURL was able to reach the MyYoast API.
	 *
	 * @deprecated 19.7.2
	 * @codeCoverageIgnore
	 *
	 * @return bool True if cURL was able to reach the MyYoast API.
	 */
	public function can_reach_my_yoast_api() {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.7.2' );

		return true;
	}

	/**
	 * Returns whether the installed cURL version is recent enough.
	 *
	 * @deprecated 19.7.2
	 * @codeCoverageIgnore
	 *
	 * @return bool True if the installed cURL version is more recent than MINIMUM_CURL_VERSION.
	 */
	public function has_recent_curl_version_installed() {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.7.2' );

		return true;
	}
}
ryte-runner.php000066600000004564151132347460007572 0ustar00<?php

namespace Yoast\WP\SEO\Services\Health_Check;

use WPSEO_Utils;
use Yoast\WP\SEO\Integrations\Admin\Ryte_Integration;

/**
 * Runs the Ryte health check.
 *
 * @deprecated 19.6
 * @codeCoverageIgnore
 */
class Ryte_Runner implements Runner_Interface {

	/**
	 * Constructor.
	 *
	 * @deprecated 19.6
	 * @codeCoverageIgnore
	 *
	 * @param Ryte_Integration $ryte  The Ryte_Integration object that the health check uses to check indexability.
	 * @param WPSEO_Utils      $utils The WPSEO_Utils object used to determine whether the site is in development mode.
	 */
	public function __construct(
		Ryte_Integration $ryte,
		WPSEO_Utils $utils
	) {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.6' );
	}

	/**
	 * Runs the health check. Checks if Ryte is accessible and whether the site is indexable.
	 *
	 * @deprecated 19.6
	 * @codeCoverageIgnore
	 *
	 * @return void
	 */
	public function run() {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.6' );
	}

	/**
	 * Checks if the site is a live production site that has Ryte enabled.
	 *
	 * @deprecated 19.6
	 * @codeCoverageIgnore
	 *
	 * @return bool
	 */
	public function should_run() {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.6' );

		return false;
	}

	/**
	 * Checks if the site is indexable.
	 *
	 * @deprecated 19.6
	 * @codeCoverageIgnore
	 *
	 * @return bool
	 */
	public function is_successful() {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.6' );

		return true;
	}

	/**
	 * Checks if the site's indexability is unknown.
	 *
	 * @deprecated 19.6
	 * @codeCoverageIgnore
	 *
	 * @return bool Returns true if the site indexability is unknown even though getting a response from Ryte was
	 *              successful.
	 */
	public function has_unknown_indexability() {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.6' );

		return false;
	}

	/**
	 * Checks whether there was a response error when attempting a request to Ryte.
	 *
	 * @deprecated 19.6
	 * @codeCoverageIgnore
	 *
	 * @return bool True if the health check got a valid error response.
	 */
	public function got_response_error() {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.6' );

		return true;
	}

	/**
	 * Returns the error response is there was one.
	 *
	 * @deprecated 19.6
	 * @codeCoverageIgnore
	 *
	 * @return array|null
	 */
	public function get_error_response() {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.6' );

		return [];
	}
}
ryte-check.php000066600000002301151132347460007321 0ustar00<?php

namespace Yoast\WP\SEO\Services\Health_Check;

/**
 * Passes if the health check determines that the site is indexable using Ryte.
 *
 * @deprecated 19.6
 * @codeCoverageIgnore
 */
class Ryte_Check extends Health_Check {

	/**
	 * Constructor.
	 *
	 * @deprecated 19.6
	 * @codeCoverageIgnore
	 *
	 * @param Ryte_Runner  $runner  The object that implements the actual health check.
	 * @param Ryte_Reports $reports The object that generates WordPress-friendly results.
	 *
	 * @return void
	 */
	public function __construct(
		Ryte_Runner $runner,
		Ryte_Reports $reports
	) {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.6' );
	}

	/**
	 * Returns a human-readable label for this health check.
	 *
	 * @deprecated 19.6
	 * @codeCoverageIgnore
	 *
	 * @return string The human-readable label.
	 */
	public function get_test_label() {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.6' );

		return '';
	}

	/**
	 * Returns the WordPress-friendly health check result.
	 *
	 * @deprecated 19.6
	 * @codeCoverageIgnore
	 *
	 * @return string[] The WordPress-friendly health check result.
	 */
	protected function get_result() {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.6' );

		return [];
	}
}
curl-check.php000066600000002244151132347460007311 0ustar00<?php

namespace Yoast\WP\SEO\Services\Health_Check;

/**
 * Passes if the health check can reach the MyYoast API using a recent enough cURL version.
 *
 * @deprecated 19.7.2
 * @codeCoverageIgnore
 */
class Curl_Check extends Health_Check {

	/**
	 * Constructor.
	 *
	 * @deprecated 19.7.2
	 * @codeCoverageIgnore
	 *
	 * @param Curl_Runner  $runner  The object that implements the actual health check.
	 * @param Curl_Reports $reports The object that generates WordPress-friendly results.
	 * @return void
	 */
	public function __construct(
		Curl_Runner $runner,
		Curl_Reports $reports
	) {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.7.2' );
	}

	/**
	 * Returns a human-readable label for this health check.
	 *
	 * @deprecated 19.7.2
	 * @codeCoverageIgnore
	 *
	 * @return string The human-readable label.
	 */
	public function get_test_label() {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.7.2' );

		return '';
	}

	/**
	 * Returns the WordPress-friendly health check result.
	 *
	 * @return string[] The WordPress-friendly health check result.
	 */
	protected function get_result() {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.7.2' );

		return [];
	}
}
ryte-reports.php000066600000004550151132347460007752 0ustar00<?php

namespace Yoast\WP\SEO\Services\Health_Check;

use WPSEO_Shortlinker;

/**
 * Presents a set of different messages for the Ryte health check.
 *
 * @deprecated 19.6
 * @codeCoverageIgnore
 */
class Ryte_Reports {

	use Reports_Trait;

	/**
	 * Constructor
	 *
	 * @deprecated 19.6
	 * @codeCoverageIgnore
	 *
	 * @param Report_Builder_Factory $report_builder_factory  The factory for result builder objects.
	 *                                                        This class uses the report builder to generate
	 *                                                        WordPress-friendly health check results.
	 * @param WPSEO_Shortlinker      $shortlinker             The WPSEO_Shortlinker object used to generate short
	 *                                                        links.
	 *
	 * @return void
	 */
	public function __construct(
		Report_Builder_Factory $report_builder_factory,
		WPSEO_Shortlinker $shortlinker
	) {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.6' );
	}

	/**
	 * Returns the message for a successful health check.
	 *
	 * @deprecated 19.6
	 * @codeCoverageIgnore
	 *
	 * @return string[] The message as a WordPress site status report.
	 */
	public function get_success_result() {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.6' );

		return [];
	}

	/**
	 * Returns the report for a health check result in which the site was not indexable.
	 *
	 * @deprecated 19.6
	 * @codeCoverageIgnore
	 *
	 * @return string[] The message as a WordPress site status report.
	 */
	public function get_not_indexable_result() {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.6' );

		return [];
	}

	/**
	 * Returns the report for when the health check was unable to determine indexability.
	 *
	 * @deprecated 19.6
	 * @codeCoverageIgnore
	 *
	 * @return string[] The message as a WordPress site status report.
	 */
	public function get_unknown_indexability_result() {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.6' );

		return [];
	}

	/**
	 * Returns the result for when the health check got an error response from Ryte.
	 *
	 * @deprecated 19.6
	 * @codeCoverageIgnore
	 *
	 * @param array $response_error The error response from Ryte.
	 *
	 * @return string[] The message as a WordPress site status report.
	 */
	public function get_response_error_result( $response_error ) {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.6' );

		return [];
	}
}
curl-reports.php000066600000003624151132347460007735 0ustar00<?php

namespace Yoast\WP\SEO\Services\Health_Check;

use WPSEO_Admin_Utils;
use WPSEO_Shortlinker;

/**
 * Presents a set of different messages for the cURL health check.
 *
 * @deprecated 19.7.2
 * @codeCoverageIgnore
 */
class Curl_Reports {

	/**
	 * Constructor
	 *
	 * @deprecated 19.7.2
	 * @codeCoverageIgnore
	 *
	 * @param  Report_Builder_Factory $report_builder_factory The factory for result builder objects.
	 *                                                        This class uses the report builder to generate WordPress-friendly
	 *                                                        health check results.
	 * @param  WPSEO_Shortlinker      $shortlinker            The WPSEO_Shortlinker object used to generate short links.
	 * @return void
	 */
	public function __construct(
		Report_Builder_Factory $report_builder_factory,
		WPSEO_Shortlinker $shortlinker
	) {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.7.2' );
	}

	/**
	 * Returns the message for a successful health check.
	 *
	 * @deprecated 19.7.2
	 * @codeCoverageIgnore
	 *
	 * @return string[] The message as a WordPress site status report.
	 */
	public function get_success_result() {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.7.2' );

		return [];
	}

	/**
	 * Returns the message for when the health check was unable to reach the MyYoast API.
	 *
	 * @deprecated 19.7.2
	 * @codeCoverageIgnore
	 *
	 * @return string[] The message as a WordPress site status report.
	 */
	public function get_my_yoast_api_not_reachable_result() {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.7.2' );

		return [];
	}

	/**
	 * Returns the message for a successful health check.
	 *
	 * @deprecated 19.7.2
	 * @codeCoverageIgnore
	 *
	 * @return string[] The message as a WordPress site status report.
	 */
	public function get_no_recent_curl_version_installed_result() {
		\_deprecated_function( __METHOD__, 'Yoast SEO 19.7.2' );

		return [];
	}
}
.htaccess000066600000000424151144072100006341 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>