Skip to content

Commit

Permalink
radio button bug fix double default values
Browse files Browse the repository at this point in the history
  • Loading branch information
RensTillmann committed Jun 14, 2019
1 parent e83b716 commit f93d473
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/assets/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,7 @@ function SUPERreCaptcha(){
$version = 'v3';
}

console.log('$data 3: ', $data);
//console.log('$data 3: ', $data);
SUPER.before_email_send_hook($event, $form, $data, $old_html, function(){
$.ajax({
url: super_common_i18n.ajaxurl,
Expand Down Expand Up @@ -1634,7 +1634,7 @@ function SUPERreCaptcha(){
clearInterval($interval);
SUPER.init_fileupload_fields();
$form.find('.super-fileupload').removeClass('super-rendered').fileupload('destroy');
console.log('$data 1:', $data);
//console.log('$data 1:', $data);
//SUPER.before_submit_hook(e, $form, $data, $old_html, function(){
setTimeout(function() {
SUPER.complete_submit( e, $form, $duration, $old_html, $status, $status_update );
Expand Down Expand Up @@ -2495,7 +2495,7 @@ function SUPERreCaptcha(){
if ($form.find('.super-fileupload-files > div').length !== 0) {
SUPER.upload_files( e, $form, $data, $duration, $old_html, $status, $status_update );
}else{
console.log('$data 2:', $data);
//console.log('$data 2:', $data);
//SUPER.before_submit_hook(e, $form, $data, $old_html, function(){
SUPER.complete_submit( e, $form, $duration, $old_html, $status, $status_update );
//});
Expand Down
10 changes: 7 additions & 3 deletions src/includes/class-shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,9 @@ public static function get_items($items=array(), $tag, $atts, $prefix='', $setti
if($tag==='radio'){
// radio -custom
$items = array();
$found = false;
foreach( $atts['radio_items'] as $k => $v ) {
if( ( (!empty($v['checked'])) && ($v['checked']!='false') ) && ($atts['value']=='') ) $selected_items[] = $v['value'];
if( ( (!empty($v['checked'])) && ($v['checked']!='false') ) && ($atts['value']=='') ) $selected_items[0] = $v['value'];
if( !isset( $v['image'] ) ) $v['image'] = '';
if( $v['image']!='' ) {
$image = wp_get_attachment_image_src( $v['image'], 'original' );
Expand All @@ -261,7 +262,7 @@ public static function get_items($items=array(), $tag, $atts, $prefix='', $setti
if( $v['max_width']!='' ) $img_styles .= 'max-width:' . $v['max_width'] . 'px;';
if( $v['max_height']!='' ) $img_styles .= 'max-height:' . $v['max_height'] . 'px;';

$item = '<label class="' . (($v['checked']=='true') || ($v['value']==$atts['value']) || (in_array($v['value'], $selected_items)) ? 'super-has-image super-active super-default-selected' : 'super-has-image' ) . ($atts['class']!='' ? ' ' . $atts['class'] : '') . '">';
$item = '<label class="' . ( $found==false && (($v['checked']=='true') || ($v['value']==$atts['value']) || (in_array($v['value'], $selected_items)) ) ? 'super-has-image super-active super-default-selected' : 'super-has-image' ) . ($atts['class']!='' ? ' ' . $atts['class'] : '') . '">';
if( !empty( $image ) ) {
$item .= '<div class="image" style="background-image:url(\'' . $image . '\');"><img src="' . $image . '"' . ($img_styles!='' ? ' style="' . $img_styles . '"' : '') . '></div>';
}else{
Expand All @@ -273,7 +274,10 @@ public static function get_items($items=array(), $tag, $atts, $prefix='', $setti
$item .='</label>';
$items[] = $item;
}else{
$items[] = '<label class="' . (($v['checked']=='true') || ($v['value']==$atts['value']) || (in_array($v['value'], $selected_items)) ? 'super-active super-default-selected' : '' ) . ($atts['class']!='' ? ' ' . $atts['class'] : '') . '"><input ' . ( (($v['checked']!=='true') && ($v['checked']!==true)) ? '' : 'checked="checked"' ) . ' type="radio" value="' . esc_attr( $v['value'] ) . '" />' . stripslashes($v['label']) . '</label>';
$items[] = '<label class="' . ( $found==false && (($v['checked']=='true') || ($v['value']==$atts['value']) || (in_array($v['value'], $selected_items))) ? 'super-active super-default-selected' : '' ) . ($atts['class']!='' ? ' ' . $atts['class'] : '') . '"><input ' . ( (($v['checked']!=='true') && ($v['checked']!==true)) ? '' : 'checked="checked"' ) . ' type="radio" value="' . esc_attr( $v['value'] ) . '" />' . stripslashes($v['label']) . '</label>';
}
if( ($found==false) && ( ($v['checked']=='true') || ($v['value']==$atts['value']) || (in_array($v['value'], $selected_items)) ) ) {
$found = true;
}
$items_values[] = $v['value'];
}
Expand Down

0 comments on commit f93d473

Please sign in to comment.