$figcaption\n";
+ $body_with_layout .= $fightml;
+ }
+ break;
+ default:
+ // handles both 'list' and 'image' since it will reset the type and then assign the reference
+ if ($element['type'] == 'list') {
+ foreach ($storyimages as $image) {
+ if ($image['type'] != 'primary') {
+ continue;
+ }
+ $reference = $image['id'];
+ $element['type'] = 'image';
+ break;
+ }
+ }
+ if ($element['type'] != 'image') {
+ break;
+ }
+ if (!empty($storyimages[$reference])) {
+ $figclass = "wp-block-image size-large";
+ $thisimg = $storyimages[$reference];
+ $fightml = !empty( (string)$thisimg['image_url']) ? '' : '';
+ $figcaption = (!empty($fightml) && !empty( $thiscaption)) ? $thiscaption : '';
+ $cites = '';
+ foreach (array('producer', 'provider', 'copyright') as $item) {
+ $thisitem = trim( (string)$thisimg[$item] );
+ if (!empty($thisitem)) {
+ $cites .= !empty($cites) ? ' | ' . $thisitem : $thisitem;
+ }
+ }
+ $cites = !empty($cites) ? "$cites" : '';
+ $thiscaption .= $cites;
+ $figcaption = (!empty($fightml) && !empty( $thiscaption)) ? "$thiscaption" : '';
+ $fightml .= (!empty($fightml) && !empty($figcaption)) ? $figcaption : '';
+ $body_with_layout .= (!empty($fightml)) ? "$fightml\n\n" : '';
+ // make sure it doesn't get reused;
+ unset($storyimages[$reference]);
+ }
+ break;
+ }
+ }
+
+ }
+ $returnary['body']= $body_with_layout;
+
+ return $returnary;
+ }
+
+
+
+
+
+
+
+
+
}
diff --git a/ds-npr-api.php b/ds-npr-api.php
index a2a4282..45053f8 100644
--- a/ds-npr-api.php
+++ b/ds-npr-api.php
@@ -32,6 +32,7 @@
define( 'NPR_BYLINE_LINK_META_KEY', 'npr_byline_link' );
define( 'NPR_MULTI_BYLINE_META_KEY', 'npr_multi_byline' );
define( 'NPR_IMAGE_GALLERY_META_KEY', 'npr_image_gallery');
+define( 'NPR_HTML_ASSETS_META_KEY', 'npr_html_assets');
define( 'NPR_AUDIO_META_KEY', 'npr_audio');
define( 'NPR_AUDIO_M3U_META_KEY', 'npr_audio_m3u');
define( 'NPR_PUB_DATE_META_KEY', 'npr_pub_date');
@@ -43,6 +44,9 @@
define( 'NPR_IMAGE_AGENCY_META_KEY', 'npr_image_agency');
define( 'NPR_IMAGE_CAPTION_META_KEY', 'npr_image_caption');
+define( 'NPR_STORY_HAS_LAYOUT_META_KEY', 'npr_has_layout');
+define( 'NPR_STORY_HAS_VIDEO_META_KEY', 'npr_has_video');
+
define( 'NPR_PUSH_STORY_ERROR', 'npr_push_story_error');
define( 'NPR_MAX_QUERIES', 10 );
diff --git a/push_story.php b/push_story.php
index a964698..6ecb6de 100644
--- a/push_story.php
+++ b/push_story.php
@@ -82,13 +82,6 @@ function nprstory_api_push ( $post_ID, $post ) {
* @param unknown_type $post_ID
*/
function nprstory_api_delete ( $post_ID ) {
- if ( ! current_user_can( 'delete_others_posts' ) ) {
- wp_die(
- __('You do not have permission to delete posts in the NPR API. Users that can delete other users\' posts have that ability: administrators and editors.'),
- __('NPR Story API Error'),
- 403
- );
- }
$push_post_type = get_option( 'ds_npr_push_post_type' );
if ( empty( $push_post_type ) ) {
@@ -106,6 +99,15 @@ function nprstory_api_delete ( $post_ID ) {
//if the push url isn't set, don't even try to delete.
$push_url = get_option( 'ds_npr_api_push_url' );
if ( $post->post_type == $push_post_type && ! empty( $push_url ) && ! empty( $api_id ) ) {
+ // don't let a non-admin/editor push a delete to the API
+ if ( ! current_user_can( 'delete_others_posts' ) ) {
+ wp_die(
+ __('You do not have permission to delete posts in the NPR API. Users that can delete other users\' posts have that ability: administrators and editors.'),
+ __('NPR Story API Error'),
+ 403
+ );
+ }
+
// For now, only submit regular posts, and only on publish.
if ( $post->post_type != 'post' || $post->post_status != 'publish' ) {
return;
diff --git a/settings.php b/settings.php
index 7778224..753ed7c 100644
--- a/settings.php
+++ b/settings.php
@@ -91,9 +91,15 @@ function nprstory_settings_init() {
add_settings_field( 'dp_npr_query_run_multi', 'Run the queries on saving changes', 'nprstory_query_run_multi_callback', 'ds_npr_api_get_multi_settings', 'ds_npr_api_get_multi_settings' );
register_setting( 'ds_npr_api_get_multi_settings', 'dp_npr_query_run_multi' , 'nprstory_validation_callback_checkbox');
+
add_settings_field( 'dp_npr_query_multi_cron_interval', 'Interval to run Get Multi cron', 'nprstory_query_multi_cron_interval_callback', 'ds_npr_api_get_multi_settings', 'ds_npr_api_get_multi_settings' );
register_setting( 'ds_npr_api_get_multi_settings', 'dp_npr_query_multi_cron_interval', 'intval' );
+
+ add_settings_field( 'dp_npr_query_use_layout', 'Use rich layout on pulled posts if available', 'nprstory_query_use_layout_callback', 'ds_npr_api_get_multi_settings', 'ds_npr_api_get_multi_settings' );
+ register_setting( 'ds_npr_api_get_multi_settings', 'dp_npr_query_use_layout' , 'nprstory_validation_callback_checkbox');
+
+
add_settings_field( 'ds_npr_pull_post_type', 'NPR Pull Post Type', 'nprstory_pull_post_type_callback', 'ds_npr_api', 'ds_npr_api_settings' );
register_setting( 'ds_npr_api', 'ds_npr_pull_post_type', 'nprstory_validation_callback_select' );
@@ -151,6 +157,19 @@ function nprstory_query_run_multi_callback() {
wp_nonce_field( 'nprstory_nonce_ds_npr_query_run_multi', 'nprstory_nonce_ds_npr_query_run_multi_name', true, true );
}
+function nprstory_query_use_layout_callback() {
+ $use_layout = get_option('dp_npr_query_use_layout');
+ $check_box_string = "If 'layout' is available in the NPR Story API output for your key, checking this box will import posts with more complex HTML to render any images, YouTube videos, Tweets, iframes, or JavaScript-based widgets within the post in the order they appeared on the NPR website. Only the 'primary' image for the story will be sideloaded into the Media Library, all other images will be linked from NPR. CAUTION: This disables the normal 'wp_kses' filtering for imported posts that prevents any JavaScript from being included in the post. We assume that NPR Story API posts will not have malicious scripts.