everything you always wanted to know about wordpress (but were afraid to ask)

15

Click here to load reader

Upload: evan-volgas

Post on 12-Apr-2017

1.343 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Everything You Always Wanted to Know About WordPress (but were afraid to ask)

THINGS YOU ALWAYS WANTED TO KNOW ABOUT WORDPRESS (BUT WERE AFRAID TO ASK)

EVAN VOLGAS

Page 2: Everything You Always Wanted to Know About WordPress (but were afraid to ask)

WORDPRESS.ORG VS WORDPRESS.COM

.COM VS .ORG▸ Build your mental model around eating in at home vs eating out at a

restaurant

▸ Eating at a restaurant:

▸ There’s not a ton of work involved to get your meal.

▸ They have menus. You can customize a few things about your meal. But you can’t customize everything. Your options are limited.

▸ But, there’s a good chance that the chef knows more about cooking than you do. And so there’s a decent chance your meal will turn out great, even if you can’t get everything you might want

Page 3: Everything You Always Wanted to Know About WordPress (but were afraid to ask)

WORDPRESS.ORG VS WORDPRESS.COM CONT.

.COM VS .ORG CONT.▸ Eating at home:

▸ You can do whatever you want. You are the only limit to your options.

▸ Depending on what you’re making, it might be cheaper to make it yourself. It might turn out better too.

▸ But, you have to do it yourself. Depending on what you’re trying to do, that could be really easy or really hard.

▸ Also, you may not be a very good cook whereas the chef at a restaurant probably is.

Page 4: Everything You Always Wanted to Know About WordPress (but were afraid to ask)

WORDPRESS.ORG VS WORDPRESS.COM CONT.

.COM VS .ORG CONT.▸ In this analogy, making your website on WordPress.com is kinda like getting dinner

from a restaurant.

▸ You have to “order from the menu” in a sense and your options are limited. But in a lot of cases, that’s not a bad thing.

▸ Making your website on WordPress.org is kinda like making dinner in your kitchen.

▸ Your options are limitless.

▸ Some things are extremely easy to make. And some people are great at creating all manner of fantastic things on their own.

▸ But, you have to do a lot of the work yourself.

Page 5: Everything You Always Wanted to Know About WordPress (but were afraid to ask)

WHAT IS AN API

AN API IS….▸ An application programming interface

▸ Build your mental model around soda machines.

▸ When you buy a soda from a soda machine, you are interacting with a machine via its software by utilizing an interface.

▸ When we’re talking about APIs, we’re talking about software that has an interface so that other software can interact with it.

▸ For example: the WordPress APIs https://codex.wordpress.org/WordPress_APIs

Page 6: Everything You Always Wanted to Know About WordPress (but were afraid to ask)

WHAT IS (WEB) ACCESSIBILITY

WEB ACCESSIBILITY IS…..▸ Making sure that the web is not difficult or impossible for some people

to use

▸ There are 20 million blind adults in the United States; eight percent of men are color blind; approximately 10 million Americans are hard of hearing and one million are deaf.

▸ When people talk about making the web accessible, they’re talking about the fact that this building we are standing in right now has elevators for people who need or want them. The web, by and large, does not.

Page 7: Everything You Always Wanted to Know About WordPress (but were afraid to ask)

WHAT IS WORDPRESS

WORDPRESS IS…▸ A database (with your posts, pages, some data about your users, some

info about your website, etc)

▸ A bunch of PHP (functions.php, template files, etc)

▸ Some files on your server: CSS, JavaScript, images, and other files that are organized on your server in such a way that WordPress can find them, kind of like you organize the files on your own computer so that you can find them

▸ A bunch of rules and conventions about how all this stuff is supposed to work together <— This is key

Page 8: Everything You Always Wanted to Know About WordPress (but were afraid to ask)

WORDPRESS RULES / CONVENTIONS

THE TEMPLATE HIERARCHY▸ Every WordPress theme, at a minimum, has index.php and

style.css

▸ A lot of WordPress themes have special page/post templates in addition to that

▸ Twenty Fifteen for example has templates for pages, posts, the 404 page, the archive…

▸ The Template Hierarchy is just a bunch of simple yes/no rules that associate your content (pages, posts) in the database with any number of templates on your fileserver.

Page 9: Everything You Always Wanted to Know About WordPress (but were afraid to ask)

MORE WORDPRESS RULES / CONVENTIONS

HOOKS▸ Hooks are likes Legos for your website’s codebase. They

let you attach your own code to whatever WordPress is doing (ex: after the header prints, render a photo of a lolcat)

▸ There are two types of hooks in WordPress

ACTIONS & FILTERS

Page 10: Everything You Always Wanted to Know About WordPress (but were afraid to ask)

WORDPRESS HOOKS: ACTIONS & FILTERS

▸ ACTIONS DO STUFF If a user clicks this button, print a message that says “You’re awesome!”

When you publish a blog post, share the link and the title of that post on Twitter

▸ FILTERS MODIFY STUFF If the user is logged into your site, modify the message to say “You’re awesome, $current_user-> display_name”.

Before you publish that post url and title to Twitter, shorten the url and rewrite the title to make it all fit under 140 characters

▸ Ideally, filters don’t actually do anything except take an input, modify it, and give it back to you (that is, they modify the message you want to send to Twitter, but they don’t actually send the message)

Page 11: Everything You Always Wanted to Know About WordPress (but were afraid to ask)

WORDPRESS AHA MOMENTS

FIRST AHA MOMENT OF THE DAYFILTER HOOKS DON’T NECESSARILY FILTER THINGS *OUT*

▸ The point about filters is just that they take an input, modify it, and return it.

▸ It has nothing to do with filtering things out or returning less of something somehow

SECOND AHA MOMENT OF THE DAY! FILTERS THAT DO STUFF ARE DANGEROUS

▸ A great example of this: http://ottopress.com/2011/actions-and-filters-are-not-the-same-thing

Page 12: Everything You Always Wanted to Know About WordPress (but were afraid to ask)

WHAT IS DOING DEVELOPMENT WITH WORDPRESS?

▸ If you printed a list of actions and filters in WordPress along with a one sentence description of what they are, you’d need about 50 pages to print them all out

▸ By the time you add the topic list on wp-config.php and the database API, you’re well over 100 pages

BUT (HERE’S THE GOOD NEWS)

Page 13: Everything You Always Wanted to Know About WordPress (but were afraid to ask)

DOING DEVELOPMENT WITH WORDPRESS HAS NOTHING TO DO WITH KNOWING EVERY

FILTER AND FUNCTION AND API AND ACTION ON THE PLANET

Page 14: Everything You Always Wanted to Know About WordPress (but were afraid to ask)

DOING DEVELOPMENT WITH WORDPRESS

VARYING VAGRANT VAGRANTS

▸ https://github.com/Varying-Vagrant-Vagrants/VVV

▸ VVV is a way for you to run multiple copies and versions of WordPress on your laptop without having to fight with MAMP/WAMP/XAMPP etc

▸ It pretty much Just Works and lets you practice (for example) editing a PHP file on your local computer and immediately being able to see how it works in your browser

▸ It also behaves the same way that a real server would. If you’ve ever deployed code you tested on MAMP/WAMP/XAMPP and had it blow up in your face cause your server had a different version of PHP… you’ll love VVV

▸ You can also check out Chassis: http://docs.chassis.io/en/latest/

Page 15: Everything You Always Wanted to Know About WordPress (but were afraid to ask)

DOING DEVELOPMENT WITH WORDPRESS: WHAT NOW?

WHAT NOW?

▸ Get VVV set up on your computer.

▸ Start with Fifteen Five and see if you can write a page template for any posts categorized as “dog.”

▸ Write an action hook that prints a message: “Hello dog lover” after the header whenever you’re on a post categorized as dog. See if you can do the same with some login in category-dog.php and with some logic in functions.php

▸ Write a filter hook that prints the user’s name after the message, if the user is logged in

▸ Read the settings in wp-config.php. Change a few of them. See what happens.

▸ Read the docs. Keep playing with the code.

▸ And if you run into something you don’t understand….don’t be afraid to ask :)