Skip to content

Commit fc4ed94

Browse files
authored
Merge pull request #4 from PolyPlugins/update-product-endpoint/add-status
Added: status attribute to update product endpoint
2 parents cfa5104 + baa22ea commit fc4ed94

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

README.MD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ Yes, the plugin supports uploading images to the WordPress media library via the
6565

6666
## Changelog
6767

68+
### 1.0.5
69+
* Added: status attribute to [Update Product](https://www.polyplugins.com/docs/content-api/api/update-product/) endpoint
70+
6871
### 1.0.4
6972
* Added: [Create Product](https://www.polyplugins.com/docs/content-api/api/create-product/) endpoint
7073
* Added: cost, map_price, and categories attributes to [Get Product](https://www.polyplugins.com/docs/content-api/api/get-product/) endpoint

content-api.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Plugin Name: Content API
55
* Plugin URI: https://www.polyplugins.com/contact/
66
* Description: Adds various endpoints to create content
7-
* Version: 1.0.4
7+
* Version: 1.0.5
88
* Requires at least: 6.5
99
* Requires PHP: 7.4
1010
* Author: Poly Plugins
@@ -480,6 +480,7 @@ public function update_product(WP_REST_Request $request) {
480480
$fields = $request->get_json_params();
481481
$product_id = isset($fields['product_id']) ? absint($fields['product_id']) : 0;
482482
$name = isset($fields['name']) ? sanitize_text_field($fields['name']) : '';
483+
$status = isset($fields['status']) ? sanitize_text_field($fields['status']) : '';
483484
$slug = isset($fields['slug']) ? sanitize_title($fields['slug']) : '';
484485
$description = isset($fields['description']) ? wp_kses_post($fields['description']) : '';
485486
$short_description = isset($fields['short_description']) ? wp_kses_post($fields['short_description']) : '';
@@ -551,6 +552,10 @@ public function update_product(WP_REST_Request $request) {
551552
$product->set_name($name);
552553
}
553554

555+
if ($status) {
556+
$product->set_status($status);
557+
}
558+
554559
if ($slug) {
555560
$product->set_slug($slug);
556561
}

readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Contributors: polyplugins
33
Tags: content api, rest api, content, creative, api
44
Tested up to: 6.8
5-
Stable tag: 1.0.4
5+
Stable tag: 1.0.5
66
Requires PHP: 7.4
77
License: GPLv3
88
License URI: https://www.gnu.org/licenses/gpl-3.0.html
@@ -84,6 +84,9 @@ Yes, the plugin supports uploading images to the WordPress media library via the
8484

8585
== Changelog ==
8686

87+
= 1.0.5 =
88+
* Added: status attribute to [Update Product](https://www.polyplugins.com/docs/content-api/api/update-product/) endpoint
89+
8790
= 1.0.4 =
8891
* Added: [Create Product](https://www.polyplugins.com/docs/content-api/api/create-product/) endpoint
8992
* Added: cost, map_price, and categories attributes to [Get Product](https://www.polyplugins.com/docs/content-api/api/get-product/) endpoint

0 commit comments

Comments
 (0)