-
+
|
Date: Wed, 2 Mar 2022 10:52:39 +0100
Subject: [PATCH 31/87] Fix typo in subscription end date post meta key.
---
src/Subscriptions/SubscriptionsDataStoreCPT.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Subscriptions/SubscriptionsDataStoreCPT.php b/src/Subscriptions/SubscriptionsDataStoreCPT.php
index e639137d..3117334f 100644
--- a/src/Subscriptions/SubscriptionsDataStoreCPT.php
+++ b/src/Subscriptions/SubscriptionsDataStoreCPT.php
@@ -670,7 +670,7 @@ private function update_post_meta( $subscription ) {
$this->update_meta( $id, 'source', $subscription->source );
$this->update_meta( $id, 'source_id', $subscription->source_id );
$this->update_meta( $id, 'email', ( null === $customer ? null : $customer->get_email() ) );
- $this->update_meta( $id, 'end_payment', $subscription->get_end_date() );
+ $this->update_meta( $id, 'end_date', $subscription->get_end_date() );
$this->update_meta( $id, 'next_payment', $subscription->get_next_payment_date() );
$this->update_meta( $id, 'next_payment_delivery_date', $subscription->get_next_payment_delivery_date() );
$this->update_meta( $id, 'version', $subscription->get_version() );
From e82565cebb0c892e58f2a38ee4364f9df4a01ce6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Reu=CC=88el=20van=20der=20Steege?=
Date: Wed, 9 Mar 2022 15:44:49 +0100
Subject: [PATCH 32/87] Columns with transaction ID and customer name are not
sortable (resolves #58).
---
src/Admin/AdminPaymentPostType.php | 45 ++-----------------------
src/Admin/AdminSubscriptionPostType.php | 5 +--
2 files changed, 3 insertions(+), 47 deletions(-)
diff --git a/src/Admin/AdminPaymentPostType.php b/src/Admin/AdminPaymentPostType.php
index 1313ba2a..961bfc39 100644
--- a/src/Admin/AdminPaymentPostType.php
+++ b/src/Admin/AdminPaymentPostType.php
@@ -15,7 +15,6 @@
use Pronamic\WordPress\Pay\Payments\PaymentPostType;
use Pronamic\WordPress\Pay\Plugin;
use WP_Post;
-use WP_Query;
/**
* WordPress admin payment post type
@@ -71,8 +70,6 @@ public function __construct( $plugin ) {
add_filter( 'post_row_actions', array( $this, 'post_row_actions' ), 10, 2 );
- add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
-
add_filter( 'default_hidden_columns', array( $this, 'default_hidden_columns' ) );
add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) );
@@ -272,42 +269,6 @@ public function admin_notices() {
}
}
- /**
- * Pre get posts.
- *
- * @param WP_Query $query WordPress query.
- * @return void
- */
- public function pre_get_posts( $query ) {
- /**
- * The `WP_Query::get` function can return different variable type.
- * For now this function can only handle one specific string orderby.
- *
- * @link https://developer.wordpress.org/reference/classes/wp_query/get/
- * @link https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters
- * @link https://github.com/WordPress/WordPress/blob/5.2/wp-includes/class-wp-query.php#L1697-L1713
- */
- $orderby = $query->get( 'orderby' );
-
- if ( ! is_string( $orderby ) ) {
- return;
- }
-
- $map = array(
- 'pronamic_payment_customer' => '_pronamic_payment_customer_name',
- 'pronamic_payment_transaction' => '_pronamic_payment_transaction_id',
- );
-
- if ( ! isset( $map[ $orderby ] ) ) {
- return;
- }
-
- $meta_key = $map[ $orderby ];
-
- $query->set( 'meta_key', $meta_key );
- $query->set( 'orderby', 'meta_value' );
- }
-
/**
* Columns.
*
@@ -360,10 +321,8 @@ public function default_hidden_columns( $hidden ) {
* @return array
*/
public function sortable_columns( $sortable_columns ) {
- $sortable_columns['pronamic_payment_title'] = 'ID';
- $sortable_columns['pronamic_payment_transaction'] = 'pronamic_payment_transaction';
- $sortable_columns['pronamic_payment_customer'] = 'pronamic_payment_customer';
- $sortable_columns['pronamic_payment_date'] = 'date';
+ $sortable_columns['pronamic_payment_title'] = 'ID';
+ $sortable_columns['pronamic_payment_date'] = 'date';
return $sortable_columns;
}
diff --git a/src/Admin/AdminSubscriptionPostType.php b/src/Admin/AdminSubscriptionPostType.php
index ec6f9682..0d8e47ea 100644
--- a/src/Admin/AdminSubscriptionPostType.php
+++ b/src/Admin/AdminSubscriptionPostType.php
@@ -14,9 +14,8 @@
use Pronamic\WordPress\Pay\Core\PaymentMethods;
use Pronamic\WordPress\Pay\Plugin;
use Pronamic\WordPress\Pay\Subscriptions\SubscriptionPeriod;
-use Pronamic\WordPress\Pay\Subscriptions\SubscriptionStatus;
-use Pronamic\WordPress\Pay\Util;
use Pronamic\WordPress\Pay\Subscriptions\SubscriptionPostType;
+use Pronamic\WordPress\Pay\Util;
use WP_Post;
use WP_Query;
@@ -252,7 +251,6 @@ public function pre_get_posts( $query ) {
}
$map = array(
- 'pronamic_subscription_customer' => '_pronamic_subscription_customer_name',
'pronamic_subscription_next_payment' => '_pronamic_subscription_next_payment',
);
@@ -300,7 +298,6 @@ public function columns( $columns ) {
*/
public function sortable_columns( $sortable_columns ) {
$sortable_columns['pronamic_subscription_title'] = 'ID';
- $sortable_columns['pronamic_subscription_customer'] = 'pronamic_subscription_customer_name';
$sortable_columns['pronamic_subscription_next_payment'] = 'pronamic_subscription_next_payment';
$sortable_columns['pronamic_subscription_date'] = 'date';
From a2d9047652f07219eb8cbe37a20bafca32fc255a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Reu=CC=88el=20van=20der=20Steege?=
Date: Thu, 10 Mar 2022 11:39:18 +0100
Subject: [PATCH 33/87] Use source `subscription_payment_method_change` for
subscription payment method changes.
---
src/Subscriptions/SubscriptionsModule.php | 36 ++++++++++++++++++-----
1 file changed, 29 insertions(+), 7 deletions(-)
diff --git a/src/Subscriptions/SubscriptionsModule.php b/src/Subscriptions/SubscriptionsModule.php
index a421990f..32a4ee15 100644
--- a/src/Subscriptions/SubscriptionsModule.php
+++ b/src/Subscriptions/SubscriptionsModule.php
@@ -10,20 +10,14 @@
namespace Pronamic\WordPress\Pay\Subscriptions;
-use DateInterval;
-use Pronamic\WordPress\DateTime\DateTime;
use Pronamic\WordPress\DateTime\DateTimeImmutable;
-use Pronamic\WordPress\DateTime\DateTimeZone;
use Pronamic\WordPress\Money\Money;
use Pronamic\WordPress\Pay\Core\PaymentMethods;
use Pronamic\WordPress\Pay\Core\Server;
-use Pronamic\WordPress\Pay\Payments\PaymentStatus;
use Pronamic\WordPress\Pay\Core\Util;
use Pronamic\WordPress\Pay\Payments\Payment;
+use Pronamic\WordPress\Pay\Payments\PaymentStatus;
use Pronamic\WordPress\Pay\Plugin;
-use WP_CLI;
-use WP_Error;
-use WP_Query;
/**
* Title: Subscriptions module
@@ -74,6 +68,10 @@ public function __construct( Plugin $plugin ) {
\add_action( 'pronamic_pay_pre_create_subscription', array( SubscriptionHelper::class, 'complement_subscription' ), 10, 1 );
\add_action( 'pronamic_pay_pre_create_payment', array( $this, 'complement_subscription_by_payment' ), 10, 1 );
+ // Payment source filters.
+ \add_filter( 'pronamic_payment_source_text_subscription_payment_method_change', array( $this, 'source_text_subscription_payment_method_change' ) );
+ \add_filter( 'pronamic_payment_source_description_subscription_payment_method_change', array( $this, 'source_description_subscription_payment_method_change' ) );
+
// Listen to payment status changes so we can update related subscriptions.
\add_action( 'pronamic_payment_status_update', array( $this, 'payment_status_update' ) );
@@ -458,6 +456,10 @@ private function handle_subscription_mandate( Subscription $subscription ) {
try {
$payment = $subscription->new_payment();
+ // Set source.
+ $payment->set_source( 'subscription_payment_method_change' );
+ $payment->set_source_id( null );
+
// Set payment method.
$payment_method = \filter_input( \INPUT_POST, 'pronamic_pay_subscription_payment_method', \FILTER_SANITIZE_STRING );
@@ -714,4 +716,24 @@ public function rest_api_subscription_phase( \WP_REST_Request $request ) {
return $phase;
}
+
+ /**
+ * Source text filter.
+ *
+ * @param string $text The source text to filter.
+ * @return string
+ */
+ public function source_text_subscription_payment_method_change( $text ) {
+ return __( 'Subscription payment method change', 'pronamic_ideal' );
+ }
+
+ /**
+ * Source description filter.
+ *
+ * @param string $text The source text to filter.
+ * @return string
+ */
+ public function source_description_subscription_payment_method_change( $text ) {
+ return __( 'subscription payment method change', 'pronamic_ideal' );
+ }
}
From 01086c3caf4518d0e609e7d43c7b1d22ee090187 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Reu=CC=88el=20van=20der=20Steege?=
Date: Tue, 15 Mar 2022 12:13:24 +0100
Subject: [PATCH 34/87] Update default error message.
---
src/Plugin.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Plugin.php b/src/Plugin.php
index b8d236d1..d94c6dde 100644
--- a/src/Plugin.php
+++ b/src/Plugin.php
@@ -716,7 +716,7 @@ public function datetime_format( $format ) {
* @return string
*/
public static function get_default_error_message() {
- return __( 'Something went wrong with the payment. Please try again later or pay another way.', 'pronamic_ideal' );
+ return __( 'Something went wrong with the payment. Please try again or pay another way.', 'pronamic_ideal' );
}
/**
From e1f9fdf85b4d97828c9e4af03a389004eb4a7f51 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Reu=CC=88el=20van=20der=20Steege?=
Date: Fri, 25 Mar 2022 10:58:18 +0100
Subject: [PATCH 35/87] Add menu badge for subscriptions 'On hold'
(pronamic/wp-pronamic-pay#315).
---
src/Admin/AdminModule.php | 87 ++++++++++++++++++++++++++++++++-------
1 file changed, 72 insertions(+), 15 deletions(-)
diff --git a/src/Admin/AdminModule.php b/src/Admin/AdminModule.php
index aa262482..6e44b87f 100644
--- a/src/Admin/AdminModule.php
+++ b/src/Admin/AdminModule.php
@@ -907,34 +907,81 @@ private function get_menu_icon_url() {
* @return void
*/
public function admin_menu() {
- // @link https://github.com/woothemes/woocommerce/blob/2.3.13/includes/admin/class-wc-admin-menus.php#L145
+ /**
+ * Badges.
+ *
+ * @link https://github.com/woothemes/woocommerce/blob/2.3.13/includes/admin/class-wc-admin-menus.php#L145
+ */
$counts = wp_count_posts( 'pronamic_payment' );
- $badge = '';
+ $payments_pending_count = \property_exists( $counts, 'payment_pending' ) ? $counts->payment_pending : 0;
- if ( isset( $counts->payment_pending ) && $counts->payment_pending > 0 ) {
- $badge = sprintf(
- ' %1$s',
- $counts->payment_pending,
- sprintf(
- /* translators: %d: pending payments count */
- \_n( '%d payment pending', '%d payments pending', $counts->payment_pending, 'pronamic_ideal' ),
- $counts->payment_pending
- )
+ $counts = wp_count_posts( 'pronamic_pay_subscr' );
+
+ $subscriptions_on_hold_count = \property_exists( $counts, 'subscr_on_hold' ) ? $counts->subscr_on_hold : 0;
+
+ $badges = array(
+ 'pay' => array(
+ 'title' => array(),
+ 'count' => 0,
+ 'html' => '',
+ ),
+ 'payments' => array(
+ 'title' => \sprintf(
+ /* translators: %d: payments pending count */
+ \_n( '%d payment pending', '%d payments pending', $payments_pending_count, 'pronamic_ideal' ),
+ $payments_pending_count
+ ),
+ 'count' => $payments_pending_count,
+ 'html' => '',
+ ),
+ 'subscriptions' => array(
+ 'title' => \sprintf(
+ /* translators: %d: subscriptions on hold count */
+ \_n( '%d subscription on hold', '%d subscriptions on hold', $subscriptions_on_hold_count, 'pronamic_ideal' ),
+ $subscriptions_on_hold_count
+ ),
+ 'count' => $subscriptions_on_hold_count,
+ 'html' => '',
+ ),
+ );
+
+ foreach ( $badges as &$badge ) {
+ $count = $badge['count'];
+
+ if ( 0 === $count ) {
+ continue;
+ }
+
+ $title = \array_key_exists( 'title', $badge ) && \is_string( $badge['title'] ) ? $badge['title'] : '';
+
+ $badge['html'] = \sprintf(
+ ' %1$d',
+ $count,
+ $title
);
+
+ // Pay badge.
+ $badges['pay']['count'] += $count;
+
+ if ( ! empty( $title ) ) {
+ $badges['pay']['title'][] = $title;
+ }
}
- // Submenu pages.
+ /**
+ * Submenu pages.
+ */
$submenu_pages = array(
array(
'page_title' => __( 'Payments', 'pronamic_ideal' ),
- 'menu_title' => __( 'Payments', 'pronamic_ideal' ) . $badge,
+ 'menu_title' => __( 'Payments', 'pronamic_ideal' ) . $badges['payments']['html'],
'capability' => 'edit_payments',
'menu_slug' => 'edit.php?post_type=pronamic_payment',
),
array(
'page_title' => __( 'Subscriptions', 'pronamic_ideal' ),
- 'menu_title' => __( 'Subscriptions', 'pronamic_ideal' ),
+ 'menu_title' => __( 'Subscriptions', 'pronamic_ideal' ) . $badges['subscriptions']['html'],
'capability' => 'edit_payments',
'menu_slug' => 'edit.php?post_type=pronamic_pay_subscr',
),
@@ -998,9 +1045,19 @@ public function admin_menu() {
$menu_icon_url = 'dashicons-money';
}
+ $pay_badge = '';
+
+ if ( 0 !== $badges['pay']['count'] ) {
+ $pay_badge = \sprintf(
+ ' %1$d',
+ $badges['pay']['count'],
+ \implode( ', ', $badges['pay']['title'] )
+ );
+ }
+
add_menu_page(
__( 'Pronamic Pay', 'pronamic_ideal' ),
- __( 'Pay', 'pronamic_ideal' ) . $badge,
+ __( 'Pay', 'pronamic_ideal' ) . $pay_badge,
$minimum_capability,
'pronamic_ideal',
function() {
From adabed15a451264c32bb410d3c03c8705ee70293 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Reu=CC=88el=20van=20der=20Steege?=
Date: Fri, 25 Mar 2022 12:29:08 +0100
Subject: [PATCH 36/87] Remove default `edit` bulk action for subscriptions
(only allowed incorrect status changes).
---
src/Admin/AdminSubscriptionPostType.php | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/Admin/AdminSubscriptionPostType.php b/src/Admin/AdminSubscriptionPostType.php
index 0d8e47ea..3b3babac 100644
--- a/src/Admin/AdminSubscriptionPostType.php
+++ b/src/Admin/AdminSubscriptionPostType.php
@@ -53,6 +53,7 @@ public function __construct( $plugin ) {
add_filter( 'manage_edit-' . self::POST_TYPE . '_columns', array( $this, 'columns' ) );
add_filter( 'manage_edit-' . self::POST_TYPE . '_sortable_columns', array( $this, 'sortable_columns' ) );
+ add_filter( 'bulk_actions-edit-' . self::POST_TYPE, array( $this, 'bulk_actions' ) );
add_filter( 'list_table_primary_column', array( $this, 'primary_column' ), 10, 2 );
add_action( 'manage_' . self::POST_TYPE . '_posts_custom_column', array( $this, 'custom_columns' ), 10, 2 );
@@ -116,6 +117,21 @@ public function removable_query_args( $args ) {
return $args;
}
+ /**
+ * Custom bulk actions.
+ *
+ * @link https://make.wordpress.org/core/2016/10/04/custom-bulk-actions/
+ * @link https://github.com/WordPress/WordPress/blob/4.7/wp-admin/includes/class-wp-list-table.php#L440-L452
+ * @param array $bulk_actions Bulk actions.
+ * @return array
+ */
+ public function bulk_actions( $bulk_actions ) {
+ // Don't allow edit in bulk.
+ unset( $bulk_actions['edit'] );
+
+ return $bulk_actions;
+ }
+
/**
* Maybe process subscription action.
*
From 5d5eeac079986fdcf39bb6233bf8755d288e384d Mon Sep 17 00:00:00 2001
From: Remco Tolsma <869674+remcotolsma@users.noreply.github.com>
Date: Fri, 25 Mar 2022 12:52:47 +0100
Subject: [PATCH 37/87] Create Updater.php
---
src/Updater.php | 199 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 199 insertions(+)
create mode 100644 src/Updater.php
diff --git a/src/Updater.php b/src/Updater.php
new file mode 100644
index 00000000..36bf99fa
--- /dev/null
+++ b/src/Updater.php
@@ -0,0 +1,199 @@
+
+ * @copyright 2005-2022 Pronamic
+ * @license GPL-3.0-or-later
+ * @package Pronamic\WordPress\Pay
+ */
+
+namespace Pronamic\WordPress\Pay;
+
+/**
+ * Updater class
+ *
+ * @author Remco Tolsma
+ * @version 2.5.0
+ * @since 2.0.1
+ */
+class Updater {
+ /**
+ * Plugins filter callback.
+ *
+ * @var callable|null
+ */
+ private $plugins_filter_callback;
+
+ /**
+ * Instance of this class.
+ *
+ * @since 1.1.0
+ * @var self
+ */
+ protected static $instance = null;
+
+ /**
+ * Construct updater.
+ *
+ * @param callable|null $plugins_filter_callback Plugins filter callback.
+ */
+ private function __construct( $plugins_filter_callback ) {
+ $this->plugins_filter_callback = $plugins_filter_callback;
+
+ \add_filter( 'http_response', array( $this, 'http_response' ), 10, 3 );
+
+ \add_filter( 'plugins_api', array( $this, 'plugins_api' ), 10, 3 );
+ }
+
+ /**
+ * HTTP Response.
+ *
+ * @link https://github.com/WordPress/WordPress/blob/5.5/wp-includes/class-http.php#L437-L446
+ * @param array $response HTTP response.
+ * @param array $parsed_args HTTP request arguments.
+ * @param string $url The request URL.
+ * @return array
+ */
+ public function http_response( $response, $parsed_args, $url ) {
+ if ( ! \array_key_exists( 'method', $parsed_args ) ) {
+ return $repsonse;
+ }
+
+ if ( 'POST' !== $parsed_args['method'] ) {
+ return $response;
+ }
+
+ if ( false !== strpos( $url, '//api.wordpress.org/plugins/update-check/' ) ) {
+ $response = $this->extend_response_with_pronamic( $response, $parsed_args, 'plugins' );
+ }
+
+ return $response;
+ }
+
+ /**
+ * Extends WordPress.org API repsonse with Pronamic API response.
+ *
+ * @param array $response HTTP response.
+ * @param array $parsed_args HTTP request arguments.
+ * @param string $type Type.
+ * @return array
+ */
+ public function extend_response_with_pronamic( $response, $parsed_args, $type ) {
+ $data = \json_decode( \wp_remote_retrieve_body( $response ), true );
+
+ if ( ! is_array( $data ) ) {
+ return $response;
+ }
+
+ $pronamic_data = $this->request_plugins_update_check( $parsed_args );
+
+ if ( false === $pronamic_data ) {
+ return $response;
+ }
+
+ if ( ! array_key_exists( $type, $data ) ) {
+ $data[ $type ] = array();
+ }
+
+ if ( \is_array( $pronamic_data[ $type ] ) ) {
+ $data[ $type ] = array_merge( $data[ $type ], $pronamic_data[ $type ] );
+ }
+
+ $response['body'] = \wp_json_encode( $data );
+
+ return $response;
+ }
+
+ /**
+ * Remote post.
+ *
+ * @param string $url URL to retrieve.
+ * @param array $args Request arguments.
+ * @param array $parsed_args Parsed request arguments.
+ * @return array
+ */
+ private function remote_post( $url, $args, $parsed_args ) {
+ $keys = array(
+ 'timeout',
+ 'user-agent',
+ 'headers',
+ );
+
+ foreach ( $keys as $key ) {
+ if ( \array_key_exists( $key, $parsed_args ) ) {
+ $args[ $key ] = $parsed_args[ $key ];
+ }
+ }
+
+ return \wp_remote_post( $url, $args );
+ }
+
+ /**
+ * Request plugins update check.
+ *
+ * @param array $parsed_args HTTP request arguments.
+ * @return array
+ */
+ private function request_plugins_update_check( $parsed_args ) {
+ $plugins = $this->get_plugins();
+
+ if ( 0 === \count( $plugins ) ) {
+ return false;
+ }
+
+ $raw_response = $this->remote_post(
+ 'https://api.pronamic.eu/plugins/update-check/1.2/',
+ array(
+ 'body' => array(
+ 'plugins' => \wp_json_encode( $plugins ),
+ ),
+ ),
+ $parsed_args
+ );
+
+ // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
+ if ( \is_wp_error( $raw_response ) || '200' != \wp_remote_retrieve_response_code( $raw_response ) ) {
+ return false;
+ }
+
+ $response = \json_decode( \wp_remote_retrieve_body( $raw_response ), true );
+
+ return $response;
+ }
+
+ /**
+ * Get plugins.
+ *
+ * @link https://github.com/pronamic/wp-pronamic-client/blob/ce45ff5b1cde51aa3959750f2a03ad76c3be0463/includes/functions.php#L3-L25
+ * @return array
+ */
+ private function get_plugins() {
+ if ( ! function_exists( '\get_plugins' ) ) {
+ return array();
+ }
+
+ $plugins = \get_plugins();
+
+ if ( null !== $this->plugins_filter_callback ) {
+ $plugins = \array_filter( $plugins, $this->plugins_filter_callback );
+ }
+
+ return $plugins;
+ }
+
+ /**
+ * Return an instance of this class.
+ *
+ * @param callable $plugins_filter_callback Plugins filter callback.
+ * @return self A single instance of this class.
+ */
+ public static function instance( $plugins_filter_callback = null ) {
+ // If the single instance hasn't been set, set it now.
+ if ( null === self::$instance ) {
+ self::$instance = new self( $plugins_filter_callback );
+ }
+
+ return self::$instance;
+ }
+}
From 91ff3946a772845b6a1233e955ef36a43ed6002a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Reu=CC=88el=20van=20der=20Steege?=
Date: Fri, 25 Mar 2022 16:38:13 +0100
Subject: [PATCH 38/87] Update payment and subscription update meta boxes.
---
css/admin.css | 26 +--
css/admin.css.map | 2 +-
docs/hooks.md | 2 +-
js/dist/admin.js | 56 +++++
js/src/admin.js | 56 +++++
scss/admin/_meta-box-update.scss | 8 +
views/meta-box-payment-info.php | 35 ++--
views/meta-box-payment-update.php | 274 ++++++++++++++-----------
views/meta-box-subscription-info.php | 18 --
views/meta-box-subscription-update.php | 72 +++++--
10 files changed, 367 insertions(+), 182 deletions(-)
diff --git a/css/admin.css b/css/admin.css
index e956acdb..0ffee749 100644
--- a/css/admin.css
+++ b/css/admin.css
@@ -25,18 +25,13 @@
}
.pronamic-pay-chart-legend li {
border-right: 5px solid #aaa;
- -webkit-box-shadow: inset 0 -1px 0 0 #e5e5e5;
- box-shadow: inset 0 -1px 0 0 #e5e5e5;
+ box-shadow: inset 0 -1px 0 0 #e5e5e5;
color: #aaa;
display: block;
margin: 0;
padding: 1em;
- -webkit-transition-duration: 0.5s;
- transition-duration: 0.5s;
- -webkit-transition-property: border, padding, -webkit-box-shadow;
- transition-property: border, padding, -webkit-box-shadow;
+ transition-duration: 0.5s;
transition-property: border, box-shadow, padding;
- transition-property: border, box-shadow, padding, -webkit-box-shadow;
}
.pronamic-pay-chart-legend li.completed-count {
border-right-color: #dbe1e3;
@@ -58,8 +53,7 @@
}
.pronamic-pay-chart-legend li:hover {
border-right-color: #23282f;
- -webkit-box-shadow: inset 0 -1px 0 0 #e5e5e5, inset 300px 0 0 #f9f9f9;
- box-shadow: inset 0 -1px 0 0 #e5e5e5, inset 300px 0 0 #f9f9f9;
+ box-shadow: inset 0 -1px 0 0 #e5e5e5, inset 300px 0 0 #f9f9f9;
padding-left: 1.5em;
}
.pronamic-pay-chart-legend strong {
@@ -80,8 +74,7 @@
}
.pronamic-pay-status-list li {
border-top: 1px solid #eee;
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
+ box-sizing: border-box;
color: #aaa;
float: left;
margin: 0;
@@ -94,7 +87,6 @@
font-size: 12px;
padding: 9px 12px;
position: relative;
- -webkit-transition: color ease 0.5s;
transition: color ease 0.5s;
}
.pronamic-pay-status-list li a strong {
@@ -290,6 +282,14 @@ body.post-type-pronamic_payment #post-body-content, body.post-type-pronamic_pay_
text-align: right;
}
+#pronamic-pay-status-display {
+ font-weight: 600;
+}
+
+#pronamic-pay-post-status-select {
+ margin-top: 3px;
+}
+
.pronamic-pay-settings select {
width: 25em;
}
@@ -477,3 +477,5 @@ body.post-type-pronamic_payment #post-body-content, body.post-type-pronamic_pay_
.pronamic-pay-cloack {
display: none;
}
+
+/*# sourceMappingURL=admin.css.map */
diff --git a/css/admin.css.map b/css/admin.css.map
index 58bbcd40..44869103 100644
--- a/css/admin.css.map
+++ b/css/admin.css.map
@@ -1 +1 @@
-{"version":3,"sourceRoot":"","sources":["../fonts/src/_variables.scss","../scss/admin/_buttons.scss","../scss/admin/_chart.scss","../scss/admin/_variables.scss","../scss/admin/_dashboard-widget-payments.scss","../scss/admin/_edit-form-post.scss","../scss/admin/_forms.scss","../scss/admin/_icons.scss","../scss/admin/_lists.scss","../scss/admin/_meta-box-gateway-config.scss","../scss/admin/_meta-box-gateway-test.scss","../scss/admin/_meta-box-payment-log.scss","../scss/admin/_meta-box-subscription-info.scss","../scss/admin/_meta-box-update.scss","../scss/admin/_settings.scss","../scss/admin/_tables.scss","../scss/admin/_tabs.scss","../scss/admin/_text.scss","../scss/admin/_tip.scss","../scss/admin/_utilities.scss"],"names":[],"mappings":"AAAA;ACGA;EACC;EAEA;;;ACFA;EACC;;;AAIF;EACC;EAEA;EAEA;;;AAGD;EACC,YCfO;EDiBP;EACA;EACA;EAEA;EAEA;EACA;;AAEA;EACC;EAEA;EAEA,OCvBK;EDyBL;EAEA;EACA;EAEA;EACA;;AAEA;EACC,oBCyDkC;;ADtDnC;EACC,oBCsD8B;;ADnD/B;EACC,oBCmDgC;;ADhDjC;EACC,oBCgDgC;;AD7CjC;EACC,oBC6C8B;;AD1C/B;EACC,oBC0C6B;;ADvC9B;EACC,oBCuCwB;EDrCxB;EAEA;;AAIF;EACC,OChDc;EDkDd;EAEA;EACA;EAEA;;;AEjFA;EACC;;;AAKH;EACC;EAEA;;AAEA;EACC;EAEA;EAEA,ODTK;ECWL;EAEA;EACA;EAEA;;AAEA;EACC,ODnBI;ECqBJ;EAEA;EAEA;EAEA;EAEA;;AAEA;EACC,ODTS;ECWT;EAEA;EACA;EAEA;;AAGD;EACC,ODlBe;;ACoBf;AAAA;EAEC,ODtBc;;AC2BjB;EACC;EAEA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ACzHP;EACC;EAEA;EAEA;EAEA;EAEA;;AAEA;EACC,YbsCwB;EapCxB;EACA;EAEA;EAEA;EAEA;EAEA;EACA;;AAEA;EACC,YbzBK;Ea2BL;EAEA;;;AAqBC;EACC,kBAjBa;;;AAgBd;EACC,kBAjBa;;;AAgBd;EACC,kBAjBa;;;AAgBd;EACC,kBAjBa;;;AAgBd;EACC,kBAjBa;;;AAgBd;EACC,kBAjBa;;;AAgBd;EACC,kBAjBa;;;AAgBd;EACC,kBAjBa;;;AAgBd;EACC,kBAjBa;;;AAwBlB;EACC;EACA;EAEA;;AAGA;EAEC;;AAEA;EAEC;;;AAKH;EACC;;;AAGD;EACC;IACC;;;EAGD;IACC;;EAEA;IACC;;;AAKH;EAGG;AAAA;IAEC;;;AClGJ;EACC;;;AAGD;EACC,OdFK;;;AcKN;EACC,OdJQ;;;AePP;EACC,OfkBS;EehBT;;;AAOD;EACC;;;ACXH;EACC","file":"admin.css"}
\ No newline at end of file
+{"version":3,"sourceRoot":"","sources":["../fonts/src/_variables.scss","../scss/admin/_buttons.scss","../scss/admin/_chart.scss","../scss/admin/_variables.scss","../scss/admin/_dashboard-widget-payments.scss","../scss/admin/_edit-form-post.scss","../scss/admin/_forms.scss","../scss/admin/_icons.scss","../scss/admin/_lists.scss","../scss/admin/_meta-box-gateway-config.scss","../scss/admin/_meta-box-gateway-test.scss","../scss/admin/_meta-box-payment-log.scss","../scss/admin/_meta-box-subscription-info.scss","../scss/admin/_meta-box-update.scss","../scss/admin/_settings.scss","../scss/admin/_tables.scss","../scss/admin/_tabs.scss","../scss/admin/_text.scss","../scss/admin/_tip.scss","../scss/admin/_utilities.scss"],"names":[],"mappings":"AAAA;ACGA;EACC;EAEA;;;ACFA;EACC;;;AAIF;EACC;EAEA;EAEA;;;AAGD;EACC,YCfO;EDiBP;EACA;EACA;EAEA;EAEA;EACA;;AAEA;EACC;EAEA;EAEA,OCvBK;EDyBL;EAEA;EACA;EAEA;EACA;;AAEA;EACC,oBCyDkC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RD;EACC;;;ACDD;EACC;EACA;;AAIF;EACC;;;ACPA;EACC;;;ACDF;AAAA;EACC;EACA;;;AAIF;EACC;EACA;;;AAGD;EACC,YViD8C;EU/C9C;EAEA;;;AAGD;EACC;EAEA;;;AAGD;EACC;;;AAGD;EACC;;;AC/BA;EAEC;;;ACJF;EACC;;;AAKC;EACC;;AAKD;AAAA;EAEC,OZHI;;AYQL;EACC;;AAEA;EACC;;;AAQH;EACC;;;AAQC;EACC,YZegC;;;AYPnC;EACC,YZMkC;;;AYCjC;EACC;EACA;EACA;EACA;EACA;;;AAOJ;EACC;;AAIE;EACC;;;AASH;AAAA;AAAA;EAGC;;AAGD;AAAA;EAEC;;;AAIF;EAUK;IAGC;;EAEA;IACC;;EAOD;IAGC;;;ACzHP;EACC;EAEA;EAEA;EAEA;EAEA;;AAEA;EACC,YbsCwB;EapCxB;EACA;EAEA;EAEA;EAEA;EAEA;EACA;;AAEA;EACC,YbzBK;Ea2BL;EAEA;;;AAqBC;EACC,kBAjBa;;;AAgBd;EACC,kBAjBa;;;AAgBd;EACC,kBAjBa;;;AAgBd;EACC,kBAjBa;;;AAgBd;EACC,kBAjBa;;;AAgBd;EACC,kBAjBa;;;AAgBd;EACC,kBAjBa;;;AAgBd;EACC,kBAjBa;;;AAgBd;EACC,kBAjBa;;;AAwBlB;EACC;EACA;EAEA;;AAGA;EAEC;;AAEA;EAEC;;;AAKH;EACC;;;AAGD;EACC;IACC;;;EAGD;IACC;;EAEA;IACC;;;AAKH;EAGG;AAAA;IAEC;;;AClGJ;EACC;;;AAGD;EACC,OdFK;;;AcKN;EACC,OdJQ;;;AePP;EACC,OfkBS;EehBT;;;AAOD;EACC;;;ACXH;EACC","file":"admin.css"}
\ No newline at end of file
diff --git a/docs/hooks.md b/docs/hooks.md
index 8c615633..3b146fd7 100644
--- a/docs/hooks.md
+++ b/docs/hooks.md
@@ -418,7 +418,7 @@ Argument | Type | Description
`$url` | `null\|string` | Redirect URL.
`$payment` | `\Pronamic\WordPress\Pay\Payments\Payment` | Payment.
-Source: [src/Plugin.php](../src/Plugin.php), [line 1207](../src/Plugin.php#L1207-L1213)
+Source: [src/Plugin.php](../src/Plugin.php), [line 1201](../src/Plugin.php#L1201-L1207)
### `pronamic_gateway_configuration_display_value`
diff --git a/js/dist/admin.js b/js/dist/admin.js
index 98640a07..cde037e6 100644
--- a/js/dist/admin.js
+++ b/js/dist/admin.js
@@ -233,6 +233,61 @@
} );
};
+ /**
+ * Pronamic Pay post status.
+ */
+ var PronamicPayPostStatus = function( element ) {
+ var $element = $( element );
+
+ // Post Status edit click.
+ $element.siblings( 'a.edit-pronamic-pay-post-status' ).on( 'click', function( event ) {
+ if ( $element.is( ':hidden' ) ) {
+ $element.slideDown( 'fast', function() { $element.find( 'select' ).trigger( 'focus' ); } );
+
+ $( this ).hide();
+ }
+
+ event.preventDefault();
+ } );
+
+ // Save post status changes and hide options.
+ $element.find( '.save-pronamic-pay-post-status' ).on( 'click', function( event ) {
+ $element.slideUp( 'fast' ).siblings( 'a.edit-pronamic-pay-post-status' ).show().trigger( 'focus' );
+
+ $( '#pronamic-pay-status-display' ).text( $( '#pronamic-pay-post-status option:selected' ).text() );
+
+ event.preventDefault();
+ } );
+
+ // Cancel post status editing and hide options.
+ $element.find( '.cancel-pronamic-pay-post-status' ).on( 'click', function( event ) {
+ $element.slideUp( 'fast' ).siblings( 'a.edit-pronamic-pay-post-status' ).show().trigger( 'focus' );
+
+ $( '#pronamic-pay-post-status' ).val( $( '#hidden_pronamic_pay_post_status' ).val() );
+
+ $( '#pronamic-pay-status-display' ).text( $( '#pronamic-pay-post-status option:selected' ).text() );
+
+ event.preventDefault();
+ } );
+ };
+
+ /**
+ * jQuery plugin - Pronamic Pay post status
+ */
+ $.fn.pronamicPayPostStatus = function() {
+ return this.each( function() {
+ var $this = $( this );
+
+ if ( $this.data( 'pronamic-pay-post-status' ) ) {
+ return;
+ }
+
+ var postStatus = new PronamicPayPostStatus( this );
+
+ $this.data( 'pronamic-pay-post-status', postStatus );
+ } );
+ };
+
/**
* Pronamic pay gateway test
*/
@@ -370,6 +425,7 @@
$( document ).ready( function() {
$( '#pronamic-pay-gateway-config-editor' ).pronamicPayGatewayConfigEditor();
$( '#pronamic_payment_form_options').pronamicPayFormOptions();
+ $( '#pronamic-pay-post-status-select' ).pronamicPayPostStatus();
$( '#pronamic_gateway_test').pronamicPayGatewayTest();
$( '.pronamic-pay-tabs' ).pronamicPayTabs();
diff --git a/js/src/admin.js b/js/src/admin.js
index 98640a07..cde037e6 100644
--- a/js/src/admin.js
+++ b/js/src/admin.js
@@ -233,6 +233,61 @@
} );
};
+ /**
+ * Pronamic Pay post status.
+ */
+ var PronamicPayPostStatus = function( element ) {
+ var $element = $( element );
+
+ // Post Status edit click.
+ $element.siblings( 'a.edit-pronamic-pay-post-status' ).on( 'click', function( event ) {
+ if ( $element.is( ':hidden' ) ) {
+ $element.slideDown( 'fast', function() { $element.find( 'select' ).trigger( 'focus' ); } );
+
+ $( this ).hide();
+ }
+
+ event.preventDefault();
+ } );
+
+ // Save post status changes and hide options.
+ $element.find( '.save-pronamic-pay-post-status' ).on( 'click', function( event ) {
+ $element.slideUp( 'fast' ).siblings( 'a.edit-pronamic-pay-post-status' ).show().trigger( 'focus' );
+
+ $( '#pronamic-pay-status-display' ).text( $( '#pronamic-pay-post-status option:selected' ).text() );
+
+ event.preventDefault();
+ } );
+
+ // Cancel post status editing and hide options.
+ $element.find( '.cancel-pronamic-pay-post-status' ).on( 'click', function( event ) {
+ $element.slideUp( 'fast' ).siblings( 'a.edit-pronamic-pay-post-status' ).show().trigger( 'focus' );
+
+ $( '#pronamic-pay-post-status' ).val( $( '#hidden_pronamic_pay_post_status' ).val() );
+
+ $( '#pronamic-pay-status-display' ).text( $( '#pronamic-pay-post-status option:selected' ).text() );
+
+ event.preventDefault();
+ } );
+ };
+
+ /**
+ * jQuery plugin - Pronamic Pay post status
+ */
+ $.fn.pronamicPayPostStatus = function() {
+ return this.each( function() {
+ var $this = $( this );
+
+ if ( $this.data( 'pronamic-pay-post-status' ) ) {
+ return;
+ }
+
+ var postStatus = new PronamicPayPostStatus( this );
+
+ $this.data( 'pronamic-pay-post-status', postStatus );
+ } );
+ };
+
/**
* Pronamic pay gateway test
*/
@@ -370,6 +425,7 @@
$( document ).ready( function() {
$( '#pronamic-pay-gateway-config-editor' ).pronamicPayGatewayConfigEditor();
$( '#pronamic_payment_form_options').pronamicPayFormOptions();
+ $( '#pronamic-pay-post-status-select' ).pronamicPayPostStatus();
$( '#pronamic_gateway_test').pronamicPayGatewayTest();
$( '.pronamic-pay-tabs' ).pronamicPayTabs();
diff --git a/scss/admin/_meta-box-update.scss b/scss/admin/_meta-box-update.scss
index 7da83173..0b0bd41d 100644
--- a/scss/admin/_meta-box-update.scss
+++ b/scss/admin/_meta-box-update.scss
@@ -25,3 +25,11 @@
text-align: right;
}
+
+#pronamic-pay-status-display {
+ font-weight: 600;
+}
+
+#pronamic-pay-post-status-select {
+ margin-top: 3px;
+}
diff --git a/views/meta-box-payment-info.php b/views/meta-box-payment-info.php
index efa428e3..fc4bdfc6 100644
--- a/views/meta-box-payment-info.php
+++ b/views/meta-box-payment-info.php
@@ -25,32 +25,37 @@
date->format_i18n() ); ?>
|
-