function bp_loader_activate() { /* Force refresh theme roots. */ delete_site_transient( 'theme_roots' ); /* Switch the user to the new bp-default if they are using the old bp-default on activation. */ if ( 'bp-sn-parent' == get_blog_option( BP_ROOT_BLOG, 'template' ) && 'bp-default' == get_blog_option( BP_ROOT_BLOG, 'stylesheet' ) ) switch_theme( 'bp-default', 'bp-default' ); /* Install site options on activation */ bp_core_activate_site_options( array( 'bp-disable-account-deletion' => 0, 'bp-disable-avatar-uploads' => 0, 'bp-disable-blogforum-comments' => 0, 'bp-disable-forum-directory' => 0, 'bp-disable-profile-sync' => 0 ) ); do_action( 'bp_loader_activate' ); }
function step_ms_update_save() { global $nxtdb; if (isset($_POST['submit'])) { check_admin_referer('bpwizard_ms_update'); if (!($active_components = bp_get_option('bp-active-components'))) { $active_components = array(); } // Transfer important settings from blog options to site options $options = array('bp-db-version' => $this->database_version, 'bp-active-components' => $active_components, 'avatar-default' => get_option('avatar-default')); bp_core_activate_site_options($options); if (isset($_POST['bp_components']['blogs'])) { $active_components['blogs'] = 1; // Make sure that the pages are created on the bp_get_root_blog_id(), no matter which Dashboard the setup is being run on if (!empty($nxtdb->blogid) && $nxtdb->blogid != bp_get_root_blog_id() && !defined('BP_ENABLE_MULTIBLOG')) { switch_to_blog(bp_get_root_blog_id()); } // Move bp-pages data from the blog options table to site options $existing_pages = bp_get_option('bp-pages'); $bp_pages = $this->setup_pages((array) $_POST['bp_pages']); $bp_pages = array_merge((array) $existing_pages, (array) $bp_pages); bp_update_option('bp-pages', $bp_pages); if (!empty($nxtdb->blogid) && $nxtdb->blogid != bp_get_root_blog_id() && !defined('BP_ENABLE_MULTIBLOG')) { restore_current_blog(); } bp_core_install($active_components); } bp_update_option('bp-active-components', $active_components); return true; } return false; }
/** * xprofile_install() * * Set up the database tables needed for the xprofile component. * * @package BuddyPress XProfile * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() * @uses dbDelta() Takes SQL statements and compares them to any existing tables and creates/updates them. * @uses add_site_option() adds a value for a meta_key into the wp_sitemeta table */ function xprofile_install() { global $bp, $wpdb; if ( !empty($wpdb->charset) ) $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; bp_core_activate_site_options( array( 'bp-xprofile-base-group-name' => 'Base', 'bp-xprofile-fullname-field-name' => 'Name' ) ); $sql[] = "CREATE TABLE {$bp->profile->table_name_groups} ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, name varchar(150) NOT NULL, description mediumtext NOT NULL, can_delete tinyint(1) NOT NULL, KEY can_delete (can_delete) ) {$charset_collate};"; $sql[] = "CREATE TABLE {$bp->profile->table_name_fields} ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, group_id bigint(20) unsigned NOT NULL, parent_id bigint(20) unsigned NOT NULL, type varchar(150) NOT NULL, name varchar(150) NOT NULL, description longtext NOT NULL, is_required tinyint(1) NOT NULL DEFAULT '0', is_default_option tinyint(1) NOT NULL DEFAULT '0', field_order bigint(20) NOT NULL DEFAULT '0', option_order bigint(20) NOT NULL DEFAULT '0', order_by varchar(15) NOT NULL, can_delete tinyint(1) NOT NULL DEFAULT '1', KEY group_id (group_id), KEY parent_id (parent_id), KEY field_order (field_order), KEY can_delete (can_delete), KEY is_required (is_required) ) {$charset_collate};"; $sql[] = "CREATE TABLE {$bp->profile->table_name_data} ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, field_id bigint(20) unsigned NOT NULL, user_id bigint(20) unsigned NOT NULL, value longtext NOT NULL, last_updated datetime NOT NULL, KEY field_id (field_id), KEY user_id (user_id) ) {$charset_collate};"; if ( '' == get_site_option( 'bp-xprofile-db-version' ) ) { if ( !$wpdb->get_var( "SELECT id FROM {$bp->profile->table_name_groups} WHERE id = 1" ) ) $sql[] = "INSERT INTO {$bp->profile->table_name_groups} VALUES ( 1, '" . get_site_option( 'bp-xprofile-base-group-name' ) . "', '', 0 );"; if ( !$wpdb->get_var( "SELECT id FROM {$bp->profile->table_name_fields} WHERE id = 1" ) ) $sql[] = "INSERT INTO {$bp->profile->table_name_fields} VALUES ( 1, 1, 0, 'textbox', '" . get_site_option( 'bp-xprofile-fullname-field-name' ) . "', '', 1, 0, 0, 0, '', 0 );"; } require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta($sql); do_action( 'xprofile_install' ); update_site_option( 'bp-xprofile-db-version', BP_XPROFILE_DB_VERSION ); }