PluginProbe
SQL Chart Builder / 3.0.6
SQL Chart Builder v3.0.6
3.0.6 3.0.5 3.0.4 3.0.3 3.0.2 3.0.1 trunk 1.0.2 1.0.3 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.7.1 2.3.7.2 2.3.8 3.0.0
← All changes | functions.php +15 -3 3.0.53.0.6 View file →
@@ -677,8 +677,14 @@
677 677 }
678 678
679 679 function gvn_chart_top_form($atts){
680 680 if (get_post_meta($atts["id"],'guaven_sqlcharts_formpartrole',true)!='' and !is_user_logged_in()) return;
681 + // Inside the chart builder's live preview the filter inputs are rendered disabled and without a <form>
682 + // or submit button: the preview sits inside WordPress's own post edit form, nested forms are dropped
683 + // by the browser, and a filter named e.g. "post_type" would otherwise be submitted with the post and
684 + // make WordPress stop with "A post type mismatch has been detected." (chart settings not saved).
685 + $preview = !empty($GLOBALS['guaven_sqlcharts_admin_preview']);
686 + $dis = $preview ? ' disabled' : '';
681 687 $topform='';$dateexists=false;
682 688 $variables_raw=get_post_meta($atts['id'],'guaven_sqlcharts_variables',true);
683 689 $variables_raw=explode("|",$variables_raw);
684 690 foreach ($variables_raw as $vrow){
@@ -690,14 +696,14 @@
690 696 if ($vrow_arr[3]=='date') {
691 697 $dateexists=true;
692 698 $topform.= '<span class="gvn-filter-field"><label>'.$vrow_arr[2].'</label> <input class="gws_datepicker" autocomplete="off" type="text"
693 699 value="'.$gvalue.'"
694 - data-toggle="datepicker" name="'.$vrow_arr[0].'" placeholder="'.$dvalue.'"></span>
700 + data-toggle="datepicker" name="'.$vrow_arr[0].'" placeholder="'.$dvalue.'"'.$dis.'></span>
695 701 ';}
696 702 else {
697 703 $topform.= '<span class="gvn-filter-field"><label>'.$vrow_arr[2].'</label> <input autocomplete="off"
698 704 type="'.$vrow_arr[3].'"
699 - value="'.$gvalue.'" name="'.$vrow_arr[0].'" placeholder="'.$dvalue.'"></span>
705 + value="'.$gvalue.'" name="'.$vrow_arr[0].'" placeholder="'.$dvalue.'"'.$dis.'></span>
700 706 ';
701 707 }
702 708 }
703 709 if (!empty($topform)) {
@@ -714,12 +720,14 @@
714 720 'class' => array(),
715 721 'data-toggle'=>array(),
716 722 'placeholder'=>array(),
717 723 'autocomplete'=>array(),
724 + 'disabled'=>array(),
718 725 'style'=>[]
719 726 ),
720 727 'span' => array('class' => array()),
721 728 'label' => array(),
729 + 'div' => array('class' => array()),
722 730 );
723 731
724 732 $submit_button_value = get_post_meta($atts['id'], 'guaven_sqlcharts_formpartbutton', true) != ''
725 733 ? esc_attr(get_post_meta($atts['id'], 'guaven_sqlcharts_formpartbutton', true))
@@ -724,10 +732,14 @@
724 732 $submit_button_value = get_post_meta($atts['id'], 'guaven_sqlcharts_formpartbutton', true) != ''
725 733 ? esc_attr(get_post_meta($atts['id'], 'guaven_sqlcharts_formpartbutton', true))
726 734 : 'OK';
727 735
728 - $topform = '<form method="get" action="" class="guaven_sqlcharts_form">' . $topform . '
736 + if ($preview) {
737 + $topform = '<div class="guaven_sqlcharts_form">' . $topform . '<input type="submit" value="' . $submit_button_value . '" disabled></div>';
738 + } else {
739 + $topform = '<form method="get" action="" class="guaven_sqlcharts_form">' . $topform . '
729 740 <input type="submit" value="' . $submit_button_value . '"></form>';
741 + }
730 742
731 743 echo wp_kses($topform, $allowed_html);
732 744 }
733 745 }