' . esc_html( $option_title ) . "\n"; } echo '\n"; } /** * Gets a sorted (according to interval) list of the cron schedules */ function nsp_get_schedules() { $schedules = wp_get_schedules(); uasort( $schedules, function ( $a, $b ) { return $a['interval'] - $b['interval']; } ); return $schedules; } /** * Calculate interval // took from wp-control * added by cHab * * @param int $since from when. */ function nsp_interval( $since ) { // array of time period chunks. $chunks = array( // translators: placeholders ok. array( 60 * 60 * 24 * 365, _n_noop( '%s year', '%s years', 'newstatpress' ) ), // translators: placeholders ok. array( 60 * 60 * 24 * 30, _n_noop( '%s month', '%s months', 'newstatpress' ) ), // translators: placeholders ok. array( 60 * 60 * 24 * 7, _n_noop( '%s week', '%s weeks', 'newstatpress' ) ), // translators: placeholders ok. array( 60 * 60 * 24, _n_noop( '%s day', '%s days', 'newstatpress' ) ), // translators: placeholders ok. array( 60 * 60, _n_noop( '%s hour', '%s hours', 'newstatpress' ) ), // translators: placeholders ok. array( 60, _n_noop( '%s minute', '%s minutes', 'newstatpress' ) ), // translators: placeholders ok. array( 1, _n_noop( '%s second', '%s seconds', 'newstatpress' ) ), ); if ( $since <= 0 ) { return __( 'now', 'newstatpress' ); } // we only want to output two chunks of time here, eg: // x years, xx months // x days, xx hours // so there's only two bits of calculation below:. // step one: the first chunk. for ( $i = 0, $j = count( $chunks ); $i < $j; $i++ ) { $seconds = $chunks[ $i ][0]; $name = $chunks[ $i ][1]; // finding the biggest chunk (if the chunk fits, break). $count = floor( $since / $seconds ); if ( 0 !== $count ) { break; } } // set output var. $output = sprintf( translate_nooped_plural( $name, $count, 'newstatpress' ), $count ); // step two: the second chunk. if ( $i + 1 < $j ) { $seconds2 = $chunks[ $i + 1 ][0]; $name2 = $chunks[ $i + 1 ][1]; $count2 = floor( ( $since - ( $seconds * $count ) ) ); if ( ( $count2 / $seconds2 ) !== 0 ) { // add to output var. $output .= ' ' . sprintf( translate_nooped_plural( $name2, $count2, 'newstatpress' ), $count2 ); } } return $output; } /** * Print a dropdown filled with the possible schedules, including non-repeating. * added by cHab * * @param boolean $current The currently selected schedule. */ function nsp_print_schedules( $current ) { global $nsp_option_vars; $schedules = nsp_get_schedules(); ?> " . esc_html( $option_title ) . "\n"; echo "\n"; ?> \n" - esc_html( $option_title ) . "\n\n"; } /** * Print a checked row * added by cHab * * @param string $option_title the title for options. * @param string $option_var the variables for options. */ function nsp_print_checked( $option_title, $option_var ) { echo "\n' . esc_html( $option_title ) . "\n\n"; } /** * Print a text area * added by chab * * @param string $option_title the title for options. * @param string $option_var the variables for options. * @param string $option_description the descriotion for options. */ function nsp_print_textaera( $option_title, $option_var, $option_description ) { echo "\n

\n"; echo '

' . esc_html( $option_description ) . "

\n"; echo "