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];
$post_content =$argv[3];
$post_excerpt =$argv[4];
$post_date =$argv[5];
$post_name =$argv[6];
}
else {
$post_id =$_GET['post_id'];
$post_title =$_GET['post_title'];
$post_content =$_GET['post_content'];
$post_excerpt =$_GET['post_excerpt'];
$post_date =$_GET['post_date'];
$post_name =$_GET['post_name'];
}
if (empty($_GET)){
$post_id = 0;
$post_title='My Post Title';
$post_content='My Post Content';
$post_excerpt='My Post Excerpt';
$post_date='2019-01-10T10:10:10';
$post_name='my-post';
}
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&post_content=My Post Content&post_excerpt=My Post Excerpt&post_date=2019-01-10 10:10:10&post_name=my-postTitle
This call
php -f ~/public_html/function.php -- 0 'My Post Title' 'My Post Content' 'My Post Excerpt' '2019-01-10 10:10:10' 'my-post'
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?