2
我正在尝试在Wordpress中独立调用PHP文件中的filter
钩子。如何调用PHP外部文件中的过滤器钩子
这是文件的代码:my_external_file.php:
<?php
require(dirname(__FILE__) . '/../../../../../../../wp-load.php');
add_filter('init', 'test_function');
function test_function(){
global $global_text_to_shown;
$global_text_to_shown = 'Hello World';
}
global $global_text_to_shown;
$quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close');
//This work fine, shown editor good.
wp_editor($global_text_to_show, 'content', array('media_buttons' => false, 'tinymce' => true, 'quicktags' => $quicktags_settings));
//Load js and work fine the editor - wp_editor function.
wp_footer();
?>
的问题是,该过滤器没有得到执行,因此该功能没有得到执行。
如何在外部PHP文件上执行过滤器钩子?