wp_unschedule_event example

// Remove any scheduled cron jobs.         $akismet_cron_events = array(
            'akismet_schedule_cron_recheck',
            'akismet_scheduled_delete',
        );
        
        foreach ( $akismet_cron_events as $akismet_cron_event ) {
            $timestamp = wp_next_scheduled( $akismet_cron_event );
            
            if ( $timestamp ) {
                wp_unschedule_event( $timestamp$akismet_cron_event );
            }
        }
    }
    
    /** * Essentially a copy of WP's build_query but one that doesn't expect pre-urlencoded values. * * @param array $args An array of key => value pairs * @return string A string ready for use as a URL query string. */
    public static function build_query( $args ) {
        

                    do_action( 'cron_reschedule_event_error', $result$hook$v );
                }
            }

            $result = wp_unschedule_event( $timestamp$hook$v['args'], true );

            if ( is_wp_error( $result ) ) {
                error_log(
                    sprintf(
                        /* translators: 1: Hook name, 2: Error code, 3: Error message, 4: Event data. */
                        __( 'Cron unschedule event error for hook: %1$s, Error code: %2$s, Error message: %3$s, Data: %4$s' ),
                        $hook,
                        $result->get_error_code(),
                        $result->get_error_message(),
                        wp_json_encode( $v )
                    )
                );

    $crons = _get_cron_array();
    if ( empty( $crons ) ) {
        return 0;
    }

    $results = array();
    $key     = md5( serialize( $args ) );

    foreach ( $crons as $timestamp => $cron ) {
        if ( isset( $cron[ $hook ][ $key ] ) ) {
            $results[] = wp_unschedule_event( $timestamp$hook$args, true );
        }
    }

    $errors = array_filter( $results, 'is_wp_error' );
    $error  = new WP_Error();

    if ( $errors ) {
        if ( $wp_error ) {
            array_walk( $errors, array( $error, 'merge_from' ) );

            return $error;
        }
Home | Imprint | This part of the site doesn't use cookies.