如何在WordPress插件中使用类的命名空间

问题描述:

I am developing a wordpress plugin using OOPS concept with classes. I want to use namespace in them. Does anyone has any idea how to implement that in my plugin ? Thanks

我正在使用带有类的OOPS概念开发一个wordpress插件。 我想在其中使用命名空间。 任何人 有任何想法如何在我的插件中实现它? 谢谢 p> div>

Please define namespace with first line and use like we do it below.


    <?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;
        }
    }