 Who the more hen who hot it with you? good Expression Netherlands, so let's go with English so WPC li is a command-line interface for WordPress and today when we have so many Command Line interface tools do we really need another one? Of course we do what? Yeah, WPC li is not just the most powerful tool You can use to do stuff to WordPress. It is also fun and not scary so now We are going to compare graphic user interface, which is WordPress dashboard and WPC li everything you can do In WordPress like fresh install no additional plugins just Default team you can do with WPC li so it's like equal, right? And this first level of using WPC li I like to think of as Guilfoy level But then you want to do more you want to list Chrome jobs. It's okay. Everybody does and you want to export and import databases With graphic user interface you need additional plugins to do that, right? with WPC li You don't you can do that on fresh install without any additional plugins. So now we have It's the same, right? Yeah, and This new level of using WPC li. I like to think of a pipe Piper level But then you don't want to always export and import the whole Database right sometimes you the database is just too big and you want Just parts of it with WPC li you can do that I had a client with the large database. Well, no their website had a large database clients Don't come with databases, right? And I didn't need all that stuff like team options and Millions of posts and users and everything I just needed posts for past six months With WPC li I could do that easily with just one command and I could even specify this query more like From this date to this date but or this author or just this category You can really specify it to meet your needs So something that could take a lot more time. I was able to do in 30 seconds and That's not all with WPC li you can scaffold You can scaffold plugins teams blocks and many more things and If we take a look at the graphic user interface, which is your dashboard There is no plugin for that So now if we compare it, it's still the same. It's not competition But this new level of using WPC li is And now you think that's all yeah, right? No, it's not With WPC li you can create your own custom WPC li commands talk about inception and Some very smart hosting companies and plugin authors are doing this for years So imagine you get a new project You log into hosting and oh my Gutenberg there is SSH but then you look further and You'll find WPC li now you're flirting But then you look even further and you see they have their own custom WPC li commands to do stuff on their server very quickly Now this new level of awesomeness is mr. Robot level And now I convinced you you want to start using it and we can start using it Now I don't have any computer or server without it So I'm not gonna show you how to install it, but it's a pretty straight forward and there is a nice documentation about it All you need is three and a half commands. That's it So first now if you don't see this this is make dot WordPress dot org CLI handbook guide Installing so you can find it all in documentation what you need first is this Command to download and it's working So basically you'd need only just one command to make it working and then you run this half of command To check if it's working it's working But you don't want to type PHP WPC li For every time you want to run command, right? So what you do you make it executable and then you move it somewhere in the path in your path where you can execute it and This is the most common name. So how you Type this you will type command like that. So this is how you name it You can name it whatever you want WP is common because From the moment you install it, you will actually do a lot of Copy pasting from slack stack overflow, right and documentation. So you are warned keep it, you know the common and now When we have installed it we can run WP info One too many Okay, and then you see the info on your System on PHP where it is what version it is your My SQL and your WPC li. I have the latest stable version Now before we start using it There are a few things to know to make it easier for you to to use it first thing to remember is every CLI command not just WPC li every CLI command is doing just one job. Don't complicate it It can do massive work, but it is just one task So keep that in mind also the structure of the command always try to be Consistent so what you have is WP or whatever you called it then we have none This is entity you want to work with and there are a lot of entities You can check it in documentation or just in in your terminal and after that we have verb Which is what you want to do with this entity and you will find a lot of entities have the same verbs like add create remove delete least generate and After that if this is not enough if you want to make it more specific What you can do is use flags. These are just parameters that allow you to to specify what exactly you want at any point There is a number of global parameters that you can use such as help. I Recommended highly because complete documentation is in help. You don't have to go to websites You will find everything there all parameters. You will find examples and all global parameters and There is another global parameter that I really love there. There are many but My personal favorite in the whole world, which is mind-blowing is prompt and we will see it today how it works. So now we know the basics and What I want to talk to you about today is how you can utilize WPC like to make your administration more fun because we know that's not fun and It's gonna be faster and we are going to talk about security Yeah, WordPress and security and development and some magic. Okay, so first administration consider this scenario You got email from old client is not old you you work with them for a long time ago And since then they never call never write nothing and now they write you email that They cannot access their login URL They try WP admin and login and it just keeps sending them to four or four page And that's because you were smart and you change the login URL to increase the website security And you even advised your client to change it again so that even you don't know it and let's pretend they did So they changed it. Okay, and now nobody in the world knows the login URL And you have two options you can go to Database if you have access and search which is boring or you can run one WPC like command Because we live in perfect world where every server has WPC like available and we have SSH access to it So yeah, you choose the second one. I support you. Let's do that. So I can say so this is my imaginary client and My port number and we can do this. So this is remote and if I type Info just to see if I have it available. Yeah, it's not the latest version of WPC like but it is available The only problem with this is I haven't heard from this client for a long time ago I don't know that port number. I don't know. Where is the file? I saved that port number I don't know even if I still have that file And I hate Memorizing port numbers as soon as I memorize one port number I forget all the parameters of WordPress functions that I ever used and that's not good But with WPC li you don't have to memorize anything You can use aliases You can create alias for every remote or local website that you are working on and you don't have to ever Think about logging or you know credentials whatever and you can even create alias for group of websites To do stuff in bulk. Just don't overdo it. Trust me So how do I know if I have alias for this website for this client? I can type WPC li alias List now here you see this word. This is list and here is the exception We have WPC li and alias. This is because alias is Configuration of WPC li on your machine. It doesn't have anything to do with configuration of the websites It's just on this machine. So if I check it here, you see I have two of them all is created When you create one custom, it's automatically created and it's obvious for all Aliases that you have you don't want to use it. Maybe you want to try. I don't know if you have too many You probably don't and there is client and you can see here credentials that I use now You can't just create alias and it's working. So before creating this alias I have created connection between my computer and server through SSH keys So this is just basic SSH administration I'm not going to go through there, but when you have that connection you can actually create alias Through SSH with WPC li and now we can start using it So I can say WPC client So you type WPC and alias name and after that Command like you would without alias and while we are there. Let me check the version of this WordPress. Oh It's up to date So disappointing This is what happens when you change routines before talk So this was supposed to be outdated and I'm gonna update it right now. So When you want to update or update WordPress you will use core update and before because I'm going backwards. I need to Well, not because I'm going backwards because I'm not going with the latest stable version. I need to specify version So I'm gonna say 5.8. We don't want to go too far back. It will break And after that because I'm going backwards. I need to force it Look ma no hands You don't even have to go there, but I would suggest going there just check if it's still there Okay, now it's outdated and Now we can pretend I did all the backup and everything that is recommended and I can update it so when you want to update to the latest version you just do this without any parameters and There we go It's updated. I wasn't even there and now let's do what we wanted to do to find that login URL So I'm gonna use command that I used More than I care to admit I love it It's for executing arbitrary PHP code at server. So you go there and you just execute code so it's evil and I Know it's not you And I happen to know what is wordpress for a function for getting the login URL. It's WP login URL and Here I'm gonna just add a new line for printing. So this this is not really important. This is just terminal stuff And here it is you should have asked Milana And this is my imaginary clients website Completely updated and nothing to see. Okay. So this task in real life could take you a Lot of time that you cannot bill you cannot log You know, you would send email to your client like I don't have credentials to hosting and then they would reply I don't have either So then you go and search through your computer Meanwhile, they replied. Oh, I found it then you log in and then you have to open ticket with support It can take a lot of frustrating time. You don't want that with WP CLI You can just do it in second and if you start creating aliases now for every website that you work on in your WP CLI config file You will find all credentials. You don't have to memorize Where's the the login that you save everything is there and you don't even have to open it because you can just find the alias and in two years, trust me, you will love yourself Yeah, so let's talk about Security now I'm gonna go to a local website. I have Now this is just freshly installed WordPress last night something like that and and Let's see what users we have Again, you see user list. So it's consistent now in next few minutes I'm gonna be saying things that are obvious and you know them and I'm not saying them because I don't think you know them I'm saying them because there is a point behind it. So bear with me So here we have admin. It's first Number one ID and its administrator. So that is the default user we have and now let's go to dashboard To see what this user can do now this command WP admin. You don't see it here You see it now WP admin is a command that will take you to dashboard Now why we didn't use it with alias in previous example It doesn't work with remote servers as expected But you can use it with locals like I don't remember any URL at all ever again Just type WP admin and this command doesn't come with WP CLI right away. You have to install it separately You can find it in documentation. It's just one command just one command and it's there. So let's log in and Here is the obvious stuff. So admin has access to everything there are posts categories tags pages Appearance there is this full-site editor plugins Tools You can edit team and plugin files in dashboard in 2022 I will repeat you can edit PHP files from dashboard If that's not dangerous, I don't know what is then Then Settings so this is obvious. This is what admin has and when you Install WordPress there is this default post hello world published and default team will always show this username of This the only user that we have right? So now we have only user only one user that has access to everything to editing PHP files in dashboard And the username is displayed on the front end. So everything we need now is just password, right? and WordPress websites gets hacked often that's not a Secret we all know that and I like to think of it because we are popular but You don't want your own website or the website of your client to Be the tool to measure WordPress popularity, right? And yeah, there was a time and WordPress was this security hole on server. Yeah Granted it was 2009 now WordPress is secure, but it still gets hacked because there is this user factor human factor and it can be many things it can be very jolly password It can be Installing plugins that are shiny, but we don't know where they came from and no developer looked at it, right? And many other things So there is a solution. It's obvious. It's right in front of us Remove the human factor, right? Well, no, we cannot do that We are building websites for humans to be used and created, right? So what we can do We can work around it and now I'm going to work around it. So first Thing I'm going to do. I'm gonna demote this Admin, but first let's see what user can do. What words we can do with the user so We can add capability add role. We can create, delete, generate, get, list so you see all these Consistent verbs then remove capability, remove role, spam, unspam. With update command, you can actually Change the password of the user. So if you want to have some fun with friends, you know, why not? I don't know. What's your cup of tea? And now I'm going to demote this admin, not remove, just demote. So I'm gonna say WP user remove role Now the parameter WP CLI needs to know which user, even though we have only one It needs to know which one. You can use user ID or username or email. I know it's user ID number one and if we list users now You see this role is empty and what that means if you take a look here at Admin bar when I reload the page There's nothing. You can try to go to dashboard, but there's nothing because WordPress Doesn't know what to do with you when you have no role. It just you know, okay, whatever I don't know who you are. Even subscriber has more access than this admin right now But I suggest keeping the password strong because you want your hackers to be amused You don't want to disappoint there But now we need someone who can actually do something in this WordPress. So we are going to create user and Now there is a number of parameters Some are mandatory some are not. I don't know. I know which ones because I practice for this talk But I don't want to know parameters. Yeah, I don't care. I don't want to memorize Anything and I don't have to now here. We have this The greatest global parameter in the world on work just use prompt and Prompt will prompt you with every parameter there is You don't have to type anything. You don't have to think about typos or which parameters You can just type what is unique for you. So user login. I'm gonna use outer And user email. It doesn't really matter because we are in local User role. So you see these are square brackets. That means it's optional. So these are the only two mandatory parameters and Default role is subscriber. I want author. So I'm gonna say author User password now this should really be strong password But I have to log in with this user in a minute. So let's pretend that this is a strong password Even though it's not and now if you have used If you have installed some software on Windows It's just next next next next I don't care. Whatever okay, so we have two users now and One is out or the other is no role And let me just go and log in with this again some obvious stuff author Can create posts, but doesn't know there are taxonomies never heard of pages No teams and plugins. No editing files in dashboard nothing. So this is very very limited Access for this user. They cannot even edit existing posts. They can just create their own posts So we have these two users one has no access at all the other one has very limited and from from terminal I can say WP plug-in install and activate and I'm gonna say simple history Nobody can do that from dashboard, but I'm doing it from terminal and What this plug-in does it will give you a list of Events that happened in your WordPress install and There is a list that you can see in dashboard if you had a user who can see it. We don't have that user, but We can do it from here simple history List now you see this plug-in author is smart. They created Custom WPC like command for their plug-in to be used in terminal and they've been consistent with list and I Can see that here. I can see everything what happened So how about that? When it comes to security, you know moving everything that is dangerous and everything that is important to SSH level Now if this author was your client, they would want more access and they should they should have But the next role is editor and that's too much for my taste So what are we going to do? Luckily WordPress has capabilities and capabilities are these small bits of Access and permission that you can combine and make every access unique Now you don't want to make every user experience unique He's you just don't have enough time for that But you can find something between author and editor that will you know be safe enough and this is what we are going to do WP user add capability now again, we need user ID or username or email I'm going to use ID and we need to tell which Capability we are going to give them so first. I think they should have Ability to manage categories and this is not just for categories. They will be able to manage Tags as well. I think someone who is making posts should be able to manage taxonomies next thing I'm going to give them option to switch teams and Do the same for plugins But it's not switch. It's activate What this will do? It will give them Ability to switch between existing teams, but not install new one and for plugins They will be able to Activate and deactivate but not to install new one and when you have a problem in WordPress when something happens and your WordPress doesn't work This is the first advice you will get from anyone just switch to default team and turn, you know Deactivate all plugins and then activate one by one to see where the problem is So I think everybody should be able to do this, but no Installing new plugins no introducing new PHP code a developer didn't see and approve and There is another thing Teams and plugins some plugins and even core are hiding some settings behind edit team options What this will give you in newer versions It will give you access to this full site editor where you can edit header and footer and create menus and all the things and There are other things that you can add. So this is just like basic. Well, these these are the four I learned Okay, and you can find all of them in Documentation WordPress.org support article roles and capabilities you can find all of roles here So roles are actually just group of capabilities role means nothing It's a group of capabilities and you can create your own roles and just pack it with with your own set of capabilities and Here you can find list of capabilities for every role there is So you can really refine everything and I believe this is our Responsibility to find this line where site owner can really have enough access to own the website, but not enough to break it so we can do that with capabilities and That's about Security, let's do development now Yeah Group of users. Let's let's leave that for the for the end. Yeah, let's I don't know probably who knows There is documentation we'll see so let's talk about development now When you start new projects often times you need the dummy content and It usually looks like another post yet another post another post It's just it takes a lot of time. It's useless because you just create posts You don't have content and you need more users and you need menus and you know well with WPC li you can use verb generate with all the entities that have it and You can generate post pages users widgets menus Custom post type. No, that's for a sky scaffolding taxonomies many many other things you can take a look in in documentation and Default number is 100 for each and you can actually use the parameters to to specify exactly what you want And it will be fun, you know to do it once but second time It won't be fun to do it to run all those commands So what you can do you can just put all that commands in bash script and Just run bash script and laugh out loud because you are not doing it manually just run it and yeah But that's for boring stuff Let's do interesting stuff Scaffold is my favorite command There it is and let's see what we can scaffold block child team package Plugin post type taxonomy team test plug-in tests underscores underscores is standalone team That is what we call now classic team It doesn't support blocks, but if you are still using classic teams you can use it, you know just to learn or maybe you are using it in your project and What we are going to scaffold? I mean we listen about blocks every day So I'm not gonna scaffold the block today. I'm gonna scaffold plug-in Again, there are parameters. I don't care slug Let's say wordComp, Netherlands The rectory name if I want to have it differently then slug. I don't want to title wordComp Netherlands 2022 Description we don't have a time outer WordPress community URI plug-in URI skip test don't Continuous integration provider is by default Travis, but you can set whatever you want if you want something different Activate yes, please Network we don't have force if you already have a plug-in that has the same Directory name you can override it, but I don't have so I don't care and we created a plug-in So let's go there Let's see what we have so you have been and there are some Useful scripts that you can use you can add more It's ready for npm. We all love that stuff, right? You can start writing tests right away There is grant file. So grant was default Task runner for WordPress projects before Gutenberg Now with Gutenberg we get more webpack, but grant is still there. It's working I mean, it's not broken and in this grant file. You will find one task It will collect all your strings from plug-in and create pod file for translation so it's useful you can convert it to webpack if you want or you can just use it and add more tasks and I want to show you this read me file so I'm gonna open it in nano because we want to close it eventually and Yeah So this is not just an empty text file This is a template if you want to host your plug-in at WordPress.org This is what you need and you don't have to go to WordPress.org and search for the page where it says what you need It's already here. It already collected data I typed in while scaffolding and what you need is just just change what is unique for your own Plug-in you don't have to reinvent the wheel copy paste or whatever just to write what is unique to your situation And now let's create this plug-in right. We didn't created it to do nothing Let's do this so here is the The PHP comment that we all know and love and here we can start typing so always Prefix your functions. I'm gonna say the title and I'm gonna pass title Now you see spaces that is WordPress coding standards return always escape your strings and always prepare for translation now it's gonna say World Camp Netherlands 2022 My text domain is World Camp Netherlands and I'm just gonna append the title here This is our little function and let's hook it to a filter Called the title You all know what's gonna happen now, right and my callback is World Camp Netherlands The title Okay, let's hope it's working Yeah, save and if it doesn't work it doesn't matter we will fix it Here it is our plug-in and what this plug-in does is It will add World Camp Netherlands 2022 before every D-title occurrence and I'm so happy Menu is not that anymore. It was before and it was very annoying. So This plug-in was created in less than two minutes in terminal during live talk and it would probably Pass code review at WordPress.org not because this function is amazing and I'm great developer But because it has everything it needs and I didn't write any of those things. I didn't download I didn't copy paste it was there in my terminal one command one parameter that's all you need and you should use this to make yourself a Better developer better developers first because this is following all the standards and best practices at WordPress.org Advice but also you can just start Doing your project. I hate today when you have to set up project when there is npm And then you need two days just to set it up and there's always some error and Docker is insane So you need a lot of time with WPC li you can just do it Just run command and start doing what you want to do. So help yourself and now We've been talking for 39 minutes and didn't break anything. What it's WordPress, right? So let's break something Yeah, I'm gonna do a little nightmare just remove semicolon, right? And this is what will happen. There has been a critical error seriously What can I do with this? If this is production, you really don't want anyone to know that error But you want you to know the error and if this was production what you would do You would download everything and then try to reproduce it and then fix it and then put it back on Testing first to see if it's working and then on production. It's at least one day. Your website is not working But with WPC li you can run when there is error You can run any command I will run something with teams because that's the latest loaded, right? So I want to cover everything. I'm gonna say WP team List whatever it doesn't matter really all you need is your old WordPress to load and this is what happens Here is error that is useless that we saw on front-end But here you have the full PHP error. So there is syntax error. Yeah, blah blah It's something is missing and we are not expecting on line 18. So let's fix it I see everything. Where is the problem? So let's go there again and The line was 18, right Here it is. This was unexpected and this is missing. Okay, and Let's go back and it's fixed now in real world You will probably not fix it this fast because it wouldn't be that little error But you would be able to see where the problem is deactivate plug-in or whatever just Let the site to live and then fix it in your local take time and test it and then put it back So I think that's awesome Now it's time for little magic Yay I will go to my Magic folder It has nothing in there. So it's completely empty and we're gonna run WP install Database name is magic as you expected Of course So this I'm not gonna use Next next next site title magic and Ural as well is magic. It's not magic Admin it's cooking Hold on. It's cooking So do we want to release the Kraken? I Want to release the Kraken? Hi Kraken And this is our magic So it's just a WordPress website that we have installed Running the bash script So let me show you that bash script to see what's there. I'm gonna open it in sublime text editor It's in bin It's there. Okay So this is pretty simple bash script. It might look like there's a lot, but it's really simple There are five WPC like commands here. So first we download WordPress then we need to create config file and this is Just getting database credentials. So I know that do you see it? Do you want me to zoom it? See it? Okay So I know it will always be root user for database for my local and I'm collecting here Database password even though it's always the same. It's my root password But I don't want to have my root password anywhere in documents and I also don't want it to be in my bash History so what I'm doing here. I'm just using a basic bash scripting to to get the inputs hidden then I'm getting the database name and I really didn't have to do this because I have prompt so I wanted you to see here You can use prompt with partial input. You can define what you want or you can take it from another file You know, you can go creative there and for every other parameter. You can just say prompt whatever, you know I don't know. I will maybe change it in the future. Maybe not you can just say prompt, but what why I did Use this database name why I collected it Separately is because I never want to type again email for admin in my local So I'm using it to actually build email address for this admin. So After creating a config file what we need to do is install and you can see here I'm just like talking to myself. It's just fun. You know almost there just one word and When installing WordPress you need again a number of parameters. I don't care to type I don't care to remind to remember what it is. I just can you know use it here and get my input With bear script. Now here is the rewrite command and I want you to take a look at This one. So this is the one we use to create a plugin and you will see here Maybe not it's too tiny, but there is index.php in URL and this website was also built with WPC li now that is because you Need to change permalinks, right and if we take a look this other one Magic that we created and we used script. There is no index.php In URL this is because we use this rewrite command to change permalink structure and I use hard Flag to just flush the rules So you need to be able to use rewrite command. You need to enable Apache modules Modry write and then you can do it for everything. So this is again configuration for WPC li in this computer, but all of that is in documentation and After that I have steam locomotive because it's fun This is something just Linux users do you know a little program and then toilet for coloring my Letters because we want color in terminal and then if I want to release the crack So this is actual script I use and I don't install WordPress every day So when I do I actually forget I have all of this and when I do I'm like, oh Crack and So if I want to release the crack and I can you I get Excal to say hi I'll be a crack and I can open Dashboard or I can have a wonderful day and this is just the beginning. So this is just installing WordPress You can add here any a set of plugins that you always do or you are always using one specific team Or you are always using Dutch language or anything that you are doing Specifically you can set it here and at the end you can run that script for dummy content. You can just Run one command and let it do you just you know take a coffee or tea and it's just Not repeating things not typing not memorizing Yeah, thanks. So I hope today you find Potential in WPC li for Everything you do and to make your work more efficient and More fun and more fast and my name is Milan. It's up. I am WordPress engineer at XWP. I'm the loudest member of WordPress documentation team I'm also classical musician. So if you want to talk about any of those things if you have any questions Just find me there. Thank you very much for your time