/** * show all categories list (redirect to allcat.php if allcat=y) */ function fastfood_allcat() { if (fastfood_is_allcat()) { get_template_part('allcat'); exit; } }
function get_the_breadcrumb() { $defaults = apply_filters('fastfood_breadcrumb_defaults', array('container_before' => '', 'container_after' => '', 'container_crumb_open' => '<div class="crumbs">', 'container_crumb_close' => '</div>', 'delimiter' => '<span class="delimiter"> » </span>', 'homename' => 'Home', 'blogname' => 'Blog', 'current_before' => '<span class="current">', 'current_after' => '</span>')); extract($defaults); $base_link = ''; $hierarchy = ''; $current_location = ''; $current_location_link = ''; $crumb_pagination = ''; $home = home_url('/'); global $wp_query, $post; // Base Link $base_link = '<a class="home" href="' . $home . '"><i class="el-icon-home"></i><span class="screen-reader-text">' . $homename . '</span></a>'; // If static Page as Front Page, and on Blog Posts Index if (is_home() && 'page' == get_option('show_on_front')) { $hierarchy = $delimiter; $current_location = $blogname; } // If static Page as Front Page, and on Blog, output Blog link if (!is_home() && !is_page() && !is_front_page() && 'page' == get_option('show_on_front')) { $hierarchy = $delimiter; $current_location = '<a href="' . get_permalink(get_option('page_for_posts')) . '">' . $blogname . '</a>'; } // Define Category Hierarchy Crumbs for Category Archive if (is_category()) { $cat_obj = $wp_query->get_queried_object(); $thisCat = $cat_obj->term_id; $thisCat = get_category($thisCat); $parentCat = get_category($thisCat->parent); if ($thisCat->parent != 0) { $hierarchy = $delimiter . get_category_parents($parentCat, TRUE, $delimiter); } else { $hierarchy = $delimiter; } // Set $current_location to the current category $current_location = single_cat_title('', FALSE); } elseif (is_date()) { // Define Year/Month Hierarchy Crumbs for Day Archive if (is_day()) { $date_string = '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a>' . $delimiter . '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '">' . get_the_time('F') . '</a>'; $date_string .= $delimiter; $current_location = get_the_date(); } elseif (is_month()) { $date_string = '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a>'; $date_string .= $delimiter; $current_location = get_the_time('F'); } elseif (is_year()) { $date_string = ''; $current_location = get_the_time('Y'); } $hierarchy = $delimiter . $date_string; } elseif (is_singular('post')) { $cats = get_the_category(); // Assume the first category is current $current_cat = $cats ? $cats[0] : ''; // Determine if category is hierarchical $cat_is_hierarchical = false; foreach ($cats as $cat) { if ('0' != $cat->parent) { $cat_is_hierarchical = true; break; } } // If category is hierarchical, // ensure we have the correct child category if ($cat_is_hierarchical) { foreach ($cats as $cat) { $children = get_categories(array('parent' => $cat->term_id)); if (0 == count($children)) { $current_cat = $cat; break; } } } // Get the hierarchical list of category links $hierarchy = $delimiter . get_category_parents($current_cat, TRUE, $delimiter); // Note: get_the_title() is filtered to output a // default title if none is specified $current_location = get_the_title(); } elseif (is_attachment()) { $hierarchy = $delimiter; $parent = $post->post_parent; if ($parent) { $parent = get_post($parent); $cat_parents = ''; if (get_the_category($parent->ID)) { $cat = get_the_category($parent->ID); $cat = $cat[0]; $cat_parents = get_category_parents($cat, TRUE, $delimiter); } $hierarchy = $delimiter . $cat_parents . '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a>' . $delimiter; } // Note: Titles are forced for attachments; the // filename will be used if none is specified $current_location = get_the_title(); } elseif (is_singular(get_post_type()) && !is_singular('post') && !is_page() && !is_attachment()) { $post_type_object = get_post_type_object(get_post_type()); $post_type_name = $post_type_object->labels->name; $post_type_slug = $post_type_object->name; $taxonomies = get_object_taxonomies(get_post_type()); $taxonomy = !empty($taxonomies) ? $taxonomies[0] : false; $terms = $taxonomy ? get_the_term_list($post->ID, $taxonomy) : false; $hierarchy = $delimiter . '<a href="' . get_post_type_archive_link($post_type_slug) . '">' . $post_type_name . '</a>'; $hierarchy .= $terms ? $delimiter . $terms . $delimiter : $delimiter; $current_location = get_the_title(); } elseif (!is_front_page() && is_page() && !$post->post_parent) { $hierarchy = $delimiter; // Note: get_the_title() is filtered to output a // default title if none is specified $current_location = get_the_title(); } elseif (!is_front_page() && is_page() && $post->post_parent) { $parent_id = $post->post_parent; $breadcrumbs = array(); while ($parent_id) { $page = get_page($parent_id); $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>'; $parent_id = $page->post_parent; } $breadcrumbs = array_reverse($breadcrumbs); foreach ($breadcrumbs as $crumb) { $hierarchy .= $delimiter . $crumb; } $hierarchy = $hierarchy . $delimiter; // Note: get_the_title() is filtered to output a // default title if none is specified $current_location = get_the_title(); } elseif (is_search()) { $hierarchy = $delimiter; $current_location = get_search_query(); } elseif (is_tag()) { $hierarchy = $delimiter; $current_location = single_tag_title('', FALSE); } elseif (is_tax()) { $post_type_object = get_post_type_object(get_post_type()); $post_type_name = $post_type_object->labels->name; $post_type_slug = $post_type_object->name; $custom_tax = $wp_query->query_vars['taxonomy']; $custom_tax_object = get_taxonomy($custom_tax); $hierarchy = $delimiter . '<a href="' . get_post_type_archive_link($post_type_slug) . '">' . $post_type_name . '</a>'; $hierarchy .= $delimiter; $current_location = single_term_title('', false); } elseif (is_author()) { $hierarchy = $delimiter; $current_location = get_the_author_meta('display_name', get_query_var('author')); } elseif (is_404()) { $hierarchy = $delimiter; $current_location = __('Error 404', 'fastfood') . ' - ' . __('Page not found', 'fastfood'); } elseif (get_post_format() && !is_home()) { $hierarchy = $delimiter; $current_location = get_post_format_string(get_post_format()); } elseif (is_post_type_archive(get_post_type())) { $hierarchy = $delimiter; $post_type_object = get_post_type_object(get_post_type()); $post_type_name = $post_type_object->labels->name; $current_location = $post_type_name; } if (is_front_page() && 'page' == get_option('show_on_front')) { $hierarchy = $delimiter; $current_location = get_the_title(); } if (is_front_page() && !('page' == get_option('show_on_front'))) { $hierarchy = $delimiter; $current_location = $blogname; } if (fastfood_is_allcat()) { $hierarchy = $delimiter; $current_location = __('All Categories', 'fastfood'); } // Define pagination for paged Archive pages if (get_query_var('paged') && !function_exists('wp_paginate')) { $crumb_pagination = ' (Page ' . get_query_var('paged') . ')'; } // Define pagination for Paged Posts and Pages if (get_query_var('page')) { $crumb_pagination = ' (Page ' . get_query_var('page') . ') '; } // Build the Current Location Link markup $current_location_link = $current_before . '<i class="el-icon-placeholder"></i>' . $current_location . $crumb_pagination . $current_after; // Define breadcrumb pagination // Build the resulting Breadcrumbs $breadcrumb = $container_before . $container_crumb_open . $base_link . $hierarchy . $current_location_link . $container_crumb_close . $container_after; // Output the result return apply_filters('fastfood_breadcrumb', $breadcrumb, $base_link, $container_before, $container_after, $container_crumb_open, $container_crumb_close, $delimiter, $homename, $blogname, $current_before, $current_after); }
/** * The Navigation Buttons * * @since Fastfood 0.37 */ function the_navbuttons($args = '') { global $post, $paged, $wp_query; wp_reset_postdata(); $is_post = is_single() && !is_attachment() && !fastfood_is_allcat(); $is_image = is_attachment() && !fastfood_is_allcat(); $is_page = is_singular() && !is_single() && !is_attachment() && !fastfood_is_allcat(); $is_singular = is_singular() && !fastfood_is_allcat(); $defaults = array('print' => 1, 'comment' => 1, 'feed' => 1, 'trackback' => 1, 'home' => 1, 'next_prev' => 1, 'up_down' => 1, 'fixed' => 1); $args = wp_parse_args($args, $defaults); $buttons = array(); // ------- Print ------- if (FastfoodOptions::get_opt('fastfood_navbuttons_print') && $args['print'] && $is_singular) { $query_vars['style'] = 'printme'; if (get_query_var('page')) { $query_vars['page'] = esc_html(get_query_var('page')); } if (get_query_var('cpage')) { $query_vars['cpage'] = esc_html(get_query_var('cpage')); } $buttons['print'] = array('class' => '', 'a_class' => '', 'a_rel' => '', 'a_href' => add_query_arg($query_vars, get_permalink($post->ID)), 'icon_class' => 'el-icon-print', 'tooltip' => __('Print preview', 'fastfood')); } // ------- Leave a comment ------- if (FastfoodOptions::get_opt('fastfood_navbuttons_comment') && $args['comment'] && $is_singular && comments_open($post->ID) && !post_password_required()) { $buttons['comment'] = array('class' => '', 'a_class' => 'show-comment-form', 'a_rel' => '', 'a_href' => '#respond', 'icon_class' => 'el-icon-comment', 'tooltip' => __('Leave a comment', 'fastfood')); } // ------- RSS feed ------- if (FastfoodOptions::get_opt('fastfood_navbuttons_feed') && $args['feed'] && $is_singular && comments_open($post->ID) && !post_password_required()) { $buttons['feed'] = array('class' => '', 'a_class' => '', 'a_rel' => '', 'a_href' => get_post_comments_feed_link($post->ID, 'rss2'), 'icon_class' => 'el-icon-rss', 'tooltip' => __('feed for comments on this post', 'fastfood')); } // ------- Trackback ------- if (FastfoodOptions::get_opt('fastfood_navbuttons_trackback') && $args['trackback'] && $is_singular && pings_open()) { $buttons['trackback'] = array('class' => '', 'a_class' => '', 'a_rel' => 'trackback', 'a_href' => get_trackback_url(), 'icon_class' => 'el-icon-refresh', 'tooltip' => __('Trackback URL', 'fastfood')); } // ------- Home ------- if (FastfoodOptions::get_opt('fastfood_navbuttons_home') && $args['home']) { $buttons['home'] = array('class' => '', 'a_class' => '', 'a_rel' => '', 'a_href' => home_url(), 'icon_class' => 'el-icon-home', 'tooltip' => __('Home', 'fastfood')); } // ------- Back to parent post ------- if ($is_image && !empty($post->post_parent)) { $buttons['image'] = array('class' => '', 'a_class' => '', 'a_rel' => 'gallery', 'a_href' => get_permalink($post->post_parent), 'icon_class' => 'el-icon-hand-left', 'tooltip' => sprintf(__('Return to %s', 'fastfood'), get_the_title($post->post_parent))); } // ------- Previous/Next image ------- if ($is_image) { $images = fastfood_get_prevnext_images($post->ID); if ($images['prev']) { $buttons['prevpost'] = array('class' => '', 'a_class' => '', 'a_rel' => 'prev', 'a_href' => get_attachment_link($images['prev']), 'icon_class' => 'el-icon-chevron-left', 'tooltip' => __('Previous Image', 'fastfood')); } if ($images['next']) { $buttons['nextpost'] = array('class' => '', 'a_class' => '', 'a_rel' => 'next', 'a_href' => get_attachment_link($images['next']), 'icon_class' => 'el-icon-chevron-right', 'tooltip' => __('Next Image', 'fastfood')); } } // ------- Previous post ------- if (FastfoodOptions::get_opt('fastfood_navbuttons_nextprev') && $args['next_prev'] && $is_post && get_previous_post()) { $buttons['prevpost'] = array('class' => '', 'a_class' => '', 'a_rel' => '', 'a_href' => get_permalink(get_previous_post()), 'icon_class' => 'el-icon-chevron-left', 'tooltip' => sprintf(__('Previous Post', 'fastfood') . ': %s', get_the_title(get_previous_post()))); } // ------- Next post ------- if (FastfoodOptions::get_opt('fastfood_navbuttons_nextprev') && $args['next_prev'] && $is_post && get_next_post()) { $buttons['nextpost'] = array('class' => '', 'a_class' => '', 'a_rel' => '', 'a_href' => get_permalink(get_next_post()), 'icon_class' => 'el-icon-chevron-right', 'tooltip' => sprintf(__('Next Post', 'fastfood') . ': %s', get_the_title(get_next_post()))); } // ------- Older Posts ------- if (FastfoodOptions::get_opt('fastfood_navbuttons_newold') && $args['next_prev'] && !$is_singular && !fastfood_is_allcat() && get_next_posts_link()) { $max_page = $wp_query->max_num_pages; $buttons['oldposts'] = array('class' => 'nb-nextprev', 'a_class' => '', 'a_rel' => '', 'a_href' => next_posts($max_page, false), 'icon_class' => 'el-icon-chevron-left', 'tooltip' => __('Older Posts', 'fastfood')); } // ------- Newer Posts ------- if (FastfoodOptions::get_opt('fastfood_navbuttons_newold') && $args['next_prev'] && !$is_singular && !fastfood_is_allcat() && get_previous_posts_link()) { $buttons['newposts'] = array('class' => 'nb-nextprev', 'a_class' => '', 'a_rel' => '', 'a_href' => previous_posts(false), 'icon_class' => 'el-icon-chevron-right', 'tooltip' => __('Newer Posts', 'fastfood')); } // ------- Top ------- if (FastfoodOptions::get_opt('fastfood_navbuttons_topbottom') && $args['up_down']) { $buttons['up'] = array('class' => '', 'a_class' => '', 'a_rel' => '', 'a_href' => '#', 'icon_class' => 'el-icon-chevron-up', 'tooltip' => __('Top of page', 'fastfood')); } // ------- Bottom ------- if (FastfoodOptions::get_opt('fastfood_navbuttons_topbottom') && $args['up_down']) { $buttons['down'] = array('class' => '', 'a_class' => '', 'a_rel' => '', 'a_href' => '#footer', 'icon_class' => 'el-icon-chevron-down', 'tooltip' => __('Bottom of page', 'fastfood')); } /* custom buttons can be easily added to navbar using filters. eg: add_filter( 'fastfood_filter_navbuttons', 'fastfood_add_my_button' ); function fastfood_add_my_button( $buttons ) { $buttons['my-button'] = array( 'class' => 'my_button_class', 'a_class' => 'my_button_anchor_class', 'a_rel' => 'my_button_anchor_rel', 'a_href' => 'my_button_anchor_href', 'icon_class' => 'elusive_icon_class', 'tooltip' => 'my button tooltip text' ); return $buttons; } */ $buttons = apply_filters('fastfood_filter_navbuttons', $buttons); if (!$buttons) { return; } ?> <div id="navbuttons"> <?php foreach ($buttons as $button) { $button['class'] = $button['class'] ? ' ' . esc_attr(trim($button['class'])) : ''; $button['icon_class'] = $button['icon_class'] ? ' ' . esc_attr(trim($button['icon_class'])) : ''; $button['tooltip'] = esc_html($button['tooltip']); ?> <div class="minibutton<?php echo $button['class']; ?> "> <?php echo fastfood_build_link(array('href' => $button['a_href'], 'class' => $button['a_class'], 'rel' => $button['a_rel'], 'text' => '<i class="minib_img' . $button['icon_class'] . '"></i>')); ?> <span class="nb_tooltip"><?php echo $button['tooltip']; ?> </span> </div> <?php } ?> </div><!-- #navbuttons --> <?php }