gpt4 book ai didi

php - 我在 do_action 之前执行 remove_action 但 Action 仍然被触发?

转载 作者:行者123 更新时间:2023-12-04 09:34:43 26 4
gpt4 key购买 nike

我不明白为什么这不起作用。我的理解是,您必须在添加操作之后但在触发之前删除该操作。这就是我在这里做的事情?这里有什么我不明白的地方吗?调试 wordpress 真的让我感到困惑,因为你无法真正通过它?

<?php
/**
* Functions hooked into storefront_header action
*
* @hooked storefront_header_container - 0
* @hooked storefront_skip_links - 5
* @hooked storefront_social_icons - 10
* @hooked storefront_site_branding - 20
* @hooked storefront_secondary_navigation - 30
* @hooked storefront_product_search - 40
* @hooked storefront_header_container_close - 41
* @hooked storefront_primary_navigation_wrapper - 42
* @hooked storefront_primary_navigation - 50
* @hooked storefront_header_cart - 60
* @hooked storefront_primary_navigation_wrapper_close - 68
*/
remove_action('storefront_header', 'storefront_product_search', 40);
do_action( 'storefront_header' );
?>

最佳答案

请参阅来自 Wordpress documentation for remove_action 的贡献注释:

If an action has been added from within a class, for example by a plugin, removing it will require accessing the class through a variable that holds the class instance.


...

To remove an action, the priority must match the priority with the function that was originally added.

关于php - 我在 do_action 之前执行 remove_action 但 Action 仍然被触发?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62644767/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com