function check_theme_ID($folder = false)
{
    global $shortname;
    if (!function_exists('WP_Filesystem')) {
        require_once ABSPATH . 'wp-admin/includes/file.php';
    }
    WP_Filesystem();
    global $wp_filesystem;
    $settings = get_settings_json($folder);
    if (isset($settings['Name'])) {
        $themeInfo = rw_get_theme_data();
        $theme_name_stylecss = $themeInfo['Name'];
        if (isset($settings['ThemeID'])) {
            $theme_prefix_old = isset($settings['ThemeID']) ? $settings['ThemeID'] : $shortname;
            if (change_theme_prefix($theme_prefix_old, $settings['ThemeID'])) {
                $wp_filesystem->put_contents(get_stylesheet_directory() . '/data/settings.json', json_encode($settings), FS_CHMOD_FILE);
            }
        }
        if (empty($theme_name_stylecss)) {
            $theme_name_stylecss = __('Unknown Theme (Theme Name in style.css is empty)', 'framework');
        }
        if (isset($settings['Name']) && $theme_name_stylecss != $settings['Name']) {
            $link = IS_CHILD ? admin_url('admin.php?page=themes') : admin_url('themes.php');
            if (isset($_GET['create-theme-id'])) {
                if ($_GET['create-theme-id']) {
                    $theme_prefix_old = isset($settings['ThemeID']) ? $settings['ThemeID'] : $shortname;
                    $theme_id = create_theme_ID();
                    $settings['ThemeID'] = $theme_id;
                    if (change_theme_prefix($theme_prefix_old, $settings['ThemeID'])) {
                        $settings['Name'] = $theme_name_stylecss;
                        $wp_filesystem->put_contents(get_stylesheet_directory() . '/data/settings.json', json_encode($settings), FS_CHMOD_FILE);
                    }
                } else {
                    $settings['Name'] = $theme_name_stylecss;
                    $wp_filesystem->put_contents(get_stylesheet_directory() . '/data/settings.json', json_encode($settings), FS_CHMOD_FILE);
                }
                $redirect = '<script type="text/javascript">window.location = "' . esc_url($link) . '";</script>';
                echo $redirect;
                // escaped above
            }
            add_action('admin_notices', 'ask_new_theme', 10, 3);
            do_action('admin_notices', $settings['Name'], $theme_name_stylecss, $link);
            remove_action('admin_notices', 'ask_new_theme');
        } else {
            return true;
        }
    }
}
function check_theme_ID($folder = false)
{
    global $shortname;
    if (!function_exists('WP_Filesystem')) {
        require_once ABSPATH . 'wp-admin/includes/file.php';
    }
    WP_Filesystem();
    global $wp_filesystem;
    $settings = get_settings_json($folder);
    if (isset($settings['Name'])) {
        $themeInfo = rw_get_theme_data();
        $theme_name_stylecss = $themeInfo['Name'];
        // $is_prefix_ID = ( isset($settings['ThemeID']) && isset($settings['isPrefixID']) )? $settings['isPrefixID'] : false;
        if (isset($settings['ThemeID'])) {
            //if( !isset($settings['isPrefixID']) || (isset($settings['isPrefixID']) && !$settings['isPrefixID']) ) {
            $theme_prefix_old = isset($settings['ThemeID']) ? $settings['ThemeID'] : $shortname;
            if (change_theme_prefix($theme_prefix_old, $settings['ThemeID'])) {
                //$settings['isPrefixID'] = true;
                $wp_filesystem->put_contents(get_stylesheet_directory() . '/data/settings.json', json_encode($settings), FS_CHMOD_FILE);
                //file_put_contents( get_stylesheet_directory() . '/data/settings.json', json_encode($settings) );
            }
            //}
        }
        if (isset($settings['Name']) && $theme_name_stylecss != $settings['Name']) {
            $link = admin_url('admin.php?page=themes');
            //$link = home_url().$_SERVER['REQUEST_URI'];
            if (isset($_GET['create-theme-id'])) {
                if ($_GET['create-theme-id']) {
                    //$theme_prefix_old = $settings['ThemeID'];
                    $theme_prefix_old = isset($settings['ThemeID']) ? $settings['ThemeID'] : $shortname;
                    $theme_id = create_theme_ID();
                    $settings['ThemeID'] = $theme_id;
                    if (change_theme_prefix($theme_prefix_old, $settings['ThemeID'])) {
                        $settings['Name'] = $theme_name_stylecss;
                        $wp_filesystem->put_contents(get_stylesheet_directory() . '/data/settings.json', json_encode($settings), FS_CHMOD_FILE);
                        //file_put_contents( get_stylesheet_directory() . '/data/settings.json', json_encode($settings) );
                    }
                } else {
                    $settings['Name'] = $theme_name_stylecss;
                    $wp_filesystem->put_contents(get_stylesheet_directory() . '/data/settings.json', json_encode($settings), FS_CHMOD_FILE);
                    //file_put_contents( get_stylesheet_directory() . '/data/settings.json', json_encode($settings) );
                }
                $redirect = '<script type="text/javascript">window.location = "' . $link . '";</script>';
                echo $redirect;
            }
            add_action('admin_notices', 'ask_new_theme', 10, 3);
            do_action('admin_notices', $settings['Name'], $theme_name_stylecss, $link);
            remove_action('admin_notices', 'ask_new_theme');
        } else {
            return true;
        }
    }
}