%s', esc_url( admin_url( 'admin.php?page=postfee-settings' ) ), esc_html__( 'Settings', 'postfee' ) ) );
return $links;
}
public static function orders_page() {
$per_page = 30;
$page = isset( $_GET['paged'] ) ? max( 1, absint( $_GET['paged'] ) ) : 1; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Pagination.
$orders = Orders::query( $per_page, $page );
$total = Orders::count();
$statuses = array(
'pending' => __( 'Pending', 'postfee' ),
'paid' => __( 'Paid', 'postfee' ),
'refunded' => __( 'Refunded', 'postfee' ),
);
?>
|
|
|
|
|
|
|
|
user_id );
$gateway = Gateways::get( $order->gateway );
?>
| #id ); ?> |
created_at ) ); ?> |
display_name ); ?>
—
|
description ); ?>
post_id && get_post( $order->post_id ) ) : ?>
|
amount, $order->currency ) ); ?> |
label() : $order->gateway ); ?>
gateway_ref ) : ?>
gateway_ref ); ?>
|
status ] ) ? $statuses[ $order->status ] : $order->status ); ?>
status ) : ?>
|
add_query_arg( 'paged', '%#%' ),
'format' => '',
'current' => $page,
'total' => max( 1, (int) ceil( $total / $per_page ) ),
)
);
if ( $links ) {
echo '
' . wp_kses_post( $links ) . '
';
}
?>
'array',
'sanitize_callback' => array( __CLASS__, 'sanitize_settings' ),
)
);
}
public static function sanitize_settings( $input ) {
$input = (array) $input;
$current = postfee_get_settings();
$gateways = array_keys( Gateways::all() );
$currency = isset( $input['currency'] ) ? strtoupper( sanitize_key( $input['currency'] ) ) : '';
return array(
'currency' => array_key_exists( $currency, postfee_currencies() ) ? $currency : $current['currency'],
'post_types' => isset( $input['post_types'] ) ? array_values( array_filter( array_map( 'sanitize_key', (array) $input['post_types'] ), 'post_type_exists' ) ) : array(),
'paid_status' => isset( $input['paid_status'] ) && 'pending' === $input['paid_status'] ? 'pending' : 'publish',
'gateways' => isset( $input['gateways'] ) ? array_values( array_intersect( array_map( 'sanitize_key', (array) $input['gateways'] ), $gateways ) ) : array(),
'stripe_secret_key' => isset( $input['stripe_secret_key'] ) ? sanitize_text_field( $input['stripe_secret_key'] ) : '',
'stripe_webhook_secret' => isset( $input['stripe_webhook_secret'] ) ? sanitize_text_field( $input['stripe_webhook_secret'] ) : '',
'paypal_mode' => isset( $input['paypal_mode'] ) && 'live' === $input['paypal_mode'] ? 'live' : 'sandbox',
'paypal_client_id' => isset( $input['paypal_client_id'] ) ? sanitize_text_field( $input['paypal_client_id'] ) : '',
'paypal_secret' => isset( $input['paypal_secret'] ) ? sanitize_text_field( $input['paypal_secret'] ) : '',
'paypal_webhook_id' => isset( $input['paypal_webhook_id'] ) ? sanitize_text_field( $input['paypal_webhook_id'] ) : '',
'submit_page' => isset( $input['submit_page'] ) ? absint( $input['submit_page'] ) : 0,
'dashboard_page' => isset( $input['dashboard_page'] ) ? absint( $input['dashboard_page'] ) : 0,
'delete_data' => empty( $input['delete_data'] ) ? 0 : 1,
);
}
public static function settings_page() {
$settings = postfee_get_settings();
$post_types = get_post_types( array( 'public' => true ), 'objects' );
unset( $post_types['attachment'], $post_types['product'] );
?>