Function Reference/wp get schedules

来自WordPress中文文档
跳转至: 导航搜索

Description

Retrieve supported and filtered Cron recurrences.

The supported recurrences are 'hourly', 'twicedaily', 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.

Usage

%%%<?php wp_get_schedules(); ?>%%%

Parameters

None.

Return Values

(array) 

Examples

display

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 a new interval schedule by doing the following using the 'cron_schedules' filter.

 add_filter( 'cron_schedules', 'cron_add_weekly' );
 
 function cron_add_weekly( $schedules ) {
 	// Adds once weekly to the existing schedules.
 	$schedules['weekly'] = array(
 		'interval' => 604800,
 		'display' => __( 'Once Weekly' )
 	);
 	return $schedules;
 }


Notes

Change Log

Since: 2.1.0

Source File

wp_get_schedules() is located in onlyincludecodewp-includes/cron.php/code/onlyinclude

div class=template-description style=padding: 0 1.5em; border: 1px solid #eeeeee; background-color: #f9f9f9

Template Description

Link to the source code on http://core.trac.wordpress.org/browser/.

Parameters

  1. filename
  2. (option) path to codetag/code (version) or codetrunk/code. This option is only used for a new function.br /Default: codetrunk/code -- trunk is the latest bleeding edge development version of WordPress.

Usage

Link to the stable version: pre检查到模板循环:模板:Trac/pre

Link to trunk: pre检查到模板循环:模板:Trac/pre

/div

wordpress.org.cn.

Related

Plugin_API/Filter_Reference/cron_schedules

includeonlydiv style=clear:both; background-color:#F7F7F7; border:1px solid #CCCCCC; color:#000000; padding:7px; margin:0.5em auto 0.5em auto; vertical-align:middle;See also index of Function Reference and index of Template Tags./div/includeonlynoinclude

Description

This Template is used by Codex:Template Messages.

Usage

pre 检查到模板循环:模板:Message /pre

Result

检查到模板循环:模板:Message

/noinclude