芝麻web文件管理V1.00
编辑当前文件:/home/ezdajrnh/public_html/wp-content/plugins/google-listings-and-ads/src/Notes/NoteInitializer.php
action_scheduler = $action_scheduler; } /** * Register the service. */ public function register(): void { add_action( self::CRON_HOOK, [ $this, 'add_notes' ] ); } /** * Loop through all notes to add any that should be added. */ public function add_notes(): void { $notes = $this->container->get( Note::class ); foreach ( $notes as $note ) { try { if ( $note->should_be_added() ) { $note->get_entry()->save(); } } catch ( Exception $e ) { do_action( 'woocommerce_gla_exception', $e, __METHOD__ ); } } } /** * Activate the service. * * @return void */ public function activate(): void { $this->maybe_add_cron_job(); } /** * Run's when plugin is installed or updated. * * @param string $old_version Previous version before updating. * @param string $new_version Current version after updating. */ public function install( string $old_version, string $new_version ): void { $this->maybe_add_cron_job(); } /** * Add notes cron job if it doesn't already exist. */ protected function maybe_add_cron_job(): void { if ( ! $this->action_scheduler->has_scheduled_action( self::CRON_HOOK ) ) { $this->action_scheduler->schedule_recurring( time(), DAY_IN_SECONDS, self::CRON_HOOK ); } } /** * Deactivate the service. * * Delete the notes cron job and all notes. */ public function deactivate(): void { try { $this->action_scheduler->cancel( self::CRON_HOOK ); } catch ( ActionSchedulerException $e ) { do_action( 'woocommerce_gla_exception', $e, __METHOD__ ); } // Ensure all note names are deleted if ( class_exists( Notes::class ) ) { $note_names = []; $notes = $this->container->get( Note::class ); foreach ( $notes as $note ) { $note_names[] = $note->get_name(); } Notes::delete_notes_with_name( $note_names ); } } }