-
Notifications
You must be signed in to change notification settings - Fork 216
Deprecating and replacing PRBs classes #4871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
12c290f
b2bd26f
a3502fd
ebe6f93
2150b89
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,78 @@ | ||||||||||||||||
| <?php | ||||||||||||||||
| if ( ! defined( 'ABSPATH' ) ) { | ||||||||||||||||
| exit; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * Admin page for UPE Customize Express Checkouts. | ||||||||||||||||
| * | ||||||||||||||||
| * @since 10.3.0 | ||||||||||||||||
| */ | ||||||||||||||||
| class WC_Stripe_Express_Checkout_Controller { | ||||||||||||||||
| public function __construct() { | ||||||||||||||||
| add_action( 'admin_enqueue_scripts', [ $this, 'admin_scripts' ] ); | ||||||||||||||||
| add_action( 'wc_stripe_gateway_admin_options_wrapper', [ $this, 'admin_options' ] ); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * Load admin scripts. | ||||||||||||||||
| */ | ||||||||||||||||
| public function admin_scripts() { | ||||||||||||||||
| // Webpack generates an assets file containing a dependencies array for our built JS file. | ||||||||||||||||
| $script_asset_path = WC_STRIPE_PLUGIN_PATH . '/build/express-checkout-settings.asset.php'; | ||||||||||||||||
| $asset_metadata = file_exists( $script_asset_path ) | ||||||||||||||||
| ? require $script_asset_path | ||||||||||||||||
| : [ | ||||||||||||||||
| 'dependencies' => [], | ||||||||||||||||
| 'version' => WC_STRIPE_VERSION, | ||||||||||||||||
| ]; | ||||||||||||||||
| wp_register_script( | ||||||||||||||||
| 'wc-stripe-express-checkout-settings', | ||||||||||||||||
| plugins_url( 'build/express-checkout-settings.js', WC_STRIPE_MAIN_FILE ), | ||||||||||||||||
| $asset_metadata['dependencies'], | ||||||||||||||||
| $asset_metadata['version'], | ||||||||||||||||
| true | ||||||||||||||||
| ); | ||||||||||||||||
| wp_set_script_translations( | ||||||||||||||||
| 'wc-stripe-express-checkout-settings', | ||||||||||||||||
| 'woocommerce-gateway-stripe' | ||||||||||||||||
| ); | ||||||||||||||||
| wp_enqueue_script( 'wc-stripe-express-checkout-settings' ); | ||||||||||||||||
|
|
||||||||||||||||
| $stripe_settings = WC_Stripe_Helper::get_stripe_settings(); | ||||||||||||||||
| $params = [ | ||||||||||||||||
| 'key' => WC_Stripe_Mode::is_test() ? $stripe_settings['test_publishable_key'] : $stripe_settings['publishable_key'], | ||||||||||||||||
| 'locale' => WC_Stripe_Helper::convert_wc_locale_to_stripe_locale( get_locale() ), | ||||||||||||||||
| 'is_ece_enabled' => WC_Stripe_Feature_Flags::is_stripe_ece_enabled(), | ||||||||||||||||
| ]; | ||||||||||||||||
| wp_localize_script( | ||||||||||||||||
| 'wc-stripe-express-checkout-settings', | ||||||||||||||||
| 'wc_stripe_express_checkout_settings_params', | ||||||||||||||||
| $params | ||||||||||||||||
| ); | ||||||||||||||||
|
|
||||||||||||||||
| wp_register_style( | ||||||||||||||||
| 'wc-stripe-express-checkout-settings', | ||||||||||||||||
| plugins_url( 'build/express-checkout-settings.css', WC_STRIPE_MAIN_FILE ), | ||||||||||||||||
| [ 'wc-components' ], | ||||||||||||||||
| $asset_metadata['version'] | ||||||||||||||||
| ); | ||||||||||||||||
| wp_enqueue_style( 'wc-stripe-express-checkout-settings' ); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * Prints the admin options for the gateway. | ||||||||||||||||
| * Remove this action once we're fully migrated to UPE and move the wrapper in the `admin_options` method of the UPE gateway. | ||||||||||||||||
| */ | ||||||||||||||||
| public function admin_options() { | ||||||||||||||||
| global $hide_save_button; | ||||||||||||||||
| $hide_save_button = true; | ||||||||||||||||
| $return_url = admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=stripe' ); | ||||||||||||||||
| $header = __( 'Customize express checkouts', 'woocommerce-gateway-stripe' ); | ||||||||||||||||
| $return_text = __( 'Return to Stripe', 'woocommerce-gateway-stripe' ); | ||||||||||||||||
|
|
||||||||||||||||
| WC_Stripe_Helper::render_admin_header( $header, $return_text, $return_url ); | ||||||||||||||||
|
|
||||||||||||||||
| echo '<div class="wrap"><div id="wc-stripe-express-checkout-settings-container"></div></div>'; | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we use a different Id here, we also need to update it in woocommerce-gateway-stripe/client/entrypoints/express-checkout-settings/index.js Lines 5 to 11 in 6226ac9
|
||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use a different object name here, we also need to update the global in
client/entrypoints/express-checkout-settings/express-checkout-preview-component.js(and the corresponding tests) that depend on it: