$id)); } function za_pp_check_post_id($id) { if(!is_numeric($id)) { nocache_headers(); bb_safe_redirect(bb_get_option('uri')); exit; } return true; } function za_pp_get_post() { if(bb_get_option('mod_rewrite')) { $s = $_SERVER['REQUEST_URI']; $pos = strpos($s, 'post/'); if($pos !== false) { $num = substr($s, $pos + 5); if($num !== false && za_pp_check_post_id($num)) return (int)$num; } } if(isset($_GET['post']) && za_pp_check_post_id($_GET['post'])) return (int)$_GET['post']; return false; } function za_pp_initialize() { global $bb_current_user; bb_load_plugin_textdomain(ZA_PP_ID, dirname(__FILE__) . '/languages'); $id = za_pp_get_post(); if($id !== false) { $post = bb_get_post(get_post_id($id)); if(!$post) bb_die(__("The post you have specified doesn't exists", ZA_PP_ID)); elseif($post->post_status == 1) bb_die(__("The post you have specified has been canceled", ZA_PP_ID)); else { $page = bb_get_page_number($bb_post->post_position); $link = apply_filters('get_post_link', get_topic_link($post->topic_id, $page) . "#post-$post->post_id", $post->post_id); wp_redirect($link); exit; } } } add_action('bb_init', 'za_pp_initialize'); ?>