Skip to content

Commit dcd04f8

Browse files
fix: external label for schedules option
1 parent a5a1ef8 commit dcd04f8

4 files changed

Lines changed: 34 additions & 12 deletions

File tree

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2910,4 +2910,21 @@ public function validate_feed() {
29102910
);
29112911
}
29122912
}
2913+
2914+
/**
2915+
* Add slugs for internal cron schedules.
2916+
*
2917+
* @param string[] $cron_slugs The cron slugs to be modified.
2918+
* @return string[]
2919+
*/
2920+
public function internal_cron_schedule_slugs( $cron_slugs ) {
2921+
$wp_standard_schedules = array(
2922+
'hourly',
2923+
'twicedaily',
2924+
'daily',
2925+
'weekly',
2926+
);
2927+
2928+
return array_merge( $wp_standard_schedules, $cron_slugs );
2929+
}
29132930
}

includes/feedzy-rss-feeds.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ private function define_admin_hooks() {
204204
self::$instance->loader->add_action( 'current_screen', self::$instance->admin, 'handle_legacy' );
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' );
207+
self::$instance->loader->add_filter( 'feedzy_internal_cron_schedule_slugs', self::$instance->admin, 'internal_cron_schedule_slugs', 10, 1 );
207208

208209
// do not load this with the loader as this will need a corresponding remove_filter also.
209210
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)