For this code:
<?php
define('WP_USE_THEMES', false);
require('./wp-blog-header.php');
if (PHP_SAPI === 'cli') {
$post_id =$argv[1];
$post_title =$argv[2];
}
else {
$post_id =$_GET['post_id'];
$post_title =$_GET['post_title'];
}
if (empty($_GET)){
$post_id = 0;
$post_title='My Post Title';
}
echo "Done";
return;
This call throws no errors, warning or notices, and shows the message Done
.
https://www.example.com/function.php?post_id=0&post_title=My Post Title
This call
php -f ~/public_html/function.php -- 0 'My Post Title'
throws the following warning and notice, and do not show the message Done
:
Notice: Undefined index: SERVER_PROTOCOL in /home/examplecom/public_html/wp-includes/load.php on line 16
Warning: Cannot modify header information - headers already sent by (output started at /home/examplecom/public_html/wp-includes/load.php:16) in /home/examplecom/public_html/wp-includes/pluggable.php on line 1223
How should I fix that?
include_once:322 mocd: !is_admin(), or doing cron -- exiting
for both calls...