Esempio n. 1
0
/**
 * Shows a breadcrumb for all types of pages.  This function is formatting the final output of the 
 * breadcrumb trail.  The breadcrumb_trail_get_items() function returns the items and this function 
 * formats those items.
 *
 * @since 0.1.0
 * @access public
 * @param array $args Mixed arguments for the menu.
 * @return string Output of the breadcrumb menu.
 */
function breadcrumb_trail($args = array())
{
    /* Create an empty variable for the breadcrumb. */
    $breadcrumb = '';
    /* Set up the default arguments for the breadcrumb. */
    $defaults = array('container' => 'div', 'separator' => '/', 'before' => __('Browse:', 'breadcrumb-trail'), 'after' => false, 'front_page' => true, 'show_home' => __('Home', 'breadcrumb-trail'), 'echo' => true);
    /* Allow singular post views to have a taxonomy's terms prefixing the trail. */
    if (is_singular()) {
        $post = get_queried_object();
        $defaults["singular_{$post->post_type}_taxonomy"] = false;
    }
    /* Apply filters to the arguments. */
    $args = apply_filters('breadcrumb_trail_args', $args);
    /* Parse the arguments and extract them for easy variable naming. */
    $args = wp_parse_args($args, $defaults);
    /* Get the trail items. */
    $trail = breadcrumb_trail_get_items($args);
    /* Connect the breadcrumb trail if there are items in the trail. */
    if (!empty($trail) && is_array($trail)) {
        /* Open the breadcrumb trail containers. */
        $breadcrumb = '<' . tag_escape($args['container']) . ' class="breadcrumb-trail breadcrumbs" itemprop="breadcrumb">';
        /* If $before was set, wrap it in a container. */
        $breadcrumb .= !empty($args['before']) ? '<span class="trail-before">' . $args['before'] . '</span> ' : '';
        /* Adds the 'trail-begin' class around first item if there's more than one item. */
        if (1 < count($trail)) {
            array_unshift($trail, '<span class="trail-begin">' . array_shift($trail) . '</span>');
        }
        /* Adds the 'trail-end' class around last item. */
        array_push($trail, '<span class="trail-end">' . array_pop($trail) . '</span>');
        /* Format the separator. */
        $separator = !empty($args['separator']) ? '<span class="sep">' . $args['separator'] . '</span>' : '<span class="sep">/</span>';
        /* Join the individual trail items into a single string. */
        $breadcrumb .= join(" {$separator} ", $trail);
        /* If $after was set, wrap it in a container. */
        $breadcrumb .= !empty($args['after']) ? ' <span class="trail-after">' . $args['after'] . '</span>' : '';
        /* Close the breadcrumb trail containers. */
        $breadcrumb .= '</' . tag_escape($args['container']) . '>';
    }
    /* Allow developers to filter the breadcrumb trail HTML. */
    $breadcrumb = apply_filters('breadcrumb_trail', $breadcrumb, $args);
    /* Output the breadcrumb. */
    if ($args['echo']) {
        echo $breadcrumb;
    } else {
        return $breadcrumb;
    }
}
/**
 * Shows a breadcrumb for all types of pages.  This function is formatting the final output of the 
 * breadcrumb trail.  The breadcrumb_trail_get_items() function returns the items and this function 
 * formats those items.
 *
 * @since 0.1.0
 * @param array $args Mixed arguments for the menu.
 * @return string Output of the breadcrumb menu.
 */
function breadcrumb_trail($args = array())
{
    /* Get the textdomain. */
    $textdomain = breadcrumb_trail_textdomain();
    /* Create an empty variable for the breadcrumb. */
    $breadcrumb = '';
    /* Set up the default arguments for the breadcrumb. */
    $defaults = array('separator' => '/', 'before' => '<span class="breadcrumb-title">' . __('Browse:', $textdomain) . '</span>', 'after' => false, 'front_page' => true, 'show_home' => __('Home', $textdomain), 'echo' => true);
    /* Allow singular post views to have a taxonomy's terms prefixing the trail. */
    if (is_singular()) {
        $post = get_queried_object();
        $defaults["singular_{$post->post_type}_taxonomy"] = false;
    }
    /* Apply filters to the arguments. */
    $args = apply_filters('breadcrumb_trail_args', $args);
    /* Parse the arguments and extract them for easy variable naming. */
    $args = wp_parse_args($args, $defaults);
    /* Get the trail items. */
    $trail = breadcrumb_trail_get_items($args);
    /* Connect the breadcrumb trail if there are items in the trail. */
    if (!empty($trail) && is_array($trail)) {
        /* Open the breadcrumb trail containers. */
        $breadcrumb = '<div class="breadcrumb breadcrumbs"><div class="breadcrumb-trail">';
        /* If $before was set, wrap it in a container. */
        $breadcrumb .= !empty($args['before']) ? '<span class="trail-before">' . $args['before'] . '</span> ' : '';
        /* Wrap the $trail['trail_end'] value in a container. */
        if (!empty($trail['trail_end'])) {
            $trail['trail_end'] = '<span class="trail-end">' . $trail['trail_end'] . '</span>';
        }
        /* Format the separator. */
        $separator = !empty($args['separator']) ? '<span class="sep">' . $args['separator'] . '</span>' : '<span class="sep">/</span>';
        /* Join the individual trail items into a single string. */
        $breadcrumb .= join(" {$separator} ", $trail);
        /* If $after was set, wrap it in a container. */
        $breadcrumb .= !empty($args['after']) ? ' <span class="trail-after">' . $args['after'] . '</span>' : '';
        /* Close the breadcrumb trail containers. */
        $breadcrumb .= '</div></div>';
    }
    /* Allow developers to filter the breadcrumb trail HTML. */
    $breadcrumb = apply_filters('breadcrumb_trail', $breadcrumb, $args);
    /* Output the breadcrumb. */
    if ($args['echo']) {
        echo $breadcrumb;
    } else {
        return $breadcrumb;
    }
}
Esempio n. 3
0
 /** 
  * Displays the breadcrumb for the current page
  * @since 1.0
  * @access public
  * @param array $args Mixed arguments for the menu.
  * @return string Output of the breadcrumb menu.
  */
 function kleo_breadcrumb($args = array())
 {
     /* Empty variable for the breadcrumb. */
     $breadcrumb = '';
     /* Default arguments for the breadcrumb. */
     $defaults = array('container' => 'ul', 'container_class' => '', 'item_tag' => 'li', 'separator' => '', 'before' => '', 'after' => false, 'front_page' => true, 'show_home' => __('Home', 'kleo_framework'), 'network' => false, 'echo' => false);
     /* Allow singular post views to have a taxonomy's terms prefixing the trail. */
     if (is_singular()) {
         $post = get_queried_object();
         $defaults["singular_{$post->post_type}_taxonomy"] = false;
     }
     /* Apply filters to the arguments. */
     $args = apply_filters('breadcrumb_trail_args', $args);
     /* Parse the arguments and extract them for easy variable naming. */
     $args = wp_parse_args($args, $defaults);
     /* Get the trail items. */
     $trail = breadcrumb_trail_get_items($args);
     /* Connect the breadcrumb trail if there are items in the trail. */
     if (!empty($trail) && is_array($trail)) {
         /* Open the breadcrumb trail containers. */
         $breadcrumb = '<' . tag_escape($args['container']) . (!empty($args['container_class']) ? ' class="' . $args['container_class'] . '"' : '') . '>';
         /* If $before was set, wrap it in a container. */
         $breadcrumb .= !empty($args['before']) ? $args['before'] : '';
         /* Format the separator. */
         $separator = !empty($args['separator']) ? '<span class="sep">' . $args['separator'] . '</span>' : '';
         /* Join the individual trail items into a single string. */
         $breadcrumb .= '<' . $args['item_tag'] . '>' . join(" {$separator} " . '</' . $args['item_tag'] . '>' . '<' . $args['item_tag'] . '>', $trail) . '</' . $args['item_tag'] . '>';
         /* If $after was set, wrap it in a container. */
         $breadcrumb .= !empty($args['after']) ? $args['after'] : '';
         /* Close the breadcrumb trail containers. */
         $breadcrumb .= '</' . tag_escape($args['container']) . '>';
     }
     /* Allow developers to filter the breadcrumb trail HTML. */
     $breadcrumb = apply_filters('kleo_breadcrumb', $breadcrumb, $args);
     /* Output the breadcrumb. */
     if ($args['echo']) {
         echo $breadcrumb;
     } else {
         return $breadcrumb;
     }
 }