џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ џџџџџџџџџџџџџџџџРС) џџџџK8$дчШrrA џџџџj^RьЩA ches( 1 ), function ( $carry, $batch ) { return $batch; }, array() ); } /** * Get batches. * * @param int $limit Number of batches to return, defaults to all. * * @џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ џџџџџџџџџџџџџџџџџџџџ P ) џџџџк!х'ч0D{A ( empty( $limit ) || ! is_int( $limit ) ) { $limit = 0; } $table = $wpdb->options; $column = 'option_name'; $key_column = 'option_id'; $value_column = 'option_value'; if ( is_multisitaЕ3%Џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ џџџџџџџџџџџџџџџџШн ) џџџџK8$дчШrrA џџџџj^RьЩA ; } $key = $wpdb->esc_like( $this->identifier . '_batch_' ) . '%'; $sql = ' SELECT * FROM ' . $table . ' WHERE ' . $column . ' LIKE %s ORDER BY ' . $key_column . ' aЕ3%ЎTџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ џџџџџџџџџџџџџџџџАў) џџџџK8$дчШrrA џџџџj^RьЩA et_results( $wpdb->prepare( $sql, $args ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared $batches = array(); if ( ! empty( $items ) ) { $batches = array_map( funcaЕ3%Јџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ џџџџџџџџџџџџџџџџџџџџУ) џџџџ $item->{$column}; $batch->data = maybe_unserialize( $item->{$value_column} ); return $batch; }, $items ); } return $batches; } /** * Handle a dispatched request. * * Pass each queuaЕ3%Ћдџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ џџџџУ) џџџџОЙГ'o=Еэ@ы ) rotected function handle() { $this->lock_process(); /** * Number of seconds to sleep between batches. Defaults to 0 seconds, minimum 0. * * @param int $seconds */ $throttle_seconds = max( 0, aЕ3%Њџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ џџџџџџџџџџџџџџџџ(Ф) џџџџK8$дчШrrA џџџџj^RьЩA 0 ) ) ); do { $batch = $this->get_batch(); foreach ( $batch->data as $key => $value ) { $task = $this->task( $value ); if ( false !== $task ) { $baaЕ3%ЅTџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ џџџџџџџџџџџџџџџџџџџџХ) џџџџ up to date while processing it. if ( ! empty( $batch->data ) ) { $this->update( $batch->key, $batch->data ); } // Let the server breathe a little. sleep( $throttle_seconds ); // Batch limiaЕ3%Їџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ џџџџџџџџФ) џџџџ=UМU[MнВы ) this->is_paused() || $this->is_cancelled() ) { break; } } // Delete current batch if fully processed. if ( empty( $batch->data ) ) { $this->delete( $batch->key ); } } while ( ! $this->timeaЕ3%Ідџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ џџџџџџџџџџџџџџџџxХ) џџџџK8$дчШrrA џџџџj^RьЩA nlock_process(); // Start next batch or complete process. if ( ! $this->is_queue_empty() ) { $this->dispatch(); } else { $this->complete(); } return $this->maybe_wp_daЕ3%Ёџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ џџџџџџџџџџџџ(K) џџџџ Ц) џџџџ 0I) џџџџ on memory_exceeded() { $memory_limit = $this->get_memory_limit() * 0.9; // 90% of max memory $current_memory = memory_get_usage( true ); $returnaЕ3% Tџџџџ џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџАХ) џџџџх,иЂры ) lters( $this->identifier . '_memory_exceeded', $return ); } /** * Get memory limit in bytes. * * @return int */ protected function get_memory_limit() { if ( function_exists( 'ini_get' ) ) { $memory_laЕ3%Ђџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ џџџџџџџџџџџџџџџџ%) џџџџK8$дчШrrA џџџџj^RьЩA ию;) џџџџђ%| №wrA Unlimited, set to 32GB. $memory_limit = '32000M'; } return wp_convert_hr_to_bytes( $memoins' ) { // If future versions of WordPress change this filter's behavior, our behavior should stay consistent. return; } if ( ! \is_array( $old_value ) || ! \is_array( $new_value ) ) { return; } $auto_updates_are_enabled = $this->are_auto_updates_enabled( self::WPSEO_FREE_PLUGIN_ID, $new_value ); $auto_updates_were_enabled = $this->are_auto_updates_enabled( self::WPSEO_FREE_PLUGIN_ID, $old_value ); if ( $auto_updates_are_enabled === $auto_updates_were_enabled ) { // Auto-updates for Yoast SEO have stayed the same, so have neither been enabled or disabled. return; } $auto_updates_have_been_enabled = $auto_updates_are_enabled && ! $auto_updates_were_enabled; if ( $auto_updates_have_been_enabled ) { $this->enable_auto_updates_for_addons( $new_value ); return; } else { $this->disable_auto_updates_for_addons( $new_value ); return; } if ( ! $auto_updates_are_enabled ) { return; } $auto_updates_have_been_removed = false; foreach ( self::ADD_ON_PLUGIN_FILES as $addon ) { if ( ! $this->are_auto_updates_enabled( $addon, $new_value ) ) { $auto_updates_have_been_removed = true; break; } } if ( $auto_updates_have_been_removed ) { $this->enable_auto_updates_for_addons( $new_value ); } } /** * Trigger a change in the auto update detection whenever a new Yoast addon is activated. * * @param string $plugin The plugin that is activated. * * @return void */ public function maybe_toggle_auto_updates_for_new_install( $plugin ) { $not_a_yoast_addon = ! \in_array( $plugin, self::ADD_ON_PLUGIN_FILES, true ); if ( $not_a_yoast_addon ) { return; } $enabled_auto_updates = \get_site_option( 'auto_update_plugins' ); $this->toggle_auto_updates_for_add_ons( 'auto_update_plugins', $enabled_auto_updates, [] ); } /** * Enables auto-updates for all addons. * * @param string[] $auto_updated_plugins The current list of auto-updated plugins. */ protected function enable_auto_updates_for_addons( $auto_updated_plugins ) { $plugins = \array_unique( \array_merge( $auto_updated_plugins, self::ADD_ON_PLUGIN_FILES ) ); \update_site_option( 'auto_update_plugins', $plugins ); } /** * Disables auto-updates for all addons. * * @param string[] $auto_updated_plugins The current list of auto-updated plugins. */ protected function disable_auto_updates_for_addons( $auto_updated_plugins ) { $plugins = \array_values( \array_diff( $auto_updated_plugins, self::ADD_ON_PLUGIN_FILES ) ); \update_site_option( 'auto_update_plugins', $plugins ); } /** * Checks whether auto updates for a plugin are enabled. * * @param string $plugin_id The plugin ID. * @param array $auto_updated_plugins The array of auto updated plugins. * * @return bool Whether auto updates for a plugin are enabled. */ protected function are_auto_updates_enabled( $plugin_id, $auto_updated_plugins ) { if ( $auto_updated_plugins === false || ! \is_array( $auto_updated_plugins ) ) { return false; } return \in_array( $plugin_id, $auto_updated_plugins, true ); } }