_register_licence_actions(); $this->_register_licence_fields(); } /** * Add the extension tab if not present * * @param array $tabs * @return array */ public function add_tabs( array $tabs ) { if ( ! isset( $tabs['extensions'] ) ) { $tabs['extensions'] = array( 'name' => Ai1ec_I18n::__( 'Add-ons' ), 'items' => array(), ); } return $tabs; } /** * Register action for licences. */ protected function _register_licence_actions() { $dispatcher = $this->_registry->get( 'event.dispatcher' ); // we need the super class so we use get_class() $class = explode( '_', get_class( $this ) ); $controller = strtolower( end( $class ) ); $dispatcher->register_filter( 'ai1ec_add_setting_tabs', array( 'controller.' . $controller, 'add_tabs' ) ); } /** * Register fields for licence */ protected function _register_licence_fields() { $plugin_id = $this->get_machine_name(); $this->_licence = 'ai1ec_licence_' . $plugin_id; $this->_licence_status = 'ai1ec_licence_status_' . $plugin_id; $options = array( $this->_licence => array( 'type' => 'string', 'version' => $this->get_version(), 'renderer' => array( 'class' => 'input', 'group-class' => 'ai1ec-col-sm-7', 'tab' => 'extensions', 'item' => 'licenses', 'type' => 'normal', 'label' => $this->get_license_label(), 'status' => $this->_licence_status, ), 'default' => '', ), $this->_licence_status => array( 'type' => 'string', 'version' => $this->get_version(), 'default' => 'invalid', ), ); $settings = $this->_registry->get( 'model.settings' ); foreach ( $options as $key => $option ) { $renderer = null; if ( isset( $option['renderer'] ) ) { $renderer = $option['renderer']; } $settings->register( $key, $option['default'], $option['type'], $renderer, $option['version'] ); } } }