How do I add some javascript validation to the admin interface form’s onsubmit?

Every post / page / post type is wrapped around a universal form with the ID of #post. So if you want to validate a page before submitting it you just need to say something like: jQuery(document).ready(function($){ $(‘#post’).submit(function(){ // Validate Stuff return false; }); }); Then you’ll want to actually enqueue your javascript – View … Read more

How to get menu location in wp_update_nav_menu hook

get_nav_menu_locations will give you menu IDs keyed by location which should correspond to the $id also passed with wp_update_nav_menu. add_action(‘wp_update_nav_menu’, function ($id, $data = NULL){ foreach( get_nav_menu_locations() as $location => $menu_id ){ if( $id == $menu_id ){ echo ‘location is ‘ . $location; } } }, 10, 2);

Use a variable created in get_header to calculate stuff in wp_footer

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> … Read more