You appear to be a bot. Output may be restricted
Description
Upgrades for EDD v2.0 and sequential payment numbers
Usage
$void = edd_v20_upgrade_sequential_payment_numbers();
Parameters
Returns
void
Source
File name: easy-digital-downloads/includes/admin/upgrades/upgrade-functions.php
Lines:
1 to 72 of 72
function edd_v20_upgrade_sequential_payment_numbers() { if( ! current_user_can( 'manage_shop_settings' ) ) { wp_die( __( 'You do not have permission to do shop upgrades', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) ); } ignore_user_abort( true ); if ( ! edd_is_func_disabled( 'set_time_limit' ) ) { set_time_limit( 0 ); } $step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1; $total = isset( $_GET['total'] ) ? absint( $_GET['total'] ) : false; if( empty( $total ) || $total <= 1 ) { $payments = edd_count_payments(); foreach( $payments as $status ) { $total += $status; } } $args = array( 'number' => 100, 'page' => $step, 'status' => 'any', 'order' => 'ASC' ); $payments = new EDD_Payments_Query( $args ); $payments = $payments->get_payments(); if( $payments ) { $prefix = edd_get_option( 'sequential_prefix' ); $postfix = edd_get_option( 'sequential_postfix' ); $number = ! empty( $_GET['custom'] ) ? absint( $_GET['custom'] ) : intval( edd_get_option( 'sequential_start', 1 ) ); foreach( $payments as $payment ) { // Re-add the prefix and postfix $payment_number = $prefix . $number . $postfix; edd_update_payment_meta( $payment->ID, '_edd_payment_number', $payment_number ); // Increment the payment number $number++; } // Payments found so upgrade them $step++; $redirect = add_query_arg( array( 'page' => 'edd-upgrades', 'edd-upgrade' => 'upgrade_sequential_payment_numbers', 'step' => $step, 'custom' => $number, 'total' => $total ), admin_url( 'index.php' ) ); wp_redirect( $redirect ); exit; } else { // No more payments found, finish up EDD()->session->set( 'upgrade_sequential', null ); delete_option( 'edd_doing_upgrade' ); wp_redirect( admin_url() ); exit; } }