Bläddra i källkod

Add JSON API. Squashed commit of the following:

commit 0b7a6a1d4d
Author: Adrian Short <adrian@adrianshort.org>
Date:   Mon Apr 13 15:15:49 2015 +0100

    Bump version 0.1.2.1

commit e79c77c68f
Author: Adrian Short <adrian@adrianshort.org>
Date:   Mon Apr 13 14:20:07 2015 +0100

    Return all sites

commit 7b1079190d
Author: Adrian Short <adrian@adrianshort.org>
Date:   Mon Apr 13 14:07:17 2015 +0100

    Bump version number 0.1.2

commit aa63797604
Author: Adrian Short <adrian@adrianshort.org>
Date:   Mon Apr 13 14:02:26 2015 +0100

    Add extra fields

commit aa5ab1ea1d
Author: Adrian Short <adrian@adrianshort.org>
Date:   Mon Apr 13 11:10:04 2015 +0100

    Remove function

commit 50a18cd311
Author: Adrian Short <adrian@adrianshort.org>
Date:   Thu Apr 9 10:27:21 2015 +0100

    Serve JSON feed for sites
master
Adrian Short 9 år sedan
förälder
incheckning
2717b0193e
2 ändrade filer med 52 tillägg och 1 borttagningar
  1. +51
    -0
      includes/sites.php
  2. +1
    -1
      talhyperlocal.php

+ 51
- 0
includes/sites.php Visa fil

@@ -0,0 +1,51 @@
<?php
// ini_set( 'display_errors', 1 );
// error_reporting( E_ALL ^ E_NOTICE );

define( 'WP_USE_THEMES', false );
require_once( '../../../../wp-load.php' );

$options = array(
'post_type' => 'site',
'posts_per_page' => -1, // -1 for all posts
'post_status' => 'publish',
'orderby' => 'title',
'order' => 'ASC'
);

$query = new WP_Query( $options ) or die("WP Query failed");

$sites = array();

if ( $query->have_posts() ) :
while ( $query->have_posts() ) : $query->the_post() ;
$meta = get_post_meta( get_the_ID() );

// party_affiliation
// hyperlocal_group_id

$row = array(
'title' => get_the_title(),
'url' => get_permalink(),
'feed_url' => $meta['feed_url'][0],
'date_created' => get_the_date("c"),
'date_modified' => get_the_modified_date("c"),
'lat' => (float)$meta['geo_latitude'][0],
'lon' => (float)$meta['geo_longitude'][0],
'radius_miles' => (float)$meta['distance_covered_miles'][0],
'area_covered' => $meta['area_covered'][0],
'body' => get_the_content(),
'area_covered' => $meta['area_covered'][0],
'country' => get_the_terms( get_the_ID(), 'countries' ),
'council' => get_the_terms( get_the_ID(), 'councils' ),
'platform' => get_the_terms( get_the_ID(), 'platforms' ),
);

$sites[]= $row;
endwhile;
else :
echo "No posts matched the query";
endif;

header( "Content-Type: application/json" );
echo json_encode( $sites );

+ 1
- 1
talhyperlocal.php Visa fil

@@ -3,7 +3,7 @@
Plugin Name: Talk About Local Hyperlocal Sites Directory
Plugin URI:
Description:
Version: 0.1.1
Version: 0.1.2.1
Author: Adrian Short
Author URI: https://adrianshort.org/
License: GPL v3


Laddar…
Avbryt
Spara