Skip to content

Commit 1f41cd5

Browse files
authored
release: fixes
- Fix inconsistency with import scheduling. - Remove the setting for initial import time to simplify the UX
2 parents 098e52f + d8b11fa commit 1f41cd5

File tree

7 files changed

+11
-80
lines changed

7 files changed

+11
-80
lines changed

includes/admin/feedzy-rss-feeds-admin.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,9 +1051,7 @@ private function save_settings() {
10511051
$settings['general']['disable-default-style'] = isset( $_POST['disable-default-style'] ) ? (int) filter_input( INPUT_POST, 'disable-default-style', FILTER_SANITIZE_NUMBER_INT ) : '';
10521052
$settings['general']['feedzy-delete-days'] = isset( $_POST['feedzy-delete-days'] ) ? (int) filter_input( INPUT_POST, 'feedzy-delete-days', FILTER_SANITIZE_NUMBER_INT ) : '';
10531053
$settings['general']['default-thumbnail-id'] = isset( $_POST['default-thumbnail-id'] ) ? (int) filter_input( INPUT_POST, 'default-thumbnail-id', FILTER_SANITIZE_NUMBER_INT ) : 0;
1054-
$settings['general']['fz_cron_execution'] = isset( $_POST['fz_cron_execution'] ) ? sanitize_text_field( wp_unslash( $_POST['fz_cron_execution'] ) ) : '';
10551054
$settings['general']['fz_cron_schedule'] = isset( $_POST['fz_cron_schedule'] ) ? filter_input( INPUT_POST, 'fz_cron_schedule', FILTER_UNSAFE_RAW ) : 'hourly';
1056-
$settings['general']['fz_execution_offset'] = isset( $_POST['fz_execution_offset'] ) ? filter_input( INPUT_POST, 'fz_execution_offset', FILTER_UNSAFE_RAW ) : '';
10571055
$settings['general']['auto-categories'] = $auto_categories;
10581056
$settings['general']['feedzy-telemetry'] = isset( $_POST['feedzy-telemetry'] ) ? (int) filter_input( INPUT_POST, 'feedzy-telemetry', FILTER_SANITIZE_NUMBER_INT ) : '';
10591057
$settings['general']['feedzy-delete-media'] = isset( $_POST['feedzy-delete-media'] ) ? (int) filter_input( INPUT_POST, 'feedzy-delete-media', FILTER_SANITIZE_NUMBER_INT ) : '';

includes/admin/feedzy-rss-feeds-import.php

Lines changed: 6 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -459,18 +459,12 @@ public function feedzy_import_feed_options() {
459459
}
460460
}
461461
$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'] : '',
464462
'fz_cron_schedule' => ! empty( $this->free_settings['general']['fz_cron_schedule'] ) ? $this->free_settings['general']['fz_cron_schedule'] : '',
465463
);
466464

467-
$fz_cron_execution = get_post_meta( $post->ID, 'fz_cron_execution', true );
468465
$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 ) ) {
471467
$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;
474468
}
475469

476470
$post_status = $post->post_status;
@@ -544,17 +538,12 @@ public function save_feedzy_import_feed_meta( $post_id, $post ) {
544538
}
545539
}
546540

547-
$global_cron_execution = ! empty( $this->free_settings['general']['fz_cron_execution'] ) ? $this->free_settings['general']['fz_cron_execution'] : '';
548541
$global_cron_schedule = ! empty( $this->free_settings['general']['fz_cron_schedule'] ) ? $this->free_settings['general']['fz_cron_schedule'] : '';
549542
if (
550-
(
551-
empty( $data_meta['fz_cron_execution'] ) || $global_cron_schedule === $data_meta['fz_cron_execution']
552-
)
553-
&&
554543
empty( $data_meta['fz_cron_schedule'] ) || $global_cron_schedule === $data_meta['fz_cron_schedule']
555544
) {
556545
// 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'] );
558547
}
559548

560549
$custom_fields_keys = array();
@@ -1361,10 +1350,6 @@ public function run_cron( $max = 100, $job_id = 0 ) {
13611350
// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
13621351
'meta_query' => array(
13631352
'relation' => 'AND',
1364-
array(
1365-
'key' => 'fz_cron_execution',
1366-
'compare' => 'NOT EXISTS',
1367-
),
13681353
array(
13691354
'key' => 'fz_cron_schedule',
13701355
'compare' => 'NOT EXISTS',
@@ -2467,19 +2452,15 @@ private function try_save_featured_image( $img_source_url, $post_id, $post_title
24672452
* @access public
24682453
*/
24692454
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();
24712455
$schedule = ! empty( $this->free_settings['general']['fz_cron_schedule'] ) ? $this->free_settings['general']['fz_cron_schedule'] : ( feedzy_is_legacyv5() ? 'hourly' : 'daily' );
24722456
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'] )) {
24772458
$schedule = sanitize_text_field( wp_unslash( $_POST['fz_cron_schedule'] ) );
24782459
Feedzy_Rss_Feeds_Util_Scheduler::clear_scheduled_hook( 'feedzy_cron' );
24792460
}
24802461
}
24812462
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' );
24832464
}
24842465

24852466
// Register import jobs based cron jobs.
@@ -2492,10 +2473,6 @@ public function add_cron() {
24922473
// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
24932474
'meta_query' => array(
24942475
'relation' => 'AND',
2495-
array(
2496-
'key' => 'fz_cron_execution',
2497-
'compare' => 'EXISTS',
2498-
),
24992476
array(
25002477
'key' => 'fz_cron_schedule',
25012478
'compare' => 'EXISTS',
@@ -2506,32 +2483,14 @@ public function add_cron() {
25062483

25072484
if ( ! empty( $import_job_crons ) ) {
25082485
foreach ( $import_job_crons as $job_id ) {
2509-
$fz_cron_execution = get_post_meta( $job_id, 'fz_cron_execution', true );
25102486
$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-
25142487
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 ) );
25162489
}
25172490
}
25182491
}
25192492
}
25202493

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-
}
25352494

25362495
/**
25372496
* Checks if WP Cron is enabled and if not, shows a notice.
@@ -2979,7 +2938,7 @@ public function add_import_actions( $actions, $post ) {
29792938
) : '#',
29802939
feedzy_is_pro() ? 'fz-export-btn' : 'fz-export-btn-pro',
29812940
! 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>' : '' )
29832942
);
29842943

29852944
$actions['export'] = $export_action;

includes/layouts/settings.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -231,17 +231,6 @@ class="<?php echo $_tab === $active_tab ? esc_attr( 'active' ) : ''; ?>"><?php e
231231
</div>
232232
<div class="form-block">
233233
<div class="fz-form-row">
234-
<div class="fz-form-col-6">
235-
<div class="fz-form-group">
236-
<label class="form-label"><?php esc_html_e( 'First cron execution time', 'feedzy-rss-feeds' ); ?></label>
237-
<input type="hidden" name="fz_execution_offset" id="fz-execution-offset" value="<?php echo ! empty( $settings['general']['fz_execution_offset'] ) ? esc_attr( $settings['general']['fz_execution_offset'] ) : ''; ?>">
238-
<input type="datetime-local" id="fz-event-execution" name="fz_cron_execution" class="form-control" value="<?php echo ! empty( $settings['general']['fz_cron_execution'] ) ? esc_attr( $settings['general']['fz_cron_execution'] ) : ''; ?>">
239-
<div class="help-text pt-8">
240-
<?php esc_html_e( 'When past date will be provided, event will be executed in the next queue.', 'feedzy-rss-feeds' ); ?>
241-
<a href="<?php echo esc_url( 'https://docs.themeisle.com/article/1820-how-to-set-scheduler-for-import-cron-jobs-in-feedzy' ); ?>" target="_blank"><?php esc_html_e( 'Learn More', 'feedzy-rss-feeds' ); ?></a>
242-
</div>
243-
</div>
244-
</div>
245234
<div class="fz-form-col-6">
246235
<div class="fz-form-group">
247236
<label class="form-label"><?php esc_html_e( 'Schedule', 'feedzy-rss-feeds' ); ?></label>
@@ -267,7 +256,7 @@ class="<?php echo $_tab === $active_tab ? esc_attr( 'active' ) : ''; ?>"><?php e
267256
<option value="<?php echo esc_attr( $slug ); ?>"<?php selected( $save_schedule, $slug ); ?>><?php echo esc_html( $schedule['display'] ); ?> (<?php echo esc_html( $slug ); ?>)</option>
268257
<?php endforeach; ?>
269258
</select>
270-
<div class="help-text pt-8"><?php esc_html_e( 'After first execution repeat.', 'feedzy-rss-feeds' ); ?></div>
259+
<div class="help-text pt-8"><?php esc_html_e( 'How often Feedzy will run the import.', 'feedzy-rss-feeds' ); ?></div>
271260
</div>
272261
</div>
273262
</div>

includes/views/import-metabox-edit.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -748,21 +748,9 @@ class="fz-switch-toggle" type="checkbox" value="yes"
748748
</div>
749749
<div class="fz-right">
750750
<div class="fz-form-row">
751+
751752
<div class="fz-form-col-6">
752753
<div class="fz-form-group">
753-
<label class="form-label"><?php esc_html_e( 'First date/time to run the import', 'feedzy-rss-feeds' ); ?></label>
754-
<?php if ( feedzy_is_pro() ) : ?>
755-
<input type="hidden" name="feedzy_meta_data[fz_execution_offset]" id="fz-execution-offset" value="<?php echo ! empty( $import_schedule['fz_execution_offset'] ) ? esc_attr( $import_schedule['fz_execution_offset'] ) : ''; ?>">
756-
<?php endif; ?>
757-
<input type="datetime-local" id="fz-event-execution" name="feedzy_meta_data[fz_cron_execution]" class="form-control" value="<?php echo ! empty( $import_schedule['fz_cron_execution'] ) ? esc_attr( $import_schedule['fz_cron_execution'] ) : ''; ?>"<?php disabled( true, ! feedzy_is_pro() ); ?>>
758-
<div class="help-text pt-8">
759-
<?php esc_html_e( 'Set the date and time when Feedzy should first run the import.', 'feedzy-rss-feeds' ); ?>
760-
</div>
761-
</div>
762-
</div>
763-
<div class="fz-form-col-6">
764-
<div class="fz-form-group">
765-
<label class="form-label"><?php esc_html_e( 'Schedule', 'feedzy-rss-feeds' ); ?></label>
766754
<select id="fz-event-schedule" class="form-control fz-select-control" name="feedzy_meta_data[fz_cron_schedule]"<?php disabled( true, ! feedzy_is_pro() ); ?>>
767755
<?php
768756
$save_schedule = ! empty( $import_schedule['fz_cron_schedule'] ) ? $import_schedule['fz_cron_schedule'] : '';

js/feedzy-setting.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,6 @@ jQuery(function ($) {
9898
}
9999
});
100100

101-
// Select cron execution time.
102-
$(document).on('change', '#fz-event-execution', function () {
103-
$('#fz-execution-offset').val(new Date().getTimezoneOffset() / 60);
104-
});
105101

106102
// License key.
107103
jQuery('.fz-license-section #license_key').on('input', function () {

tests/e2e/specs/loop.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ test.describe('Feedzy Loop', () => {
3535
await page.getByLabel('Add title').click();
3636
await page.keyboard.type(POST_TITLE);
3737

38-
await page.getByLabel('Toggle block inserter').click();
38+
await page.getByLabel('Add block').click();
3939

4040
await page.getByPlaceholder('Search').click();
4141
await page.keyboard.type('Feedzy Loop');

tests/e2e/specs/upsell.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ test.describe( 'Upsell', () => {
3535
let upgradeAlert = page.locator('#feedzy-import-form a[href*="utm_campaign=fallback-image"]');
3636
await expect( upgradeAlert ).toBeVisible();
3737

38-
await page.locator('.fz-form-group:has( #fz-event-execution )').hover({ force: true });
38+
await page.locator('.fz-form-group:has( #fz-event-schedule )').scrollIntoViewIfNeeded()
39+
await page.locator('.fz-form-group:has( #fz-event-schedule )').hover({ force: true });
3940
upgradeAlert = page.locator('#feedzy-import-form a[href*="utm_campaign=schedule-import-job"]');
4041
await expect( upgradeAlert ).toBeVisible();
4142

0 commit comments

Comments
 (0)