<?php
$current_user = wp_get_current_user();
$show_hide_custom_admin = get_field( 'show_custom_admin_bar', 'user_' . $current_user->ID );
$show_enable_refresh = get_field( 'enable_refresh', 'user_' . $current_user->ID );
?>
<?php if ( $show_hide_custom_admin ) {
include('admin-bar.php');
}?>
<?php wp_footer(); ?>
<?php if( $show_enable_refresh ): ?>
<script>
function poll(poll_url, poll_timeout) {
setInterval( function() {
$.ajax({
dataType: "json",
url: poll_url,
success: function (data){
if(data.modified != date_modified){
if(!date_modified){
date_modified = data.modified;
}
else{
location.reload();
}
}
}
});
}, poll_timeout);
}
var date_modified = null; poll("<?php echo site_url() ?>/wp-json/wp/v2/<?php echo $post->post_type ?>s/<?php echo $post->ID ?>", 3000);
</script>
<?php endif; ?>
We have two true/false fields one with an id of 'show_custom_admin_bar' and the other 'enable_refresh'. They are assigned to a current user that is logged in.
The admin bar is part of this project: https://github.com/ipodscott/WordPress-Custom-Admin-Bar
The admin bar is part of this project: https://github.com/ipodscott/WordPress-Custom-Admin-Bar
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.