在我的插件中无法识别引导和 css
Bootstrap and css are not being recognized in my plugin
我正在尝试在Wordpress上制作自己的插件,但是引导程序和css不起作用,它们之间没有形成任何连接。这是我的代码,如果你对此有任何想法,我将不胜感激。
function my_options_style() {
wp_register_style('my_options_css', plugin_dir_url(__FILE__) . 'css/style.css', false, '1.0.0');
wp_register_style('bootstrap_options_css', plugin_dir_url(__FILE__) . 'includes/bootstrap-3.3.6-dist/css/bootstrap.min.css', false, '1.0.0');
wp_register_style('bootstrap_css', plugin_dir_url(__FILE__) . 'includes/bootstrap-3.3.6-dist/css/bootstrap-theme.min.css', false, '1.0.0');
wp_enqueue_style('my_options_css');
wp_enqueue_style('bootstrap_options_css');
wp_enqueue_style('bootstrap_css');
}
add_action('admin_enqueue_scripts', 'my_options_style');
function theme_scripts() {
wp_enqueue_script( 'my-ads', plugin_dir_url(__FILE__) . 'includes/bootstrap-3.3.6-dist/js/bootstrap.min.js', array(), '1.0.1', true );
}
add_action( 'wp_enqueue_scripts', 'theme_scripts' );
你需要
像这样使用 wp_register_style() & wp_register_script()
寄存器脚本演示
// Register Script
function custom_scripts() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', '//code.jquery.com/jquery-2.1.1.min.js', false, '2.1.1', false );
wp_enqueue_script( 'jquery' );
wp_deregister_script( 'bootstrap' );
wp_register_script( 'bootstrap', '//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js', array( 'jquery' ), '3.2.0', false );
wp_enqueue_script( 'bootstrap' );
}
add_action( 'wp_enqueue_scripts', 'custom_scripts' );
和对于寄存器样式
// Register Style
function custom_styles() {
wp_register_style( 'bootstrap', '//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css', false, '3.2.0' );
wp_enqueue_style( 'bootstrap' );
wp_register_style( 'bootstrap-theme', '//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css', array( 'bootstrap' ), '3.2.0' );
wp_enqueue_style( 'bootstrap-theme' );
}
add_action( 'wp_enqueue_scripts', 'custom_styles' );
更多详情
https://developer.wordpress.org/reference/functions/wp_enqueue_style/
https://developer.wordpress.org/reference/functions/wp_enqueue_script/
相关文章:
- CSS-如何定位内容数据标题
- 如何识别我的网站中的慢速设备
- 窗口大小html css
- 如果文本字段为空,则使用JavaScript应用CSS样式
- 动画.CSS重播
- 使用 CSS 或 JS 来识别设备类型
- CSS 无法识别 ID 或名称
- Dojo:使用 CSS 选择器识别 dijit 树节点
- 在我的插件中无法识别引导和 css
- 如何识别设备,为iPad和Galaxy Tab制作单独的css
- 谷歌网站HTML框是't识别CSS或Javascript
- 识别哪些JS函数和CSS用于网页中的组件
- CSS访问的链接-如何识别访问的链接,通过点击我的应用程序访问
- 我的自定义CSS单选按钮在我的javascript中不被识别
- 给一个css块一个特殊的id来识别
- 不识别CSS动画期间设置的值
- 使用jQuery添加/删除css类,通过css类识别元素
- 使Internet Explorer识别“;高级“;CSS选择器
- .load()信息无法识别CSS样式
- 使CSS/Javascript菜单正确识别链接