 So, ask yourself a few questions. Do I do the same things over and over again? Do I click the same buttons and the same sequence when I do a second? Do I fix in the same problem day in and day out that I have to log into this screen, go to this button, go to this screen, go to this button, type this field, cash clear, got the out of. Yeah, of course we all do. If you're maintaining the site at all, you're building sites at all, do the same things over and over and over again. And it's time to let the robots do that. Human beings are really prone to errors. We are great at making mistakes and we do repeatable boring processes. So anything that you can make a machine do, it's time to make it do it. Not just because they're good at flipping pancakes, but because they can do really intricate, hard to do things. And once you've got them set up to do it once, the pancake bot here can make a pancake all day and you keep refilling that batter and you make the same dinosaur every time. I couldn't make this dinosaur if you paid me $100. I just couldn't do it. A dollar might want me to do it, but I couldn't do it all day. I couldn't do it reliably all day. And that's what machines are really good at. You can tell them what to do and they can do good stuff. So let me show you a quick example. Speaking of Cloud 9, I'm actually using that. I know that's the wrong logo, but it's a joke. So don't attack me for using the wrong logo for Cloud 9. That's the game you know. So let's go out and watch a really quick example. This is all real time. I didn't ever spend this thing up. Oh, hopefully I'll be able to see all of this. I don't know what to speak about. This is real. So right now I just have a blank apache in the environment. There's all my files. That's a php environment. If you look familiar, there's no script that I built. I'm going to go ahead and run. One of the reasons why Cloud 9 is that I'm doing a special variant. Don't worry about the MySQL thing. That's a specific Cloud 9. I didn't notice all the files that appeared. That was the downloaded core. Somewhere along the line, I also configured it. I built my big php. I did a few other things. And I go back to the exact same apache server. And that fast, I have a kind of ugly theme, but a beautiful site with a bunch of dummy posts in it. Some using more, some just posts. A little fun little widget I made over the corner with a CIA list of emojis. Just picks one that was random. You can see it in the description. It's not just on the website. This is where you see it live. And I put a quick list of Google because it's a demo site. Why not end on Google? And if that's somebody in this room at least, it's thinking, what was that? What just happened? I saw a minute and 15 second video of building a website. What the heck was that? Let's take a step back. Before we talk about the internals. Who here uses a terminal or a command prompt every day or whatever? Yep. Before there was the GUI. Before we had click and point and Apple introduced us to Xerox invented it and Apple productized it. We had a command line. I still use gray and blacks. I think it's a great combo. Green and black. But line by line, I can go tell a computer to do a thing. It's happened to have this up. You can do fun things like a cruel party parade. Well, it's terrible. Yes. I'm going to have to kill out of that. I can tip the weather underground. Which looks terrible. Sorry, this is a soap. The party parade messes this up. We've got to stop it in just a right second. Yeah, you guys have to adjust the right one. I think the weather undergrounds tell that server. And find out where the weather is if it's working. They don't have this as the highest priority over there. Surprisingly. So, oh no, I said that doesn't have the data. All right, not a big deal because it's just a demo. But you know all sorts of fun things in command line. Just from a fun, I'm using a command line. But what I think is super powerful is that line by line you can tell a computer to do. You can start stacking those commands. That's called scripting. Who of you here have ever written a script? For everyone that didn't put their hands up, it's super easy to do. A script is no different than Shakespeare or NCIS. It's a line of things that do this repeatedly. You can get a fellow or Romeo and Juliet and do it line by line the way it was written. We will have performed that play. Same thing. Robot, do this set of things. In orders. That brings us to WPCLI. WordPress command line interface is written in PHP. It's an open source bucket of tools for managing WordPress. You can go contribute to it right now. You can jump out to github.com. Slash WPCLI. Or go to WPCLI.org and get there from there. A lot of people wrote this. Christie and Andrea over there on the end invented it. Daniel is currently the chief maintainer. Alan, our land has been working with it quite a bit the last year. They got rolled into the WordPress project in January of last year. So it's officially WordPress. You're not using some third-party tool that someone dreamed of and hoped it worked for the project. This is the project itself. The website is still its own independent landing page. We can click any of the links. They go over to WordPress.org. So if you're playing along at home, this is the time when you go to WPCLI.org. And you can start playing along with me. We're going through the next section pretty quick. But how do we do this? First, you've got to install it or anything. While it is part of the project, you're going to use this tool on a server or locally. And you need to say, hey, I'm turning on to make it work. So how do you do that? It needs a few things. Sorry, Windows users, you're going to need bash. I say sorry because you're going to have to install something or configure your machine to use bash. Windows 10 professional edition users, it's there. Bash into one-to-one Windows is a real thing. You can turn it on right now. It'll take a couple of weeks to start so we can do it. Or you can just install and get bash and it works. You're going to need SSH access if you're going to put this on a remote server. And you're going to need PHP 5.3 or later. But who here is not on 7 yet? Okay. Well, not on everything. Not everything. What are you getting there? You're working on it. Because you should be on 7 at least. It's 7.2 right now and 7.3 is coming. So how do you do this? Three steps. That's it. That's all you need to do. So everybody in the room is like, what the heck does that mean? That's all right. I see a couple of point faces. Curl just means go over URL the information I am requesting. Capital O says name it the thing that is named there and you pull it over. So let's pull this far file. A far file is, let's say like a jar file. Nobody knows what that means either. So it's a prepackaged set of executable PHP code in a bucket they call a far. So then we're going to shimab it to say, hey, this is executable on my system. DHMI, whatever you pronounce it. And then we're going to move it somewhere useful. So I'm going to type WP. I get this. I get a beautiful list of commands that it can do. Ever growing, ever expanding. So this one looks like when you actually go through this process. All of my slides are available online. I'm not going to follow the slides verbatim today because I have a shorter amount of time and I want to demo some other cool stuff. But you want to say like, what does this look like when it works properly? Go through the slides. Go feel free to use them and leverage them. There's, all right. So that's it. Once you've gotten through that, the hard part's over. A couple caveats. If you're going to put this on a remote server, that's got to be a remote server you can access and actually install things on. Shared boxes, sorry. You might get lucky and there might be some kind of bash in your C panel that you can access, but actually hitting the right site will require you to remote at it and now you're getting complicated. On UPSes, obviously it's easy. What one stalls, brilliant. Third parties. Pantheon, for instance, it's just there. You can just target the site on. Pantheon through your command-liner face. But once you're up and running, you can do anything. But what's anything? The problem with saying you can do anything is that's a lot of stuff and you have to figure out what you're doing. So with the rest of these slides going up through our basic usage of this thing. So if I'm going to use any of this, I've got to know where the commands live. Fortunately, this command list is a living list. It's not static doc that you're hoping gets updated after the product gets released and has a lot of ambition to do it. This command list is auto-generated from the tool itself. The way they built it is in the commands themselves, there's a header that has the help docs. The whole set of commands in the help docs are in the tool already. Very amazing way to approach the situation. So when you go to the command, you can get that same command by tagging WP and seeing the command list pop up and start drilling into it. I learned how to use WP-CLI on plain. Not even kidding. When I fly, it was like, ah, I got my local up. Let's see what this thing can do and dub through the docs all completely offline. Before we look at these commands, it's good to know how these things are structured. So you're always going to tag WP because you've got a telecomputer. I want to use the WP-CLI. You have a general command like user, general category. That's the first command. It's a sub-commander. What do you want to do with that thing? So you need to forget how exactly it's worded. If you can get as far as WP, user, oh, add, but I don't know what to do. If you put that in, the error screens tell you, oh, I think you meant to do this. Or here's what you should probably do. The error screen is brilliant in this thing. A few global parameters you can throw in. There's a whole bunch more, but things like prompt. So if you don't remember at all what a thing does or how to put the additional variables it requires, so if I'm doing an install, I don't remember all those fields. But I can say dash dash prompt. It'll just tell me. It'll say, I need these 16 things. Let's go through the list and use it at an end as an aspirant. Or if I run this command all the time and I just do not want my terminal cluttered with messages, I can say quiet just to assign them. Those are global. Every command will adhere to these things. Then there are specific command arguments that only work with that. Certain commands, like dry run. Dry run's awesome and I use it a lot when I am using this in my work, in the demos. Because dry run will say, what would happen if I actually ran it? But it won't actually run it. It will say, here's the results, but it didn't do it. This is what it looks like. So let's go through a few quick examples and then I'm going to jump over and show you a few other things. So one of the things I did was download and import. That's it. That's the entire process for downloading and import. Now admittedly it is cached on C9 because they also, you can just start up a WordPress site on C9 in a dev environment. So it's there. So it's a little faster over the wire than pulling it from the repo. But we're talking a matter of a couple seconds faster. But this is it. Download all the necessary files on command. Build and config. Who likes building config php? Or don't make config files by hand. Yeah, nobody out of the interviews. But core config will build it for me. And I can say prompt and it will ask for the specific things it absolutely needs. Now C9 I didn't get away with just using my IG name and database name which are right there for you if you don't want to log in my account. So I can feel free to fill in that information. You know the five minutes call. This is the ten seconds. One more powerful features of this whole thing. How I found it. Oh, this looks terrible. Hold on. Hold on. It looks great. Graph on size. Screen resolution. Screen resolution is where I was before everybody. Screen resolution. It looked better before I plugged it in. So I have... Everything I run today is just out on GitHub. This example script. You know, it gets you to look at the raw so you can count the pace. So I want to download core. I want to configure it the way I want to configure it. And install it. Let's see how long this actually takes in real time. It even verifies the hash. I don't see nine, so run project. I'm going to get this nice link to my demo site. And I have broken site. I did something wrong. I did something wrong on purpose. There's no reason you have to use C9 incorrectly. You can use it correctly. There's this ability. This is how I discovered the tool existed in the first place. To say, hey, WordPress command line interface. Go through the whole site. So how I broke it. I called it the wrong thing. The full URL. The user, the site name is... But it's actually for something slightly different. And that slight difference is this versus that with a lot of the images to look at. To say, hey, the PCOI through and make these five replacements. You can see that in the back. If I ran a dry run on that, it would have said, I would make five replacements. But it wouldn't actually do it. That seems logical to me. On a brand new install, there would only be a few assets. If it came back and said, I'm going to make 3,000 changes, I would be scared. If it came back and said, I'm going to make zero changes, I'd be like, oh, something's not right. Because that's definitely a string I want to replace. So it's a quick way to just real quick test. You just hit up arrow and take off dry run and you're back to where you were. So I did that. It went through the whole database. It said, that URL, that string. Not in the URL, but that string was your arm. So will it search any column in any table? Yeah, you can say dash dash all tables and it will go through everything. And it is going through the database. If you want to do more specific explicit, I can't hear what's down there because I've never used it. But you can say, hey, PHP replace everything. Everything you see, period. Just anything. And it's not just things that that metal level is like, hello world. I hate hello world because we use it all the time. So I say, I don't run out of time, but something's cool. Is it case sensitive or can you flag that? Let's find out. And I put a double quote instead of a single quote. Loved live demos, don't you? Oh, zero replacements made. So if I come back and say hello world, I get a replacement. It's case sensitive. Yeah, you can actually. You can pass all sorts of parameters. How I know that is you can go about the command list. This is actually the next point I was getting to. So great question. So the first two things I showed, I just like kind of whiz through and hey, BBQ. And yeah, I know those commands really well in the way I use them. There are a bunch of commands and a bunch of sub commands. How many commands are there? I threw it in a spreadsheet. And there are that many 42, 42 general commands. There are a lot more sub commands inside of all the sub commands. So let's look at search replace. And by the way, if you see anything like, I would love to improve that. That doesn't read correctly. And then we could say that better. Open issue queues right there. Go to a pull request, go in and contribute. We need all hands on deck for contributing to this stuff. So we can say old, new, table, dry run network, all tables with prefix, all tables. I can, oh, this is a fun one. I have that in the slide. I can say, hey, go through and make all of these changes, but don't do it in the current database. Do that in a database export at the same time. So when you're on your dev server, and you need to push it over to live server and make all those path changes, because how does WordPress store its paths? Absolutely it does. Terrible joke. You can say, hey, just throw that in the new database and I'll import that new database to production, and we're done. Not that I would say import live production over at your database ever, but you could do it that way if you're just launching. So again, what were we looking for, though? We were looking for skip columns, include columns, precise. Precise is what I was looking for for PHP instead of SQL. Looks like currently no. You can do regex. So there you go. But no iFlag right at the moment. Oh, well, there you go then. I guess, sorry, my mind's racing because I'm trying to get through everything in 10 minutes and open it up for questions. So I'm not going to demo anything else live except for one other thing. So if I want to generate posts, how do I generate those posts? Well, obviously you can just say, hey, generate me some posts. You can also do fun things like pass in data to it. So I could curl from a lorem up some generator and say, hey, build me post out of this what you curled in. Thank you. So now we got to really speed up. So if you get a site and you're like, well, how many posts actually are there? What are these posts? What are their status? You're on a post list and just kick it out. You don't have to go through the admin screen. Because we're using, and this is what I'm showing here, because we're using Bash, you have all of Bash at your disposal. All of the cool things Bash can do, like, I can easily write to a file. Bash is really good at that. So you can say, hey, I want to put this in export, or format equals CSV, and I can dump this into a CSV right now. And I can see all my posts. In this use case, or this example, maybe not that useful, and a site with thousands of posts. Oh, absolutely, easy way to do it. I want to delete those posts, post IDs. I can delete them all at the same time. And again, I'm going to let you go find these slides and see this, if you want to dig in and see this in action. But if I want my post delete, one, two, and three, I can do multiple posts at the same time. Bam, those are gone. I go back and look, and sure enough, they are gone. All right, users. Who likes creating users through the dashboard? Some people do. You could just throw up in your terminal and get it done in one line. Or if you don't remember that one line to create, you could throw a prompt and say, hey, remind me what I'm supposed to put in here? Oh, I need 10 things. I can optionally put 10 things, actually. If it's in Angular brackets, it's required. Square brackets, it's optional. Notice, password is actually optional. Don't worry, you get a password, but it generates it for you. It's a preferred method. So here I'm making Daniel an admin or an author, and there's the password. Probably not great that I saw that. That's another good use of silent. So I'm going to do that silently. I don't know what your password is. You can go reset that yourself. User get, I made Daniel something, but I don't remember what I made Daniel. Oh yeah, I can just user get him. Now I see all his information. Delete, obviously you can delete. One of the cooler things you can do is you can start modifying and playing around capabilities and roles. So if I say, authors should not be able to delete their own posts. Only editors should be able to do that. I can go into author and take that capability out. I can add roles to people, so I can say you're an editor and an author, and you get both of those worlds and start stacking things, or I can come in with capability. Actually, I don't think I have that on the slide. But say I want to add a capability to a role. Or I want to create a brand new role. You can start using workflows without plugins, the proper WP way to do it without a lot of must or fuss. Of course, you can delete people. That makes total sense. Themes. I can see what themes are there and what's active, and very importantly what's up to date. If it needs to update all, you should probably delete the ones you're not using, quite honestly. Unless you're swapping themes a whole lot, and then that's super easy. Downloading them is super easy. It's a theme install, and you name the theme. If it exists in the repo, it finds it. Do you limit it to just the repo? No. If you give it a full path to a theme, no matter where it is, it will get off that path. So if you wrote your own theme through it on GitHub Bitbucket, point at it, grab it, you're good to go. Activating another command. You can also combine theme and install, or activate and install to be one thing. So I can install and activate with one word. One of the coolest features and the thing they're expanding a lot is scaffold. Who here uses child themes every time? No exceptions. I see some waving hands too. I don't know. Great idea, because you know what? You can accidentally blow up your child theme all you want, and it defaults to the parent theme and nobody's mad at you. Oh, they're mad, but they're not that mad. This is how you create a child theme with WPCLI. You name the child theme, tell what parent it's got, and you're done. You activate it at the same time, and you're working in that child theme. You're ready to go. You didn't have to install anything. You just pop open your ID, your PHP ID, and get to work configuring that thing. I'll come back to scaffolding in a minute. That's one of the last things I want to demo, and I know we're running out of time. Delete themes, plugins, just like themes. I can install them, and I can install specific versions. So if I say, I do not want the latest, greatest Jetpack. I would like the 4.7 version, please. No problem. But if I can also update everything. So if I, like, that was a dumb idea to not get the latest, greatest Jetpack. It's available. Let me update Jetpack. Or I could say, all. That's a scary thing to do on a production website. Plugins, too. And as of a few weeks ago, a few weeks ago, you can do this. Let me see it. Anyway, just for the sake of time, they just added Scaffold Block. So all of you plugin developers who are like, how am I going to start developing for Gutenberg? Scaffold Block, you'll put all the files in the right place. Building. You could do anything in those files. Yes. Early version, this is like, first release of it. In fact, it's not in the general release. You have to go install the Scaffold edition that they've just recently built with Composer. Composer scares you. Maybe not for you just today. But it will insert the right things in the plugins so you can start building right now. What about databases? Scary. A couple of things to talk about, but this is one of the last big ones. What tables do I got in my database? I don't need my SQL tools to figure that out. WBCLI will do it for me. Do I want an exported database? Five more time, I'll show you the magic trick that Sean Hooper who gives the similar talk always does, which is let's export the database. Then there's database reset, which is a terrible idea if you're not prepared for it. You can also do database import. You can database import right after we left off. He does it in the magic trick. He's like, oh my god, the second spirit. Now it's back! And it took three commands all together to make all of that happen. No special, most of these tools. But yeah, sometimes you want to just get to the MySQL command line. Rarely, but sometimes you do. So, yeah, WBCLI, that's what it gets on MySQL command prompt. And then there's everything else you can do. If you want to arbitrarily execute PHP inside the environment, yeah, you can just get to Shell. Not everybody lets you do this. Kind of the idea that's locked down. You're doing it locally, of course. That's your machine, you can do whatever you want. But that's our arbitrarily running PHP code in Shell. Hey, we've got the site ready for, put the real content in. We've got to go through and manually delete all of these posts. No, recite empty. All the posters are gone. Crime? Who likes crime? You're lying. You can start controlling it a lot better on the screen. All the commands are out on the repo. You can start using WBCLI within other tools. And once you start doing that, you can start doing interesting things like this is how I build demo sites. I don't save this file that often, honestly anymore. But I will save this version of it. But that's the only thing I change. That one variable. And then it creates a site. It installs the site using the credentials that I normally use for my demo sites. It sort of the themes I don't want, updates what's left, puts in WPCLM for the win and activates it for me. And I'm ready to go. And I have a laundry list of other things I can do that I'm ready to uncomment and make it do on that particular run Can I start earning that bash script on a computer I don't own? Yeah, it's called CircleCI or Travis or Jenkins. And now I programatically start talking to WordPress and how build tools and scripts do things for me. It also is tied into a lot of other CLIs and more and more that's growing. So if you use other CLIs, WBCLI might be in there. Question time, we got time for one? Three questions. We can take three questions I'm told. Your heads are like, also extendability, there's no question I'll say extendability, you can start writing your own plugins for the CLI itself. There's an awesome talk from WorkCamp Seattle last year from, I don't know if you know what I'm talking about, CoreShop Creative. They've built their own custom theme and their own plugins suite for WBCLI produce that puts mustache code in for certain things and they change variables and every site's completely custom working off a scaffold theme that's completely rock solid. So you can start doing all sorts of fun things when you start extending out the power of the CLI itself. Not one more question, any others? Let's thank our speaker. I still have a manager North Cross. I'll never get it back.