diff --git a/wp-includes/cron.php b/wp-includes/cron.php
index 65c5d8573a..50a95fde55 100644
--- a/wp-includes/cron.php
+++ b/wp-includes/cron.php
@@ -1,5 +1,24 @@
0.01, 'blocking' => false));
}
+/**
+ * Run scheduled callbacks or spawn cron for all scheduled events.
+ *
+ * @since 2.1.0
+ *
+ * @return null When doesn't need to run Cron.
+ */
function wp_cron() {
// Prevent infinite loops caused by lack of wp-cron.php
if ( strpos($_SERVER['REQUEST_URI'], '/wp-cron.php') !== false )
@@ -119,6 +200,36 @@ function wp_cron() {
}
}
+/**
+ * Retrieve supported and filtered Cron recurrences.
+ *
+ * The supported recurrences are 'hourly' and 'daily'. A plugin may add more by
+ * hooking into the 'cron_schedules' filter. The filter accepts an array of
+ * arrays. The outer array has a key that is the name of the schedule or for
+ * example 'weekly'. The value is an array with two keys, one is 'interval' and
+ * the other is 'display'.
+ *
+ * The 'interval' is a number in seconds of when the cron job should run. So for
+ * 'hourly', the time is 3600 or 60*60. For weekly, the value would be
+ * 60*60*24*7 or 604800. The value of 'interval' would then be 604800.
+ *
+ * The 'display' is the description. For the 'weekly' key, the 'display' would
+ * be __('Once Weekly')
.
+ *
+ * For your plugin, you will be passed an array. you can easily add your
+ * schedule by doing the following.
+ *
+ * // filter parameter variable name is 'array'
+ * $array['weekly'] = array(
+ * 'interval' => 604800,
+ * 'display' => __('Once Weekly')
+ * );
+ *
+ *
+ * @since 2.1.0
+ *
+ * @return array
+ */
function wp_get_schedules() {
$schedules = array(
'hourly' => array( 'interval' => 3600, 'display' => __('Once Hourly') ),
@@ -128,6 +239,15 @@ function wp_get_schedules() {
return array_merge( apply_filters( 'cron_schedules', array() ), $schedules );
}
+/**
+ * Retrieve Cron schedule for hook with arguments.
+ *
+ * @since 2.1.0
+ *
+ * @param callback $hook Function or method to call, when cron is run.
+ * @param array $args Optional. Arguments to pass to the hook function.
+ * @return string|bool False, if no schedule. Schedule on success.
+ */
function wp_get_schedule($hook, $args = array()) {
$crons = _get_cron_array();
$key = md5(serialize($args));
@@ -144,6 +264,14 @@ function wp_get_schedule($hook, $args = array()) {
// Private functions
//
+/**
+ * Retrieve cron info array option.
+ *
+ * @since 2.1.0
+ * @access private
+ *
+ * @return array CRON info array.
+ */
function _get_cron_array() {
$cron = get_option('cron');
if ( ! is_array($cron) )
@@ -157,11 +285,30 @@ function _get_cron_array() {
return $cron;
}
+/**
+ * Updates the CRON option with the new CRON array.
+ *
+ * @since 2.1.0
+ * @access private
+ *
+ * @param array $cron Cron info array from {@link _get_cron_array()}.
+ */
function _set_cron_array($cron) {
$cron['version'] = 2;
update_option( 'cron', $cron );
}
+/**
+ * Upgrade a Cron info array.
+ *
+ * This function upgrades the Cron info array to version 2.
+ *
+ * @since 2.1.0
+ * @access private
+ *
+ * @param array $cron Cron info array from {@link _get_cron_array()}.
+ * @return array An upgraded Cron info array.
+ */
function _upgrade_cron_array($cron) {
if ( isset($cron['version']) && 2 == $cron['version'])
return $cron;