Delete an item for this element.

@param int   $id   Object ID.
@param array $args Optional data used to delete an object.

@throws \UnexpectedValueException
438452
public function delete($id, $args = [])
    {
        $result = wp_delete_post($id, isset($args['force']));

        if (! $result) {
            throw new UnexpectedValueException('[W605] Failed deleting content.');
        }
    }
594259
public function remove($id, $options = [])
    {
        $_options = [
            'area' => false,
        ];

        $options = array_merge($_options, $options);

        if ($options['area']) {
            $this->area = $item['area'];
        }

        unset(self::$data[$this->area][$id]);
    }
551567
public function handleDelete(Args $args)
    {
        $moduleName = $args->getArgument('name');

        if (!$this->moduleManager->hasModule($moduleName)) {
            throw new RuntimeException(sprintf(
                'The module "%s" is not installed.',
                $moduleName
            ));
        }

        $this->moduleManager->removeModule($moduleName);

        return 0;
    }
1358337
function remove($args)
    {
        $cache  = $this->get_cache();
        $status = $cache->remove($args['id']);

        $args['status'] = true;

        return $args;
    }
67956
public function get($id, $args = [])
    {
        $wpcli_args = buildCLIArgs(
            array(
                'field',
                'fields',
            ),
            $args
        );

        array_unshift($wpcli_args, $id, '--format=json');
        $comment = $this->drivers->getDriver()->wpcli('comment', 'get', $wpcli_args)['stdout'];
        $comment = json_decode($comment);

        if (! $comment) {
            throw new UnexpectedValueException(sprintf('[W500] Could not find comment with ID %d', $id));
        }

        return $comment;
    }
869316
public function get($id, $args = [])
    {
        $url = '';

        // Support fetching via arbitrary field.
        if (! is_numeric($id)) {
            $wpcli_args = ['--fields=ID,url', "--{$args['by']}=" . escapeshellarg($id), '--post_type=any', '--format=json', '--ignore_sticky_posts=true'];
            $result     = json_decode($this->drivers->getDriver()->wpcli('post', 'list', $wpcli_args)['stdout']);

            if (empty($result)) {
                throw new UnexpectedValueException(sprintf('[W501] Could not find post with ID %d', $id));
            }

            $id  = (int) $result[0]->ID;
            $url = $result[0]->url;
        }

        // Fetch by ID.
        $wpcli_args = buildCLIArgs(
            array(
                'field',
                'fields',
            ),
            $args
        );

        array_unshift($wpcli_args, $id, '--format=json');
        $post = $this->drivers->getDriver()->wpcli('post', 'get', $wpcli_args)['stdout'];
        $post = json_decode($post);

        if (! $post) {
            throw new UnexpectedValueException(sprintf('[W501] Could not find post with ID %d', $id));
        }

        if (! $url) {
            $wpcli_args = ['--post__in=' . $post->ID, '--fields=url', '--post_type=any', '--format=json'];
            $result     = json_decode($this->drivers->getDriver()->wpcli('post', 'list', $wpcli_args)['stdout']);
            $url        = $result[0]->url;
        }

        $post->url = $url;

        return $post;
    }
280121
public function delete(string $id, array $params = [])
    {
        return $this->executeRequest(
            RequestMethodEnum::DELETE,
            ResourceMethodEnum::DELETE,
            $params,
            $id
        );
    }
287445
public function activate($id, $args = [])
    {
        $plugin = $this->drivers->getDriver()->getPlugin($id);

        if (! $plugin) {
            throw new UnexpectedValueException("[W608] Cannot find the plugin: {$id}.");
        }

        $this->update($plugin, ['status' => 'activate']);
    }
104041
public function get($id, $args = [])
    {
        $post = false;

        if (is_numeric($id) || (is_object($id) && $id instanceof \WP_Post)) {
            $post = get_post($id);
        } else {
            $query = new WP_Query();
            $query = $query->query(array(
                "{$args['by']}"          => $id,
                'ignore_sticky_posts'    => true,
                'no_found_rows'          => true,
                'posts_per_page'         => 1,
                'suppress_filters'       => false,
                'update_post_meta_cache' => false,
                'update_post_term_cache' => false,
            ));

            if ($query) {
                $post = $query[0];
            }
        }

        if (! $post) {
            throw new UnexpectedValueException(sprintf('[W604] Could not find content with ID %d', $id));
        }

        $post->url = get_permalink($post);

        return $post;
    }
650764
public static function get($args = [], $id = '') {
        if (!isset(static::$_instance[static::class])) {
            static::$_instance[static::class] = [];
        }
        if (!isset(static::$_instance[static::class][$id])) {
            static::$_instance[static::class][$id] = new static($args);
        }
        return static::$_instance[static::class][$id];
    }
145128
public function remove($id) {
		// Format id
		$id = $this->_format($id);
		// Verify existence
		if(!$this->has($id)) {
			throw new NotFoundException("'$id' value does not exist");
		}
		// Remove value
		unset($this->values[$id]);
	}
105229
public function delete($id)
    {
        // TODO: move order to an archive instead of removing it from database
        $order = $this->orderRepository->findById($id);

        if (!$order) {
            throw new OrderNotFoundException($id);
        }

        $this->em->remove($order);
        $this->em->flush();
    }
144248
function(id, callback) {
    var self = this;
    
    if (typeof id == 'number' || typeof id == 'string' || id instanceof Array || id instanceof ObjectID) {

      this.driver.deleteById({
        collection: this.context,
        _id: id
      }, function(err) {
        callback.call(self, err);
      });
      
    } else if (id && typeof id == 'object') {
      
      var o = id;
      
      this.driver.deleteWhere({
        collection: this.context,
        condition: o
      }, function(err) {
        callback.call(self, err);
      });
      
    } else {
      callback.call(self, new Error(util.format("%s: Wrong value for `id` parameter", this.className)));
    }
  }
176977
public function delete( $args, $assoc_args ) {
		list( $object_id ) = $args;

		$meta_key   = ! empty( $args[1] ) ? $args[1] : '';
		$meta_value = ! empty( $args[2] ) ? $args[2] : '';

		if ( empty( $meta_key ) && ! Utils\get_flag_value( $assoc_args, 'all' ) ) {
			WP_CLI::error( 'Please specify a meta key, or use the --all flag.' );
		}

		$object_id = $this->check_object_id( $object_id );

		if ( Utils\get_flag_value( $assoc_args, 'all' ) ) {
			$errors = false;
			foreach ( $this->get_metadata( $object_id ) as $meta_key => $values ) {
				$success = $this->delete_metadata( $object_id, $meta_key );
				if ( $success ) {
					WP_CLI::log( "Deleted '{$meta_key}' custom field." );
				} else {
					WP_CLI::warning( "Failed to delete '{$meta_key}' custom field." );
					$errors = true;
				}
			}
			if ( $errors ) {
				WP_CLI::error( 'Failed to delete all custom fields.' );
			} else {
				WP_CLI::success( 'Deleted all custom fields.' );
			}
		} else {
			$success = $this->delete_metadata( $object_id, $meta_key, $meta_value );
			if ( $success ) {
				WP_CLI::success( 'Deleted custom field.' );
			} else {
				WP_CLI::error( 'Failed to delete custom field.' );
			}
		}
	}
1011846
public function delete($id) {

		$bean = \R::findOne( $this->type, ' id = :id ', [ ':id' => $id ] );
		if ( !$bean ) {
			throw new \Exception('This '.$this->type.' does not exist.');
		}

		// Check for property type specific delete methods
		foreach ( $this->properties as $property ) {

			// Check if specific delete property method exists
			$c = new $property['type'];
			if ( method_exists( $c, 'delete' ) ) {
				$c->delete( $bean, $property );
			}

		}

		\R::trash( $bean );

	}
1254931
public function get($id, $args = [])
    {
        $wpcli_args = buildCLIArgs(
            array(
                'field',
                'fields',
            ),
            $args
        );

        array_unshift($wpcli_args, $args['taxonomy'], $id, '--format=json');
        $term = $this->drivers->getDriver()->wpcli('term', 'get', $wpcli_args)['stdout'];
        $term = json_decode($term);

        if (! $term) {
            throw new UnexpectedValueException(sprintf('[W503] Could not find term with ID %d', $id));
        }

        return $term;
    }
137929
public function deleteById($id)
	{
		$sql = "DELETE FROM `$this->tableName` WHERE `$this->pkColName` = :entityId ";

		$stmt = $this->pdo->prepare($sql);
		$stmt->bindParam(':entityId', intval($id), \PDO::PARAM_INT);
		$res = $stmt->execute();

		return ($res !== false && $stmt->rowCount() === 1);
	}