Skip to content

Commit

Permalink
Merge branch 'trunk' into fix/articles-infinite-loading
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoo authored Sep 20, 2024
2 parents e706ef9 + 0b0b02c commit 153f717
Show file tree
Hide file tree
Showing 17 changed files with 272 additions and 189 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## [4.1.2](https://github.com/Automattic/newspack-blocks/compare/v4.1.1...v4.1.2) (2024-09-17)


### Bug Fixes

* **modal-checkout:** tweak HTML to satisfy Woo Payments field validation ([#1883](https://github.com/Automattic/newspack-blocks/issues/1883)) ([16b5e9d](https://github.com/Automattic/newspack-blocks/commit/16b5e9db840d7dfccd064776285221c66d92e7f2))

## [4.1.1](https://github.com/Automattic/newspack-blocks/compare/v4.1.0...v4.1.1) (2024-09-16)


### Bug Fixes

* support new is_my_account() method from main plugin ([#1869](https://github.com/Automattic/newspack-blocks/issues/1869)) ([b9a3aba](https://github.com/Automattic/newspack-blocks/commit/b9a3aba064073f97bca5e08dd96ff450fe287faf))

# [4.1.0](https://github.com/Automattic/newspack-blocks/compare/v4.0.1...v4.1.0) (2024-08-26)


Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dealerdirect/phpcodesniffer-composer-installer": "*",
"phpcompatibility/phpcompatibility-wp": "*",
"sirbrillig/phpcs-variable-analysis": "^2.10",
"yoast/phpunit-polyfills": "^2.0",
"yoast/phpunit-polyfills": "^3.0",
"phpunit/phpunit": "^7.0 || ^9.5"
},
"license": "GPL-3.0-or-later",
Expand Down
112 changes: 56 additions & 56 deletions composer.lock

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

39 changes: 20 additions & 19 deletions includes/class-modal-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public static function woocommerce_checkout_create_order_line_item( $item, $cart
* Change the post-transaction return URL.
* This is specifically for non-redirect-based flows, such as Apple Pay.
*
* @param array $result The return payload for a successfull transaction.
* @param array $result The return payload for a successful transaction.
*/
public static function woocommerce_payment_successful_result( $result ) {
$order_id = $result['order_id'];
Expand All @@ -134,24 +134,21 @@ public static function woocommerce_payment_successful_result( $result ) {
return $result;
}

$originating_from_modal = ! empty( $order->get_meta( '_newspack_modal_checkout_url' ) );
if ( $originating_from_modal ) {
$modal_checkout_url_query = \wp_parse_url( $modal_checkout_url, PHP_URL_QUERY );
\wp_parse_str( $modal_checkout_url_query, $modal_checkout_url_query_params );
$passed_params_names = [ 'modal_checkout', 'after_success_behavior', 'after_success_url', 'after_success_button_label' ];
// Pick passed params from the query params.
$passed_params = array_intersect_key( $modal_checkout_url_query_params, array_flip( $passed_params_names ) );

$result['redirect'] = \add_query_arg(
array_merge(
$passed_params,
[
'order_id' => $order_id,
]
),
$result['redirect']
);
}
$modal_checkout_url_query = \wp_parse_url( $modal_checkout_url, PHP_URL_QUERY );
\wp_parse_str( $modal_checkout_url_query, $modal_checkout_url_query_params );
$passed_params_names = [ 'modal_checkout', 'after_success_behavior', 'after_success_url', 'after_success_button_label' ];
// Pick passed params from the query params.
$passed_params = array_intersect_key( $modal_checkout_url_query_params, array_flip( $passed_params_names ) );

$result['redirect'] = \add_query_arg(
array_merge(
$passed_params,
[
'order_id' => $order_id,
]
),
$result['redirect']
);
return $result;
}

Expand Down Expand Up @@ -1077,6 +1074,10 @@ public static function hide_expiry_message_shop_link( $message ) {
* Is this request using the modal checkout?
*/
public static function is_modal_checkout() {
// Until we use the modal checkout flow from My Account, we don't want to show the modal checkout thank you template for checkouts originating from My Account.
if ( method_exists( 'Newspack\WooCommerce_My_Account', 'is_from_my_account' ) && \Newspack\WooCommerce_My_Account::is_from_my_account() ) {
return false;
}

$is_modal_checkout = isset( $_REQUEST['modal_checkout'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( ! $is_modal_checkout && isset( $_REQUEST['post_data'] ) && is_string( $_REQUEST['post_data'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
Expand Down
1 change: 1 addition & 0 deletions includes/class-newspack-blocks-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ public static function posts_endpoint( $request ) {
'excerpt' => [
'rendered' => post_password_required( $post ) ? '' : $excerpt,
],
'full_content' => get_the_content( $post->ID ),
'featured_media' => (int) get_post_thumbnail_id( $post->ID ),
'id' => $post->ID,
'meta' => $meta->get_value( $post->ID, $request ),
Expand Down
5 changes: 2 additions & 3 deletions newspack-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@
* Author URI: https://newspack.com/
* Text Domain: newspack-blocks
* Domain Path: /languages
* Version: 4.1.0
* Version: 4.1.2
*
* @package Newspack_Blocks
*/

define( 'NEWSPACK_BLOCKS__PLUGIN_FILE', __FILE__ );
define( 'NEWSPACK_BLOCKS__BLOCKS_DIRECTORY', 'dist/' );
define( 'NEWSPACK_BLOCKS__PLUGIN_DIR', plugin_dir_path( NEWSPACK_BLOCKS__PLUGIN_FILE ) );
define( 'NEWSPACK_BLOCKS__VERSION', '4.1.0' );
define( 'NEWSPACK_BLOCKS__VERSION', '4.1.2' );

require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks.php';
require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks-api.php';
require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks-patterns.php';
require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks-caching.php';
require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-modal-checkout.php';

require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/plugins/class-the-events-calendar.php';
Expand Down
Loading

0 comments on commit 153f717

Please sign in to comment.