Parse error - unexpected 'class' (T_CLASS)
This is problem i get 5th time yet, using underscores.me _S theme...
Parse error: syntax error, unexpected 'class' (T_CLASS) in /public_html/xxx/wp-content/themes/mytheme/inc/wp-bootstrap-navwalker.php on line 1
using
<?php
wp_nav_menu( array(
'menu' => 'Main Menu',
'theme_location' => 'main',
'depth' => 2,
'items_wrap' => '<ul id="menu-top-menu" class="%2$s %1$s navbar-nav">%3$s</ul>',
'container' => '',
'container_class' => '',
'container_id' => '',
'menu_class' => 'nav main topnav',
'fallback_cb' => 'wp_bootstrap_navwalker::fallback',
'walker' => new wp_bootstrap_navwalker())
);
?>
register_nav_menus( array(
'main' => __( 'Main Menu', 'decom' )
) );
Sorry for the late reply.
This is odd, I build all of my themes with _s and have never run into this issues. did you discover anything additional?
Last 5times didnt get that error.. i guess it have something to do if there is no menu created and its calling it.. `coz last 5times i started with fresh installs and without wp_nav_menu before i created menu in backend... if it show again will note here.
Very interesting. If you have the fallback_cb value set as you do, there should not be an issue as it will create an assign a single menu item linking to the menu manager if your logged in.
@apsolut did you ever figure out what caused this error?
Since the error is thrown on line 1 of the wp-bootstrap-navwalker.php file I would think that the cause comes directly before the walker is included - rather than there being a problem with the actual walker.
I'm going to close this issue for the moment but if you still have problems come back and reopen it by commenting and I'll take a closer look at what might have happened that caused the error.
The problem was IDE, invisible chars on first line and inside start of <php header, also its not everytime, some kind of a bug with eclipse i guess, its random, every X project.. - after i changed editor no errors 2months... - last two times i was updating old projects, the same thing again, error first line etc... so i opened it in other IDE,deleted and added it again (empty space), all started working and errors stoped - without changing anything other than that...