微算力 · API 导航与自营网关
API 接入 EN
未登录登录
✨

WordPress Self-Hosted

WordPress Self-Hosted · v1.0.1
安全 unknown 级 作者 eddygk 公开目录收录
969 下载 1 安装 4.3k 收藏 1 浏览

简介

WordPress Self-Hosted

原始描述

Manage a self-hosted WordPress site via SSH+WP-CLI (primary) and WP REST API (when direct HTTPS access is available). Use when asked to write, draft, publish...

通过你的 Agent 添加

安装目录:wordpress-selfhosted/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。

点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。

或者手动安装

Claude Code~/.claude/skills/wordpress-self-hosted/
Codex CLI~/.codex/skills/wordpress-self-hosted/
DeepSeek Harness~/.agents/skills/wordpress-self-hosted/

包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可; 目录名不用换,也不要把包直接解压到 skills 根目录。 技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。

技能正文


name: wordpress-selfhosted license: MIT description: "Manage a self-hosted WordPress site via SSH+WP-CLI (primary) and WP REST API (when direct HTTPS access is available). Use when asked to write, draft, publish, update, or delete posts/pages on a self-hosted WordPress installation — including SEO optimization, categories/tags, featured images, author assignment, and proper post formatting. Designed for WordPress running on LXC, VPS, or bare-metal (not WordPress.com hosted). Requires: ssh, scp, curl, jq, wp (WP-CLI). Optional: op (1Password CLI for credential hydration via SSH agent socket). Network: SSH to user-configured WordPress host (LAN IP or public domain). Credentials: SSH key (via ssh-agent or 1Password SSH agent on macOS), WP application password (stored in 1Password, item name configurable via WP_1P_ITEM). Config values read from TOOLS.md: WP_HOST, WP_USER, WP_SSH_USER, WP_ROOT, WP_1P_ITEM. File writes: /tmp/post-content.html, /tmp/*.html (temporary content files SCP'd to host). Uses -o StrictHostKeyChecking=no for SSH (see Security Notes)." metadata: { "openclaw": { "emoji": "📝", "requires": { "bins": ["ssh", "scp", "curl", "jq", "wp"], "anyBins": ["op"] }, "os": ["darwin", "linux"] } }

WordPress Self-Hosted

Manage a self-hosted WordPress site via SSH+WP-CLI (primary) or WP REST API (when direct HTTPS access is available).

Configuration — set these from TOOLS.md before using:

  • WP_HOST — LAN IP or domain (e.g., 10.0.0.10 or myblog.com)
  • WP_USER — WordPress username
  • WP_1P_ITEM — 1Password item name for app password
  • WP_SSH_USER — SSH user (e.g., dev)
  • WP_ROOT — WordPress root path (e.g., /var/www/html/wordpress)

Connection Decision Tree

Use SSH+WP-CLI when:

  • WordPress is on a LAN IP (HTTP only)
  • Site is behind Cloudflare or a reverse proxy that strips Authorization headers
  • SITEURL is https:// but you're connecting over HTTP (SSL mismatch blocks app passwords)
  • You need plugin/theme/DB/cache operations (REST can't do these anyway)

Use REST API when:

  • You have direct HTTPS access to the WordPress host (no proxy stripping headers)
  • SITEURL matches the URL you're calling (no SSL mismatch)
  • Verify first: curl -s "https://<wp-host>/wp-json/" | jq '.authentication' — must return non-empty

⚠️ Common blockers for REST API auth:

  • Cloudflare (and most reverse proxies) strip Authorization headers — REST API auth will fail via public domain
  • WordPress requires SSL for application passwords — HTTP LAN access fails even if app passwords are created
  • Wordfence can disable application passwords entirely (wf_prevent_application_passwords option)

SSH + WP-CLI (Primary)

Use for all content operations when REST API is unavailable. Also the only option for plugin installs, cache flush, DB operations, file management.

# macOS with 1Password SSH agent
SSH_AUTH_SOCK="$HOME/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock" \
  ssh -o StrictHostKeyChecking=no <ssh-user>@<wp-host> \
  'cd <wp-root> && wp <command>'

# Linux / other SSH agents — SSH_AUTH_SOCK is already set in most environments
ssh -o StrictHostKeyChecking=no <ssh-user>@<wp-host> \
  'cd <wp-root> && wp <command>'

⚠️ macOS + 1Password users: Always use pty: true on exec tool calls — the 1Password agent needs a PTY for Touch ID signing. Without it: communication with agent failed.

SCP (file upload)

Large content bodies should be written to a local temp file, SCP'd over, then passed via $(cat /tmp/file) — avoids shell quoting issues with HTML/special chars.

SSH_AUTH_SOCK="$HOME/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock" \
  scp -o StrictHostKeyChecking=no /tmp/file.html <ssh-user>@<wp-host>:/tmp/

WP REST API (When Direct HTTPS Available)

No PTY, no Touch ID, single HTTP call. Use only when connection decision tree above confirms it will work.

WP_USER="<wp-username>"
WP_PASS=$(op item get "<1p-item-name>" --fields password --reveal)
WP_BASE="https://<wp-host>/wp-json/wp/v2"

# Verify auth works before proceeding
curl -s -u "$WP_USER:$WP_PASS" "$WP_BASE/users/me" | jq '{id, name}'

# List posts
curl -s -u "$WP_USER:$WP_PASS" "$WP_BASE/posts?per_page=20&status=any" | jq '[.[] | {id, title: .title.rendered, status}]'

# Get post content (raw blocks)
curl -s -u "$WP_USER:$WP_PASS" "$WP_BASE/posts/<ID>?context=edit" | jq -r '.content.raw'

# Create post (draft)
curl -s -X POST -u "$WP_USER:$WP_PASS" "$WP_BASE/posts" \
  -H "Content-Type: application/json" \
  -d '{"title":"Post Title","content":"<p>Body</p>","status":"draft"}'

# Update post content
curl -s -X POST -u "$WP_USER:$WP_PASS" "$WP_BASE/posts/<ID>" \
  -H "Content-Type: application/json" \
  -d "{\"content\": $(cat /tmp/content.html | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()))')}"

# Publish
curl -s -X POST -u "$WP_USER:$WP_PASS" "$WP_BASE/posts/<ID>" \
  -H "Content-Type: application/json" \
  -d '{"status": "publish"}'

To create an app password:

wp user application-password create <username> "MyAgent" --porcelain

Store output in 1Password. Note: passwords are hashed in the DB — you can't recover them later.

Quick Start Workflow (WP-CLI)

0. Pre-Write (gather context)

ssh <ssh-user>@<wp-host> 'cd <wp-root> && wp post list --post_status=publish --fields=ID,post_title,post_name --format=json 2>/dev/null' | jq '[.[] | {id: .ID, title: .post_title, slug: .post_name}]'

Pick 2–3 related posts to link contextually in the content body.

1. Write content to temp file locally

Write Gutenberg HTML to /tmp/post-content.html, then SCP to host.

2. Create Draft

ssh <ssh-user>@<wp-host> 'cd <wp-root> && \
  wp post create /tmp/post-content.html \
  --post_title="Post Title" \
  --post_status=draft \
  --post_author=<user-id> \
  --porcelain 2>/dev/null'
# Returns post ID

3. Set Metadata

POST_ID=123
ssh <ssh-user>@<wp-host> 'cd <wp-root> && \
  wp post term set '"$POST_ID"' category <slug> && \
  wp post term set '"$POST_ID"' post_tag <tag1> <tag2> && \
  wp post meta update '"$POST_ID"' _yoast_wpseo_metadesc "Meta description 120-155 chars" && \
  wp post meta update '"$POST_ID"' _yoast_wpseo_focuskw "focus keyphrase" 2>/dev/null'

4. SEO Checklist

Before publishing, verify:

  • Meta description set (120–155 chars)
  • Focus keyphrase set
  • 2–3 internal links to related posts
  • 5–7 tags
  • Categories assigned
  • Featured image set (optional but recommended)

5. Publish

ssh <ssh-user>@<wp-host> 'cd <wp-root> && wp post update '"$POST_ID"' --post_status=publish 2>/dev/null'

Authors

ssh <ssh-user>@<wp-host> 'cd <wp-root> && wp user list --fields=ID,user_login,display_name --format=json 2>/dev/null'

Common pattern for AI-assisted blogs: separate author accounts for human posts vs. agent-authored posts.

Post Content Format

Use WordPress block format (Gutenberg):

<!-- wp:paragraph -->
<p>Paragraph text here.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Section Heading</h2>
<!-- /wp:heading -->

<!-- wp:code -->
<pre class="wp-block-code"><code>code here</code></pre>
<!-- /wp:code -->

<!-- wp:list -->
<ul>
<li>List item</li>
</ul>
<!-- /wp:list -->

Author Signatures (optional)

Append at end of AI-authored posts:

<!-- wp:separator -->
<hr class="wp-block-separator has-alpha-channel-opacity"/>
<!-- /wp:separator -->

<!-- wp:paragraph {"style":{"typography":{"fontSize":"14px"},"color":{"text":"#888888"}}} -->
<p style="font-size:14px;color:#888888"><em>Written by <strong>Your Agent Name</strong> — AI agent (OpenClaw / Claude)<br>First-person perspective from an AI execution engine</em></p>
<!-- /wp:paragraph -->

Security Notes

StrictHostKeyChecking=no: Used throughout SSH/SCP commands because this skill targets user-configured hosts on trusted LANs (e.g., Proxmox LXC containers). In automation contexts where the host IP is known and the network is controlled, disabling host-key checking avoids interactive prompts that break non-interactive exec calls. Users connecting over untrusted networks should replace with StrictHostKeyChecking=accept-new or pre-populate ~/.ssh/known_hosts.

1Password SSH agent socket: On macOS, SSH commands reference SSH_AUTH_SOCK="$HOME/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock" to authenticate via the 1Password SSH agent. This is the standard macOS 1Password agent path — it allows SSH key signing via Touch ID without writing private keys to disk. The agent socket is only accessed when pty: true is set on exec calls (required for Touch ID prompt). On Linux or when using a different SSH agent, the standard SSH_AUTH_SOCK is used instead.

Credentials used:

  • SSH key — via ssh-agent (1Password agent on macOS, standard agent on Linux). Never written to disk by this skill.
  • WP application password — retrieved at runtime via op item get (1Password CLI) when using the REST API path. Not cached to disk.
  • Config values (WP_HOST, WP_USER, WP_SSH_USER, WP_ROOT, WP_1P_ITEM) — read from the agent's TOOLS.md, not env vars. No gating required.

Featured Images

# SCP image to host first, then import
ssh <ssh-user>@<wp-host> 'cd <wp-root> && \
  ATTACH_ID=$(wp media import /tmp/image.png --title="Image Title" --porcelain 2>/dev/null) && \
  wp post meta update POST_ID _thumbnail_id $ATTACH_ID 2>/dev/null'

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

标签

没有标签

同类 Skill