Woocommerce PHP Fatal Error - wordpress

I am getting the white screen of death with my Wordpress site and I have narrowed it down to a .php file in my Woocommerce includes file. The error is as follows:
PHP Fatal error: Call to a member function get_formatted_name() on a non-object in /home2/hatchchi/public_html/wp-content/plugins/woocommerce/includes/wc-deprecated-functions.php on line 63
Here is what line 63 includes:
function woocommerce_get_formatted_product_name( $product ) {
_deprecated_function( __FUNCTION__, '2.1', 'WC_Product::get_formatted_name()' );
return $product->get_formatted_name();
}
I tried removing the file, the line of code and replacing the Woocommerce plugin manually via FTP but nothing fixed it.
What would be causing this sort of error? What is the solution?

By best to narrow these sort of things down is to try deactivating all other plugins and trying a default WordPress theme to see if that solves your issue.

Related

WordPress function undefined when adding a shortcode

We would like to add a custom function of a shortcode in wp_include/functions.php.
This is the function:
function url_id() {
$apiUrl = 'https:exampleurl.api.com/exemple123';
$response = wp_remote_get($apiUrl);
return wp_remote_retrieve_body($response);
}
add_shortcode('session_id', 'url_id');
But we were getting this error:
There has been a critical error on this website.
Learn more about troubleshooting WordPress.
After reading some more troubleshooting documentation we added these two lines in wp-config:
define( 'WP_DEBUG', true );
define( 'WP_CACHE', true );
And after that we are getting this error:
Fatal error: Uncaught Error: Call to undefined function add_shortcode() in /home/c1624672c/public_html/woo/wp-includes/functions.php:18 Stack trace: #0 /home/c1624672c/public_html/woo/wp-settings.php(111): require() #1 /home/c1624672c/public_html/woo/wp-config.php(104): require_once('/home/c1624672c...') #2 /home/c1624672c/public_html/woo/wp-load.php(50): require_once('/home/c1624672c...') #3 /home/c1624672c/public_html/woo/wp-blog-header.php(13): require_once('/home/c1624672c...') #4 /home/c1624672c/public_html/woo/index.php(17): require('/home/c1624672c...') #5 {main} thrown in /home/c1624672c/public_html/woo/wp-includes/functions.php on line 18
There has been a critical error on this website. Learn more about troubleshooting WordPress.
If you want to add custom shortcodes to your website, that can be done via a custom plugin, or in your theme (as I suspect you're trying to do).
Instead of editing wp-includes/functions.php, add your code to wp-content/themes/<name-of-your-theme>/functions.php.
You should never edit the core files of WordPress, which includes all files in /wp-admin and /wp-includes. When you upgrade WordPress in the future, these files will be overwritten, and you'll lose any changes you've made.
The error message occurs because you're attempting to use the add_shortcode() function before WordPress has fully loaded, and defined all available functions.
Please change the shortcode parameter session_id because session_id predefined function in wordpress see the blow or your code
add_shortcode('session_id', 'url_id');
But right code will be work when you change the session_id.

When trying to preview a theme - The site is experiencing technical difficulties. Please check your site admin email inbox for instructions

When trying to preview a new theme for my blog, this appears...
The site is experiencing technical difficulties. Please check your site admin email inbox for instructions.
I didn't receive an email though. I've tried deactivating all of my plugins and this didn't work. Any ideas? I'm new to this.
You should detect the error before do anything.
Turn on WP debug mode and you will see what error do you have:
In wp-config.php:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', true );
More information about WP debugging: https://wordpress.org/support/article/debugging-in-wordpress/
Website/Admin is displaying "The site is experiencing technical difficulties. Please check your site admin email inbox for instructions."
This was my solution for our website. I only fixed enough issues for the admin page to start working again.
This was all done after I fixed my initial site issues that crashed the entire site, addressed in this question: https://stackoverflow.com/a/65357857/14850513
After I made those fixes, the admin page was still giving the previously stated error message that you described, so here is how I fixed it. The following bullets are all of the error messages I faced and how I fixed them. This may not solve everyone's issues but these were the specific ones I faced.
Go to the public.html/wp-config.php
go to the following line and change debugging to true
define('WP_DEBUG', false); #Change to true
This will show all of the errors that are causing the site to have issues. You must address them until it begins to function again. You will know because it will start working the next time you refresh.
ERROR 1: Array and string offset access syntax with curly braces is deprecated
Follow to each line listed and change '{}' to '[]'
ERROR 2: Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home1/seth/public_html/wp-content/plugins/revslider/includes/operations.class.php on line 2364
I open the php file at the problem line, I changed the term [continue;] to [break;]
ERROR 3: "Deprecated: Function create_function() is deprecated in xxx.php" on 258 line
Changed
public static function registerWidget($widgetName){
add_action('widgets_init', create_function('', 'return register_widget("'.$widgetName.'");'));
}
to
public static function registerWidget($widgetName){
add_action('widgets_init', function () use ($widgetName) {
return register_widget($widgetName);
});
}
ERROR 4: Fatal error: Uncaught Error: [] operator not supported for strings
the failing line was:
self::$arrMetaBoxes[] = $box;
The fix is to add the following line right before it
self::$arrMetaBoxes = [];
My admin page started working at this point, but you may need to continue fixing errors until it begins to function properly again.

WordPress Fatal Error Class 'wpforge_walker' not found line 317

I'm receiving the following error on my WordPress website:
Fatal error: Class 'wpforge_walker' not found in
/home/content/25/11572025/html/site/wp-content/themes/wp-starter/content-nav.php
on line 317
On my FTP File Manager, line 317 on "content-nav.php" shows the following:
'walker' => new wpforge_walker( array(
After reading on this issue other forums mentioned how removing the parenthesis might solve the problem. Accordingly, this is how I saved the "content-nav.php" file:
'walker' => new wpforge_walker
After refreshing my website, it is showing the following error:
Parse error: syntax error, unexpected ''in_top_bar''
(T_CONSTANT_ENCAPSED_STRING), expecting ')' in
/home/content/25/11572025/html/site/wp-content/themes/wp-starter/content-nav.php
on line 319
I went back to my FTP File Manager and put back the "( array(" into the "content-nav.php" file and now I'm back to my initial problem.
Any assistance would be appreciated. Thanks!
You are using the Theme wp-starter, can you share any more info about it, developer, website, etc.?
Share a bigger chunk of code from content-nav.php, for example rows 300 till 350. Make sure you include the complete block of code.
Removing ( array( will result in another error. This is normal because it will completely break the function.
Some info about the error.
The code wants to load the class wpforge_walker, but it isn't available. Something went wrong with including the file that contains that particular class.
In the error log, do you see another returning log (notice or something else) before the fatal error? I'm looking for an include_once() / No such file or directory error, or something like that.
Another option is to re-upload ALL theme files, maybe an update or something else did not complete correctly. You can overwrite all theme files savely.
Edit: re-upload all theme files fixed the problem.
Disable theme to get WP admin access.
Using FTP or a hosting filemanager you can rename the theme folder, example 'wp-starter-off'.
WP will then deactivate the theme and you can access WP again.
Regards, Bjorn

Notice and warning with Video Sidebar Widgets plugin

I'm getting a notice and a warning when I try to delete a post or update something:
Notice: Undefined index: vsw_noncename in /mysite/wp-content/plugins/video-sidebar-widgets/class-postmetavideowidget.php on line 296
Warning: Cannot modify header information - headers already sent by (output started at /mysite/wp-content/plugins/video-sidebar-widgets/class-postmetavideowidget.php:296) in /mysite/wp-includes/pluggable.php on line 881
¿Any hints about this? I have tried to fix the Header Information issue by removing spaces in the file as the codex says but without results, so, probably is another thing.
I'm using wordpress 3.4.2, the plugin version is 5.3 (latest) and a custom theme (checked with Theme-Check and no issues found)
Thank you for your help
The plugin has a bug - it is not checking to make sure that the nonce field exists in the $_POST. Many types of actions that call save_post will not have this field, as it is only added on the post editor (line 154 of the plugin).
You should check to make sure that the nonce field exists before validating it. If it does not exist, just return from the function.
To correct it change line 296-297 to read:
if ( !isset($_POST['vsw_noncename']) || !wp_verify_nonce( $_POST['vsw_noncename'], plugin_basename( __FILE__ ) ) )
return;

Missing includes in Wordpress plugin (wp_insert_post function)

I created a code which generates content and I want to populate Wordpress's database with it. I am using wp_insert_post and add_post_meta functions but every time I load which triggers the script I get this error:
Fatal error: Call to undefined function add_action() in \www\scriptmafia\wp-includes\post.php on line 153
To my mind it due to some missing includes. I have included post.php which it mentioned as required include for wp_insert_post function.
I know this is pretty common among newbies in WordPress. However, any solution I have tried have not worked for me.
require_once( ABSPATH . '/wp-load.php'); should solve it :)

Resources