Skip to content

Commit

Permalink
if no api key clear cron job and do not set new one
Browse files Browse the repository at this point in the history
  • Loading branch information
unfulvio committed Jun 24, 2015
1 parent e75e237 commit 52a86b1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions includes/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,12 @@ public function updated_options( $option, $old_value, $new_value ) {
if ( $option == 'wp_currencies_settings' ) {
if ( $old_value != $new_value ) {

wp_clear_scheduled_hook( 'wp_currencies_update' );

// Makes sure we have an API key (won't tell if valid, but at least is not empty).
$api_key = isset( $new_value['api_key'] ) ? $new_value['api_key'] : ( isset( $old_value['api_key'] ) ? $old_value['api_key'] : '' );
if ( ! empty( $api_key ) ) {

wp_clear_scheduled_hook( 'wp_currencies_update' );

// Has this ever been scheduled before?
if ( ! wp_next_scheduled( 'wp_currencies_update' ) ) {
wp_schedule_event( time(), $new_value['update_interval'], 'wp_currencies_update' );
Expand Down

0 comments on commit 52a86b1

Please sign in to comment.