Skip to:
Content

BuddyPress.org

Changeset 2863 for trunk/bp-blogs.php


Ignore:
Timestamp:
03/22/2010 11:34:23 AM (15 years ago)
Author:
apeatling
Message:

Added new install/upgrade wizard. Removed root components and replaced them with actual WordPress pages. Testing on WordPress vhost/novhost and root profile support still to do.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-blogs.php

    r2842 r2863  
    11<?php
    2 
    3 define ( 'BP_BLOGS_DB_VERSION', '2015' );
    4 
    5 /* Define the slug for the component */
    6 if ( !defined( 'BP_BLOGS_SLUG' ) )
    7     define ( 'BP_BLOGS_SLUG', 'blogs' );
    8 
    92require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-classes.php' );
    103require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-templatetags.php' );
     
    147    require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-widgets.php' );
    158
    16 function bp_blogs_install() {
    17     global $wpdb, $bp;
    18 
    19     if ( !empty($wpdb->charset) )
    20         $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    21 
    22     $sql[] = "CREATE TABLE {$bp->blogs->table_name} (
    23                 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    24                 user_id bigint(20) NOT NULL,
    25                 blog_id bigint(20) NOT NULL,
    26                 KEY user_id (user_id),
    27                 KEY blog_id (blog_id)
    28              ) {$charset_collate};";
    29 
    30     $sql[] = "CREATE TABLE {$bp->blogs->table_name_blogmeta} (
    31                 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    32                 blog_id bigint(20) NOT NULL,
    33                 meta_key varchar(255) DEFAULT NULL,
    34                 meta_value longtext DEFAULT NULL,
    35                 KEY blog_id (blog_id),
    36                 KEY meta_key (meta_key)
    37              ) {$charset_collate};";
    38 
    39 
    40     require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
    41 
    42     dbDelta($sql);
    43 
    44     // On first installation - record all existing blogs in the system.
    45     if ( !(int)$bp->site_options['bp-blogs-first-install'] && bp_core_is_multisite() ) {
    46         bp_blogs_record_existing_blogs();
    47         add_site_option( 'bp-blogs-first-install', 1 );
    48     }
    49 
    50     update_site_option( 'bp-blogs-db-version', BP_BLOGS_DB_VERSION );
    51 }
    52 
    53 function bp_blogs_check_installed() {
    54     global $wpdb, $bp, $userdata;
    55 
    56     /* Only create the bp-blogs tables if this is a multisite install */
    57     if ( is_site_admin() && bp_core_is_multisite() ) {
    58         /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
    59         if ( get_site_option( 'bp-blogs-db-version' ) < BP_BLOGS_DB_VERSION )
    60             bp_blogs_install();
    61     }
    62 }
    63 add_action( 'admin_menu', 'bp_blogs_check_installed' );
    64 
    659function bp_blogs_setup_globals() {
    6610    global $bp, $wpdb;
    6711
     12    if ( !defined( 'BP_BLOGS_SLUG' ) )
     13        define ( 'BP_BLOGS_SLUG', $bp->pages->blogs->slug );
     14
    6815    /* For internal identification */
    6916    $bp->blogs->id = 'blogs';
     17    $bp->blogs->name = $bp->pages->blogs->name;
     18    $bp->blogs->slug = BP_BLOGS_SLUG;
    7019
    7120    $bp->blogs->table_name = $wpdb->base_prefix . 'bp_user_blogs';
    7221    $bp->blogs->table_name_blogmeta = $wpdb->base_prefix . 'bp_user_blogs_blogmeta';
    7322    $bp->blogs->format_notification_function = 'bp_blogs_format_notifications';
    74     $bp->blogs->slug = BP_BLOGS_SLUG;
    7523
    7624    /* Register this in the active components array */
     
    8028}
    8129add_action( 'bp_setup_globals', 'bp_blogs_setup_globals' );
    82 
    83 function bp_blogs_setup_root_component() {
    84     /* Register 'blogs' as a root component */
    85     bp_core_add_root_component( BP_BLOGS_SLUG );
    86 }
    87 add_action( 'bp_setup_root_components', 'bp_blogs_setup_root_component' );
    8830
    8931/**
     
    10547
    10648    /* Add 'Blogs' to the main navigation */
    107     bp_core_new_nav_item( array( 'name' => sprintf( __( 'Blogs <span>(%d)</span>', 'buddypress' ), bp_blogs_total_blogs_for_user() ), 'slug' => $bp->blogs->slug, 'position' => 30, 'screen_function' => 'bp_blogs_screen_my_blogs', 'default_subnav_slug' => 'my-blogs', 'item_css_id' => $bp->blogs->id ) );
    108 
    109     $blogs_link = $bp->loggedin_user->domain . $bp->blogs->slug . '/';
     49    bp_core_new_nav_item( array( 'name' => sprintf( __( 'Blogs <span>(%d)</span>', 'buddypress' ), bp_blogs_total_blogs_for_user() ), 'slug' => $bp->blogs->name, 'position' => 30, 'screen_function' => 'bp_blogs_screen_my_blogs', 'default_subnav_slug' => 'my-blogs', 'item_css_id' => $bp->blogs->id ) );
     50
     51    $blogs_link = $bp->loggedin_user->domain . $bp->blogs->name . '/';
    11052
    11153    /* Set up the component options navigation for Blog */
Note: See TracChangeset for help on using the changeset viewer.