{
  "$schema": "https://playground.wordpress.net/blueprint-schema.json",
  "meta": {
    "title": "Royal Links — Live Demo",
    "description": "Create custom short URLs, track clicks, and manage link health. This demo loads a WordPress admin in your browser with Royal Links installed and 10 sample links pre-seeded.",
    "author": "royalplugins",
    "categories": ["Link Management"]
  },
  "landingPage": "/wp-admin/edit.php?post_type=royal_link",
  "preferredVersions": { "php": "8.2", "wp": "latest" },
  "phpExtensionBundles": ["kitchen-sink"],
  "features": { "networking": true },
  "login": { "username": "admin", "password": "password" },
  "steps": [
    {
      "step": "setSiteOptions",
      "options": {
        "blogname": "Royal Links Demo",
        "blogdescription": "Live preview — create short links, track clicks, manage redirects."
      }
    },
    {
      "step": "installPlugin",
      "pluginData": { "resource": "wordpress.org/plugins", "slug": "royal-links" },
      "options": { "activate": true }
    },
    {
      "step": "runPHP",
      "code": "<?php\nrequire_once '/wordpress/wp-load.php';\n\n$samples = [\n  ['Royal Plugins Home',   'royal',   'https://royalplugins.com/'],\n  ['SEObolt Pro',          'seobolt', 'https://royalplugins.com/seobolt/'],\n  ['SiteVault Backup',     'backup',  'https://royalplugins.com/sitevault/'],\n  ['ForgeCache',           'cache',   'https://royalplugins.com/forgecache/'],\n  ['Free Tools',           'tools',   'https://royalplugins.com/tools/'],\n  ['GitHub',               'gh',      'https://github.com/royalplugins'],\n  ['Blog',                 'blog',    'https://royalplugins.com/blog/'],\n  ['Pricing',              'pricing', 'https://royalplugins.com/pricing/'],\n  ['Support',              'help',    'https://royalplugins.com/support/'],\n  ['WP.org listing',       'wporg',   'https://wordpress.org/plugins/royal-links/'],\n];\n\n$link_ids = [];\nforeach ( $samples as $row ) {\n  list( $title, $slug, $dest ) = $row;\n  $post_id = wp_insert_post( [\n    'post_title'  => $title,\n    'post_name'   => $slug,\n    'post_type'   => 'royal_link',\n    'post_status' => 'publish',\n  ] );\n  if ( $post_id && ! is_wp_error( $post_id ) ) {\n    update_post_meta( $post_id, '_royal_links_destination_url', $dest );\n    update_post_meta( $post_id, '_royal_links_slug', $slug );\n    update_post_meta( $post_id, '_royal_links_redirect_type', '301' );\n    update_post_meta( $post_id, '_royal_links_nofollow', 0 );\n    update_post_meta( $post_id, '_royal_links_sponsored', 0 );\n    update_post_meta( $post_id, '_royal_links_new_tab', 0 );\n    $link_ids[] = $post_id;\n  }\n}\n\nglobal $wpdb;\n$table = $wpdb->prefix . 'royal_links_clicks';\n// Table is created on plugin activation; seed clicks so analytics charts render non-empty.\nif ( $wpdb->get_var( \"SHOW TABLES LIKE '{$table}'\" ) === $table ) {\n  $browsers   = [ 'Chrome', 'Firefox', 'Safari', 'Edge' ];\n  $oses       = [ 'Windows', 'macOS', 'Linux', 'iOS', 'Android' ];\n  $devices    = [ 'desktop', 'mobile', 'tablet' ];\n  $countries  = [ 'US', 'GB', 'DE', 'CA', 'AU', 'FR', 'BR', 'JP' ];\n  foreach ( $link_ids as $idx => $lid ) {\n    $clicks = 30 + ( count( $link_ids ) - $idx ) * 8 + wp_rand( 0, 20 );\n    for ( $i = 0; $i < $clicks; $i++ ) {\n      $days_ago   = wp_rand( 0, 29 );\n      $click_date = gmdate( 'Y-m-d H:i:s', time() - ( $days_ago * 86400 ) - wp_rand( 0, 86399 ) );\n      $wpdb->insert( $table, [\n        'link_id'      => $lid,\n        'click_date'   => $click_date,\n        'ip_address'   => sprintf( '192.0.2.%d', wp_rand( 1, 254 ) ),\n        'user_agent'   => 'Mozilla/5.0 (demo)',\n        'browser'      => $browsers[ array_rand( $browsers ) ],\n        'os'           => $oses[ array_rand( $oses ) ],\n        'device_type'  => $devices[ array_rand( $devices ) ],\n        'country'      => $countries[ array_rand( $countries ) ],\n        'is_unique'    => ( wp_rand( 0, 10 ) > 2 ) ? 1 : 0,\n        'click_source' => 'direct',\n      ] );\n    }\n  }\n}\n\n// Flush permalinks so /royal, /seobolt etc short-slug redirects work in the demo.\nflush_rewrite_rules();\n"
    }
  ]
}
