$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>javascript - XMLHttpRequest of admin data to public|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - XMLHttpRequest of admin data to public

matteradmin7PV0评论

I have a function that get the data from a admin page and display the result at frontpage. But only works when admin user is logged in. How can I display the result even if user is not logged in?

Here the code in apoiadores.js

xhr.open("GET", "http://localhost/editora/wp-admin/edit.php?post_type=shop_order");

xhr.addEventListener("load", carregarapoiadores);
xhr.addEventListener("load", preco);    
xhr.send();`

and here the code in functions.php

function apoiadores () {
      wp_enqueue_script('apoiadores', get_template_directory_uri() . 
     '/chsv/js/apoiadores.js', array('jquery'), '', true);

} 
 add_action('wp_enqueue_scripts', 'apoiadores');


function prazo () {
 wp_enqueue_script('prazo', get_template_directory_uri() . 
  '/chsv/js/prazofinal.js', array('jquery'), '', true);

}
add_action('wp_enqueue_scripts', 'prazo');`

I have a function that get the data from a admin page and display the result at frontpage. But only works when admin user is logged in. How can I display the result even if user is not logged in?

Here the code in apoiadores.js

xhr.open("GET", "http://localhost/editora/wp-admin/edit.php?post_type=shop_order");

xhr.addEventListener("load", carregarapoiadores);
xhr.addEventListener("load", preco);    
xhr.send();`

and here the code in functions.php

function apoiadores () {
      wp_enqueue_script('apoiadores', get_template_directory_uri() . 
     '/chsv/js/apoiadores.js', array('jquery'), '', true);

} 
 add_action('wp_enqueue_scripts', 'apoiadores');


function prazo () {
 wp_enqueue_script('prazo', get_template_directory_uri() . 
  '/chsv/js/prazofinal.js', array('jquery'), '', true);

}
add_action('wp_enqueue_scripts', 'prazo');`
Share Improve this question edited Apr 3, 2019 at 19:50 Thages W. Almeida asked Apr 3, 2019 at 19:45 Thages W. AlmeidaThages W. Almeida 32 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

The short answer is "you can't do that." The WordPress admin content requires a user be logged in to view any of the content. If this were possible, anyone could get into the admin on your site.

You will have to make this content available from the front-end by another method.

Post a comment

comment list (0)

  1. No comments so far