Skip to content

Commit

Permalink
Merge branch 'release/4.1.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed May 4, 2022
2 parents 8dabf24 + f4268d7 commit 661e1b8
Show file tree
Hide file tree
Showing 125 changed files with 1,835 additions and 2,002 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
## [Unreleased][unreleased]
-

## [4.1.3] - 2022-05-04
### Changed
- Solved some PHPStan and Psalm errors.
- Improved PHP 8.1 support.

### Removed
- Removed `plugins_api` filter, callback does not exist.
- Removed specific s2Member code, we no longer support s2Member.
- Removed specific WP e-Commerce code, we no longer support WP e-Commerce.

## [4.1.2] - 2022-04-19
### Fixed
- Fixed plugin updater.
Expand Down Expand Up @@ -477,7 +487,8 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
## 1.0.0
- First release.

[unreleased]: https://github.com/pronamic/wp-pay-core/compare/4.1.2...HEAD
[unreleased]: https://github.com/pronamic/wp-pay-core/compare/4.1.3...HEAD
[4.1.3]: https://github.com/pronamic/wp-pay-core/compare/4.1.2...4.1.3
[4.1.2]: https://github.com/pronamic/wp-pay-core/compare/4.1.1...4.1.2
[4.1.1]: https://github.com/pronamic/wp-pay-core/compare/4.1.0...4.1.1
[4.1.0]: https://github.com/pronamic/wp-pay-core/compare/4.0.2...4.1.0
Expand Down
78 changes: 39 additions & 39 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function get_pronamic_payment( $post_id ) {
* @param array $args Query arguments.
* @return Payment|null
*/
function get_pronamic_payment_by_meta( $meta_key, $meta_value, $args = array() ) {
function get_pronamic_payment_by_meta( $meta_key, $meta_value, $args = [] ) {
$args['posts_per_page'] = 1;

$payments = get_pronamic_payments_by_meta( $meta_key, $meta_value, $args );
Expand All @@ -68,29 +68,29 @@ function get_pronamic_payment_by_meta( $meta_key, $meta_value, $args = array() )
* @param array $args Query arguments.
* @return Payment[]
*/
function get_pronamic_payments_by_meta( $meta_key, $meta_value, $args = array() ) {
$payments = array();
function get_pronamic_payments_by_meta( $meta_key, $meta_value, $args = [] ) {
$payments = [];

$defaults = array(
$defaults = [
'post_type' => 'pronamic_payment',
'post_status' => 'any',
'posts_per_page' => -1,
'no_found_rows' => true,
'meta_query' => array(),
);
'meta_query' => [],
];

$args = wp_parse_args( $args, $defaults );

// Add meta query for given meta key and value.
if ( ! empty( $meta_key ) ) {
if ( ! is_array( $args['meta_query'] ) ) {
$args['meta_query'] = array();
$args['meta_query'] = [];
}

$args['meta_query'][] = array(
$args['meta_query'][] = [
'key' => $meta_key,
'value' => $meta_value,
);
];
}

$query = new WP_Query( $args );
Expand Down Expand Up @@ -139,7 +139,7 @@ function get_pronamic_payments_by_user_id( $user_id = null ) {
$user_id = \get_current_user_id();
}

return get_pronamic_payments_by_meta( null, null, array( 'author' => $user_id ) );
return get_pronamic_payments_by_meta( null, null, [ 'author' => $user_id ] );
}

/**
Expand All @@ -151,27 +151,27 @@ function get_pronamic_payments_by_user_id( $user_id = null ) {
*/
function get_pronamic_payments_by_source( $source, $source_id = null ) {
// Meta query.
$meta_query = array(
array(
$meta_query = [
[
'key' => '_pronamic_payment_source',
'value' => $source,
),
);
],
];

// Add source ID meta query condition.
if ( ! empty( $source_id ) ) {
$meta_query[] = array(
$meta_query[] = [
'key' => '_pronamic_payment_source_id',
'value' => $source_id,
);
];
}

// Return.
$args = array(
$args = [
'meta_query' => $meta_query,
'order' => 'DESC',
'orderby' => 'ID',
);
];

return get_pronamic_payments_by_meta( null, null, $args );
}
Expand All @@ -194,7 +194,7 @@ function get_pronamic_subscription( $post_id ) {
* @param array $args Query arguments.
* @return Subscription|null
*/
function get_pronamic_subscription_by_meta( $meta_key, $meta_value, $args = array() ) {
function get_pronamic_subscription_by_meta( $meta_key, $meta_value, $args = [] ) {
$args['posts_per_page'] = 1;

$subscriptions = get_pronamic_subscriptions_by_meta( $meta_key, $meta_value, $args );
Expand All @@ -218,28 +218,28 @@ function get_pronamic_subscription_by_meta( $meta_key, $meta_value, $args = arra
* @param array $args Query arguments.
* @return Subscription[]
*/
function get_pronamic_subscriptions_by_meta( $meta_key, $meta_value, $args = array() ) {
$subscriptions = array();
function get_pronamic_subscriptions_by_meta( $meta_key, $meta_value, $args = [] ) {
$subscriptions = [];

$defaults = array(
$defaults = [
'post_type' => 'pronamic_pay_subscr',
'post_status' => 'any',
'posts_per_page' => -1,
'no_found_rows' => true,
'meta_query' => array(),
);
'meta_query' => [],
];

$args = wp_parse_args( $args, $defaults );

// Add meta query for given meta key and value.
if ( ! is_array( $args['meta_query'] ) ) {
$args['meta_query'] = array();
$args['meta_query'] = [];
}

$args['meta_query'][] = array(
$args['meta_query'][] = [
'key' => $meta_key,
'value' => $meta_value,
);
];

$query = new WP_Query( $args );

Expand All @@ -266,7 +266,7 @@ function get_pronamic_subscriptions_by_user_id( $user_id = null ) {
$user_id = \get_current_user_id();
}

return get_pronamic_subscriptions_by_meta( null, null, array( 'author' => $user_id ) );
return get_pronamic_subscriptions_by_meta( null, null, [ 'author' => $user_id ] );
}

/**
Expand All @@ -278,27 +278,27 @@ function get_pronamic_subscriptions_by_user_id( $user_id = null ) {
*/
function get_pronamic_subscriptions_by_source( $source, $source_id = null ) {
// Meta query.
$meta_query = array(
array(
$meta_query = [
[
'key' => '_pronamic_subscription_source',
'value' => $source,
),
);
],
];

// Add source ID meta query condition.
if ( ! empty( $source_id ) ) {
$meta_query[] = array(
$meta_query[] = [
'key' => '_pronamic_subscription_source_id',
'value' => $source_id,
);
];
}

// Return.
$args = array(
$args = [
'meta_query' => $meta_query,
'order' => 'DESC',
'orderby' => 'ID',
);
];

return get_pronamic_subscriptions_by_meta( null, null, $args );
}
Expand All @@ -315,9 +315,9 @@ function bind_providers_and_gateways() {
$provider = $integration->provider;

if ( ! isset( $pronamic_pay_providers[ $provider ] ) ) {
$pronamic_pay_providers[ $provider ] = array(
'integrations' => array(),
);
$pronamic_pay_providers[ $provider ] = [
'integrations' => [],
];
}

$pronamic_pay_providers[ $provider ]['integrations'][] = $integration;
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": "@wp-pay/core",
"version": "4.1.2",
"version": "4.1.3",
"description": "Core components for the WordPress payment processing library.",
"repository": {
"type": "git",
Expand Down
5 changes: 1 addition & 4 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
includes:
- vendor-bin/phpstan/vendor/szepeviktor/phpstan-wordpress/extension.neon
parameters:
level: max
level: 8
checkMissingIterableValueType: false
dynamicConstantNames:
- DOING_AUTOSAVE
Expand All @@ -21,6 +21,3 @@ parameters:
ignoreErrors:
# Uses func_get_args()
- '#^Function apply_filters(_ref_array)? invoked with [34567] parameters, 2 required\.$#'
-
message: '#Function pll_home_url not found\.#'
path: src/Payments/Payment.php
2 changes: 1 addition & 1 deletion src/AbstractDataStoreCPT.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ abstract class AbstractDataStoreCPT {
*
* @var array
*/
protected $meta = array();
protected $meta = [];

/**
* Meta key prefix.
Expand Down
20 changes: 10 additions & 10 deletions src/AbstractGatewayIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ abstract class AbstractGatewayIntegration extends AbstractIntegration {
/**
* URL.
*
* @var string
* @var string|null
*/
public $url;

/**
* Product URL.
*
* @var string
* @var string|null
*/
public $product_url;

Expand Down Expand Up @@ -66,7 +66,7 @@ abstract class AbstractGatewayIntegration extends AbstractIntegration {
*
* @var array
*/
protected $supports = array();
protected $supports = [];

use ModeTrait;

Expand All @@ -75,18 +75,18 @@ abstract class AbstractGatewayIntegration extends AbstractIntegration {
*
* @param array $args Arguments.
*/
public function __construct( $args = array() ) {
public function __construct( $args = [] ) {
$args = wp_parse_args(
$args,
array(
[
'mode' => 'live',
'provider' => null,
'url' => null,
'product_url' => null,
'dashboard_url' => null,
'manual_url' => null,
'supports' => array(),
)
'supports' => [],
]
);

parent::__construct( $args );
Expand Down Expand Up @@ -123,7 +123,7 @@ public function get_provider() {
* @return array
*/
public function get_settings() {
return array();
return [];
}

/**
Expand All @@ -132,7 +132,7 @@ public function get_settings() {
* @return array
*/
public function get_settings_fields() {
return array();
return [];
}

/**
Expand Down Expand Up @@ -183,7 +183,7 @@ public function set_manual_url( $manual_url ) {
/**
* Get provider URL.
*
* @return string|false
* @return string|null
*/
public function get_url() {
return $this->url;
Expand Down
6 changes: 3 additions & 3 deletions src/AbstractIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ abstract class AbstractIntegration {
*
* @param array $args Arguments.
*/
public function __construct( $args = array() ) {
public function __construct( $args = [] ) {
$args = wp_parse_args(
$args,
array(
[
'id' => null,
'name' => null,
'version' => null,
'version_option_name' => null,
'db_version_option_name' => null,
'deprecated' => false,
)
]
);

// ID.
Expand Down
8 changes: 4 additions & 4 deletions src/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ public function set_phone( $phone ) {
* @return object|null
*/
public function get_json() {
$data = array(
$data = [
'name' => ( null === $this->name ) ? null : $this->name->get_json(),
'email' => $this->get_email(),
'company_name' => $this->get_company_name(),
Expand All @@ -512,7 +512,7 @@ public function get_json() {
'region' => ( null === $this->region ) ? null : $this->region->get_json(),
'country' => ( null === $this->country ) ? null : $this->country->get_json(),
'phone' => $this->get_phone(),
);
];

$data = array_filter( $data );

Expand Down Expand Up @@ -622,7 +622,7 @@ public static function from_json( $json ) {
* @return string
*/
public function __toString() {
$parts = array(
$parts = [
$this->get_company_name(),
$this->get_name(),
$this->get_line_1(),
Expand All @@ -631,7 +631,7 @@ public function __toString() {
$this->get_country_code(),
$this->get_phone(),
$this->get_email(),
);
];

$parts = array_map( 'strval', $parts );

Expand Down
Loading

0 comments on commit 661e1b8

Please sign in to comment.