Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed scheduler time issue #1047

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions includes/admin/feedzy-rss-feeds-import.php
Original file line number Diff line number Diff line change
Expand Up @@ -802,9 +802,9 @@ public function manage_feedzy_import_columns( $column, $post_id ) {

break;
case 'feedzy-next_run':
$next = Feedzy_Rss_Feeds_Util_Scheduler::is_scheduled( 'feedzy_cron', array( 100, $post_id ) );
$next = Feedzy_Rss_Feeds_Util_Scheduler::get_next( 'feedzy_cron', array( 100, $post_id ) );
if ( ! $next ) {
$next = Feedzy_Rss_Feeds_Util_Scheduler::is_scheduled( 'feedzy_cron' );
$next = Feedzy_Rss_Feeds_Util_Scheduler::get_next( 'feedzy_cron' );
}
if ( $next ) {
echo wp_kses_post( human_time_diff( $next, time() ) );
Expand Down
20 changes: 20 additions & 0 deletions includes/util/feedzy-rss-feeds-util-scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,24 @@ public static function schedule_event( $time, $recurrence, $hook, $args = array(

return wp_schedule_event( $time, $recurrence, $hook, $args );
}

/**
* Get the date and time for the next scheduled occurrence of an action with a given hook
* (an optionally that matches certain args and group), if any.
*
* @param string $hook The hook that the job will trigger.
* @param array $args Filter to a hook with matching args that will be passed to the job when it runs.
* @param string $group Filter to only actions assigned to a specific group.
* @return int|null The date and time for the next occurrence, or null if there is no pending, scheduled action for the given hook.
*/
public static function get_next( $hook, $args = null, $group = '' ) {
if ( function_exists( 'as_next_scheduled_action' ) ) {
$next_timestamp = as_next_scheduled_action( $hook, $args, $group );
if ( is_numeric( $next_timestamp ) ) {
return $next_timestamp;
}
}

return wp_next_scheduled( $hook, $args );
}
}
Loading