Wordpress - How to enqueue the style using wp_enqueue_style()
This is what you could do:
1 - Put the CSS in a separate file and save it in your theme directory.
2 - Add the following code in your functions php
:
function wpse_89494_enqueue_scripts() {
if ( has_nav_menu( 'secondary' ) ) {
wp_enqueue_style(
'wpse_89494_style_1',
get_template_directory_uri() . '/your-style_1.css'
);
}
if ( has_nav_menu( 'primary' ) ) {
wp_enqueue_style(
'wpse_89494_style_2',
get_template_directory_uri() . '/your-style_2.css'
);
}
if ( ! has_nav_menu( 'primary' ) && ! has_nav_menu( 'secondary' ) ) {
wp_enqueue_style(
'wpse_89494_style_3',
get_template_directory_uri() . '/your-style_3.css'
);
}
}
add_action( 'wp_enqueue_scripts', 'wpse_89494_enqueue_scripts' );