Skip to content

Commit

Permalink
Import a stand-alone starter content file (#82)
Browse files Browse the repository at this point in the history
- Write the content of the file starter-content.php into the plugin
directory
- Active the plugin 
- Use the "importThemeStarterContent" step. 
- User lands on home page and can see the starter content on the "Our
Subscriptions" page.
![Screenshot 2024-11-27 at 17 15
37](https://github.com/user-attachments/assets/40dcd4b2-9fbe-4c16-875b-b93861c6c025)



Thank you to @bgrgicak + @juanmaguitar for inspiration.
Thank you to @zaerl for reviews
  • Loading branch information
bph authored Nov 29, 2024
1 parent 090b149 commit ad285e8
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
1 change: 1 addition & 0 deletions GALLERY.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Here's the list of all the community Blueprints submitted to this repository. Se
| Display Admin Notice | Blueprint to add a tiny mu-plugin and display an admin notice | [@bph](https://github.com/bph) |[Open in Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/admin-notice/blueprint.json)<br>• [View source](https://github.com/wordpress/blueprints/blob/trunk/blueprints/admin-notice/blueprint.json)<br>• [Edit](https://playground.wordpress.net/builder/builder.html?blueprint-url=https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/admin-notice/blueprint.json) |
| Grid Variations Experiments enabled | Blueprint example to toggle on enable a feature from the Experiments page in Gutenberg plugin | [@bph](https://github.com/bph) |[Open in Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/grid-variations/blueprint.json)<br>• [View source](https://github.com/wordpress/blueprints/blob/trunk/blueprints/grid-variations/blueprint.json)<br>• [Edit](https://playground.wordpress.net/builder/builder.html?blueprint-url=https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/grid-variations/blueprint.json) |
| Import Theme Starter Content | Blueprint to install a theme with starter content, (here: Twenty-Twenty-One) | [@bph](https://github.com/bph) |[Open in Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/themestartercontent/blueprint.json)<br>• [View source](https://github.com/wordpress/blueprints/blob/trunk/blueprints/themestartercontent/blueprint.json)<br>• [Edit](https://playground.wordpress.net/builder/builder.html?blueprint-url=https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/themestartercontent/blueprint.json) |
| Import a standalone starter content | Import a standalone starter content using a blueprint step | [@bph](https://github.com/bph) |[Open in Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/file-starter-content/blueprint.json)<br>• [View source](https://github.com/wordpress/blueprints/blob/trunk/blueprints/file-starter-content/blueprint.json)<br>• [Edit](https://playground.wordpress.net/builder/builder.html?blueprint-url=https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/file-starter-content/blueprint.json) |
| Install WordPress language packs | Installs and activates the latest WordPress Japanese translation pack from https://translate.wordpress.org/ – both for WordPress core and for the friends plugin. | [@adamziel](https://github.com/adamziel) |[Open in Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/translations/blueprint.json)<br>• [View source](https://github.com/wordpress/blueprints/blob/trunk/blueprints/translations/blueprint.json)<br>• [Edit](https://playground.wordpress.net/builder/builder.html?blueprint-url=https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/translations/blueprint.json) |
| Install plugin from a gist | Install and activate a WordPress plugin from a .php file stored in a gist. | [@zieladam](https://github.com/zieladam) |[Open in Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/install-plugin-from-gist/blueprint.json)<br>• [View source](https://github.com/wordpress/blueprints/blob/trunk/blueprints/install-plugin-from-gist/blueprint.json)<br>• [Edit](https://playground.wordpress.net/builder/builder.html?blueprint-url=https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/install-plugin-from-gist/blueprint.json) |
| Latest Gutenberg plugin | A preview of the latest version of the Gutenberg plugin. | [@zieladam](https://github.com/zieladam) |[Open in Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/latest-gutenberg/blueprint.json)<br>• [View source](https://github.com/wordpress/blueprints/blob/trunk/blueprints/latest-gutenberg/blueprint.json)<br>• [Edit](https://playground.wordpress.net/builder/builder.html?blueprint-url=https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/latest-gutenberg/blueprint.json) |
Expand Down
30 changes: 30 additions & 0 deletions blueprints/file-starter-content/blueprint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "https://playground.wordpress.net/blueprint-schema.json",
"meta": {
"title": "Import a standalone starter content via a blueprint step",
"author": "bph",
"description": "Blueprint to use a stand-alone starter content file and then to import it. Click on 'Subscriptions'",
"categories": ["Themes", "Starter Content"]
},
"landingPage": "/",
"features": {
"networking": true
},
"steps": [
{
"step": "writeFile",
"path": "/wordpress/wp-content/plugins/starter-content.php",
"data": {
"resource": "url",
"url": "https://raw.githubusercontent.com/wordpress/blueprints/filestartercontent/blueprints/file-starter-content/startercontent.php"
}
},
{
"step": "activatePlugin",
"pluginPath": "/wordpress/wp-content/plugins/starter-content.php"
},
{
"step": "importThemeStarterContent"
}
]
}
35 changes: 35 additions & 0 deletions blueprints/file-starter-content/startercontent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/*
Plugin Name: Short Starter Content Example
Description: This plugin adds a starter content to a Playground instance. Used as part of a Playground Blueprint example.
Author: Birgit Pauli-Haack
Version: 0.0.1
*/
/**
* To learn more about Starter Content for Themes read: https://make.wordpress.org/core/2016/11/30/starter-content-for-themes-in-4-7/
*/
add_action( 'after_setup_theme', function() {
add_theme_support( 'starter-content', array(
'posts' => array(
'homepage-section' => array(
'post_type' => 'page',
'post_title' => _x( 'Our Subscriptions', 'Theme starter content', 'your-text-domain' ),
'post_content' => '<!-- wp:group {"layout":{"type":"constrained"}} -->
<div class="wp-block-group"><!-- wp:heading {"textAlign":"center"} -->
<!-- /wp:heading -->
<!-- wp:paragraph {"align":"center","style":{"typography":{"fontSize":"1.125rem"},"spacing":{"margin":{"top":"var:preset|spacing|10"}}}} -->
<p class="has-text-align-center" style="margin-top:var(--wp--preset--spacing--10);font-size:1.125rem">We offer two subscription levels: </p>
<!-- /wp:paragraph -->
<!-- wp:list -->
<ul class="wp-block-list"><!-- wp:list-item -->
<li><strong><em>Free</em> at $0</strong> - Access to 5 exclusive <em>Études Articles</em> per month.</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li><strong><em>Connoisseur</em> at $12</strong> - Access to 20 exclusive <em>Études Articles</em> per month.<br></li>
<!-- /wp:list-item --></ul>
<!-- /wp:list --></div>
<!-- /wp:group -->'
),
),
) );
} );

0 comments on commit ad285e8

Please sign in to comment.