Last Updated: September 17, 2016
· leoj3n

Theme Wrappers™

Due to the confusion caused by the implementation of scribu's theme wrapper "technique" in Roots (db41099f5b) I have created the following diagram:

Link to larger size →

By reading the code in order, as indicated by the numbers and colored lines, you should be on your way to understanding the logic behind the "theme wrapper".

Additional explanation...

Notice how near #2 the Roots_Wrapping class in lib/utils.php looks for 'base-%s.php'? This means you can make your own base-*.php files such as base-page.php. If you don't create your own base files, the wrapper falls back to just base.php

Notice how near #4 base.php includes whatever "template" was passed by WordPress? The "template" passed by WP may be page.php or single.php or any other template. This is the beauty of the theme wrapper because, without the wrapper, the code surrounding that include would have to be repeated in, for example, page.php or single.php... this allows the template files to be extremely concise. Check out the contents of page.php and single.php in the root of Roots to see what I mean.

1 Response
Add your response

That was the best explanation I've read of it. Thanks!

over 1 year ago ·