From 265dd6ef14f62aaf4baf751fafee6e4c97f9467c Mon Sep 17 00:00:00 2001 From: Abdukhaligov Date: Thu, 19 Nov 2020 20:04:58 +0400 Subject: [PATCH 1/2] Add optional parameter for post (post_type) --- src/WordpressClient.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/WordpressClient.php b/src/WordpressClient.php index fd6ac00..a7f0277 100644 --- a/src/WordpressClient.php +++ b/src/WordpressClient.php @@ -282,15 +282,17 @@ function getPosts(array $filters = array(), array $fields = array()) * @param array $categorieIds the list of category ids * @param integer $thumbnailId the thumbnail id * @param array $content the content array, see more at wordpress documentation + * @param string|null $type the type of post * * @return integer the new post id * * @link http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.newPost */ - function newPost($title, $body, array $content = array()) + function newPost($title, $body, array $content = array(), string $type = null) { + $postType = $type ?: 'post'; $default = array( - 'post_type' => 'post', + 'post_type' => $postType, 'post_status' => 'publish', ); $content = array_merge($default, $content); From 57768a8acdff25eddd76ca0d98341709e8d4d820 Mon Sep 17 00:00:00 2001 From: Abdukhaligov Date: Fri, 20 Nov 2020 16:30:01 +0400 Subject: [PATCH 2/2] Update WordpressClient.php --- src/WordpressClient.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/WordpressClient.php b/src/WordpressClient.php index a7f0277..d878fb1 100644 --- a/src/WordpressClient.php +++ b/src/WordpressClient.php @@ -290,9 +290,8 @@ function getPosts(array $filters = array(), array $fields = array()) */ function newPost($title, $body, array $content = array(), string $type = null) { - $postType = $type ?: 'post'; $default = array( - 'post_type' => $postType, + 'post_type' => $type ?: 'post', 'post_status' => 'publish', ); $content = array_merge($default, $content);