0 ) { $user = get_user_by( 'id', $user_id ); if ( $user && in_array( 'administrator', $user->roles, true ) ) { return true; } } return false; } /** * Check if a module is activated * * @param string $module_name Module name. * @return boolean */ private function is_module_activated( string $module_name ) { return Module_Registry::is_enabled( $module_name ); } /** * Check if AI Connectors is active and has at least one configured provider. * * @return bool */ protected function is_ai_connected(): bool { if ( ! $this->is_module_activated( 'ai_connectors' ) ) { return false; } if ( function_exists( '\ao_ai_available' ) ) { return \ao_ai_available(); } if ( class_exists( AO_AI_Key_Store::class ) ) { return ! empty( AO_AI_Key_Store::get_configured_providers() ); } return false; } /** * A quick check to see if the current request is REST request * * @return bool */ private function is_rest_request(): bool { if ( ! defined( 'REST_REQUEST' ) || ( defined( 'REST_REQUEST' ) && ! REST_REQUEST ) ) { return false; } else { return true; } } }