[英]Calling a Class from a parent Theme issue Wordpress
我有一个Wordpress父主题,我的孩子主题正在扩展很多功能。 我的问题是,当我想在我的子主题文件夹结构中使用或扩展一个类时,我得到“类未定义”或“未找到类”的错误
使用父主题中的类的正确方法是什么?
以下是其中一个类的示例:
class MyNewClass extends ReadAndDigestWidget {}
该类将调用其中来自父主题的更多类。
任何有助于理解Wordpress和php的帮助都非常感谢!
PHP不是设计上的OOP语言,因此结果有时是微不足道的。 以下是继承如何在PHP中工作的基本示例
class ChildTheme extends ParentTheme {
function parentDropDownMenu(){
parent::dropDownMenu();
//do additionall stuff
}
}
theme = new ParentTheme();
$theme->dropDownMenu(); // will call the parent function directly
$theme->parentDropDownMenu(); // will call the function override
通常我甚至不会在PHP中覆盖我父类的类方法,而只是在我没有完全控制父类的情况下扩展类。 如果在wordpress中进行升级并覆盖必须升级,该怎么办?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.