Making WordPress.org


Ignore:
Timestamp:
03/18/2021 08:44:59 PM (3 years ago)
Author:
coffee2code
Message:

Handbooks, Import: Change get_cron_interval() to optionally allow it to return information about the cron interval rather than the cron interval label itself.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/inc/importer.php

    r10815 r10835  
    134134     * Returns the handbook's cron interval schedule.
    135135     *
    136      * @return string
    137      */
    138     public function get_cron_interval() {
     136     * @param string $as_string Return the interval as a label? True if a cron
     137     *                          interval should be returned as string or false
     138     *                          to return array of interval's data. Default true.
     139     * @return string|array
     140     */
     141    public function get_cron_interval( $as_string = true ) {
    139142        $cron_intervals = wp_get_schedules();
    140143        $default = 'hourly';
     
    142145        $cron_interval = $this->handbook->get_config()['cron_interval'] ?: $default;
    143146
    144         return empty( $cron_intervals[ $cron_interval ] ) ? $default : $cron_interval;
     147        $cron_label = empty( $cron_intervals[ $cron_interval ] ) ? $default : $cron_interval;
     148
     149        return $as_string ? $cron_label : ( $cron_intervals[ $cron_label ] ?? [] );
    145150    }
    146151
Note: See TracChangeset for help on using the changeset viewer.