我正在处理名为PointFinder的WordPress安装。用户发布的项目会在某个预定义的时间段后被删除。我的目标是禁用此行为。我已找到相应的代码行,并取消激活add_action
挂钩,触发pointfinder_clean_pending_orders()
中定期调用的函数schedule-config.php
,暂时可以正常工作。
add_action( 'pointfinder_schedule_hooks_hourly', 'pointfinder_clean_pending_orders' ); // <--- commented out this line
function pointfinder_clean_pending_orders() {
/* code that cleans-up ... */
}
如何实现儿童主题的停用?如果我只是在我的子主题中添加remove_action
到functions.php
,那会有用吗?我不确定首先会调用什么,add_action
中的schedule-config.php
或remove_action
中的functions.php
?
我只能访问高效的服务器而没有测试环境,因此我对实验有点不情愿。
答案 0 :(得分:1)
试试这个:
add_action('init','remove_hourly_hook');
function remove_hourly_hook() {
remove_action( 'pointfinder_schedule_hooks_hourly', 'pointfinder_clean_pending_orders' );
}
这样做是在WordPress初始化之后(无论函数被调用的函数的顺序如何),它将删除该动作。
现在,如果初始add_action位于其自己的钩子中,您将需要确保您的钩子初始化&#39;之后发生变化。