{
	"$schema": "https://playground.wordpress.net/blueprint-schema.json",
	"meta": {
		"title": "WP Store Locator demo",
		"description": "WP Store Locator with ten demo locations in Amsterdam, color coded by category, on an OpenStreetMap (Leaflet) map.",
		"author": "wpstorelocator",
		"categories": [
			"Maps"
		]
	},
	"landingPage": "/store-locator/",
	"preferredVersions": {
		"php": "8.2",
		"wp": "latest"
	},
	"steps": [
		{
			"step": "login",
			"username": "admin",
			"password": "password"
		},
		{
			"step": "installPlugin",
			"pluginData": {
				"resource": "wordpress.org/plugins",
				"slug": "wp-store-locator"
			},
			"options": {
				"activate": true
			}
		},
		{
			"step": "runPHP",
			"code": "<?php\nrequire_once '/wordpress/wp-load.php';\n\n// Skip the onboarding redirect, the demo is already set up.\ndelete_transient( 'wpsl_onboarding_redirect' );\nupdate_option( 'wpsl_onboarding_finished', 1 );\n\n$settings = wpsl_get_service( 'wpsl_settings' );\n\n// Leaflet with the default OpenStreetMap tiles.\n$api = $settings->get_group( 'api' );\n$api['active_map_service'] = 'osm';\n$settings->update( 'api', $api );\n\n// Start in Amsterdam.\n$map = $settings->get_group( 'map' );\n$map['start_name']   = 'Amsterdam, Netherlands';\n$map['start_latlng'] = '52.3676,4.9041';\n$map['zoom_level']   = 12;\n$settings->update( 'map', $map );\n\n// Don't ask for the visitor's location, they would end up far away from the demo stores.\n$search = $settings->get_group( 'search' );\n$search['auto_locate']     = false;\n$search['category_filter'] = true;\n$settings->update( 'search', $search );\n\n// Show the categories, with their color, in the search results.\n$appearance = $settings->get_group( 'appearance' );\n$appearance['map_style']['osm']['tile_source'] = 'default';\n$appearance['categories']['enabled']           = 1;\n\n// The vertical template keeps its own font sizes, the default one takes them from the theme.\n$appearance['template_id'] = 'vertical';\n$settings->update( 'appearance', $appearance );\n\n// Categories with their color.\n$categories = [\n\t'italian' => [ 'Italian Food', '#00a32a' ],\n\t'fast'    => [ 'Fast Food', '#e26f1e' ],\n\t'asian'   => [ 'Asian Food', '#d63638' ],\n\t'coffee'  => [ 'Coffee & Bakery', '#7e57c2' ],\n];\n\n$term_ids = [];\n\nforeach ( $categories as $key => $category ) {\n\t$term = wp_insert_term( $category[0], 'wpsl_store_category' );\n\n\tif ( ! is_wp_error( $term ) ) {\n\t\t$term_ids[ $key ] = (int) $term['term_id'];\n\t\tupdate_term_meta( $term['term_id'], 'wpsl_category_color', $category[1] );\n\t}\n}\n\n// Demo stores with coordinates, so nothing has to be geocoded.\n$stores = [\n\t[ 'Pasta Piccola', 'Utrechtsestraat 50', '1017 VP', 52.3627, 4.8973, [ 'italian' ] ],\n\t[ 'Trattoria del Canale', 'Prinsengracht 300', '1016 HX', 52.3713, 4.8834, [ 'italian' ] ],\n\t[ 'Pizzeria Jordaan', 'Westerstraat 100', '1015 MN', 52.3784, 4.8815, [ 'italian', 'fast' ] ],\n\t[ 'Burger Corner', 'Damrak 50', '1012 LL', 52.3757, 4.8960, [ 'fast' ] ],\n\t[ 'Frites Express', 'Leidsestraat 20', '1017 PA', 52.3655, 4.8851, [ 'fast' ] ],\n\t[ 'Noodle Box', 'Zeedijk 80', '1012 BA', 52.3740, 4.9010, [ 'asian', 'fast' ] ],\n\t[ 'Sushi Oost', 'Javastraat 40', '1094 HB', 52.3630, 4.9390, [ 'asian' ] ],\n\t[ 'Koffie & Co', 'Kinkerstraat 150', '1053 EB', 52.3667, 4.8680, [ 'coffee' ] ],\n\t[ 'Bakkerij De Pijp', 'Ferdinand Bolstraat 60', '1072 LM', 52.3555, 4.8920, [ 'coffee' ] ],\n\t[ 'Cafe Noord', 'Buiksloterweg 5', '1031 CC', 52.3840, 4.9020, [ 'coffee' ] ],\n];\n\nforeach ( $stores as $store ) {\n\t$store_id = wp_insert_post( [\n\t\t'post_type'   => 'wpsl_stores',\n\t\t'post_status' => 'publish',\n\t\t'post_title'  => $store[0],\n\t\t'meta_input'  => [\n\t\t\t'wpsl_address' => $store[1],\n\t\t\t'wpsl_city'    => 'Amsterdam',\n\t\t\t'wpsl_zip'     => $store[2],\n\t\t\t'wpsl_country' => 'Netherlands',\n\t\t\t'wpsl_lat'     => $store[3],\n\t\t\t'wpsl_lng'     => $store[4],\n\t\t\t'wpsl_phone'   => '+31 20 000 0000',\n\t\t],\n\t] );\n\n\t$store_terms = array_values( array_intersect_key( $term_ids, array_flip( $store[5] ) ) );\n\n\tif ( $store_id && $store_terms ) {\n\t\twp_set_object_terms( $store_id, $store_terms, 'wpsl_store_category' );\n\t}\n}\n\nif ( function_exists( 'wpsl_flush_store_cache' ) ) {\n\twpsl_flush_store_cache();\n}\n\n// Front-end page with the store locator.\nwp_insert_post( [\n\t'post_type'    => 'page',\n\t'post_status'  => 'publish',\n\t'post_title'   => 'Store Locator',\n\t'post_name'    => 'store-locator',\n\t'post_content' => '<!-- wp:shortcode -->[wpsl]<!-- /wp:shortcode -->',\n] );\n"
		}
	]
}
