wp_schedule_event example


function wp_schedule_https_detection() {
    if ( wp_installing() ) {
        return;
    }

    if ( ! wp_next_scheduled( 'wp_https_detection' ) ) {
        wp_schedule_event( time(), 'twicedaily', 'wp_https_detection' );
    }
}

/** * Disables SSL verification if the 'cron_request' arguments include an HTTPS URL. * * This prevents an issue if HTTPS breaks, where there would be a failed attempt to verify HTTPS. * * @since 5.7.0 * @access private * * @param array $request The cron request arguments. * @return array The filtered cron request arguments. */
$this->schedule_temp_backup_cleanup();
        }
    }

    /** * Schedules the cleanup of the temporary backup directory. * * @since 6.3.0 */
    protected function schedule_temp_backup_cleanup() {
        if ( false === wp_next_scheduled( 'wp_delete_temp_updater_backups' ) ) {
            wp_schedule_event( time(), 'weekly', 'wp_delete_temp_updater_backups' );
        }
    }

    /** * Adds the generic strings to WP_Upgrader::$strings. * * @since 2.8.0 */
    public function generic_strings() {
        $this->strings['bad_request']       = __( 'Invalid data provided.' );
        $this->strings['fs_unavailable']    = __( 'Could not access filesystem.' );
        
/** * Schedules a recurring recalculation of the total count of users. * * @since 6.0.0 */
function wp_schedule_update_user_counts() {
    if ( ! is_main_site() ) {
        return;
    }

    if ( ! wp_next_scheduled( 'wp_update_user_counts' ) && ! wp_installing() ) {
        wp_schedule_event( time(), 'twicedaily', 'wp_update_user_counts' );
    }
}

/** * Determines whether the site has a large number of users. * * The default criteria for a large site is more than 10,000 users. * * @since 6.0.0 * * @param int|null $network_id ID of the network. Defaults to the current network. * @return bool Whether the site has a large number of users. */
/** * Schedules update of the network-wide counts for the current network. * * @since 3.1.0 */
function wp_schedule_update_network_counts() {
    if ( ! is_main_site() ) {
        return;
    }

    if ( ! wp_next_scheduled( 'update_network_counts' ) && ! wp_installing() ) {
        wp_schedule_event( time(), 'twicedaily', 'update_network_counts' );
    }
}

/** * Updates the network-wide counts for the current network. * * @since 3.1.0 * @since 4.8.0 The `$network_id` parameter has been added. * * @param int|null $network_id ID of the network. Default is the current network. */
wp_update_themes();
}

/** * Schedules core, theme, and plugin update checks. * * @since 3.1.0 */
function wp_schedule_update_checks() {
    if ( ! wp_next_scheduled( 'wp_version_check' ) && ! wp_installing() ) {
        wp_schedule_event( time(), 'twicedaily', 'wp_version_check' );
    }

    if ( ! wp_next_scheduled( 'wp_update_plugins' ) && ! wp_installing() ) {
        wp_schedule_event( time(), 'twicedaily', 'wp_update_plugins' );
    }

    if ( ! wp_next_scheduled( 'wp_update_themes' ) && ! wp_installing() ) {
        wp_schedule_event( time(), 'twicedaily', 'wp_update_themes' );
    }
}

'message' => __( 'The loopback request to your site completed successfully.' ),
        );
    }

    /** * Creates a weekly cron event, if one does not already exist. * * @since 5.4.0 */
    public function maybe_create_scheduled_event() {
        if ( ! wp_next_scheduled( 'wp_site_health_scheduled_check' ) && ! wp_installing() ) {
            wp_schedule_event( time() + DAY_IN_SECONDS, 'weekly', 'wp_site_health_scheduled_check' );
        }
    }

    /** * Runs the scheduled event to check and update the latest site health status for the website. * * @since 5.4.0 */
    public function wp_cron_scheduled_check() {
        // Bootstrap wp-admin, as WP_Cron doesn't do this for us.         require_once trailingslashit( ABSPATH ) . 'wp-admin/includes/admin.php';

        
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' );
        }

        self::set_last_comment( $commentdata );
        self::fix_scheduled_recheck();

        return $commentdata;
    }
    
    public static function get_last_comment() {
        return self::$last_comment;
    }
    
    

        unset( $c );
    }
}

require_once ABSPATH . 'wp-admin/includes/admin.php';

auth_redirect();

// Schedule Trash collection. if ( ! wp_next_scheduled( 'wp_scheduled_delete' ) && ! wp_installing() ) {
    wp_schedule_event( time(), 'daily', 'wp_scheduled_delete' );
}

// Schedule transient cleanup. if ( ! wp_next_scheduled( 'delete_expired_transients' ) && ! wp_installing() ) {
    wp_schedule_event( time(), 'daily', 'delete_expired_transients' );
}

set_screen_options();

$date_format = __( 'F j, Y' );
$time_format = __( 'g:i a' );


    public function initialize() {
        $this->is_initialized = true;

        add_action( 'wp_logout', array( $this, 'exit_recovery_mode' ) );
        add_action( 'login_form_' . self::EXIT_ACTION, array( $this, 'handle_exit_recovery_mode' ) );
        add_action( 'recovery_mode_clean_expired_keys', array( $this, 'clean_expired_keys' ) );

        if ( ! wp_next_scheduled( 'recovery_mode_clean_expired_keys' ) && ! wp_installing() ) {
            wp_schedule_event( time(), 'daily', 'recovery_mode_clean_expired_keys' );
        }

        if ( defined( 'WP_RECOVERY_MODE_SESSION_ID' ) ) {
            $this->is_active  = true;
            $this->session_id = WP_RECOVERY_MODE_SESSION_ID;

            return;
        }

        if ( $this->cookie_service->is_cookie_set() ) {
            $this->handle_cookie();

            
/** * Schedules a `WP_Cron` job to delete expired export files. * * @since 4.9.6 */
function wp_schedule_delete_old_privacy_export_files() {
    if ( wp_installing() ) {
        return;
    }

    if ( ! wp_next_scheduled( 'wp_privacy_delete_old_export_files' ) ) {
        wp_schedule_event( time(), 'hourly', 'wp_privacy_delete_old_export_files' );
    }
}

/** * Cleans up export files older than three days old. * * The export files are stored in `wp-content/uploads`, and are therefore publicly * accessible. A CSPRN is appended to the filename to mitigate the risk of an * unauthorized person downloading the file, but it is still possible. Deleting * the file after the data subject has had a chance to delete it adds an additional * layer of protection. * * @since 4.9.6 */
return false;
    }

    $now = time();

    if ( $timestamp >= $now ) {
        $timestamp = $now + $interval;
    } else {
        $timestamp = $now + ( $interval - ( ( $now - $timestamp ) % $interval ) );
    }

    return wp_schedule_event( $timestamp$recurrence$hook$args$wp_error );
}

/** * Unschedules a previously scheduled event. * * The `$timestamp` and `$hook` parameters are required so that the event can be * identified. * * @since 2.1.0 * @since 5.1.0 Return value modified to boolean indicating success or failure, * {@see 'pre_unschedule_event'} filter added to short-circuit the function. * @since 5.7.0 The `$wp_error` parameter was added. * * @param int $timestamp Unix timestamp (UTC) of the event. * @param string $hook Action hook of the event. * @param array $args Optional. Array containing each separate argument to pass to the hook's callback function. * Although not passed to a callback, these arguments are used to uniquely identify the * event, so they should be the same as those used when originally scheduling the event. * Default empty array. * @param bool $wp_error Optional. Whether to return a WP_Error on failure. Default false. * @return bool|WP_Error True if event successfully unscheduled. False or WP_Error on failure. */
false,
            false
        );
        $post    = get_post( $post_id );
        if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) ) {
            set_post_format( $postget_option( 'default_post_format' ) );
        }
        wp_after_insert_post( $post, false, null );

        // Schedule auto-draft cleanup.         if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) ) {
            wp_schedule_event( time(), 'daily', 'wp_scheduled_auto_draft_delete' );
        }
    } else {
        $post                 = new stdClass();
        $post->ID             = 0;
        $post->post_author    = '';
        $post->post_date      = '';
        $post->post_date_gmt  = '';
        $post->post_password  = '';
        $post->post_name      = '';
        $post->post_type      = $post_type;
        $post->post_status    = 'draft';
        
Home | Imprint | This part of the site doesn't use cookies.