芝麻web文件管理V1.00
编辑当前文件:/home/freeclou/optimyar/wp-content/plugins/google-site-kit/includes/Core/Util/Migration_1_3_0.php
context = $context; $this->options = $options ?: new Options( $context ); $this->user_options = $user_options ?: new User_Options( $context ); } /** * Registers hooks. * * @since 1.3.0 */ public function register() { add_action( 'admin_init', array( $this, 'migrate' ) ); } /** * Migrates the DB. * * @since 1.3.0 */ public function migrate() { $db_version = $this->options->get( 'googlesitekit_db_version' ); if ( ! $db_version || version_compare( $db_version, self::DB_VERSION, '<' ) ) { $this->migrate_tracking_opt_in(); $this->options->set( 'googlesitekit_db_version', self::DB_VERSION ); } } /** * Migrates the global tracking opt-in to a user option. * * @since 1.3.0 * @since 1.4.0 Migrates preference for up to 20 users. */ private function migrate_tracking_opt_in() { // Only migrate if tracking was opted-in. if ( $this->options->get( Tracking_Consent::OPTION ) ) { $backup_user_id = $this->user_options->get_user_id(); foreach ( $this->get_authenticated_users() as $user_id ) { $this->user_options->switch_user( $user_id ); $this->user_options->set( Tracking_Consent::OPTION, 1 ); } $this->user_options->switch_user( $backup_user_id ); } } /** * Gets the authenticated users connected to Site Kit. * * @since 1.4.0 * * @return string[] User IDs of authenticated users. Maximum of 20. */ private function get_authenticated_users() { return get_users( array( 'meta_key' => $this->user_options->get_meta_key( OAuth_Client::OPTION_ACCESS_TOKEN ), // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key 'meta_compare' => 'EXISTS', 'number' => 20, 'fields' => 'ID', ) ); } }