EstudioJuridicoAlmagro_Web/www/wpv_common/shortcodes/chart.php
2013-03-01 18:06:10 +00:00

51 lines
1.2 KiB
PHP

<?php
/**
* @author Mike Jolley
*
* http://blue-anvil.com/archives/8-fun-useful-shortcode-functions-for-wordpress/
*/
function theme_shortcode_chart( $atts ) {
extract(shortcode_atts(array(
'data' => '',
'colors' => '',
'size' => '400x200',
'bg' => 'bg,s,ffffff',
'title' => '',
'labels' => '',
'advanced' => '',
'type' => 'pie'
), $atts));
switch ($type) {
case 'line' :
$charttype = 'lc'; break;
case 'xyline' :
$charttype = 'lxy'; break;
case 'sparkline' :
$charttype = 'ls'; break;
case 'meter' :
$charttype = 'gom'; break;
case 'scatter' :
$charttype = 's'; break;
case 'venn' :
$charttype = 'v'; break;
case 'pie' :
$charttype = 'p3'; break;
case 'pie2d' :
$charttype = 'p'; break;
default :
$charttype = $type;
break;
}
if ($title) $string .= '&chtt='.$title.'';
if ($labels) $string .= '&chl='.$labels.'';
if ($colors) $string .= '&chco='.$colors.'';
$string .= '&chs='.$size.'';
$string .= '&chd=t:'.$data.'';
$string .= '&chf='.$bg.'';
return wpv_get_lazy_load('http://chart.apis.google.com/chart?cht='.$charttype.''.$string.$advanced, $title);
}
add_shortcode('chart', 'theme_shortcode_chart');