/** * Echo no widget content. * * @since 1.0.0 */ function beans_no_widget() { // Only apply this notice to sidebar_primary and sidebar_secondary. if (!in_array(beans_get_widget_area('id'), array('sidebar_primary', 'sidebar_secondary'))) { return; } echo beans_open_markup('beans_no_widget_notice', 'p', array('class' => 'uk-alert uk-alert-warning')); echo beans_output('beans_no_widget_notice_text', sprintf(__('%s does not have any widget assigned!', 'tm-beans'), beans_get_widget_area('name'))); echo beans_close_markup('beans_no_widget_notice', 'p'); }
/** * Modify wp_nav_menu arguments. * * This function converts the wp_nav_menu to UIKit format. It uses Beans custom walker and also makes * use of the Beans HTML API. * * @since 1.0.0 * * @param array $args The wp_nav_menu arguments. * * @return array The modified wp_nav_menu arguments. */ function beans_modify_menu_args($args) { // Get type. $type = beans_get('beans_type', $args); // Check if the menu is in a widget area and set the type accordingly if it is defined. if ($widget_area_type = beans_get_widget_area('beans_type')) { $type = $widget_area_type == 'stack' ? 'sidenav' : $widget_area_type; } // Stop if it isn't a beans menu. if (!$type) { return $args; } // Default item wrap attributes. $attr = array('id' => '%1$s', 'class' => array(beans_get('menu_class', $args))); // Add UIKit navbar item wrap attributes. if ($type == 'navbar') { $attr['class'][] = 'uk-navbar-nav'; } // Add UIKit sidenav item wrap attributes. if ($type == 'sidenav') { $attr['class'][] = 'uk-nav uk-nav-parent-icon uk-nav-side'; $attr['data-uk-nav'] = '{multiple:true}'; } // Add UIKit offcanvas item wrap attributes. if ($type == 'offcanvas') { $attr['class'][] = 'uk-nav uk-nav-parent-icon uk-nav-offcanvas'; $attr['data-uk-nav'] = '{multiple:true}'; } // Implode to avoid empty spaces. $attr['class'] = implode(' ', array_filter($attr['class'])); // Set to null if empty to avoid outputing empty class html attribute. if (!$attr['class']) { $attr['class'] = null; } $location_sub_filter = ($location = beans_get('theme_location', $args)) ? "[_{$location}]" : null; // Force beans menu arguments. $force = array('beans_type' => $type, 'items_wrap' => beans_open_markup("beans_menu[_{$type}]{$location_sub_filter}", 'ul', $attr, $args) . '%3$s' . beans_close_markup("beans_menu[_{$type}]{$location_sub_filter}", 'ul', $args)); // Allow walker overwrite. if (!beans_get('walker', $args)) { $args['walker'] = new _Beans_Walker_Nav_Menu(); } // Adapt level to walker depth. $force['beans_start_level'] = ($level = beans_get('beans_start_level', $args)) ? $level - 1 : 0; return array_merge($args, $force); }
/** * Setup widget global data. * * @ignore */ function _beans_setup_widget($id) { global $_beans_widget; $widgets = beans_get_widget_area('widgets'); $_beans_widget = $widgets[$id]; }
beans_close_markup_e('beans_widget_panel' . _beans_widget_subfilters(), 'div'); if ('grid' == beans_get_widget_area('beans_type')) { beans_close_markup_e('beans_widget_grid' . _beans_widget_subfilters(), 'div'); } } /** * Fires after the widgets loop. * * This hook only fires if widgets exist. * * @since 1.0.0 */ do_action('beans_after_widgets_loop'); } else { /** * Fires if no widgets exist. * * @since 1.0.0 */ do_action('beans_no_widget'); } if ('offcanvas' == beans_get_widget_area('beans_type')) { beans_close_markup_e('beans_widget_area_offcanvas_bar' . _beans_widget_area_subfilters(), 'div'); beans_close_markup_e('beans_widget_area_offcanvas_wrap' . _beans_widget_area_subfilters(), 'div'); } if ('grid' == beans_get_widget_area('beans_type')) { beans_close_markup_e('beans_widget_area_grid' . _beans_widget_area_subfilters(), 'div'); } // This includes everything added to wp hooks after the widgets. echo beans_get_widget_area('after_widgets');