当前位置: 首页>>代码示例>>PHP>>正文


PHP Events::instance方法代码示例

本文整理汇总了PHP中Events::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Events::instance方法的具体用法?PHP Events::instance怎么用?PHP Events::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Events的用法示例。


在下文中一共展示了Events::instance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run_event

 /**
  * Execute a specific event
  */
 public function run_event($request)
 {
     // Parse request for details needed to identify the event to execute
     // `$timestamp` is, unsurprisingly, the Unix timestamp the event is scheduled for
     // `$action` is the md5 hash of the action used when the event is registered
     // `$instance` is the md5 hash of the event's arguments array, which Core uses to index the `cron` option
     $event = $request->get_json_params();
     $timestamp = isset($event['timestamp']) ? absint($event['timestamp']) : null;
     $action = isset($event['action']) ? trim(sanitize_text_field($event['action'])) : null;
     $instance = isset($event['instance']) ? trim(sanitize_text_field($event['instance'])) : null;
     return rest_ensure_response(Events::instance()->run_event($timestamp, $action, $instance));
 }
开发者ID:Automattic,项目名称:vip-mu-plugins-public,代码行数:15,代码来源:class-rest-api.php

示例2: time

            }
            // Now we try to get it from the saved interval, in case the schedule disappears
            if (0 == $interval) {
                $interval = $event['interval'];
            }
            // If we have an interval, update the existing event entry
            if (0 != $interval) {
                // Determine new timestamp, according to how `wp_reschedule_event()` does
                $now = time();
                $new_timestamp = $event['timestamp'];
                if ($new_timestamp >= $now) {
                    $new_timestamp = $now + $interval;
                } else {
                    $new_timestamp = $now + ($interval - ($now - $new_timestamp) % $interval);
                }
                // Build the expected arguments format
                $event_args = array('schedule' => $event['schedule'], 'args' => $event['args'], 'interval' => $interval);
                // Update CPT store
                Cron_Options_CPT::instance()->create_or_update_job($new_timestamp, $event['action'], $event_args, $job_id);
                // If the event could be rescheduled, don't then delete it :)
                if (is_int($job_id) && $job_id > 0) {
                    return;
                }
            }
        }
        // Either event doesn't recur, or the interval couldn't be determined
        Cron_Options_CPT::instance()->mark_job_completed($event['timestamp'], $event['action'], $event['instance']);
    }
}
Events::instance();
开发者ID:Automattic,项目名称:vip-mu-plugins-public,代码行数:30,代码来源:class-events.php


注:本文中的Events::instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。