I'm working on a plugin which needs a custom Preview page. In this page i call the neccessary wp functions(wp-load.php & wp-admin/includes/admin.php).
The problem is, that the admin bar is not visible. So my question is, how to display the admin bar on this page? Here is the preview.php file:
<?php
//Include wordpress core files
for ($i = 0; $i < $depth = 10; $i++) {
$wp_root_path = str_repeat( '../', $i );
if ( file_exists("{$wp_root_path}wp-load.php" ) ) {
require_once("{$wp_root_path}wp-load.php");
require_once("{$wp_root_path}wp-admin/includes/admin.php");
break;
}
}
//Redirect if user is not logged in
auth_redirect();
//Die if user can't edit posts
if(!current_user_can('edit_posts') ) die(__("You don't have the neccessary permission to preview forms.", "nemus_slider"));
//And the actual preview code
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Preview</title>
<?php wp_head(); ?>
</head>
<body>
Some preview stuff...
<?php wp_footer(); ?>
</body>
</html>