{
	"$schema": "https://playground.wordpress.net/blueprint-schema.json",
	"meta": {
		"title": "Simple Taxonomy Refreshed demo",
		"description": "The released plugin from WordPress.org, with five custom taxonomies, extra functions on Tags, sample posts and a page of the plugin's blocks. Built from the playground folder by npm run assets-blueprint.",
		"author": "NeilWJames",
		"categories": [
			"Content"
		]
	},
	"landingPage": "/wp-admin/admin.php?page=staxo_settings",
	"preferredVersions": {
		"php": "8.2",
		"wp": "latest"
	},
	"steps": [
		{
			"step": "installPlugin",
			"pluginData": {
				"resource": "wordpress.org/plugins",
				"slug": "simple-taxonomy-refreshed"
			},
			"options": {
				"activate": true
			}
		},
		{
			"step": "setSiteOptions",
			"options": {
				"blogname": "STR Playground",
				"blogdescription": "Simple Taxonomy Refreshed demo site",
				"permalink_structure": "/%postname%/"
			}
		},
		{
			"step": "runPHP",
			"code": "<?php\nrequire '/wordpress/wp-load.php';\n\n/**\n * Demo content for the Simple Taxonomy Refreshed playground.\n *\n * Loaded by playground/blueprint.json (and blueprint-local.json) once the plugin is active:\n * it defines five taxonomies, sets extra functions on Tags, creates their terms and a set of\n * posts and a page that show what the plugin does. The documentation in docs/ describes this site.\n *\n * The taxonomies follow the plugin's test suite (tests/files/staxo-config-suite.json and the\n * end-to-end radio fixture), with names for a music and arts magazine:\n *\n * | Taxonomy  | Based on  | Shows                                                         |\n * |-----------|-----------|---------------------------------------------------------------|\n * | genre     | test_hier | Hierarchical; terms shown after the post content; rewrite URL |\n * | colour    | test_flat | Flat, posts and pages; REST base; default term; content+excerpt |\n * | audience  | test_cntl | Term Control: 1 or 2 terms on every saved post                |\n * | topic     | test_count| Term Count of published and draft posts; admin list filter    |\n * | section   | e2e_kind  | At most one term: radio buttons with \"No term\"               |\n *\n * @package simple-taxonomy-refreshed\n */\n\ndefined( 'ABSPATH' ) || exit;\n\n/**\n * Settings of a taxonomy defined by the plugin, from the plugin's defaults.\n *\n * @param string $name     taxonomy name (slug).\n * @param string $singular singular label.\n * @param string $plural   plural label.\n * @param array  $settings settings that differ from the defaults.\n * @return array\n */\nfunction staxo_demo_taxonomy( $name, $singular, $plural, $settings ) {\n\t$hier   = ! empty( $settings['hierarchical'] );\n\t$labels = SimpleTaxonomyRefreshed_Client::get_taxonomy_default_labels( $hier ? 1 : 0 );\n\n\t// The default labels speak of categories or tags: use the taxonomy's own names.\n\t$from = $hier ? array( 'Categories', 'categories', 'Category', 'category' ) : array( 'Tags', 'tags', 'Tag', 'tag' );\n\t$to   = array( $plural, strtolower( $plural ), $singular, strtolower( $singular ) );\n\tforeach ( $labels as $key => $label ) {\n\t\tif ( is_string( $label ) ) {\n\t\t\t$labels[ $key ] = str_replace( $from, $to, $label );\n\t\t}\n\t}\n\t$labels['name']          = $plural;\n\t$labels['singular_name'] = $singular;\n\t$labels['menu_name']     = $plural;\n\n\treturn array_merge(\n\t\tSimpleTaxonomyRefreshed_Client::get_taxonomy_default_fields(),\n\t\tarray(\n\t\t\t'name'         => $name,\n\t\t\t'labels'       => $labels,\n\t\t\t'capabilities' => SimpleTaxonomyRefreshed_Client::get_taxonomy_default_capabilities(),\n\t\t\t'query_var'    => $name,\n\t\t),\n\t\t$settings\n\t);\n}\n\n/**\n * Create a tree of terms.\n *\n * @param string $taxonomy taxonomy name.\n * @param array  $tree     term name => child tree (array) for each term.\n * @param int    $parent   parent term id.\n * @return void\n */\nfunction staxo_demo_terms( $taxonomy, $tree, $parent = 0 ) {\n\tforeach ( $tree as $name => $children ) {\n\t\t$term = wp_insert_term( $name, $taxonomy, array( 'parent' => $parent ) );\n\t\tif ( is_array( $term ) && ! empty( $children ) ) {\n\t\t\tstaxo_demo_terms( $taxonomy, $children, (int) $term['term_id'] );\n\t\t}\n\t}\n}\n\n/**\n * Attach terms (by name) to a post.\n *\n * @param int   $post_id post id.\n * @param array $terms   taxonomy => term names.\n * @return void\n */\nfunction staxo_demo_set_terms( $post_id, $terms ) {\n\tforeach ( $terms as $taxonomy => $names ) {\n\t\t$ids = array();\n\t\tforeach ( $names as $name ) {\n\t\t\t$term = get_term_by( 'name', $name, $taxonomy );\n\t\t\tif ( $term ) {\n\t\t\t\t$ids[] = (int) $term->term_id;\n\t\t\t}\n\t\t}\n\t\twp_set_object_terms( $post_id, $ids, $taxonomy );\n\t}\n}\n\n/**\n * Load the demo: settings, terms, posts and the demo page.\n *\n * @return void\n */\nfunction staxo_demo_load() {\n\t// Work as the administrator so that block markup in the content is kept as written.\n\twp_set_current_user( 1 );\n\tkses_remove_filters();\n\n\tSimpleTaxonomyRefreshed_Client::get_wp_default_labels();\n\n\t$taxonomies = array(\n\t\t'genre'    => staxo_demo_taxonomy(\n\t\t\t'genre',\n\t\t\t'Genre',\n\t\t\t'Genres',\n\t\t\tarray(\n\t\t\t\t'hierarchical' => 1,\n\t\t\t\t'objects'      => array( 'post' ),\n\t\t\t\t'auto'         => 'content',\n\t\t\t\t'st_before'    => 'Genres:',\n\t\t\t\t'rewrite'      => 1,\n\t\t\t\t'st_slug'      => 'genre',\n\t\t\t)\n\t\t),\n\t\t'colour'   => staxo_demo_taxonomy(\n\t\t\t'colour',\n\t\t\t'Colour',\n\t\t\t'Colours',\n\t\t\tarray(\n\t\t\t\t'hierarchical' => 0,\n\t\t\t\t'objects'      => array( 'post', 'page' ),\n\t\t\t\t'auto'         => 'both',\n\t\t\t\t'st_before'    => 'Colours:',\n\t\t\t\t'rest_base'    => 'colours',\n\t\t\t\t'st_dft_name'  => 'Unsorted',\n\t\t\t\t'st_dft_slug'  => 'unsorted',\n\t\t\t)\n\t\t),\n\t\t'audience' => staxo_demo_taxonomy(\n\t\t\t'audience',\n\t\t\t'Audience',\n\t\t\t'Audiences',\n\t\t\tarray(\n\t\t\t\t'hierarchical' => 0,\n\t\t\t\t'objects'      => array( 'post' ),\n\t\t\t\t'st_cc_type'   => 2,\n\t\t\t\t'st_cc_hard'   => 1,\n\t\t\t\t'st_cc_umin'   => 1,\n\t\t\t\t'st_cc_min'    => 1,\n\t\t\t\t'st_cc_umax'   => 1,\n\t\t\t\t'st_cc_max'    => 2,\n\t\t\t)\n\t\t),\n\t\t'topic'    => staxo_demo_taxonomy(\n\t\t\t'topic',\n\t\t\t'Topic',\n\t\t\t'Topics',\n\t\t\tarray(\n\t\t\t\t'hierarchical' => 1,\n\t\t\t\t'objects'      => array( 'post' ),\n\t\t\t\t'st_cb_type'   => 2,\n\t\t\t\t'st_cb_pub'    => 1,\n\t\t\t\t'st_cb_dft'    => 1,\n\t\t\t\t'st_adm_types' => array( 'post' ),\n\t\t\t\t'st_adm_hier'  => 1,\n\t\t\t\t'st_adm_count' => 1,\n\t\t\t)\n\t\t),\n\t\t'section'  => staxo_demo_taxonomy(\n\t\t\t'section',\n\t\t\t'Section',\n\t\t\t'Sections',\n\t\t\tarray(\n\t\t\t\t'hierarchical' => 1,\n\t\t\t\t'objects'      => array( 'post' ),\n\t\t\t\t'st_cc_type'   => 2,\n\t\t\t\t'st_cc_hard'   => 0,\n\t\t\t\t'st_cc_umin'   => 0,\n\t\t\t\t'st_cc_min'    => 0,\n\t\t\t\t'st_cc_umax'   => 1,\n\t\t\t\t'st_cc_max'    => 1,\n\t\t\t)\n\t\t),\n\t);\n\n\t// Extra functions on WordPress's own Tags: an admin list filter, and counts of all posts except trash.\n\t$externals = array(\n\t\t'post_tag' => array(\n\t\t\t'name'         => 'post_tag',\n\t\t\t'hierarchical' => 0,\n\t\t\t'show_ui'      => 1,\n\t\t\t'st_adm_types' => array( 'post' ),\n\t\t\t'st_adm_count' => 1,\n\t\t\t'st_cb_type'   => 1,\n\t\t),\n\t);\n\n\tupdate_option(\n\t\tOPTION_STAXO,\n\t\tarray(\n\t\t\t'taxonomies' => $taxonomies,\n\t\t\t'externals'  => $externals,\n\t\t\t'list_order' => array( 'post' => array( 'genre', 'topic', 'section', 'audience', 'colour', 'category', 'post_tag' ) ),\n\t\t),\n\t\ttrue\n\t);\n\n\t// Register the taxonomies now (normally done on init) so that terms and posts can use them.\n\tSimpleTaxonomyRefreshed_Client::init();\n\tSimpleTaxonomyRefreshed_Client::init_2();\n\tSimpleTaxonomyRefreshed_Client::refresh_term_cntl_cache();\n\n\t// Remove WordPress's sample post and page, so that the site only holds the demo content.\n\tforeach ( array( 'post' => 'hello-world', 'page' => 'sample-page' ) as $post_type => $slug ) {\n\t\t$sample = get_page_by_path( $slug, OBJECT, $post_type );\n\t\tif ( $sample ) {\n\t\t\twp_delete_post( $sample->ID, true );\n\t\t}\n\t}\n\n\t// Terms: the test suite's trees and lists.\n\tstaxo_demo_terms(\n\t\t'genre',\n\t\tarray(\n\t\t\t'Music' => array(\n\t\t\t\t'Jazz' => array(\n\t\t\t\t\t'Bebop'    => array(),\n\t\t\t\t\t'Big Band' => array(),\n\t\t\t\t),\n\t\t\t\t'Rock' => array( 'Punk' => array() ),\n\t\t\t),\n\t\t\t'Art'   => array(\n\t\t\t\t'Painting'  => array(),\n\t\t\t\t'Sculpture' => array(),\n\t\t\t),\n\t\t\t'Misc'  => array(),\n\t\t)\n\t);\n\tstaxo_demo_terms(\n\t\t'topic',\n\t\tarray(\n\t\t\t'Science'    => array(\n\t\t\t\t'Physics' => array(\n\t\t\t\t\t'Astronomy' => array(),\n\t\t\t\t\t'Quantum'   => array(),\n\t\t\t\t),\n\t\t\t\t'Biology' => array( 'Botany' => array() ),\n\t\t\t),\n\t\t\t'Humanities' => array(\n\t\t\t\t'History'    => array(),\n\t\t\t\t'Philosophy' => array(),\n\t\t\t),\n\t\t\t'Misc'       => array(),\n\t\t)\n\t);\n\tstaxo_demo_terms( 'colour', array_fill_keys( array( 'Red', 'Green', 'Blue', 'Yellow', 'Cyan' ), array() ) );\n\tstaxo_demo_terms( 'audience', array_fill_keys( array( 'Beginners', 'Experts', 'Students', 'Teachers', 'Everyone' ), array() ) );\n\tstaxo_demo_terms(\n\t\t'section',\n\t\tarray(\n\t\t\t'News'       => array(),\n\t\t\t'Reviews'    => array(\n\t\t\t\t'Albums'   => array(),\n\t\t\t\t'Concerts' => array(),\n\t\t\t),\n\t\t\t'Interviews' => array(),\n\t\t)\n\t);\n\tstaxo_demo_terms( 'post_tag', array_fill_keys( array( 'live', 'study' ), array() ) );\n\n\t// Posts: the test suite's post matrix, one post for each status.\n\t$posts = array(\n\t\tarray( 'A night of jazz', 'publish', array( 'Jazz' ), array( 'Red', 'Green' ), array( 'Beginners' ), array( 'Physics' ), array( 'News' ), array( 'live' ) ),\n\t\tarray( 'Bebop basics', 'publish', array( 'Bebop' ), array( 'Green' ), array( 'Experts' ), array( 'Astronomy' ), array( 'Albums' ), array( 'study' ) ),\n\t\tarray( 'From jazz to bebop', 'publish', array( 'Jazz', 'Bebop' ), array( 'Blue' ), array( 'Beginners', 'Students' ), array( 'Physics' ), array( 'News' ), array( 'study', 'live' ) ),\n\t\tarray( 'The big band sound', 'publish', array( 'Big Band' ), array( 'Red', 'Blue' ), array( 'Students' ), array(), array( 'Concerts' ), array() ),\n\t\tarray( 'Rock notes (draft)', 'draft', array( 'Rock' ), array( 'Yellow' ), array(), array( 'Biology' ), array(), array() ),\n\t\tarray( 'Punk review (pending)', 'pending', array( 'Punk' ), array( 'Yellow' ), array(), array( 'Botany' ), array(), array() ),\n\t\tarray( 'Painting diary (private)', 'private', array( 'Painting' ), array( 'Cyan' ), array(), array( 'History' ), array(), array() ),\n\t\tarray( 'Sculpture next year (scheduled)', 'future', array( 'Sculpture' ), array(), array(), array( 'Philosophy' ), array(), array() ),\n\t\tarray( 'Old jazz listings (trash)', 'trash', array( 'Jazz' ), array( 'Red' ), array(), array( 'Physics' ), array(), array() ),\n\t);\n\tforeach ( $posts as $post ) {\n\t\t$args = array(\n\t\t\t'post_title'   => $post[0],\n\t\t\t'post_content' => '<!-- wp:paragraph --><p>' . esc_html( $post[0] ) . ': a sample post for Simple Taxonomy Refreshed.</p><!-- /wp:paragraph -->',\n\t\t\t'post_excerpt' => 'A sample post.',\n\t\t\t'post_status'  => ( 'trash' === $post[1] ? 'publish' : $post[1] ),\n\t\t);\n\t\tif ( 'future' === $post[1] ) {\n\t\t\t$args['post_date'] = gmdate( 'Y-m-d H:i:s', time() + YEAR_IN_SECONDS );\n\t\t}\n\t\t$post_id = wp_insert_post( $args );\n\t\tstaxo_demo_set_terms(\n\t\t\t$post_id,\n\t\t\tarray(\n\t\t\t\t'genre'    => $post[2],\n\t\t\t\t'colour'   => $post[3],\n\t\t\t\t'audience' => $post[4],\n\t\t\t\t'topic'    => $post[5],\n\t\t\t\t'section'  => $post[6],\n\t\t\t\t'post_tag' => $post[7],\n\t\t\t)\n\t\t);\n\t\tif ( 'trash' === $post[1] ) {\n\t\t\twp_trash_post( $post_id );\n\t\t}\n\t}\n\n\t// A page with the plugin's blocks and shortcode.\n\t$page_id = wp_insert_post(\n\t\tarray(\n\t\t\t'post_title'   => 'Taxonomy blocks',\n\t\t\t'post_type'    => 'page',\n\t\t\t'post_status'  => 'publish',\n\t\t\t'post_content' => implode(\n\t\t\t\t\"\\n\\n\",\n\t\t\t\tarray(\n\t\t\t\t\t'<!-- wp:paragraph --><p>This page shows the blocks and shortcode of Simple Taxonomy Refreshed.</p><!-- /wp:paragraph -->',\n\t\t\t\t\t'<!-- wp:heading --><h2 class=\"wp-block-heading\">Display Post Terms block</h2><!-- /wp:heading -->',\n\t\t\t\t\t'<!-- wp:simple-taxonomy-refreshed/staxo-terms {\"tax\":\"colour\"} /-->',\n\t\t\t\t\t'<!-- wp:heading --><h2 class=\"wp-block-heading\">Taxonomy Cloud block: cloud</h2><!-- /wp:heading -->',\n\t\t\t\t\t'<!-- wp:simple-taxonomy-refreshed/cloud-widget {\"title\":\"Genres\",\"taxonomy\":\"genre\",\"disptype\":\"cloud\"} /-->',\n\t\t\t\t\t'<!-- wp:heading --><h2 class=\"wp-block-heading\">Taxonomy Cloud block: list</h2><!-- /wp:heading -->',\n\t\t\t\t\t'<!-- wp:simple-taxonomy-refreshed/cloud-widget {\"title\":\"Topics\",\"taxonomy\":\"topic\",\"disptype\":\"list\",\"showcount\":true} /-->',\n\t\t\t\t\t'<!-- wp:heading --><h2 class=\"wp-block-heading\">Shortcode</h2><!-- /wp:heading -->',\n\t\t\t\t\t'<!-- wp:shortcode -->[staxo_post_terms tax=\"colour\"]<!-- /wp:shortcode -->',\n\t\t\t\t)\n\t\t\t),\n\t\t)\n\t);\n\tstaxo_demo_set_terms( $page_id, array( 'colour' => array( 'Red' ) ) );\n\n\t// New rewrite rules for the Genres URL.\n\tset_transient( 'simple_taxonomy_refreshed_rewrite', true, 0 );\n\tflush_rewrite_rules( false );\n}\n\nstaxo_demo_load();\n"
		},
		{
			"step": "login",
			"username": "admin",
			"password": "password"
		}
	]
}
