@@ -459,18 +459,12 @@ public function feedzy_import_feed_options() {
459
459
}
460
460
}
461
461
$ import_schedule = array (
462
- 'fz_execution_offset ' => ! empty ( $ this ->free_settings ['general ' ]['fz_execution_offset ' ] ) ? $ this ->free_settings ['general ' ]['fz_execution_offset ' ] : '' ,
463
- 'fz_cron_execution ' => ! empty ( $ this ->free_settings ['general ' ]['fz_cron_execution ' ] ) ? $ this ->free_settings ['general ' ]['fz_cron_execution ' ] : '' ,
464
462
'fz_cron_schedule ' => ! empty ( $ this ->free_settings ['general ' ]['fz_cron_schedule ' ] ) ? $ this ->free_settings ['general ' ]['fz_cron_schedule ' ] : '' ,
465
463
);
466
464
467
- $ fz_cron_execution = get_post_meta ( $ post ->ID , 'fz_cron_execution ' , true );
468
465
$ fz_cron_schedule = get_post_meta ( $ post ->ID , 'fz_cron_schedule ' , true );
469
- $ fz_execution_offset = get_post_meta ( $ post ->ID , 'fz_execution_offset ' , true );
470
- if ( ! empty ( $ fz_cron_schedule ) && ! empty ( $ fz_cron_execution ) ) {
466
+ if ( ! empty ( $ fz_cron_schedule ) ) {
471
467
$ import_schedule ['fz_cron_schedule ' ] = $ fz_cron_schedule ;
472
- $ import_schedule ['fz_execution_offset ' ] = $ fz_execution_offset ;
473
- $ import_schedule ['fz_cron_execution ' ] = $ fz_cron_execution ;
474
468
}
475
469
476
470
$ post_status = $ post ->post_status ;
@@ -544,17 +538,12 @@ public function save_feedzy_import_feed_meta( $post_id, $post ) {
544
538
}
545
539
}
546
540
547
- $ global_cron_execution = ! empty ( $ this ->free_settings ['general ' ]['fz_cron_execution ' ] ) ? $ this ->free_settings ['general ' ]['fz_cron_execution ' ] : '' ;
548
541
$ global_cron_schedule = ! empty ( $ this ->free_settings ['general ' ]['fz_cron_schedule ' ] ) ? $ this ->free_settings ['general ' ]['fz_cron_schedule ' ] : '' ;
549
542
if (
550
- (
551
- empty ( $ data_meta ['fz_cron_execution ' ] ) || $ global_cron_schedule === $ data_meta ['fz_cron_execution ' ]
552
- )
553
- &&
554
543
empty ( $ data_meta ['fz_cron_schedule ' ] ) || $ global_cron_schedule === $ data_meta ['fz_cron_schedule ' ]
555
544
) {
556
545
// Remove scheduled cron settings if they are equal to the global settings.
557
- unset( $ data_meta ['fz_cron_execution ' ], $ data_meta [ ' fz_cron_schedule ' ], $ data_meta [ ' fz_execution_offset ' ] );
546
+ unset( $ data_meta ['fz_cron_schedule ' ] );
558
547
}
559
548
560
549
$ custom_fields_keys = array ();
@@ -1361,10 +1350,6 @@ public function run_cron( $max = 100, $job_id = 0 ) {
1361
1350
// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
1362
1351
'meta_query ' => array (
1363
1352
'relation ' => 'AND ' ,
1364
- array (
1365
- 'key ' => 'fz_cron_execution ' ,
1366
- 'compare ' => 'NOT EXISTS ' ,
1367
- ),
1368
1353
array (
1369
1354
'key ' => 'fz_cron_schedule ' ,
1370
1355
'compare ' => 'NOT EXISTS ' ,
@@ -2467,19 +2452,15 @@ private function try_save_featured_image( $img_source_url, $post_id, $post_title
2467
2452
* @access public
2468
2453
*/
2469
2454
public function add_cron () {
2470
- $ time = ! empty ( $ this ->free_settings ['general ' ]['fz_cron_execution ' ] ) ? $ this ->get_cron_execution ( $ this ->free_settings ['general ' ]['fz_cron_execution ' ] ) : time ();
2471
2455
$ schedule = ! empty ( $ this ->free_settings ['general ' ]['fz_cron_schedule ' ] ) ? $ this ->free_settings ['general ' ]['fz_cron_schedule ' ] : ( feedzy_is_legacyv5 () ? 'hourly ' : 'daily ' );
2472
2456
if ( ( isset ( $ _POST ['nonce ' ] ) && isset ( $ _POST ['tab ' ] ) ) && ( wp_verify_nonce ( filter_input ( INPUT_POST , 'nonce ' , FILTER_UNSAFE_RAW ), filter_input ( INPUT_POST , 'tab ' , FILTER_UNSAFE_RAW ) ) ) ) {
2473
- if ( ! empty ( $ _POST ['fz_cron_execution ' ] ) && ! empty ( $ _POST ['fz_cron_schedule ' ] ) && ! empty ( $ _POST ['fz_execution_offset ' ] ) ) {
2474
- $ execution = sanitize_text_field ( wp_unslash ( $ _POST ['fz_cron_execution ' ] ) );
2475
- $ offset = sanitize_text_field ( wp_unslash ( $ _POST ['fz_execution_offset ' ] ) );
2476
- $ time = $ this ->get_cron_execution ( $ execution , $ offset );
2457
+ if ( ! empty ( $ _POST ['fz_cron_schedule ' ] )) {
2477
2458
$ schedule = sanitize_text_field ( wp_unslash ( $ _POST ['fz_cron_schedule ' ] ) );
2478
2459
Feedzy_Rss_Feeds_Util_Scheduler::clear_scheduled_hook ( 'feedzy_cron ' );
2479
2460
}
2480
2461
}
2481
2462
if ( false === Feedzy_Rss_Feeds_Util_Scheduler::is_scheduled ( 'feedzy_cron ' ) ) {
2482
- Feedzy_Rss_Feeds_Util_Scheduler::schedule_event ( $ time , $ schedule , 'feedzy_cron ' );
2463
+ Feedzy_Rss_Feeds_Util_Scheduler::schedule_event ( time () + 10 , $ schedule , 'feedzy_cron ' );
2483
2464
}
2484
2465
2485
2466
// Register import jobs based cron jobs.
@@ -2492,10 +2473,6 @@ public function add_cron() {
2492
2473
// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
2493
2474
'meta_query ' => array (
2494
2475
'relation ' => 'AND ' ,
2495
- array (
2496
- 'key ' => 'fz_cron_execution ' ,
2497
- 'compare ' => 'EXISTS ' ,
2498
- ),
2499
2476
array (
2500
2477
'key ' => 'fz_cron_schedule ' ,
2501
2478
'compare ' => 'EXISTS ' ,
@@ -2506,32 +2483,14 @@ public function add_cron() {
2506
2483
2507
2484
if ( ! empty ( $ import_job_crons ) ) {
2508
2485
foreach ( $ import_job_crons as $ job_id ) {
2509
- $ fz_cron_execution = get_post_meta ( $ job_id , 'fz_cron_execution ' , true );
2510
2486
$ fz_cron_schedule = get_post_meta ( $ job_id , 'fz_cron_schedule ' , true );
2511
- $ fz_execution_offset = get_post_meta ( $ job_id , 'fz_execution_offset ' , true );
2512
- $ time = $ this ->get_cron_execution ( $ fz_cron_execution , $ fz_execution_offset );
2513
-
2514
2487
if ( false === Feedzy_Rss_Feeds_Util_Scheduler::is_scheduled ( 'feedzy_cron ' , array ( 100 , $ job_id ) ) ) {
2515
- Feedzy_Rss_Feeds_Util_Scheduler::schedule_event ( $ time , $ fz_cron_schedule , 'feedzy_cron ' , array ( 100 , $ job_id ) );
2488
+ Feedzy_Rss_Feeds_Util_Scheduler::schedule_event ( time () + 10 , $ fz_cron_schedule , 'feedzy_cron ' , array ( 100 , $ job_id ) );
2516
2489
}
2517
2490
}
2518
2491
}
2519
2492
}
2520
2493
2521
- /**
2522
- * Get cron job execution.
2523
- *
2524
- * @param string $execution Execution time.
2525
- * @param int $offset Offset.
2526
- * @return int
2527
- */
2528
- public function get_cron_execution ( $ execution , $ offset = 0 ) {
2529
- if ( empty ( $ offset ) && ! empty ( $ this ->free_settings ['general ' ]['fz_execution_offset ' ] ) ) {
2530
- $ offset = $ this ->free_settings ['general ' ]['fz_execution_offset ' ];
2531
- }
2532
- $ execution = strtotime ( $ execution ) ? strtotime ( $ execution ) + ( HOUR_IN_SECONDS * (int ) $ offset ) : time () + ( HOUR_IN_SECONDS * (int ) $ offset );
2533
- return $ execution ;
2534
- }
2535
2494
2536
2495
/**
2537
2496
* Checks if WP Cron is enabled and if not, shows a notice.
@@ -2979,7 +2938,7 @@ public function add_import_actions( $actions, $post ) {
2979
2938
) : '# ' ,
2980
2939
feedzy_is_pro () ? 'fz-export-btn ' : 'fz-export-btn-pro ' ,
2981
2940
! feedzy_is_pro () ? 'opacity:0.5; ' : '' ,
2982
- ( ! feedzy_is_pro () ? ' <span style="font-size: 13px;line-height: 1.5em;width: 13px;height: 13px;" class="dashicons dashicons-lock"></span> ' : '' ) . esc_html__ ( ' Export ' , ' feedzy-rss-feeds ' )
2941
+ ( ! feedzy_is_pro () ? esc_html__ ( ' Export ' , ' feedzy-rss-feeds ' ) . ' <span style="font-size: 13px;line-height: 1.5em;width: 13px;height: 13px;" class="dashicons dashicons-lock"></span> ' : '' )
2983
2942
);
2984
2943
2985
2944
$ actions ['export ' ] = $ export_action ;
0 commit comments