It needs your config! Use the template tags to show comments under the wordpress post. :) Version: ρ Author: fel64 Author URI: http://www.loinhead.net/ load replies if single post, forget felbbreplies() maybe there's a comments global that I can change? */ add_action('publish_post', 'felsyncpost', 999 ); add_action('comment_post', 'felsynccomment', 999, 2 ); add_action('admin_menu', 'bbsyncaddsubmenu'); add_action('edit_form_advanced', 'bbsyncpostoptions'); remove_action('publish_post', 'bbpress_setpost'); remove_filter('the_content', 'bbpress_add_forumlink'); /* CORE */ function load_bb() { global $bb, $bbdb, $bb_current_user, $page, $bb_cache, $posts, $bb_post, $post_id, $topics, $topic, $topic_id, $forums, $forum, $forum_id, $tags, $tag, $tag_name, $user, $user_id, $view; // MAINTAIN - source is template-functions.php global $bb_roles, $bb_table_prefix, $bb_locale, $bb_timestart, $timeend; // INCOMPLETE global $opshuns; $opshuns = get_option('bbsync'); /**/ remove_action('bb_user_has_no_caps', 'bb_give_user_default_role'); // MAINTAIN require_once( $opshuns['bbpath'] ); //bb-load /**/ add_action('bb_user_has_no_caps', 'bb_give_user_default_role'); // MAINTAIN } function felsyncpost( $post_id ) { global $bbdb, $wpdb, $current_user; $opshuns = get_option('bbsync'); $post = wp_get_single_post( $post_id ); if( !empty( $post->post_password ) ) return; load_bb(); if( !$current_user ) return; bb_set_current_user( $current_user->ID ); $post_title = $bbdb->escape( $post->post_title ); $post_text = $bbdb->escape( felprepposttext( $post_id ) ); if( !felwptobb( $post_id ) ) { $forum_id = $opshuns['forum']; $topic_id = bb_new_topic( $post_title, $forum_id, $tags ); $reply_id = bb_new_post( $topic_id, $post_text ); if( $topic_id && $reply_id ) { felmetalink( $post_id, $topic_id ); } $oldcoms = get_approved_comments( $post_id ); if( $oldcoms ) { foreach( $oldcoms AS $oldcom ) { if( $user = bb_get_user( $oldcom->comment_author ) ) { $time = strtotime( $oldcom->comment_date ); $text = 'This comment was originally posted at ' . date( 'G:i', $time ) . ' on ' . date( 'jS F Y', $time ) . ".\n\n" . $oldcom->comment_content; bb_set_current_user( $user->ID ); bb_new_post( $topic_id, mysql_real_escape_string( $text ) ); } } } } else { //update topic/post $topic_id = felwptobb( $post_id ); bb_update_topic( $post_title, $topic_id ); $reply = bb_get_first_post( $topic_id ); bb_update_post( mysql_real_escape_string( $post_text ), $reply->post_id, $topic_id ); } } function felmetalink( $post_id, $topic_id ) { $opshuns = get_option('bbsync'); load_bb(); bb_update_topicmeta( $topic_id, 'wp_post', $post_id ); if( !update_post_meta( $post_id, 'bb_topic', $topic_id ) ) add_post_meta( $post_id, 'bb_topic', $topic_id, true ); return true; } function felwptobb( $post_id ) { $bb_topic = get_post_meta( $post_id, 'bb_topic', $true ); return $bb_topic[0]; } function felgetbbreplies() { global $wpdb, $post; $opshuns = get_option('bbsync'); $topic_id = felwptobb( $post->ID ); if( $topic_id ) { $bb_ = $opshuns['bb_']; $bb_posts = $bb_ . 'posts'; $bbreplies = $wpdb->get_results(" SELECT poster_id, post_text, post_time FROM $bb_posts WHERE topic_id = $topic_id AND post_status = 0 "); array_shift( $bbreplies ); //pops first one off return $bbreplies; } else { return false; } } /* COMMENTS -> REPLIES */ function felsynccomment( $comment_id, $ham ) { global $wpdb; $opshuns = get_option('bbsync'); load_bb(); $comment = get_comment( $comment_id ); $topic_id = felwptobb( $comment->comment_post_ID ); $ham = $comment->comment_approved; if( ( $topic_id ) && ( $ham == 1 ) && ( $comment->user_id ) && bb_set_current_user( $comment->user_id ) ) { //topic linked, genuine comment, actual user, bb likes user bb_new_post( $topic_id, $comment->comment_content ); return true; } else { return false; } } /* MIGRATION */ function felbbPostmigration() { global $wpdb; $bbPoststable = $wpdb->prefix . 'bbpress_post_posts'; $bbPostsoptionstable = $wpdb->prefix . 'bbpress_post_options'; $bbPosts = $wpdb->get_results(" SELECT * FROM $bbPoststable "); if( $bbPosts ) { foreach( $bbPosts as $bbPost ) { if( !felwptobb( $bbPost->post_id ) ) { if( !felmetalink( $bbPost->post_id, $bbPost->topic_id ) ) $fail = true; } } if( $fail ) { $errorsfelled[] = $felerrors['notopicmetalink']; } else { $wpdb->query(" DROP TABLE $bbPoststable, $bbPostsoptionstable "); $felmessage = $felmessages['migrated']; } } else { $errorsfelled[] = $felerrors['nobbPost']; } } function felbringtospeed() { //post links only in bb_topicmeta now also plz in wp_postmeta global $bbdb; $opshuns = get_option('bbsync'); load_bb(); $topiclinks = $bbdb->get_results("SELECT topic_id, meta_value FROM $bbdb->topicmeta WHERE meta_key = 'wp_post'"); foreach( $topiclinks AS $link ) { felmetalink( $link->meta_value, $link->topic_id ); } } function felprepposttext( $post_id ) { $post = wp_get_single_post( $post_id ); $opshuns = get_option('bbsync'); $set_truncate = get_post_meta( $post_id, 'bbsync_truncate', true ); if( $opshuns['nomore'] ) { $ptvers = get_extended( $post->post_content ); $post_text = $ptvers['main']; } elseif( $opshuns['pageonly'] ) { list( $post_text, $throwaway ) = explode('', $post->post_content, 2 ); } elseif( ( isset( $_POST['truncate'] ) && $_POST['truncate'] === 0 ) || ( !( isset( $_POST['truncate'] ) && $_POST['truncate'] === 0 ) && $opshuns['truncate'] ) ) { //if POSTed truncate is 0 XOR default truncate is 0 $post_text = $post->post_content; } elseif( $_POST['truncate'] ) { //if POSTed truncate is not 0 $post_text = substr( $post->post_content, 0, $_POST['truncate'] ) . '...'; if( !add_post_meta( $post_id, 'bbsync_truncate', $_POST['truncate'], true ) ) update_post_meta( $post_id, 'bbsync_truncate', $_POST['truncate'] ); } elseif( $set_truncate ) { //if no POSTed truncate and special data for this 'un $post_text = substr( $post->post_content, 0, $set_truncate ) . '...'; } elseif( $opshuns['truncate'] ) { //otherwise, go to default if exists $post_text = substr( $post->post_content, 0, $opshuns['truncate'] ) . '...'; } else { //or just don't do anything $post_text = $post->post_content; } if( !empty( $opshuns['link'] ) && $post_text != $post->post_content ) { $arrrsearches = array('%title%', '%name%'); $arrrreplaces = array($post->post_title, get_bloginfo('name') ); $linktext = str_replace($arrrsearches, $arrrreplaces, $opshuns['link'] ); $linkurl = get_permalink( $post->ID ); $linktext = "\n\n$linktext"; $post_text .= $linktext; } remove_filter('pre_post', 'encode_bad'); remove_filter('pre_post', 'bb_encode_bad'); remove_filter('pre_post', 'bb_filter_kses', 50 ); remove_filter('pre_post', 'addslashes', 55 ); remove_filter('pre_post', 'bb_autop', 60 ); remove_filter('pre_post', 'allow_images_encode_bad', 9 ); remove_filter('pre_post', 'allow_images', 52 ); $post_text = bb_autop( addslashes( $post_text ) ); return $post_text; } /* INTERFACE */ function bbsyncaddsubmenu() { if (function_exists("add_submenu_page")) add_submenu_page('options-general.php', 'bbSync', 'bbSync', 10, 'bbsync.php', 'felbbsyncinterface'); } function felbbsyncinterface() { if (function_exists("add_submenu_page")) { $opshuns = get_option('bbsync'); $bbsyncurl = get_bloginfo('wpurl') . '/wp-admin/options-general.php?page=bbsync.php'; $felerrors = array( 'nobbpath' => 'I don\'t have a working path to your bb-load.php file for bbPress, and I need it to make this work!', 'nobbPost' => 'I couldn\'t find the bbPress Post table, so I couldn\'t migrate it either. Sorry!', ); $felmessages = array( 'options' => 'Thanks! Updated your options no problem. Should all work! :-)', 'migrated' => 'Coolio, your old data from bbPress Post has been migrated and the tables it used deleted. \o/', 'broughttospeed' => 'Yup, brought your forum to speed with old blog posts and comments. Check your forum and (hopefully) cheer!' ); if( $_POST['migrate'] == 'bbPress Post') { felbbPostmigration(); } if( $_POST['settings'] == true ) { //options handling $allowed_opshuns = array( 'bbpath', 'bburl', 'bb_', 'forum', 'nomore', 'pageonly', 'truncate', 'bbAPI', 'ppo', 'link' ); foreach( $_POST AS $postkey => $postvalue ) { if( in_array( $postkey, $allowed_opshuns ) ) $opshuns[ $postkey ] = $postvalue; } if( !is_int( $opshuns['truncate'] ) && $opshuns['truncate'] < 0 ) { $opshuns['truncate'] = 0; } if( $_POST['forum'] ) { $opshuns['forum'] = felinterpretforum( $_POST['forum'] ); } $truefalses = array( 'nomore', 'pageonly', 'bbAPI', 'ppo' ); foreach( $truefalses AS $kee ) { if( !$_POST[ $kee ] ) { $opshuns[ $kee ] = false; } } update_option( 'bbsync', $opshuns ); } if( !$opshuns['bbpath'] || !strpos( $opshuns['bbpath'], 'bb-load.php') || !is_readable( $opshuns['bbpath'] ) ) { $errorsfelled[] = $felerrors['nobbpath']; } if( $_POST['settings'] == true && !$errorsfelled ) { $felmessage = $felmessages['options']; } if( $_POST['migrate'] == true ) { felbbPostmigration(); } if( $_POST['bringtospeed'] == true ) { felbringtospeed(); } if( $errorsfelled ) { foreach( $errorsfelled AS $felerror ) { ?>

bbSync ~ bbPress Synchronisation Options

Settings

  • />
  • />
  • Do you want me to load bbPress whenever to make things like links nicer? This could add a lot of work to your server and make it slower.
  • />

Migrate from bbPress Post

This will get all the old blog post -> topic links, transfer them into the new system, and finally kill the unnecessary tables. It's a permanent change. Backup your databases first!

Update Plugin

This will get all the old links and update them to enable caching and stuff. Do it if you just replaced this plugin with a newer version.

bbSync

This plugin should completely synchronise everything of interest between Wordpress and bbPress.

bbSync ~

get_row(" SELECT forum_id, forum_name FROM $bb_forums WHERE ( forum_id = '$forumidname' OR forum_name = '$forumidname' ) "); if( $forum ) { return $forum->forum_id; } else { return 1; } } /* TEMPLATE TAGGING */ function felbbreplies() { global $opshuns; // if template wants it I guess $opshuns = get_option('bbsync'); $bbreplies = felgetbbreplies(); if( $bbreplies !== false ) { $a = 1; echo '
    '; global $bbreply, $bbposter; foreach( $bbreplies AS $bbreply ) { $bbposter = get_userdata( $bbreply->poster_id ); if( $a = 1 ) $alt = 'alt'; else $alt = ''; $a = $a - 1; if( is_readable( TEMPLATEPATH . '/bbreply.php' ) ) { include TEMPLATEPATH . '/bbreply.php'; } else { ?>
  1. ~
  2. '; return true; } else { echo '

    Reply!

    '; return false; } } function bbreplier() { global $bbposter; echo $bbposter->user_login; } function bbreplytime( $dtformat = 'G:i jS M y' ) { global $bbreply; $bbreplyts = strtotime( $bbreply->post_time ); $bbreplytime = date( $dtformat, $bbreplyts ); echo $bbreplytime; } function bbreplyavatar() { global $bbposter; $opshuns = get_option('bbsync'); $avatar = get_usermeta( $bbposter->ID, 'avatar_file' ); if( $avatar ) { $avatar = explode('|', $avatar ); $bburl = $opshuns['bburl']; echo '' . $bbposter->user_login . ' avatar'; } } function bbreplytext() { global $bbreply; echo $bbreply->post_text; } function bbreplylink( $topic_id = 0 ) { global $id; $opshuns = get_option('bbsync'); if( !$topic_id ) $topic_id = felwptobb( $id ); if( $topic_id ) { return felforumtopiclink( $topic_id ); } return false; } function felforumtopiclink( $topic_id ) { $opshuns = get_option('bbsync'); if( $opshuns['bbAPI'] ) { load_bb(); $topic = get_topic( $topic_id ); $last_page = get_page_number( $topic->topic_posts + topic_pages_add( $topic->topic_id ) ); $replylink = attribute_escape( get_topic_link( $topic->topic_id, $last_page ) . '#postform' ); } else { $replylink = $opshuns['bburl'] . '/topic.php?id=' . $topic_id . '#postform'; } return $replylink; } function bbrepliestext( $texties = 'Talk about this! %no% %replies%' ) { global $id; $opshuns = get_option('bbsync'); load_bb(); $topic_id = felwptobb( $id ); if( $topic_id ) { $topic = get_topic( $topic_id ); $posties = $topic->topic_posts; $repliesword = 'replies'; if( $posties == 1 ) $repliesword = 'reply'; $arrrsearches = array('%no%', '%replies%'); $arrrreplaces = array($topic->topic_posts, $repliesword ); $linktext = str_replace($arrrsearches, $arrrreplaces, $texties ); $linkurl = felforumtopiclink( $topic_id ); $linktext = "\n\n$linktext"; } } function bbfancypostform() { $opshuns = get_option('bbsync'); if( $opshuns['bbAPI'] ) { load_bb(); ?>
    $h2) ); ?>