WordPress 默认小部件文件或功能位于何处?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2293443/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 18:34:38  来源:igfitidea点击:

Where are WordPress default widget files or functions located?

wordpresstagswidget

提问by kevtrout

I'm trying to slightly modify the default WordPress tag cloud widget. I don't want to create my own widget because I literally want to adjust one small thing. I've looked through my WordPress installation but can't find the PHP file that contains the basic widgets.

我正在尝试稍微修改默认的 WordPress 标签云小部件。我不想创建自己的小部件,因为我真的想调整一件小事。我查看了我的 WordPress 安装,但找不到包含基本小部件的 PHP 文件。

Even though I assume that they are defined in each theme, I still looked in the core directories but came up empty handed.

尽管我假设它们是在每个主题中定义的,但我仍然查看了核心目录,但空手而归。

So if any of you happen to have already figured this out, please make my life easier and let me know where I can find the default widgets...most importantly the tag cloud widget.

因此,如果你们中的任何人碰巧已经弄清楚了这一点,请让我的生活更轻松,并告诉我在哪里可以找到默认小部件......最重要的是标签云小部件。

Thanks

谢谢

回答by Dave Konopka

Those are located in the default widget class:

这些位于默认小部件类中:

/wp-includes/default-widgets.php

For more detail: http://phpdoc.wordpress.org/trunk/WordPress/Widgets/WP_Widget_Tag_Cloud.html

更多详情:http: //phpdoc.wordpress.org/trunk/WordPress/Widgets/WP_Widget_Tag_Cloud.html

The widget invokes a function deeper though that generates the actual output. You'll want to take a look at the wp_tag_cloudand wp_generate_tag_cloudfunctions in:

尽管生成实际输出,小部件更深入地调用函数。您需要查看以下中的wp_tag_cloudwp_generate_tag_cloud函数:

/wp-includes/category-template.php

回答by futtta

do take into account however that you'll lose your change when you upgrade wordpress (which is why I eventually did create my own shabby category-cloud widgetinstead of changing the default tag-cloud code).

但是请注意,升级 wordpress 时会丢失更改(这就是为什么我最终创建了自己的破旧类别云小部件而不是更改默认标签云代码的原因)。

回答by adrianbanks

The tag cloud widget is defined near the bottom of the default-widgets.phpfile in the wp-includesfolder.

标签云小部件定义在default-widgets.php文件wp-includes夹中文件底部附近。