bp_nouveau_customizer_group_nav.

一个特定的Group NAV类,可以为BuddyPress() - >组 - >导航设置新的位置。

描述

来源

文件:bp-templates / bp-nouveau /包括/ groups / classes.php

bp_nouveau_customizer_group_nav extends bp_core_nav {/ ** *构造函数* * @param int $ object_id可选。用于生成NAV的随机组ID。* /公共功能_construct($ object_id = 0){$ error = new wp_error('simess_parameter');if(空($ object_id)||!bp_current_user_can('bp_moderate')||!did_action('admin_init')){return $错误;$ group = groups_get_group(array('group_id'=> $ object_id)));if(空($ group-> ID)){返回$错误;$以下 - > group = $ group;父母:: __构造($组 - > ID);$ this-> setup_nav();} / ** *检查是否设置了属性。 * * Overrides BP_Core_Nav::__isset() to avoid looking into its nav property. * * @since BuddyPress 3.0.0 * * @param string $key The property. * * @return bool True if the property is set, false otherwise. */ public function __isset( $key ) { return isset( $this->{$key} ); } /** * Gets a property. * * Overrides BP_Core_Nav::__isset() to avoid looking into its nav property. * * @since BuddyPress 3.0.0 * * @param string $key The property. * * @return mixed The value corresponding to the property. */ public function __get( $key ) { if ( ! isset( $this->{$key} ) ) { $this->{$key} = null; } return $this->{$key}; } /** * Sets a property. * * Overrides BP_Core_Nav::__isset() to avoid adding a value to its nav property. * * @since BuddyPress 3.0.0 * * @param string $key The property. * * @param mixed $value The value of the property. */ public function __set( $key, $value ) { $this->{$key} = $value; } /** * Setup a temporary nav with only the needed parameters. * * @since BuddyPress 3.0.0 */ protected function setup_nav() { $nav_items = array( 'root' => array( 'name' => __( 'My Groups', 'buddyboss' ), 'slug' => $this->group->slug, 'position' => -1, /** This filter is documented in bp-groups/classes/class-bp-groups-component.php. */ 'default_subnav_slug' => apply_filters( 'bp_groups_default_extension', defined( 'BP_GROUPS_DEFAULT_EXTENSION' ) ? BP_GROUPS_DEFAULT_EXTENSION : 'home' ), ), 'members' => array( 'name' => __( 'Members', 'buddyboss' ), 'slug' => 'members', 'parent_slug' => $this->group->slug, 'position' => 10, ), 'invites' => array( 'name' => __( 'Send Invites', 'buddyboss' ), 'slug' => 'send-invites', 'parent_slug' => $this->group->slug, 'position' => 70, ), 'manage' => array( 'name' => __( 'Manage', 'buddyboss' ), 'slug' => 'admin', 'parent_slug' => $this->group->slug, 'position' => 1000, ), ); if ( bp_is_active( 'forums' ) && function_exists( 'bbp_is_group_forums_active' ) ) { if ( bbp_is_group_forums_active() ) { $nav_items['forum'] = array( 'name' => __( 'Discussions', 'buddyboss' ), 'slug' => get_option( '_bbp_forum_slug', 'forum' ), 'parent_slug' => $this->group->slug, 'position' => 30, ); } } if ( bp_enable_group_hierarchies() ) { $nav_items['subgroups'] = array( 'name' => __( 'Subgroups', 'buddyboss' ), 'slug' => 'subgroups', 'parent_slug' => $this->group->slug, 'position' => 30, ); } if ( function_exists( 'bp_ld_sync' ) ) { $va = bp_ld_sync( 'settings' )->get( 'buddypress.enabled', true ); if ( '1' === $va ) { $nav_items['courses'] = array( 'name' => __( 'Courses', 'buddyboss' ), 'slug' => 'courses', 'parent_slug' => $this->group->slug, 'position' => 40, ); } } if ( function_exists( 'bp_ld_sync' ) ) { $va = bp_ld_sync( 'settings' )->get( 'reports.enabled', true ); if ( '1' === $va ) { $nav_items['reports'] = array( 'name' => __( 'Reports', 'buddyboss' ), 'slug' => 'reports', 'parent_slug' => $this->group->slug, 'position' => 40, ); } } if ( bp_is_active( 'activity' ) ) { $nav_items['activity'] = array( 'name' => __( 'Feed', 'buddyboss' ), 'slug' => 'activity', 'parent_slug' => $this->group->slug, 'position' => 20, ); } // Required params $required_params = array( 'slug' => true, 'name' => true, 'nav_item_position' => true, ); // Now find nav items plugins are creating within their Group extensions! foreach ( get_declared_classes() as $class ) { if ( is_subclass_of( $class, 'BP_Group_Extension' ) ) { $extension = new $class; if ( ! empty( $extension->params ) && ! array_diff_key( $required_params, $extension->params ) ) { $nav_items[ $extension->params['slug'] ] = array( 'name' => $extension->params['name'], 'slug' => $extension->params['slug'], 'parent_slug' => $this->group->slug, 'position' => $extension->params['nav_item_position'], ); } } } // Now we got all, create the temporary nav. foreach ( $nav_items as $nav_item ) { $this->add_nav( $nav_item ); } } /** * Front template: do not look into group's template hierarchy. * * @since BuddyPress 3.0.0 * * @param array $templates The list of possible group front templates. * * @return array The list of "global" group front templates. */ public function all_groups_fronts( $templates = array() ) { return array_intersect( array( 'groups/single/front.php', 'groups/single/default-front.php', ), $templates ); } /** * Get the original order for the group navigation. * * @since BuddyPress 3.0.0 * * @return array a list of nav items slugs ordered. */ public function get_default_value() { $default_nav = $this->get_secondary( array( 'parent_slug' => $this->group->slug ) ); return wp_list_pluck( $default_nav, 'slug' ); } /** * Get the list of nav items ordered according to the Site owner preferences. * * @since BuddyPress 3.0.0 * * @return array the nav items ordered. */ public function get_group_nav() { // Eventually reset the order bp_nouveau_set_nav_item_order( $this, bp_nouveau_get_appearance_settings( 'group_nav_order' ), $this->group->slug ); return $this->get_secondary( array( 'parent_slug' => $this->group->slug ) ); } }

变更乐

变更乐
版本 描述
Buddypress 3.0.0. 介绍。

方法

问题?

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