Awesome. You are welcome, ??
Oh, one last thing: since we are using wp_enqueue_scripts
to load jQuery anyway, it will definitely be “neater” to add the script that way too. It won’t make any difference in terms of functionality or outcome, but it would abide by best practices better.
To do that, you would need to:
1. Create a folder named js
inside your theme folder, if it doesn’t already exist. If it does, just skip this step.
2. Create a lidget.js
file in the js
folder and paste this inside the file:
jQuery(window).load(function() {
var width = "680", /* Enter popup window width here */
height = "480", /* Enter popup window height here */
menuItem = "menu-item-47", /* Enter menu item ID */
target = "#"+menuItem+" a",
hrefVal = jQuery(target).attr("href")
;
jQuery(target).attr({
"href" : "#",
"onclick" : "window.open('"+hrefVal+"','','width="+width+",height="+height+",scrollbars=no,resizable=no,location=no,menubar=no,toolbar=no')"
});
jQuery(".lidget-popup").attr("onclick", "window.open('"+hrefVal+"','','width="+width+",height="+height+",scrollbars=no,resizable=no,location=no,menubar=no,toolbar=no')");
});
3. Replace the entire old code you pasted in functions.php
with this one:
function lidget_script_call() {
wp_register_script('lidget_popup', get_stylesheet_directory_uri()."/js/lidget.js", array('jquery'), '', true);
wp_enqueue_script('lidget_popup');
}
add_action('wp_enqueue_scripts', 'lidget_script_call');
That should do it. Have a good weekend!