In this video you'll make a change to the Wordpress dashboard instead of the front facing Web site.
This is accomplished through editing the functions that BHP file within the active theme to keep the
parent theme from losing changes when updated.
This should be done elsewhere.
In our case the child theme is the perfect place.
You'll use a code snippet from WordPress start to remove a menu item from the Wordpress dashboard in
a way that it hears to best practices since we're going to be making some fundamental changes to the
files within our child theme.
It makes sense to make a backup first.
One thing you can do is go to your migration or backup plug in and go ahead an expert export a whole
copy of the site that you know you can re-install if you need to.
Another thing you should do as well is to take the file structure that you're working with and just
create a backup original that you can revert to if you make a mistake or need to upload the old original
files to the file structure knowing that my theme is the affinity child too.
I could go straight to Windows Explorer or via FTB if the site is live and go inside of the file structure
from my site and NWP content themes.
I can see that this whole folder child O2 has a set of files.
So one thing I could do is just right click and create a copy and then I could go outside of my site
say somewhere into my computer like my desktop and I'll create live site and I'll just right click and
I'll paste that copy.
Now I know outside of my site itself I have a copy of the file structure for those theme files.
Now when I open these files from the actual active theme within my code editor I'll know that I have
a backup just in case I make a mistake go ahead and open your code editor and go to the child theme
and open the functions dot ph P file.
The only things in this functions that BHP are in cuing the style sheet like we did when we manually
created our child the files before.
After this comment section I can add any other code snippets or pieces of code that I want to use to
make fundamental changes to my wordpress installation.
You can find plenty of different WordPress code snippets if you just do a search for code snippets WordPress
for example and there are so many different developers making stuff for Wordpress that you can find
a lot of good code snippets.
I found a function referenced inside the Wordpress dot org support area code x that talks about how
to remove a menu page.
For example if I were inside of my wordpress dashboard that I was making this site for a client I might
want to eliminate their ability to add new users and look at all users if they don't need it.
If there's only going to be one administrative user if I get rid of this user's menu all together they'll
still be able to edit their own profile up here.
But the ad users and all need all users pages will be invisible to them.
So how do I do that.
I simply need to find the code snippet that I'm looking for and insert it inside the tags in the existing
functions.
DHP file.
That would be within my child theme.
You can read a little bit about how this function is used but here's an example and you can see that
what it's going to do is remove the menu page for any of these menu items.
If I just want to remove the user's item from the admin dashboard I could simply go over here and just
use the user's line inside of this piece of code.
Now when you add code snippets to the functions that ph profile you don't need the PH P-TECH beginning
or end because that file already has it right there.
So I'm going to go into this function example.
I'll just go ahead and select the whole thing and hit Control C to copy it and I need to go into my
code editor a couple of line breaks past the last item and paste it right in there.
It's nice that the code editor gives us some color syntax highlighting so we can see more easily what's
going on.
I'm going to go ahead and erase all the items that I want to leave and create some code that will just
remove the user's DUP THP file.
That is the user's menu item.
The file itself.
If you browse with the URL is still there.
We're just removing the menu item for any administrator and I'm going to clean up the code a little
bit.
Give it a little space so it's very readable and there it is.
I'll take control s to save and let's take a look.
I refresh the page inside of the administrator dashboard between plugins and tools.
I no longer have a users menu so go ahead and give that a try.
Update the admin page removing the user menu using the same function reference that I found.
I did find that page inside of the Wordpress darg codecs by searching for Remove admin menu and it was
the first function reference called remove menu page inside of Wordpress or pause the video now and
make that edit to the administration page.
If you haven't already
great Chanuka.
Well here's another challenge for you.
I'd like you to follow along with me here while I go to the current theme and hit Ed.
And under the affinity child to the style sheet that we're using is here and the theme functions Doppie
HP files here.
I'd like you to go into the Wordpress code editor here and under themed functions functions dot ph p.
Go ahead and remove that semi-colon and then let's go ahead and update the file.
Oops we've been here before.
Inside of one of the other chapters.
But now both the admin dashboard and the site itself are going to give us the white screen of death.
Oh my.
Even if you go back to the U R L for for the dashboard itself it's not going to work.
We've broken the site by making a mistake in our code inside of the functions dot ph P file.
Your challenge is to restore the site back to working again any way that you can give it a go.
Well how did it go.
Were you able to get back and replace the functions up here HP file with your backup.
Or maybe you just edited that file and added the semi-colon that we had mistakenly taken out before
and then refresh and fix the site.
Those are the two options and I'll show you as I go ahead and do it.
There's the functions that BHP file and it's actually updated itself within my code editor because I
can see what's going on there.
Now one of the things that I can do is go over to a different place inside of the windows explorer and
actually hear let me open up my backup.
This is live site infinity Here's my backup file called functions.
All right.
I'm going to right click and go ahead and actually you know what I do I'm going to just copy that file
over by holding control into that theme.
The theme folder and I'm going to go ahead and copy and replace it that way it doesn't matter what mistake
I made.
I am replacing that file with my original.
And now that it's copied it over the new site should work.
Let's check it out.
Refresh the page.
Take a deep breath.
You've restored the website to normal great.
How about the dashboard area.
Who.
Well that says something about Cowboy coding.
You really should be working in a staging area.
That's separate from your live site while you make any fundamental changes.
Just in case you go ahead and break the Web site and then have to fix it again.
So if I look under appearance themes and then in the editor I can now access the functions that P.H.
file and it's back to where it was before.
Of course the changes that I had made under under the functions that BHP have been replaced because
I didn't make a backup after I made those code changes.
So if I wanted want to have that function I would go back and replace what I had been doing this time
making sure that I include the semi-colon that's needed.
For now though I'm going to leave that edit out of our functions that ph P and leave it the way it was
before because I actually do want the users button right there in case I need to use it later.
In this video you edited the functions that P-H profile of the child theme in your local environment.
You looked up a code snippet and pasted an edited version into the file making a change to the Wordpress
dashboard.
You also broke the Web site by missing an important semi-colon and fixed it by accessing the file and
fixing your mistake in the next video.
You'll log into your students sandbox at W.P. of course dot com and configure your first Genesys child
theme using the custom either