npr / nprapi-wordpress

Access the NPR API from within WordPress. This repository is no longer being maintained. See the README for more information.
GNU General Public License v2.0
13 stars 30 forks source link

import externalAssets and htmlAssets from a story into postmeta #69

Closed tamw-wnet closed 4 years ago

tamw-wnet commented 4 years ago

The "externalAssets" at the end of many stories are oembed links for YouTube and Twitter (possibly others) that are referred to in the story. Parsing those into arrays and saving them into appropriate postmeta eg 'npr_ds_oembeds_twitter'/'npr_ds_oembeds_youtube' allows them to be integrated into the WordPress posts as appropriate. They could then be retrieved like so:

$tweets = get_post_custom('npr_ds_oembeds_twitter); foreach ($tweets as $tweet) { echo (wp_oembed_get($tweet['url'])); } YouTube videos are importable the same way, expect replace 'twitter' with 'youtube' in the example.

Similarly, the "htmlAssets" are standalone elements -- typically a div and some javascript that generate an interactive map or table. Again, this PR saves those into a postmeta with the key 'npr_html_assets' where they could be appended to the story in WordPress, eg

$htmlassets = get_post_custom('npr_html_assets'); foreach ($htmlassets as $htmlasset) { echo ($htmlasset); }

This pull request only adds functionality and does not alter any current functionality.

tamw-wnet commented 4 years ago

Noting that the build failure is because the Travis integration seems to be broken -- each build failed setting up the build environment (rather than this pull req): $ mysql -e "CREATE DATABASE wordpress_tests;" -uroot

tamw-wnet commented 4 years ago

withdrawing this, I'm taking a different approach that will allow inline placement of the assets in the post.