admin管理员组

文章数量:1387449

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 :)

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 :)

Share Improve this question asked Apr 14, 2020 at 1:40 hiyohiyo 356 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 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.

本文标签: plugin developmentBuddypress function and global bp question