get(); $items[ $id ] = $item; return set_transient( self::BATCH_CHECK_TRANSIENT, array_filter( $items ), self::BATCH_CHECK_TRANSIENT_EXPIRATION ); } /** * Remove the batch check item. * * @param string $id The id of the batch. */ public function remove( $id ) { $items = $this->get(); // remove the item. unset( $items[ $id ] ); // if there are no items, delete the transient. return empty( $items ) ? delete_transient( self::BATCH_CHECK_TRANSIENT ) : set_transient( self::BATCH_CHECK_TRANSIENT, array_filter( $items ), self::BATCH_CHECK_TRANSIENT_EXPIRATION ); } /** * Get the batches by prefix. * * @param string $prefix The prefix. * * @return array */ public function getByPrefix( $prefix ) { $items = $this->get(); return array_filter( $items, function ( $item, $key ) use ( $prefix ) { return strpos( $key, $prefix ) === 0; }, ARRAY_FILTER_USE_BOTH ); } }