/**
 * Install
 *
 * Runs on plugin install by setting up the post types, custom taxonomies,
 * flushing rewrite rules also creates the plugin and populates the settings
 * fields for those plugin pages. After successful install, the user is
 * redirected to the POPMAKE Welcome screen.
 *
 * @since 1.0
 * @global $wpdb
 * @global $popmake_options
 * @global $wp_version
 * @return void
 */
function popmake_install()
{
    global $wpdb, $popmake_options, $wp_version;
    // Setup the Popup & Theme Custom Post Type
    popmake_setup_post_types();
    // Setup the Popup Taxonomies
    popmake_setup_taxonomies();
    // Clear the permalinks
    flush_rewrite_rules();
    // Add Upgraded From Option
    $current_version = get_option('popmake_version');
    if ($current_version) {
        update_option('popmake_version_upgraded_from', $current_version);
    }
    // Setup some default options
    $options = array();
    // Checks if the purchase page option exists
    if (!get_option('popmake_default_theme')) {
        // Default Theme
        popmake_install_default_theme();
    }
    if (!isset($popmake_options['popmake_powered_by_size'])) {
        $popmake_options['popmake_powered_by_size'] = '';
    }
    update_option('popmake_settings', array_merge($popmake_options, $options));
    update_option('popmake_version', POPMAKE_VERSION);
    // Add a temporary option to note that POPMAKE theme is ready for customization
    set_transient('_popmake_installed', $options, 30);
    // Bail if activating from network, or bulk
    if (is_network_admin() || isset($_GET['activate-multi'])) {
        return;
    }
    // Add the transient to redirect to welcome page.
    set_transient('_popmake_activation_redirect', true, 30);
}
function popmake_get_default_popup_theme()
{
    $default_theme = get_option('popmake_default_theme');
    if (false === get_post_status($default_theme)) {
        popmake_install_default_theme();
        $default_theme = get_option('popmake_default_theme');
    }
    return $default_theme;
}