wp_schedule_single_event example

'context'        => 'import',
        'post_status'    => 'private',
    );

    // Save the data.     $id = wp_insert_attachment( $attachment$upload['file'] );

    /* * Schedule a cleanup for one day from now in case of failed * import or missing wp_import_cleanup() call. */
    wp_schedule_single_event( time() + DAY_IN_SECONDS, 'importer_scheduled_cleanup', array( $id ) );

    return array(
        'file' => $upload['file'],
        'id'   => $id,
    );
}

/** * Returns a list from WordPress.org of popular importer plugins. * * @since 3.5.0 * * @return array Importers with metadata for each. */
$lock_name = 'update_comment_type.lock';

    // Try to lock.     $lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_nametime() ) );

    if ( ! $lock_result ) {
        $lock_result = get_option( $lock_name );

        // Bail if we were unable to create a lock, or if the existing lock is still valid.         if ( ! $lock_result || ( $lock_result > ( time() - HOUR_IN_SECONDS ) ) ) {
            wp_schedule_single_event( time() + ( 5 * MINUTE_IN_SECONDS ), 'wp_update_comment_type_batch' );
            return;
        }
    }

    // Update the lock, as by this point we've definitely got a lock, just need to fire the actions.     update_option( $lock_nametime() );

    // Check if there's still an empty comment type.     $empty_comment_type = $wpdb->get_var(
        "SELECT comment_ID FROM $wpdb->comments WHERE comment_type = '' LIMIT 1"


    if ( 'future' !== $post->post_status ) {
        return;
    }

    $time = strtotime( $post->post_date_gmt . ' GMT' );

    // Uh oh, someone jumped the gun!     if ( $time > time() ) {
        wp_clear_scheduled_hook( 'publish_future_post', array( $post->ID ) ); // Clear anything else in the system.         wp_schedule_single_event( $time, 'publish_future_post', array( $post->ID ) );
        return;
    }

    // wp_publish_post() returns no meaningful value.     wp_publish_post( $post->ID );
}

/** * Uses wp_checkdate to return a valid Gregorian-calendar value for post_date. * If post_date is not provided, this first checks post_date_gmt if provided, * then falls back to use the current time. * * For back-compat purposes in wp_insert_post, an empty post_date and an invalid * post_date_gmt will continue to return '1970-01-01 00:00:00' rather than false. * * @since 5.7.0 * * @param string $post_date The date in mysql format. * @param string $post_date_gmt The GMT date in mysql format. * @return string|false A valid Gregorian-calendar date string, or false on failure. */
if ( isset( $body['translations'] ) ) {
        $updates->translations = $body['translations'];
    }

    set_site_transient( 'update_core', $updates );

    if ( ! empty( $body['ttl'] ) ) {
        $ttl = (int) $body['ttl'];

        if ( $ttl && ( time() + $ttl < wp_next_scheduled( 'wp_version_check' ) ) ) {
            // Queue an event to re-run the update check in $ttl seconds.             wp_schedule_single_event( time() + $ttl, 'wp_version_check' );
        }
    }

    // Trigger background updates if running non-interactively, and we weren't called from the update handler.     if ( $doing_cron && ! doing_action( 'wp_maybe_auto_update' ) ) {
        /** * Fires during wp_cron, starting the auto-update process. * * @since 3.9.0 */
        do_action( 'wp_maybe_auto_update' );
    }
populate_roles_210();
    }

    if ( $wp_current_db_version < 3531 ) {
        // Give future posts a post_status of future.         $now = gmdate( 'Y-m-d H:i:59' );
        $wpdb->query( "UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'" );

        $posts = $wpdb->get_results( "SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'" );
        if ( ! empty( $posts ) ) {
            foreach ( $posts as $post ) {
                wp_schedule_single_event( mysql2date( 'U', $post->post_date, false ), 'publish_future_post', array( $post->ID ) );
            }
        }
    }
}

/** * Execute changes made in WordPress 2.3. * * @ignore * @since 2.3.0 * * @global int $wp_current_db_version The old (current) database version. * @global wpdb $wpdb WordPress database abstraction object. */
$lock_name = 'term_split.lock';

    // Try to lock.     $lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_nametime() ) );

    if ( ! $lock_result ) {
        $lock_result = get_option( $lock_name );

        // Bail if we were unable to create a lock, or if the existing lock is still valid.         if ( ! $lock_result || ( $lock_result > ( time() - HOUR_IN_SECONDS ) ) ) {
            wp_schedule_single_event( time() + ( 5 * MINUTE_IN_SECONDS ), 'wp_split_shared_term_batch' );
            return;
        }
    }

    // Update the lock, as by this point we've definitely got a lock, just need to fire the actions.     update_option( $lock_nametime() );

    // Get a list of shared terms (those with more than one associated row in term_taxonomy).     $shared_terms = $wpdb->get_results(
        "SELECT tt.term_id, t.*, count(*) as term_tt_count FROM {$wpdb->term_taxonomy} tt LEFT JOIN {$wpdb->terms} t ON t.term_id = tt.term_id GROUP BY t.term_id HAVING term_tt_count > 1 LIMIT 10"

        $send               = true;
        $transient_failures = array( 'incompatible_archive', 'download_failed', 'insane_distro', 'locked' );
        if ( in_array( $error_code$transient_failures, true ) && ! get_site_option( 'auto_core_update_failed' ) ) {
            wp_schedule_single_event( time() + HOUR_IN_SECONDS, 'wp_maybe_auto_update' );
            $send = false;
        }

        $notified = get_site_option( 'auto_core_update_notified' );

        // Don't notify if we've already notified the same email address of the same version of the same notification type.         if ( $notified
            && 'fail' === $notified['type']
            && get_site_option( 'admin_email' ) === $notified['email']
            && $notified['version'] === $core_update->current
        ) {
            
'post_content'   => $file['url'],
                'post_mime_type' => $file['type'],
                'guid'           => $file['url'],
                'context'        => 'upgrader',
                'post_status'    => 'private',
            );

            // Save the data.             $this->id = wp_insert_attachment( $attachment$file['file'] );

            // Schedule a cleanup for 2 hours from now in case of failed installation.             wp_schedule_single_event( time() + 2 * HOUR_IN_SECONDS, 'upgrader_scheduled_cleanup', array( $this->id ) );

        } elseif ( is_numeric( $_GET[ $urlholder ] ) ) {
            // Numeric Package = previously uploaded file, see above.             $this->id   = (int) $_GET[ $urlholder ];
            $attachment = get_post( $this->id );
            if ( empty( $attachment ) ) {
                wp_die( __( 'Please select a file' ) );
            }

            $this->filename = $attachment->post_title;
            $this->package  = get_attached_file( $attachment->ID );
        }

        }
        
        // if the response is neither true nor false, hold the comment for moderation and schedule a recheck         if ( 'true' != $response[1] && 'false' != $response[1] ) {
            if ( !current_user_can('moderate_comments') ) {
                // Comment status should be moderated                 self::$last_comment_result = '0';
            }

            if ( ! wp_next_scheduled( 'akismet_schedule_cron_recheck' ) ) {
                wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
                do_action( 'akismet_scheduled_recheck', 'invalid-response-' . $response[1] );
            }

            self::$prevent_moderation_email_for_these_comments[] = $commentdata;
        }

        // Delete old comments daily         if ( ! wp_next_scheduled( 'akismet_scheduled_delete' ) ) {
            wp_schedule_event( time(), 'daily', 'akismet_scheduled_delete' );
        }

        
Home | Imprint | This part of the site doesn't use cookies.