Permalink
Browse files

Use our own method names to wrap bbPress methods to avoid conflict on…

… bbPress activation.
  • Loading branch information...
1 parent a51d020 commit ebe362d668d2c69b64a295797f94005e03b46024 @kdeldycke committed May 6, 2011
Showing with 17 additions and 13 deletions.
  1. +17 −13 e107-redirector.php
View
@@ -16,11 +16,6 @@
define('OPTION_PREFIX' , 'e107_redirector_');
-// Redefine some bbPress methods to avoid PHP errors if bbPress is not installed or activated
-if (!function_exists('bbp_get_forum_post_type')) { function bbp_get_forum_post_type() { return 'forum';}}
-if (!function_exists('bbp_get_topic_post_type')) { function bbp_get_topic_post_type() { return 'topic';}}
-if (!function_exists('bbp_get_reply_post_type')) { function bbp_get_reply_post_type() { return 'reply';}}
-
class e107_Redirector {
@@ -56,18 +51,27 @@ function normalize_urlpath($urlpath) {
}
+ // Wrap some bbPress methods to avoid PHP errors if bbPress is not installed or activated
+ function e107_get_forum_post_type() { return function_exists('bbp_get_forum_post_type') ? bbp_get_forum_post_type() : 'forum';}
+ function e107_get_topic_post_type() { return function_exists('bbp_get_topic_post_type') ? bbp_get_topic_post_type() : 'topic';}
+ function e107_get_reply_post_type() { return function_exists('bbp_get_reply_post_type') ? bbp_get_reply_post_type() : 'reply';}
+
+
// Load pre-existing mappings and clean them
function load_mappings() {
// Here is the list of mappings and the type of WordPress content they can point to
$mapping_list = array(
- array('name' => 'user' , 'types' => array('user') )
- , array('name' => 'news' , 'types' => array('post') )
- , array('name' => 'category' , 'types' => array('category') )
- , array('name' => 'page' , 'types' => array('page') )
- , array('name' => 'comment' , 'types' => array('comment') )
- , array('name' => 'forum' , 'types' => array(bbp_get_forum_post_type()) )
- , array('name' => 'forum_post', 'types' => array(bbp_get_reply_post_type(), bbp_get_topic_post_type()))
- , array('name' => 'image' , 'types' => array('attachment') )
+ array('name' => 'user' , 'types' => array('user'))
+ , array('name' => 'news' , 'types' => array('post'))
+ , array('name' => 'category' , 'types' => array('category'))
+ , array('name' => 'page' , 'types' => array('page'))
+ , array('name' => 'comment' , 'types' => array('comment'))
+ , array('name' => 'forum' , 'types' => array( e107_Redirector::e107_get_forum_post_type()
+ ))
+ , array('name' => 'forum_post', 'types' => array( e107_Redirector::e107_get_reply_post_type()
+ , e107_Redirector::e107_get_topic_post_type()
+ ))
+ , array('name' => 'image' , 'types' => array('attachment'))
);
// List of content types that are not based on posts

0 comments on commit ebe362d

Please sign in to comment.