field['after'] ) ) { $class['has-addons'] = 'has-addons'; $class[] = 'has-addons-append'; } if( $meta ){ $class[] = 'pseudo'; } $class = implode( ' ', $class ); // placeholder if( !empty( $this->field['std'] ) ) { $placeholder = $this->field['std']; } if( !empty($this->field['default_value']) ) $value = $this->field['default_value']; if( ! empty($this->value) ){ $value = $this->value; } // parameters $min = isset( $this->field['param']['min'] ) ? $this->field['param']['min'] : 1; $max = isset( $this->field['param']['max'] ) ? $this->field['param']['max'] : 100; $step = isset( $this->field['param']['step'] ) ? $this->field['param']['step'] : 1; $unit = isset( $this->field['param']['unit'] ) ? $this->field['param']['unit'] : ''; $clean_value = ''; if(isset($this->field['units'])){ if( $unit == '' ) $unit = 'px'; if( !empty($value) ){ $clean_value = str_replace(array('px', 'rem', 'em', '%', 'vw', 'vh'), '', $value); if( strpos($value, 'rem') !== false ){ $unit = 'rem'; }else if( strpos($value, 'em') !== false ){ $unit = 'em'; }else if( strpos($value, 'vw') !== false ){ $unit = 'vw'; }else if( strpos($value, 'vh') !== false ){ $unit = 'vh'; }else if( strpos($value, '%') !== false ){ $unit = '%'; } } } elseif( isset( $value ) ){ $clean_value = str_replace( array($unit, 'background'), '', $value ); } // output ----- echo '
'; // units if( isset( $this->field['units'] ) ){ if( $js ){ echo ''; }else{ echo ''; } } // except theme options if( $meta ){ if( $js ){ if( $js_ex_0 && !empty($js_ex_0) ){ echo 'get_name( $meta ) .' value="\'+( '.$js_ex_0.' && '.$js.' && typeof '.$js_ex_0.' !== \'undefined\' && typeof '.$js.' !== \'undefined\' ? '.$js.' : "")+\'">'; }else{ echo 'get_name( $meta ) .' value="\'+( '.$js.' && typeof '.$js.' !== \'undefined\' ? '.$js.' : "")+\'">'; } }else{ echo 'get_name( $meta ) .' value="'. esc_attr( $value ) .'">'; } } echo '
'; if( $js ){ if( $js_ex_0 ){ echo 'get_name( $meta ) : null ) .' value="\'+( '.$js_ex_0.' && '.$js.' && typeof '.$js_ex_0.' !== \'undefined\' && typeof '.$js.' !== \'undefined\' ? '.$js.'.replaceAll(/[a-z\%\s]/g, "") : "")+\'" placeholder="'. esc_attr( $placeholder ) .'" />'; }else{ if( !empty($unit) ){ echo 'get_name( $meta ) : null ) .' value="\'+( '.$js.' && typeof '.$js.' !== \'undefined\' ? '.$js.'.replaceAll(/[a-z\%\s]/g, "") : "")+\'" placeholder="'. esc_attr( $placeholder ) .'" />'; }else{ echo 'get_name( $meta ) : null ) .' value="\'+( '.$js.' && typeof '.$js.' !== \'undefined\' ? '.$js.' : "")+\'" placeholder="'. esc_attr( $placeholder ) .'" />'; } } }else{ // var_dump($this->value); // var_dump($clean_value); if( ! $meta ){ // theme options if( '' === $this->value ){ // empty value $clean_value = $this->field['std']; } elseif( '0' === $this->value ){ // zero $clean_value = 0; } } echo 'get_name( $meta ) : null ) .' value="'. esc_attr( $clean_value ) .'" placeholder="'. esc_attr( $placeholder ) .'" />'; } echo '
'; if( ! empty( $this->field['after'] ) ){ echo '
'; echo ''. esc_attr( $this->field['after'] ) .''; echo '
'; } echo '
'; if( ! $meta ){ echo '
'. esc_attr( $min ) .' - '. esc_attr( $max ) .'
'; } echo '
'; // theme options if( ! $meta ){ echo $this->get_description(); } } /** * Enqueue */ public function enqueue() { wp_enqueue_style( 'mfn-opts-jquery-ui-css' ); wp_enqueue_script( 'mfn-opts-field-sliderbar', MFN_OPTIONS_URI .'fields/sliderbar/field_sliderbar.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-slider' ), MFN_THEME_VERSION, true ); } }