如何清理 WordPress 代码?

发布于 2024-10-15 19:14:09 字数 373 浏览 4 评论 0原文

我正在寻找一些技巧来清理 WordPress 和一些插件生成的代码,因为我对 WordPress 生成的代码不满意,原因有两个:

  1. 代码格式不正确。我知道,我知道......这并不重要,因为浏览器不需要“解析”格式良好的代码。但是,我喜欢保持所有代码的格式良好,其中包括我或第三方系统生成的 HTML 代码。

  2. 不幸的是,WordPress 放在 上的代码的某些部分格式不正确,并且在某些情况下这些部分并不是真正必要的。顺便说一句,我不知道如何清理它或如何挂钩打印该代码的函数。

有没有办法在不更改核心文件/代码的情况下向 WordPress 生成的代码添加制表符/空格?

谢谢你!

I'm looking for some tips to clean the code which is generated by WordPress and some plug-ins, because I'm not happy with the code generated by WordPress for two reasons:

  1. The code isn't well formatted. I know, I know... It isn't important since that the browsers don't need to "parse" a well formatted code. However, I like to keep all codes well formatted and it includes HTML code generated by me or third-part systems.

  2. Unfortunately, some parts of the code that WordPress puts on the <head> aren't well formatted and in some cases those parts aren't really necessary. By the way, I have no idea about how to clean-up it or how to hook the function which prints that code.

Is there some way to add tabs / spaces to the code generated by WordPress without change the core files / code?

Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

骄兵必败 2024-10-22 19:14:09

忽略您的问题的整体模糊性,您需要编辑以修复 元素的文件是 header.php。您将在 wp-contents 的主题文件夹中找到它。

Overlooking the overall ambiguity of your question, the file you need to edit to fix the <head> element is header.php. You will find it in your theme's folder in wp-contents.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文