Skip to content

Commit

Permalink
Fixed bug that prevented next scheduling to happen
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo Roman committed Mar 21, 2012
1 parent 99281fd commit 173d218
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ function tnwsc_log($message)
function tnwsc_process( $all_posts = false )
{
tnwsc_log('Request: tnwsc_process()');

// Schedule next sync inmediately
if( get_option( 'tnwsc_active_sync' ) == 1) {
tnwsc_schedule_sync();
}

$tnwsc_services = get_option( 'tnwsc_services' );
$tnwsc_debug = get_option( 'tnwsc_debug' );
$posts = tnwsc_get_posts( $all_posts );
Expand All @@ -61,9 +67,6 @@ function tnwsc_process( $all_posts = false )
tnwsc_log("Request: ".$permalink. $debug_info);
}
}
if( get_option( 'tnwsc_active_sync' ) == 1) {
tnwsc_schedule_sync();
}
return count($posts);
}

Expand Down Expand Up @@ -180,7 +183,6 @@ function tnwsc_schedule_sync( $immediate = false )
$hook = "tnwsc_sync";
$tnwsc_sync_frequency = get_option( 'tnwsc_sync_frequency' ) ? get_option( 'tnwsc_sync_frequency' ) : $tnwsc_wp_options['tnwsc_sync_frequency'];
tnwsc_log( "tnwsc_schedule_sync() - Synching in ".$tnwsc_sync_frequency." seconds" );
wp_clear_scheduled_hook( $hook );
if ( $immediate ) {
wp_schedule_single_event( time() -1, $hook );
} else {
Expand All @@ -189,16 +191,6 @@ function tnwsc_schedule_sync( $immediate = false )
}
}

/*
function tnwsc_init()
{
if ( isset( $_GET['tnwsc_sync'] ) ) {
tnwsc_process();
exit;
}
}
add_action( 'init', 'tnwsc_init' );
*/

// Backend actions
add_action( 'tnwsc_sync', 'tnwsc_process' );
Expand Down

0 comments on commit 173d218

Please sign in to comment.