/** * @param RESTian_Client $api */ function set_api($api) { if (empty($this->_forms)) { /** * What about plugins with an API but no need for forms? Is that possible since forms=settings in Sidecar? */ $error_message = __('$plugin->set_api($api) cannot be called before forms have been added. Please call $plugin->add_form() in $plugin->initialize_plugin() at least once prior to calling set_api().', 'sidecar'); trigger_error($error_message); exit; } $api->caller = $this; $api->initialize_client(); $this->_api = $api; if ($this->_admin_initialized) { /** * If Admin has been initialized then set grant. * If not, wait to set until after initialization * otherwise we get into a bad spiral of not-defined-yet. */ $this->_api->set_grant($this->get_grant()); } }