國內推薦使用 Staticfile CDN 上的庫:
<!-- 新 Bootstrap4 核心 CSS 文件 -->
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
<!-- jQuery文件。務必在bootstrap.min.js 之前引入 -->
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<!-- bootstrap.bundle.min.js 用於彈窗、提示、下拉菜單,包含了 popper.min.js -->
<script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
<!-- 最新的 Bootstrap4 核心 JavaScript 文件 -->
<script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
注意:popper.min.js 用於設置彈窗、提示、下拉菜單,目前 bootstrap.bundle.min.js 已經包含了 popper.min.js。
此外,你還可以使用以下的 CDN 服務:
- 國內推薦使用 : https://www.staticfile.org/
- 國際推薦使用:https://cdnjs.com/
以下代碼放在 add_action(『wp_enqueue_scripts』, 『xxx』); 里。
wp_enqueue_style( 'bootstrap-style', 'https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css', array(), '4.3.1');
wp_enqueue_script( 'popper', 'https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js' , array('jquery'), '1.15.0');
wp_enqueue_script( 'bootstrap', 'https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js' , array('jquery'), '4.3.1');
<link rel='stylesheet' id='bootstrap-style-css' href='https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css?ver=4.3.1' media='all' />
<script src='http://127.0.0.1/wpstrap/wp-includes/js/jquery/jquery.js?ver=1.12.4-wp'></script>
<script src='http://127.0.0.1/wpstrap/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1'></script>
<script src='https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js?ver=1.15.0'></script>
<script src='https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js?ver=4.3.1'></script>