diff --git a/packages/docs/site/i18n/ja/docusaurus-plugin-content-docs/current/main/guides/providing-content-for-your-demo.md b/packages/docs/site/i18n/ja/docusaurus-plugin-content-docs/current/main/guides/providing-content-for-your-demo.md new file mode 100644 index 0000000000..602ab58e56 --- /dev/null +++ b/packages/docs/site/i18n/ja/docusaurus-plugin-content-docs/current/main/guides/providing-content-for-your-demo.md @@ -0,0 +1,274 @@ +--- +title: Playground でデモ用のコンテンツを提供する +slug: /guides/providing-content-for-your-demo +description: WordPress Playground でデモ用のコンテンツを提供する +--- + +WordPress Playground で優れたデモを提供するために、プラグインやテーマの機能をわかりやすく示すために、デフォルトのコンテンツを読み込むことをお勧めします。このデフォルトコンテンツには、画像やその他のアセットが含まれる場合があります。 + + + +Playground インスタンスにコンテンツをインポート (または生成) するために使用できる [ブループリントのステップ](/blueprints/steps) と方策がいくつかあります。 + + + +## `importWxr` + +[`importWxr`](/blueprints/steps#importWxr) ステップを使用すると、以前に [既存の WordPress インストールからエクスポートされた](https://wordpress.org/documentation/article/tools-export-screen/) `.xml` ファイルを介して独自のコンテンツをインポートできます。 + + + +```json +"steps": [ + ..., + { + "step": "importWxr", + "file": { + "resource": "url", + "url": "https://raw.githubusercontent.com/WordPress/blueprints/trunk/blueprints/install-activate-setup-theme-from-gh-repo/blueprint-content.xml" + } + }, + ... +] +``` + +[   Run Blueprint   ](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/install-activate-setup-theme-from-gh-repo/blueprint.json)   [   See blueprint.json   ](https://github.com/WordPress/blueprints/blob/eb6da7dfa295a095eea2e424c0ae83a219803a8d/blueprints/install-activate-setup-theme-from-gh-repo/blueprint.json#L43) + +:::info +インポートしたコンテンツに画像を含めるには、画像を GitHub リポジトリにアップロードし、URL 形式 `https://raw.githubusercontent.com/{repo}/{branch}/{image_path}` を使用して、エクスポートされた `.xml` ファイル内の画像のパスを検索/置換するのが良い方法です。 + + + +```html + +
+ +
+ +``` + +::: + +エクスポートした `.xml` ファイルと参照されているアセット (画像など) を、GitHub リポジトリ内の `blueprint.json` と同じディレクトリにアップロードすることをお勧めします。 + + + +## `importWordPressFiles` + +[`importWordPressFiles`](/blueprints/steps#importWordPressFiles) ステップを使用すると、指定された `.zip` ファイルから独自のトップレベル WordPress ファイルをインスタンスのルートフォルダにインポートできます。例えば、`.zip` ファイルに `wp-content` ディレクトリと `wp-includes` ディレクトリが含まれている場合、Playground のルートフォルダ内の対応するディレクトリが置き換えられます。 + + + +この `zip` ファイルは、[Playground オプション メニュー](/web-instance#playground-options-menu) の「zip としてダウンロード」オプションを使用して、任意の Playground インスタンスから作成できます。 + + + +Playground インスタンスで WordPress テーマまたはプラグインのデモ(画像やその他のアセットを含む)を準備し、そのデモのスナップショットを`.zip`ファイルにエクスポートできます。このファイルは、後で`importWordPressFiles`ステップを使用してインポートできます。 + + + +```json +{ + "landingPage": "/", + "login": true, + "steps": [ + { + "step": "importWordPressFiles", + "wordPressFilesZip": { + "resource": "url", + "url": "https://raw.githubusercontent.com/adamziel/playground-sites/main/playground-for-site-builders/playground.zip" + } + } + ] +} +``` + +[   Run Blueprint   ](https://playground.wordpress.net/builder/builder.html#{%22landingPage%22:%22/%22,%22login%22:true,%22steps%22:[{%22step%22:%22importWordPressFiles%22,%22wordPressFilesZip%22:{%22resource%22:%22url%22,%22url%22:%22https://raw.githubusercontent.com/adamziel/playground-sites/main/playground-for-site-builders/playground.zip%22}}]}) + +## `importThemeStarterContent` + +[一部のテーマにはスターターコンテンツ](https://make.wordpress.org/core/2016/11/30/starter-content-for-themes-in-4-7/)があり、公開してテーマの機能を強調することができます。 + + + +[`importThemeStarterContent` ステップ](/blueprints/steps#importThemeStarterContent) を使用すると、そのテーマが Playground インスタンスでアクティブ化されていないものであっても、任意のテーマのスターター コンテンツを公開できます。 + + + +```json + +"steps": [ + { + "step": "installTheme", + "themeData": { + "resource": "wordpress.org/themes", + "slug": "twentytwenty" + } + }, + { + "step": "installTheme", + "themeData": { + "resource": "wordpress.org/themes", + "slug": "twentytwentyone" + }, + "options": { + "activate": true + } + }, + { + "step": "importThemeStarterContent", + "themeSlug": "twentytwenty" + } + ] + +``` + +[   Run Blueprint   ](https://playground.wordpress.net/builder/builder.html#{%22steps%22:[{%22step%22:%22installTheme%22,%22themeData%22:{%22resource%22:%22wordpress.org/themes%22,%22slug%22:%22twentytwenty%22}},{%22step%22:%22installTheme%22,%22themeData%22:{%22resource%22:%22wordpress.org/themes%22,%22slug%22:%22twentytwentyone%22},%22options%22:{%22activate%22:true}},{%22step%22:%22importThemeStarterContent%22,%22themeSlug%22:%22twentytwenty%22}]}) + +[`installTheme` ステップ](/blueprints/steps#installTheme)でテーマをインストールするときに、`importStarterContent` オプションを `true` に設定することで、テーマのスターター コンテンツを公開することもできます。 + + + +```json +{ + "steps": [ + { + "step": "installTheme", + "themeData": { + "resource": "wordpress.org/themes", + "slug": "twentytwenty" + }, + "options": { + "activate": true, + "importStarterContent": true + } + } + ] +} +``` + +[   Run Blueprint   ](https://playground.wordpress.net/builder/builder.html#{%22steps%22:[{%22step%22:%22installTheme%22,%22themeData%22:{%22resource%22:%22wordpress.org/themes%22,%22slug%22:%22twentytwenty%22},%22options%22:{%22activate%22:true,%22importStarterContent%22:true}}]}) + +## `wp-cli` + +テーマやプラグインのコンテンツを生成するもう 1 つの方法は、`wp-cli` ステップを使用することです。このステップでは、[`wp post generate`](https://developer.wordpress.org/cli/commands/post/generate/) などの [WP-CLI コマンド](https://developer.wordpress.org/cli/commands/) を実行できます。 + + + +```json +{ + "landingPage": "/wp-admin/edit.php", + "login": true, + "steps": [ + { + "step": "wp-cli", + "command": "wp post generate --count=20 --post_type=post --post_date=1999-01-04" + } + ] +} +``` + +[   Run Blueprint   ](https://playground.wordpress.net/builder/builder.html#{%22landingPage%22:%22/wp-admin/edit.php%22,%22login%22:true,%22steps%22:[{%22step%22:%22wp-cli%22,%22command%22:%22wp%20post%20generate%20--count=20%20--post_type=post%20--post_date=1999-01-04%22}]}) + +また、`wp-cli` ステップを `writeFile` ステップと組み合わせて使用 ​​ して、既存のコンテンツに基づいて投稿を作成し、Playground インスタンスに画像をインポートすることもできます。 + + + +```json +{ + "$schema": "https://playground.wordpress.net/blueprint-schema.json", + "landingPage": "/?p=4", + "login": true, + "steps": [ + { + "step": "writeFile", + "path": "/wordpress/wp-content/postcontent.md", + "data": { + "resource": "url", + "url": "https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/wpcli-post-with-image/postcontent.md" + } + }, + { + "step": "wp-cli", + "command": "wp post create --post_title='Welcome to Playground' --post_status='published' /wordpress/wp-content/postcontent.md" + }, + { + "step": "writeFile", + "path": "/wordpress/wp-content/Select-storage-method.png", + "data": { + "resource": "url", + "url": "https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/wpcli-post-with-image/Select-storage-method.png" + } + }, + { + "step": "wp-cli", + "command": "wp media import wordpress/wp-content/Select-storage-method.png --post_id=4 --title='Select your storage method' --featured_image" + } + ] +} +``` + +[   Run Blueprint   ](https://playground.wordpress.net/builder/builder.html#{%22$schema%22:%22https://playground.wordpress.net/blueprint-schema.json%22,%22meta%22:{%22title%22:%22Use%20wp-cli%20to%20add%20a%20post%20with%20image%22,%22description%22:%22Use%20wp-cli%20to%20create%20a%20post%20from%20text%20file%20with%20block%20markup%20and%20a%20featured%20image%22,%22author%22:%22bph%22,%22categories%22:[%22Content%22,%22wpcli%22]},%22landingPage%22:%22/?p=4%22,%22login%22:true,%22steps%22:[{%22step%22:%22writeFile%22,%22path%22:%22/wordpress/wp-content/postcontent.md%22,%22data%22:{%22resource%22:%22url%22,%22url%22:%22https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/wpcli-post-with-image/postcontent.md%22}},{%22step%22:%22wp-cli%22,%22command%22:%22wp%20post%20create%20--post_title='Welcome%20to%20Playground'%20--post_status='published'%20/wordpress/wp-content/postcontent.md%22},{%22step%22:%22writeFile%22,%22path%22:%22/wordpress/wp-content/Select-storage-method.png%22,%22data%22:{%22resource%22:%22url%22,%22url%22:%22https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/wpcli-post-with-image/Select-storage-method.png%22}},{%22step%22:%22wp-cli%22,%22command%22:%22wp%20media%20import%20wordpress/wp-content/Select-storage-method.png%20--post_id=4%20--title='Select%20your%20storage%20method'%20--featured_image%22}]}) + +:::tip + +コンテンツとアイキャッチ画像の関係を示す完全な例を確認するには、[Blueprints ギャラリー](https://github.com/WordPress/blueprints/blob/trunk/GALLERY.md) の ["wp-cli を使用して画像付きの投稿を追加する"](https://github.com/WordPress/blueprints/tree/trunk/blueprints/wpcli-post-with-image) の例を確認してください。 + +::: + + + +## `runPHP` + +[`runPHP` ステップ](https://wordpress.github.io/wordpress-playground/blueprints/steps#runPHP) を使用すると、たとえば [`wp_insert_post` 関数](https://developer.wordpress.org/reference/functions/wp_insert_post/) を使用して、WordPress インストールに情報を挿入するために必要な PHP コードを実行できます。 + + + +```json +{ + "landingPage": "/wp-admin/edit.php", + "login": true, + "steps": [ + { + "step": "runPHP", + "code": " 'Simple post from PHP', 'post_content' => '

This is a simple post inserted with wp_insert_post

', 'post_author' => 1, 'post_status' => 'publish')); ?>" + } + ] +} +``` + +[   Run Blueprint   ]()