> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wp-content.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Initialize a new plugin

> wpc plugin init

Create a folder named after the plugin slug, with a minimal `<slug>.php` carrying the plugin headers. On a terminal, anything you leave out is asked for by a short wizard; with `--no-interaction` (`-n`), nothing is asked.

## Usage

```bash theme={null}
wpc plugin init [options] [--] [<name> [<slug>]]
```

## Arguments

<ParamField body="name" type="string">
  Name of the plugin. Asked for when it is missing; with `--no-interaction`, a missing name fails with exit code `2`.
</ParamField>

<ParamField body="slug" type="string">
  Folder name and slug of the plugin. Always normalized to a slug (`my_plugin` becomes `my-plugin`); when omitted, it is derived from the name.
</ParamField>

## Options

The options allow you to set the information in your plugin’s header ([see the WordPress documentation](https://developer.wordpress.org/plugins/plugin-basics/header-requirements/)).

<ParamField body="--plugin-uri" type="string">
  Plugin URI plugin header
</ParamField>

<ParamField body="--description" type="string">
  Description plugin header
</ParamField>

<ParamField body="--plugin-version" type="string" default="1.0.0">
  Version plugin header
</ParamField>

<ParamField body="--requires-at-least" type="string">
  Requires at least plugin header
</ParamField>

<ParamField body="--requires-php" type="string">
  Requires PHP plugin header
</ParamField>

<ParamField body="--author" type="string">
  Author plugin header
</ParamField>

<ParamField body="--author-uri" type="string">
  Author URI plugin header
</ParamField>

<ParamField body="--license" type="string">
  License plugin header
</ParamField>

<ParamField body="--license-uri" type="string">
  License URI plugin header
</ParamField>

<ParamField body="--text-domain" type="string">
  Text Domain plugin header
</ParamField>

<ParamField body="--domain-path" type="string">
  Domain Path plugin header
</ParamField>

<ParamField body="--network" type="string">
  Network plugin header
</ParamField>

<ParamField body="--no-interaction" type="boolean">
  Do not ask any interactive question
</ParamField>

## Interactive mode

On a terminal, `wpc plugin init` opens a wizard:

1. **Plugin name**, unless you passed it.
2. **Headers to edit**: a checklist of the optional headers. The ones that already have a value are ticked: the options you passed, `Version` (`1.0.0`) and the author details known to your organization (`Author`, `Author URI`).
3. One question per ticked header, pre-filled with its current value.

Press <kbd>esc</kbd> at any step to abandon: nothing is written.

<Note>
  The registry refuses to publish a plugin without an `Author` header. If your
  organization has no author details, or `wpc` has no API key to look them up,
  pass `--author` yourself.
</Note>

Options passed on the command line are never overwritten by these defaults. With `--no-interaction`, the same defaults fill in the headers you did not pass, without asking.

Outside a terminal (piped input, CI), or with `--output=plain` or `WPC_NO_TUI=1`, the same questions are asked line by line instead, after a `Would you like to define plugin additional headers ? [N/y]` confirmation.

## Examples

<Tabs>
  <Tab title="Create a plugin without any interaction">
    <CodeGroup>
      ```bash Input theme={null}
      $ cd /Users/me/Wordpress/wp-content/plugins/

      $ wpc plugin init --author="Acme" --author-uri="https://example.com" --no-interaction "Dummy Plugin" dummy
      ┌──────┬──────────────────────────────────────────────┐
      │ path │ /Users/me/Wordpress/wp-content/plugins/dummy │
      └──────┴──────────────────────────────────────────────┘
      ```

      ```php Output file: dummy/dummy.php theme={null}
      <?php
       /**
       * Plugin Name: Dummy Plugin
       * Description:
       * Version: 1.0.0
       * Author: Acme
       * Author URI: https://example.com
       * Update URI: https://registry.wp-content.io
       *
       * Generated by WPC-CLI Generator (https://wp-content.io).
       */
      ```

      ```json Output with --output=json theme={null}
      {"path":"/Users/me/Wordpress/wp-content/plugins/dummy"}
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Answer the questions line by line">
    <CodeGroup>
      ```bash Input theme={null}
      $ wpc plugin init --output=plain
      Plugin name: <Dummy Plugin>
      Would you like to define plugin additional headers ? [N/y] <y>
      Version (1.0.0): <1.0.1>
      Author (Acme): <>
      Author URI (https://example.com): <>
      Plugin URI: <>
      Description: <Lorem ipsum dolor sit amet>
      Requires at least: <6.4>
      Requires PHP: <8.2>
      License: <>
      License URI: <>
      Text Domain: <dummy>
      Domain Path: <>
      Network: <>
      ┌──────┬──────────────────────────────────────────────┐
      │ path │ /Users/me/Wordpress/wp-content/plugins/dummy │
      └──────┴──────────────────────────────────────────────┘
      ```

      ```php Output file: dummy/dummy.php theme={null}
      <?php
       /**
       * Plugin Name: Dummy Plugin
       * Description: Lorem ipsum dolor sit amet
       * Version: 1.0.1
       * Author: Acme
       * Author URI: https://example.com
       * Requires at least: 6.4
       * Requires PHP: 8.2
       * Text Domain: dummy
       * Update URI: https://registry.wp-content.io
       *
       * Generated by WPC-CLI Generator (https://wp-content.io).
       */
      ```
    </CodeGroup>
  </Tab>
</Tabs>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.