Файловый менеджер - Редактировать - /home/kunzqhe/photostocker/2/initializers.tar
Ðазад
migration-runner.php 0000644 00000010100 15152576670 0010563 0 ustar 00 <?php namespace Yoast\WP\SEO\Initializers; use Exception; use Yoast\WP\Lib\Migrations\Adapter; use Yoast\WP\Lib\Migrations\Migration; use Yoast\WP\SEO\Conditionals\No_Conditionals; use Yoast\WP\SEO\Config\Migration_Status; use Yoast\WP\SEO\Loader; /** * Triggers database migrations and handles results. */ class Migration_Runner implements Initializer_Interface { use No_Conditionals; /** * The migrations adapter. * * @var Adapter */ protected $adapter; /** * The loader. * * @var Loader */ protected $loader; /** * The migration status. * * @var Migration_Status */ protected $migration_status; /** * Retrieves the conditionals for the migrations. * * @return array The conditionals. */ public static function get_conditionals() { return []; } /** * Migrations constructor. * * @param Migration_Status $migration_status The migration status. * @param Loader $loader The loader. * @param Adapter $adapter The migrations adapter. */ public function __construct( Migration_Status $migration_status, Loader $loader, Adapter $adapter ) { $this->migration_status = $migration_status; $this->loader = $loader; $this->adapter = $adapter; } /** * Runs this initializer. * * @return void * * @throws Exception When a migration errored. */ public function initialize() { $this->run_free_migrations(); // The below actions is used for when queries fail, this may happen in a multisite environment when switch_to_blog is used. \add_action( '_yoast_run_migrations', [ $this, 'run_free_migrations' ] ); } /** * Runs the free migrations. * * @return void * * @throws Exception When a migration errored. */ public function run_free_migrations() { $this->run_migrations( 'free' ); } /** * Initializes the migrations. * * @param string $name The name of the migration. * @param string $version The current version. * * @return bool True on success, false on failure. * * @throws Exception If the migration fails and YOAST_ENVIRONMENT is not production. */ public function run_migrations( $name, $version = \WPSEO_VERSION ) { if ( ! $this->migration_status->should_run_migration( $name, $version ) ) { return true; } if ( ! $this->migration_status->lock_migration( $name ) ) { return false; } $migrations = $this->loader->get_migrations( $name ); if ( $migrations === false ) { $this->migration_status->set_error( $name, "Could not perform $name migrations. No migrations found.", $version ); return false; } try { $this->adapter->create_schema_version_table(); $all_versions = \array_keys( $migrations ); $migrated_versions = $this->adapter->get_migrated_versions(); $to_do_versions = \array_diff( $all_versions, $migrated_versions ); \sort( $to_do_versions, \SORT_STRING ); foreach ( $to_do_versions as $to_do_version ) { $class = $migrations[ $to_do_version ]; $this->run_migration( $to_do_version, $class ); } } catch ( Exception $exception ) { // Something went wrong... $this->migration_status->set_error( $name, $exception->getMessage(), $version ); if ( \defined( 'YOAST_ENVIRONMENT' ) && \YOAST_ENVIRONMENT !== 'production' ) { throw $exception; } return false; } $this->migration_status->set_success( $name, $version ); return true; } /** * Runs a single migration. * * @param string $version The version. * @param string $class The migration class. * * @return void * * @throws Exception If the migration failed. Caught by the run_migrations function. */ protected function run_migration( $version, $class ) { /** * The migration to run. * * @var Migration */ $migration = new $class( $this->adapter ); try { $this->adapter->start_transaction(); $migration->up(); $this->adapter->add_version( $version ); $this->adapter->commit_transaction(); } catch ( Exception $e ) { $this->adapter->rollback_transaction(); throw new Exception( \sprintf( '%s - %s', $class, $e->getMessage() ), 0, $e ); } } } initializer-interface.php 0000644 00000000531 15152576670 0011553 0 ustar 00 <?php namespace Yoast\WP\SEO\Initializers; use Yoast\WP\SEO\Loadable_Interface; /** * Integration interface definition. * * An interface for registering integrations with WordPress. */ interface Initializer_Interface extends Loadable_Interface { /** * Runs this initializer. * * @return void */ public function initialize(); } disable-core-sitemaps.php 0000644 00000005544 15152576670 0011457 0 ustar 00 <?php namespace Yoast\WP\SEO\Initializers; use Yoast\WP\SEO\Conditionals\No_Conditionals; use Yoast\WP\SEO\Helpers\Options_Helper; use Yoast\WP\SEO\Helpers\Redirect_Helper; /** * Disables the WP core sitemaps. */ class Disable_Core_Sitemaps implements Initializer_Interface { use No_Conditionals; /** * The options helper. * * @var Options_Helper */ private $options; /** * The redirect helper. * * @var Redirect_Helper */ private $redirect; /** * Sitemaps_Enabled_Conditional constructor. * * @codeCoverageIgnore * * @param Options_Helper $options The options helper. * @param Redirect_Helper $redirect The redirect helper. */ public function __construct( Options_Helper $options, Redirect_Helper $redirect ) { $this->options = $options; $this->redirect = $redirect; } /** * Disable the WP core XML sitemaps. */ public function initialize() { // This needs to be on priority 15 as that is after our options initialize. \add_action( 'plugins_loaded', [ $this, 'maybe_disable_core_sitemaps' ], 15 ); } /** * Disables the core sitemaps if Yoast SEO sitemaps are enabled. * * @return void */ public function maybe_disable_core_sitemaps() { if ( $this->options->get( 'enable_xml_sitemap' ) ) { \add_filter( 'wp_sitemaps_enabled', '__return_false' ); \add_action( 'template_redirect', [ $this, 'template_redirect' ], 0 ); } } /** * Redirects requests to the WordPress sitemap to the Yoast sitemap. * * @return void */ public function template_redirect() { // If there is no path, nothing to do. if ( empty( $_SERVER['REQUEST_URI'] ) ) { return; } $path = \sanitize_text_field( \wp_unslash( $_SERVER['REQUEST_URI'] ) ); // If it's not a wp-sitemap request, nothing to do. if ( \substr( $path, 0, 11 ) !== '/wp-sitemap' ) { return; } $redirect = $this->get_redirect_url( $path ); if ( ! $redirect ) { return; } $this->redirect->do_safe_redirect( \home_url( $redirect ), 301 ); } /** * Returns the relative sitemap URL to redirect to. * * @param string $path The original path. * * @return string|false The path to redirct to. False if no redirect should be done. */ private function get_redirect_url( $path ) { // Start with the simple string comparison so we avoid doing unnecessary regexes. if ( $path === '/wp-sitemap.xml' ) { return '/sitemap_index.xml'; } if ( \preg_match( '/^\/wp-sitemap-(posts|taxonomies)-(\w+)-(\d+)\.xml$/', $path, $matches ) ) { $index = ( (int) $matches[3] - 1 ); $index = ( $index === 0 ) ? '' : (string) $index; return '/' . $matches[2] . '-sitemap' . $index . '.xml'; } if ( \preg_match( '/^\/wp-sitemap-users-(\d+)\.xml$/', $path, $matches ) ) { $index = ( (int) $matches[1] - 1 ); $index = ( $index === 0 ) ? '' : (string) $index; return '/author-sitemap' . $index . '.xml'; } return false; } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Ð“ÐµÐ½ÐµÑ€Ð°Ñ†Ð¸Ñ Ñтраницы: 0 |
proxy
|
phpinfo
|
ÐаÑтройка