插件开发文档

💡 云策文档标注

概述

本文档介绍了测试和管理 WordPress 中 WP-Cron 的多种方法,包括使用 WP-CLI 命令、插件以及核心函数来查看和操作定时任务。

关键要点

  • 使用 WP-CLI 命令如 wp cron event list 和 wp cron event run {job name} 来测试和管理 cron 任务。
  • 通过 WordPress.org 插件目录中的插件来查看、编辑和控制站点的定时事件和可用计划。
  • 利用 _get_cron_array() 函数获取所有当前已安排的 cron 事件的原始数组。
  • 使用 wp_get_schedules() 函数获取可用事件重复计划的原始数组。

📄 原文内容

WP-CLI

Cron jobs can be tested using WP-CLI. It offers commands like wp cron event list and wp cron event run {job name}. Check the documentation for more details.

WP-Cron Management Plugins

Several plugins are available on the WordPress.org Plugin Directory for viewing, editing, and controlling the scheduled cron events and available schedules on your site.

_get_cron_array()

The _get_cron_array() function returns an array of all currently scheduled cron events. Use this function if you need to inspect the raw list of events.

wp_get_schedules()

The wp_get_schedules() function returns an array of available event recurrence schedules. Use this function if you need to inspect the raw list of available schedules.