Beispiel #1
0
/**
 * Install and/or upgrade the database
 */
function bp_group_hierarchy_install()
{
    global $wpdb, $bp;
    if (!empty($wpdb->charset)) {
        $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
    }
    $sql[] = "CREATE TABLE {$bp->groups->table_name} (\r\n\t\t\t\tparent_id BIGINT(20) NOT NULL DEFAULT 0,\r\n\t\t\t\tKEY parent_id (parent_id),\r\n\t\t\t) {$charset_collate};\r\n\t \t   ";
    if (!get_site_option('bp-group-hierarchy-db-version') || get_site_option('bp-group-hierarchy-db-version') < BP_GROUP_HIERARCHY_DB_VERSION || !bp_group_hierarchy_verify_install()) {
        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
        dbDelta($sql);
    }
    if (bp_group_hierarchy_verify_install(true)) {
        update_site_option('bp-group-hierarchy-db-version', BP_GROUP_HIERARCHY_DB_VERSION);
    } else {
        die('Could not create the required column.  Please enable debugging for more details.');
    }
}
Beispiel #2
0
/**
 * Install and/or upgrade the database
 */
function bp_group_hierarchy_install()
{
    global $wpdb, $bp;
    // Check whether BP is active and whether Groups component is loaded, and throw error if not
    if (!(function_exists('buddypress') || is_a($bp, 'BuddyPress')) || !bp_is_active('groups')) {
        _e('BuddyPress is not installed or the Groups component is not activated. Cannot continue install.', 'bp-group-hierarchy');
        exit;
    }
    if (!empty($wpdb->charset)) {
        $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
    }
    $sql[] = "CREATE TABLE {$bp->groups->table_name} (\r\n\t\t\t\tparent_id BIGINT(20) NOT NULL DEFAULT 0,\r\n\t\t\t\tKEY parent_id (parent_id),\r\n\t\t\t) {$charset_collate};\r\n\t \t   ";
    if (!get_site_option('bp-group-hierarchy-db-version') || get_site_option('bp-group-hierarchy-db-version') < BP_GROUP_HIERARCHY_DB_VERSION || !bp_group_hierarchy_verify_install()) {
        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
        dbDelta($sql);
    }
    if (bp_group_hierarchy_verify_install(true)) {
        update_site_option('bp-group-hierarchy-db-version', BP_GROUP_HIERARCHY_DB_VERSION);
    } else {
        die('Could not create the required column.  Please enable debugging for more details.');
    }
}