function render_field($field) { // format value $hidden_value = ''; $display_value = ''; if ($field['value']) { $hidden_value = acf_format_date($field['value'], 'Y-m-d H:i:s'); $display_value = acf_format_date($field['value'], $field['display_format']); } // convert display_format to date and time // the letter 'm' is used for date and minute in JS, so this must be done here in PHP $formats = acf_split_date_time($field['display_format']); // vars $e = ''; $div = array('class' => 'acf-date-time-picker acf-input-wrap', 'data-date_format' => acf_convert_date_to_js($formats['date']), 'data-time_format' => acf_convert_time_to_js($formats['time']), 'data-first_day' => $field['first_day']); $hidden = array('id' => $field['id'], 'class' => 'input-alt', 'type' => 'hidden', 'name' => $field['name'], 'value' => $hidden_value); $input = array('class' => 'input', 'type' => 'text', 'value' => $display_value); // html $e .= '<div ' . acf_esc_attr($div) . '>'; $e .= '<input ' . acf_esc_attr($hidden) . '/>'; $e .= '<input ' . acf_esc_attr($input) . '/>'; $e .= '</div>'; // return echo $e; }
function render_field($field) { // vars $e = ''; $div = array('class' => 'acf-date_picker', 'data-display_format' => acf_convert_date_to_js($field['display_format']), 'data-first_day' => $field['first_day']); $input = array('id' => $field['id'], 'class' => 'input-alt', 'type' => 'hidden', 'name' => $field['name'], 'value' => $field['value']); // html $e .= '<div ' . acf_esc_attr($div) . '>'; $e .= '<input ' . acf_esc_attr($input) . '/>'; $e .= '<input type="text" value="" class="input" />'; $e .= '</div>'; // return echo $e; }
function render_field($field) { // format value $display_value = ''; if ($field['value']) { // get time $unixtimestamp = strtotime('0000-00-00 ' . $field['value']); // translate $display_value = date_i18n($field['display_format'], $unixtimestamp); } // vars $e = ''; $div = array('class' => 'acf-time-picker acf-input-wrap', 'data-time_format' => acf_convert_date_to_js($field['display_format'])); $hidden = array('id' => $field['id'], 'class' => 'input-alt', 'type' => 'hidden', 'name' => $field['name'], 'value' => $field['value']); $input = array('class' => 'input', 'type' => 'text', 'value' => $display_value); // html $e .= '<div ' . acf_esc_attr($div) . '>'; $e .= '<input ' . acf_esc_attr($hidden) . '/>'; $e .= '<input ' . acf_esc_attr($input) . '/>'; $e .= '</div>'; // return echo $e; }
function render_field($field) { // format value $hidden_value = ''; $display_value = ''; if ($field['value']) { $hidden_value = acf_format_date($field['value'], 'Ymd'); $display_value = acf_format_date($field['value'], $field['display_format']); } // vars $e = ''; $div = array('class' => 'acf-date-picker acf-input-wrap', 'data-date_format' => acf_convert_date_to_js($field['display_format']), 'data-first_day' => $field['first_day']); $hidden = array('id' => $field['id'], 'class' => 'input-alt', 'type' => 'hidden', 'name' => $field['name'], 'value' => $hidden_value); $input = array('class' => 'input', 'type' => 'text', 'value' => $display_value); // save_format - compatibility with ACF < 5.0.0 if (!empty($field['save_format'])) { // add custom JS save format $div['data-save_format'] = $field['save_format']; // revert hidden input value to raw DB value $hidden['value'] = $field['value']; // remove formatted value (will do this via JS) $input['value'] = ''; } // html $e .= '<div ' . acf_esc_attr($div) . '>'; $e .= '<input ' . acf_esc_attr($hidden) . '/>'; $e .= '<input ' . acf_esc_attr($input) . '/>'; $e .= '</div>'; // return echo $e; }
function render_field($field) { // format value $hidden_value = ''; $display_value = ''; if ($field['value']) { $hidden_value = acf_format_date($field['value'], 'Ymd'); $display_value = acf_format_date($field['value'], $field['display_format']); } // vars $e = ''; $div = array('class' => 'acf-date-picker acf-input-wrap', 'data-date_format' => acf_convert_date_to_js($field['display_format']), 'data-first_day' => $field['first_day']); $hidden = array('id' => $field['id'], 'class' => 'input-alt', 'type' => 'hidden', 'name' => $field['name'], 'value' => $hidden_value); $input = array('class' => 'input', 'type' => 'text', 'value' => $display_value); // html $e .= '<div ' . acf_esc_attr($div) . '>'; $e .= '<input ' . acf_esc_attr($hidden) . '/>'; $e .= '<input ' . acf_esc_attr($input) . '/>'; $e .= '</div>'; // return echo $e; }
function display_quickedit_field($column, $post_type, $field) { ?> <fieldset class="inline-edit-col-left inline-edit-<?php echo $post_type; ?> "><?php ?> <div class="inline-edit-col column-<?php echo $column; ?> "><?php ?> <label class="inline-edit-group"><?php ?> <span class="title"><?php echo $field['label']; ?> </span><?php ?> <span class="input-text-wrap"><?php $input_atts = array('data-acf-field-key' => $field['key'], 'name' => $this->post_field_prefix . $column); switch ($field['type']) { case 'checkbox': $input_atts += array('class' => 'acf-quick-edit', 'id' => $this->post_field_prefix . $column); $field['value'] = \acf_get_array($field['value'], false); $input_atts['name'] .= '[]'; foreach ($field['choices'] as $value => $label) { $atts = array('type' => 'checkbox', 'value' => $value) + $input_atts; if (in_array($value, $field['value'])) { $atts['checked'] = 'checked'; } else { $all_checked = false; } $atts['id'] .= '-' . $value; echo '<label><input ' . \acf_esc_attr($atts) . '/>' . $label . '</label>'; } break; case 'select': $input_atts += array('class' => 'acf-quick-edit widefat', 'id' => $this->post_field_prefix . $column); if ($field['multiple']) { $input_atts['multiple'] = 'multiple'; } ?> <select <?php echo \acf_esc_attr($input_atts); ?> ><?php if ($field['allow_null']) { echo '<option value="">' . '- ' . \__('Select', 'acf-quick-edit-fields') . ' -'; } foreach ($field['choices'] as $name => $label) { echo '<option value="' . $name . '">' . $label; } ?> </select><?php break; case 'radio': ?> <ul class="acf-radio-list<?php echo $field['other_choice'] ? ' other' : ''; ?> " data-acf-field-key="<?php echo $field['key']; ?> "><?php foreach ($field['choices'] as $name => $value) { ?> <li><label for="<?php echo $this->post_field_prefix . $column . '-' . $name; ?> "><?php ?> <input id="<?php echo $this->post_field_prefix . $column . '-' . $name; ?> " type="radio" value="<?php echo $name; ?> " class="acf-quick-edit" data-acf-field-key="<?php echo $field['key']; ?> " name="<?php echo $this->post_field_prefix . $column; ?> " /><?php echo $value; ?> </label></li><?php } if ($field['other_choice']) { ?> <li><label for="<?php echo $this->post_field_prefix . $column . '-other'; ?> "><?php ?> <input id="<?php echo $this->post_field_prefix . $column . '-other'; ?> " type="radio" value="other" class="acf-quick-edit" data-acf-field-key="<?php echo $field['key']; ?> " name="<?php echo $this->post_field_prefix . $column; ?> " /><?php ?> <input type="text" class="acf-quick-edit" data-acf-field-key="<?php echo $field['key']; ?> " name="<?php echo $this->post_field_prefix . $column; ?> " style="width:initial" /><?php ?> </li><?php ?> </label><?php } ?> </ul><?php break; case 'true_false': ?> <ul class="acf-radio-list" data-acf-field-key="<?php echo $field['key']; ?> "><?php ?> <li><label for="<?php echo $this->post_field_prefix . $column; ?> -yes"><?php ?> <input id="<?php echo $this->post_field_prefix . $column; ?> -yes" type="radio" value="1" class="acf-quick-edit" data-acf-field-key="<?php echo $field['key']; ?> " name="<?php echo $this->post_field_prefix . $column; ?> " /><?php _e('Yes', 'acf-quick-edit-fields'); ?> </label></li><?php ?> <li><label for="<?php echo $this->post_field_prefix . $column; ?> -no"><?php ?> <input id="<?php echo $this->post_field_prefix . $column; ?> -no" type="radio" value="0" class="acf-quick-edit" data-acf-field-key="<?php echo $field['key']; ?> " name="<?php echo $this->post_field_prefix . $column; ?> " /><?php \_e('No', 'acf-quick-edit-fields'); ?> </label></li><?php ?> </ul><?php break; case 'number': $input_atts += array('class' => 'acf-quick-edit', 'type' => 'number', 'min' => $field['min'], 'max' => $field['max'], 'step' => $field['step']); echo '<input ' . \acf_esc_attr($input_atts) . ' />'; break; case 'date_picker': $input_atts += array('class' => 'acf-quick-edit acf-quick-edit-' . $field['type'], 'type' => 'text', 'data-display_format' => \acf_convert_date_to_js($field['display_format']), 'data-first_day' => $field['first_day']); echo '<input ' . \acf_esc_attr($input_atts) . ' />'; break; case 'textarea': $input_atts += array('class' => 'acf-quick-edit acf-quick-edit-' . $field['type'], 'type' => 'text'); echo '<textarea ' . \acf_esc_attr($input_atts) . '>' . esc_textarea($field['value']) . '</textarea>'; break; default: $input_atts += array('class' => 'acf-quick-edit acf-quick-edit-' . $field['type'], 'type' => 'text'); echo '<input ' . \acf_esc_attr($input_atts) . ' />'; break; } ?> </span><?php ?> </label><?php ?> </div><?php ?> </fieldset><?php }