Quantcast
Viewing latest article 2
Browse Latest Browse All 2

Transients API conditional

I have the following transient, but if the user changes the value of $url the transient should not be used. I want to know what is the most appropriate way to use this variable with the transient. Should I save the value of $url with Options API to compare it with the new value?

if ( false === ( $videos_result = get_transient( 'html' ) )){
    //HTTP API
    $videos_result = wp_remote_get( $url );

    $response_code = wp_remote_retrieve_response_code( $videos_result );
    $response_message = wp_remote_retrieve_response_message( $videos_result );
    set_transient('html', $videos_result, HOUR_IN_SECONDS );
} else{
    $response_code = 200;
}

Viewing latest article 2
Browse Latest Browse All 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>