admin管理员组文章数量:1130349
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
ob_start();
include admin_url('index.php');
$generate_index = ob_get_contents();
ob_end_clean();
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?
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
ob_start();
include admin_url('index.php');
$generate_index = ob_get_contents();
ob_end_clean();
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?
Share Improve this question edited Nov 10, 2018 at 19:46 Krzysiek Dróżdż 25.6k9 gold badges53 silver badges74 bronze badges asked Nov 10, 2018 at 18:50 middleladymiddlelady 5531 gold badge6 silver badges18 bronze badges1 Answer
Reset to default 0In case something like this would ever need to somebody, I solved pinging the page with an AJAX request
$.ajax({
url: 'your_url_to_ping',
beforeSend: function(xhr) {
//something
}
}).done(function(data) {
//something else with your data
});
The page would be into your response data.
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
ob_start();
include admin_url('index.php');
$generate_index = ob_get_contents();
ob_end_clean();
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?
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
ob_start();
include admin_url('index.php');
$generate_index = ob_get_contents();
ob_end_clean();
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?
Share Improve this question edited Nov 10, 2018 at 19:46 Krzysiek Dróżdż 25.6k9 gold badges53 silver badges74 bronze badges asked Nov 10, 2018 at 18:50 middleladymiddlelady 5531 gold badge6 silver badges18 bronze badges1 Answer
Reset to default 0In case something like this would ever need to somebody, I solved pinging the page with an AJAX request
$.ajax({
url: 'your_url_to_ping',
beforeSend: function(xhr) {
//something
}
}).done(function(data) {
//something else with your data
});
The page would be into your response data.
本文标签: pluginsStore admin page into variable
版权声明:本文标题:plugins - Store admin page into variable 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749189796a2329996.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论