WP-CLI Commands
WP-CLI Commands for ABSPLITTEST
ABSPLITTEST includes comprehensive WP-CLI commands for managing A/B tests from the command line. Perfect for automation, CI/CD pipelines, and developer workflows.
Installation
WP-CLI commands are automatically available when the ABSPLITTEST plugin is active. Ensure you have WP-CLI installed.
Available Commands
1. Create Test
wp absplittest create_test --name="Test Name" --type=magic [options]
Required Parameters:
--name– Test title/name--type– Test type:magic,ab_test,css_test, orfull_page
Optional Parameters:
--status– Post status:publish,draft, orpending(default: draft)--magic_definition– JSON string for magic test configuration--conversion_page– Conversion page ID or trigger type--target_percentage– Traffic percentage (1-100, default: 100)
Examples:
# Create a draft magic test
wp absplittest create_test --name="Homepage Hero" --type=magic --status=draft
# Create with magic definition
wp absplittest create_test
--name="Button Test"
--type=magic
--magic_definition='[{"original":"Buy Now","variations":["Get Started","Try Free"]}]'
# Create published full page test
wp absplittest create_test
--name="Landing Page"
--type=full_page
--status=publish
--conversion_page=123
2. List Tests
wp absplittest list_tests [options]
Optional Parameters:
--status– Filter by status:publish,draft,pending, orany--type– Filter by test type--format– Output format:table,csv,json, oryaml
Examples:
# List all tests (table format)
wp absplittest list_tests
# List only published tests
wp absplittest list_tests --status=publish
# Export to JSON
wp absplittest list_tests --format=json > tests.json
# Filter by type
wp absplittest list_tests --type=magic --format=csv
3. Get Test Results
wp absplittest get_results <test_id> [--format=<format>]
Examples:
# View results for test #123
wp absplittest get_results 123
# Export results as JSON
wp absplittest get_results 123 --format=json
# Export as YAML
wp absplittest get_results 123 --format=yaml
4. Update Test Status
wp absplittest update_status <test_id> <status>
Valid Statuses: publish, draft, pending
Examples:
# Publish a test
wp absplittest update_status 123 publish
# Set to draft
wp absplittest update_status 123 draft
Automation Examples
Bash Script: Create Multiple Tests
#!/bin/bash
# create-tests.sh
tests=(
"Homepage Hero:magic"
"CTA Button:magic"
"Pricing Page:full_page"
)
for test in "${tests[@]}"; do
IFS=':' read -r name type <<< "$test"
wp absplittest create_test --name="$name" --type="$type" --status=draft
done
Cron Job: Daily Test Report
# Add to crontab
0 9 * * * cd /var/www/html && wp absplittest list_tests --status=publish --format=csv > /tmp/daily-tests.csv
CI/CD Integration
# .github/workflows/deploy.yml
- name: Publish A/B Tests
run: |
wp absplittest update_status 123 publish
wp absplittest update_status 124 publish
Getting Help
For detailed help on any command:
wp absplittest <command> --help