Skip to content

Commit b780b29

Browse files
committed
Add [COMPONENTS] Wordpress.com
1 parent 9964c4a commit b780b29

19 files changed

+874
-944
lines changed

components/wordpress_com/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,33 @@ The Wordpress.com API empowers developers to extend and integrate their website'
99
- **Comment Moderation Alerts**: Set up a Pipedream workflow that monitors Wordpress.com for new comments. When a comment is detected, analyze its content for specific keywords or sentiment using a service like Google's Natural Language API. If the comment requires attention (e.g., contains flagged words or negative sentiment), send an immediate alert to a Slack channel or via email to prompt review and moderation, keeping your community healthy and engaged.
1010

1111
- **User Synchronization and Engagement**: Create a workflow that triggers when a new user registers on your Wordpress.com site. This workflow can add the user to a CRM like HubSpot or Salesforce, subscribe them to a Mailchimp email list, and even send a personalized welcome email via SendGrid. This ensures your user data is consistent across platforms and kickstarts the user engagement process from the moment they sign up.
12+
13+
14+
# Available Event Sources
15+
16+
Trigger workflows automatically when specific Wordpress.com events occur:
17+
18+
New Post: Emit a new event when a post, page, or media attachment is published.
19+
Required props: site ID or URL. Optional: post type (post, page, attachment).
20+
21+
New Comment: Emit a new event when a comment is added to any post or page.
22+
Required props: site ID or URL. Optional: post ID to filter comments.
23+
24+
New Follower: Emit a new event when someone subscribes to the site's blog.
25+
Required props: site ID or URL.
26+
27+
Each source manages its own database cursor to ensure only new data is processed each time it runs — no duplicates, no missed updates.
28+
Available Actions
29+
30+
Perform direct operations on your Wordpress.com site:
31+
32+
Create Post: Create a new post on the site.
33+
Required props: site ID or URL, post title, post content.
34+
Optional props: post status (draft, published), categories, and tags.
35+
36+
Upload Media: Upload a media file (image, video, etc.) to the site's library.
37+
Required props: site ID or URL, media file (binary or URL).
38+
Optional props: media title and description.
39+
40+
Delete Post: Delete an existing post from the site.
41+
Required props: site ID or URL, post ID.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import wordpress from "../wordpress_com.app.mjs";
2+
3+
export default {
4+
key: "worpress_com-create-post",
5+
name: "Create New Post",
6+
description: "Retrieves the authenticated user's account information.",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
wordpress,
11+
site: {
12+
type: "string",
13+
label: "Site ID or domain",
14+
description: "Enter a site ID or domain (e.g. testsit38.wordpress.com). Do not include 'https://' or 'www'."
15+
},
16+
title: {
17+
type: "string",
18+
label: "Post Title",
19+
description: "The title of the post.",
20+
},
21+
content: {
22+
type: "string",
23+
label: "Post Content",
24+
description: "The content of the post (HTML or text).",
25+
},
26+
status: {
27+
type: "string",
28+
label: "Status",
29+
description: "The status of the post.",
30+
options: [
31+
"publish",
32+
"draft",
33+
"private",
34+
"pending",
35+
],
36+
default: "draft",
37+
},
38+
type: {
39+
type: "string",
40+
label: "Post Type",
41+
description: "The type of the post (post or page). For attachments, use the 'Upload Media' action.",
42+
options: [
43+
{ label: "Post", value: "post" },
44+
{ label: "Page", value: "page" },
45+
],
46+
default: "post",
47+
}
48+
},
49+
50+
async run({ $ }) {
51+
52+
const warnings = [];
53+
54+
const {
55+
site,
56+
wordpress,
57+
...fields
58+
} = this;
59+
60+
warnings.push(...wordpress.checkDomainOrId(site)); // TEST
61+
62+
let response;
63+
64+
try {
65+
response = await wordpress.createWordpressPost({ //TEST
66+
67+
$,
68+
site,
69+
data : {
70+
...fields
71+
}
72+
});
73+
74+
} catch (error) {
75+
wordpress.onAxiosCatch("Could not create post", error, warnings);
76+
};
77+
78+
$.export("$summary", `Post successfully created. ID = ${response?.ID}` + "\n- " + warnings.join("\n- "));
79+
},
80+
81+
};
82+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import wordpress from "../wordpress_com.app.mjs";
2+
3+
export default {
4+
5+
key: "worpress_com-delete-post",
6+
name: "Delete Post",
7+
description: "Delete post",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
wordpress,
12+
site: {
13+
type: "string",
14+
description: "Enter a site ID or domain (e.g. testsit38.wordpress.com).",
15+
},
16+
postId: {
17+
type: "integer",
18+
label: "Post ID",
19+
description: "The ID of the post you want to delete.",
20+
},
21+
},
22+
23+
async run({ $ }) {
24+
25+
const warnings = [];
26+
27+
const {
28+
site,
29+
wordpress,
30+
postId
31+
} = this;
32+
33+
34+
warnings.push(...wordpress.checkDomainOrId(site));
35+
36+
let response;
37+
38+
try {
39+
response = await wordpress.deleteWordpressPost({$, site, postId});
40+
} catch (error) {
41+
wordpress.onAxiosCatch("Could not delete post", error, warnings);
42+
};
43+
44+
$.export("$summary", `Post ID = ${response?.ID} successfully deleted.` + "\n- " + warnings.join("\n- "));
45+
},
46+
};
47+
48+
49+
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import {prepareMediaUpload} from "../common/utils.mjs";
2+
import wordpress from "../wordpress_com.app.mjs";
3+
4+
export default {
5+
6+
key: "wordpress_com-upload-media",
7+
name: "Upload Media",
8+
description: "Uploads a media file from a URL to the specified WordPress.com site.",
9+
version: "0.0.1",
10+
type: "action",
11+
12+
props: {
13+
wordpress,
14+
site: {
15+
type: "string",
16+
label: "Site ID or domain",
17+
description: "Enter a site ID or domain (e.g. testsit38.wordpress.com).",
18+
},
19+
media: {
20+
type: "any",
21+
label: "Media URL",
22+
description: "A direct media URL, or a FormData object with the file attached under the field name 'media[]'.",
23+
},
24+
title: {
25+
type: "string",
26+
label: "Title",
27+
description: "Title of the media.",
28+
optional: true,
29+
},
30+
caption: {
31+
type: "string",
32+
label: "Caption",
33+
optional: true,
34+
},
35+
description: {
36+
type: "string",
37+
label: "Description",
38+
optional: true,
39+
},
40+
},
41+
42+
async run({ $ }) {
43+
44+
const warnings = [];
45+
46+
const
47+
{
48+
wordpress,
49+
site,
50+
media,
51+
...fields
52+
} = this;
53+
54+
warnings.push(...wordpress.checkDomainOrId(site));
55+
56+
let form;
57+
58+
// If not form data
59+
if (wordpress.isFormData(media)){
60+
61+
console.log("Media was received as multipart/form-data");
62+
warnings.push("Media was received as multipart/form-data");
63+
64+
form = media;
65+
66+
} else {
67+
68+
warnings.push("Media was received as URL");
69+
warnings.push(...wordpress.checkIfUrlValid(media));
70+
71+
form = await prepareMediaUpload(media, fields, $);
72+
}
73+
74+
let response;
75+
76+
try {
77+
78+
response = await wordpress.uploadWordpressMedia({
79+
$,
80+
contentType : form.getHeaders()["content-type"],
81+
site,
82+
data : form,
83+
});
84+
85+
const media = response.media?.[0];
86+
87+
$.export("$summary", `Media "${media.title}" uploaded successfully (ID: ${media.ID})` + "\n- " + warnings.join("\n- "));
88+
89+
console.log(response);
90+
return response;
91+
92+
} catch (error) {
93+
94+
wordpress.onAxiosCatch("Failed to upload media", error, warnings);
95+
96+
};
97+
},
98+
};
99+

0 commit comments

Comments
 (0)