以下是解决方案:
创建了一个文件(run\\cron.php),该文件通过cURL调用了我需要运行的作业,并将其放置在子主题文件夹中:cURL:
<?php
define(\'RUN_CRON_URI\', \'https://path-to-file-to-be-executed/process_orders.php\');
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => RUN_CRON_URI,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false
]);
$result = curl_exec($curl);
if (curl_error($curl)) {
throw new Exception(curl_error());
} else {
$httpStatusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($httpStatusCode != 200) {
throw new Exception(\'Submission failed with this status: \' . $httpStatusCode);
} elseif (stripos($result, \'error\') !== false) {
throw new Exception(\'Error detected: \' . $result);
}
} ?>
将要执行的作业移动到父主题文件夹中。
在打开和关闭PHP标记的可执行文件顶部添加了以下内容:
/***@package OceanWP WordPress主题*/需要\\u一次(“../../../../wp load.php”);
其余代码。。。