Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 17 additions & 0 deletions includes/admin/feedzy-rss-feeds-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3132,4 +3132,21 @@ public function validate_feed() {
);
}
}

/**
* Add slugs for internal cron schedules.
*
* @param string[] $cron_slugs The cron slugs to be modified.
* @return string[]
*/
public function internal_cron_schedule_slugs( $cron_slugs ) {
$wp_standard_schedules = array(
'hourly',
'twicedaily',
'daily',
'weekly',
);

return array_merge( $wp_standard_schedules, $cron_slugs );
}
}
1 change: 1 addition & 0 deletions includes/feedzy-rss-feeds.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ private function define_admin_hooks() {
self::$instance->loader->add_action( 'init', self::$instance->admin, 'register_settings' );
self::$instance->loader->add_action( 'wp_ajax_feedzy_validate_feed', self::$instance->admin, 'validate_feed' );
self::$instance->loader->add_action( 'wp_ajax_feedzy_dashboard_subscribe', self::$instance->admin, 'feedzy_dashboard_subscribe' );
self::$instance->loader->add_filter( 'feedzy_internal_cron_schedule_slugs', self::$instance->admin, 'internal_cron_schedule_slugs', 10, 1 );

// do not load this with the loader as this will need a corresponding remove_filter also.
add_filter( 'update_post_metadata', array( self::$instance->admin, 'validate_category_feeds' ), 10, 5 );
Expand Down
22 changes: 18 additions & 4 deletions includes/layouts/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ class="btn btn-outline-primary<?php echo 0 === $index ? ' disabled' : ''; ?>" <?
<div class="fz-form-row">
<div class="fz-form-col-6">
<div class="fz-form-group">
<label class="form-label"><?php esc_html_e( 'Schedule', 'feedzy-rss-feeds' ); ?></label>
<label class="form-label"><?php esc_html_e( 'Default Importing Schedule', 'feedzy-rss-feeds' ); ?></label>
<?php
$save_schedule = ! empty( $settings['general']['fz_cron_schedule'] ) ? $settings['general']['fz_cron_schedule'] : '';

Expand All @@ -268,20 +268,34 @@ class="btn btn-outline-primary<?php echo 0 === $index ? ' disabled' : ''; ?>" <?
unset( $schedules['hourly'] );
$schedules = array_merge( array( 'hourly' => $hourly ), $schedules );
}
$internal_cron_schedules = apply_filters( 'feedzy_internal_cron_schedule_slugs', array() );
?>
<select id="fz-event-schedule" class="form-control fz-select-control" name="fz_cron_schedule">
<?php
$duplicate_schedule = array();
foreach ( $schedules as $slug => $schedule ) :
if ( empty( $schedule['interval'] ) || in_array( $schedule['interval'], $duplicate_schedule, true ) ) {
if (
empty( $schedule['interval'] ) ||
in_array( $schedule['interval'], $duplicate_schedule, true )
) {
continue;
}
$duplicate_schedule[] = $schedule['interval'];
$display_text = $schedule['display'];

if ( ! in_array( $slug, $internal_cron_schedules, true ) ) {
// translators: (externally created) is used to indicate that the schedule is created by another plugin or manually.
$display_text .= ' (' . esc_html__( 'externally created', 'feedzy-rss-feeds' ) . ')';
}
?>
<option value="<?php echo esc_attr( $slug ); ?>"<?php selected( $save_schedule, $slug ); ?>><?php echo esc_html( $schedule['display'] ); ?> (<?php echo esc_html( $slug ); ?>)</option>
<option
value="<?php echo esc_attr( $slug ); ?>"
<?php selected( $save_schedule, $slug ); ?>
>
<?php echo esc_html( $display_text ); ?>
</option>
<?php endforeach; ?>
</select>
<div class="help-text pt-8"><?php esc_html_e( 'How often Feedzy will run the import.', 'feedzy-rss-feeds' ); ?></div>
</div>
</div>
</div>
Expand Down
14 changes: 11 additions & 3 deletions includes/views/import-metabox-edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -672,20 +672,28 @@ class="fz-switch-toggle" type="checkbox" value="yes"
unset( $schedules['daily'] );
$schedules = array_merge( array( 'daily' => $daily ), $schedules );
}
$duplicate_schedule = array();
$internal_cron_schedules = apply_filters( 'feedzy_internal_cron_schedule_slugs', array() );
$duplicate_schedule = array();
foreach ( $schedules as $slug => $schedule ) :
if ( empty( $schedule['interval'] ) || in_array( $schedule['interval'], $duplicate_schedule, true ) ) {
continue;
}
$duplicate_schedule[] = $schedule['interval'];
$display_text = $schedule['display'];

if ( ! in_array( $slug, $internal_cron_schedules, true ) ) {
$display_text .= ' (' . esc_html__( 'externally created)', 'feedzy-rss-feeds' ) . ')';
}
?>
<option data-slug="<?php echo esc_attr( $slug ); ?>" value="<?php echo esc_attr( $slug ); ?>"<?php selected( $save_schedule, $slug ); ?>
>
<?php echo esc_html( $schedule['display'] ); ?>
<?php echo esc_html( $display_text ); ?>
</option>
<?php endforeach; ?>
</select>
<div class="help-text pt-8"><?php esc_html_e( 'Choose how often Feedzy should import new items from your feeds.', 'feedzy-rss-feeds' ); ?></div>
<div class="help-text pt-8">
<?php esc_html_e( 'Choose how often Feedzy should import new items from your feeds.', 'feedzy-rss-feeds' ); ?>
</div>
</div>
</div>
</div>
Expand Down
Loading