I am ussing bbPress and want to extend the BBP_Shortcodes class in order to replace a function with my own.
Here is my basic snippet which seems to do nothing:
class WPTUMBLE_Shortcodes extends BBP_Shortcodes { /** * Display an index of all visible root level forums in an output buffer * and return to ensure that post/page contents are displayed first. * * @since bbPress (r3031) * * @param array $attr * @param string $content * @uses bbp_has_forums() * @uses get_template_part() * @return string */ public function display_forum_index() { echo 'Yo Adrian'; } } function wptumble_register_shortcodes() { global $bbp; // Bail if bbPress is not loaded if (is_a($bbp, 'bbPress')) return; $bbp->shortcodes = new WPTUMBLE_Shortcodes(); } add_action( 'bbp_init', 'wptumble_register_shortcodes', 25 );
Looking at the bbpress functions setup it says:
add_action( 'bbp_init', 'bbp_register_shortcodes', 18 );
What am I missing?
*I have tried every priority from hooking to init at priority 1, all the way through where I posted above, but none seem to do anything.
Even stranger: I basically paste that code into a plugin file I called xyz and I receive no errors, just nothing happens when I view what should be outputted. Meaning I get the original output for display_forum_index() instead of my new one.
Here is where it gets even worse: Instead of simply creating a plugin with that code in it, I place the code into my 'full' plugin.
I use the following:
include_once (WPTUMBLE_PLUGIN_DIR.'twentyeleven-bbpress-child/inc/tumble-core-shortcodes-single.php');
I then have the WPTUMBLE_Shortcodes class pasted into the file above. *Trying to keep things clean so separating my different functions into different files in my custom plugin
What happens is when I do that I end up with a fatal error saying BBP_Shortcodes is not defined.
The ONLY difference is I am putting the code into a file that is include_once..
What in the world could be going on there?
Either I get nothing happening when it's a single plugin file, or I get fatal error if I include_once and place the code in another file.
Soooo confused now.