| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Redux Framework is free software: you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation, either version 2 of the License, or |
| 7 |
* any later version. |
| 8 |
* Redux Framework is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU General Public License for more details. |
| 12 |
* You should have received a copy of the GNU General Public License |
| 13 |
* along with Redux Framework. If not, see <http://www.gnu.org/licenses/>. |
| 14 |
* |
| 15 |
* @package ReduxFramework |
| 16 |
* @subpackage Field_Date |
| 17 |
* @author Daniel J Griffiths (Ghost1227) |
| 18 |
* @author Dovy Paukstys |
| 19 |
* @author Kevin Provance (kprovance) |
| 20 |
* @version 3.0.0 |
| 21 |
*/ |
| 22 |
|
| 23 |
// Exit if accessed directly |
| 24 |
if ( ! defined( 'ABSPATH' ) ) { |
| 25 |
exit; |
| 26 |
} |
| 27 |
|
| 28 |
// Don't duplicate me! |
| 29 |
if ( ! class_exists( 'ReduxFramework_date' ) ) { |
| 30 |
|
| 31 |
/** |
| 32 |
* Main ReduxFramework_date class |
| 33 |
* |
| 34 |
* @since 1.0.0 |
| 35 |
*/ |
| 36 |
class ReduxFramework_date { |
| 37 |
|
| 38 |
/** |
| 39 |
* Field Constructor. |
| 40 |
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function |
| 41 |
* |
| 42 |
* @since 1.0.0 |
| 43 |
* @access public |
| 44 |
* @return void |
| 45 |
*/ |
| 46 |
function __construct( $field = array(), $value = '', $parent ) { |
| 47 |
$this->parent = $parent; |
| 48 |
$this->field = $field; |
| 49 |
$this->value = $value; |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* Field Render Function. |
| 54 |
* Takes the vars and outputs the HTML for the field in the settings |
| 55 |
* |
| 56 |
* @since 1.0.0 |
| 57 |
* @access public |
| 58 |
* @return void |
| 59 |
*/ |
| 60 |
public function render() { |
| 61 |
$placeholder = ( isset( $this->field['placeholder'] ) ) ? ' placeholder="' . esc_attr( $this->field['placeholder'] ) . '" ' : ''; |
| 62 |
|
| 63 |
echo '<input data-id="' . $this->field['id'] . '" type="text" id="' . $this->field['id'] . '-date" name="' . $this->field['name'] . $this->field['name_suffix'] . '"' . $placeholder . 'value="' . $this->value . '" class="redux-datepicker regular-text ' . $this->field['class'] . '" />'; |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* Enqueue Function. |
| 68 |
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
| 69 |
* |
| 70 |
* @since 1.0.0 |
| 71 |
* @access public |
| 72 |
* @return void |
| 73 |
*/ |
| 74 |
public function enqueue() { |
| 75 |
|
| 76 |
if ($this->parent->args['dev_mode']) { |
| 77 |
wp_enqueue_style( |
| 78 |
'redux-field-date-css', |
| 79 |
ReduxFramework::$_url . 'inc/fields/date/field_date.css', |
| 80 |
array(), |
| 81 |
time(), |
| 82 |
'all' |
| 83 |
); |
| 84 |
} |
| 85 |
|
| 86 |
wp_enqueue_script( |
| 87 |
'redux-field-date-js', |
| 88 |
ReduxFramework::$_url . 'inc/fields/date/field_date' . Redux_Functions::isMin() . '.js', |
| 89 |
array( 'jquery', 'jquery-ui-core', 'jquery-ui-datepicker', 'redux-js' ), |
| 90 |
time(), |
| 91 |
true |
| 92 |
); |
| 93 |
} |
| 94 |
} |
| 95 |
} |