Created
July 7, 2022 20:31
-
-
Save patrickfreitasdev/71d59ee5cf470513bedb4f8c9d5f5a2d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('ABSPATH') or die('What are you looking for?'); | |
/** Handle the HTML */ | |
function my_custom_header_branda_shortcode_function( ){ | |
ob_start(); ?> | |
<div id="my-custom-header"> | |
<?php | |
wp_nav_menu( [ | |
'theme_location' => 'custom_universal_header' | |
]); | |
?> | |
</div> | |
<?php return ob_get_clean(); | |
} | |
/** Styles **/ | |
function custom_header_style_branda_header_function(){ | |
?> | |
<style> | |
#my-custom-header ul{ | |
display: flex; | |
justify-content: space-between; | |
list-style: none; | |
} | |
</style> | |
<?php | |
} | |
/** Scripts */ | |
function custom_header_scripts_branda_header_function(){ | |
?> | |
<script> | |
alert('function enabled'); | |
</script> | |
<?php | |
} | |
/*** Let's make a custom menu */ | |
function custom_branda_menu_register(){ | |
register_nav_menus( | |
[ | |
'custom_universal_header' => __( 'Universal Header', 'my-textdomain' ), | |
] | |
); | |
} | |
/** Hooks */ | |
add_shortcode( 'branda-custom-header','my_custom_header_branda_shortcode_function', 0 ); | |
add_action( 'wp_head','custom_header_style_branda_header_function', 10 ); | |
//add_action( 'wp_footer','custom_header_scripts_branda_header_function', 999 ); | |
add_action( 'after_setup_theme','custom_branda_menu_register', 10 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment