douxing2652 2019-01-11 05:39
浏览 220
已采纳

如何在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

  • 写回答

1条回答 默认 最新

  • douyu0725 2019-01-11 05:49
    关注

    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;
            }
        }
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?