public/wordpress/wp-content/plugins/backupbuddy/classes/housekeeping.php
/* remove_wp_schedules_with_no_bb_schedule()
	 *
	 * Loop through each WP schedule and delete any schedules without corresponding BB schedules or corrupt entries. Also handles migration from old to new tag backupbuddy_cron.
	 * NOTE: Also upgrades to new backupbuddy_cron tag from pb_backupbuddy-cron_scheduled_backup AND migrationg of housekeeping tag AND removal of faulty tags.
	 *
	 */
remove_wp_schedules_with_no_bb_schedule()
Loop through each WP schedule and delete any schedules without corresponding BB schedules or corrupt entries. Also handles migration from old to new tag backupbuddy_cron.
NOTE: Also upgrades to new backupbuddy_cron tag from pb_backupbuddy-cron_scheduled_backup AND migrationg of housekeeping tag AND removal of faulty tags.
remove_wp_schedules_with_no_bb_schedule () Loop through each WP schedule and delete any schedules without corresponding BB schedules or corrupt entries . Also handles migration from old to new tag backupbuddy_cron . NOTE : Also upgrades to new backupbuddy_cron tag from pb_backupbuddy - cron_scheduled_backup AND migrationg of housekeeping tag AND removal of faulty tags .
public static function remove_wp_schedules_with_no_bb_schedule() {
		$cron = get_option('cron');
		foreach ( (array) $cron as $time => $cron_item ) { 
			if ( is_numeric( $time ) ) {
				foreach ( (array) $cron_item as $hook_name => $event ) { 
					foreach ( (array) $event as $item_name => $item ) { 
						if ( ( 'backupbuddy_cron' == $hook_name ) && ( 'run_scheduled_backup' == $item['args'][0] ) ) { 
							if ( ! empty( $item['args'] ) ) {
								if ( ! isset( pb_backupbuddy::$options['schedules'][ $item['args'][1][0] ] ) ) { 
									if ( FALSE === backupbuddy_core::unschedule_event( $time, $hook_name, $item['args'] ) ) { 
										pb_backupbuddy::status( 'error', 'Error #5657667675b. Unable to delete CRON job. Please see your BackupBuddy error log for details.' );
									} else {
										pb_backupbuddy::status( 'warning', 'Removed stale cron scheduled backup.' );
									}
								}
							} else { 
								if ( FALSE === backupbuddy_core::unschedule_event( $time, $hook_name, $item['args'] ) ) { 
									pb_backupbuddy::status( 'error', 'Error #5657667675c. Unable to delete CRON job. Please see your BackupBuddy error log for details.' );
								} else {
									pb_backupbuddy::status( 'warning', 'Removed stale cron scheduled backup which had no arguments.' );
								}
							}
						} elseif ( 'pb_backupbuddy-cron_scheduled_backup' == $hook_name ) { 
							if ( FALSE === wp_unschedule_event( $time, $hook_name, $item['args'] ) ) { 
								pb_backupbuddy::status( 'error', 'Error #327237. Unable to delete CRON job for migration to new tag. Please see your BackupBuddy error log for details.' );
							} else {
								pb_backupbuddy::status( 'details', 'Removed cron with old tag format.' );
							}
							if ( isset( pb_backupbuddy::$options['schedules'][ $item['args'][0] ] ) ) { 
								$result = backupbuddy_core::schedule_event( $time, pb_backupbuddy::$options['schedules'][ $item['args'][0] ]['interval'], 'run_scheduled_backup', $item['args'] );
								if ( $result === false ) {
									pb_backupbuddy::status( 'error', 'Error #8923832: Unable to reschedule with new cron tag.' );
								} else {
									pb_backupbuddy::status( 'details', 'Replaced cron with old tag format with new format.' );
								}
							} else {
								pb_backupbuddy::status( 'warning', 'Stale schedule found with WordPress without corresponding BackupBuddy schedule. Not keeping when migrating to new cron tag.' );
							}
						} elseif ( 'pb_backupbuddy_cron' == $hook_name ) { 
							wp_unschedule_event( $time, $hook_name, $item['args'] );
						} elseif ( 'pb_backupbuddy_corn' == $hook_name ) { 
							wp_unschedule_event( $time, $hook_name, $item['args'] );
						} elseif ( 'pb_backupbuddy_housekeeping' == $hook_name ) { 
							wp_unschedule_event( $time, $hook_name, $item['args'] );
						}
					} 
					unset( $item );
					unset( $item_name );
				} 
				unset( $event );
				unset( $hook_name );
			} 
		} 
		unset( $cron_item );
		unset( $time );
	}
public static function remove_wp_schedules_with_no_bb_schedule ( ) { $ cron = get_option ( 'cron' ) ; foreach ( ( array ) $ cron as $ time => $ cron_item ) { if ( is_numeric ( $ time ) ) { foreach ( ( array ) $ cron_item as $ hook_name => $ event ) { foreach ( ( array ) $ event as $ item_name => $ item ) { if ( ( 'backupbuddy_cron' == $ hook_name ) && ( 'run_scheduled_backup' == $ item [ 'args' ] [ 0 ] ) ) { if ( ! empty ( $ item [ 'args' ] ) ) { if ( ! isset ( pb_backupbuddy :: $ options [ 'schedules' ] [ $ item [ 'args' ] [ 1 ] [ 0 ] ] ) ) { if ( FALSE === backupbuddy_core :: unschedule_event ( $ time , $ hook_name , $ item [ 'args' ] ) ) { pb_backupbuddy :: status ( 'error' , 'Error #5657667675b. Unable to delete CRON job. Please see your BackupBuddy error log for details.' ) ; } else { pb_backupbuddy :: status ( 'warning' , 'Removed stale cron scheduled backup.' ) ; } } } else { if ( FALSE === backupbuddy_core :: unschedule_event ( $ time , $ hook_name , $ item [ 'args' ] ) ) { pb_backupbuddy :: status ( 'error' , 'Error #5657667675c. Unable to delete CRON job. Please see your BackupBuddy error log for details.' ) ; } else { pb_backupbuddy :: status ( 'warning' , 'Removed stale cron scheduled backup which had no arguments.' ) ; } } } elseif ( 'pb_backupbuddy-cron_scheduled_backup' == $ hook_name ) { if ( FALSE === wp_unschedule_event ( $ time , $ hook_name , $ item [ 'args' ] ) ) { pb_backupbuddy :: status ( 'error' , 'Error #327237. Unable to delete CRON job for migration to new tag. Please see your BackupBuddy error log for details.' ) ; } else { pb_backupbuddy :: status ( 'details' , 'Removed cron with old tag format.' ) ; } if ( isset ( pb_backupbuddy :: $ options [ 'schedules' ] [ $ item [ 'args' ] [ 0 ] ] ) ) { $ result = backupbuddy_core :: schedule_event ( $ time , pb_backupbuddy :: $ options [ 'schedules' ] [ $ item [ 'args' ] [ 0 ] ] [ 'interval' ] , 'run_scheduled_backup' , $ item [ 'args' ] ) ; if ( $ result === false ) { pb_backupbuddy :: status ( 'error' , 'Error #8923832: Unable to reschedule with new cron tag.' ) ; } else { pb_backupbuddy :: status ( 'details' , 'Replaced cron with old tag format with new format.' ) ; } } else { pb_backupbuddy :: status ( 'warning' , 'Stale schedule found with WordPress without corresponding BackupBuddy schedule. Not keeping when migrating to new cron tag.' ) ; } } elseif ( 'pb_backupbuddy_cron' == $ hook_name ) { wp_unschedule_event ( $ time , $ hook_name , $ item [ 'args' ] ) ; } elseif ( 'pb_backupbuddy_corn' == $ hook_name ) { wp_unschedule_event ( $ time , $ hook_name , $ item [ 'args' ] ) ; } elseif ( 'pb_backupbuddy_housekeeping' == $ hook_name ) { wp_unschedule_event ( $ time , $ hook_name , $ item [ 'args' ] ) ; } } unset ( $ item ) ; unset ( $ item_name ) ; } unset ( $ event ) ; unset ( $ hook_name ) ; } } unset ( $ cron_item ) ; unset ( $ time ) ; }
remove_wp_schedules_with_no_bb_schedule()
 Loop through each WP schedule and delete any schedules without corresponding BB schedules or corrupt entries.
remove_wp_schedules_with_no_bb_schedule () Loop through each WP schedule and delete any schedules without corresponding BB schedules or corrupt entries .
// Times // Loop through each schedule for this time // Methods // Full args for method // scheduled backup // BB schedule does not exist so delete this cron item. // Delete the scheduled cron. // No args, something wrong so delete it. // Delete the scheduled cron. // Upgrade hook name to 'backupbuddy_cron'. // Delete the scheduled cron. // BB schedule exists so recreate. // Remove. // Remove. // Remove. // End foreach. // End foreach. // End if is_numeric. // End foreach.