xprofile_admin_screen( string $message = '', string $type = 'error' )
Output the main XProfile management screen.
Parameters Parameters
- $message
-
(string) (Optional) Feedback message.
Default value: ''
- $type
-
(string) (Optional) Feedback type.
Default value: 'error'
Source Source
File: bp-xprofile/bp-xprofile-admin.php
function xprofile_admin_screen( $message = '', $type = 'error' ) { // Users admin URL. $url = bp_get_admin_url( 'users.php' ); // Add Group. $add_group_url = add_query_arg( array( 'page' => 'bp-profile-setup', 'mode' => 'add_group' ), $url ); // Validate type. $type = preg_replace( '|[^a-z]|i', '', $type ); // Get all of the profile groups & fields. $groups = bp_xprofile_get_groups( array( 'fetch_fields' => true ) ); ?> <div class="wrap"> <h1 class="wp-heading-inline"><?php _ex( 'Profile Fields', 'Settings page header', 'buddypress'); ?></h1> <a id="add_group" class="page-title-action" href="<?php echo esc_url( $add_group_url ); ?>"><?php _e( 'Add New Field Group', 'buddypress' ); ?></a> <hr class="wp-header-end"> <form action="" id="profile-field-form" method="post"> <?php wp_nonce_field( 'bp_reorder_fields', '_wpnonce_reorder_fields' ); wp_nonce_field( 'bp_reorder_groups', '_wpnonce_reorder_groups', false ); if ( ! empty( $message ) ) : $type = ( $type == 'error' ) ? 'error' : 'updated'; ?> <div id="message" class="<?php echo $type; ?> fade notice is-dismissible"> <p><?php echo esc_html( $message ); ?></p> </div> <?php endif; ?> <div id="tabs" aria-live="polite" aria-atomic="true" aria-relevant="all"> <ul id="field-group-tabs"> <?php if ( !empty( $groups ) ) : foreach ( $groups as $group ) : ?> <li id="group_<?php echo esc_attr( $group->id ); ?>"> <a href="#tabs-<?php echo esc_attr( $group->id ); ?>" class="ui-tab"> <?php /** This filter is documented in bp-xprofile/bp-xprofile-template.php */ echo esc_html( apply_filters( 'bp_get_the_profile_group_name', $group->name ) ); ?> <?php if ( !$group->can_delete ) : ?> <?php _e( '(Primary)', 'buddypress'); ?> <?php endif; ?> </a> </li> <?php endforeach; endif; ?> <li id="signup-group" class="not-sortable last"> <a href="#tabs-signup-group" class="ui-tab"> <?php esc_html_e( 'Signup Fields', 'buddypress' ); ?> </a> </li> </ul> <?php if ( !empty( $groups ) ) : foreach ( $groups as $group ) : // Add Field to Group URL. $add_field_url = add_query_arg( array( 'page' => 'bp-profile-setup', 'mode' => 'add_field', 'group_id' => (int) $group->id ), $url ); // Edit Group URL. $edit_group_url = add_query_arg( array( 'page' => 'bp-profile-setup', 'mode' => 'edit_group', 'group_id' => (int) $group->id ), $url ); // Delete Group URL. $delete_group_url = wp_nonce_url( add_query_arg( array( 'page' => 'bp-profile-setup', 'mode' => 'delete_group', 'group_id' => (int) $group->id ), $url ), 'bp_xprofile_delete_group' ); ?> <noscript> <h3><?php /** This filter is documented in bp-xprofile/bp-xprofile-template.php */ echo esc_html( apply_filters( 'bp_get_the_profile_group_name', $group->name ) ); ?></h3> </noscript> <div id="tabs-<?php echo esc_attr( $group->id ); ?>" class="tab-wrapper"> <div class="tab-toolbar"> <div class="tab-toolbar-left"> <a class="button-primary" href="<?php echo esc_url( $add_field_url ); ?>"><?php _e( 'Add New Field', 'buddypress' ); ?></a> <a class="button edit" href="<?php echo esc_url( $edit_group_url ); ?>"><?php _ex( 'Edit Group', 'Edit Profile Fields Group', 'buddypress' ); ?></a> <?php if ( $group->can_delete ) : ?> <div class="delete-button"> <a class="confirm submitdelete deletion ajax-option-delete" href="<?php echo esc_url( $delete_group_url ); ?>"><?php _ex( 'Delete Group', 'Delete Profile Fields Group', 'buddypress' ); ?></a> </div> <?php endif; ?> <?php /** * Fires at end of action buttons in xprofile management admin. * * @since 2.2.0 * * @param BP_XProfile_Group $group BP_XProfile_Group object * for the current group. */ do_action( 'xprofile_admin_group_action', $group ); ?> </div> </div> <?php if ( ! empty( $group->description ) ) : ?> <p><?php /** This filter is documented in bp-xprofile/bp-xprofile-template.php */ echo esc_html( apply_filters( 'bp_get_the_profile_group_description', $group->description ) ); ?></p> <?php endif; ?> <fieldset id="<?php echo esc_attr( $group->id ); ?>" class="connectedSortable field-group" aria-live="polite" aria-atomic="true" aria-relevant="all"> <legend class="screen-reader-text"><?php /** This filter is documented in bp-xprofile/bp-xprofile-template.php */ /* translators: accessibility text */ printf( esc_html__( 'Fields for "%s" Group', 'buddypress' ), apply_filters( 'bp_get_the_profile_group_name', $group->name ) ); ?></legend> <?php if ( !empty( $group->fields ) ) : foreach ( $group->fields as $field ) { // Load the field. $field = xprofile_get_field( $field->id, null, false ); $class = ''; if ( empty( $field->can_delete ) ) { $class = ' core nodrag'; } /** * This function handles the WYSIWYG profile field * display for the xprofile admin setup screen. */ xprofile_admin_field( $field, $group, $class ); } // end for else : // !$group->fields ?> <p class="nodrag nofields"><?php _e( 'There are no fields in this group.', 'buddypress' ); ?></p> <?php endif; // End $group->fields. ?> </fieldset> </div> <?php endforeach; else : ?> <div id="message" class="error notice is-dismissible"><p><?php _ex( 'You have no groups.', 'You have no profile fields groups.', 'buddypress' ); ?></p></div> <p><a href="<?php echo esc_url( $add_group_url ); ?>"><?php _ex( 'Add New Group', 'Add New Profile Fields Group', 'buddypress' ); ?></a></p> <?php endif; ?> <?php $signup_groups = bp_xprofile_get_groups( array( 'fetch_fields' => true, 'signup_fields_only' => true, ) ); $has_signup_fields = false; $signup_fields = array(); $signup_fields_order = bp_xprofile_get_signup_field_ids(); ?> <div id="tabs-signup-group"" class="tab-wrapper"> <div class="tab-toolbar"> <p class="description"><?php esc_html_e( 'Drag fields from other groups and drop them on the above tab to include them into your registration form.', 'buddypress' ); ?></a> </div> <fieldset id="signup-fields" class="connectedSortable field-group" aria-live="polite" aria-atomic="true" aria-relevant="all"> <legend class="screen-reader-text"> <?php esc_html_e( 'Fields to use into the registration form', 'buddypress' );?> </legend> <?php if ( ! empty( $signup_groups ) ) { foreach ( $signup_groups as $signup_group ) { if ( ! empty( $signup_group->fields ) ) { $has_signup_fields = true; foreach ( $signup_group->fields as $signup_field ) { // Load the field. $_signup_field = xprofile_get_field( $signup_field, null, false ); /** * This function handles the WYSIWYG profile field * display for the xprofile admin setup screen. */ $signup_fields[ $_signup_field->id ] = bp_xprofile_admin_get_signup_field( $_signup_field, $signup_group, '' ); } } } // Output signup fields according to their signup position. foreach ( $signup_fields_order as $ordered_signup_field_id ) { if ( ! isset( $signup_fields[ $ordered_signup_field_id ] ) ) { continue; } echo $signup_fields[ $ordered_signup_field_id ]; } } if ( ! $has_signup_fields ) { ?> <p class="nodrag nofields"><?php esc_html_e( 'There are no registration fields set. The registration form uses the primary group by default.', 'buddypress' ); ?></p> <?php } ?> </fieldset> <?php if ( bp_get_signup_allowed() ) : ?> <p><?php esc_html_e( '* Fields in this group appear on the registration page.', 'buddypress' ); ?></p> <?php else : ?> <p> <?php // Include a link to edit settings. $settings_link = ''; if ( is_multisite() && current_user_can( 'manage_network_users') ) { $settings_link = sprintf( ' <a href="%1$">%2$s</a>.', esc_url( network_admin_url( 'settings.php' ) ), esc_html__( 'Edit settings', 'buddypress' ) ); } elseif ( current_user_can( 'manage_options' ) ) { $settings_link = sprintf( ' <a href="%1$s">%2$s</a>.', esc_url( bp_get_admin_url( 'options-general.php' ) ), esc_html__( 'Edit settings', 'buddypress' ) ); } printf( /* translators: %s is the link to the registration settings. */ esc_html__( '* Fields in this group will appear on the registration page as soon as users will be able to register to your site.%s', 'buddypress' ), $settings_link ); ?> </p> <?php endif; ?> </div> </div> </form> </div> <?php }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
2.3.0 | Introduced. |