示例#1
0
 /**
  * Portfolio shortcode callback
  *
  * @param  array  $atts    shortcode attributes
  * @param  string $content shortcode content
  * @param  string $code    shortcode name
  * @return string          output html
  */
 public static function shortcode($atts, $content = null, $code = 'portfolio')
 {
     global $post;
     extract(shortcode_atts(array('column' => 4, 'cat' => '', 'ids' => '', 'max' => 4, 'height' => 400, 'title' => 'overlay', 'desc' => 'false', 'more' => 'button text', 'nopaging' => 'false', 'group' => 'true', 'layout' => 'static', 'post__not_in' => '', 'engine' => 'isotope', 'class' => '', 'fancy_page' => false), $atts));
     $moreText = $more;
     $more = !empty($moreText);
     $cat = empty($cat) ? array() : (is_array($cat) ? $cat : explode(',', $cat));
     $desc = wpv_sanitize_bool($desc);
     // number of columns - get the css class
     $column = intval($column);
     // get the overall portfolio width
     $central_width = wpv_get_central_column_width();
     $column_width = intval($central_width / $column);
     $size = array($central_width, $height);
     // set the width of a column (without blank space)
     if ($column > 1) {
         $size[0] = round($central_width * (1 - 0.02 * ($column - 1)) / $column);
     }
     $sortable = $layout === 'fit-rows' || $layout === 'masonry' ? $layout : '';
     $paging_preference = !empty($sortable) ? 'paged' : null;
     $scrollable = $layout === 'scrollable';
     if ($scrollable) {
         $nopaging = 'true';
     }
     $rel_group = 'portfolio_' . rand(1, 1000);
     //for lightbox group
     $old_column = isset($GLOBALS['wpv_portfolio_column']) ? $GLOBALS['wpv_portfolio_column'] : null;
     $GLOBALS['wpv_portfolio_column'] = $column;
     $query = array('post_type' => 'portfolio', 'orderby' => array('menu_order' => 'ASC', 'date' => 'DESC'), 'posts_per_page' => $max, 'paged' => $nopaging === 'false' ? get_query_var('paged') > 1 ? get_query_var('paged') : (get_query_var('page') ? get_query_var('page') : 1) : 1);
     if (!empty($cat) && !empty($cat[0])) {
         $query['tax_query'] = array(array('taxonomy' => 'portfolio_category', 'field' => 'slug', 'terms' => $cat));
     }
     if ($ids && $ids != 'null') {
         $query['post__in'] = explode(',', $ids);
     }
     if (!empty($post__not_in)) {
         $query['post__not_in'] = explode(',', $post__not_in);
     }
     query_posts($query);
     ob_start();
     include locate_template('templates/portfolio/loop.php');
     $GLOBALS['wpv_portfolio_column'] = $old_column;
     wp_reset_query();
     return ob_get_clean();
 }
示例#2
0
 function wpv_str_to_width($frac = 'full')
 {
     $width = wpv_get_central_column_width();
     if ($frac != 'full') {
         $frac = explode('_', $frac);
         $map = array('one' => 1, 'two' => 2, 'half' => 2, 'three' => 3, 'third' => 3, 'thirds' => 3, 'four' => 4, 'fourth' => 4, 'fourths' => 4, 'five' => 5, 'fifth' => 5, 'fifths' => 5, 'six' => 6, 'sixth' => 6, 'sixths' => 6);
         $frac[0] = $map[$frac[0]];
         $frac[1] = $map[$frac[1]];
         $width = ($width - ($frac[1] - 1) * 20) / $frac[1] * $frac[0] + ($frac[0] - 1) * 20;
     }
     return $width;
 }
        list($terms_slug, $terms_name) = wpv_get_portfolio_terms();
        ?>
			<article id="post-<?php 
        the_ID();
        ?>
" <?php 
        post_class(WpvTemplates::get_layout() . ' ' . $type);
        ?>
>
				<div class="page-content">
					<?php 
        global $wpv_has_header_sidebars;
        if ($wpv_has_header_sidebars) {
            WpvTemplates::header_sidebars();
        }
        $column_width = wpv_get_central_column_width();
        $size = $column_width;
        ?>

					<div class="clearfix">
					<?php 
        if ($type != 'document') {
            ?>
						<div class="portfolio_image_wrapper fullwidth-folio">
							<?php 
            if ($type == 'gallery') {
                list($gallery, ) = WpvPostFormats::get_first_gallery(get_the_content(), null, 'single-portfolio');
                echo do_shortcode($gallery);
            } elseif ($type == 'video') {
                global $wp_embed;
                echo do_shortcode($wp_embed->run_shortcode('[embed width="' . $size . '"]' . $href . '[/embed]'));