settings = $settings; $this->not_found = $not_found; $this->changes = $changes; } /** * Registers the handler and makes sure the daily event exists. */ public function register() { add_action( self::HOOK, array( $this, 'run' ) ); if ( ! wp_next_scheduled( self::HOOK ) ) { wp_schedule_event( time() + HOUR_IN_SECONDS, 'daily', self::HOOK ); } } /** * Runs the housekeeping. * * @return array{not_found:int,changes:int} Rows removed. */ public function run() { if ( ! Tables::v3_ready() ) { return array( 'not_found' => 0, 'changes' => 0, ); } return array( 'not_found' => $this->not_found->trim(), 'changes' => $this->changes->prune( (int) $this->settings->get( 'change_retention_days' ) ), ); } }