我正在使用 OOPS 概念和类开发一个 WordPress 插件。 我想在其中使用 namespace 。 有谁知道如何在我的插件中实现它? 谢谢
最佳答案
请在第一行定义命名空间并像下面一样使用。
<?php
namespace Appsense\popop;
class shortcode{
public function gernerateShortcode(){
add_shortcode('appsense_popop',array('Appsense\popop\shortcode','popop_shortcode'));
}
public function popop_shortcode(){
$output = "Hello world!";
return $output;
}
}
关于php - 如何在 WordPress 插件中使用命名空间和类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54140914/