メインコンテンツへスキップ

@wp-playground/blueprints

Index

Type Aliases

Blueprint

BlueprintBundle

BlueprintBundle: Filesystem

A filesystem structure containing a /blueprint.json file and any resources referenced by that blueprint.

BlueprintDeclaration

BlueprintDeclaration: { constants?: PHPConstants; description?: string; extraLibraries?: ExtraLibrary[]; features?: { networking?: boolean }; landingPage?: string; login?: boolean | { password: string; username: string }; meta?: { author: string; categories?: string[]; description?: string; title: string }; phpExtensionBundles?: any; plugins?: (string | FileReference)[]; preferredVersions?: { php: SupportedPHPVersion | latest; wp: string | latest }; siteOptions?: Record<string, string> & { blogname?: string }; steps?: (StepDefinition | string | undefined | false | null)[] }

The Blueprint declaration, typically stored in a blueprint.json file.


Type declaration

  • optionalconstants?: PHPConstants

    PHP Constants to define on every request

  • optionaldescription?: string

    Optional description. It doesn't do anything but is exposed as a courtesy to developers who may want to document which blueprint file does what.

    @deprecated

    Use meta.description instead.

  • optionalextraLibraries?: ExtraLibrary[]

    Extra libraries to preload into the Playground instance.

  • optionalfeatures?: { networking?: boolean }
    • optionalnetworking?: boolean

      Should boot with support for network request via wp_safe_remote_get?

  • optionallandingPage?: string

    The URL to navigate to after the blueprint has been run.

  • optionallogin?: boolean | { password: string; username: string }

    User to log in as. If true, logs the user in as admin/password.

  • optionalmeta?: { author: string; categories?: string[]; description?: string; title: string }

    Optional metadata. Used by the Blueprints gallery at https://github.com/WordPress/blueprints

    • author: string

      A GitHub username of the author of this Blueprint.

    • optionalcategories?: string[]

      Relevant categories to help users find your Blueprint in the future Blueprints section on WordPress.org.

    • optionaldescription?: string

      A brief explanation of what your Blueprint offers.

    • title: string

      A clear and concise name for your Blueprint.

  • optionalphpExtensionBundles?: any
    @deprecated

    No longer used. Feel free to remove it from your Blueprint.

  • optionalplugins?: (string | FileReference)[]

    WordPress plugins to install and activate

  • optionalpreferredVersions?: { php: SupportedPHPVersion | latest; wp: string | latest }

    The preferred PHP and WordPress versions to use.

    • php: SupportedPHPVersion | latest

      The preferred PHP version to use. If not specified, the latest supported version will be used

    • wp: string | latest

      The preferred WordPress version to use. If not specified, the latest supported version will be used

  • optionalsiteOptions?: Record<string, string> & { blogname?: string }

    WordPress site options to define

  • optionalsteps?: (StepDefinition | string | undefined | false | null)[]

    The steps to run after every other operation in this Blueprint was executed.

CompiledStep

CompiledStep: (php: UniversalPHP) => Promise<void> | void

Type declaration

CorePluginReference

CorePluginReference: { resource: wordpress.org/plugins; slug: string }

Type declaration

  • resource: wordpress.org/plugins

    Identifies the file resource as a WordPress Core plugin

  • slug: string

    The slug of the WordPress Core plugin

CoreThemeReference

CoreThemeReference: { resource: wordpress.org/themes; slug: string }

Type declaration

  • resource: wordpress.org/themes

    Identifies the file resource as a WordPress Core theme

  • slug: string

    The slug of the WordPress Core theme

FileReference

GenericStep

GenericStep<FileResource, DirectoryResource>: ActivatePluginStep | ActivateThemeStep | CpStep | DefineWpConfigConstsStep | DefineSiteUrlStep | EnableMultisiteStep | ImportWxrStep<FileResource> | ImportThemeStarterContentStep | ImportWordPressFilesStep<FileResource> | InstallPluginStep<FileResource, DirectoryResource> | InstallThemeStep<FileResource, DirectoryResource> | LoginStep | MkdirStep | MvStep | ResetDataStep | RequestStep | RmStep | RmdirStep | RunPHPStep | RunPHPWithOptionsStep | RunWpInstallationWizardStep | RunSqlStep<FileResource> | SetSiteOptionsStep | UnzipStep<FileResource> | UpdateUserMetaStep | WriteFileStep<FileResource> | WriteFilesStep<DirectoryResource> | WPCLIStep | SetSiteLanguageStep

If you add a step here, make sure to also add it to the exports below.


Type parameters

  • FileResource
  • DirectoryResource

LiteralReference

LiteralReference: { contents: string | Uint8Array; name: string; resource: literal }

Type declaration

  • contents: string | Uint8Array

    The contents of the file

  • name: string

    The name of the file

  • resource: literal

    Identifies the file resource as a literal file

LoginStep

LoginStep: { password?: string; step: login; username?: string }

Logs in to Playground. Under the hood, this function sets the PLAYGROUND_AUTO_LOGIN_AS_USER constant. The 0-auto-login.php mu-plugin uses that constant to log in the user on the first load. This step depends on the @wp-playground/wordpress package because the plugin is located in and loaded automatically by the @wp-playground/wordpress package.

@hasRunnableExample
@example
<code>
{
"step": "login",
"username": "admin",
}
</code>

Type declaration

  • optionalpassword?: string
    @deprecated

    The password field is deprecated and will be removed in a future version. Only the username field is required for user authentication.

  • step: login
  • optionalusername?: string

    The user to log in as. Defaults to 'admin'.

OnStepCompleted

OnStepCompleted: (output: any, step: StepDefinition) => any

Type declaration

PHPConstants

PHPConstants: Record<string, string | boolean | number>

SetSiteOptionsStep

SetSiteOptionsStep: { options: Record<string, unknown>; step: setSiteOptions }

Sets site options. This is equivalent to calling update_option for each option in the options object.

@hasRunnableExample
@example
<code>
{
"step": "setSiteOptions",
"options": {
"blogname": "My Blog",
"blogdescription": "A great blog"
}
}
</code>

Type declaration

  • options: Record<string, unknown>

    The options to set on the site.

  • step: setSiteOptions

    The name of the step. Must be "setSiteOptions".

Step

Step: GenericStep<FileReference, DirectoryReference>

StepDefinition

StepDefinition: Step & { progress?: { caption?: string; weight?: number } }

StepHandler

StepHandler<S, Return>: (php: UniversalPHP, args: Omit<S, step>, progressArgs?: StepProgress) => Return

Type parameters

Type declaration

StepProgress

StepProgress: { initialCaption?: string; tracker: ProgressTracker }

Progress reporting details.


Type declaration

UrlReference

UrlReference: { caption?: string; resource: url; url: string }

Type declaration

  • optionalcaption?: string

    Optional caption for displaying a progress message

  • resource: url

    Identifies the file resource as a URL

  • url: string

    The URL of the file

VFSReference

VFSReference: { path: string; resource: vfs }

Type declaration

  • path: string

    The path to the file in the VFS

  • resource: vfs

    Identifies the file resource as Virtual File System (VFS)

Variables

constResourceTypes

ResourceTypes: readonly [vfs, literal, wordpress.org/themes, wordpress.org/plugins, url, git:directory, bundled] = ...

constwpContentFilesExcludedFromExport

wpContentFilesExcludedFromExport: string[] = ...

Used by the export step to exclude the Playground-specific files from the zip file. Keep it in sync with the list of files created by WordPressPatcher.