API setting constants

This commit is contained in:
Tetrakern 2023-02-13 22:48:17 +01:00
parent 8bb48da55e
commit 0b50861c75
2 changed files with 12 additions and 2 deletions

View File

@ -84,6 +84,11 @@ if ( ! defined( 'FICTIONEER_UPDATE_CHECK_TIMEOUT' ) ) {
define( 'FICTIONEER_UPDATE_CHECK_TIMEOUT', 3600 );
}
// Integer: Storygraph API cache TTL
if ( ! defined( 'FICTIONEER_API_STORYGRAPH_CACHE_TTL' ) ) {
define( 'FICTIONEER_API_STORYGRAPH_CACHE_TTL', 3600 );
}
/*
* Booleans
*/
@ -134,6 +139,11 @@ if ( ! defined( 'FICTIONEER_FILTER_STORY_CHAPTERS' ) ) {
define( 'FICTIONEER_FILTER_STORY_CHAPTERS', true );
}
// Integer: Storygraph API hotlink permission
if ( ! defined( 'FICTIONEER_API_STORYGRAPH_HOTLINK' ) ) {
define( 'FICTIONEER_API_STORYGRAPH_HOTLINK', false );
}
// =============================================================================
// GLOBAL
// =============================================================================

View File

@ -57,7 +57,7 @@ if ( ! function_exists( 'fictioneer_api_get_story_node' ) ) {
// Image
if ( true ) {
$node['images'] = ['hotlinkAllowed' => false]; // TODO
$node['images'] = ['hotlinkAllowed' => FICTIONEER_API_STORYGRAPH_HOTLINK];
$cover = get_the_post_thumbnail_url( $story_id, 'full' );
$header = fictioneer_get_field( 'fictioneer_custom_header_image', $story_id );
$header = wp_get_attachment_image_url( $header, 'full' );
@ -160,7 +160,7 @@ if ( ! function_exists( 'fictioneer_api_request_story' ) ) {
$graph['cached'] = false;
// Cache request
set_transient( 'fictioneer_api_story_' . $story_id, $graph, 3600 );
set_transient( 'fictioneer_api_story_' . $story_id, $graph, FICTIONEER_API_STORYGRAPH_CACHE_TTL );
// Response
return rest_ensure_response( $graph );