'; luzuk_baker_shop_edit_link(); echo ' '; } } endif; if ( ! function_exists( 'luzuk_baker_shop_edit_link' ) ) : function luzuk_baker_shop_edit_link() { edit_post_link( sprintf( /* translators: %s: Name of current post */ __( 'Edit "%s"', 'baker-shop' ), esc_html( get_the_title() ) ), '', '' ); } endif; function luzuk_baker_shop_categorized_blog() { $category_count = get_transient( 'luzuk_baker_shop_categories' ); if ( false === $category_count ) { // Create an array of all the categories that are attached to posts. $categories = get_categories( array( 'fields' => 'ids', 'hide_empty' => 1, // We only need to know if there is more than one category. 'number' => 2, ) ); // Count the number of categories that are attached to the posts. $category_count = count( $categories ); set_transient( 'luzuk_baker_shop_categories', $category_count ); } // Allow viewing case of 0 or 1 categories in post preview. if ( is_preview() ) { return true; } return $category_count > 1; } if ( ! function_exists( 'luzuk_baker_shop_the_custom_logo' ) ) : function luzuk_baker_shop_the_custom_logo() { the_custom_logo(); } endif; function luzuk_baker_shop_category_transient_flusher() { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } // Like, beat it. Dig? delete_transient( 'luzuk_baker_shop_categories' ); } add_action( 'edit_category', 'luzuk_baker_shop_category_transient_flusher' ); add_action( 'save_post', 'luzuk_baker_shop_category_transient_flusher' ); /** * Menus */ /** * Filters classes of wp_list_pages items to match menu items. * * Filter the class applied to wp_list_pages() items with children to match the menu class, to simplify. * styling of sub levels in the fallback. Only applied if the match_menu_classes argument is set. * * @since Baker Shop 1.0 * * @param string[] $css_class An array of CSS classes to be applied to each list item. * @param WP_Post $page Page data object. * @param int $depth Depth of page, used for padding. * @param array $args An array of arguments. * @return array CSS class names. */ function baker_shop_filter_wp_list_pages_item_classes( $css_class, $page, $depth, $args ) { // Only apply to wp_list_pages() calls with match_menu_classes set to true. $match_menu_classes = isset( $args['match_menu_classes'] ); if ( ! $match_menu_classes ) { return $css_class; } // Add current menu item class. if ( in_array( 'current_page_item', $css_class, true ) ) { $css_class[] = 'current-menu-item'; } // Add menu item has children class. if ( in_array( 'page_item_has_children', $css_class, true ) ) { $css_class[] = 'menu-item-has-children'; } return $css_class; } add_filter( 'page_css_class', 'baker_shop_filter_wp_list_pages_item_classes', 10, 4 ); /** * Adds a Sub Nav Toggle to the Expanded Menu and Mobile Menu. * * @since Baker Shop 1.0 * * @param stdClass $args An object of wp_nav_menu() arguments. * @param WP_Post $item Menu item data object. * @return stdClass An object of wp_nav_menu() arguments. */ function baker_shop_add_sub_toggles_to_main_menu( $args, $item ) { // Add sub menu toggles to the Expanded Menu with toggles. if ( isset( $args->show_toggles ) && $args->show_toggles ) { // Wrap the menu item link contents in a div, used for positioning. $args->before = '