Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

trait class has consttoctor

trait HasPluginInfoTrait{
    public function __construct() { 

        $this->plugin_name        = PLUGIN_NAME;
        $this->version            = PLUGIN_VERSION;

        if ( method_exists( $this, 'init' ){
            $this->init();
        }
    }
}

class SampleClass {
    use HasPluginInfoTrait;

    private function init(){
        // Code specific to SampleClass
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #trait #class #consttoctor
ADD COMMENT
Topic
Name
6+5 =