A collection of tools for publishing from and to NPR's Story API. Find this plugin on the Wordpress.org Plugin Repository.
Contributors: nprds, innlabs
Requires at least: 3.8.14
Tested up to: 4.9
Stable tag: 1.8
License: GPLv2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
The NPR Story API Plugin provides push and pull functionality with the NPR Story API along with a user-friendly administrative interface.
NPR's API is a content API, which essentially provides a structured way for other computer applications to get NPR stories in a predictable, flexible and powerful way. The content that is available includes audio from most NPR programs dating back to 1995 as well as text, images and other web-only content from NPR and NPR member stations. This archive consists of over 250,000 stories that are grouped into more than 5,000 different aggregations.
Access to the NPR Story API requires an API Key to NPR's legacy APIs. If you are an NPR member station or are working with an NPR member station and do not know your key, please ask NPR station relations for help.
The WordPress plugin is being developed as an Open Source plugin by NPR. If you would like to suggest features or bug fixes, or better yet if you would like to contribute new features or bug fixes please contact NPR station relations.
/wp-content/plugins/plugin-name
directory, or install the plugin through the WordPress plugins screen directly.We are no longer provisioning public API key for our legacy APIs. If you are an NPR member station or are working with an NPR member station and do not know your key, please ask NPR station relations for help.
Push requires an Organization ID in the NPR Story API, which is typically given out to only NPR stations and approved content providers. If that's you, you probably already have an Organization ID.
There is some documentation in the NPR Story API site: www.npr.org/api/index.php.
You bet, just visit the NPR Query Generator: www.npr.org/api/queryGenerator.php
NPR Story API Plugin Settings screen
NPR Story API multiple get settings
Get NPR Stories link in the dashboard
Getting an NPR Story by Story ID
NPR Stories having got gotten
delete_others_posts
capability for the user trying to delete the post. In effect, this limits deletion of stories from the NPR Story API to admins and editors.publish_posts
capability, which means that contributors and guests can't push to NPR.edit_posts
capability, meaning that contributors and guests can't pull from NPR. We may want to revisit this in the future, or make the permissions filterable if sites using the plugin want to lock permissions down or open them up.DS_NPR_API
class now uses new-style __construct()
constructor./wp-admin/includes/admin.php
, /wp-load.php
, /wp-includes/class-wp-error.php
from the cron job function, see 4b3d65a and cf2dfa3 - the cron job works without them.Multiple Bylines for pulled stories - When an API story has multiple bylines, we will now populate a meta field npr_multi_byline
with a pipe (|) deliminated list of names. If the author also has a link for thier byline then there'll be a tilde (~) separating the author's name and the link.
An example of data for multiple bylines:
Ari Shapiro~https://www.npr.org/people/2101154/ari-shapiro|kmoylan@npr.org|Tommy Writer
Here there are three authors for this story, Ari Shapiro (and his bio link), then "kmoylan@npr.org" and a third author "Tommy Writer". Single author stories will not be changed. (This fix came from Ryan Tainter at KERA. Thanks, Ryan!)
Do not re-pull stories that are already in draft status - The get multi process would repleatedly re-pull stories into draft mode if there is already a draft copy. This fix will check for status=any
when checking to see if a story already exists in the WordPress database.
Reversed the order of images and audio that are being pushed to the NPR Story API. We're now sending them in the order the file was created.
Mapping of media credit and agency - If you have a field that you are storing image credit and agency, you can now send these to the NPR Story API. In making this change we needed to expose meta fields that begin with an underscore. So you may see more meta fields visable on the mapping page.
Multiple bylines are now being pushed to the NPR Story API if you use the plugin co-author-plus (https://wordpress.org/plugins/co-authors-plus/) We insert a byline row for each of the co-authors of a post when we push. You can still use a custom byline field if you want to use that along with the co-authors plugin.
Retrieved story dates - Now when you retrieve a story from the NPR Story API the published date for WordPress will be the date from the
Retrieved story order - When you retrieve stories from the API, if you do not include a sort
parameter in your query, we will insure that the order of the stories is in reverse cron for any stories that have the same storyDate in the API. Often some aggregate groups in the API will publish stories with the same storyDate. Shows like Morning Edition do this often, and prior to this fix stories would appear to be published in reverse order from what the API shows. Now if you do not include sort
in your query, the stories with the same time will be published in the same order as the API shows them.
Configurable Cron interval - When you use the Get Multi page, which fires off of wp-cron, you can now set the interval for the wp-cron to fire. This is on the Get Multi configuration page, and allows you to enter a number of minutes you want as your wp-cron interval. If you enter any thing that is not a number, or a number less than 1, we will resolve that to 60 minutes...because, well, that's a resonable interval, and the wp-cron doesn't understand 'every now and then' as an interval.
Images from crops - In earlier versions of the plugin we would pull down the image from the URL in <image src=>
. Alas, a lot of those images were small, with ?s=12 in the URL, or thumbnails. So now we're bringing down any bigger versions that we can find. We'll look for the following elements under <enlargement>
, <crop type=enlargement>
, <crop type=standard>
, and then get <image src=>
if those other elements do not exist. This should help with getting bigger images. If you need a smaller image, just theme the bigger one.
When pushing a story to the NPR Story API, we will now be checking to see if images exist in the content, if so, add the query string parameter origin=body
to the image url so CorePublisher will like it. This is only something the Core Publisher uses, but it will help greatly for stories published in Wordpress and retrieved into Core Publisher.
Adding meta data as meta fields to each pulled image. The following meta fields will be attached to the posts for pulled images:
npr_image_credit =>$api_image->producer
npr_image_agency =>$api_image->provider
npr_image_caption =>$api_image->caption
When pushing a story with Audio, the audio description will be pushed as well, provided there is one.
npr_ds_shortcode_filter
) will fire before we remove shortcodes when we're pushing the post. Any plugin that has shortcodes should alter those shortcodes via this filter to something that's more HTML-friendly, so that other clients can access that information. As an example of what needs to be done in a plugin to take advantage of this new filter please see the branch for the following plugin: https://github.com/argoproject/navis-documentcloud/tree/kmoylan-filter What we've done here is write a function my_documentCloud_filter
that is linked to the filter npr_ds_shortcode_filter
(all near the bottom of the PHP file). This function will turn any shortcode created by this plugin into an HTML <a>
tag to link to what was an embedded document. As with any other filter in WordPress, nothing will happen if you do not have any plugins installed that have implemented the filter. It will be up to any other plugin's maintainer to implement the filter correctly if they wish to take advantage of this functionality.npr_byline_link
. This should allow you to supply a link for any author who has a biography registered with the NPR Story API.This version will allow admins to configure their WordPress site to retrieve multiple NPR Story API stories that will be automatically published (via cron) to their site.
From the Settings -> NPR API Get Multi page (wp-admin/options-general.php?page=ds_npr_api_get_multi_settings) an admin can add a number of queries.
These query entries can contain an API ID for a single story, or an ID for a specific category, program, topic, etc.
The query can also contain the full query string can be created from the NPR Story API Query Generator: https://www.npr.org/api/queryGenerator.php
You can also enter the URL for a story you found on npr.org.
The entered queries will be executed via the Wordpress cron functionality, hourly.
Any new stories that are available will be automatically published. You can find a list of query filters at the npr.org's API documentation page: https://www.npr.org/api/inputReference.php
Stories retrieved from the NPR Story API will be created as Posts in WordPress. Each post will have a number of meta fields associated with the post. These meta fields will all begin with npr_
and can be viewed on a post edit screen with Custom Fields option enabled through Screen Options. A story from the API that has a primary image defined will have that image set as the featured image of the Wordpress post. Any bylines for the NPR Story will be stored in the meta field npr_byline
. The list of npr_ meta fields is:
npr_api_link
npr_byline
npr_html_link
npr_last_modified_date
npr_pub_date
npr_retrieved_story
npr_story_content
npr_story_id
On the All Posts admin screen we've made a couple of modification/additions to help you manage your NPR Story API content.
Update and Delete of pushed stories - A story that was written in your Wordpress site and pushed to the NPR Story API will be automatically be updated in the API when your story is updated in Wordpress. When your Post is moved to the Trash in Wordpress, your story will be deleted from the NPR Story API. If a Trashed Post is resorted, your story will be made available to the NPR Story API again.
As not a lot of users have installed the V1.0 of the NPR Story API Plugin, there are a couple of things to keep in mind.
https://api-s1.npr.org
. NOTE: this url should not contain a trailing slash.https://api-s1.npr.org
. If you do not wish to push your content, or your NPR Story API has not been authorized, you should leave this field empty and the WordPress plugin will not attempt to push you content to the NPR Story API.This version adds export functionality for the NPR One mobile app, in addition to assorted bug fixes.