在黑暗中拍摄,但是。。。
完全可以使用do_action
定义在处理主题之前挂接。
找出do_action
定义,并找出它何时被钩住。
您可能需要钩住do_action
定义也被钩住,然后钩住那个动作定义。
Example:
打开包含
do_action
您试图使用自定义函数连接到的定义。
查看是否do_action
定义驻留在插件函数中。
如果是,请查看插件以找到add_action()
引用包含do_action
释义
记下那个钩子是什么。
现在,您知道WordPress何时调用包含do_action
释义
现在在你的主题中functions.php
文件中,您可能有类似于以下代码的内容:
/**
* This is the WordPress action the plugin\'s do_action function definition is
* hooked to.
*
* Example: This hook could be anything. I\'m not saying the hook will be: "plugins_loaded"
* for sure, but if it was "plugins_loaded"... After WordPress loads and instantiates all
* of it\'s activated plugins, WordPress will fire the plugin\'s function containing the
* plugin\'s do_action definition (As long as the plugin you are trying to work with is
* activated). So you\'re getting on the same level as the plugin when it needs WordPress to
* execute this particular defined custom action and telling WordPress that your theme function
* needs to be on that same level as well, before it can hook to your plugin\'s do_action reference.
*/
add_action(\'plugins_loaded\', \'wpse_setup_theme\');
function wpse_setup_theme(){
/**
* This your function that you want fired then the do_action is executed.
*
* Example: If the plugin file has a function named osmosis_jones() and
* inside osmosis_jones(), there is a do_action() reference. Note down
* the do_action tag name inside the osmosis_jones() function.
*/
add_action(\'the_plugin_do_action_tag_name\', \'wpse_display_theme_header\');
}
function wpse_display_theme_header(){
echo \'THEME HEADER HERE!\';
}