我的脚本需要加载整个WP才能正常工作。我现在是这样做的
if ( !defined(\'ABSPATH\') ) {
/** Load WordPress Bootstrap */
@ini_set(\'include_path\', \'../../../\');
require_once(\'../../../wp-load.php\');
}
//additional html stuff
do_action(\'my_custom_hook\');
//more html stuff
大部分时间都有效。但有时人们会因为丢失的文件而收到致命错误。脚本位于
wp-content/plugins/my-plugin-slug/script.php
加载它的最佳方式是什么?