You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: how-to-create-custom-plugins.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
-
##How to create a custom plugin:
1
+
# How to create a custom plugin:
2
2
3
3
If you want to create your plugins, WP-CLI has a powerful scaffold command that allows us to generate starter code. In this guide we will see how to generate starter code for a basic plugin.
4
4
5
-
###Step 1 - Scaffold the plugin files
5
+
## Step 1 - Scaffold the plugin files
6
6
7
7
The following command uses several options to lets us specify the plugin slug, its name, description, author name and uri as well as the plugin uri. You can replace the values passed to the options below to customize the plugin based on your needs.
8
8
@@ -34,7 +34,7 @@ Unless you use the --skip-tests flag the following files are always generated:
34
34
-`tests/test-sample.php` is a sample file containing test cases.
35
35
-`.phpcs.xml.dist` is a collection of PHP_CodeSniffer rules.
36
36
37
-
###Step 2 - create a custom post type:
37
+
## Step 2 - create a custom post type:
38
38
39
39
We can now use the scaffold command again to add a custom post type inside our new plugin using the `wp scaffold post-type` command.
40
40
@@ -43,7 +43,7 @@ We can now use the scaffold command again to add a custom post type inside our n
43
43
Success: Created '/wpcli-demo-plugin/post-types/books.php'.
44
44
```
45
45
46
-
###Step 3 - Write code inside the main file:
46
+
## Step 3 - Write code inside the main file:
47
47
48
48
The main plugin file `wpcli-demo-plugin.php` is the starting point that we can use to write our plugin logic.
49
49
@@ -57,7 +57,7 @@ and under the line saying "your code starts here" add the following:
57
57
require('post-types/books.php');
58
58
```
59
59
60
-
###Step 4 - Activate the plugin
60
+
## Step 4 - Activate the plugin
61
61
62
62
You can now use two wp-cli commands to check the list of plugins and activate your newly created plugin.
63
63
`wp plugin list` and `wp plugin activate`. The first command lists all plugins installed while the second
0 commit comments