I noticed a lot of developers of WordPress themes would use this in functions.php
if (function_exists('register_nav_menus')) {
register_nav_menus (array('primary' => 'Header Navigation'));
}
For me, I alwayse use add_action for every function I am using in functions.php
So, the above would be written as:
add_action('init', 'my_register_nav_menus');
function my_register_nav_menus() {
register_nav_menus (array('primary' => 'Header Navigation'));
}
I have two questions:
Why use the if statement in the first method?
Which one is the correct way?