all(); $row = isset( $all[ $site_id ] ) && is_array( $all[ $site_id ] ) ? $all[ $site_id ] : array(); return array_merge( array( 'next' => 0, 'last_sent' => 0, 'last_error' => '', 'last_count' => 0, 'retries' => 0, ), $row ); } /** * Updates fields for a site. * * @param string $site_id Site ID. * @param array $fields Fields to change. * @return void */ public function update( $site_id, array $fields ) { OptionUpdate::change( self::OPTION, static function ( array $all ) use ( $site_id, $fields ) { $current = isset( $all[ $site_id ] ) && is_array( $all[ $site_id ] ) ? $all[ $site_id ] : array(); $all[ $site_id ] = array_merge( $current, $fields ); return $all; } ); } /** * Forgets a site. * * @param string $site_id Site ID. * @return void */ public function forget( $site_id ) { OptionUpdate::change( self::OPTION, static function ( array $all ) use ( $site_id ) { unset( $all[ $site_id ] ); return $all; } ); } /** * Every status row. * * @return array */ private function all() { $all = get_option( self::OPTION, array() ); return is_array( $all ) ? $all : array(); } /** * Drops WordPress's in-request copy of the log so the next read hits the database. * * @return void */ public function refresh() { wp_cache_delete( self::OPTION, 'options' ); wp_cache_delete( 'notoptions', 'options' ); } }