From 0a28170ce0babf083a6fea87450d0e779b653434 Mon Sep 17 00:00:00 2001 From: Justin Sternberg Date: Sun, 5 Feb 2017 16:27:23 -0500 Subject: [PATCH 01/13] Return notes object separately. Might fix #2232 --- wpsc-admin/init.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wpsc-admin/init.php b/wpsc-admin/init.php index ef86f0a3e4..ca1f015b94 100644 --- a/wpsc-admin/init.php +++ b/wpsc-admin/init.php @@ -560,8 +560,9 @@ function wpsc_purchlogs_update_notes( $purchlog_id = 0, $purchlog_notes = '' ) { : wpsc_get_order( $purchlog_id ); $notes = wpsc_get_order_notes( $purchase_log ); + $notes->add( $purchlog_notes )->save(); - return $notes->add( $purchlog_notes )->save(); + return $notes; } /** From 4e26f429d405eadec2bf8492a31d1930d8780143 Mon Sep 17 00:00:00 2001 From: Justin Sternberg Date: Mon, 6 Feb 2017 12:19:56 -0500 Subject: [PATCH 02/13] Fix issue with refund causing notes to duplicate. Fixes #2232 (by passing around the original log object) --- .../merchant-core-v3/gateways/paypal-express-checkout.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wpsc-components/merchant-core-v3/gateways/paypal-express-checkout.php b/wpsc-components/merchant-core-v3/gateways/paypal-express-checkout.php index 1635d00491..199f823f78 100644 --- a/wpsc-components/merchant-core-v3/gateways/paypal-express-checkout.php +++ b/wpsc-components/merchant-core-v3/gateways/paypal-express-checkout.php @@ -116,7 +116,7 @@ public function callback_shortcut_process() { global $wpsc_cart; // Create a new PurchaseLog Object - $purchase_log = new WPSC_Purchase_Log(); + $purchase_log = wpsc_get_order(); // Create a Sessionid $sessionid = ( mt_rand( 100, 999 ) . time() ); @@ -1076,7 +1076,7 @@ public function process_refund( $order_id, $amount = 0.00, $reason = '', $manual return new WP_Error( 'paypal_refund_error', __( 'Refund Error: You need to specify a refund amount.', 'wp-e-commerce' ) ); } - $log = new WPSC_Purchase_Log( $order_id ); + $log = wpsc_get_order( $order_id ); if ( ! $log->get( 'transactid' ) ) { return new WP_Error( 'error', __( 'Refund Failed: No transaction ID', 'wp-e-commerce' ) ); @@ -1092,7 +1092,7 @@ public function process_refund( $order_id, $amount = 0.00, $reason = '', $manual $current_refund = $log->get_total_refunded(); $log->set( 'total_order_refunded' , $amount + $current_refund )->save(); - wpsc_purchlogs_update_notes( absint( $order_id ), sprintf( __( 'Refunded %s via Manual Refund', 'wp-e-commerce' ), wpsc_currency_display( $amount ) ) ); + wpsc_purchlogs_update_notes( $log, sprintf( __( 'Refunded %s via Manual Refund', 'wp-e-commerce' ), wpsc_currency_display( $amount ) ) ); return true; } @@ -1129,7 +1129,7 @@ public function process_refund( $order_id, $amount = 0.00, $reason = '', $manual $current_refund = $log->get_total_refunded(); $log->set( 'total_order_refunded' , $amount + $current_refund )->save(); - wpsc_purchlogs_update_notes( absint( $order_id ), sprintf( __( 'Refunded %s - Refund ID: %s', 'wp-e-commerce' ), wpsc_currency_display( $params['GROSSREFUNDAMT'] ), $params['REFUNDTRANSACTIONID'] ) ); + wpsc_purchlogs_update_notes( $log, sprintf( __( 'Refunded %s - Refund ID: %s', 'wp-e-commerce' ), wpsc_currency_display( $params['GROSSREFUNDAMT'] ), $params['REFUNDTRANSACTIONID'] ) ); return true; } From c734443ed260271d4d847a928ae5013be49f9b5b Mon Sep 17 00:00:00 2001 From: Justin Sternberg Date: Mon, 6 Feb 2017 12:26:37 -0500 Subject: [PATCH 03/13] Use helper functions --- wpsc-admin/ajax.php | 8 ++++---- wpsc-admin/display-sales-logs.php | 8 ++++---- wpsc-admin/init.php | 8 ++++---- wpsc-components/marketplace-core-v1/library/Sputnik.php | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/wpsc-admin/ajax.php b/wpsc-admin/ajax.php index 26103b837a..30571f660e 100644 --- a/wpsc-admin/ajax.php +++ b/wpsc-admin/ajax.php @@ -532,7 +532,7 @@ function _wpsc_ajax_remove_log_item() { $item_id = absint( $_POST['item_id'] ); $log_id = absint( $_POST['log_id'] ); - $log = new WPSC_Purchase_Log( $log_id ); + $log = wpsc_get_order( $log_id ); if ( $log->remove_item( $item_id ) ) { return _wpsc_init_log_items( $log ); @@ -560,7 +560,7 @@ function _wpsc_ajax_update_log_item_qty() { $item_id = absint( $_POST['item_id'] ); $log_id = absint( $_POST['log_id'] ); - $log = new WPSC_Purchase_Log( $log_id ); + $log = wpsc_get_order( $log_id ); $result = $log->update_item( $item_id, array( 'quantity' => absint( $_POST['qty'] ) ) ); if ( 0 === $result ) { @@ -600,7 +600,7 @@ function _wpsc_ajax_add_log_item() { foreach ( $_POST['product_ids'] as $product_id ) { $product_id = absint( $product_id ); $log_id = absint( $_POST['log_id'] ); - $log = new WPSC_Purchase_Log( $log_id ); + $log = wpsc_get_order( $log_id ); // Is product is already in item list? if ( $existing && in_array( $product_id, $existing, true ) ) { @@ -674,7 +674,7 @@ function _wpsc_ajax_edit_contact_details() { parse_str( $_POST['fields'], $fields ); $log_id = absint( $_POST['log_id'] ); - $log = new WPSC_Purchase_Log( $log_id ); + $log = wpsc_get_order( $log_id ); if ( isset( $fields['wpsc_checkout_details'] ) && is_array( $fields['wpsc_checkout_details'] ) ) { $details = wp_unslash( $fields['wpsc_checkout_details'] ); diff --git a/wpsc-admin/display-sales-logs.php b/wpsc-admin/display-sales-logs.php index 2b79bc6714..6f7b14a155 100755 --- a/wpsc-admin/display-sales-logs.php +++ b/wpsc-admin/display-sales-logs.php @@ -36,8 +36,8 @@ public function __construct() { // If individual purchase log, setup ID and action links. if ( isset( $_REQUEST['id'] ) && is_numeric( $_REQUEST['id'] ) ) { $this->log_id = (int) $_REQUEST['id']; - $this->log = new WPSC_Purchase_Log( $this->log_id ); - $this->notes = new WPSC_Purchase_Log_Notes( $this->log ); + $this->log = wpsc_get_order( $this->log_id ); + $this->notes = wpsc_get_order_notes( $this->log ); $this->can_edit = $this->log->can_edit(); } @@ -572,7 +572,7 @@ public static function maybe_delete_note_from_log( WPSC_Purchase_Log $log, $note if ( is_numeric( $note_id ) ) { check_admin_referer( 'delete-note', 'delete-note' ); - $notes = new WPSC_Purchase_Log_Notes( $log ); + $notes = wpsc_get_order_notes( $log ); $notes->remove( $note_id )->save(); @@ -759,7 +759,7 @@ public function process_bulk_action() { $ids = array_map( 'intval', $_REQUEST['post'] ); foreach ( $ids as $id ) { - $log = new WPSC_Purchase_Log( $id ); + $log = wpsc_get_order( $id ); $log->delete(); } diff --git a/wpsc-admin/init.php b/wpsc-admin/init.php index ca1f015b94..cf9d1372dd 100644 --- a/wpsc-admin/init.php +++ b/wpsc-admin/init.php @@ -358,7 +358,7 @@ function wpsc_purchase_log_action_downloads_lock( $log_id ) { */ function wpsc_purchase_log_action_delete( $log_id ) { - $log = new WPSC_Purchase_Log( $log_id ); + $log = wpsc_get_order( $log_id ); $deleted = $log->delete(); // Redirect back to purchase logs list @@ -426,7 +426,7 @@ function wpsc_purchlog_resend_email( $log_id = '' ) { $wpec_taxes_controller = new wpec_taxes_controller(); if ( is_numeric( $log_id ) ) { - $purchase_log = new WPSC_Purchase_Log( $log_id ); + $purchase_log = wpsc_get_order( $log_id ); return wpsc_send_customer_email( $purchase_log ); } } @@ -505,7 +505,7 @@ function wpsc_purchlog_bulk_modify() { } elseif ( $_POST['purchlog_multiple_status_change'] == 'delete' ) { foreach ( (array)$_POST['purchlogids'] as $purchlogid ) { - $log = new WPSC_Purchase_Log( $purchlogid ); + $log = wpsc_get_order( $purchlogid ); $deleted_log = $log->delete(); if ( $deleted_log ) { $deleted++; @@ -583,7 +583,7 @@ function wpsc_delete_purchlog( $purchlog_id = '' ) { return false; } - $log = new WPSC_Purchase_Log( $purchlog_id ); + $log = wpsc_get_order( $purchlog_id ); return $log->delete(); diff --git a/wpsc-components/marketplace-core-v1/library/Sputnik.php b/wpsc-components/marketplace-core-v1/library/Sputnik.php index 5ccc4f3fb5..1fbed33de8 100644 --- a/wpsc-components/marketplace-core-v1/library/Sputnik.php +++ b/wpsc-components/marketplace-core-v1/library/Sputnik.php @@ -295,7 +295,7 @@ public static function credentials() { */ public static function push_sales_data( $purchase_log_id, $current_status, $old_status, $purchase_log ) { - $purchase_log = new WPSC_Purchase_Log( $purchase_log_id ); + $purchase_log = wpsc_get_order( $purchase_log_id ); $id = absint( $purchase_log->get( 'id' ) ); @@ -343,7 +343,7 @@ public static function sales_data_postback() { unset( $data['id'] ); - $purchase_log = new WPSC_Purchase_Log( $data ); + $purchase_log = wpsc_get_order( $data ); $purchase_log->save(); $purchase_log_id = $purchase_log->get( 'id' ); From 7f003faf20dd973c0e18d7f3c0020be7a497e7f1 Mon Sep 17 00:00:00 2001 From: Justin Sternberg Date: Mon, 6 Feb 2017 12:27:27 -0500 Subject: [PATCH 04/13] Fix refund ajax action to follow ajax precedent and clean up UI --- wpsc-admin/ajax.php | 94 +++++++++++++++---------------- wpsc-admin/css/admin.css | 4 ++ wpsc-admin/display-sales-logs.php | 79 +++++++++++++------------- wpsc-admin/js/purchase-logs.js | 29 +++++----- 4 files changed, 105 insertions(+), 101 deletions(-) diff --git a/wpsc-admin/ajax.php b/wpsc-admin/ajax.php index 30571f660e..96b0908fa3 100644 --- a/wpsc-admin/ajax.php +++ b/wpsc-admin/ajax.php @@ -1,66 +1,66 @@ get( 'gateway' ); - $gateway = wpsc_get_payment_gateway( $gateway_id ); + $log = wpsc_get_order( $order_id ); + $gateway_id = $log->get( 'gateway' ); + $gateway = wpsc_get_payment_gateway( $gateway_id ); - try { - // Validate that the refund can occur - $refund_amount = $refund_amount ? $refund_amount : $log->get( 'totalprice' ); + try { + // Validate that the refund can occur + $refund_amount = $refund_amount ? $refund_amount : $log->get( 'totalprice' ); - if ( wpsc_payment_gateway_supports( $gateway_id, 'refunds' ) ) { - // Send api request to process refund. Returns Refund transaction ID - $result = $gateway->process_refund( $order_id, $refund_amount, $refund_reason, $manual ); + if ( wpsc_payment_gateway_supports( $gateway_id, 'refunds' ) ) { + // Send api request to process refund. Returns Refund transaction ID + $result = $gateway->process_refund( $order_id, $refund_amount, $refund_reason, $manual ); - do_action( 'wpsc_refund_processed', $log, $result, $refund_amount, $refund_reason ); + do_action( 'wpsc_refund_processed', $log, $result, $refund_amount, $refund_reason ); - if ( is_wp_error( $result ) ) { - throw new Exception( $result->get_error_message() ); - } elseif ( ! $result ) { - throw new Exception( __( 'Refund failed', 'wp-e-commerce' ) ); - } + if ( is_wp_error( $result ) ) { + return $result; } - if ( $log->get_remaining_refund() > 0 ) { - /** - * wpsc_order_partially_refunded. - * - * @since 4.0.0 - */ - do_action( 'wpsc_order_partially_refunded', $log ); - $response_data['status'] = 'partially_refunded'; - - } else { - /** - * wpsc_order_fully_refunded. - * - * @since 4.0.0 - */ - do_action( 'wpsc_order_fully_refunded', $log ); - $response_data['status'] = 'fully_refunded'; + if ( ! $result ) { + throw new Exception( __( 'Refund failed', 'wp-e-commerce' ) ); } + } - wp_send_json_success( $response_data ); + if ( $log->get_remaining_refund() > 0 ) { + /** + * wpsc_order_partially_refunded. + * + * @since 4.0.0 + */ + do_action( 'wpsc_order_partially_refunded', $log ); + $response_data['status'] = 'partially_refunded'; - } catch ( Exception $e ) { - wp_send_json_error( array( 'error' => $e->getMessage() ) ); + } else { + /** + * wpsc_order_fully_refunded. + * + * @since 4.0.0 + */ + do_action( 'wpsc_order_fully_refunded', $log ); + $response_data['status'] = 'fully_refunded'; } + + return $response_data; + + } catch ( Exception $e ) { + return new WP_Error( 'wpsc_ajax_purchase_log_refund_failed', $e->getMessage() ); } - return new WP_Error( 'wpsc_ajax_invalid_purchase_log_refund_items', __( 'Refund failed.', 'wp-e-commerce' ) ); } /** diff --git a/wpsc-admin/css/admin.css b/wpsc-admin/css/admin.css index 831e3a3900..0aa06b3f5f 100644 --- a/wpsc-admin/css/admin.css +++ b/wpsc-admin/css/admin.css @@ -2675,3 +2675,7 @@ a.wpsc_remove_meta { .wpsc-refund-ui { display: none; } + +.wp-core-ui .wpsc-refund-ui .button { + margin-right: 5px; +} diff --git a/wpsc-admin/display-sales-logs.php b/wpsc-admin/display-sales-logs.php index 6f7b14a155..62286ca7dc 100755 --- a/wpsc-admin/display-sales-logs.php +++ b/wpsc-admin/display-sales-logs.php @@ -228,11 +228,9 @@ public function items_ordered_box() {
- - - + + + @@ -288,44 +286,45 @@ public function items_ordered_box() { + + + + + + log->get( 'gateway' ), 'partial-refunds' ) ) : ?> + + + + + + + + + + + + + + +
- - - - - - log->get( 'gateway' ), 'partial-refunds' ) ) : ?> - - - - - - - - - - - - -
:log->get_total_refunded() );?>
- -
-
- -
-
-

- - - -
-

-
-
:log->get_total_refunded() );?>
+ +
+
+ +
+
+

+ + +

+
+ +
+ - + -
log_id ); ?> diff --git a/wpsc-admin/js/purchase-logs.js b/wpsc-admin/js/purchase-logs.js index 9780758f4f..626a7d0bf5 100644 --- a/wpsc-admin/js/purchase-logs.js +++ b/wpsc-admin/js/purchase-logs.js @@ -85,42 +85,43 @@ window.WPSC_Purchase_Logs_Admin = window.WPSC_Purchase_Logs_Admin || {}; $( '.wpsc-refund-ui' ).toggle(); }; - admin.refundItem = function() { - var $this = $( this ); - var $spinner = $this.siblings('.ajax-feedback'); - var api_refund = $this.is( '.do-api-refund' ); + admin.refundItem = function( evt ) { + var $button = $( this ); + var $spinner = $button.parents( 'tr' ).find('.spinner'); + var api_refund = $button.is( '.do-api-refund' ); var refund_string = api_refund ? wpsc.strings.confirm_refund_order : wpsc.strings.confirm_refund_order_manually; if ( ! window.confirm( refund_string ) ) { return; } - var refund_reason = $( 'input#refund_reason' ).val(); - var refund_amount = $( 'input#refund_amount' ).val(); - var data = { action : 'purchase_log_refund_items', order_id : wpsc.log_id, - refund_reason : refund_reason, - refund_amount : refund_amount, + refund_reason : $( 'input#refund_reason' ).val(), + refund_amount : $( 'input#refund_amount' ).val(), api_refund : api_refund, nonce : wpsc.purchase_log_refund_items_nonce }; var ajax_callback = function( response ) { - $spinner.toggleClass( 'ajax-feedback-active' ); - + $spinner.removeClass( 'is-active' ); if ( ! response.is_successful ) { if ( response.error ) { window.alert( response.error.messages.join( BR ) ); } + } else { - return; + setTimeout( function() { + // Re-spinner while we refresh page. + $spinner.addClass( 'is-active' ); + }, 900 ); + + window.location.href = window.location.href; } - window.location.href = window.location.href; }; - $spinner.toggleClass( 'ajax-feedback-active' ); + $spinner.addClass( 'is-active' ); $.wpsc_post( data, ajax_callback ); }; From d2e0a2bfdb21de33902b0e204e7ebc22aa752b61 Mon Sep 17 00:00:00 2001 From: Justin Sternberg Date: Mon, 6 Feb 2017 12:57:24 -0500 Subject: [PATCH 05/13] Add some doc blocks --- wpsc-includes/purchase-log-notes.class.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/wpsc-includes/purchase-log-notes.class.php b/wpsc-includes/purchase-log-notes.class.php index 028cdb27db..6014f2cfa0 100644 --- a/wpsc-includes/purchase-log-notes.class.php +++ b/wpsc-includes/purchase-log-notes.class.php @@ -142,6 +142,18 @@ protected function prepare_get_data() { return apply_filters( 'wpsc_get_purchase_log_notes', $this->data, $this ); } + /** + * Add a note to the log. + * + * @since 4.0 + * + * @param mixed $note_args String to add note. Optionally Accepts an array to specify note attributes: { + * @type string $type The note type. Defaults to 'default', but can be 'error'. + * @type string $status The note status. Defaults to 'public'. + * @type int $time The note timestamp. Defaults to time(). + * @type string $content The note text. + * } + */ public function add( $note_args ) { if ( ! is_array( $note_args ) ) { $note_args = self::parse_args( array( self::$map_keys[ self::KEY_CONTENT ] => $note_args ) ); @@ -150,6 +162,15 @@ public function add( $note_args ) { return $this->set( false, $note_args ); } + /** + * Remove a note from the log by the note_id (or index). + * + * @since 4.0 + * + * @param int $note_id Note index. + * + * @return WPSC_Query_Base The current object (for method chaining) + */ public function remove( $note_id ) { $this->fetch(); unset( $this->data[ $note_id ] ); From ff9de1d8e8377c535196cae27c4169d77720e729 Mon Sep 17 00:00:00 2001 From: Justin Sternberg Date: Mon, 6 Feb 2017 12:57:38 -0500 Subject: [PATCH 06/13] New add_note/add_refund_note methods/api to WPSC_Purchase_Log --- wpsc-includes/purchase-log.class.php | 44 ++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/wpsc-includes/purchase-log.class.php b/wpsc-includes/purchase-log.class.php index 6af93370aa..1df1106b81 100644 --- a/wpsc-includes/purchase-log.class.php +++ b/wpsc-includes/purchase-log.class.php @@ -1565,4 +1565,48 @@ public function get_remaining_refund() { return $this->get( 'totalprice' ) - $this->get_total_refunded(); } + /** + * Add a purchase log note. + * + * @since 3.12.0 + * + * @param mixed $note_text String to add note. Optionally Accepts an array to specify note attributes: { + * @type string $type The note type. Defaults to 'default', but can be 'error'. + * @type string $status The note status. Defaults to 'public'. + * @type int $time The note timestamp. Defaults to time(). + * @type string $content The note text. + * } + * + * @return WPSC_Purchase_Log The current object (for method chaining) + */ + public function add_note( $note_text ) { + static $notes = null; + + if ( ! ( $notes instanceof WPSC_Purchase_Log_Notes ) ) { + $notes = wpsc_get_order_notes( $this ); + } + + $notes->add( $note_text )->save(); + + return $this; + } + + /** + * Add a purchase log refund note. + * + * @since 3.12.0 + * + * @param mixed $note_text String to add refund note. + * @param string $reason_for_refund Optional reason for refund. Will display on a new line from default text. + * + * @return WPSC_Purchase_Log The current object (for method chaining) + */ + public function add_refund_note( $note_text, $reason_for_refund = '' ) { + if ( ! empty( $reason_for_refund ) ) { + $note_text .= sprintf( __( "\nReason: %s", 'wp-e-commerce' ), $reason_for_refund ); + } + + return $this->add_note( $note_text ); + } + } From ecd16093b6800aefbcb9e86f6fa14d321d3f1ac6 Mon Sep 17 00:00:00 2001 From: Justin Sternberg Date: Mon, 6 Feb 2017 12:58:28 -0500 Subject: [PATCH 07/13] use WPSC_Purchase_Log::add_refund_note from paypal gateway --- .../gateways/paypal-express-checkout.php | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/wpsc-components/merchant-core-v3/gateways/paypal-express-checkout.php b/wpsc-components/merchant-core-v3/gateways/paypal-express-checkout.php index 199f823f78..23d06c7422 100644 --- a/wpsc-components/merchant-core-v3/gateways/paypal-express-checkout.php +++ b/wpsc-components/merchant-core-v3/gateways/paypal-express-checkout.php @@ -1090,9 +1090,15 @@ public function process_refund( $order_id, $amount = 0.00, $reason = '', $manual if ( $manual ) { $current_refund = $log->get_total_refunded(); - $log->set( 'total_order_refunded' , $amount + $current_refund )->save(); - wpsc_purchlogs_update_notes( $log, sprintf( __( 'Refunded %s via Manual Refund', 'wp-e-commerce' ), wpsc_currency_display( $amount ) ) ); + $log + // Set a log meta entry + ->set( 'total_order_refunded' , $amount + $current_refund )->save() + ->add_refund_note( + sprintf( __( 'Refunded %s via Manual Refund', 'wp-e-commerce' ), wpsc_currency_display( $amount ) ), + $reason + ); + return true; } @@ -1125,11 +1131,16 @@ public function process_refund( $order_id, $amount = 0.00, $reason = '', $manual if ( 'Success' == $params['ACK'] || 'SuccessWithWarning' == $params['ACK'] ) { $this->log_error( $response ); - // Set a log meta entry + $current_refund = $log->get_total_refunded(); - $log->set( 'total_order_refunded' , $amount + $current_refund )->save(); - wpsc_purchlogs_update_notes( $log, sprintf( __( 'Refunded %s - Refund ID: %s', 'wp-e-commerce' ), wpsc_currency_display( $params['GROSSREFUNDAMT'] ), $params['REFUNDTRANSACTIONID'] ) ); + $log + // Set a log meta entry + ->set( 'total_order_refunded' , $amount + $current_refund )->save() + ->add_refund_note( + sprintf( __( 'Refunded %s - Refund ID: %s', 'wp-e-commerce' ), wpsc_currency_display( $params['GROSSREFUNDAMT'] ), $params['REFUNDTRANSACTIONID'] ), + $reason + ); return true; } From 4be33fdeee9c721258e7172fb62cd18dc2914666 Mon Sep 17 00:00:00 2001 From: Justin Sternberg Date: Mon, 6 Feb 2017 13:09:23 -0500 Subject: [PATCH 08/13] Log processing order is important when adding notes. So save, then add note. --- .../gateways/paypal-express-checkout.php | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/wpsc-components/merchant-core-v3/gateways/paypal-express-checkout.php b/wpsc-components/merchant-core-v3/gateways/paypal-express-checkout.php index 23d06c7422..cd52ce4d23 100644 --- a/wpsc-components/merchant-core-v3/gateways/paypal-express-checkout.php +++ b/wpsc-components/merchant-core-v3/gateways/paypal-express-checkout.php @@ -1091,13 +1091,13 @@ public function process_refund( $order_id, $amount = 0.00, $reason = '', $manual if ( $manual ) { $current_refund = $log->get_total_refunded(); - $log - // Set a log meta entry - ->set( 'total_order_refunded' , $amount + $current_refund )->save() - ->add_refund_note( - sprintf( __( 'Refunded %s via Manual Refund', 'wp-e-commerce' ), wpsc_currency_display( $amount ) ), - $reason - ); + // Set a log meta entry, and save log before adding refund note. + $log->set( 'total_order_refunded' , $amount + $current_refund )->save(); + + $log->add_refund_note( + sprintf( __( 'Refunded %s via Manual Refund', 'wp-e-commerce' ), wpsc_currency_display( $amount ) ), + $reason + ); return true; } @@ -1134,13 +1134,13 @@ public function process_refund( $order_id, $amount = 0.00, $reason = '', $manual $current_refund = $log->get_total_refunded(); - $log - // Set a log meta entry - ->set( 'total_order_refunded' , $amount + $current_refund )->save() - ->add_refund_note( - sprintf( __( 'Refunded %s - Refund ID: %s', 'wp-e-commerce' ), wpsc_currency_display( $params['GROSSREFUNDAMT'] ), $params['REFUNDTRANSACTIONID'] ), - $reason - ); + // Set a log meta entry, and save log before adding refund note. + $log->set( 'total_order_refunded' , $amount + $current_refund )->save(); + + $log->add_refund_note( + sprintf( __( 'Refunded %s - Refund ID: %s', 'wp-e-commerce' ), wpsc_currency_display( $params['GROSSREFUNDAMT'] ), $params['REFUNDTRANSACTIONID'] ), + $reason + ); return true; } From 726f56f085eb680a8e90a5cd26f933ce537689fb Mon Sep 17 00:00:00 2001 From: Justin Sternberg Date: Mon, 6 Feb 2017 13:12:59 -0500 Subject: [PATCH 09/13] Use log add note api instead of helper function --- wpsc-admin/display-sales-logs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wpsc-admin/display-sales-logs.php b/wpsc-admin/display-sales-logs.php index 62286ca7dc..769d89a1af 100755 --- a/wpsc-admin/display-sales-logs.php +++ b/wpsc-admin/display-sales-logs.php @@ -560,7 +560,7 @@ public static function maybe_add_note_to_log( WPSC_Purchase_Log $log, $note ) { if ( $note ) { check_admin_referer( 'wpsc_log_add_notes_nonce', 'wpsc_log_add_notes_nonce' ); - wpsc_purchlogs_update_notes( $log, wp_kses_post( $note ) ); + $log->add_note( wp_kses_post( $note ) ); wp_safe_redirect( esc_url_raw( remove_query_arg( 'wpsc_log_add_notes_nonce' ) ) ); exit; From 194faffbb0e30bcf40e475f5c80d636ce7229603 Mon Sep 17 00:00:00 2001 From: Justin Sternberg Date: Mon, 6 Feb 2017 13:28:34 -0500 Subject: [PATCH 10/13] Correct @since version tags --- wp-shopping-cart.php | 2 +- wpsc-admin/admin.php | 6 ++--- wpsc-admin/ajax.php | 18 +++++++------- wpsc-includes/purchase-log-notes.class.php | 28 +++++++++++----------- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/wp-shopping-cart.php b/wp-shopping-cart.php index 104d9410be..9530e8f479 100644 --- a/wp-shopping-cart.php +++ b/wp-shopping-cart.php @@ -143,7 +143,7 @@ public function load_old_textdomain( $mofile, $textdomain ) { /** * Sets table names as WPDB properties. * - * @since 4.0.0 + * @since 3.11.5 * @return array Array of custom tables */ public function setup_table_names() { diff --git a/wpsc-admin/admin.php b/wpsc-admin/admin.php index 528ab45d1e..06f7126c83 100644 --- a/wpsc-admin/admin.php +++ b/wpsc-admin/admin.php @@ -118,7 +118,7 @@ function wpsc_set_screen_option($status, $option, $value){ * @param string $taxonomy Taxonomy. * @param string $context Context. * - * @since 4.0.0 + * @since 3.11.5 * * @return array Filtered dropdown args. */ @@ -1521,7 +1521,7 @@ function wpsc_support_links( $links ) { * * @param array $args Array of removable query args. * - * @since 4.0.0 + * @since 3.11.5 * * @return array $args Array of removable query args. */ @@ -1538,7 +1538,7 @@ function wpsc_removable_query_args( $args ) { * @param array $bulk_messages Array of bulk messages. * @param int $bulk_counts The amount of messages affected. * - * @since 4.0.0 + * @since 3.11.5 * * @return array Array of bulk messages. */ diff --git a/wpsc-admin/ajax.php b/wpsc-admin/ajax.php index 96b0908fa3..e35fae97d0 100644 --- a/wpsc-admin/ajax.php +++ b/wpsc-admin/ajax.php @@ -41,7 +41,7 @@ function _wpsc_ajax_purchase_log_refund_items() { /** * wpsc_order_partially_refunded. * - * @since 4.0.0 + * @since 3.11.5 */ do_action( 'wpsc_order_partially_refunded', $log ); $response_data['status'] = 'partially_refunded'; @@ -50,7 +50,7 @@ function _wpsc_ajax_purchase_log_refund_items() { /** * wpsc_order_fully_refunded. * - * @since 4.0.0 + * @since 3.11.5 */ do_action( 'wpsc_order_fully_refunded', $log ); $response_data['status'] = 'fully_refunded'; @@ -521,7 +521,7 @@ function _wpsc_ajax_purchase_log_action_link() { /** * Remove purchase log item. * - * @since 4.0 + * @since 3.11.5 * @access private * * @return array|WP_Error $return Response args if successful, WP_Error if otherwise @@ -545,7 +545,7 @@ function _wpsc_ajax_remove_log_item() { /** * Update purchase log item quantity. * - * @since 4.0 + * @since 3.11.5 * @access private * * @return array|WP_Error $return Response args if successful, WP_Error if otherwise @@ -576,7 +576,7 @@ function _wpsc_ajax_update_log_item_qty() { /** * Add purchase log item. * - * @since 4.0 + * @since 3.11.5 * @access private * * @return array|WP_Error $return Response args if successful, WP_Error if otherwise @@ -661,7 +661,7 @@ function _wpsc_init_log_items( WPSC_Purchase_Log $log, $item_ids = array() ) { /** * Edit log contact details. * - * @since 4.0 + * @since 3.11.5 * @access private * * @return array|WP_Error $return Response args if successful, WP_Error if otherwise @@ -717,7 +717,7 @@ function _wpsc_ajax_edit_contact_details() { /** * Add a note to a log. * - * @since 4.0 + * @since 3.11.5 * @access private * * @return array|WP_Error $return Response args if successful, WP_Error if otherwise @@ -753,7 +753,7 @@ function _wpsc_ajax_add_note() { /** * Delete a note from a log. * - * @since 4.0 + * @since 3.11.5 * @access private * * @return array|WP_Error $return Response args if successful, WP_Error if otherwise @@ -774,7 +774,7 @@ function _wpsc_ajax_delete_note() { /** * Search for products. * - * @since 4.0 + * @since 3.11.5 * @access private * * @return array|WP_Error $return Response args if successful, WP_Error if otherwise diff --git a/wpsc-includes/purchase-log-notes.class.php b/wpsc-includes/purchase-log-notes.class.php index 6014f2cfa0..bb4e5ccdec 100644 --- a/wpsc-includes/purchase-log-notes.class.php +++ b/wpsc-includes/purchase-log-notes.class.php @@ -119,7 +119,7 @@ public function time_sort( $a, $b ) { * Prepares the return value for get() (apply_filters, etc). * * @access protected - * @since 4.0 + * @since 3.11.5 * * @param mixed $value Value fetched * @param string $key Key for $data. @@ -134,7 +134,7 @@ protected function prepare_get( $value, $key ) { * Prepares the return value for get_data() (apply_filters, etc). * * @access protected - * @since 4.0 + * @since 3.11.5 * * @return mixed */ @@ -145,7 +145,7 @@ protected function prepare_get_data() { /** * Add a note to the log. * - * @since 4.0 + * @since 3.11.5 * * @param mixed $note_args String to add note. Optionally Accepts an array to specify note attributes: { * @type string $type The note type. Defaults to 'default', but can be 'error'. @@ -165,7 +165,7 @@ public function add( $note_args ) { /** * Remove a note from the log by the note_id (or index). * - * @since 4.0 + * @since 3.11.5 * * @param int $note_id Note index. * @@ -183,7 +183,7 @@ public function remove( $note_id ) { * as arguments, or an associative array containing key value pairs. * * @access public - * @since 4.0 + * @since 3.11.5 * * @param mixed $key Name of the property (column), or an array containing * key value pairs @@ -217,7 +217,7 @@ public function set( $key, $value = null ) { * Saves the object back to the database. * * @access public - * @since 4.0 + * @since 3.11.5 * * @return mixed */ @@ -278,7 +278,7 @@ public function save() { /** * Merge arguments into defaults array. * - * @since 4.0 + * @since 3.11.5 * * @param array $args Value to merge with defaults. * @return array Merged arguments with defaults. @@ -295,7 +295,7 @@ public static function parse_args_for_db( array $args ) { /** * Merge arguments into defaults array. * - * @since 4.0 + * @since 3.11.5 * * @param array $args Value to merge with defaults. * @return array Merged arguments with defaults. @@ -312,7 +312,7 @@ public static function parse_args( array $args ) { /** * Get current for Iterator. * - * @since 4.0 + * @since 3.11.5 * * @return mixed */ @@ -324,7 +324,7 @@ public function current() { /** * Get key for Iterator. * - * @since 4.0 + * @since 3.11.5 * * @return scalar */ @@ -336,7 +336,7 @@ public function key() { /** * Get next for Iterator. * - * @since 4.0 + * @since 3.11.5 * * @return void */ @@ -348,7 +348,7 @@ public function next() { /** * Get prev for Iterator. * - * @since 4.0 + * @since 3.11.5 * * @return void */ @@ -360,7 +360,7 @@ public function prev() { /** * Get rewind for Iterator. * - * @since 4.0 + * @since 3.11.5 * * @return void */ @@ -372,7 +372,7 @@ public function rewind() { /** * Get valid for Iterator. * - * @since 4.0 + * @since 3.11.5 * * @return boolean */ From d9acefface04815623e62e4f792fc7655c5c90ed Mon Sep 17 00:00:00 2001 From: Justin Sternberg Date: Mon, 6 Feb 2017 13:59:34 -0500 Subject: [PATCH 11/13] Update many "4.0" @since tags to accurately represent the version they were introduced --- .../includes/duplicate-product-class.php | 28 +++++----- .../purchase-log-list-table-class.php | 4 +- .../classes/payment-gateway.php | 12 ++-- .../gateways/amazon-payments.php | 22 ++++---- .../gateways/paypal-digital-goods.php | 42 +++++++------- .../gateways/paypal-express-checkout.php | 30 +++++----- .../merchant-core-v3/gateways/paypal-pro.php | 30 +++++----- .../assets/emails/hard-decline-email-de.php | 4 +- .../assets/emails/hard-decline-email-en.php | 4 +- .../assets/emails/hard-decline-email-es.php | 4 +- .../assets/emails/hard-decline-email-fr.php | 4 +- .../assets/emails/hard-decline-email-it.php | 4 +- .../assets/emails/soft-decline-email-de.php | 4 +- .../assets/emails/soft-decline-email-en.php | 4 +- .../assets/emails/soft-decline-email-es.php | 4 +- .../assets/emails/soft-decline-email-fr.php | 4 +- .../assets/emails/soft-decline-email-it.php | 4 +- wpsc-core/js/wp-e-commerce.js | 2 +- wpsc-core/wpsc-functions.php | 2 +- wpsc-includes/category.functions.php | 2 +- wpsc-includes/checkout-form-data.class.php | 22 ++++---- wpsc-includes/coupon.class.php | 56 ++++++++++--------- wpsc-includes/mimetype.php | 4 +- wpsc-includes/product-template.php | 8 +-- wpsc-includes/purchase-log.class.php | 34 +++++------ wpsc-includes/purchase-log.helpers.php | 10 ++-- wpsc-includes/query-base.class.php | 44 +++++++-------- wpsc-includes/variations.class.php | 10 ++-- wpsc-includes/wp-cli/wpsc-wp-cli-category.php | 2 +- .../wp-cli/wpsc-wp-cli-product-tag.php | 2 +- ...psc-customizer-thumbnail-control.class.php | 4 +- wpsc-includes/wpsc-customizer.class.php | 4 +- wpsc-includes/wpsc-logging.class.php | 4 +- 33 files changed, 211 insertions(+), 207 deletions(-) diff --git a/wpsc-admin/includes/duplicate-product-class.php b/wpsc-admin/includes/duplicate-product-class.php index 48777d0130..290a7ac983 100644 --- a/wpsc-admin/includes/duplicate-product-class.php +++ b/wpsc-admin/includes/duplicate-product-class.php @@ -5,7 +5,7 @@ * * @package WP eCommerce * @subpackage Duplicate Product Class - * @since 4.0 + * @since 3.11.0 */ /** @@ -13,7 +13,7 @@ * * Used to duplicate products. * - * @since 4.0 + * @since 3.11.0 */ class WPSC_Duplicate_Product { @@ -24,7 +24,7 @@ class WPSC_Duplicate_Product { /** * Create new duplicate product * - * @since 4.0 + * @since 3.11.0 * * @param int $post_id Post ID. * @param int|false $new_parent_id Optional. New post parent ID. @@ -40,7 +40,7 @@ public function __construct( $post_id, $new_parent_id = false, $new_post_id = nu /** * Duplicates a product * - * @since 4.0 + * @since 3.11.0 * * @uses wp_insert_post() Inserts a new post to the database. * @@ -117,7 +117,7 @@ public function duplicate_product_process() { /** * Copy the taxonomies of a post to another post * - * @since 4.0 + * @since 3.11.0 * * @uses get_object_taxonomies() Gets taxonomies for the given object. * @uses wpsc_get_product_terms() Gets terms for the product taxonomies. @@ -145,7 +145,7 @@ public function duplicate_taxonomies() { /** * Copy the meta information of a post to another post * - * @since 4.0 + * @since 3.11.0 * * @uses $wpdb WordPress database object for queries. * @uses get_results() Gets generic multirow results from the database. @@ -197,7 +197,7 @@ public function duplicate_product_meta() { * duplicated this function is used to update the gallery meta to * refer to the IDs of any duplicated media. * - * @since 4.0 + * @since 3.11.0 * * @param array $duplicated_children Associative array mapping original child IDs to duplicated child IDs. */ @@ -248,7 +248,7 @@ private function update_duplicate_product_gallery_meta( $duplicated_children ) { * the duplicated product and offers the opportunity to change the featured image * of the duplicated product via the 'wpsc_duplicate_product_thumbnail' filter. * - * @since 4.0 + * @since 3.11.0 */ private function duplicate_product_thumbnail() { @@ -277,7 +277,7 @@ private function duplicate_product_thumbnail() { /** * Duplicates product children and meta * - * @since 4.0 + * @since 3.11.0 * * @uses get_posts() Gets an array of posts given array of arguments. * @@ -331,7 +331,7 @@ private function duplicate_children() { * Uses a portion of code from media_sideload_image() in `wp-admin/includes/media.php` * to check file before downloading from URL. * - * @since 4.0 + * @since 3.11.0 * * @uses get_post_type() Gets post type. * @uses wp_get_attachment_url() Gets attachment URL. @@ -411,7 +411,7 @@ public function duplicate_product_image_process() { /** * Get Post ID * - * @since 4.0 + * @since 3.11.0 * * @return int Post ID. */ @@ -423,7 +423,7 @@ public function get_post_id() { /** * Get New Post ID * - * @since 4.0 + * @since 3.11.0 * * @return int Post ID. */ @@ -435,7 +435,7 @@ public function get_new_post_id() { /** * Get New Parent ID * - * @since 4.0 + * @since 3.11.0 * * @param int $default Default parent ID. * @return int Post ID. @@ -444,4 +444,4 @@ public function get_new_parent_id( $default = 0 ) { return false === $this->new_parent_id ? $default : $this->new_parent_id; } -} \ No newline at end of file +} diff --git a/wpsc-admin/includes/purchase-log-list-table-class.php b/wpsc-admin/includes/purchase-log-list-table-class.php index 1f0b16863f..ea07aa3a83 100644 --- a/wpsc-admin/includes/purchase-log-list-table-class.php +++ b/wpsc-admin/includes/purchase-log-list-table-class.php @@ -214,7 +214,7 @@ public function prepare_items() { * prior 3 months, this year, last year. You can insert your own custom periods by filtering * either based on the $period_flag or just filter the final query setup. * - * @since 4.0 + * @since 3.11.5 * * @param array $period_flag The period requested from $_REQUEST['m']. * @@ -855,7 +855,7 @@ public function get_bulk_actions() { /** * Filter the available bulk actions on the purchase log listing screen. * - * @since 4.0 + * @since 3.11.5 * * @param array $actions The bulk actions currently defined. */ diff --git a/wpsc-components/merchant-core-v3/classes/payment-gateway.php b/wpsc-components/merchant-core-v3/classes/payment-gateway.php index 316a55d00f..71ab033731 100644 --- a/wpsc-components/merchant-core-v3/classes/payment-gateway.php +++ b/wpsc-components/merchant-core-v3/classes/payment-gateway.php @@ -356,7 +356,7 @@ public static function get_active_gateways() { * Initialize the Active Gateways * * @access public - * @since 4.0 + * @since 3.9.0 * * @return void */ @@ -380,7 +380,7 @@ public static function initialize_gateways() { * * @link http://www.currency-iso.org/dam/downloads/table_a1.xml * - * @since 4.0 + * @since 3.9.0 * * @return array Currency ISO codes that do not use fractions. */ @@ -417,7 +417,7 @@ public static function currencies_without_fractions() { * * MC (monaco) and IM (Isle of Man, part of UK) also use VAT. * - * @since 4.0 + * @since 3.9.0 * @param $type Type of countries to retrieve. Blank for EU member countries. eu_vat for EU VAT countries. * @return string[] */ @@ -545,7 +545,7 @@ public function default_credit_card_form( $args = array(), $fields = array() ) { * * @param string $feature string The name of a feature to test support for. * @return bool True if the gateway supports the feature, false otherwise. - * @since 4.0 + * @since 3.9.0 */ public function supports( $feature ) { return apply_filters( 'wpsc_payment_gateway_supports', in_array( $feature, $this->supports ) ? true : false, $feature, $this ); @@ -745,7 +745,7 @@ public function __construct() { * You should use this function for hooks with actions and filters that are required by the gateway. * * @access public - * @since 4.0 + * @since 3.9.0 * * @return void */ @@ -762,7 +762,7 @@ public function init() {} * @param string $reason * @param boolean $manual If refund is a manual refund. * - * @since 4.0.0 + * @since 3.9.0 * @return bool|WP_Error True or false based on success, or a WP_Error object */ public function process_refund( $order_id, $amount = 0.00, $reason = '', $manual = false ) { diff --git a/wpsc-components/merchant-core-v3/gateways/amazon-payments.php b/wpsc-components/merchant-core-v3/gateways/amazon-payments.php index c3ce2ccbb3..e30d593de5 100644 --- a/wpsc-components/merchant-core-v3/gateways/amazon-payments.php +++ b/wpsc-components/merchant-core-v3/gateways/amazon-payments.php @@ -114,7 +114,7 @@ public static function load() { * * @access public * - * @since 4.0 + * @since 3.11.0 * * @return void */ @@ -382,7 +382,7 @@ public function process() { * * If it is declined for any other reason, they're basically out of luck. * - * @since 4.0 + * @since 3.11.0 * * @param WPSC_Purchase_Log $order Current purchase log for transaction. * @return void @@ -412,7 +412,7 @@ private function handle_declined_transaction( $order ) { * @param array $buyer Buyer information * @param array $address Shipping information * - * @since 4.0 + * @since 3.11.0 */ private function set_customer_address( $buyer, $address ) { @@ -480,7 +480,7 @@ private function set_customer_address( $buyer, $address ) { /** * Maybe hide standard checkout button on the cart, if enabled * - * @since 4.0 + * @since 3.11.0 */ public function maybe_hide_standard_checkout_button() { if ( $this->setting->get( 'hide_button_display' ) ) { @@ -637,7 +637,7 @@ public function checkout_button( $cart_table, $context ) { * Retrieve the IPN URL for Amazon * * @access public - * @since 4.0 + * @since 3.11.0 * @return string */ private function get_amazon_ipn_url() { @@ -785,7 +785,7 @@ public function payment_widget() { * * This function primarily effects TEv1 * - * @since 4.0 + * @since 3.11.0 */ public function remove_gateways() { @@ -797,7 +797,7 @@ public function remove_gateways() { * * This function effects TEv2. * - * @since 4.0 + * @since 3.11.0 */ public function remove_gateways_v2( $fields ) { foreach ( $fields as $i => $field ) { @@ -1570,7 +1570,7 @@ public function close_authorization( $amazon_authorization_id ) { * Process IPN messages from Amazon * * @access public - * @since 4.0 + * @since 3.11.0 * @return void */ public function process_ipn() { @@ -1667,7 +1667,7 @@ public function process_ipn() { * * Templates are named by language and type. * - * @since 4.0 + * @since 3.11.0 * * @param boolean $hard Whether it was a hard decline (invalid payment) or soft (systems). * @return boolean $mail Whether or not email was sent. @@ -1715,7 +1715,7 @@ public static function email_content_type( $type ) { /** * Retrieves the email template path (and subject) for declined email notifications. * - * @since 4.0 + * @since 3.11.0 * @param boolean $hard Whether or not decline is "hard". Hard declined methods may not be retried. * * @return array Array of template part path and subject line. @@ -1855,4 +1855,4 @@ public function refund_payment( $capture_id, $amount, $note ) { } } } -} \ No newline at end of file +} diff --git a/wpsc-components/merchant-core-v3/gateways/paypal-digital-goods.php b/wpsc-components/merchant-core-v3/gateways/paypal-digital-goods.php index c45c527295..66986510c3 100644 --- a/wpsc-components/merchant-core-v3/gateways/paypal-digital-goods.php +++ b/wpsc-components/merchant-core-v3/gateways/paypal-digital-goods.php @@ -15,7 +15,7 @@ class WPSC_Payment_Gateway_Paypal_Digital_Goods extends WPSC_Payment_Gateway_Pay * * @param array $options * - * @since 3.9 + * @since 3.9.0 */ public function __construct( $options ) { require_once( 'php-merchant/gateways/paypal-digital-goods.php' ); @@ -43,7 +43,7 @@ public function __construct( $options ) { * Run the gateway hooks * * @access public - * @since 4.0 + * @since 3.9.0 * * @return void */ @@ -57,7 +57,7 @@ public function init() { // Load DG scripts and styles add_action( 'wp_enqueue_scripts', array( 'WPSC_Payment_Gateway_Paypal_Digital_Goods', 'dg_script' ) ); - + // Express Checkout for DG Button add_action( 'wpsc_cart_item_table_form_actions_left', array( $this, 'add_ecs_button' ), 2, 2 ); @@ -68,7 +68,7 @@ public function init() { /** * Toggles Digital Goods option based on whether or not shipping is being used on the given cart. * - * @since 4.0 + * @since 3.9.0 * * @param array $fields Payment method form fields * @@ -149,7 +149,7 @@ public function review_order_callback( $url ) { * * @return void * - * @since 3.9 + * @since 3.9.0 */ public static function dg_script() { $dg_loc = array( @@ -174,7 +174,7 @@ public static function dg_script() { * No payment gateway is selected by default * * @access public - * @since 3.9 + * @since 3.9.0 * * @param array $fields * @@ -193,7 +193,7 @@ public static function filter_unselect_default( $fields ) { * * @return string * - * @since 3.9 + * @since 3.9.0 */ protected function get_return_url() { $redirect = add_query_arg( array( @@ -211,7 +211,7 @@ protected function get_return_url() { * * @return void * - * @since 3.9 + * @since 3.9.0 */ public function callback_return_url_redirect() { // Session id @@ -270,7 +270,7 @@ public function callback_return_url_redirect() { * * @return string * - * @since 3.9 + * @since 3.9.0 */ protected function get_original_return_url( $session_id ) { $transact_url = get_option( 'transact_url' ); @@ -298,7 +298,7 @@ protected function get_original_return_url( $session_id ) { * * @return string * - * @since 3.9 + * @since 3.9.0 */ protected function get_cancel_url() { $redirect = add_query_arg( array( @@ -315,7 +315,7 @@ protected function get_cancel_url() { * * @return void * - * @since 3.9 + * @since 3.9.0 */ public function callback_cancel_url_redirect() { // Page Styles @@ -356,7 +356,7 @@ public function callback_cancel_url_redirect() { * * @return string * - * @since 3.9 + * @since 3.9.0 */ protected function get_original_cancel_url() { return apply_filters( 'wpsc_paypal_digital_goods_cancel_url', $this->get_shopping_cart_payment_url() ); @@ -367,7 +367,7 @@ protected function get_original_cancel_url() { * * @return string * - * @since 3.9 + * @since 3.9.0 */ protected function get_notify_url() { $location = add_query_arg( array( @@ -383,7 +383,7 @@ protected function get_notify_url() { * * @return void * - * @since 3.9 + * @since 3.9.0 */ public function callback_ipn() { $ipn = new PHP_Merchant_Paypal_IPN( false, (bool) $this->setting->get( 'sandbox_mode', false ) ); @@ -418,7 +418,7 @@ public function callback_ipn() { * * @return null * - * @since 3.9 + * @since 3.9.0 */ public function callback_confirm_transaction() { @@ -434,7 +434,7 @@ public function callback_confirm_transaction() { /** * Process the transaction through the PayPal APIs * - * @since 3.9 + * @since 3.9.0 */ public function callback_process_confirmed_payment() { $args = array_map( 'urldecode', $_GET ); @@ -497,7 +497,7 @@ public function callback_process_confirmed_payment() { * * @return void * - * @since 3.9 + * @since 3.9.0 */ public function callback_display_paypal_error_redirect() { // Redirect Location @@ -551,7 +551,7 @@ public function callback_display_generic_error() { /** * Error Page Template * - * @since 3.9 + * @since 3.9.0 */ public function filter_paypal_error_page() { $errors = wpsc_get_customer_meta( 'paypal_express_checkout_errors' ); @@ -574,7 +574,7 @@ public function filter_paypal_error_page() { /** * Generic Error Page Template * - * @since 3.9 + * @since 3.9.0 */ public function filter_generic_error_page() { ob_start(); @@ -589,7 +589,7 @@ public function filter_generic_error_page() { /** * Settings Form Template * - * @since 3.9 + * @since 3.9.0 */ public function setup_form() { $paypal_currency = $this->get_currency_code(); @@ -732,7 +732,7 @@ public function setup_form() { * @param array $args * @return void * - * @since 3.9 + * @since 3.9.0 */ public function process( $args = array() ) { $total = $this->convert( $this->purchase_log->get( 'totalprice' ) ); diff --git a/wpsc-components/merchant-core-v3/gateways/paypal-express-checkout.php b/wpsc-components/merchant-core-v3/gateways/paypal-express-checkout.php index cd52ce4d23..8a59ebe016 100644 --- a/wpsc-components/merchant-core-v3/gateways/paypal-express-checkout.php +++ b/wpsc-components/merchant-core-v3/gateways/paypal-express-checkout.php @@ -18,7 +18,7 @@ class WPSC_Payment_Gateway_Paypal_Express_Checkout extends WPSC_Payment_Gateway * @param array $options * @param bool $child * - * @since 3.9 + * @since 3.9.0 */ public function __construct( $options, $child = false ) { parent::__construct(); @@ -216,7 +216,7 @@ public function review_order_callback( $url ) { * Run the gateway hooks * * @access public - * @since 4.0 + * @since 3.9.0 * * @return void */ @@ -234,7 +234,7 @@ public function init() { * @param array $fields * @return array * - * @since 3.9 + * @since 3.9.0 */ public static function filter_unselect_default( $fields ) { foreach ( $fields as $i => $field ) { @@ -250,7 +250,7 @@ public static function filter_unselect_default( $fields ) { * @access public * @return string * - * @since 3.9 + * @since 3.9.0 */ public function get_mark_html() { $html = 'PayPal Logo'; @@ -264,7 +264,7 @@ public function get_mark_html() { * @param array $data Arguments to encode with the URL * @return string * - * @since 3.9 + * @since 3.9.0 */ public function get_redirect_url( $data = array() ) { @@ -550,7 +550,7 @@ public function review_order_shipping_details( $output ) { * * @return bool * - * @since 3.9 + * @since 3.9.0 */ public function callback_confirm_transaction() { if ( ! isset( $_REQUEST['sessionid'] ) || ! isset( $_REQUEST['token'] ) || ! isset( $_REQUEST['PayerID'] ) ) { @@ -571,7 +571,7 @@ public function callback_confirm_transaction() { /** * Process the transaction through the PayPal APIs * - * @since 3.9 + * @since 3.9.0 */ public function do_transaction() { $args = array_map( 'urldecode', $_GET ); @@ -753,7 +753,7 @@ public function callback_process_confirmed_payment() { /** * Error Page Template * - * @since 3.9 + * @since 3.9.0 */ public function filter_paypal_error_page() { $errors = wpsc_get_customer_meta( 'paypal_express_checkout_errors' ); @@ -776,7 +776,7 @@ public function filter_paypal_error_page() { /** * Generic Error Page Template * - * @since 3.9 + * @since 3.9.0 */ public function filter_generic_error_page() { ob_start(); @@ -791,7 +791,7 @@ public function filter_generic_error_page() { /** * Settings Form Template * - * @since 3.9 + * @since 3.9.0 */ public function setup_form() { $paypal_currency = $this->get_currency_code(); @@ -951,7 +951,7 @@ public function setup_form() { * * @return bool * - * @since 3.9 + * @since 3.9.0 */ protected function is_currency_supported() { return in_array( parent::get_currency_code(), $this->gateway->get_supported_currencies() ); @@ -962,7 +962,7 @@ protected function is_currency_supported() { * * @return string * - * @since 3.9 + * @since 3.9.0 */ public function get_currency_code() { $code = parent::get_currency_code(); @@ -980,7 +980,7 @@ public function get_currency_code() { * * @return integer * - * @since 3.9 + * @since 3.9.0 */ protected function convert( $amt ) { if ( $this->is_currency_supported() ) { @@ -995,7 +995,7 @@ protected function convert( $amt ) { * * @return void * - * @since 3.9 + * @since 3.9.0 */ public function process() { $total = $this->convert( $this->purchase_log->get( 'totalprice' ) ); @@ -1046,7 +1046,7 @@ public function process() { * @param PHP_Merchant_Paypal_Express_Checkout_Response $response * @return void * - * @since 3.9 + * @since 3.9.0 */ public function log_error( $response ) { if ( $this->setting->get( 'debugging' ) ) { diff --git a/wpsc-components/merchant-core-v3/gateways/paypal-pro.php b/wpsc-components/merchant-core-v3/gateways/paypal-pro.php index 55cee65013..161f91802b 100644 --- a/wpsc-components/merchant-core-v3/gateways/paypal-pro.php +++ b/wpsc-components/merchant-core-v3/gateways/paypal-pro.php @@ -13,7 +13,7 @@ class WPSC_Payment_Gateway_Paypal_Pro extends WPSC_Payment_Gateway { * @param array $options * @return void * - * @since 3.9 + * @since 3.9.0 */ public function __construct( $options ) { parent::__construct(); @@ -39,7 +39,7 @@ public function __construct( $options ) { * Run the gateway hooks * * @access public - * @since 4.0 + * @since 3.9.0 * * @return void */ @@ -61,7 +61,7 @@ public function init() { * @param array $fields * @return array * - * @since 3.9 + * @since 3.9.0 */ public static function filter_unselect_default( $fields ) { foreach ( $fields as $i=>$field ) { @@ -76,7 +76,7 @@ public static function filter_unselect_default( $fields ) { * * @return void * - * @since 3.9 + * @since 3.9.0 */ public static function pro_script() { if ( wpsc_is_checkout() ) { @@ -96,7 +96,7 @@ public static function pro_script() { * @access public * @return string * - * @since 3.9 + * @since 3.9.0 */ public function get_mark_html() { $html = '' . esc_attr__( 'Credit Card Icons', 'wp-e-commerce' ) .''; @@ -198,7 +198,7 @@ public function callback_ipn() { * * @return bool * - * @since 3.9 + * @since 3.9.0 */ public function callback_confirm_transaction() { if ( ! isset( $_REQUEST['sessionid'] ) || ! isset( $_REQUEST['tx'] ) ) { @@ -215,7 +215,7 @@ public function callback_confirm_transaction() { /** * Process the transaction through the PayPal APIs * - * @since 3.9 + * @since 3.9.0 */ public function do_transaction() { $args = array_map( 'urldecode', $_GET ); @@ -335,7 +335,7 @@ public function callback_process_confirmed_payment() { /** * Error Page Template * - * @since 3.9 + * @since 3.9.0 */ public function filter_paypal_error_page() { $errors = wpsc_get_customer_meta( 'paypal_pro_errors' ); @@ -358,7 +358,7 @@ public function filter_paypal_error_page() { /** * Generic Error Page Template * - * @since 3.9 + * @since 3.9.0 */ public function filter_generic_error_page() { ob_start(); @@ -373,7 +373,7 @@ public function filter_generic_error_page() { /** * Settings Form Template * - * @since 3.9 + * @since 3.9.0 */ public function setup_form() { $paypal_currency = $this->get_currency_code(); @@ -485,7 +485,7 @@ public function setup_form() { * * @return bool * - * @since 3.9 + * @since 3.9.0 */ protected function is_currency_supported() { return in_array( parent::get_currency_code(), $this->gateway->get_supported_currencies() ); @@ -496,7 +496,7 @@ protected function is_currency_supported() { * * @return string * - * @since 3.9 + * @since 3.9.0 */ public function get_currency_code() { $code = parent::get_currency_code(); @@ -514,7 +514,7 @@ public function get_currency_code() { * * @return integer * - * @since 3.9 + * @since 3.9.0 */ protected function convert( $amt ) { if ( $this->is_currency_supported() ) { @@ -529,7 +529,7 @@ protected function convert( $amt ) { * * @return void * - * @since 3.9 + * @since 3.9.0 */ public function process() { $total = $this->convert( $this->purchase_log->get( 'totalprice' ) ); @@ -598,7 +598,7 @@ public function process() { * @param PHP_Merchant_Paypal_Pro_Response $response * @return void * - * @since 3.9 + * @since 3.9.0 */ public function log_error( $response ) { if ( $this->setting->get( 'debugging' ) ) { diff --git a/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/hard-decline-email-de.php b/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/hard-decline-email-de.php index 503b6047ef..54e905bab1 100644 --- a/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/hard-decline-email-de.php +++ b/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/hard-decline-email-de.php @@ -9,7 +9,7 @@ * * @author WP eCommerce * @package WP-e-Commerce/Templates/Emails - * @version 4.0 + * @version 3.9.0 */ ?> @@ -21,4 +21,4 @@ Mit freundlichen Grüßen - \ No newline at end of file + diff --git a/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/hard-decline-email-en.php b/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/hard-decline-email-en.php index 5729e4faad..ba4833f289 100644 --- a/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/hard-decline-email-en.php +++ b/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/hard-decline-email-en.php @@ -9,7 +9,7 @@ * * @author WP eCommerce * @package WP-e-Commerce/Templates/Emails - * @version 4.0 + * @version 3.9.0 */ ?> @@ -24,4 +24,4 @@ Kind regards, - \ No newline at end of file + diff --git a/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/hard-decline-email-es.php b/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/hard-decline-email-es.php index b578a1ff44..68414955e1 100644 --- a/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/hard-decline-email-es.php +++ b/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/hard-decline-email-es.php @@ -9,7 +9,7 @@ * * @author WP eCommerce * @package WP-e-Commerce/Templates/Emails - * @version 4.0 + * @version 3.9.0 */ ?> @@ -19,4 +19,4 @@ Gracias por elegir Pagar con Amazon, - \ No newline at end of file + diff --git a/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/hard-decline-email-fr.php b/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/hard-decline-email-fr.php index 6575c52f22..734f41cd22 100644 --- a/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/hard-decline-email-fr.php +++ b/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/hard-decline-email-fr.php @@ -9,7 +9,7 @@ * * @author WP eCommerce * @package WP-e-Commerce/Templates/Emails - * @version 4.0 + * @version 3.9.0 */ ?> @@ -19,4 +19,4 @@ Meilleures salutations, - \ No newline at end of file + diff --git a/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/hard-decline-email-it.php b/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/hard-decline-email-it.php index e0e7bb11ce..8e4027efe7 100644 --- a/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/hard-decline-email-it.php +++ b/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/hard-decline-email-it.php @@ -9,7 +9,7 @@ * * @author WP eCommerce * @package WP-e-Commerce/Templates/Emails - * @version 4.0 + * @version 3.9.0 */ ?> @@ -21,4 +21,4 @@ Cordiali saluti, - \ No newline at end of file + diff --git a/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/soft-decline-email-de.php b/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/soft-decline-email-de.php index 8c06e8e8eb..866ef1c9da 100644 --- a/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/soft-decline-email-de.php +++ b/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/soft-decline-email-de.php @@ -9,7 +9,7 @@ * * @author WP eCommerce * @package WP-e-Commerce/Templates/Emails - * @version 4.0 + * @version 3.9.0 */ ?> @@ -23,4 +23,4 @@ Mit freundlichen Grüßen - \ No newline at end of file + diff --git a/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/soft-decline-email-en.php b/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/soft-decline-email-en.php index 9e6948d6e9..4568f8f2af 100644 --- a/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/soft-decline-email-en.php +++ b/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/soft-decline-email-en.php @@ -9,7 +9,7 @@ * * @author WP eCommerce * @package WP-e-Commerce/Templates/Emails - * @version 4.0 + * @version 3.9.0 */ ?> @@ -24,4 +24,4 @@ Kind regards, - \ No newline at end of file + diff --git a/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/soft-decline-email-es.php b/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/soft-decline-email-es.php index 9fb919912c..4f350f0998 100644 --- a/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/soft-decline-email-es.php +++ b/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/soft-decline-email-es.php @@ -9,7 +9,7 @@ * * @author WP eCommerce * @package WP-e-Commerce/Templates/Emails - * @version 4.0 + * @version 3.9.0 */ ?> @@ -23,4 +23,4 @@ Gracias por elegir Pagar con Amazon, - \ No newline at end of file + diff --git a/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/soft-decline-email-fr.php b/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/soft-decline-email-fr.php index 60259d2995..e303dfa437 100644 --- a/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/soft-decline-email-fr.php +++ b/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/soft-decline-email-fr.php @@ -9,7 +9,7 @@ * * @author WP eCommerce * @package WP-e-Commerce/Templates/Emails - * @version 4.0 + * @version 3.9.0 */ ?> @@ -23,4 +23,4 @@ Meilleures salutations, - \ No newline at end of file + diff --git a/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/soft-decline-email-it.php b/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/soft-decline-email-it.php index c620de9fde..6a2f78ff1a 100644 --- a/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/soft-decline-email-it.php +++ b/wpsc-components/merchant-core-v3/libraries/amazon-payments/assets/emails/soft-decline-email-it.php @@ -9,7 +9,7 @@ * * @author WP eCommerce * @package WP-e-Commerce/Templates/Emails - * @version 4.0 + * @version 3.9.0 */ ?> @@ -25,4 +25,4 @@ Cordiali saluti, - \ No newline at end of file + diff --git a/wpsc-core/js/wp-e-commerce.js b/wpsc-core/js/wp-e-commerce.js index 9484a1d1d5..9cd40ccf74 100755 --- a/wpsc-core/js/wp-e-commerce.js +++ b/wpsc-core/js/wp-e-commerce.js @@ -110,7 +110,7 @@ function wpsc_var_set( name, value ) { * Create an tags. * @param {string|int|float} [value=''] The value's option, (for the "value" attribute). diff --git a/wpsc-core/wpsc-functions.php b/wpsc-core/wpsc-functions.php index 71c86dfdb2..d9304de9a5 100644 --- a/wpsc-core/wpsc-functions.php +++ b/wpsc-core/wpsc-functions.php @@ -993,7 +993,7 @@ function _wpsc_clear_wp_cache_on_version_change() { * * In a future version, we will likely have a `System` page that would include a link to the repair.php page. * - * @since 4.0 + * @since 3.11.0 * * @param array $tables Core tables * diff --git a/wpsc-includes/category.functions.php b/wpsc-includes/category.functions.php index a716878db2..63e44bb0b2 100755 --- a/wpsc-includes/category.functions.php +++ b/wpsc-includes/category.functions.php @@ -158,7 +158,7 @@ function wpsc_get_terms_variation_sort_filter( $terms ) { * By default, taxonomy queries include posts assigned to child categories. * To disable this the taxonomy query needs to set `include_children` to false. * - * @since 4.0 + * @since 3.11.0 * @access private * * @param WP_Query $query Query object. diff --git a/wpsc-includes/checkout-form-data.class.php b/wpsc-includes/checkout-form-data.class.php index 8fc34550d4..417f5bfeff 100644 --- a/wpsc-includes/checkout-form-data.class.php +++ b/wpsc-includes/checkout-form-data.class.php @@ -41,7 +41,7 @@ public function __construct( $log_id, $pre_fetch = true ) { * Fetches the actual $data array. * * @access protected - * @since 4.0 + * @since 3.11.5 * * @return WPSC_Checkout_Form_Data */ @@ -101,7 +101,7 @@ protected function fetch() { /** * Get the raw data indexed by the 'id' column. * - * @since 4.0 + * @since 3.11.5 * * @return array */ @@ -119,7 +119,7 @@ public function get_indexed_raw_data() { /** * Determines if values in shipping fields matches values in billing fields. * - * @since 4.0 + * @since 3.11.5 * * @return bool Whether shipping values match billing values. */ @@ -152,7 +152,7 @@ public function shipping_matches_billing() { /** * Get the segmented billing info. * - * @since 4.0 + * @since 3.11.5 * * @return array */ @@ -165,7 +165,7 @@ public function get_billing_data() { /** * Get the segmented shipping info. * - * @since 4.0 + * @since 3.11.5 * * @return array */ @@ -178,7 +178,7 @@ public function get_shipping_data() { /** * Gets the raw data array. * - * @since 4.0 + * @since 3.11.5 * * @return array */ @@ -192,7 +192,7 @@ public function get_raw_data() { * Prepares the return value for get() (apply_filters, etc). * * @access protected - * @since 4.0 + * @since 3.11.5 * * @param mixed $value Value fetched * @param string $key Key for $data. @@ -207,7 +207,7 @@ protected function prepare_get( $value, $key ) { * Prepares the return value for get_data() (apply_filters, etc). * * @access protected - * @since 4.0 + * @since 3.11.5 * * @return mixed */ @@ -266,7 +266,7 @@ public function get_gateway_data() { * @param string|int $key Expects either form ID or unique name. * @param string $value Value to be set for field. * - * @since 4.0 + * @since 3.11.5 * @return WPSC_Checkout_Form_Data Current instance of form data. */ public function set( $key, $value = '' ) { @@ -284,7 +284,7 @@ public function set( $key, $value = '' ) { /** * Used in conjunction with set() method, saves individual checkout form fields to database. * - * @since 4.0 + * @since 3.11.5 * @return void */ public function save() { @@ -361,7 +361,7 @@ public static function save_form( $purchase_log, $fields, $data = array(), $upda /** * Returns the log id property. * - * @since 4.0 + * @since 3.11.5 * * @return int The log id. */ diff --git a/wpsc-includes/coupon.class.php b/wpsc-includes/coupon.class.php index b572b5c6cd..a4e5dc4699 100644 --- a/wpsc-includes/coupon.class.php +++ b/wpsc-includes/coupon.class.php @@ -1,5 +1,9 @@ "x-conference-xcooltalk" ); } -} \ No newline at end of file +} diff --git a/wpsc-includes/product-template.php b/wpsc-includes/product-template.php index 1fb2b3f2ef..78dadda0f4 100644 --- a/wpsc-includes/product-template.php +++ b/wpsc-includes/product-template.php @@ -290,20 +290,20 @@ function wpsc_product_has_variations( $id = 0 ) { * Check whether or not a product is a variation. * * @param int $product_id Product ID to check. -* @since 4.0.0 +* @since 3.11.0 * @return mixed Returns parent product ID if product is a variation, false otherwise. */ function wpsc_product_is_variation( $product_id ) { $product = get_post( $product_id ); - + if ( ! is_a( $product, 'WP_Post' ) ) { return false; } - + if ( 'wpsc-product' !== $product->post_type || ! $product->post_parent ) { return false; } - + return $product->post_parent; } diff --git a/wpsc-includes/purchase-log.class.php b/wpsc-includes/purchase-log.class.php index 1df1106b81..dee0b83755 100644 --- a/wpsc-includes/purchase-log.class.php +++ b/wpsc-includes/purchase-log.class.php @@ -70,7 +70,7 @@ class WPSC_Purchase_Log extends WPSC_Query_Base { * into the database * * @static - * @since 4.0 + * @since 3.11.5 * @var array */ private static $float_cols = array( @@ -85,7 +85,7 @@ class WPSC_Purchase_Log extends WPSC_Query_Base { * Array of metadata * * @static - * @since 4.0 + * @since 3.11.5 * @var array */ private static $metadata = array( @@ -393,7 +393,7 @@ public static function update_cache( &$log ) { * * @access public * @static - * @since 4.0 + * @since 3.11.5 * * @return void */ @@ -435,7 +435,7 @@ public static function delete_cache( $value, $col = 'id' ) { * * @access public * @static - * @since 4.0 + * @since 3.11.5 * * @param string|null $value Optional (left for back-compatibility). The value which was queried. * @param string|null $col Optional (left for back-compatibility). The column used as the identifier. @@ -696,14 +696,14 @@ protected function fetch() { * Returns the value of the specified property of the $data array if it exists. * * @access public - * @since 4.0 + * @since 3.11.5 * * @param string $key Name of the property (column) * @return mixed */ public function get( $key ) { if ( 'notes' === $key ) { - _wpsc_doing_it_wrong( __FUNCTION__, __( 'Getting notes from the Log object has been deprecated in favor of the wpsc_get_order_notes() function.', 'wp-e-commerce' ), '4.0' ); + _wpsc_doing_it_wrong( __FUNCTION__, __( 'Getting notes from the Log object has been deprecated in favor of the wpsc_get_order_notes() function.', 'wp-e-commerce' ), '3.11.5' ); } return parent::get( $key ); @@ -713,7 +713,7 @@ public function get( $key ) { * Prepares the return value for get() (apply_filters, etc). * * @access protected - * @since 4.0 + * @since 3.11.5 * * @param mixed $value Value fetched * @param string $key Key for $data. @@ -728,7 +728,7 @@ protected function prepare_get( $value, $key ) { * Prepares the return value for get_data() (apply_filters, etc). * * @access protected - * @since 4.0 + * @since 3.11.5 * * @return mixed */ @@ -740,7 +740,7 @@ protected function prepare_get_data() { * Prepares the return value for get_meta() (apply_filters, etc). * * @access protected - * @since 4.0 + * @since 3.11.5 * * @return mixed */ @@ -749,7 +749,7 @@ protected function prepare_get_meta() { } public function get_cart_contents() { - _wpsc_doing_it_wrong( __FUNCTION__, __( 'This function has been deprecated in favor of the get_items() method.', 'wp-e-commerce' ), '4.0' ); + _wpsc_doing_it_wrong( __FUNCTION__, __( 'This function has been deprecated in favor of the get_items() method.', 'wp-e-commerce' ), '3.11.5' ); return $this->get_items(); } @@ -1053,7 +1053,7 @@ public function save() { * Save meta data for purchase log, if any was set via set(). * * @access public - * @since 4.0 + * @since 3.11.5 * * @return WPSC_Purchase_Log The current object (for method chaining) */ @@ -1112,7 +1112,7 @@ public function have_downloads_locked() { /** * Adds ability to retrieve a purchase log by a meta key or value. * - * @since 4.0 + * @since 3.11.5 * * @param string $key Meta key. Optional. * @param string $value Meta value. Optional. @@ -1189,7 +1189,7 @@ public function can_edit() { * If you want to allow editing completed orders via this fitler, you will * be responsible for ensuring that the item stock is adjusted accordingly. * - * @since 4.0.0 + * @since 3.11.5 * * @var bool $can_edit Whether this order can be edited * @var WPSC_Purchase_Log $log This log object @@ -1242,7 +1242,7 @@ public function is_refund_pending() { /** * Init the purchase log items for this purchase log. * - * @since 4.0 + * @since 3.11.5 * * @return wpsc_purchaselogs_items|false The purhchase log item object or false. */ @@ -1463,7 +1463,7 @@ public function shipping_method() { /** * Returns base shipping should make a function to calculate items shipping as well * - * @since 4.0 + * @since 3.11.5 * * @param boolean $numeric Return numeric value. * @@ -1481,7 +1481,7 @@ public function discount( $numeric = false ) { /** * Returns base shipping should make a function to calculate items shipping as well * - * @since 4.0 + * @since 3.11.5 * * @param boolean $numeric Return numeric value. * @param boolean $include_items Whether to calculate per-item-shipping. @@ -1505,7 +1505,7 @@ public function shipping( $numeric = false, $include_items = false ) { /** * Returns taxes total. * - * @since 4.0 + * @since 3.11.5 * * @param boolean $numeric Return numeric value. * diff --git a/wpsc-includes/purchase-log.helpers.php b/wpsc-includes/purchase-log.helpers.php index 15834b8089..d437ab276f 100644 --- a/wpsc-includes/purchase-log.helpers.php +++ b/wpsc-includes/purchase-log.helpers.php @@ -170,7 +170,7 @@ function _wpsc_process_transaction_coupon( $purchase_log ) { * Currently, only used to send customer and admin emails upon successful purchase. * * @since 3.8.9 - * @since 4.0 Removed coupons and stocks from email sending. Much easier now to remove_action() on either + * @since 3.11.5 Removed coupons and stocks from email sending. Much easier now to remove_action() on either * of those functions when desiring to override. * * @param int $id Purchase Log ID. @@ -192,7 +192,7 @@ function _wpsc_action_update_purchase_log_status( $id, $status, $old_status, $pu /** * Routine that runs when updating a purchase log's status, used to update status of coupon's used. * - * @since 4.0 + * @since 3.11.5 * * @param int $id Purchase Log ID. * @param int $status Current status. @@ -228,7 +228,7 @@ function _wpsc_update_purchase_log_coupon_status( $id, $status, $old_status, $pu /** * Routine that runs when updating a purchase log's status, used to update status of inventory. * - * @since 4.0 + * @since 3.11.5 * * @param int $id Purchase Log ID. * @param int $status Current status. @@ -331,7 +331,7 @@ function _wpsc_update_log_total_with_item_update( $item_id, $purchase_log ) { * Returns a purchase log. * * @param int $order_id Order ID. - * @since 4.0 + * @since 3.11.5 */ function wpsc_get_order( $order_id ) { return new WPSC_Purchase_Log( $order_id ); @@ -341,7 +341,7 @@ function wpsc_get_order( $order_id ) { * Returns a purchase log's notes object. * * @param int $order_id Order ID or WPSC_Purchase_Log object. - * @since 4.0 + * @since 3.11.5 */ function wpsc_get_order_notes( $order_id ) { return new WPSC_Purchase_Log_Notes( $order_id ); diff --git a/wpsc-includes/query-base.class.php b/wpsc-includes/query-base.class.php index e32a309721..90518c7d45 100644 --- a/wpsc-includes/query-base.class.php +++ b/wpsc-includes/query-base.class.php @@ -3,7 +3,7 @@ * The WP eCommerce Base Query Class * * @package wp-e-commerce - * @since 4.0 + * @since 3.11.5 */ abstract class WPSC_Query_Base { @@ -41,7 +41,7 @@ abstract class WPSC_Query_Base { * Contains the values fetched from the DB * * @access protected - * @since 4.0 + * @since 3.11.5 * * @var array */ @@ -51,7 +51,7 @@ abstract class WPSC_Query_Base { * Data that is not directly stored inside the DB but is inferred. Optional. * * @access protected - * @since 4.0 + * @since 3.11.5 */ protected $meta_data = array(); @@ -59,7 +59,7 @@ abstract class WPSC_Query_Base { * True if the DB row is fetched into the $data array. * * @access protected - * @since 4.0 + * @since 3.11.5 * * @var boolean */ @@ -69,7 +69,7 @@ abstract class WPSC_Query_Base { * True if the row exists in DB * * @access protected - * @since 4.0 + * @since 3.11.5 * * @var boolean */ @@ -81,7 +81,7 @@ abstract class WPSC_Query_Base { * Should return $this; * * @access protected - * @since 4.0 + * @since 3.11.5 * * @return WPSC_Query_Base */ @@ -91,7 +91,7 @@ abstract protected function fetch(); * Whether the DB row for this purchase log exists * * @access public - * @since 4.0 + * @since 3.11.5 * * @return bool True if it exists. Otherwise false. */ @@ -103,7 +103,7 @@ public function exists() { /** * Resets properties so any subsequent requests will be refreshed. * - * @since 4.0 + * @since 3.11.5 * * @return void */ @@ -117,7 +117,7 @@ protected function reset() { * Returns the value of the specified property of the $data array if it exists. * * @access public - * @since 4.0 + * @since 3.11.5 * * @param string $key Name of the property (column) * @return mixed @@ -144,7 +144,7 @@ public function get( $key ) { * Prepares the return value for get() (apply_filters, etc). * * @access protected - * @since 4.0 + * @since 3.11.5 * * @param mixed $value Value fetched * @param string $key Key for $data. @@ -157,7 +157,7 @@ abstract protected function prepare_get( $value, $key ); * Returns the entire $data array. * * @access public - * @since 4.0 + * @since 3.11.5 * * @return array */ @@ -173,7 +173,7 @@ public function get_data() { * Prepares the return value for get_data() (apply_filters, etc). * * @access protected - * @since 4.0 + * @since 3.11.5 * * @return mixed */ @@ -183,7 +183,7 @@ abstract protected function prepare_get_data(); * Returns the entire $meta_data array. * * @access public - * @since 4.0 + * @since 3.11.5 * * @return array */ @@ -201,7 +201,7 @@ public function get_meta() { * Prepares the return value for get_meta() (apply_filters, etc). * * @access protected - * @since 4.0 + * @since 3.11.5 * * @return mixed */ @@ -214,7 +214,7 @@ protected function prepare_get_meta() { * as arguments, or an associative array containing key value pairs. * * @access public - * @since 4.0 + * @since 3.11.5 * * @param mixed $key Name of the property (column), or an array containing * key value pairs @@ -228,7 +228,7 @@ abstract public function set( $key, $value = null ); * Saves the object back to the database. * * @access public - * @since 4.0 + * @since 3.11.5 * * @return mixed */ @@ -239,7 +239,7 @@ abstract public function save(); * and a value as arguments, or an associative array containing key value pairs. * * @access public - * @since 4.0 + * @since 3.11.5 * * @param mixed $key Name of the property (column), or an array containing * key value pairs @@ -269,7 +269,7 @@ public function set_meta( $key, $value = null ) { * Saves the meta data back to the database. * * @access public - * @since 4.0 + * @since 3.11.5 * * @return WPSC_Query_Base The current object (for method chaining) */ @@ -281,7 +281,7 @@ public function save_meta() { * Wrapper for wp_cache_get. * * @access public - * @since 4.0 + * @since 3.11.5 * * @see wp_cache_get() * @@ -300,7 +300,7 @@ public function cache_get( $key, $group_id ) { * Wrapper for wp_cache_set. * * @access public - * @since 4.0 + * @since 3.11.5 * * @see wp_cache_set() * @@ -320,7 +320,7 @@ public function cache_set( $key, $data, $group_id, $expire = 0 ) { * Wrapper for wp_cache_delete. * * @access public - * @since 4.0 + * @since 3.11.5 * * @see wp_cache_delete() * @@ -336,7 +336,7 @@ public function cache_delete( $key, $group_id ) { /** * Get the versioned group id from the $group_ids array. * - * @since 4.0 + * @since 3.11.5 * * @param string $group_id The key for the group_ids array to compile the group * from version/key. diff --git a/wpsc-includes/variations.class.php b/wpsc-includes/variations.class.php index 2ff2baefe6..3ebfac2293 100755 --- a/wpsc-includes/variations.class.php +++ b/wpsc-includes/variations.class.php @@ -314,7 +314,7 @@ function wpsc_get_child_object_in_terms_var( $parent_id, $terms, $taxonomies, $a * Here the keys are captured when someone clicks the 'add to cart' button and correspond with ... whatever. They don't really matter for our function. * Really you could pass an array of 2 term_ids here and a $product_id that has variations to match those terms and you'd get back the expected array. * - * @since 4.0 + * @since 3.11.0 * * @param array $variations required The array of variation selections * @param int $product_id required The default product_id @@ -357,7 +357,7 @@ function wpsc_get_product_data_from_variations( $variations, $product_id ) { * * See wpsc_get_product_data_from_variations for a full description on what needs to be passed in the $variations params * - * @since 4.0 + * @since 3.11.0 * * @uses wpsc_get_product_data_from_variations() Returns array of data pertaining to product variations * @return int $product_id The product_id corresponding to the selected variation @@ -369,7 +369,7 @@ function wpsc_get_product_id_from_variations( $variations, $product_id ){ /** * Allows users to filter the product_id based on the variation selections * - * @since 4.0 + * @since 3.11.0 * * @param int $$values['product_id'] The variation product_id * @param array $variations The variation selections passed to the core function @@ -390,7 +390,7 @@ function wpsc_get_product_id_from_variations( $variations, $product_id ){ * * See wpsc_get_product_data_from_variations for a full description on what needs to be passed in the $variations params * - * @since 4.0 + * @since 3.11.0 * * @uses wpsc_get_product_data_from_variations() Returns array of data pertaining to product variations * @return array $variation_values The variation values for the selected variation terms, so the term_ids as the array $values @@ -402,7 +402,7 @@ function wpsc_get_variation_values_from_variations( $variations, $product_id ){ /** * Allows users to filter the variation values based on the variation selections * - * @since 4.0 + * @since 3.11.0 * * @param array $variations The variation selections passed to the core function * @param int $product_id The default passed product_id diff --git a/wpsc-includes/wp-cli/wpsc-wp-cli-category.php b/wpsc-includes/wp-cli/wpsc-wp-cli-category.php index 66ab18d2f8..0b10f6b33e 100644 --- a/wpsc-includes/wp-cli/wpsc-wp-cli-category.php +++ b/wpsc-includes/wp-cli/wpsc-wp-cli-category.php @@ -3,7 +3,7 @@ /** * Commands for working with WP e-Commerce product categories. * - * @since 4.0 + * @since 3.11.5 * * @todo This is fairly generic, and doesn't support WP e-Commerce specific category values such as: * * Category images diff --git a/wpsc-includes/wp-cli/wpsc-wp-cli-product-tag.php b/wpsc-includes/wp-cli/wpsc-wp-cli-product-tag.php index 5ece313504..8ed635bd21 100644 --- a/wpsc-includes/wp-cli/wpsc-wp-cli-product-tag.php +++ b/wpsc-includes/wp-cli/wpsc-wp-cli-product-tag.php @@ -3,7 +3,7 @@ /** * Commands for working with WP e-Commerce product tags. * - * @since 4.0 + * @since 3.11.5 * * @todo This is fairly generic, and doesn't support WP e-Commerce specific category values such as: * * Category images diff --git a/wpsc-includes/wpsc-customizer-thumbnail-control.class.php b/wpsc-includes/wpsc-customizer-thumbnail-control.class.php index 24d95e98df..5b13e71d3d 100644 --- a/wpsc-includes/wpsc-customizer-thumbnail-control.class.php +++ b/wpsc-includes/wpsc-customizer-thumbnail-control.class.php @@ -11,14 +11,14 @@ * * @package WP eCommerce * @subpackage Customizer - * @since 4.0 + * @since 3.11.5 */ /** * Thumbnail setting control for WxH settings in Customizer. * * @todo Move to its own file. - * @since 4.0 + * @since 3.11.5 */ class WPSC_Customizer_Thumbnail_Control extends WP_Customize_Control { diff --git a/wpsc-includes/wpsc-customizer.class.php b/wpsc-includes/wpsc-customizer.class.php index 178fb15a5d..bd304d2b68 100644 --- a/wpsc-includes/wpsc-customizer.class.php +++ b/wpsc-includes/wpsc-customizer.class.php @@ -5,13 +5,13 @@ * * @package WP eCommerce * @subpackage Customizer - * @since 4.0 + * @since 3.11.5 */ /** * Class used to implement Customizer ( specifically Selective Refresh ) functionality. * - * @since 4.0 + * @since 3.11.5 */ /** WPSC_Customizer_Thumbnail_Control class */ diff --git a/wpsc-includes/wpsc-logging.class.php b/wpsc-includes/wpsc-logging.class.php index 7c733e694d..7a1dcb08d2 100644 --- a/wpsc-includes/wpsc-logging.class.php +++ b/wpsc-includes/wpsc-logging.class.php @@ -441,7 +441,7 @@ public static function get_log_count( $object_id = 0, $type = null, $meta_query * @param array $args Arguments passed to the taxonomy and post type hooks. * @return array $args Arguments passed to the taxonomy and post type hooks. * - * @since 4.0 + * @since 3.11.0 */ public static function force_ui( $args ) { $args['show_ui'] = true; @@ -450,4 +450,4 @@ public static function force_ui( $args ) { } -$GLOBALS['wpsc_logs'] = new WPSC_Logging(); \ No newline at end of file +$GLOBALS['wpsc_logs'] = new WPSC_Logging(); From 4e5786e58d4acaa24cad7a75b8dfc3a565b2aedd Mon Sep 17 00:00:00 2001 From: Justin Sternberg Date: Thu, 9 Feb 2017 20:48:46 -0500 Subject: [PATCH 12/13] Intro wpsc_is_order and update wpsc_get_order to check if object is an order --- wpsc-includes/purchase-log.helpers.php | 94 ++++++++++++++++---------- 1 file changed, 58 insertions(+), 36 deletions(-) diff --git a/wpsc-includes/purchase-log.helpers.php b/wpsc-includes/purchase-log.helpers.php index d437ab276f..aa4cccc77a 100644 --- a/wpsc-includes/purchase-log.helpers.php +++ b/wpsc-includes/purchase-log.helpers.php @@ -1,4 +1,45 @@ get( 'processed' ); + $log->set( 'processed', $new_status ); - $old_status = $purchase_log->get( 'processed' ); - $purchase_log->set( 'processed', $new_status ); - return $purchase_log->save(); + return $log->save(); } -function wpsc_update_purchase_log_details( $unique_id, $details, $by = 'id' ) { +function wpsc_update_purchase_log_details( $log_id, $details, $by = 'id' ) { + $log = wpsc_get_order( $log_id, $by ); + $log->set( $details ); - $purchase_log = new WPSC_Purchase_Log( $unique_id, $by ); - $purchase_log->set( $details ); - return $purchase_log->save(); + return $log->save(); } function wpsc_get_downloadable_links( $purchase_log ) { - if ( ! $purchase_log->is_transaction_completed() ) + if ( ! $purchase_log->is_transaction_completed() ) { return array(); + } $cart_contents = $purchase_log->get_items(); $links = array(); foreach ( $cart_contents as $item ) { $item_links = _wpsc_get_cart_item_downloadable_links( $item, $purchase_log ); - if ( empty( $item_links ) ) + if ( empty( $item_links ) ) { continue; + } $links[$item->name] = $item_links; } @@ -152,7 +194,7 @@ function _wpsc_process_transaction_coupon( $purchase_log ) { global $wpdb; if ( ! is_object( $purchase_log ) ) - $purchase_log = new WPSC_Purchase_Log( $purchase_log ); + $purchase_log = wpsc_get_order( $purchase_log ); $discount_data = $purchase_log->get( 'discount_data' ); if ( ! empty( $discount_data ) ) { @@ -264,7 +306,7 @@ function _wpsc_update_purchase_log_stock_status( $id, $status, $old_status, $pur function wpsc_send_customer_email( $purchase_log ) { if ( ! is_object( $purchase_log ) ) { - $purchase_log = new WPSC_Purchase_Log( $purchase_log ); + $purchase_log = wpsc_get_order( $purchase_log ); } if ( ! $purchase_log->is_transaction_completed() && ! $purchase_log->is_order_received() ) { @@ -281,7 +323,7 @@ function wpsc_send_customer_email( $purchase_log ) { function wpsc_send_admin_email( $purchase_log, $force = false ) { if ( ! is_object( $purchase_log ) ) { - $purchase_log = new WPSC_Purchase_Log( $purchase_log ); + $purchase_log = wpsc_get_order( $purchase_log ); } if ( $purchase_log->get( 'email_sent' ) && ! $force ) { @@ -303,7 +345,7 @@ function wpsc_send_admin_email( $purchase_log, $force = false ) { function wpsc_get_transaction_html_output( $purchase_log ) { if ( ! is_object( $purchase_log ) ) { - $purchase_log = new WPSC_Purchase_Log( $purchase_log ); + $purchase_log = wpsc_get_order( $purchase_log ); } $notification = new WPSC_Purchase_Log_Customer_HTML_Notification( $purchase_log ); @@ -326,23 +368,3 @@ function _wpsc_update_log_total_with_item_update( $item_id, $purchase_log ) { $purchase_log->set( 'totalprice', $purchase_log->get_total() )->save(); } add_action( 'wpsc_purchase_log_update_item', '_wpsc_update_log_total_with_item_update', 10, 2 ); - -/** - * Returns a purchase log. - * - * @param int $order_id Order ID. - * @since 3.11.5 - */ -function wpsc_get_order( $order_id ) { - return new WPSC_Purchase_Log( $order_id ); -} - -/** - * Returns a purchase log's notes object. - * - * @param int $order_id Order ID or WPSC_Purchase_Log object. - * @since 3.11.5 - */ -function wpsc_get_order_notes( $order_id ) { - return new WPSC_Purchase_Log_Notes( $order_id ); -} From 96a215816bc30722cbd6ae55df50049cf106ed7e Mon Sep 17 00:00:00 2001 From: Justin Sternberg Date: Thu, 9 Feb 2017 23:10:53 -0500 Subject: [PATCH 13/13] Add registry base class and use for log notes objects --- wpsc-core/wpsc-includes.php | 1 + wpsc-includes/purchase-log-notes.class.php | 47 ++++++++-- wpsc-includes/purchase-log.class.php | 7 +- wpsc-includes/purchase-log.helpers.php | 2 +- wpsc-includes/query-registry.class.php | 100 +++++++++++++++++++++ 5 files changed, 145 insertions(+), 12 deletions(-) create mode 100644 wpsc-includes/query-registry.class.php diff --git a/wpsc-core/wpsc-includes.php b/wpsc-core/wpsc-includes.php index b3aa28378f..db6dfee947 100644 --- a/wpsc-core/wpsc-includes.php +++ b/wpsc-core/wpsc-includes.php @@ -9,6 +9,7 @@ require_once( WPSC_FILE_PATH . '/wpsc-includes/wpsc-meta-util.php' ); require_once( WPSC_FILE_PATH . '/wpsc-includes/wpsc-deprecated-meta.php' ); require_once( WPSC_FILE_PATH . '/wpsc-includes/query-base.class.php' ); +require_once( WPSC_FILE_PATH . '/wpsc-includes/query-registry.class.php' ); require_once( WPSC_FILE_PATH . '/wpsc-includes/customer.php' ); require_once( WPSC_FILE_PATH . '/wpsc-includes/wpsc-meta-customer.php' ); require_once( WPSC_FILE_PATH . '/wpsc-includes/wpsc-meta-visitor.php' ); diff --git a/wpsc-includes/purchase-log-notes.class.php b/wpsc-includes/purchase-log-notes.class.php index bb4e5ccdec..51d0fad9a3 100644 --- a/wpsc-includes/purchase-log-notes.class.php +++ b/wpsc-includes/purchase-log-notes.class.php @@ -1,6 +1,6 @@ log = $log; - } else { - $this->log = new WPSC_Purchase_Log( $log ); + $this->log = wpsc_get_order( $log ); + + parent::add_instance( $this ); + + if ( ! self::$flag ) { + _wpsc_doing_it_wrong( 'wpsc_purchlog_notes_class_error', __( 'Please use `WPSC_Purchase_Log_Notes::get_instance( $log_id )` instead of `new WPSC_Purchase_Log_Notes( $log_id ).', 'wp-e-commerce' ), '3.12.0' ); } if ( empty( self::$map_text ) ) { @@ -51,6 +54,40 @@ public function __construct( $log ) { } } + /** + * Retrieve a WPSC_Purchase_Log_Notes instance by instance id. + * + * @since 3.12.0 + * + * @param string $instance_id A WPSC_Purchase_Log_Notes instance id. + * + * @return WPSC_Purchase_Log_Notes object instance. + */ + public static function get_instance( $log_id ) { + $log = wpsc_get_order( $log_id ); + + $instance = parent::_get_instance( __CLASS__, $log->get( 'id' ) ); + + if ( ! $instance ) { + self::$flag = true; + $instance = new self( $log ); + self::$flag = false; + } + + return $instance; + } + + /** + * Retrieves the unique identifier for a WPSC_Query_Base instance. + * + * @since 3.12.0 + * + * @return mixed + */ + public function instance_id() { + return $this->log->get( 'id' ); + } + /** * Fetches the actual record from the database * diff --git a/wpsc-includes/purchase-log.class.php b/wpsc-includes/purchase-log.class.php index dee0b83755..03d79e5a26 100644 --- a/wpsc-includes/purchase-log.class.php +++ b/wpsc-includes/purchase-log.class.php @@ -1580,12 +1580,7 @@ public function get_remaining_refund() { * @return WPSC_Purchase_Log The current object (for method chaining) */ public function add_note( $note_text ) { - static $notes = null; - - if ( ! ( $notes instanceof WPSC_Purchase_Log_Notes ) ) { - $notes = wpsc_get_order_notes( $this ); - } - + $notes = wpsc_get_order_notes( $this ); $notes->add( $note_text )->save(); return $this; diff --git a/wpsc-includes/purchase-log.helpers.php b/wpsc-includes/purchase-log.helpers.php index aa4cccc77a..028faabf05 100644 --- a/wpsc-includes/purchase-log.helpers.php +++ b/wpsc-includes/purchase-log.helpers.php @@ -37,7 +37,7 @@ function wpsc_is_order( $order ) { * @return WPSC_Purchase_Log */ function wpsc_get_order_notes( $order_id ) { - return new WPSC_Purchase_Log_Notes( $order_id ); + return WPSC_Purchase_Log_Notes::get_instance( $order_id ); } function wpsc_get_plaintext_table( $headings, $rows ) { diff --git a/wpsc-includes/query-registry.class.php b/wpsc-includes/query-registry.class.php new file mode 100644 index 0000000000..3ca6840439 --- /dev/null +++ b/wpsc-includes/query-registry.class.php @@ -0,0 +1,100 @@ +instance_id() ] = $instance; + + return $instance; + } + + /** + * Remove a WPSC_Query_Base instance object from the registry. + * + * @since 3.12.0 + * + * @param string $instance_id A WPSC_Query_Base instance id. + * @param string $class_name The name of the instance class. Optional if $instance_id is an object. + */ + protected static function remove_instance( $instance_id, $class_name = '' ) { + $class_name = is_object( $instance_id ) ? get_class( $instance_id ) : $class_name; + if ( empty( $class_name ) ) { + throw new Exception( sprintf( __( '%s requires a class name be provided', 'wp-e-commerce' ), __METHOD__ ), __LINE__ ); + } + + if ( isset( self::$instances[ $class_name ][ $instance_id ] ) ) { + unset( self::$instances[ $class_name ][ $instance_id ] ); + } + } + + /** + * Retrieve a WPSC_Query_Base instance by instance id. + * a `get_instance` method is required in extended class. + * Extended method should call: + * `parent::_get_instance( __CLASS__, $id )`, + * and if not found, call: + * `$instance = parent::add_instance( new self( $log ) );` + * + * @since 3.12.0 + * + * @param string $class_name The name of the instance class. + * @param string $instance_id A WPSC_Query_Base instance id. + * + * @return WPSC_Query_Base|bool False or WPSC_Query_Base object instance. + */ + protected static function _get_instance( $class_name, $instance_id ) { + if ( empty( self::$instances[ $class_name ][ $instance_id ] ) ) { + return false; + } + + return self::$instances[ $class_name ][ $instance_id ]; + } + + /** + * Retrieve all WPSC_Query_Base instances registered. + * + * @since 3.12.0 + * + * @param string $class_name The name of the class for which to fetch all instances. + * + * @return WPSC_Query_Base[] Array of all registered instance instances. + */ + public static function get_all( $class_name = '' ) { + if ( $class_name ) { + return isset( self::$instances[ $class_name ] ) ? self::$instances[ $class_name ] : array(); + } + + return self::$instances; + } + + /** + * Retrieves the unique identifier for a WPSC_Query_Base instance. + * + * @since 3.12.0 + * + * @return mixed + */ + abstract public function instance_id(); + +}