Wordpress WooCommerce Storefront Theme - 功能在哪里定义?
Wordpress WooCommerce Storefront Theme - Where are functions defined?
我是 WooCommerce 和 Storefront 主题的新手。在开始修改源代码之前,我试图了解它。我只是很难找到所有必要代码的位置。
当我打开 header.php 时,我迷路了,因为每个函数都像这样挂接到其他一些文件。
do_action( 'storefront_before_header' );
Storefront 主题中这些功能是在哪里定义的?以及除了打开所有正在搜索字符串的文件之外,我如何才能找到所有这些 do_action 函数在未来的定义位置?
我查看了以下文件:
- 店面-functions.php
- 店面模板-functions.php
- 店面模板-hooks.php
- functions.php
对于所有与 woocommerce 相关的产品,在每个挂钩之前的 phpdoc 块中都有一个 @hooked
标记。如果没有 @hooked
标签,则该钩子只是一个保留的钩子,以后可能会用到。
让我们看看 storefront_header hook:
/**
* Functions hooked into storefront_header action
*
* @hooked storefront_skip_links - 0
* @hooked storefront_social_icons - 10
* @hooked storefront_site_branding - 20
* @hooked storefront_secondary_navigation - 30
* @hooked storefront_product_search - 40
* @hooked storefront_primary_navigation_wrapper - 42
* @hooked storefront_primary_navigation - 50
* @hooked storefront_header_cart - 60
* @hooked storefront_primary_navigation_wrapper_close - 68
*/
do_action( 'storefront_header' );
在@hooked
标签之后是一个函数名称和优先级,在触发操作时执行该函数。较低的数字对应较早的执行。
挂钩的大部分函数位于storefront-template-functions.php
内部,添加在storefront-template-hooks.php
内部。
您可以在主题文件夹中通过简单的 IDE 搜索找到这些功能。
我是 WooCommerce 和 Storefront 主题的新手。在开始修改源代码之前,我试图了解它。我只是很难找到所有必要代码的位置。
当我打开 header.php 时,我迷路了,因为每个函数都像这样挂接到其他一些文件。
do_action( 'storefront_before_header' );
Storefront 主题中这些功能是在哪里定义的?以及除了打开所有正在搜索字符串的文件之外,我如何才能找到所有这些 do_action 函数在未来的定义位置?
我查看了以下文件:
- 店面-functions.php
- 店面模板-functions.php
- 店面模板-hooks.php
- functions.php
对于所有与 woocommerce 相关的产品,在每个挂钩之前的 phpdoc 块中都有一个 @hooked
标记。如果没有 @hooked
标签,则该钩子只是一个保留的钩子,以后可能会用到。
让我们看看 storefront_header hook:
/**
* Functions hooked into storefront_header action
*
* @hooked storefront_skip_links - 0
* @hooked storefront_social_icons - 10
* @hooked storefront_site_branding - 20
* @hooked storefront_secondary_navigation - 30
* @hooked storefront_product_search - 40
* @hooked storefront_primary_navigation_wrapper - 42
* @hooked storefront_primary_navigation - 50
* @hooked storefront_header_cart - 60
* @hooked storefront_primary_navigation_wrapper_close - 68
*/
do_action( 'storefront_header' );
在@hooked
标签之后是一个函数名称和优先级,在触发操作时执行该函数。较低的数字对应较早的执行。
挂钩的大部分函数位于storefront-template-functions.php
内部,添加在storefront-template-hooks.php
内部。
您可以在主题文件夹中通过简单的 IDE 搜索找到这些功能。