本文整理汇总了PHP中_set_cron_array函数的典型用法代码示例。如果您正苦于以下问题:PHP _set_cron_array函数的具体用法?PHP _set_cron_array怎么用?PHP _set_cron_array使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_set_cron_array函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wp33423_hotfix
function wp33423_hotfix()
{
global $wp_version;
/**
* Disable this plugin from 4.3.1
*/
if (1 !== version_compare("4.3.1", $wp_version) && current_user_can('activate_plugins')) {
deactivate_plugins(plugin_basename(__FILE__));
}
/**
* Prevent 4.3 from messing up the cron array and options table
*/
remove_action('admin_init', '_wp_check_for_scheduled_split_terms');
/**
* Clean the cron array after 4.3 messed it up
*/
$cron_array = _get_cron_array();
if (isset($cron_array['wp_batch_split_terms'])) {
unset($cron_array['wp_batch_split_terms']);
_set_cron_array($cron_array);
}
/**
* In order to avoid the wp_batch_split_terms() job being accidentally removed,
* check that it's still scheduled while we haven't finished splitting terms.
*/
if (!get_option('finished_splitting_shared_terms') && !wp_next_scheduled('wp_split_shared_term_batch')) {
wp_schedule_single_event(time() + MINUTE_IN_SECONDS, 'wp_split_shared_term_batch');
}
}
示例2: pmpro_upgrade_1_8_7
function pmpro_upgrade_1_8_7()
{
//fix cron jobs
$jobs = _get_cron_array();
// Remove all pmpro cron jobs (for now).
foreach ($jobs as $when => $job_array) {
foreach ($job_array as $name => $job) {
//delete pmpro cron
if (false !== stripos($name, 'pmpro_cron')) {
unset($jobs[$when][$name]);
}
}
//delete empty cron time slots
if (empty($jobs[$when])) {
unset($jobs[$when]);
}
}
// Save the data
_set_cron_array($jobs);
//add the three we want back
pmpro_maybe_schedule_event(current_time('timestamp'), 'daily', 'pmpro_cron_expire_memberships');
pmpro_maybe_schedule_event(current_time('timestamp') + 1, 'daily', 'pmpro_cron_expiration_warnings');
pmpro_maybe_schedule_event(current_time('timestamp'), 'monthly', 'pmpro_cron_credit_card_expiring_warnings');
pmpro_setOption("db_version", "1.87");
return 1.87;
}
示例3: setUp
function setUp()
{
parent::setUp();
wp_set_current_user(self::$editor_id);
_set_cron_array(array());
$this->post_ids = array();
}
示例4: setUp
function setUp() {
parent::setUp();
$this->author_id = $this->factory->user->create( array( 'role' => 'editor' ) );
$this->old_current_user = get_current_user_id();
wp_set_current_user( $this->author_id );
_set_cron_array(array());
$this->post_ids = array();
}
示例5: wp_unschedule_event
function wp_unschedule_event( $timestamp, $hook, $args = array() ) {
$crons = _get_cron_array();
$key = md5(serialize($args));
unset( $crons[$timestamp][$hook][$key] );
if ( empty($crons[$timestamp][$hook]) )
unset( $crons[$timestamp][$hook] );
if ( empty($crons[$timestamp]) )
unset( $crons[$timestamp] );
_set_cron_array( $crons );
}
示例6: remove_schedules
/** Remove all schedules */
public function remove_schedules()
{
$cron = _get_cron_array();
foreach ($cron as $timestamp => $schedule) {
if (!isset($schedule['gf_digest_send_notifications'])) {
continue;
}
unset($cron[$timestamp]['gf_digest_send_notifications']);
if (empty($cron[$timestamp])) {
unset($cron[$timestamp]);
}
}
_set_cron_array($cron);
}
示例7: unschedule_event
/**
* Unschedule an event by hook name
*
* @see https://core.trac.wordpress.org/ticket/18997#comment:23
* @since 1.0.5
* @return void
*/
public static function unschedule_event($hook)
{
$crons = _get_cron_array();
if (empty($crons)) {
return;
}
foreach ($crons as $timestamp => $cron) {
if (!empty($cron[$hook])) {
unset($crons[$timestamp][$hook]);
}
if (empty($crons[$timestamp])) {
unset($crons[$timestamp]);
}
}
_set_cron_array($crons);
}
示例8: clear
public static function clear($hook)
{
$crons = _get_cron_array();
if (empty($crons)) {
return;
}
foreach ($crons as $timestamp => $cron) {
if (!empty($cron[$hook])) {
unset($crons[$timestamp][$hook]);
// Unset empty timestamps
if (empty($crons[$timestamp])) {
unset($crons[$timestamp]);
}
}
}
return _set_cron_array($crons);
}
示例9: upgrade_hooks
/**
* Update subscription WP-Cron tasks to Action Scheduler.
*
* @since 2.0
*/
public static function upgrade_hooks($number_hooks_to_upgrade)
{
$counter = 0;
$cron = _get_cron_array();
foreach ($cron as $timestamp => $actions) {
foreach ($actions as $hook => $details) {
if ('scheduled_subscription_payment' == $hook || 'scheduled_subscription_expiration' == $hook || 'scheduled_subscription_end_of_prepaid_term' == $hook || 'scheduled_subscription_trial_end' == $hook || 'paypal_check_subscription_payment' == $hook) {
foreach ($details as $hook_key => $values) {
if (!wc_next_scheduled_action($hook, $values['args'])) {
wc_schedule_single_action($timestamp, $hook, $values['args']);
unset($cron[$timestamp][$hook][$hook_key]);
$counter++;
}
if ($counter >= $number_hooks_to_upgrade) {
break;
}
}
// If there are no other jobs scheduled for this hook at this timestamp, remove the entire hook
if (0 == count($cron[$timestamp][$hook])) {
unset($cron[$timestamp][$hook]);
}
if ($counter >= $number_hooks_to_upgrade) {
break;
}
}
}
// If there are no actions schedued for this timestamp, remove the entire schedule
if (0 == count($cron[$timestamp])) {
unset($cron[$timestamp]);
}
if ($counter >= $number_hooks_to_upgrade) {
break;
}
}
// Set the cron with the removed schedule
_set_cron_array($cron);
return $counter;
}
示例10: tearDown
function tearDown()
{
parent::tearDown();
// make sure the schedule is clear
_set_cron_array(array());
}
示例11: cron_schedule_single_event
/**
* @param int $timestamp Timestamp for when to run the event.
* @param string $hook Action hook to execute when cron is run.
* @param array $args Optional. Arguments to pass to the hook's callback function.
*/
public function cron_schedule_single_event($timestamp, $hook, $args = array())
{
// don't schedule a duplicate if there's already an identical event due in the next 10 minutes
$next = cron_next_scheduled($hook, $args);
if ($next && $next <= $timestamp + 600) {
return;
}
$crons = _get_cron_array();
$key = md5(serialize($args));
$crons[$timestamp][$hook][$key] = array('schedule' => false, 'args' => $args);
uksort($crons, "strnatcasecmp");
_set_cron_array($crons);
}
示例12: refresh_cron
static function refresh_cron()
{
if (!extension_loaded('suhosin')) {
@ini_set('memory_limit', -1);
}
// Remove all cron jobs created by NextGEN Gallery
$cron = _get_cron_array();
if (is_array($cron)) {
foreach ($cron as $timestamp => $job) {
if (is_array($job)) {
unset($cron[$timestamp]['ngg_delete_expired_transients']);
if (empty($cron[$timestamp])) {
unset($cron[$timestamp]);
}
}
}
}
_set_cron_array($cron);
}
示例13: _clean_cron_array
/**
*
*
* @desc Clean cron array
*/
private function _clean_cron_array()
{
//retrive all crons
$crons = _get_cron_array();
if (!is_array($crons)) {
return;
}
$local_time = microtime(true);
$doing_wp_cron = sprintf('%.22F', $local_time);
set_transient('doing_cron', $doing_wp_cron);
foreach ($crons as $timestamp => $cronhooks) {
foreach ($cronhooks as $hook => $keys) {
if ($hook == $this->_hook) {
unset($crons[$timestamp][$hook]);
}
}
if (empty($crons[$timestamp])) {
unset($crons[$timestamp]);
}
}
//update cron with new array
_set_cron_array($crons);
delete_transient('doing_cron');
}
示例14: gd_unschedule_event
/**
* Unschedule a previously scheduled cron job using job key.
*
* @param int $timestamp timestamp for when to run the event.
* @param string $hook action hook, the execution of which will be unscheduled.
* @param string $key key for arguments to identify the event.
*/
function gd_unschedule_event($timestamp, $hook, $key)
{
$crons = _get_cron_array();
unset($crons[$timestamp][$hook][$key]);
if (empty($crons[$timestamp][$hook])) {
unset($crons[$timestamp][$hook]);
}
if (empty($crons[$timestamp])) {
unset($crons[$timestamp]);
}
_set_cron_array($crons);
}
示例15: wp_unschedule_event
/**
* Unschedule a previously scheduled cron job.
*
* The $timestamp and $hook parameters are required, so that the event can be
* identified.
*
* @since 2.1.0
*
* @param int $timestamp Timestamp for when to run the event.
* @param string $hook Action hook, the execution of which will be unscheduled.
* @param array $args Arguments to pass to the hook's callback function.
* Although not passed to a callback function, these arguments are used
* to uniquely identify the scheduled event, so they should be the same
* as those used when originally scheduling the event.
* @return false|void False when an event is not unscheduled.
*/
function wp_unschedule_event($timestamp, $hook, $args = array())
{
// Make sure timestamp is a positive integer
if (!is_numeric($timestamp) || $timestamp <= 0) {
return false;
}
$crons = _get_cron_array();
$key = md5(serialize($args));
unset($crons[$timestamp][$hook][$key]);
if (empty($crons[$timestamp][$hook])) {
unset($crons[$timestamp][$hook]);
}
if (empty($crons[$timestamp])) {
unset($crons[$timestamp]);
}
_set_cron_array($crons);
}