/**
  * Set up the contextual help menu.
  */
 private function _setup()
 {
     // Do we display the help tabs?
     $post_type = get_current_screen()->post_type;
     $enabled_post_types = WP2D_Options::instance()->get_option('enabled_post_types');
     if ('' !== $post_type && !in_array($post_type, $enabled_post_types)) {
         return;
     }
     // If we don't have a post type, we're on the main settings page.
     if ('' === $post_type) {
         // Set the sidebar in the contextual help.
         $this->_set_sidebar();
         // Add the main settings tabs and their content.
         $this->_add_settings_help_tabs();
     } else {
         // Add the post type specific tabs and their content.
         $this->_add_post_type_help_tabs();
     }
 }
 /**
  * Set up and return an API connection using the currently saved options..
  *
  * @return WP2D_API The API object.
  */
 public static function api_quick_connect()
 {
     $options = WP2D_Options::instance();
     $pod = (string) $options->get_option('pod');
     $is_secure = true;
     $username = (string) $options->get_option('username');
     $password = WP2D_Helpers::decrypt((string) $options->get_option('password'));
     $api = new WP2D_API($pod, $is_secure);
     // This is necessary for correct error handline!
     if ($api->init()) {
         $api->login($username, $password);
     }
     return $api;
 }
 /**
  * When the post is saved, save our meta data.
  *
  * @since 1.5.0
  *
  * @param integer $post_id The ID of the post being saved.
  */
 public function save_meta_box_data($post_id)
 {
     /*
      * We need to verify this came from our screen and with proper authorization,
      * because the save_post action can be triggered at other times.
      */
     if (!$this->_is_safe_to_save()) {
         return;
     }
     /* OK, it's safe for us to save the data now. */
     // Meta data to save.
     $meta_to_save = $_POST['wp_to_diaspora_settings'];
     $options = WP2D_Options::instance();
     // Checkboxes.
     $options->validate_checkboxes(array('post_to_diaspora', 'fullentrylink'), $meta_to_save);
     // Single Selects.
     $options->validate_single_selects('display', $meta_to_save);
     // Multiple Selects.
     $options->validate_multi_selects('tags_to_post', $meta_to_save);
     // Save custom tags as array.
     $options->validate_tags($meta_to_save['custom_tags']);
     // Clean up the list of aspects. If the list is empty, only use the 'Public' aspect.
     $options->validate_aspects_services($meta_to_save['aspects'], array('public'));
     // Clean up the list of services.
     $options->validate_aspects_services($meta_to_save['services']);
     // Update the meta data for this post.
     update_post_meta($post_id, '_wp_to_diaspora', $meta_to_save);
 }
 /**
  * Get a specific option.
  *
  * @param string       $option  ID of option to get.
  * @param array|string $default Override default value if option not found.
  * @return array|string Requested option value.
  */
 public function get_option($option = null, $default = null)
 {
     if (!isset(self::$_options)) {
         self::$_options = get_option('wp_to_diaspora_settings', self::$_default_options);
     }
     if (isset($option)) {
         if (isset(self::$_options[$option])) {
             // Return found option value.
             return self::$_options[$option];
         } elseif (isset($default)) {
             // Return overridden default value.
             return $default;
         } elseif (isset(self::$_default_options[$option])) {
             // Return default option value.
             return self::$_default_options[$option];
         }
     }
 }
 /**
  * Check the pod connection status.
  *
  * @return string The status of the connection.
  */
 private function _check_pod_connection_status()
 {
     $options = WP2D_Options::instance();
     $status = null;
     if ($options->is_pod_set_up()) {
         $status = !(bool) $this->_load_api()->last_error;
     }
     return $status;
 }