Search code examples
wordpresstwitter-bootstrapboilerplate

How to implement Bootstrap in WordPress Plugin Boilerplate correct? https://wppb.me/


I want to know how to integrate Bootstrap the correct way into this Boilerplate.

Here some Code from the public/Class-public.php

/**
 * Register the JavaScript for the public-facing side of the site.
 *
 * @since    1.0.0
 */
public function enqueue_scripts() {

    /**
     * This function is provided for demonstration purposes only.
     *
     * An instance of this class should be passed to the run() function
     * defined in Price_Hubble_Loader as all of the hooks are defined
     * in that particular class.
     *
     * The Price_Hubble_Loader will then create the relationship
     * between the defined hooks and the functions defined in this
     * class.
     */

    wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/pricepublic.js', array( 'jquery' ), $this->version, false );
    

}

Solution

  • you can use the same wp_enqueue_script() function and add first params as a handler and second param as a path in here I am using CDN path as an example.

    public function enqueue_scripts() {
    
        /**
         * This function is provided for demonstration purposes only.
         *
         * An instance of this class should be passed to the run() function
         * defined in Test_Loader as all of the hooks are defined
         * in that particular class.
         *
         * The Test_Loader will then create the relationship
         * between the defined hooks and the functions defined in this
         * class.
         */
    
        wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/test-public.js', array( 'jquery' ), $this->version, false );
    
        wp_enqueue_script( 'bootstrap-js', 'https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js', array( 'jquery' ), '4.5.2', false );
    
    }