{
	"$schema": "https://playground.wordpress.net/blueprint-schema.json",
	"landingPage": "/donate-now/",
	"preferredVersions": {
		"php": "8.2",
		"wp": "latest"
	},
	"features": {
		"networking": true
	},
	"steps": [
		{
			"step": "login",
			"username": "admin",
			"password": "password"
		},
		{
			"step": "installPlugin",
			"pluginData": {
				"resource": "wordpress.org/plugins",
				"slug": "smartpay"
			},
			"options": {
				"activate": true
			}
		},
		{
			"step": "setSiteOptions",
			"options": {
				"blogname": "WP Smart Pay - Demo site",
				"blogdescription": "Accept payments easily with WordPress"
			}
		},
		{
			"step": "writeFile",
			"path": "/tmp/sp_form_content.html",
			"data": "<!-- wp:smartpay-form/name {\"showMiddleName\":false} -->\n<div class=\"wp-block-smartpay-form-name form-element row\"><!-- wp:smartpay-form/name-field {\"label\":\"First Name\",\"fieldType\":\"first_name\"} -->\n<div class=\"wp-block-smartpay-form-name-field col\"><!-- wp:smartpay-form/name-label {\"text\":\"First Name\",\"htmlFor\":\"first_name\"} -->\n<label class=\"wp-block-smartpay-form-name-label\" for=\"first_name\">First Name</label>\n<!-- /wp:smartpay-form/name-label -->\n\n<!-- wp:smartpay-form/name-input {\"placeholder\":\"First Name\",\"isRequired\":true} -->\n<input class=\"wp-block-smartpay-form-name-input form-control\" type=\"text\" id=\"first_name\" name=\"smartpay_form[name][first_name]\" placeholder=\"First Name\" required/>\n<!-- /wp:smartpay-form/name-input --></div>\n<!-- /wp:smartpay-form/name-field -->\n\n<!-- wp:smartpay-form/name-field {\"label\":\"Last Name\",\"fieldType\":\"last_name\"} -->\n<div class=\"wp-block-smartpay-form-name-field col\"><!-- wp:smartpay-form/name-label {\"text\":\"Last Name\",\"htmlFor\":\"last_name\"} -->\n<label class=\"wp-block-smartpay-form-name-label\" for=\"last_name\">Last Name</label>\n<!-- /wp:smartpay-form/name-label -->\n\n<!-- wp:smartpay-form/name-input {\"fieldName\":\"last_name\",\"placeholder\":\"Last Name\"} -->\n<input class=\"wp-block-smartpay-form-name-input form-control\" type=\"text\" id=\"last_name\" name=\"smartpay_form[name][last_name]\" placeholder=\"Last Name\"/>\n<!-- /wp:smartpay-form/name-input --></div>\n<!-- /wp:smartpay-form/name-field --></div>\n<!-- /wp:smartpay-form/name -->\n\n<!-- wp:smartpay-form/email -->\n<div class=\"wp-block-smartpay-form-email form-element\"><!-- wp:smartpay-form/email-label {\"text\":\"Email Address\"} -->\n<label class=\"wp-block-smartpay-form-email-label\">Email Address</label>\n<!-- /wp:smartpay-form/email-label -->\n\n<!-- wp:smartpay-form/email-input {\"placeholder\":\"you@example.com\"} -->\n<input class=\"wp-block-smartpay-form-email-input form-control\" type=\"email\" id=\"email\" name=\"smartpay_form[email]\" placeholder=\"you@example.com\" required/>\n<!-- /wp:smartpay-form/email-input --></div>\n<!-- /wp:smartpay-form/email -->\n\n<!-- wp:smartpay-form/pricing -->\n<div class=\"wp-block-smartpay-form-pricing form--amount-section smartpay-pricing is-style-grid\" style=\"--sp-currency:'$'\"><div class=\"form-amounts\"><div class=\"form-plan-grid\"><!-- wp:smartpay-form/pricing-option {\"key\":\"opt_1\",\"label\":\"$10\",\"amount\":\"10\"} -->\n<label class=\"wp-block-smartpay-form-pricing-option form-plan-card plan-amount\"><span class=\"plan-name\" aria-hidden=\"true\"><input type=\"radio\" name=\"_form_amount\" id=\"_form_amount_opt_1\" class=\"radio\" value=\"10\"/><span class=\"plan-info\"><span class=\"plan-type\">$10</span></span></span><span class=\"plan-details\" aria-hidden=\"true\"><span class=\"plan-cost\"><span class=\"plan-symbol\"></span>10</span></span><input type=\"hidden\" name=\"_form_billing_type\" value=\"One Time\"/><input type=\"hidden\" name=\"_form_amount_key\" value=\"opt_1\"/></label>\n<!-- /wp:smartpay-form/pricing-option -->\n\n<!-- wp:smartpay-form/pricing-option {\"key\":\"opt_2\",\"label\":\"$25\",\"amount\":\"25\"} -->\n<label class=\"wp-block-smartpay-form-pricing-option form-plan-card plan-amount\"><span class=\"plan-name\" aria-hidden=\"true\"><input type=\"radio\" name=\"_form_amount\" id=\"_form_amount_opt_2\" class=\"radio\" value=\"25\"/><span class=\"plan-info\"><span class=\"plan-type\">$25</span></span></span><span class=\"plan-details\" aria-hidden=\"true\"><span class=\"plan-cost\"><span class=\"plan-symbol\"></span>25</span></span><input type=\"hidden\" name=\"_form_billing_type\" value=\"One Time\"/><input type=\"hidden\" name=\"_form_amount_key\" value=\"opt_2\"/></label>\n<!-- /wp:smartpay-form/pricing-option -->\n\n<!-- wp:smartpay-form/pricing-option {\"key\":\"opt_3\",\"label\":\"$50\",\"amount\":\"50\"} -->\n<label class=\"wp-block-smartpay-form-pricing-option form-plan-card plan-amount\"><span class=\"plan-name\" aria-hidden=\"true\"><input type=\"radio\" name=\"_form_amount\" id=\"_form_amount_opt_3\" class=\"radio\" value=\"50\"/><span class=\"plan-info\"><span class=\"plan-type\">$50</span></span></span><span class=\"plan-details\" aria-hidden=\"true\"><span class=\"plan-cost\"><span class=\"plan-symbol\"></span>50</span></span><input type=\"hidden\" name=\"_form_billing_type\" value=\"One Time\"/><input type=\"hidden\" name=\"_form_amount_key\" value=\"opt_3\"/></label>\n<!-- /wp:smartpay-form/pricing-option -->\n\n<!-- wp:smartpay-form/pricing-option {\"key\":\"opt_4\",\"label\":\"$100\",\"amount\":\"100\"} -->\n<label class=\"wp-block-smartpay-form-pricing-option form-plan-card plan-amount\"><span class=\"plan-name\" aria-hidden=\"true\"><input type=\"radio\" name=\"_form_amount\" id=\"_form_amount_opt_4\" class=\"radio\" value=\"100\"/><span class=\"plan-info\"><span class=\"plan-type\">$100</span></span></span><span class=\"plan-details\" aria-hidden=\"true\"><span class=\"plan-cost\"><span class=\"plan-symbol\"></span>100</span></span><input type=\"hidden\" name=\"_form_billing_type\" value=\"One Time\"/><input type=\"hidden\" name=\"_form_amount_key\" value=\"opt_4\"/></label>\n<!-- /wp:smartpay-form/pricing-option --></div><input type=\"hidden\" name=\"smartpay_form_billing_type\" value=\"One Time\"/><input type=\"hidden\" name=\"smartpay_form_billing_period\" value=\"month\"/><input type=\"hidden\" class=\"form-control form--custom-amount amount\" name=\"smartpay_form_amount\" value=\"0.00\"/></div></div>\n<!-- /wp:smartpay-form/pricing -->\n\n<!-- wp:smartpay-form/submit-button -->\n<!-- wp:smartpay-form/submit-coupon /-->\n\n<!-- wp:smartpay-form/submit-pay {\"label\":\"Donate Now\"} /-->\n<!-- /wp:smartpay-form/submit-button -->\n\n<!-- wp:paragraph -->\n<p></p>\n<!-- /wp:paragraph -->"
		},
		{
			"step": "runPHP",
			"code": "<?php\nrequire_once '/wordpress/wp-load.php';\n\n// --- Permalink structure ---\nupdate_option('permalink_structure', '/%postname%/');\nflush_rewrite_rules(true);\n\n// --- Gateway & currency settings ---\n$s = get_option('smartpay_settings', []);\n$s['default_gateway'] = 'manual';\n$s['gateways'] = ['manual' => 1, 'paypal' => 1];\n$s['currency'] = 'USD';\n$s['currency_position'] = 'before';\n$s['decimal_separator'] = '.';\n$s['thousands_separator'] = ',';\n$s['paypal_email'] = 'sales@yourpaypal.com';\n$s['paypal_token'] = '12345';\nupdate_option('smartpay_settings', $s, false);\n\n// --- Quick Donation form ---\n// Bypass wp_kses_post so <input>,<label>,<span> in block HTML are preserved.\nremove_filter('content_save_pre', 'wp_filter_post_kses');\nremove_filter('content_filtered_save_pre', 'wp_filter_post_kses');\n\n$content = file_get_contents('/tmp/sp_form_content.html');\n\n$form_id = wp_insert_post([\n    'post_title'   => 'Quick Donation',\n    'post_content' => $content,\n    'post_status'  => 'publish',\n    'post_type'    => 'smartpay_form',\n]);\n\nkses_init_filters();\n\nif ($form_id && !is_wp_error($form_id)) {\n    update_post_meta($form_id, '_smartpay_amounts', json_encode([\n        ['key' => 'opt_1', 'label' => '$10',  'amount' => 10,  'billing_type' => 'One Time'],\n        ['key' => 'opt_2', 'label' => '$25',  'amount' => 25,  'billing_type' => 'One Time'],\n        ['key' => 'opt_3', 'label' => '$50',  'amount' => 50,  'billing_type' => 'One Time'],\n        ['key' => 'opt_4', 'label' => '$100', 'amount' => 100, 'billing_type' => 'One Time'],\n    ]));\n}\n\n$fid = ($form_id && !is_wp_error($form_id)) ? $form_id : 1;\n\n// --- Donate Now page ---\n$page_id = wp_insert_post([\n    'post_title'   => 'Donate Now',\n    'post_name'    => 'donate-now',\n    'post_content' => '<!-- wp:shortcode -->[sp_form id=\"' . $fid . '\"]<!-- /wp:shortcode -->',\n    'post_status'  => 'publish',\n    'post_type'    => 'page',\n]);\n\n// --- Nav menu: Donate Now + Dashboard only ---\n$menu_id = wp_create_nav_menu('Main Menu');\nif (!is_wp_error($menu_id)) {\n    wp_update_nav_menu_item($menu_id, 0, [\n        'menu-item-title'     => 'Donate Now',\n        'menu-item-object'    => 'page',\n        'menu-item-object-id' => $page_id,\n        'menu-item-type'      => 'post_type',\n        'menu-item-status'    => 'publish',\n    ]);\n    wp_update_nav_menu_item($menu_id, 0, [\n        'menu-item-title'  => 'Dashboard',\n        'menu-item-url'    => admin_url(),\n        'menu-item-type'   => 'custom',\n        'menu-item-status' => 'publish',\n    ]);\n    $locs = get_registered_nav_menus();\n    set_theme_mod('nav_menu_locations', array_fill_keys(array_keys($locs), $menu_id));\n}\n\n// --- Seed 5 sample donations ---\nglobal $wpdb;\n$tp = $wpdb->prefix . 'smartpay_payments';\n$tc = $wpdb->prefix . 'smartpay_customers';\n$donors = [\n    ['Sarah',  'Mitchell', 'sarah@example.com',  25,  'opt_2'],\n    ['James',  'Okafor',   'james@example.com',  50,  'opt_3'],\n    ['Emily',  'Chen',     'emily@example.com',  10,  'opt_1'],\n    ['Marcus', 'Williams', 'marcus@example.com', 25,  'opt_2'],\n    ['Aisha',  'Patel',    'aisha@example.com',  100, 'opt_4'],\n];\nforeach ($donors as $i => $d) {\n    $existing = $wpdb->get_var($wpdb->prepare(\"SELECT id FROM {$tc} WHERE email=%s\", $d[2]));\n    if (!$existing) {\n        $wpdb->insert($tc, ['first_name' => $d[0], 'last_name' => $d[1], 'email' => $d[2]]);\n        $cid = $wpdb->insert_id;\n    } else {\n        $cid = $existing;\n    }\n    $wpdb->insert($tp, [\n        'type'           => 'form_payment',\n        'data'           => json_encode(['form_id' => $fid, 'key' => $d[4]]),\n        'amount'         => $d[3],\n        'currency'       => 'USD',\n        'gateway'        => 'manual',\n        'transaction_id' => 'DEMO-' . strtoupper(substr(md5($d[2] . $i), 0, 8)),\n        'customer_id'    => $cid,\n        'email'          => $d[2],\n        'key'            => md5($d[2] . $i . time()),\n        'mode'           => 'Live',\n        'status'         => 'completed',\n        'completed_at'   => date('Y-m-d H:i:s', strtotime('-' . (($i + 1) * 3) . ' days')),\n    ]);\n}\n\necho 'Done. Form: ' . $fid . ' Page: ' . $page_id . ' Menu: ' . $menu_id;"
		}
	]
}
