date_picker.php
| 1 | <?php |
| 2 | |
| 3 | class acf_Date_picker extends acf_Field |
| 4 | { |
| 5 | |
| 6 | /*-------------------------------------------------------------------------------------- |
| 7 | * |
| 8 | * Constructor |
| 9 | * |
| 10 | * @author Elliot Condon |
| 11 | * @since 1.0.0 |
| 12 | * @updated 2.2.0 |
| 13 | * |
| 14 | *-------------------------------------------------------------------------------------*/ |
| 15 | |
| 16 | function __construct($parent) |
| 17 | { |
| 18 | parent::__construct($parent); |
| 19 | |
| 20 | $this->name = 'date_picker'; |
| 21 | $this->title = __("Date Picker",'acf'); |
| 22 | |
| 23 | } |
| 24 | |
| 25 | |
| 26 | /*-------------------------------------------------------------------------------------- |
| 27 | * |
| 28 | * admin_head |
| 29 | * |
| 30 | * @author Elliot Condon |
| 31 | * @since 2.0.6 |
| 32 | * |
| 33 | *-------------------------------------------------------------------------------------*/ |
| 34 | |
| 35 | function admin_head() |
| 36 | { |
| 37 | // add datepicker |
| 38 | echo '<link rel="stylesheet" type="text/css" href="'.$this->parent->dir.'/core/fields/date_picker/style.date_picker.css" />'; |
| 39 | echo '<script type="text/javascript" src="'.$this->parent->dir.'/core/fields/date_picker/jquery.ui.datepicker.js" ></script>'; |
| 40 | } |
| 41 | |
| 42 | |
| 43 | /*-------------------------------------------------------------------------------------- |
| 44 | * |
| 45 | * create_field |
| 46 | * |
| 47 | * @author Elliot Condon |
| 48 | * @since 2.0.5 |
| 49 | * @updated 2.2.0 |
| 50 | * |
| 51 | *-------------------------------------------------------------------------------------*/ |
| 52 | |
| 53 | function create_field($field) |
| 54 | { |
| 55 | // vars |
| 56 | $field['date_format'] = isset($field['date_format']) ? $field['date_format'] : 'dd/mm/yy'; |
| 57 | |
| 58 | // html |
| 59 | echo '<input type="text" value="' . $field['value'] . '" class="acf_datepicker" name="' . $field['name'] . '" data-date_format="' . $field['date_format'] . '" />'; |
| 60 | |
| 61 | } |
| 62 | |
| 63 | |
| 64 | /*-------------------------------------------------------------------------------------- |
| 65 | * |
| 66 | * create_options |
| 67 | * |
| 68 | * @author Elliot Condon |
| 69 | * @since 2.0.6 |
| 70 | * @updated 2.2.0 |
| 71 | * |
| 72 | *-------------------------------------------------------------------------------------*/ |
| 73 | |
| 74 | function create_options($key, $field) |
| 75 | { |
| 76 | // defaults |
| 77 | $field['date_format'] = isset($field['date_format']) ? $field['date_format'] : ''; |
| 78 | |
| 79 | ?> |
| 80 | <tr class="field_option field_option_<?php echo $this->name; ?>"> |
| 81 | <td class="label"> |
| 82 | <label><?php _e("Date format",'acf'); ?></label> |
| 83 | <p class="description"><?php _e("eg. dd/mm/yy. read more about",'acf'); ?> <a href="http://docs.jquery.com/UI/Datepicker/formatDate">formatDate</a></p> |
| 84 | </td> |
| 85 | <td> |
| 86 | <input type="text" name="fields[<?php echo $key; ?>][date_format]" value="<?php echo $field['date_format']; ?>" /> |
| 87 | </td> |
| 88 | </tr> |
| 89 | |
| 90 | <?php |
| 91 | } |
| 92 | |
| 93 | |
| 94 | |
| 95 | } |
| 96 | |
| 97 | ?> |