I copy/pasted some JS in the functions.php file of the Kalium Child Freelancer Theme and I must have done something wrong because it went horribly wrong. My site went offline with a critical error and stuff.
I replaced the functions.php file with the original one from the theme files and the site came back but this error displays at the top of my WP back-office:
"Deprecated: rtrim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/sofianewjd/www/wp-includes/formatting.php on line 2827"
Everything works fine on the website, but I can't add new JS code to functions.php, I mean I can but it doesn't work.
After looking up online, I tried to go back to PHP 8.0 (although it worked perfectly fine with PHP 8.1 until then), the error disappeared but the JS still didn't work. When I try to switch to PHP 8.2, even more errors appear.
Unfortunately, the last save is from two weeks ago so I can't revert to it. I don't understand how this error appeared even though I didn't touch the formatting.php file.
Do you have any idea on how I can fix this? Huge thanks in advance, have a nice day.
First, here is the error I received by email after I updated the php file with a mistake:
"Détails de l’erreur ====================== Une erreur de type E_ERROR a été causée dans la ligne 18 du fichier /home/sofianewjd/www/wp-content/themes/kalium-child-freelancer/functions.php. Message d’erreur : Uncaught Error: Failed opening required '/home/sofianewjd/www/wp-content/themes/kalium-child-freelancer/includes/classes/kalium-main.php' (include_path='.:/usr/local/php8.1/lib/php') in /home/sofianewjd/www/wp-content/themes/kalium-child-freelancer/functions.php:18 Stack trace: #0 /home/sofianewjd/www/wp-settings.php(600): include() #1 /home/sofianewjd/www/wp-config.php(95): require_once('/home/sofianewj...') #2 /home/sofianewjd/www/wp-load.php(50): require_once('/home/sofianewj...') #3 /home/sofianewjd/www/wp-admin/admin-ajax.php(22): require_once('/home/sofianewj...') #4 {main} thrown"
Since yesterday, here is what I tried:
-reverting to the UpdraftPlus save from two weeks ago: it didn't make the error disappear
-disabling UpdraftPlus : the error disappears from the back office but leaves a blank space and the JS I add in functions.php or footer.php still doesn't work
-reverting to PHP 7.4 : the error disappears and leaves no blank space, but the JS doesn't work neither in functions.php nor in footer.php
-replacing formatting.php with the original file from WP installation files : it didn't work
What I don't understand is that from what I gathered, the "Deprecated" error simply suggests that something in the formatting.php file won't be supported in future PHP updates. Thus, I don't get why it prevents my JS from working. It doesn't look connected but since the Deprecated error appeared after a fail with the JS, it's the natural conclusion.
I really hope you'll be able to help me, I don't care much about the "Deprecated" thing itself but I really need the JS to work.
I forgot to try it this way and it does work, so thanks a lot!!
However, the text "function custom_js() { echo ''; }" displays at the bottom of each page, could you tell me how to make it disappear?
Last question: do you think there won't be any problem if I leave the deprecated thing as is? I worry that I left something unrepaired since the JS in question worked just fine in functions.php before.
1. There may be a typo in the code which is showing the "function custom_js() { echo ''; }". Can you please share your site credentials here, because we need to login to your site and see this issue live. Your information is safe (private) in this thread.
To include your credentials click Insert Credentials button in the editor toolbar. (See how)
2. We recommend using PHP 8.1 as it is not recommended to update to 8.2 since there may be some code in the theme and plugins which is not compatible with this version of PHP.
There was an error in the code and that was causing the errors to show in the live site.
2. The problem is not related to the theme, I have switched to the default WordPress theme and the warning still shows. Have you tried disabling plugins one by one to troubleshoot and see which of them is showing this warning?
Having made some researches, I found that UpdraftPlus was responsible for this error in some cases. I deleted it and the error disappeared, but it leaves a blank space where it used to display:
I tried disabling the plugins, the blank space was still there. The only time I saw it disappear completely since the beginning of all this is when I switched to PHP 7.4.
This displayed at the top when I reactivated WooCommerce but disappeared shortly after, I'm no expert but I think it had to do with the WooCommerce payment plugins left active while Woocommerce itself was disabled.
My website looks like it works just fine as is, but these questions remain:
-why didn't the error appear before I fumbled with functions.php, if UpdraftPlus was at fault?
-why won't the blank space disappear? It feels like there's another error but it doesn't display for some reason.
-why the JS didn't work in functions.php since last Friday when I made the mistake, even though the same JS worked just fine before?
I'm not sure you're the persons to ask for this since it doesn't look like it has something to do with Kalium, but I'd be very grateful if you could point me to where I could look for to find the answers for this.
As mentioned previously the problem is related to the plugins so it's not that we don't want to help you but that's not related at all to the theme, or we do not have the expertise to give you instructions on how to fix something the theme is not causing. I would suggest you contact the plugin support whichever plugin is causing these errors, just let them know the issues are occurring with the default WordPress theme since everyone will point out that you have to check the theme.
Hi, it's me again (hopefully for the last time !)
I copy/pasted some JS in the functions.php file of the Kalium Child Freelancer Theme and I must have done something wrong because it went horribly wrong. My site went offline with a critical error and stuff.
I replaced the functions.php file with the original one from the theme files and the site came back but this error displays at the top of my WP back-office:
"Deprecated: rtrim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/sofianewjd/www/wp-includes/formatting.php on line 2827"
Everything works fine on the website, but I can't add new JS code to functions.php, I mean I can but it doesn't work.
After looking up online, I tried to go back to PHP 8.0 (although it worked perfectly fine with PHP 8.1 until then), the error disappeared but the JS still didn't work. When I try to switch to PHP 8.2, even more errors appear.
Unfortunately, the last save is from two weeks ago so I can't revert to it. I don't understand how this error appeared even though I didn't touch the formatting.php file.
Do you have any idea on how I can fix this?
Huge thanks in advance, have a nice day.
Some more details:
First, here is the error I received by email after I updated the php file with a mistake:
"Détails de l’erreur
======================
Une erreur de type E_ERROR a été causée dans la ligne 18 du fichier /home/sofianewjd/www/wp-content/themes/kalium-child-freelancer/functions.php. Message d’erreur : Uncaught Error: Failed opening required '/home/sofianewjd/www/wp-content/themes/kalium-child-freelancer/includes/classes/kalium-main.php' (include_path='.:/usr/local/php8.1/lib/php') in /home/sofianewjd/www/wp-content/themes/kalium-child-freelancer/functions.php:18
Stack trace:
#0 /home/sofianewjd/www/wp-settings.php(600): include()
#1 /home/sofianewjd/www/wp-config.php(95): require_once('/home/sofianewj...')
#2 /home/sofianewjd/www/wp-load.php(50): require_once('/home/sofianewj...')
#3 /home/sofianewjd/www/wp-admin/admin-ajax.php(22): require_once('/home/sofianewj...')
#4 {main}
thrown"
Since yesterday, here is what I tried:
-reverting to the UpdraftPlus save from two weeks ago: it didn't make the error disappear
-disabling UpdraftPlus : the error disappears from the back office but leaves a blank space and the JS I add in functions.php or footer.php still doesn't work
-reverting to PHP 7.4 : the error disappears and leaves no blank space, but the JS doesn't work neither in functions.php nor in footer.php
-replacing formatting.php with the original file from WP installation files : it didn't work
What I don't understand is that from what I gathered, the "Deprecated" error simply suggests that something in the formatting.php file won't be supported in future PHP updates. Thus, I don't get why it prevents my JS from working. It doesn't look connected but since the Deprecated error appeared after a fail with the JS, it's the natural conclusion.
I really hope you'll be able to help me, I don't care much about the "Deprecated" thing itself but I really need the JS to work.
Again, many thanks in advance!
Hi there,
Actually for JS we have a specific area where you can add it. Have you tried adding it through the Theme Options?
Best regards,
Laborator Team
Hi Art, thank you for your answer!
I forgot to try it this way and it does work, so thanks a lot!!
However, the text "function custom_js() { echo ''; }" displays at the bottom of each page, could you tell me how to make it disappear?
Last question: do you think there won't be any problem if I leave the deprecated thing as is? I worry that I left something unrepaired since the JS in question worked just fine in functions.php before.
Have a great day,
Sofiane
Hi Sofiane,
1. There may be a typo in the code which is showing the "function custom_js() { echo ''; }". Can you please share your site credentials here, because we need to login to your site and see this issue live. Your information is safe (private) in this thread.
To include your credentials click Insert Credentials button in the editor toolbar. (See how)
2. We recommend using PHP 8.1 as it is not recommended to update to 8.2 since there may be some code in the theme and plugins which is not compatible with this version of PHP.
Best regards,
Laborator Team
Hi Sofiane,
1. I have simplified the JS code in Theme Options and now it looks like this:
There was an error in the code and that was causing the errors to show in the live site.
2. The problem is not related to the theme, I have switched to the default WordPress theme and the warning still shows. Have you tried disabling plugins one by one to troubleshoot and see which of them is showing this warning?
Best regards,
Laborator Team
Hello Art,
Thank you very much!
Having made some researches, I found that UpdraftPlus was responsible for this error in some cases. I deleted it and the error disappeared, but it leaves a blank space where it used to display:
I tried disabling the plugins, the blank space was still there. The only time I saw it disappear completely since the beginning of all this is when I switched to PHP 7.4.
This displayed at the top when I reactivated WooCommerce but disappeared shortly after, I'm no expert but I think it had to do with the WooCommerce payment plugins left active while Woocommerce itself was disabled.
My website looks like it works just fine as is, but these questions remain:
-why didn't the error appear before I fumbled with functions.php, if UpdraftPlus was at fault?
-why won't the blank space disappear? It feels like there's another error but it doesn't display for some reason.
-why the JS didn't work in functions.php since last Friday when I made the mistake, even though the same JS worked just fine before?
I'm not sure you're the persons to ask for this since it doesn't look like it has something to do with Kalium, but I'd be very grateful if you could point me to where I could look for to find the answers for this.
Thank you very much already 🙏
Hi Sofiane,
As mentioned previously the problem is related to the plugins so it's not that we don't want to help you but that's not related at all to the theme, or we do not have the expertise to give you instructions on how to fix something the theme is not causing. I would suggest you contact the plugin support whichever plugin is causing these errors, just let them know the issues are occurring with the default WordPress theme since everyone will point out that you have to check the theme.
Best regards,
Laborator Team