Skip to content

Instantly share code, notes, and snippets.

@jack-arturo
Last active July 21, 2025 05:38
Show Gist options
  • Save jack-arturo/7a76a5743cb5292c2a98fadec2ae0ac0 to your computer and use it in GitHub Desktop.
Save jack-arturo/7a76a5743cb5292c2a98fadec2ae0ac0 to your computer and use it in GitHub Desktop.
update-docs.md
allowed-tools auto-approve description
Bash(git branch:*), Bash(git log:*), Bash(git status:*), Bash(curl:*), Bash(jq:*), Bash(echo:*), Bash(base64:*)
true
Update wpfusion.com documentation after implementing a feature using WordPress REST API

Update WP Fusion Documentation

Context

  • Current branch: !git branch --show-current
  • Recent commits: !git log --oneline -5
  • Current changes: !git status --porcelain
  • Scratchpad status: @.cursor/scratchpad.md
  • Available documentation endpoints: !curl -s -H "Authorization: Basic $(echo -n "$WPF_DOCS_USER:$WPF_DOCS_PASSWORD" | base64)" "$WPF_DOCS_URL/wp-json/wp/v2" | jq -r 'keys[]' | grep -E "(doc|page|post)" || echo "Standard endpoints available"
  • Recent documentation updates: !curl -s -H "Authorization: Basic $(echo -n "$WPF_DOCS_USER:$WPF_DOCS_PASSWORD" | base64)" "$WPF_DOCS_URL/wp-json/wp/v2/posts?per_page=3&orderby=modified&order=desc" | jq -r '.[] | "\(.id): \(.title.rendered) (modified: \(.modified))"' || echo "Unable to fetch recent posts"

Task

Update the documentation on wpfusion.com for the feature: $ARGUMENTS

Steps to complete:

  1. Analyze the implemented feature based on the git context and scratchpad
  2. Search existing documentation using REST API to find relevant content:
    • !curl -s -H "Authorization: Basic $(echo -n "$WPF_DOCS_USER:$WPF_DOCS_PASSWORD" | base64)" "$WPF_DOCS_URL/wp-json/wp/v2/posts?search=FEATURE_NAME&per_page=10" | jq -r '.[] | "\(.id): \(.title.rendered)"'
  3. Fetch current content of identified documentation:
    • !curl -s -H "Authorization: Basic $(echo -n "$WPF_DOCS_USER:$WPF_DOCS_PASSWORD" | base64)" "$WPF_DOCS_URL/wp-json/wp/v2/posts/POST_ID" | jq -r '.content.rendered'
  4. Draft the documentation updates following wpfusion.com writing style
  5. Update documentation via REST API POST/PUT requests
  6. Verify update by checking the public URL once (skip REST API re-fetch and timestamp checks)

WordPress REST API Helper Functions:

Search for existing documentation:

# Search posts by keyword
!curl -s -H "Authorization: Basic $(echo -n "$WPF_DOCS_USER:$WPF_DOCS_PASSWORD" | base64)" \
     "$WPF_DOCS_URL/wp-json/wp/v2/posts?search=$SEARCH_TERM&per_page=10" | \
     jq -r '.[] | "\(.id): \(.title.rendered) - \(.link)"'

Get specific post content:

# Fetch post by ID
!curl -s -H "Authorization: Basic $(echo -n "$WPF_DOCS_USER:$WPF_DOCS_PASSWORD" | base64)" \
     "$WPF_DOCS_URL/wp-json/wp/v2/posts/$POST_ID" | \
     jq -r '.content.rendered'

Update post content:

# Update existing post (API response with post ID confirms success)
!curl -s -X PUT \
     -H "Authorization: Basic $(echo -n "$WPF_DOCS_USER:$WPF_DOCS_PASSWORD" | base64)" \
     -H "Content-Type: application/json" \
     -d '{"content":"NEW_CONTENT_HTML"}' \
     "$WPF_DOCS_URL/wp-json/wp/v2/posts/$POST_ID" | jq -r '.id // "Update failed"'

Available Endpoints:

  • /wp-json/wp/v2/posts - Blog posts/announcements
  • /wp-json/wp/v2/pages - Static pages
  • /wp-json/wp/v2/documentation - Documentation posts (if custom post type exists)
  • /wp-json/wp/v2/categories - Post categories

Authentication Requirements:

  • Uses WordPress Application Passwords stored in environment variables
  • Required env vars: WPF_DOCS_URL, WPF_DOCS_USER, WPF_DOCS_PASSWORD
  • Scope permissions to documentation updates only

API Authentication:

# Basic authentication header
AUTH_HEADER="Authorization: Basic $(echo -n "$WPF_DOCS_USER:$WPF_DOCS_PASSWORD" | base64)"

# Example API call
curl -H "$AUTH_HEADER" \
     -H "Content-Type: application/json" \
     -X GET "$WPF_DOCS_URL/wp-json/wp/v2/posts"

Documentation Style Guidelines:

  • Follow existing wpfusion.com writing patterns
  • Be concise and action-oriented
  • Include practical examples where relevant
  • Match the tone from existing feature announcements

Code Example Format:

When including code examples, use this HTML syntax for the syntax highlighter:

<pre><code class="language-php">if ( wpf_has_tag( 'New Customer' ) &amp;&amp; ! wpf_has_tag( 'Watched Intro Video' )  ) {

	echo "Welcome to our site! Please watch our introduction video here:";

}
</code></pre>

Important formatting rules:

  • Use <pre><code class="language-php"> for PHP code blocks
  • HTML entities: & becomes &amp;, < becomes &lt;, > becomes &gt;
  • Maintain original indentation (tabs preferred)
  • Include realistic, practical examples that users can copy-paste
  • Use proper WordPress/WP Fusion function names and patterns

Verification Strategy:

  • Update confirmation: REST API PUT response returning post ID confirms success
  • Single verification: Check public URL once to confirm changes are live
  • Skip redundant checks: Don't re-fetch via REST API or check timestamps

Safety Checks:

  • Verify the feature is complete and tested
  • Ensure changelog entry exists in readme.txt
  • Confirm the feature aligns with existing documentation structure
  • Preview changes before publishing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment