How to extend a class in WordPress?

I can’t tell you what you’re doing wrong with your includes and such, but your method of extending the class is basically correct.

However, the most likely scenario that I can see is that your add_action is basically executing in the wrong place. Also, you’re doing-it-wrong by allowing the original action to stand instead of replacing it.

Try this:

add_action('bbp_plugins_loaded','wptumble_actions_modification');
function wptumble_actions_modification() {
  remove_action('bbp_init', 'bbp_register_shortcodes', 18);
  add_action('bbp_init', 'wptumble_register_shortcodes', 18);
}

This removes the original action and replaces it with your own, and it does it at the plugins loaded hook, ensuring that it happens after both your plugin and the bbPress plugin is loaded, and presumably all the action hooks for bbPress were in place, but not yet executed (since init hasn’t been reached).

Leave a Comment