有一种情况是,主题通过do_action("action_name") 但它并没有被迫将实际操作绑定到它,因为theme的开发人员可能只是为了使theme更具可扩展性而这样做,事实上从来没有在theme中使用它。
因此,您可以通过add_action("colormag_before", "your_function_name") 在子主题或插件中,它将起作用。
显然,如果您只想检查钩子是否已经在主题中的某个地方使用过,只需在主题的代码中搜索add_action("colormag_before" (或add_action( "colormag_before" 或add_action(\'colormag_before\' 或add_action( \'colormag_before\'. 这些只是拼写方式不同的变体)
如果可以通过正则表达式进行搜索,则add_action\\(\\s*[\'"]colormag_before