BP_XProfile_Field_Type_WordPress_Textbox::admin_new_field_html( BP_XProfile_Field $current_field, string $control_type = '' )

This method usually outputs HTML for this field type’s children options on the wp-admin Profile Fields “Add Field” and “Edit Field” screens, but for this field type, we don’t want it, so it’s stubbed out.


Parameters Parameters

$current_field

(BP_XProfile_Field) (Required) The current profile field on the add/edit screen.

$control_type

(string) (Optional) HTML input type used to render the current field's child options.

Default value: ''


Source Source

File: bp-xprofile/classes/class-bp-xprofile-field-type-wordpress-textbox.php

	public function admin_new_field_html( BP_XProfile_Field $current_field, $control_type = '' ) {
		$type = array_search( get_class( $this ), bp_xprofile_get_field_types() );

		if ( false === $type ) {
			return;
		}

		$style = 'margin-top: 15px;';
		if ( $current_field->type !== $type ) {
			$style .= ' display: none;';
		};

		$setting = self::get_field_settings( $current_field->id );

		$wp_labels = array_merge(
			array(
				'first_name' => _x( 'First Name', 'xpofile wp-textbox field type label', 'buddypress' ),
				'last_name'  => _x( 'Last Name', 'xpofile wp-textbox field type label', 'buddypress' ),
				'user_url'   => _x( 'Website', 'xpofile wp-textbox field type label', 'buddypress' ),
			),
			wp_get_user_contact_methods()
		);
		?>
		<div id="<?php echo esc_attr( $type ); ?>" class="postbox bp-options-box" style="<?php echo esc_attr( $style ); ?>">
			<h3><?php esc_html_e( 'Select the information you want to use for your WordPress field.', 'buddypress' ); ?></h3>

			<div class="inside" aria-live="polite" aria-atomic="true" aria-relevant="all">
				<div class="bp-option">
					<ul>
						<?php
						foreach ( $this->supported_keys as $key ) {
							if ( 'description' === $key || ! isset( $wp_labels[ $key ] ) ) {
								continue;
							}

							printf(
								'<li>
									<label for="wp-textbox-wp_user_key-%1$s">
										<input type="radio" id="wp-textbox-wp_user_key-%1$s" name="field-settings[wp_user_key]" value="%1$s" %2$s/>
										%3$s
									</label>
								</li>',
								esc_attr( $key ),
								checked( $key, $setting, false ),
								esc_html( $wp_labels[ $key ] )
							);
						}
						?>
					</ul>
				</div>
			</div>
		</div>
		<?php
	}


Top ↑

Changelog Changelog

Changelog
Version Description
8.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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