Файловый менеджер - Редактировать - /home/kunzqhe/photostocker/2/config.tar
Ðазад
researcher-languages.php 0000644 00000000506 15154230336 0011347 0 ustar 00 <?php namespace Yoast\WP\SEO\Config; /** * Holds all languages supported with specific researches for our readability analysis. */ class Researcher_Languages { const SUPPORTED_LANGUAGES = [ 'ar', 'ca', 'de', 'en', 'es', 'fa', 'fr', 'he', 'hu', 'id', 'it', 'nb', 'nl', 'pl', 'pt', 'ru', 'sv', 'tr', 'cs', 'sk', 'el' ]; } schema-ids.php 0000644 00000002067 15154230336 0007301 0 ustar 00 <?php namespace Yoast\WP\SEO\Config; /** * Class Schema_IDs. */ class Schema_IDs { /** * Hash used for the Author `@id`. */ const AUTHOR_HASH = '#author'; /** * Hash used for the Author Logo's `@id`. */ const AUTHOR_LOGO_HASH = '#authorlogo'; /** * Hash used for the Breadcrumb's `@id`. */ const BREADCRUMB_HASH = '#breadcrumb'; /** * Hash used for the Person `@id`. */ const PERSON_HASH = '#/schema/person/'; /** * Hash used for the Article `@id`. */ const ARTICLE_HASH = '#article'; /** * Hash used for the Organization `@id`. */ const ORGANIZATION_HASH = '#organization'; /** * Hash used for the Organization `@id`. */ const ORGANIZATION_LOGO_HASH = '#logo'; /** * Hash used for the logo `@id`. */ const PERSON_LOGO_HASH = '#personlogo'; /** * Hash used for an Article's primary image `@id`. */ const PRIMARY_IMAGE_HASH = '#primaryimage'; /** * Hash used for the WebPage's `@id`. */ const WEBPAGE_HASH = '#webpage'; /** * Hash used for the Website's `@id`. */ const WEBSITE_HASH = '#website'; } semrush-client.php 0000644 00000016677 15154230336 0010242 0 ustar 00 <?php namespace Yoast\WP\SEO\Config; use Exception; use Yoast\WP\SEO\Exceptions\OAuth\Authentication_Failed_Exception; use Yoast\WP\SEO\Exceptions\SEMrush\Tokens\Empty_Property_Exception; use Yoast\WP\SEO\Exceptions\SEMrush\Tokens\Empty_Token_Exception; use Yoast\WP\SEO\Exceptions\SEMrush\Tokens\Failed_Storage_Exception; use Yoast\WP\SEO\Helpers\Options_Helper; use Yoast\WP\SEO\Values\SEMrush\SEMrush_Token; use Yoast\WP\SEO\Wrappers\WP_Remote_Handler; use YoastSEO_Vendor\GuzzleHttp\Client; use YoastSEO_Vendor\League\OAuth2\Client\Provider\Exception\IdentityProviderException; use YoastSEO_Vendor\League\OAuth2\Client\Provider\GenericProvider; /** * Class SEMrush_Client */ class SEMrush_Client { /** * The option's key. */ const TOKEN_OPTION = 'semrush_tokens'; /** * The provider. * * @var GenericProvider */ protected $provider; /** * The options helper. * * @var Options_Helper */ protected $options_helper; /** * The token. * * @var SEMrush_Token|null */ protected $token; /** * SEMrush_Client constructor. * * @param Options_Helper $options_helper The Options_Helper instance. * @param WP_Remote_Handler $wp_remote_handler The request handler. * * @throws Empty_Property_Exception Exception thrown if a token property is empty. */ public function __construct( Options_Helper $options_helper, WP_Remote_Handler $wp_remote_handler ) { $this->provider = new GenericProvider( [ 'clientId' => 'yoast', 'clientSecret' => 'YdqNsWwnP4vE54WO1ugThKEjGMxMAHJt', 'redirectUri' => 'https://oauth.semrush.com/oauth2/yoast/success', 'urlAuthorize' => 'https://oauth.semrush.com/oauth2/authorize', 'urlAccessToken' => 'https://oauth.semrush.com/oauth2/access_token', 'urlResourceOwnerDetails' => 'https://oauth.semrush.com/oauth2/resource', ], [ 'httpClient' => new Client( [ 'handler' => $wp_remote_handler ] ), ] ); $this->options_helper = $options_helper; $this->token = $this->get_token_from_storage(); } /** * Requests the access token and refresh token based on the passed code. * * @param string $code The code to send. * * @return SEMrush_Token The requested tokens. * * @throws Authentication_Failed_Exception Exception thrown if authentication has failed. */ public function request_tokens( $code ) { try { $response = $this->provider ->getAccessToken( 'authorization_code', [ 'code' => $code, ] ); $token = SEMrush_Token::from_response( $response ); return $this->store_token( $token ); } catch ( Exception $exception ) { throw new Authentication_Failed_Exception( $exception ); } } /** * Performs an authenticated GET request to the desired URL. * * @param string $url The URL to send the request to. * @param array $options The options to pass along to the request. * * @return mixed The parsed API response. * * @throws IdentityProviderException Exception thrown if there's something wrong with the identifying data. * @throws Authentication_Failed_Exception Exception thrown if authentication has failed. * @throws Empty_Token_Exception Exception thrown if the token is empty. */ public function get( $url, $options = [] ) { return $this->do_request( 'GET', $url, $options ); } /** * Performs an authenticated POST request to the desired URL. * * @param string $url The URL to send the request to. * @param mixed $body The data to send along in the request's body. * @param array $options The options to pass along to the request. * * @return mixed The parsed API response. * * @throws IdentityProviderException Exception thrown if there's something wrong with the identifying data. * @throws Authentication_Failed_Exception Exception thrown if authentication has failed. * @throws Empty_Token_Exception Exception thrown if the token is empty. */ public function post( $url, $body, $options = [] ) { $options['body'] = $body; return $this->do_request( 'POST', $url, $options ); } /** * Determines whether or not there are valid tokens available. * * @return bool Whether or not there are valid tokens. */ public function has_valid_tokens() { return ! empty( $this->token ) && $this->token->has_expired() === false; } /** * Gets the stored tokens and refreshes them if they've expired. * * @return SEMrush_Token The stored tokens. * * @throws Empty_Token_Exception Exception thrown if the token is empty. */ public function get_tokens() { if ( empty( $this->token ) ) { throw new Empty_Token_Exception(); } if ( $this->token->has_expired() ) { $this->token = $this->refresh_tokens( $this->token ); } return $this->token; } /** * Retrieves the token from storage. * * @return SEMrush_Token|null The token object. Returns null if none exists. * * @throws Empty_Property_Exception Exception thrown if a token property is empty. */ public function get_token_from_storage() { $tokens = $this->options_helper->get( self::TOKEN_OPTION ); if ( empty( $tokens ) ) { return null; } return new SEMrush_Token( $tokens['access_token'], $tokens['refresh_token'], $tokens['expires'], $tokens['has_expired'], $tokens['created_at'] ); } /** * Stores the passed token. * * @param SEMrush_Token $token The token to store. * * @return SEMrush_Token The stored token. * * @throws Failed_Storage_Exception Exception thrown if storing of the token fails. */ public function store_token( SEMrush_Token $token ) { $saved = $this->options_helper->set( self::TOKEN_OPTION, $token->to_array() ); if ( $saved === false ) { throw new Failed_Storage_Exception(); } return $token; } /** * Performs the specified request. * * @param string $method The HTTP method to use. * @param string $url The URL to send the request to. * @param array $options The options to pass along to the request. * * @return mixed The parsed API response. * * @throws IdentityProviderException Exception thrown if there's something wrong with the identifying data. * @throws Authentication_Failed_Exception Exception thrown if authentication has failed. * @throws Empty_Token_Exception Exception thrown if the token is empty. */ protected function do_request( $method, $url, array $options ) { $defaults = [ 'headers' => $this->provider->getHeaders(), 'params' => [ 'access_token' => $this->get_tokens()->access_token, ], ]; $options = \array_merge_recursive( $defaults, $options ); if ( \array_key_exists( 'params', $options ) ) { $url .= '?' . \http_build_query( $options['params'] ); unset( $options['params'] ); } $request = $this->provider ->getAuthenticatedRequest( $method, $url, null, $options ); return $this->provider->getParsedResponse( $request ); } /** * Refreshes the outdated tokens. * * @param SEMrush_Token $tokens The outdated tokens. * * @return SEMrush_Token The refreshed tokens. * * @throws Authentication_Failed_Exception Exception thrown if authentication has failed. */ protected function refresh_tokens( SEMrush_Token $tokens ) { try { $new_tokens = $this->provider->getAccessToken( 'refresh_token', [ 'refresh_token' => $tokens->refresh_token, ] ); $token = SEMrush_Token::from_response( $new_tokens ); return $this->store_token( $token ); } catch ( Exception $exception ) { throw new Authentication_Failed_Exception( $exception ); } } } migrations/20200429105310_TruncateIndexableTables.php 0000644 00000002013 15154230336 0015617 0 ustar 00 <?php namespace Yoast\WP\SEO\Config\Migrations; use Yoast\WP\Lib\Migrations\Migration; use Yoast\WP\Lib\Model; /** * Class TruncateIndexableTables. */ class TruncateIndexableTables extends Migration { /** * The plugin this migration belongs to. * * @var string */ public static $plugin = 'free'; /** * Migration up. */ public function up() { $this->query( 'TRUNCATE TABLE ' . $this->get_indexable_table_name() ); $this->query( 'TRUNCATE TABLE ' . $this->get_indexable_hierarchy_table_name() ); } /** * Migration down. */ public function down() { // Nothing to do. } /** * Retrieves the table name to use for storing indexables. * * @return string The table name to use. */ protected function get_indexable_table_name() { return Model::get_table_name( 'Indexable' ); } /** * Retrieves the table name to use. * * @return string The table name to use. */ protected function get_indexable_hierarchy_table_name() { return Model::get_table_name( 'Indexable_Hierarchy' ); } } migrations/20200420073606_AddColumnsToIndexables.php 0000644 00000004052 15154230336 0015426 0 ustar 00 <?php namespace Yoast\WP\SEO\Config\Migrations; use Yoast\WP\Lib\Migrations\Migration; use Yoast\WP\Lib\Model; /** * Class AddColumnsToIndexables. */ class AddColumnsToIndexables extends Migration { /** * The plugin this migration belongs to. * * @var string */ public static $plugin = 'free'; /** * Migration up. */ public function up() { $tables = $this->get_tables(); $blog_id = \get_current_blog_id(); foreach ( $tables as $table ) { $this->add_column( $table, 'blog_id', 'biginteger', [ 'null' => false, 'limit' => 20, 'default' => $blog_id, ] ); } $attr_limit_32 = [ 'null' => true, 'limit' => 32, ]; $attr_limit_64 = [ 'null' => true, 'limit' => 64, ]; $indexable_table = $this->get_indexable_table(); $this->add_column( $indexable_table, 'language', 'string', $attr_limit_32 ); $this->add_column( $indexable_table, 'region', 'string', $attr_limit_32 ); $this->add_column( $indexable_table, 'schema_page_type', 'string', $attr_limit_64 ); $this->add_column( $indexable_table, 'schema_article_type', 'string', $attr_limit_64 ); } /** * Migration down. */ public function down() { $tables = $this->get_tables(); foreach ( $tables as $table ) { $this->remove_column( $table, 'blog_id' ); } $indexable_table = $this->get_indexable_table(); $this->remove_column( $indexable_table, 'language' ); $this->remove_column( $indexable_table, 'region' ); $this->remove_column( $indexable_table, 'schema_page_type' ); $this->remove_column( $indexable_table, 'schema_article_type' ); } /** * Retrieves the Indexable table. * * @return string The Indexable table name. */ protected function get_indexable_table() { return Model::get_table_name( 'Indexable' ); } /** * Retrieves the table names to use. * * @return string[] The table names to use. */ protected function get_tables() { return [ $this->get_indexable_table(), Model::get_table_name( 'Indexable_Hierarchy' ), Model::get_table_name( 'Primary_Term' ), ]; } } migrations/20200428194858_ExpandIndexableColumnLengths.php 0000644 00000003341 15154230336 0016656 0 ustar 00 <?php namespace Yoast\WP\SEO\Config\Migrations; use Yoast\WP\Lib\Migrations\Migration; use Yoast\WP\Lib\Model; /** * Class ExpandIndexableColumnLengths. */ class ExpandIndexableColumnLengths extends Migration { /** * The plugin this migration belongs to. * * @var string */ public static $plugin = 'free'; /** * Migration up. */ public function up() { $this->change_column( $this->get_table_name(), 'title', 'text', [ 'null' => true ] ); $this->change_column( $this->get_table_name(), 'open_graph_title', 'text', [ 'null' => true ] ); $this->change_column( $this->get_table_name(), 'twitter_title', 'text', [ 'null' => true ] ); $this->change_column( $this->get_table_name(), 'open_graph_image_source', 'text', [ 'null' => true ] ); $this->change_column( $this->get_table_name(), 'twitter_image_source', 'text', [ 'null' => true ] ); } /** * Migration down. */ public function down() { $attr_limit_191 = [ 'null' => true, 'limit' => 191, ]; $this->change_column( $this->get_table_name(), 'title', 'string', $attr_limit_191 ); $this->change_column( $this->get_table_name(), 'opengraph_title', 'string', $attr_limit_191 ); $this->change_column( $this->get_table_name(), 'twitter_title', 'string', $attr_limit_191 ); $this->change_column( $this->get_table_name(), 'open_graph_image_source', 'string', $attr_limit_191 ); $this->change_column( $this->get_table_name(), 'twitter_image_source', 'string', $attr_limit_191 ); } /** * Retrieves the table name to use for storing indexables. * * @return string The table name to use. */ protected function get_table_name() { return Model::get_table_name( 'Indexable' ); } } migrations/20200702141921_CreateIndexableSubpagesIndex.php 0000644 00000002354 15154230336 0016576 0 ustar 00 <?php namespace Yoast\WP\SEO\Config\Migrations; use Yoast\WP\Lib\Migrations\Migration; use Yoast\WP\Lib\Model; /** * CreateIndexableSubpagesIndex class. */ class CreateIndexableSubpagesIndex extends Migration { /** * The plugin this migration belongs to. * * @var string */ public static $plugin = 'free'; /** * Migration up. * * @return void */ public function up() { $this->change_column( $this->get_table_name(), 'post_status', 'string', [ 'null' => true, 'limit' => 20, ] ); $this->add_index( $this->get_table_name(), [ 'post_parent', 'object_type', 'post_status', 'object_id' ], [ 'name' => 'subpages' ] ); } /** * Migration down. * * @return void */ public function down() { $this->change_column( $this->get_table_name(), 'post_status', 'string', [ 'null' => true, 'limit' => 191, ] ); $this->remove_index( $this->get_table_name(), [ 'post_parent', 'object_type', 'post_status', 'object_id' ], [ 'name' => 'subpages' ] ); } /** * Retrieves the table name to use for storing indexables. * * @return string The table name to use. */ protected function get_table_name() { return Model::get_table_name( 'Indexable' ); } } migrations/20190529075038_WpYoastDropIndexableMetaTableIfExists.php 0000644 00000001521 15154230336 0020421 0 ustar 00 <?php namespace Yoast\WP\SEO\Config\Migrations; use Yoast\WP\Lib\Migrations\Migration; use Yoast\WP\Lib\Model; /** * Class WpYoastDropIndexableMetaTableIfExists. */ class WpYoastDropIndexableMetaTableIfExists extends Migration { /** * The plugin this migration belongs to. * * @var string */ public static $plugin = 'free'; /** * Migration up. */ public function up() { $table_name = $this->get_table_name(); // This can be done safely as it executes a DROP IF EXISTS. $this->drop_table( $table_name ); } /** * Migration down. */ public function down() { // No down required. This specific table should never exist. } /** * Retrieves the table name to use. * * @return string The table name to use. */ protected function get_table_name() { return Model::get_table_name( 'Indexable_Meta' ); } } migrations/20200728095334_AddIndexesForProminentWordsOnIndexables.php 0000644 00000002265 15154230336 0021002 0 ustar 00 <?php namespace Yoast\WP\SEO\Config\Migrations; use Yoast\WP\Lib\Migrations\Migration; use Yoast\WP\Lib\Model; /** * AddIndexesForProminentWordsOnIndexables class. */ class AddIndexesForProminentWordsOnIndexables extends Migration { /** * The plugin this migration belongs to. * * @var string */ public static $plugin = 'free'; /** * The columns on which an index should be added. * * @var string[] */ private $columns_with_index = [ 'prominent_words_version', 'object_type', 'object_sub_type', 'post_status', ]; /** * Migration up. * * @return void */ public function up() { $table_name = $this->get_table_name(); $adapter = $this->get_adapter(); if ( ! $adapter->has_index( $table_name, $this->columns_with_index, [ 'name' => 'prominent_words' ] ) ) { $this->add_index( $table_name, $this->columns_with_index, [ 'name' => 'prominent_words', ] ); } } /** * Migration down. * * @return void */ public function down() { } /** * Retrieves the table name to use. * * @return string The table name to use. */ protected function get_table_name() { return Model::get_table_name( 'Indexable' ); } } migrations/20171228151840_WpYoastIndexable.php 0000644 00000014204 15154230336 0014327 0 ustar 00 <?php namespace Yoast\WP\SEO\Config\Migrations; use Yoast\WP\Lib\Migrations\Migration; use Yoast\WP\Lib\Model; /** * Indexable migration. */ class WpYoastIndexable extends Migration { /** * The plugin this migration belongs to. * * @var string */ public static $plugin = 'free'; /** * Migration up. * * @return void */ public function up() { $this->add_table(); } /** * Migration down. * * @return void */ public function down() { $this->drop_table( $this->get_table_name() ); } /** * Creates the indexable table. */ private function add_table() { $table_name = $this->get_table_name(); $indexable_table = $this->create_table( $table_name ); // Permalink. $indexable_table->column( 'permalink', 'mediumtext', [ 'null' => true ] ); $indexable_table->column( 'permalink_hash', 'string', [ 'null' => true, 'limit' => 191, ] ); // Object information. $indexable_table->column( 'object_id', 'integer', [ 'unsigned' => true, 'null' => true, 'limit' => 11, ] ); $indexable_table->column( 'object_type', 'string', [ 'null' => false, 'limit' => 32, ] ); $indexable_table->column( 'object_sub_type', 'string', [ 'null' => true, 'limit' => 32, ] ); // Ownership. $indexable_table->column( 'author_id', 'integer', [ 'unsigned' => true, 'null' => true, 'limit' => 11, ] ); $indexable_table->column( 'post_parent', 'integer', [ 'unsigned' => true, 'null' => true, 'limit' => 11, ] ); // Title and description. $indexable_table->column( 'title', 'string', [ 'null' => true, 'limit' => 191, ] ); $indexable_table->column( 'description', 'text', [ 'null' => true ] ); $indexable_table->column( 'breadcrumb_title', 'string', [ 'null' => true, 'limit' => 191, ] ); // Post metadata: status, public, protected. $indexable_table->column( 'post_status', 'string', [ 'null' => true, 'limit' => 191, ] ); $indexable_table->column( 'is_public', 'boolean', [ 'null' => true, 'default' => null, ] ); $indexable_table->column( 'is_protected', 'boolean', [ 'default' => false ] ); $indexable_table->column( 'has_public_posts', 'boolean', [ 'null' => true, 'default' => null, ] ); $indexable_table->column( 'number_of_pages', 'integer', [ 'unsigned' => true, 'null' => true, 'default' => null, 'limit' => 11, ] ); $indexable_table->column( 'canonical', 'mediumtext', [ 'null' => true ] ); // SEO and readability analysis. $indexable_table->column( 'primary_focus_keyword', 'string', [ 'null' => true, 'limit' => 191, ] ); $indexable_table->column( 'primary_focus_keyword_score', 'integer', [ 'null' => true, 'limit' => 3, ] ); $indexable_table->column( 'readability_score', 'integer', [ 'null' => true, 'limit' => 3, ] ); $indexable_table->column( 'is_cornerstone', 'boolean', [ 'default' => false ] ); // Robots. $indexable_table->column( 'is_robots_noindex', 'boolean', [ 'null' => true, 'default' => false, ] ); $indexable_table->column( 'is_robots_nofollow', 'boolean', [ 'null' => true, 'default' => false, ] ); $indexable_table->column( 'is_robots_noarchive', 'boolean', [ 'null' => true, 'default' => false, ] ); $indexable_table->column( 'is_robots_noimageindex', 'boolean', [ 'null' => true, 'default' => false, ] ); $indexable_table->column( 'is_robots_nosnippet', 'boolean', [ 'null' => true, 'default' => false, ] ); // Twitter. $indexable_table->column( 'twitter_title', 'string', [ 'null' => true, 'limit' => 191, ] ); $indexable_table->column( 'twitter_image', 'mediumtext', [ 'null' => true ] ); $indexable_table->column( 'twitter_description', 'mediumtext', [ 'null' => true ] ); $indexable_table->column( 'twitter_image_id', 'string', [ 'null' => true, 'limit' => 191, ] ); $indexable_table->column( 'twitter_image_source', 'string', [ 'null' => true, 'limit' => 191, ] ); // Open-Graph. $indexable_table->column( 'open_graph_title', 'string', [ 'null' => true, 'limit' => 191, ] ); $indexable_table->column( 'open_graph_description', 'mediumtext', [ 'null' => true ] ); $indexable_table->column( 'open_graph_image', 'mediumtext', [ 'null' => true ] ); $indexable_table->column( 'open_graph_image_id', 'string', [ 'null' => true, 'limit' => 191, ] ); $indexable_table->column( 'open_graph_image_source', 'string', [ 'null' => true, 'limit' => 191, ] ); $indexable_table->column( 'open_graph_image_meta', 'text', [ 'null' => true ] ); // Link count. $indexable_table->column( 'link_count', 'integer', [ 'null' => true, 'limit' => 11, ] ); $indexable_table->column( 'incoming_link_count', 'integer', [ 'null' => true, 'limit' => 11, ] ); // Prominent words. $indexable_table->column( 'prominent_words_version', 'integer', [ 'null' => true, 'limit' => 11, 'unsigned' => true, 'default' => null, ] ); $indexable_table->finish(); $this->add_indexes( $table_name ); $this->add_timestamps( $table_name ); } /** * Adds indexes to the indexable table. * * @param string $indexable_table_name The name of the indexable table. */ private function add_indexes( $indexable_table_name ) { $this->add_index( $indexable_table_name, [ 'object_type', 'object_sub_type', ], [ 'name' => 'object_type_and_sub_type', ] ); $this->add_index( $indexable_table_name, 'permalink_hash', [ 'name' => 'permalink_hash', ] ); } /** * Retrieves the table name to use for storing indexables. * * @return string The table name to use. */ protected function get_table_name() { return Model::get_table_name( 'Indexable' ); } } migrations/20210817092415_AddVersionColumnToIndexables.php 0000644 00000001547 15154230336 0016631 0 ustar 00 <?php namespace Yoast\WP\SEO\Config\Migrations; use Yoast\WP\Lib\Migrations\Migration; use Yoast\WP\Lib\Model; /** * AddVersionColumnToIndexables class. */ class AddVersionColumnToIndexables extends Migration { /** * The plugin this migration belongs to. * * @var string */ public static $plugin = 'free'; /** * Migration up. * * @return void */ public function up() { $this->add_column( $this->get_table_name(), 'version', 'integer', [ 'default' => 1, ] ); } /** * Migration down. * * @return void */ public function down() { $this->remove_column( $this->get_table_name(), 'version' ); } /** * Retrieves the table name to use for storing indexables. * * @return string The table name to use. */ protected function get_table_name() { return Model::get_table_name( 'Indexable' ); } } migrations/20201202144329_AddEstimatedReadingTime.php 0000644 00000001703 15154230336 0015534 0 ustar 00 <?php namespace Yoast\WP\SEO\Config\Migrations; use Yoast\WP\Lib\Migrations\Migration; use Yoast\WP\Lib\Model; /** * AddEstimatedReadingTime class. */ class AddEstimatedReadingTime extends Migration { /** * The plugin this migration belongs to. * * @var string */ public static $plugin = 'free'; /** * Migration up. * * @return void */ public function up() { $table_name = $this->get_table_name(); $this->add_column( $table_name, 'estimated_reading_time_minutes', 'integer', [ 'null' => true, 'default' => null, ] ); } /** * Migration down. * * @return void */ public function down() { $table_name = $this->get_table_name(); $this->remove_column( $table_name, 'estimated_reading_time_minutes' ); } /** * Retrieves the table name to use. * * @return string The table name to use. */ protected function get_table_name() { return Model::get_table_name( 'Indexable' ); } } migrations/20200408101900_AddCollationToTables.php 0000644 00000001624 15154230336 0015063 0 ustar 00 <?php namespace Yoast\WP\SEO\Config\Migrations; use Yoast\WP\Lib\Migrations\Migration; use Yoast\WP\Lib\Model; /** * Class AddCollationToTables. */ class AddCollationToTables extends Migration { /** * The plugin this migration belongs to. * * @var string */ public static $plugin = 'free'; /** * Migration up. */ public function up() { global $wpdb; $charset_collate = $wpdb->get_charset_collate(); if ( empty( $charset_collate ) ) { return; } $tables = [ Model::get_table_name( 'migrations' ), Model::get_table_name( 'Indexable' ), Model::get_table_name( 'Indexable_Hierarchy' ), Model::get_table_name( 'Primary_Term' ), ]; foreach ( $tables as $table ) { $this->query( 'ALTER TABLE ' . $table . ' CONVERT TO ' . \str_replace( 'DEFAULT ', '', $charset_collate ) ); } } /** * Migration down. */ public function down() { // No down required. } } migrations/20200430150130_ClearIndexableTables.php 0000644 00000002005 15154230336 0015051 0 ustar 00 <?php namespace Yoast\WP\SEO\Config\Migrations; use Yoast\WP\Lib\Migrations\Migration; use Yoast\WP\Lib\Model; /** * Class ClearIndexableTables. */ class ClearIndexableTables extends Migration { /** * The plugin this migration belongs to. * * @var string */ public static $plugin = 'free'; /** * Migration up. */ public function up() { $this->query( 'TRUNCATE TABLE ' . $this->get_indexable_table_name() ); $this->query( 'TRUNCATE TABLE ' . $this->get_indexable_hierarchy_table_name() ); } /** * Migration down. */ public function down() { // Nothing to do. } /** * Retrieves the table name to use for storing indexables. * * @return string The table name to use. */ protected function get_indexable_table_name() { return Model::get_table_name( 'Indexable' ); } /** * Retrieves the table name to use. * * @return string The table name to use. */ protected function get_indexable_hierarchy_table_name() { return Model::get_table_name( 'Indexable_Hierarchy' ); } } migrations/20200616130143_ReplacePermalinkHashIndex.php 0000644 00000004365 15154230336 0016111 0 ustar 00 <?php namespace Yoast\WP\SEO\Config\Migrations; use Yoast\WP\Lib\Migrations\Migration; use Yoast\WP\Lib\Model; /** * ReplacePermalinkHashIndex class. */ class ReplacePermalinkHashIndex extends Migration { /** * The plugin this migration belongs to. * * @var string */ public static $plugin = 'free'; /** * Migration up. * * @return void */ public function up() { $table_name = $this->get_table_name(); $adapter = $this->get_adapter(); if ( ! $adapter->has_table( $table_name ) ) { return; } $this->change_column( $table_name, 'permalink_hash', 'string', [ 'null' => true, 'limit' => 40, ] ); if ( $adapter->has_index( $table_name, [ 'permalink_hash' ], [ 'name' => 'permalink_hash' ] ) ) { $this->remove_index( $table_name, [ 'permalink_hash', ], [ 'name' => 'permalink_hash', ] ); } if ( ! $adapter->has_index( $table_name, [ 'permalink_hash', 'object_type' ], [ 'name' => 'permalink_hash_and_object_type' ] ) ) { $this->add_index( $table_name, [ 'permalink_hash', 'object_type', ], [ 'name' => 'permalink_hash_and_object_type', ] ); } } /** * Migration down. * * @return void */ public function down() { $table_name = $this->get_table_name(); $adapter = $this->get_adapter(); if ( ! $adapter->has_table( $table_name ) ) { return; } if ( $adapter->has_index( $table_name, [ 'permalink_hash', 'object_type' ], [ 'name' => 'permalink_hash_and_object_type' ] ) ) { $this->remove_index( $table_name, [ 'permalink_hash', 'object_type', ], [ 'name' => 'permalink_hash_and_object_type', ] ); } $this->change_column( $table_name, 'permalink_hash', 'string', [ 'null' => true, 'limit' => 191, ] ); if ( ! $adapter->has_index( $table_name, [ 'permalink_hash' ], [ 'name' => 'permalink_hash' ] ) ) { $this->add_index( $table_name, [ 'permalink_hash', ], [ 'name' => 'permalink_hash', ] ); } } /** * Retrieves the table name to use for storing indexables. * * @return string The table name to use. */ protected function get_table_name() { return Model::get_table_name( 'Indexable' ); } } migrations/20200513133401_ResetIndexableHierarchyTable.php 0000644 00000001314 15154230336 0016567 0 ustar 00 <?php namespace Yoast\WP\SEO\Config\Migrations; use Yoast\WP\Lib\Migrations\Migration; use Yoast\WP\Lib\Model; /** * Class ResetIndexableHierarchyTable. */ class ResetIndexableHierarchyTable extends Migration { /** * The plugin this migration belongs to. * * @var string */ public static $plugin = 'free'; /** * Migration up. */ public function up() { $this->query( 'TRUNCATE TABLE ' . $this->get_table_name() ); } /** * Migration down. */ public function down() { // Nothing to do. } /** * Retrieves the table name to use. * * @return string The table name to use. */ protected function get_table_name() { return Model::get_table_name( 'Indexable_Hierarchy' ); } } migrations/20200609154515_AddHasAncestorsColumn.php 0000644 00000001607 15154230336 0015272 0 ustar 00 <?php namespace Yoast\WP\SEO\Config\Migrations; use Yoast\WP\Lib\Migrations\Migration; use Yoast\WP\Lib\Model; use Yoast\WP\SEO\WordPress\Wrapper; /** * Class AddHasAncestorsColumn. */ class AddHasAncestorsColumn extends Migration { /** * The plugin this migration belongs to. * * @var string */ public static $plugin = 'free'; /** * Migration up. */ public function up() { $this->add_column( Model::get_table_name( 'Indexable' ), 'has_ancestors', 'boolean', [ 'default' => false, ] ); Wrapper::get_wpdb()->query( ' UPDATE ' . Model::get_table_name( 'Indexable' ) . ' SET has_ancestors = 1 WHERE id IN ( SELECT indexable_id FROM ' . Model::get_table_name( 'Indexable_Hierarchy' ) . ' ) ' ); } /** * Migration down. */ public function down() { $this->remove_column( Model::get_table_name( 'Indexable' ), 'has_ancestors' ); } } migrations/20200617122511_CreateSEOLinksTable.php 0000644 00000004735 15154230336 0014624 0 ustar 00 <?php namespace Yoast\WP\SEO\Config\Migrations; use Yoast\WP\Lib\Migrations\Migration; use Yoast\WP\Lib\Model; /** * CreateSEOLinksTable class. */ class CreateSEOLinksTable extends Migration { /** * The plugin this migration belongs to. * * @var string */ public static $plugin = 'free'; /** * Migration up. * * @return void */ public function up() { $table_name = $this->get_table_name(); $adapter = $this->get_adapter(); // The table may already have been created by legacy code. // If not, create it exactly as it was. if ( ! $adapter->table_exists( $table_name ) ) { $table = $this->create_table( $table_name, [ 'id' => false ] ); $table->column( 'id', 'biginteger', [ 'primary_key' => true, 'limit' => 20, 'unsigned' => true, 'auto_increment' => true, ] ); $table->column( 'url', 'string', [ 'limit' => 255 ] ); $table->column( 'post_id', 'biginteger', [ 'limit' => 20, 'unsigned' => true, ] ); $table->column( 'target_post_id', 'biginteger', [ 'limit' => 20, 'unsigned' => true, ] ); $table->column( 'type', 'string', [ 'limit' => 8 ] ); $table->finish(); } if ( ! $adapter->has_index( $table_name, [ 'post_id', 'type' ], [ 'name' => 'link_direction' ] ) ) { $this->add_index( $table_name, [ 'post_id', 'type' ], [ 'name' => 'link_direction' ] ); } // Add these columns outside of the initial table creation as these did not exist on the legacy table. $this->add_column( $table_name, 'indexable_id', 'integer', [ 'unsigned' => true ] ); $this->add_column( $table_name, 'target_indexable_id', 'integer', [ 'unsigned' => true ] ); $this->add_column( $table_name, 'height', 'integer', [ 'unsigned' => true ] ); $this->add_column( $table_name, 'width', 'integer', [ 'unsigned' => true ] ); $this->add_column( $table_name, 'size', 'integer', [ 'unsigned' => true ] ); $this->add_column( $table_name, 'language', 'string', [ 'limit' => 32 ] ); $this->add_column( $table_name, 'region', 'string', [ 'limit' => 32 ] ); $this->add_index( $table_name, [ 'indexable_id', 'type' ], [ 'name' => 'indexable_link_direction' ] ); } /** * Migration down. * * @return void */ public function down() { $this->drop_table( $this->get_table_name() ); } /** * Returns the SEO Links table name. * * @return string */ private function get_table_name() { return Model::get_table_name( 'SEO_Links' ); } } migrations/20201216124002_ExpandIndexableIDColumnLengths.php 0000644 00000002023 15154230336 0017031 0 ustar 00 <?php namespace Yoast\WP\SEO\Config\Migrations; use Yoast\WP\Lib\Migrations\Migration; use Yoast\WP\Lib\Model; /** * ExpandIndexableIDColumnLengths class. */ class ExpandIndexableIDColumnLengths extends Migration { /** * The plugin this migration belongs to. * * @var string */ public static $plugin = 'free'; /** * The columns to change the column type and length of. * * @var string[] */ protected static $columns_to_change = [ 'object_id', 'author_id', 'post_parent', ]; /** * Migration up. * * @return void */ public function up() { foreach ( self::$columns_to_change as $column ) { $this->change_column( $this->get_table_name(), $column, 'biginteger', [ 'limit' => 20 ] ); } } /** * Migration down. * * @return void */ public function down() { } /** * Retrieves the table name to use for storing indexables. * * @return string The table name to use. */ protected function get_table_name() { return Model::get_table_name( 'Indexable' ); } } migrations/20200507054848_DeleteDuplicateIndexables.php 0000644 00000002041 15154230336 0016140 0 ustar 00 <?php namespace Yoast\WP\SEO\Config\Migrations; use Yoast\WP\Lib\Migrations\Migration; use Yoast\WP\Lib\Model; /** * Class DeleteDuplicateIndexables. */ class DeleteDuplicateIndexables extends Migration { /** * The plugin this migration belongs to. * * @var string */ public static $plugin = 'free'; /** * Migration up. */ public function up() { $table_name = $this->get_table_name(); /* * Deletes duplicate indexables that have the same object_id and object_type. * The rows with a higher ID are deleted as those should be unused and could be outdated. */ $this->query( 'DELETE wyi FROM ' . $table_name . ' wyi INNER JOIN ' . $table_name . ' wyi2 WHERE wyi2.object_id = wyi.object_id AND wyi2.object_type = wyi.object_type AND wyi2.id < wyi.id;' ); } /** * Migration down. */ public function down() { // Nothing to do. } /** * Retrieves the table name to use. * * @return string The table name to use. */ protected function get_table_name() { return Model::get_table_name( 'Indexable' ); } } migrations/20201216141134_ExpandPrimaryTermIDColumnLengths.php 0000644 00000002005 15154230336 0017416 0 ustar 00 <?php namespace Yoast\WP\SEO\Config\Migrations; use Yoast\WP\Lib\Migrations\Migration; use Yoast\WP\Lib\Model; /** * ExpandPrimaryTermIDColumnLengths class. */ class ExpandPrimaryTermIDColumnLengths extends Migration { /** * The plugin this migration belongs to. * * @var string */ public static $plugin = 'free'; /** * The columns to change the column type and length of. * * @var string[] */ protected static $columns_to_change = [ 'post_id', 'term_id', ]; /** * Migration up. * * @return void */ public function up() { foreach ( self::$columns_to_change as $column ) { $this->change_column( $this->get_table_name(), $column, 'biginteger', [ 'limit' => 20 ] ); } } /** * Migration down. * * @return void */ public function down() { } /** * Retrieves the table name to use for storing indexables. * * @return string The table name to use. */ protected function get_table_name() { return Model::get_table_name( 'Primary_Term' ); } } migrations/20200430075614_AddIndexableObjectIdAndTypeIndex.php 0000644 00000001665 15154230336 0017271 0 ustar 00 <?php namespace Yoast\WP\SEO\Config\Migrations; use Yoast\WP\Lib\Migrations\Migration; use Yoast\WP\Lib\Model; /** * Class AddIndexableObjectIdAndTypeIndex. */ class AddIndexableObjectIdAndTypeIndex extends Migration { /** * The plugin this migration belongs to. * * @var string */ public static $plugin = 'free'; /** * Migration up. */ public function up() { $this->add_index( $this->get_table_name(), [ 'object_id', 'object_type', ], [ 'name' => 'object_id_and_type', ] ); } /** * Migration down. */ public function down() { $this->remove_index( $this->get_table_name(), [ 'object_id', 'object_type', ], [ 'name' => 'object_id_and_type', ] ); } /** * Retrieves the table name to use for storing indexables. * * @return string The table name to use. */ protected function get_table_name() { return Model::get_table_name( 'Indexable' ); } } migrations/20191011111109_WpYoastIndexableHierarchy.php 0000644 00000003020 15154230336 0016142 0 ustar 00 <?php namespace Yoast\WP\SEO\Config\Migrations; use Yoast\WP\Lib\Migrations\Migration; use Yoast\WP\Lib\Model; /** * Class WpYoastIndexableHierarchy. */ class WpYoastIndexableHierarchy extends Migration { /** * The plugin this migration belongs to. * * @var string */ public static $plugin = 'free'; /** * Migration up. */ public function up() { $table_name = $this->get_table_name(); $indexable_table = $this->create_table( $table_name, [ 'id' => false ] ); $indexable_table->column( 'indexable_id', 'integer', [ 'primary_key' => true, 'unsigned' => true, 'null' => true, 'limit' => 11, ] ); $indexable_table->column( 'ancestor_id', 'integer', [ 'primary_key' => true, 'unsigned' => true, 'null' => true, 'limit' => 11, ] ); $indexable_table->column( 'depth', 'integer', [ 'unsigned' => true, 'null' => true, 'limit' => 11, ] ); $indexable_table->finish(); $this->add_index( $table_name, 'indexable_id', [ 'name' => 'indexable_id' ] ); $this->add_index( $table_name, 'ancestor_id', [ 'name' => 'ancestor_id' ] ); $this->add_index( $table_name, 'depth', [ 'name' => 'depth' ] ); } /** * Migration up. */ public function down() { $this->drop_table( $this->get_table_name() ); } /** * Retrieves the table name to use. * * @return string The table name to use. */ protected function get_table_name() { return Model::get_table_name( 'Indexable_Hierarchy' ); } } migrations/20171228151841_WpYoastPrimaryTerm.php 0000644 00000002775 15154230336 0014722 0 ustar 00 <?php namespace Yoast\WP\SEO\Config\Migrations; use Yoast\WP\Lib\Migrations\Migration; use Yoast\WP\Lib\Model; /** * Migration for the Primary Term. */ class WpYoastPrimaryTerm extends Migration { /** * The plugin this migration belongs to. * * @var string */ public static $plugin = 'free'; /** * Migration up. * * @return void */ public function up() { $table_name = $this->get_table_name(); $indexable_table = $this->create_table( $table_name ); $indexable_table->column( 'post_id', 'integer', [ 'unsigned' => true, 'null' => false, 'limit' => 11, ] ); $indexable_table->column( 'term_id', 'integer', [ 'unsigned' => true, 'null' => false, 'limit' => 11, ] ); $indexable_table->column( 'taxonomy', 'string', [ 'null' => false, 'limit' => 32, ] ); // Executes the SQL to create the table. $indexable_table->finish(); $this->add_index( $table_name, [ 'post_id', 'taxonomy', ], [ 'name' => 'post_taxonomy', ] ); $this->add_index( $table_name, [ 'post_id', 'term_id', ], [ 'name' => 'post_term', ] ); $this->add_timestamps( $table_name ); } /** * Migration down. */ public function down() { $this->drop_table( $this->get_table_name() ); } /** * Retrieves the table name to use. * * @return string Table name to use. */ protected function get_table_name() { return Model::get_table_name( 'Primary_Term' ); } } migrations/20200428123747_BreadcrumbTitleAndHierarchyReset.php 0000644 00000002304 15154230336 0017440 0 ustar 00 <?php namespace Yoast\WP\SEO\Config\Migrations; use Yoast\WP\Lib\Migrations\Migration; use Yoast\WP\Lib\Model; /** * Class BreadcrumbTitleAndHierarchyReset. */ class BreadcrumbTitleAndHierarchyReset extends Migration { /** * The plugin this migration belongs to. * * @var string */ public static $plugin = 'free'; /** * Migration up. */ public function up() { $this->change_column( $this->get_indexable_table_name(), 'breadcrumb_title', 'text', [ 'null' => true ] ); $this->query( 'DELETE FROM ' . $this->get_indexable_hierarchy_table_name() ); } /** * Migration down. */ public function down() { $this->change_column( $this->get_indexable_table_name(), 'breadcrumb_title', 'string', [ 'null' => true, 'limit' => 191, ] ); } /** * Retrieves the table name to use for storing indexables. * * @return string The table name to use. */ protected function get_indexable_table_name() { return Model::get_table_name( 'Indexable' ); } /** * Retrieves the table name to use. * * @return string The table name to use. */ protected function get_indexable_hierarchy_table_name() { return Model::get_table_name( 'Indexable_Hierarchy' ); } } indexing-reasons.php 0000644 00000001473 15154230336 0010541 0 ustar 00 <?php namespace Yoast\WP\SEO\Config; /** * Class Indexing_Reasons. Contains constants that aren't context specific. */ class Indexing_Reasons { /** * Represents the reason that the indexing process failed and should be tried again. */ const REASON_INDEXING_FAILED = 'indexing_failed'; /** * Represents the reason that the permalink settings are changed. */ const REASON_PERMALINK_SETTINGS = 'permalink_settings_changed'; /** * Represents the reason that the category base is changed. */ const REASON_CATEGORY_BASE_PREFIX = 'category_base_changed'; /** * Represents the reason that the tag base is changed. */ const REASON_TAG_BASE_PREFIX = 'tag_base_changed'; /** * Represents the reason that the home url option is changed. */ const REASON_HOME_URL_OPTION = 'home_url_option_changed'; } schema-types.php 0000644 00000007555 15154230336 0007675 0 ustar 00 <?php namespace Yoast\WP\SEO\Config; /** * Class Schema_Types. */ class Schema_Types { /** * Holds the possible schema page types. * * Capitalized in this way so the value can be directly used in the schema output. * * @var string[] */ const PAGE_TYPES = [ 'WebPage' => '', 'ItemPage' => '', 'AboutPage' => '', 'FAQPage' => '', 'QAPage' => '', 'ProfilePage' => '', 'ContactPage' => '', 'MedicalWebPage' => '', 'CollectionPage' => '', 'CheckoutPage' => '', 'RealEstateListing' => '', 'SearchResultsPage' => '', ]; /** * Holds the possible schema article types. * * Capitalized in this way so the value can be directly used in the schema output. * * @var string[] */ const ARTICLE_TYPES = [ 'Article' => '', 'SocialMediaPosting' => '', 'NewsArticle' => '', 'AdvertiserContentArticle' => '', 'SatiricalArticle' => '', 'ScholarlyArticle' => '', 'TechArticle' => '', 'Report' => '', 'None' => '', ]; /** * Gets the page type options. * * @return array[] The schema page type options. */ public function get_page_type_options() { return [ [ 'name' => \__( 'Web Page', 'wordpress-seo' ), 'value' => 'WebPage', ], [ 'name' => \__( 'Item Page', 'wordpress-seo' ), 'value' => 'ItemPage', ], [ 'name' => \__( 'About Page', 'wordpress-seo' ), 'value' => 'AboutPage', ], [ 'name' => \__( 'FAQ Page', 'wordpress-seo' ), 'value' => 'FAQPage', ], [ 'name' => \__( 'QA Page', 'wordpress-seo' ), 'value' => 'QAPage', ], [ 'name' => \__( 'Profile Page', 'wordpress-seo' ), 'value' => 'ProfilePage', ], [ 'name' => \__( 'Contact Page', 'wordpress-seo' ), 'value' => 'ContactPage', ], [ 'name' => \__( 'Medical Web Page', 'wordpress-seo' ), 'value' => 'MedicalWebPage', ], [ 'name' => \__( 'Collection Page', 'wordpress-seo' ), 'value' => 'CollectionPage', ], [ 'name' => \__( 'Checkout Page', 'wordpress-seo' ), 'value' => 'CheckoutPage', ], [ 'name' => \__( 'Real Estate Listing', 'wordpress-seo' ), 'value' => 'RealEstateListing', ], [ 'name' => \__( 'Search Results Page', 'wordpress-seo' ), 'value' => 'SearchResultsPage', ], ]; } /** * Gets the article type options. * * @return array[] The schema article type options. */ public function get_article_type_options() { /** * Filter: 'wpseo_schema_article_types_labels' - Allow developers to filter the available article types and their labels. * * Make sure when you filter this to also filter `wpseo_schema_article_types`. * * @api array $schema_article_types_labels The available schema article types and their labels. */ return \apply_filters( 'wpseo_schema_article_types_labels', [ [ 'name' => \__( 'Article', 'wordpress-seo' ), 'value' => 'Article', ], [ 'name' => \__( 'Social Media Posting', 'wordpress-seo' ), 'value' => 'SocialMediaPosting', ], [ 'name' => \__( 'News Article', 'wordpress-seo' ), 'value' => 'NewsArticle', ], [ 'name' => \__( 'Advertiser Content Article', 'wordpress-seo' ), 'value' => 'AdvertiserContentArticle', ], [ 'name' => \__( 'Satirical Article', 'wordpress-seo' ), 'value' => 'SatiricalArticle', ], [ 'name' => \__( 'Scholarly Article', 'wordpress-seo' ), 'value' => 'ScholarlyArticle', ], [ 'name' => \__( 'Tech Article', 'wordpress-seo' ), 'value' => 'TechArticle', ], [ 'name' => \__( 'Report', 'wordpress-seo' ), 'value' => 'Report', ], [ 'name' => \__( 'None', 'wordpress-seo' ), 'value' => 'None', ], ] ); } } badge-group-names.php 0000644 00000002753 15154230336 0010563 0 ustar 00 <?php namespace Yoast\WP\SEO\Config; /** * Class Badge_Group_Names. * * This class defines groups for "new" badges, with the version in which those groups are no longer considered * to be "new". */ class Badge_Group_Names { const GROUP_GLOBAL_TEMPLATES = 'global-templates'; /** * Constant describing when certain groups of new badges will no longer be shown. */ const GROUP_NAMES = [ self::GROUP_GLOBAL_TEMPLATES => '16.7-beta0', ]; /** * The current plugin version. * * @var string */ protected $version; /** * Badge_Group_Names constructor. * * @param string|null $version Optional: the current plugin version. */ public function __construct( $version = null ) { if ( ! $version ) { $version = \WPSEO_VERSION; } $this->version = $version; } /** * Check whether a group of badges is still eligible for a "new" badge. * * @param string $group One of the GROUP_* constants. * @param string|null $current_version The current version of the plugin that's being checked. * * @return bool Whether a group of badges is still eligible for a "new" badge. */ public function is_still_eligible_for_new_badge( $group, $current_version = null ) { if ( ! \array_key_exists( $group, $this::GROUP_NAMES ) ) { return false; } $group_version = $this::GROUP_NAMES[ $group ]; if ( \is_null( $current_version ) ) { $current_version = $this->version; } return (bool) \version_compare( $group_version, $current_version, '>' ); } } migration-status.php 0000644 00000012220 15154230336 0010566 0 ustar 00 <?php namespace Yoast\WP\SEO\Config; /** * Migration_Status class. * * Used to validate whether or not migrations have been run and whether or not they should be run again. */ class Migration_Status { /** * The migration option key. * * @var string */ const MIGRATION_OPTION_KEY = 'yoast_migrations_'; /** * The migration options. * * @var array */ protected $migration_options = []; /** * Checks if a given migration should be run. * * @param string $name The name of the migration. * @param string $version The current version. * * @return bool Whether or not the migration should be run. */ public function should_run_migration( $name, $version = \WPSEO_VERSION ) { $migration_status = $this->get_migration_status( $name ); // Check if we've attempted to run this migration in the past 10 minutes. If so, it may still be running. if ( \array_key_exists( 'lock', $migration_status ) ) { $timestamp = \strtotime( '-10 minutes' ); return $timestamp > $migration_status['lock']; } // Is the migration version less than the current version. return \version_compare( $migration_status['version'], $version, '<' ); } /** * Checks whether or not the given migration is at least the given version, defaults to checking for the latest version. * * @param string $name The name of the migration. * @param string $version The version to check, defaults to the latest version. * * @return bool Whether or not the requested migration is at least the requested version. */ public function is_version( $name, $version = \WPSEO_VERSION ) { $migration_status = $this->get_migration_status( $name ); return \version_compare( $version, $migration_status['version'], '<=' ); } /** * Gets the error of a given migration if it exists. * * @param string $name The name of the migration. * * @return bool|array False if there is no error, otherwise the error. */ public function get_error( $name ) { $migration_status = $this->get_migration_status( $name ); if ( ! isset( $migration_status['error'] ) ) { return false; } return $migration_status['error']; } /** * Sets an error for the migration. * * @param string $name The name of the migration. * @param string $message Message explaining the reason for the error. * @param string $version The current version. * * @return void */ public function set_error( $name, $message, $version = \WPSEO_VERSION ) { $migration_status = $this->get_migration_status( $name ); $migration_status['error'] = [ 'time' => \strtotime( 'now' ), 'version' => $version, 'message' => $message, ]; $this->set_migration_status( $name, $migration_status ); } /** * Updates the migration version to the latest version. * * @param string $name The name of the migration. * @param string $version The current version. * * @return void */ public function set_success( $name, $version = \WPSEO_VERSION ) { $migration_status = $this->get_migration_status( $name ); unset( $migration_status['lock'] ); unset( $migration_status['error'] ); $migration_status['version'] = $version; $this->set_migration_status( $name, $migration_status ); } /** * Locks the migration status. * * @param string $name The name of the migration. * * @return bool Whether or not the migration was succesfully locked. */ public function lock_migration( $name ) { $migration_status = $this->get_migration_status( $name ); $migration_status['lock'] = \strtotime( 'now' ); return $this->set_migration_status( $name, $migration_status ); } /** * Retrieves the migration option. * * @param string $name The name of the migration. * * @return bool|array The status of the migration, false if no status exists. */ protected function get_migration_status( $name ) { $current_blog_id = \get_current_blog_id(); if ( ! isset( $this->migration_options[ $current_blog_id ][ $name ] ) ) { $migration_status = \get_option( self::MIGRATION_OPTION_KEY . $name ); if ( ! \is_array( $migration_status ) || ! isset( $migration_status['version'] ) ) { $migration_status = [ 'version' => '0.0' ]; } if ( ! isset( $this->migration_options[ $current_blog_id ] ) ) { $this->migration_options[ $current_blog_id ] = []; } $this->migration_options[ $current_blog_id ][ $name ] = $migration_status; } return $this->migration_options[ $current_blog_id ][ $name ]; } /** * Retrieves the migration option. * * @param string $name The name of the migration. * @param array $migration_status The migration status. * * @return bool True if the status was succesfully updated, false otherwise. */ protected function set_migration_status( $name, $migration_status ) { if ( ! \is_array( $migration_status ) || ! isset( $migration_status['version'] ) ) { return false; } $current_blog_id = \get_current_blog_id(); if ( ! isset( $this->migration_options[ $current_blog_id ] ) ) { $this->migration_options[ $current_blog_id ] = []; } $this->migration_options[ $current_blog_id ][ $name ] = $migration_status; return \update_option( self::MIGRATION_OPTION_KEY . $name, $migration_status ); } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Ð“ÐµÐ½ÐµÑ€Ð°Ñ†Ð¸Ñ Ñтраницы: 0 |
proxy
|
phpinfo
|
ÐаÑтройка