Skip to content

Commit

Permalink
Add Transient to Main page
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Fear committed Mar 15, 2023
1 parent 267a1bb commit e6893b9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions core/includes/classes/class-RRCLET-shortcode-rentals.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,23 @@ public function create_clet_rentals_shortcode( $atts = array(), $content = '' )

$output = '';
$api_key_1 = get_option( 'RRCLET_api_key' ); // Array of All Options

$cache = "";
if( get_transient( 'RRCLET' ) ) {
$cache = get_transient( 'RRCLET' );
} else {
$theurltouse = 'https://www.casperpanel.com/api/rentals.php?accessKey=' . $api_key_1;
$args = array();
$response = wp_remote_get( $theurltouse, $args );

$bodyofchrist = wp_remote_retrieve_body( $response );
$d1 = json_decode(substr($bodyofchrist,5));
$d2 = $d1->availableUnits;
set_transient( 'RRCLET', $d2, DAY_IN_SECONDS/2 );

$cache = $d2;

foreach($d2 as $query){
}
foreach($cache as $query){
$addon = $this->clet_rentals_templater($query);
$output .= $addon;
}
Expand Down

0 comments on commit e6893b9

Please sign in to comment.