Exemple #1
0
/**
 * @package Kopa
 * @subpackage Core
 * @author thethangtran <*****@*****.**>
 * @since 1.0.0         
 */
function kopa_init_database()
{
    $kopa_is_database_setup = get_option(KOPA_OPT_PREFIX . 'database_setup');
    if ($kopa_is_database_setup !== KOPA_INIT_VERSION) {
        $kopa_setting = array('home' => array('layout_slug' => 'blog-page-1', 'sidebars' => array('blog-page-1' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'blog-page-2' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'))), 'front-page' => array('layout_slug' => 'front-page-1', 'sidebars' => array('front-page-1' => array('sidebar_1', 'sidebar_3', 'sidebar_4', 'sidebar_7', 'sidebar_8', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'front-page-2' => array('sidebar_1', 'sidebar_2', 'sidebar_7', 'sidebar_8', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'front-page-3' => array('sidebar_1', 'sidebar_2', 'sidebar_3', 'sidebar_4', 'sidebar_5', 'sidebar_6', 'sidebar_7', 'sidebar_8', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'static-page-1' => array('sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'contact-page' => array('sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'static-page-timeline' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'))), 'post' => array('layout_slug' => 'single-post-1', 'sidebars' => array('single-post-1' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'))), 'page' => array('layout_slug' => 'static-page-1', 'sidebars' => array('static-page-1' => array('sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'contact-page' => array('sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'static-page-timeline' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'front-page-1' => array('sidebar_1', 'sidebar_3', 'sidebar_4', 'sidebar_7', 'sidebar_8', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'front-page-2' => array('sidebar_1', 'sidebar_2', 'sidebar_7', 'sidebar_8', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'front-page-3' => array('sidebar_1', 'sidebar_2', 'sidebar_3', 'sidebar_4', 'sidebar_5', 'sidebar_6', 'sidebar_7', 'sidebar_8', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'))), 'taxonomy' => array('layout_slug' => 'blog-page-1', 'sidebars' => array('blog-page-1' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'blog-page-2' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'))), 'author' => array('layout_slug' => 'blog-page-1', 'sidebars' => array('blog-page-1' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'blog-page-2' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'))), 'search' => array('layout_slug' => 'blog-page-1', 'sidebars' => array('blog-page-1' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'blog-page-2' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'))), 'archive' => array('layout_slug' => 'blog-page-1', 'sidebars' => array('blog-page-1' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'), 'blog-page-2' => array('sidebar_7', 'sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'))), '_404' => array('layout_slug' => 'error-404', 'sidebars' => array('error-404' => array('sidebar_9', 'sidebar_10', 'sidebar_11', 'sidebar_12'))));
        $kopa_sidebar = KopaInit::get_sidebars();
        update_option(KOPA_OPT_PREFIX . 'layout_settings', $kopa_setting);
        update_option(KOPA_OPT_PREFIX . 'database_setup', KOPA_INIT_VERSION);
        //if (KOPA_DOMAIN . '-layout-setting-v1' == KOPA_INIT_VERSION) {
        update_option(KOPA_OPT_PREFIX . 'sidebars', $kopa_sidebar);
        //}
        $saved_opts = get_option(KOPA_OPT_PREFIX . 'options');
        if (!$saved_opts) {
            $tabs = KopaInit::get_theme_option_fields();
            $opts = array();
            foreach ($tabs as $tab) {
                foreach ($tab['groups'] as $groups) {
                    foreach ($groups['fields'] as $field) {
                        kopa_save_theme_options_loop($field, $opts);
                    }
                }
            }
            update_option(KOPA_OPT_PREFIX . 'options', $opts);
        }
    }
    $sidebars = get_option(KOPA_OPT_PREFIX . 'sidebars');
    foreach ($sidebars as $key => $value) {
        if ('sidebar_hide' != $key) {
            $sidebar_args = KopaInit::get_sidebar_args();
            $sidebar_args['name'] = $value;
            $sidebar_args['id'] = $key;
            register_sidebar($sidebar_args);
        }
    }
}