What Does the Wordpress "_E()" Function Do

wordpress _e function

This is one one classic bug.

When PHP started your script, $wordscut is not defined. When you run

$wordscut .= "sometext";

The code actually do

$wordscut = $wordscut . "sometext";

At this point, $wordscut is not available, thus Undefined Variable error occurred.

To fix it, add

$wordscut = '';

before

for($i=0; $i<count($info[0]); $i++) {

Wordpress how to use jquery and $ sign

By default when you enqueue jQuery in Wordpress you must use jQuery, and $ is not used (this is for compatibility with other libraries).

Your solution of wrapping it in function will work fine, or you can load jQuery some other way (but that's probably not a good idea in Wordpress).

If you must use document.ready, you can actually pass $ into the function call:

jQuery(function ($) { ...

Warning: call_user_func_array() expects parameter 1 to be a valid callback

The reason why you are getting that warning is already mentioned in comments section by @LoicTheAztec. I will quote his comment here:

That is when a hooked function name doesn't match with the hook
association… so for example when you have add_action('hook_name', 'function_name' ); and so function_name doesn't match with any
declared function… This can happen when renaming a function, but not
renaming the function name in the hook association.

I will give some pointers on how to debug and resolve the issue. Since you mentioned that it happened all of a sudden and you have not done anything, I assume that it might be caused by a plugin. One of your plugin might be updated and the plugin developer might have made this mistake.

What you can do is, visit your WordPress Admin Dashboard --> Plugins page. Then deactivate each plugin one by one. Make sure you check after deactivating each plugin, so that you would be able to figure out which plugin is causing the issue. While you are deactivating the plugins, if the warning disappeared, you would be able to tell that the plugin that you just deactivated is the villain here.

Since you figured out the plugin causing the issue, check whether it has any updates available. If so, update that plugin and see if it resolves the issue. If no updates,

  1. you could try contacting the plugin developer, reporting the bug.
  2. or, you could try debugging and fixing the bug yourself (if you are comfortable with coding)

If you plan to fix it yourself (#2), then try looking at the sourcecode of the plugin. Location would be : /wp-content/plugins/name_of_plugin

You can use the File Manager in your cPanel or use FTP, to access the files. On each file of that plugin, you have to search for add_action(. And note down the second parameter, which would be callback function name. And search whether that function is defined somewhere. If not defined, then it could be mispelled. You have to find the mispelled function definition and change it's name to what is being used (as second parameter) of add_action()

This will resolve the issue. In other case, while you are deactivating the plugins one by one and the warning message never disappeared even after trying to deactivate all the plugins, then you need look at your theme files (location: /wp-content/themes/your_current_theme_name_here/ )

To search for the keywords within files, there's a good plugin called String Locator. I most often use it for debugging purposes. Might come in handy for you.

How to style text inside _e() wordpress function?

As per the WordPress standard you can not use the html tag inside the _e() function.
Here I have shared the WordPress official link for your reference:
URL: https://developer.wordpress.org/reference/functions/_e/

As you can see in this function 1st parameter is string $text and 2nd paramenter string $domain = 'default'.

Here I have shared the example of code which you can use.

echo '<p style="color:red;">' . __( 'Please enter a valid email address!', 'mytextdomain' ) . '</p>';


Related Topics



Leave a reply



Submit