balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

class-redux-date.php (2279B)


      1 <?php
      2 /**
      3  * Date Field.
      4  *
      5  * @package     ReduxFramework/Fields
      6  * @author      Dovy Paukstys & Kevin Provance (kprovance)
      7  * @version     4.0.0
      8  */
      9 
     10 defined( 'ABSPATH' ) || exit;
     11 
     12 // Don't duplicate me!
     13 if ( ! class_exists( 'Redux_Date', false ) ) {
     14 
     15 	/**
     16 	 * Main Redux_date class
     17 	 *
     18 	 * @since       1.0.0
     19 	 */
     20 	class Redux_Date extends Redux_Field {
     21 
     22 		/**
     23 		 * Field Render Function.
     24 		 * Takes the vars and outputs the HTML for the field in the settings
     25 		 *
     26 		 * @since         1.0.0
     27 		 * @access        public
     28 		 * @return        void
     29 		 */
     30 		public function render() {
     31 			$placeholder = ( isset( $this->field['placeholder'] ) ) ? ' placeholder="' . $this->field['placeholder'] . '" ' : '';
     32 
     33 			$this->field['attributes']['data-id']     = $this->field['id'];
     34 			$this->field['attributes']['id']          = $this->field['id'];
     35 			$this->field['attributes']['name']        = esc_attr( $this->field['name'] . $this->field['name_suffix'] );
     36 			$this->field['attributes']['value']       = $this->value;
     37 			$this->field['attributes']['placeholder'] = ( isset( $this->field['placeholder'] ) && ! is_array( $this->field['placeholder'] ) ) ? esc_attr( $this->field['placeholder'] ) : '';
     38 			$this->field['attributes']['class']       = 'redux-datepicker regular-text ' . esc_attr( $this->field['class'] );
     39 			$attributes_string                        = $this->render_attributes( $this->field['attributes'] );
     40 			echo '<input ' . $attributes_string . '>'; // phpcs:ignore WordPress.Security.EscapeOutput
     41 		}
     42 
     43 		/**
     44 		 * Enqueue Function.
     45 		 * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
     46 		 *
     47 		 * @since         1.0.0
     48 		 * @access        public
     49 		 * @return        void
     50 		 */
     51 		public function enqueue() {
     52 			if ( $this->parent->args['dev_mode'] ) {
     53 				wp_enqueue_style(
     54 					'redux-field-date-css',
     55 					Redux_Core::$url . 'inc/fields/date/redux-date.css',
     56 					array(),
     57 					$this->timestamp
     58 				);
     59 			}
     60 
     61 			wp_enqueue_script(
     62 				'redux-field-date-js',
     63 				Redux_Core::$url . 'inc/fields/date/redux-date' . Redux_Functions::is_min() . '.js',
     64 				array( 'jquery', 'jquery-ui-core', 'jquery-ui-datepicker', 'redux-js' ),
     65 				$this->timestamp,
     66 				true
     67 			);
     68 		}
     69 	}
     70 }
     71 
     72 class_alias( 'Redux_Date', 'ReduxFramework_Date' );