/**
 * Get the current layout.
 *
 * This function return the current layout according the the view it is called from.
 *
 * @since 1.0.0
 *
 * @return bool Layout, false if no layout found.
 */
function beans_get_layout()
{
    if (is_singular()) {
        $layout = beans_get_post_meta('beans_layout');
    } elseif (is_category() || is_tag() || is_tax()) {
        $layout = beans_get_term_meta('beans_layout');
    }
    // Fallback onto the global theme layout option if value is false or default_fallback.
    if (!isset($layout) || !$layout || $layout === 'default_fallback') {
        $layout = get_theme_mod('beans_layout', beans_get_default_layout());
    }
    /**
     * Filter the layout id.
     *
     * @since 1.0.0
     *
     * @param string $layout The layout id.
     */
    return apply_filters('beans_layout', $layout);
}
Example #2
0
 /**
  * Get the field value.
  */
 private function get_field_value($field_id, $context, $default)
 {
     switch ($context) {
         case 'option':
             return get_option($field_id, $default);
             break;
         case 'post_meta':
             return beans_get_post_meta($field_id, $default);
             break;
         case 'term_meta':
             return beans_get_term_meta($field_id, $default);
             break;
         case 'wp_customize':
             return get_theme_mod($field_id, $default);
             break;
     }
 }