PHP Warning: Missing argument 1 for __ ()

0

Greetings, I made for one of my wordpress sites an .php file that contains all the tags with the corresponding links said publications. I do not have much knowledge of php, the file I did was basically built by modifying the original file destined for the categories. Apparently it works fine, but in the cpanel log I'm looking at a lot of errors, here's an example:

  

PHP Warning: Missing argument 1 for __ (), called in /home/wksxspir/public_html/wp-content/themes/tube/all_tag.php on line 48 and defined in / home / wksxspir / public_html / wp-includes /l10n.php on line 201

The same error is repeated again and again and I have no idea how to solve it, I do not want to touch things and end up ruining my site

The file I made is all_tag.php, on line 48 of that file is this:

echo '<div class="buttons"><a class="btn" href="' . get_tag_link( $tag->term_id ) . '" title="' . sprintf( __( ), $tag->name ) . '" ' . '>View All '. $tag->name.'</a></div>';

On line 201 of the l10n.php file you can find this:

function __( $text, $domain = 'default' ) {

What should I do? I would appreciate your suggestions.

    
asked by Lucius 13.02.2017 в 13:49
source

1 answer

1

We go by parties

On the 48 line do the following:

echo '<div class="buttons"><a class="btn" href="' . get_tag_link( $tag->term_id ) . '" title="' . sprintf( __( ), $tag->name ) . '" ' . '>View All '. $tag->name.'</a></div>';

But, if you analyze the line, you will find that you are calling your function __() without passing any argument:

sprintf( __( ), $tag->name )

While the function statement is:

function __( $text, $domain = 'default' );

The literal translation of your error is:

  

Lost argument 1 of the function __ () ...

You have 2 solutions:

  • You add the first parameter to the function.

    sprintf (__ ("Hello World"), $ tag- > name)

  • You add a default parameter as you do with the parameter $domain

    function __ ($ text = 'Hello World', $ domain = 'default');

  • answered by 13.02.2017 в 14:15