/**
     * Set up admin options page.
     */
    public function admin_options_page()
    {
        ?>
		<div class="wrap">
			<h2>WP to diaspora*</h2>

			<div id="wp2d-message" class="notice hidden" <?php 
        echo defined('WP2D_DEBUGGING') ? ' data-debugging' : '';
        ?>
></div>

			<?php 
        // Check the connection status to diaspora.
        if (!$this->is_pod_set_up()) {
            add_settings_error('wp_to_diaspora_settings', 'wp_to_diaspora_connected', __('First of all, set up the connection to your pod below.', 'wp-to-diaspora'), 'updated');
        } else {
            // Get initial aspects list and connected services.
            // DON'T check for empty services list here!!
            // It could always be empty, resulting in this code being run every time the page is loaded.
            // The aspects will at least have a "Public" entry after the initial fetch.
            $aspects_list = $this->get_option('aspects_list');
            if (empty($aspects_list)) {
                // Set up the connection to diaspora*.
                $conn = WP2D_Helpers::api_quick_connect();
                if (empty($conn->last_error)) {
                    // Get the loaded aspects.
                    if ($aspects = $conn->get_aspects()) {
                        // Save the new list of aspects.
                        $this->set_option('aspects_list', $aspects);
                    }
                    // Get the loaded services.
                    if ($services = $conn->get_services()) {
                        // Save the new list of services.
                        $this->set_option('services_list', $services);
                    }
                    $this->save();
                }
            }
            // Attempt to get the cacert.pem file and save it to the plugin's root directory.
            if (isset($_GET['temp_ssl_fix'])) {
                $cacert_file = file_get_contents('http://curl.haxx.se/ca/cacert.pem');
                if ($cacert_file && file_put_contents(WP2D_DIR . '/cacert.pem', $cacert_file)) {
                    add_settings_error('wp_to_diaspora_settings', 'wp_to_diaspora_temp_ssl_fix', __('Successfully saved cacert.pem!', 'wp-to-diaspora'), 'updated');
                } else {
                    add_settings_error('wp_to_diaspora_settings', 'wp_to_diaspora_temp_ssl_fix', __('Failed to save cacert.pem!', 'wp-to-diaspora'), 'error');
                }
            }
        }
        // Output success or error message.
        settings_errors('wp_to_diaspora_settings');
        ?>

			<?php 
        $page_tabs = array_keys($this->_options_page_tabs(true));
        ?>

			<form action="options.php" method="post">

				<?php 
        // Load the settings fields.
        settings_fields('wp_to_diaspora_settings');
        do_settings_sections('wp_to_diaspora_settings');
        // Get the name of the current tab, if set, else take the first one from the list.
        $tab = $this->_current_tab($page_tabs[0]);
        // Add Save and Reset buttons.
        echo '<input id="submit-' . esc_attr($tab) . '" name="wp_to_diaspora_settings[submit_' . esc_attr($tab) . ']" type="submit" class="button-primary" value="' . esc_attr__('Save Changes') . '" />&nbsp;';
        if ('setup' !== $tab) {
            echo '<input id="reset-' . esc_attr($tab) . '" name="wp_to_diaspora_settings[reset_' . esc_attr($tab) . ']" type="submit" class="button-secondary" value="' . esc_attr__('Reset Defaults', 'wp-to-diaspora') . '" />';
        }
        ?>

			</form>
		</div>

		<?php 
    }
 /**
  * Post to diaspora* when saving a post.
  *
  * @since 1.5.0
  *
  * @todo Maybe somebody wants to share a password protected post to a closed aspect.
  *
  * @param integer $post_id ID of the post being saved.
  * @param WP_Post $post    Post object being saved.
  * @return boolean If the post was posted successfully.
  */
 public function post($post_id, $post)
 {
     $this->_assign_wp_post($post);
     $options = WP2D_Options::instance();
     // Is this post type enabled for posting?
     if (!in_array($post->post_type, $options->get_option('enabled_post_types'))) {
         return false;
     }
     // Make sure we're posting to diaspora* and the post isn't password protected.
     if (!($this->post_to_diaspora && 'publish' === $post->post_status && '' === $post->post_password)) {
         return false;
     }
     $status_message = $this->_get_title_link();
     // Post the full post text or just the excerpt?
     if ('full' === $this->display) {
         $status_message .= $this->_get_full_content();
     } else {
         $status_message .= $this->_get_excerpt_content();
     }
     // Add the tags assigned to the post.
     $status_message .= $this->_get_tags_to_add();
     // Add the original entry link to the post?
     $status_message .= $this->_get_posted_at_link();
     $status_converter = new HtmlConverter(array('strip_tags' => true));
     $status_message = $status_converter->convert($status_message);
     // Set up the connection to diaspora*.
     $conn = WP2D_Helpers::api_quick_connect();
     if (!empty($status_message)) {
         if ($conn->last_error) {
             // Save the post error as post meta data, so we can display it to the user.
             update_post_meta($post_id, '_wp_to_diaspora_post_error', $conn->last_error);
             return false;
         }
         // Add services to share to via diaspora*.
         $extra_data = array('services' => $this->services);
         // Try to post to diaspora*.
         if ($response = $conn->post($status_message, $this->aspects, $extra_data)) {
             // Save certain diaspora* post data as meta data for future reference.
             $this->_save_to_history((object) $response);
             // If there is still a previous post error around, remove it.
             delete_post_meta($post_id, '_wp_to_diaspora_post_error');
         }
     } else {
         return false;
     }
 }
 /**
  * Load the diaspora* API for ease of use.
  *
  * @return WP2D_API|boolean The API object, or false.
  */
 private function _load_api()
 {
     if (!isset($this->_api)) {
         $this->_api = WP2D_Helpers::api_quick_connect();
     }
     return $this->_api;
 }