我编写了一个插件,它可以执行一些通知,tasks.This工作得很好。现在,我想在处理HTTP请求时执行主插件脚本。就在这里,我有点困惑:
我的插件源代码位于经典的WP插件目录中:/wp/plugins/ My - plugin
下面是我希望在处理http请求时执行的主脚本的来源:
<?php
require_once('../wp-load.php');
require_once(ABSPATH."wp-content/plugins/my-plugin/classes/Model.class.php") ;
require_once(ABSPATH."wp-content/plugins/my-plugin/classes/MailNotifier.class.php") ;
$mailNotif= new MailNotifier('myadress@foo.bar');
$mailNotif->sendMailToRecipient() ;
?>实际上,这个脚本位于:WordpressRoot/script/main.php --它可以工作,但是我想从WP核心文件中删除它,并且只获取插件目录中的文件。
我实际上执行了这个脚本,处理以下http请求:http://example.com/script/main.php,但它只是为了测试目的。
我想要的是使用http请求执行位于插件dir中的主程序。我试图做一个符号链接,但这是不允许的:
ln -s /wp-content/plugins/my-plugin/script/main.php script我该怎么做?
怎样才是最合适的方法呢?
发布于 2012-10-17 12:57:49
你可以试着
$request = wp_remote_get('http://mydomain.com/script/main.php')
$theBody = wp_remote_retrieve_body($request);API
https://stackoverflow.com/questions/12933567
复制相似问题