function deleteTag( $tag, $blog_id, $tag_group, $for_real = false ) {

		/** @var $wpdb \wpdb */
		global $wpdb;

		// Get ID

		$sql = "SELECT id FROM {$this->dbTagsTable} WHERE tag = %s ";
		$tag_id = $wpdb->get_var( $wpdb->prepare( $sql, $tag ) ); // @codingStandardsIgnoreLine

		if ( ! $tag_id ) {
			return false;
		}

		if ( $for_real && is_super_admin() ) {
			$wpdb->delete(
				$this->dbLinkTable, [
					'tags_id' => $tag_id,
				], [ '%d' ]
			);
			$wpdb->delete(
				$this->dbTagsTable, [
					'id' => $tag_id,
				], [ '%d' ]
			);
			$result = 1;
		} else {
			$result = $wpdb->delete(
				$this->dbLinkTable,
				[
					'users_id' => $this->userId,
					'blogs_id' => $blog_id,
					'tags_id' => $tag_id,
					'tags_group' => $tag_group,
				],
				[ '%d', '%d', '%d', '%d' ]
			);
		}

		// TODO:
		// Optimize the links table: $wpdb->query( "OPTIMIZE TABLE {$this->dbLinkTable} " );
		// Optimize the tags table: $wpdb->query( "OPTIMIZE TABLE {$this->dbTagsTable} " );

		return $result;
	}
function deleteTag( $tag, $blog_id, $tag_group, $for_real = false ) {

		/** @var $wpdb \wpdb */
		global $wpdb;

		// Get ID

		$sql = "SELECT id FROM {$this->dbTagsTable} WHERE tag = %s ";
		$tag_id = $wpdb->get_var( $wpdb->prepare( $sql, $tag ) ); // @codingStandardsIgnoreLine

		if ( ! $tag_id ) {
			return false;
		}

		if ( $for_real && is_super_admin() ) {
			$wpdb->delete(
				$this->dbLinkTable, [
					'tags_id' => $tag_id,
				], [ '%d' ]
			);
			$wpdb->delete(
				$this->dbTagsTable, [
					'id' => $tag_id,
				], [ '%d' ]
			);
			$result = 1;
		} else {
			$result = $wpdb->delete(
				$this->dbLinkTable,
				[
					'users_id' => $this->userId,
					'blogs_id' => $blog_id,
					'tags_id' => $tag_id,
					'tags_group' => $tag_group,
				],
				[ '%d', '%d', '%d', '%d' ]
			);
		}

		// TODO:
		// Optimize the links table: $wpdb->query( "OPTIMIZE TABLE {$this->dbLinkTable} " );
		// Optimize the tags table: $wpdb->query( "OPTIMIZE TABLE {$this->dbTagsTable} " );

		return $result;
	}
function deleteTag ( $ tag , $ blog_id , $ tag_group , $ for_real = false ) { /** @var $wpdb \wpdb */ global $ wpdb ; // Get ID $ sql = "SELECT id FROM {$this->dbTagsTable} WHERE tag = %s " ; $ tag_id = $ wpdb -> get_var ( $ wpdb -> prepare ( $ sql , $ tag ) ) ; // @codingStandardsIgnoreLine if ( ! $ tag_id ) { return false ; } if ( $ for_real && is_super_admin ( ) ) { $ wpdb -> delete ( $ this -> dbLinkTable , [ 'tags_id' => $ tag_id , ] , [ '%d' ] ) ; $ wpdb -> delete ( $ this -> dbTagsTable , [ 'id' => $ tag_id , ] , [ '%d' ] ) ; $ result = 1 ; } else { $ result = $ wpdb -> delete ( $ this -> dbLinkTable , [ 'users_id' => $ this -> userId , 'blogs_id' => $ blog_id , 'tags_id' => $ tag_id , 'tags_group' => $ tag_group , ] , [ '%d' , '%d' , '%d' , '%d' ] ) ; } // TODO: // Optimize the links table: $wpdb->query( "OPTIMIZE TABLE {$this->dbLinkTable} " ); // Optimize the tags table: $wpdb->query( "OPTIMIZE TABLE {$this->dbTagsTable} " ); return $ result ; }
Delete a tag.

IMPORTANT: The 'for_real' option is extremely destructive. Do not use unless you know what you are doing.

@param string $tag
@param int $blog_id
@param int $tag_group
@param bool $for_real (optional)

@return int|false
Delete a tag .