WooCommerce Search Engine – INSTANT, RELEVANT AND SMART Search Box

Turn your website search into Smart Search which find products by price, SKU, attributes, meta data, categorys, tags etc.

“WooCommerce Search Engine” is a very powerful and easy to use WooCommerce Search Plugin which turns a simple search box of your WooCommerce Store to the powerful multifunctional magic box which helps you to sell more products. The plugin UI is compatible with ALL THEMES.

Get the Search Box '; } function guaven_sqlcharts_my_admin_notice() { global $post; if( (!empty($_SERVER["REQUEST_URI"]) and strpos($_SERVER["REQUEST_URI"],'post_type=gvn_schart')!==false) or (!empty($post) and $post->post_type == 'gvn_schart') ){ echo guaven_sqlcharts_recommended(); } if (!empty($post) and $post->post_type == 'gvn_schart'): if (!current_user_can('manage_options')) { echo '

Only administrators can manage this page
'; die(); } echo '
'; if (empty($_GET["post"]) and strpos($_SERVER["REQUEST_URI"], "post-new") === false): $gf_message = 'Use Add new button above to create new sql report. And click on any existing rule names below to manage them. '; else: $gf_message = ' 1. Give any name to your report.
2. Choose chart type, type sql query, enter field names, labels and then press to Publish/Update
3. After update you will see needed shortcode below. You can use that shortcode anywhere in your website: in pages, posts, widgets etc.
'; endif; _e('
' . $gf_message . '
', 'guaven_sqlcharts'); echo '
Get Premium Support OR Make a Small Donation
'; endif; } add_action('admin_notices', 'guaven_sqlcharts_my_admin_notice'); function guaven_sqlcharts_onboarding_notice(){ if((function_exists('wp_doing_ajax') and wp_doing_ajax()) or get_option('guaven_sqlcharts_onboarding_notice_dismissed') == 1) return; printf('

Welcome aboard on MySQL Charts!

' ); } add_action('admin_notices', 'guaven_sqlcharts_onboarding_notice'); function guaven_sqlcharts_onboarding_notice_dismissed(){ check_ajax_referer('notice_dismissed', 'nonce'); switch ($_POST['type']){ case 'onboarding_notice': update_option('guaven_sqlcharts_onboarding_notice_dismissed', 1); break; } } add_action('wp_ajax_guaven_sqlcharts_onboarding_notice_dismissed', 'guaven_sqlcharts_onboarding_notice_dismissed'); function guaven_sqlcharts_enqueue_chart() { wp_enqueue_script('guaven_sqlcharts_chartjs', plugins_url('asset/bundle.min.js', __FILE__),array('jquery'),GVNSQLCHARTS_VERSION); wp_localize_script('guaven_sqlcharts_chartjs', 'guaven_sqlcharts_notice_dismissed', array( 'action' => 'guaven_sqlcharts_onboarding_notice_dismissed', 'nonce' => wp_create_nonce('notice_dismissed') )); } add_action('wp_enqueue_scripts', 'guaven_sqlcharts_enqueue_chart'); add_action('admin_enqueue_scripts', 'guaven_sqlcharts_enqueue_chart'); function guaven_sqlcharts_enqueue_main_style() { wp_enqueue_style('guaven_sqlcharts_main_style', plugins_url('asset/guaven_sqlcharts.css', __FILE__),array(),GVNSQLCHARTS_VERSION); } add_action('admin_enqueue_scripts', 'guaven_sqlcharts_enqueue_main_style'); function guaven_sqlcharts_isJson($string) { json_decode($string); return (json_last_error() == JSON_ERROR_NONE); } add_action('init', 'guaven_sqlcharts_register_post'); function guaven_sqlcharts_register_post() { //register_taxonomy('guaven_update_push_tag', 'termin'); register_post_type('gvn_schart', array( 'labels' => array( 'name' => __('My SQL Charts'), 'singular_name' => __('My SQL chart') ), 'public' => true, //'taxonomies' => array('guaven_update_push_tag'), 'supports' => array( 'title', 'postmeta' ), 'register_meta_box_cb' => 'guaven_sqlcharts_metabox_area' )); guaven_sqlcharts_load_defaults(); } add_action('admin_footer', 'guaven_sqlcharts_admin_front'); function guaven_sqlcharts_admin_front() { global $post; if (!empty($post) and $post->post_type == 'gvn_schart') { ?> post_type != 'gvn_schart'){ return "Invalid id"; } return guaven_sqlcharts_local_shortcode(array('id' => $atts['chart_id'])); // temporary explicit value } function guaven_register_gutenberg_blocks() { wp_register_script( 'gvn_gutenberg_charts', plugins_url( 'asset/guaven_gutenberg_charts.js', __FILE__ ), array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-server-side-render' ), GVNSQLCHARTS_VERSION.'_'.filemtime( plugin_dir_path( __FILE__ ) . 'asset/guaven_gutenberg_charts.js' ) ); wp_localize_script('gvn_gutenberg_charts', 'guaven', array( 'description' => 'Add My SQL Chart to your post', )); register_block_type( 'guaven-sqlcharts/gvn-chart-gutenberg', array( 'editor_script' => 'gvn_gutenberg_charts', 'render_callback' => 'guaven_gutenberg_wrapper', 'attributes' => array( 'chart_id' => array( 'type' => 'string', 'default' => null ), 'sqlcharts_inserted_script' => array( 'type' => 'number', 'default' => null ) ) )); } add_action('init', 'guaven_register_gutenberg_blocks'); function guaven_sqlcharts_save_metabox_area($post_id, $post) { if (!isset($_POST['meta_box_nonce_field']) or !wp_verify_nonce($_POST['meta_box_nonce_field'], 'meta_box_nonce_action')) { return $post->ID; } $fields = array( "guaven_sqlcharts_chartheight", "guaven_sqlcharts_chartwidth", "guaven_sqlcharts_graphtype", "guaven_sqlcharts_xarg_s", "guaven_sqlcharts_xarg_l", "guaven_sqlcharts_yarg_s", "guaven_sqlcharts_yarg_l", "guaven_sqlcharts_tablepart", "guaven_sqlcharts_variables", "guaven_sqlcharts_formpartrole", "guaven_sqlcharts_formpartbutton", "guaven_sqlcharts_dbhost", "guaven_sqlcharts_dblogin", "guaven_sqlcharts_dbname", "guaven_sqlcharts_colors", "guaven_sqlcharts_begin_with_0_x", "guaven_sqlcharts_begin_with_0_y", "guaven_sqlcharts_round_y_values", "guaven_sqlcharts_legend_position", "guaven_sqlcharts_nostacked" ); foreach ($fields as $key => $value) { if(isset($_POST[$value]))$newval=esc_attr($_POST[$value]); else $newval=''; update_post_meta($post->ID, $value, $newval); } if(!empty($_POST["guaven_sqlcharts_dbpass"])){ $encpass=guaven_sqlcharts_encrypt_decrypt('encrypt',$_POST["guaven_sqlcharts_dbpass"]); update_post_meta($post->ID, 'guaven_sqlcharts_dbpass', ['encrypted',$encpass]); } update_post_meta($post->ID, 'guaven_sqlcharts_code', esc_attr(str_replace("'",'"',stripslashes($_POST['guaven_sqlcharts_code']))) ); } add_action('save_post', 'guaven_sqlcharts_save_metabox_area', 1, 2); // save the custom fields function guaven_sqlcharts_libloads($type, $step) { $stty = array( 'bar' => array( 'packages' => "'corechart', 'bar'", 'charts' => "BarChart" ), 'column' => array( 'packages' => "'corechart', 'bar'", 'charts' => "ColumnChart" ), 'area' => array( 'packages' => "'corechart'", 'charts' => "AreaChart" ), 'pie' => array( 'packages' => "'corechart'", 'charts' => "PieChart" ), '3dpie' => array( 'packages' => "'corechart'", 'charts' => "PieChart" ) ); return $stty[$type][$step]; } function gvn_chart_check_sql_query($sql) { $blacklister = array( "delete", "update", "insert", "drop", "truncate", "alter" ); //add all $blacklister_f = 0; foreach ($blacklister as $key => $value) { if (strpos($sql, $value) !== false) $blacklister_f = 1; } return $blacklister_f; } function guaven_get_labels_and_values($id, $fvs) { $values = array(); $labels = array(); $xarg_s = get_post_meta($id, 'guaven_sqlcharts_xarg_s', true); $xarg_l = get_post_meta($id, 'guaven_sqlcharts_xarg_l', true); $yarg_s = get_post_meta($id, 'guaven_sqlcharts_yarg_s', true); $yarg_l = get_post_meta($id, 'guaven_sqlcharts_yarg_l', true); $chartype = array( 'line_l' => 'Line', 'pie_l' => 'Pie', 'donut_l' => 'Pie', 'bar_l' => 'Bar', 'horizontalbar_l' => 'Horizontal Bar', 'area_l' => 'Line' ); foreach ($fvs as $key => $value) { $values[] = $value->$yarg_s; $labels[] = '"' . $value->$xarg_s . '"'; } return array( $labels, $values, explode(";", $yarg_l), explode(";", $xarg_l) ); } function guaven_sqlcharts_print_chart_js($tip_g, $title, $labels, $values, $ylabel, $pid = null) { if ($tip_g == 'line_l') { guaven_sqlcharts_linedata($title, $labels, $values, $ylabel, 'false', $pid); } if ($tip_g == 'area_l') { guaven_sqlcharts_linedata($title, $labels, $values, $ylabel, 'true', $pid); } elseif ($tip_g == 'pie_l') { guaven_sqlcharts_piedata($title, $labels, $values, $ylabel, $pid); } elseif ($tip_g == 'donut_l') { guaven_sqlcharts_piedata($title, $labels, $values, $ylabel, $pid, 'doughnut'); } elseif ($tip_g == 'bar_l') { guaven_sqlcharts_bardata($title, $labels, $values, $ylabel, 'bar', $pid); } elseif ($tip_g == 'horizontalbar_l') { guaven_sqlcharts_bardata($title, $labels, $values, $ylabel, 'horizontalBar', $pid); } elseif($tip_g == 'custom'){ guaven_sqlcharts_custom($title, $labels, $values, $ylabel, $pid); } elseif ($tip_g == 'polar_l') { guaven_sqlcharts_piedata($title, $labels, $values, $ylabel, $pid, 'polarArea'); } } function guaven_sqlcharts_custom($title, $labels, $values, $ylabel, $pid){ do_action('guaven_sqlcharts_custom',$title, $labels, $values, $ylabel, $pid); } function gvn_chart_put_variables($sql,$pid){ $sql_initial=$sql; $default_tag_keys=['{current_user_id}','{current_user_login}','{current_user_email}','{current_user_display_name}']; if(is_user_logged_in( )){ $currentuser=wp_get_current_user(); $default_tag_values=[$currentuser->ID,$currentuser->user_login,$currentuser->user_email,$currentuser->user_display_name]; } else { $default_tag_values=''; } $sql_initial=str_replace($default_tag_keys,$default_tag_values,$sql_initial); $variables_raw=get_post_meta($pid,'guaven_sqlcharts_variables',true); $variables_arr=explode("|",$variables_raw); foreach($variables_arr as $varfield){ $varfield_arr=explode("~",$varfield); if (count($varfield_arr)<3) continue; $varfield_arr=array_map("trim",$varfield_arr); if (!empty($_GET[$varfield_arr[0]])) $varreplacement=$_GET[$varfield_arr[0]]; else $varreplacement=$varfield_arr[1]; if (!is_numeric($varreplacement) and strpos($varreplacement,'()')===false) $varreplacement='"'.$varreplacement.'"'; $sql_initial=str_replace('{'.$varfield_arr[0].'}',$varreplacement,$sql_initial); } return $sql_initial; } function gvn_chart_top_form($atts){ if (get_post_meta($atts["id"],'guaven_sqlcharts_formpartrole',true)!='' and !is_user_logged_in()) return; $topform='';$dateexists=false; $variables_raw=get_post_meta($atts['id'],'guaven_sqlcharts_variables',true); $variables_raw=explode("|",$variables_raw); foreach ($variables_raw as $vrow){ $vrow_arr=explode("~",$vrow); $vrow_arr=array_map("trim",$vrow_arr); if (empty($vrow_arr[3])) continue; $gvalue=!empty($_GET[$vrow_arr[0]])?esc_attr(urldecode($_GET[$vrow_arr[0]])):''; $dvalue=(strpos($vrow_arr[1],'()')===false)?esc_attr($vrow_arr[1]):''; if ($vrow_arr[3]=='date') { $dateexists=true; $topform.= $vrow_arr[2].' ';} else { $topform.= $vrow_arr[2].' '; } } if (!empty($topform)) { $topform='
'.$topform.'
'; if ($dateexists) $topform.=''; return $topform ; } return; } function guaven_sqlcharts_encrypt_decrypt($action, $string) { $output = false; $encrypt_method = "AES-256-CBC"; $secret_key = 'GWSCHARTPL2022.2016.'; $secret_iv = 'GWSCHARTPL2016.2022'; $key = hash('sha256', $secret_key); $iv = substr(hash('sha256', $secret_iv), 0, 16); if ( $action == 'encrypt' ) { $output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv); $output = base64_encode($output); } else if( $action == 'decrypt' ) { $output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv); } return $output; } function guaven_sqlcharts_local_shortcode($atts) { $remote_host=get_post_meta($atts['id'], 'guaven_sqlcharts_dbhost', true); if ($remote_host!=''){ $remote_db=get_post_meta($atts['id'], 'guaven_sqlcharts_dbname', true); $remote_login=get_post_meta($atts['id'], 'guaven_sqlcharts_dblogin', true); $remote_pass=get_post_meta($atts['id'], 'guaven_sqlcharts_dbpass', true); if(is_array($remote_pass)){ $remote_pass=guaven_sqlcharts_encrypt_decrypt('decrypt',$remote_pass[1]); } $wpdb=new wpdb($remote_login,$remote_pass,$remote_db,$remote_host); } else { global $wpdb; } $GLOBALS["guaven_sqlcharts_atts"]=$atts; $sql = html_entity_decode(get_post_meta($atts['id'], 'guaven_sqlcharts_code', true)); $sql=gvn_chart_put_variables($sql,$atts['id']); $blacklister_f = gvn_chart_check_sql_query($sql); if ($blacklister_f == 1) return 'You given SQL code contains forbidden commands. Remember that you should only use SELECT queries'; $tip_g = get_post_meta($atts['id'], 'guaven_sqlcharts_graphtype', true); for($i=1;$i<20;$i++){ $replacearg=!empty($atts["arg".$i])?$atts["arg".$i]:0; $sql=str_replace("{arg".$i."}",esc_sql($replacearg),$sql);} $sql_split = explode(';', $sql); $labels_and_values = array(); $post_g = get_post($atts['id']); global $sqlcharts_inserted_script; for ($i = 0; $i < count($sql_split); $i++) { if (!empty($sql_split[$i])) { $fvs = $wpdb->get_results($sql_split[$i]); if (strpos($_SERVER["REQUEST_URI"],'wp-admin')!==false){ $wpdb->show_errors(); ob_start(); $wpdb->print_error(); $printerror = ob_get_clean(); if ($printerror != '' and strpos($printerror, "[]") === false) return $printerror; elseif (empty($fvs)) return 'Your SQL returnes empty date, please recheck your SQL query above'; } ob_start(); if (empty($sqlcharts_inserted_script)) $sqlcharts_inserted_script = 1; $labels_and_values[$i] = guaven_get_labels_and_values($atts['id'], $fvs); $labels[$i] = $labels_and_values[$i][0]; $values[$i] = $labels_and_values[$i][1]; $ylabel[$i] = !empty($labels_and_values[$i][2][$i]) ? $labels_and_values[$i][2][$i] : ''; $xlabel[$i] = !empty($labels_and_values[$i][3][$i]) ? $labels_and_values[$i][3][$i] : ''; } } echo gvn_chart_top_form($atts); ?> post_title, $labels, $values, $ylabel,$xlabel); $sqlcharts_inserted_script++; return ob_get_clean(); } add_shortcode('gvn_schart_2', 'guaven_sqlcharts_local_shortcode'); function guaven_sqlcharts_colors($index, $pid = null){ if(!isset($pid)) { global $post; $pid = $post->ID; } $colors=get_post_meta($pid,'guaven_sqlcharts_colors',true); $colors=explode(",",$colors); if (!empty($colors[$index])) return $colors[$index]; return rand(0, 255) . ',' . rand(0, 255) . ',' . rand(0, 255); } function guaven_sqlcharts_toshowlegend($pid){ $guaven_sqlcharts_legend_position=get_post_meta($pid, 'guaven_sqlcharts_legend_position', true); if(in_array($guaven_sqlcharts_legend_position,['top','bottom','left','right'])){ $display='true';$position=$guaven_sqlcharts_legend_position; } else { $display='false';$position='top'; } return "legend: {display: ".$display.",position:'".$position."'},"; } function guaven_sqlcharts_bardata($title, $labels, $values, $ylabel, $type = 'bar', $pid = null) { ?> var data = { labels: [], datasets: [ { label: "", backgroundColor: [ ], borderColor: [ ], borderWidth: 1, data: [], }, ] }; var options={ responsive: true, scales: { xAxes: [{ ticks: { beginAtZero: } }], yAxes: [{ ticks: { beginAtZero: } }] } }; var myBarChart = new Chart(ctx, { type: '', data: data, options: options }); var data = { labels: [], datasets: [ { label: "", fill: , lineTension: 0.1, backgroundColor: borderColor: pointBorderColor: pointHoverBackgroundColor: pointHoverBorderColor: data: [], spanGaps: false, }, ] }; var myLineChart = new Chart(ctx, { type: 'line', data: data, options: { responsive: true, scales: { xAxes: [{ display: true, ticks: { beginAtZero: } }], yAxes: [{ ticks: { beginAtZero: } }] } } }); var options={ responsive: true, }; var data = { labels: [ ], datasets: [ { data: [], backgroundColor: [ $valuecolor){ echo guaven_sqlcharts_colorgenerator(1, 0, 0, guaven_sqlcharts_colors($vci, $pid)); } ?> ], hoverBackgroundColor: [ $valuecolor){ echo guaven_sqlcharts_colorgenerator(1, 0, 0.2, guaven_sqlcharts_colors($vci, $pid)); } ?> ] }, ] }; var myPieChart = new Chart(ctx,{ type: '', data: data, options: options }); 'red', 'linebr' => 'yellow', 'linebc' => 'green', 'linehbg' => 'white', 'linehbc' => 'black' ); if (!empty($initial_colors[$count])) return '"' . $initial_colors[$count] . '", '; $ret = ''; for ($i = 0; $i < $count; $i++) { $ret .= "'rgba(" . $initcolor . "," . ($darkness + 0.8 - $indic * $i * 0.8 / ($count)) . ")', "; } return $ret; } function guaven_sqlcharts_tablepart($title, $labels, $values, $ylabel,$xlabel){ $tabledata=''; $fcol=[];$scol=[]; $tablein='
'; foreach($values as $valuerow){ foreach ($valuerow as $key => $value) { $fcol[$key]=''.str_replace('"',"",$labels[0][$key]).''; $scol[$key][]=''.$value.''; } } foreach($fcol as $key=>$value){ $tablein.=''.$value.implode(" ",$scol[$key]).''.PHP_EOL; } $tabledata.=' '.$tablein.'
'.$xlabel[0].''.implode("",$ylabel).'

'; return $tabledata; }