public function render_admin_form($message = '')
    {
        if (empty($this->id)) {
            $title = __('Add Field', 'buddypress');
            $action = "users.php?page=bp-profile-setup&group_id=" . $this->group_id . "&mode=add_field#tabs-" . $this->group_id;
            if (!empty($_POST['saveField'])) {
                $this->name = $_POST['title'];
                $this->description = $_POST['description'];
                $this->is_required = $_POST['required'];
                $this->type = $_POST['fieldtype'];
                $this->order_by = $_POST["sort_order_{$this->type}"];
                $this->field_order = $_POST['field_order'];
            }
        } else {
            $title = __('Edit Field', 'buddypress');
            $action = "users.php?page=bp-profile-setup&mode=edit_field&group_id=" . $this->group_id . "&field_id=" . $this->id . "#tabs-" . $this->group_id;
        }
        ?>

		<div class="wrap">
			<div id="icon-users" class="icon32"><br /></div>
			<h2><?php 
        echo esc_html($title);
        ?>
</h2>

			<?php 
        if (!empty($message)) {
            ?>

				<div id="message" class="error fade">
					<p><?php 
            echo esc_html($message);
            ?>
</p>
				</div>

			<?php 
        }
        ?>

			<form id="bp-xprofile-add-field" action="<?php 
        echo esc_url($action);
        ?>
" method="post">
				<div id="poststuff">
					<div id="post-body" class="metabox-holder columns-<?php 
        echo 1 == get_current_screen()->get_columns() ? '1' : '2';
        ?>
">
						<div id="post-body-content">
							<div id="titlediv">
								<input type="text" name="title" id="title" value="<?php 
        echo esc_attr($this->name);
        ?>
" />
							</div>
							<div class="postbox">
								<h3><?php 
        _e('Field Description', 'buddypress');
        ?>
</h3>
								<div class="inside">
									<textarea name="description" id="description" rows="8" cols="60"><?php 
        echo esc_textarea($this->description);
        ?>
</textarea>
								</div>
							</div>
						</div><!-- #post-body-content -->

						<div id="postbox-container-1" class="postbox-container">
							<div id="submitdiv" class="postbox">
								<h3><?php 
        _e('Submit', 'buddypress');
        ?>
</h3>
								<div class="inside">
									<div id="submitcomment" class="submitbox">
										<div id="major-publishing-actions">
											<input type="hidden" name="field_order" id="field_order" value="<?php 
        echo esc_attr($this->field_order);
        ?>
" />
											<div id="publishing-action">
												<input type="submit" value="<?php 
        esc_attr_e('Save', 'buddypress');
        ?>
" name="saveField" id="saveField" style="font-weight: bold" class="button-primary" />
											</div>
											<div id="delete-action">
												<a href="users.php?page=bp-profile-setup" class="deletion"><?php 
        _e('Cancel', 'buddypress');
        ?>
</a>
											</div>
											<?php 
        wp_nonce_field('xprofile_delete_option');
        ?>
											<div class="clear"></div>
										</div>
									</div>
								</div>
							</div>

							<?php 
        /* Field 1 is the fullname field, which cannot have custom visibility */
        ?>
							<?php 
        if (1 != $this->id) {
            ?>

								<div class="postbox">
									<h3><label for="default-visibility"><?php 
            _e('Default Visibility', 'buddypress');
            ?>
</label></h3>
									<div class="inside">
										<ul>

											<?php 
            foreach (bp_xprofile_get_visibility_levels() as $level) {
                ?>

												<li>
													<input type="radio" id="default-visibility[<?php 
                echo esc_attr($level['id']);
                ?>
]" name="default-visibility" value="<?php 
                echo esc_attr($level['id']);
                ?>
" <?php 
                checked($this->default_visibility, $level['id']);
                ?>
 />
													<label for="default-visibility[<?php 
                echo esc_attr($level['id']);
                ?>
]"><?php 
                echo esc_html($level['label']);
                ?>
</label>
												</li>

											<?php 
            }
            ?>

										</ul>
									</div>
								</div>

								<div class="postbox">
									<h3><label for="allow-custom-visibility"><?php 
            _e('Per-Member Visibility', 'buddypress');
            ?>
</label></h3>
									<div class="inside">
										<ul>
											<li>
												<input type="radio" id="allow-custom-visibility-allowed" name="allow-custom-visibility" value="allowed" <?php 
            checked($this->allow_custom_visibility, 'allowed');
            ?>
 />
												<label for="allow-custom-visibility-allowed"><?php 
            _e("Let members change this field's visibility", 'buddypress');
            ?>
</label>
											</li>
											<li>
												<input type="radio" id="allow-custom-visibility-disabled" name="allow-custom-visibility" value="disabled" <?php 
            checked($this->allow_custom_visibility, 'disabled');
            ?>
 />
												<label for="allow-custom-visibility-disabled"><?php 
            _e('Enforce the default visibility for all members', 'buddypress');
            ?>
</label>
											</li>
										</ul>
									</div>
								</div>

							<?php 
        }
        ?>
						</div>

						<div id="postbox-container-2" class="postbox-container">

							<?php 
        /* Field 1 is the fullname field, which cannot be altered */
        ?>
							<?php 
        if (1 != $this->id) {
            ?>

								<div class="postbox">
									<h3><label for="required"><?php 
            _e("Field Requirement", 'buddypress');
            ?>
</label></h3>
									<div class="inside">
										<select name="required" id="required" style="width: 30%">
											<option value="0"<?php 
            selected($this->is_required, '0');
            ?>
><?php 
            _e('Not Required', 'buddypress');
            ?>
</option>
											<option value="1"<?php 
            selected($this->is_required, '1');
            ?>
><?php 
            _e('Required', 'buddypress');
            ?>
</option>
										</select>
									</div>
								</div>

								<div class="postbox">
									<h3><label for="fieldtype"><?php 
            _e('Field Type', 'buddypress');
            ?>
</label></h3>
									<div class="inside">
										<select name="fieldtype" id="fieldtype" onchange="show_options(this.value)" style="width: 30%">
											<?php 
            bp_xprofile_admin_form_field_types($this->type);
            ?>
										</select>

										<?php 
            // Deprecated filter, don't use. Go look at {@link BP_XProfile_Field_Type::admin_new_field_html()}.
            do_action('xprofile_field_additional_options', $this);
            $this->render_admin_form_children();
            ?>
									</div>
								</div>

							<?php 
        } else {
            ?>

								<input type="hidden" name="required"  id="required"  value="1"       />
								<input type="hidden" name="fieldtype" id="fieldtype" value="textbox" />

							<?php 
        }
        ?>

						</div>
					</div><!-- #post-body -->

				</div><!-- #poststuff -->

			</form>
		</div>

<?php 
    }
    /**
     * Filter 'global' visibility levels from radio buttons.
     *
     * @since  1.0
     *
     * @param string 	$retval
     * @param array   	$request
     * @param array   	$args
     *
     * @return array
     */
    public function filter_global_visibility_from_radio_buttons($retval, $r, $args)
    {
        // Empty return value, filled in below if a valid field ID is found
        $retval = '';
        // Only do-the-do if there's a valid field ID
        if (!empty($r['field_id'])) {
            // Start the output buffer
            ob_start();
            // Output anything before
            echo $r['before'];
            ?>

			<?php 
            if (bp_current_user_can('bp_xprofile_change_field_visibility')) {
                ?>

				<?php 
                foreach (bp_xprofile_get_visibility_levels() as $level) {
                    ?>

					<?php 
                    if ($level['id'] != 'global') {
                        ?>

						<?php 
                        printf($r['before_radio'], esc_attr($level['id']));
                        ?>

						<label for="<?php 
                        echo esc_attr('see-field_' . $r['field_id'] . '_' . $level['id']);
                        ?>
">
							<input type="radio" id="<?php 
                        echo esc_attr('see-field_' . $r['field_id'] . '_' . $level['id']);
                        ?>
" name="<?php 
                        echo esc_attr('field_' . $r['field_id'] . '_visibility');
                        ?>
" value="<?php 
                        echo esc_attr($level['id']);
                        ?>
" <?php 
                        checked($level['id'], bp_get_the_profile_field_visibility_level());
                        ?>
 />
							<span class="field-visibility-text"><?php 
                        echo esc_html($level['label']);
                        ?>
</span>
						</label>

						<?php 
                        echo $r['after_radio'];
                        ?>

					<?php 
                    }
                    ?>

				<?php 
                }
                ?>

			<?php 
            }
            // Output anything after
            echo $r['after'];
            // Get the output buffer and empty it
            $retval = ob_get_clean();
        }
        return $retval;
    }
/**
 * Set the visibility level for this field
 *
 * @param int $field_id The ID of the xprofile field
 * @param int $user_id The ID of the user to whom the data belongs
 * @param string $visibility_level
 * @return bool True on success
 */
function xprofile_set_field_visibility_level($field_id = 0, $user_id = 0, $visibility_level = '')
{
    if (empty($field_id) || empty($user_id) || empty($visibility_level)) {
        return false;
    }
    // Check against a whitelist
    $allowed_values = bp_xprofile_get_visibility_levels();
    if (!array_key_exists($visibility_level, $allowed_values)) {
        return false;
    }
    // Stored in an array in usermeta
    $current_visibility_levels = bp_get_user_meta($user_id, 'bp_xprofile_visibility_levels', true);
    if (!$current_visibility_levels) {
        $current_visibility_levels = array();
    }
    $current_visibility_levels[$field_id] = $visibility_level;
    return bp_update_user_meta($user_id, 'bp_xprofile_visibility_levels', $current_visibility_levels);
}
/**
 * Return the XProfile field visibility select list for settings.
 *
 * @since 2.0.0
 *
 * @param array|string $args {
 *    Args for the select list.
 *
 *    @type int    $field_id ID of the field to render.
 *    @type string $before   Markup to render before the field.
 *    @type string $before_controls  markup before form controls.
 *    @type string $after    Markup to render after the field.
 *    @type string $after_controls Markup after the form controls.
 *    @type string $class    Class to apply to the field markup.
 *    @type string $label_class Class to apply for the label element.
 *    @type string $notoggle_tag Markup element to use for notoggle tag.
 *    @type string $notoggle_class Class to apply to the notoggle element.
 * }
 * @return string $retval
 */
function bp_profile_get_settings_visibility_select($args = '')
{
    // Parse optional arguments.
    $r = bp_parse_args($args, array('field_id' => bp_get_the_profile_field_id(), 'before' => '', 'before_controls' => '', 'after' => '', 'after_controls' => '', 'class' => 'bp-xprofile-visibility', 'label_class' => 'bp-screen-reader-text', 'notoggle_tag' => 'span', 'notoggle_class' => 'field-visibility-settings-notoggle'), 'xprofile_settings_visibility_select');
    // Empty return value, filled in below if a valid field ID is found.
    $retval = '';
    // Only do-the-do if there's a valid field ID.
    if (!empty($r['field_id'])) {
        // Start the output buffer.
        ob_start();
        // Output anything before.
        echo $r['before'];
        ?>

			<?php 
        if (bp_current_user_can('bp_xprofile_change_field_visibility')) {
            ?>

			<?php 
            echo $r['before_controls'];
            ?>

				<label for="<?php 
            echo esc_attr('field_' . $r['field_id']);
            ?>
_visibility" class="<?php 
            echo esc_attr($r['label_class']);
            ?>
"><?php 
            /* translators: accessibility text */
            _e('Select visibility', 'buddypress');
            ?>
</label>
				<select class="<?php 
            echo esc_attr($r['class']);
            ?>
" name="<?php 
            echo esc_attr('field_' . $r['field_id']);
            ?>
_visibility" id="<?php 
            echo esc_attr('field_' . $r['field_id']);
            ?>
_visibility">

					<?php 
            foreach (bp_xprofile_get_visibility_levels() as $level) {
                ?>

						<option value="<?php 
                echo esc_attr($level['id']);
                ?>
" <?php 
                selected($level['id'], bp_get_the_profile_field_visibility_level());
                ?>
><?php 
                echo esc_html($level['label']);
                ?>
</option>

					<?php 
            }
            ?>

				</select>

			<?php 
            echo $r['after_controls'];
            ?>

			<?php 
        } else {
            ?>

				<<?php 
            echo esc_html($r['notoggle_tag']);
            ?>
 class="<?php 
            echo esc_attr($r['notoggle_class']);
            ?>
"><?php 
            bp_the_profile_field_visibility_level_label();
            ?>
</<?php 
            echo esc_html($r['notoggle_tag']);
            ?>
>

			<?php 
        }
        // Output anything after.
        echo $r['after'];
        // Get the output buffer and empty it.
        $retval = ob_get_clean();
    }
    /**
     * Filters the dropdown list for setting visibility.
     *
     * @since 2.0.0
     *
     * @param string $retval HTML output for the visibility dropdown list.
     * @param array  $r      Parsed arguments to be used with display.
     * @param array  $args   Original passed in arguments to be used with display.
     */
    return apply_filters('bp_profile_settings_visibility_select', $retval, $r, $args);
}
/**
 * Handles the adding or editing of profile field data for a user.
 *
 * @param int      $group_id ID of the group.
 * @param int|null $field_id ID of the field being managed.
 */
function xprofile_admin_manage_field($group_id, $field_id = null)
{
    global $wpdb, $message, $groups;
    $bp = buddypress();
    if (is_null($field_id)) {
        $field = new BP_XProfile_Field();
    } else {
        $field = xprofile_get_field($field_id);
    }
    $field->group_id = $group_id;
    if (isset($_POST['saveField'])) {
        if (BP_XProfile_Field::admin_validate()) {
            $field->is_required = $_POST['required'];
            $field->type = $_POST['fieldtype'];
            $field->name = $_POST['title'];
            if (!empty($_POST['description'])) {
                $field->description = $_POST['description'];
            } else {
                $field->description = '';
            }
            if (!empty($_POST["sort_order_{$field->type}"])) {
                $field->order_by = $_POST["sort_order_{$field->type}"];
            }
            $field->field_order = $wpdb->get_var($wpdb->prepare("SELECT field_order FROM {$bp->profile->table_name_fields} WHERE id = %d", $field_id));
            if (empty($field->field_order) || is_wp_error($field->field_order)) {
                $field->field_order = (int) $wpdb->get_var($wpdb->prepare("SELECT max(field_order) FROM {$bp->profile->table_name_fields} WHERE group_id = %d", $group_id));
                $field->field_order++;
            }
            // For new profile fields, set the $field_id. For existing profile
            // fields, this will overwrite $field_id with the same value.
            $field_id = $field->save();
            if (empty($field_id)) {
                $message = __('There was an error saving the field. Please try again.', 'buddypress');
                $type = 'error';
            } else {
                $message = __('The field was saved successfully.', 'buddypress');
                $type = 'success';
                // @todo remove these old options
                if (1 == $field_id) {
                    bp_update_option('bp-xprofile-fullname-field-name', $field->name);
                }
                // Set member types.
                if (isset($_POST['has-member-types'])) {
                    $member_types = array();
                    if (isset($_POST['member-types'])) {
                        $member_types = stripslashes_deep($_POST['member-types']);
                    }
                    $field->set_member_types($member_types);
                }
                // Validate default visibility.
                if (!empty($_POST['default-visibility']) && in_array($_POST['default-visibility'], wp_list_pluck(bp_xprofile_get_visibility_levels(), 'id'))) {
                    bp_xprofile_update_field_meta($field_id, 'default_visibility', $_POST['default-visibility']);
                }
                // Validate custom visibility.
                if (!empty($_POST['allow-custom-visibility']) && in_array($_POST['allow-custom-visibility'], array('allowed', 'disabled'))) {
                    bp_xprofile_update_field_meta($field_id, 'allow_custom_visibility', $_POST['allow-custom-visibility']);
                }
                // Validate signup.
                if (!empty($_POST['signup-position'])) {
                    bp_xprofile_update_field_meta($field_id, 'signup_position', (int) $_POST['signup-position']);
                } else {
                    bp_xprofile_delete_meta($field_id, 'field', 'signup_position');
                }
                /**
                 * Fires at the end of the process to save a field for a user, if successful.
                 *
                 * @since 1.0.0
                 *
                 * @param BP_XProfile_Field $field Current BP_XProfile_Field object.
                 */
                do_action('xprofile_fields_saved_field', $field);
                $groups = bp_xprofile_get_groups();
            }
            unset($_GET['mode']);
            xprofile_admin($message, $type);
        } else {
            $field->render_admin_form($message);
        }
    } else {
        $field->render_admin_form();
    }
}
Example #6
0
    function render_admin_form($message = '')
    {
        if (empty($this->id)) {
            $title = __('Add Field', 'buddypress');
            $action = "admin.php?page=bp-profile-setup&amp;group_id=" . $this->group_id . "&amp;mode=add_field#tabs-" . $this->group_id;
            if (!empty($_POST['saveField'])) {
                $this->name = $_POST['title'];
                $this->description = $_POST['description'];
                $this->is_required = $_POST['required'];
                $this->type = $_POST['fieldtype'];
                $this->order_by = $_POST["sort_order_{$this->type}"];
                $this->field_order = $_POST['field_order'];
            }
        } else {
            $title = __('Edit Field', 'buddypress');
            $action = "admin.php?page=bp-profile-setup&amp;mode=edit_field&amp;group_id=" . $this->group_id . "&amp;field_id=" . $this->id . "#tabs-" . $this->group_id;
        }
        ?>

		<div class="wrap">
			<div id="icon-users" class="icon32"><br /></div>
			<h2><?php 
        echo $title;
        ?>
</h2>
			<p><?php 
        _e('Fields marked * are required', 'buddypress');
        ?>
</p>

			<?php 
        if (!empty($message)) {
            ?>

				<div id="message" class="error fade">
					<p><?php 
            echo $message;
            ?>
</p>
				</div>

			<?php 
        }
        ?>

			<form action="<?php 
        echo $action;
        ?>
" method="post">
				<div id="poststuff">
					<div id="titlediv">
						<h3><label for="title"><?php 
        _e('Field Title', 'buddypress');
        ?>
 *</label></h3>
						<div id="titlewrap">
							<input type="text" name="title" id="title" value="<?php 
        echo esc_attr($this->name);
        ?>
" style="width:50%" />
						</div>
					</div>

					<div id="titlediv">
						<h3><label for="description"><?php 
        _e("Field Description", 'buddypress');
        ?>
</label></h3>
						<div id="titlewrap">
							<textarea name="description" id="description" rows="8" cols="60"><?php 
        echo htmlspecialchars($this->description);
        ?>
</textarea>
						</div>
					</div>

					<?php 
        if ('0' != $this->can_delete) {
            ?>

						<div id="titlediv">
							<h3><label for="required"><?php 
            _e("Is This Field Required?", 'buddypress');
            ?>
 *</label></h3>
							<select name="required" id="required" style="width: 30%">
								<option value="0"<?php 
            if ($this->is_required == '0') {
                ?>
 selected="selected"<?php 
            }
            ?>
><?php 
            _e('Not Required', 'buddypress');
            ?>
</option>
								<option value="1"<?php 
            if ($this->is_required == '1') {
                ?>
 selected="selected"<?php 
            }
            ?>
><?php 
            _e('Required', 'buddypress');
            ?>
</option>
							</select>
						</div>

						<div id="titlediv">
							<h3><label for="fieldtype"><?php 
            _e("Field Type", 'buddypress');
            ?>
 *</label></h3>
							<select name="fieldtype" id="fieldtype" onchange="show_options(this.value)" style="width: 30%">
								<option value="textbox"<?php 
            if ($this->type == 'textbox') {
                ?>
 selected="selected"<?php 
            }
            ?>
><?php 
            _e('Text Box', 'buddypress');
            ?>
</option>
								<option value="textarea"<?php 
            if ($this->type == 'textarea') {
                ?>
 selected="selected"<?php 
            }
            ?>
><?php 
            _e('Multi-line Text Box', 'buddypress');
            ?>
</option>
								<option value="datebox"<?php 
            if ($this->type == 'datebox') {
                ?>
 selected="selected"<?php 
            }
            ?>
><?php 
            _e('Date Selector', 'buddypress');
            ?>
</option>
								<option value="radio"<?php 
            if ($this->type == 'radio') {
                ?>
 selected="selected"<?php 
            }
            ?>
><?php 
            _e('Radio Buttons', 'buddypress');
            ?>
</option>
								<option value="selectbox"<?php 
            if ($this->type == 'selectbox') {
                ?>
 selected="selected"<?php 
            }
            ?>
><?php 
            _e('Drop Down Select Box', 'buddypress');
            ?>
</option>
								<option value="multiselectbox"<?php 
            if ($this->type == 'multiselectbox') {
                ?>
 selected="selected"<?php 
            }
            ?>
><?php 
            _e('Multi Select Box', 'buddypress');
            ?>
</option>
								<option value="checkbox"<?php 
            if ($this->type == 'checkbox') {
                ?>
 selected="selected"<?php 
            }
            ?>
><?php 
            _e('Checkboxes', 'buddypress');
            ?>
</option>
							</select>
						</div>

						<?php 
            do_action_ref_array('xprofile_field_additional_options', array($this));
            ?>

						<?php 
            $this->render_admin_form_children();
            ?>

					<?php 
        } else {
            ?>

						<input type="hidden" name="required" id="required" value="1" />
						<input type="hidden" name="fieldtype" id="fieldtype" value="textbox" />

					<?php 
        }
        ?>

					<?php 
        /* The fullname field cannot be hidden */
        ?>
					<?php 
        if (1 != $this->id) {
            ?>

						<div id="titlediv">

							<div id="titlewrap">
								<h3><label for="default-visibility"><?php 
            _e("Default Visibility", 'buddypress');
            ?>
</label></h3>
								<ul>
								<?php 
            foreach (bp_xprofile_get_visibility_levels() as $level) {
                ?>
									<li><input type="radio" name="default-visibility" value="<?php 
                echo esc_attr($level['id']);
                ?>
" <?php 
                checked($this->default_visibility, $level['id']);
                ?>
> <?php 
                echo esc_html($level['label']);
                ?>
</li>
								<?php 
            }
            ?>
								</ul>
							</div>

							<div id="titlewrap">
								<h3><label for="allow-custom-visibility"><?php 
            _e("Per-Member Visibility", 'buddypress');
            ?>
</label></h3>
								<ul>
									<li><input type="radio" name="allow-custom-visibility" value="allowed" <?php 
            checked($this->allow_custom_visibility, 'allowed');
            ?>
> <?php 
            _e("Let members change the this field's visibility", 'buddypress');
            ?>
</li>

									<li><input type="radio" name="allow-custom-visibility" value="disabled" <?php 
            checked($this->allow_custom_visibility, 'disabled');
            ?>
> <?php 
            _e('Enforce the default visibility for all members', 'buddypress');
            ?>
</li>
								</ul>
							</div>
						</div>

					<?php 
        }
        ?>

					<p class="submit">
						<input type="hidden" name="field_order" id="field_order" value="<?php 
        echo esc_attr($this->field_order);
        ?>
" />
						<input type="submit" value="<?php 
        _e('Save', 'buddypress');
        ?>
" name="saveField" id="saveField" style="font-weight: bold" class="button-primary" />
						<?php 
        _e('or', 'buddypress');
        ?>
 <a href="admin.php?page=bp-profile-setup" class="deletion"><?php 
        _e('Cancel', 'buddypress');
        ?>
</a>
					</p>

				</div>

				<?php 
        wp_nonce_field('xprofile_delete_option');
        ?>

			</form>
		</div>

<?php 
    }
    /**
     * Private method used to output field visibility metaboxes.
     *
     * @since 2.3.0
     *
     * @return void If default field id 1.
     */
    private function visibility_metabox()
    {
        // Default field cannot have custom visibility.
        if (true === $this->is_default_field()) {
            return;
        }
        ?>

		<div class="postbox">
			<h2><label for="default-visibility"><?php 
        esc_html_e('Visibility', 'buddypress');
        ?>
</label></h2>
			<div class="inside">
				<div>
					<select name="default-visibility" id="default-visibility">

						<?php 
        foreach (bp_xprofile_get_visibility_levels() as $level) {
            ?>

							<option value="<?php 
            echo esc_attr($level['id']);
            ?>
" <?php 
            selected($this->get_default_visibility(), $level['id']);
            ?>
>
								<?php 
            echo esc_html($level['label']);
            ?>
							</option>

						<?php 
        }
        ?>

					</select>
				</div>

				<div>
					<ul>
						<li>
							<input type="radio" id="allow-custom-visibility-allowed" name="allow-custom-visibility" value="allowed" <?php 
        checked($this->get_allow_custom_visibility(), 'allowed');
        ?>
 />
							<label for="allow-custom-visibility-allowed"><?php 
        esc_html_e('Allow members to override', 'buddypress');
        ?>
</label>
						</li>
						<li>
							<input type="radio" id="allow-custom-visibility-disabled" name="allow-custom-visibility" value="disabled" <?php 
        checked($this->get_allow_custom_visibility(), 'disabled');
        ?>
 />
							<label for="allow-custom-visibility-disabled"><?php 
        esc_html_e('Enforce field visibility', 'buddypress');
        ?>
</label>
						</li>
					</ul>
				</div>
			</div>
		</div>

		<?php 
    }
/**
 * Return the XProfile field visibility select list for settings
 *
 * @since BuddyPress (2.0.0)
 */
function bp_profile_get_settings_visibility_select($args = '')
{
    // Parse optional arguments
    $r = bp_parse_args($args, array('field_id' => bp_get_the_profile_field_id(), 'before' => '', 'after' => '', 'class' => 'bp-xprofile-visibility'), 'xprofile_settings_visibility_select');
    // Empty return value, filled in below if a valid field ID is found
    $retval = '';
    // Only do-the-do if there's a valid field ID
    if (!empty($r['field_id'])) {
        // Start the output buffer
        ob_start();
        // Output anything before
        echo $r['before'];
        ?>

			<?php 
        if (bp_current_user_can('bp_xprofile_change_field_visibility')) {
            ?>

				<select class="<?php 
            echo esc_attr($r['class']);
            ?>
" name="<?php 
            echo esc_attr('field_' . $r['field_id']);
            ?>
_visibility">

					<?php 
            foreach (bp_xprofile_get_visibility_levels() as $level) {
                ?>

						<option value="<?php 
                echo esc_attr($level['id']);
                ?>
" <?php 
                selected($level['id'], bp_get_the_profile_field_visibility_level());
                ?>
><?php 
                echo esc_html($level['label']);
                ?>
</option>

					<?php 
            }
            ?>

				</select>

			<?php 
        } else {
            ?>

				<span class="field-visibility-settings-notoggle" title="<?php 
            esc_attr_e("This field's visibility cannot be changed.", 'buddypress');
            ?>
"><?php 
            bp_the_profile_field_visibility_level_label();
            ?>
</span>

			<?php 
        }
        // Output anything after
        echo $r['after'];
        // Get the output buffer and empty it
        $retval = ob_get_clean();
    }
    // Output the dropdown list
    return apply_filters('bp_profile_settings_visibility_select', $retval, $r, $args);
}
/**
 * Return the field visibility radio buttons
 */
function bp_profile_get_visibility_radio_buttons()
{
    $html = '<ul class="radio">';
    foreach (bp_xprofile_get_visibility_levels() as $level) {
        $checked = $level['id'] == bp_get_the_profile_field_visibility_level() ? ' checked="checked" ' : '';
        $html .= '<li><label for="see-field_' . esc_attr($level['id']) . '"><input type="radio" id="see-field_' . esc_attr($level['id']) . '" name="field_' . bp_get_the_profile_field_id() . '_visibility" value="' . esc_attr($level['id']) . '"' . $checked . ' /> ' . esc_html($level['label']) . '</label></li>';
    }
    $html .= '</ul>';
    return apply_filters('bp_profile_get_visibility_radio_buttons', $html);
}
        /**
         * Return the field visibility radio buttons
         */
        function ez_bp_profile_get_visibility_radio_buttons($arr_args = '')
        {
            global $field;
            $arr_ev_levels_processed = $this->_arr_ev_levels_processed;
            $str_ev_level = $this->ez_bp_get_the_profile_field_visibility_level();
            $str_field_edit = $arr_ev_levels_processed[$str_ev_level]['edit'];
            $str_field_viz = $arr_ev_levels_processed[$str_ev_level]['visible'];
            // Parse optional arguments
            $r = bp_parse_args($arr_args, array('field_id' => bp_get_the_profile_field_id(), 'before' => '<ul class="radio">', 'after' => '</ul>', 'before_radio' => '<li>', 'after_radio' => '</li>', 'class' => 'bp-xprofile-visibility'), 'xprofile_visibility_radio_buttons');
            // Empty return value, filled in below if a valid field ID is found
            $retval = '';
            // Only do-the-do if there's a valid field ID
            if (!empty($r['field_id'])) {
                // Start the output buffer
                ob_start();
                // Output anything before
                echo $r['before'];
                ?>

			<?php 
                if (bp_current_user_can('bp_xprofile_change_field_visibility')) {
                    ?>

				<?php 
                    $str_label_needle = ':';
                    foreach (bp_xprofile_get_visibility_levels() as $level) {
                        $str_edit = $this->get_level_edit($level['id']);
                        $str_viz = $this->get_level_visible($level['id']);
                        if ($str_edit == $str_field_edit) {
                            echo $r['before_radio'];
                            ?>
					  
					<label for="<?php 
                            echo esc_attr('see-field_' . $r['field_id'] . '_' . $level['id']);
                            ?>
">
						<input type="radio" id="<?php 
                            echo esc_attr('see-field_' . $r['field_id'] . '_' . $level['id']);
                            ?>
" name="<?php 
                            echo esc_attr('field_' . $r['field_id'] . '_visibility');
                            ?>
" value="<?php 
                            echo esc_attr($level['id']);
                            ?>
" <?php 
                            checked($level['id'], bp_get_the_profile_field_visibility_level());
                            ?>
 />
						<span class="field-visibility-text"><?php 
                            echo esc_html($this->ez_bp_get_the_profile_field_visibility_level_label($level['id']));
                            ?>
</span>
					</label>

					<?php 
                            echo $r['after_radio'];
                        }
                        ?>

				<?php 
                    }
                    ?>

			<?php 
                }
                // Output anything after
                echo $r['after'];
                // Get the output buffer and empty it
                $retval = ob_get_clean();
            }
            return apply_filters('bp_profile_get_visibility_radio_buttons', $retval, $r, $arr_args);
        }