delete_site_option

The timeline below displays how wordpress function delete_site_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 the current network.
 *
 * @since 2.8.0
 * @since 4.4.0 Modified into wrapper for delete_network_option()
 *
 * @see delete_network_option()
 *
 * @param string $option Name of the option to delete. Expected to not be SQL-escaped.
 * @return bool True if the option was deleted, false otherwise.
 */
function delete_site_option($option)
{
    return delete_network_option(null, $option);
}

WordPress Version: 5.5

/**
 * Removes a option by name for the current network.
 *
 * @since 2.8.0
 * @since 4.4.0 Modified into wrapper for delete_network_option()
 *
 * @see delete_network_option()
 *
 * @param string $option Name of the option to delete. Expected to not be SQL-escaped.
 * @return bool True if the option was deleted, false otherwise.
 */
function delete_site_option($option)
{
    return delete_network_option(null, $option);
}

WordPress Version: 4.4

/**
 * Removes a option by name for the current network.
 *
 * @since 2.8.0
 * @since 4.4.0 Modified into wrapper for delete_network_option()
 *
 * @see delete_network_option()
 *
 * @param string $option Name of option to remove. Expected to not be SQL-escaped.
 * @return bool True, if succeed. False, if failure.
 */
function delete_site_option($option)
{
    return delete_network_option(null, $option);
}

WordPress Version: 4.3

/**
 * Removes site option by name.
 *
 * @since 2.8.0
 *
 * @see delete_option()
 *
 * @global wpdb $wpdb
 *
 * @param string $option Name of option to remove. Expected to not be SQL-escaped.
 * @return bool True, if succeed. False, if failure.
 */
function delete_site_option($option)
{
    global $wpdb;
    // ms_protect_special_option( $option ); @todo
    /**
     * Fires immediately before a specific site option is deleted.
     *
     * The dynamic portion of the hook name, `$option`, refers to the option name.
     *
     * @since 3.0.0
     */
    do_action('pre_delete_site_option_' . $option);
    if (!is_multisite()) {
        $result = delete_option($option);
    } else {
        $row = $wpdb->get_row($wpdb->prepare("SELECT meta_id FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid));
        if (is_null($row) || !$row->meta_id) {
            return false;
        }
        $cache_key = "{$wpdb->siteid}:{$option}";
        wp_cache_delete($cache_key, 'site-options');
        $result = $wpdb->delete($wpdb->sitemeta, array('meta_key' => $option, 'site_id' => $wpdb->siteid));
    }
    if ($result) {
        /**
         * Fires after a specific site option has been deleted.
         *
         * The dynamic portion of the hook name, `$option`, refers to the option name.
         *
         * @since 2.9.0 As "delete_site_option_{$key}"
         * @since 3.0.0
         *
         * @param string $option Name of the site option.
         */
        do_action("delete_site_option_{$option}", $option);
        /**
         * Fires after a site option has been deleted.
         *
         * @since 3.0.0
         *
         * @param string $option Name of the site option.
         */
        do_action("delete_site_option", $option);
        return true;
    }
    return false;
}

WordPress Version: 4.1

/**
 * Removes site option by name.
 *
 * @since 2.8.0
 *
 * @see delete_option()
 *
 * @param string $option Name of option to remove. Expected to not be SQL-escaped.
 * @return bool True, if succeed. False, if failure.
 */
function delete_site_option($option)
{
    global $wpdb;
    // ms_protect_special_option( $option ); @todo
    /**
     * Fires immediately before a specific site option is deleted.
     *
     * The dynamic portion of the hook name, `$option`, refers to the option name.
     *
     * @since 3.0.0
     */
    do_action('pre_delete_site_option_' . $option);
    if (!is_multisite()) {
        $result = delete_option($option);
    } else {
        $row = $wpdb->get_row($wpdb->prepare("SELECT meta_id FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid));
        if (is_null($row) || !$row->meta_id) {
            return false;
        }
        $cache_key = "{$wpdb->siteid}:{$option}";
        wp_cache_delete($cache_key, 'site-options');
        $result = $wpdb->delete($wpdb->sitemeta, array('meta_key' => $option, 'site_id' => $wpdb->siteid));
    }
    if ($result) {
        /**
         * Fires after a specific site option has been deleted.
         *
         * The dynamic portion of the hook name, `$option`, refers to the option name.
         *
         * @since 2.9.0 As "delete_site_option_{$key}"
         * @since 3.0.0
         *
         * @param string $option Name of the site option.
         */
        do_action("delete_site_option_{$option}", $option);
        /**
         * Fires after a site option has been deleted.
         *
         * @since 3.0.0
         *
         * @param string $option Name of the site option.
         */
        do_action("delete_site_option", $option);
        return true;
    }
    return false;
}

WordPress Version: 3.9

/**
 * Removes site option by name.
 *
 * @since 2.8.0
 *
 * @see delete_option()
 *
 * @param string $option Name of option to remove. Expected to not be SQL-escaped.
 * @return bool True, if succeed. False, if failure.
 */
function delete_site_option($option)
{
    global $wpdb;
    // ms_protect_special_option( $option ); @todo
    /**
     * Fires immediately before a specific site option is deleted.
     *
     * The dynamic portion of the hook name, $option, refers to the option name.
     *
     * @since 3.0.0
     */
    do_action('pre_delete_site_option_' . $option);
    if (!is_multisite()) {
        $result = delete_option($option);
    } else {
        $row = $wpdb->get_row($wpdb->prepare("SELECT meta_id FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid));
        if (is_null($row) || !$row->meta_id) {
            return false;
        }
        $cache_key = "{$wpdb->siteid}:{$option}";
        wp_cache_delete($cache_key, 'site-options');
        $result = $wpdb->delete($wpdb->sitemeta, array('meta_key' => $option, 'site_id' => $wpdb->siteid));
    }
    if ($result) {
        /**
         * Fires after a specific site option has been deleted.
         *
         * The dynamic portion of the hook name, $option, refers to the option name.
         *
         * @since 2.9.0 As "delete_site_option_{$key}"
         * @since 3.0.0
         *
         * @param string $option Name of the site option.
         */
        do_action("delete_site_option_{$option}", $option);
        /**
         * Fires after a site option has been deleted.
         *
         * @since 3.0.0
         *
         * @param string $option Name of the site option.
         */
        do_action("delete_site_option", $option);
        return true;
    }
    return false;
}

WordPress Version: 3.7

/**
 * Removes site option by name.
 *
 * @see delete_option()
 * @package WordPress
 * @subpackage Option
 * @since 2.8.0
 *
 * @uses do_action() Calls 'pre_delete_site_option_$option' hook before option is deleted.
 * @uses do_action() Calls 'delete_site_option' and 'delete_site_option_$option'
 * 	hooks on success.
 *
 * @param string $option Name of option to remove. Expected to not be SQL-escaped.
 * @return bool True, if succeed. False, if failure.
 */
function delete_site_option($option)
{
    global $wpdb;
    // ms_protect_special_option( $option ); @todo
    do_action('pre_delete_site_option_' . $option);
    if (!is_multisite()) {
        $result = delete_option($option);
    } else {
        $row = $wpdb->get_row($wpdb->prepare("SELECT meta_id FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid));
        if (is_null($row) || !$row->meta_id) {
            return false;
        }
        $cache_key = "{$wpdb->siteid}:{$option}";
        wp_cache_delete($cache_key, 'site-options');
        $result = $wpdb->delete($wpdb->sitemeta, array('meta_key' => $option, 'site_id' => $wpdb->siteid));
    }
    if ($result) {
        do_action("delete_site_option_{$option}", $option);
        do_action("delete_site_option", $option);
        return true;
    }
    return false;
}