true )
);
}
/**
* Slider tag callback
*/
public function slider_tag_handler_callback( $tag ) {
$validation_error = wpcf7_get_validation_error( $tag->name );
$class = wpcf7_form_controls_class( $tag->type );
if ( $validation_error ) {
$class .= ' wpcf7-not-valid';
}
$atts = array();
$class .= ' uacf7-range-slider';
$atts['class'] = $class;
if ( $tag->is_required() ) {
$atts['aria-required'] = 'true';
}
$atts['aria-invalid'] = $validation_error ? 'true' : 'false';
$atts = wpcf7_format_atts( $atts );
$show_value = !empty( $tag->get_option( 'show_value', '', true ) ) ? $tag->get_option( 'show_value', '', true ) : 'on';
$handle = !empty( $tag->get_option( 'handle', '', true ) ) ? $tag->get_option( 'handle', '', true ) : '1';
if(class_exists('UACF7_RANGE_SLIDER_PRO')){
$label = !empty( $tag->get_option( 'label', '', true ) ) ? $tag->get_option( 'label', '', true ) : '';
$separator = !empty( $tag->get_option( 'separator', '', true ) ) ? $tag->get_option( 'separator', '', true ) : '-';
$min_label = !empty( $tag->get_option( 'min_label', '', true ) ) ? $tag->get_option( 'min_label', '', true ) : 'Min : ';
$max_label = !empty( $tag->get_option( 'max_label', '', true ) ) ? $tag->get_option( 'max_label', '', true ) : 'Max : ';
}else{
$label = '';
$separator = '-';
$min_label = 'Min : ';
$max_label = 'Max : ';
}
$min = !empty( $tag->get_option( 'min', '', true ) ) ? $tag->get_option( 'min', '', true ) : 0;
$max = !empty( $tag->get_option( 'max', '', true ) ) ? $tag->get_option( 'max', '', true ) : 100;
$default = !empty( $tag->get_option( 'default', '', true ) ) ? $tag->get_option( 'default', '', true ) : 100;
$step = !empty( $tag->get_option( 'step', '', true ) ) ? $tag->get_option( 'step', '', true ) : 1;
$steps = '0';
for ($x = $step; $x <= $max; $x+=$step) {
$steps .= ','.$x.'';
}
// return array for range style as $values[0]
if ( $data = (array) $tag->get_data_option() ) {
$tag->values = array_merge( $tag->values, array_values( $data ) );
}
$values = $tag->values;
$newValue = (esc_html( $default ) - esc_html( $min )) * 100 / (esc_html( $max) - esc_html( $min));
ob_start();
if ( $handle == 1 ) {
echo '
';
if( $show_value == 'on'){
?>
__( 'UACF7 Range Slider', 'ultimate-addons-cf7' ),
'callback' => array( $this, 'uacf7_create_range_slider_panel_fields' ),
);
return $panels;
}
/**
* Range Slider Panel Fields
*/
public function uacf7_create_range_slider_panel_fields( $post ) {
$selection_color = ! empty( get_post_meta( $post->id(), 'uacf7_range_selection_color', true )) ? get_post_meta( $post->id(), 'uacf7_range_selection_color', true ) : "#1e90ff" ;
$handle_width = get_post_meta( $post->id(), 'uacf7_range_handle_width', true );
$handle_height = get_post_meta( $post->id(), 'uacf7_range_handle_height', true );
$handle_color = ! empty( get_post_meta( $post->id(), 'uacf7_range_handle_color', true )) ? get_post_meta( $post->id(), 'uacf7_range_handle_color', true ) : "#3498db";
$border_radius = get_post_meta( $post->id(), 'uacf7_range_handle_border_radius', true );
$range_slider_height = get_post_meta( $post->id(), 'uacf7_range_slider_height', true );
?>
documentation'
); ?>
id(), 'uacf7_range_selection_color', sanitize_text_field( $_POST['uacf7_range_selection_color'] ));
update_post_meta( $form->id(), 'uacf7_range_handle_color', sanitize_text_field($_POST['uacf7_range_handle_color'] ));
update_post_meta( $form->id(), 'uacf7_range_handle_width', sanitize_text_field($_POST['uacf7_range_handle_width'] ));
update_post_meta( $form->id(), 'uacf7_range_handle_height', sanitize_text_field($_POST['uacf7_range_handle_height'] ));
update_post_meta( $form->id(), 'uacf7_range_handle_border_radius', sanitize_text_field($_POST['uacf7_range_handle_border_radius'] ));
update_post_meta( $form->id(), 'uacf7_range_slider_height', sanitize_text_field($_POST['uacf7_range_slider_height'] ));
}
/**
* Contact Form Properties
*/
public function uacf7_contact_form_properties( $properties, $cf ) {
if ( !is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
$form = $properties['form'];
ob_start();
$selection_color = !empty( get_post_meta( $cf->id(), 'uacf7_range_selection_color', true ) ) ? get_post_meta( $cf->id(), 'uacf7_range_selection_color', true ) : "#1e90ff";
$handle_width = !empty( get_post_meta( $cf->id(), 'uacf7_range_handle_width', true ) ) ? get_post_meta( $cf->id(), 'uacf7_range_handle_width', true ) : '24';
$handle_height = !empty( get_post_meta( $cf->id(), 'uacf7_range_handle_height', true ) ) ? get_post_meta( $cf->id(), 'uacf7_range_handle_height', true ) : '24';
$handle_border_radius = !empty( get_post_meta( $cf->id(), 'uacf7_range_handle_border_radius', true ) ) ? get_post_meta( $cf->id(), 'uacf7_range_handle_border_radius', true ) : '24';
$handle_color = !empty( get_post_meta( $cf->id(), 'uacf7_range_handle_color', true ) ) ? get_post_meta( $cf->id(), 'uacf7_range_handle_color', true ) : '#3498db';
$range_slider_height = !empty( get_post_meta( $cf->id(), 'uacf7_range_slider_height', true ) ) ? get_post_meta( $cf->id(), 'uacf7_range_slider_height', true ) : 9;
$handle_dynamic_position = ( $handle_height / 2 - $range_slider_height / 2 ) + 1;
?>
id() . '">' . $form . '';
$properties['form'] = ob_get_clean();
}
return $properties;
}
/**
* Enqueue Slider scripts
*/
public function enqueue_slider_scripts() {
wp_enqueue_script( 'uacf7-range-slider', UACF7_URL . 'addons/range-slider/js/range-slider.js', array( 'jquery', 'jquery-ui' ), false, true );
wp_enqueue_style( 'jquery-ui-style', '//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css' );
wp_enqueue_style( 'range-slider-style', UACF7_URL . 'addons/range-slider/css/style.css' );
wp_register_script( 'jquery-ui', 'https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js', array( 'jquery' ), false, true );
wp_register_script( 'touch-punch', 'https://cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.3/jquery.ui.touch-punch.min.js', array( 'jquery' ), false, true );
wp_enqueue_script( 'jquery-ui' );
wp_enqueue_script( 'touch-punch' );
}
/**
* Admin enqueue scripts
*/
public function uacf7_admin_enqueue_scripts() {
wp_enqueue_style( 'range-slider-style', UACF7_URL . 'addons/range-slider/css/style.css' );
wp_enqueue_script( 'uacf7-admin-slider-color', UACF7_URL . 'addons/range-slider/js/admin.js', array( 'jquery' ) );
}
}
new UACF7_range_Slider;