{
	"$schema": "https://playground.wordpress.net/blueprint-schema.json",
	"landingPage": "/",
	"preferredVersions": {
		"php": "8.2",
		"wp": "latest"
	},
	"features": {
		"networking": true
	},
	"steps": [
		{
			"step": "login",
			"username": "admin",
			"password": "password"
		},
		{
			"step": "installPlugin",
			"pluginZipFile": {
				"resource": "wordpress.org/plugins",
				"slug": "adfusion-ad-manager-and-monetization"
			},
			"options": {
				"activate": true
			}
		},
		{
			"step": "runPHP",
			"code": "<?php\nrequire_once '/wordpress/wp-load.php';\n\n/**\n * Ensure an ad group term exists; return term ID.\n *\n * @param string $name Term name.\n * @param string $slug Term slug.\n * @return int\n */\nfunction adf_demo_term_id( $name, $slug ) {\n\t$term = wp_insert_term( $name, 'adfusion_group', array( 'slug' => $slug ) );\n\tif ( is_wp_error( $term ) ) {\n\t\t$t = get_term_by( 'slug', $slug, 'adfusion_group' );\n\t\treturn $t ? (int) $t->term_id : 0;\n\t}\n\treturn (int) $term['term_id'];\n}\n\n/**\n * Create a text ad and assign groups.\n *\n * @param string   $title    Ad title.\n * @param string   $slug     Post slug.\n * @param int[]    $term_ids Term IDs.\n * @param string   $code     Text body.\n * @param int      $weight   Weight.\n * @return int Post ID or 0.\n */\nfunction adf_demo_text_ad( $title, $slug, $term_ids, $code, $weight = 10 ) {\n\t$id = wp_insert_post(\n\t\tarray(\n\t\t\t'post_title'  => $title,\n\t\t\t'post_name'   => $slug,\n\t\t\t'post_status' => 'publish',\n\t\t\t'post_type'   => 'adfusion_ad',\n\t\t)\n\t);\n\tif ( ! $id || is_wp_error( $id ) ) {\n\t\treturn 0;\n\t}\n\tif ( ! empty( $term_ids ) ) {\n\t\twp_set_object_terms( $id, array_map( 'intval', $term_ids ), 'adfusion_group' );\n\t}\n\tupdate_post_meta( $id, '_adf_ad_type', 'text' );\n\tupdate_post_meta( $id, '_adf_ad_code', $code );\n\tupdate_post_meta( $id, '_adf_weight', (string) $weight );\n\tupdate_post_meta( $id, '_adf_destination_url', 'https://example.com' );\n\tupdate_post_meta( $id, '_adf_ad_url', 'https://example.com' );\n\treturn (int) $id;\n}\n\n/**\n * Create an image ad and assign groups.\n *\n * @param string   $title     Ad title.\n * @param string   $slug      Post slug.\n * @param int[]    $term_ids  Term IDs.\n * @param string   $image_url Image URL (HTTPS, WordPress.org CDN).\n * @param int      $weight    Weight.\n * @return int Post ID or 0.\n */\nfunction adf_demo_image_ad( $title, $slug, $term_ids, $image_url, $weight = 10 ) {\n\t$id = wp_insert_post(\n\t\tarray(\n\t\t\t'post_title'  => $title,\n\t\t\t'post_name'   => $slug,\n\t\t\t'post_status' => 'publish',\n\t\t\t'post_type'   => 'adfusion_ad',\n\t\t)\n\t);\n\tif ( ! $id || is_wp_error( $id ) ) {\n\t\treturn 0;\n\t}\n\tif ( ! empty( $term_ids ) ) {\n\t\twp_set_object_terms( $id, array_map( 'intval', $term_ids ), 'adfusion_group' );\n\t}\n\tupdate_post_meta( $id, '_adf_ad_type', 'image' );\n\tupdate_post_meta( $id, '_adf_ad_image', esc_url_raw( $image_url ) );\n\tupdate_post_meta( $id, '_adf_weight', (string) $weight );\n\tupdate_post_meta( $id, '_adf_destination_url', 'https://wordpress.org' );\n\tupdate_post_meta( $id, '_adf_ad_url', 'https://wordpress.org' );\n\treturn (int) $id;\n}\n\n// Group slugs align with Settings UI labels and option keys (free + Premium).\n$g_story_header  = adf_demo_term_id( 'Story header (above title)', 'story-header' );\n$g_header_strip  = adf_demo_term_id( 'Header strip', 'header-strip' );\n$g_after_content = adf_demo_term_id( 'After content', 'after-content' );\n$g_leaderboard   = adf_demo_term_id( 'Leaderboard', 'leaderboard' );\n$g_incontent_1   = adf_demo_term_id( 'In-content 1', 'incontent-1' );\n$g_incontent_2   = adf_demo_term_id( 'In-content 2', 'incontent-2' );\n$g_story_footer  = adf_demo_term_id( 'Story footer', 'story-footer' );\n$g_sticky        = adf_demo_term_id( 'Sticky anchor', 'sticky-footer' );\n$g_popup         = adf_demo_term_id( 'Popup', 'popup' );\n\n// Sample images: WordPress.org / theme directory assets (HTTPS, public CDN).\n$img_story_header  = 'https://s.w.org/style/images/welcome/about-header-about.png';\n$img_header_strip  = 'https://s.w.org/style/images/wp-header-logo.png';\n$img_after_content = 'https://s.w.org/style/images/about/WordPress-logotype-standard.png';\n$img_leaderboard   = 'https://s.w.org/images/core/5.8/about-header-bg.jpg';\n$img_incontent_1   = 'https://themes.svn.wordpress.org/twentytwentyfour/1.2/screenshot.png';\n$img_incontent_2   = 'https://themes.svn.wordpress.org/twentytwentythree/1.4/screenshot.png';\n$img_story_footer  = 'https://themes.svn.wordpress.org/twentytwentytwo/1.8/screenshot.png';\n$img_sticky        = 'https://themes.svn.wordpress.org/twentytwentyone/2.2/screenshot.png';\n$img_popup         = 'https://themes.svn.wordpress.org/twentytwentyfive/1.0/screenshot.png';\n\n// Text + image per group (equal weight) so the rotator can pick either.\n$w_text  = 10;\n$w_image = 10;\n\n$first_id       = 0;\n$first_image_id = 0;\n\n$ids = array();\n\n$ids[] = adf_demo_text_ad( 'Sample text — Story header', 'sample-text-story-header', array( $g_story_header ), 'Story header (text) — rotates with the image ad in this group.', $w_text );\n$t     = adf_demo_image_ad( 'Sample image — Story header', 'sample-img-story-header', array( $g_story_header ), $img_story_header, $w_image );\n$ids[] = $t;\nif ( $t > 0 && 0 === $first_image_id ) {\n\t$first_image_id = $t;\n}\n\n$ids[] = adf_demo_text_ad( 'Sample text — Header strip', 'sample-text-header-strip', array( $g_header_strip ), 'Header strip (text) — Before content in core; rotates with image.', $w_text );\n$ids[] = adf_demo_image_ad( 'Sample image — Header strip', 'sample-img-header-strip', array( $g_header_strip ), $img_header_strip, $w_image );\n\n$ids[] = adf_demo_text_ad( 'Sample text — After content', 'sample-text-after-content', array( $g_after_content ), 'After content (text) — end of post body; rotates with image.', $w_text );\n$ids[] = adf_demo_image_ad( 'Sample image — After content', 'sample-img-after-content', array( $g_after_content ), $img_after_content, $w_image );\n\n$ids[] = adf_demo_text_ad( 'Sample text — Leaderboard', 'sample-text-leaderboard', array( $g_leaderboard ), 'Leaderboard (text) — rotates with image.', $w_text );\n$ids[] = adf_demo_image_ad( 'Sample image — Leaderboard', 'sample-img-leaderboard', array( $g_leaderboard ), $img_leaderboard, $w_image );\n\n$ids[] = adf_demo_text_ad( 'Sample text — In-content 1', 'sample-text-incontent-1', array( $g_incontent_1 ), 'In-content 1 (text) — rotates with image.', $w_text );\n$ids[] = adf_demo_image_ad( 'Sample image — In-content 1', 'sample-img-incontent-1', array( $g_incontent_1 ), $img_incontent_1, $w_image );\n\n$ids[] = adf_demo_text_ad( 'Sample text — In-content 2', 'sample-text-incontent-2', array( $g_incontent_2 ), 'In-content 2 (text) — rotates with image.', $w_text );\n$ids[] = adf_demo_image_ad( 'Sample image — In-content 2', 'sample-img-incontent-2', array( $g_incontent_2 ), $img_incontent_2, $w_image );\n\n$ids[] = adf_demo_text_ad( 'Sample text — Story footer', 'sample-text-story-footer', array( $g_story_footer ), 'Story footer (text) — rotates with image.', $w_text );\n$ids[] = adf_demo_image_ad( 'Sample image — Story footer', 'sample-img-story-footer', array( $g_story_footer ), $img_story_footer, $w_image );\n\n$ids[] = adf_demo_text_ad( 'Sample text — Sticky anchor', 'sample-text-sticky', array( $g_sticky ), 'Sticky anchor (text) — rotates with image.', $w_text );\n$ids[] = adf_demo_image_ad( 'Sample image — Sticky anchor', 'sample-img-sticky', array( $g_sticky ), $img_sticky, $w_image );\n\n$ids[] = adf_demo_text_ad( 'Sample text — Popup', 'sample-text-popup', array( $g_popup ), 'Popup (text) — rotates with image.', $w_text );\n$ids[] = adf_demo_image_ad( 'Sample image — Popup', 'sample-img-popup', array( $g_popup ), $img_popup, $w_image );\n\nforeach ( $ids as $aid ) {\n\tif ( $aid > 0 ) {\n\t\t$first_id = $aid;\n\t\tbreak;\n\t}\n}\n\nif ( $first_image_id > 0 ) {\n\t$first_id = $first_image_id;\n}\n\n// Free core: before / after post content (single posts).\nupdate_option( 'adfusion_before_content_group', 'header-strip' );\nupdate_option( 'adfusion_after_content_group', 'after-content' );\n\n// Premium placements (stored for when Premium is active; wp.org Playground ships core plugin only).\nupdate_option( 'adfusion_premium_story_header_group', 'story-header' );\nupdate_option( 'adfusion_premium_leaderboard_group', 'leaderboard' );\nupdate_option( 'adfusion_premium_incontent_group', 'incontent-1' );\nupdate_option( 'adfusion_premium_incontent_2_group', 'incontent-2' );\nupdate_option( 'adfusion_premium_story_footer_group', 'story-footer' );\nupdate_option( 'adfusion_premium_sticky_anchor_group', 'sticky-footer' );\nupdate_option( 'adfusion_premium_popup_group', 'popup' );\nupdate_option( 'adfusion_premium_incontent_paragraph', 3 );\nupdate_option( 'adfusion_premium_incontent_2_paragraph', 8 );\n\n$paragraphs = array(\n\t'This sample post has multiple paragraphs so Premium in-content placements have anchors.',\n\t'Second paragraph — keep reading for the demo story.',\n\t'Third paragraph — In-content 1 targets after paragraph 3 by default.',\n\t'Fourth paragraph of placeholder text.',\n\t'Fifth paragraph.',\n\t'Sixth paragraph.',\n\t'Seventh paragraph.',\n\t'Eighth paragraph — In-content 2 targets after paragraph 8 by default.',\n\t'Ninth paragraph.',\n\t'Tenth paragraph — end of demo body.',\n);\n$post_body = '';\nforeach ( $paragraphs as $p ) {\n\t$post_body .= '<p>' . esc_html( $p ) . '</p>';\n}\n\n$post_id = wp_insert_post(\n\tarray(\n\t\t'post_title'   => 'Sample post with placements',\n\t\t'post_name'    => 'adfusion-demo-story',\n\t\t'post_content' => $post_body,\n\t\t'post_status'  => 'publish',\n\t\t'post_type'    => 'post',\n\t)\n);\n\n$story_url = ( $post_id && ! is_wp_error( $post_id ) ) ? get_permalink( $post_id ) : home_url( '/' );\n\n$html  = '<h2>AdFusion Playground demo</h2>';\n$html .= '<p>Each group has <strong>two ads</strong> (text + image, equal weight) so the rotator can show either. <strong>Before content</strong> uses the <em>Header strip</em> group. Open <a href=\"' . esc_url( $story_url ) . '\">the sample single post</a> for core before/after injection.</p>';\n$html .= '<p>Premium placements are saved in options; they render when <strong>AdFusion Premium</strong> is active.</p>';\n$html .= '<h3>Story header (above title)</h3>';\n$html .= '[adfusion group=\"story-header\"]';\n$html .= '<h3>Header strip — Before content (core)</h3>';\n$html .= '[adfusion group=\"header-strip\"]';\n$html .= '<h3>After content (core)</h3>';\n$html .= '[adfusion group=\"after-content\"]';\n$html .= '<h3>Leaderboard</h3>';\n$html .= '[adfusion group=\"leaderboard\"]';\n$html .= '<h3>In-content 1</h3>';\n$html .= '[adfusion group=\"incontent-1\"]';\n$html .= '<h3>In-content 2</h3>';\n$html .= '[adfusion group=\"incontent-2\"]';\n$html .= '<h3>Story footer</h3>';\n$html .= '[adfusion group=\"story-footer\"]';\n$html .= '<h3>Sticky anchor</h3>';\n$html .= '[adfusion group=\"sticky-footer\"]';\n$html .= '<h3>Popup</h3>';\n$html .= '[adfusion group=\"popup\"]';\nif ( $first_id > 0 ) {\n\t$html .= '<h3>Single ad by ID (sample image)</h3>';\n\t$html .= '[adfusion id=\"' . (int) $first_id . '\"]';\n}\n\n$page_id = wp_insert_post(\n\tarray(\n\t\t'post_title'   => 'AdFusion demo',\n\t\t'post_name'    => 'adfusion-demo',\n\t\t'post_content' => $html,\n\t\t'post_status'  => 'publish',\n\t\t'post_type'    => 'page',\n\t)\n);\n\nif ( $page_id && ! is_wp_error( $page_id ) ) {\n\tupdate_option( 'show_on_front', 'page' );\n\tupdate_option( 'page_on_front', (int) $page_id );\n}\n"
		}
	]
}
