Skip to main content

Class Reference

The Method_Layout class is a PHP class for building the front-end of your site in an efficient and performance-friendly way. Method_Layout is an abstract class, meaning it cannot be used directly and must instead be extended by a theme-specific layout class. Method includes a barebones extended class to use as a starting point, which can be found in lib/class-theme-layout.php


Properties#

  • $meta
    ( array ) When building a single post (of any post type), all meta for the current post is stored in this array. Rather than interacting directly with this property, several methods are provided to assist in easily retrieving and using meta keys. These include: get_meta(), get_serialized_meta(), get_headline(), and get_content()
  • $loaded_meta
    ( array ) This is an array used to load meta from a different post. This can be useful in loops, especially if you need access to numerous meta keys. Meta is loaded into this array by passing a post ID to the load_meta() method, and is removed from this array by calling the unload_meta() method. As with meta for the current post, several methods are provided to assist in easily retrieving and using loaded meta keys. These include: get_loaded_meta(), get_serialized_loaded_meta(), get_loaded_headline(), and get_loaded_content()
  • $opts
    ( array ) Theme options are loaded into this array upon calling the build_page() method. While Method uses the theme options page route, theme mods can be loaded into this array. A handful of methods are provided to assist in easily retrieving and using option keys. These include: get_option(), get_headline_from_option(), and get_content_from_option()
  • $id
    ( int ) When building a single post (of any post type), this property is set to the ID of that post so that it can easily be referenced across the class.
  • $html
    ( string ) HTML markup assembled by the layout class and returned to the template calling the build_page() method.
  • $modals
    ( string ) Bootstrap modal markup to append to the end of the $html property before it is returned to the frontend. Modal markup can be appended directly to this property as needed, or can be added by using the inject_modal() method.
  • $scripts
    ( string ) Scripts (or any other markup) that appear after all other markup generated by the class. Markup is appended directly to the property.
  • $attr
    ( array ) An array used to hold various bits of information about the current page being built. Examples include the post type of the post or archive being built, whether or not it is the front page, and taxonomy information. Layout components passed to the buildcomponents() method are also stored in this array, under the _components key.

Methods#

Abstract Methods#

Post Meta Methods#

Theme Option Methods#

Frontend Building Methods#

Bootstrap Elements#

Utility Methods#

Other#