-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwp-cli-workshop.sh
137 lines (86 loc) · 3.13 KB
/
wp-cli-workshop.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
# Slides From the Workshop
# https://www.slideshare.net/4nd4p0p/wpcli-workshop-at-wordpress-meetup-clujnapoca
# WP-CLI example
# Download WP-CLI
# curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
# check to make sure it worked
# php wp-cli.phar --info
# make it executable
# sudo chmod +x wp-cli.phar
# set file to path :$wp
# sudo mv wp-cli.phar /usr/local/bin/wp
# test that it's working
# wp --info
# ------CORE------
# download WordPress
wp core download
# build the wp-config.php file
wp core config --dbname=anda --dbuser=root --dbpass=pass --dbhost=localhost --dbprefix=an_
# run install
wp core install --url=anda.local --title="Anda's Demo Site" --admin_user=admin --admin_password=password [email protected]
# ------ OPTIONS ------
# list options that begin with site
wp option list --search="blog*"
wp option update blogdescription "Oh that was so fast!"
# discourage search engines
# wp option update blog_public 0
# ------POSTS------
# Generate some dummy posts
wp post generate --count=5 --post_date=2017-01-01
# Generate posts with fetched content.
curl http://loripsum.net/api/5/short/ul/headers | wp post generate --post_content --count=5
# ------USERS------
# create users with different roles
wp user create paula [email protected] --role=author --user_pass=“password”
# Delete Bob
wp user delete paula
# ------THEMES------
# List current themes
wp theme list
# Let's install a new theme and go ahead and activate it
wp theme install twentytwelve --activate
# We can create our own child themes pretty quickly
wp scaffold child-theme twentyseventeen_child_theme --parent_theme=twentyseventeen --activate
# Add a post type
wp scaffold post-type movie --label=Movie --theme=twentyseventeen_child_theme
# make sure to include the created file in functions php
# require_once 'post-types/movie.php';
# check status
wp theme status
#------PLUGINS------#
# Install Yoast and activate it
wp plugin install wordpress-seo --activate
# Install An older version of a plugin
wp plugin install search-everything --version=8.1.6 --activate
# Test the version that a plugin will update to
wp plugin update search-everything --dry-run
# Update all the plugins
# wp plugin update --all
# Delete Hello plugin
wp plugin delete hello
# List all plugins
wp plugin list
#------Menus------#
# Create a new menu
wp menu create "primary-navigation"
# Add it to a location. What menu locations were there?
wp menu location list
# Set the menu location
wp menu location assign my-menu top
# Create a menu link to a page
wp menu item add-post my-menu 2
# Create a menu link to a known address (google in this case)
wp menu item add-custom my-menu Slides https://www.slideshare.net/4nd4p0p/wpcli-workshop-at-wordpress-meetup-clujnapoca
# ------WIDGETS------
# Turn off the widgets. All of them.
wp widget reset --all
# list all sidebar locations
wp sidebar list
# Add a Calendar widget
wp widget add calendar sidebar-1 1 --title="When did I write"
# -----Database-------
# Let's export the current DB
wp db export anda-db.sql
# Resetting the db: THIS WILL ERASE ALL DATA IN THE DB
# wp db reset