pre_schedule_event

過濾鉤子
apply_filters( 'pre_schedule_event', null, $event, $wp_error )
引數
  • (null|bool|WP_Error) $pre Value to return instead. Default null to continue adding the event.
    Required:
  • (stdClass) $event { An object containing an event's data. @type string $hook Action hook to execute when the event is run. @type int $timestamp Unix timestamp (UTC) for when to next run the event. @type string|false $schedule How often the event should subsequently recur. @type array $args Array containing each separate argument to pass to the hook's callback function. @type int $interval The interval time in seconds for the schedule. Only present for recurring events. }
    Required:
  • (bool) $wp_error Whether to return a WP_Error on failure.
    Required:
定義位置
相關勾子
pre_unschedule_eventpre_reschedule_eventpre_get_scheduled_eventschedule_eventcron_unschedule_event_error
相關方法
wp_reschedule_eventwp_schedule_eventwp_unschedule_eventwp_get_scheduled_eventwp_scheduled_deletewp_schedule_single_event
引入
5.7.0
棄用
-

pre_schedule_event。這個過濾器是用來過濾傳遞給wp_schedule_event函式的引數的。這允許開發者修改傳遞給函式的引數,例如改變預定事件的重複性。

篩選器,用於預處理或劫持排程一個事件。

返回一個非空值將短路將事件新增到cron陣列中,導致該函式返回過濾後的值。

單一事件和迴圈事件都通過這個過濾器;單一事件的 $event->schedule 為false,而迴圈事件則被設定為來自wp_get_schedules()的recurrence。重複發生的事件也有整數的重複發生間隔,設定為$event->interval

對於取代wp-cron的外掛,建議你檢查十分鐘內是否有相同的事件,並應用{@see ‘schedule_event’}過濾器來檢查其他外掛是否在排程前禁止了該事件。

如果事件被安排了,返回true;如果沒有,返回false或WP_Error。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$pre = apply_filters( 'pre_schedule_event', null, $event, $wp_error );
$pre = apply_filters( 'pre_schedule_event', null, $event, $wp_error );
$pre = apply_filters( 'pre_schedule_event', null, $event, $wp_error );

常見問題

FAQs
檢視更多 >