delete_blog_option

The timeline below displays how wordpress function delete_blog_option has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * Removes an option by name for a given blog ID. Prevents removal of protected WordPress options.
 *
 * @since MU (3.0.0)
 *
 * @param int    $id     A blog ID. Can be null to refer to the current blog.
 * @param string $option Name of option to remove. Expected to not be SQL-escaped.
 * @return bool True if the option was deleted, false otherwise.
 */
function delete_blog_option($id, $option)
{
    $id = (int) $id;
    if (empty($id)) {
        $id = get_current_blog_id();
    }
    if (get_current_blog_id() == $id) {
        return delete_option($option);
    }
    switch_to_blog($id);
    $return = delete_option($option);
    restore_current_blog();
    return $return;
}

WordPress Version: 5.5

/**
 * Removes option by name for a given blog ID. Prevents removal of protected WordPress options.
 *
 * @since MU (3.0.0)
 *
 * @param int    $id     A blog ID. Can be null to refer to the current blog.
 * @param string $option Name of option to remove. Expected to not be SQL-escaped.
 * @return bool True if the option was deleted, false otherwise.
 */
function delete_blog_option($id, $option)
{
    $id = (int) $id;
    if (empty($id)) {
        $id = get_current_blog_id();
    }
    if (get_current_blog_id() == $id) {
        return delete_option($option);
    }
    switch_to_blog($id);
    $return = delete_option($option);
    restore_current_blog();
    return $return;
}

WordPress Version: 4.9

/**
 * Removes option by name for a given blog id. Prevents removal of protected WordPress options.
 *
 * @since MU (3.0.0)
 *
 * @param int    $id     A blog ID. Can be null to refer to the current blog.
 * @param string $option Name of option to remove. Expected to not be SQL-escaped.
 * @return bool True, if option is successfully deleted. False on failure.
 */
function delete_blog_option($id, $option)
{
    $id = (int) $id;
    if (empty($id)) {
        $id = get_current_blog_id();
    }
    if (get_current_blog_id() == $id) {
        return delete_option($option);
    }
    switch_to_blog($id);
    $return = delete_option($option);
    restore_current_blog();
    return $return;
}

WordPress Version: 4.3

/**
 * Removes option by name for a given blog id. Prevents removal of protected WordPress options.
 *
 * @since MU
 *
 * @param int    $id     A blog ID. Can be null to refer to the current blog.
 * @param string $option Name of option to remove. Expected to not be SQL-escaped.
 * @return bool True, if option is successfully deleted. False on failure.
 */
function delete_blog_option($id, $option)
{
    $id = (int) $id;
    if (empty($id)) {
        $id = get_current_blog_id();
    }
    if (get_current_blog_id() == $id) {
        return delete_option($option);
    }
    switch_to_blog($id);
    $return = delete_option($option);
    restore_current_blog();
    return $return;
}

WordPress Version: 3.7

/**
 * Removes option by name for a given blog id. Prevents removal of protected WordPress options.
 *
 * @since MU
 *
 * @param int $id A blog ID. Can be null to refer to the current blog.
 * @param string $option Name of option to remove. Expected to not be SQL-escaped.
 * @return bool True, if option is successfully deleted. False on failure.
 */
function delete_blog_option($id, $option)
{
    $id = (int) $id;
    if (empty($id)) {
        $id = get_current_blog_id();
    }
    if (get_current_blog_id() == $id) {
        return delete_option($option);
    }
    switch_to_blog($id);
    $return = delete_option($option);
    restore_current_blog();
    return $return;
}