Skip to content

Commit fe823ac

Browse files
artpidereksmart
authored andcommitted
Simple payments: load CSS on demand (Automattic#7626)
* Enqueue style only if not enqueued first * review feedback
1 parent 85f3ab9 commit fe823ac

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎modules/simple-payments/simple-payments.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ private function register_scripts() {
3535
wp_register_script( 'paypal-checkout-js', 'https://www.paypalobjects.com/api/checkout.js', array(), null, true );
3636
wp_register_script( 'paypal-express-checkout', plugins_url( '/paypal-express-checkout.js', __FILE__ ),
3737
array( 'jquery', 'paypal-checkout-js' ), self::$version );
38-
wp_enqueue_style( 'simple-payments', plugins_url( '/simple-payments.css', __FILE__ ) );
3938
}
4039
private function register_init_hook() {
4140
add_action( 'init', array( $this, 'init_hook_action' ) );
@@ -104,6 +103,9 @@ function parse_shortcode( $attrs, $content = false ) {
104103
if ( ! wp_script_is( 'paypal-express-checkout', 'enqueued' ) ) {
105104
wp_enqueue_script( 'paypal-express-checkout' );
106105
}
106+
if ( ! wp_style_is( 'simple-payments', 'enqueued' ) ) {
107+
wp_enqueue_style( 'simple-payments', plugins_url( 'simple-payments.css', __FILE__ ) );
108+
}
107109

108110
wp_add_inline_script( 'paypal-express-checkout', sprintf(
109111
"try{PaypalExpressCheckout.renderButton( '%d', '%d', '%s', '%d' );}catch(e){}",

0 commit comments

Comments
 (0)