I am writing a Wordpress plugin that uses an array as an option but the new value is never set when I run update_option function. The first time this runs last_updated is a new element in the array but when I output the before update and after update values to the error_log I can see that the element last_updated has not been added to the option. Any help into what I am doing wrong here would be greatly appreciated! Thanks!
$coupon_grab_options = get_option( 'coupon_grab_option' );
// Output the current version of coupon_grab_option
error_log( print_r( $coupon_grab_options, true ), 0);
$last_updated = $coupon_grab_options['last_updated'];
$request = wp_remote_get('http://codes.clipncrazy.com/lastupdated.php');
$response = wp_remote_retrieve_body( $request );
// Update the coupon_grab_option with the latest last_updated value
if( $last_updated != $response ) {
$coupon_grab_options['last_updated'] = $response;
update_option( 'coupon_grab_option', $coupon_grab_options );
}
$coupon_grab_options = get_option( 'coupon_grab_option' );
// Output the updated version of coupon_grab_option
error_log( print_r( $coupon_grab_options, true ), 0);
$response
supposed to be$request
, or vice versa?