BP_REST_Group_Settings_Endpoint:: get_forum_fields (整数group_id美元)
获得群组论坛设置。
描述
参数
- group_id美元
-
(整数)(必需)组ID。
返回
(混合|空白)
源
文件:bp-groups /类/ class-bp-rest-group-settings-endpoint.php
get_forum_fields($group_id) {$fields = array();Buddypress ()->groups->current_group = group_get_group ($group_id);如果(!Bp_is_active('论坛')|| !Function_exists ('bbp_is_group_forums_active') || !bbp_is_group_forums_active()) {return new WP_Error('bp_rest_invalid_group_setting_nav', __('对不起,您不允许看到论坛组设置选项。', 'buddyboss'), array('status' => 400,));} $forum_id = 0;$forum_ids = bbp_get_group_forum_ids($group_id);//获取第一个论坛ID。如果(! empty( $forum_ids ) ) { $forum_id = (int) is_array( $forum_ids ) ? $forum_ids[0] : $forum_ids; } $checked = bp_get_new_group_enable_forum() || bp_group_is_forum_enabled( $group_id ); $fields[] = array( 'label' => esc_html__( 'Group Forum Settings', 'buddyboss' ), 'name' => '', 'description' => esc_html__( 'Create a discussion forum to allow members of this group to communicate in a structured, bulletin-board style fashion.', 'buddyboss' ), 'field' => 'heading', 'value' => '', 'options' => array(), ); $fields[] = array( 'label' => esc_html__( 'Yes. I want this group to have a discussion forum.', 'buddyboss' ), 'name' => 'bbp-edit-group-forum', 'description' => esc_html__( 'Saying no will not delete existing forum content.', 'buddyboss' ), 'field' => 'checkbox', 'value' => $checked, 'options' => array(), ); if ( bbp_is_user_keymaster() ) { $forum_field = array( 'label' => esc_html__( 'Group Forum:', 'buddyboss' ), 'name' => 'bbp_group_forum_id', 'description' => esc_html__( 'Only site administrators can reconfigure which forum belongs to this group.', 'buddyboss' ), 'field' => 'select', 'value' => $forum_id, 'options' => array(), ); $forums = get_posts( array( 'post_type' => 'forum', 'numberposts' => -1, 'orderby' => 'menu_order title', 'order' => 'ASC', 'disable_categories' => true, ) ); if ( ! empty( $forums ) ) { $forum_field['options'][] = array( 'label' => esc_html__( '(No Forum)', 'buddyboss' ), 'value' => '', 'description' => '', 'is_default_option' => empty( $forum_id ), ); foreach ( $forums as $forum ) { $title = $forum->post_title; if ( '' === $title ) { /* translators: %d: ID of a post. */ $title = sprintf( __( '#%d (no title)', 'buddyboss' ), $forum->ID ); } $forum_field['options'][] = array( 'label' => $title, 'value' => $forum->ID, 'description' => '', 'is_default_option' => $forum_id === $forum->ID, ); } } $fields[] = $forum_field; } return apply_filters( 'bp_rest_group_settings_forum', $fields, $group_id ); }