Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Profile Type ID added to the querystring #15

Merged
merged 1 commit into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion get_stories.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public static function nprstory_cron_pull() {
for ( $i=0; $i < $num; $i++ ) {
$api = new NPRAPIWordpress();
$q = 'ds_npr_query_' . $i;
$profileTypeID = get_option( $p );
$query_string = get_option( $q );
if ( !empty( $query_string ) ) {
nprstory_error_log( 'Cron '. $i . ' querying NPR API for ' . $query_string );
Expand All @@ -60,7 +61,7 @@ public static function nprstory_cron_pull() {
var_export( get_option( 'ds_npr_api_pull_url' ), true )
) ); // debug use
} else {
$params = [ 'id' => $query_string, 'apiKey' => get_option( 'ds_npr_api_key' ) ];
$params = [ 'id' => $query_string, 'profileTypeId' => $profileTypeID, 'apiKey' => get_option( 'ds_npr_api_key' )];
$api->request( $params, 'query', get_option( 'ds_npr_api_pull_url' ) );
}
}
Expand Down
16 changes: 16 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function nprstory_add_query_page() {
delete_option( 'ds_npr_query_category_' . $k );
delete_option( 'ds_npr_query_tags_' . $k );
delete_option( 'ds_npr_query_publish_' . $k );
delete_option( 'ds_npr_query_profileTypeID_' . $k );
$k++;
$opt = get_option( 'ds_npr_query_' . $k );
}
Expand All @@ -42,6 +43,7 @@ function nprstory_add_query_page() {
delete_option( 'ds_npr_query_category_' . $k );
delete_option( 'ds_npr_query_tags_' . $k );
delete_option( 'ds_npr_query_publish_' . $k );
delete_option( 'ds_npr_query_profileTypeID_' . $k );
$k++;
}
}
Expand Down Expand Up @@ -88,6 +90,10 @@ function nprstory_settings_init() {
add_settings_field( 'ds_npr_query_' . $i, 'Query String ' . $i, 'nprstory_api_query_callback', 'ds_npr_api_get_multi_settings', 'ds_npr_api_get_multi_settings', $i );
register_setting( 'ds_npr_api_get_multi_settings', 'ds_npr_query_' . $i , 'nprstory_validation_callback_url');

// Add ProfileTypeIDs
add_settings_field( 'ds_npr_query_profileTypeID_' . $i, 'Add Profile Type IDs for querystring' . $i, 'ds_npr_api_query_profileTypeID_callback', 'ds_npr_api_get_multi_settings', 'ds_npr_api_get_multi_settings', $i );
register_setting( 'ds_npr_api_get_multi_settings', 'ds_npr_query_profileTypeID_' . $i, 'nprstory_validation_callback_url' );

//ds_npr_query_publish_
add_settings_field( 'ds_npr_query_publish_' . $i, 'Publish Stories ' . $i, 'nprstory_api_query_publish_callback', 'ds_npr_api_get_multi_settings', 'ds_npr_api_get_multi_settings', $i );
register_setting( 'ds_npr_api_get_multi_settings', 'ds_npr_query_publish_' . $i , 'nprstory_validation_callback_select');
Expand Down Expand Up @@ -244,6 +250,16 @@ function ds_npr_api_query_tags_callback( $i ) {
echo "<p><hr></p>";
}

// profile type id
function ds_npr_api_query_profileTypeID_callback( $i ) {
$name = 'ds_npr_query_profileTypeID_' . $i;
$option = get_option( $name );

echo nprstory_esc_html( "<input type='text' value='$option' name='$name' style='width: 300px;' /> <p>***Optional Profile ID Type(s) to each story pulled from NPR (comma separated).</p>" );
wp_nonce_field( 'nprstory_nonce_ds_npr_profileidtype_' . $i, 'nprstory_nonce_ds_npr_profileidtype_' . $i . '_name', true, true );
echo "<p><hr></p>";
}

function nprstory_api_num_multi_callback() {
$option = get_option('ds_npr_num');
echo nprstory_esc_html( "<input type='number' value='$option' name='ds_npr_num' /> <p> Increase the number of queries by changing the number in the field above." );
Expand Down