function block_pricing_output($params) { extract($params); // MAKE SURE ARRAY IS TIGHT $tables = array_values($tables); // BLOCK CLASSES $block_classes = "outter-wrapper"; if (!empty($custom_classes)) { $block_classes .= " " . $custom_classes; } ?> <!-- BLOCK: LATEST POSTS--> <!-- start outter-wrapper --> <div <?php pb_block_id_class($block_classes, $params); ?> > <!-- block styles --> <style type="text/css" scoped> <?php include 'includes/inc_block_output_style.php'; ?> </style> <!-- start main-container --> <div class="main-container"> <!-- start main wrapper --> <div class="main wrapper clearfix"> <!-- start main-content --> <div class="main-content"> <?php if (!empty($title)) { printf('<h1>%s</h1>', esc_attr($title)); } ?> <?php if (!empty($text)) { printf('<p class="lead">%s</p>', do_shortcode($text)); } ?> <hr/> <!-- Start Post --> <div class="clearfix"> <?php $base_class = "price"; $size_class = " " . mb_get_size_class_from_num(count($tables), 'third'); for ($i = 0; $i < count($tables); $i++) { $feature_class = $tables[$i]['feature'] == "checked" ? " price-feature" : ""; $last_class = $i === count($tables) - 1 ? " last" : ""; $final_class = $base_class . $size_class . $feature_class . $last_class; ?> <div class="<?php echo $final_class; ?> "> <h3> <span><?php echo $tables[$i]['price']; ?> <span><?php echo $tables[$i]['interval']; ?> </span> </span> <?php echo $tables[$i]['table_title']; ?> </h3> <div class="price-detail"> <?php echo do_shortcode($tables[$i]['content']); ?> <?php if (!empty($tables[$i]['btn_text'])) { printf('<a class="btn" href="%s">%s</a>', esc_url($tables[$i]['btn_link']), esc_attr($tables[$i]['btn_text'])); } ?> </div> </div> <?php } ?> </div> </div> <!-- end main-content --> </div> <!-- end main wrapper --> </div> <!-- end main-container --> </div> <!-- end outter-wrapper --> <!-- END BLOCK --> <?php return true; }
<?php //SETTTINGS $cmb_gallery_style = get_post_meta($post->ID, 'cmb_gallery_style', true); $cmb_gallery_num_columns = get_post_meta($post->ID, 'cmb_gallery_num_columns', true); $cmb_gallery_source = get_post_meta($post->ID, 'cmb_gallery_source', true); // DEFAULTS if (empty($cmb_gallery_style)) { $cmb_gallery_style = "isotope"; } // HANDLE WP GALLERY SOURCE $consolidated_gallery_array = array(); $cmb_gallery_source = get_post_meta($post->ID, 'cmb_gallery_source', true); $gallery_array = mb_strip_wp_galleries_to_array($cmb_gallery_source); $consolidated_gallery_array = mb_convert_wp_galleries_array_to_consolidated_wp_gallery_array($gallery_array); // GET CLASSES $size_class = mb_get_size_class_from_num($cmb_gallery_num_columns, "third"); // var_dump($size_class); ?> <!-- Start Outter Wrapper --> <div class="outter-wrapper feature"> <hr/> </div> <!-- End Outter Wrapper --> <!-- start outter-wrapper --> <div class="outter-wrapper"> <!-- start main-container --> <div class="main-container"> <!-- start main wrapper -->
function block_featured_icons_output($params) { extract($params); $block_classes = "outter-wrapper"; if (!empty($custom_classes)) { $block_classes .= " " . $custom_classes; } $size_class = mb_get_size_class_from_num(count($column), "fourth"); ?> <!-- BLOCK: LATEST POSTS--> <!-- start outter-wrapper --> <div <?php pb_block_id_class($block_classes, $params); ?> <?php if ($bg_boxed != 'checked') { printf("data-stellar-background-ratio='{$parallax_ratio}'"); } ?> > <!-- block styles --> <style type="text/css" scoped> #<?php echo pb_get_block_id($params); ?> .iconBlock em { <?php if (!empty($icon_color)) { echo "color: {$icon_color};"; } ?> <?php if (!empty($icon_size)) { echo "font-size: " . $icon_size . "px;"; } ?> } <?php include 'includes/inc_block_output_style.php'; ?> </style> <!-- start main-container --> <div class="main-container"> <!-- start main wrapper --> <div class="main wrapper clearfix" <?php if ($bg_boxed == 'checked') { printf("data-stellar-background-ratio='{$parallax_ratio}'"); } ?> > <!-- start main-content --> <div class="main-content"> <!-- Start Post --> <div class="clearfix iconBlock centered"> <?php if (!empty($title)) { printf('<h2>%s</h2>', esc_attr($title)); } ?> <?php for ($i = 0; $i < count($column); $i++) { if ($i == count($column) - 1) { $size_class .= " last"; } ?> <div class="<?php echo $size_class; ?> "> <em class="fa <?php echo $column[$i]['icon']; ?> "></em> <h3><?php echo $column[$i]['title']; ?> </h3> <p><?php echo do_shortcode($column[$i]['text']); ?> </p> </div> <?php } ?> </div> </div> <!-- end main-content --> </div> <!-- end main wrapper --> </div> <!-- end main-container --> </div> <!-- end outter-wrapper --> <!-- END BLOCK --> <?php return true; }
<?php get_header(); ?> <?php // SETTTINGS $cmb_portfolio_click = get_post_meta($post->ID, 'cmb_portfolio_click', true); $cmb_portfolio_cat = get_post_meta($post->ID, 'cmb_portfolio_cat', true); $cmb_portfolio_num_columns = get_post_meta($post->ID, 'cmb_portfolio_num_columns', true); // DEFAULTS if (empty($cmb_portfolio_num_columns)) { $cmb_portfolio_num_columns = 3; } // GET CLASSES $size_class = mb_get_size_class_from_num($cmb_portfolio_num_columns, "third"); $post_counter = 1; // BUILD INCLUDE ARRAY FOR QUERY $include_array = array(); if (!empty($cmb_portfolio_cat)) { foreach ($cmb_portfolio_cat as $key => $value) { array_push($include_array, get_term_by('slug', $key, 'project_category')->term_id); } } // BUILD INCLUDE STRING FOR FILTER MENU $include_string = " "; //notice the extra space - to prevent include string from being empty which would display all categories. if (!empty($cmb_portfolio_cat)) { foreach ($cmb_portfolio_cat as $key => $value) { $include_string .= get_term_by('slug', $key, 'project_category')->term_id . ","; }
function block_gallery_output($params) { extract($params); $block_classes = "outter-wrapper"; if (!empty($custom_classes)) { $block_classes .= " " . $custom_classes; } // HANDLE WP GALLERY SOURCE $consolidated_gallery_array = array(); $gallery_array = mb_strip_wp_galleries_to_array($source); $consolidated_gallery_array = mb_convert_wp_galleries_array_to_consolidated_wp_gallery_array($gallery_array); $size_class = mb_get_size_class_from_num($num_columns, "third"); // var_dump($size_class); ?> <!-- BLOCK: LATEST POSTS--> <!-- start outter-wrapper --> <div <?php pb_block_id_class($block_classes, $params); ?> <?php if ($bg_boxed != 'checked') { printf("data-stellar-background-ratio='{$parallax_ratio}'"); } ?> > <!-- block styles --> <style type="text/css" scoped> <?php include 'includes/inc_block_output_style.php'; ?> </style> <!-- start main-container --> <div class="main-container"> <!-- start main wrapper --> <div class="main wrapper clearfix" <?php if ($bg_boxed == 'checked') { printf("data-stellar-background-ratio='{$parallax_ratio}'"); } ?> > <!-- start main-content --> <div class="main-content"> <!-- Start Gallery --> <div class="clearfix"> <!-- Start Meta --> <aside class="clearfix"> <div class="text-seperator gal-sep"> <h5><?php echo $params['title']; ?> </h5> <ul class="meta option-set isotope_filter_menu right clearfix"> <?php if ($hide_filter_menu != "checked") { mb_list_categories_of_consolidated_wp_gallery($consolidated_gallery_array); } ?> </ul> </div> </aside> <!-- Start Isotope --> <div class="last thumb-gallery super-list variable-sizes pb_isotope_gallery" data-num_columns="<?php echo $num_columns; ?> "> <?php for ($i = 0; $i < count($consolidated_gallery_array); $i++) { $last_class = ($i + 1) % $num_columns ? "" : " last"; $cat_class = ""; foreach ($consolidated_gallery_array[$i]['categories'] as $key => $value) { $cat_class .= " " . $key; } $final_class = $size_class . $cat_class . $last_class; $post_thumbnail_src = wp_get_attachment_image_src($consolidated_gallery_array[$i]['id'], 'full'); $post_thumbnail_src_fit = wp_get_attachment_image_src($consolidated_gallery_array[$i]['id'], 'gallery_isotope_x2'); $img_alt = get_post_meta($consolidated_gallery_array[$i]['id'], '_wp_attachment_image_alt', true); $img_post = get_post($consolidated_gallery_array[$i]['id']); printf('<div class="gallery_item mosaic-block fade element %s">', esc_attr($final_class)); printf('<a href="%s" class="mosaic-overlay fancybox" title="%s"></a>', esc_url($post_thumbnail_src[0]), esc_attr($img_post->post_excerpt)); printf('<div class="mosaic-backdrop"><img src="%s" alt="%s" /></div>', esc_url($post_thumbnail_src_fit[0]), esc_attr($img_alt)); echo '</div>'; } ?> </div> <!-- end isotope --> </div> <!-- end gallery --> </div> <!-- end main-content --> </div> <!-- end main wrapper --> </div> <!-- end main-container --> </div> <!-- end outter-wrapper --> <!-- END BLOCK --> <?php return true; }
function block_people_output($params) { extract($params); // VARS $default_excerpt_length = 80; // SET CLASSES $base_class = "boxed"; $size_class = " " . mb_get_size_class_from_num($num_columns, "fourth"); // GET PEOPLE $query_args = array(); $query_args = array('post_type' => 'cpt_people', 'posts_per_page' => -1, 'post_status' => 'publish', 'tax_query' => array(array('taxonomy' => 'people_category', 'field' => 'slug', 'terms' => $show)), 'suppress_filters' => false); // DETERMINE ORDER if ($orderby == "alphabetical_asc") { $query_args = array_merge($query_args, array('orderby' => 'title', 'order' => 'ASC')); } elseif ($orderby == "alphabetical_desc") { $query_args = array_merge($query_args, array('orderby' => 'title', 'order' => 'DESC')); } elseif ($orderby == "date_asc") { $query_args = array_merge($query_args, array('orderby' => 'date', 'order' => 'ASC')); } elseif ($orderby == "date_desc") { $query_args = array_merge($query_args, array('orderby' => 'date', 'order' => 'DESC')); } elseif ($orderby == "index_asc") { $query_args = array_merge($query_args, array('meta_key' => 'cmb_index', 'orderby' => 'meta_value_num', 'order' => 'ASC')); } elseif ($orderby == "index_desc") { $query_args = array_merge($query_args, array('meta_key' => 'cmb_index', 'orderby' => 'meta_value_num', 'order' => 'DESC')); } else { $query_args = array_merge($query_args, array('orderby' => 'rand')); } // FINAL QUERY $results_people = get_posts($query_args); // UPDATE NUM PEOPLE if (count($results_people) < $num_people) { $num_people = count($results_people); } // BLOCK CLASSES $block_classes = "outter-wrapper"; if (!empty($custom_classes)) { $block_classes .= " " . $custom_classes; } ?> <!-- BLOCK: PEOPLE--> <!-- start outter-wrapper --> <div <?php pb_block_id_class($block_classes, $params); ?> > <!-- block styles --> <style type="text/css" scoped> <?php include 'includes/inc_block_output_style.php'; ?> </style> <!-- start main-container --> <div class="main-container"> <!-- start main wrapper --> <div class="main wrapper clearfix"> <!-- start main-content --> <div class="main-content"> <?php if (!empty($title)) { printf('<h1>%s</h1>', esc_attr($title)); } ?> <?php if (!empty($text)) { printf('<p class="lead">%s</p>', do_shortcode($text)); } ?> <?php for ($i = 0; $i < $num_people; $i++) { $last_class = ($i + 1) % $num_columns ? "" : " last"; $final_class = $base_class . $size_class . $last_class; $this_person = $results_people[$i]; // get custom fields $cmb_title = get_post_meta($this_person->ID, 'cmb_title', true); $cmb_excerpt = get_post_meta($this_person->ID, 'cmb_excerpt', true); $cmb_excerpt_is_quote = get_post_meta($this_person->ID, 'cmb_excerpt_is_quote', true); $cmb_show_social_links = get_post_meta($this_person->ID, 'cmb_show_social_links', true); $cmb_social_links = get_post_meta($this_person->ID, 'cmb_social_links', true); // get featured image $post_thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($this_person->ID), 'full'); $img_alt = get_post_meta(get_post_thumbnail_id($this_person->ID), '_wp_attachment_image_alt', true); // var_dump($this_person); ?> <?php if ($i === 0 || $i % $num_columns === 0) { echo '<div class="clearfix">'; } ?> <div class="<?php echo $final_class; ?> personColumn"> <!-- image --> <?php if ($post_thumbnail_src) { if ($link_through == "checked") { printf('<a href="%s"><img src="%s" alt="%s" /></a>', esc_url(get_permalink($this_person->ID)), esc_url($post_thumbnail_src[0]), esc_attr($img_alt)); } else { printf('<img src="%s" alt="%s" />', esc_url($post_thumbnail_src[0]), esc_attr($img_alt)); } } ?> <div class="inner-box"> <div class="person_info<?php if ($even_height == "checked") { echo " even-height"; } ?> " data-even_height_group="inner-box-<?php echo $block_index; ?> "> <!-- name --> <?php if ($link_through == "checked") { printf('<h4><a href="%s">%s</a></h4>', esc_url(get_permalink($this_person->ID)), esc_attr($this_person->post_title)); } else { printf('<h4>%s</h4>', esc_attr($this_person->post_title)); } ?> <h5><?php echo $cmb_title; ?> </h5> <em class="<?php if ($cmb_excerpt_is_quote == 'checked') { echo "quote"; } ?> "><?php if (empty($cmb_excerpt)) { echo mb_make_excerpt($this_person->post_content, $default_excerpt_length, true); } else { echo do_shortcode($cmb_excerpt); } ?> </em> </div> <?php if ($cmb_show_social_links == "checked") { echo '<ul class="social-link">'; for ($n = 0; $n < count($cmb_social_links); $n++) { ?> <li><a href="<?php echo $cmb_social_links[$n]['link']; ?> " target="_blank"><em class="fa <?php echo $cmb_social_links[$n]['icon']; ?> "></em></a></li> <?php } echo '</ul>'; } ?> </div> </div> <?php if (($i + 1) % $num_columns === 0 || $i + 1 === $num_people) { echo '</div>'; } ?> <?php } ?> </div> <!-- end main-content --> </div> <!-- end main wrapper --> </div> <!-- end main-container --> </div> <!-- end outter-wrapper --> <!-- END BLOCK --> <?php return true; }
function block_featured_posts_output($params) { extract($params); $block_classes = "outter-wrapper"; if (!empty($custom_classes)) { $block_classes .= " " . $custom_classes; } // VARS $default_excerpt_length = 165; //build exclude string $exclude_string = ""; $results_exclude_posts = get_posts(array('numberposts' => -1, 'meta_key' => 'cmb_hide_from_popular', 'meta_value' => 'checked', 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'any')); if (count($results_exclude_posts) > 0) { $exclude_string = ""; for ($i = 0; $i < count($results_exclude_posts); $i++) { $exclude_string .= $results_exclude_posts[$i]->ID . ","; } $exclude_string = substr($exclude_string, 0, strlen($exclude_string) - 1); } //basic args $query_args = array(); $query_args = array_merge($query_args, array('post_type' => 'post', 'numberposts' => $num_posts, 'post_status' => 'publish', 'offset' => 0, 'suppress_filters' => false)); if ($show == "latest_posts") { $query_args = array_merge($query_args, array('category' => '', 'orderby' => 'post_date', 'order' => 'DESC')); } elseif ($show == "random_posts") { $query_args = array_merge($query_args, array('category' => '', 'orderby' => 'rand')); } elseif ($show == "popular_views") { $query_args = array_merge($query_args, array('category' => '', 'meta_key' => 'post_views', 'orderby' => 'meta_value_num', 'order' => 'DESC', 'exclude' => $exclude_string)); } elseif ($show == "popular_comments") { $query_args = array_merge($query_args, array('category' => '', 'orderby' => 'comment_count', 'order' => 'DESC', 'exclude' => $exclude_string)); } elseif (strpos($show, "postcat_") !== false) { $show = str_replace("postcat_", "", $show); $query_args = array_merge($query_args, array('category_name' => $show, 'orderby' => 'post_date', 'order' => 'DESC')); } //final query $results_query = get_posts($query_args); // var_dump($query_args); // var_dump($results_query); //if less posts in query set num_posts to num query posts if (count($results_query) < $num_posts) { $num_posts = count($results_query); } ?> <!-- BLOCK: FEATURED POSTS--> <!-- start outter-wrapper --> <div <?php pb_block_id_class($block_classes, $params); ?> <?php if ($bg_boxed != 'checked') { printf("data-stellar-background-ratio='{$parallax_ratio}'"); } ?> > <!-- block styles --> <style type="text/css" scoped> <?php include 'includes/inc_block_output_style.php'; ?> </style> <!-- start main-container --> <div class="main-container"> <!-- start main wrapper --> <div class="main wrapper clearfix" <?php if ($bg_boxed == 'checked') { printf("data-stellar-background-ratio='{$parallax_ratio}'"); } ?> > <!-- start main-content --> <div class="main-content"> <!-- Start Post --> <div class="clearfix"> <?php if ($show_section_header == "checked") { ?> <!-- section header --> <div class="text-seperator"> <h5><?php echo $params['title']; ?> </h5> <?php if (!empty($params['button_text'])) { printf('<a class="btn right white-btn xsmall-btn" href="%s">%s</a>', esc_url($params['button_link']), esc_attr($params['button_text'])); } ?> </div> <?php } ?> <?php for ($i = 0; $i < count($results_query); $i++) { $current_post = $results_query[$i]; $cmb_excerpt = get_post_meta($current_post->ID, 'cmb_excerpt', true); $cmb_feature = get_post_meta($current_post->ID, 'cmb_feature', true); $cmb_media_link = get_post_meta($current_post->ID, 'cmb_media_link', true); $current_post_publish_date = mb_localize_datetime(get_the_time("j M", $current_post->ID)); // build classes $base_class = ""; $size_class = " " . mb_get_size_class_from_num($num_columns, "third"); $last_class = ($i + 1) % $num_columns ? "" : " last"; $final_class = $base_class . $size_class . $last_class; $last_class = " last"; if ($i === 0 || $i % $num_columns === 0) { echo '<div class="clearfix recentwork">'; } echo '<div class="' . $final_class . '">'; // featured image. For future reference this section has most in common with page-galleries.php gallery style 3 if ($show_featured_image == "checked") { if ($cmb_feature == "media" && !empty($cmb_media_link)) { echo $cmb_media_link; } elseif ($cmb_feature == "media_in_lightbox" && !empty($cmb_media_link) && get_post(get_post_thumbnail_id($current_post->ID))) { echo '<div class="mosaic-block fade">'; $post_thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($current_post->ID), 'full'); $post_thumbnail_src_fit = wp_get_attachment_image_src(get_post_thumbnail_id($current_post->ID), 'featured_posts_thumb_x2'); $img_alt = get_post_meta(get_post_thumbnail_id($current_post->ID), '_wp_attachment_image_alt', true); $img_post = get_post(get_post_thumbnail_id($current_post->ID)); if ($link_to == "post") { printf('<a href="%s" class="mosaic-overlay link fancybox" title="%s"></a>', get_permalink($current_post->ID), esc_attr($img_post->post_title)); } else { printf('<a href="%s" class="mosaic-overlay fancybox-media fancybox.iframe play" rel="gallery"></a>', esc_attr($cmb_media_link)); } if ($show_date == "checked") { printf('<div class="mosaic-backdrop"><div class="corner-date">%s</div><img src="%s" alt="%s" /></div>', esc_attr($current_post_publish_date), esc_url($post_thumbnail_src_fit[0]), esc_attr($img_alt)); } else { printf('<div class="mosaic-backdrop"><img src="%s" alt="%s" /></div>', esc_url($post_thumbnail_src_fit[0]), esc_attr($img_alt)); } echo '</div>'; } elseif (has_post_thumbnail($current_post->ID) && get_post(get_post_thumbnail_id($current_post->ID))) { echo '<div class="mosaic-block fade">'; $post_thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($current_post->ID), 'full'); $post_thumbnail_src_fit = wp_get_attachment_image_src(get_post_thumbnail_id($current_post->ID), 'featured_posts_thumb_x2'); $img_alt = get_post_meta(get_post_thumbnail_id($current_post->ID), '_wp_attachment_image_alt', true); $img_post = get_post(get_post_thumbnail_id($current_post->ID)); if ($link_to == "post") { printf('<a href="%s" class="mosaic-overlay link fancybox" title="%s"></a>', get_permalink($current_post->ID), esc_attr($img_post->post_title)); } else { printf('<a href="%s" class="mosaic-overlay fancybox" title="%s"></a>', esc_url($post_thumbnail_src[0]), esc_attr($img_post->post_title)); } if ($show_date == "checked") { printf('<div class="mosaic-backdrop"><div class="corner-date">%s</div><img src="%s" alt="%s" /></div>', esc_attr($current_post_publish_date), esc_url($post_thumbnail_src_fit[0]), esc_attr($img_alt)); } else { printf('<div class="mosaic-backdrop"><img src="%s" alt="%s" /></div>', esc_url($post_thumbnail_src_fit[0]), esc_attr($img_alt)); } echo '</div>'; } } ?> <!-- title --> <?php if ($show_title == "checked") { printf('<h3><a href="%s">%s</a></h3>', esc_url(get_permalink($current_post->ID)), esc_attr($current_post->post_title)); } ?> <!-- excerpt --> <?php if ($show_excerpt == "checked") { if (empty($cmb_excerpt)) { echo mb_make_excerpt($current_post->post_content, $default_excerpt_length, true); } else { echo do_shortcode($cmb_excerpt); } } ?> <!-- more link --> <?php if ($show_more_link == "checked") { printf('<a class="more" href="%s">%s</a>', esc_url(get_permalink($current_post->ID)), __("more", "loc_sport_core_plugin")); } ?> <?php echo "</div>"; if (($i + 1) % $num_columns === 0 || $i + 1 === $num_posts) { echo '</div>'; } } ?> </div> </div> <!-- end main-content --> </div> <!-- end main wrapper --> </div> <!-- end main-container --> </div> <!-- end outter-wrapper --> <!-- END BLOCK --> <?php return true; }
<?php //SMART WIDGETIZED FOOTER $min_num_widgets = 2; $max_num_widgets = 5; //count active widget areas $num_widgets = 0; for ($i = 1; $i < $max_num_widgets + 1; $i++) { if (is_active_sidebar("canon_footer_widget_area_" . $i)) { $num_widgets++; } } //set classes $widget_area_base_class = ""; $widget_area_size_class = mb_get_size_class_from_num($num_widgets, "fourth"); ?> <!-- Start Widget Footer --> <div class="outter-wrapper main-footer widget-footer main"> <div class="wrapper clearfix"> <?php if ($num_widgets < $min_num_widgets) { ?> <h3 class="centered"><?php _e("Footer Widget Areas", "loc_canon"); ?> </h3> <p class="centered"><i><?php
function block_gallery_preview_output($params) { extract($params); // BLOCK CLASSES $block_classes = "outter-wrapper"; if (!empty($custom_classes)) { $block_classes .= " " . $custom_classes; } // HANDLE WP GALLERY SOURCE $consolidated_gallery_array = array(); $gallery_array = mb_strip_wp_galleries_to_array($source); $consolidated_gallery_array = mb_convert_wp_galleries_array_to_consolidated_wp_gallery_array($gallery_array); $size_class = mb_get_size_class_from_num($num_columns, "third"); // var_dump($size_class); ?> <!-- BLOCK: LATEST POSTS--> <!-- start outter-wrapper --> <div <?php pb_block_id_class($block_classes, $params); ?> <?php if ($bg_boxed != 'checked') { printf("data-stellar-background-ratio='{$parallax_ratio}'"); } ?> > <!-- block styles --> <style type="text/css" scoped> <?php include 'includes/inc_block_output_style.php'; ?> </style> <!-- start main-container --> <div class="main-container"> <!-- start main wrapper --> <div class="main wrapper clearfix" <?php if ($bg_boxed == 'checked') { printf("data-stellar-background-ratio='{$parallax_ratio}'"); } ?> > <!-- start main-content --> <div class="main-content"> <!-- start gallery preview--> <div class="clearfix"> <!-- Start Meta --> <aside class="left-aside left fifth"> <ul class="meta"> <li><strong><?php echo $title; ?> </strong></li> <li><?php echo $meta_text; ?> </li> </ul> <?php if (!empty($description)) { printf('<p>%s</p>', do_shortcode($description)); } ?> <?php if (!empty($button_text)) { printf('<p><a href="%s" class="btn">%s</a></p>', esc_url($button_url), esc_attr($button_text)); } ?> </aside> <div class="four-fifths right last thumb-gallery"> <?php for ($i = 0; $i < count($consolidated_gallery_array); $i++) { $last_class = ($i + 1) % $num_columns ? "" : " last"; $cat_class = ""; foreach ($consolidated_gallery_array[$i]['categories'] as $key => $value) { $cat_class .= " " . $key; } $final_class = $size_class . $cat_class . $last_class; $post_thumbnail_src = wp_get_attachment_image_src($consolidated_gallery_array[$i]['id'], 'full'); $post_thumbnail_src_fit = wp_get_attachment_image_src($consolidated_gallery_array[$i]['id'], 'gallery_isotope_x2'); $img_alt = get_post_meta($consolidated_gallery_array[$i]['id'], '_wp_attachment_image_alt', true); $img_post = get_post($consolidated_gallery_array[$i]['id']); printf('<div class="%s"><img src="%s" alt="%s" /></div>', esc_attr($final_class), esc_url($post_thumbnail_src_fit[0]), esc_attr($img_alt)); } ?> </div> </div> <!-- end gallery preview--> </div> <!-- end main-content --> </div> <!-- end main wrapper --> </div> <!-- end main-container --> </div> <!-- end outter-wrapper --> <!-- END BLOCK --> <?php return true; }
function widget($args, $instance) { extract($args); extract($instance); // DEFAULTS if (empty($instance)) { $widget_title = __('More posts', "loc_sport_widgets_plugin"); $posts_from = 'latest_posts'; $display_style = 'images_to_posts'; $num_posts = 4; $num_columns = 4; } //build exclude string $exclude_string = ""; $results_exclude_posts = get_posts(array('numberposts' => -1, 'meta_key' => 'cmb_hide_from_popular', 'meta_value' => 'checked', 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'any')); if (count($results_exclude_posts) > 0) { $exclude_string = ""; for ($i = 0; $i < count($results_exclude_posts); $i++) { $exclude_string .= $results_exclude_posts[$i]->ID . ","; } $exclude_string = substr($exclude_string, 0, strlen($exclude_string) - 1); } //basic args $query_args = array(); $query_args = array_merge($query_args, array('post_type' => 'post', 'numberposts' => $num_posts * 10, 'post_status' => 'publish', 'offset' => 0, 'suppress_filters' => false)); if ($posts_from == "latest_posts") { $query_args = array_merge($query_args, array('category' => '', 'orderby' => 'post_date', 'order' => 'DESC')); } elseif ($posts_from == "random_posts") { $query_args = array_merge($query_args, array('category' => '', 'orderby' => 'rand')); } elseif ($posts_from == "popular_views") { $query_args = array_merge($query_args, array('category' => '', 'meta_key' => 'post_views', 'orderby' => 'meta_value_num', 'order' => 'DESC', 'exclude' => $exclude_string)); } elseif ($posts_from == "popular_comments") { $query_args = array_merge($query_args, array('category' => '', 'orderby' => 'comment_count', 'order' => 'DESC', 'exclude' => $exclude_string)); } elseif (strpos($posts_from, "postcat_") !== false) { $posts_from = str_replace("postcat_", "", $posts_from); $query_args = array_merge($query_args, array('category' => $posts_from, 'orderby' => 'post_date', 'order' => 'DESC')); } //final query $results_query = get_posts($query_args); // var_dump($query_args); // var_dump($results_query); //if less posts in query set num_posts to num query posts if (count($results_query) < $num_posts) { $num_posts = count($results_query); } // WPML if (function_exists('icl_translate')) { $widget_title = icl_translate('loc_sport_widgets_plugin', "{$widget_id}-widget[widget_title]", $widget_title); } ?> <?php echo $before_widget; ?> <?php echo $before_title . $widget_title; ?> <?php echo $after_title; ?> <div class="clearfix"> <?php if ($display_style == "images_to_posts" || $display_style == "images_to_lightbox") { $post_counter = 0; for ($i = 0; $i < count($results_query); $i++) { if ($post_counter < $num_posts) { $current_post = $results_query[$i]; //the get_post check seems necessary if you have imported posts that have thumbnail id but not actual thumbnail if (has_post_thumbnail($current_post->ID) && get_post(get_post_thumbnail_id($current_post->ID))) { //set classes $base_class = "mosaic-block fade"; $size_class = " " . mb_get_size_class_from_num($num_columns, "fourth"); $last_class = ($post_counter + 1) % $num_columns ? "" : " last"; $cat_class = ""; $item_categories = get_the_terms($current_post->ID, 'category'); if ($item_categories) { foreach ($item_categories as $value) { $cat_class .= " cat-item-" . $value->term_id; } } $final_class = $base_class . $size_class . $cat_class . $last_class; echo '<div class="' . $final_class . '">'; $post_thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($current_post->ID), 'full'); $post_thumbnail_src_fit = wp_get_attachment_image_src(get_post_thumbnail_id($current_post->ID), 'widget_more_posts_thumb'); $img_alt = get_post_meta(get_post_thumbnail_id($current_post->ID), '_wp_attachment_image_alt', true); $img_post = get_post(get_post_thumbnail_id($current_post->ID)); if ($display_style == "images_to_posts") { printf('<a href="%s" class="mosaic-overlay link fancybox" data-fancybox-group="gallery" title="%s"></a>', get_permalink($current_post->ID), esc_attr($img_post->post_title)); } else { printf('<a href="%s" class="mosaic-overlay fancybox" data-fancybox-group="gallery" title="%s"></a>', esc_url($post_thumbnail_src[0]), esc_attr($img_post->post_title)); } printf('<div class="mosaic-backdrop"><img src="%s" alt="%s" /></div>', esc_url($post_thumbnail_src_fit[0]), esc_attr($img_alt)); echo '</div>'; $post_counter++; } } } } else { echo "<ul>"; for ($i = 0; $i < $num_posts; $i++) { $current_post = $results_query[$i]; printf('<li><a href="%s">%s</a></li>', get_permalink($current_post->ID), esc_attr($current_post->post_title)); } echo "</ul>"; } ?> </div> <?php echo $after_widget; ?> <?php }