public function cleanGallery($output, $attr)
 {
     static $cleaner_gallery_instance = 0;
     $cleaner_gallery_instance++;
     if (is_feed()) {
         return $output;
     }
     /* Default gallery settings. */
     $defaults = array('order' => 'ASC', 'orderby' => 'ID', 'id' => get_the_ID(), 'link' => '', 'itemtag' => 'figure', 'icontag' => '', 'captiontag' => '', 'columns' => 3, 'size' => 'thumbnail', 'ids' => '', 'include' => '', 'exclude' => '', 'numberposts' => -1, 'offset' => '');
     $attr = array_merge($defaults, $attr);
     extract($attr);
     $id = intval($id);
     /* Arguments for get_children(). */
     $children = array('post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby, 'exclude' => $exclude, 'include' => $include, 'numberposts' => $numberposts, 'offset' => $offset, 'suppress_filters' => true);
     if (empty($include)) {
         $attachments = get_children(array_merge(array('post_parent' => $id), $children));
     } else {
         $attachments = get_posts($children);
     }
     $attr['link'] = get_option('yopress_gallery_clean_link');
     if ($attr['link'] == '' || $attr['link'] == null) {
         $attr['link'] = 'big-thumbnail';
         update_option('yopress_gallery_clean_link', 'full');
     }
     $size = get_option('yopress_theme_gallery_def_size');
     if ($size == '' || $size == null) {
         $size = 'thumbnail';
         update_option('yopress_gallery_clean_size', 'thumbnail');
     }
     if (empty($attachments)) {
         return '<!-- No images. -->';
     }
     $itemtag = tag_escape($itemtag);
     $icontag = tag_escape($icontag);
     $captiontag = tag_escape($captiontag);
     $columns = intval($columns);
     $i = 0;
     $galleryWidth = floor(100 / $columns);
     $style = '<style type="text/css">#gallery-' . $cleaner_gallery_instance . ' .gallery-item			{ width : ' . $galleryWidth . '%}</style>';
     $output = $style;
     $output .= '<div id="gallery-' . $cleaner_gallery_instance . '" class="gallery gallery-columns-' . $columns . ' gallery-size-thumbnail">';
     $itemInColum = 0;
     foreach ($attachments as $attachment) {
         $output .= '<dl class="gallery-item"><dt class="gallery-icon">';
         $image = isset($attr['link']) && 'full' == $attr['link'] ? wp_get_attachment_link($attachment->ID, $size, false, false) : wp_get_attachment_link($attachment->ID, $size, true, false);
         $lightbox = $attr['link'] == 'full' ? 'class="apply-lightbox"' : '';
         $output .= "<div " . $lightbox . ">";
         $output .= apply_filters('cleaner_gallery_image', $image, $attachment->ID, $attr, $cleaner_gallery_instance);
         $output .= '</div>';
         $output .= '</dt></dl>';
         $itemInColum++;
         if ($itemInColum == $columns) {
             $itemInColum = 0;
             $output .= '<br class="clearfix">';
         }
     }
     $output .= '<br class="clearfix">';
     $output .= "</div><!-- .gallery -->";
     return $output;
 }
Beispiel #2
0
/**
 * OVERRIDES: gallery_shortcode()
 *
 * This implements the functionality of the Gallery Shortcode for displaying
 * WordPress images on a post.
 */
function vanilla_gallery($attr)
{
    global $post, $tpl;
    // BUG: I'm doing something wrong, because $attr is not the array of attributes from gallery_shortcode function. Why not??
    // We're trusting author input, so let's at least make sure it looks like a valid orderby statement
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail'), $attr));
    $id = intval($id);
    $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    if (empty($attachments)) {
        return '';
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $id => $attachment) {
            $output .= wp_get_attachment_link($id, $size, true) . "\n";
        }
        return $output;
    }
    $images = array();
    foreach ($attachments as $id => $attachment) {
        $images[] = array("link" => wp_get_attachment_link($id, $size, true), "caption" => $captiontag && trim($attachment->post_excerpt) ? $attachment->post_excerpt : 0);
    }
    // Prepare the template data
    $tpl["gallery"] = array("tpl_file" => "shortcodes/gallery.html", "itemtag" => tag_escape($itemtag), "icontag" => tag_escape($icontag), "captiontag" => tag_escape($captiontag), "columns" => intval($columns), "itemwidth" => $columns > 0 ? floor(100 / $columns) - 1 : 100, "images" => $images);
    // Execute the template
    return vanilla_shortcode("gallery");
}
 public function __construct(array $aTabs, $asActiveTabSlugs, $sTabTag = 'h2', $aAttributes = array('class' => 'nav-tab-wrapper'), $aCallbacks = array())
 {
     $this->aCallbacks = $aCallbacks + array('format' => null, 'arguments' => null);
     $this->aTabs = $this->_getFormattedTabs($aTabs);
     $this->aActiveSlugs = $this->getAsArray($asActiveTabSlugs);
     $this->sTabTag = $sTabTag ? tag_escape($sTabTag) : $this->sTabTag;
     $this->aAttributes = $aAttributes;
 }
 function vw_custom_post_gallery($null, $attr = array())
 {
     global $post, $wp_locale;
     static $instance = 0;
     $instance++;
     extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'figure', 'captiontag' => 'figcaption', 'columns' => 3, 'size' => 'vw_medium', 'include' => '', 'exclude' => ''), $attr));
     $id = intval($id);
     if ('RAND' == $order) {
         $orderby = 'none';
     }
     if (!empty($include)) {
         $include = preg_replace('/[^0-9,]+/', '', $include);
         $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
         $attachments = array();
         foreach ($_attachments as $key => $val) {
             $attachments[$val->ID] = $_attachments[$key];
         }
     } elseif (!empty($exclude)) {
         $exclude = preg_replace('/[^0-9,]+/', '', $exclude);
         $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
     } else {
         $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
     }
     if (empty($attachments)) {
         return '';
     }
     if (is_feed()) {
         $output = "\n";
         foreach ($attachments as $att_id => $attachment) {
             $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
         }
         return $output;
     }
     $itemtag = tag_escape($itemtag);
     $captiontag = tag_escape($captiontag);
     $float = is_rtl() ? 'right' : 'left';
     $gallery_layout = vw_get_option('blog_custom_gallery_layout', '213');
     $output = "<div id='gallery-{$instance}' class='custom-gallery galleryid-{$id} clearfix' data-gallery-layout='{$gallery_layout}'>";
     if ($itemtag != '' && $captiontag != '') {
         $i = 1;
         foreach ($attachments as $id => $attachment) {
             $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, false, false);
             $link = str_replace('<a', '<a title="' . $attachment->post_excerpt . '" ', $link);
             $output .= "<{$itemtag} class='gallery-item'>";
             $output .= "{$link}";
             if ($captiontag && trim($attachment->post_excerpt)) {
                 $output .= "\r\n\t\t\t\t\t<{$captiontag} class='gallery-caption'>\r\n\t\t\t\t\t" . wptexturize($attachment->post_excerpt) . "\r\n\t\t\t\t\t</{$captiontag}>";
             }
             $output .= "</{$itemtag}>";
             $i++;
         }
     }
     $output .= "</div>\n";
     return $output;
 }
Beispiel #5
0
function pressplay_gallery_shortcode($null, $attr = array())
{
    global $post;
    static $instance = 0;
    $instance++;
    // We're trusting author input, so let's at least make sure it looks like a valid orderby statement
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail'), $attr));
    $id = intval($id);
    $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    if (empty($attachments)) {
        return '';
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $att_id => $attachment) {
            $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
        }
        return $output;
    }
    $itemtag = tag_escape($itemtag);
    $captiontag = tag_escape($captiontag);
    $columns = intval($columns);
    if ($columns >= 4) {
        $galleryItemDimensions = "height:80%;width:80%;";
    } else {
        $galleryItemDimensions = "";
    }
    $itemwidth = $columns > 0 ? floor(100 / $columns) : 100;
    $itemheight = $itemwidth;
    $selector = "gallery-{$instance}";
    $output = apply_filters('gallery_style', "\r\n\t\t<style type='text/css'>\r\n\t\t\t#{$selector} {\r\n\t\t\t\tmargin: auto;\r\n\t\t\t}\r\n\t\t\t#{$selector} .gallery-item {\r\n\t\t\t\tfloat: left;\r\n\t\t\t\tmargin-top: 10px;\r\n\t\t\t\ttext-align: center;\r\n\t\t\t\twidth: {$itemwidth}%;\r\n\t\t\t\theight: {$itemheight}%;\r\n\t\t\t}\r\n\t\t\t#{$selector} img {\r\n\t\t\t\tborder: 2px solid #cfcfcf;\r\n\t\t\t\t" . $galleryItemDimensions . "\t\t\t\r\n\t\t\t}\r\n\t\t\t#{$selector} .gallery-caption {\r\n\t\t\t\tmargin-left: 0;\r\n\t\t\t}\r\n\t\t</style>\r\n\t\t<!-- see gallery_shortcode() in wp-includes/media.php -->\r\n\t\t<div id='{$selector}' class='gallery galleryid-{$id}'>");
    $i = 0;
    foreach ($attachments as $id => $attachment) {
        $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
        $output .= "<{$itemtag} class='gallery-item'>";
        $output .= "\r\n\t\t\t<{$icontag} class='gallery-icon'>\r\n\t\t\t\t{$link}\r\n\t\t\t</{$icontag}>";
        if ($captiontag && trim($attachment->post_excerpt)) {
            $output .= "\r\n\t\t\t\t<{$captiontag} class='gallery-caption'>\r\n\t\t\t\t" . wptexturize($attachment->post_excerpt) . "\r\n\t\t\t\t</{$captiontag}>";
        }
        $output .= "</{$itemtag}>";
        if ($columns > 0 && ++$i % $columns == 0) {
            $output .= '<br style="clear: both" />';
        }
    }
    $output .= "\r\n\t\t\t<br style='clear: both;' />\r\n\t\t</div>\n";
    return $output;
}
/**
 * Dispaly the list of comments.
 *
 * @since 4.0.0
 */
function cherry_comments_default_list()
{
    $defaults = array('style' => 'ol', 'type' => 'all', 'avatar_size' => 48, 'short_ping' => true, 'callback' => 'cherry_rewrite_comment_item');
    /**
     * Filter the defaults list arguments of comments.
     *
     * @since 4.0.0
     * @param array $defaults Defaults arguments.
     */
    $args = apply_filters('cherry_comment_list_args', $defaults);
    // Set argument 'echo' to the function 'wp_list_comments' for return result.
    $args = array_merge($args, array('echo' => false));
    printf('<%1$s class="comment-list">%2$s</%1$s>', tag_escape($args['style']), wp_list_comments($args));
}
Beispiel #7
0
function theme_gallery_shortcode($attr)
{
    global $post;
    // Allow plugins/themes to override the default gallery template.
    $output = apply_filters('post_gallery', '', $attr);
    if ($output != '') {
        return $output;
    }
    // We're trusting author input, so let's at least make sure it looks like a valid orderby statement
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail'), $attr));
    $id = intval($id);
    $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    if (empty($attachments)) {
        return '';
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $id => $attachment) {
            $output .= wp_get_attachment_link($id, $size, true) . "\n";
        }
        return $output;
    }
    $itemtag = tag_escape($itemtag);
    $captiontag = tag_escape($captiontag);
    $columns = intval($columns);
    $itemwidth = $columns > 0 ? floor(100 / $columns) : 100;
    $output = '<div class="gallery">' . "\n";
    $i = 0;
    foreach ($attachments as $id => $attachment) {
        $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
        $output .= "\n<" . $itemtag . ' class="gallery-item" style="width:' . $itemwidth . '%;">' . "\n";
        $output .= '<' . $icontag . ' class="gallery-icon">' . $link . '</' . $icontag . '>';
        if ($captiontag && trim($attachment->post_excerpt)) {
            $output .= '<' . $captiontag . ' class="gallery-caption">' . $attachment->post_excerpt . '</' . $captiontag . '>';
        }
        $output .= '</' . $itemtag . '>' . "\n";
        if ($columns > 0 && ++$i % $columns == 0) {
            $output .= "\n" . '<br class="clear" />' . "\n";
        }
    }
    $output .= "\n" . '<br class="clear" />' . "</div>\n";
    return $output;
}
Beispiel #8
0
function cfct_post_gallery($attr)
{
    global $post;
    // We're trusting author input, so let's at least make sure it looks like a valid orderby statement
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail'), $attr));
    $id = intval($id);
    $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    if (empty($attachments)) {
        return '';
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $id => $attachment) {
            $output .= wp_get_attachment_link($id, $size, true) . "\n";
        }
        return $output;
    }
    $itemtag = tag_escape($itemtag);
    $captiontag = tag_escape($captiontag);
    $columns = apply_filters('cfct_post_gallery_columns', intval($columns));
    $itemwidth = $columns > 0 ? floor(100 / $columns) : 100;
    $output = apply_filters('gallery_style', "\n\t\t<style type='text/css'>\n\t\t\t.gallery {\n\t\t\t\tmargin: auto;\n\t\t\t}\n\t\t\t.gallery-item {\n\t\t\t\tfloat: left;\n\t\t\t\tmargin-top: 10px;\n\t\t\t\ttext-align: center;\n\t\t\t\twidth: {$itemwidth}%;\t\t\t}\n\t\t\t.gallery img {\n\t\t\t\tborder: 2px solid #cfcfcf;\n\t\t\t}\n\t\t\t.gallery-caption {\n\t\t\t\tmargin-left: 0;\n\t\t\t}\n\t\t</style>\n\t\t<!-- see gallery_shortcode() in wp-includes/media.php -->\n\t\t<div class='gallery'>");
    $i = 0;
    foreach ($attachments as $id => $attachment) {
        // get full item src
        $item_src = wp_get_attachment_image_src($id, 'full', false);
        $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
        // add full item src as rel
        $link = str_replace('><img', ' class="thickbox" rel="' . $item_src[0] . '"><img', $link);
        $output .= "<{$itemtag} class='gallery-item'>";
        $output .= "\n\t\t\t<{$icontag} class='gallery-icon'>\n\t\t\t\t{$link}\n\t\t\t</{$icontag}>";
        if ($captiontag && trim($attachment->post_excerpt)) {
            $output .= "\n\t\t\t\t<{$captiontag} class='gallery-caption'>\n\t\t\t\t{$attachment->post_excerpt}\n\t\t\t\t</{$captiontag}>";
        }
        $output .= "</{$itemtag}>";
        if ($columns > 0 && ++$i % $columns == 0) {
            $output .= '<br style="clear: both" />';
        }
    }
    $output .= "\n\t\t\t<br style='clear: both;' />\n\t\t</div>\n";
    return $output;
}
/**
 * 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 tc_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'), 'network' => false, '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 = tc_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;
    }
}
Beispiel #10
0
function post_gallery_output($output, $attr)
{
    global $post;
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => ''), $attr));
    $id = intval($id);
    if ('RAND' == $order) {
        $orderby = 'none';
    }
    if (!empty($include)) {
        $include = preg_replace('/[^0-9,]+/', '', $include);
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    }
    if (empty($attachments)) {
        return '';
    }
    $itemtag = tag_escape($itemtag);
    $captiontag = tag_escape($captiontag);
    $columns = intval($columns);
    $itemwidth = $columns > 0 ? floor(100 / $columns) : 100;
    // Here's your actual output, you may customize it to your need
    $output = "<div id=\"gallery-{$id}\" class=\"gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}\">\n";
    // Now you loop through each attachment
    foreach ($attachments as $id => $attachment) {
        // Fetch the thumbnail (or full image, it's up to you)
        //      $img = wp_get_attachment_image_src($id, 'medium');
        $img_large = wp_get_attachment_image_src($id, 'large');
        $img = wp_get_attachment_image_src($id, 'thumbnail');
        $output .= "<div class=\"gallery-item\">\n";
        $output .= "<a href=\"{$img_large[0]}\" data-lightbox=\"post-gallery\" data-title=\" {$attachment->post_excerpt} \">\n";
        $output .= "<img src=\"{$img[0]}\" width=\"{$img[1]}\" height=\"{$img[2]}\" alt=\"\" />\n";
        $output .= "</a>\n";
        $output .= "</div>\n";
    }
    $output .= "</div>\n";
    return $output;
}
Beispiel #11
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;
     }
 }
Beispiel #12
0
 function sf_gallery($attr)
 {
     $post = get_post();
     static $instance = 0;
     $instance++;
     if (!empty($attr['ids'])) {
         // 'ids' is explicitly ordered, unless you specify otherwise.
         if (empty($attr['orderby'])) {
             $attr['orderby'] = 'post__in';
             $attr['include'] = $attr['ids'];
         }
     }
     // Allow plugins/themes to override the default gallery template.
     $output = apply_filters('post_gallery', '', $attr);
     if ($output != '') {
         return $output;
     }
     // We're trusting author input, so let's at least make sure it looks like a valid orderby statement
     if (isset($attr['orderby'])) {
         $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
         if (!$attr['orderby']) {
             unset($attr['orderby']);
         }
     }
     extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post ? $post->ID : 0, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'large', 'include' => '', 'exclude' => ''), $attr, 'gallery'));
     $id = intval($id);
     if ('RAND' == $order) {
         $orderby = 'none';
     }
     if (!empty($include)) {
         $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
         $attachments = array();
         foreach ($_attachments as $key => $val) {
             $attachments[$val->ID] = $_attachments[$key];
         }
     } elseif (!empty($exclude)) {
         $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
     } else {
         $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
     }
     if (empty($attachments)) {
         return '';
     }
     if (is_feed()) {
         $output = "\n";
         foreach ($attachments as $att_id => $attachment) {
             $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
         }
         return $output;
     }
     $itemtag = tag_escape($itemtag);
     $captiontag = tag_escape($captiontag);
     $icontag = tag_escape($icontag);
     $valid_tags = wp_kses_allowed_html('post');
     if (!isset($valid_tags[$itemtag])) {
         $itemtag = 'dl';
     }
     if (!isset($valid_tags[$captiontag])) {
         $captiontag = 'dd';
     }
     if (!isset($valid_tags[$icontag])) {
         $icontag = 'dt';
     }
     $columns = intval($columns);
     $itemwidth = $columns > 0 ? floor(100 / $columns) : 100;
     $float = is_rtl() ? 'right' : 'left';
     $selector = "gallery-{$instance}";
     $gallery_style = '';
     $size_class = sanitize_html_class($size);
     $output = "<div id='{$selector}' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
     $i = 0;
     foreach ($attachments as $id => $attachment) {
         $image_output = '<figure class="animated-overlay">';
         $image_file_url = wp_get_attachment_image_src($id, $size);
         $image_file_lightbox_url = wp_get_attachment_url($id, "full");
         $image_caption = wptexturize($attachment->post_excerpt);
         $image_meta = wp_get_attachment_metadata($id);
         $image_alt = get_post_meta($id, '_wp_attachment_image_alt', true);
         $image_output .= '<img src="' . $image_file_url[0] . '" alt="' . $image_alt . '" />';
         if (!empty($attr['link']) && 'file' === $attr['link']) {
             $image_output .= '<a href="' . $image_file_lightbox_url . '" class="view" rel="' . $selector . '" title="' . $image_alt . '"></a>';
         } elseif (!empty($attr['link']) && 'none' === $attr['link']) {
         } else {
             $image_output .= '<a href="' . get_attachment_link($id) . '"></a>';
         }
         if ($captiontag && trim($attachment->post_excerpt) && $columns <= 3) {
             $image_output .= '<figcaption><div class="thumb-info">';
             $image_output .= '<h4 itemprop="name headline">' . wptexturize($attachment->post_excerpt) . '</h4>';
         } else {
             $image_output .= '<figcaption><div class="thumb-info thumb-info-alt">';
         }
         $image_output .= '<i class="ss-search"></i>';
         $image_output .= '</div></figcaption>';
         $image_output .= '</figure>';
         $orientation = '';
         if (isset($image_meta['height'], $image_meta['width'])) {
             $orientation = $image_meta['height'] > $image_meta['width'] ? 'portrait' : 'landscape';
         }
         $output .= "<{$itemtag} class='gallery-item'>";
         $output .= "\n\t\t\t<{$icontag} class='gallery-icon {$orientation}'>\n\t\t\t{$image_output}\n\t\t\t</{$icontag}>";
         $output .= "</{$itemtag}>";
     }
     $output .= "\n\t\t<br style='clear: both;' />\n\t\t</div>\n";
     return $output;
 }
Beispiel #13
0
/**
 * Dynamic element to wrap the site description in.  If it is the front page, wrap it in an <h2> element.  
 * On other pages, wrap it in a <div> element.
 *
 * @since 0.1.0
 * @access public
 * @return void
 */
function hybrid_site_description()
{
    /* If viewing the front page of the site, use an <h2> tag.  Otherwise, use a <div> tag. */
    $tag = is_front_page() ? 'h2' : 'div';
    /* Get the site description.  If it's not empty, wrap it with the appropriate HTML. */
    if ($desc = get_bloginfo('description')) {
        $desc = sprintf('<%1$s id="site-description"><span>%2$s</span></%1$s>', tag_escape($tag), $desc);
    }
    /* Display the site description and apply filters for developers to overwrite. */
    echo apply_atomic('site_description', $desc);
}
 /**
  * Formats and outputs the breadcrumb trail.
  *
  * @since  0.6.0
  * @access public
  * @return string
  */
 public function trail()
 {
     $breadcrumb = '';
     /* Connect the breadcrumb trail if there are items in the trail. */
     if (!empty($this->items) && is_array($this->items)) {
         /* Make sure we have a unique array of items. */
         $this->items = array_unique($this->items);
         /* Open the breadcrumb trail containers. */
         $breadcrumb = "\n\t\t" . '<' . tag_escape($this->args['container']) . ' class="breadcrumb-trail breadcrumb">';
         // xmlns:v="http://rdf.data-vocabulary.org/#" itemprop="breadcrumb"
         /* If $before was set, wrap it in a container. */
         $breadcrumb .= !empty($this->args['before']) ? "\n\t\t\t" . '<span class="trail-before">' . $this->args['before'] . '</span> ' . "\n\t\t\t" : '';
         /* Add 'browse' label if it should be shown. */
         if (true === $this->args['show_browse']) {
             $breadcrumb .= "\n\t\t\t" . '<span class="trail-browse">' . $this->args['labels']['browse'] . '</span> ';
         }
         /* Adds the 'trail-begin' class around first item if there's more than one item. */
         if (1 < count($this->items)) {
             array_unshift($this->items, '<span class="trail-begin">' . array_shift($this->items) . '</span>');
         }
         /* Adds the 'trail-end' class around last item. */
         array_push($this->items, '<span class="trail-end">' . array_pop($this->items) . '</span>');
         /* Format the separator. */
         $separator = !empty($this->args['separator']) ? '<span class="sep navigation-pipe">' . $this->args['separator'] . '</span>' : '<span class="navigation-pipe">/</span>';
         /* Join the individual trail items into a single string. */
         $breadcrumb .= join("\n\t\t\t {$separator} ", $this->items);
         /* If $after was set, wrap it in a container. */
         $breadcrumb .= !empty($this->args['after']) ? "\n\t\t\t" . ' <span class="trail-after">' . $this->args['after'] . '</span>' : '';
         /* Close the breadcrumb trail containers. */
         $breadcrumb .= "\n\t\t" . '</' . tag_escape($this->args['container']) . '>';
     }
     /* Allow developers to filter the breadcrumb trail HTML. */
     $breadcrumb = apply_filters('breadcrumb_trail', $breadcrumb, $this->args);
     if (true === $this->args['echo']) {
         echo balanceTags($breadcrumb);
     } else {
         return balanceTags($breadcrumb);
     }
 }
Beispiel #15
0
function roots_gallery_shortcode($attr)
{
    global $post, $wp_locale;
    static $instance = 0;
    $instance++;
    // Allow plugins/themes to override the default gallery template.
    $output = apply_filters('post_gallery', '', $attr);
    if ($output != '') {
        return $output;
    }
    // We're trusting author input, so let's at least make sure it looks like a valid orderby statement
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'icontag' => 'figure', 'captiontag' => 'figcaption', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => ''), $attr));
    $id = intval($id);
    if ('RAND' == $order) {
        $orderby = 'none';
    }
    if (!empty($include)) {
        $include = preg_replace('/[^0-9,]+/', '', $include);
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    } elseif (!empty($exclude)) {
        $exclude = preg_replace('/[^0-9,]+/', '', $exclude);
        $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    } else {
        $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    }
    if (empty($attachments)) {
        return '';
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $att_id => $attachment) {
            $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
        }
        return $output;
    }
    $captiontag = tag_escape($captiontag);
    $columns = intval($columns);
    $itemwidth = $columns > 0 ? floor(100 / $columns) : 100;
    $float = is_rtl() ? 'right' : 'left';
    $selector = "gallery-{$instance}";
    $gallery_style = $gallery_div = '';
    if (apply_filters('use_default_gallery_style', true)) {
        $gallery_style = "";
    }
    $size_class = sanitize_html_class($size);
    $gallery_div = "<section id='{$selector}' class='clearfix gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
    $output = apply_filters('gallery_style', $gallery_style . "\n\t\t" . $gallery_div);
    $i = 0;
    foreach ($attachments as $id => $attachment) {
        // make the gallery link to the file by default instead of the attachment
        // thanks to Matt Price (countingrows.com)
        switch ($attr['link']) {
            case 'file':
                $link = wp_get_attachment_link($id, $size, false, false);
                break;
            case 'attachment':
                $link = wp_get_attachment_link($id, $size, true, false);
                break;
            default:
                $link = wp_get_attachment_link($id, $size, false, false);
                break;
        }
        $output .= "\n\t\t\t<{$icontag} class=\"gallery-item\">\n\t\t\t\t{$link}\n\t\t\t";
        if ($captiontag && trim($attachment->post_excerpt)) {
            $output .= "\n\t\t\t\t<{$captiontag} class=\"gallery-caption\">\n\t\t\t\t" . wptexturize($attachment->post_excerpt) . "\n\t\t\t\t</{$captiontag}>";
        }
        $output .= "</{$icontag}>";
        if ($columns > 0 && ++$i % $columns == 0) {
            $output .= '';
        }
    }
    $output .= "</section>\n";
    return $output;
}
/**
 * Overwrites the default WordPress [gallery] shortcode's output.  This function removes the invalid 
 * HTML and inline styles.  It adds the number of columns used as a class attribute, which allows 
 * developers to style the gallery more easily.
 *
 * @since 0.9.0
 * @access private
 * @param string $output
 * @param array $attr
 * @return string $output
 */
function cleaner_gallery($output, $attr)
{
    static $cleaner_gallery_instance = 0;
    $cleaner_gallery_instance++;
    /* We're not worried abut galleries in feeds, so just return the output here. */
    if (is_feed()) {
        return $output;
    }
    /* Orderby. */
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    /* Default gallery settings. */
    $defaults = array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => get_the_ID(), 'link' => '', 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => '', 'numberposts' => -1, 'offset' => '');
    /* Apply filters to the default arguments. */
    $defaults = apply_filters('cleaner_gallery_defaults', $defaults);
    /* Apply filters to the arguments. */
    $attr = apply_filters('cleaner_gallery_args', $attr);
    /* Merge the defaults with user input.  */
    $attr = shortcode_atts($defaults, $attr);
    extract($attr);
    $id = intval($id);
    /* Arguments for get_children(). */
    $children = array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby, 'exclude' => $exclude, 'include' => $include, 'numberposts' => $numberposts, 'offset' => $offset, 'suppress_filters' => true);
    /* Get image attachments. If none, return. */
    $attachments = get_children($children);
    if (empty($attachments)) {
        return '';
    }
    /* Properly escape the gallery tags. */
    $itemtag = tag_escape($itemtag);
    $icontag = tag_escape($icontag);
    $captiontag = tag_escape($captiontag);
    $i = 0;
    /* Count the number of attachments returned. */
    $attachment_count = count($attachments);
    /* Allow developers to overwrite the number of columns. This can be useful for reducing columns with with fewer images than number of columns. */
    //$columns = ( ( $columns <= $attachment_count ) ? intval( $columns ) : intval( $attachment_count ) );
    $columns = apply_filters('cleaner_gallery_columns', intval($columns), $attachment_count, $attr);
    /* Open the gallery <div>. */
    $output = "\n\t\t\t<div id='gallery-{$id}-{$cleaner_gallery_instance}' class='gallery gallery-{$id}'>";
    /* Loop through each attachment. */
    foreach ($attachments as $id => $attachment) {
        /* Open each gallery row. */
        if ($columns > 0 && $i % $columns == 0) {
            $output .= "\n\t\t\t\t<div class='gallery-row gallery-clear'>";
        }
        /* Open each gallery item. */
        $output .= "\n\t\t\t\t\t<{$itemtag} class='gallery-item col-{$columns}'>";
        /* Open the element to wrap the image. */
        $output .= "\n\t\t\t\t\t\t<{$icontag} class='gallery-icon'>";
        /* Add the image. */
        $image = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
        $output .= apply_filters('cleaner_gallery_image', $image, $id, $attr, $cleaner_gallery_instance);
        /* Close the image wrapper. */
        $output .= "</{$icontag}>";
        /* Get the caption. */
        $caption = apply_filters('cleaner_gallery_caption', wptexturize(esc_html($attachment->post_excerpt)), $id, $attr, $cleaner_gallery_instance);
        /* If image caption is set. */
        if (!empty($caption)) {
            $output .= "\n\t\t\t\t\t\t<{$captiontag} class='gallery-caption'>{$caption}</{$captiontag}>";
        }
        /* Close individual gallery item. */
        $output .= "\n\t\t\t\t\t</{$itemtag}>";
        /* Close gallery row. */
        if ($columns > 0 && ++$i % $columns == 0) {
            $output .= "\n\t\t\t\t</div>";
        }
    }
    /* Close gallery row. */
    if ($columns > 0 && $i % $columns !== 0) {
        $output .= "\n\t\t\t</div>";
    }
    /* Close the gallery <div>. */
    $output .= "\n\t\t\t</div><!-- .gallery -->\n";
    /* Return out very nice, valid HTML gallery. */
    return $output;
}
Beispiel #17
0
function ljxp_inline_gallery($output, $attr)
{
    global $post;
    // We're trusting author input, so let's at least make sure it looks like a valid orderby statement
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => ''), $attr));
    $id = intval($id);
    if ('RAND' == $order) {
        $orderby = 'none';
    }
    if (!empty($include)) {
        $include = preg_replace('/[^0-9,]+/', '', $include);
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    } elseif (!empty($exclude)) {
        $exclude = preg_replace('/[^0-9,]+/', '', $exclude);
        $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    } else {
        $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    }
    if (empty($attachments)) {
        return '';
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $att_id => $attachment) {
            $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
        }
        return $output;
    }
    $itemtag = tag_escape($itemtag);
    $captiontag = tag_escape($captiontag);
    $columns = intval($columns);
    $itemwidth = $columns > 0 ? floor(100 / $columns) : 100;
    $float = is_rtl() ? 'right' : 'left';
    $selector = "gallery-{$instance}";
    $gallery_style = $gallery_div = '';
    $size_class = sanitize_html_class($size);
    $gallery_div = "<div style='margin: auto;'>";
    $i = 0;
    foreach ($attachments as $id => $attachment) {
        $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
        $output .= "<{$itemtag} style='float: {$float}; margin-top: 10px; text-align: center; width: {$itemwidth}%;'>";
        $output .= "\r\n\t\t\t<{$icontag} class='gallery-icon'>\r\n\t\t\t\t{$link}\r\n\t\t\t</{$icontag}>";
        if ($captiontag && trim($attachment->post_excerpt)) {
            $output .= "\r\n\t\t\t\t<{$captiontag} style='margin-left: 0;'>\r\n\t\t\t\t" . wptexturize($attachment->post_excerpt) . "\r\n\t\t\t\t</{$captiontag}>";
        }
        $output .= "</{$itemtag}>";
        if ($columns > 0 && ++$i % $columns == 0) {
            $output .= '<br style="clear: both" />';
        }
    }
    $output .= "\r\n\t\t\t<br style='clear: both;' />\r\n\t\t</div>\n";
    return $output;
}
Beispiel #18
0
/**
 * Clean up gallery_shortcode()
 *
 * Re-create the [gallery] shortcode and use thumbnails styling from Bootstrap
 *
 * @link http://twitter.github.com/bootstrap/components.html#thumbnails
 */
function roots_gallery($attr)
{
    global $post, $wp_locale;
    static $instance = 0;
    $instance++;
    $output = apply_filters('post_gallery', '', $attr);
    if ($output != '') {
        return $output;
    }
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'icontag' => 'li', 'captiontag' => 'p', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => ''), $attr));
    $id = intval($id);
    if ($order === 'RAND') {
        $orderby = 'none';
    }
    if (!empty($include)) {
        $include = preg_replace('/[^0-9,]+/', '', $include);
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    } elseif (!empty($exclude)) {
        $exclude = preg_replace('/[^0-9,]+/', '', $exclude);
        $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    } else {
        $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    }
    if (empty($attachments)) {
        return '';
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $att_id => $attachment) {
            $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
        }
        return $output;
    }
    $captiontag = tag_escape($captiontag);
    $columns = intval($columns);
    $itemwidth = $columns > 0 ? floor(100 / $columns) : 100;
    $float = is_rtl() ? 'right' : 'left';
    $selector = "gallery-{$instance}";
    $gallery_style = $gallery_div = '';
    if (apply_filters('use_default_gallery_style', true)) {
        $gallery_style = '';
    }
    $size_class = sanitize_html_class($size);
    $gallery_div = "<ul id='{$selector}' class='thumbnails gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
    $output = apply_filters('gallery_style', $gallery_style . "\n\t\t" . $gallery_div);
    $i = 0;
    foreach ($attachments as $id => $attachment) {
        $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
        $output .= "\n      <{$icontag} class=\"gallery-item\">\n        {$link}\n      ";
        if ($captiontag && trim($attachment->post_excerpt)) {
            $output .= "\n        <{$captiontag} class=\"gallery-caption hidden\">\n        " . wptexturize($attachment->post_excerpt) . "\n        </{$captiontag}>";
        }
        $output .= "</{$icontag}>";
        if ($columns > 0 && ++$i % $columns == 0) {
            $output .= '';
        }
    }
    $output .= "</ul>\n";
    return $output;
}
/**
 * Callback function to display galleries (in HTML5)
 *
 * @author	Konstantin Obenland
 * @since	1.0.0 - 05.02.2012
 *
 * @param	string	$content
 * @param	array	$attr
 *
 * @return	string
 */
function the_bootstrap_post_gallery($content, $attr)
{
    global $instance, $post;
    $instance++;
    // We're trusting author input, so let's at least make sure it looks like a valid orderby statement
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'figure', 'icontag' => 'div', 'captiontag' => 'figcaption', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => ''), $attr));
    $id = intval($id);
    if ('RAND' == $order) {
        $orderby = 'none';
    }
    if ($include) {
        $include = preg_replace('/[^0-9,]+/', '', $include);
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    } elseif ($exclude) {
        $exclude = preg_replace('/[^0-9,]+/', '', $exclude);
        $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    } else {
        $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    }
    if (empty($attachments)) {
        return;
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $att_id => $attachment) {
            $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
        }
        return $output;
    }
    $itemtag = tag_escape($itemtag);
    $captiontag = tag_escape($captiontag);
    $columns = intval(min(array(8, $columns)));
    $float = is_rtl() ? 'right' : 'left';
    if (4 > $columns) {
        $size = 'full';
    }
    $selector = "gallery-{$instance}";
    $size_class = sanitize_html_class($size);
    $output = "<ul id='{$selector}' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class} thumbnails'>";
    $i = 0;
    foreach ($attachments as $id => $attachment) {
        $comments = get_comments(array('post_id' => $id, 'count' => true, 'type' => 'comment', 'status' => 'approve'));
        $link = wp_get_attachment_link($id, $size, !(isset($attr['link']) and 'file' == $attr['link']));
        $clear_class = 0 == $i++ % $columns ? ' clear' : '';
        $span = 'span' . floor(8 / $columns);
        $output .= "<li class='{$span}{$clear_class}'><{$itemtag} class='gallery-item'>";
        $output .= "<{$icontag} class='gallery-icon'>{$link}</{$icontag}>\n";
        if ($captiontag and (0 < $comments or trim($attachment->post_excerpt))) {
            $comments = 0 < $comments ? sprintf(_n('%d comment', '%d comments', $comments, 'the-bootstrap'), $comments) : '';
            $excerpt = wptexturize($attachment->post_excerpt);
            $out = ($comments and $excerpt) ? " {$excerpt} <br /> {$comments} " : " {$excerpt}{$comments} ";
            $output .= "<{$captiontag} class='wp-caption-text gallery-caption'>{$out}</{$captiontag}>\n";
        }
        $output .= "</{$itemtag}></li>\n";
    }
    $output .= "</ul>\n";
    return $output;
}
function my_gallery_shortcode($attr)
{
    $post = get_post();
    static $instance = 0;
    $instance++;
    if (!empty($attr['ids'])) {
        // 'ids' is explicitly ordered, unless you specify otherwise.
        if (empty($attr['orderby'])) {
            $attr['orderby'] = 'post__in';
        }
        $attr['include'] = $attr['ids'];
    }
    // Allow plugins/themes to override the default gallery template.
    $output = apply_filters('post_gallery', '', $attr);
    if ($output != '') {
        return $output;
    }
    // We're trusting author input, so let's at least make sure it looks like a valid orderby statement
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'li', 'icontag' => 'li', 'captiontag' => 'span', 'columns' => 3, 'size' => 'gallery', 'include' => '', 'exclude' => ''), $attr));
    $id = intval($id);
    if ('RAND' == $order) {
        $orderby = 'none';
    }
    if (!empty($include)) {
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    } elseif (!empty($exclude)) {
        $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    } else {
        $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    }
    if (empty($attachments)) {
        return '';
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $att_id => $attachment) {
            $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
        }
        return $output;
    }
    $itemtag = tag_escape($itemtag);
    $captiontag = tag_escape($captiontag);
    $icontag = tag_escape($icontag);
    $valid_tags = wp_kses_allowed_html('post');
    if (!isset($valid_tags[$itemtag])) {
        $itemtag = 'dl';
    }
    if (!isset($valid_tags[$captiontag])) {
        $captiontag = 'dd';
    }
    if (!isset($valid_tags[$icontag])) {
        $icontag = 'dt';
    }
    $columns = intval($columns);
    $itemwidth = $columns > 0 ? floor(100 / $columns) : 100;
    $float = is_rtl() ? 'right' : 'left';
    $selector = "gallery-{$instance}";
    $gallery_div = "<div id='{$selector}' class='cycle-slideshow gallery galleryid-{$id}' data-cycle-fx='scrollHorz' data-cycle-timeout='0' data-cycle-swipe=true data-cycle-slides='div'>\n\t<nav class='cycle-prev'></nav>\n    <nav class='cycle-next'></nav>\n    ";
    $output = $gallery_div;
    $i = 0;
    foreach ($attachments as $id => $attachment) {
        $tag = '';
        $img = wp_get_attachment_image_src($id, $size);
        /*
        		$largeimg = wp_get_attachment_image_src($id, 'single');
        		$large = $largeimg[0];
        */
        if ($captiontag && trim($attachment->post_excerpt)) {
            $tag = "\n\t\t\t\t<{$captiontag} class='wp-caption-text gallery-caption'>\n\t\t\t\t" . wptexturize($attachment->post_excerpt) . "\n\t\t\t\t</{$captiontag}>";
        } else {
            $tag = null;
        }
        /*
        
        		$output .= "
        			<{$icontag} class='gallery-item'>
        			<div class='gallery-item-holder'>
        				<div class='gallery-img'>
        					<img src='{$img[0]}'>
        				</div>
        				{$tag}
        			</div>
        			</{$icontag}>";
        */
        $output .= "<div><img src='{$img[0]}'>{$tag}</div>";
    }
    $output .= "</div>\n";
    return $output;
}
 /**
  * Filter: 'wpseo_breadcrumb_output_wrapper' - Allow changing the HTML wrapper element for the WP SEO breadcrumbs output
  *
  * @api string $wrapper The wrapper element
  */
 private function filter_wrapper()
 {
     $wrapper = apply_filters('wpseo_breadcrumb_output_wrapper', $this->wrapper);
     $wrapper = tag_escape($wrapper);
     if (is_string($wrapper) && '' !== $wrapper) {
         $this->wrapper = $wrapper;
     }
 }
Beispiel #22
0
/**
 * Filter the default gallery shortcode.
 *
 * This filter allows the output of the default gallery shortcode to be
 * customized and adds support for additional functionality, shortcode
 * attributes, and classes for CSS and JavaScript hooks.
 *
 * A lot of the default sanitization is duplicated because WordPress doesn't
 * provide a filter later in the process.
 *
 * @since 1.2.0
 *
 * @param string $output Output string passed from default shortcode.
 * @param array $attr Array of shortcode attributes.
 * @return string Custom gallery output markup.
 */
function audiotheme_post_gallery($output, $attr)
{
    global $post;
    // Something else is already overriding the gallery. Jetpack?
    if (!empty($output)) {
        return $output;
    }
    static $instance = 0;
    $instance++;
    // Let WordPress handle the output for feed requests.
    if (is_feed()) {
        return $output;
    }
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    $attr = shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'link' => 'file', 'columns' => 3, 'size' => 'thumbnail', 'ids' => '', 'include' => '', 'exclude' => ''), $attr, 'gallery');
    $attr['id'] = absint($attr['id']);
    if ('RAND' === $attr['order']) {
        $attr['orderby'] = 'none';
    }
    // Build up an array of arguments to pass to get_posts().
    $args = array('post_parent' => $attr['id'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $attr['order'], 'orderby' => $attr['orderby'], 'numberposts' => -1);
    if (!empty($attr['ids'])) {
        $attr['include'] = $attr['ids'];
        // 'ids' should be explicitly ordered.
        $args['orderby'] = 'post__in';
    }
    if (!empty($attr['include'])) {
        $args['include'] = $attr['include'];
        // Don't want to restrict images to a parent post if 'include' is set.
        unset($args['post_parent']);
    } elseif (!empty($attr['exclude'])) {
        $args['exclude'] = $attr['exclude'];
    }
    $attachments = get_posts($args);
    if (empty($attachments)) {
        return '';
    }
    // Sanitize tags and values.
    $attr['captiontag'] = tag_escape($attr['captiontag']);
    $attr['icontag'] = tag_escape($attr['icontag']);
    $attr['itemtag'] = tag_escape($attr['itemtag']);
    $valid_tags = wp_kses_allowed_html('post');
    $attr['captiontag'] = isset($valid_tags[$attr['captiontag']]) ? $attr['captiontag'] : 'dd';
    $attr['icontag'] = isset($valid_tags[$attr['icontag']]) ? $attr['icontag'] : 'dl';
    $attr['itemtag'] = isset($valid_tags[$attr['itemtag']]) ? $attr['itemtag'] : 'dl';
    $attr['columns'] = absint($attr['columns']) ? absint($attr['columns']) : 1;
    // Add gallery wrapper classes to $attr variable so they can be passed to the filter.
    $attr['gallery_classes'] = array('gallery', 'galleryid-' . $attr['id'], 'gallery-columns-' . $attr['columns'], 'gallery-size-' . $attr['size'], 'gallery-link-' . $attr['link'], is_rtl() ? 'gallery-rtl' : 'gallery-ltr');
    $attr['gallery_classes'] = apply_filters('audiotheme_post_gallery_classes', $attr['gallery_classes'], $attr, $instance);
    extract($attr);
    // id attribute is a combination of post ID and instance to ensure uniqueness.
    $wrapper = sprintf("\n" . '<div id="gallery-%d-%d" class="%s">', $post->ID, $instance, join(' ', array_map('sanitize_html_class', $gallery_classes)));
    // Hooks should append custom output to the $wrapper arg if necessary and be sure to close the div.
    $output = apply_filters('audiotheme_post_gallery_output', $wrapper, $attachments, $attr, $instance);
    // Skip output generation if a hook modified the output.
    if (empty($output) || $wrapper === $output) {
        // If $output is empty for some reason, restart the output with the default wrapper.
        if (empty($output)) {
            $output = $wrapper;
        }
        foreach ($attachments as $i => $attachment) {
            // More 'link' options have been added.
            if ('none' === $link) {
                // Don't link the thumbnails in the gallery.
                $href = '';
            } elseif ('file' === $link) {
                // Link directly to the attachment.
                $href = wp_get_attachment_url($attachment->ID);
            } elseif ('link' === $link) {
                // Use a custom meta field associated with the image for the link.
                $href = get_post_meta($attachment->ID, '_audiotheme_attachment_url', true);
            } else {
                // Link to the attachment's permalink page.
                $href = get_permalink($attachment->ID);
            }
            $image_meta = wp_get_attachment_metadata($attachment->ID);
            $orientation = '';
            if (isset($image_meta['height'], $image_meta['width'])) {
                $orientation = $image_meta['height'] > $image_meta['width'] ? 'portrait' : 'landscape';
            }
            $classes = array('gallery-item', 'gallery-item-' . ($i + 1));
            $classes = array_merge($classes, audiotheme_nth_child_classes(array('base' => 'gallery-item', 'current' => $i + 1, 'max' => $columns)));
            $output .= "\n\t\t" . '<' . $itemtag . ' class="' . join(' ', $classes) . '">';
            $output .= '<' . $icontag . ' class="gallery-icon ' . $orientation . '">';
            $image = $href ? '<a href="' . esc_url($href) . '">' : '';
            $image .= wp_get_attachment_image($attachment->ID, $size, false);
            $image .= $href ? '</a>' : '';
            // Some plugins use this filter, so mimic it as best we can.
            if ('none' !== $link) {
                $permalink = in_array($link, array('file', 'link')) ? false : true;
                $icon = $text = false;
                $image = apply_filters('wp_get_attachment_link', $image, $attachment->ID, $size, $permalink, $icon, $text);
            }
            $output .= $image;
            $output .= '</' . $icontag . '>';
            if ($captiontag && trim($attachment->post_excerpt)) {
                $output .= '<' . $captiontag . ' class="wp-caption-text gallery-caption">';
                $output .= wptexturize($attachment->post_excerpt);
                $output .= '</' . $captiontag . '>';
            }
            $output .= '</' . $itemtag . '>';
        }
        $output .= "\n</div>\n";
        // Close the default gallery wrapper.
    }
    return $output;
}
 /**
  * Formats and outputs the breadcrumb trail.
  *
  * @since  0.6.0
  * @access public
  * @return string
  */
 public function trail()
 {
     $breadcrumb = '';
     /* Connect the breadcrumb trail if there are items in the trail. */
     if (!empty($this->items) && is_array($this->items)) {
         /* Make sure we have a unique array of items. */
         $this->items = array_unique($this->items);
         /* Open the breadcrumb trail containers. */
         $breadcrumb = "\n\t\t" . '<' . tag_escape($this->args['container']) . '  role="navigation" aria-label="' . esc_attr_x('Breadcrumbs', 'Breadcrumbs aria label', 'toivo-lite') . '" class="breadcrumb-trail breadcrumbs" itemprop="breadcrumb">';
         /* If $before was set, wrap it in a container. */
         $breadcrumb .= !empty($this->args['before']) ? "\n\t\t\t" . '<span class="trail-before">' . $this->args['before'] . '</span> ' . "\n\t\t\t" : '';
         /* Add 'browse' label if it should be shown. */
         if (true === $this->args['show_browse']) {
             $breadcrumb .= "\n\t\t\t" . '<h2 class="trail-browse">' . $this->args['labels']['browse'] . '</h2> ';
         }
         /* Adds the 'trail-begin' class around first item if there's more than one item. */
         if (1 < count($this->items)) {
             array_unshift($this->items, '<span class="trail-begin">' . array_shift($this->items) . '</span>');
         }
         /* Adds the 'trail-end' class around last item. */
         array_push($this->items, '<span class="trail-end">' . array_pop($this->items) . '</span>');
         $breadcrumb .= '<ul class="trail-items"><li>';
         /* Join the individual trail items into a single string. */
         $breadcrumb .= join("\n\t\t\t</li><li>", $this->items);
         $breadcrumb .= '</li></ul>';
         /* If $after was set, wrap it in a container. */
         $breadcrumb .= !empty($this->args['after']) ? "\n\t\t\t" . ' <span class="trail-after">' . $this->args['after'] . '</span>' : '';
         /* Close the breadcrumb trail containers. */
         $breadcrumb .= "\n\t\t" . '</' . tag_escape($this->args['container']) . '>';
     }
     /* Allow developers to filter the breadcrumb trail HTML. */
     $breadcrumb = apply_filters('breadcrumb_trail', $breadcrumb, $this->args);
     if (true === $this->args['echo']) {
         echo $breadcrumb;
     } else {
         return $breadcrumb;
     }
 }
Beispiel #24
0
function my_post_gallery($output, $attr)
{
    global $post, $wp_locale;
    static $instance = 0;
    $instance++;
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => '', 'icontag' => '', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'medium', 'include' => '', 'exclude' => ''), $attr));
    $id = intval($id);
    if ('RAND' == $order) {
        $orderby = 'none';
    }
    if (!empty($include)) {
        $include = preg_replace('/[^0-9,]+/', '', $include);
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    } elseif (!empty($exclude)) {
        $exclude = preg_replace('/[^0-9,]+/', '', $exclude);
        $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    } else {
        $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    }
    if (empty($attachments)) {
        return '';
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $att_id => $attachment) {
            $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
        }
        return $output;
    }
    $itemtag = tag_escape($itemtag);
    $captiontag = tag_escape($captiontag);
    $columns = intval($columns);
    $itemwidth = $columns > 0 ? floor(100 / $columns) : 100;
    $float = is_rtl() ? 'right' : 'left';
    $selector = "gallery-{$instance}";
    $output = apply_filters('gallery_style', "<div id='{$selector}' class='gallery galleryid-{$id}'>");
    $output = "<div class=\"phaziz_gallery\">\n";
    $i = 0;
    foreach ($attachments as $id => $attachment) {
        $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size . ' lazyload', false, false) : wp_get_attachment_link($id, $size . ' lazyload', true, false);
        $output .= "{$link}";
        if ($captiontag && trim($attachment->post_excerpt)) {
            $output .= "<{$captiontag} class='gallery-caption'>" . wptexturize($attachment->post_excerpt) . "</{$captiontag}>";
        }
        if ($columns > 0 && ++$i % $columns == 0) {
            $output .= '<br style="clear:both">';
        }
    }
    $output .= "<br style='clear:both'></div>\n";
    return $output;
}
Beispiel #25
0
/**
 * Return RegEx body to liberally match an opening HTML tag.
 *
 * Matches an opening HTML tag that:
 * 1. Is self-closing or
 * 2. Has no body but has a closing tag of the same name or
 * 3. Contains a body and a closing tag of the same name
 *
 * Note: this RegEx does not balance inner tags and does not attempt
 * to produce valid HTML
 *
 * @since 3.6.0
 *
 * @param string $tag An HTML tag name. Example: 'video'.
 * @return string Tag RegEx.
 */
function get_tag_regex($tag)
{
    if (empty($tag)) {
        return;
    }
    return sprintf('<%1$s[^<]*(?:>[\\s\\S]*<\\/%1$s>|\\s*\\/>)', tag_escape($tag));
}
Beispiel #26
0
 /**
  * Formats the HTML output for the breadcrumb trail.
  *
  * @since  0.6.0
  * @access public
  * @return string
  */
 public function trail()
 {
     // Set up variables that we'll need.
     $breadcrumb = '';
     $item_count = count($this->items);
     $item_position = 0;
     // Connect the breadcrumb trail if there are items in the trail.
     if (0 < $item_count) {
         // Add 'browse' label if it should be shown.
         if (true === $this->args['show_browse']) {
             $breadcrumb .= sprintf('<h2 class="trail-browse">%s</h2>', $this->labels['browse']);
         }
         // Open the unordered list.
         $breadcrumb .= '<ul class="trail-items" itemscope itemtype="http://schema.org/BreadcrumbList">';
         // Add the number of items and item list order schema.
         $breadcrumb .= sprintf('<meta name="numberOfItems" content="%d" />', absint($item_count));
         $breadcrumb .= '<meta name="itemListOrder" content="Ascending" />';
         // Loop through the items and add them to the list.
         foreach ($this->items as $item) {
             // Iterate the item position.
             ++$item_position;
             // Check if the item is linked.
             preg_match('/(<a.*?>)(.*?)(<\\/a>)/i', $item, $matches);
             // Wrap the item text with appropriate itemprop.
             $item = !empty($matches) ? sprintf('%s<span itemprop="name">%s</span>%s', $matches[1], $matches[2], $matches[3]) : sprintf('<span itemprop="name">%s</span>', $item);
             // Add list item classes.
             $item_class = 'trail-item';
             if (1 === $item_position && 1 < $item_count) {
                 $item_class .= ' trail-begin';
             } elseif ($item_count === $item_position) {
                 $item_class .= ' trail-end';
             }
             // Create list item attributes.
             $attributes = 'itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem" class="' . $item_class . '"';
             // Build the meta position HTML.
             $meta = sprintf('<meta itemprop="position" content="%s" />', absint($item_position));
             // Build the list item.
             $breadcrumb .= sprintf('<li %s>%s%s</li>', $attributes, $item, $meta);
         }
         // Close the unordered list.
         $breadcrumb .= '</ul>';
         // Wrap the breadcrumb trail.
         $breadcrumb = sprintf('<%1$s role="navigation" aria-label="%2$s" class="breadcrumb-trail breadcrumbs" itemprop="breadcrumb">%3$s%4$s%5$s</%1$s>', tag_escape($this->args['container']), esc_attr($this->labels['aria_label']), $this->args['before'], $breadcrumb, $this->args['after']);
     }
     // Allow developers to filter the breadcrumb trail HTML.
     $breadcrumb = apply_filters('breadcrumb_trail', $breadcrumb, $this->args);
     if (false === $this->args['echo']) {
         return $breadcrumb;
     }
     echo $breadcrumb;
 }
function de_post_gallery($output, $attr)
{
    global $post, $wp_locale;
    static $instance = 0;
    $instance++;
    // We're trusting author input, so let's at least make sure it looks like a valid orderby statement
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => ''), $attr));
    $id = intval($id);
    if ('RAND' == $order) {
        $orderby = 'none';
    }
    if (!empty($include)) {
        $include = preg_replace('/[^0-9,]+/', '', $include);
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    } elseif (!empty($exclude)) {
        $exclude = preg_replace('/[^0-9,]+/', '', $exclude);
        $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    } else {
        $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    }
    if (empty($attachments)) {
        return '';
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $att_id => $attachment) {
            $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
        }
        return $output;
    }
    $itemtag = tag_escape($itemtag);
    $captiontag = tag_escape($captiontag);
    $columns = intval($columns);
    $itemwidth = $columns > 0 ? floor(100 / $columns) : 100;
    $float = is_rtl() ? 'right' : 'left';
    $selector = "gallery-{$instance}";
    $output = apply_filters('gallery_style', "\n\t        <style type='text/css'>\n\t            #{$selector} {\n\t                margin: auto;\n\t            }\n\t            #{$selector} .gallery-item {\n\t                float: {$float};\n\t                margin-top: 10px;\n\t                text-align: center;\n\t                width: {$itemwidth}%;           }\n\t            #{$selector} img {\n\t                border: 2px solid #cfcfcf;\n\t            }\n\t            #{$selector} .gallery-caption {\n\t                margin-left: 0;\n\t            }\n\t        </style>\n\t        <!-- see gallery_shortcode() in wp-includes/media.php -->\n\t        <div id='{$selector}' class='gallery galleryid-{$id}'>");
    $i = 0;
    $rand_id = mt_rand(1, 1000);
    foreach ($attachments as $id => $attachment) {
        $image_attributes = wp_get_attachment_image_src($id, 'large');
        // returns an array
        //$link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false, 'rel="prettyPhoto[pp_gal]"') : wp_get_attachment_link($id, $size, true, false,  'rel="prettyPhoto[pp_gal]"');
        $link = isset($attr['link']) && 'file' == $attr['link'] ? '<a href="' . $image_attributes[0] . '"  rel="prettyPhoto[pp_' . $rand_id . ']">' . wp_get_attachment_image($id, $size, false) . '</a>' : '<a href="' . $image_attributes[0] . '"  rel="prettyPhoto[pp_' . $rand_id . ']">' . wp_get_attachment_image($id, $size, false) . '</a>';
        $output .= "<{$itemtag} class='gallery-item'>";
        $output .= "\n\t            <{$icontag} class='gallery-icon'>\n\t                {$link}\n\t            </{$icontag}>";
        if ($captiontag && trim($attachment->post_excerpt)) {
            $output .= "\n\t                <{$captiontag} class='gallery-caption'>\n\t                " . wp_get_attachment_link($id, $size, true, false, wptexturize($attachment->post_excerpt)) . "\n\t                </{$captiontag}>";
        }
        $output .= "</{$itemtag}>";
        if ($columns > 0 && ++$i % $columns == 0) {
            $output .= '<br style="clear: both" />';
        }
    }
    $output .= "\n\t            <br style='clear: both;' />\n\t        </div>\n";
    return $output;
}
Beispiel #28
0
/**
 * Builds the Gallery shortcode output.
 *
 * This implements the functionality of the Gallery Shortcode for displaying
 * WordPress images on a post.
 *
 * @since 2.5.0
 *
 * @staticvar int $instance
 *
 * @param array $attr {
 *     Attributes of the gallery shortcode.
 *
 *     @type string       $order      Order of the images in the gallery. Default 'ASC'. Accepts 'ASC', 'DESC'.
 *     @type string       $orderby    The field to use when ordering the images. Default 'menu_order ID'.
 *                                    Accepts any valid SQL ORDERBY statement.
 *     @type int          $id         Post ID.
 *     @type string       $itemtag    HTML tag to use for each image in the gallery.
 *                                    Default 'dl', or 'figure' when the theme registers HTML5 gallery support.
 *     @type string       $icontag    HTML tag to use for each image's icon.
 *                                    Default 'dt', or 'div' when the theme registers HTML5 gallery support.
 *     @type string       $captiontag HTML tag to use for each image's caption.
 *                                    Default 'dd', or 'figcaption' when the theme registers HTML5 gallery support.
 *     @type int          $columns    Number of columns of images to display. Default 3.
 *     @type string|array $size       Size of the images to display. Accepts any valid image size, or an array of width
 *                                    and height values in pixels (in that order). Default 'thumbnail'.
 *     @type string       $ids        A comma-separated list of IDs of attachments to display. Default empty.
 *     @type string       $include    A comma-separated list of IDs of attachments to include. Default empty.
 *     @type string       $exclude    A comma-separated list of IDs of attachments to exclude. Default empty.
 *     @type string       $link       What to link each image to. Default empty (links to the attachment page).
 *                                    Accepts 'file', 'none'.
 * }
 * @return string HTML content to display gallery.
 */
function gallery_shortcode($attr)
{
    $post = get_post();
    static $instance = 0;
    $instance++;
    if (!empty($attr['ids'])) {
        // 'ids' is explicitly ordered, unless you specify otherwise.
        if (empty($attr['orderby'])) {
            $attr['orderby'] = 'post__in';
        }
        $attr['include'] = $attr['ids'];
    }
    /**
     * Filter the default gallery shortcode output.
     *
     * If the filtered output isn't empty, it will be used instead of generating
     * the default gallery template.
     *
     * @since 2.5.0
     * @since 4.2.0 The `$instance` parameter was added.
     *
     * @see gallery_shortcode()
     *
     * @param string $output   The gallery output. Default empty.
     * @param array  $attr     Attributes of the gallery shortcode.
     * @param int    $instance Unique numeric ID of this gallery shortcode instance.
     */
    $output = apply_filters('post_gallery', '', $attr, $instance);
    if ($output != '') {
        return $output;
    }
    $html5 = current_theme_supports('html5', 'gallery');
    $atts = shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post ? $post->ID : 0, 'itemtag' => $html5 ? 'figure' : 'dl', 'icontag' => $html5 ? 'div' : 'dt', 'captiontag' => $html5 ? 'figcaption' : 'dd', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => '', 'link' => ''), $attr, 'gallery');
    $id = intval($atts['id']);
    if (!empty($atts['include'])) {
        $_attachments = get_posts(array('include' => $atts['include'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby']));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    } elseif (!empty($atts['exclude'])) {
        $attachments = get_children(array('post_parent' => $id, 'exclude' => $atts['exclude'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby']));
    } else {
        $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby']));
    }
    if (empty($attachments)) {
        return '';
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $att_id => $attachment) {
            $output .= wp_get_attachment_link($att_id, $atts['size'], true) . "\n";
        }
        return $output;
    }
    $itemtag = tag_escape($atts['itemtag']);
    $captiontag = tag_escape($atts['captiontag']);
    $icontag = tag_escape($atts['icontag']);
    $valid_tags = wp_kses_allowed_html('post');
    if (!isset($valid_tags[$itemtag])) {
        $itemtag = 'dl';
    }
    if (!isset($valid_tags[$captiontag])) {
        $captiontag = 'dd';
    }
    if (!isset($valid_tags[$icontag])) {
        $icontag = 'dt';
    }
    $columns = intval($atts['columns']);
    $itemwidth = $columns > 0 ? floor(100 / $columns) : 100;
    $float = is_rtl() ? 'right' : 'left';
    $selector = "gallery-{$instance}";
    $gallery_style = '';
    /**
     * Filter whether to print default gallery styles.
     *
     * @since 3.1.0
     *
     * @param bool $print Whether to print default gallery styles.
     *                    Defaults to false if the theme supports HTML5 galleries.
     *                    Otherwise, defaults to true.
     */
    if (apply_filters('use_default_gallery_style', !$html5)) {
        $gallery_style = "\n\t\t<style type='text/css'>\n\t\t\t#{$selector} {\n\t\t\t\tmargin: auto;\n\t\t\t}\n\t\t\t#{$selector} .gallery-item {\n\t\t\t\tfloat: {$float};\n\t\t\t\tmargin-top: 10px;\n\t\t\t\ttext-align: center;\n\t\t\t\twidth: {$itemwidth}%;\n\t\t\t}\n\t\t\t#{$selector} img {\n\t\t\t\tborder: 2px solid #cfcfcf;\n\t\t\t}\n\t\t\t#{$selector} .gallery-caption {\n\t\t\t\tmargin-left: 0;\n\t\t\t}\n\t\t\t/* see gallery_shortcode() in wp-includes/media.php */\n\t\t</style>\n\t\t";
    }
    $size_class = sanitize_html_class($atts['size']);
    $gallery_div = "<div id='{$selector}' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
    /**
     * Filter the default gallery shortcode CSS styles.
     *
     * @since 2.5.0
     *
     * @param string $gallery_style Default CSS styles and opening HTML div container
     *                              for the gallery shortcode output.
     */
    $output = apply_filters('gallery_style', $gallery_style . $gallery_div);
    $i = 0;
    foreach ($attachments as $id => $attachment) {
        $attr = trim($attachment->post_excerpt) ? array('aria-describedby' => "{$selector}-{$id}") : '';
        if (!empty($atts['link']) && 'file' === $atts['link']) {
            $image_output = wp_get_attachment_link($id, $atts['size'], false, false, false, $attr);
        } elseif (!empty($atts['link']) && 'none' === $atts['link']) {
            $image_output = wp_get_attachment_image($id, $atts['size'], false, $attr);
        } else {
            $image_output = wp_get_attachment_link($id, $atts['size'], true, false, false, $attr);
        }
        $image_meta = wp_get_attachment_metadata($id);
        $orientation = '';
        if (isset($image_meta['height'], $image_meta['width'])) {
            $orientation = $image_meta['height'] > $image_meta['width'] ? 'portrait' : 'landscape';
        }
        $output .= "<{$itemtag} class='gallery-item'>";
        $output .= "\n\t\t\t<{$icontag} class='gallery-icon {$orientation}'>\n\t\t\t\t{$image_output}\n\t\t\t</{$icontag}>";
        if ($captiontag && trim($attachment->post_excerpt)) {
            $output .= "\n\t\t\t\t<{$captiontag} class='wp-caption-text gallery-caption' id='{$selector}-{$id}'>\n\t\t\t\t" . wptexturize($attachment->post_excerpt) . "\n\t\t\t\t</{$captiontag}>";
        }
        $output .= "</{$itemtag}>";
        if (!$html5 && $columns > 0 && ++$i % $columns == 0) {
            $output .= '<br style="clear: both" />';
        }
    }
    if (!$html5 && $columns > 0 && $i % $columns !== 0) {
        $output .= "\n\t\t\t<br style='clear: both' />";
    }
    $output .= "\n\t\t</div>\n";
    return $output;
}
Beispiel #29
0
function sandbox_gallery($attr)
{
    global $post;
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('orderby' => 'menu_order ASC, ID ASC', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail'), $attr));
    $id = intval($id);
    $orderby = addslashes($orderby);
    $attachments = get_children("post_parent={$id}&post_type=attachment&post_mime_type=image&orderby={$orderby}");
    if (empty($attachments)) {
        return null;
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $id => $attachment) {
            $output .= wp_get_attachment_link($id, $size, true) . "\n";
        }
        return $output;
    }
    $listtag = tag_escape($listtag);
    $itemtag = tag_escape($itemtag);
    $captiontag = tag_escape($captiontag);
    $columns = intval($columns);
    $itemwidth = $columns > 0 ? floor(100 / $columns) : 100;
    $output = apply_filters('gallery_style', "\n" . '<div class="gallery">', 9);
    // Available filter: gallery_style
    foreach ($attachments as $id => $attachment) {
        $img_lnk = get_attachment_link($id);
        $img_src = wp_get_attachment_image_src($id, $size);
        $img_src = $img_src[0];
        $img_alt = $attachment->post_excerpt;
        if ($img_alt == null) {
            $img_alt = $attachment->post_title;
        }
        $img_rel = apply_filters('gallery_img_rel', 'attachment');
        // Available filter: gallery_img_rel
        $img_class = apply_filters('gallery_img_class', 'gallery-image');
        // Available filter: gallery_img_class
        $output .= "\n\t" . '<' . $itemtag . ' class="gallery-item gallery-columns-' . $columns . '">';
        $output .= "\n\t\t" . '<' . $icontag . ' class="gallery-icon"><a href="' . $img_lnk . '" title="' . $img_alt . '" rel="' . $img_rel . '"><img src="' . $img_src . '" alt="' . $img_alt . '" class="' . $img_class . ' attachment-' . $size . '" /></a></' . $icontag . '>';
        if ($captiontag && trim($attachment->post_excerpt)) {
            $output .= "\n\t\t" . '<' . $captiontag . ' class="gallery-caption">' . $attachment->post_excerpt . '</' . $captiontag . '>';
        }
        $output .= "\n\t" . '</' . $itemtag . '>';
        if ($columns > 0 && ++$i % $columns == 0) {
            $output .= "\n</div>\n" . '<div class="gallery">';
        }
    }
    $output .= "\n</div>\n";
    return $output;
}
                                <<?php 
        echo tag_escape($title_tag);
        ?>
><?php 
        if (function_exists('is_woocommerce') && is_woocommerce()) {
            echo get_post(woocommerce_get_page_id('shop'))->post_title;
            if (is_tax('product_cat') || is_tax('product_tag')) {
                $term = get_queried_object();
                echo is_object($term) && isset($term->name) ? ' &rsaquo; ' . esc_html($term->name) : '';
            }
        } else {
            echo trim($ts_page_title) ? esc_attr($ts_page_title) : get_the_title();
        }
        ?>
</<?php 
        echo tag_escape($title_tag);
        ?>
>
                                <?php 
        echo trim($ts_caption) ? '<p class="title-bar-caption">' . wp_kses_post($ts_caption) . '</p>' : '';
    }
    ?>
                            </div>
                            <div class="span4 breadcrumbs-wrap">
                                <?php 
    $has_yoast_breadcrumbs = false;
    if (function_exists('yoast_breadcrumb')) {
        $yoast_breadcrumbs = yoast_breadcrumb('<div class="breadcrumbs small" data-breadcrumbs-by="yoast">', '</div>', false);
        $has_yoast_breadcrumbs = trim($yoast_breadcrumbs) ? true : false;
    }
    if (!$has_yoast_breadcrumbs) {