parent = $parent; $this->field = $field; $this->value = $value; if (empty(self::$_extension_dir)) { $this->_extension_dir = trailingslashit(str_replace('\\', '/', dirname(__FILE__))); $this->_extension_url = site_url(str_replace(trailingslashit(str_replace('\\', '/', ABSPATH)), '', $this->_extension_dir)); } // No errors please $defaults = array( 'speed' => false, 'action' => false, 'options' => '', 'mode' => array( 'speed' => false, 'action' => false, ), ); $this->field = wp_parse_args($this->field, $defaults); $defaults = array( 'speed' => '', 'action' => '', 'options' => '' ); $this->value = wp_parse_args($this->value, $defaults); } function render() { echo '
'; if (isset($this->field['select2'])) { $select2_params = json_encode($this->field['select2']); $select2_params = htmlspecialchars($select2_params, ENT_QUOTES); echo ''; } //echo ''; if (isset($this->field['options']) && is_array($this->field['options'])) { echo ''; echo '
'; echo ''; echo '
'; }; if (isset($this->field['action']) && is_array($this->field['action'])) { echo ''; echo '
'; echo ''; echo '
'; }; if (isset($this->field['speed']) && is_array($this->field['speed'])) { echo ''; echo '
'; echo ''; echo '
'; }; echo "
"; } function enqueue() { wp_enqueue_style('select2-css'); wp_enqueue_style( 'redux-field-animation-css', $this->_extension_url . 'field_animation' . Redux_Functions::isMin() . '.css', array(), time(), 'all' ); wp_enqueue_script( 'redux-field-animation-js', $this->_extension_url . 'field_animation' . Redux_Functions::isMin() . '.js', array('jquery', 'select2-js', 'redux-js'), time(), true ); } public function output() { // if field options has a value and IS an array, then evaluate as needed. if (isset($this->field['options']) && !is_array($this->field['options'])) { //if options fields has a value but options value does not then make options value the field value if (isset($this->field['options']) && !isset($this->value['options']) || $this->field['options'] == false) { $this->value['options'] = $this->field['options']; // If options field does NOT have a value and options value does NOT have a value, set both to blank (default?) } else if (!isset($this->field['options']) && !isset($this->value['options'])) { $this->field['options'] = 'px'; $this->value['options'] = 'px'; // If options field has NO value but options value does, then set unit field to value field } else if (!isset($this->field['options']) && isset($this->value['options'])) { $this->field['options'] = $this->value['options']; // if unit value is set and unit value doesn't equal unit field (coz who knows why) // then set unit value to unit field } elseif (isset($this->value['options']) && $this->value['options'] !== $this->field['options']) { $this->value['options'] = $this->field['options']; } // do stuff based on unit field NOT set as an array } elseif (isset($this->field['options']) && is_array($this->field['options'])) { // nothing to do here, but I'm leaving the construct just in case I have to debug this again. } $options = isset($this->value['options']) ? $this->value['options'] : ""; $action = isset($this->value['action']) ? $this->value['action'] : ""; $speed = isset($this->value['speed']) ? $this->value['speed'] : ""; $style = ""; foreach ($cleanValue as $key => $value) { // Output if it's a numeric entry if (isset($value) && is_numeric($value)) { $style .= $key . ':' . $value . $options . ';'; } } if (!empty($style)) { if (!empty($this->field['output']) && is_array($this->field['output'])) { $keys = implode(",", $this->field['output']); $this->parent->outputCSS .= $keys . "{" . $style . '}'; } if (!empty($this->field['compiler']) && is_array($this->field['compiler'])) { $keys = implode(",", $this->field['compiler']); $this->parent->compilerCSS .= $keys . "{" . $style . '}'; } } } } }