Skip to content

Commit 183d31f

Browse files
fix: external label for schedules option
1 parent 5e1d8ba commit 183d31f

File tree

4 files changed

+34
-12
lines changed

4 files changed

+34
-12
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3132,4 +3132,21 @@ public function validate_feed() {
31323132
);
31333133
}
31343134
}
3135+
3136+
/**
3137+
* Add slugs for internal cron schedules.
3138+
*
3139+
* @param string[] $cron_slugs The cron slugs to be modified.
3140+
* @return string[]
3141+
*/
3142+
public function internal_cron_schedule_slugs( $cron_slugs ) {
3143+
$wp_standard_schedules = array(
3144+
'hourly',
3145+
'twicedaily',
3146+
'daily',
3147+
'weekly',
3148+
);
3149+
3150+
return array_merge( $wp_standard_schedules, $cron_slugs );
3151+
}
31353152
}

includes/feedzy-rss-feeds.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ private function define_admin_hooks() {
205205
self::$instance->loader->add_action( 'init', self::$instance->admin, 'register_settings' );
206206
self::$instance->loader->add_action( 'wp_ajax_feedzy_validate_feed', self::$instance->admin, 'validate_feed' );
207207
self::$instance->loader->add_action( 'wp_ajax_feedzy_dashboard_subscribe', self::$instance->admin, 'feedzy_dashboard_subscribe' );
208+
self::$instance->loader->add_filter( 'feedzy_internal_cron_schedule_slugs', self::$instance->admin, 'internal_cron_schedule_slugs', 10, 1 );
208209

209210
// do not load this with the loader as this will need a corresponding remove_filter also.
210211
add_filter( 'update_post_metadata', array( self::$instance->admin, 'validate_category_feeds' ), 10, 5 );

includes/layouts/settings.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,7 @@ class="btn btn-outline-primary<?php echo 0 === $index ? ' disabled' : ''; ?>" <?
268268
unset( $schedules['hourly'] );
269269
$schedules = array_merge( array( 'hourly' => $hourly ), $schedules );
270270
}
271-
$wp_standard_schedules = array(
272-
'hourly',
273-
'twicedaily',
274-
'daily',
275-
'weekly',
276-
);
271+
$internal_cron_schedules = apply_filters( 'feedzy_internal_cron_schedule_slugs', array() );
277272
?>
278273
<select id="fz-event-schedule" class="form-control fz-select-control" name="fz_cron_schedule">
279274
<?php
@@ -286,10 +281,11 @@ class="btn btn-outline-primary<?php echo 0 === $index ? ' disabled' : ''; ?>" <?
286281
continue;
287282
}
288283
$duplicate_schedule[] = $schedule['interval'];
289-
$display_text = esc_html( $schedule['display'] );
284+
$display_text = $schedule['display'];
290285

291-
if ( ! in_array( $slug, $wp_standard_schedules, true ) ) {
292-
$display_text .= ' ' . esc_html__( '(externally created)', 'feedzy-rss-feeds' );
286+
if ( ! in_array( $slug, $internal_cron_schedules, true ) ) {
287+
// translators: (externally created) is used to indicate that the schedule is created by another plugin or manually.
288+
$display_text .= ' (' . esc_html__( 'externally created', 'feedzy-rss-feeds' ) . ')';
293289
}
294290
?>
295291
<option

includes/views/import-metabox-edit.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,20 +672,28 @@ class="fz-switch-toggle" type="checkbox" value="yes"
672672
unset( $schedules['daily'] );
673673
$schedules = array_merge( array( 'daily' => $daily ), $schedules );
674674
}
675-
$duplicate_schedule = array();
675+
$internal_cron_schedules = apply_filters( 'feedzy_internal_cron_schedule_slugs', array() );
676+
$duplicate_schedule = array();
676677
foreach ( $schedules as $slug => $schedule ) :
677678
if ( empty( $schedule['interval'] ) || in_array( $schedule['interval'], $duplicate_schedule, true ) ) {
678679
continue;
679680
}
680681
$duplicate_schedule[] = $schedule['interval'];
682+
$display_text = $schedule['display'];
683+
684+
if ( ! in_array( $slug, $internal_cron_schedules, true ) ) {
685+
$display_text .= ' (' . esc_html__( 'externally created)', 'feedzy-rss-feeds' ) . ')';
686+
}
681687
?>
682688
<option data-slug="<?php echo esc_attr( $slug ); ?>" value="<?php echo esc_attr( $slug ); ?>"<?php selected( $save_schedule, $slug ); ?>
683689
>
684-
<?php echo esc_html( $schedule['display'] ); ?>
690+
<?php echo esc_html( $display_text ); ?>
685691
</option>
686692
<?php endforeach; ?>
687693
</select>
688-
<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>
694+
<div class="help-text pt-8">
695+
<?php esc_html_e( 'Choose how often Feedzy should import new items from your feeds.', 'feedzy-rss-feeds' ); ?>
696+
</div>
689697
</div>
690698
</div>
691699
</div>

0 commit comments

Comments
 (0)