wp_get_schedule

函式
wp_get_schedule ( $hook, $args = array() )
引數
  • (string) $hook Action hook to identify the event.
    Required:
  • (array) $args Optional. Arguments passed to the event's callback function. Default empty array.
    Required:
    Default: array()
返回值
  • (string|false) Schedule name on success, false if no schedule.
相關
  • wp_get_schedules()
定義位置
相關方法
wp_get_scheduleswp_next_scheduledwp_get_scheduled_eventwp_get_themewp_reschedule_event
引入
2.1.0
棄用
-

wp_get_schedule: 這個函式用來檢索特定鉤子的cron時間表。它將鉤子的名稱作為引數,並返回時間表。

檢索一個事件的重複發生時間表。

function wp_get_schedule( $hook, $args = array() ) {
	$schedule = false;
	$event    = wp_get_scheduled_event( $hook, $args );

	if ( $event ) {
		$schedule = $event->schedule;
	}

	/**
	 * Filters the schedule for a hook.
	 *
	 * @since 5.1.0
	 *
	 * @param string|false $schedule Schedule for the hook. False if not found.
	 * @param string       $hook     Action hook to execute when cron is run.
	 * @param array        $args     Arguments to pass to the hook's callback function.
	 */
	return apply_filters( 'get_schedule', $schedule, $hook, $args );
}

常見問題

FAQs
檢視更多 >