/** * Add Beans options to the WordPress Customizer. * * @since 1.0.0 */ function beans_do_register_wp_customize_options() { $fields = array(array('id' => 'beans_logo_image', 'label' => __('Logo Image', 'tm-beans'), 'type' => 'WP_Customize_Image_Control', 'transport' => 'refresh')); beans_register_wp_customize_options($fields, 'title_tagline', array('title' => __('Branding', 'tm-beans'))); // Get layout option without default for the count. $options = beans_get_layouts_for_options(); // Only show the layout options if more than two layouts are registered. if (count($options) > 2) { $fields = array(array('id' => 'beans_layout', 'label' => __('Default Layout', 'tm-beans'), 'type' => 'radio', 'default' => beans_get_default_layout(), 'options' => $options, 'transport' => 'refresh')); beans_register_wp_customize_options($fields, 'beans_layout', array('title' => __('Default Layout', 'tm-beans'), 'priority' => 1000)); } $fields = array(array('id' => 'beans_viewport_width_group', 'label' => __('Viewport Width', 'tm-beans'), 'type' => 'group', 'fields' => array(array('id' => 'beans_enable_viewport_width', 'type' => 'activation', 'default' => false), array('id' => 'beans_viewport_width', 'type' => 'slider', 'default' => 1000, 'min' => 300, 'max' => 2500, 'interval' => 10, 'unit' => 'px'))), array('id' => 'beans_viewport_height_group', 'label' => __('Viewport Height', 'tm-beans'), 'type' => 'group', 'fields' => array(array('id' => 'beans_enable_viewport_height', 'type' => 'activation', 'default' => false), array('id' => 'beans_viewport_height', 'type' => 'slider', 'default' => 1000, 'min' => 300, 'max' => 2500, 'interval' => 10, 'unit' => 'px')))); beans_register_wp_customize_options($fields, 'beans_preview', array('title' => __('Preview Tools', 'tm-beans'), 'priority' => 1010)); }
/** * 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); }