 We回 nama kai jagini kita kina wakisa jya kufika... kuk majita kak rewarding jassim pomayakia sipazabimu, S، sipazabimu laksitik indone na sehNo granoso, her Tunia wan Twini lu lit Themm, wa la mania sobo para kupya pasuku duchimu Reh, Assла� wa omi Kosgino al Asim eni mwenili jasa Twini lu hasu tenti speziu commissionu, kutunia m hinge hini uirti sipazabimu. to come with the consistency in terms of design that you do have. So I'm going to use our block template, so I plug in here. So I'll save this inside our plugin of our website. And I'll drop it here and add it to our workspace. And in here I'm just going to change these small tags that I wanted to do that I've been using before. So I'll call this our newsletter style guide. We're going to use this as our style guide for our newsletter to make it look like it's mail chimp. We'll give this a newsletter style guide, text domain, and we'll give it a version and say this is our version 1.0.0. So what we're going to do is come back to our plugins this side, leave this page, come back and we're going to activate it and we have it ready to start with. Now we're going to create a new custom post type as we work with our new style guide for our newsletter. So the first thing that we'll do is that we're going to type tap into an action hook of wordpress which is called init. Now in init we're going to add a function that we shall call newsletter blocks and I'm going to use namespaces in this case so that I don't have any trouble with any other plugins. So I'm going to add a namespace and I'm going to do omchigai and then I'm going to do a forward slash and then add newsletter blocks as our namespace. So if you want to see how this work, I have a video that I've just added in the link that is above so please visit it to see the pros and cons of why I would use our namespaces in my plugin. So the first thing that I'm going to do is add a function with our namespace blocks and then I'm going to start adding our code here. So the first thing that we shall do is that we're going to register a post type that is actually called and this is a function that is in wordpress and we're going to call it a newsletter for now. And in newsletter we shall need to throw a bunch of arguments to make this actually work. So we're going to write our arguments up here, our args and then that will be an array of a couple of options and then that will be run when we have our newsletter, our post type working. So the first thing that we want to do is that we want to make it public and we shall set that to true. But what I'm going to do here is add this in quotes because other is my PHP will throw errors. It's going to be true. And the next thing that I want to do is add a label for my post type and that label will be newsletter. And then of course add a comma here to add more options. What I want to also do is that I want to show it in the REST API and this will allow us to actually work with Gutenberg by having this as true. The moment we add it as false we will not be able to work with Gutenberg and yet that's what we are looking at using to make this possible. Now the new option that is available and that we need to use is actually called template. This will allow us to tap into what we'll call the block templates. This allows an array of options. Now in this array we're going to have an array of other components in there. So we're going to throw in core blocks in here. And these core blocks are what we have when we come to let's say the pages edit. When we go to edit a particular block for example this is a paragraph block but it can be changed into a number of items maybe a group block, a verse. So those are the core blocks that come by default into WordPress. However we can have blocks that come in from other plugins and those are not the ones that I'm talking about. I'm talking about the core blocks in our template going to be shown. We now start adding our core blocks so each of these block comes as part of an array. And the reason this is is because they also have options in there. The first thing we do is add the ID and it's always also a namespace of core. And we're now going to add an image which is a part of core. These namespaces can be found by going to the documentation of the blocks editor. So we can have maybe a cover image, cover dash image. We can have an image. We can have a heading. We can have a paragraph and this will be available. But for now let's use an image and with this image it will also accept an array. And in this array we are going to determine whether this is actually aligned to the left or we are aligning it to the center. For example now with this I'm just going to align it to the center. So let's save this and see what we have so far done in our plugin. So I will save this and reload. And when we come here we actually see that there is a new post type called newsletter. And we can add a new newsletter. And when we come here we already see that this is actually locked in. We have to just add a title and say maybe this is the March newsletter. I'll just add this March 2020 newsletter. And we already are ready to just upload or add something from our gallery. And then we'll be able to save this and use it in our newsletter. So I can make it full width if need be. I can change the different settings about it. So this is the power of the block templates allowing us to do this. So I'm just going to send this back to center. And maybe we can give this a caption and say we are making the new video ready as our caption. And we shall publish this. Of course we still have the option of adding all our other blocks that available. But what I want to do now is that I'm going to lock down so that anytime someone creates a new newsletter the only block they do get is actually the image block. And that is simply done by a very simple technique. So the other option that we do add to lock that is we have what is called a template underscore lock. And it comes with two options. It has the option of either saying all and this essentially will say do not allow any insertion of any new blocks. Do not move the blocks around. Basically just keep what I have set up here. So in this case you will see we have an option because we are adding a new command to our templates. We're going to allow that and you'll actually see now we don't have any other blocks. We cannot add even a new image block. All we have to do is just edit what's available here. We can insert we can replace the image by coming here and then changing it. That will be available but we can't add any other blocks. We can't add any new images here. So this is good if you are actually working with a number of people and you as a designer have set up how your block should actually look like how your particular post type should look like. So what we're going to do here is we're going to go back into our code and we're going to just add a couple of core blocks in here to settle this down. So I'll add an array, another array and in this time we're going to just add a paragraph and for the paragraph what we're going to do is that we're going to just add a placeholder inside our array. So we have a placeholder and in here we're going to just add an instruction and say maybe add the except of the story. So if we save this, come back and reload this page we'll actually see that our blocks are still locked out but in here we are able to add a paragraph and that's the only thing we can do. So we can have this is the main story of our day. So when we do that, change this image by replacing it from the media and then save it. We shall have our newsletter actually ready for showing to the other people. So the reason this is not working out is because I need to come back to pama links this is a normal error in Wordpress and I'll just set this to post name, change the pama link type and then when I come and reload we actually have our newsletter and we have our story there and we are good to go. So you can add a number of blocks inside your newsletter, lock it up and make sure that people are following the style that you've actually set up. So this could include just having columns and having the columns, having the different images locked inside them and then you can have your sort of mailchimp inside your own Gutenberg editor and inside your Wordpress site. So I hope you enjoyed this video and you saw the possibilities that are available. If you like the video please give it a thumbs up if you haven't subscribed to the channel please subscribe and let us know what you'd like to see or if you're having any challenges let me know how this is working out for you. Have you tried it out? Please share with us and let us know. Thank you for watching and happy coding.