/** * Get post thumbnail src based on post formats * * @param $size * * @return string */ function constructent_post_thumbnail_src($size) { $src = ''; switch (get_post_format()) { case 'gallery': $images = constructent_meta('images', "type=image&size={$size}"); if (empty($images)) { break; } $image = current($images); $src = $image['url']; break; default: $src = constructent_get_image(array('size' => $size, 'format' => 'src', 'meta_key' => 'image', 'echo' => false)); break; } return $src; }
/** * Display social sharing box * * @since 1.0 * @return void */ function constructent_social_share() { ?> <ul class="box-social-share"> <?php $size = 'constructent-big-post-thumbs'; $image = constructent_get_image(array('size' => $size, 'format' => 'src', 'meta_key' => 'image', 'echo' => false)); // Call class $socials = new Constructent_Share_Buttons(); $share = sprintf('<li>%s</li>', $socials->facebook(get_permalink())); $share .= sprintf('<li>%s</li>', $socials->twitter(get_permalink(), get_the_title())); $share .= sprintf('<li>%s</li>', $socials->google(get_permalink())); $share .= sprintf('<li>%s</li>', $socials->pinterest(get_permalink(), get_the_title(), $image)); $share .= sprintf('<li>%s</li>', $socials->linkedin(get_permalink(), get_the_title())); echo $share; ?> </ul> <?php }
/** * Display widget * * @param array $args Sidebar configuration * @param array $instance Widget settings * * @return void */ function widget($args, $instance) { $instance = wp_parse_args($instance, $this->defaults); extract($args); $query = array('posts_per_page' => intval($instance['limit']), 'post_status' => 'publish', 'post_type' => 'portfolio', 'ignore_sticky_posts' => true); if ('completed' == $instance['type']) { $query['meta_query'] = array(array('key' => 'completion', 'value' => 100, 'compare' => '=')); } elseif ('under_construction' == $instance['type']) { $query['meta_query'] = array(array('key' => 'completion', 'value' => 100, 'compare' => '>')); } $projects = new WP_Query($query); echo $before_widget; if ($title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base)) { echo $before_title . $title . $after_title; } if ($projects->have_posts()) { echo '<div class="projects clearfix">'; while ($projects->have_posts()) { $projects->the_post(); ?> <div class="project"> <a href="<?php the_permalink(); ?> "> <?php constructent_get_image('size=constructent-widget-thumb'); ?> </a> </div> <?php } echo '</div>'; } wp_reset_postdata(); echo $after_widget; }
<?php if (have_posts()) { ?> <div class="fitsc-portfolio portfolio-big-gutter columns-4"> <div class="projects"> <?php while (have_posts()) { the_post(); ?> <figure class="project"> <div class="figure-image"><?php constructent_get_image('size=constructent-portfolio-thumbnail'); ?> </div> <figcaption> <h3><?php the_title(); ?> </h3> <a href="<?php the_permalink(); ?> " class="view-project"><?php esc_html_e('View Project', 'constructent'); ?> </a> </figcaption> </figure>
/** * Show team shortcode * * @param array $atts * @param string $content * * @return string */ function team($atts, $content) { $atts = shortcode_atts(array('number' => 10, 'columns' => 4, 'orderby' => 'date', 'order' => 'DESC'), $atts, 'team'); $args = array('post_type' => 'team_member', 'posts_per_page' => absint($atts['number']), 'orderby' => $atts['orderby'], 'order' => $atts['order']); $members = new WP_Query($args); if (!$members->have_posts()) { return ''; } $socials = array('facebook', 'twitter', 'google', 'linkedin', 'tumblr'); $list = array(); while ($members->have_posts()) { $members->the_post(); $links = array(); foreach ($socials as $social) { $url = constructent_meta($social); if ($url) { $links[] = sprintf('<li><a href="%s" rel="nofollow" target="_blank"><i class="fa fa-%s"></i></a></li>', esc_url($url), $social == 'google' ? 'google-plus' : $social); } } $list[] = sprintf('<div class="team-member clearfix"> %s <div class="member-bio"> %s </div> <div class="member-info"> <h5 class="name">%s</h5> <span class="position">%s</span> </div> %s </div>', constructent_get_image('size=constructent-member-thumbnail&echo=0'), constructent_content_limit(12, false, false), get_the_title(), constructent_meta('job'), $links ? '<ul class="social-icons">' . implode("\n", $links) . '</ul>' : ''); } wp_reset_postdata(); return sprintf('<div class="fitsc-team"><div class="team-members" data-items="%d">%s</div></div>', absint($atts['columns']), implode("\n", $list)); }
/** * Show entry format images, video, gallery, audio, etc. * @return void */ function constructent_post_formats() { $html = ''; $size = apply_filters('constructent_post_format_thumbnail_size', 'constructent-big-post-thumbs'); switch (get_post_format()) { case 'image': $image = constructent_get_image(array('size' => $size, 'format' => 'src', 'meta_key' => 'image', 'echo' => false)); if (!$image) { break; } $html = sprintf('<a class="post-image" href="%1$s" title="%2$s"><img src="%3$s" alt="%2$s"></a>', get_permalink(), the_title_attribute('echo=0'), $image); break; case 'gallery': $images = constructent_meta('images', "type=image&size={$size}"); if (empty($images)) { break; } $current = 0; $carousel = array('id' => 'entry-gallery-' . get_the_ID(), 'indicators' => array(), 'items' => array()); foreach ($images as $image) { $carousel['indicators'][] = sprintf('<li data-target="#%s" data-slide-to="%s" class="%s"></li>', $carousel['id'], $current, 0 == $current ? 'active' : ''); $carousel['items'][] = sprintf('<div class="item %s"><img src="%s" alt="gallery"></div>', 0 == $current ? 'active' : '', $image['url']); $current++; } $html .= '<div id="' . $carousel['id'] . '" class="carousel slide" data-ride="carousel">'; $html .= '<ol class="carousel-indicators">' . implode("\n", $carousel['indicators']) . '</ol>'; $html .= '<div class="carousel-inner">' . implode("\n", $carousel['items']) . '</div>'; $html .= '</div>'; break; case 'audio': $audio = constructent_meta('audio'); if (!$audio) { break; } // If URL: show oEmbed HTML or jPlayer if (filter_var($audio, FILTER_VALIDATE_URL)) { // Try oEmbed first if ($oembed = @wp_oembed_get($audio)) { $html .= $oembed; } else { $html .= '<div class="audio-player">' . wp_audio_shortcode(array('src' => $audio)) . '</div>'; $attachment_id = constructent_get_attachment_id_from_url($audio); if (!empty($attachment_id)) { $html .= constructent_media_metadata($attachment_id, 'audio'); } } } else { $html .= $audio; } break; case 'video': $video = constructent_meta('video'); if (!$video) { break; } // If URL: show oEmbed HTML if (filter_var($video, FILTER_VALIDATE_URL)) { if ($oembed = @wp_oembed_get($video)) { $html .= $oembed; } else { $atts = array('src' => $video, 'width' => 848); if (has_post_thumbnail()) { $atts['poster'] = constructent_get_image('format=src&echo=0&size=full'); } $html .= wp_video_shortcode($atts); $attachment_id = constructent_get_attachment_id_from_url($video); if (!empty($attachment_id)) { $html .= constructent_media_metadata($attachment_id, 'video'); } } } else { $html .= $video; } break; case 'quote': $quote = constructent_meta('quote'); $author = constructent_meta('author'); $author_url = constructent_meta('author_url'); if ($author_url) { $author = "<a href='{$author_url}'>{$author}</a>"; } if ($quote && $author) { $html .= "<blockquote>{$quote}<cite>- {$author}</cite></blockquote>"; } break; case 'link': $url = constructent_meta('url'); $text = constructent_meta('text'); if ($url && $text) { $html .= "<p><a class='link' title='{$text}' href='{$url}'>{$text}</a></p>"; } break; default: $thumb = get_the_post_thumbnail(get_the_ID(), $size); if (empty($thumb)) { return; } $html .= '<a class="post-image" href="' . get_permalink() . '">'; $html .= $thumb; $html .= '</a>'; } if ($html) { echo "<div class='entry-format'>{$html}</div>"; } }