Delete all the posts
TODO Make this more efficient
@param $bypass_trash (aka force_delete per wp_delete_post)
@return integer Number of posts deleted
421429
public static function deleteAll($bypass_trash = false)
    {
        $num_deleted = 0;

        $all = static::getAll(false);
        if (!Arr::iterable($all)) {
            return $num_deleted;
        }

        foreach ($all as $post) {
            if ($post->delete($bypass_trash)) {
                $num_deleted++;
            }
        }

        return $num_deleted;
    }
890164
public function delete_item( $request ) {

		$force = isset( $request['force'] ) ? (bool) $request['force'] : false;

		// We don't support trashing for this resource type.
		if ( ! $force ) {
			return new WP_Error( 'rest_trash_not_supported', __( 'Resource does not support trashing.' ), array( 'status' => 501 ) );
		}

		$term = get_term( (int) $request['id'], $this->taxonomy );
		$request->set_param( 'context', 'view' );
		$response = $this->prepare_item_for_response( $term, $request );

		$retval = wp_delete_term( $term->term_id, $term->taxonomy );
		if ( ! $retval ) {
			return new WP_Error( 'rest_cannot_delete', __( 'The resource cannot be deleted.' ), array( 'status' => 500 ) );
		}

		/**
		 * Fires after a single term is deleted via the REST API.
		 *
		 * @param WP_Term          $term     The deleted term.
		 * @param WP_REST_Response $response The response data.
		 * @param WP_REST_Request  $request  The request sent to the API.
		 */
		do_action( "rest_delete_{$this->taxonomy}", $term, $response, $request );

		return $response;
	}
443722
public function indexOfDeleted()
    {
        $this->authorize('readList', Block::class);
        $input   = $this->validator->validate('list');
        $params  = $this->processor->process($input)->getProcessedFields();
        $results = $this->repository->getDeletedBlocks(
            $params['filter'],
            $params['orderBy'],
            $params['page'],
            $params['perPage']
        );
        return $this->respondWithSuccess($results, new BlockTransformer);
    }
1316619
public function flush(
        int $bulkNumber = 500,
        bool $skipIfLess = false
    ) {
        if (
            $skipIfLess &&
            count($this->elementsToUpdate) < $bulkNumber
        ) {
            return;
        }

        $offset = 0;

        try {
            while (true) {
                $items = array_slice(
                    $this->elementsToUpdate,
                    $offset,
                    $bulkNumber
                );

                if (empty($items)) {
                    break;
                }

                $this->flushItems($items, []);
                $offset += $bulkNumber;
            }

            $this->flushItems([], $this->elementsToDelete);
        } catch (Exception $exception) {
            /*
             * No matter the exception is thrown, cached elements should be
             * deleted
             */
            $this->resetCachedElements();

            throw $exception;
        }

        $this->resetCachedElements();
    }
1258109
public function deleteMany($ids = null)
    {
        if (is_null($ids)) {
            $parameters = [
                'performAll' => true
            ];
        } else {
            $parameters = [
                'ids' => implode(',', (array) $ids),
            ];
        }

        $response = $this->ontraport->delete(
            $this->getNamespace(), $this->toArray($parameters)
        );

        // When deleting many objects, we get a string for the data field in the response,
        // saying "Deleted". When an object does not exist, it is ignored by oap. I believe
        // its safe to assume that we can always return successfuly here. Unless we receive
        // a non 200 status code in which case an InvalidRequest would be thrown.

        return true;
    }
1197930
public function delete()
    {
        // Delete row
        $result = static::connection()
            ->delete()
            ->from(static::table())
            ->where(static::$_primaryKey . " = ?", $this->{static::$_primaryKey})
            ->limit(1)
            ->exec();

        // Run filters
        if ($result) {
            $this->runFilters('after', 'delete');
        }

        return $result;
    }
1273590
protected function _deleteObject( $post_id ) {
		$post = get_post( $post_id );
		if ( ! $post ) {
			return false;
		}

		$deleted = wp_delete_post( $post_id, true );
		if ( $deleted ) {
			$this->_debug( 'Deleted post with ID: ' . $post_id );
			return true;
		}

		$this->_debug( 'Post removal failed for ID: ' . $post_id );
		return false;
	}
21553
public static function cleanupRemovedItems()
    {
        $db = eZDB::instance();
        // Find items that have been moved to trash or deleted
        $itemArray = array();
        $offset = 0;
        $limit = 50;
        do
        {
            $items = $db->arrayQuery( 'SELECT node_id FROM ezm_pool', array( 'offset' => $offset, 'limit' => $limit ) );
            if ( empty( $items ) )
                break;

            foreach( $items as $item )
            {
                $rows = $db->arrayQuery( 'SELECT node_id FROM ezcontentobject_tree WHERE node_id = ' . $item['node_id'] );
                if ( empty( $rows ) )
                    $itemArray[] = $item['node_id'];
            }

            $offset += $limit;
        } while ( true );

        // Remove them all from the flow
        $itemArrayCount = count( $itemArray );
        if ( $itemArrayCount > 0 )
        {
            $db->begin();
            $db->query( 'DELETE FROM ezm_pool WHERE ' . $db->generateSQLINStatement( $itemArray, 'node_id' ) );
            $db->commit();
        }

        return $itemArrayCount;
    }
1039863
public function count($with_deleted = null)
    {
        if (false === $this->has_table()) return false;

        if ($this->count === 0) {
            $with_deleted !== null or $with_deleted = (! $this->is_destructive);

            if (false === $with_deleted) {
                $db = $this->db->where($this->deletion_key, 0);
            }

            $this->count = $db->count_all_results($this->table);
        }

        return $this->count;
    }
1164182
protected function _delete( $args, $assoc_args, $callback ) {
		$status = 0;

		if ( Utils\get_flag_value( $assoc_args, 'defer-term-counting' ) ) {
			wp_defer_term_counting( true );
		}

		foreach ( $args as $obj_id ) {
			$result = $callback( $obj_id, $assoc_args );
			$status = $this->success_or_failure( $result );
		}

		if ( Utils\get_flag_value( $assoc_args, 'defer-term-counting' ) ) {
			wp_defer_term_counting( false );
		}

		exit( $status );
	}
1234115
def destroy_all_deleted
      @posts = LatoBlog::Post.deleted

      if !@posts || @posts.empty?
        flash[:warning] = LANGUAGES[:lato_blog][:flashes][:deleted_posts_not_found]
        redirect_to lato_blog.posts_path(status: 'deleted')
        return
      end

      @posts.each do |post|
        unless post.destroy
          flash[:danger] = post.errors.full_messages.to_sentence
          redirect_to lato_blog.edit_post_path(post.id)
          return
        end
      end

      flash[:success] = LANGUAGES[:lato_blog][:flashes][:deleted_posts_destroy_success]
      redirect_to lato_blog.posts_path(status: 'deleted')
    end
619852
protected function deleteExtraRecords()
    {
        try {
            $limit = (int)($this->limitMax);
        } catch (\Exception $ex) {
            Yii::error($ex->getMessage(), __METHOD__);
            return 0;
        }
        $host = $this->host;
         /* @var $host \rhosocial\user\User */
        $count = static::find()->createdBy($host)->count();
        Yii::info($host->getReadableGUID() . " has $count login logs.", __METHOD__);
        if ($count > $limit) {
            foreach (static::find()->createdBy($host)->orderByCreatedAt()->limit($count - $limit)->all() as $login) {
                /* @var $login static */
                $result = $login->delete();
                if (YII_ENV_DEV) {
                    Yii::info($host->getReadableGUID() . ": ($result) login record created at (" . $login->getCreatedAt() . ") was just deleted.", __METHOD__);
                }
            }
        }
        return $count - $limit;
    }
795882
public function delete($blogId, $postId, $optParams = array()) {
      $params = array('blogId' => $blogId, 'postId' => $postId);
      $params = array_merge($params, $optParams);
      $data = $this->__call('delete', array($params));
      return $data;
    }
239904
public function delete()
    {
        $query = $this->getDeleteQuery();

        $query->where($this->morphType, $this->morphClass);

        return $query->delete();
    }
340139
function delete() {

        // if this is an association result or it is limited,
        // create specific result for local rows and execute

        if ( $this->parent_ || isset( $this->limitCount ) ) {

            return $this->primaryResult()->delete();

        }

        return $this->db->delete( $this->table, $this->where, $this->whereParams );

    }
929219
public function delete(Post $post)
    {
        $this->authorize(PostsPolicy::PERMISSION_DELETE);

        try {
            $post->trashed() ? $post->forceDelete() : $post->delete();

            return $this->jsonResponseSuccess([
                'message' => $this->transNotification('deleted', ['title' => $post->title], $post->toArray())
            ]);
        }
        catch(\Exception $e) {
            return $this->jsonResponseError(['message' => $e->getMessage()], 500);
        }
    }
1354369
public function trashCollect()
    {
        $this->debug->groupCollapsed(__METHOD__);
        // $cfg = $this->cfg;
        $tsNow = \microtime(true);
        // $this->debug->log('this->data', $this->data);
        if (isset($_SESSION['form_persist']) && \is_array($_SESSION['form_persist'])) {
            foreach ($_SESSION['form_persist'] as $formName => $data) {
                if (!isset($data['ver'])) {
                    continue;
                }
                $tsDiff = $tsNow - $data['timestamp'];
                $this->debug->log($formName.' created '.\number_format($tsDiff, 4).' sec ago');
                // && ( empty($_SERVER['HTTP_USER_AGENT']) || \strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') )
                /*
                primarily a Safari issue
                <img src="" />, imgNode.setAttribute('src', ''), etc
                will get interepreted as <img src=" {request_uri} " />...
                these requests can be seen in the browser's development console and network requests as
                "Resource interpreted as Image but transferred with MIME type text/html."
                which will effectevely come in as a GET request after the page is loaded.
                this GET request will end up here triggering trash collection!!
                */
                $remove = false;
                if (isset($this->data['name']) && $formName == $this->data['name']) {
                    $this->debug->warn('not trashing current form');
                    continue;
                } elseif ($data['trashCollectable'] && $tsDiff > 10) {
                    $remove = true;
                }
                if ($remove) {
                    $this->debug->warn('removing', $formName);
                    $this->trashCollectFiles($data);
                    unset($_SESSION['form_persist'][$formName]);
                }
            }
        }
        if (empty($_SESSION['form_persist'])) {
            unset($_SESSION['form_persist']);
        }
        $this->debug->groupEnd();
    }