function zippo_thumbnail_url($post_id = null, $size = 'post-thumbnail', $attr = '') { $url = array(); $post_id = null === $post_id ? get_the_ID() : $post_id; $post_thumbnail_id = get_post_thumbnail_id($post_id); /** * Filter the post thumbnail size. * * @since 2.9.0 * * @param string $size The post thumbnail size. */ $size = apply_filters('post_thumbnail_size', $size); if ($post_thumbnail_id) { /** * Fires before fetching the post thumbnail HTML. * * Provides "just in time" filtering of all filters in wp_get_attachment_image(). * * @since 2.9.0 * * @param string $post_id The post ID. * @param string $post_thumbnail_id The post thumbnail ID. * @param string $size The post thumbnail size. */ do_action('begin_fetch_post_thumbnail_html', $post_id, $post_thumbnail_id, $size); if (in_the_loop()) { update_post_thumbnail_cache(); } $url = wp_get_attachment_image_src($post_thumbnail_id, $size, false, $attr); } return reset($url); }
function test_update_post_thumbnail_cache() { set_post_thumbnail($this->post, $this->attachment_id); $WP_Query = new WP_Query(array('post_type' => 'any', 'post__in' => array($this->post->ID), 'orderby' => 'post__in')); $this->assertFalse($WP_Query->thumbnails_cached); update_post_thumbnail_cache($WP_Query); $this->assertTrue($WP_Query->thumbnails_cached); }
function widget($args, $instance) { extract($args); $instance = wp_parse_args((array) $instance, self::$widget_defaults); /* Our variables from the widget settings. */ $title = apply_filters('widget_title', $instance['title']); $args = array('no_found_rows' => 1, 'posts_per_page' => $instance['show'], 'post_type' => 'dt_portfolio', 'post_status' => 'publish', 'orderby' => $instance['orderby'], 'order' => $instance['order'], 'tax_query' => array(array('taxonomy' => 'dt_portfolio_category', 'field' => 'term_id', 'terms' => $instance['cats']))); switch ($instance['select']) { case 'only': $args['tax_query'][0]['operator'] = 'IN'; break; case 'except': $args['tax_query'][0]['operator'] = 'NOT IN'; break; default: unset($args['tax_query']); } $p_query = new WP_Query($args); // for usage as shortcode if (!isset($img_size)) { $img_size = array($instance['max_width'], $instance['max_width']); } if (!isset($img_size_origin)) { $img_size_origin = $img_size; } else { $p = $img_size[1] / $img_size[0]; $img_size_origin[1] = round($img_size_origin[0] * $p); } echo $before_widget; // title if ($title) { echo $before_title . $title . $after_title; } if ($p_query->have_posts()) { update_post_thumbnail_cache($p_query); echo '<div class="instagram-photos" data-image-max-width="' . absint($instance['max_width']) . '">'; while ($p_query->have_posts()) { $p_query->the_post(); $thumb_id = get_post_thumbnail_id(get_the_ID()); if (!has_post_thumbnail(get_the_ID())) { $args = array('posts_per_page' => 1, 'no_found_rows' => 1, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'post_parent' => get_the_ID(), 'post_status' => 'inherit'); $images = new WP_Query($args); if ($images->have_posts()) { $thumb_id = $images->posts[0]->ID; } } $thumb_meta = wp_get_attachment_image_src($thumb_id, 'full'); dt_get_thumb_img(array('img_meta' => $thumb_meta ? $thumb_meta : null, 'img_id' => $thumb_id, 'use_noimage' => true, 'class' => 'post-rollover', 'title' => get_the_title(), 'href' => get_permalink(), 'options' => array('w' => $img_size_origin[0], 'h' => $img_size_origin[1]), 'wrap' => "\n" . '<a %HREF% %TITLE% %CLASS% %CUSTOM%><img %IMG_CLASS% %SRC% ' . image_hwstring($img_size[0], $img_size[1]) . ' %ALT% /></a>' . "\n")); } // while have posts wp_reset_postdata(); echo '</div>'; } // if have posts echo $after_widget; }
public function renderThumbnail($post, $post_thumbnail_id, $size, $attr) { $size = apply_filters('post_thumbnail_size', $size); if ($post_thumbnail_id) { /** * Fires before fetching the post thumbnail HTML. * * Provides "just in time" filtering of all filters in wp_get_attachment_image(). * * @since 2.9.0 * * @param int $post_id The post ID. * @param string $post_thumbnail_id The post thumbnail ID. * @param string|array $size The post thumbnail size. Image size or array of width * and height values (in that order). Default 'post-thumbnail'. */ do_action('begin_fetch_post_thumbnail_html', $post->ID, $post_thumbnail_id, $size); if (in_the_loop()) { update_post_thumbnail_cache(); } $html = wp_get_attachment_image($post_thumbnail_id, $size, false, $attr); /** * Fires after fetching the post thumbnail HTML. * * @since 2.9.0 * * @param int $post_id The post ID. * @param string $post_thumbnail_id The post thumbnail ID. * @param string|array $size The post thumbnail size. Image size or array of width * and height values (in that order). Default 'post-thumbnail'. */ do_action('end_fetch_post_thumbnail_html', $post->ID, $post_thumbnail_id, $size); } else { $html = ''; } /** * Filters the post thumbnail HTML. * * @since 2.9.0 * * @param string $html The post thumbnail HTML. * @param int $post_id The post ID. * @param string $post_thumbnail_id The post thumbnail ID. * @param string|array $size The post thumbnail size. Image size or array of width and height * values (in that order). Default 'post-thumbnail'. * @param string $attr Query string of attributes. */ return apply_filters('post_thumbnail_html', $html, $post->ID, $post_thumbnail_id, $size, $attr); }
/** * @param string|array $size * @param string|array $attr * * @return string */ public function getHTML($size = 'thumbnail', $attr = '') { $size = apply_filters('post_thumbnail_size', $size); if ($this->id) { do_action('begin_fetch_post_thumbnail_html', $this->parent->id, $this->id, $size); if (in_the_loop()) { update_post_thumbnail_cache(); } $html = wp_get_attachment_image($this->id, $size, false, $attr); do_action('end_fetch_post_thumbnail_html', $this->parent->id, $this->id, $size); } else { $html = ''; } return apply_filters('post_thumbnail_html', $html, $this->parent->id, $this->id, $size, $attr); }
function widget($args, $instance) { extract($args); $instance = wp_parse_args((array) $instance, self::$widget_defaults); /* Our variables from the widget settings. */ $title = apply_filters('widget_title', $instance['title']); $args = array('no_found_rows' => 1, 'posts_per_page' => $instance['show'], 'post_type' => 'dt_team', 'post_status' => 'publish', 'orderby' => $instance['orderby'], 'order' => $instance['order'], 'tax_query' => array(array('taxonomy' => 'dt_team_category', 'field' => 'term_id', 'terms' => $instance['cats']))); switch ($instance['select']) { case 'only': $args['tax_query'][0]['operator'] = 'IN'; break; case 'except': $args['tax_query'][0]['operator'] = 'NOT IN'; break; default: unset($args['tax_query']); } $p_query = new WP_Query($args); $autoslide = absint($instance['autoslide']); echo $before_widget . "\n"; // title if ($title) { echo $before_title . $title . $after_title . "\n"; } if ($p_query->have_posts()) { update_post_thumbnail_cache($p_query); echo '<ul class="team-items slider-content round-images bg-under-post rsContW"' . ($autoslide ? ' data-autoslide="' . $autoslide . '"' : '') . '>', "\n"; // get config instance $config = Presscore_Config::get_instance(); // backup and reset config $config_backup = $config->get(); $this->setup_config($instance); while ($p_query->have_posts()) { $p_query->the_post(); presscore_populate_team_config(); echo '<li>'; $this->render_teammate($instance); echo '</li>'; } // while have posts wp_reset_postdata(); // restore config $config->reset($config_backup); echo '</ul>', "\n"; } // if have posts echo $after_widget . "\n"; }
function get_the_post_thumbnail($post = null, $size = 'post-thumbnail', $attr = '') { $post = get_post($post); if (!$post) { return ''; } $post_thumbnail_id = get_post_thumbnail_id($post); $size = apply_filters('post_thumbnail_size', $size); if ($post_thumbnail_id) { do_action('begin_fetch_post_thumbnail_html', $post->ID, $post_thumbnail_id, $size); if (in_the_loop()) { update_post_thumbnail_cache(); } $html = wp_get_attachment_image($post_thumbnail_id, $size, false, $attr); do_action('end_fetch_post_thumbnail_html', $post->ID, $post_thumbnail_id, $size); } else { $html = ''; } return apply_filters('post_thumbnail_html', $html, $post->ID, $post_thumbnail_id, $size, $attr); }
public function get_posts_by_terms($instance = array()) { if (empty($this->post_type) || empty($this->taxonomy)) { return false; } $args = array('posts_per_page' => isset($instance['number']) ? $instance['number'] : -1, 'post_type' => $this->post_type, 'post_status' => 'publish', 'orderby' => isset($instance['orderby']) ? $instance['orderby'] : 'date', 'order' => isset($instance['order']) ? $instance['order'] : 'DESC', 'tax_query' => array(array('taxonomy' => $this->taxonomy, 'field' => 'slug', 'terms' => $instance['category']))); switch ($instance['select']) { case 'only': $args['tax_query'][0]['operator'] = 'IN'; break; case 'except': $args['tax_query'][0]['operator'] = 'NOT IN'; break; default: unset($args['tax_query']); } $query = new WP_Query($args); update_post_thumbnail_cache($query); return $query; }
function widget($args, $instance) { extract($args); $instance = wp_parse_args((array) $instance, self::$widget_defaults); /* Our variables from the widget settings. */ $title = apply_filters('widget_title', $instance['title']); $args = array('no_found_rows' => 1, 'posts_per_page' => $instance['show'], 'post_type' => 'dt_testimonials', 'post_status' => 'publish', 'orderby' => $instance['orderby'], 'order' => $instance['order'], 'tax_query' => array(array('taxonomy' => 'dt_testimonials_category', 'field' => 'term_id', 'terms' => $instance['cats']))); switch ($instance['select']) { case 'only': $args['tax_query'][0]['operator'] = 'IN'; break; case 'except': $args['tax_query'][0]['operator'] = 'NOT IN'; break; default: unset($args['tax_query']); } $p_query = new WP_Query($args); $autoslide = absint($instance['autoslide']); echo $before_widget . "\n"; // title if ($title) { echo $before_title . $title . $after_title . "\n"; } if ($p_query->have_posts()) { update_post_thumbnail_cache($p_query); echo '<ul class="testimonials slider-content rsContW"' . ($autoslide ? ' data-autoslide="' . $autoslide . '"' : '') . '>', "\n"; while ($p_query->have_posts()) { $p_query->the_post(); echo '<li>' . Presscore_Inc_Testimonials_Post_Type::render_testimonial() . '</li>'; } // while have posts wp_reset_postdata(); echo '</ul>', "\n"; } // if have posts echo $after_widget . "\n"; }
function mom_feature_slider($atts, $content = null) { global $unique_posts; global $do_unique_posts; extract(shortcode_atts(array('id' => '', 'type' => 'def', 'display' => 'latest', 'cats' => '', 'tag' => '', 'specific' => '', 'orderby' => '', 'number_of_posts' => '', 'animation' => '', 'animationin' => '', 'animationout' => '', 'autoplay' => '', 'timeout' => '4000', 'cap' => 'yes', 'exc' => '', 'class' => '', 'num_bullets' => '', 'bullets_event' => ''), $atts)); if ($id == '') { static $id = 75; $id++; } $specific = explode(',', $specific); if ($type == 'cat') { wp_enqueue_script('cycle'); wp_enqueue_script('nicescroll'); } if ($cats == 'Select a Category') { $cats = ''; } if ($tag == 'Select a Tag') { $tag = ''; } $output = get_transient('mom_feature_sliders' . $id . $type . $display . $cats . $tag . $class . $orderby); if ($orderby == 'rand') { $output = false; } if ($output == false) { ob_start(); if ($num_bullets == 'yes') { $class .= ' numbers_bullets'; } if (is_rtl()) { $rtl = 'true'; } else { $rtl = 'false'; } if ($animation == 'fade') { $animationout = 'fadeOut'; $animationin = ''; } elseif ($animation == 'slide') { $animationout = ''; $animationin = ''; } elseif ($animation == 'flip') { $animationout = 'slideOutDown'; $animationin = 'flipInX'; } if ($autoplay == 'no') { $autoplay = 'false'; } else { $autoplay = 'true'; } $post_meta_hp = mom_option('post_meta_hp'); if ($post_meta_hp == 1) { $post_head = mom_option('post_head'); $post_head_date = mom_option('post_head_date'); } else { $post_head = 1; $post_head_date = 1; } ?> <?php if ($type == 'slider2') { ?> <!-- Full width Slider 2 --> <section class="section <?php echo $class; ?> feature_slider_<?php echo $id; ?> "><!--def slider--> <div class="slider2 clearfix"> <!-- slider2 wrap --> <?php if ($display == 'cat') { $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'cat' => $cats, 'posts_per_page' => 2, 'orderby' => $orderby, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } elseif ($display == 'tag') { $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'tag' => $tag, 'posts_per_page' => 2, 'orderby' => $orderby, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } elseif ($display == 'specific') { $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'post__in' => $specific, 'posts_per_page' => 2, 'orderby' => $orderby, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } else { $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 2, 'orderby' => $orderby, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); if ($unique_posts) { $do_unique_posts[] = get_the_ID(); } ?> <?php if (mom_post_image() != false) { ?> <div class="def-slider-item big-slider2" itemscope="" itemtype="http://schema.org/Article"> <a itemprop="url" href="<?php the_permalink(); ?> "> <?php mom_post_image_full('catslider-thumb'); ?> </a> <?php if ($cap != 'no') { ?> <div class="def-slider-cap"> <div class="def-slider-title"> <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> </div> <?php if ($exc != false) { ?> <p class="def-slider-desc"> <?php global $post; $excerpt = $post->post_excerpt; if ($excerpt == '') { $excerpt = get_the_content(''); } echo wp_html_excerpt(strip_shortcodes($excerpt), $exc); ?> ... </p> <?php } ?> </div> <?php } ?> </div> <?php } ?> <?php } } else { } wp_reset_postdata(); ?> <?php if ($display == 'cat') { $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'cat' => $cats, 'posts_per_page' => 3, 'offset' => 2, 'orderby' => $orderby, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } elseif ($display == 'tag') { $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'tag' => $tag, 'posts_per_page' => 3, 'offset' => 2, 'orderby' => $orderby, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } elseif ($display == 'specific') { $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'post__in' => $specific, 'posts_per_page' => 3, 'offset' => 2, 'orderby' => $orderby, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } else { $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 3, 'offset' => 2, 'orderby' => $orderby, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); if ($unique_posts) { $do_unique_posts[] = get_the_ID(); } ?> <?php if (mom_post_image() != false) { ?> <div class="def-slider-item small-slider2" itemscope="" itemtype="http://schema.org/Article"> <a itemprop="url" href="<?php the_permalink(); ?> "><?php mom_post_image_full('catslider-thumb'); ?> </a> <?php if ($cap != 'no') { ?> <div class="def-slider-cap"> <div class="def-slider-title"> <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> </div> <?php if ($exc != false) { ?> <p class="def-slider-desc"> <?php global $post; $excerpt = $post->post_excerpt; if ($excerpt == '') { $excerpt = get_the_content(''); } echo wp_html_excerpt(strip_shortcodes($excerpt), $exc); ?> ... </p> <?php } ?> </div> <?php } ?> </div> <?php } ?> <?php } } else { } wp_reset_postdata(); ?> </div><!-- slider2 wrap --> </section> <?php } elseif ($type == 'cat') { ?> <section class="section clearfix <?php echo $class; ?> feature_slider_<?php echo $id; ?> feature-cat-slider-wrap"> <div class="fc_nav"> <a class="fc_prev" href="#"><span class="enotype-icon-arrow-left7"></span></a> <a class="fc_next" href="#"><span class="enotype-icon-uniE6D8"></span></a> </div> <div class="cat-slider feature-cat-slider"> <div class="cat-slider-wrap" data-cat_timeout="<?php echo $timeout; ?> "> <?php $parent_posts = ''; if ($display == 'cat') { $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'cat' => $cats, 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } elseif ($display == 'tag') { $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'tag' => $tag, 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } elseif ($display == 'specific') { $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'post__in' => $specific, 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } else { $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); if ($unique_posts) { $do_unique_posts[] = get_the_ID(); } $parent_posts[] = get_the_ID(); ?> <?php if (mom_post_image() != false) { ?> <div class="cat-slider-item" itemscope="" itemtype="http://schema.org/Article"> <?php $layout = mom_option('main_layout'); $site_width = mom_option('site_width'); $thumb_size = 'catslider1-thumb'; if (strpos($layout, 'both') === false) { $thumb_size = 'catslider-thumb'; if ($site_width == 'wide') { $thumb_size = 'catslider1-thumb'; } } if ($layout == 'fullwidth' && strpos(mom_option('main_layout'), 'both') !== false) { $thumb_size = 'catslider1-thumb'; } ?> <div class="feature-cs-cap"> <?php $category = get_the_category(); if ($category) { $cat_data = get_option("category_" . $category[0]->term_id); $cat_color = isset($cat_data['color']) ? $cat_data['color'] : ''; echo '<div class="cat-label" style="background:' . $cat_color . ';"><a href="' . get_category_link($category[0]->term_id) . '" title="' . sprintf(__("View all posts in %s", 'framework'), $category[0]->name) . '" ' . '>' . $category[0]->name . '</a></div>'; } ?> <h2 itemprop="name"><a href="<?php the_permalink(); ?> " itemprop="url"><?php the_title(); ?> </a></h2> <?php if ($exc != '') { ?> <p class="feature-cs-desc"> <?php global $post; $excerpt = $post->post_excerpt; if ($excerpt == '') { $excerpt = get_the_content(''); } echo wp_html_excerpt(strip_shortcodes($excerpt), $exc); ?> ... </p> <?php } ?> </div> <a href="<?php the_permalink(); ?> "> <?php echo mom_post_image_full($thumb_size); ?> </a> </div> <?php } } } else { ?> <?php } ?> <?php wp_reset_postdata(); ?> </div> <div class="cat-slider-nav"> <ul> <?php $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $number_of_posts, 'orderby' => 'post__in', 'no_found_rows' => true, 'cache_results' => false, 'post__in' => $parent_posts)); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); if ($unique_posts) { $do_unique_posts[] = get_the_ID(); } ?> <?php if (mom_post_image() != false) { ?> <li itemscope="" itemtype="http://schema.org/Article"> <a href="<?php the_permalink(); ?> " itemprop="url"> <h2 itemprop="name"><?php short_title(47); ?> </h2> <div class="entry-meta"> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><?php the_time('Y/m/d'); ?> </time> <div class="author-link"> <?php _e('by ', 'framework'); ?> <a itemprop="author" href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?> " rel="author"><?php echo get_the_author(); ?> </a> </div> </div> </a> </li> <?php } ?> <?php } } else { ?> <?php } wp_reset_postdata(); ?> </ul> </div> </div> </section> <?php } else { ?> <!-- Default slider --> <section class="section <?php echo $class; ?> feature_slider_<?php echo $id; ?> "><!--def slider--> <div class="def-slider"> <div class="def-slider-wrap momizat-custom-slider" data-srtl="<?php echo $rtl; ?> " data-animate_out='<?php echo $animationout; ?> ' data-animate_in="<?php echo $animationin; ?> " data-autoplay="<?php echo $autoplay; ?> " data-timeout="<?php echo $timeout; ?> " data-bullets_event="<?php echo $bullets_event; ?> "> <?php $count = 1; if ($display == 'cat') { $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'cat' => $cats, 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } elseif ($display == 'tag') { $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'tag' => $tag, 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } elseif ($display == 'specific') { $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'post__in' => $specific, 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } else { $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); if ($unique_posts) { $do_unique_posts[] = get_the_ID(); } ?> <?php if (mom_post_image() != false) { ?> <div class="def-slider-item" data-dot="<?php echo $count; ?> " itemscope="" itemtype="http://schema.org/Article"> <a itemprop="url" href="<?php the_permalink(); ?> "> <?php $thumbsize = 'slider-thumb'; if (mom_option('site_width') == 'wide') { $classes = get_body_class(); if (in_array('right-sidebar', $classes) || in_array('left-sidebar', $classes)) { $thumbsize = 'big-thumb-hd'; } } mom_post_image_full($thumbsize); ?> </a> <?php if ($cap != 'no') { ?> <div class="def-slider-cap"> <div class="def-slider-title"> <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> </div> <?php if ($exc != false) { ?> <p class="def-slider-desc"> <?php global $post; $excerpt = $post->post_excerpt; if ($excerpt == '') { $excerpt = get_the_content(''); } echo wp_html_excerpt(strip_shortcodes($excerpt), $exc, '...'); ?> </p> <?php } ?> </div> <?php } ?> </div> <?php } ?> <?php $count++; } } else { } wp_reset_postdata(); ?> </div> </div> </section><!--def slider--> <?php } ?> <!-- End Slider type --> <?php $output = ob_get_contents(); ob_end_clean(); set_transient('mom_feature_sliders' . $id . $type . $display . $cats . $tag . $class . $orderby, $output, 60 * 60 * 24); } return $output; }
/** * This function return array with thumbnail image meta for items list in admin are. * If fitured image not set it gets last image by menu order. * If there are no images and $noimage not empty it returns $noimage in other way it returns false * * @param integer $post_id * @param integer $max_w * @param integer $max_h * @param string $noimage */ function dt_get_admin_thumbnail($post_id, $max_w = 100, $max_h = 100, $noimage = '') { $thumb = array(); update_post_thumbnail_cache(); if (has_post_thumbnail($post_id)) { $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'thumbnail'); } $thumb = apply_filters('presscore_admin_get_post_thumbnail', $thumb, get_post_type($post_id), $post_id); if (empty($thumb)) { if (!$noimage) { return false; } $thumb = $noimage; $w = $max_w; $h = $max_h; } else { $sizes = wp_constrain_dimensions($thumb[1], $thumb[2], $max_w, $max_h); $w = $sizes[0]; $h = $sizes[1]; $thumb = $thumb[0]; } return array(esc_url($thumb), $w, $h); }
/** * Get posts list. */ static function get_posts_tab() { if (!self::get_posts_query()->have_posts()) { return ''; } global $post, $wpdb; $imgs_text = array(_x('no pictures', 'backend', 'the7mk2'), _x('1 picture', 'backend', 'the7mk2'), _x('% pictures', 'backend', 'the7mk2')); $html = ''; $html .= '<div class="dt_tab-items hide-if-js">'; update_post_thumbnail_cache(self::get_posts_query()); foreach (self::get_posts_query()->posts as $_post) { $attachments = get_post_meta($_post->ID, '_dt_album_media_items', true); // count post images $imgs_count = count($attachments); // prepare title info if (0 == $imgs_count) { $title_info = $imgs_text[0]; } elseif (1 == $imgs_count) { $title_info = $imgs_text[1]; } else { $title_info = str_replace('%', $imgs_count, $imgs_text[2]); } // post terms $terms = get_the_terms($_post->ID, self::$field['taxonomy']); if (!is_wp_error($terms) && $terms) { $term_links = array(); foreach ($terms as $term) { $link = get_admin_url() . 'edit-tags.php'; $link = add_query_arg(array('action' => 'edit', 'post_type' => self::$field['post_type'], 'taxonomy' => self::$field['taxonomy'], 'tag_ID' => $term->term_id), $link); $term_links[] = '<a href="' . esc_url($link) . '" rel="tag" target="_blank">' . $term->name . '</a>'; } if (empty($term_links)) { $term_links[] = 'none'; } $terms_list = '<p><strong>' . _x('Categories: ', 'backend', 'the7mk2') . '</strong>' . implode(', ', $term_links) . '</p>'; } else { $terms_list = '<p></p>'; } // item start $item_str = '<div class="dt_list-item"><div class="dt_item-holder">'; // item checkbox $item_str .= sprintf('<label class="dt_checkbox"><input type="checkbox" name="%s" value="%s" %s /></label>', self::$field['field_name'] . '[posts_ids][' . $_post->ID . ']', $_post->ID, checked(in_array($_post->ID, (array) self::$meta['posts_ids']), true, false)); // get thumbnail or first post image $img = ''; if (has_post_thumbnail($_post->ID)) { $img = wp_get_attachment_image_src(get_post_thumbnail_id($_post->ID), 'thumbnail'); } else { if ($attachments && is_array($attachments)) { $img = wp_get_attachment_image_src(current($attachments), 'thumbnail'); } } // if no image if (!$img) { $img = array(get_template_directory_uri() . '/images/no-avatar.gif'); } // image style and dimensions $cover_style = 'dt_album-cover'; $w = $h = 88; if ('dt_slider' == $_post->post_type) { $cover_style = 'dt_slider-cover'; $w = 98; $h = 68; } // image block $item_str .= sprintf('<div class="dt_item-cover %s"><div><img src="%s" heught="%d" width="%d" /></div></div>', $cover_style, $img[0], $h, $w); // description start $item_str .= '<div class="dt_item-desc">'; // title $item_str .= '<strong><a href="' . esc_url(get_admin_url() . 'post.php?post=' . $_post->ID . '&action=edit') . '" target="_blank">' . get_the_title($_post->ID) . '</a> (' . $title_info . ')</strong>'; // terms list $item_str .= $terms_list; // date $date_format = get_option('date_format'); $item_str .= sprintf('<strong>%1$s</strong><abbr title="%2$s">%2$s</abbr>', _x('Date: ', 'backend', 'the7mk2'), apply_filters('get_the_date', mysql2date($date_format, $_post->post_date), $date_format)); // actions start $item_str .= '<div class="row-actions">'; // edit $item_str .= sprintf('<span class="edit"><a title="%s" href="%s" target="_blank">%s</a></span>', _x('Edit this item', 'backend', 'the7mk2'), esc_url(get_admin_url() . 'post.php?post=' . $_post->ID . '&action=edit'), _x('Edit', 'backend', 'the7mk2')); // move to trash if (current_user_can('edit_post', $_post->ID)) { $item_str .= sprintf(' | <span class="trash"><a title="%s" href="%s">%s</a></span>', _x('Move this item to the Trash', 'backend', 'the7mk2'), wp_nonce_url(site_url() . "/wp-admin/post.php?action=trash&post=" . $_post->ID, 'trash-' . $_post->post_type . '_' . $_post->ID), _x('Trash', 'backend', 'the7mk2')); } // ections end $item_str .= '</div>'; // description end $item_str .= '</div>'; $item_str .= '</div></div>'; $html .= $item_str; } $html .= '</div>'; return $html; }
?> </h2> </header> <ul class="mom-related-posts clearfix"> <?php global $post; $cats = get_the_category($post->ID); if ($cats) { $cat_ids = array(); foreach ($cats as $individual_cat) { $cat_ids[] = $individual_cat->cat_ID; } $args = array('category__in' => $cat_ids, 'post__not_in' => array($post->ID), 'showposts' => mom_option('related_count'), 'ignore_sticky_posts' => 1, 'no_found_rows' => true, 'cache_results' => false); $query = new WP_Query($args); update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); ?> <li itemscope="" itemtype="http://schema.org/Article"> <?php if (mom_post_image() != false) { ?> <figure class="post-thumbnail"><a href="<?php the_permalink(); ?> "> <?php mom_post_image_full('related-thumb'); ?>
function mom_scrollers($atts, $content = null) { global $unique_posts; global $do_unique_posts; extract(shortcode_atts(array('style' => 'sc1', 'title' => '', 'title_size' => '17', 'sub_title' => '', 'display' => 'latest', 'cats' => '', 'tags' => '', 'orderby' => '', 'number_of_posts' => '5', 'auto_play' => '3000', 'speed' => '300', 'items' => '4'), $atts)); static $id = 75; $id++; if ($cats == 'Select a Category') { $cats = ''; } if ($tags == 'Select a Tag') { $tags = ''; } $output = get_transient('mom_scroller_' . $id . $style . $display . $cats . $tags . $items . $orderby); if ($orderby == 'rand') { $output = false; } if ($output == false) { ob_start(); //wp_enqueue_script('owl'); $dateformat = mom_option('date_format'); $post_meta_hp = mom_option('post_meta_hp'); if ($post_meta_hp == 1) { $post_head = mom_option('post_head'); $post_head_author = mom_option('post_head_author'); $post_head_date = mom_option('post_head_date'); $post_head_cat = mom_option('post_head_cat'); $post_head_commetns = mom_option('post_head_commetns'); $post_head_views = mom_option('post_head_views'); } else { $post_head = 1; $post_head_author = 1; $post_head_date = 1; $post_head_cat = 1; $post_head_commetns = 1; $post_head_views = 1; } $authormeta = mom_option('post_head_author'); $rndn = rand(0, 100); global $wpdb; $tag_ID = $wpdb->get_var("SELECT * FROM " . $wpdb->terms . " WHERE 'name' = '" . $tags . "'"); $nb_link = ''; if ($display == 'cats') { if ($title == '') { $nb_title = get_cat_name($cats); $nb_link = get_category_link($cats); } else { $nb_title = $title; } } elseif ($display == 'tags') { if ($title == '') { $nb_title = $tags; $nb_link = get_tag_link($tag_ID); } else { $nb_title = $title; } } else { $nb_title = $title; $nb_link = ''; } if ($auto_play != '') { $autoplay = 'true'; } else { $autoplay = 'false'; } if (is_rtl()) { $rtl = 'true'; } else { $rtl = 'false'; } $link_start = ''; $link_end = ''; if ($nb_link != '') { $link_start = '<a href="' . $nb_link . '">'; $link_end = '</a>'; } ?> <?php if ($style == 'sc1') { ?> <section class="section scroller-section scroller-<?php echo $id; ?> "> <header class="section-header"> <?php if ($title_size == '17') { ?> <h2 class="section-title"><?php echo $link_start . $nb_title . $link_end; ?> </h2> <?php } else { ?> <h1 class="section-title2"><?php echo $link_start . $nb_title . $link_end; ?> </h1> <?php } ?> <?php if ($sub_title != '') { ?> <span class="mom-sub-title"><?php echo $sub_title; ?> </span><?php } ?> </header> <div class="scroller"> <div class="scroller-wrap scroller-wrap-1" data-sc-auto="<?php echo $autoplay; ?> " data-sc-autotime="<?php echo $auto_play; ?> " data-sc-speed="<?php echo $speed; ?> " data-sc-rtl="<?php echo $rtl; ?> " data-items="<?php echo $items; ?> "> <?php if ($display == 'cats') { $squery = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'cat' => $cats, 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } elseif ($display == 'tags') { $squery = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'tag' => $tags, 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } else { $squery = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } update_post_thumbnail_cache($squery); if ($squery->have_posts()) { while ($squery->have_posts()) { $squery->the_post(); if ($unique_posts) { $do_unique_posts[] = get_the_ID(); } $post_url = get_post_meta(get_the_ID(), 'mom_post_custom_link', true); if ($post_url == '') { $post_url = get_permalink(); } ?> <?php if (mom_post_image() != false) { ?> <div class="scroller-item" itemscope="" itemtype="http://schema.org/Article"> <a itemprop="url" href="<?php echo $post_url; ?> "> <figure class="post-thumbnail"> <?php mom_post_image_full('scroller-thumb'); ?> </figure> <h2 itemprop="name"><?php the_title(); ?> </h2> </a> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_author == 1) { ?> <div class="author-link"> <i class="momizat-icon-user3"></i><a itemprop="author" href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?> " rel="author"><?php echo get_the_author(); ?> </a> </div> <?php } ?> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php the_time('Y/m/d'); ?> </time> <?php } ?> <?php if ($post_head_cat != 0) { ?> <div class="cat-link"> <i class="momizat-icon-folder-open"></i><?php $category = get_the_category(); echo '<a class="category" href="' . get_category_link($category[0]->term_id) . '">' . $category[0]->cat_name . '</a>'; ?> </div> <?php } ?> </div> <?php } ?> </div> <?php } ?> <?php } } else { } wp_reset_postdata(); ?> </div> </div> </section> <?php } else { ?> <section class="section scroller-section scroller-<?php echo $id; ?> "> <header class="section-header"> <?php if ($title_size == '17') { ?> <h2 class="section-title"><?php echo $link_start . $nb_title . $link_end; ?> </h2> <?php } else { ?> <h1 class="section-title2"><?php echo $link_start . $nb_title . $link_end; ?> </h1> <?php } ?> <?php if ($sub_title != '') { ?> <span class="mom-sub-title"><?php echo $sub_title; ?> </span><?php } ?> </header> <div class="scroller2"> <div class="scroller2-wrap scroller-wrap-2" data-sc2-auto="<?php echo $autoplay; ?> " data-sc2-autotime="<?php echo $auto_play; ?> " data-sc2-speed="<?php echo $speed; ?> " data-sc2-rtl="<?php echo $rtl; ?> " data-items="<?php echo $items; ?> "> <?php if ($display == 'cats') { $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'cat' => $cats, 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } elseif ($display == 'tags') { $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'tag' => $tags, 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } else { $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); if ($unique_posts) { $do_unique_posts[] = get_the_ID(); } $post_url = get_post_meta(get_the_ID(), 'mom_post_custom_link', true); if ($post_url == '') { $post_url = get_permalink(); } ?> <div class="scroller-item" itemscope="" itemtype="http://schema.org/Article"> <a itemprop="url" href="<?php echo $post_url; ?> "> <?php if (mom_post_image() != false) { ?> <figure class="post-thumbnail"> <?php mom_post_image_full('scroller-thumb'); ?> </figure> <?php } ?> <h2 itemprop="name"><?php the_title(); ?> </h2> </a> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_author == 1) { ?> <div class="author-link"> <i class="momizat-icon-user3"></i><a itemprop="author" href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?> " rel="author"><?php echo get_the_author(); ?> </a> </div> <?php } ?> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php the_time('Y/m/d'); ?> </time> <?php } ?> <?php if ($post_head_cat != 0) { ?> <div class="cat-link"> <i class="momizat-icon-folder-open"></i><?php $category = get_the_category(); echo '<a class="category" href="' . get_category_link($category[0]->term_id) . '">' . $category[0]->cat_name . '</a>'; ?> </div> <?php } ?> </div> <?php } ?> </div> <?php } } else { } wp_reset_postdata(); ?> </div> </div> </section> <?php } ?> <?php $output = ob_get_contents(); ob_end_clean(); set_transient('mom_scroller_' . $id . $style . $display . $cats . $tags . $items . $orderby, $output, 60 * 60 * 24); } return $output; }
function widget($args, $instance) { extract($args); /* User-selected settings. */ $title = apply_filters('widget_title', $instance['title']); $orderby = $instance['orderby']; $count = $instance['count']; $display = isset($instance['display']) ? $instance['display'] : array(); $cats = isset($instance['cats']) ? $instance['cats'] : array(); $output = get_transient($this->id); if ($orderby == 'Random') { $output = false; } if ($output == false) { ob_start(); /* Before widget (defined by themes). */ echo $before_widget; /* Title of widget (before and after defined by themes). */ if ($title) { echo $before_title . $title . $after_title; } global $unique_posts; global $do_unique_posts; ?> <div class="news-pics-widget"> <ul class="npwidget clearfix"> <?php if ($orderby == 'Popular') { ?> <?php if ($display == 'cats') { $catsi = implode(',', $cats); ?> <?php $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'cat' => $catsi, 'ignore_sticky_posts' => 1, 'posts_per_page' => $count, 'orderby' => 'comment_count', 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); ?> <?php } else { ?> <?php $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $count, 'orderby' => 'comment_count', 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); ?> <?php } ?> <?php } elseif ($orderby == 'Random') { ?> <?php if ($display == 'cats') { $catsi = implode(',', $cats); ?> <?php $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'cat' => $catsi, 'ignore_sticky_posts' => 1, 'posts_per_page' => $count, 'orderby' => 'rand', 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); ?> <?php } else { ?> <?php $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $count, 'orderby' => 'comment_count', 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); ?> <?php } ?> <?php } elseif ($orderby == 'Recent') { ?> <?php if ($display == 'cats') { $catsi = implode(',', $cats); ?> <?php $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'cat' => $catsi, 'ignore_sticky_posts' => 1, 'posts_per_page' => $count, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); ?> <?php } else { ?> <?php $query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $count, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); ?> <?php } ?> <?php } ?> <?php update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); if ($unique_posts) { $do_unique_posts[] = get_the_ID(); } ?> <?php if (mom_post_image() != false) { ?> <li class="simptip-position-top simptip-movable half-arrow simptip-multiline" data-tooltip="<?php the_title(); ?> " itemscope="" itemtype="http://schema.org/Article"> <figure class="post-thumbnail"><a itemprop="url" href="<?php the_permalink(); ?> " rel="bookmark"> <?php mom_post_image_full('postpicwid-thumb'); ?> </a></figure> </li> <?php } ?> <?php } ?> <?php } else { ?> <!-- Else in here --> <?php } ?> <?php wp_reset_postdata(); ?> </ul> </div> <?php /* After widget (defined by themes). */ echo $after_widget; $output = ob_get_contents(); ob_end_clean(); set_transient($this->id, $output, 60 * 60 * 24); } echo $output; }
function presscore_get_blog_query() { $config = presscore_get_config(); $orderby = $config->get('orderby'); $query_args = array('post_type' => 'post', 'post_status' => 'publish', 'paged' => dt_get_paged_var(), 'order' => $config->get('order'), 'orderby' => 'name' == $orderby ? 'title' : $orderby); $ppp = $config->get('posts_per_page'); if ($ppp) { $query_args['posts_per_page'] = intval($ppp); } $display = $config->get('display'); if (!empty($display['terms_ids'])) { $terms_ids = array_values($display['terms_ids']); switch ($display['select']) { case 'only': $query_args['category__in'] = $terms_ids; break; case 'except': $query_args['category__not_in'] = $terms_ids; } } // get filter request $request_display = $config->get('request_display'); if ($request_display) { // get all dt_portfolio_category terms $all_terms = get_categories(array('type' => 'post', 'hide_empty' => 1, 'hierarchical' => 0, 'taxonomy' => 'category', 'pad_counts' => false)); // populate $all_terms_array with terms names $all_terms_array = array(); foreach ($all_terms as $term) { $all_terms_array[] = $term->term_id; } // except for empty term that appers when all filter category selcted, see it's url if (0 == current($request_display['terms_ids'])) { $request_display['terms_ids'] = $all_terms_array; } // override base tax_query $query_args['tax_query'] = array(array('taxonomy' => 'category', 'field' => 'id', 'terms' => array_values($request_display['terms_ids']), 'operator' => 'IN')); if ('except' == $request_display['select']) { $query_args['tax_query'][0]['operator'] = 'NOT IN'; } } $query = new WP_Query($query_args); update_post_thumbnail_cache($query); return $query; }
function mom_blog_sc($atts, $content) { extract(shortcode_atts(array('style' => '', 'display' => '', 'category' => '', 'tag' => '', 'specific' => '', 'orderby' => '', 'posts_per_page' => 9, 'offset' => '', 'nexcerpt' => '', 'pagination' => 'yes', 'class' => '', 'cols' => 2, 'post_type' => '', 'ad_id' => '', 'ad_count' => 3, 'ad_repeat' => ''), $atts)); $cols = 'grid-col-' . $cols; static $id = 75; $id++; if ($category == 'Select a Category') { $category = ''; } if ($tag == 'Select a Tag') { $tag = ''; } if (get_query_var('paged')) { $paged = get_query_var('paged'); } elseif (get_query_var('page')) { $paged = get_query_var('page'); } else { $paged = 1; } global $post; $exclude_posts = array($post->ID); //$output = get_transient('mom_blog_sc_'.$id.$style.$display.$category.$tag.$specific.$orderby.$offset.$nexcerpt.$posts_per_page.$pagination.$paged); $output = false; if ($orderby == 'rand') { $output = false; } if ($output == false) { ob_start(); ?> <?php if ($style == 'grid') { ?> <div class="site-content page-wrap category-view-blog"> <?php if (mom_option('cat_swi')) { ?> <div class="f-tabbed-head"> <ul class="f-tabbed-sort cat-sort"> <li class="grid active"><a href="#"><span class="brankic-icon-grid"></span><?php _e(' Grid', 'framework'); ?> </a></li> <li class="list"><a href="#"><span class="brankic-icon-list2"></span><?php _e(' List', 'framework'); ?> </a></li> </ul> </div> <?php } ?> <?php $catswi = mom_option('cat_swi_def'); $swiclass = 'cat-grid ' . $cols; if ($catswi == 'list') { $swiclass = 'cat-list'; } $srclass = ''; if (mom_option('cat_swi') != true) { $srclass = ' no-head'; } ?> <div class="cat-body<?php echo $srclass; ?> "> <ul class="nb1 <?php echo $swiclass; ?> clearfix"> <?php } else { ?> <div class="blog_posts"> <?php } ?> <?php if ($display == 'category') { $args = array('post_type' => $post_type, 'post__not_in' => $exclude_posts, 'post_status' => 'publish', 'posts_per_page' => $posts_per_page, 'paged' => $paged, 'cat' => $category, 'offset' => $offset, 'orderby' => $orderby, 'cache_results' => false); } elseif ($display == 'tag') { $args = array('post_type' => $post_type, 'post__not_in' => $exclude_posts, 'post_status' => 'publish', 'posts_per_page' => $posts_per_page, 'paged' => $paged, 'tag' => $tag, 'offset' => $offset, 'orderby' => $orderby, 'cache_results' => false); } elseif ($display == 'specific') { $args = array('post_type' => $post_type, 'post__not_in' => $exclude_posts, 'post_status' => 'publish', 'posts_per_page' => $posts_per_page, 'paged' => $paged, 'p' => $specific, 'orderby' => $orderby, 'cache_results' => false); } else { $args = array('post_type' => $post_type, 'post__not_in' => $exclude_posts, 'post_status' => 'publish', 'posts_per_page' => $posts_per_page, 'paged' => $paged, 'offset' => $offset, 'orderby' => $orderby, 'cache_results' => false); } $post_count = 1; $query = new WP_Query($args); update_post_thumbnail_cache($query); ?> <?php if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); ?> <?php $grid_class = ''; if ($style == 'grid') { if ($post_count % 2 == 0) { $grid_class = ' second'; } else { $grid_class = ' first'; } } mom_blog_post($style, $nexcerpt, $class . $grid_class); if ($ad_id != '') { if ($ad_repeat == 'yes') { if ($post_count % $ad_count == 0) { if ($style == 'grid') { echo '<li>'; } echo do_shortcode('[ad id="' . $ad_id . '"]'); if ($style == 'grid') { echo '</li>'; } } } else { if ($post_count == $ad_count) { if ($style == 'grid') { echo '<li>'; } echo do_shortcode('[ad id="' . $ad_id . '"]'); if ($style == 'grid') { echo '</li>'; } } } } $post_count++; ?> <?php } } else { ?> <p><?php _e('Sorry, no posts matched your criteria.', 'framework'); ?> </p> <?php } ?> <?php if ($pagination != 'no') { ?> <?php if ($style != 'grid') { mom_pagination($query->max_num_pages); } ?> <?php } ?> <?php wp_reset_query(); ?> <?php if ($style == 'grid') { ?> </ul> <?php if ($pagination != 'no') { mom_pagination($query->max_num_pages); } ?> </div> </div> <?php } else { ?> </div> <!-- blog posts --> <?php } $output = ob_get_contents(); ob_end_clean(); //set_transient('mom_blog_sc_'.$id.$style.$display.$category.$tag.$specific.$orderby.$offset.$nexcerpt.$posts_per_page.$pagination.$paged, $output, 60*60*24); } return $output; }
function widget($args, $instance) { extract($args); /* User-selected settings. */ $title = apply_filters('widget_title', $instance['title']); $orderby = $instance['orderby']; $count = $instance['count']; $display = $instance['display']; $cats = isset($instance['cats']) ? $instance['cats'] : array(); $tags = isset($instance['tags']) ? $instance['tags'] : array(); $output = get_transient($this->id); if ($output == false) { ob_start(); /* Before widget (defined by themes). */ echo $before_widget; /* Title of widget (before and after defined by themes). */ if ($title) { echo $before_title . $title . $after_title; } ?> <ul class="post-list"> <?php if ($orderby == 'top') { if ($display == 'cats') { $catsi = implode(',', $cats); $query = new WP_Query(array('orderby' => 'meta_value_num', 'meta_key' => '_mom_review-final-score', 'meta_value' => 0, 'meta_compare' => '!=', "ignore_sticky_posts" => 1, 'showposts' => $count, 'cat' => $catsi, 'no_found_rows' => true, 'cache_results' => false)); } elseif ($display == 'tags') { $query = new WP_Query(array('orderby' => 'meta_value_num', 'meta_key' => '_mom_review-final-score', 'meta_value' => 0, 'meta_compare' => '!=', "ignore_sticky_posts" => 1, 'showposts' => $count, 'tag' => $tags, 'no_found_rows' => true, 'cache_results' => false)); } else { $query = new WP_Query(array('orderby' => 'meta_value_num', 'meta_key' => '_mom_review-final-score', 'meta_value' => 0, 'meta_compare' => '!=', "ignore_sticky_posts" => 1, 'showposts' => $count, 'no_found_rows' => true, 'cache_results' => false)); } } elseif ($orderby == 'random') { if ($display == 'cats') { $catsi = implode(',', $cats); $query = new WP_Query(array('meta_key' => '_mom_review-final-score', "orderby" => "rand", 'meta_value' => 0, 'meta_compare' => '!=', "ignore_sticky_posts" => 1, 'showposts' => $count, 'cat' => $catsi, 'no_found_rows' => true, 'cache_results' => false)); } elseif ($display == 'tags') { $query = new WP_Query(array('meta_key' => '_mom_review-final-score', "orderby" => "rand", 'meta_value' => 0, 'meta_compare' => '!=', "ignore_sticky_posts" => 1, 'showposts' => $count, 'tag' => $tags, 'no_found_rows' => true, 'cache_results' => false)); } else { $query = new WP_Query(array('meta_key' => '_mom_review-final-score', "orderby" => "rand", 'meta_value' => 0, 'meta_compare' => '!=', "ignore_sticky_posts" => 1, 'showposts' => $count, 'no_found_rows' => true, 'cache_results' => false)); } } else { if ($display == 'cats') { $catsi = implode(',', $cats); $query = new WP_Query(array('meta_key' => '_mom_review-final-score', 'meta_value' => 0, 'meta_compare' => '!=', "ignore_sticky_posts" => 1, 'showposts' => $count, 'cat' => $catsi, 'no_found_rows' => true, 'cache_results' => false)); } elseif ($display == 'tags') { $query = new WP_Query(array('meta_key' => '_mom_review-final-score', 'meta_value' => 0, 'meta_compare' => '!=', "ignore_sticky_posts" => 1, 'showposts' => $count, 'tag' => $tags, 'no_found_rows' => true, 'cache_results' => false)); } else { $query = new WP_Query(array('meta_key' => '_mom_review-final-score', 'meta_value' => 0, 'meta_compare' => '!=', "ignore_sticky_posts" => 1, 'showposts' => $count, 'no_found_rows' => true, 'cache_results' => false)); } } update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $criterias = get_post_meta(get_the_ID(), '_mom_review-criterias', false); $all_scores = 0; $the_score = 0; $score = 0; if ($criterias != false) { foreach ($criterias[0] as $criteria) { $all_scores += 100; $score += $criteria['cr_score']; } $the_score = $score / $all_scores * 100; $score = round($the_score); } ?> <li itemscope="" itemtype="http://schema.org/Review"> <?php if (mom_post_image() != false) { ?> <figure class="post-thumbnail"><a itemprop="url" href="<?php the_permalink(); ?> " rel="bookmark"> <?php mom_post_image_full('postlist-thumb'); ?> </a></figure> <?php } ?> <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> " rel="bookmark"><?php the_title(); ?> </a></h2> <div class="entry-review"> <?php $stars_score = number_format($score / 20, 1, '.', ','); $summary = get_post_meta(get_the_ID(), '_mom_review_summary', true); ?> <span class="rev-title"><?php _e('Review :', 'framework'); ?> </span> <div class="star-rating mom_review_score"><span style="width:<?php echo $score; ?> %;"></span></div> <small>(<?php echo $stars_score; ?> )</small> </div> </li> <?php } ?> <?php } else { ?> <!-- Else in here --> <?php } ?> <?php wp_reset_query(); ?> </ul> <?php /* After widget (defined by themes). */ echo $after_widget; $output = ob_get_contents(); ob_end_clean(); set_transient($this->id, $output, 60 * 60 * 24); } echo $output; }
/** * Retrieve Post Thumbnail. * * @since 2.9.0 * * @param int $post_id Optional. Post ID. * @param string $size Optional. Image size. Defaults to 'thumbnail'. * @param string|array $attr Optional. Query string or array of attributes. */ function get_the_post_thumbnail($post_id = null, $size = 'post-thumbnail', $attr = '') { $post_id = null === $post_id ? get_the_ID() : $post_id; $post_thumbnail_id = get_post_thumbnail_id($post_id); $size = apply_filters('post_thumbnail_size', $size); if ($post_thumbnail_id) { do_action('begin_fetch_post_thumbnail_html', $post_id, $post_thumbnail_id, $size); // for "Just In Time" filtering of all of nxt_get_attachment_image()'s filters if (in_the_loop()) { update_post_thumbnail_cache(); } $html = nxt_get_attachment_image($post_thumbnail_id, $size, false, $attr); do_action('end_fetch_post_thumbnail_html', $post_id, $post_thumbnail_id, $size); } else { $html = ''; } return apply_filters('post_thumbnail_html', $html, $post_id, $post_thumbnail_id, $size, $attr); }
function mom_mega_menu_cats_loop($object = '', $layout = '', $id = '') { if ($object == '') { $object = $_POST['object']; } if ($layout == '') { $layout = isset($_POST['layout']) ? $_POST['layout'] : ''; } if ($id == '') { $id = $_POST['id']; } if ($layout == 'horz') { $post_count = mom_option('cm_counter'); $sep = ''; $img_size = 'megamenu-thumb'; } else { $post_count = mom_option('cm_counter'); $sep = '-'; $img_size = 'megamenu-thumb'; } $output = ''; $r = new WP_Query(array('posts_per_page' => $post_count, 'no_found_rows' => true, 'cache_results' => false, 'post_status' => 'publish', 'post_type' => 'post', 'cat' => $id)); update_post_thumbnail_cache($r); if ($r->have_posts()) { while ($r->have_posts()) { $r->the_post(); $output .= "<li><figure><a href='" . get_permalink() . "' title='" . get_the_title() . "'><img src='" . mom_post_image($img_size) . "' alt='menu' width='112' height='75'></a></figure><h2><a href='" . get_permalink() . "' title='" . get_the_title() . "'> " . get_the_title() . "</a></h2></li>"; } // Reset the global $the_post as this query will have stomped on it wp_reset_postdata(); } if (isset($_POST['id'])) { echo $output; } else { return $output; } if (isset($_POST['id'])) { exit; } }
function mom_nb_tabs() { // stay away from bad guys $nonce = $_POST['nonce']; $nbs = $_POST['nbs']; $number_of_posts = $_POST['number_of_posts']; $cat = $_POST['cat']; $orderby = ''; $offset = $_POST['offset']; $nb_excerpt = $_POST['nb_excerpt']; $post_meta_hp = mom_option('post_meta_hp'); if ($post_meta_hp == 1) { $post_head = mom_option('post_head'); $post_head_author = mom_option('post_head_author'); $post_head_date = mom_option('post_head_date'); $post_head_cat = mom_option('post_head_cat'); $post_head_commetns = mom_option('post_head_commetns'); $post_head_views = mom_option('post_head_views'); } else { $post_head = 1; $post_head_author = 1; $post_head_date = 1; $post_head_cat = 1; $post_head_commetns = 1; $post_head_views = 1; } if (!wp_verify_nonce($nonce, 'ajax-nonce')) { die('Nope!'); } ?> <?php if ($nbs == 'nb1') { $query = new WP_Query(array('cat' => $cat, 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'post_status' => 'publish')); update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); ?> <li <?php post_class(); ?> itemscope="" itemtype="http://schema.org/Article"> <?php if (mom_post_image() != false) { ?> <figure class="post-thumbnail"><a href="<?php the_permalink(); ?> "> <?php mom_post_image_full('nb1-thumb'); ?> <span class="post-format-icon"></span> </a></figure> <?php } if (mom_post_image() != false) { $mom_class = ' class="fix-right-content"'; } else { $mom_class = ''; } ?> <div<?php echo $mom_class; ?> > <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <div class="entry-content"> <?php if ($nb_excerpt != '0') { ?> <p> <?php global $post; $excerpt = $post->post_excerpt; if ($excerpt == '') { $excerpt = get_the_content(''); } if ($nb_excerpt == '') { echo wp_html_excerpt(strip_shortcodes($excerpt), 115, '...'); } else { echo wp_html_excerpt(strip_shortcodes($excerpt), $nb_excerpt, '...'); } ?> </p> <?php } ?> </div> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php mom_date_format(); ?> </time> <?php } if ($post_head_commetns != 0) { ?> <div class="comments-link"> <i class="momizat-icon-bubbles4"></i><a href="<?php comments_link(); ?> "><?php comments_number(__('(0) Comments', 'framework'), __('(1) Comment', 'framework'), __('(%) Comments', 'framework')); ?> </a> </div> <?php } ?> </div> <?php } ?> </div> </li> <?php } } else { } wp_reset_postdata(); } elseif ($nbs == 'nb2') { $query = new WP_Query(array('cat' => $cat, 'posts_per_page' => 1, 'orderby' => $orderby, 'post_status' => 'publish')); update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); ?> <div <?php post_class('first-item'); ?> role="article" itemscope="" itemtype="http://schema.org/Article"> <?php if (mom_post_image() != false) { ?> <figure class="post-thumbnail"><a href="<?php the_permalink(); ?> "> <?php mom_post_image_full('nb1-thumb'); ?> <span class="post-format-icon"></span> </a></figure> <?php } if (mom_post_image() != false) { $mom_class = ' class="fix-right-content"'; } else { $mom_class = ''; } ?> <div<?php echo $mom_class; ?> > <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php mom_date_format(); ?> </time> <?php } if ($post_head_commetns != 0) { ?> <div class="comments-link"> <i class="momizat-icon-bubbles4"></i><a href="<?php comments_link(); ?> "><?php comments_number(__('(0) Comments', 'framework'), __('(1) Comment', 'framework'), __('(%) Comments', 'framework')); ?> </a> </div> <?php } ?> </div> <?php } ?> <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <div class="entry-content"> <?php if ($nb_excerpt != '0') { ?> <p> <?php global $post; $excerpt = $post->post_excerpt; if ($excerpt == '') { $excerpt = get_the_content(''); } if ($nb_excerpt == '') { echo wp_html_excerpt(strip_shortcodes($excerpt), 145, '...'); } else { echo wp_html_excerpt(strip_shortcodes($excerpt), $nb_excerpt, '...'); } ?> </p> <?php } ?> </div> </div> </div> <?php } } else { } wp_reset_postdata(); $query = new WP_Query(array('cat' => $cat, 'posts_per_page' => $number_of_posts, 'offset' => $offset, 'orderby' => $orderby, 'post_status' => 'publish')); update_post_thumbnail_cache($query); if ($query->have_posts()) { echo '<ul>'; while ($query->have_posts()) { $query->the_post(); ?> <li role="article" itemscope="" itemtype="http://schema.org/Article"> <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php mom_date_format(); ?> </time> <?php } if ($post_head_commetns != 0) { ?> <div class="comments-link"> <i class="momizat-icon-bubbles4"></i><a href="<?php comments_link(); ?> "><?php comments_number(__('(0) Comments', 'framework'), __('(1) Comment', 'framework'), __('(%) Comments', 'framework')); ?> </a> </div> <?php } ?> </div> <?php } ?> </li> <?php } echo '</ul>'; } else { } wp_reset_postdata(); } elseif ($nbs == 'nb3') { $query = new WP_Query(array('cat' => $cat, 'posts_per_page' => 2, 'orderby' => $orderby, 'post_status' => 'publish')); update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); ?> <div <?php post_class('first-item'); ?> role="article" itemscope="" itemtype="http://schema.org/Article"> <?php if (mom_post_image() != false) { ?> <figure class="post-thumbnail"><a href="<?php the_permalink(); ?> "> <?php mom_post_image_full('nb1-thumb'); ?> <span class="post-format-icon"></span> </a></figure> <?php } if (mom_post_image() != false) { $mom_class = ' class="fix-right-content"'; } else { $mom_class = ''; } ?> <div<?php echo $mom_class; ?> > <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <div class="entry-content"> <?php if ($nb_excerpt != '0') { ?> <p> <?php global $post; $excerpt = $post->post_excerpt; if ($excerpt == '') { $excerpt = get_the_content(''); } if ($nb_excerpt == '') { echo wp_html_excerpt(strip_shortcodes($excerpt), 115, '...'); } else { echo wp_html_excerpt(strip_shortcodes($excerpt), $nb_excerpt, '...'); } ?> </p> <?php } ?> </div> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php mom_date_format(); ?> </time> <?php } if ($post_head_commetns != 0) { ?> <div class="comments-link"> <i class="momizat-icon-bubbles4"></i><a href="<?php comments_link(); ?> "><?php comments_number(__('(0) Comments', 'framework'), __('(1) Comment', 'framework'), __('(%) Comments', 'framework')); ?> </a> </div> <?php } ?> </div> <?php } ?> </div> </div> <?php } } else { } wp_reset_postdata(); $query = new WP_Query(array('cat' => $cat, 'posts_per_page' => $number_of_posts, 'offset' => $offset, 'orderby' => $orderby, 'post_status' => 'publish')); update_post_thumbnail_cache($query); if ($query->have_posts()) { echo '<ul>'; while ($query->have_posts()) { $query->the_post(); ?> <li role="article" itemscope="" itemtype="http://schema.org/Article"> <?php if (mom_post_image() != false) { ?> <figure class="post-thumbnail"><a href="<?php the_permalink(); ?> "> <?php mom_post_image_full('nb3-thumb'); ?> </a></figure> <?php } ?> <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php mom_date_format(); ?> </time> <?php } if ($post_head_commetns != 0) { ?> <div class="comments-link"> <i class="momizat-icon-bubbles4"></i><a href="<?php comments_link(); ?> "><?php comments_number('0', '1', '%'); ?> </a> </div> <?php } ?> </div> <?php } ?> </li> <?php } echo '</ul>'; } else { } wp_reset_postdata(); } elseif ($nbs == 'nb4') { $query = new WP_Query(array('cat' => $cat, 'posts_per_page' => 1, 'orderby' => $orderby, 'post_status' => 'publish')); update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); ?> <div <?php post_class('first-item'); ?> role="article" itemscope="" itemtype="http://schema.org/Article"> <?php if (mom_post_image() != false) { ?> <figure class="post-thumbnail"><a href="<?php the_permalink(); ?> "> <?php mom_post_image_full('nb1-thumb'); ?> <span class="post-format-icon"></span> </a></figure> <?php } if (mom_post_image() != false) { $mom_class = ' class="fix-right-content"'; } else { $mom_class = ''; } ?> <div<?php echo $mom_class; ?> > <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <div class="entry-content"> <?php if ($nb_excerpt != '0') { ?> <p> <?php global $post; $excerpt = $post->post_excerpt; if ($excerpt == '') { $excerpt = get_the_content(''); } if ($nb_excerpt == '') { echo wp_html_excerpt(strip_shortcodes($excerpt), 110, '...'); } else { echo wp_html_excerpt(strip_shortcodes($excerpt), $nb_excerpt, '...'); } ?> </p> <?php } ?> </div> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php mom_date_format(); ?> </time> <?php } if ($post_head_commetns != 0) { ?> <div class="comments-link"> <i class="momizat-icon-bubbles4"></i><a href="<?php comments_link(); ?> "><?php comments_number(__('(0) Comments', 'framework'), __('(1) Comment', 'framework'), __('(%) Comments', 'framework')); ?> </a> </div> <?php } ?> </div> <?php } ?> </div> </div> <?php } } else { } wp_reset_postdata(); $query = new WP_Query(array('cat' => $cat, 'posts_per_page' => $number_of_posts, 'offset' => $offset, 'orderby' => $orderby, 'post_status' => 'publish')); update_post_thumbnail_cache($query); if ($query->have_posts()) { echo '<ul>'; while ($query->have_posts()) { $query->the_post(); ?> <li role="article" itemscope="" itemtype="http://schema.org/Article"> <?php if (mom_post_image() != false) { ?> <figure class="post-thumbnail"><a href="<?php the_permalink(); ?> "> <?php mom_post_image_full('nb3-thumb'); ?> </a></figure> <?php } ?> <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php mom_date_format(); ?> </time> <?php } ?> </div> <?php } ?> </li> <?php } echo '</ul>'; } else { } wp_reset_postdata(); } elseif ($nbs == 'nb5') { $query = new WP_Query(array('cat' => $cat, 'posts_per_page' => 1, 'orderby' => $orderby, 'post_status' => 'publish')); update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); ?> <div <?php post_class('first-item'); ?> role="article" itemscope="" itemtype="http://schema.org/Article"> <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <?php if (mom_post_image() != false) { ?> <figure class="post-thumbnail"><a href="<?php the_permalink(); ?> "> <?php mom_post_image_full('nb5-thumb'); ?> <span class="post-format-icon"></span> </a></figure> <?php } if (mom_post_image() != false) { $mom_class = ' class="fix-right-content"'; } else { $mom_class = ''; } ?> <div<?php echo $mom_class; ?> > <div class="entry-content"> <?php if ($nb_excerpt != '0') { ?> <p> <?php global $post; $excerpt = $post->post_excerpt; if ($excerpt == '') { $excerpt = get_the_content(''); } if ($nb_excerpt == '') { echo wp_html_excerpt(strip_shortcodes($excerpt), 180, '...'); } else { echo wp_html_excerpt(strip_shortcodes($excerpt), $nb_excerpt, '...'); } ?> </p> <?php } ?> </div> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php mom_date_format(); ?> </time> <?php } if ($post_head_commetns != 0) { ?> <div class="comments-link"> <i class="momizat-icon-bubbles4"></i><a href="<?php comments_link(); ?> "><?php comments_number(__('(0) Comments', 'framework'), __('(1) Comment', 'framework'), __('(%) Comments', 'framework')); ?> </a> </div> <?php } ?> </div> <?php } ?> </div> </div> <?php } } else { } wp_reset_postdata(); $query = new WP_Query(array('cat' => $cat, 'posts_per_page' => $number_of_posts, 'offset' => $offset, 'orderby' => $orderby, 'post_status' => 'publish')); update_post_thumbnail_cache($query); if ($query->have_posts()) { echo '<ul>'; while ($query->have_posts()) { $query->the_post(); ?> <li role="article" itemscope="" itemtype="http://schema.org/Article"> <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php mom_date_format(); ?> </time> <?php } if ($post_head_commetns != 0) { ?> <div class="comments-link"> <i class="momizat-icon-bubbles4"></i><a href="<?php comments_link(); ?> "><?php comments_number(__('(0) Comments', 'framework'), __('(1) Comment', 'framework'), __('(%) Comments', 'framework')); ?> </a> </div> <?php } ?> </div> <?php } ?> </li> <?php } echo '</ul>'; } else { } wp_reset_postdata(); } elseif ($nbs == 'nb6') { $query = new WP_Query(array('cat' => $cat, 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'post_status' => 'publish')); update_post_thumbnail_cache($query); if ($query->have_posts()) { echo '<ul>'; while ($query->have_posts()) { $query->the_post(); ?> <li <?php post_class(); ?> role="article" itemscope="" itemtype="http://schema.org/Article"> <?php if (mom_post_image() != false) { ?> <figure class="post-thumbnail"><a href="<?php the_permalink(); ?> "> <?php mom_post_image_full('scroller-thumb'); ?> <span class="post-format-icon"></span> </a></figure> <?php } if (mom_post_image() != false) { $mom_class = ' class="fix-right-content"'; } else { $mom_class = ''; } ?> <div<?php echo $mom_class; ?> > <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <div class="entry-content"> <?php if ($nb_excerpt != '0') { ?> <p> <?php global $post; $excerpt = $post->post_excerpt; if ($excerpt == '') { $excerpt = get_the_content(''); } if ($nb_excerpt == '') { echo wp_html_excerpt(strip_shortcodes($excerpt), 120, '...'); } else { echo wp_html_excerpt(strip_shortcodes($excerpt), $nb_excerpt, '...'); } ?> </p> <?php } ?> </div> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php mom_date_format(); ?> </time> <?php } if ($post_head_commetns != 0) { ?> <div class="comments-link"> <i class="momizat-icon-bubbles4"></i><a href="<?php comments_link(); ?> "><?php comments_number('0', '1', '%'); ?> </a> </div> <?php } ?> </div> <?php } ?> </div> </li> <?php } echo '</ul>'; } else { } wp_reset_postdata(); } elseif ($nbs == 'list') { $query = new WP_Query(array('cat' => $cat, 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'post_status' => 'publish')); update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); ?> <li <?php post_class(); ?> itemscope="" itemtype="http://schema.org/Article"> <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <div class="entry-content"> <?php if ($nb_excerpt != '0') { ?> <p> <?php global $post; $excerpt = $post->post_excerpt; if ($excerpt == '') { $excerpt = get_the_content(''); } if ($nb_excerpt == '') { echo wp_html_excerpt(strip_shortcodes($excerpt), 115, '...'); } else { echo wp_html_excerpt(strip_shortcodes($excerpt), $nb_excerpt, '...'); } ?> </p> <?php } ?> </div> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php mom_date_format(); ?> </time> <?php } if ($post_head_cat != 0) { ?> <span class="cat-link"> <i class="momizat-icon-folder-open"></i><?php the_category(', '); ?> </span> <?php } if ($post_head_commetns != 0) { ?> <span class="comments-link"> <i class="momizat-icon-bubbles4"></i><a href="<?php comments_link(); ?> "><?php comments_number(__('(0) Comments', 'framework'), __('(1) Comment', 'framework'), __('(%) Comments', 'framework')); ?> </a> </span> <?php } ?> <div class="clear"></div> </div> <?php } ?> </li> <?php } } else { } wp_reset_postdata(); } exit; }
function mom_timeline_posts($count = 10, $author = '', $excat = '', $cats = '', $order = '') { $post_meta_hp = mom_option('post_meta_hp'); if ($post_meta_hp == 1) { $post_head = mom_option('post_head'); $post_head_author = mom_option('post_head_author'); $post_head_date = mom_option('post_head_date'); $post_head_cat = mom_option('post_head_cat'); $post_head_commetns = mom_option('post_head_commetns'); $post_head_views = mom_option('post_head_views'); } else { $post_head = 1; $post_head_author = 1; $post_head_date = 1; $post_head_cat = 1; $post_head_commetns = 1; $post_head_views = 1; } if (is_singular()) { global $post; $display = get_post_meta($post->ID, 'mom_timeline_display', true); } else { $display = ''; } $last_month = 0; $offset = isset($_POST['offset']) ? $_POST['offset'] : ''; if (isset($_POST['count'])) { $count = $_POST['count']; } if (isset($_POST['author'])) { $author = $_POST['author']; } if (isset($_POST['excat'])) { $excat = $_POST['excat']; } if (isset($_POST['display'])) { $display = $_POST['display']; } if (isset($_POST['cats'])) { $cats = $_POST['cats']; } if (isset($_POST['order'])) { $order = $_POST['order']; } if ($display == 'cat') { $query = new WP_Query(array('post_type' => 'post', "ignore_sticky_posts" => 1, 'cache_results' => false, 'no_found_rows' => true, 'post_status' => 'publish', 'offset' => $offset, 'posts_per_page' => $count, 'author' => $author, 'cat' => $cats, 'orderby' => $order)); } else { $query = new WP_Query(array('post_type' => 'post', "ignore_sticky_posts" => 1, 'cache_results' => false, 'no_found_rows' => true, 'post_status' => 'publish', 'offset' => $offset, 'posts_per_page' => $count, 'author' => $author, 'cat' => $excat, 'orderby' => $order)); } update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $month = get_the_time('n'); $year = get_the_time('Y'); $p_month = get_the_time('F'); global $post; $single = $post; if ($month != $last_month) { echo "</ul><span class='blog-timeline-date'>{$p_month}, {$year}</span><ul class='tl-posts'>"; $last_month = $month; } ?> <li class="nb5"> <div <?php post_class('first-item', $single->ID); ?> role="article" itemscope="" itemtype="http://schema.org/Article"> <h2 itemprop="name"><a itemprop="url" href="<?php echo get_permalink($single->ID); ?> "><?php echo get_the_title($single->ID); ?> </a></h2> <?php if (mom_post_image('', '', $single->ID) != false) { ?> <figure class="post-thumbnail"><a href="<?php echo get_permalink($single->ID); ?> "> <?php mom_post_image_full('nb5-thumb', $single->ID); ?> <span class="post-format-icon"></span> </a></figure> <?php } ?> <?php if (mom_post_image() != false) { $mom_class = ' class="fix-right-content"'; } else { $mom_class = ''; } ?> <div<?php echo $mom_class; ?> > <div class="entry-content"> <p> <?php $excerpt = get_the_excerpt(); if ($excerpt == '') { $excerpt = get_the_content(); } echo wp_html_excerpt(strip_shortcodes($excerpt), 100); ?> ... </p> </div> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php echo mysql2date(mom_option('date_format'), $single->post_date); ?> </time> <?php } ?> <?php if ($post_head_commetns != 0) { ?> <div class="comments-link"> <i class="momizat-icon-bubbles4"></i><a href="<?php echo get_permalink($single->ID); ?> "> <?php $num_comments = get_comments_number($single->ID); // get_comments_number returns only a numeric value if (comments_open()) { if ($num_comments == 0) { $comments = __('0 Comments', 'framework'); } elseif ($num_comments > 1) { $comments = $num_comments . __(' Comments', 'framework'); } else { $comments = __('1 Comment', 'framework'); } $write_comments = '<a class="comment_number" href="' . get_comments_link($single->ID) . '">' . $comments . '</a>'; } else { //$write_comments = __('Comments off', 'framework'); $write_comments = ''; } ?> <?php echo $write_comments; ?> </a> </div> <?php } ?> </div> <?php } ?> </div> </div> </li> <?php } ?> </ul> <?php } else { } wp_reset_postdata(); if (isset($_POST['offset'])) { exit; } }
public static function get_template_query() { $config = Presscore_Config::get_instance(); $order = $config->get('order'); $orderby = $config->get('orderby'); $display = $config->get('display'); $ppp = $config->get('posts_per_page'); $query_args = array('post_type' => self::$post_type, 'post_status' => 'publish', 'paged' => dt_get_paged_var(), 'order' => $order, 'orderby' => 'name' == $orderby ? 'title' : $orderby); if ($ppp) { $query_args['posts_per_page'] = intval($ppp); } if ('all' != $display['select']) { $query_args['tax_query'] = array(array('taxonomy' => self::$taxonomy, 'field' => 'term_id', 'terms' => array_values($display['terms_ids']))); switch ($display['select']) { case 'only': $query_args['tax_query'][0]['operator'] = 'IN'; break; case 'except': $query_args['tax_query'][0]['operator'] = 'NOT IN'; } } $query = new WP_Query($query_args); update_post_thumbnail_cache($query); return $query; }
function widget($args, $instance) { extract($args); /* User-selected settings. */ $title = apply_filters('widget_title', $instance['title']); $orderby = $instance['orderby']; $count = $instance['count']; $display = $instance['display']; $cats = isset($instance['cats']) ? $instance['cats'] : array(); $layout = isset($instance['layout']) ? $instance['layout'] : ''; $sidebar_size = isset($instance['sidebar_size']) ? $instance['sidebar_size'] : ''; $tag = isset($instance['tag']) ? $instance['tag'] : ''; $output = get_transient('mom-posts-widget-' . $this->id); if ($orderby == 'random') { $output = false; } if ($output == false) { ob_start(); /* Before widget (defined by themes). */ echo $before_widget; /* Title of widget (before and after defined by themes). */ if ($title) { echo $before_title . $title . $after_title; } ?> <ul class="post-list jw2 <?php echo $layout; ?> "> <?php global $unique_posts; global $do_unique_posts; $dateformat = mom_option('date_format'); $post_meta_hp = mom_option('post_meta_hp'); if ($post_meta_hp == 1) { $post_head = mom_option('post_head'); $post_head_author = mom_option('post_head_author'); $post_head_date = mom_option('post_head_date'); $post_head_cat = mom_option('post_head_cat'); $post_head_commetns = mom_option('post_head_commetns'); $post_head_views = mom_option('post_head_views'); } else { $post_head = 1; $post_head_author = 1; $post_head_date = 1; $post_head_cat = 1; $post_head_commetns = 1; $post_head_views = 1; } if ($orderby == 'popular') { if ($display == 'cats') { $catsi = implode(',', $cats); $args = array("ignore_sticky_posts" => 1, 'posts_per_page' => $count, 'cache_results' => false, 'no_found_rows' => true, 'post__not_in' => $do_unique_posts, "orderby" => "comment_count", 'cat' => $catsi); } elseif ($display == 'tag') { $args = array("ignore_sticky_posts" => 1, 'posts_per_page' => $count, 'cache_results' => false, 'no_found_rows' => true, 'post__not_in' => $do_unique_posts, "orderby" => "comment_count", 'tag' => $tag); } else { $args = array("ignore_sticky_posts" => 1, 'posts_per_page' => $count, 'cache_results' => false, 'no_found_rows' => true, 'post__not_in' => $do_unique_posts, "orderby" => "comment_count"); } } elseif ($orderby == 'random') { if ($display == 'cats') { $catsi = implode(',', $cats); $args = array("ignore_sticky_posts" => 1, 'posts_per_page' => $count, 'cache_results' => false, 'no_found_rows' => true, 'post__not_in' => $do_unique_posts, "orderby" => "rand", 'cat' => $catsi); } elseif ($display == 'tag') { $args = array("ignore_sticky_posts" => 1, 'posts_per_page' => $count, 'cache_results' => false, 'no_found_rows' => true, 'post__not_in' => $do_unique_posts, "orderby" => "rand", 'tag' => $tag); } else { $args = array("ignore_sticky_posts" => 1, 'posts_per_page' => $count, 'cache_results' => false, 'no_found_rows' => true, 'post__not_in' => $do_unique_posts, "orderby" => "rand"); } } elseif ($orderby == 'views') { $views_key = 'post_views_count'; if (function_exists('the_views')) { $views_key = 'views'; } if ($display == 'cats') { $catsi = implode(',', $cats); $args = array("ignore_sticky_posts" => 1, 'posts_per_page' => $count, 'cache_results' => false, 'no_found_rows' => true, 'post__not_in' => $do_unique_posts, 'cat' => $catsi, 'meta_key' => $views_key, 'orderby' => 'meta_value_num', 'order' => 'DESC'); } elseif ($display == 'tag') { $args = array("ignore_sticky_posts" => 1, 'posts_per_page' => $count, 'cache_results' => false, 'no_found_rows' => true, 'post__not_in' => $do_unique_posts, 'tag' => $tag, 'meta_key' => $views_key, 'orderby' => 'meta_value_num', 'order' => 'DESC'); } else { $args = array("ignore_sticky_posts" => 1, 'posts_per_page' => $count, 'cache_results' => false, 'no_found_rows' => true, 'post__not_in' => $do_unique_posts, 'meta_key' => $views_key, 'orderby' => 'meta_value_num', 'order' => 'DESC'); } } else { if ($display == 'cats') { $catsi = implode(',', $cats); $args = array("ignore_sticky_posts" => 1, 'posts_per_page' => $count, 'cache_results' => false, 'no_found_rows' => true, 'post__not_in' => $do_unique_posts, 'cat' => $catsi); } elseif ($display == 'tag') { $args = array("ignore_sticky_posts" => 1, 'posts_per_page' => $count, 'cache_results' => false, 'no_found_rows' => true, 'post__not_in' => $do_unique_posts, 'tag' => $tag); } else { $args = array("ignore_sticky_posts" => 1, 'posts_per_page' => $count, 'cache_results' => false, 'no_found_rows' => true, 'post__not_in' => $do_unique_posts); } } // JWOOL - added for custom post types $args['post_type'] = array('post', 'appearance', 'program'); $query = new WP_Query($args); update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); if ($unique_posts) { $do_unique_posts[] = get_the_ID(); } if ($sidebar_size == 'small') { $img_size = 'postlist-thumb'; if ($layout == 'full') { $img_size = 'postlist-thumb'; } } elseif ($sidebar_size == 'big') { $img_size = 'postpicwid-thumb'; if ($layout == 'full') { $img_size = 'sliderwidget-thumb'; } } else { $img_size = 'postlist-thumb'; if ($layout == 'full') { $img_size = 'sliderwidget-thumb'; } } ?> <li itemscope="" itemtype="http://schema.org/Article"> <?php if (mom_post_image() != false) { ?> <figure class="post-thumbnail"><a itemprop="url" href="<?php the_permalink(); ?> " rel="bookmark"> <?php mom_post_image_full($img_size); ?> </a></figure> <?php } ?> <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> " rel="bookmark"><?php the_title(); ?> </a></h2> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php the_time($dateformat); ?> </time> <?php } ?> <?php if ($post_head_commetns != 0) { ?> <div class="comments-link"> <i class="momizat-icon-bubbles4"></i><a href="<?php the_permalink(); ?> "><?php comments_number(__('(0) Comments', 'framework'), __('(1) Comment', 'framework'), __('(%) Comments', 'framework')); ?> </a> </div> <?php } ?> </div> <?php } ?> <a href="<?php the_permalink(); ?> " class="read-more-link"><?php _e('Read more...', 'framework'); ?> </a> </li> <?php } ?> <?php } else { ?> <!-- Else in here --> <?php } ?> <?php wp_reset_query(); ?> </ul> <?php /* After widget (defined by themes). */ echo $after_widget; $output = ob_get_contents(); ob_end_clean(); set_transient('mom-posts-widget-' . $this->id, $output, 60 * 60 * 24); } echo $output; }
/** * Get related posts attachments data slightly modified. * * @return array Attachments data. */ function presscore_get_related_posts($options = array()) { $default_options = array('select' => 'only', 'exclude_current' => true, 'args' => array()); $options = wp_parse_args($options, $default_options); // exclude current post if in the loop if (in_the_loop() && $options['exclude_current']) { $options['args'] = array_merge($options['args'], array('post__not_in' => array(get_the_ID()))); } $posts = presscore_get_posts_in_categories($options); update_post_thumbnail_cache($posts); $attachments_ids = array(); $attachments_data_override = array(); $posts_data = array(); // get posts attachments id if ($posts->have_posts()) { global $post; $post_back = $post; while ($posts->have_posts()) { $posts->the_post(); // thumbnail or first attachment id if (has_post_thumbnail()) { $attachment_id = get_post_thumbnail_id(); } else { if ($attachment = presscore_get_first_image()) { $attachment_id = $attachment->ID; } else { $attachment_id = 0; } } switch (get_post_type()) { case 'post': $post_meta = presscore_new_posted_on('post'); break; case 'dt_portfolio': $post_meta = presscore_new_posted_on('dt_portfolio'); break; default: $post_meta = presscore_new_posted_on(); } $post_data = array(); ///////////////////////// // attachment data // ///////////////////////// $post_data['full'] = $post_data['width'] = $post_data['height'] = ''; $meta = wp_get_attachment_image_src($attachment_id, 'full'); if (!empty($meta)) { $post_data['full'] = esc_url($meta[0]); $post_data['width'] = absint($meta[1]); $post_data['height'] = absint($meta[2]); } $post_data['thumbnail'] = wp_get_attachment_image_src($attachment_id, 'thumbnail'); $post_data['caption'] = ''; $post_data['video_url'] = esc_url(get_post_meta($attachment_id, 'dt-video-url', true)); $post_data['mime_type_full'] = get_post_mime_type($attachment_id); $post_data['mime_type'] = dt_get_short_post_myme_type($attachment_id); $post_data['ID'] = $attachment_id; $post_data['image_attachment_data'] = array('caption' => $post_data['caption'], 'description' => wp_kses_post(get_post_field('post_content', $attachment_id)), 'title' => presscore_imagee_title_is_hidden($attachment_id) ? '' : get_the_title($attachment_id), 'permalink' => get_permalink($attachment_id), 'video_url' => $post_data['video_url'], 'ID' => $attachment_id); /////////////////// // post data // /////////////////// $post_data['title'] = get_the_title(); $post_data['permalink'] = get_permalink(); $post_data['link'] = presscore_get_project_link('project-link'); $post_data['description'] = get_the_excerpt(); $post_data['alt'] = get_the_title(); $post_data['parent_id'] = get_the_ID(); $post_data['meta'] = $post_meta; // save data $posts_data[] = $post_data; } $post = $post_back; setup_postdata($post); } return $posts_data; }
<!-- Content --> <div id="content" class="content" role="main"> <?php if (have_posts()) { ?> <div class="articles-list"> <?php do_action('presscore_before_loop'); ?> <?php update_post_thumbnail_cache(); ?> <?php while (have_posts()) { the_post(); ?> <?php // populate config with current post settings presscore_populate_post_config(); presscore_get_template_part('theme', 'blog/list/blog-list-post'); ?> <?php }
/** * Retrieve Post Thumbnail. * * @since 2.9.0 * * @param int $post_id Optional. Post ID. * @param string $size Optional. Image size. Defaults to 'post-thumbnail'. * @param string|array $attr Optional. Query string or array of attributes. */ function get_the_post_thumbnail($post_id = null, $size = 'post-thumbnail', $attr = '') { $post_id = null === $post_id ? get_the_ID() : $post_id; $post_thumbnail_id = get_post_thumbnail_id($post_id); /** * Filter the post thumbnail size. * * @since 2.9.0 * * @param string $size The post thumbnail size. */ $size = apply_filters('post_thumbnail_size', $size); if ($post_thumbnail_id) { /** * Fires before fetching the post thumbnail HTML. * * Provides "just in time" filtering of all filters in wp_get_attachment_image(). * * @since 2.9.0 * * @param string $post_id The post ID. * @param string $post_thumbnail_id The post thumbnail ID. * @param string $size The post thumbnail size. */ do_action('begin_fetch_post_thumbnail_html', $post_id, $post_thumbnail_id, $size); if (in_the_loop()) { update_post_thumbnail_cache(); } $html = wp_get_attachment_image($post_thumbnail_id, $size, false, $attr); /** * Fires after fetching the post thumbnail HTML. * * @since 2.9.0 * * @param string $post_id The post ID. * @param string $post_thumbnail_id The post thumbnail ID. * @param string $size The post thumbnail size. */ do_action('end_fetch_post_thumbnail_html', $post_id, $post_thumbnail_id, $size); } else { $html = ''; } /** * Filter the post thumbnail HTML. * * @since 2.9.0 * * @param string $html The post thumbnail HTML. * @param string $post_id The post ID. * @param string $post_thumbnail_id The post thumbnail ID. * @param string $size The post thumbnail size. * @param string $attr Query string of attributes. */ return apply_filters('post_thumbnail_html', $html, $post_id, $post_thumbnail_id, $size, $attr); }
/** * Update post thumbnail cache for $query. * * @param WP_Query $query */ function presscore_update_post_thumbnail_cache($query) { if ($query->have_posts()) { update_post_thumbnail_cache($query); } }
function mom_news_boxes($atts, $content = null) { global $unique_posts; global $do_unique_posts; extract(shortcode_atts(array('style' => 'nb1', 'title' => '', 'display' => '', 'cat' => '', 'tag' => '', 'number_of_posts' => '4', 'orderby' => '', 'order' => '', 'nb_excerpt' => '', 'sub_categories' => 'no', 'show_more' => 'yes', 'show_more_event' => '', 'post_type' => '', 'exclude_posts' => '', 'class' => ''), $atts)); global $post; $exclude_posts = array($post->ID); $ajax_class = ''; if ($show_more_event == 'ajax') { $ajax_class = 'show_more_ajax'; } if ($style == 'nb6' && $number_of_posts == '4') { $number_of_posts = '3'; } static $id = 75; $id++; if ($cat == 'Select a Category') { $cat = ''; } if ($tag == 'Select a Tag') { $tag = ''; } $head_colors = ''; $head_class = ''; if ($display == 'category' && mom_option('nb_skin') == 'color') { $cat_color = get_option("category_" . $cat); $cat_color = isset($cat_color['color']) ? $cat_color['color'] : ''; if ($cat_color) { $head_colors .= 'style="'; $head_colors .= 'background-color:' . $cat_color . ';'; $head_colors .= '"'; $head_class = 'colorful-box'; } } $output = get_transient('mom_news_boxes_' . $id . $style . $display . $cat . $tag . $orderby . $show_more_event . $post_type); if ($orderby == 'rand') { $output = false; } $output = false; if ($output == false) { ob_start(); $dateformat = mom_option('date_format'); global $wpdb; $tag_ID = $wpdb->get_var("SELECT * FROM " . $wpdb->terms . " WHERE `name` = '" . $tag . "'"); if ($display == 'category') { if ($title == '') { $nb_title = get_cat_name($cat); } else { $nb_title = $title; } $nb_link = get_category_link($cat); } elseif ($display == 'tag') { if ($title == '') { $nb_title = $tag; } else { $nb_title = $title; } $nb_link = get_tag_link($tag_ID); } else { $nb_title = $title; $nb_link = '#'; } $sm_Atts = 'data-display="' . $display . '" data-nbs="' . $style . '" data-number_of_posts="' . $number_of_posts . '" data-cat_id="' . $cat . '" data-nb_excerpt="' . $nb_excerpt . '" data-tag="' . $tag . '"'; $post_meta_hp = mom_option('post_meta_hp'); /* if ($post_meta_hp === null) { $post_meta_hp = 1; } */ if ($post_meta_hp == 1) { $post_head = mom_option('post_head'); $post_head_author = mom_option('post_head_author'); $post_head_date = mom_option('post_head_date'); $post_head_cat = mom_option('post_head_cat'); $post_head_commetns = mom_option('post_head_commetns'); $post_head_views = mom_option('post_head_views'); } else { $post_head = 1; $post_head_author = 1; $post_head_date = 1; $post_head_cat = 1; $post_head_commetns = 1; $post_head_views = 1; } ?> <?php if ($style == 'nb2') { ?> <section class="section news-box <?php if ($display == 'category') { ?> cat_<?php echo $cat; } ?> <?php echo $class; ?> "><!--News box 2--> <header class="block-title <?php echo $head_class; ?> " <?php echo $head_colors; ?> > <h2><a href="<?php echo $nb_link; ?> "><?php echo $nb_title; ?> </a></h2> <?php mom_nb_head($style, $cat, $display, $number_of_posts, $sub_categories, $orderby, $nb_excerpt); ?> </header> <div class="nb2"> <?php if ($display == 'category') { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'cat' => $cat, 'posts_per_page' => 1, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } elseif ($display == 'tag') { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'tag' => $tag, 'posts_per_page' => 1, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } else { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'posts_per_page' => 1, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); if ($unique_posts) { $do_unique_posts[] = get_the_ID(); } ?> <div <?php post_class('first-item'); ?> role="article" itemscope="" itemtype="http://schema.org/Article"> <?php if (mom_post_image() != false) { ?> <figure class="post-thumbnail"><a href="<?php the_permalink(); ?> "> <?php mom_post_image_full('nb1-thumb'); ?> <span class="post-format-icon"></span> </a></figure> <?php } ?> <?php if (mom_post_image() != false) { $mom_class = ' class="fix-right-content"'; } else { $mom_class = ''; } ?> <div<?php echo $mom_class; ?> > <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php mom_date_format(); ?> </time> <?php } ?> <?php if ($post_head_commetns != 0) { ?> <div class="comments-link"> <i class="momizat-icon-bubbles4"></i><a href="<?php comments_link(); ?> "><?php comments_number(__('(0) Comments', 'framework'), __('(1) Comment', 'framework'), __('(%) Comments', 'framework')); ?> </a> </div> <?php } ?> </div> <?php } ?> <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <div class="entry-content"> <?php if ($nb_excerpt != '0') { ?> <p> <?php global $post; $excerpt = $post->post_excerpt; if ($excerpt == '') { $excerpt = get_the_content(''); } if ($nb_excerpt == '') { echo wp_html_excerpt(strip_shortcodes($excerpt), 145, '...'); } else { echo wp_html_excerpt(strip_shortcodes($excerpt), $nb_excerpt, '...'); } ?> </p> <?php } ?> </div> </div> </div> <?php } } else { } wp_reset_postdata(); ?> <ul> <?php if ($display == 'category') { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'cat' => $cat, 'posts_per_page' => $number_of_posts, 'offset' => 1, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } elseif ($display == 'tag') { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'tag' => $tag, 'posts_per_page' => $number_of_posts, 'offset' => 1, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } else { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'posts_per_page' => $number_of_posts, 'offset' => 1, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); if ($unique_posts) { $do_unique_posts[] = get_the_ID(); } ?> <li role="article" itemscope="" itemtype="http://schema.org/Article"> <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><?php mom_date_format(); ?> </time> <?php } ?> <?php if ($post_head_commetns != 0) { ?> <div class="comments-link"> <a href="<?php comments_link(); ?> "><?php comments_number(__('(0) Comments', 'framework'), __('(1) Comment', 'framework'), __('(%) Comments', 'framework')); ?> </a> </div> <?php } ?> </div> <?php } ?> </li> <?php } } else { } wp_reset_postdata(); ?> </ul> </div> <?php if ($show_more != 'no') { ?> <footer class="newb2 show-more <?php echo $ajax_class; ?> " <?php echo $sm_Atts; ?> > <a href="<?php echo $nb_link; ?> " data-post_type="<?php echo $post_type; ?> " data-offset="<?php echo absint($number_of_posts + 1); ?> " data-orig-offset="<?php echo absint($number_of_posts + 1); ?> "><?php _e('Show More News', 'framework'); ?> </a> </footer> <?php } ?> </section><!--News box 2--> <?php } elseif ($style == 'nb3') { ?> <section class="section news-box <?php if ($display == 'category') { ?> cat_<?php echo $cat; } ?> <?php echo $class; ?> "><!--News box 3--> <header class="block-title <?php echo $head_class; ?> " <?php echo $head_colors; ?> > <h2><a href="<?php echo $nb_link; ?> "><?php echo $nb_title; ?> </a></h2> <?php mom_nb_head($style, $cat, $display, $number_of_posts, $sub_categories, $orderby, $nb_excerpt); ?> </header> <div class="nb3"> <?php if ($display == 'category') { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'cat' => $cat, 'posts_per_page' => 2, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } elseif ($display == 'tag') { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'tag' => $tag, 'posts_per_page' => 2, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } else { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'posts_per_page' => 2, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); if ($unique_posts) { $do_unique_posts[] = get_the_ID(); } ?> <div <?php post_class('first-item'); ?> role="article" itemscope="" itemtype="http://schema.org/Article"> <?php if (mom_post_image() != false) { ?> <figure class="post-thumbnail"><a href="<?php the_permalink(); ?> "> <?php mom_post_image_full('nb1-thumb'); ?> <span class="post-format-icon"></span> </a></figure> <?php } ?> <?php if (mom_post_image() != false) { $mom_class = ' class="fix-right-content"'; } else { $mom_class = ''; } ?> <div<?php echo $mom_class; ?> > <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <div class="entry-content"> <?php if ($nb_excerpt != '0') { ?> <p> <?php global $post; $excerpt = $post->post_excerpt; if ($excerpt == '') { $excerpt = get_the_content(''); } if ($nb_excerpt == '') { echo wp_html_excerpt(strip_shortcodes($excerpt), 115, '...'); } else { echo wp_html_excerpt(strip_shortcodes($excerpt), $nb_excerpt, '...'); } ?> </p> <?php } ?> </div> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php mom_date_format(); ?> </time> <?php } ?> <?php if ($post_head_commetns != 0) { ?> <div class="comments-link"> <i class="momizat-icon-bubbles4"></i><a href="<?php comments_link(); ?> "><?php comments_number(__('(0) Comments', 'framework'), __('(1) Comment', 'framework'), __('(%) Comments', 'framework')); ?> </a> </div> <?php } ?> </div> <?php } ?> </div> </div> <?php } } else { } wp_reset_postdata(); ?> <ul> <?php if ($display == 'category') { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'cat' => $cat, 'posts_per_page' => $number_of_posts, 'offset' => 2, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } elseif ($display == 'tag') { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'tag' => $tag, 'posts_per_page' => $number_of_posts, 'offset' => 2, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } else { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'posts_per_page' => $number_of_posts, 'offset' => 2, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); if ($unique_posts) { $do_unique_posts[] = get_the_ID(); } ?> <li role="article" itemscope="" itemtype="http://schema.org/Article"> <?php if (mom_post_image() != false) { ?> <figure class="post-thumbnail"><a href="<?php the_permalink(); ?> "> <?php mom_post_image_full('nb3-thumb'); ?> </a></figure> <?php } ?> <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php mom_date_format(); ?> </time> <?php } ?> <?php if ($post_head_commetns != 0) { ?> <div class="comments-link"> <i class="momizat-icon-bubbles4"></i><a href="<?php comments_link(); ?> "><?php comments_number('0', '1', '%'); ?> </a> </div> <?php } ?> </div> <?php } ?> </li> <?php } } else { } wp_reset_postdata(); ?> </ul> </div> <?php if ($show_more != 'no') { ?> <footer class="show-more <?php echo $ajax_class; ?> " <?php echo $sm_Atts; ?> > <a href="<?php echo $nb_link; ?> " data-post_type="<?php echo $post_type; ?> " data-offset="<?php echo absint($number_of_posts + 2); ?> " data-orig-offset="<?php echo absint($number_of_posts + 2); ?> "><?php _e('Show More News', 'framework'); ?> </a> </footer> <?php } ?> </section><!--News box 3--> <?php } elseif ($style == 'nb4') { ?> <section class="section news-box <?php if ($display == 'category') { ?> cat_<?php echo $cat; } ?> <?php echo $class; ?> "><!--News box 4--> <header class="block-title <?php echo $head_class; ?> " <?php echo $head_colors; ?> > <h2><a href="<?php echo $nb_link; ?> "><?php echo $nb_title; ?> </a></h2> <?php mom_nb_head($style, $cat, $display, $number_of_posts, $sub_categories, $orderby, $nb_excerpt); ?> </header> <div class="nb4"> <?php if ($display == 'category') { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'cat' => $cat, 'posts_per_page' => 1, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } elseif ($display == 'tag') { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'tag' => $tag, 'posts_per_page' => 1, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } else { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'posts_per_page' => 1, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); if ($unique_posts) { $do_unique_posts[] = get_the_ID(); } ?> <div <?php post_class('first-item'); ?> role="article" itemscope="" itemtype="http://schema.org/Article"> <?php if (mom_post_image() != false) { ?> <figure class="post-thumbnail"><a href="<?php the_permalink(); ?> "> <?php mom_post_image_full('nb1-thumb'); ?> <span class="post-format-icon"></span> </a></figure> <?php } ?> <?php if (mom_post_image() != false) { $mom_class = ' class="fix-right-content"'; } else { $mom_class = ''; } ?> <div<?php echo $mom_class; ?> > <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <div class="entry-content"> <?php if ($nb_excerpt != '0') { ?> <p> <?php global $post; $excerpt = $post->post_excerpt; if ($excerpt == '') { $excerpt = get_the_content(''); } if ($nb_excerpt == '') { echo wp_html_excerpt(strip_shortcodes($excerpt), 110, '...'); } else { echo wp_html_excerpt(strip_shortcodes($excerpt), $nb_excerpt, '...'); } ?> </p> <?php } ?> </div> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php mom_date_format(); ?> </time> <?php } ?> <?php if ($post_head_commetns != 0) { ?> <div class="comments-link"> <i class="momizat-icon-bubbles4"></i><a href="<?php comments_link(); ?> "><?php comments_number(__('(0) Comments', 'framework'), __('(1) Comment', 'framework'), __('(%) Comments', 'framework')); ?> </a> </div> <?php } ?> </div> <?php } ?> </div> </div> <?php } } else { } wp_reset_postdata(); ?> <ul> <?php if ($display == 'category') { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'cat' => $cat, 'posts_per_page' => $number_of_posts, 'offset' => 1, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } elseif ($display == 'tag') { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'tag' => $tag, 'posts_per_page' => $number_of_posts, 'offset' => 1, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } else { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'posts_per_page' => $number_of_posts, 'offset' => 1, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); if ($unique_posts) { $do_unique_posts[] = get_the_ID(); } ?> <li role="article" itemscope="" itemtype="http://schema.org/Article"> <?php if (mom_post_image() != false) { ?> <figure class="post-thumbnail"><a href="<?php the_permalink(); ?> "> <?php mom_post_image_full('nb3-thumb'); ?> </a></figure> <?php } ?> <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php mom_date_format(); ?> </time> <?php } ?> <!-- <div class="comments-link"> <a href="<?php comments_link(); ?> "><?php comments_number(__('(0) Comments', 'framework'), __('(1) Comment', 'framework'), __('(%) Comments', 'framework')); ?> </a> </div> --> </div> <?php } ?> </li> <?php } } else { } wp_reset_postdata(); ?> </ul> </div> <?php if ($show_more != 'no') { ?> <footer class="show-more <?php echo $ajax_class; ?> " <?php echo $sm_Atts; ?> > <a href="<?php echo $nb_link; ?> " data-post_type="<?php echo $post_type; ?> " data-offset="<?php echo absint($number_of_posts + 1); ?> " data-orig-offset="<?php echo absint($number_of_posts + 1); ?> "><?php _e('Show More News', 'framework'); ?> </a> </footer> <?php } ?> </section><!--News box 4--> <?php } elseif ($style == 'nb5') { ?> <section class="section news-box <?php if ($display == 'category') { ?> cat_<?php echo $cat; } ?> <?php echo $class; ?> "><!--News box 5--> <header class="block-title <?php echo $head_class; ?> " <?php echo $head_colors; ?> > <h2><a href="<?php echo $nb_link; ?> "><?php echo $nb_title; ?> </a></h2> <?php mom_nb_head($style, $cat, $display, $number_of_posts, $sub_categories, $orderby, $nb_excerpt); ?> </header> <div class="nb5"> <?php if ($display == 'category') { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'cat' => $cat, 'posts_per_page' => 1, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } elseif ($display == 'tag') { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'tag' => $tag, 'posts_per_page' => 1, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } else { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'posts_per_page' => 1, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); if ($unique_posts) { $do_unique_posts[] = get_the_ID(); } ?> <div <?php post_class('first-item'); ?> role="article" itemscope="" itemtype="http://schema.org/Article"> <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <?php if (mom_post_image() != false) { ?> <figure class="post-thumbnail"><a href="<?php the_permalink(); ?> "> <?php mom_post_image_full('nb5-thumb'); ?> <span class="post-format-icon"></span> </a></figure> <?php } ?> <?php if (mom_post_image() != false) { $mom_class = ' class="fix-right-content"'; } else { $mom_class = ''; } ?> <div<?php echo $mom_class; ?> > <div class="entry-content"> <?php if ($nb_excerpt != '0') { ?> <p> <?php global $post; $excerpt = $post->post_excerpt; if ($excerpt == '') { $excerpt = get_the_content(''); } if ($nb_excerpt == '') { echo wp_html_excerpt(strip_shortcodes($excerpt), 180, '...'); } else { echo wp_html_excerpt(strip_shortcodes($excerpt), $nb_excerpt, '...'); } ?> </p> <?php } ?> </div> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php mom_date_format(); ?> </time> <?php } ?> <?php if ($post_head_commetns != 0) { ?> <div class="comments-link"> <i class="momizat-icon-bubbles4"></i><a href="<?php comments_link(); ?> "><?php comments_number(__('(0) Comments', 'framework'), __('(1) Comment', 'framework'), __('(%) Comments', 'framework')); ?> </a> </div> <?php } ?> </div> <?php } ?> </div> </div> <?php } } else { } wp_reset_postdata(); ?> <ul> <?php if ($display == 'category') { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'cat' => $cat, 'posts_per_page' => $number_of_posts, 'offset' => 1, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } elseif ($display == 'tag') { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'tag' => $tag, 'posts_per_page' => $number_of_posts, 'offset' => 1, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } else { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'posts_per_page' => $number_of_posts, 'offset' => 1, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); if ($unique_posts) { $do_unique_posts[] = get_the_ID(); } ?> <li role="article" itemscope="" itemtype="http://schema.org/Article"> <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><?php mom_date_format(); ?> </time> <?php } ?> <?php if ($post_head_commetns != 0) { ?> <div class="comments-link"> <a href="<?php comments_link(); ?> "><?php comments_number(__('(0) Comments', 'framework'), __('(1) Comment', 'framework'), __('(%) Comments', 'framework')); ?> </a> </div> <?php } ?> </div> <?php } ?> </li> <?php } } else { } wp_reset_postdata(); ?> </ul> </div> <?php if ($show_more != 'no') { ?> <footer class="show-more <?php echo $ajax_class; ?> " <?php echo $sm_Atts; ?> > <a href="<?php echo $nb_link; ?> " data-post_type="<?php echo $post_type; ?> " data-offset="<?php echo absint($number_of_posts + 1); ?> " data-orig-offset="<?php echo absint($number_of_posts + 1); ?> "><?php _e('Show More News', 'framework'); ?> </a> </footer> <?php } ?> </section><!--News box 5--> <?php } elseif ($style == 'nb6') { ?> <section class="section news-box <?php if ($display == 'category') { ?> cat_<?php echo $cat; } ?> <?php echo $class; ?> "><!--news box 6--> <header class="block-title <?php echo $head_class; ?> " <?php echo $head_colors; ?> > <h2><a href="<?php echo $nb_link; ?> "><?php echo $nb_title; ?> </a></h2> <?php mom_nb_head($style, $cat, $display, $number_of_posts, $sub_categories, $orderby, $nb_excerpt); ?> </header> <div class="nb6"> <ul> <?php if ($display == 'category') { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'cat' => $cat, 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } elseif ($display == 'tag') { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'tag' => $tag, 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } else { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); if ($unique_posts) { $do_unique_posts[] = get_the_ID(); } ?> <li <?php post_class(); ?> role="article" itemscope="" itemtype="http://schema.org/Article"> <?php if (mom_post_image() != false) { ?> <figure class="post-thumbnail"><a href="<?php the_permalink(); ?> "> <?php mom_post_image_full('scroller-thumb'); ?> <span class="post-format-icon"></span> </a></figure> <?php } ?> <?php if (mom_post_image() != false) { $mom_class = ' class="fix-right-content"'; } else { $mom_class = ''; } ?> <div<?php echo $mom_class; ?> > <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <div class="entry-content"> <?php if ($nb_excerpt != '0') { ?> <p> <?php global $post; $excerpt = $post->post_excerpt; if ($excerpt == '') { $excerpt = get_the_content(''); } if ($nb_excerpt == '') { echo wp_html_excerpt(strip_shortcodes($excerpt), 120, '...'); } else { echo wp_html_excerpt(strip_shortcodes($excerpt), $nb_excerpt, '...'); } ?> </p> <?php } ?> </div> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php mom_date_format(); ?> </time> <?php } ?> <?php if ($post_head_commetns != 0) { ?> <div class="comments-link"> <i class="momizat-icon-bubbles4"></i><a href="<?php comments_link(); ?> "><?php comments_number('0', '1', '%'); ?> </a> </div> <?php } ?> </div> <?php } ?> </div> </li> <?php } } else { } wp_reset_postdata(); ?> </ul> </div> <?php if ($show_more != 'no') { ?> <footer class="show-more <?php echo $ajax_class; ?> " <?php echo $sm_Atts; ?> > <a href="<?php echo $nb_link; ?> " data-post_type="<?php echo $post_type; ?> " data-offset="<?php echo $number_of_posts; ?> " data-orig-offset="<?php echo $number_of_posts; ?> "><?php _e('Show More News', 'framework'); ?> </a> </footer> <?php } ?> </section><!--news box 6--> <?php } elseif ($style == 'list') { ?> <section class="section news-box nb1 news-list <?php if ($display == 'category') { ?> cat_<?php echo $cat; } ?> <?php echo $class; ?> "><!--News box 1--> <header class="block-title <?php echo $head_class; ?> " <?php echo $head_colors; ?> > <h2><a href="<?php echo $nb_link; ?> "><?php echo $nb_title; ?> </a></h2> <?php mom_nb_head($style, $cat, $display, $number_of_posts, $sub_categories, $orderby, $nb_excerpt); ?> </header> <ul> <?php if ($display == 'category') { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'cat' => $cat, 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } elseif ($display == 'tag') { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'tag' => $tag, 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } else { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); if ($unique_posts) { $do_unique_posts[] = get_the_ID(); } ?> <li <?php post_class(); ?> itemscope="" itemtype="http://schema.org/Article"> <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <div class="entry-content"> <?php if ($nb_excerpt != '0') { ?> <p> <?php global $post; $excerpt = $post->post_excerpt; if ($excerpt == '') { $excerpt = get_the_content(''); } if ($nb_excerpt == '') { echo wp_html_excerpt(strip_shortcodes($excerpt), 115, '...'); } else { echo wp_html_excerpt(strip_shortcodes($excerpt), $nb_excerpt, '...'); } ?> </p> <?php } ?> </div> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php mom_date_format(); ?> </time> <?php } ?> <?php if ($post_head_cat != 0) { ?> <span class="cat-link"> <i class="momizat-icon-folder-open"></i><?php the_category(', '); ?> </span> <?php } ?> <?php if ($post_head_commetns != 0) { ?> <span class="comments-link"> <i class="momizat-icon-bubbles4"></i><a href="<?php comments_link(); ?> "><?php comments_number(__('(0) Comments', 'framework'), __('(1) Comment', 'framework'), __('(%) Comments', 'framework')); ?> </a> </span> <?php } ?> <div class="clear"></div> </div> <?php } ?> </li> <?php } } else { } wp_reset_postdata(); ?> </ul> <?php if ($show_more != 'no') { ?> <footer class="show-more <?php echo $ajax_class; ?> " <?php echo $sm_Atts; ?> > <a href="<?php echo $nb_link; ?> " data-post_type="<?php echo $post_type; ?> " data-offset="<?php echo $number_of_posts; ?> " data-orig-offset="<?php echo $number_of_posts; ?> "><?php _e('Show More News', 'framework'); ?> </a> </footer> <?php } ?> </section><!--News box 1--> <?php } else { ?> <section class="section news-box nb1 <?php if ($display == 'category') { ?> cat_<?php echo $cat; } ?> <?php echo $class; ?> "><!--News box 1--> <header class="block-title <?php echo $head_class; ?> " <?php echo $head_colors; ?> > <h2><a href="<?php echo $nb_link; ?> "><?php echo $nb_title; ?> </a></h2> <?php mom_nb_head($style, $cat, $display, $number_of_posts, $sub_categories, $orderby, $nb_excerpt); ?> </header> <ul> <?php if ($display == 'category') { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'cat' => $cat, 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } elseif ($display == 'tag') { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'tag' => $tag, 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } else { $query = new WP_Query(array('post_status' => 'publish', 'order' => $order, 'posts_per_page' => $number_of_posts, 'orderby' => $orderby, 'post__not_in' => $exclude_posts, 'post_type' => $post_type, 'no_found_rows' => true, 'cache_results' => false, 'post__not_in' => $do_unique_posts)); } update_post_thumbnail_cache($query); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); if ($unique_posts) { $do_unique_posts[] = get_the_ID(); } ?> <li <?php post_class(); ?> itemscope="" itemtype="http://schema.org/Article"> <?php if (mom_post_image() != false) { ?> <figure class="post-thumbnail"><a href="<?php the_permalink(); ?> "> <?php mom_post_image_full('nb1-thumb'); ?> <span class="post-format-icon"></span> </a></figure> <?php } ?> <?php if (mom_post_image() != false) { $mom_class = ' class="fix-right-content"'; } else { $mom_class = ''; } ?> <div<?php echo $mom_class; ?> > <h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <div class="entry-content"> <?php if ($nb_excerpt != '0') { ?> <p> <?php global $post; $excerpt = $post->post_excerpt; if ($excerpt == '') { $excerpt = get_the_content(''); } if ($nb_excerpt == '') { echo wp_html_excerpt(strip_shortcodes($excerpt), 115, '...'); } else { echo wp_html_excerpt(strip_shortcodes($excerpt), $nb_excerpt, '...'); } ?> </p> <?php } ?> </div> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php mom_date_format(); ?> </time> <?php } ?> <?php if ($post_head_commetns != 0) { ?> <div class="comments-link"> <i class="momizat-icon-bubbles4"></i><a href="<?php comments_link(); ?> "><?php comments_number(__('(0) Comments', 'framework'), __('(1) Comment', 'framework'), __('(%) Comments', 'framework')); ?> </a> </div> <?php } ?> </div> <?php } ?> </div> </li> <?php } } else { } wp_reset_postdata(); ?> </ul> <?php if ($show_more != 'no') { ?> <footer class="show-more <?php echo $ajax_class; ?> " <?php echo $sm_Atts; ?> > <a href="<?php echo $nb_link; ?> " data-post_type="<?php echo $post_type; ?> " data-offset="<?php echo $number_of_posts; ?> " data-orig-offset="<?php echo $number_of_posts; ?> "><?php _e('Show More News', 'framework'); ?> </a> </footer> <?php } ?> </section><!--News box 1--> <?php } ?> <?php $output = ob_get_contents(); ob_end_clean(); set_transient('mom_news_boxes_' . $id . $style . $display . $cat . $tag . $orderby . $show_more_event . $post_type, $output, 60 * 60 * 24); } return $output; }
function scalia_get_the_post_thumbnail($html, $post_id, $post_thumbnail_id, $size, $attr) { if (in_array($size, array_keys(scalia_image_sizes()))) { if ($post_thumbnail_id) { do_action('begin_fetch_post_thumbnail_html', $post_id, $post_thumbnail_id, $size); if (in_the_loop()) { update_post_thumbnail_cache(); } $html = scalia_get_thumbnail_image($post_thumbnail_id, $size, false, $attr); do_action('end_fetch_post_thumbnail_html', $post_id, $post_thumbnail_id, $size); } else { $html = ''; } } return $html; }