BP_Integration

API来创建BuddyBoss集成。

描述

文件:bp-core /类/ class-bp-integration.php

类BP_Integration{/** *集成的可翻译名称。* * @internal */ public $name = ";/** *集成的唯一ID。* * @since BuddyBoss 1.0.0 */ public $id = ";/** *用于集成的唯一的slug,用于查询字符串和url。* * @since BuddyBoss 1.0.0 */ public $slug = ";/** *集成文件的路径。* * @since BuddyBoss 1.0.0 */ public $path = ";public function start($id = ", $name = ", $path = ", $params = array()){//集成的内部标识符。$ this - > id = $ id; // Internal integration name. $this->name = $name; // Path for includes. $this->path = trailingslashit( buddypress()->integration_dir ) . $path; $this->url = trailingslashit( buddypress()->integration_url ) . $path; if ( $params ) { if ( isset( $params['required_plugin'] ) ) { $this->required_plugin = $params['required_plugin']; } } $this->setup_actions(); } public function setup_actions() { add_action( 'bp_register_admin_integrations', array( $this, 'setup_admin_integration_tab' ) ); if ( $this->is_activated() ) { $this->activation(); add_action( 'bp_include', array( $this, 'includes' ), 8 ); add_action( 'bp_late_include', array( $this, 'late_includes' ) ); } } public function is_activated() { if ( ! $this->required_plugin ) { return false; } $plugins = get_option( 'active_plugins' ) ?: []; if ( in_array( $this->required_plugin, $plugins ) ) { return true; } if ( ! is_multisite() ) { return false; } $plugins = get_site_option( 'active_sitewide_plugins' ) ?: []; return isset( $plugins[$this->required_plugin] ); } public function activation() { // place to put default value } public function setup_admin_integration_tab() { if ( $this->admin_tab ) { require_once trailingslashit( $this->path ) . $this->admin_tab; } } public function includes( $includes = array() ) { if ( empty( $includes ) ) { return; } $slashed_path = trailingslashit( $this->path ); // Loop through files to be included. foreach ( (array) $includes as $file ) { $paths = array( // Passed with no extension. 'bp-' . $this->id . '/bp-' . $this->id . '-' . $file . '.php', 'bp-' . $this->id . '-' . $file . '.php', 'bp-' . $this->id . '/' . $file . '.php', // Passed with extension. $file, 'bp-' . $this->id . '-' . $file, 'bp-' . $this->id . '/' . $file, ); foreach ( $paths as $path ) { if ( @is_file( $slashed_path . $path ) ) { require( $slashed_path . $path ); break; } } } } public function late_includes() {} }

更新日志

更新日志
版本 描述
BuddyBoss 1.0.0 介绍了。

方法

问题吗?

我们总是很乐意帮助您解决代码或其他问题!搜索我们的开发人员文档联络支持,或与我们联系销售团队