LLMS_Metabox_Date_Field::output()

outputs the Html for the given field


Return Return

(void)


Top ↑

Source Source

File: includes/admin/post-types/meta-boxes/fields/llms.class.meta.box.date.php

	public function output() {

		global $post;

		parent::output(); ?>
		<?php
		// Convert the meta value into display format.
		$js_display_date = $this->meta;
		if ( ! empty( $this->meta ) ) {
			$meta_date = DateTime::createFromFormat( $this->jquery_date_to_php_format( $this->field['date_format'] ), $this->meta );

			if ( ! $meta_date ) {
				error_log( sprintf( 'Meta value %s for field %s is not in the expected format %s', $this->meta, $this->field['id'], $this->field['date_format'] ) );
			}

			if ( $meta_date ) {
				$js_display_date = $meta_date->format( $this->jquery_date_to_php_format( $this->field['date_displayformat'] ) );
			}
		}
		?>
		<input type="hidden"
				id="<?php echo esc_attr( $this->field['id'] ); ?>_alt_datefield"
				name="<?php echo esc_attr( $this->field['id'] ); ?>"
				value="<?php echo ! empty( $this->meta ) ? esc_attr( $this->meta ) : ''; ?>"
			<?php if ( isset( $this->field['required'] ) && $this->field['required'] ) : ?>
				required="required"
			<?php endif; ?>
		/>
		<input type="text"
			name="<?php echo esc_attr( $this->field['id'] ); ?>_datepicker"
			id="<?php echo esc_attr( $this->field['id'] ); ?>"
			class="<?php echo esc_attr( $this->field['class'] ); ?>"
			value="<?php echo ! empty( $this->meta ) ? esc_attr( $js_display_date ) : ''; ?>"
			size="30"
			<?php if ( isset( $this->field['required'] ) && $this->field['required'] ) : ?>
			required="required"
			<?php endif; ?>
			<?php if ( isset( $this->field['placeholder'] ) ) : ?>
			placeholder="<?php echo esc_attr( $this->field['placeholder'] ); ?>"
			<?php endif; ?>
			data-format="<?php echo esc_attr( $this->field['date_displayformat'] ); ?>"
			data-alt-format="<?php echo esc_attr( $this->field['date_format'] ); ?>"
			<?php if ( ! empty( $this->field['date_max'] ) ) : ?>
				data-max-date="<?php echo esc_attr( $this->field['date_max'] ); ?>"
			<?php endif; ?>
			<?php if ( ! empty( $this->field['date_min'] ) ) : ?>
				data-min-date="<?php echo esc_attr( $this->field['date_min'] ); ?>"
			<?php endif; ?>
			data-alt-field="#<?php echo esc_attr( $this->field['id'] ); ?>_alt_datefield"

		/>
		<?php
		parent::close_output();
	}


Top ↑

Changelog Changelog

Changelog
Version Description
?? Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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