Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function myscripts ()
- {
- wp_deregister_script('jquery');
- wp_register_script( 'jquery',get_bloginfo('wpurl') . "/wp-content/plugins/infograph/jquery-1.9.1.min.js");
- wp_enqueue_script('jquery');
- wp_register_script( 'jqplot',get_bloginfo('wpurl') . '/wp-content/plugins/infograph/src/jquery.jqplot.js', 'jquery');
- // wp_enqueue_script( 'jqplot' ); // Not required as wp_enqueue_scripts below will invoke this.
- wp_register_script( 'bar', get_bloginfo('wpurl') . '/wp-content/plugins/infograph/src/plugins/jqplot.barRenderer.js', 'jqplot');
- wp_enqueue_script( 'bar' );
- wp_register_script( 'cax', get_bloginfo('wpurl') . '/wp-content/plugins/infograph/src/plugins/jqplot.categoryAxisRenderer.js', 'jqplot');
- wp_enqueue_script( 'cax' );
- wp_register_script( 'pol', get_bloginfo('wpurl') . '/wp-content/plugins/infograph/src/plugins/jqplot.pointLabels.js', 'jqplot');
- wp_enqueue_script( 'pol' );
- wp_register_script( 'fun', get_bloginfo('wpurl') . '/wp-content/plugins/infograph/src/plugins/jqplot.funnelRenderer.js', 'jqplot');
- wp_enqueue_script( 'fun' );
- wp_register_script( 'pie', get_bloginfo('wpurl') . '/wp-content/plugins/infograph/src/plugins/jqplot.pieRenderer.js', 'jqplot');
- wp_enqueue_script( 'pie' );
- wp_register_script( 'meg', get_bloginfo('wpurl') . '/wp-content/plugins/infograph/src/plugins/jqplot.meterGaugeRenderer.js', 'jqplot');
- wp_enqueue_script( 'meg' );
- }
- function add_css () {
- wp_register_style('jqPlotStyleSheet', plugins_url() . '/infograph/src/jquery.jqplot.css');
- wp_enqueue_style( 'jqPlotStyleSheet');
- wp_register_style('InfographExamplesStyleSheet', plugins_url() . '/infograph/examples.css');
- wp_enqueue_style( 'InfographExamplesStyleSheet');
- }
- add_action('wp_enqueue_scripts', 'myscripts');
- add_action('wp_print_styles', 'add_css'); // See note at http://codex.wordpress.org/Function_Reference/wp_register_style
- add_action( 'add_meta_boxes', 'category_meta_box_add' );
- function category_meta_box_add()
- {
- add_meta_box( 'my-meta-box-id', 'Category by Percentage', 'categories', 'post', 'normal', 'high' );
- }
- function categories($atts,$content = '') {
- $ch_cats = get_categories(array('orderby'=>'count','order'=>'desc') );
- $sayy= count($ch_cats);
- $chl='';
- for ($i=1;$i<=5;$i++)
- {
- $chl=$chl.'[\''.$ch_cats[$i-1]->name.'\','.$ch_cats[$i-1]->count.'],'; //[[[\'a\',25],[\'b\',14],[\'c\',7]]]
- }
- $chl='[['.substr($chl,0,-1).']]';
- return '<script>
- $(document).ready(function(){
- plot1 = $.jqplot(\'chart1\', '.$chl.', {
- title: \'Most popular categories of example.com\',
- seriesDefaults:{renderer:$.jqplot.PieRenderer,rendererOptions: { padding: 8, showDataLabels: true}},legend:{show:true,placement: \'outside\',rendererOptions: {numberRows: 1}},
- legend:{show:true,
- placement: \'outside\',
- rendererOptions: {
- numberRows: 1
- },
- location:\'s\',
- marginTop: \'15px\'
- }
- });
- });
- </script>
- <div id="chart1" style="margin-top:30px;margin-bottom:30px; margin-left:20px; width:500px; height:300px;"></div> ';
- }
- add_shortcode('mycategories', 'categories');
- echo do_shortcode('[mycategories]');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement