This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add_social_media_posts_controller($controllers) { | |
$controllers[] = 'social_media_posts'; | |
return $controllers; | |
} | |
add_filter('json_api_controllers', 'add_social_media_posts_controller'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* public function getHelloName() { | |
global $json_api; | |
$name = $json_api->query->name; | |
return array( | |
"message" => "Hello, $name." | |
); | |
} | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class json_api_social_media_posts_controller { | |
public function get_meaning_of_life() { | |
return array( | |
"meaningoflife" => '42', | |
); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function get_by_pod_category() { | |
global $json_api; | |
$cat = $json_api->query->cat; | |
if (!$cat) | |
{ | |
$json_api->error("Oops. You forgot to include 'cat' var in your request"); | |
} | |
$params = array( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function posts_by_day() { | |
global $json_api; | |
$oldest = get_posts(array( | |
'orberby' => 'date', | |
'order' => 'ASC', | |
'posts_per_page' => 1, | |
'caller_get_posts' => 1 | |
)); | |
$years = array_reverse(range(mysql2date('ISO 8601', $oldest[0]->post_date), date('ISO 8601', current_time('timestamp')))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function posts_by_day() { | |
global $json_api, $post; | |
$days = array(); | |
$query = new WP_Query( array( | |
'post_type' => array('post', 'imported_content' ), | |
'posts_per_page' => -1, | |
) ); | |
if( $query->have_posts() ): while( $query->have_posts() ): $query->the_post(); | |
if( !isset( $days[ get_the_time( 'Y-m-d' ) ] ) ) | |
$days[ get_the_time( 'Y-m-d' ) ] = array(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Plugin Name: Twitter Pull | |
* Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates | |
* Description: A brief description of the Plugin. | |
* Version: The Plugin's Version Number, e.g.: 1.0 | |
* Author: Name Of The Plugin Author | |
* Author URI: http://URI_Of_The_Plugin_Author | |
* License: A "Slug" license name e.g. GPL2 | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function get_all_recent_two() { | |
global $json_api; | |
$args= array( | |
'post_type' => array( 'post', 'imported_content') | |
); | |
$wp_query = new WP_Query($args); | |
$posts = $json_api->introspector->get_posts();; | |
return $posts; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$post = array( | |
'post_content' => $tweet->text, | |
'tweet_author_avatar' => $tweet ->profile_image_url_https, | |
'post_type' => 'imported_content', | |
'post_title' => __('Tweet', 'ttp').'-'.$tweet->id, | |
'post_status' => 'publish', | |
'post_date_gmt' => $gmt_date, | |
'post_date' => get_date_from_gmt($gmt_date), | |
'post_author' => $author->ID, | |
#'tax_input' => array('categories' => array('foo')) // Support for custom taxonomies. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$post = array( | |
'post_content' => $tweet->text, | |
'post_type' => 'imported_content', | |
'post_title' => __('Tweet', 'ttp').'-'.$tweet->id, | |
'post_status' => 'publish', | |
'post_date_gmt' => $gmt_date, | |
'post_date' => get_date_from_gmt($gmt_date), | |
'post_author' => $author->ID, | |
#'tax_input' => array('categories' => array('foo')) // Support for custom taxonomies. | |
); |