/** * Display a widget area. * * @since 1.0.0 * * @param string $id The ID of the registered widget area. * * @return string|bool The output, if a widget area was found and called. False if not found. */ function beans_widget_area($id) { // Stop here if the widget area is not registered. if (!beans_has_widget_area($id)) { return false; } _beans_setup_widget_area($id); /** * Fires after a widget area is initialized. * * @since 1.0.0 */ do_action('beans_widget_area_init'); ob_start(); /** * Fires when {@see beans_widget_area()} is called. * * @since 1.0.0 */ do_action('beans_widget_area'); $output = ob_get_clean(); // Reset widget area global to reduce memory usage. _beans_reset_widget_area(); /** * Fires after a widget area is reset. * * @since 1.0.0 */ do_action('beans_widget_area_reset'); return $output; }
/** * Generate layout elements used by Beans 'imageradio' option type. * * Added layout should contain a unique ID as the array key and a URL path to its related image * as the array value. * * @since 1.0.0 * * @param bool $add_default Optional. Whether the 'default_fallback' element is added or not. * * @return array Layouts ready for Beans 'imageradio' option type. */ function beans_get_layouts_for_options($add_default = false) { $base = BEANS_ADMIN_ASSETS_URL . 'images/layouts/'; $layouts = array('c' => $base . 'c.png'); // Add sidebar primary layouts if the primary widget area is registered. if ($has_primary = beans_has_widget_area('sidebar_primary')) { $layouts['c_sp'] = $base . 'cs.png'; $layouts['sp_c'] = $base . 'sc.png'; } // Add sidebar secondary layouts if the primary and secondary widget area are registered. if ($has_primary && beans_has_widget_area('sidebar_secondary')) { $layouts['c_sp_ss'] = $base . 'css.png'; $layouts['sp_ss_c'] = $base . 'ssc.png'; $layouts['sp_c_ss'] = $base . 'scs.png'; } /** * Filter the layouts. * * - $c stands for content. * - $sp stands for sidebar primary. * - $ss stands for 'sidebar secondary. * * @since 1.0.0 * * @param array $args An array of layouts. */ $layouts = apply_filters('beans_layouts', $layouts); if ($add_default) { $layouts = array_merge(array('default_fallback' => __('Use Default', 'tm-beans')), $layouts); } return $layouts; }
/** * Echo secondary sidebar template part. * * The secondary sidebar template part only loads if the layout set includes it, thus prevent unnecessary memory usage. * * @since 1.0.0 */ function beans_sidebar_secondary_template() { if (stripos(beans_get_layout(), 'ss') === false || !beans_has_widget_area('sidebar_secondary')) { return; } get_sidebar('secondary'); }