When developing WordPress plugin, is it a good idea to create my class object by hooking to existing class constructor?

Question

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
, Saeid 2 years 2020-01-12T08:42:21-05:00 0 Answers 61 views 0

Leave an answer

Browse
Browse