bp_groups_admin_load ()
设置群组管理页面。
描述
这个函数在呈现页面之前加载,完成所有初始设置,包括:处理表单请求、注册上下文帮助和设置屏幕选项。
源
文件:bp-groups / bp-groups-admin.php
函数bp_groups_admin_load(){global$bp_groups_list_table;//构建重定向URL。$redirect_to=remove_query_arg(数组('action'、'action2'、'gid'、'deleted'、'error'、'updated'、'success_new'、'error_new'、'success_modified'、$_modified'、$SERVER['REQUEST_URI']);$doaction=bp_admin_list_table_table_current_action($min=bp_core_get_minified_asset_suffix();/***在组管理页面顶部激发。**@自BuddyPress 1.7.0以来**@param string$doaction当前$\u get操作正在管理屏幕中执行。*/do_操作('bp_groups_admin_load',$doaction)//编辑屏幕。如果('do_delete'=$doaction&&!empty($\u get['gid']){请检查\u admin\u referer('bp groups delete');$group_ids=wp_parse_id_list($_GET['gid']);$gf_ids=wp_parse_id_list($_GET['gfid']);//如果(!empty($gf_id)){foreach($gf_id作为$gf_id){$forum_id=bbp_获得组_论坛id($gf u id);foreach($forum_id作为$forum_id){forum_id($forum_id){wp_delete论坛后($forum_id,true=forum};foreach}($group_id as$group_id){if(groups_delete_group($group_id)){$count++}$redirect_to=add_query_arg('deleted',$count,$redirect_to);}elseif('edit'=$doaction&&!empty($GET['gid']){//列屏幕选项。添加屏幕选项('layout_列',数组('default'=>2,'max'=>2,);get_current_screen()->add_help_选项卡(数组('id'=>'bp group edit overview','title'=>。'content'=>','content'=>','p>。。uuuu('此页面是编辑与您的一个组关联的详细信息的便捷方式,'buddyboss')。。'__(“名称和说明框已固定到位,但您可以使用拖放重新定位所有其他框,并可以通过单击每个框的标题栏来最小化或展开它们。使用“屏幕选项”选项卡隐藏或取消隐藏,或为此屏幕选择一列或两列布局。”,“buddyboss”)。
);//帮助面板-侧栏链接。获取当前屏幕()->设置帮助侧栏(“”。“”。”//www.zdfhmy.com/resources/“>Documentation”,“buddyboss”)。
”;//为编辑屏幕注册元盒。添加元盒('submitdiv'__('Save','buddyboss'),'bp_groups_admin_edit_metabox_status',get_current_screen()->id','side','high');add_meta box('bp_group_settings','settings','buddyboss'),'bp_groups_admin_edit_metabox_settings_,get_current_screen()->id','side','core');add_meta box('bp_group_add members','buddyboss,',“bp组管理编辑元框添加新成员”,获取当前屏幕()->id,“正常”,“核心”);添加元框('bp组成员','Manage members','buddyboss'),'bp组管理编辑元框成员',获取当前屏幕()->id,“正常”,“核心”)//组类型元框。仅在组类型已注册的情况下添加。$Group_types=bp_groups_get_Group_types();if(!empty($Group_types)){添加元框('bp_groups_admin_Group_Type'、'Group Type'、'buddyboss')、'bp_groups_admin_edit_metabox_Group_Type'、get_CUP_CUP_CUP_CUP_CU_CU_CU_CU_CU_CU_Group_SCREE){add_meta_box('bp_groups_admin_group_parent','bp_('group parent','buddyboss'),'bp_groups_admin_edit_metabox_group_parent',get_current_screen()->id,'side',core');/***在注册所有默认组元框后激发。**@自BuddyPress 1.7.0*/do_action('bp_groups_meta box'))//Enqueue JavaScript文件。wpEnqueue脚本('postbox');wpEnqueue脚本('dashboard');//索引屏幕。}其他{//创建组屏幕列表表格。$bp组列表表格=新的bp组列表表格();//每页屏幕选项。添加屏幕选项('per page',array('label'=>。'Groups','buddyboss'));//帮助面板-概述文本。获取当前屏幕()->添加帮助选项卡(数组('id'=>'bp groups overview','title'=>。\uu('overview','buddyboss'),'content'=>''__(“您可以像管理评论和其他内容一样管理组。此屏幕与其他管理屏幕一样可自定义,您可以使用悬停操作链接或批量操作对组进行操作。”,“buddyboss”)。
,);获取当前屏幕()->添加帮助选项卡(数组('id'=>'bp groups overview actions'、'title'=>.'('Group actions'、'buddyboss')、'content'=>'。。。。。。。。。。。。。。。。。。('单击“访问”将带您进入该群的公共页面。使用此链接可查看该群在您网站前端的外观。','buddyboss')。
。。。。。'将带您进入一个仪表板面板,您可以在其中管理组的各种详细信息,例如组的名称和说明、成员和其他设置。“,“buddyboss”)。
“,”。\uuu('如果您单击特定组下的“删除”,或选择多个组,然后从“批量操作”菜单中选择“删除”,您将看到page where you\'ll be asked to confirm the permanent deletion of the group(s).', 'buddyboss' ) . '
', ) ); // Help panel - sidebar links. get_current_screen()->set_help_sidebar( '' . __( 'For more information:', 'buddyboss' ) . '
' . '' . __( 'Documentation', 'buddyboss' ) . '
' ); // Add accessible hidden heading and text for Groups screen pagination. get_current_screen()->set_screen_reader_content( array( /* translators: accessibility text */ 'heading_pagination' => __( 'Groups list navigation', 'buddyboss' ), ) ); } $bp = buddypress(); // Enqueue CSS and JavaScript. wp_enqueue_script( 'bp_groups_admin_js', $bp->plugin_url . "bp-groups/admin/js/admin{$min}.js", array( 'jquery', 'wp-ajax-response', 'jquery-ui-autocomplete' ), bp_get_version(), true ); wp_localize_script( 'bp_groups_admin_js', 'BP_Group_Admin', array( 'add_member_placeholder' => __( 'Start typing a username to add a new member.', 'buddyboss' ), 'warn_on_leave' => __( 'If you leave this page, you will lose any unsaved changes you have made to the group.', 'buddyboss' ), ) ); wp_enqueue_style( 'bp_groups_admin_css', $bp->plugin_url . "bp-groups/admin/css/admin{$min}.css", array(), bp_get_version() ); wp_style_add_data( 'bp_groups_admin_css', 'rtl', true ); if ( $min ) { wp_style_add_data( 'bp_groups_admin_css', 'suffix', $min ); } if ( $doaction && 'save' == $doaction ) { // Get group ID. $group_id = isset( $_REQUEST['gid'] ) ? (int) $_REQUEST['gid'] : ''; $redirect_to = add_query_arg( array( 'gid' => (int) $group_id, 'action' => 'edit' ), $redirect_to ); // Check this is a valid form submission. check_admin_referer( 'edit-group_' . $group_id ); // Get the group from the database. $group = groups_get_group( $group_id ); // If the group doesn't exist, just redirect back to the index. if ( empty( $group->slug ) ) { wp_redirect( $redirect_to ); exit; } // Check the form for the updated properties. // Store errors. $error = 0; $success_new = $error_new = $success_modified = $error_modified = array(); // Name, description and slug must not be empty. if ( empty( $_POST['bp-groups-name'] ) ) { $error = $error - 1; } if ( empty( $_POST['bp-groups-slug'] ) ) { $error = $error - 4; } /* * Group name, slug, and description are handled with * groups_edit_base_group_details(). */ if ( ! $error && ! groups_edit_base_group_details( array( 'group_id' => $group_id, 'name' => $_POST['bp-groups-name'], 'slug' => $_POST['bp-groups-slug'], 'description' => $_POST['bp-groups-description'], 'parent_id' => isset( $_POST['bp-groups-parent'] ) ? $_POST['bp-groups-parent'] : 0, 'notify_members' => false, ) ) ) { $error = $group_id; } // Enable discussion forum. $enable_forum = ( isset( $_POST['group-show-forum'] ) ) ? 1 : 0; /** * Filters the allowed status values for the group. * * @since BuddyPress 1.0.2 * * @param array $value Array of allowed group statuses. */ $allowed_status = apply_filters( 'groups_allowed_status', array( 'public', 'private', 'hidden' ) ); $status = ( in_array( $_POST['group-status'], (array) $allowed_status ) ) ? $_POST['group-status'] : 'public'; /** * Filters the allowed invite status values for the group. * * @since BuddyPress 1.5.0 * * @param array $value Array of allowed invite statuses. */ $allowed_invite_status = apply_filters( 'groups_allowed_invite_status', array( 'members', 'mods', 'admins' ) ); $invite_status = in_array( $_POST['group-invite-status'], (array) $allowed_invite_status ) ? $_POST['group-invite-status'] : 'members'; /** * Filters the allowed activity feed status values for the group. * * @since BuddyBoss 1.0.0 * * @param array $value Array of allowed activity feed statuses. */ $allowed_activity_feed_status = apply_filters( 'groups_allowed_activity_feed_status', array( 'members', 'mods', 'admins' ) ); $activity_feed_status = in_array( $_POST['group-activity-feed-status'], (array) $allowed_activity_feed_status ) ? $_POST['group-activity-feed-status'] : 'members'; /** * Filters the allowed media status values for the group. * * @since BuddyBoss 1.0.0 * * @param array $value Array of allowed media statuses. */ $allowed_media_status = apply_filters( 'groups_allowed_media_status', array( 'members', 'mods', 'admins' ) ); $media_status = in_array( $_POST['group-media-status'], (array) $allowed_media_status ) ? $_POST['group-media-status'] : 'members'; /** * Filters the allowed album status values for the group. * * @since BuddyBoss 1.0.0 * * @param array $value Array of allowed album statuses. */ $allowed_album_status = apply_filters( 'groups_allowed_album_status', array( 'members', 'mods', 'admins' ) ); $album_status = in_array( $_POST['group-album-status'], (array) $allowed_album_status ) ? $_POST['group-album-status'] : 'members'; if ( !groups_edit_group_settings( $group_id, $enable_forum, $status, $invite_status, $activity_feed_status, false, $media_status, $album_status ) ) { $error = $group_id; } // Process new members. $user_names = array(); if ( ! empty( $_POST['bp-groups-new-members'] ) ) { $user_names = array_merge( $user_names, explode( ',', $_POST['bp-groups-new-members'] ) ); } if ( ! empty( $user_names ) ) { foreach( array_values( $user_names ) as $user_name ) { $un = trim( $user_name ); // Make sure the user exists before attempting // to add to the group. $user = get_user_by( 'slug', $un ); if ( empty( $user ) ) { $error_new[] = $un; } else { if ( ! groups_join_group( $group_id, $user->ID ) ) { $error_new[] = $un; } else { $success_new[] = $un; } } } } // Process member role changes. if ( ! empty( $_POST['bp-groups-role'] ) && ! empty( $_POST['bp-groups-existing-role'] ) ) { // Before processing anything, make sure you're not // attempting to remove the all user admins. $admin_count = 0; foreach ( (array) $_POST['bp-groups-role'] as $new_role ) { if ( 'admin' == $new_role ) { $admin_count++; break; } } if ( ! $admin_count ) { $redirect_to = add_query_arg( 'no_admins', 1, $redirect_to ); $error = $group_id; } else { // Process only those users who have had their roles changed. foreach ( (array) $_POST['bp-groups-role'] as $user_id => $new_role ) { $user_id = (int) $user_id; $existing_role = isset( $_POST['bp-groups-existing-role'][$user_id] ) ? $_POST['bp-groups-existing-role'][$user_id] : ''; if ( $existing_role != $new_role ) { $result = false; switch ( $new_role ) { case 'mod' : // Admin to mod is a demotion. Demote to // member, then fall through. if ( 'admin' == $existing_role ) { groups_demote_member( $user_id, $group_id ); } case 'admin' : // If the user was banned, we must // unban first. if ( 'banned' == $existing_role ) { groups_unban_member( $user_id, $group_id ); } // At this point, each existing_role // is a member, so promote. $result = groups_promote_member( $user_id, $group_id, $new_role ); break; case 'member' : if ( 'admin' == $existing_role || 'mod' == $existing_role ) { $result = groups_demote_member( $user_id, $group_id ); } elseif ( 'banned' == $existing_role ) { $result = groups_unban_member( $user_id, $group_id ); } break; case 'banned' : $result = groups_ban_member( $user_id, $group_id ); break; case 'remove' : $result = groups_remove_member( $user_id, $group_id ); break; } // Store the success or failure. if ( $result ) { $success_modified[] = $user_id; } else { $error_modified[] = $user_id; } } } } } /** * Fires before redirect so plugins can do something first on save action. * * @since BuddyPress 1.6.0 * * @param int $group_id ID of the group being edited. */ do_action( 'bp_group_admin_edit_after', $group_id ); // Create the redirect URL. if ( $error ) { // This means there was an error updating group details. $redirect_to = add_query_arg( 'error', (int) $error, $redirect_to ); } else { // Group details were update successfully. $redirect_to = add_query_arg( 'updated', 1, $redirect_to ); } if ( !empty( $success_new ) ) { $success_new = implode( ',', array_filter( $success_new, 'urlencode' ) ); $redirect_to = add_query_arg( 'success_new', $success_new, $redirect_to ); } if ( !empty( $error_new ) ) { $error_new = implode( ',', array_filter( $error_new, 'urlencode' ) ); $redirect_to = add_query_arg( 'error_new', $error_new, $redirect_to ); } if ( !empty( $success_modified ) ) { $success_modified = implode( ',', array_filter( $success_modified, 'urlencode' ) ); $redirect_to = add_query_arg( 'success_modified', $success_modified, $redirect_to ); } if ( !empty( $error_modified ) ) { $error_modified = implode( ',', array_filter( $error_modified, 'urlencode' ) ); $redirect_to = add_query_arg( 'error_modified', $error_modified, $redirect_to ); } /** * Filters the URL to redirect to after successfully editing a group. * * @since BuddyPress 1.7.0 * * @param string $redirect_to URL to redirect user to. */ wp_redirect( apply_filters( 'bp_group_admin_edit_redirect', $redirect_to ) ); exit; // If a referrer and a nonce is supplied, but no action, redirect back. } elseif ( ! empty( $_GET['_wp_http_referer'] ) ) { wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) ); exit; } }
更新日志
版本 | 描述 |
---|---|
BuddyPress 1.7.0 | 介绍了。 |