Skip to content

Automation Theme

The Automation theme is a custom WordPress theme that powers the content management and automation workflows for Man In America. It provides a comprehensive admin interface for managing podcasts, broadcasts, guests, and automated publishing to multiple platforms.

Repository Location

The Automation theme source code is located in the automation repository: AmericanMedia/automation

Overview

Purpose

The Automation theme transforms WordPress into a podcast production control center:

  • Podcast Management — Create and manage podcast episodes with rich metadata
  • Livestream Publishing — One-click publishing to Rumble, YouTube, Boxcast, Restream
  • AI Content Generation — Generate descriptions, summaries, and social posts
  • Social Media Automation — Automated posting to Telegram, Twitter, Facebook
  • Guest Management — Track guest information and booking pipeline
  • Sync & Scraping — Fetch metadata from Rumble episodes automatically

Theme Structure

wp-content/themes/automation/
├── style.css                    # Theme metadata
├── functions.php                # Main theme file
├── index.php                    # Template fallback
├── assets/
│   └── js/
│       └── podcast-sync-actions.js
└── includes/
    ├── simple_html_dom.php      # HTML parsing library
    ├── catalog.php              # Podcast sync & metadata
    ├── live.php                 # Livestream status checking
    ├── api-podcasts.php         # REST API endpoints
    ├── dropbox.php              # Dropbox integration
    ├── transistor.php           # Transistor podcast hosting
    ├── post-types/              # Custom post types
    │   ├── post-types.php
    │   ├── broadcast.php
    │   └── guest.php
    ├── admin/                   # Admin tools & UI
    │   ├── admin-tools.php
    │   ├── css/
    │   └── js/
    └── automation/              # Core automation system
        ├── core/                # Framework files
        ├── handlers/            # Step execution
        ├── steps/               # Platform integrations
        ├── buttons/             # Action buttons
        ├── boxcast/             # Boxcast-specific
        ├── prompts/             # AI prompt templates
        └── ui/                  # Flow tracker UI

Custom Post Types

Podcast

The primary content type for managing episodes.

FieldTypeDescription
titlestringEpisode title
contenttextEpisode teaser/description
stream_datedateScheduled stream date
stream_timetimeScheduled stream time
stream_visibilityselectpublic/private/unlisted
automation_modeselectproduction/development
rumble_urlurlRumble video URL
rumble_embedurlRumble embed URL
rumble_stream_urlurlRTMP stream URL
rumble_stream_keystringRTMP stream key
youtube_urlurlYouTube video URL
restream_idstringRestream event ID
show_notestextareaFull show notes

Broadcast

Pre-production content before becoming a podcast.

FieldTypeDescription
boxcast_idstringBoxcast broadcast ID
boxcast_statusstringProcessing status
boxcast_mp4_urlurlDownload URL for video
boxcast_m4a_urlurlDownload URL for audio
boxcast_poster_urlurlThumbnail URL

Guest

Guest information and booking.

FieldTypeDescription
titlestringGuest name
guest_biotextareaGuest biography
thumbnailimageGuest photo

Automation System

Core Components

The automation system is built around a step-based workflow:

Step Registration

Steps are registered using a declarative API:

php
register_automation_step('rumble', "rumble_setup", [
    'meta_field_inputs' => [ 
        'visibility' => "stream_visibility",
        'stream_date' => "stream_date",
        'stream_time' => "stream_time",
    ],
    'delete_button_meta_key' => 'rumble_embed',
    'post_meta_updates' => [...],
    'response_fields' => ['rumble_url', 'rumble_embed', 'rumble_stream_url', 'rumble_stream_key'],
    'extra_fields' => function($post_id, $post) {
        return [
            'title' => $post->post_title,
            'featured_image' => get_the_post_thumbnail_url($post_id, 'full'),
            'content' => $post->post_content
        ];
    },
    'cascade_create_steps' => ['generate_shortlink', 'boxcast_integration'],
    'disable_if' => function($post_id) { /* ... */ },
    'embed_renderer' => function($post_id) { /* ... */ },
]);

Available Steps

StepEndpointDescription
rumble_setup/rumble-createCreate Rumble livestream
boxcast_integration/boxcast-update-integrationUpdate Boxcast RTMP
generate_shortlink/shortlinkCreate short.io link
telegram_post/telegramPost to Telegram
twitter_post/ayrshare-createPost to Twitter/X
facebook_post/ayrshare-createPost to Facebook
restream_setup/restream-createCreate Restream event
youtube_setup/youtube-createCreate YouTube Live

Flow Tracker UI

The Flow Tracker is an admin metabox showing automation status:

┌──────────────────────────────────────────────────────────────┐
│ Automation Flow Tracker                                       │
├──────────────────────────────────────────────────────────────┤
│ 👁 Rumble Setup        [Success]  ▶️ 🗑 ☑                      │
│ 👁 Boxcast Integration [Success]  ▶️ 🗑 ☑                      │
│    Generate Shortlink  [Pending]  ▶️    ☑                      │
│    Telegram Post       [Pending]  ▶️    ☑                      │
│    Restream Setup      [Pending]  ▶️    ☑                      │
│    YouTube Setup       [Pending]  ▶️    ☑                      │
└──────────────────────────────────────────────────────────────┘

Features:

  • Status badges — Pending, Success, Failed
  • Run button — Execute or re-run individual steps
  • Delete button — Delete platform content (when applicable)
  • Toggle switches — Enable/disable steps for batch run
  • Embed preview — View platform embeds inline

Webhook Buttons

Action buttons are registered dynamically:

php
register_dynamic_webhook_button([
    'post_type'         => 'podcast',
    'button_id'         => 'create-livestreams',
    'button_label'      => 'Publish Livestreams',
    'button_location'   => 'post_submitbox_misc_actions',
    'processing_label'  => '⏳ Publishing...',
    'button_class'      => 'button button-primary',
    'webhook_action'    => 'create_livestream',
    'prepare_payload'   => function($data) { /* ... */ },
    'handle_response'   => function($payload, $post_id) { /* ... */ },
]);

Button Types

ButtonDescription
Publish LivestreamsRun all enabled automation steps
Generate AI SummaryGenerate description via OpenAI
HeadlinesGenerate headline variations
Short SummaryCreate short teaser
All Social PostsGenerate all social content
Facebook PostGenerate Facebook-specific post
Telegram PostGenerate Telegram message
Twitter PostGenerate Twitter/X post
Convert to PodcastConvert broadcast to podcast CPT

AI Integration

The theme integrates with OpenAI for content generation:

php
register_dynamic_webhook_button([
    'button_id'         => 'generate-ai-description',
    'button_label'      => 'Generate AI Summary',
    'target_url'        => 'https://api.openai.com/v1/chat/completions',
    'api_key'           => OPENAI_API_KEY,
    'prepare_payload'   => function ($data) {
        $prompt = "Write a short, hard-hitting show description...";
        return [
            'model' => 'gpt-4',
            'messages' => [
                ['role' => 'user', 'content' => $prompt],
            ],
            'temperature' => 0.7,
        ];
    },
]);

Prompt Templates

Stored in includes/automation/prompts/:

FilePurpose
universal.txtGeneral episode description
teaser.txtEpisode teaser format
short-teaser.txtShort social format
facebook-post.txtFacebook-specific format
instructions.txtStyle guidelines

Boxcast Integration

The theme has deep Boxcast integration for broadcast management:

includes/automation/boxcast/
├── boxcast-core.php      # Core loader
├── acf-hooks.php         # ACF field hooks
├── ajax.php              # AJAX handlers
├── enqueue.php           # Script loading
├── iframe-ui.php         # Embed rendering
├── api/
│   └── api.php           # API client
└── js/                   # Frontend scripts

Features

  • Status polling — Track upload/processing status
  • Download URLs — Fetch MP4/M4A download links
  • Integration updates — Update RTMP credentials
  • Iframe preview — Embed broadcasts in admin

Podcast Sync

The catalog.php file handles Rumble episode synchronization:

Manual Sync

Sync button in podcast list view triggers:

  1. Fetch episode data from Rumble via X Server
  2. Update post meta (title, description, views, duration)
  3. Update post date based on Rumble publish date
  4. Extract video resolutions

Scheduled Sync

Cron job runs hourly to fetch latest Rumble episodes:

php
add_action('mia_fetch_rumble_latest_episodes', 'mia_fetch_rumble_latest_episodes_job');

Creates new podcast posts for episodes not yet tracked.

Livestream Status

The live.php file checks stream status via Browserless:

php
function update_stream_status_in_db() {
    // Uses Browserless.io to scrape Rumble livestream status
    // Returns: Live, Starting Soon, Ended, Offline
}

REST API

Podcasts Endpoint

GET /wp-json/automation/v1/podcasts?limit=10

Returns:

json
{
  "success": true,
  "count": 10,
  "data": [
    {
      "id": 123,
      "title": "Episode Title",
      "date": "2026-02-05T10:00:00-05:00",
      "link": "https://example.com/podcast/episode-title",
      "content": "Episode description...",
      "featured_image": "https://example.com/image.jpg",
      "rumble_url": "https://rumble.com/...",
      "rumble_embed": "https://rumble.com/embed/...",
      "bunny_id": "abc123"
    }
  ]
}

Plugin: Stream Status Bar

A companion plugin for frontend livestream status:

wp-content/plugins/stream-status-bar/
├── stream-status-bar.php    # Plugin main file
├── stream-status-bar.js     # Frontend script
└── stream-status-bar.css    # Styles

Shortcode

[stream_status_bar]

Displays current livestream status with countdown timer.

Environment Configuration

Required constants in wp-config.php:

php
define('OPENAI_API_KEY', 'sk-...');
define('X_SERVER_URL', 'http://x-server:3000');
define('BOXCAST_YOUTUBE_INTEGRATION_ID', 't8i39wflb8ugjrrcytpe');

Integration with X Server

The theme communicates with X Server for platform automation:

php
// Example: Create Rumble livestream
wp_remote_post(X_SERVER_URL . '/rumble-create', [
    'headers' => ['Content-Type' => 'application/json'],
    'body' => json_encode([
        'title' => $post->post_title,
        'content' => $post->post_content,
        'featured_image' => get_the_post_thumbnail_url($post_id, 'full'),
        'visibility' => 'public',
        'stream_date' => '2026-02-05',
        'stream_time' => '10:00'
    ])
]);

MediaMagic CRM Documentation