library/Helper/Navigation.php
public function mobileMenuAuto()
    {
        //Create common hash for 404 & search
        if(is_search()) {
            $transientHash = "is_search";
            $cacheTtl = 60*60*168; //Cache for a week
        } elseif(is_404()) {
            $transientHash = "is_404";
            $cacheTtl = 60*60*168; //Cache for a week
        } else {
            $transientHash = \Municipio\Helper\Hash::short(\Municipio\Helper\Url::getCurrent());
            $cacheTtl = 60*30; //Cache for an hour
        }

        //Toggle between logged out / logged in
        $transientType = '';
        if (is_user_logged_in()) {
            $transientType = '_loggedin';
        }

        //Get menu cached value
        $menu = wp_cache_get($transientHash, 'municipioMenuCache' . $transientType);

        if (!$menu || (isset($_GET['menu_cache']) && $_GET['menu_cache'] == 'false')) {

            $mobileMenuArgs = array(
                'include_top_level' => true
            );

            if (get_field('nav_primary_type', 'option') == 'wp') {
                $mobileMenuArgs['top_level_type'] = 'mobile';
            }

            //Render menu
            $menu = new \Municipio\Helper\NavigationTree($mobileMenuArgs);

            //Add to cache
            wp_cache_add($transientHash, $menu, 'municipioMenuCache' . $transientType, $cacheTtl);
        }

        if ($menu->itemCount === 0) {
            return '';
        }

        return '<ul class="nav-mobile">' . apply_filters( 'Municipio/Helper/Navigation/MobileMenuAutoItems', $menu->render(false) ) . '</ul>';
    }
public function mobileMenuAuto()
    {
        //Create common hash for 404 & search
        if(is_search()) {
            $transientHash = "is_search";
            $cacheTtl = 60*60*168; //Cache for a week
        } elseif(is_404()) {
            $transientHash = "is_404";
            $cacheTtl = 60*60*168; //Cache for a week
        } else {
            $transientHash = \Municipio\Helper\Hash::short(\Municipio\Helper\Url::getCurrent());
            $cacheTtl = 60*30; //Cache for an hour
        }

        //Toggle between logged out / logged in
        $transientType = '';
        if (is_user_logged_in()) {
            $transientType = '_loggedin';
        }

        //Get menu cached value
        $menu = wp_cache_get($transientHash, 'municipioMenuCache' . $transientType);

        if (!$menu || (isset($_GET['menu_cache']) && $_GET['menu_cache'] == 'false')) {

            $mobileMenuArgs = array(
                'include_top_level' => true
            );

            if (get_field('nav_primary_type', 'option') == 'wp') {
                $mobileMenuArgs['top_level_type'] = 'mobile';
            }

            //Render menu
            $menu = new \Municipio\Helper\NavigationTree($mobileMenuArgs);

            //Add to cache
            wp_cache_add($transientHash, $menu, 'municipioMenuCache' . $transientType, $cacheTtl);
        }

        if ($menu->itemCount === 0) {
            return '';
        }

        return '<ul class="nav-mobile">' . apply_filters( 'Municipio/Helper/Navigation/MobileMenuAutoItems', $menu->render(false) ) . '</ul>';
    }
public function mobileMenuAuto ( ) { //Create common hash for 404 & search if ( is_search ( ) ) { $ transientHash = "is_search" ; $ cacheTtl = 60 * 60 * 168 ; //Cache for a week } elseif ( is_404 ( ) ) { $ transientHash = "is_404" ; $ cacheTtl = 60 * 60 * 168 ; //Cache for a week } else { $ transientHash = \ Municipio \ Helper \ Hash :: short ( \ Municipio \ Helper \ Url :: getCurrent ( ) ) ; $ cacheTtl = 60 * 30 ; //Cache for an hour } //Toggle between logged out / logged in $ transientType = '' ; if ( is_user_logged_in ( ) ) { $ transientType = '_loggedin' ; } //Get menu cached value $ menu = wp_cache_get ( $ transientHash , 'municipioMenuCache' . $ transientType ) ; if ( ! $ menu || ( isset ( $ _GET [ 'menu_cache' ] ) && $ _GET [ 'menu_cache' ] == 'false' ) ) { $ mobileMenuArgs = array ( 'include_top_level' => true ) ; if ( get_field ( 'nav_primary_type' , 'option' ) == 'wp' ) { $ mobileMenuArgs [ 'top_level_type' ] = 'mobile' ; } //Render menu $ menu = new \ Municipio \ Helper \ NavigationTree ( $ mobileMenuArgs ) ; //Add to cache wp_cache_add ( $ transientHash , $ menu , 'municipioMenuCache' . $ transientType , $ cacheTtl ) ; } if ( $ menu -> itemCount === 0 ) { return '' ; } return '<ul class="nav-mobile">' . apply_filters ( 'Municipio/Helper/Navigation/MobileMenuAutoItems' , $ menu -> render ( false ) ) . '</ul>' ; }
Get navigation tree mobile menu
@return [type] [description]
Get navigation tree mobile menu