php - Using Namespace in Child Theme is breaking my site

admin2025-05-31  0

I’m customizing a theme through a staging site + a child theme, however, after taking a look at almost all the files in both the child theme and the parent theme, I’ve come to the conclusion that the meat of what I wanna alter is all built with namespaces.

The problem is: I called the Namespaces in my child functions.php, and my website keeps getting critical errors because it can’t find the class in question... Even though it IS in the parent theme, autoloaded with composer in fact.

This is the code I used, literally just ctrl c ctrl v from the parent theme for a few tweaks:

use LottaFramework\Customizer\Section as CustomizerSection;

with this at the end:

if ( !defined( 'ABSPATH' ) ) {
exit;
// Exit if accessed directly.
}

if ( !class_exists( 'Yuki_Global_Section' ) ) {
class Yuki_Global_Section extends CustomizerSection {
/* rest of the code*/

This is the result:

I tried using require_once, it fixes the issue but still breaks my site so it’s no use, include_once also breaks it because it still can't find the class, the theme also has composer installed and autoload files do look alright, both in the parent and child themes, also tried copying the specific class file to my child theme in case it is any easier, I’m baffled the system still can’t find the class.

And yes, the function I’m trying to edit is a pluggable one so theoretically I should be able to override it without any issue.

Is there anything I can do to fix this? I’m already looking into changing my theme for another easier to edit, but this is still my top priority since design is a very important aspect to me, I want the best one I can get for free. So if there’s a way to fix this, I’d really appreciate it!

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748624889a313610.html

最新回复(0)