Function create_function() is deprecated - deprecated

My site is currently on PHP 7.2.0, and I'm getting this error in my debug log showing PHP Deprecated: Function create_function() is deprecated
I don't know what happened but my site somehow became broken and stuff wasn't showing properly. The only way I can access my wordpress dashboard is when I force the site to load on a default theme.
So I guess the problem lies within my Theme...
Right now, the site doesn't load up at all and it's showing a blank white screen or saying that The site is experiencing technical difficulties.
I'm still a new web developer... Any idea what could have gone wrong and how to fix my current code that is showing the error?
add_action('widgets_init', create_function('', 'return register_widget("Essential_Grids_Widget");'));
Thanks for your help!

use it like this
$MywidgetName='Essential_Grids_Widget';
add_action('widgets_init', function () use ($MywidgetName) {
return register_widget($MywidgetName);
});

Related

Algolia - WordPress - Uncaught TypeError: wp.template is not a function

I am getting this error:
Uncaught TypeError: wp.template is not a function on template for Algolia. It is clearly associated with the widget that calls the hits:
search.addWidget(
instantsearch.widgets.hits({
container: '#hits',
hitsPerPage: 30,
templates: {
item: wp.template('instantsearch-hit'),
empty: "We didn't find any results for the search <em>\"{{query}}\"</em>"
}
})
);
From what I already know this needs wp-util.js script to work (this is supposed to be part of WordPress and this script can be found:
/wp-includes/js/wp-util.js
More about it here:
https://codex.wordpress.org/Javascript_Reference/wp.template
It seems the issue is that the template is not loading for some reason. I tried to enqueue the script via functions.php, but after doing so apart from getting previous error I get two new errors:
Uncaught ReferenceError: _ is not defined
at wp-util.js:17
at wp-util.js:124
Did anyone had such issue and managed to resolve it already?
Thank you for your help.
Are you using Cloudflare rocket loader by any chance?
There is a bug report for the same error that is apparently caused by Cloudflare rocket loader.
The solution mentioned in that bug report is:
I applied a small workaround to prevent the js error, which was
blocking other scripts in my website, adding:
if( wp.template == null ) return;
right after the firing of the script:
jQuery(function () {
In this way, my following scripts are fired correctly, but sometimes
(let's say 1 time every 4 page loads) the autocomplete search is not
fired.
Faced same issue in my wp's admin panel. And found that "BackUpWordpress" plugin was the problem. I just deactivate it and checked page again. Error was gone.
So the solution is just deactivate additional plugins one by one and check errored page every time. This is how you can have the idea which plugin is responsible for this jquery error.
I confirmed that to deactivate plugin will not erase saved data inside that plugins. So there is no issue to deactivate plugin. Once your work complete on the page where "Uncaught TypeError: wp.template is not a function" error occurred, you can activate plugins again.
In my case I had W3 Total Cache plugin installed, and Minify option was set to Manual.
After I removed wp-underscore script from manual minify list, issue with the wp.template() Not a function was gone.

Ninja Forms 3.0.11: <noscript>

I am getting this no script error, and am unsure as to why.
Javascript is allowed in my browser, and the adblock is disabled. I see Ninja Forms 3.0.11 has a JS directory with several files.
<noscript class="ninja-forms-noscript-message">
Notice: JavaScript is required for this content.</noscript>
Has anyone come across this upgrading? If so, could you please explain how you resolved this?
Thank you.
I was having this same problem today so I decided to switch themes and see if that fixed it. And that did fix the problem. So I switched back and it was still broken. I inspected the page and noticed there was a JS error in the console and I resolved that JS error that had nothing to do with Ninja Forms and it made my form show up and work fine now. So it seems if there are any JS errors going on it will affect it.
Make sure all of the scripts from your header and footers are getting added to the page correctly. I experienced this issue with an add on for ninja forms and my call to get_footer wasn't being included on the page and created this issue.
i got same error:
Notice: JavaScript is required for this content.
i removed my cache plugin Autoptimize, SG optimizer, the plugin used to combine js/css files etc,
it will solve your problem :)
Thank You
Мy decision: add code <? php wp_footer (); ?> in the template file footer.php

Wordpress: media library grid mode infinite loading

So this problem is very strange because for me doesn't work Wordpress media library in Wordpress admin menu only grid mode, its very strange problem because this problem occurs ONLY on 1 account/ That would be same account that yesterday i was trying upload bunch of pictures to media library and it gave error:
Try again later...
Since that i have tried many things but besides logging with other account nothing helped.
Tried reninstall wordpress via wordpress admin panel
Tried disabling all plugins, changed theme to default wordpress
Tried inspect elemet for JS errors nothing there except
upload.php?mode=grid:46 Consider using 'dppx' units, as in CSS 'dpi'
means dots-per-CSS-inch, not dots-per-physical-inch, so does not
correspond to the actual 'dpi' of a screen. In media query expression:
print, not all, (-webkit-min-device-pixel-ratio: 1.25),
(min-resolution: 120dpi)
Tried include in theme functions bunch of codes that i found on internet didn't helped.(i don't have them now since nothing helped and i didn't saved them sorry...)
Tried flushing cache, proxy, different computers, different operating systems(max,windows), tablet nothing still on that particular account media grid view doesn't work
View that 'm seeing is this:
I don't understand whats wrong, why on 1 particular account it doesn't work i even tried flushing Wordpress cache but it doesn't work after i received that error which i showed above. Did somebody know how can i solve this? Thanks in advance!
Got exactly the same problem and some ajax error on revolution slider too, and after searching for long time i resolved my problem.
It was just an HTML comment in functions.php on child theme, after remove it, everything work perfectly for me.
Same problem with space in function.php don't cut your code with space between php tag
this type problem is create by functions.php file , remove the code of you added in functions.php and than see it work proper.
standerd code write in functions.php file
In my case, there was an error in the backend. You should check your network tab in developer tools and find admin-ajax.php. Even if it returns HTTP 200, it shows an error in the response body.
From the information provided, you can work on which plugin, theme, or whatever file causes the error.
If the problem is with the user and seeing that you have tried almost all, you can try deleting the user and creating it again.
I had exactly the same error. I could not search for plugins, get the list of my uploads, everywhere where an ajax function was triggered, I needed to reload the page to see the results.
clean your functions.php and see if it works now. if yes, clean up your functions.php search for spaces or not set closing tags.
Solution was simple – I just had accidentally added a closing php tag in my functions.php (?>).
After I removed it the problem was solved.

WordPress + Easy FancyBox = d.onCleanup is not a function

Hi Guys I have a problem similar to this previous question but based on WordPress.
Everything was working fine, then the plugin has stopped to work! I am no more able to load my modal windows because the plugin is not able to load the CSS.
The fact is that I've tryed to unistall and install a brand new version of the plugin a coupple of times, but noting has changed, I still see this error:
d.onCleanup is not a function
from the file wp-content/plugins/easy-fancybox/fancybox/jquery.fancybox-1.3.4.pack.js?ver=1.3.4
Now I've seen that I sould check for the css file created by easy-fancybox.css.php and when I try what's is inside this file I've a 404 Nothing Found error, but the file is present inside my folder and I really don't understand why its behaving like that!
I've cheched permissions, copied a coupple of times but nothing solved my problem!
Someone has a clue on how to fix this issue?
If you wanna see the site follow this link and click on a thumbnail.
Thanks for the help!
Just add fancybox js and css like below.
add_action('init','jsregister');
function jsregister(){
wp_register_script( 'fb', WP_PLUGIN_URL.'/fancybox/fancy/jquery.fancybox-1.3.4.pack.js','jquery', false );
wp_enqueue_script( 'fb' );
wp_register_script( 'fbe', WP_PLUGIN_URL.'/fancybox/fancy/jquery.easing-1.3.pack.js','jquery', false );
wp_enqueue_script( 'fbe' );
wp_register_style('fbs', WP_PLUGIN_URL.'/fancybox/fancy/jquery.fancybox-1.3.4.css');
wp_enqueue_style( 'fbs');
}
I'm sure you're long past this, but as it came up for me, I'll present what worked for me, namely Turn off Super-cache or whatever cache type plugin you might have running (make sure the cache files are gone too.) Everything went back to normal for me after that.
It seems your WP installation in the site root catches the call to http://designonsale.info/wordpress/wp-content/plugins/easy-fancybox/easy-fancybox.css.php?ver=1.3.4 before it reaches the actual file.
Is there some .htaccess rule doing that maybe?

'Undefined function' in fresh WordPress install?

I've been having a problem with my media browser for weeks and haven't been able to solve it. When browsing to insert an image, the media library shows absolutely nothing, just blank white. I see tabs telling me that it sees the objects in the library, but they do not display as thumbnails to select.
For some reason it just occurred to me (a-doy) to look at my server logs - turns out my ISP has been suppressing PHP errors. The error I'm getting is this:
PHP Fatal error: Call to undefined
function get_post_thumbnail_id() in
REDACTED/wp-admin/includes/media.php
on line 1292, referer:
http://REDACTED/wp-admin/media-upload.php?post_id=877&type=image&
Now this is baffling - I did a completely fresh install of WordPress to try and solve this problem, and yet I'm still getting an "undefined function" error. Why is this happening, and how can I fix it?
Any help is greatly appreciated. Thank you!
It looks as if you have to initialize theme support before get_post_thumbnail_id() can be used.
<?php add_theme_support('post-thumbnails'); ?>
http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
Make sure that your add_theme_support('post-thumbnails') function is run before init. I know this has screwed me up when I had it in a hook tied into init.
If it has to be hooked in, it should be hooked into after_setup_theme

Resources