本文整理汇总了PHP中wp_schedule_single_event函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_schedule_single_event函数的具体用法?PHP wp_schedule_single_event怎么用?PHP wp_schedule_single_event使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_schedule_single_event函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: status_transition
/**
* Hooked into transition_post_status. Will initiate search engine pings
* if the post is being published, is a post type that a sitemap is built for
* and is a post that is included in sitemaps.
*
* @param string $new_status New post status.
* @param string $old_status Old post status.
* @param \WP_Post $post Post object.
*/
function status_transition($new_status, $old_status, $post)
{
if ($new_status != 'publish') {
return;
}
wp_cache_delete('lastpostmodified:gmt:' . $post->post_type, 'timeinfo');
// #17455.
$options = WPSEO_Options::get_options(array('wpseo_xml', 'wpseo_titles'));
if (isset($options['post_types-' . $post->post_type . '-not_in_sitemap']) && $options['post_types-' . $post->post_type . '-not_in_sitemap'] === true || $post->post_type === 'nav_menu_item') {
return;
}
if (WP_CACHE) {
wp_schedule_single_event(time() + 300, 'wpseo_hit_sitemap_index');
}
/**
* Filter: 'wpseo_allow_xml_sitemap_ping' - Check if pinging is not allowed (allowed by default)
*
* @api boolean $allow_ping The boolean that is set to true by default.
*/
if (apply_filters('wpseo_allow_xml_sitemap_ping', true) === false) {
return;
}
// Allow the pinging to happen slightly after the hit sitemap index so the sitemap is fully regenerated when the ping happens.
$excluded_posts = explode(',', $options['excluded-posts']);
if (!in_array($post->ID, $excluded_posts)) {
if (defined('YOAST_SEO_PING_IMMEDIATELY') && YOAST_SEO_PING_IMMEDIATELY) {
wpseo_ping_search_engines();
} else {
wp_schedule_single_event(time() + 300, 'wpseo_ping_search_engines');
}
}
}
示例2: 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');
}
}
示例3: get_transient
/**
* Get the data from the transient and/or schedule new data to be retrieved.
*
* @param string $transient The name of the transient. Must be 43 characters or less including $this->transient_prefix.
* @param string $hook The name of the hook to retrieve new data.
* @param array $args An array of arguments to pass to the function.
*
* @return mixed Either false or the data from the transient.
*/
public function get_transient($transient, $hook, $args)
{
// Build the transient names.
$transient = $this->prefix . $transient;
$fallback_transient = $transient . '_';
if (is_multisite()) {
if (false === ($data = get_site_transient($transient))) {
$data = get_site_transient($fallback_transient);
if (!wp_get_schedule($hook, $args)) {
wp_clear_scheduled_hook($hook, $args);
wp_schedule_single_event(time(), $hook, $args);
}
return $data;
} else {
return $data;
}
} else {
if (false === ($data = get_transient($transient))) {
$data = get_transient($fallback_transient);
if (!wp_get_schedule($hook, $args)) {
wp_clear_scheduled_hook($hook, $args);
wp_schedule_single_event(time(), $hook, $args);
}
return $data;
} else {
return $data;
}
}
}
示例4: post_restore
public function post_restore()
{
if (isset($_POST['job_id']) && isset($_POST['backup_uniqid']) && isset($_POST['_wpnonce']) && isset($_POST['method'])) {
$nonce = filter_input(INPUT_POST, '_wpnonce', FILTER_SANITIZE_STRING);
if (!wp_verify_nonce($nonce, 'my-wp-backup-restore-backup')) {
wp_die(esc_html__('Nope! Security check failed!', 'my-wp-backup'));
}
$id = absint($_POST['job_id']);
$uniqid = sanitize_key($_POST['backup_uniqid']);
$method = filter_input(INPUT_POST, 'method', FILTER_SANITIZE_STRING);
$backup = self::get($id, $uniqid);
if (!isset($backup['duration'])) {
add_settings_error('', '', __('Invalid backup id/uniqid.', 'my-wp-backup'));
set_transient('settings_errors', get_settings_errors());
wp_safe_redirect($this->admin->get_page_url('backup', array('settings-updated' => 1)));
}
if (!$backup->has_archives()) {
// No local copy and no remote copy === DEAD END.
if (empty($backup['destinations'])) {
add_settings_error('', '', __('Backup files missing.', 'my-wp-backup'));
set_transient('settings_errors', get_settings_errors());
wp_safe_redirect($this->admin->get_page_url('backup', array('settings-updated' => 1)));
}
if (!isset($backup['destinations'][$method])) {
add_settings_error('', '', sprintf(__('No backup files from %s.', 'my-wp-backup'), Job::$destinations[$method]));
set_transient('settings_errors', get_settings_errors());
wp_safe_redirect($this->admin->get_page_url('backup', array('settings-updated' => 1)));
}
}
wp_schedule_single_event(time(), 'wp_backup_restore_backup', array(array($id, $uniqid, $method)));
wp_safe_redirect($this->admin->get_page_url('backup', array('uniqid' => $uniqid, 'action' => 'viewprogress', 'id' => $id)));
}
}
示例5: doWhenPluginActivates
public function doWhenPluginActivates()
{
// Requirement Check
$oRequirement = new FetchTweets_Requirements($this->strFilePath, array('php' => array('version' => '5.2.4', 'error' => 'The plugin requires the PHP version %1$s or higher.'), 'wordpress' => array('version' => '3.3', 'error' => 'The plugin requires the WordPress version %1$s or higher.'), 'functions' => array('curl_version' => sprintf(__('The plugin requires the %1$s to be installed.', 'fetch-tweets'), 'the cURL library')), 'constants' => array()), True, null);
$oRequirement->checkRequirements();
// Schedule transient set-ups
wp_schedule_single_event(time(), 'fetch_tweets_action_setup_transients');
}
示例6: podlove_init_user_agent_refresh
function podlove_init_user_agent_refresh()
{
foreach (range(0, floor(UserAgent::count() / 500) * 500, 500) as $start_id) {
wp_schedule_single_event(time() + mt_rand(2, 30), 'podlove_parse_user_agents', [$start_id]);
}
// must be done after user agent refresh is finished
wp_schedule_single_event(time() + 180, 'podlove_delete_bots_from_clean_downloadintents');
}
示例7: _scheduleCacheRenewal
protected function _scheduleCacheRenewal($aURLs)
{
// Schedules the action to run in the background with WP Cron.
if (wp_next_scheduled('aal_action_simplepie_renew_cache', array($aURLs))) {
return;
}
wp_schedule_single_event(time(), 'aal_action_simplepie_renew_cache', array($aURLs));
}
示例8: __construct
function __construct()
{
$queue = TP_CSV_Queue::get();
if (!wp_next_scheduled('tp_csv_importer') && 0 < count($queue)) {
wp_schedule_single_event(time(), 'tp_csv_importer');
}
add_action('tp_csv_importer', array($this, 'perform'));
}
示例9: do_install_woocommerce
/**
* Runs the installer.
*
* @access public
* @return void
*/
function do_install_woocommerce()
{
global $woocommerce_settings, $woocommerce;
// Do install
woocommerce_default_options();
woocommerce_tables_install();
woocommerce_init_roles();
// Register post types
$woocommerce->init_taxonomy();
// Add default taxonomies
woocommerce_default_taxonomies();
// Cron jobs
wp_clear_scheduled_hook('woocommerce_scheduled_sales');
wp_clear_scheduled_hook('woocommerce_cancel_unpaid_orders');
wp_clear_scheduled_hook('woocommerce_cleanup_sessions');
$ve = get_option('gmt_offset') > 0 ? '+' : '-';
wp_schedule_event(strtotime('tomorrow ' . $ve . get_option('gmt_offset') . ' HOURS'), 'daily', 'woocommerce_scheduled_sales');
$held_duration = get_option('woocommerce_hold_stock_minutes', null);
if (is_null($held_duration)) {
$held_duration = '60';
}
if ($held_duration != '') {
wp_schedule_single_event(time() + absint($held_duration) * 60, 'woocommerce_cancel_unpaid_orders');
}
wp_schedule_event(time(), 'twicedaily', 'woocommerce_cleanup_sessions');
// Install files and folders for uploading files and prevent hotlinking
$upload_dir = wp_upload_dir();
$files = array(array('base' => $upload_dir['basedir'] . '/woocommerce_uploads', 'file' => '.htaccess', 'content' => 'deny from all'), array('base' => $upload_dir['basedir'] . '/woocommerce_uploads', 'file' => 'index.html', 'content' => ''), array('base' => WP_PLUGIN_DIR . "/" . plugin_basename(dirname(dirname(__FILE__))) . '/logs', 'file' => '.htaccess', 'content' => 'deny from all'), array('base' => WP_PLUGIN_DIR . "/" . plugin_basename(dirname(dirname(__FILE__))) . '/logs', 'file' => 'index.html', 'content' => ''));
foreach ($files as $file) {
if (wp_mkdir_p($file['base']) && !file_exists(trailingslashit($file['base']) . $file['file'])) {
if ($file_handle = @fopen(trailingslashit($file['base']) . $file['file'], 'w')) {
fwrite($file_handle, $file['content']);
fclose($file_handle);
}
}
}
// Clear transient cache
$woocommerce->clear_product_transients();
// Recompile LESS styles if they are custom
if (get_option('woocommerce_frontend_css') == 'yes') {
$colors = get_option('woocommerce_frontend_css_colors');
if (!empty($colors['primary']) && !empty($colors['secondary']) && !empty($colors['highlight']) && !empty($colors['content_bg']) && !empty($colors['subtext']) && ($colors['primary'] != '#ad74a2' || $colors['secondary'] != '#f7f6f7' || $colors['highlight'] != '#85ad74' || $colors['content_bg'] != '#ffffff' || $colors['subtext'] != '#777777')) {
woocommerce_compile_less_styles();
}
}
// Queue upgrades
$current_version = get_option('woocommerce_version', null);
$current_db_version = get_option('woocommerce_db_version', null);
if (version_compare($current_db_version, '2.0.9', '<') && null !== $current_db_version) {
update_option('_wc_needs_update', 1);
} else {
update_option('woocommerce_db_version', $woocommerce->version);
}
// Update version
update_option('woocommerce_version', $woocommerce->version);
// Flush rewrite rules
flush_rewrite_rules();
}
示例10: schedule_migrate_old_table
public function schedule_migrate_old_table()
{
global $wpdb;
if ($wpdb->get_var("SELECT post_id FROM " . $wpdb->prefix . "postmeta WHERE meta_key = '_links_to'") !== null) {
if (!wp_get_schedule('idx_migrate_old_table')) {
wp_schedule_single_event(time(), 'idx_migrate_old_table');
}
}
}
示例11: schedule
/**
* Main scheduling function
*
* @access public
* @param int $timestamp
* @param string $hook
* @param int $subscription_id
* @return bool
*/
public static function schedule($timestamp, $hook, $subscription_id)
{
if (wp_schedule_single_event($timestamp, $hook, array((int)$subscription_id)) === false) {
return false;
}
else {
return true;
}
}
示例12: assign
/**
* @param string $event
* @param array $args
* @return bool
*/
public function assign($event, array $args = array())
{
// we've already scheduled this
if (wp_next_scheduled($event, $args) !== false) {
return false;
}
wp_schedule_single_event(time() + 1, $event, $args);
return true;
}
示例13: _scheduleEvent
/**
* @since 3.6.2
*/
private function _scheduleEvent()
{
$_sActionName = AdminPageFrameworkLoader_Registry::HOOK_SLUG . '_action_get_development_version';
$_aArguments = array();
if (wp_next_scheduled($_sActionName, $_aArguments)) {
return false;
}
wp_schedule_single_event(time(), $_sActionName, $_aArguments);
}
开发者ID:sultann,项目名称:admin-page-framework,代码行数:12,代码来源:AdminPageFrameworkLoader_AdminPageMetaBox_Notification.php
示例14: _register_cron_event
/**
* Register Cron event to invalidate
*
* @param array $query
* @since 4.3.0
* @access private
**/
private function _register_cron_event($query)
{
if ($query['Paths']['Items'][0] === '/*') {
return;
}
$query = $this->_merge_transient_invalidation_query($query);
set_transient(self::C3_CRON_INDALITATION_TARGET, $query, 5 * 60);
$time = time() + MINUTE_IN_SECONDS * 5;
wp_schedule_single_event($time, 'c3_cron_invalidation');
}
示例15: schedule_event
/**
* Schedule the event
*
* @since 1.0.0
* @return void
*/
public function schedule_event()
{
if (!wp_next_scheduled($this->args['name'])) {
if ($this->args['schedule'] === 'schedule') {
wp_schedule_event(current_time('timestamp'), $this->args['recurrence'], $this->args['name'], $this->args['args']);
} elseif ($this->args['schedule'] === 'single') {
wp_schedule_single_event($this->args['recurrence'], $this->args['name'], $this->args['args']);
}
}
}