You need to redeclare the variable in your end_time() and also you don’t need the user to be logged in.. You can try the below answer.
// LOAD TIME CHECKER
function start_timer() {
global $time_start;
$time_start = microtime(true);
}
add_action('wp_head', 'start_timer', 1);
function end_time() {
//try redeclaring the var
global $time_start;
echo '
<div class="clearfix"></div>
<div id="queryTime" style="position: fixed; bottom: 30px; left: 30px;">
<ul class="li"><span class="label label-success fs13">Start Time: '.$time_start.'</span></ul>
<ul class="li"><span class="label label-success fs13">Query Took: '.number_format( microtime(true) - $time_start, 10).'</span></ul>
</div>
';
}
add_action('wp_footer', 'end_time', 100);
Related Posts:
- $GLOBALS & global doesn’t work [closed]
- Is there a hook that runs after a user logs in?
- WP Cron Doesn’t Execute When Time Elapses
- Why do some hooks not work inside class context?
- Action hook for custom tax edit
- Is there a limit to hook priority?
- Auto-retrieve YouTube Image for Thumbnail?
- Global Objects and Public Methods
- Do WordPress Core Filenames Work as Hooks?
- Can I hook inside another hook?
- How to check if which hook triggered the call to a function?
- How do I flush the rules after saving settings using the Settings API?
- Run javascript code after wp_login hook?
- Is it possible to save/modify a post without calling the “save_post” action hook?
- Redirect logged in users if they are on a specific page
- Check if action hook exists before adding actions to it
- Generating robots.txt dynamically
- Hooks are not executing
- Rest API Hook When Post Is Requested
- Best possible way to get all options
- wordpress custom modules/widget areas on the page? can i make my own?
- How to add hook to the_title() and get_the_title()
- Is there a recover_post hook to go with trash_post hook?
- Add custom URLs to WordPress’s XML sitemap
- Hooking after get_header()
- How to get post ID in post_updated action hook?
- hooks & filters and variables
- How can I set status=’publish’ for all featured images?
- How to send data from a form created by a plugin to an external API?
- How to get all functions with priority ‘1’ attached to hook ‘wp_head’
- How to use do_action_ref_array?
- How to change the location of admin notice in html without using Javascript?
- Why doesn’t wp_enqueue_script() work when including a JavaScript file with TEMPLATEPATH?
- What are the differences between comment_form_logged_in_after and comment_form_after_fields?
- Detect change to user_meta and retrieve old and new values
- Featured Image Action Hook
- Update post meta using pending_to_publish hook
- How to find a callback attached to a bbpress hook?
- Event Calendar using insert_post_data after save_post and insert_post after post_transition draft_to_schedule
- How to extend custom (non-core) blocks?
- Hooking into the init action will fire it too frequently?
- Implement Hooks Using Array
- What hook is used to display the admin_bar on the front end?
- Is there a JavaScript equivalent of get_post_field?
- register_activation_hook not updating
- Adding a hook to the default (page.php) template
- Add action hook into wp_localize_script
- PHP header() gives headers already sent
- How to replace a function using a child theme?
- Conditional for autosave or auto draft?
- Using delete_attachment to prevent an attachment not working
- How does do_action( ) works actually?
- Giving the_excerpt in the place of the_content?
- I would like to send a notification email (Asana) whenever something is published (posts, pages, custom post types) [duplicate]
- Hook to init or call explicitly within functions.php
- How to add content to the end of a page with a hook?
- register_deactivation_hook argument -> pass arguments in the selected function
- Alternative to new_to_publish Hook for Custom Statuses
- How to use a WooCommerce action hook?
- Force file download in WordPress
- How to use pre_get_posts
- hooks for automatic approve user registration according to data in custom fields
- How to render an element, that was saved as a template, using a hook?
- How to use embed_content hook?
- Notify admin when Custom post meta data gets updated or deletet
- WP Cron not executing after timespan
- Action hook with wrapper html
- call php file from form and use wp functions
- wp_insert_post hook for a wordpress plugin
- WordPress add_action the_post hook
- Post via wp-admin and via iOS app, same hooks and triggers involved?
- add_action hook for links.php page
- Hooking after blog info update
- Hook to add_action(‘updated_option_my_option’, [$this, ‘save_data’], 10, 3]);
- Session management issues with WordPRess 404 Error page
- Template_redirect works, but headers aren’t sent when checking via cURL
- template_redirect hooks redirect wrong URL
- Registered custom dynamic tag not appearing
- Add a Call to Action Button to WordPress Post Thumbnail
- Add stuff above header edit form
- How to hook add_action() into after category description with id?
- What hook can you use to get the full response?
- Easy Digital Downloads – How to use hooks correctly?
- Updating a related post’s “post_modified” value
- adding wordpress yoast SEO canonical url from “transition_post_status” hook
- Cookie cant be read even cookie is present
- How to create callback function which returns all posts with specific data?
- How to trigger click events using hooks
- remove_action() hook not working
- Why the post ID is 0 in a hook within wp_insert_post_data?
- Function Hooked on Init Running Multiple Times
- How to work with hooks and Posts to posts plugin?
- template_redirect and title
- When is get_currentuserinfo() needed?
- disable publish button until condition is not met
- How do I remove an action hook by s2member
- How do I change TinyMCE button “i” to create a i tag rather than em? [duplicate]
- Removing script tags that are loaded by other script tag
- Does wp_login hook fire on user registration?
- wp_trash_post not firing as expected (also applies to trashed_post)