Changeset 1664371
- Timestamp:
- 05/24/2017 10:56:24 PM (9 years ago)
- Location:
- json-feeder/trunk
- Files:
-
- 3 edited
-
json-feeder.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
template/json-feeder.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
json-feeder/trunk/json-feeder.php
r1664279 r1664371 5 5 Description: Adds a new type of feed you can subscribe to. http://example.com/feed/json or http://example.com/?feed=json to anywhere you get a JSON form. 6 6 Author: signalfade 7 Version: 1.0. 37 Version: 1.0.4 8 8 9 9 License: -
json-feeder/trunk/readme.txt
r1664279 r1664371 4 4 Requires at least: 4.0 5 5 Tested up to: 4.7.5 6 Stable tag: 1.0. 36 Stable tag: 1.0.4 7 7 8 8 Adds a feed based on the jsonfeed.org standard that one can subscribe to or parse. … … 19 19 20 20 == Changelog == 21 22 **1.0.4 May 24, 2017** 23 24 Improvements and cleanup for template of feed. 21 25 22 26 **1.0.3 May 24, 2017** -
json-feeder/trunk/template/json-feeder.php
r1664279 r1664371 5 5 */ 6 6 $callback = trim(esc_html(get_query_var('callback'))); 7 $charset = get_option(' charset');7 $charset = get_option('blog_charset'); 8 8 if(strpos($_SERVER['REQUEST_URI'], 'feed/json')!==false) { 9 9 query_posts('posts_per_page=10'); … … 15 15 // Make sure query args are always in the same order 16 16 ksort( $query_array ); 17 $site_description = get_bloginfo('description'); 17 18 18 19 $json = array( 19 20 'version' => 'https://jsonfeed.org/version/1', 20 21 'title' => get_bloginfo('name'), 21 'description' => get_bloginfo('description'),22 22 'home_page_url' => home_url(), 23 23 'feed_url' => get_bloginfo('rss2_url').'json', 24 'items' => array(), 25 // 'favicon' => site_url().'/favicon.ico', 26 // 'icon' => '', 24 'author' => array( 25 'name' => 'nextSTL' 26 ), 27 'items' => array() 27 28 ); 29 30 if(!empty($site_description)) { 31 $json['description'] = $site_description; 32 } 28 33 29 34 while ( have_posts() ) { … … 32 37 33 38 $single = array( 34 'id' => $id,39 'id' => get_permalink(), 35 40 'title' => get_the_title(), 36 41 'url' => get_permalink(), 37 'date_published' => get_the_date( ),38 'content_ text' => get_the_content(),42 'date_published' => get_the_date('Y-m-dTH:i:s', $id).'Z', 43 'content_html' => get_the_content(), 39 44 'summary' => get_the_excerpt(), 40 'date' => get_the_date('Y-m-d H:i:s','','',false),41 45 'author' => array( 42 46 'name' => get_the_author(), … … 48 52 // thumbnail 49 53 if (function_exists('has_post_thumbnail') && has_post_thumbnail($id)) { 50 $single[ "image"] = get_the_post_thumbnail_url($id);54 $single['image'] = get_the_post_thumbnail_url($id); 51 55 } 52 56 53 57 // category -- not difference between this and tags in JSON Feed. 54 $single[ "tags"] = array();58 $single['tags'] = array(); 55 59 $categories = get_the_category(); 56 60 $categories_arr = array(); 57 61 if ( ! empty( $categories ) ) { 58 $categories_arr = wp_list_pluck( $categories, ' cat_name' );62 $categories_arr = wp_list_pluck( $categories, 'slug' ); 59 63 } 60 64 … … 71 75 $json['items'][] = $single; 72 76 } 73 74 77 $json = json_encode($json); 75 78 76 79 nocache_headers(); 77 if (!empty($callback)) { 78 header("Content-Type: application/x-javascript; charset={$charset}"); 79 echo "{$callback}({$json});"; 80 } else { 81 header("Content-Type: application/json; charset={$charset}"); 82 echo $json; 83 } 84 80 header("Content-Type: application/json; charset={$charset}"); 81 echo $json; 82 exit(); 85 83 } else { 86 84 status_header('404');
Note: See TracChangeset
for help on using the changeset viewer.