public static function preparePost($post)
{
if (!is_object($post)) {
$post = get_post($post);
}
$user = get_userdata($post->post_author);
if ($user instanceof WP_User) {
$user_data = ['raw' => $user->user_login, 'login' => $user->user_login, 'display_name' => $user->display_name, 'id' => $user->ID];
} else {
$user_data = ['raw' => '', 'login' => '', 'display_name' => '', 'id' => ''];
}
$post_date = $post->post_date;
$post_date_gmt = $post->post_date_gmt;
$post_modified = $post->post_modified;
$post_modified_gmt = $post->post_modified_gmt;
if (strtotime($post_date) <= 0) {
$post_date = null;
}
if (strtotime($post_date_gmt) <= 0) {
$post_date_gmt = null;
}
if (strtotime($post_modified) <= 0) {
$post_modified = null;
}
if (strtotime($post_modified_gmt) <= 0) {
$post_modified_gmt = null;
}
$post_args = (object) ['post_id' => $post->ID, 'post_author' => $user_data, 'post_date' => $post_date, 'post_date_gmt' => $post_date_gmt, 'post_title' => $post->post_title, 'post_excerpt' => $post->post_excerpt, 'post_content' => $post->post_content, 'post_status' => $post->post_status, 'post_name' => $post->post_name, 'post_modified' => $post_modified, 'post_modified_gmt' => $post_modified_gmt, 'post_parent' => $post->post_parent, 'post_type' => $post->post_type, 'post_mime_type' => $post->post_mime_type, 'permalink' => get_permalink($post->ID), 'terms' => static::prepareTerms($post), 'post_meta' => $meta = static::prepareMeta($post), 'post_meta_num' => static::prepareMetaNum($meta), 'post_date_object' => static::prepareDateTerms($post_date), 'post_date_gmt_object' => static::prepareDateTerms($post_date_gmt), 'post_modified_object' => static::prepareDateTerms($post_modified), 'post_modified_gmt_object' => static::prepareDateTerms($post_modified_gmt), 'menu_order' => $post->menu_order, 'guid' => $post->guid, 'comment_count' => $post->comment_count];
$post_args = apply_filters('esi_post_sync_args', $post_args, $post);
return $post_args;
}