Wordpress 2 Flashcards
Wordpress uses a ……… templating system?
distributed
What principle is the templating system in wordpress based on?
DRY - Don’t Repeat Yourself.
What is one of the most important things you have to do in the functions.php to allow support of child themes?
You should wrap your functions in a conditional block:
if ( ! function_exists('the_name_of_function')) { function the_name_of_function() { } }
This allows child theme creators to override your functions if they need to. This is referred to as “pluggable functions.”
Under appearance in the WP dashboard, there are some sub menus, like “themes”, “header” etc. Where are these defined?
In functions.php. There are entries for “add_theme_support” that allow you to add / remove options from the menu list.
The call to add extra stylesheets should always be done where?
In the head section of the markup - however, you don’t add these directly, you must use the enqueue function from functions.php
In the styles.css file there is a section called css reset - should you touch this?
No, in general leave it as is.
Why is it useful to use rem’s to resize fonts?
The rem (or relative em size) is based on the outer most element (the body tag) - in underscores for instance, this will be set to 100%, so when using rem’s you can be sure you are using a consistent sizing method, and you shouldn’t get screwed by hierarchical nonsense.
Not every browser supports rem sizing, how do you support a fallback?
Make sure you put both px and rem size, and make sure the rem size comes after the px size. That way, if rem isn’t supported it’s simply ignored, and if rem IS supported, it will overwrite the px size.
font-size: 16px;
font-size: 16rem;
How do you use hsl colors in your css?
color: #404040;
color: hsl(0, 0%, 25%);
NOTE: First 0 doesn’t have a percentage, and note that we are providing a fallback for browsers that don’t support it.
If you want different styles to apply to different pages, where should you put your css?
It should likely go into one of the css files (content-sidebar or sidebar-content) in the layouts folder. In order to load this, you need to enqueue it in the functions file.
What are the three main elements that are typically kept in the header.php file?
The site title, the site tagline and the main menu
The enqueue scripts are hooked into what function?
wp_head();
This means that all the styles, scripts etc that you enqueue in functions.php, will appear in the header at the location of the wp_head() call.
What is the custom header feature in wordpress?
It is a feature that allows the user to modify how the header is display. It must be enabled in wordpress, usually through the functions.php file (some themes may wrap the functions in a file in the inc directory).
What is one of the gotchas with using the custom header function?
There is an option (tick box) that allows you to disable the display of the site text. However, this means the HTML may still be showing in the header.php file.
When you setup a theme so that you can edit the theme in the customizer, where does the config occur?
In a js file called customizer.js (at least for the underscores theme it is).
If you make a change in customizer.js and it doesn’t change in the customizer, what may be the problem?
A lot of browsers will cache customizer.js, you must flush the cache in the browser.
What is the best tool for enabling keyboard control of menus?
Super Fish
How do you add a custom search form?
In the header, you can simply call get_search_form() and wordpress will give you the html for the form. You can add additional styling by wrapping the form in your own HTML.
If you are using something like font-awesome, it uses i tags to inject an icon/font into a page using CSS. What does this mean for accessibility?
If you are using a keyboard or screenreader, you will not be able to access the icon as it technically doesn’t exist. You should use a anchor link (a href) to make sure there is something for it to find. You can use the css (wordpress) class screen-reader-text to hide it so it doesn’t affect layout.
What css class can be used to hide an item and what is the caveat?
screen-reader-text
However, this is intended for items that should be invisible to a user, but visible to screen readers or keyboard input for accessibility purposes. Therefore you shouldn’t just use it on everything.
Wordpress refers to the location that widgets can go as the “sidebar” - is that technically the only place they can go?
No - that is legacy. Widgets can also go in the footer, or elsewhere on the page.
Where are widgetised areas created?
functions.php
What function is used to create a widgetised area?
register_sidebar()
What html element are widgets usually wrapped in?
An “aside” tag