JavaScript for WordPress

JavaScript for WordPress Reviewing the JavaScript for WordPress

Though many of the concepts in this course are still relevant, overall this course does not reflect our current course standards.

Check out a free preview of the full JavaScript for WordPress course:
The "Reviewing the JavaScript for WordPress" Lesson is part of the full, JavaScript for WordPress course featured in this preview video. Here's what you'd learn in this lesson:

Zac reviews the topics discussed and examined in the course.

Get Unlimited Access Now

Transcript from the "Reviewing the JavaScript for WordPress" Lesson

>> Zac: Let's do a quick little recap on everything amazing that we have learn today and gone through. Then we will send you out to the world to build JavaScript stuff in WordPress and be amazing at it. Look at that y'all. You learned all of this today. Remember when we were just starting off and I told you that JavaScript has a long history in WordPress.

[00:00:28] It started out with like 300 lines in one file and now it's 30% in like tens of thousands of lines. And they're considering whether they should add React or View and what they should do next. We have a single page web app as a customizer. We're getting a single page web app to override all of the edit pages and all of the add new post pages.

[00:00:50] And you are at the perfect time to be fluent in JavaScript and getting better, and know just enough WordPress to do way more than a lot of other people who have been working with WordPress for awhile. So, it's very cool the time that we're in. And raise your hand if you feel like you've at least learned how to enqueue a JavaScript file.

[00:01:09] Please everybody, please, right? We know how to take our JavaScript, and we know how to run it through PHP and load it. We know how to do it in a theme, we know how to do it in a plugin, and guess what? You could forget because you have the code examples there.

[00:01:22] So don't bother remembering, enqueue is spelled E-N-Q-U-E-U-E every time, weird word. Unless you have I-N-G, then the other E isn't there. But that's the basic of it. So you've gotta know that. And then we looked a little bit at AJAX. We did a jQuery example together. You have an Axios example to go over on your own.

[00:01:44] And it's just a matter of what you wanna use. And there are times in WordPress, like our Like thing, it would have taken us setting up a custom API route, and accepting POST requests in order to handle all that. So in some cases, doing a little quick and dirty AJAX within a theme or a plugin, not completely frowned upon, still okay.

[00:02:06] But the direction we're moving in is if we wanted to do that, we would set up a custom endpoint where we could get the total number of likes and we can authenticate and post in new likes at the same time. So that's the direction we're moving towards. We looked at how to get posts, pages, media, all that other stuff and adding an ID to the end of it.

[00:02:30] We looked at how we can pass arguments, so we could do even more by filtering stuff down and getting exactly what we want. And then we looked at how to build a enhanced theme using JavaScript. And again, this is the place I would suggest, I would not necessarily suggest building a WordPress theme in WordPress that has no PHP.

[00:02:52] Because PHP can leverage a lot of things that JavaScript still has a hard time doing or you'd have to code a lot of API functionality on your own. So one of the best ways to start implementing this is in little ways, maybe a sexy footer. Maybe a certain page on your site.

[00:03:09] Maybe in the header somewhere. One of the biggest places I've seen it implemented first is with searches. So when Airbnb got all its complicity for rolling out React in production very early on, what did they do? Search, that was the first thing they hit, because it makes sense to make that interactive.

[00:03:27] Some other people in the WordPress space that are getting client work, their stuff is completely traditional PHP theme. An then they're like, we want this fancy search. Let's use the API for that. So piecemeal, adding it in and enhancing it. Now outside of WordPress, build whatever the heck you want and just use WordPress on the backend.

[00:03:46] Now we showed how to edit and how to save and how to delete, but you have to make a decision for yourself. It may be way easier to build a super slick front facing read-only JavaScript app and use WordPress for editing, right? Then you don't have to build the whole editor.

[00:04:04] Then you don't have to deal with authentication. So if all your decoupled app is doing is always receiving data and you're never trying to send it back, then they could just go into WordPress, log into the admin area, make the changes there and then they're pushed to your site, and you don't have to code any of that.

[00:04:21] But, if you want to get really custom and you wanna hide the fact that you're even using WordPress as a data store or as an application framework, you've got the basic crud down and you can go from there. Now, where do we go from here? Because there aren't a ton of resources at this point.

[00:04:39] I did share with you a few projects. I have my site JavaScript for WP. There's some free content in the blogs that I'm sharing out, projects and things. I also have the show interviewing people who are pioneers in developing this stuff as well as projects. And you can just from time to time search REST API Project with WordPress, things like that.

[00:05:00] But we are at the cutting edge. So the standards of how to approach things the best way are still being developed. And the opportunity to come into a lot of these really prestigious WordPress companies that really value great work lifestyle and pay you well and like, like Human Made is one of them.

[00:05:19] The guy who built the WordPress REST API works there, and some of their core contributors. And what you find in a lot of these bigger Wordpress agencies is they're not just making money off of it, they're actually contributing and building back to the platform itself. So, you may have not thought about a job in the WordPress space as a JavaScript developer, but let me tell you the WordPress world would love to have you.

[00:05:41] So the more you know about JavaScript, the more you could enter into this. And even if you don't get too far with the community or working with it, if you know that WordPress is a potential backend application framework, data store, CMS that you could do, leave as it is and then build your own JS either on top of it or completely independently.

[00:06:02] Then that is a huge win for you. There are other ones. Drupal is out there. I'd say that's the main other one. It has an API. It tends to be a little bit more developer-centric, the community. And you don't see quite as many people who are like, yeah I'm gonna throw up a new site, going to Drupal as much.

[00:06:20] But it has an API and the stuff that you learn today, you could apply to that. There's gonna be slightly different things like post.title.rendered isn't exactly the same but the skills that you have are pretty versatile in terms of what you could do.