Store admin page into variable

I’m trying to store and admin page into a variable and sending back to an AJAX request. My code is the following, considering I’m in a class:

add_action(‘wp_ajax_get_dashboard’, array(‘$this’, ‘get_dashboard’));

public function get_dashboard(){

//generate the admin home page /wp-admin/index.php
include admin_url(‘index.php’);
$generate_index = ob_get_contents();

wp_send_json( $generate_index );


The problem is that I get the login screen as output. I’m working in a plugin enviroment. Any suggestion?

Read more here:: Store admin page into variable

Leave a Reply

Your email address will not be published. Required fields are marked *