1

I have a question regarding Buddypress tweak.

I can use any Buddypress function when I make a plugin without any include or require functions.

How is it possible? Because Buddypress loads faster than my plugin?

In addition, What does global $bp mean? Withou this global $bp, I can use any buddypress functions, so why does it need?

I'm newbie to development. Thank you :)

1

Plugins load alphabetically by default. If Buddypress is alphbetically before your plugins folder name, then Buddypress will load first and it's functions will be available. Additionally, whatever functionality depends on another plugins you can always attach to the plugins_loaded hook, which fires after all plugins are finished loading. For example:

/**
 * Runs code after plugins have finished loading
 *
 * @return void
 */
function prefix_plugins_loaded() {

    die( 'Plugins have finished loading.' );

}
add_action( 'plugins_loaded', 'prefix_plugins_loaded' );

PHP Globals are common in Plugins and WordPress. The $bp global is simply a variable that likely holds a required object needed by the specific plugin function.

1
  • Thank you for your reply! It helps a lot! :)
    – hiyo
    Apr 14 '20 at 5:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.