get_theme_mods

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

WordPress Version: 5.9

/**
 * Retrieves all theme modifications.
 *
 * @since 3.1.0
 * @since 5.9.0 The return value is always an array.
 *
 * @return array Theme modifications.
 */
function get_theme_mods()
{
    $theme_slug = get_option('stylesheet');
    $mods = get_option("theme_mods_{$theme_slug}");
    if (false === $mods) {
        $theme_name = get_option('current_theme');
        if (false === $theme_name) {
            $theme_name = wp_get_theme()->get('Name');
        }
        $mods = get_option("mods_{$theme_name}");
        // Deprecated location.
        if (is_admin() && false !== $mods) {
            update_option("theme_mods_{$theme_slug}", $mods);
            delete_option("mods_{$theme_name}");
        }
    }
    if (!is_array($mods)) {
        $mods = array();
    }
    return $mods;
}

WordPress Version: 5.5

/**
 * Retrieves all theme modifications.
 *
 * @since 3.1.0
 *
 * @return array|void Theme modifications.
 */
function get_theme_mods()
{
    $theme_slug = get_option('stylesheet');
    $mods = get_option("theme_mods_{$theme_slug}");
    if (false === $mods) {
        $theme_name = get_option('current_theme');
        if (false === $theme_name) {
            $theme_name = wp_get_theme()->get('Name');
        }
        $mods = get_option("mods_{$theme_name}");
        // Deprecated location.
        if (is_admin() && false !== $mods) {
            update_option("theme_mods_{$theme_slug}", $mods);
            delete_option("mods_{$theme_name}");
        }
    }
    return $mods;
}

WordPress Version: 4.3

/**
 * Retrieve all theme modifications.
 *
 * @since 3.1.0
 *
 * @return array|void Theme modifications.
 */
function get_theme_mods()
{
    $theme_slug = get_option('stylesheet');
    $mods = get_option("theme_mods_{$theme_slug}");
    if (false === $mods) {
        $theme_name = get_option('current_theme');
        if (false === $theme_name) {
            $theme_name = wp_get_theme()->get('Name');
        }
        $mods = get_option("mods_{$theme_name}");
        // Deprecated location.
        if (is_admin() && false !== $mods) {
            update_option("theme_mods_{$theme_slug}", $mods);
            delete_option("mods_{$theme_name}");
        }
    }
    return $mods;
}

WordPress Version: 4.1

/**
 * Retrieve all theme modifications.
 *
 * @since 3.1.0
 *
 * @return array|null Theme modifications.
 */
function get_theme_mods()
{
    $theme_slug = get_option('stylesheet');
    if (false === $mods = get_option("theme_mods_{$theme_slug}")) {
        $theme_name = get_option('current_theme');
        if (false === $theme_name) {
            $theme_name = wp_get_theme()->get('Name');
        }
        $mods = get_option("mods_{$theme_name}");
        // Deprecated location.
        if (is_admin() && false !== $mods) {
            update_option("theme_mods_{$theme_slug}", $mods);
            delete_option("mods_{$theme_name}");
        }
    }
    return $mods;
}

WordPress Version: 3.7

/**
 * Retrieve all theme modifications.
 *
 * @since 3.1.0
 *
 * @return array Theme modifications.
 */
function get_theme_mods()
{
    $theme_slug = get_option('stylesheet');
    if (false === $mods = get_option("theme_mods_{$theme_slug}")) {
        $theme_name = get_option('current_theme');
        if (false === $theme_name) {
            $theme_name = wp_get_theme()->get('Name');
        }
        $mods = get_option("mods_{$theme_name}");
        // Deprecated location.
        if (is_admin() && false !== $mods) {
            update_option("theme_mods_{$theme_slug}", $mods);
            delete_option("mods_{$theme_name}");
        }
    }
    return $mods;
}