BP__组件
创建一个组件。
描述
来源
文件:bp-invites /类/ class-bp-invites-component.php
类BP\U组件扩展了BP\U组件{/***默认邀请扩展名。**@自BuddyBoss 1.0.0*@todo是否在任何地方使用?这是$Default_扩展名的副本吗?*@var string*/var$Default_component;/***默认邀请扩展名。**@自BuddyBoss 1.0.0*@var string*/public$Default_扩展名;/***自BuddyBoss 1.0.0*@varray*/public$forbidden_names;/***启动邀请组件创建过程。**@自BuddyBoss 1.0*/public function__construct(){parent::Start('invests',uuuu('Sent invests','BuddyBoss'),buddypress()->插件目录,数组('adminbar_myaccount_order'=>100,'search\u query\u arg'=>'invests\u search',)}/***Include invests component files.*@since BuddyBoss 1.0.0**@有关参数的说明,请参阅BP_component::includes()。*@param array$includes有关说明,请参阅BP_component::includes()。*/public function includes($includes=array()){$includes=array('filters','template','functions',;//条件包含。如果(bp_is_active('activity'){$includes[]='activity';}if(is_admin(){$includes[]='admin';})parent::includes($includes)}/***Late includes方法。**仅在特定页面上加载某些代码。**@因为BuddyBoss 1.0.0*/公共函数Late_includes{//{return;}//Bail if not on Settings component.if(!bp_is_invests_component()){return;}$actions=array('invests','send invests','send invests');//已验证的操作。if(is_user_logged_in()){if(!bp_current_action()| bp_is_current_action('invests')){require$this->path。'bp invests/actions/invests.php';//特定于post请求。}elseif(bp_is_post_request()&&in_数组(bp_current_action(),$actions,true)){require$this->path。'bp invests/actions/'.bp_current_action()。.php'}如果(是用户登录的()&&in_数组(bp_current_action(),数组('revoke invite'),true)){require$this->path。'bp invests/actions/'.bp_current_action()..php'}if(is_user_logged_in()&&in_array(bp_current_action(),array('revoke invite admin'),true)){require$this->path。'bp invests/actions/'.bp_current_action()..php'}屏幕-用户配置文件集成。if(bp_is_is_user()){require$this->path。'bp invests/screens/send invests.php';//子导航项.if(在_数组(bp_current_action(),$actions,true)中){require$this->path。'bp invests/screens/'.bp_current_action()。.php'}/***设置组件全局数据。**不推荐使用BP_invests_SLUG常量,此处仅用于*向后兼容性。**@因为BuddyBoss 1.0.0**@有关参数的说明,请参见BP_组件::setup_globals()。*@param array$args有关说明,请参见BP_组件::setup_globals()。*/public function setup_globals($args=array()){$bp=buddypress();//如果需要,请定义一个slug。如果(!defined('bp\u invests\u slug')){Define('bp\u invests\u slug',$this->id);//invests组件的所有全局变量。//请注意,此数组中包含全局表。$args=array('slug'=>bp\u invests\u slug',root\u slug'=>isset($bp->pages invests->slug)?$bp->pages->invites->slug:bp\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\为该组件设置规范堆栈。**自BuddyBoss 1.0.0.0.0*/公共函数设置\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\{return;}/***设置组件导航。**@自BuddyBoss 1.0.0以来**@有关参数的说明,请参见BP_组件::setup_nav()。*@param数组$main_nav可选。有关说明,请参见BP_组件::setup_nav()。*@param数组$sub_nav可选。有关说明,请参见BP_组件::setup_nav()。*/public function setup_nav($main_nav=array(),$sub_nav=array()){if(is_user_logged_in()){//确定要使用的用户。if(bp_displated_user_domain()){$user_domain=bp_displated_user_domain();}elseif(bp_loggedin user_domain()){$user_domain=bp_loggedin user_domain()}否则{$user_domain=false;}$navu name='Email_u}$slug=bp_get_invests_slug();if(!empty($user_domain)){$access=bp_core_can_edit_settings();$invests_link=trailingslashit($user_domain.$slug);if($access){if(true==bp_allow_user_to_发送邀请()){//将“发送邀请”添加到主导航。$main_nav=array('name'=>$nav\u name,'slug'=>$slug,'position'=>90,'screen\u function'=>'bp\u invests\u screen\u send\u invite','default\u subnav\u slug'=>'send invests','user\u拥有访问权'=>$access',item\u css\u id'=>$this->id,);//通过电子邮件添加邀请导航项。$sub nav[]=数组('name'=>('send invests','buddyboss'),'slug'=>'send invests','parent\u url'=>$invests\u link','parent\u slug'=>$slug',screen\u function'=>'bp\u invites_screen_send_invite', 'user_has_access' => $access, 'position' => 10, 'item_css_id' => 'invites-send-invite' ); // Add the Sent Invites nav item. $sub_nav[] = array( 'name' => __( 'Sent Invites', 'buddyboss' ), 'slug' => 'sent-invites', 'parent_url' => $invites_link, 'parent_slug' => $slug, 'screen_function' => 'bp_invites_screen_sent_invite', 'user_has_access' => $access, 'position' => 30, 'item_css_id' => 'invites-sent-invites' ); } } parent::setup_nav( $main_nav, $sub_nav ); } } } /** * Set up the component entries in the WordPress Admin Bar. * * @since BuddyBoss 1.0.0 * * @see BP_Component::setup_nav() for a description of the $wp_admin_nav * parameter array. * * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a description. */ public function setup_admin_bar( $wp_admin_nav = array() ) { // Menus for logged in user. if ( is_user_logged_in() ) { if ( true === bp_allow_user_to_send_invites() ) { // Setup the logged in user variables. $invites_link = trailingslashit( bp_loggedin_user_domain() . bp_get_invites_slug() ); $title = __( 'Email Invites', 'buddyboss' ); // Add the "My Account" sub menus. $wp_admin_nav[] = array( 'parent' => buddypress()->my_account_menu_id, 'id' => 'my-account-' . $this->id, 'title' => $title, 'href' => $invites_link ); // Invite by Email $wp_admin_nav[] = array( 'parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-invites', 'title' => __( 'Send Invites', 'buddyboss' ), 'href' => $invites_link, 'position' => 10 ); // Sent Invites $wp_admin_nav[] = array( 'parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-sent', 'title' => __( 'Sent Invites', 'buddyboss' ), 'href' => $invites_link . 'sent-invites', 'position' => 20 ); } } parent::setup_admin_bar( $wp_admin_nav ); } /** * Set up the title for pages and. * * @since BuddyBoss 1.0.0 */ public function setup_title() { if ( bp_is_invites_component() ) { $bp = buddypress(); } parent::setup_title(); } public function register_post_types() { // Register invite custom post type. register_post_type( bp_get_invite_post_type(), apply_filters( 'bp_invite_post_type', array( 'description' => __( 'BuddyBoss Invites', 'buddyboss' ), 'labels' => bp_get_invite_post_type_labels(), 'public' => false, 'publicly_queryable' => bp_current_user_can( 'bp_moderate' ), 'query_var' => false, 'rewrite' => false, 'show_in_admin_bar' => false, 'show_in_menu' => false, 'map_meta_cap' => true, 'menu_icon' => 'dashicons-email', //'menu_position' => 27, 'show_in_rest' => true, 'capabilities' => array( 'create_posts' => 'do_not_allow', // false < WP 4.5, credit @Ewout ), 'show_ui' => bp_current_user_can( 'bp_moderate' ), 'supports' => bp_get_invite_post_type_supports(), ) ) ); parent::register_post_types(); } }
变更日志
版本 | 描述 |
---|---|
BuddyBoss 1.0.0 | 介绍。 |
方法
- __construct—启动邀请组件创建过程。
- 包括-包括组件文件。
- 迟交的费用包括-后期包括方法。
- 注册\发布\类型
- rest\u api\u init-初始化BuddybossRESTAPI。
- setup_admin_bar-在WordPress管理栏中设置组件条目。
- 设置\u规范\u堆栈-为此组件设置规范堆栈。
- 全球设置-设置组件全局数据。
- setup_nav-设置组件导航。
- setup_title-设置页面和的标题。