ActionScheduler_WPCommentCleaner::maybe_schedule_cleanup
Schedules the WP Post comment table cleanup to run in 6 months if it's not already scheduled. Attached to the migration complete hook 'action_scheduler/migration_complete'.
Method of the class: ActionScheduler_WPCommentCleaner{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = ActionScheduler_WPCommentCleaner::maybe_schedule_cleanup();
ActionScheduler_WPCommentCleaner::maybe_schedule_cleanup() ActionScheduler WPCommentCleaner::maybe schedule cleanup code WC 10.8.1
public static function maybe_schedule_cleanup() {
$has_logs = 'no';
$args = array(
'type' => ActionScheduler_wpCommentLogger::TYPE,
'number' => 1,
'fields' => 'ids',
);
if ( (bool) get_comments( $args ) ) {
$has_logs = 'yes';
if ( ! as_next_scheduled_action( self::$cleanup_hook ) ) {
as_schedule_single_action( gmdate( 'U' ) + ( 6 * MONTH_IN_SECONDS ), self::$cleanup_hook );
}
}
update_option( self::$has_logs_option_key, $has_logs, true );
}