I have theme with this code in one php file :
'logged_in_as' => '<p class="logged-in-as">'.
sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>', 'testshop' ),
admin_url( 'profile.php' ),
$user_identity,
wp_logout_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ).
'</p>',
Now I want to change this code and unlocalized and only one text.
I change this to code below , but not work and get the error
Parse error: syntax error, unexpected ‘echo’ (T_ECHO)
'logged_in_as' => '<p class="logged-in-as">'.
echo ( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>'),
admin_url( 'profile.php' ),
$user_identity,
wp_logout_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ).
'</p>',
please help me to fix this. thanks
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
The main problem is that you removed the sprintf.
Replace the echo with sprintf and remove the ().
Should be like this
'logged_in_as' => '<p class="logged-in-as">'.
sprintf( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>',
admin_url( 'profile.php' ),
$user_identity,
wp_logout_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ).
'</p>',
Be careful! changing code directly in a plugin will lead to problems.
Next plugin update your code will be removed so be mindful.
If you can try using a filter, if the plugin has one. That way the changed you are doing when connecting to that filter will stay, unless the plugin author changed the filter name =]
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0