Skip to content

Commit

Permalink
Merge branch 'develop' into issue-65
Browse files Browse the repository at this point in the history
Conflicts:
	includes/admin.php
	includes/db-updates.php
  • Loading branch information
frankiejarrett committed Apr 22, 2014
2 parents c07e3a9 + ca2d245 commit b56b238
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
9 changes: 6 additions & 3 deletions includes/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static function load() {
add_action( 'wp_ajax_wp_stream_uninstall', array( __CLASS__, 'uninstall_plugin' ) );

// Auto purge setup
add_action( 'wp', array( __CLASS__, 'purge_schedule_setup' ) );
add_action( 'wp_loaded', array( __CLASS__, 'purge_schedule_setup' ) );
add_action( 'wp_stream_auto_purge', array( __CLASS__, 'purge_scheduled_action' ) );

// Admin notices
Expand Down Expand Up @@ -571,6 +571,10 @@ public static function uninstall_plugin() {
delete_site_option( 'dashboard_stream_activity_options' );
}

// Delete scheduled cron event hooks
wp_clear_scheduled_hook( 'stream_auto_purge' ); // Deprecated hook
wp_clear_scheduled_hook( 'wp_stream_auto_purge' );

// Deactivate the plugin
deactivate_plugins( plugin_basename( WP_STREAM_DIR ) . '/stream.php' );

Expand All @@ -580,12 +584,11 @@ public static function uninstall_plugin() {
} else {
wp_die( "You don't have sufficient privileges to do this action." );
}

}

public static function purge_schedule_setup() {
if ( ! wp_next_scheduled( 'wp_stream_auto_purge' ) ) {
wp_schedule_event( time(), 'daily', 'wp_stream_auto_purge' );
wp_schedule_event( time(), 'twicedaily', 'wp_stream_auto_purge' );
}
}

Expand Down
9 changes: 8 additions & 1 deletion includes/db-updates.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,18 @@ function wp_stream_update_140( $db_version, $current_version ) {
}
}

do_action( 'wp_stream_after_db_update_' . $db_version, $current_version, $wpdb->last_error );

if ( $wpdb->last_error ) {
return __( 'Database Update Error', 'stream' );
}

do_action( 'wp_stream_after_db_update_' . $db_version, $current_version, $wpdb->last_error );
// Clear an old cron event hook that is lingering, replaced by `wp_stream_auto_purge`
wp_clear_scheduled_hook( 'stream_auto_purge' );

// Clear out this cron event hook too since we're changing the interval in this release
// and want the new schedule to take affect immediately after updating.
wp_clear_scheduled_hook( 'wp_stream_auto_purge' );

return $current_version;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/test-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function test_constructor() {
array( 'admin_enqueue_scripts', self::CLASSNAME, 'admin_enqueue_scripts' ),
array( 'admin_enqueue_scripts', self::CLASSNAME, 'admin_menu_css' ),
array( 'wp_ajax_wp_stream_reset', self::CLASSNAME, 'wp_ajax_reset' ),
array( 'wp', self::CLASSNAME, 'purge_schedule_setup' ),
array( 'wp_loaded', self::CLASSNAME, 'purge_schedule_setup' ),
array( 'wp_stream_auto_purge', self::CLASSNAME, 'purge_scheduled_action' ),
);

Expand Down

0 comments on commit b56b238

Please sign in to comment.