BP_XProfile_Field_Type_Datebox::admin_new_field_html( BP_XProfile_Field $current_field, string $control_type = '' )
Generate the settings markup for Date fields.
Description
Parameters
- $current_field
-
(Required) The current profile field on the add/edit screen.
- $control_type
-
(Optional) HTML input type used to render the current field's child options.
Default value: ''
Source
File: bp-xprofile/classes/class-bp-xprofile-field-type-datebox.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; } $class = $current_field->type != $type ? 'display: none;' : ''; $settings = self::get_field_settings( $current_field->id ); ?> <div id="<?php echo esc_attr( $type ); ?>" class="postbox bp-options-box" style="<?php echo esc_attr( $class ); ?> margin-top: 15px;"> <table class="form-table bp-date-options"> <tr> <th scope="row"> <?php esc_html_e( 'Date format', 'buddyboss' ); ?> </th> <td> <fieldset> <legend class="screen-reader-text"> <?php esc_html_e( 'Date format', 'buddyboss' ); ?> </legend> <?php foreach ( $this->get_date_formats() as $format ): ?> <div class="bp-date-format-option"> <label for="date-format-<?php echo esc_attr( $format ); ?>"> <input type="radio" name="field-settings[date_format]" id="date-format-<?php echo esc_attr( $format ); ?>" value="<?php echo esc_attr( $format ); ?>" <?php checked( $format, $settings['date_format'] ); ?> /> <span class="date-format-label"><?php echo date_i18n( $format ); ?></span> <code><?php echo esc_html( $format ); ?></code> </label> </div> <?php endforeach;?> <div class="bp-date-format-option"> <label for="date-format-elapsed"> <input type="radio" name="field-settings[date_format]" id="date-format-elapsed" <?php checked( 'elapsed', $settings['date_format'] ); ?> value="elapsed" aria-describedby="date-format-elapsed-setting" /> <span class="date-format-label" id="date-format-elapsed-setting"><?php esc_html_e( 'Time elapsed', 'buddyboss' ); ?></span> <?php _e( '<code>4 years ago</code>, <code>4 years from now</code>', 'buddyboss' ); ?> </label> </div> <div class="bp-date-format-option"> <label for="date-format-custom"> <input type="radio" name="field-settings[date_format]" id="date-format-custom" <?php checked( 'custom', $settings['date_format'] ); ?> value="custom" /> <span class="date-format-label"><?php esc_html_e( 'Custom:', 'buddyboss' ); ?></span> </label> <label for="date-format-custom-value" class="screen-reader-text"><?php esc_html_e( 'Enter custom time format', 'buddyboss' ); ?></label> <input type="text" name="field-settings[date_format_custom]" id="date-format-custom-value" class="date-format-custom-value" value="<?php echo esc_attr( $settings['date_format_custom'] ); ?>" aria-describedby="date-format-custom-example" /> <span class="screen-reader-text"><?php esc_html_e( 'Example:', 'buddyboss' ); ?></span><span class="date-format-custom-example" id="date-format-custom-sample"><?php if ( $settings['date_format_custom'] ) : ?><?php echo esc_html( date_i18n( $settings['date_format_custom'] ) ); endif; ?></span><span class="spinner" id="date-format-custom-spinner" aria-hidden="true"></span> <p><a href="https://wordpress.org/support/article/formatting-date-and-time/"><?php esc_html_e( 'Documentation on date and time formatting', 'buddyboss' ); ?></a></p> </div> </fieldset> </td> </tr> <tr> <th scope="row"> <?php esc_html_e( 'Range', 'buddyboss' ); ?> </th> <td> <fieldset class="bp-range-types"> <legend class="screen-reader-text"> <?php esc_html_e( 'Range', 'buddyboss' ); ?> </legend> <div class="bp-date-format-option"> <div class="bp-date-range-type-label"> <label for="range_type_absolute"> <input type="radio" name="field-settings[range_type]" id="range_type_absolute" value="absolute" <?php checked( 'absolute', $settings['range_type'] ); ?> /> <?php esc_html_e( 'Absolute', 'buddyboss' ); ?> </label> </div> <div class="bp-date-range-type-values"> <label for="field-settings[range_absolute_start]" aria-label="Year"><?php esc_html_e( 'Start:', 'buddyboss' ); ?></label> <?php printf( '<input class="date-range-numeric" type="text" name="field-settings[range_absolute_start]" id="field-settings[range_absolute_start]" value="%s" />', esc_attr( $settings['range_absolute_start'] ) ); ?> <label for="field-settings[range_absolute_end]" aria-label="Year"><?php esc_html_e( 'End:', 'buddyboss' ); ?></label> <?php printf( '<input class="date-range-numeric" type="text" name="field-settings[range_absolute_end]" id="field-settings[range_absolute_end]" value="%s" />', esc_attr( $settings['range_absolute_end'] ) ); ?> </div> </div> <div class="bp-date-format-option"> <div class="bp-date-range-type-label"> <label for="range_type_relative"> <input type="radio" name="field-settings[range_type]" id="range_type_relative" value="relative" <?php checked( 'relative', $settings['range_type'] ); ?> /> <?php esc_html_e( 'Relative', 'buddyboss' ); ?> </label> </div> <div class="bp-date-range-type-values"> <label for="field-settings[range_relative_start]"><?php esc_html_e( 'Start:', 'buddyboss' ); ?></label> <?php printf( '<input type="text" class="date-range-numeric" name="field-settings[range_relative_start]" id="field-settings[range_relative_start]" value="%s" />', esc_attr( abs( $settings['range_relative_start'] ) ) ); ?> <label class="screen-reader-text" for="field-settings[range_relative_start_type]"><?php esc_html_e( 'Select range', 'buddyboss' ); ?></label> <?php printf( '<select name="field-settings[range_relative_start_type]" id="field-settings[range_relative_start_type]"><option value="past" %s>%s</option><option value="future" %s>%s</option></select>', selected( true, $settings['range_relative_start'] <= 0, false ), esc_attr__( 'years ago', 'buddyboss' ), selected( true, $settings['range_relative_start'] > 0, false ), esc_attr__( 'years from now', 'buddyboss' ) ); ?> <label for="field-settings[range_relative_end]"><?php esc_html_e( 'End:', 'buddyboss' ); ?></label> <?php printf( '<input type="text" class="date-range-numeric" name="field-settings[range_relative_end]" id="field-settings[range_relative_end]" value="%s" />', esc_attr( abs( $settings['range_relative_end'] ) ) ); ?> <label class="screen-reader-text" for="field-settings[range_relative_end_type]"><?php esc_html_e( 'Select range', 'buddyboss' ); ?></label> <?php printf( '<select name="field-settings[range_relative_end_type]" id="field-settings[range_relative_end_type]"><option value="past" %s>%s</option><option value="future" %s>%s</option></select>', selected( true, $settings['range_relative_end'] <= 0, false ), esc_attr__( 'years ago', 'buddyboss' ), selected( true, $settings['range_relative_end'] > 0, false ), esc_attr__( 'years from now', 'buddyboss' ) ); ?> </div> </div> </fieldset> </td> </tr> </table> </div> <?php }
Changelog
Version | Description |
---|---|
BuddyPress 2.7.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.