type = $type; self::$init_containers[] = $container; return $container; } /** * An alias of factory(). * * @see Container::factory() **/ public static function make( $type, $name ) { return self::factory( $type, $name ); } /** * Initialize containers created via factory * * @return object **/ public static function init_containers() { while ( ( $container = array_shift( self::$init_containers ) ) ) { $container->init(); } return $container; } /** * Returns all the active containers created via factory * * @return array **/ public static function get_active_containers() { return self::$active_containers; } /** * Adds a container to the active containers array and triggers an action **/ public static function activate_container( $container ) { self::$active_containers[] = $container; $container->boot(); do_action( 'crb_container_activated', $container ); } /** * Returns all the active fields created via factory * * @return array **/ public static function get_active_fields() { return self::$active_fields; } /** * Adds a field to the active fields array and triggers an action **/ public static function activate_field( $field ) { self::$active_fields[] = $field; if ( method_exists( $field, 'get_fields' ) ) { $fields = $field->get_fields(); foreach ( $fields as $inner_field ) { self::activate_field( $inner_field ); } } $field->boot(); do_action( 'crb_field_activated', $field ); } /** * Perform instance initialization after calling setup() **/ abstract public function init(); /** * Prints the container Underscore template **/ public function template() { ?>