Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,350 --> 00:00:03,340
Hello, everyone.
2
00:00:03,790 --> 00:00:11,530
In this lesson, we will get our first taste of pee, HP, which is the language that word press is
3
00:00:11,530 --> 00:00:12,130
written in.
4
00:00:12,730 --> 00:00:18,790
Now, working with a programming language might sound intimidating at first, but that's why we're going
5
00:00:18,790 --> 00:00:23,290
to walk through this together step by step at a nice pace.
6
00:00:23,620 --> 00:00:26,230
So without further ado, let's get started.
7
00:00:26,770 --> 00:00:27,100
OK.
8
00:00:27,160 --> 00:00:33,640
In our previous lesson, we set up a local dev environment copy of WordPress for ourselves.
9
00:00:34,060 --> 00:00:39,730
And now the question becomes how and where can we get our first taste of the P.
10
00:00:39,730 --> 00:00:41,140
HP language?
11
00:00:41,650 --> 00:00:48,760
Well, in our previous lesson, we also learned how to find the files and folders that power this site.
12
00:00:49,240 --> 00:00:53,800
So, for example, if you're using local by flywheel, you can just.
13
00:00:53,800 --> 00:00:54,190
Right.
14
00:00:54,190 --> 00:00:58,960
Click on your site right here and choose reveal in Finder.
15
00:00:59,500 --> 00:01:05,740
Or if you're on Windows, it should say show in folder or open explore or something similar to that.
16
00:01:07,740 --> 00:01:11,610
Go ahead and click into that folder, then click into app.
17
00:01:13,070 --> 00:01:14,480
Then click into public.
18
00:01:15,530 --> 00:01:20,150
And these are the WordPress system files that power your site.
19
00:01:20,720 --> 00:01:27,140
Now, before you and I worry about doing anything useful, like maybe creating our own brand new theme,
20
00:01:27,440 --> 00:01:30,730
before we get to that, let's first start simple.
21
00:01:31,190 --> 00:01:39,290
For now, let's just create an experiment file in this folder where we can try a few simple tests and
22
00:01:39,290 --> 00:01:41,750
dip our feet into the P HP waters.
23
00:01:42,260 --> 00:01:49,640
Now, it's important to point out that you can not use a word processing program to create a new P HP
24
00:01:49,640 --> 00:01:53,870
file or make edits to an existing P HP file.
25
00:01:54,410 --> 00:01:58,280
Instead, you need a dedicated text editor program.
26
00:01:58,700 --> 00:02:07,010
Now, most computers do not come with a text editor program out of the box, but luckily the industry
27
00:02:07,010 --> 00:02:12,680
standard and most popular text editing program is completely free to download and use.
28
00:02:13,160 --> 00:02:20,690
So right now, in a new tab, I want you to search for Visual Studio Code.
29
00:02:21,260 --> 00:02:27,170
As of this recording, the domain is code dot visual studio dot com.
30
00:02:27,740 --> 00:02:33,410
Obviously, this is not the only text editing program in the world, but I strongly, strongly encourage
31
00:02:33,410 --> 00:02:36,170
you to use this as your text editor.
32
00:02:36,710 --> 00:02:42,320
There are many reasons why this is the most popular editor, but the biggest reason I recommend it is
33
00:02:42,320 --> 00:02:46,310
because a bit later in the course when we need to work with the command line.
34
00:02:46,640 --> 00:02:53,360
Well, V.S. Code has a built in command line and it's always automatically pointing towards your current
35
00:02:53,360 --> 00:03:01,040
project directory, which will save us from having to manually navigate around our folders in the command
36
00:03:01,040 --> 00:03:01,370
line.
37
00:03:01,850 --> 00:03:06,270
It's also nice to not have to jump back and forth between two different program windows.
38
00:03:06,360 --> 00:03:10,280
Write your text editor and your command line, your text editor and your command line.
39
00:03:10,610 --> 00:03:13,730
It's nice to have them both just in one program.
40
00:03:14,300 --> 00:03:20,210
So right now, go ahead and pause this video while you download and install VNS code.
41
00:03:20,750 --> 00:03:24,950
Once you've installed and opened V.S. code, then you can come back and resume this video.
42
00:03:25,580 --> 00:03:25,720
Okay.
43
00:03:25,790 --> 00:03:30,980
Now, once you do that, once you've opened up V.S. Code here, you'll see a welcome screen.
44
00:03:31,220 --> 00:03:35,990
We actually want to create a new empty canvas or a new file where we can begin typing.
45
00:03:36,470 --> 00:03:42,080
To do that, you can either use the file menu and then choose file new or you can just press control
46
00:03:42,140 --> 00:03:46,850
n on your keyboard on windows or command an on Mac.
47
00:03:47,630 --> 00:03:51,170
Essentially, we just want a new file where we can begin typing.
48
00:03:51,740 --> 00:03:54,830
OK, so in this blank canvas, why don't we type out.
49
00:03:55,310 --> 00:03:57,850
This is a test.
50
00:03:58,680 --> 00:04:06,500
OK then let's go ahead and save this as a P HP file into our WordPress system folder.
51
00:04:06,920 --> 00:04:14,750
So click file save or control s or command s and we need to save this file into a very specific location.
52
00:04:15,230 --> 00:04:19,700
We want to save it into that folder where all of the WordPress system files live.
53
00:04:19,970 --> 00:04:24,380
So within your user account home folder, click into local sites.
54
00:04:25,540 --> 00:04:29,770
Then click on the name of your site, then app and then public.
55
00:04:30,630 --> 00:04:30,870
OK.
56
00:04:30,940 --> 00:04:36,820
And this is that same directory that we've already seen twice now with the different WordPress files
57
00:04:36,820 --> 00:04:37,660
and folders.
58
00:04:37,960 --> 00:04:43,030
So let's save our new file into this folder in the name of our new file.
59
00:04:43,120 --> 00:04:48,280
Only matters in the sense that we don't want to overwrite any of the existing WordPress files.
60
00:04:48,850 --> 00:04:52,150
So why don't we name our new file X bereavement?
61
00:04:53,290 --> 00:04:54,580
And this is the important part.
62
00:04:55,120 --> 00:04:57,000
Dot p HP.
63
00:04:57,760 --> 00:05:00,940
So save it as experiment dot BHP.
64
00:05:02,110 --> 00:05:02,410
Cool.
65
00:05:02,440 --> 00:05:07,840
So now in that same folder with all of the WordPress files by scroll down to the bottom, there is our
66
00:05:07,840 --> 00:05:10,840
brand new little experiment, DCPI, HP.
67
00:05:11,470 --> 00:05:14,110
Now, let's try to view this in the Web browser.
68
00:05:14,620 --> 00:05:19,930
So back in your browser, if you visit your local dev environment copy of WordPress.
69
00:05:20,500 --> 00:05:24,340
If you're using flywheel, remember, you can always use the view site button.
70
00:05:24,910 --> 00:05:33,640
But at the end of this, you r-al add on, make sure there's a forward slash and add on experiment dot
71
00:05:33,730 --> 00:05:36,310
p hp press enter.
72
00:05:36,340 --> 00:05:40,570
And you can see we are viewing that brand new file that we just created.
73
00:05:41,170 --> 00:05:48,410
Now I want to point out that this is not how you add new pages or you are URLs to award press Web site.
74
00:05:48,820 --> 00:05:53,280
So you would never do this in the real world on a live public Web site.
75
00:05:53,590 --> 00:05:58,060
We are only doing this for educational and testing purposes.
76
00:05:58,540 --> 00:06:04,270
At the end of this lesson, we are actually going to delete our experiment DCPI, HP file.
77
00:06:04,670 --> 00:06:12,070
However, for the time being, this is a great place to try and write our first bit of P HP code.
78
00:06:12,670 --> 00:06:16,980
So why don't we jump back into our text editor and let's delete the.
79
00:06:17,050 --> 00:06:18,550
This is a test message.
80
00:06:18,910 --> 00:06:27,520
And instead, let's write a tiny bit of h t N.L. so we can then see how p HP fits into the equation.
81
00:06:28,030 --> 00:06:38,870
So just as a test, let's create a heading level one HDMI element and say this page is all about Brad.
82
00:06:39,520 --> 00:06:47,400
And then maybe right below that, I want a less important headline that reads all about Brad.
83
00:06:48,260 --> 00:06:51,370
OK, let's save this and refresh the page.
84
00:06:52,360 --> 00:06:52,780
All right.
85
00:06:52,810 --> 00:06:54,460
So nothing too exciting here.
86
00:06:54,520 --> 00:06:59,190
This is just a bit of each demo heading level one and a heading level two.
87
00:06:59,560 --> 00:07:03,310
But remember, we are not editing an H t AML file.
88
00:07:03,580 --> 00:07:05,650
We are editing a P HP file.
89
00:07:06,010 --> 00:07:10,300
So if this is just H.T. Amelle, what does P HP look like and what can it do?
90
00:07:10,720 --> 00:07:11,830
Well, check this out.
91
00:07:12,310 --> 00:07:14,500
Maybe on a new line above this code.
92
00:07:14,860 --> 00:07:16,180
Typed this out with me.
93
00:07:16,810 --> 00:07:18,010
Less than symbol.
94
00:07:18,660 --> 00:07:21,860
Questionmark P HP.
95
00:07:22,540 --> 00:07:23,560
And then a space.
96
00:07:24,220 --> 00:07:25,390
And then a question mark.
97
00:07:26,080 --> 00:07:27,640
And then greater than symbol.
98
00:07:28,450 --> 00:07:29,800
So what does this code mean?
99
00:07:30,250 --> 00:07:33,190
Well, this first chunk that I have highlighted right now.
100
00:07:33,580 --> 00:07:39,700
This begins BHP mode and this chunk ends P BHP mode.
101
00:07:40,120 --> 00:07:40,300
OK.
102
00:07:40,360 --> 00:07:46,090
So in between those where my cursor is right now, that means we are in p hp mode.
103
00:07:46,480 --> 00:07:49,330
Now when we are not enpi HP mode like down here.
104
00:07:49,360 --> 00:07:49,620
Right.
105
00:07:49,630 --> 00:07:51,520
Because this closes p p mode.
106
00:07:51,910 --> 00:08:00,790
This code down here is just regular old HDMI all but up here while we are in p p mode we can write magical
107
00:08:00,790 --> 00:08:02,440
beautiful p HP code.
108
00:08:02,800 --> 00:08:03,580
So check this out.
109
00:08:03,640 --> 00:08:04,780
Type this out with me.
110
00:08:05,500 --> 00:08:10,870
Echo echo is how you output things to the page while you're in p p mode.
111
00:08:11,230 --> 00:08:15,640
So echo and then let's write two plus two.
112
00:08:16,240 --> 00:08:19,510
Then let's save this and refresh in the browser.
113
00:08:20,290 --> 00:08:23,470
And there we see for now, you might be underwhelmed.
114
00:08:23,530 --> 00:08:28,660
You might be wondering what is so exciting about two plus two equals four.
115
00:08:29,110 --> 00:08:33,679
Well, it's exciting because we could never do that in regular old H.T. demo.
116
00:08:34,240 --> 00:08:35,919
Each team doesn't have a brain.
117
00:08:36,159 --> 00:08:39,700
You just type out exactly what you want and that's exactly what you get.
118
00:08:40,000 --> 00:08:42,340
BHP, on the other hand, has a brain.
119
00:08:42,400 --> 00:08:44,860
It is a legitimate programming language.
120
00:08:45,250 --> 00:08:46,690
We can give it equations.
121
00:08:46,930 --> 00:08:48,910
We can tell it to talk to databases.
122
00:08:49,180 --> 00:08:52,830
We can have it resize images or send out automatic emails.
123
00:08:53,260 --> 00:08:56,830
We can make P HP do just about anything for us.
124
00:08:57,250 --> 00:09:00,820
And what's cool is that the general public that's visiting our Web site.
125
00:09:01,180 --> 00:09:02,400
They don't see our P.
126
00:09:02,410 --> 00:09:03,310
HP code.
127
00:09:03,640 --> 00:09:05,530
They only see the final product.
128
00:09:05,800 --> 00:09:11,800
So, for example, here in the Web browser, if we view the source of this page view, page source.
129
00:09:12,950 --> 00:09:15,230
So here we can see the H.T. Amelle code.
130
00:09:15,410 --> 00:09:17,930
But notice we don't see two plus two.
131
00:09:18,170 --> 00:09:19,370
We just see four.
132
00:09:19,730 --> 00:09:23,570
This is because P HP is a server side language.
133
00:09:24,020 --> 00:09:27,740
And that means that all of our P HP code runs on the server.
134
00:09:28,010 --> 00:09:34,070
And then only the result of that code, not the code itself, gets sent to the visitors of our Web site.
135
00:09:34,370 --> 00:09:40,640
So in other words, the server is what's calculating two plus two, not people's Web browsers.
136
00:09:41,060 --> 00:09:44,750
Let's jump back into our text editor because practice makes perfect.
137
00:09:45,080 --> 00:09:51,200
I want to show you that we can jump in and out of HP mode as many times as we need to.
138
00:09:51,560 --> 00:09:56,400
So, for example, maybe after this heading level one, but before this heading level two.
139
00:09:56,740 --> 00:10:04,490
So maybe in between those two lines, I want to drop in to P HP mode and maybe echo out the results
140
00:10:04,550 --> 00:10:11,210
of five times five K and then I'll be sure to close out or end P HP mode.
141
00:10:12,500 --> 00:10:12,710
OK.
142
00:10:12,800 --> 00:10:14,960
And if I save this and refresh.
143
00:10:15,860 --> 00:10:16,100
Cool.
144
00:10:16,110 --> 00:10:17,960
So in between the two headlines we see.
145
00:10:17,980 --> 00:10:18,860
Twenty five.
146
00:10:19,250 --> 00:10:20,270
So back to the code.
147
00:10:20,660 --> 00:10:25,450
You can see that in a P HP file we can seamlessly jump back and forth between P.
148
00:10:25,460 --> 00:10:27,350
HP hdmi l.
149
00:10:27,520 --> 00:10:28,970
P hp h.
150
00:10:28,970 --> 00:10:29,480
Temo.
151
00:10:30,110 --> 00:10:30,380
All right.
152
00:10:30,410 --> 00:10:35,540
Now before we end this lesson, I want to have you type out one more P HP example.
153
00:10:36,020 --> 00:10:36,420
All right.
154
00:10:36,470 --> 00:10:41,360
So on this page, you can see that my name is included twice here in here.
155
00:10:41,780 --> 00:10:44,780
Now imagine I legally changed my name in the future.
156
00:10:45,110 --> 00:10:47,450
I would have to update my name in both places.
157
00:10:47,810 --> 00:10:50,480
Now, just updating it in two spots isn't too bad.
158
00:10:50,510 --> 00:10:57,080
But imagine if the page listed my name 100 times or 300 times updating it and all of those places would
159
00:10:57,080 --> 00:10:58,670
be very time consuming.
160
00:10:59,000 --> 00:11:01,880
So it would be nice instead of having to hard code my name.
161
00:11:02,090 --> 00:11:04,880
If we could just include a place holder for my name.
162
00:11:05,240 --> 00:11:05,450
Right.
163
00:11:05,480 --> 00:11:11,390
So, for example, if instead of Brad right here, it just said blank and instead of Brad right here,
164
00:11:11,750 --> 00:11:12,790
it said blank.
165
00:11:13,190 --> 00:11:17,810
And then we could somehow programmatically replace all of the blanks with my name.
166
00:11:18,260 --> 00:11:24,170
Well, there's no way to do that with regular old HDMI oil, but we can do it with P HP.
167
00:11:24,530 --> 00:11:25,340
So check this out.
168
00:11:25,640 --> 00:11:29,030
Up here on this top line right after two plus two.
169
00:11:29,090 --> 00:11:31,220
While we are still in P HP mode.
170
00:11:31,610 --> 00:11:33,410
Let's add a semicolon.
171
00:11:33,890 --> 00:11:39,740
The semicolon tells BHP that we are done with this task and that we want to move on to a new task.
172
00:11:40,130 --> 00:11:42,950
So we could begin typing right here where my cursor is.
173
00:11:42,980 --> 00:11:44,750
But just to stay organized.
174
00:11:44,810 --> 00:11:46,730
I'm going to drop down to a new line.
175
00:11:48,550 --> 00:11:48,850
OK.
176
00:11:48,920 --> 00:11:51,530
And right now, I'm still in P HP mode.
177
00:11:51,860 --> 00:11:56,780
And what I'm going to do right now is create a variable that stores my name.
178
00:11:57,170 --> 00:11:58,400
So type this out with me.
179
00:11:58,780 --> 00:11:59,780
Dollar symbol.
180
00:12:00,200 --> 00:12:05,990
My name equals quote, Brad.
181
00:12:06,500 --> 00:12:12,020
And then just to be safe, why don't we add a semicolon at the very end of the line to tell P HP that
182
00:12:12,020 --> 00:12:13,640
we are done with this task.
183
00:12:14,060 --> 00:12:15,920
Now, let's go over this code that we just wrote.
184
00:12:16,340 --> 00:12:20,690
So the $ symbol is how you create a variable in P-H p.
185
00:12:21,080 --> 00:12:23,900
And then this text that comes right after the dollar symbol.
186
00:12:24,380 --> 00:12:25,820
This doesn't matter what you type.
187
00:12:25,910 --> 00:12:27,110
I just made this up.
188
00:12:27,350 --> 00:12:29,450
There's nothing magical about my name.
189
00:12:29,780 --> 00:12:34,460
Instead, we could have typed unicorn or pizza.
190
00:12:34,860 --> 00:12:35,110
Right.
191
00:12:35,150 --> 00:12:36,890
It really doesn't matter what we type here.
192
00:12:36,920 --> 00:12:39,230
Just as long as it's something we can remember.
193
00:12:40,850 --> 00:12:47,540
So this line of code basically creates a sticky note in P.H. PS Memory with my name written on one side
194
00:12:47,630 --> 00:12:49,490
and then on the back of that sticky note.
195
00:12:49,550 --> 00:12:50,840
It says, Brad.
196
00:12:51,230 --> 00:12:54,740
Now, what's cool is we can reference this throughout the rest of our page.
197
00:12:55,100 --> 00:13:01,760
So now instead of literally typing out blank here, we can just use BHP to reference this.
198
00:13:01,820 --> 00:13:03,190
My name variable.
199
00:13:03,560 --> 00:13:05,510
So let's delete this first blank.
200
00:13:06,680 --> 00:13:08,960
So this page is all about.
201
00:13:09,290 --> 00:13:12,860
And then we want to output whatever the value of my name is.
202
00:13:13,040 --> 00:13:14,330
So place our cursor here.
203
00:13:14,450 --> 00:13:17,060
And then we want to enter into P.H. P mode.
204
00:13:19,440 --> 00:13:19,690
OK.
205
00:13:19,760 --> 00:13:23,600
And remember, Echo is how we output something onto the page.
206
00:13:23,630 --> 00:13:25,310
When we are in p p mode.
207
00:13:25,760 --> 00:13:27,750
And then we just type out the variable name.
208
00:13:27,800 --> 00:13:30,650
So dollar sign my name.
209
00:13:31,010 --> 00:13:31,190
OK.
210
00:13:31,260 --> 00:13:34,100
And then let's be sure to close out of P p mode.
211
00:13:35,570 --> 00:13:35,870
Cool.
212
00:13:35,900 --> 00:13:38,610
So on this line we start out with H Temo.
213
00:13:38,900 --> 00:13:42,590
Then we enter into p p mode to get that variable value.
214
00:13:42,980 --> 00:13:44,840
Then we close out of P HP.
215
00:13:45,320 --> 00:13:47,390
So then we're back into H.T. AML mode.
216
00:13:47,420 --> 00:13:49,010
So we can close out the headline.
217
00:13:49,520 --> 00:13:51,770
Let's go ahead and do the same thing for this line.
218
00:13:51,860 --> 00:13:53,450
So let's delete blank.
219
00:13:55,070 --> 00:13:58,940
And then instead of typing this out again, let's just copy and paste it.
220
00:13:59,300 --> 00:14:01,280
So select this BHP section.
221
00:14:01,820 --> 00:14:04,160
Copy it pasted right here.
222
00:14:05,160 --> 00:14:05,330
OK.
223
00:14:05,430 --> 00:14:11,460
Now, if I save this and refresh, we don't see any difference because my name still equals Brad.
224
00:14:11,760 --> 00:14:22,050
But now if we change this variable to equal John Doe and save cool, it gets updated in both locations.
225
00:14:22,560 --> 00:14:25,860
Now, again, it's not very impressive because it's in only two locations.
226
00:14:25,890 --> 00:14:28,620
But imagine if your page was way more complex.
227
00:14:28,920 --> 00:14:31,500
And that name was referenced hundreds of times.
228
00:14:31,830 --> 00:14:32,670
You get the idea.
229
00:14:33,240 --> 00:14:36,720
And that's actually going to bring this example to a close.
230
00:14:37,170 --> 00:14:43,530
Now, I do want to point out that what we just did in this lesson has absolutely nothing to do with
231
00:14:43,530 --> 00:14:44,430
WordPress.
232
00:14:44,970 --> 00:14:52,410
This experiment dot p HP file that we just created is not in any way connected to the core of WordPress.
233
00:14:52,900 --> 00:14:56,210
However, WordPress is written in the P.
234
00:14:56,210 --> 00:14:57,600
HP language.
235
00:14:58,020 --> 00:15:03,770
And at this point in the course, you are now familiar with the basics of P HP, right?
236
00:15:03,810 --> 00:15:05,910
You know how to enter p HP mode.
237
00:15:06,240 --> 00:15:08,460
You know how to close p HP mode.
238
00:15:09,270 --> 00:15:12,150
You know how to create variables using the dollar sign.
239
00:15:12,480 --> 00:15:15,930
And you know how to output content to the page using Echo.
240
00:15:16,440 --> 00:15:22,080
And with just that little bit of P HP knowledge in your tool belt, you are now ready to start writing
241
00:15:22,080 --> 00:15:29,760
WordPress code, or in other words, you're ready to use P HP to tell WordPress what to do.
242
00:15:30,180 --> 00:15:31,590
And this is where things get fun.
243
00:15:31,920 --> 00:15:40,500
So in our very next lesson, we are going to use P HP Code to create our own brand new custom WordPress
244
00:15:40,500 --> 00:15:41,040
theme.
245
00:15:41,670 --> 00:15:47,400
But really quick, before we jump into that next lesson, I want to talk about our experiment dot p
246
00:15:47,400 --> 00:15:48,450
HP file.
247
00:15:48,900 --> 00:15:55,440
If everything in this lesson made sense, I encourage you to actually go ahead and delete our experiment.
248
00:15:55,470 --> 00:15:56,970
DCPI, HP file.
249
00:15:57,330 --> 00:15:59,010
You don't need to delete it.
250
00:15:59,130 --> 00:16:01,620
You can keep it for reference if you'd like to.
251
00:16:02,010 --> 00:16:08,610
I just want to make sure that you're aware that it's not normal to have random extra files sitting in
252
00:16:08,610 --> 00:16:11,550
the core root folder of WordPress like this.
253
00:16:11,880 --> 00:16:15,270
We only did this for educational testing reasons.
254
00:16:15,630 --> 00:16:20,760
So I would strongly encourage you to delete this file, but it's not going to hurt anything.
255
00:16:20,970 --> 00:16:23,610
So if you want to keep it there for reference, that's OK.
256
00:16:24,150 --> 00:16:27,930
Anyways, I'm looking forward to creating a theme with you in the next lesson.
257
00:16:27,990 --> 00:16:29,460
So let's keep things rolling.
258
00:16:29,550 --> 00:16:30,600
And I will see you then.
23510
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.