-1

I am getting this error in my server error logs:

[Thu Dec 11 10:06:30 2014] [error] [client 11.111.111.111] PHP Warning:  Missing argument 1 for __(), called in /var/www/vhosts/mysite.org/public_html/wp-content/themes/mysite_v2.2/functions-cpt-projects.php on line 15 and defined in /var/www/vhosts/mysite.org/public_html/wp-includes/l10n.php on line 146, referer: http://www.mysite.org/wp-admin/edit.php

I've never encountered this before and I'm wondering what might be causing it. The line of code it refers to in the l10n.php file is:

function __( $text, $domain = 'default' ) {
    return translate( $text, $domain );
}

I'm wondering if anyone knows how I might go about debugging this? I read somewhere that it could be related to a plugin and to disable them one by one to find out if the issue is resolved but this has not worked for me as of yet.

  • 1
    PHP errors are off-topic as they are not specific to WordPress. Also, note that the error message says what is causing the problem: you are not providing the first argument that is required by the function. – cybmeta Dec 12 '14 at 12:07
2

you get this error if you passed empty string or did not pass any argument to the __() function.

You should check where you've used the __() function and check what value is being passed as argument.

0

I had a similar problem.
The issue was with a Custom Post Type and the solution was that the _x() translation function needed context (the 'missing argument') for a single word that has multiple meanings.

Example: Custom Post Type "Members" threw this error:

Warning: Missing argument 2 for _x(), called in /wp-content/plugins/my-cpt/posttypes.php on line 29 and defined in /Users/SITE-NAME/Sites/THEME-NAME/wp-includes/l10n.php on line 294


Without context, my Custom Post Type looked like this:


Custom Post Type without Context

The 'Members' name/s were throwing all the errors because without context, (the second argument taken by the _x() function), translators might not know which Member I was referring to.


For Example:

  • Member - Someone or something that belongs to a group or an organization?
  • Member - A part of a structure?
  • Member - A body part, such as an arm or a leg?


    So I added context:

Custom Post Type with context

And the error messages went away.

  • 1
    Though it’s optional it is allways good to set the third parameter ($domain) using a short unique custom string. That helps to differentiate when using for example string translation plugins. – Luckyfella Feb 2 '18 at 8:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.