Skip to main content

WordPress Automation — publish markdown files as WordPress pages via the REST API

Project description

WPA — WordPress Automation

CI Coverage Python PyPI License: MIT

Minimal CLI tool to publish markdown files as WordPress pages via the REST API.

Install

pip install wpa

Or install from source:

git clone https://github.com/cadentdev/wpa.git
cd wpa
pip install -e .

Create a site config

wpa site add

This prompts for your WordPress URL, username, application password (hidden), and optional admin path. Configs are stored at ~/.config/wpa/<site-name>/.env with 600 permissions.

WordPress Application Password

  1. Log into wp-admin → Users → Your Profile
  2. Scroll to "Application Passwords"
  3. Enter name: "WPA CLI", click "Add New Application Password"
  4. Copy the generated password (use it during --new-site setup)

Usage

# Publish a page (auto-selects site if only one config exists)
wpa publish pages/your-page.md

# Specify which site to use
wpa publish --site mysite pages/your-page.md

# Create or manage site configs
wpa site add
wpa site list

# Show version
wpa --version

Multi-site behavior

Configs --site flag Behavior
0 No Prompts to create a new config
1 No Uses the single config automatically
2+ No Prompts to select from list
Any Yes Uses the named config (error if not found)

Markdown file format

---
title: "Your Page Title"
slug: "your-page-slug"
status: draft
---

Page content in markdown here...
  • title (required): Page title
  • slug (optional): URL slug
  • status (optional): draft (default), publish, pending, or private

Site config format

Each site config is stored at ~/.config/wpa/<name>/.env:

WP_SITE_URL=https://example.com
WP_USER=your-username
WP_APP_PASSWORD=xxxx xxxx xxxx xxxx
WP_ADMIN_PATH=wp-admin
  • WP_ADMIN_PATH is optional (defaults to wp-admin). Override it if your site uses a custom admin URL.
  • The XDG_CONFIG_HOME environment variable is respected if set.

Migration from repo-root .env

If you have an existing .env in the repo root and no XDG configs, the tool will offer to migrate it on first run.

Safety and Security

  • Default status is always draft — never publishes unless frontmatter explicitly says otherwise
  • HTTPS enforced for public addresses — rejects http:// for public URLs; allows HTTP for private/LAN addresses (RFC 1918 + localhost) with a warning
  • Credentials in XDG config — stored outside the repo at ~/.config/wpa/ with 600 permissions
  • Password input hidden — uses getpass during interactive setup
  • Status validation — rejects typos and invalid values in frontmatter
  • Site name validation — only alphanumeric characters and hyphens allowed
  • Connection error handling — timeouts and network failures produce clear messages, not tracebacks

Development

pip install -e '.[dev]'
pytest --cov=wpa --cov-report=term-missing

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wpa-0.4.0.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wpa-0.4.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file wpa-0.4.0.tar.gz.

File metadata

  • Download URL: wpa-0.4.0.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for wpa-0.4.0.tar.gz
Algorithm Hash digest
SHA256 bdac82ac2fdd0c073965d7ea868eb0604dbebc98814ddd8471d7c242684ff551
MD5 887e1e9fe73281b213b78ffb9da56856
BLAKE2b-256 e012b0279f8cafb4832045f5adda1569a8992c540034eec6ffe355b7b9a685ac

See more details on using hashes here.

File details

Details for the file wpa-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: wpa-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for wpa-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f2f90ca2c128d9b715e9ce5f553c4aaee976a6f55a600b0de9d3b46b880f732
MD5 65960edd34cc040df2812ef0266efc3b
BLAKE2b-256 8f582448e5fedd417b839ad5cb87bdcd135717f8e73e50c08b3476041e0c5bc2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page