 Hi everyone Wi-Fi details you have one second Okay, bye Right, what is WordPress CLI? Well, it's pretty much what it says. It's command line interface for you to manipulate WordPress so you don't have to play with the web UI it was originally coded by Christie Berger and Andreas Creighton and Daniel book color is mostly the Main dude that looks after it, but if you've looked at their github the activity stream is pretty intense. I've not seen a git That active for a while What can you do you can install an update WordPress themes plugins You can manage your content manipulate your users and a whole bunch more it works on single and multi-site installs So why the command line why not would be my question? not having to use a mouse is very handy and very fast so Makes it very very quick and easy for you to Do all kinds of different things if you can type it you can script it and if you can script it it can be repeated Which makes your automation happen the interface doesn't change it's all text and if you seem to be on a terrible connection which can happen and as per Jaff yesterday mentioning or was it with Jeff mentioning how he was using Shell on his phone to fix a client site I've had to do the same thing in WPC li has saved my bacon Errors are easy to detect because you'll get a response very quickly that something isn't working and If the command is documented correctly you get help built in so you can type out the command as you go and it'll tell you What you've missed or just tell you you type something completely incorrectly so The WPC li website tells you how to install it and I'm not going to go through that But once you've installed and followed their instructions You should get something like this at your at your prompt as you can see I'm running this on mep It doesn't work on Windows very well. I haven't even tried to be honest But it should work on any flavor of Linux and and Mac Basic commands would be more of the setup side of things. So I'm going to cover two kind of streams basic commands and What I would call advanced commands, which is more manipulation of your your environment when you've got it set up and running I Have notes to slow down. Otherwise, I'll talk too fast Right First thing you'd want to do is look at some of the common commands WP core Kind of makes sense what you do with that one WP plug-in same there WP theme and WP user so the first one is WP core That allows you to install and configure your base WordPress install whether that's a single site or multi-site First you have to download The core whether that comes from case or fresh Depends on whether you've run the command recently Then you need to configure it which is WP config or core config which will create the WP dash config file for you Which is very handy if you need to spin up client sites And then core install which pretty much skips the installer screen you get when you first install WordPress I've just given you a quick little thing there Which shows you what would run I didn't do the output because I'll actually do a demo a bit later You can install and activate plugins You can chain the plugins too. So if you have a whole list of plugins you like to install you can have them all on one line and then You can activate them as you want You can search for plugins The Plug-in you need to when you name the plug-in you want to install. It's the slug for your plug-in So you can see that here That's what you want to use Unless you've got a very unique plug-in you can do the in quotations And you can chain them and activate all at the same time so install we commerce and WC vendors and activate them Themes are pretty straightforward a Lot of the common commands are the same across most of the install stuff. So you get download install activate search and these search the WordPress org so You can install themes activate search for themes Do all that kind of themey stuff users come in handy if Someone's forgotten their password. It's a good way to not have to touch the database Or purge a user you can just reset their password on the command line Pretty handy One that's pretty good for people who haven't used WPC a lot very often Is the dash prompt and it'll just go through and prompt you for each of the User fields as you require or you can just chain a nice big one like that and then you can add roles and Do all of the stuff you would usually do on the back end, but all without having to touch the back end Here's where the stuff gets fun and interesting and where you'd probably spend most of your time Once you've got things set up and configured Because it'll allow you to Do a whole bunch of different stuff? One that I thought that that I use quite regularly is that being able to manipulate posts on the command line So being able to create a post on the command line I actually have I don't know if you guys know what NAR Geos is But it's a server monitoring system and I have an internal status blog for all my servers that will post Relevant information to a status blog so everyone on the network for the company I work for knows what's going on and I do that all on the command line and If you want to post regular Scheduled posts and things like that where you're getting the data externally another good way to do it is with this Updating your site options and other cool utilities. One of my favorite is search and replace So when you migrate aside from your local development environment to a staging or production environment Search and replace will actually go through and find every single Instance of that string and replace it with your your domain. So it does and And another good one if you change your thumbnail sizes regenerate your media and That's a big one for people who have huge subsets of media Do it all on the command line and don't have to worry about the is it working on the little loathe bit there Which often happens Importing and exporting data. I forgot to put the export command, but it's pretty much the same thing but export This is this one here will actually import the dummy data for WooCommerce. It takes forever Because it's actually pulling down all the media off the web Which reminds me? And that'll allow you to import your data into a whole bunch of useful things Exports another good one for part of your migration from local dev through to staging in Production as well see export from one import to the other search and replace and then You could go Right demo time I'll type really slowly because I've spoken quickly. I've already run One ready to go here script which is available in my github if you want to use it No, I Know why I'm Running the script twice. I broke it and that one's gonna break in a second too right here What we'll do is we'll just all right when you're inside you have to be In a WordPress install you can pass a path to your WP command. It's easy to just do it within the install when you're doing interactive So I'll search database and tell me what current plugins are installed So it gives you an idea of what's been installed Anyone got a theme they like to use? Which one? How do you spell that? Yeah, so then you could Let's see how slow the network is do it and Get that and now it's installed so Clark and storefront and a few others Here we've got as I told you 31 or 78 still going I'll make that a little bit actually Megasize so what I'll actually do is I have got a script here, and I'll talk through my script So what I've got here is just a simple bash script I got a little bit fancy so it checks to make sure WPC li is installed it'll automatically generate a database based on the Name of the directory you pass to the script and then it appends the date on the end Then it'll create a user in your database In theory it won't overwrite your database, but I did that already Then it'll go through and start creating a new site Here's the standard stuff Don't interrupt me demo. I like to remove the sample just cause config Then install Got a whole bunch of base plugins, which I've defined up here So if you want to actually change what plugins are installed you just change that line there, and then that'll change that Activate my base plugins delete the heap. Hello plug-in. I need to delete the sample page for my WooCommerce demo, which is This guy here What this does is it installs the storefront WooCommerce theme Creates all the WooCommerce pages From there it will Create your contact form your contact page Populates the privacy policy in terms from some sample documents are found on the web And then it'll create your primary and secondary navigation populate the menu for you and Then it imports the demo content so you see what's going on Then it'll rewrite your permalink structure for you So WooCommerce requires that for their endpoints to work then it just outputs what What it should look like and it already because I'm on OS X this open site URL will actually open my browser, which it did This guy test door to so if you Go over to the script See home shop about terms of condition privacy policy and contact the system works And yeah, it's actually inserted the shortcode Directly into the page from the script because when you install contact form 7 it creates a generic contact form So I just grabbed that Contact form ID direct out of the DB So now you did Do a whole bunch of nice demo stuff all the content's been imported and The terms and conditions actually pull in from a text file, which you can change if you need to And this is all Done automatically One thing I was trying to do was actually to reset the shop homepage But there's a limitation in how WPC a lie Manages its Pages so when you ask for a page from the from the database it formats it in such a way that it's a bit of a pain to Extract the IDs correctly with bash slash. I couldn't be bothered All that code is available up on here So if you want to mess around fork it make it better you can How many more minutes do I have? 20 Anyone have anything specific within WPC a lie they want me to demo Questions that I could mess around with at the same time If it's local everything Okay, the question was how is the theme metadata stored and if you're searching for a theme it's actually searching the wordpress.org repository and For anything that's on the installation. It's actually just querying the local installs database so Let's go over here so that there This is all done. This that's just querying. What's the current installs? That's actually an array that lives in the DB. So it's just been formatted into a nice format for you That's does anyone have a favorite plugin that I haven't installed. Oh, yeah It takes over It's sort of like a drag-and-drop system because we've got content editors that Obviously need that and have no idea about HTML on that. So when we put a Like a URL in the page that base 64 encodes it So it would search and replace do that because I know it goes through the serialized arrays and But would it manage to be able to pick up something like that? Don't think so because a base 64 encode it'd be a good thing to suggest to WPC a lie and I'll have a look actually I'll write that down because I like Contributing random things to it. So That's one thing I forgot to mention is that you don't have to just Install plugins or things from the WordPress repo. You can give private URLs and local zip files as well So if you have paid for plugins or anything like that You can just link to an s3 link or an internal server or something you've got or just package the zip file With your code that you zip up that you send up onto onto your server See what other commands I can demo for you then Play with posts so here's the The built-in help. So if you'd like WP It'll actually tell you all of the different available. Oh, this is my fun one. It's one of my favorite commands actually this allows you to generate skeleton code for custom post types child themes and taxonomies So say you've got a do you want to make an events post type? Let's go the whole whole shall we and you always want to be translatable See what happens? Boom Let's make that a little bit smaller It's outputted all the code you need to create a custom post up and it pre-fills in everything for you It does everything you need to do and you can literally just echo that directly into say Password because it I got really fancy and it creates a password and I never set them the same somewhere up here There we go back over here Theory what did I break? I probably break the functions. Thanks friends. Let's make sure I've got the equals on the end Well, we know just go over here. That's why it's what happens when you run too many terminals Lesson learned children and go and see is there any updates available? No, I just installed you You can actually All these things here all stored in side options So you could get fancy and find what those side options are in your database and Delete those options or change the options. So when you start when you log into the back end everything's already been Stop nagging me events Sweet events boom just like that so Yeah, and you can do child theme starts It's a nice way to get your plug-in and theme development done very quickly. Don't put them Custom post types in your themes never do that Always put functionality in plugins All right, how that looks yeah scaffold for a plug-in Where am I? Yep, I am there's so many Options for these that I don't actually often remember all of them. Oh and don't forget your plug-in tests as well Which it'll it'll auto create for you What would we call it my sweet plug-in and what else do we need to add to that anything I know text domain always text domain That should be for me. Nope What did I spell incorrectly? Not let us do that for No, it does not I will have to submit that change You can do tab complete once you install a whole bunch extra stuff. So it makes it a little bit faster I have no idea why this is so slow So what you get Very much a skeleton, but you get everything you need you get your PHP unit your grunt file so for your automations for your minifiers and pot generation and all those kinds of things all your tests and just the basic Plug-in file which has absolutely nothing in it and then from there you could use that to scaffold just your base plug-in template and then scaffold your Custom post types and your custom taxonomies and have it all packaged up and if you kind of know exactly what you want you can get most of the Skeleton of your plug-in done in minutes. I was totally logged in Yes Any extensions regularly for it? No, none. Okay. I haven't needed them. I've got any you'd recommend Yep I found a word commerce one, but they tried to get really fancy and it just blew up in their face and that's why I Ended up spinning beach ball of doom. That's why I ended up Making my own Well, yeah, well the the idea is that you can Call the word commerce commands and stuff to create these pages and all that and so they were actually Including all of the word commerce class files and doing all of this fancy. So I'm like, why don't you just make the page like that? So I they had this massive WC PC alive plug-in and I did it in like 10 lines of shell Does the same thing. So what I ended up doing was just a one thing you should do is If you want to see what a plug-in changes is do your database import export and then use Differential tool to see what changes in the database so you can see what options It's actually manipulating when it's installing and being configured and then take those options and put them in To actually change this so that one there is That takes away the word commerce nag screen in one line So that's kind of stuff Because I'm just wanting if you could if there was a dash P like my school dash P option But when you're creating users Passwords on the command line, you'll get them in the oh in the when you're creating users or when you're doing config You can do interactive But it's kind of pointless Yeah Yeah, the kind of the idea behind a lot of what I do though is that it is completely automated So you like you saw the script I run one line and then magic we have the The whole we commerce demo site up and running which is great if you need to just test some plug-ins on a local site You can just spin up that shell script once you've got WPC or lion stalled in a couple of minutes You've got a demo site that you can mess around with without having to sit there and click and drag in slight go Go up make coffee come back and it's ready to go So and then it doesn't really matter with local stuff You can that's why I've got it generating usernames and passwords and database names and all that kind of stuff My script doesn't work if you want to try and run multiple things at this on the same day unless you install them on different Directories then it's then it'll work fine There's a bunch of resources go and check out their github They're extremely active and very responsive to problems. They may have As my github and my little plug-in there, which will have a WPC a lie import soon Depends if it's a new production or an existing production. Yeah, that's always hard Something that I've done quite regularly is I will dump the production database into staging and Manipulate what I need to on the staging one and then export the database and run a text diff on the database and Then only import the changes back into production I Descripted Usually the plug-ins are cool and all that but they usually just get in the way So I just write a script to do it for me. Yeah, Json export or just SQL Json's really good because there's some really good Json diff tools now Which makes it very easy to import stuff There's actually a plug-in that allows you to export any WordPress option as a json object Which makes it very easy to then import using WPD We got time for one more question. Does anyone else Most of my stuff is usually just I don't like to polish a lot of my stuff before I put it up there I just put up there and hope that people use it or comment on it All my most of it is shell script actually I'm in the process of building a whole bunch of automated High availability WordPress infrastructure, which will be up there. That'll be a bunch of Docker files They're not there yet. I've just got a whole bunch of random node tests that I've been doing But this is the only probably the most polished repo minus my plug-in that's up there at the moment but feel free to fork it and give me some comments or if you've got other scripts you want to add to it because there's just a base WordPress and then a WooCommerce store, but you could probably build other ones that are Like a forum for instance, and then it'll auto-configure BP press Or you can do social media base one, which will Install other things Thank you very much