{
	"$schema": "https://playground.wordpress.net/blueprint-schema.json",
	"meta": {
		"title": "Jumplinks Flow — Demo Review Page",
		"description": "You're logged in as a reviewer. Select any text to leave an inline comment, use the sidebar for general feedback, or hit Approve when you're happy.",
		"author": "jumplinks",
		"categories": ["editorial", "workflow"]
	},
	"landingPage": "/?flow_demo_go=1",
	"preferredVersions": {
		"php": "8.2",
		"wp": "latest"
	},
	"phpExtensionBundles": ["kitchen-sink"],
	"features": {
		"networking": true
	},
	"steps": [
		{
			"step": "installPlugin",
			"pluginData": {
				"resource": "wordpress.org/plugins",
				"slug": "jumplinks-editorial-workflow"
			}
		},
		{
			"step": "writeFile",
			"path": "/wordpress/wp-content/mu-plugins/flow-demo-go.php",
			"data": "<?php\n// Demo helper: /?flow_demo_go=1 → redirects to the signed review URL\n// generated by the runPHP step below. This indirection is needed because\n// blueprint `landingPage` is static, but the review URL contains a\n// signed token computed at runtime.\nadd_action( 'init', function () {\n\tif ( ! isset( $_GET['flow_demo_go'] ) ) {\n\t\treturn;\n\t}\n\t$url = get_option( 'flow_demo_review_url' );\n\tif ( $url ) {\n\t\twp_safe_redirect( $url );\n\t\texit;\n\t}\n} );\n"
		},
		{
			"step": "runPHP",
			"code": "<?php\nrequire_once '/wordpress/wp-load.php';\n\n// 1. Reviewer user (Editor role).\nif ( ! get_user_by( 'login', 'reviewer' ) ) {\n\t$reviewer_id = wp_insert_user( [\n\t\t'user_login'   => 'reviewer',\n\t\t'user_pass'    => 'reviewer',\n\t\t'user_email'   => 'reviewer@example.com',\n\t\t'display_name' => 'Demo Reviewer',\n\t\t'role'         => 'editor',\n\t] );\n} else {\n\t$reviewer_id = get_user_by( 'login', 'reviewer' )->ID;\n}\n\n// 2. Flow settings — mark setup completed and (re-)assert reviewer-role + post-type\n//    options so cap sync runs and `editor` gets `flow_review_posts`.\nupdate_option( 'flow_ew_setup_completed', true );\nupdate_option( 'flow_ew_reviewer_roles', [ 'editor' ] );\nupdate_option( 'flow_ew_supported_post_types', [ 'post', 'page' ] );\n\n// 3. Sample draft post (admin = id 1 as author and requester).\n//    HTML attributes use single quotes so the surrounding PHP double-quoted\n//    string (and the surrounding JSON encoding) doesn't need extra escaping.\n$post_id = wp_insert_post( [\n\t'post_title'   => 'Welcome to the Flow Review Demo page',\n\t'post_content' => \"<!-- wp:paragraph --><p>You're logged in as the <strong>reviewer</strong>. Try the things below — this whole page is the Flow review experience.</p><!-- /wp:paragraph --><!-- wp:heading --><h2>What you can try</h2><!-- /wp:heading --><!-- wp:list --><ul><li><strong>Select any text</strong> on this page — an Add Comment popover appears next to your selection.</li><li><strong>Click on the image below</strong> to leave a comment anchored to that image.</li><li><strong>Open the comment sidebar</strong> on the right to leave a general comment.</li><li><strong>Click Approve or Request Changes</strong> in the top bar to take action.</li></ul><!-- /wp:list --><!-- wp:heading --><h2>Comment on an image</h2><!-- /wp:heading --><!-- wp:paragraph --><p>Image comments are useful when reviewing visual designs, screenshots, or photography. Click the image to leave feedback anchored to it.</p><!-- /wp:paragraph --><!-- wp:image --><figure class='wp-block-image size-large'><img src='https://placehold.co/800x400/2271b1/ffffff/png?text=Click+me+to+leave+a+comment' alt='Demo image - click to leave a comment' /></figure><!-- /wp:image --><!-- wp:heading --><h2>Comment on a video</h2><!-- /wp:heading --><!-- wp:paragraph --><p>Embed videos behave like images here — click to leave a comment, not to play. Try clicking the video below.</p><!-- /wp:paragraph --><!-- wp:html --><div style='text-align:center'><video controls preload='metadata' width='800' style='max-width:100%;aspect-ratio:16/9' poster='https://placehold.co/800x450/2c3338/ffffff/png?text=Click+to+leave+a+comment'><source src='https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4' type='video/mp4'></video></div><!-- /wp:html --><!-- wp:heading --><h2>Try a longer paragraph</h2><!-- /wp:heading --><!-- wp:paragraph --><p>Editorial review is most useful on real content — paragraphs, headings, lists, the works. Highlight a sentence here and leave a suggestion. Inline comments anchor to the text you selected, so the conversation stays in context instead of getting lost in a long thread.</p><!-- /wp:paragraph -->\",\n\t'post_status'  => 'draft',\n\t'post_author'  => 1,\n] );\n\n// 4. Snapshot to a revision so the review preview has something stable to point at.\nwp_save_post_revision( $post_id );\n$revisions   = wp_get_post_revisions( $post_id, [ 'numberposts' => 1 ] );\n$revision_id = ! empty( $revisions ) ? (int) reset( $revisions )->ID : 0;\n\n// 5. Create the review and move it to in_review state.\n$review_id = \\Flow\\EditorialWorkflow\\Review::request( $post_id, $reviewer_id, 1 );\n\\Flow\\EditorialWorkflow\\Review::send_for_review( $review_id, 1 );\n\n// 6. Generate the signed preview URL and stash it for the mu-plugin to read.\n$preview_url = \\Flow\\EditorialWorkflow\\Review::get_preview_url( $review_id, $revision_id, $post_id );\nupdate_option( 'flow_demo_review_url', $preview_url );\n"
		},
		{
			"step": "login",
			"username": "reviewer",
			"password": "reviewer"
		}
	]
}
