halben Posted October 15, 2013 Share Posted October 15, 2013 I'm getting this : PHP Parse error: syntax error, unexpected T_STRING on this line of code, $link = '<a href="' . esc_url(wp_logout_url($redirect)) . '" title="' . esc_attr(__('Logout')) . '">' . esc_attr(__('Logout')) . '</a>'; Am I missing something? Thanks, hal Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted October 15, 2013 Share Posted October 15, 2013 the line of code you posted doesn't produce that error. the problem is on a line leading up to that one, usually a missing ; look at 2-3 lines before that one. Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted October 15, 2013 Share Posted October 15, 2013 It's probably the line before that one as that one is OK. Try pasting it here in code tags and the syntax highlighting should show the error. Also, if you use a good editor it should highlight errors. Quote Link to comment Share on other sites More sharing options...
halben Posted October 15, 2013 Author Share Posted October 15, 2013 (edited) Here is what I have: add_filter('wp_nav_menu_items', 'custom_menu', 50, 2); function custom_menu($items, $args) { if (is_admin() || $args -> theme_location != 'top_menu') return $items; if (is_user_logged_in()) { $user = wp_get_current_user(); $firstName = $user -> user_firstname; $lastName = $user -> user_lastname; $items .= '<li id="user-name" title="Edit" ><a href="' . esc_url(site_url('/profile')) . '">' . esc_attr($firstName) . ' ' . esc_attr($lastName) . '</a></li>'; $link = '<a href="' . esc_url(wp_logout_url($redirect)) . '" title="' . esc_attr(__('Logout')) . '">' . esc_attr(__('Logout')) . '</a>'; } else { $link2 = '<a href="' . esc_url(site_url('/register')) . '" title="' . esc_attr(__('Register')) . '">' . esc_attr(__('Register')) . '</a>'; $items .= '<li id="register-link" class="menu-item menu-type-link">' . $link2 . '</li>'; $link = '<a href="' . esc_url(wp_login_url($redirect)) . '" title="' . esc_attr(__('Login')) . '">' . esc_attr(__('Login')) . '</a>'; } return $items .= '<li id="log-in-out-link" class="menu-item menu-type-link">' . $link . '</li>'; } Edited October 15, 2013 by halben Quote Link to comment Share on other sites More sharing options...
halben Posted October 15, 2013 Author Share Posted October 15, 2013 I've looked over the code over and over and I'm wondering if there is an escape issue? Or other codes before that. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted October 15, 2013 Share Posted October 15, 2013 nope, the code in the post does not produce that syntax error. some possibilities - 1) your actual code contains some smart/curly quotes or other non-ascii characters in the php code, and when you paste it into this forum, they are converted to straight quotes, 2) the actual file/line where the error is at is not the code you are looking at (perhaps you have multiple versions at different paths.) has this code ever worked? are you typing this code or are you copy/pasting this from some web site (code is often 'published' using characters/encoding that isn't valid code)? Quote Link to comment Share on other sites More sharing options...
Solution halben Posted October 15, 2013 Author Solution Share Posted October 15, 2013 (edited) I figured it out. It's silly. I checked my error log and the error was posted 2 hours ago. I probably fixed it and forgot it was an old error. Sorry for your time and thanks for checking the code. Edited October 15, 2013 by halben Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted October 15, 2013 Share Posted October 15, 2013 during development, you should have your errors displayed, not logged. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.