ActionScheduler_wpCommentLogger::create_wp_commentprotectedWC 1.0

Create comment.

Method of the class: ActionScheduler_wpCommentLogger{}

No Hooks.

Returns

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->create_wp_comment( $action_id, $message, $date );
$action_id(int) (required)
Action ID.
$message(string) (required)
Action log's message.
$date(DateTime) (required)
Action log entry's timestamp.

ActionScheduler_wpCommentLogger::create_wp_comment() code WC 10.8.1

protected function create_wp_comment( $action_id, $message, DateTime $date ) {

	$comment_date_gmt = $date->format( 'Y-m-d H:i:s' );
	ActionScheduler_TimezoneHelper::set_local_timezone( $date );
	$comment_data = array(
		'comment_post_ID'  => $action_id,
		'comment_date'     => $date->format( 'Y-m-d H:i:s' ),
		'comment_date_gmt' => $comment_date_gmt,
		'comment_author'   => self::AGENT,
		'comment_content'  => $message,
		'comment_agent'    => self::AGENT,
		'comment_type'     => self::TYPE,
	);

	return wp_insert_comment( $comment_data );
}