/** * Handles all actions for the admin area for creating, editing and deleting * profile groups and fields. * * @param string $message Message to display. * @param string $type Type of action to be displayed. */ function xprofile_admin($message = '', $type = 'error') { if (isset($_GET['mode']) && isset($_GET['group_id']) && 'add_field' == $_GET['mode']) { xprofile_admin_manage_field($_GET['group_id']); } elseif (isset($_GET['mode']) && isset($_GET['group_id']) && isset($_GET['field_id']) && 'edit_field' == $_GET['mode']) { xprofile_admin_manage_field($_GET['group_id'], $_GET['field_id']); } elseif (isset($_GET['mode']) && isset($_GET['field_id']) && 'delete_field' == $_GET['mode']) { xprofile_admin_delete_field($_GET['field_id'], 'field'); } elseif (isset($_GET['mode']) && isset($_GET['option_id']) && 'delete_option' == $_GET['mode']) { xprofile_admin_delete_field($_GET['option_id'], 'option'); } elseif (isset($_GET['mode']) && 'add_group' == $_GET['mode']) { xprofile_admin_manage_group(); } elseif (isset($_GET['mode']) && isset($_GET['group_id']) && 'delete_group' == $_GET['mode']) { xprofile_admin_delete_group($_GET['group_id']); } elseif (isset($_GET['mode']) && isset($_GET['group_id']) && 'edit_group' == $_GET['mode']) { xprofile_admin_manage_group($_GET['group_id']); } else { xprofile_admin_screen($message, $type); } }
/** * Handles all actions for the admin area for creating, editing and deleting * profile groups and fields. */ function xprofile_admin($message = '', $type = 'error') { global $bp; $type = preg_replace('|[^a-z]|i', '', $type); $groups = BP_XProfile_Group::get(array('fetch_fields' => true)); if (isset($_GET['mode']) && isset($_GET['group_id']) && 'add_field' == $_GET['mode']) { xprofile_admin_manage_field($_GET['group_id']); } else { if (isset($_GET['mode']) && isset($_GET['group_id']) && isset($_GET['field_id']) && 'edit_field' == $_GET['mode']) { xprofile_admin_manage_field($_GET['group_id'], $_GET['field_id']); } else { if (isset($_GET['mode']) && isset($_GET['field_id']) && 'delete_field' == $_GET['mode']) { xprofile_admin_delete_field($_GET['field_id'], 'field'); } else { if (isset($_GET['mode']) && isset($_GET['option_id']) && 'delete_option' == $_GET['mode']) { xprofile_admin_delete_field($_GET['option_id'], 'option'); } else { if (isset($_GET['mode']) && 'add_group' == $_GET['mode']) { xprofile_admin_manage_group(); } else { if (isset($_GET['mode']) && isset($_GET['group_id']) && 'delete_group' == $_GET['mode']) { xprofile_admin_delete_group($_GET['group_id']); } else { if (isset($_GET['mode']) && isset($_GET['group_id']) && 'edit_group' == $_GET['mode']) { xprofile_admin_manage_group($_GET['group_id']); } else { ?> <div class="wrap"> <?php screen_icon('buddypress'); ?> <h2> <?php _e('Extended Profile Fields', 'buddypress'); ?> <a id="add_group" class="button add-new-h2" href="admin.php?page=bp-profile-setup&mode=add_group"><?php _e('Add New Group', 'buddypress'); ?> </a> </h2> <p><?php _e('Your users will distinguish themselves through their profile page. You must give them profile fields that allow them to describe themselves in a way that is relevant to the theme of your social network.', 'buddypress'); ?> </p> <p><?php echo sprintf(__('NOTE: Any fields in the "%s" group will appear on the signup page.', 'buddypress'), esc_html(stripslashes(bp_get_option('bp-xprofile-base-group-name')))); ?> </p> <form action="" id="profile-field-form" method="post"> <?php nxt_nonce_field('bp_reorder_fields', '_nxtnonce_reorder_fields'); ?> <?php nxt_nonce_field('bp_reorder_groups', '_nxtnonce_reorder_groups', false); if (!empty($message)) { $type = $type == 'error' ? 'error' : 'updated'; ?> <div id="message" class="<?php echo $type; ?> fade"> <p><?php echo esc_html(esc_attr($message)); ?> </p> </div> <?php } ?> <div id="tabs"> <ul id="field-group-tabs"> <?php if (!empty($groups)) { foreach ($groups as $group) { ?> <li id="group_<?php echo $group->id; ?> "><a href="#tabs-<?php echo $group->id; ?> " class="ui-tab"><?php echo esc_attr($group->name); if (!$group->can_delete) { ?> <?php _e('(Primary)', 'buddypress'); } ?> </a></li> <?php } } ?> </ul> <?php if (!empty($groups)) { foreach ($groups as $group) { ?> <noscript> <h3><?php echo esc_attr($group->name); ?> </h3> </noscript> <div id="tabs-<?php echo $group->id; ?> " class="tab-wrapper"> <div class="tab-toolbar"> <div class="tab-toolbar-left"> <a class="button" href="admin.php?page=bp-profile-setup&group_id=<?php echo esc_attr($group->id); ?> &mode=add_field"><?php _e('Add New Field', 'buddypress'); ?> </a> <a class="button edit" href="admin.php?page=bp-profile-setup&mode=edit_group&group_id=<?php echo esc_attr($group->id); ?> "><?php _e('Edit Group', 'buddypress'); ?> </a> <?php if ($group->can_delete) { ?> <a class="submitdelete deletion" href="admin.php?page=bp-profile-setup&mode=delete_group&group_id=<?php echo esc_attr($group->id); ?> "><?php _e('Delete Group', 'buddypress'); ?> </a> <?php } ?> </div> </div> <fieldset id="<?php echo $group->id; ?> " class="connectedSortable field-group"> <?php if ($group->description) { ?> <legend><?php echo esc_attr($group->description); ?> </legend> <?php } if (!empty($group->fields)) { foreach ($group->fields as $field) { // Load the field $field = new BP_XProfile_Field($field->id); $class = ''; if (!$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 } // end $group->fields ?> </fieldset> </div> <?php } // End For ?> </div> <?php } else { ?> <div id="message" class="error"><p><?php _e('You have no groups.', 'buddypress'); ?> </p></div> <p><a href="admin.php?page=bp-profile-setup&mode=add_group"><?php _e('Add New Group', 'buddypress'); ?> </a></p> <?php } ?> <div id="tabs-bottom"> </div> </form> </div> <?php } } } } } } } }
function xprofile_admin( $message = '', $type = 'error' ) { global $bp; $type = preg_replace( '|[^a-z]|i', '', $type ); $groups = BP_XProfile_Group::get( array( 'fetch_fields' => true ) ); if ( isset($_GET['mode']) && isset($_GET['group_id']) && 'add_field' == $_GET['mode'] ) { xprofile_admin_manage_field($_GET['group_id']); } else if ( isset($_GET['mode']) && isset($_GET['group_id']) && isset($_GET['field_id']) && 'edit_field' == $_GET['mode'] ) { xprofile_admin_manage_field($_GET['group_id'], $_GET['field_id']); } else if ( isset($_GET['mode']) && isset($_GET['field_id']) && 'delete_field' == $_GET['mode'] ) { xprofile_admin_delete_field($_GET['field_id'], 'field'); } else if ( isset($_GET['mode']) && isset($_GET['option_id']) && 'delete_option' == $_GET['mode'] ) { xprofile_admin_delete_field($_GET['option_id'], 'option'); } else if ( isset($_GET['mode']) && 'add_group' == $_GET['mode'] ) { xprofile_admin_manage_group(); } else if ( isset($_GET['mode']) && isset($_GET['group_id']) && 'delete_group' == $_GET['mode'] ) { xprofile_admin_delete_group($_GET['group_id']); } else if ( isset($_GET['mode']) && isset($_GET['group_id']) && 'edit_group' == $_GET['mode'] ) { xprofile_admin_manage_group($_GET['group_id']); } else { ?> <div class="wrap"> <h2><?php _e( 'Profile Field Setup', 'buddypress') ?></h2> <br /> <p><?php _e( 'Your users will distinguish themselves through their profile page. You must give them profile fields that allow them to describe themselves in a way that is relevant to the theme of your social network.', 'buddypress') ?></p> <p><?php _e('NOTE: Any fields in the first group will appear on the signup page.', 'buddypress'); ?></p> <form action="" id="profile-field-form" method="post"> <?php wp_nonce_field( 'bp_reorder_fields', '_wpnonce_reorder_fields' ); ?> <?php if ( $message != '' ) { $type = ( $type == 'error' ) ? 'error' : 'updated'; ?> <div id="message" class="<?php echo $type; ?> fade"> <p><?php echo wp_specialchars( esc_attr( $message ) ); ?></p> </div> <?php } if ( $groups ) { ?> <?php for ( $i = 0; $i < count($groups); $i++ ) { // TODO: foreach ?> <p> <table id="group_<?php echo $groups[$i]->id;?>" class="widefat field-group"> <thead> <tr> <th scope="col" width="10"> </th> <th scope="col" colspan="<?php if ( $groups[$i]->can_delete ) { ?>3<?php } else { ?>5<?php } ?>"><?php echo esc_attr( $groups[$i]->name ); ?></th> <?php if ( $groups[$i]->can_delete ) { ?> <th scope="col"><a class="edit" href="admin.php?page=bp-profile-setup&mode=edit_group&group_id=<?php echo esc_attr( $groups[$i]->id ); ?>"><?php _e( 'Edit', 'buddypress' ) ?></a></th> <th scope="col"><a class="delete" href="admin.php?page=bp-profile-setup&mode=delete_group&group_id=<?php echo esc_attr( $groups[$i]->id ); ?>"><?php _e( 'Delete', 'buddypress' ) ?></a></th> <?php } ?> </tr> <tr class="header"> <td> </td> <td><?php _e( 'Field Name', 'buddypress' ) ?></td> <td width="14%"><?php _e( 'Field Type', 'buddypress' ) ?></td> <td width="6%"><?php _e( 'Required?', 'buddypress' ) ?></td> <td colspan="2" width="10%" style="text-align:center;"><?php _e( 'Action', 'buddypress' ) ?></td> </tr> </thead> <tbody id="the-list"> <?php if ( $groups[$i]->fields ) { ?> <?php for ( $j = 0; $j < count($groups[$i]->fields); $j++ ) { ?> <?php if ( 0 == $j % 2 ) { $class = ""; } else { $class = "alternate"; } ?> <?php $field = new BP_XProfile_Field($groups[$i]->fields[$j]->id); ?> <?php if ( !$field->can_delete ) { $class .= ' core'; } ?> <tr id="field_<?php echo esc_attr( $field->id ); ?>" class="sortable<?php if ( $class ) { echo ' ' . $class; } ?>"> <td width="10"><img src="<?php echo BP_PLUGIN_URL ?>/bp-xprofile/admin/images/move.gif" alt="<?php _e( 'Drag', 'buddypress' ) ?>" /></td> <td><span title="<?php echo $field->description; ?>"><?php echo esc_attr( $field->name ); ?> <?php if(!$field->can_delete) { ?> <?php _e( '(Core Field)', 'buddypress' ) ?><?php } ?></span></td> <td><?php echo esc_attr( $field->type ); ?></td> <td style="text-align:center;"><?php if ( $field->is_required ) { echo '<img src="' . BP_PLUGIN_URL . '/bp-xprofile/admin/images/tick.gif" alt="' . __( 'Yes', 'buddypress' ) . '" />'; } else { ?>--<?php } ?></td> <td style="text-align:center;"><?php if ( !$field->can_delete ) { ?><strike><?php _e( 'Edit', 'buddypress' ) ?></strike><?php } else { ?><a class="edit" href="admin.php?page=bp-profile-setup&group_id=<?php echo esc_attr( $groups[$i]->id ); ?>&field_id=<?php echo esc_attr( $field->id ); ?>&mode=edit_field"><?php _e( 'Edit', 'buddypress' ) ?></a><?php } ?></td> <td style="text-align:center;"><?php if ( !$field->can_delete ) { ?><strike><?php _e( 'Delete', 'buddypress' ) ?></strike><?php } else { ?><a class="delete" href="admin.php?page=bp-profile-setup&field_id=<?php echo esc_attr( $field->id ); ?>&mode=delete_field"><?php _e( 'Delete', 'buddypress' ) ?></a><?php } ?></td> </tr> <?php } ?> <?php } else { ?> <tr class="nodrag"> <td colspan="6"><?php _e( 'There are no fields in this group.', 'buddypress' ) ?></td> </tr> <?php } ?> </tbody> <tfoot> <tr class="nodrag"> <td colspan="6"><a href="admin.php?page=bp-profile-setup&group_id=<?php echo esc_attr( $groups[$i]->id ); ?>&mode=add_field"><?php _e( 'Add New Field', 'buddypress' ) ?></a></td> </tr> </tfoot> </table> </p> <?php } /* End For */ ?> <p> <a class="button" href="admin.php?page=bp-profile-setup&mode=add_group"><?php _e( 'Add New Field Group', 'buddypress' ) ?></a> </p> <?php } else { ?> <div id="message" class="error"><p><?php _e('You have no groups.', 'buddypress' ); ?></p></div> <p><a href="admin.php?page=bp-profile-setup&mode=add_group"><?php _e( 'Add New Group', 'buddypress' ) ?></a></p> <?php } ?> </form> </div> <?php } }
/** * Handles all actions for the admin area for creating, editing and deleting * profile groups and fields. */ function xprofile_admin($message = '', $type = 'error') { $type = preg_replace('|[^a-z]|i', '', $type); $groups = bp_xprofile_get_groups(array('fetch_fields' => true)); if (isset($_GET['mode']) && isset($_GET['group_id']) && 'add_field' == $_GET['mode']) { xprofile_admin_manage_field($_GET['group_id']); } elseif (isset($_GET['mode']) && isset($_GET['group_id']) && isset($_GET['field_id']) && 'edit_field' == $_GET['mode']) { xprofile_admin_manage_field($_GET['group_id'], $_GET['field_id']); } elseif (isset($_GET['mode']) && isset($_GET['field_id']) && 'delete_field' == $_GET['mode']) { xprofile_admin_delete_field($_GET['field_id'], 'field'); } elseif (isset($_GET['mode']) && isset($_GET['option_id']) && 'delete_option' == $_GET['mode']) { xprofile_admin_delete_field($_GET['option_id'], 'option'); } elseif (isset($_GET['mode']) && 'add_group' == $_GET['mode']) { xprofile_admin_manage_group(); } elseif (isset($_GET['mode']) && isset($_GET['group_id']) && 'delete_group' == $_GET['mode']) { xprofile_admin_delete_group($_GET['group_id']); } elseif (isset($_GET['mode']) && isset($_GET['group_id']) && 'edit_group' == $_GET['mode']) { xprofile_admin_manage_group($_GET['group_id']); } else { ?> <div class="wrap"> <?php screen_icon('users'); ?> <h2> <?php _ex('Profile Fields', 'Settings page header', 'buddypress'); ?> <a id="add_group" class="add-new-h2" href="users.php?page=bp-profile-setup&mode=add_group"><?php _e('Add New Field Group', 'buddypress'); ?> </a> </h2> <p><?php echo sprintf(__('Fields in the "%s" group will appear on the signup page.', 'buddypress'), esc_html(stripslashes(bp_get_option('bp-xprofile-base-group-name')))); ?> </p> <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"> <p><?php echo esc_html(esc_attr($message)); ?> </p> </div> <?php } ?> <div id="tabs"> <ul id="field-group-tabs"> <?php if (!empty($groups)) { foreach ($groups as $group) { ?> <li id="group_<?php echo $group->id; ?> "><a href="#tabs-<?php echo $group->id; ?> " class="ui-tab"><?php echo esc_attr($group->name); if (!$group->can_delete) { ?> <?php _e('(Primary)', 'buddypress'); } ?> </a></li> <?php } } ?> </ul> <?php if (!empty($groups)) { foreach ($groups as $group) { ?> <noscript> <h3><?php echo esc_attr($group->name); ?> </h3> </noscript> <div id="tabs-<?php echo $group->id; ?> " class="tab-wrapper"> <div class="tab-toolbar"> <div class="tab-toolbar-left"> <a class="button-primary" href="users.php?page=bp-profile-setup&group_id=<?php echo esc_attr($group->id); ?> &mode=add_field"><?php _e('Add New Field', 'buddypress'); ?> </a> <a class="button edit" href="users.php?page=bp-profile-setup&mode=edit_group&group_id=<?php echo esc_attr($group->id); ?> "><?php _e('Edit Group', 'buddypress'); ?> </a> <?php if ($group->can_delete) { ?> <a class="confirm submitdelete deletion ajax-option-delete" href="users.php?page=bp-profile-setup&mode=delete_group&group_id=<?php echo esc_attr($group->id); ?> "><?php _e('Delete Group', 'buddypress'); ?> </a> <?php } ?> <?php /** * Fires at end of action buttons in xprofile management admin. * * @since BuddyPress (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> <fieldset id="<?php echo $group->id; ?> " class="connectedSortable field-group"> <?php if ($group->description) { ?> <legend><?php echo esc_attr($group->description); ?> </legend> <?php } if (!empty($group->fields)) { foreach ($group->fields as $field) { // Load the field $field = new BP_XProfile_Field($field->id); $class = ''; if (!$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 } // end $group->fields ?> </fieldset> </div> <?php } } else { ?> <div id="message" class="error"><p><?php _e('You have no groups.', 'buddypress'); ?> </p></div> <p><a href="users.php?page=bp-profile-setup&mode=add_group"><?php _e('Add New Group', 'buddypress'); ?> </a></p> <?php } ?> <div id="tabs-bottom"> </div> </div> </form> </div> <?php } }