Last active
October 30, 2022 05:44
-
-
Save robertstaddon/fb4fb122fa22261d9c666400fca3cb39 to your computer and use it in GitHub Desktop.
Turn a WordPress Menu into a LiteSpeed ESI Block
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 | |
add_filter( 'wp_nav_menu', function( $nav_menu_html, $args ) { | |
if ( $args->menu_id == "menu-id-to-replace" ) { | |
if ( apply_filters( 'litespeed_esi_status', false ) ) | |
return apply_filters( 'litespeed_esi_url', 'my-esi-menu', 'Navigation Menu', array( 'nav_menu_html' => $nav_menu_html, 'args' => $args ), $control = 'private,no-vary', $silence = false ); | |
} | |
return $nav_menu_html; | |
}, 10, 2); | |
add_action( 'litespeed_esi_load-my-esi-menu', function ( $atts ) { | |
echo $atts['nav_menu_html']; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment