if (is_wp_error($post_id)) { return $post_id; } if (!$post_id) { continue; } // Track which Keyring service was used wp_set_object_terms($post_id, self::LABEL, 'keyring_services'); set_post_format($post_id, 'status'); // Update Category wp_set_post_categories($post_id, $post_category); if (count($tags)) { wp_set_post_terms($post_id, implode(',', $tags)); } add_post_meta($post_id, 'raw_import_data', wp_slash(json_encode($fitbit_raw))); $imported++; do_action('keyring_post_imported', $post_id, static::SLUG, $post); } } $this->posts = array(); // Return, so that the handler can output info (or update DB, or whatever) return array('imported' => $imported, 'skipped' => $skipped); } } } // end function Keyring_Fitbit_Importer add_action('init', function () { Keyring_Fitbit_Importer(); // Load the class code from above keyring_register_importer('fitbit', 'Keyring_Fitbit_Importer', plugin_basename(__FILE__), __('Import your daily activities as single Posts, marked with the "status" format. You can also use the data as part of other maps or whatever else you\'d like to do with it.', 'keyring')); });
wp_set_post_terms($post_id, implode(',', $tags)); } // Store geodata if it's available if (!empty($geo)) { add_post_meta($post_id, 'geo_latitude', $geo['lat']); add_post_meta($post_id, 'geo_longitude', $geo['long']); add_post_meta($post_id, 'geo_public', 1); } add_post_meta($post_id, 'raw_import_data', wp_slash(json_encode($flickr_raw))); $this->sideload_media($flickr_img, $post_id, $post, apply_filters('keyring_flickr_importer_image_embed_size', 'large')); $imported++; do_action('keyring_post_imported', $post_id, static::SLUG, $post); } } $this->posts = array(); // Return, so that the handler can output info (or update DB, or whatever) return array('imported' => $imported, 'skipped' => $skipped); } function do_auto_import() { $this->set_option('auto_page', 1); parent::do_auto_import(); } } } // end function Keyring_Twitter_Importer add_action('init', function () { Keyring_Flickr_Importer(); // Load the class code from above keyring_register_importer('flickr', 'Keyring_Flickr_Importer', plugin_basename(__FILE__), __('Download copies of your Flickr photos into your Media Library and save them all as individual Posts, marked with the "image" post format.', 'keyring')); });
if (!$post_id) { continue; } // Track which Keyring service was used wp_set_object_terms($post_id, self::LABEL, 'keyring_services'); // Mark it as a link set_post_format($post_id, 'link'); // Update Category wp_set_post_categories($post_id, $post_category); add_post_meta($post_id, 'delicious_id', $delicious_id); add_post_meta($post_id, 'href', $href); if (count($tags)) { wp_set_post_terms($post_id, implode(',', $tags)); } add_post_meta($post_id, 'raw_import_data', wp_slash(json_encode($delicious_raw))); $imported++; do_action('keyring_post_imported', $post_id, static::SLUG, $post); } } $this->posts = array(); // Return, so that the handler can output info (or update DB, or whatever) return array('imported' => $imported, 'skipped' => $skipped); } } } // end function Keyring_Delicious_Importer add_action('init', function () { Keyring_Delicious_Importer(); // Load the class code from above keyring_register_importer('delicious', 'Keyring_Delicious_Importer', plugin_basename(__FILE__), __('Import all of your Delicious bookmarks as Posts with the "Link" format.', 'keyring')); });
} // Store geodata if it's available if (!empty($geo)) { add_post_meta($post_id, 'geo_latitude', $geo['lat']); add_post_meta($post_id, 'geo_longitude', $geo['long']); add_post_meta($post_id, 'geo_public', 1); } add_post_meta($post_id, 'raw_import_data', wp_slash(json_encode($twitter_raw))); if (!empty($images)) { $images = array_reverse($images); // Reverse so they stay in order when prepended foreach ($images as $image) { $this->sideload_media($image, $post_id, $post, apply_filters('keyring_twitter_importer_image_embed_size', 'full')); } } $imported++; do_action('keyring_post_imported', $post_id, static::SLUG, $post); } } $this->posts = array(); // Return, so that the handler can output info (or update DB, or whatever) return array('imported' => $imported, 'skipped' => $skipped); } } } // end function Keyring_Twitter_Importer add_action('init', function () { Keyring_Twitter_Importer(); // Load the class code from above keyring_register_importer('twitter', 'Keyring_Twitter_Importer', plugin_basename(__FILE__), __('Import all of your tweets from Twitter as Posts (marked as "asides") in WordPress.', 'keyring')); });
if (count($tags)) { wp_set_post_terms($post_id, implode(',', $tags)); } // Store geodata if it's available if (!empty($geo)) { add_post_meta($post_id, 'geo_latitude', $geo['lat']); add_post_meta($post_id, 'geo_longitude', $geo['long']); add_post_meta($post_id, 'geo_public', 1); } add_post_meta($post_id, 'raw_import_data', wp_slash(json_encode($instagram_raw))); $this->sideload_media($instagram_img, $post_id, $post, apply_filters('keyring_instagram_importer_image_embed_size', 'full')); $imported++; do_action('keyring_post_imported', $post_id, static::SLUG, $post); } } $this->posts = array(); // If we're doing a normal import and the last request was all skipped, then we're at "now" if (!$this->auto_import && self::NUM_PER_REQUEST == $skipped) { $this->finished = true; } // Return, so that the handler can output info (or update DB, or whatever) return array('imported' => $imported, 'skipped' => $skipped); } } } // end function Keyring_Instagram_Importer add_action('init', function () { Keyring_Instagram_Importer(); // Load the class code from above keyring_register_importer('instagram', 'Keyring_Instagram_Importer', plugin_basename(__FILE__), __('Download copies of your Instagram photos and publish them all as individual Posts (marked as "image" format).', 'keyring')); });
return $post_id; } if (!$post_id) { continue; } // Track which Keyring service was used wp_set_object_terms($post_id, self::LABEL, 'keyring_services'); set_post_format($post_id, 'status'); // Update Category wp_set_post_categories($post_id, $post_category); if (count($tags)) { wp_set_post_terms($post_id, implode(',', $tags)); } add_post_meta($post_id, 'raw_import_data', wp_slash(json_encode($moves_raw))); add_post_meta($post_id, 'moves_summary', wp_slash(json_encode($summary))); $imported++; do_action('keyring_post_imported', $post_id, static::SLUG, $post); } } $this->posts = array(); // Return, so that the handler can output info (or update DB, or whatever) return array('imported' => $imported, 'skipped' => $skipped); } } } // end function Keyring_Moves_Importer add_action('init', function () { Keyring_Moves_Importer(); // Load the class code from above keyring_register_importer('moves', 'Keyring_Moves_Importer', plugin_basename(__FILE__), __('<strong>[Under Development!]</strong> Import your daily storylines as single Posts, marked with the "status" format. You can also use the data as part of other maps or whatever else you\'d like to do with it.', 'keyring')); });
} // Store geodata if it's available if (!empty($geo)) { add_post_meta($post_id, 'geo_latitude', $geo['lat']); add_post_meta($post_id, 'geo_longitude', $geo['long']); add_post_meta($post_id, 'geo_public', 1); } add_post_meta($post_id, 'raw_import_data', wp_slash(json_encode($foursquare_raw))); if (!empty($photos)) { $photos = array_reverse($photos); // Reverse so they stay in order when prepended foreach ($photos as $photo) { $this->sideload_media($photo, $post_id, $post, apply_filters('keyring_foursquare_importer_image_embed_size', 'full')); } } $imported++; do_action('keyring_post_imported', $post_id, static::SLUG, $post); } } $this->posts = array(); // Return, so that the handler can output info (or update DB, or whatever) return array('imported' => $imported, 'skipped' => $skipped); } } } // end function Keyring_Foursquare_Importer add_action('init', function () { Keyring_Foursquare_Importer(); // Load the class code from above keyring_register_importer('foursquare', 'Keyring_Foursquare_Importer', plugin_basename(__FILE__), __('Download all of your Foursquare checkins as individual Posts (with a "status" post format).', 'keyring')); });
} $imported++; do_action('keyring_post_imported', $post_id, static::SLUG, $post); } } $this->posts = array(); if ($this->get_option('page', 1) >= $this->get_option('max_page')) { $this->finished = true; } // Return, so that the handler can output info (or update DB, or whatever) return array('imported' => $imported, 'skipped' => $skipped); } /** * The parent class creates an hourly cron job to run auto import. That's unnecessarily aggressive for * TripIt, so we're going to cut that down to once every 12 hours by just skipping the job depending * on the hour. If we want to run, then call the parent auto_import. */ function do_auto_import() { if (01 == date('H') || 12 == date('H')) { parent::do_auto_import(); } } } } // end function Keyring_Instagram_Importer add_action('init', function () { Keyring_TripIt_Importer(); // Load the class code from above keyring_register_importer('tripit', 'Keyring_TripIt_Importer', plugin_basename(__FILE__), __('Download your travel details from TripIt and auto-post maps of your flights. Each flight is saved as a Post containing a map, marked with the Status format.', 'keyring')); });
} // Track which Keyring service was used wp_set_object_terms($post_id, self::LABEL, 'keyring_services'); // Mark it as a link set_post_format($post_id, 'link'); // Update Category wp_set_post_categories($post_id, $post_category); add_post_meta($post_id, 'instapaper_id', $instapaper_id); add_post_meta($post_id, 'href', $href); if (count($tags)) { wp_set_post_terms($post_id, implode(',', $tags)); } add_post_meta($post_id, 'raw_import_data', wp_slash(json_encode($instapaper_raw))); $imported++; do_action('keyring_post_imported', $post_id, static::SLUG, $post); } } $this->posts = array(); $this->finished = true; // All done in a single request // Return, so that the handler can output info (or update DB, or whatever) return array('imported' => $imported, 'skipped' => $skipped); } } } // end function Keyring_Delicious_Importer add_action('init', function () { Keyring_Instapaper_Importer(); // Load the class code from above keyring_register_importer('instapaper', 'Keyring_Instapaper_Importer', plugin_basename(__FILE__), __('Import all of your archived Instapaper links as Posts with the "Link" format.', 'keyring')); });