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.
';
?>
' . $gf_message . '
Note: Shortcodes supports width and height attributes. F.e. [gvn_schart id="1" width="500" height="400"]. If no attributes, default width, height (which you enter in this page above) will be used.
Demo
ID . '"]');
}
}
function gvn_schart_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_code",
"guaven_sqlcharts_xarg_s",
"guaven_sqlcharts_xarg_l",
"guaven_sqlcharts_yarg_s",
"guaven_sqlcharts_yarg_l"
);
foreach ($fields as $key => $value) {
update_post_meta($post->ID, $value, esc_attr($_POST[$value]));
}
}
add_action('save_post', 'gvn_schart_save_metabox_area', 1, 2);
// save the custom fields
function gvn_schart_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_schart_shortcode($atts)
{
global $wpdb;
$sql = html_entity_decode(get_post_meta($atts['id'], 'guaven_sqlcharts_code', true));
$blacklister = array(
"delete",
"update",
"insert",
"drop",
"truncate"
); //add all
$blacklister_f = 0;
foreach ($blacklister as $key => $value) {
if (strpos($sql, $value) !== false)
$blacklister_f = 1;
}
if ($blacklister_f == 1)
return 'You given SQL code contains forbidden commands. Remember that you should only use SELECT queries';
$fvs = $wpdb->get_results($sql);
$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';
else {
ob_start();
?>
"DESC",
"orderby" => "count",
"number" => 10
));
$html = '';
$itag = 0;
$html60 = '';
foreach ($tags as $tag) {
$itag++;
$html_temp .= "['{$tag->name}', {$tag->count}, '#b87333'],";
}
?>
var data = google.visualization.arrayToDataTable([
['Element', 'Density', { role: 'style' }],
]);
var options = {
chart: {
title: 'Company Performance',
subtitle: 'Sales, Expenses, and Profit: 2014-2017',
}
};