Пример #1
0
/**
 * Install script to create database tables and then insert default data.
 * Only run if theme is being activated.
 *
 */
function cp_install_theme()
{
    // run the table install script
    cp_tables_install();
    // populate the database tables
    cp_populate_tables();
    // insert the default values
    cp_default_values();
    // create pages and assign templates
    cp_create_pages();
    // create a default ad and category
    cp_default_ad();
    // create the default menus
    cp_default_menus();
    // assign default widgets to sidebars
    cp_default_widgets();
    // flush the rewrite rules
    flush_rewrite_rules();
    // if fresh install, setup current database version, and do not process update
    if (get_option('cp_db_version') == false) {
        // set blog and ads pages
        update_option('show_on_front', 'page');
        update_option('page_on_front', CP_Ads_Home::get_id());
        update_option('page_for_posts', CP_Blog_Archive::get_id());
        update_option('cp_db_version', CP_DB_VERSION);
    }
}
Пример #2
0
function cp_db_update()
{
    if (is_admin() && current_user_can('update_themes')) {
        global $wpdb, $app_abbr, $app_current_db_version, $wp_rewrite;
        // get the ClassiPress db version number
        $app_current_db_version = get_option($app_abbr . '_db_version');
        // only run through the main install script if it's a brand spanking new install
        if ($app_current_db_version < 1200) {
            // run the table install script
            cp_tables_install();
            // insert the default values
            cp_default_values();
            // insert the default links
            cp_insert_links();
            // create pages and assign templates
            cp_create_pages();
            // create a default ad and category
            cp_default_ad();
            $wp_rewrite->flush_rules();
            // triggered in admin-post-types.php
            add_option($app_abbr . '_rewrite_flush_flag', 'true');
        }
        // see if the database needs updating
        require_once 'admin-updates.php';
        cp_upgrade_all();
    }
}
Пример #3
0
/**
* Install script to create database tables and then insert default data.
* Only run if theme is being activated.
*
*
*/
function cp_install_theme()
{
    global $wpdb, $app_abbr, $app_db_version, $wp_rewrite;
    // run the table install script
    cp_tables_install();
    // populate the database tables
    cp_populate_tables();
    // insert the default values
    cp_default_values();
    // create pages and assign templates
    cp_create_pages();
    // create a default ad and category
    cp_default_ad();
    // create the default menus
    cp_default_menus();
    // flush the rewrite rules, triggered in admin-post-types.php
    update_option($app_abbr . '_rewrite_flush_flag', 'true');
    // if fresh install, setup current database version, and do not process update
    if (get_option($app_abbr . '_db_version') == false) {
        update_option($app_abbr . '_db_version', $app_db_version);
    }
}