Handbook Examples: Documentation

Any good theme has some documentation. A video tutorial on how to setup some basic options, a specific page on how to use hooksHooks In WordPress theme and development, hooks are functions that can be applied to an action or a Filter in WordPress. Actions are functions performed when a certain event occurs in WordPress. Filters allow you to modify certain functions. Arguments used to hook both filters and actions look the same. inside of the theme. How to make child themeChild theme A Child Theme is a customized theme based upon a Parent Theme. It’s considered best practice to create a child theme if you want to modify the CSS of your theme. https://developer.wordpress.org/themes/advanced-topics/child-themes/. or even a simple how to install the theme. These are examples of documentation. Let’s keep this going by leaving a comment below on some documentation examples.

I’ll start it off:

Action hook

/*
 * Fires before the opening #page tag
 */
function theme_before_page(){
    do_action( 'theme_before_page' );
}

FilterFilter Filters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output. hook

/*
 * Returns a specified width for the slider
 * 
 * Usage:
 * add_filter( 'theme_slider_width', 'my_callback' );
 * function my_callback(){
 *     return 755;
 * }
 */
$width = intval( apply_filters( 'theme_slider_width', 600 ) );