Skip to content

Commit

Permalink
Merge branch 'release/3.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Aug 5, 2021
2 parents 8089f1f + 3cf2754 commit be2c8bd
Show file tree
Hide file tree
Showing 11 changed files with 282 additions and 149 deletions.
35 changes: 23 additions & 12 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
build:
nodes:
analysis:
tests:
override:
- php-scrutinizer-run

coverage:
tests:
override:
- command: ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml
coverage:
file: build/logs/clover.xml
format: clover

environment:
php: 7.3.0
variables:
WP_TESTS_DB_NAME: 'wp_phpunit_tests'
WP_TESTS_DB_USER: 'root'
WP_TESTS_DB_PASS: ''
WP_TESTS_DB_HOST: 'localhost'
project_setup:
before:
- mysql -e "CREATE DATABASE wp_phpunit_tests"
WP_TESTS_DB_HOST: '127.0.0.1'

services:
mysql: 5.7

dependencies:
override:
- composer install --ignore-platform-reqs --no-interaction
nodes:
coverage:
tests:
override:
- command: ./vendor/bin/phpunit
coverage:
file: build/logs/clover.xml
format: clover

project_setup:
before:
- mysql -e "CREATE DATABASE wp_phpunit_tests"

checks:
php:
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
## [Unreleased][unreleased]
-

## [3.0.0] - 2021-08-05
- Updated to `pronamic/wp-pay-core` version `3.0.0`.
- Updated to `pronamic/wp-money` version `2.0.0`.
- Changed `TaxedMoney` to `Money`, no tax info.
- Switched to `pronamic/wp-coding-standards`.
- Added subscription email parameters.

## [2.3.3] - 2021-06-18
- Added subscription mandate selection link to account update page.
- Fixed updating gateway in subscription/transaction on payment method update (via mandate selection URL).
Expand Down Expand Up @@ -131,7 +138,8 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
## 1.0.0 - 2016-02-01
- First release.

[unreleased]: https://github.com/wp-pay-extensions/memberpress/compare/2.3.3...HEAD
[unreleased]: https://github.com/wp-pay-extensions/memberpress/compare/3.0.0...HEAD
[3.0.0]: https://github.com/wp-pay-extensions/memberpress/compare/2.3.3...3.0.0
[2.3.3]: https://github.com/wp-pay-extensions/memberpress/compare/2.3.2...2.3.3
[2.3.2]: https://github.com/wp-pay-extensions/memberpress/compare/2.3.1...2.3.2
[2.3.1]: https://github.com/wp-pay-extensions/memberpress/compare/2.3.0...2.3.1
Expand Down
12 changes: 4 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,16 @@
},
"require": {
"php": ">=5.6.20",
"wp-pay/core": "^2.6"
"wp-pay/core": "^3.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
"php-coveralls/php-coveralls": "^2.4",
"phpcompatibility/php-compatibility": "^9.2",
"phpcompatibility/phpcompatibility-wp": "^2.0",
"phpmd/phpmd": "^2.7",
"phpunit/phpunit": "^5.7 || ^6.0",
"roots/wordpress": "^5.6",
"squizlabs/php_codesniffer": "^3.4",
"wp-coding-standards/wpcs": "^2.3",
"wp-phpunit/wp-phpunit": "^5.6",
"pronamic/wp-coding-standards": "^1.0",
"roots/wordpress": "^5.8",
"wp-phpunit/wp-phpunit": "^5.8",
"wp-premium/memberpress-basic": "^1.3"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "memberpress",
"version": "2.3.3",
"version": "3.0.0",
"description": "MemberPress driver for the WordPress payment processing library.",
"repository": {
"type": "git",
Expand Down
22 changes: 2 additions & 20 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -1,32 +1,14 @@
<?xml version="1.0"?>

<ruleset name="WordPress Pay MemberPress rules">
<config name="minimum_supported_wp_version" value="4.7" />

<config name="testVersion" value="5.6-" />

<file>.</file>

<arg name="colors"/>
<arg name="extensions" value="php" />
<arg name="parallel" value="8" />
<arg value="sp" />

<exclude-pattern>node_modules/*</exclude-pattern>
<exclude-pattern>tests/bootstrap.php</exclude-pattern>
<exclude-pattern>tests/wp-config.php</exclude-pattern>
<exclude-pattern>vendor/*</exclude-pattern>
<exclude-pattern>wordpress/*</exclude-pattern>
<exclude-pattern type="relative">^wp-content/*</exclude-pattern>

<rule ref="PHPCompatibilityWP" />

<rule ref="WordPress">
<exclude name="Generic.Files.LowercasedFilename.NotFound" />

<rule ref="PronamicWP">
<exclude name="WordPress.DB.SlowDBQuery.slow_db_query_meta_query" />

<exclude name="WordPress.Files.FileName.InvalidClassFileName" />
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />
<exclude name="WordPressVIPMinimum.Performance.NoPaging.nopaging_nopaging" />
</rule>
</ruleset>
4 changes: 0 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
</whitelist>
</filter>

<logging>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>

<php>
<env name="WP_PHPUNIT__TESTS_CONFIG" value="tests/wp-config.php" />
</php>
Expand Down
69 changes: 68 additions & 1 deletion src/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,12 @@ public function setup() {

\add_action( 'mepr_subscription_transition_status', array( $this, 'memberpress_subscription_transition_status' ), 10, 3 );

// MemberPress subscription email parameters.
\add_filter( 'mepr_subscription_email_params', array( $this, 'subscription_email_params' ), 10, 2 );
\add_filter( 'mepr_transaction_email_params', array( $this, 'transaction_email_params' ), 10, 2 );

// Hide MemberPress columns for payments and subscriptions.
\add_filter( 'registered_post_type', array( $this, 'post_type_columns_hide' ), 15, 1 );
\add_action( 'registered_post_type', array( $this, 'post_type_columns_hide' ), 15, 1 );

if ( \is_admin() ) {
$this->admin_subscriptions = new Admin\AdminSubscriptions();
Expand Down Expand Up @@ -399,6 +403,69 @@ public function subscription_pre_delete( $subscription_id ) {
}
}

/**
* Subscription email parameters.
*
* @param array $params Email parameters.
* @param MeprSubscription $memberpress_subscription MemberPress subscription.
* @return array
*/
public function subscription_email_params( $params, MeprSubscription $memberpress_subscription ) {
$subscriptions = \get_pronamic_subscriptions_by_source( 'memberpress', $memberpress_subscription->id );

if ( empty( $subscriptions ) ) {
return $params;
}

$subscription = reset( $subscriptions );

// Add parameters.
$next_payment_date = $subscription->get_next_payment_date();

return \array_merge(
$params,
array(
'pronamic_subscription_id' => $subscription->get_id(),
'pronamic_subscription_cancel_url' => $subscription->get_cancel_url(),
'pronamic_subscription_renewal_url' => $subscription->get_renewal_url(),
'pronamic_subscription_renewal_date' => null === $next_payment_date ? '' : \date_i18n( \get_option( 'date_format' ), $next_payment_date->getTimestamp() ),
)
);
}

/**
* Transaction email parameters.
*
* @param array $params Parameters.
* @param MeprTransaction $transaction MemberPress transaction.
* @return array
*/
public function transaction_email_params( $params, MeprTransaction $transaction ) {
$payments = \get_pronamic_payments_by_source( 'memberpress', $transaction->id );

if ( null === $payments ) {
return $params;
}

$payment = reset( $payments );

// Get subscription.
$periods = $payment->get_periods();

if ( null === $periods ) {
return $params;
}

$period = reset( $periods );

$subscription = $period->get_phase()->get_subscription();

// Add parameters.
$memberpress_subscription = new MeprSubscription( $subscription->get_source_id() );

return $this->subscription_email_params( $params, $memberpress_subscription );
}

/**
* Source text.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Gateways/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ public function display_payment_form( $amount, $user, $product_id, $txn_id ) {
<div class="mepr_spacer">&nbsp;</div>

<input type="submit" class="mepr-submit" value="<?php esc_attr_e( 'Pay', 'pronamic_ideal' ); ?>"/>
<img src="<?php echo esc_attr( admin_url( 'images/loading.gif' ) ); ?>" style="display: none;" class="mepr-loading-gif"/>
<img src="<?php echo \esc_url( admin_url( 'images/loading.gif' ) ); ?>" style="display: none;" class="mepr-loading-gif"/>
<?php MeprView::render( '/shared/has_errors', get_defined_vars() ); ?>

<noscript>
Expand Down
2 changes: 1 addition & 1 deletion src/Pronamic.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public static function get_subscription( MeprTransaction $memberpress_transactio
$subscription,
$start_date,
new SubscriptionInterval( 'P' . $memberpress_product->period . Core_Util::to_period( $memberpress_product->period_type ) ),
new TaxedMoney( $memberpress_transaction->total, MemberPress::get_currency() )
new Money( $memberpress_transaction->total, MemberPress::get_currency() )
);

$regular_phase->set_total_periods( $total_periods );
Expand Down
46 changes: 25 additions & 21 deletions vendor-bin/phpstan/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit be2c8bd

Please sign in to comment.