最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugin development - Buddypress function and global $bp question

programmeradmin5浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论