/** * Ensures that we've got a singleton */ public static function instance() { if (empty(self::$instance)) { // Don't try to initialize with no URL if (participad_api_endpoint()) { self::$instance = new Participad_Client(participad_api_key(), participad_api_endpoint()); } } return self::$instance; }
/** * Is Participad installed correctly? */ function participad_is_installed_correctly() { $is_installed_correctly = true; $api_endpoint = participad_api_endpoint(); $api_key = participad_api_key(); if (!$api_endpoint || !$api_key) { $is_installed_correctly = false; } if (!method_exists(participad_client(), 'is_connected') || !participad_client()->is_connected()) { $is_installed_correctly = false; } return $is_installed_correctly; }
/** * Check to see whether Participad is set up correctly, and show a notice * * @since 1.0 */ function participad_setup_admin_notice() { if (!current_user_can('manage_options')) { return; } if (!participad_is_installed_correctly()) { $html = '<div class="message error">'; $html .= '<p>'; if (participad_is_admin_page()) { if (!participad_api_endpoint()) { $message = __('You must provide a valid Etherpad Lite URL.', 'participad'); } else { if (!participad_api_key()) { $message = __('You must provide a valid Etherpad Lite API key. You can find this key in the <code>APIKEY.txt</code> file in the root of your Etherpad Lite installation.', 'participad'); } else { $message = __('We couldn\'t find an Etherpad Lite installation at the URL you provided. Please check the details and try again.', 'participad'); } } $html .= $message; } else { $html .= sprintf(__('<strong>Participad is not set up correctly.</strong> Visit the <a href="%s">settings page</a> to learn more.', 'participad'), participad_admin_url()); } $html .= '</p>'; $html .= '</div>'; echo $html; } }