【问题标题】:How to implement Bootstrap in WordPress Plugin Boilerplate correct? https://wppb.me/如何在 WordPress Plugin Boilerplate 中正确实现 Bootstrap? https://wppb.me/
【发布时间】:2021-03-11 18:51:54
【问题描述】:

我想知道如何以正确的方式将 Bootstrap 集成到这个 Boilerplate 中。

这里有一些来自 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 );
    

}

【问题讨论】:

    标签: wordpress twitter-bootstrap boilerplate


    【解决方案1】:

    您可以使用相同的wp_enqueue_script() 函数并将第一个参数添加为处理程序,并将第二个参数添加为路径,这里我以CDN 路径为例。

    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 );
    
    }
    

    【讨论】:

      猜你喜欢
      • 2021-06-08
      • 2021-12-13
      • 2012-02-05
      • 2014-05-23
      • 1970-01-01
      • 2021-01-03
      • 2016-08-20
      • 2020-08-07
      • 2020-10-11
      相关资源
      最近更新 更多