Last active
November 2, 2018 19:50
-
-
Save krogsgard/6386511 to your computer and use it in GitHub Desktop.
jQuery for handling toggle functionality with wp_localize_script ( small_menu_vars.size ) and WordPress.
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 | |
/** | |
* krogs_child_theme_new_menu_size function. | |
* | |
*/ | |
add_filter( 'krogs_theme_small_menu_size', 'krogs_child_theme_new_menu_size' ); | |
function krogs_child_theme_new_menu_size( $size ) { | |
$size = 450; | |
return 450; | |
} |
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 | |
/** | |
* Registers scripts for the theme and enqueue those used sitewide. | |
* | |
* @since 0.1.0. | |
*/ | |
add_action( 'wp_enqueue_scripts', 'krogs_theme_scripts' ); | |
function krogs_theme_scripts() { | |
wp_register_script( 'small-menu', get_template_directory_uri() . '/js/small-menu.js', array( 'jquery' ), '20120206', true ); | |
wp_localize_script('small-menu', 'small_menu_vars', array( | |
'size' => apply_filters( 'krogs_theme_small_menu_size', 600 ) | |
) | |
); | |
wp_enqueue_script( 'small-menu' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment