Function Reference: gd_set_theme_compat

Summary

Sets theme compatibility options.

Global Values

$wpdb
(object) (required) WordPress Database object.

Default: None

Package

GeoDirectory

Change Log

Since: 1.0.0

Source File

gd_set_theme_compat() is located in geodirectory-admin/admin_functions.php [Line: 1956]

Source Code

function gd_set_theme_compat()
{
    global $wpdb;
    $theme = wp_get_theme();

    if ($theme->parent()) {
        $theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
    } else {
        $theme_name = str_replace(" ", "_", $theme->get('Name'));
    }

    $theme_compats = get_option('gd_theme_compats');
    $current_compat = get_option('gd_theme_compat');
    $current_compat = str_replace("_custom", "", $current_compat);
 
    if ($current_compat == $theme_name && strpos(get_option('gd_theme_compat'), "_custom") !== false) {
        return;
    }// if already running correct compat then bail

    if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
        update_option('gd_theme_compat', $theme_name);
        update_option('theme_compatibility_setting', $theme_compats[$theme_name]);

        // if there are default options to set then set them
        if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {

            foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
                update_option($key, $val);
            }
        }

    } else {
        update_option('gd_theme_compat', '');
        update_option('theme_compatibility_setting', '');
    }


}