It needs your config! Use the template tags to show comments under the wordpress post. :) Version: λ Author: fel64 Author URI: http://www.loinhead.net/ */ add_action('publish_post', 'felsyncpost', 999 ); add_action('comment_post', 'felsynccomment', 999 ); 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 felsyncpost( $post_id ) { global $bbdb, $wpdb, $current_user, $pages; $post = wp_get_single_post( $post_id ); if( !empty( $post->post_password ) ) return; $opshuns = get_option('bbsync'); require_once( $opshuns['bbpath'] ); //bb-load //get_currentuserinfo(); /* test if necessary! */ if( !$current_user ) return; bb_set_current_user( $current_user->ID ); $post_title = $bbdb->escape( $post->post_title ); $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'] ) ) { $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 ) ); 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 ) { feltopicmetalink( $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, $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( $post_text, $reply->post_id, $topic_id ); } } function feltopicmetalink( $post_id, $topic_id ) { global $bbdb; $opshuns = get_option('bbsync'); require_once( $opshuns['bbpath'] ); //bb-load if( !felwptobb( $post_id ) ) { $bbdb->query(" INSERT INTO $bbdb->topicmeta (topic_id, meta_key, meta_value) VALUES ( $topic_id, 'wp_post', $post_id ) "); return true; } return false; } function felwptobb( $post_id ) { global $wpdb, $opshuns; $opshuns = get_option('bbsync'); $bb_topicmeta = $opshuns['bb_'] . 'topicmeta'; $topic_id = $wpdb->get_var(" SELECT topic_id FROM $bb_topicmeta WHERE meta_key = 'wp_post' AND meta_value = $post_id "); if( $topic_id ) return $topic_id; else return false; } function felgetbbreplies() { global $wpdb, $post, $opshuns; $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'); require_once( $opshuns['bbpath'] ); $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( !feltopicmetalink( $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() { //transfer olden blog posts into topics and comments into replies to said topic } /* 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")) { global $opshuns; $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!

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; $opshuns = get_option('bbsync'); //require_once( $opshuns['bbpath'] ); $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; $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; if( !$opshuns ) $opshuns = get_option('bbsync'); if( !$topic_id ) $topic_id = felwptobb( $id ); if( $topic_id ) { return felforumtopiclink( $topic_id ); } return false; } function felforumtopiclink( $topic_id ) { global $opshuns; if( !$opshuns ) $opshuns = get_option('bbsync'); if( $opshuns['bbAPI'] ) { require_once( $opshuns['bbpath'] ); $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; if( !$opshuns ) $opshuns = get_option('bbsync'); require_once( $opshuns['bbpath'] ); $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() { global $opshuns; if( !$opshuns ) $opshuns = get_option('bbsync'); if( $opshuns['bbAPI'] ) { require_once $opshuns['bbpath']; ?>
    $h2) ); ?>