{
  "$schema": "https://playground.wordpress.net/blueprint-schema.json",
  "meta": {
    "title": "Royal Ledger — Live Demo",
    "description": "Try the cost tracker and encrypted license key vault live in your browser. Pre-populated with 10 sample WordPress costs and 4 license keys — no signup.",
    "author": "royalplugins",
    "categories": ["Site Management"]
  },
  "landingPage": "/?p=1",
  "preferredVersions": { "php": "8.2", "wp": "latest" },
  "phpExtensionBundles": ["kitchen-sink"],
  "features": { "networking": true },
  "login": { "username": "admin", "password": "password" },
  "steps": [
    {
      "step": "setSiteOptions",
      "options": {
        "blogname": "Royal Ledger Demo",
        "blogdescription": "Click into the WordPress admin to see the cost dashboard, renewal calendar, and license vault."
      }
    },
    {
      "step": "installPlugin",
      "pluginData": { "resource": "wordpress.org/plugins", "slug": "royal-ledger" },
      "options": { "activate": true }
    },
    {
      "step": "runPHP",
      "code": "<?php\nrequire_once '/wordpress/wp-load.php';\n\nglobal $wpdb;\n$items_table = $wpdb->prefix . 'rledger_items';\n$keys_table  = $wpdb->prefix . 'rledger_keys';\n\n$items = [\n  ['WPForms Pro',          'plugins', 199.50, 'annual',  '+45 days',  'https://wpforms.com'],\n  ['Yoast SEO Premium',    'plugins',  99.00, 'annual',   '+8 days',  'https://yoast.com'],\n  ['Elementor Pro',        'plugins',  59.00, 'annual', '+200 days',  'https://elementor.com'],\n  ['Astra Pro',            'themes',   59.00, 'annual', '+178 days',  'https://wpastra.com'],\n  ['SiteGround GoGeek',    'hosting',  14.99, 'monthly', '+22 days',  'https://siteground.com'],\n  ['Cloudflare Pro',       'saas',     25.00, 'monthly',  '+5 days',  'https://cloudflare.com'],\n  ['Mailgun Email API',    'saas',     35.00, 'monthly', '+12 days',  'https://mailgun.com'],\n  ['Google Workspace',     'saas',     12.00, 'monthly', '+30 days',  'https://workspace.google.com'],\n  ['mybusiness.com',       'domains',  12.99, 'annual',  '+90 days',  'https://namecheap.com'],\n  ['AWS S3 Storage',       'saas',      8.50, 'monthly', '+18 days',  'https://aws.amazon.com'],\n];\n\n$item_ids = [];\nforeach ( $items as $i => $row ) {\n  $wpdb->insert( $items_table, [\n    'name'             => $row[0],\n    'category'         => $row[1],\n    'cost'             => $row[2],\n    'currency'         => 'USD',\n    'billing_cycle'    => $row[3],\n    'renewal_date'     => gmdate( 'Y-m-d', strtotime( $row[4] ) ),\n    'status'           => 'active',\n    'url'              => $row[5],\n    'is_auto_detected' => 0,\n  ] );\n  $item_ids[ $i ] = (int) $wpdb->insert_id;\n}\n\nif ( class_exists( 'RLEDGER_Crypto' ) ) {\n  $keys = [\n    [0, 'WPForms Pro License',       'wpfp-7N3K-9X2M-A8FH-PDJ4-Q7K5L9MNV3CB'],\n    [1, 'Yoast SEO Premium License', 'YSPRM-A8X2-B7K3-CD45-EF67-GH89IJ12'],\n    [2, 'Elementor Pro License',     'ELP-7K3X9N-2M8B4D-A6F1J5-PQR8-2026'],\n    [3, 'Astra Pro License',         'ASTRA-9X2K-7N3M-A8B4-PQ1J'],\n  ];\n  foreach ( $keys as $k ) {\n    $encrypted = RLEDGER_Crypto::encrypt( $k[2] );\n    if ( false !== $encrypted ) {\n      $wpdb->insert( $keys_table, [\n        'item_id'     => $item_ids[ $k[0] ] ?? null,\n        'key_name'    => $k[1],\n        'license_key' => $encrypted,\n        'expiry_date' => gmdate( 'Y-m-d', strtotime( '+1 year' ) ),\n      ] );\n    }\n  }\n}\n\n$body = <<<HTML\n<h2>Royal Ledger &mdash; live demo</h2>\n<p>This demo is pre-populated with <strong>10 sample WordPress costs</strong> across plugins, themes, hosting, domains, and SaaS, plus <strong>4 encrypted license keys</strong>. Click into the WordPress admin to explore the dashboard, calendar, and vault.</p>\n<p><a class=\"button button-primary\" href=\"/wp-admin/admin.php?page=royal-ledger\">Open Royal Ledger Dashboard</a></p>\n<h3>What to try</h3>\n<ul>\n  <li><strong>Dashboard</strong>: Monthly burn (\\$131), annual cost (\\$1,575), and a doughnut chart of spending by category.</li>\n  <li><strong>Cost Items</strong>: Filter by category or status, search, edit, or delete any of the 10 sample items.</li>\n  <li><strong>License Keys</strong>: AES-256 encrypted vault &mdash; click the eye icon to reveal a key, copy with one click.</li>\n  <li><strong>Renewal Calendar</strong>: Color-coded month view of upcoming renewals so nothing catches you off guard.</li>\n  <li><strong>Settings</strong>: Currency switcher, email reminder settings, full CSV / JSON export and import.</li>\n</ul>\n<h3>Real-world use</h3>\n<p>Track every cost associated with your WordPress site &mdash; premium plugins, hosting, domains, CDNs, email services, SaaS tools &mdash; in one place. License keys you receive from third-party vendors (WPForms, Yoast, Elementor, etc.) are encrypted with AES-256-CBC + HMAC, derived from your WordPress security salts. No external service, no account, no phone-home.</p>\n<p>Log in with <code>admin</code> / <code>password</code>.</p>\nHTML;\n\nwp_update_post( [\n  'ID'           => 1,\n  'post_title'   => 'Royal Ledger — Live Demo',\n  'post_content' => $body,\n  'post_status'  => 'publish',\n  'post_author'  => 1,\n] );\n"
    }
  ]
}
