最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

customization - When developing WordPress plugin, is it a good idea to create my class object by hooking to existing class const

programmeradmin3浏览0评论

I want to create my object when another object is made. Is it a good idea to create my object by hooking to existing class constructor?

for example if the main class is

class WordPress_Class {
/**
 * Constructor
 */
public function __construct() {
    add_action( 'some_action', array( $this, 'some_WP_Class_Method' ) );

    return true;
}

Then can I use 'some_action' to create my object:

my_object = new My_Class();

and use it on the same page that WordPress_Class object is used?

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论