Et_get_main_menu function problem with cache expire

This topic has 2 replies, 2 voices, and was last updated 4 years ago ago by Olga Barlow

  • Avatar: Sven_Moller
    Sven Möller
    Participant
    November 8, 2020 at 19:19

    There is a problem in et_get_main_menu function inside theme-functions.php
    The function wp_cache_add is getting $cache_slug value with “et_get_main-menu”, while wp_cache_add function just accepts an Int value in that position as cache expire time.

    
    if(!function_exists('et_get_main_menu')) {
        function et_get_main_menu( $menu_id = 'main-menu', $class = '' ) {
    
            $custom_menu_slug = 'custom_nav';
            $cache_slug = 'et_get_' . $menu_id;
            if($menu_id == 'main-menu-right') $custom_menu_slug = 'custom_nav_right';
            $custom_menu = etheme_get_custom_field( $custom_menu_slug );
            $one_page_menu = '';
            if(etheme_get_custom_field('one_page')) $one_page_menu = ' one-page-menu';
            if(!empty($custom_menu) && $custom_menu != '') {
                $output = false;
                $output = wp_cache_get( $class, $custom_menu, $cache_slug );
                if ( !$output ) {
                    ob_start();
    
                    wp_nav_menu(array(
                        'menu' => $custom_menu,
                        'before' => '',
                        'container_class' => 'menu-main-container' . $one_page_menu . $class,
                        'after' => '',
                        'link_before' => '',
                        'link_after' => '',
                        'depth' => 10,
                        'fallback_cb' => false,
                        'walker' => new Et_Navigation
                    ));
    
                    $output = ob_get_contents();
                    ob_end_clean();
    
                    wp_cache_add( $class, $custom_menu, $output, $cache_slug );
                }
    
    1 Answer
    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    November 10, 2020 at 09:44

    Hello,

    We’ll fix this issue in the next theme update. If you want to fix it now then https://prnt.sc/vgl317

    replace wp_cache_get( $class, $custom_menu, $cache_slug );
    by
    wp_cache_get( $class, $cache_slug );
    and
    wp_cache_add( $class, $custom_menu, $output, $cache_slug );
    by
    wp_cache_add( $class, $output, $cache_slug );

    Regards

  • Viewing 2 results - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.Log in/Sign up

8theme customization service
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.