• Resolved sectorx

    (@sectorx)


    Hello,

    thanks for this plugin. It is very easy to use. I really like it.

    I have question about how to use plugin graphs in admin page. This topic was here already but it was not asked/answered in depth.

    I have custom page in admin backend like this:

    function my_admin_menu()
    {
      add_menu_page('My nice graphs', 'My nice graphs', 'activate_plugins', 'my-nice-graphs', 'my_nice_graphs_page_handler');
    }
    add_action('admin_menu', 'my_admin_menu');
    
    function my_nice_graphs_page_handler()
    {
        	echo do_shortcode( '[wpcharts type="barchart" bgcolor="blue" legend="false" titles="Jan,Feb" values="5,10"]' );
    }

    However wpcharts shortcode does not work in pages like this and only outputs text “[wpcharts type=”barchart….]”

    I looked into source code and see that you only load shortcode if !is_admin()

    public function __construct() {
    	// ...
    if ( is_admin() ) {
       // ...
    }
    else {
       // ...
       //integrate the public functions
       add_shortcode( 'wpcharts', array( &$this, 'pantherius_wpcharts_shortcode' ) );
       add_action( 'init', array( &$this, 'enqueue_custom_scripts_and_styles' ) );
       add_action( 'get_footer' , array( &$this, 'initialize_chartjs' ), 175 );								
    }
    }

    It would be nice to modify wpcharts so it is also usable in admin as many people want to create some graphs also in admin area pages and not just in frontend pages.

    Many thanks.

Viewing 1 replies (of 1 total)
  • Plugin Author pantherius

    (@pantherius)

    Hello,

    Sorry, I wouldn’t like to load all plugin files on all admin pages as it can be causing conflicts. However, you can create private or password protected pages where you can add your own charts.

    Regards,
    Pantherius

Viewing 1 replies (of 1 total)
  • The topic ‘shortcode works only if !is_admin()’ is closed to new replies.