bp_profile_get_settings_visibility_select( array|string $args = '' )

Return the XProfile field visibility select list for settings.


Parameters Parameters

$args

(array|string) (Optional) Args for the select list.

  • 'field_id'
    (int) ID of the field to render.
  • 'before'
    (string) Markup to render before the field.
  • 'before_controls'
    (string) markup before form controls.
  • 'after'
    (string) Markup to render after the field.
  • 'after_controls'
    (string) Markup after the form controls.
  • 'class'
    (string) Class to apply to the field markup.
  • 'label_class'
    (string) Class to apply for the label element.
  • 'notoggle_tag'
    (string) Markup element to use for notoggle tag.
  • 'notoggle_class'
    (string) Class to apply to the notoggle element.

Default value: ''


Top ↑

Return Return

(string) $retval


Source Source

File: bp-xprofile/bp-xprofile-template.php

	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 endforeach; ?>

				</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 endif;

			// Output anything after.
			echo $r['after'];

			// Get the output buffer and empty it.
			$retval = ob_get_clean();
		endif;

		/**
		 * 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 );
	}


Top ↑

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.