Skip to content

Commit

Permalink
feat: deprecate streamlined (Stripe) Donate block version (#1638)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: streamlined (Stripe) Donate block version is no more
  • Loading branch information
dkoo committed Jan 24, 2024
1 parent 947ed9a commit fc36e5b
Show file tree
Hide file tree
Showing 36 changed files with 125 additions and 2,454 deletions.
23 changes: 0 additions & 23 deletions __mocks__/@stripe/stripe-js/pure/index.js

This file was deleted.

46 changes: 14 additions & 32 deletions includes/class-newspack-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class Newspack_Blocks {
const SCRIPT_HANDLES = [
'modal-checkout' => 'newspack-blocks-donate-modal-checkout',
'modal-checkout-block' => 'newspack-blocks-donate-modal-checkout-block',
'streamlined' => 'newspack-blocks-donate-streamlined',
'frequency-based' => 'newspack-blocks-donate-frequency-based',
'tiers-based' => 'newspack-blocks-donate-tiers-based',
];
Expand Down Expand Up @@ -247,18 +246,17 @@ public static function enqueue_block_editor_assets() {
);

$localized_data = [
'patterns' => self::get_patterns_for_post_type( get_post_type() ),
'posts_rest_url' => rest_url( 'newspack-blocks/v1/newspack-blocks-posts' ),
'specific_posts_rest_url' => rest_url( 'newspack-blocks/v1/newspack-blocks-specific-posts' ),
'authors_rest_url' => rest_url( 'newspack-blocks/v1/authors' ),
'assets_path' => plugins_url( '/src/assets', NEWSPACK_BLOCKS__PLUGIN_FILE ),
'post_subtitle' => get_theme_support( 'post-subtitle' ),
'is_rendering_stripe_payment_form' => self::is_rendering_stripe_payment_form(),
'iframe_accepted_file_mimes' => self::iframe_accepted_file_mimes(),
'supports_recaptcha' => class_exists( 'Newspack\Recaptcha' ),
'has_recaptcha' => class_exists( 'Newspack\Recaptcha' ) && \Newspack\Recaptcha::can_use_captcha(),
'recaptcha_url' => admin_url( 'admin.php?page=newspack-connections-wizard' ),
'custom_taxonomies' => self::get_custom_taxonomies(),
'patterns' => self::get_patterns_for_post_type( get_post_type() ),
'posts_rest_url' => rest_url( 'newspack-blocks/v1/newspack-blocks-posts' ),
'specific_posts_rest_url' => rest_url( 'newspack-blocks/v1/newspack-blocks-specific-posts' ),
'authors_rest_url' => rest_url( 'newspack-blocks/v1/authors' ),
'assets_path' => plugins_url( '/src/assets', NEWSPACK_BLOCKS__PLUGIN_FILE ),
'post_subtitle' => get_theme_support( 'post-subtitle' ),
'iframe_accepted_file_mimes' => self::iframe_accepted_file_mimes(),
'supports_recaptcha' => class_exists( 'Newspack\Recaptcha' ),
'has_recaptcha' => class_exists( 'Newspack\Recaptcha' ) && \Newspack\Recaptcha::can_use_captcha(),
'recaptcha_url' => admin_url( 'admin.php?page=newspack-connections-wizard' ),
'custom_taxonomies' => self::get_custom_taxonomies(),
];

if ( class_exists( 'WP_REST_Newspack_Author_List_Controller' ) ) {
Expand Down Expand Up @@ -294,22 +292,6 @@ public static function enqueue_block_editor_assets() {
);
}

/**
* Should the Donate block be a "streamlined" block?
*
* @return bool True if it can.
*/
public static function is_rendering_stripe_payment_form() {
if (
class_exists( 'Newspack\Donations' )
&& method_exists( 'Newspack\Donations', 'can_use_streamlined_donate_block' )
&& method_exists( 'Newspack\Donations', 'is_platform_stripe' )
) {
return \Newspack\Donations::can_use_streamlined_donate_block() && \Newspack\Donations::is_platform_stripe();
}
return false;
}

/**
* Enqueue block scripts and styles for view.
*/
Expand Down Expand Up @@ -802,9 +784,9 @@ public static function build_articles_query( $attributes, $block_name ) {
* The filter is called after the build_articles_query() function is called by a Newspack block to
* build the WP_Query arguments based on the given attributes and block requesting the query.
*
* @param array $args WP_Query arguments as created by build_articles_query()
* @param array $attributes The attributes initial passed to build_articles_query()
* @param string $block_name The name of the requesting block to create the query args for
* @param array $args WP_Query arguments as created by build_articles_query()
* @param array $attributes The attributes initial passed to build_articles_query()
* @param string $block_name The name of the requesting block to create the query args for
*/
return apply_filters( 'newspack_blocks_build_articles_query', $args, $attributes, $block_name );
}
Expand Down
40 changes: 0 additions & 40 deletions languages/newspack-blocks-de_DE.po
Original file line number Diff line number Diff line change
Expand Up @@ -751,30 +751,6 @@ msgstr ""
msgid "Paused"
msgstr ""

#: dist/donateStreamlined.js:1
#: release/newspack-blocks/dist/donateStreamlined.js:72
msgid "Email address is invalid."
msgstr ""

#. Translators: %d is minimum donation amount set in Reader Revenue wizard or block attributes.
#: dist/donateStreamlined.js:1
#: release/newspack-blocks/dist/donateStreamlined.js:72
msgid "Amount must be at least %d."
msgstr ""

#: dist/donateStreamlined.js:1
#: release/newspack-blocks/dist/donateStreamlined.js:72
msgid "Full name should be provided."
msgstr ""

#. Translators: %s is the email address of the current user.
#: dist/donateStreamlined.js:1
#: release/newspack-blocks/dist/donateStreamlined.js:72
msgid ""
"Your payment has been processed. Thank you for your contribution! You will "
"receive a confirmation email at %s."
msgstr ""

#: dist/editor.js:41 release/newspack-blocks/dist/editor.js:2541
#: release/newspack-blocks/src/blocks/author-list/edit.js:105
#: release/newspack-blocks/src/blocks/author-list/edit.js:109
Expand Down Expand Up @@ -1893,22 +1869,6 @@ msgstr ""
msgid "Remove Block"
msgstr ""

#: release/newspack-blocks/dist/donateStreamlined.js:61
msgid "Error loading the reCaptcha library."
msgstr ""

#: release/newspack-blocks/dist/donateStreamlined.js:61
msgid "Error processing captcha request."
msgstr ""

#: release/newspack-blocks/dist/donateStreamlined.js:61
msgid "Something went wrong with the payment. Please try again later."
msgstr ""

#: release/newspack-blocks/dist/donateStreamlined.js:61
msgid "Processing payment…"
msgstr ""

#: release/newspack-blocks/dist/editor.js:2541
#: release/newspack-blocks/src/blocks/author-list/edit.js:224
#: src/blocks/author-list/edit.js:224
Expand Down
40 changes: 0 additions & 40 deletions languages/newspack-blocks-es_ES.po
Original file line number Diff line number Diff line change
Expand Up @@ -743,30 +743,6 @@ msgstr ""
msgid "Paused"
msgstr ""

#: dist/donateStreamlined.js:1
#: release/newspack-blocks/dist/donateStreamlined.js:72
msgid "Email address is invalid."
msgstr ""

#. Translators: %d is minimum donation amount set in Reader Revenue wizard or block attributes.
#: dist/donateStreamlined.js:1
#: release/newspack-blocks/dist/donateStreamlined.js:72
msgid "Amount must be at least %d."
msgstr ""

#: dist/donateStreamlined.js:1
#: release/newspack-blocks/dist/donateStreamlined.js:72
msgid "Full name should be provided."
msgstr ""

#. Translators: %s is the email address of the current user.
#: dist/donateStreamlined.js:1
#: release/newspack-blocks/dist/donateStreamlined.js:72
msgid ""
"Your payment has been processed. Thank you for your contribution! You will "
"receive a confirmation email at %s."
msgstr ""

#: dist/editor.js:41 release/newspack-blocks/dist/editor.js:2541
#: release/newspack-blocks/src/blocks/author-list/edit.js:105
#: release/newspack-blocks/src/blocks/author-list/edit.js:109
Expand Down Expand Up @@ -1885,22 +1861,6 @@ msgstr ""
msgid "Remove Block"
msgstr ""

#: release/newspack-blocks/dist/donateStreamlined.js:61
msgid "Error loading the reCaptcha library."
msgstr ""

#: release/newspack-blocks/dist/donateStreamlined.js:61
msgid "Error processing captcha request."
msgstr ""

#: release/newspack-blocks/dist/donateStreamlined.js:61
msgid "Something went wrong with the payment. Please try again later."
msgstr ""

#: release/newspack-blocks/dist/donateStreamlined.js:61
msgid "Processing payment…"
msgstr ""

#: release/newspack-blocks/dist/editor.js:2541
#: release/newspack-blocks/src/blocks/author-list/edit.js:224
#: src/blocks/author-list/edit.js:224
Expand Down
40 changes: 0 additions & 40 deletions languages/newspack-blocks-fr_BE.po
Original file line number Diff line number Diff line change
Expand Up @@ -742,30 +742,6 @@ msgstr ""
msgid "Paused"
msgstr ""

#: dist/donateStreamlined.js:1
#: release/newspack-blocks/dist/donateStreamlined.js:72
msgid "Email address is invalid."
msgstr ""

#. Translators: %d is minimum donation amount set in Reader Revenue wizard or block attributes.
#: dist/donateStreamlined.js:1
#: release/newspack-blocks/dist/donateStreamlined.js:72
msgid "Amount must be at least %d."
msgstr ""

#: dist/donateStreamlined.js:1
#: release/newspack-blocks/dist/donateStreamlined.js:72
msgid "Full name should be provided."
msgstr ""

#. Translators: %s is the email address of the current user.
#: dist/donateStreamlined.js:1
#: release/newspack-blocks/dist/donateStreamlined.js:72
msgid ""
"Your payment has been processed. Thank you for your contribution! You will "
"receive a confirmation email at %s."
msgstr ""

#: dist/editor.js:41 release/newspack-blocks/dist/editor.js:2541
#: release/newspack-blocks/src/blocks/author-list/edit.js:105
#: release/newspack-blocks/src/blocks/author-list/edit.js:109
Expand Down Expand Up @@ -1884,22 +1860,6 @@ msgstr ""
msgid "Remove Block"
msgstr ""

#: release/newspack-blocks/dist/donateStreamlined.js:61
msgid "Error loading the reCaptcha library."
msgstr ""

#: release/newspack-blocks/dist/donateStreamlined.js:61
msgid "Error processing captcha request."
msgstr ""

#: release/newspack-blocks/dist/donateStreamlined.js:61
msgid "Something went wrong with the payment. Please try again later."
msgstr ""

#: release/newspack-blocks/dist/donateStreamlined.js:61
msgid "Processing payment…"
msgstr ""

#: release/newspack-blocks/dist/editor.js:2541
#: release/newspack-blocks/src/blocks/author-list/edit.js:224
#: src/blocks/author-list/edit.js:224
Expand Down
40 changes: 0 additions & 40 deletions languages/newspack-blocks-pt_PT.po
Original file line number Diff line number Diff line change
Expand Up @@ -743,30 +743,6 @@ msgstr ""
msgid "Paused"
msgstr ""

#: dist/donateStreamlined.js:1
#: release/newspack-blocks/dist/donateStreamlined.js:72
msgid "Email address is invalid."
msgstr ""

#. Translators: %d is minimum donation amount set in Reader Revenue wizard or block attributes.
#: dist/donateStreamlined.js:1
#: release/newspack-blocks/dist/donateStreamlined.js:72
msgid "Amount must be at least %d."
msgstr ""

#: dist/donateStreamlined.js:1
#: release/newspack-blocks/dist/donateStreamlined.js:72
msgid "Full name should be provided."
msgstr ""

#. Translators: %s is the email address of the current user.
#: dist/donateStreamlined.js:1
#: release/newspack-blocks/dist/donateStreamlined.js:72
msgid ""
"Your payment has been processed. Thank you for your contribution! You will "
"receive a confirmation email at %s."
msgstr ""

#: dist/editor.js:41 release/newspack-blocks/dist/editor.js:2541
#: release/newspack-blocks/src/blocks/author-list/edit.js:105
#: release/newspack-blocks/src/blocks/author-list/edit.js:109
Expand Down Expand Up @@ -1885,22 +1861,6 @@ msgstr ""
msgid "Remove Block"
msgstr ""

#: release/newspack-blocks/dist/donateStreamlined.js:61
msgid "Error loading the reCaptcha library."
msgstr ""

#: release/newspack-blocks/dist/donateStreamlined.js:61
msgid "Error processing captcha request."
msgstr ""

#: release/newspack-blocks/dist/donateStreamlined.js:61
msgid "Something went wrong with the payment. Please try again later."
msgstr ""

#: release/newspack-blocks/dist/donateStreamlined.js:61
msgid "Processing payment…"
msgstr ""

#: release/newspack-blocks/dist/editor.js:2541
#: release/newspack-blocks/src/blocks/author-list/edit.js:224
#: src/blocks/author-list/edit.js:224
Expand Down
38 changes: 0 additions & 38 deletions languages/newspack-blocks.pot
Original file line number Diff line number Diff line change
Expand Up @@ -759,28 +759,6 @@ msgstr ""
msgid "Paused"
msgstr ""

#: dist/donateStreamlined.js:1
#: release/newspack-blocks/dist/donateStreamlined.js:72
msgid "Email address is invalid."
msgstr ""

#. Translators: %d is minimum donation amount set in Reader Revenue wizard or block attributes.
#: dist/donateStreamlined.js:1
#: release/newspack-blocks/dist/donateStreamlined.js:72
msgid "Amount must be at least %d."
msgstr ""

#: dist/donateStreamlined.js:1
#: release/newspack-blocks/dist/donateStreamlined.js:72
msgid "Full name should be provided."
msgstr ""

#. Translators: %s is the email address of the current user.
#: dist/donateStreamlined.js:1
#: release/newspack-blocks/dist/donateStreamlined.js:72
msgid "Your payment has been processed. Thank you for your contribution! You will receive a confirmation email at %s."
msgstr ""

#: dist/editor.js:41
#: release/newspack-blocks/dist/editor.js:2541
#: release/newspack-blocks/src/blocks/author-list/edit.js:105
Expand Down Expand Up @@ -2085,22 +2063,6 @@ msgstr ""
msgid "Remove Block"
msgstr ""

#: release/newspack-blocks/dist/donateStreamlined.js:61
msgid "Error loading the reCaptcha library."
msgstr ""

#: release/newspack-blocks/dist/donateStreamlined.js:61
msgid "Error processing captcha request."
msgstr ""

#: release/newspack-blocks/dist/donateStreamlined.js:61
msgid "Something went wrong with the payment. Please try again later."
msgstr ""

#: release/newspack-blocks/dist/donateStreamlined.js:61
msgid "Processing payment…"
msgstr ""

#: release/newspack-blocks/dist/editor.js:2541
#: release/newspack-blocks/src/blocks/author-list/edit.js:224
#: src/blocks/author-list/edit.js:224
Expand Down
12 changes: 0 additions & 12 deletions newspack-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
// REST Controller for Author List Block.
require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'src/blocks/author-list/class-wp-rest-newspack-author-list-controller.php';

// REST Controller for Donate Block.
require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'src/blocks/donate/class-wp-rest-newspack-donate-controller.php';

// REST Controller for Iframe Block.
require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'src/blocks/iframe/class-wp-rest-newspack-iframe-controller.php';

Expand Down Expand Up @@ -64,15 +61,6 @@ function newspack_author_list_block_register_rest_routes() { // phpcs:ignore Wor
}
add_action( 'rest_api_init', 'newspack_author_list_block_register_rest_routes' );

/**
* Registers Donate block routes.
*/
function newspack_donate_block_register_rest_routes() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
$donate_controller = new WP_REST_Newspack_Donate_Controller();
$donate_controller->register_routes();
}
add_action( 'rest_api_init', 'newspack_donate_block_register_rest_routes' );

/**
* Registers Iframe block routes.
*/
Expand Down
Loading

0 comments on commit fc36e5b

Please sign in to comment.