15 , 'forum-page' => 20 , // stickies are added to these numbers, not included, because of bbPress design 'topic-page' => 10 , // this is actually number of posts on a topic page 'view-page' => 20 , 'tag-page' => 20 , 'search-page' => 20 , 'feed-page' => 10 , // some versions of bbPress do not obey feed limits, sorry 'profile-page' => 10 , 'favorites-page' => 10 , 'stats-page' => 10 ); /* stop editing here */ add_filter( 'bb_get_option_page_topics', 'topics_per_page',200); add_filter( 'get_post_link','topics_per_page_fix_link',10, 2); add_filter( 'get_topic_page_links_per_page', 'topics_per_page_fix_topic_links'); add_filter( 'bb_get_option_front_page_topics', 'front_page_topics_fetch'); // backward-compatibility fix for old front page topic plugin add_filter('get_latest_topics_limit','front_page_pagination',999); function front_page_topics_fetch($limit) {global $topics_per_page; return $topics_per_page;} function topics_per_page($limit) { // set custom topics per page limits global $topics_per_page, $topics_per_page_fix_link, $topics, $topic, $topic_id; if ($topics_per_page_fix_link) {$location="topic-page";} else {$location=topics_per_page_location();} if (isset($topics_per_page[$location])) {return $topics_per_page[$location];} return $limit; } function topics_per_page_fix_topic_links($limit) { // er, thanks Sam, I think - 1.0a2 fix global $topics_per_page; return isset($topics_per_page['topic-page']) ? $topics_per_page['topic-page'] : $limit; } function topics_per_page_fix_link($link,$post_id) { // required to calculate correct post/page jumps into topic pages global $topic, $bb_topic_cache, $wp_object_cache, $topics_per_page_fix_link; $topic_id=0; $topics_per_page_fix_link=true; if ($topic && $topic->topic_last_post_id==$post_id) { $topic_id=$topic->topic_id; $page=get_page_number( $topic->topic_posts ); } elseif ( isset( $bb_topic_cache ) || isset($wp_object_cache->cache['bb_topic']) ) { if (!isset( $bb_topic_cache)) {$cache=& $wp_object_cache->cache['bb_topic'];} // 1.0 compatibility workaround else {$cache=& $bb_topic_cache;} foreach ($cache as $test) { if ($test->topic_last_post_id==$post_id) {$topic_id=$test->topic_id; $page=get_page_number( $test->topic_posts ); break;} } } if (!$topic_id) { // all other cache lookup attempts have failed, do a manual lookup $bb_post = bb_get_post( get_post_id( $post_id ) ); $topic_id=$bb_post->topic_id; $page = get_page_number( $bb_post->post_position ); } $topic_link=get_topic_link( $topic_id, $page )."#post-$post_id"; $topics_per_page_fix_link=false; return $topic_link; } function front_page_pagination($limit="") { global $page; if (!defined('BACKPRESS_PATH') && is_front() && $page>1) {$limit.=" OFFSET ".($page-1)*bb_get_option('page_topics');} return $limit; } function front_page_pages() { global $page, $bbdb, $forums; $total=0; if (empty($forums)) {$forums=get_forums();} foreach ($forums as $forum) {$total+=$forum->topics;} $last=substr($_SERVER['REQUEST_URI'],-1,1); if ($last=="?" || $last=="&") {$_SERVER['REQUEST_URI']=substr($_SERVER['REQUEST_URI'],0,-1);} if ( bb_get_option( 'mod_rewrite' ) ) { $base=rtrim(bb_get_option('uri'),'/ ').'%_%'; $format='/page/%#%'; $total=ceil($total/bb_get_option('page_topics')); echo apply_filters( 'topic_pages', paginate_links( array( 'base' => $base, 'format' =>$format, 'total' =>$total, 'current' =>$page, 'add_args' => false )), 0);; } else { echo apply_filters( 'topic_pages', get_page_number_links( $page, $total),0); } } function topics_per_page_location() { $file=bb_get_location(); if (empty($file)) { $file = ''; foreach ( array($_SERVER['PHP_SELF'], $_SERVER['SCRIPT_FILENAME'], $_SERVER['SCRIPT_NAME']) as $name ) {if ( false !== strpos($name, '.php') ) {$file = $name;}} $file=bb_find_filename( $file ); } if ($file=="delete-post.php") {$file="topic-page";} return $file; } ?>