博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
wordpress后台样式_在WordPress中删除插件样式表和脚本
阅读量:2513 次
发布时间:2019-05-11

本文共 1988 字,大约阅读时间需要 6 分钟。

wordpress后台样式

Many WordPress plugins implicitly inject stylesheets and JavaScript files into the page on each page load.  If you don't plan on custom-styling for elements created by the plugin, that's no problem...but you can get caught in a CSS specificity battle if you do intend custom styling.  If the plugin is created properly (which is sometimes a big "if" when it comes to WordPress plugins), you can programmatically tell these files not to load from within your given theme.

许多WordPress插件会在每次加载页面时隐式将样式表和JavaScript文件注入页面。 如果您不打算为插件创建的元素进行自定义样式,那没问题...但是,如果您打算自定义样式,则可能会陷入CSS特殊性之争。 如果插件创建正确(当涉及到WordPress插件时,有时会是一个很大的“ if”),则可以以编程方式告诉这些文件不要从给定的主题中加载。

When scripts and styles are added properly, they use the wp_enqueue_style and wp_enqueue_script functions within the plugin files as such:

正确添加脚本和样式后,它们将在插件文件中使用the wp_enqueue_stylewp_enqueue_script函数,例如:

// Styles Format:  wp_enqueue_style($handle, $src, $deps, $ver, $media);wp_register_style('pagination-style', plugins_url('style.css', __FILE__));wp_enqueue_style('pagination-style');// Script Format:  wp_enqueue_script($handle, $src, $deps, $ver, $in_footer);wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js');wp_enqueue_script('jquery');

Those handle names are incredibly important, as within your theme's functions.php you'll be adding their counterpart calls of wp_dequeue_style and wp_dequeue_script functions:

这些句柄名称非常重要,因为在主题的functions.php您将添加它们的对等调用wp_dequeue_stylewp_dequeue_script函数:

// Get out of my page!wp_dequeue_style('pagination-style');wp_dequeue_script('jquery');

In the past I've argued that each plugin should make including their styles and scripts optional, but with these simple functions, I'm not as frustrated as I once was.  You'll need to dig into the plugin code to find their script and style handles, but it will be will worth it in the end!

在过去,我认为每个插件都应使其样式和脚本(包括脚本)为可选项,但是有了这些简单的功能,我就不会像以前那样沮丧。 您需要深入研究插件代码以找到其脚本和样式句柄,但最终还是值得的!

翻译自:

wordpress后台样式

转载地址:http://sppwd.baihongyu.com/

你可能感兴趣的文章
项目需求分析答辩总结
查看>>
mysql-6正则表达式
查看>>
廖雪峰Java2面向对象编程-5包和classpath-1包package
查看>>
廖雪峰Java7处理日期和时间-3java.time的API-1LocalDateTime
查看>>
利用golang语法检查对象是否实现了接口
查看>>
在UBUNTU上安装基于bochs的 xv6
查看>>
Azure Storage Blob文件重命名
查看>>
RxJava2.0 使用
查看>>
FreeImage的图像处理软件
查看>>
ASP.NET MVC开发必看系列
查看>>
点到平面的距离
查看>>
linux下安装FTP
查看>>
第四周编程总结
查看>>
《第12章 类的无参方法》
查看>>
经典机器学习算法系列7-svd
查看>>
mxnet系列 全连接层代码阅读
查看>>
0715
查看>>
Android开发进度06
查看>>
Beautiful Soup 中文文档
查看>>
USB各种模式 解释
查看>>