@pipedream/wordpress_org 0.3.8 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -29
- package/actions/create-post/create-post.mjs +16 -1
- package/actions/create-user/create-user.mjs +1 -1
- package/actions/get-user/get-user.mjs +1 -1
- package/actions/search-posts/search-posts.mjs +1 -1
- package/actions/update-post/update-post.mjs +16 -1
- package/actions/update-user/update-user.mjs +1 -1
- package/actions/upload-media/upload-media.mjs +55 -0
- package/common/utils.mjs +22 -0
- package/package.json +2 -1
- package/wordpress_org.app.mjs +31 -1
package/README.md
CHANGED
@@ -1,32 +1,11 @@
|
|
1
1
|
# Overview
|
2
2
|
|
3
|
-
WordPress API
|
4
|
-
efficiency and functionality. Whether it’s developing and creating a custom
|
5
|
-
WordPress site, creating an API for a product, or developing a plugin for a
|
6
|
-
program, the WordPress API offers more possibilities than ever to customize and
|
7
|
-
enhance your online experience. Here are a few examples of things you can build
|
8
|
-
using the WordPress API:
|
3
|
+
The WordPress.org API offers a wide range of capabilities for content management, theme and plugin information, and community engagement. With Pipedream, you can harness this API to create automated workflows that react to events in WordPress, sync content across platforms, or even manage your site's appearance and functionality programmatically. Whether you're looking to streamline your publishing process, enhance user interaction, or keep everything in sync, the WordPress.org API on Pipedream offers a powerful toolset to craft custom solutions.
|
9
4
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
-
|
15
|
-
|
16
|
-
|
17
|
-
applications and websites.
|
18
|
-
- Plugin Creation: If you need a plugin for something you’re developing, the
|
19
|
-
WordPress API can help you create something tailored to your exact needs.
|
20
|
-
From custom shortcodes to mini programs and full-fledged plugins, the
|
21
|
-
WordPress API has what you need.
|
22
|
-
- Widgets: Widgets are small pieces of code that you can use on your website to
|
23
|
-
display different types of content. You can use the WordPress API to create
|
24
|
-
custom widgets that help you display plugins, videos, images, and more.
|
25
|
-
- Custom Social Network Platforms: The WordPress API offers more possibilities
|
26
|
-
than ever to create custom social network platforms. With access to the API,
|
27
|
-
you can create specialized networks for your website, unfettered by
|
28
|
-
third-party restrictions.
|
29
|
-
- Mobile Applications:Do you need to create a mobile application that interacts
|
30
|
-
with your website? The WordPress API can provide the tools and features you
|
31
|
-
need to create a smooth and seamless integration between your website and
|
32
|
-
your app.
|
5
|
+
# Example Use Cases
|
6
|
+
|
7
|
+
- **Automated Content Syndication**: Publish new WordPress posts automatically to social media platforms like Twitter or Facebook. Whenever you push a new post, Pipedream can capture this event and send out tweets or posts with links back to your article, driving traffic and engagement.
|
8
|
+
|
9
|
+
- **Dynamic Content Updates**: Update content across multiple WordPress sites in response to a single trigger. For instance, when you update a post on your main site, Pipedream can propagate these changes to other WordPress sites you manage, ensuring content consistency.
|
10
|
+
|
11
|
+
- **Scheduled Theme Changes**: Swap WordPress themes based on time or specific triggers, such as holidays or promotional events. With Pipedream, you can schedule these changes in advance, so your site reflects the right mood or branding at just the right time.
|
@@ -1,10 +1,11 @@
|
|
1
1
|
import wordpress from "../../wordpress_org.app.mjs";
|
2
|
+
import utils from "../../common/utils.mjs";
|
2
3
|
|
3
4
|
export default {
|
4
5
|
key: "wordpress_org-create-post",
|
5
6
|
name: "Create Post",
|
6
7
|
description: "Creates a post. [See the documentation](https://developer.wordpress.org/rest-api/reference/posts/#create-a-post)",
|
7
|
-
version: "0.0.
|
8
|
+
version: "0.0.4",
|
8
9
|
type: "action",
|
9
10
|
props: {
|
10
11
|
wordpress,
|
@@ -50,6 +51,18 @@ export default {
|
|
50
51
|
"commentStatus",
|
51
52
|
],
|
52
53
|
},
|
54
|
+
meta: {
|
55
|
+
propDefinition: [
|
56
|
+
wordpress,
|
57
|
+
"meta",
|
58
|
+
],
|
59
|
+
},
|
60
|
+
media: {
|
61
|
+
propDefinition: [
|
62
|
+
wordpress,
|
63
|
+
"media",
|
64
|
+
],
|
65
|
+
},
|
53
66
|
},
|
54
67
|
async run({ $ }) {
|
55
68
|
const params = {
|
@@ -60,6 +73,8 @@ export default {
|
|
60
73
|
categories: this.categories,
|
61
74
|
excerpt: this.excerpt,
|
62
75
|
comment_status: this.commentStatus,
|
76
|
+
meta: utils.parseObj(this.meta),
|
77
|
+
featured_media: this.media,
|
63
78
|
};
|
64
79
|
|
65
80
|
const resp = await this.wordpress.createPost(params);
|
@@ -4,7 +4,7 @@ export default {
|
|
4
4
|
key: "wordpress_org-create-user",
|
5
5
|
name: "Create User",
|
6
6
|
description: "Creates a user. [See the documentation](https://developer.wordpress.org/rest-api/reference/users/#create-a-user)",
|
7
|
-
version: "0.0.
|
7
|
+
version: "0.0.5",
|
8
8
|
type: "action",
|
9
9
|
props: {
|
10
10
|
wordpress,
|
@@ -4,7 +4,7 @@ export default {
|
|
4
4
|
key: "wordpress_org-get-user",
|
5
5
|
name: "Get User",
|
6
6
|
description: "Retrieves information for a user. [See the documentation](https://developer.wordpress.org/rest-api/reference/users/#retrieve-a-user-2)",
|
7
|
-
version: "0.0.
|
7
|
+
version: "0.0.3",
|
8
8
|
type: "action",
|
9
9
|
props: {
|
10
10
|
wordpress,
|
@@ -4,7 +4,7 @@ export default {
|
|
4
4
|
key: "wordpress_org-search-posts",
|
5
5
|
name: "Search Posts",
|
6
6
|
description: "Searches for specific posts. [See the documentation](https://developer.wordpress.org/rest-api/reference/posts/#list-posts)",
|
7
|
-
version: "0.0.
|
7
|
+
version: "0.0.4",
|
8
8
|
type: "action",
|
9
9
|
props: {
|
10
10
|
wordpress,
|
@@ -1,10 +1,11 @@
|
|
1
1
|
import wordpress from "../../wordpress_org.app.mjs";
|
2
|
+
import utils from "../../common/utils.mjs";
|
2
3
|
|
3
4
|
export default {
|
4
5
|
key: "wordpress_org-update-post",
|
5
6
|
name: "Update Post",
|
6
7
|
description: "Updates a post specified by its ID. [See the documentation](https://developer.wordpress.org/rest-api/reference/posts/#update-a-post)",
|
7
|
-
version: "0.0.
|
8
|
+
version: "0.0.4",
|
8
9
|
type: "action",
|
9
10
|
props: {
|
10
11
|
wordpress,
|
@@ -58,6 +59,18 @@ export default {
|
|
58
59
|
"commentStatus",
|
59
60
|
],
|
60
61
|
},
|
62
|
+
meta: {
|
63
|
+
propDefinition: [
|
64
|
+
wordpress,
|
65
|
+
"meta",
|
66
|
+
],
|
67
|
+
},
|
68
|
+
media: {
|
69
|
+
propDefinition: [
|
70
|
+
wordpress,
|
71
|
+
"media",
|
72
|
+
],
|
73
|
+
},
|
61
74
|
},
|
62
75
|
async run({ $ }) {
|
63
76
|
const params = {
|
@@ -68,6 +81,8 @@ export default {
|
|
68
81
|
categories: this.categories,
|
69
82
|
excerpt: this.excerpt,
|
70
83
|
comment_status: this.commentStatus,
|
84
|
+
meta: utils.parseObj(this.meta),
|
85
|
+
featured_media: this.media,
|
71
86
|
};
|
72
87
|
|
73
88
|
const resp = await this.wordpress.updatePost(this.post, params);
|
@@ -5,7 +5,7 @@ export default {
|
|
5
5
|
key: "wordpress_org-update-user",
|
6
6
|
name: "Update User",
|
7
7
|
description: "Updates the information of a user. [See the documentation](https://developer.wordpress.org/rest-api/reference/users/#update-a-user-2)",
|
8
|
-
version: "0.0.
|
8
|
+
version: "0.0.3",
|
9
9
|
type: "action",
|
10
10
|
props: {
|
11
11
|
wordpress,
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import wordpress from "../../wordpress_org.app.mjs";
|
2
|
+
import utils from "../../common/utils.mjs";
|
3
|
+
import { getFileStream } from "@pipedream/platform";
|
4
|
+
|
5
|
+
export default {
|
6
|
+
key: "wordpress_org-upload-media",
|
7
|
+
name: "Upload Media",
|
8
|
+
description: "Upload a media item to your WordPress media library. Returns a media ID to be used in creating or updating posts.[See the documentation](https://www.npmjs.com/package/wpapi#uploading-media)",
|
9
|
+
version: "0.0.2",
|
10
|
+
type: "action",
|
11
|
+
props: {
|
12
|
+
wordpress,
|
13
|
+
filePath: {
|
14
|
+
type: "string",
|
15
|
+
label: "File Path or URL",
|
16
|
+
description: "Provide either a file URL or a path to a file in the /tmp directory (for example, /tmp/myFile.pdf).",
|
17
|
+
},
|
18
|
+
title: {
|
19
|
+
propDefinition: [
|
20
|
+
wordpress,
|
21
|
+
"title",
|
22
|
+
],
|
23
|
+
description: "Title of the media item",
|
24
|
+
optional: true,
|
25
|
+
},
|
26
|
+
altText: {
|
27
|
+
type: "string",
|
28
|
+
label: "Alt Text",
|
29
|
+
description: "Alternative text to display when media is not displayed",
|
30
|
+
optional: true,
|
31
|
+
},
|
32
|
+
description: {
|
33
|
+
propDefinition: [
|
34
|
+
wordpress,
|
35
|
+
"description",
|
36
|
+
],
|
37
|
+
description: "Description of the media item",
|
38
|
+
optional: true,
|
39
|
+
},
|
40
|
+
},
|
41
|
+
async run({ $ }) {
|
42
|
+
const content = await getFileStream(this.filePath);
|
43
|
+
|
44
|
+
const params = utils.cleanObj({
|
45
|
+
title: this.title,
|
46
|
+
alt_text: this.altText,
|
47
|
+
description: this.description,
|
48
|
+
});
|
49
|
+
const response = await this.wordpress.createMedia(content, params);
|
50
|
+
|
51
|
+
$.export("$summary", "Successfully uploaded media.");
|
52
|
+
|
53
|
+
return response;
|
54
|
+
},
|
55
|
+
};
|
package/common/utils.mjs
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
export default {
|
2
|
+
parseObj(obj) {
|
3
|
+
return !obj
|
4
|
+
? undefined
|
5
|
+
: typeof obj === "string"
|
6
|
+
? JSON.parse(obj)
|
7
|
+
: obj;
|
8
|
+
},
|
9
|
+
cleanObj(o) {
|
10
|
+
for (var k in o || {}) {
|
11
|
+
if (typeof o[k] === "undefined") {
|
12
|
+
delete o[k];
|
13
|
+
}
|
14
|
+
}
|
15
|
+
return o;
|
16
|
+
},
|
17
|
+
getFilePath(path) {
|
18
|
+
return path.includes("tmp/")
|
19
|
+
? path
|
20
|
+
: `/tmp/${path}`;
|
21
|
+
},
|
22
|
+
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pipedream/wordpress_org",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.4.1",
|
4
4
|
"description": "Pipedream Wordpress.org Components",
|
5
5
|
"main": "wordpress_org.app.mjs",
|
6
6
|
"keywords": [
|
@@ -10,6 +10,7 @@
|
|
10
10
|
"homepage": "https://pipedream.com/apps/wordpress_org",
|
11
11
|
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
|
12
12
|
"dependencies": {
|
13
|
+
"@pipedream/platform": "^3.1.0",
|
13
14
|
"lodash.pickby": "^4.6.0",
|
14
15
|
"wpapi": "^1.2.2"
|
15
16
|
},
|
package/wordpress_org.app.mjs
CHANGED
@@ -61,7 +61,7 @@ export default {
|
|
61
61
|
email: {
|
62
62
|
type: "string",
|
63
63
|
label: "Email",
|
64
|
-
description: "
|
64
|
+
description: "The email address for the user",
|
65
65
|
},
|
66
66
|
url: {
|
67
67
|
type: "string",
|
@@ -150,6 +150,25 @@ export default {
|
|
150
150
|
}));
|
151
151
|
},
|
152
152
|
},
|
153
|
+
media: {
|
154
|
+
type: "string",
|
155
|
+
label: "Featured Media",
|
156
|
+
description: "Identifier of an uploaded media item",
|
157
|
+
optional: true,
|
158
|
+
async options({ page }) {
|
159
|
+
const media = await this.listMedia(page + 1);
|
160
|
+
return media.map((item) => ({
|
161
|
+
label: item?.title?.rendered || item.id,
|
162
|
+
value: item.id,
|
163
|
+
}));
|
164
|
+
},
|
165
|
+
},
|
166
|
+
meta: {
|
167
|
+
type: "object",
|
168
|
+
label: "Meta",
|
169
|
+
description: "Metafields for the post. Note: Metafield keys must be registered in your Wordpress instance.",
|
170
|
+
optional: true,
|
171
|
+
},
|
153
172
|
},
|
154
173
|
methods: {
|
155
174
|
async getClient() {
|
@@ -232,5 +251,16 @@ export default {
|
|
232
251
|
const wp = await this.getClient();
|
233
252
|
return wp.users().create(params);
|
234
253
|
},
|
254
|
+
async createMedia(file, params) {
|
255
|
+
const wp = await this.getClient();
|
256
|
+
return wp.media()
|
257
|
+
.file(file)
|
258
|
+
.create(params);
|
259
|
+
},
|
260
|
+
async listMedia(page) {
|
261
|
+
const wp = await this.getClient();
|
262
|
+
return wp.media().perPage(PER_PAGE)
|
263
|
+
.page(page);
|
264
|
+
},
|
235
265
|
},
|
236
266
|
};
|