Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: bbsync broken – plugin like it? BB 1.0


Benzilla069
Member

@benzilla069

Yeah I’m currently just messing about with it at the moment, I’ve stripped it down to what I believe are the bare essentials… please note I don’t have any PHP experience but I do have other languages like C under my belt so I’m getting the hang of it ok.

<?php
/*
Plugin Name: WordPress to BBPost hacked by Ben
*/

add_action('publish_post', 'bensyncpost', 999 );

/* 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,
$del_class, $bb_alt;
}

function bensyncpost( $post_id ) {
global $bbdb, $wpdb, $current_user;

$post = wp_get_single_post( $post_id );

if( !load_bb() )
return false;

bb_set_current_user( $current_user->ID );

$post_title = $bbdb->escape( $post->post_title );
$post_text = benprepposttext( $post->post_content, get_post_meta( $post_id ) );

if( !$link_exists ) {
bennewtopic( $post_id, $post_title, $post_text );
}
}

function bennewtopic( $post_id, $post_title, $post_text ) {

$topic_id = bb_new_topic( $post_title, 2, $tags );
$reply_id = bb_new_post( $topic_id, $post_text );

/* if( $topic_id && $reply_id ) {
felmetalink( $post_id, $topic_id );
$r = true;
}*/

return $r;
}

function benprepposttext( $post_text) {

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', 'allow_images_encode_bad', 9 );
remove_filter('pre_post', 'allow_images', 52 );

return $post_text;
}

?>

I got rid of the error, but it’s not propogating to the correct forum(I used the forum ID of 2 and I also tried just plain old “Site Posts” as the forum) need to debug some more, fel do you recognise anything plainly wrong with my hacked up code?

Skip to toolbar