lijnam / wc_hbl_payment_gateway

Himalayan Bank Payment Gateway Plugin for WooCommerce
GNU General Public License v3.0
3 stars 4 forks source link

Organize CSS and styles #12

Open sanzeeb3 opened 3 years ago

sanzeeb3 commented 3 years ago

There are inline CSS, and inside the php files templates/canceled.php & templates/declined.

Let's add style.css in asssets/style.css.

and enqueue from init() method of src/Plugin.php. So, it would be something like:

add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_stlyes' ] );
public function enqueue_styles() {
     if ( condition ) {
        wp_enqueue_style( 'hbl-payment-for-woocommerce-style', plugins_url( 'assets/css/style.css', HBL_PAYMENT_FOR_WOOCOMMERCE_PLUGIN_FILE ), array(), HBL_PAYMENT_FOR_WOOCOMMERCE_VERSION, $media = 'all' );
     }
}

condition is to make sure the style is loaded only on the required page. For example: WC checkout page?