0, 'meta_key' => null, 'meta_value' => null, 'meta_table' => 'usermeta', 'meta_field' => 'user_id', 'cache_group' => 'users' ); $args = wp_parse_args( $args, $defaults ); extract( $args, EXTR_SKIP ); return update_user_meta( $id, $meta_key, $meta_value ); } } if ( !class_exists( 'BPDB' ) ) : /** * bbPress needs the DB class to be BPDB, but we want to use WPDB, so we can * extend it and use this. */ class BPDB extends WPDB { var $db_servers = array(); function BPDB( $dbuser, $dbpassword, $dbname, $dbhost ) { $this->__construct( $dbuser, $dbpassword, $dbname, $dbhost ); } function __construct( $dbuser, $dbpassword, $dbname, $dbhost ) { parent::__construct( $dbuser, $dbpassword, $dbname, $dbhost ); $args = func_get_args(); $args = call_user_func_array( array( &$this, 'init' ), $args ); if ( $args['host'] ) $this->db_servers['dbh_global'] = $args; } /** * Determine if a database supports a particular feature. * * Overriden here to work around differences between bbPress', and WordPress', implementation differences. * In particular, when BuddyPress tries to run bbPress' SQL installation script, the collation check always * failed. The capability is long supported by WordPress' minimum required MySQL version, so this is safe. */ function has_cap( $db_cap, $_table_name='' ) { if ( 'collation' == $db_cap ) return true; return parent::has_cap( $db_cap ); } /** * Initialises the class variables based on provided arguments. * Based on, and taken from, the BackPress class in turn taken from the 1.0 branch of bbPress. */ function init( $args ) { if ( 4 == func_num_args() ) { $args = array( 'user' => $args, 'password' => func_get_arg( 1 ), 'name' => func_get_arg( 2 ), 'host' => func_get_arg( 3 ), 'charset' => defined( 'BBDB_CHARSET' ) ? BBDB_CHARSET : false, 'collate' => defined( 'BBDB_COLLATE' ) ? BBDB_COLLATE : false, ); } $defaults = array( 'user' => false, 'password' => false, 'name' => false, 'host' => 'localhost', 'charset' => false, 'collate' => false, 'errors' => false ); return wp_parse_args( $args, $defaults ); } function escape_deep( $data ) { if ( is_array( $data ) ) { foreach ( (array) $data as $k => $v ) { if ( is_array( $v ) ) { $data[$k] = $this->_escape( $v ); } else { $data[$k] = $this->_real_escape( $v ); } } } else { $data = $this->_real_escape( $data ); } return $data; } } endif; // class_exists if ( !function_exists( 'bb_cache_users' ) ) : function bb_cache_users( $users ) { } endif; /** * bbPress Standalone Importer * * Helps in converting your bbPress Standalone into the new bbPress Plugin * * @package bbPress * @subpackage Importer * * @todo Docs * @todo User Mapping (ref. MT Importer) * @todo Role Mapping Options */ class bbPress_Importer { /** * @var string Path to bbPress standalone configuration file (bb-config.php) */ var $bbconfig = ''; /** * Load the bbPress environment */ function load_bbpress() { // BuddyPress Install if ( defined( 'BP_VERSION' ) && bp_is_active( 'forums' ) && bp_forums_is_installed_correctly() ) { global $bp; if ( !empty( $bp->forums->bbconfig ) && ( $bp->forums->bbconfig == $this->bbconfig ) ) bp_forums_load_bbpress(); } global $wpdb, $wp_roles, $current_user, $wp_users_object, $wp_taxonomy_object; global $bb, $bbdb, $bb_table_prefix, $bb_current_user, $bb_roles, $bb_queries; // Return if we've already run this function or it is BuddyPress if ( is_object( $bbdb ) ) return; // Config file does not exist if ( !file_exists( $this->bbconfig ) ) return false; // Set the path constants define( 'BB_PATH', trailingslashit( dirname( $this->bbconfig ) ) ); define( 'BACKPRESS_PATH', BB_PATH . 'bb-includes/backpress/' ); define( 'BB_INC', 'bb-includes/' ); require_once( BB_PATH . BB_INC . 'class.bb-query.php' ); require_once( BB_PATH . BB_INC . 'class.bb-walker.php' ); require_once( BB_PATH . BB_INC . 'functions.bb-core.php' ); require_once( BB_PATH . BB_INC . 'functions.bb-forums.php' ); require_once( BB_PATH . BB_INC . 'functions.bb-topics.php' ); require_once( BB_PATH . BB_INC . 'functions.bb-posts.php' ); require_once( BB_PATH . BB_INC . 'functions.bb-topic-tags.php' ); require_once( BB_PATH . BB_INC . 'functions.bb-capabilities.php' ); require_once( BB_PATH . BB_INC . 'functions.bb-meta.php' ); require_once( BB_PATH . BB_INC . 'functions.bb-pluggable.php' ); require_once( BB_PATH . BB_INC . 'functions.bb-formatting.php' ); require_once( BB_PATH . BB_INC . 'functions.bb-template.php' ); require_once( BACKPRESS_PATH . 'class.wp-taxonomy.php' ); require_once( BB_PATH . BB_INC . 'class.bb-taxonomy.php' ); $bb = new stdClass(); require_once( $this->bbconfig ); // Setup the global database connection $bbdb = new BPDB( BBDB_USER, BBDB_PASSWORD, BBDB_NAME, BBDB_HOST ); // Set the table names $bbdb->forums = $bb_table_prefix . 'forums'; $bbdb->meta = $bb_table_prefix . 'meta'; $bbdb->posts = $bb_table_prefix . 'posts'; $bbdb->terms = $bb_table_prefix . 'terms'; $bbdb->term_relationships = $bb_table_prefix . 'term_relationships'; $bbdb->term_taxonomy = $bb_table_prefix . 'term_taxonomy'; $bbdb->topics = $bb_table_prefix . 'topics'; // Users table if ( isset( $bb->custom_user_table ) ) $bbdb->users = $bb->custom_user_table; else $bbdb->users = $bb_table_prefix . 'users'; // Users meta table if ( isset( $bb->custom_user_meta_table ) ) $bbdb->usermeta = $bb->custom_user_meta_table; else $bbdb->usermeta = $bb_table_prefix . 'usermeta'; // Table prefix $bbdb->prefix = $bb_table_prefix; // Not installing define( 'BB_INSTALLING', false ); // Ghetto role map if ( is_object( $wp_roles ) ) { $bb_roles = $wp_roles; bb_init_roles( $bb_roles ); } // Call the standard bbPress actions do_action( 'bb_got_roles' ); do_action( 'bb_init' ); do_action( 'init_roles' ); // Setup required objects $bb_current_user = $current_user; $wp_users_object = new bbPress_Importer_BB_Auth; // Taxonomy object if ( !isset( $wp_taxonomy_object ) ) $wp_taxonomy_object = new BB_Taxonomy( $bbdb ); $wp_taxonomy_object->register_taxonomy( 'bb_topic_tag', 'bb_topic' ); } /** * Returns the tag name from tag object * * @param object $tag Tag Object * @return string Tag name */ function get_tag_name( $tag ) { return $tag->name; } /** * Simple check to check if the WP and bb user tables are integrated or not * * @return bool True if integrated, false if not */ function is_integrated() { global $bbdb, $wpdb; return ( $wpdb->users == $bbdb->users && $wpdb->usermeta == $bbdb->usermeta ); } /** * Tries to automatically locate the bbPress standalone install path * * @return string Path, if found */ function autolocate_bbconfig() { // BuddyPress Install if ( defined( 'BP_VERSION' ) && bp_is_active( 'forums' ) && bp_forums_is_installed_correctly() ) { global $bp; if ( !empty( $bp->forums->bbconfig ) ) return $bp->forums->bbconfig; } // Normal install $dirs = array( 'forum', 'forums', 'board', 'discussion', 'bbpress', 'bb', '' ); $base = trailingslashit( ABSPATH ); $base_dirs = array( $base, dirname( $base ) ); // Loop through possible directories foreach ( $dirs as $dir ) { // Loop through base dir foreach ( $base_dirs as $base_dir ) { // Path to try $test_path = $base_dir . $dir . '/bb-config.php'; // File exists if ( file_exists( $test_path ) ) { return realpath( $test_path ); } } } // Nothing found return ''; } /** * Get the bbPress standalone topic favoriters from topic id * * @param int $topic_id Topic id * @return array Topic Favoriters' IDs */ function bb_get_topic_favoriters( $topic_id = 0 ) { if ( empty( $topic_id ) ) return array(); global $bbdb; return (array) $bbdb->get_col( $bbdb->prepare( "SELECT user_id FROM $bbdb->usermeta WHERE meta_key = '{$bbdb->prefix}favorites' AND FIND_IN_SET( %d, meta_value ) > 0", $topic_id ) ); } /** * Get the bbPress standalone topic subscribers from topic id * * If the Subscribe to Topic bbPress plugin is active, then subscription * info is taken from that. Otherwise, if the the user is using * bbPress >= 1.1 alpha, then get the info from there. * * @param int $topic_id Topic id * @return array Topic Subscribers' IDs */ function bb_get_topic_subscribers( $topic_id = 0 ) { if ( empty( $topic_id ) ) return array(); global $bbdb, $subscribe_to_topic; $users = array(); // The user is using Subscribe to Topic plugin by _ck_, get the subscribers from there if ( !empty( $subscribe_to_topic ) && !empty( $subscribe_to_topic['db'] ) ) { $users = $bbdb->get_col( $bbdb->prepare( "SELECT user FROM {$subscribe_to_topic['db']} WHERE topic = %d AND type = 2", $topic_id ) ); // The user is using alpha, get the subscribers from built-in functionality } elseif ( function_exists( 'bb_notify_subscribers' ) ) { $users = $bbdb->get_col( $bbdb->prepare( "SELECT `$bbdb->term_relationships`.`object_id` FROM $bbdb->term_relationships, $bbdb->term_taxonomy, $bbdb->terms WHERE `$bbdb->term_relationships`.`term_taxonomy_id` = `$bbdb->term_taxonomy`.`term_taxonomy_id` AND `$bbdb->term_taxonomy`.`term_id` = `$bbdb->terms`.`term_id` AND `$bbdb->term_taxonomy`.`taxonomy` = 'bb_subscribe' AND `$bbdb->terms`.`slug` = 'topic-%d'", $topic_id ) ); } return (array) $users; } function header() { ?>

' . $error->get_error_message() . '

'; echo $this->next_step( $step, __( 'Try Again', 'bbpress' ) ); } /** * Returns the HTML for a link to the next page * * @param type $next_step * @param type $label * @param type $id * @return string */ function next_step( $next_step, $label, $id = 'bbpress-import-next-form' ) { $str = '
'; $str .= wp_nonce_field( 'bbp-bbpress-import', '_wpnonce', true, false ); $str .= wp_referer_field( false ); $str .= ''; $str .= '

'; $str .= '
'; return $str; } /** * Footer */ function footer() { ?>
header(); switch ( $step ) { case -1 : $this->cleanup(); // Intentional no break case 0 : $this->greet(); break; case 1 : case 2 : case 3 : check_admin_referer( 'bbp-bbpress-import' ); $result = $this->{ 'step' . $step }(); break; } $this->footer(); } /** * Greet message */ function greet() { global $wpdb, $bbdb; // Attempt to autolocate config file $autolocate = $this->autolocate_bbconfig(); ?>

  1. backup of your database and files. If the import process is interrupted for any reason, restore from that backup and re-run the import.', 'bbpress' ), 'http://codex.wordpress.org/WordPress_Backups' ); ?>
    1. Subscribe to Topic plugin active, then this script will migrate user subscriptions from that plugin.', 'bbpress' ), 'http://bbpress.org/plugins/topic/subscribe-to-topic/' ); ?>

bb-config.php:', 'bbpress' ); ?>

bbconfig = realpath( $_POST['bbp_bbpress_path'] ); // Update path update_option( 'bbp_bbpress_path', $this->bbconfig ); // Get details from DB } else { $this->bbconfig = get_option( 'bbp_bbpress_path' ); } // No config file found if ( empty( $this->bbconfig ) ) { ?>

bb-config.php.', 'bbpress' ); ?>

bbconfig ) && file_exists( trailingslashit( $this->bbconfig ) . 'bb-config.php' ) ) { $this->bbconfig = trailingslashit( $this->bbconfig ) . 'bb-config.php'; } // Check if the file exists if ( !file_exists( $this->bbconfig ) || is_dir( $this->bbconfig ) ) { delete_option( 'bbp_bbpress_path' ); ?>

bb-config.php doesn\'t exist in the path specified! Please check the path and try again.', 'bbpress' ); ?>

load_bbpress(); remove_filter( 'pre_post_status', 'bb_bozo_pre_post_status', 5, 3 ); return true; } /** * Notes & User Options */ function step1() { update_option( 'bbp_bbpress_step', 1 ); $setup = $this->setup(); if ( empty( $setup ) ) { return false; } elseif ( is_wp_error( $setup ) ) { $this->throw_error( $setup, 1 ); return false; } $radio = 'user'; global $wpdb, $bbdb; ?>

is_integrated() ) : $radio = 'board'; ?>

Auto-detected: Your WordPress and bbPress user tables are integrated. Proceed to .', 'bbpress' ); ?>

  1. new and you don\'t have the fear of losing WordPress users:', 'bbpress' ); ?> Note: The WordPress %1$s and %2$s tables will be renamed (not deleted) so that you can restore them if something goes wrong.', 'bbpress' ), '' . $wpdb->users . '', '' . $wpdb->usermeta . '' ); ?> ' . $bbdb->prefix . $wpdb->users . '_tmp' . '', '' . $bbdb->prefix . $wpdb->usermeta . '_tmp' . '' ); ?>
  2. integrated:', 'bbpress' ); ?>
  3. established WordPress user base, the user tables are not integrated and you can\'t lose your users:', 'bbpress' ); ?> welcome. :)', 'bbpress' ), 'http://bbpress.trac.wordpress.org/ticket/1523' ); ?>
is_integrated() ); ?> value="2" id="step_user" /> id="step_board" />

setup(); if ( empty( $setup ) ) { return false; } elseif ( is_wp_error( $setup ) ) { $this->throw_error( $setup, 2 ); return false; } global $wpdb, $bbdb; ?>

  1. query( "RENAME TABLE $wpdb->users TO {$bbdb->prefix}{$wpdb->users}_tmp, $wpdb->usermeta TO {$bbdb->prefix}{$wpdb->usermeta}_tmp" ) !== false ) : printf( __( 'Renamed the %1$s and %2$s tables to %3$s and %4$s respectively.', 'bbpress' ), $wpdb->users, $wpdb->usermeta, $bbdb->prefix . $wpdb->users . '_tmp', $bbdb->prefix . $wpdb->usermeta . '_tmp' ); else : printf( __( 'There was a problem dropping the %1$s and %2$s tables. Please check and re-run the script or rename or drop the tables yourself.', 'bbpress' ), $wpdb->users, $wpdb->usermeta ); ?>
  • query( "CREATE TABLE $wpdb->users ( `ID` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, `user_activation_key` VARCHAR( 60 ) NOT NULL DEFAULT '', KEY ( `user_login` ), KEY( `user_nicename` ) ) SELECT * FROM $bbdb->users ORDER BY `ID`" ) !== false ) : printf( __( 'Created the %s table and copied the users from bbPress.', 'bbpress' ), $wpdb->users ); else : printf( __( 'There was a problem duplicating the table %1$s to %2$s. Please check and re-run the script or duplicate the table yourself.', 'bbpress' ), $bbdb->users, $wpdb->users ); ?>
  • query( "CREATE TABLE $wpdb->usermeta ( `umeta_id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, KEY ( `user_id` ), KEY( `meta_key` ) ) SELECT * FROM $bbdb->usermeta ORDER BY `umeta_id`" ) !== false ) : printf( __( 'Created the %s table and copied the user information from bbPress.', 'bbpress' ), $wpdb->usermeta ); else : printf( __( 'There was a problem duplicating the table %1$s to %2$s. Please check and re-run the script or duplicate the table yourself.', 'bbpress' ), $bbdb->usermeta, $wpdb->usermeta ); ?>
  • 'administrator', 'administrator' => 'bbp_moderator', 'moderator' => 'bbp_moderator', 'member' => get_option( 'default_role' ), 'inactive' => get_option( 'default_role' ), 'blocked' => get_option( 'default_role' ), 'throttle' => 'throttle' ); $wp_user_level_map = array( 'administrator' => 10, 'editor' => 7, 'author' => 2, 'contributor' => 1, 'subscriber' => 0, 'throttle' => 0 ); // Apply the WordPress roles to the new users based on their bbPress roles wp_cache_flush(); $users = get_users( array( 'fields' => 'all_with_meta', 'orderby' => 'ID' ) ); foreach ( $users as $user ) { // Get the bbPress roles $bb_roles =& $user->{ $bbdb->prefix . 'capabilities' }; $converted_roles = $converted_level = array(); // Loop through each role the user has if ( !empty( $bb_roles ) ) { foreach ( $bb_roles as $bb_role => $bb_role_value ) { // If we have one of those in our roles map, add the WP counterpart in the new roles array if ( $roles_map[strtolower( $bb_role )] && !empty( $bb_role_value ) ) { $converted_roles[$roles_map[strtolower( $bb_role )]] = true; // Have support for deprecated levels too $converted_level[] = $wp_user_level_map[$roles_map[strtolower( $bb_role )]]; // We need an admin for future use if ( empty( $admin_user ) && 'administrator' == $roles_map[strtolower( $bb_role )] ) $admin_user = $user; } } } // If we have new roles, then update the user meta if ( count( $converted_roles ) ) { update_user_meta( $user->ID, $wpdb->prefix . 'capabilities', $converted_roles ); update_user_meta( $user->ID, $wpdb->prefix . 'user_level', max( $converted_level ) ); } } if ( empty( $admin_user ) || is_wp_error( $admin_user ) ) : /* I ask why */ ?>
  • ID ); // Set the current user wp_set_current_user( $admin_user->ID, $admin_user->user_login ); ?>
  • user_login, $admin_user->ID ); ?>
  • next_step( 3, __( 'Import forums, topics and posts »', 'bbpress' ) ); ?>
    setup(); if ( empty( $setup ) ) { return false; } elseif ( is_wp_error( $setup ) ) { $this->throw_error( $setup, 3 ); return false; } global $wpdb, $bbdb, $bbp; ?>

      " . __( 'No forums found', 'bbpress' ) . "
    \n"; return; } echo "
  • " . sprintf( __( 'Total number of forums: %s', 'bbpress' ), count( $forums ) ) . "
  • \n"; $forum_map = array(); $post_statuses = array( bbp_get_public_status_id(), bbp_get_trash_status_id(), bbp_get_spam_status_id() ); foreach ( (array) $forums as $forum ) { echo "
  • " . sprintf( __( 'Processing forum #%1$s (%3$s)', 'bbpress' ), $forum->forum_id, get_forum_link( $forum->forum_id ), esc_html( $forum->forum_name ) ) . "\n
  • \n"; continue; } $topics_query = new BB_Query( 'topic', array( 'forum_id' => $forum->forum_id, 'per_page' => -1, 'topic_status' => 'all', 'order_by' => 'topic_start_time', 'order' => 'ASC' ) ); $topics = $topics_query->results; // In standalone, categories can have topics, but this is not the case in plugin // So make the forum category if it doesn't have topics // Else close it if it's a category and has topics if ( bb_get_forum_is_category( $forum->forum_id ) ) { if ( count( $topics ) == 0 ) { bbp_categorize_forum( $inserted_forum ); echo "
  • " . __( 'The forum is a category and has no topics.', 'bbpress' ) . "
  • \n\n"; continue; } else { bbp_close_forum( $inserted_forum ); echo "
  • " . __( 'The forum is a category but has topics, so it has been set as closed on the new board.', 'bbpress' ) . "
  • \n"; } } bb_cache_first_posts( $topics ); echo "
  • " . sprintf( __( 'Total number of topics in the forum: %s', 'bbpress' ), count( $topics ) ) . "
  • \n"; foreach ( (array) $topics as $topic ) { $first_post = bb_get_first_post( $topic->topic_id ); // If the topic is public, check if it's open and set the status accordingly $topic_status = $topic->topic_status == 0 ? ( $topic->topic_open == 0 ? bbp_get_closed_status_id() : $post_statuses[$topic->topic_status] ) : $post_statuses[$topic->topic_status]; $inserted_topic = wp_insert_post( array( 'post_parent' => $inserted_forum, 'post_author' => $topic->topic_poster, 'post_content' => $first_post->post_text, 'post_title' => $topic->topic_title, 'post_name' => ( strlen( $topic->topic_slug ) > 200 ) ? sanitize_title_with_dashes( $topic->topic_slug ) : $topic->topic_slug, 'post_status' => $topic_status, 'post_date_gmt' => $topic->topic_start_time, 'post_date' => get_date_from_gmt( $topic->topic_start_time ), 'post_type' => bbp_get_topic_post_type(), 'tax_input' => array( 'topic-tag' => array_map( array( $this, 'get_tag_name' ), bb_get_public_tags( $topic->topic_id ) ) ) ) ); if ( !empty( $inserted_topic ) && !is_wp_error( $inserted_topic ) ) { // Loginless Posting if ( $topic->topic_poster == 0 ) { update_post_meta( $inserted_topic, '_bbp_anonymous_name', bb_get_post_meta( 'post_author', $first_post->post_id ) ); update_post_meta( $inserted_topic, '_bbp_anonymous_email', bb_get_post_meta( 'post_email', $first_post->post_id ) ); update_post_meta( $inserted_topic, '_bbp_anonymous_website', bb_get_post_meta( 'post_url', $first_post->post_id ) ); } // Author IP update_post_meta( $inserted_topic, '_bbp_author_ip', $first_post->poster_ip ); // Forum topic meta update_post_meta( $inserted_topic, '_bbp_forum_id', $inserted_forum ); update_post_meta( $inserted_topic, '_bbp_topic_id', $inserted_topic ); $posts = bb_cache_posts( $bbdb->prepare( 'SELECT * FROM ' . $bbdb->posts . ' WHERE topic_id = %d AND post_id != %d ORDER BY post_time', $topic->topic_id, $first_post->post_id ) ); $replies = 0; $hidden_replies = 0; $last_reply = 0; $post = null; foreach ( (array) $posts as $post ) { // Pingback if ( $post->poster_id == 0 && $pingback_uri = bb_get_post_meta( 'pingback_uri', $post->post_id ) ) { $pingback = wp_insert_comment( wp_filter_comment( array( 'comment_post_ID' => $inserted_topic, 'comment_author' => bb_get_post_meta( 'pingback_title', $post->post_id ), 'comment_author_url' => $pingback_uri, 'comment_author_IP' => $post->poster_ip, 'comment_date_gmt' => $post->post_time, 'comment_date' => get_date_from_gmt( $post->post_time ), 'comment_content' => $post->post_text, 'comment_approved' => $post->post_status == 0 ? 1 : ( $post->post_status == 2 ? 'spam' : 0 ), 'comment_type' => 'pingback' ) ) ); // Normal post } else { $reply_title = sprintf( __( 'Reply To: %s', 'bbpress' ), $topic->topic_title ); $last_reply = wp_insert_post( array( 'post_parent' => $inserted_topic, 'post_author' => $post->poster_id, 'post_date_gmt' => $post->post_time, 'post_date' => get_date_from_gmt( $post->post_time ), 'post_title' => $reply_title, 'post_name' => sanitize_title_with_dashes( $reply_title ), 'post_status' => $post_statuses[$post->post_status], 'post_type' => bbp_get_reply_post_type(), 'post_content' => $post->post_text ) ); // Loginless if ( $post->poster_id == 0 ) { update_post_meta( $last_reply, '_bbp_anonymous_name', bb_get_post_meta( 'post_author', $post->post_id ) ); update_post_meta( $last_reply, '_bbp_anonymous_email', bb_get_post_meta( 'post_email', $post->post_id ) ); update_post_meta( $last_reply, '_bbp_anonymous_website', bb_get_post_meta( 'post_url', $post->post_id ) ); } // Author IP update_post_meta( $last_reply, '_bbp_author_ip', $post->poster_ip ); // Reply Parents update_post_meta( $last_reply, '_bbp_forum_id', $inserted_forum ); update_post_meta( $last_reply, '_bbp_topic_id', $inserted_topic ); bbp_update_reply_walker( $last_reply ); } if ( $post->post_status != 0 ) $hidden_replies++; else $replies++; } // Only add favorites and subscriptions if the topic is public if ( in_array( $topic_status, array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) ) ) { // Favorites foreach ( (array) $this->bb_get_topic_favoriters( $topic->topic_id ) as $favoriter ) bbp_add_user_favorite ( $favoriter, $inserted_topic ); // Subscriptions foreach ( (array) $this->bb_get_topic_subscribers( $topic->topic_id ) as $subscriber ) bbp_add_user_subscription( $subscriber, $inserted_topic ); } // Topic stickiness switch ( $topic->topic_sticky ) { // Forum case 1 : bbp_stick_topic( $inserted_topic ); break; // Front case 2 : bbp_stick_topic( $inserted_topic, true ); break; } // Last active $last_active_id = !empty( $last_reply ) ? $last_reply : $inserted_topic; $last_active_time = !empty( $post ) ? $post->post_time : $first_post->post_time; // Reply topic meta update_post_meta( $inserted_topic, '_bbp_last_reply_id', $last_reply ); update_post_meta( $inserted_topic, '_bbp_last_active_id', $last_active_id ); update_post_meta( $inserted_topic, '_bbp_last_active_time', $last_active_time ); update_post_meta( $inserted_topic, '_bbp_reply_count', $replies ); update_post_meta( $inserted_topic, '_bbp_reply_count_hidden', $hidden_replies ); // Voices will be done by recount bbp_update_topic_walker( $inserted_topic ); echo "
  • " . sprintf( __( 'Added topic #%1$s (%3$s) as topic #%5$s with %6$s replies.', 'bbpress' ), $topic->topic_id, get_topic_link( $topic->topic_id ), esc_html( $topic->topic_title ), get_permalink( $inserted_topic ), $inserted_topic, $replies ) . "
  • \n"; } else { echo "
  • " . sprintf( __( 'There was a problem in adding topic #1$s (%3$s).', 'bbpress' ), $topic->topic_id, get_topic_link( $topic->topic_id ), esc_html( $topic->topic_title ) ) . "
  • \n"; continue; } } echo "\n\n"; } ?> cleanup(); do_action( 'import_done', 'bbpress' ); ?>

    recount to get the counts in sync! Yes, we’re bad at Math.', 'bbpress' ), add_query_arg( array( 'page' => 'bbp-recount' ), get_admin_url( 0, 'tools.php' ) ) ); ?>

    Have fun! :)', 'bbpress' ), home_url() ); ?>