$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>php - Using Namespace in Child Theme is breaking my site|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

php - Using Namespace in Child Theme is breaking my site

matteradmin9PV0评论

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!

Post a comment

comment list (0)

  1. No comments so far