if ($smof_data['post_sidebar_pos'] == 'No Sidebar') { define('IS_FULLWIDTH', TRUE); } get_header(); // Disabling Section shortcode global $disable_section_shortcode; $disable_section_shortcode = TRUE; wp_enqueue_script('comment-reply'); if (have_posts()) { while (have_posts()) { the_post(); $post_format = get_post_format() ? get_post_format() : 'standard'; $post_content = get_the_content(); $preview = ''; if ($post_format == 'image') { $preview = us_post_format_image_preview('blog-big', $post_content); } elseif ($post_format == 'video') { $preview = us_post_format_video_preview($post_content); } elseif ($post_format == 'gallery') { $preview = us_post_format_gallery_preview(false, '', $post_content); } ?> <div class="l-submain"> <div class="l-submain-h g-html i-cf"> <div class="l-content"> <div <?php post_class("w-blog"); ?> > <div class="w-blog-preview">
<?php global $smof_data; $post_format = get_post_format() ? get_post_format() : 'standard'; global $us_thumbnail_size, $post; if (empty($us_thumbnail_size)) { $us_thumbnail_size = 'blog-grid'; } if ($post_format == 'image') { $preview = us_post_format_image_preview($us_thumbnail_size); } elseif ($post_format == 'gallery') { $preview = has_post_thumbnail() ? get_the_post_thumbnail(get_the_ID(), $us_thumbnail_size) : ''; if ($preview == '') { $preview = us_post_format_gallery_preview(true, $us_thumbnail_size); if ($us_thumbnail_size == 'blog-small') { $preview = '<span class="w-blog-entry-preview-icon"> <i class="mdfi_image_collections"></i> </span>'; } } } elseif ($post_format == 'video') { $preview = has_post_thumbnail() ? get_the_post_thumbnail(get_the_ID(), $us_thumbnail_size) : ''; if ($preview == '') { if ($us_thumbnail_size == 'blog-small') { $preview = '<span class="w-blog-entry-preview-icon"> <i class="mdfi_av_play_circle_fill"></i> </span>'; } else { $preview = us_post_format_video_preview(); } }
public function vc_blog($attributes, $content) { $attributes = shortcode_atts(array('pagination' => '', 'type' => 'large_image', 'show_date' => null, 'show_author' => null, 'show_categories' => null, 'show_tags' => null, 'show_comments' => null, 'show_read_more' => null, 'category' => null, 'items' => null, 'post_content' => null, 'columns' => null), $attributes); $blog_thumbnails = array('large_image' => 'large', 'small_circle_image' => 'blog-small', 'masonry' => 'blog-grid'); if (!in_array($attributes['type'], array('large_image', 'small_circle_image', 'masonry'))) { $attributes['type'] = 'large_image'; } if (!in_array($attributes['columns'], array(1, 2, 3))) { $attributes['columns'] = 1; } global $paged; if (is_front_page()) { $page_string = 'page'; } else { $page_string = 'paged'; } if ($attributes['pagination'] == 1 or $attributes['pagination'] == 'yes' or $attributes['pagination'] == 'regular') { $paged = get_query_var($page_string) ? get_query_var($page_string) : 1; } else { $paged = 1; } $args = array('post_type' => 'post', 'post_status' => 'publish', 'orderby' => 'date', 'order' => 'DESC', 'paged' => $paged); $categories_slugs = null; if (!empty($attributes['category'])) { $categories_slugs = explode(',', $attributes['category']); $args['tax_query'] = array(array('taxonomy' => 'category', 'field' => 'slug', 'terms' => $categories_slugs)); } $attributes['items'] = intval($attributes['items']); if (is_integer($attributes['items']) and $attributes['items'] > 0) { $args['posts_per_page'] = $attributes['items']; } else { $attributes['items'] = 0; } $classes = 'w-blog columns_' . $attributes['columns']; switch ($attributes['type']) { case 'large_image': $classes .= ' imgpos_attop'; break; case 'small_circle_image': $classes .= ' imgpos_atleft imgtype_circle'; break; case 'masonry': $classes .= ' type_masonry imgpos_attop animate_revealgrid'; // We'll need the isotope script for this, but only once if (!wp_script_is('us-isotope', 'enqueued')) { wp_enqueue_script('us-isotope'); } break; } $output = '<div class="' . $classes . '"> <div class="w-blog-list">'; global $wp_query; $temp = $wp_query; $wp_query = null; $wp_query = new WP_Query(); $wp_query->query($args); while ($wp_query->have_posts()) { $wp_query->the_post(); global $us_thumbnail_size, $post, $smof_data; $us_thumbnail_size = $blog_thumbnails[$attributes['type']]; $post_format = get_post_format() ? get_post_format() : 'standard'; if (empty($us_thumbnail_size)) { $us_thumbnail_size = 'blog-grid'; } if ($post_format == 'image') { $preview = us_post_format_image_preview($us_thumbnail_size); } elseif ($post_format == 'gallery') { $preview = has_post_thumbnail() ? get_the_post_thumbnail(get_the_ID(), $us_thumbnail_size) : ''; if ($preview == '') { $preview = us_post_format_gallery_preview(true, $us_thumbnail_size); if ($us_thumbnail_size == 'blog-small') { $preview = '<span class="w-blog-entry-preview-icon"> <i class="mdfi_image_collections"></i> </span>'; } } } elseif ($post_format == 'video') { $preview = has_post_thumbnail() ? get_the_post_thumbnail(get_the_ID(), $us_thumbnail_size) : ''; if ($preview == '') { if ($us_thumbnail_size == 'blog-small') { $preview = '<span class="w-blog-entry-preview-icon"> <i class="mdfi_av_play_circle_fill"></i> </span>'; } else { $preview = us_post_format_video_preview(); } } } elseif ($post_format == 'quote') { $preview = has_post_thumbnail() ? get_the_post_thumbnail(get_the_ID(), $us_thumbnail_size) : ''; if ($preview == '' and $us_thumbnail_size == 'blog-small') { $preview = '<span class="w-blog-entry-preview-icon"> <i class="mdfi_editor_format_quote"></i> </span>'; } } else { $preview = has_post_thumbnail() ? get_the_post_thumbnail(get_the_ID(), $us_thumbnail_size) : ''; } if (empty($preview) and $us_thumbnail_size == 'blog-small') { $preview = '<span class="w-blog-entry-preview-icon"><i class="fa fa-file-o"></i></span>'; } $blog_entry_classes = 'w-blog-entry'; if ($attributes['type'] == 'masonry') { $blog_entry_classes .= ' animate_reveal'; } $output .= '<div class="' . join(' ', get_post_class($blog_entry_classes, null)) . '"> <div class="w-blog-entry-h">'; if ($preview and in_array($post_format, array('video', 'gallery'))) { $output .= '<span class="w-blog-entry-preview">' . $preview . '</span>'; } $output .= '<a class="w-blog-entry-link" href="' . get_permalink() . '">'; if ($preview and !in_array($post_format, array('video', 'gallery'))) { $output .= '<span class="w-blog-entry-preview">' . $preview . '</span>'; } if ($post_format == 'quote') { $output .= '<div class="w-blog-entry-title"> <blockquote class="w-blog-entry-title-h">' . get_the_title() . '</blockquote> </div>'; } else { $output .= '<h2 class="w-blog-entry-title"> <span class="w-blog-entry-title-h">' . get_the_title() . '</span> </h2>'; } $output .= '</a> <div class="w-blog-entry-body"> <div class="w-blog-meta">'; if ($attributes['show_date'] == 1 or $attributes['show_date'] == 'yes') { $output .= '<div class="w-blog-meta-date"> <i class="mdfi_device_access_time"></i> <span>' . get_the_date() . '</span> </div>'; } if ($attributes['show_author'] == 1 or $attributes['show_author'] == 'yes') { $output .= '<div class="w-blog-meta-author"> <i class="mdfi_social_person"></i> '; if (get_the_author_meta('url')) { $output .= '<a href="' . esc_url(get_the_author_meta('url')) . '">' . get_the_author() . '</a>'; } else { $output .= '<span>' . get_the_author() . '</span>'; } $output .= '</div>'; } if ($attributes['show_categories'] == 1 or $attributes['show_categories'] == 'yes') { $output .= '<div class="w-blog-meta-category"> <i class="mdfi_file_folder_open"></i> '; $categories = get_the_category(); $categories_output = ''; $separator = ', '; if ($categories) { foreach ($categories as $category) { $categories_output .= '<a href="' . get_category_link($category->term_id) . '" title="' . esc_attr(sprintf(__("View all posts in %s", 'us'), $category->name)) . '">' . $category->cat_name . '</a>' . $separator; } } $output .= trim($categories_output, $separator) . ' </div>'; } if ($attributes['show_tags'] == 1 or $attributes['show_tags'] == 'yes') { $tags = wp_get_post_tags($post->ID); if ($tags) { $output .= '<div class="w-blog-meta-tags"> <i class="mdfi_action_turned_in_not"></i> '; $tags_output = ''; $separator = ', '; foreach ($tags as $tag) { $tags_output .= '<a href="' . get_tag_link($tag->term_id) . '">' . $tag->name . '</a>' . $separator; } $output .= trim($tags_output, $separator) . ' </div>'; } } if ($attributes['show_comments'] == 1 or $attributes['show_comments'] == 'yes') { if (!(get_comments_number() == 0 and !comments_open() and !pings_open())) { $output .= '<div class="w-blog-meta-comments">'; $output .= '<i class="mdfi_communication_comment"></i> '; $number = get_comments_number(); if (0 == $number) { $comments_link = get_permalink() . '#respond'; } else { $comments_link = esc_url(get_comments_link()); } $output .= '<a href="' . $comments_link . '" class="w-blog-entry-meta-comments-h">'; if ($number > 1) { $output .= str_replace('%', number_format_i18n($number), __('% Comments', 'us')); } elseif ($number == 0) { $output .= __('No Comments', 'us'); } else { // must be one $output .= __('1 Comment', 'us'); } $output .= '</a></div>'; } } $output .= '</div>'; $output .= '<div class="w-blog-entry-short">'; if ($attributes['post_content'] != 'none') { global $disable_section_shortcode; $original_section_shortcode_state = $disable_section_shortcode; $disable_section_shortcode = TRUE; if ($attributes['post_content'] != 'full' or $attributes['type'] == 'masonry') { $excerpt = $post->post_excerpt; if ($excerpt == '') { $excerpt = $post->post_content; $more_tag_found = 0; if (preg_match('/<!--nextpage(.*?)?-->/', $excerpt, $matches)) { $excerpt = explode($matches[0], $excerpt, 2); $excerpt = $excerpt[0]; } if (preg_match('/<!--more(.*?)?-->/', $excerpt, $matches)) { $more_tag_found = 1; $excerpt = explode($matches[0], $excerpt, 2); $excerpt = $excerpt[0]; } $excerpt = apply_filters('the_excerpt', $excerpt); $excerpt = str_replace(']]>', ']]>', $excerpt); $excerpt_length = apply_filters('excerpt_length', 55); $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]'); $excerpt = wp_trim_words($excerpt, $excerpt_length, $excerpt_more); if ($more_tag_found) { $excerpt .= ' <a href="' . get_the_permalink() . '">' . __('Continue reading', 'us') . '</a>'; } } else { $excerpt = apply_filters('the_excerpt', $excerpt); $excerpt = str_replace(']]>', ']]>', $excerpt); } $output .= $excerpt; } else { $excerpt = $post->post_content; $more_tag_found = 0; if (preg_match('/<!--nextpage(.*?)?-->/', $excerpt, $matches)) { $excerpt = explode($matches[0], $excerpt, 2); $excerpt = $excerpt[0]; } if (preg_match('/<!--more(.*?)?-->/', $excerpt, $matches)) { $more_tag_found = 1; $excerpt = explode($matches[0], $excerpt, 2); $excerpt = $excerpt[0]; } $excerpt = do_shortcode($excerpt); $excerpt = $this->sections_fix($excerpt); $excerpt = str_replace(']]>', ']]>', $excerpt); $output .= $excerpt; if ($more_tag_found) { $output .= ' <a href="' . get_the_permalink() . '">' . __('Continue reading', 'us') . '</a>'; } } $link_pages_args = array('before' => '<div class="w-blog-pagination"><div class="g-pagination">', 'after' => '</div></div>', 'next_or_number' => 'next_and_number', 'nextpagelink' => __('Next', 'us'), 'previouspagelink' => __('Previous', 'us'), 'echo' => 0); if (function_exists('us_wp_link_pages')) { $output .= us_wp_link_pages($link_pages_args); } else { $output .= wp_link_pages(array('echo' => 0)); } $disable_section_shortcode = $original_section_shortcode_state; } $output .= '</div>'; if ($attributes['show_read_more'] == 1 or $attributes['show_read_more'] == 'yes') { $output .= '<a class="w-blog-entry-more g-btn color_white type_raised" href="' . get_permalink() . '"><span>' . __('Read More', 'us') . '</span></a>'; } $output .= '</div></div></div>'; } $output .= '</div></div>'; if ($attributes['pagination'] == 1 or $attributes['pagination'] == 'yes' or $attributes['pagination'] == 'regular') { if ($pagination = us_pagination()) { $output .= '<div class="g-pagination"> ' . $pagination . ' </div>'; } } elseif ($attributes['pagination'] == 'ajax') { $max_num_pages = $wp_query->max_num_pages; if ($max_num_pages > 1) { $output .= '<div class="w-loadmore"> <a href="javascript:void(0);" id="grid_load_more" class="g-btn color_primary type_flat size_big"><span>' . __('Load More Posts', 'us') . '</span></a> <div class="w-preloader type_2"></div> </div>'; $output .= '<script type="text/javascript"> var page = 1, max_page = ' . $max_num_pages . '; jQuery(document).ready(function(){ jQuery("#grid_load_more").click(function(){ jQuery(".w-loadmore").addClass("loading"); jQuery.ajax({ type: "POST", url: "' . admin_url("admin-ajax.php") . '", data: { action: "blogAjaxPagination", type: "' . $us_thumbnail_size . '", post_content: "' . $attributes['post_content'] . '", show_date: "' . $attributes['show_date'] . '", show_author: "' . $attributes['show_author'] . '", show_comments: "' . $attributes['show_comments'] . '", show_categories: "' . $attributes['show_categories'] . '", show_tags: "' . $attributes['show_tags'] . '", show_read_more: "' . $attributes['show_read_more'] . '", category: "' . $attributes['category'] . '", items: "' . $attributes['items'] . '", page: page+1 }, success: function(data, textStatus, XMLHttpRequest){ page++; var newItemsContainer = jQuery("<div>", {html:data}), blogContainer = jQuery(".w-blog"), blogList = jQuery(".w-blog-list");'; if ($us_thumbnail_size == 'blog-grid') { $output .= ' var newItems = newItemsContainer.children(); if (blogContainer.hasClass("animate_revealgrid")) newItems.addClass("animate_reveal"); newItemsContainer.imagesLoaded(function(){ var iso = blogList.data("isotope"), addedItems = iso.appended(newItems.appendTo(blogList)); newItems.revealGridMD(); blogList.find(".fotorama").fotorama().on("fotorama:ready", function (e, fotorama){ blogList.isotope("layout"); }); jQuery(".w-loadmore").removeClass("loading").toggleClass("done", max_page <= page); });'; } else { $output .= ' var newItems = newItemsContainer.children(); blogList.append(newItems); if (jQuery().fotorama){ blogList.find(".fotorama").fotorama(); } jQuery(".w-loadmore").removeClass("loading").toggleClass("done", max_page <= page); '; } $output .= ' }, error: function(MLHttpRequest, textStatus, errorThrown){ jQuery(".w-loadmore").removeClass("loading"); } }); }); }); </script>'; } } wp_reset_postdata(); $wp_query = $temp; return $output; }
public function vc_blog($attributes, $content) { if (is_admin()) { return ''; } $attributes = shortcode_atts(array('pagination' => '', 'type' => 'large_image', 'show_date' => null, 'show_author' => null, 'show_categories' => null, 'show_tags' => null, 'show_comments' => null, 'show_read_more' => null, 'category' => null, 'items' => null, 'post_content' => null, 'columns' => null, 'el_class' => ''), $attributes); $rand_id = rand(100000, 999999); // We need fotorama script for this, but only once per page if (!wp_script_is('us-fotorama', 'enqueued')) { wp_enqueue_script('us-fotorama'); } $blog_thumbnails = array('large_image' => 'blog-large', 'small_square_image' => 'blog-small', 'small_circle_image' => 'blog-small', 'masonry_ajax' => 'blog-grid', 'masonry_paginated' => 'blog-grid'); if (!in_array($attributes['type'], array('large_image', 'small_square_image', 'small_circle_image', 'masonry_ajax', 'masonry_paginated'))) { $attributes['type'] = 'large_image'; } if (!in_array($attributes['columns'], array(1, 2, 3))) { $attributes['columns'] = 1; } if ($attributes['el_class'] != '') { $attributes['el_class'] = ' ' . $attributes['el_class']; } global $paged; if (is_front_page()) { $page_string = 'page'; } else { $page_string = 'paged'; } if ($attributes['pagination'] == 1 or $attributes['pagination'] == 'yes' or $attributes['pagination'] == 'regular') { $paged = get_query_var($page_string) ? get_query_var($page_string) : 1; } else { $paged = 1; } $args = array('post_type' => 'post', 'post_status' => 'publish', 'orderby' => 'date', 'order' => 'DESC', 'paged' => $paged); $categories_slugs = null; if (!empty($attributes['category'])) { $categories_slugs = explode(',', $attributes['category']); $args['tax_query'] = array(array('taxonomy' => 'category', 'field' => 'slug', 'terms' => $categories_slugs)); } $attributes['items'] = intval($attributes['items']); if (is_integer($attributes['items']) and $attributes['items'] > 0) { $args['posts_per_page'] = $attributes['items']; } else { $attributes['items'] = 0; } $classes = 'w-blog columns_' . $attributes['columns'] . $attributes['el_class']; switch ($attributes['type']) { case 'large_image': $classes .= ' imgpos_attop'; break; case 'small_square_image': $classes .= ' imgpos_atleft'; break; case 'small_circle_image': $classes .= ' imgpos_atleft imgtype_circle'; break; case 'masonry': case 'masonry_ajax': case 'masonry_paginated': $classes .= ' type_masonry imgpos_attop'; // We'll need the isotope script for this, but only once if (!wp_script_is('us-isotope', 'enqueued')) { wp_enqueue_script('us-isotope'); } break; } $output = '<div class="' . $classes . '" id="us_blog_' . $rand_id . '"> <div class="w-blog-list">'; global $wp_query; $wp_query = new WP_Query(); $wp_query->query($args); while ($wp_query->have_posts()) { $wp_query->the_post(); global $us_thumbnail_size, $post, $smof_data; $us_thumbnail_size = $blog_thumbnails[$attributes['type']]; $post_format = get_post_format() ? get_post_format() : 'standard'; if (empty($us_thumbnail_size)) { $us_thumbnail_size = 'blog-grid'; } if ($post_format == 'image') { $preview = us_post_format_image_preview($us_thumbnail_size); } elseif ($post_format == 'gallery') { $preview = has_post_thumbnail() ? get_the_post_thumbnail(get_the_ID(), $us_thumbnail_size) : ''; if ($preview == '') { if ($us_thumbnail_size == 'blog-small') { $preview = '<span class="w-blog-entry-preview-icon"> <i class="fa fa-camera"></i> </span>'; } else { $preview = us_post_format_gallery_preview(true, $us_thumbnail_size); } } } elseif ($post_format == 'video') { $preview = has_post_thumbnail() ? get_the_post_thumbnail(get_the_ID(), $us_thumbnail_size) : ''; if ($preview == '') { if ($us_thumbnail_size == 'blog-small') { $preview = '<span class="w-blog-entry-preview-icon"> <i class="fa fa-film"></i> </span>'; } else { $preview = us_post_format_video_preview(); } } } elseif ($post_format == 'quote') { $preview = has_post_thumbnail() ? get_the_post_thumbnail(get_the_ID(), $us_thumbnail_size) : ''; if ($preview == '' and $us_thumbnail_size == 'blog-small') { $preview = '<span class="w-blog-entry-preview-icon"> <i class="fa fa-quote-left"></i> </span>'; } } else { $preview = has_post_thumbnail() ? get_the_post_thumbnail(get_the_ID(), $us_thumbnail_size) : ''; } if (empty($preview) and $us_thumbnail_size == 'blog-small') { $preview = '<span class="w-blog-entry-preview-icon"><i class="fa fa-file-o"></i></span>'; } $output .= '<div class="' . join(' ', get_post_class('w-blog-entry', null)) . '"> <div class="w-blog-entry-h">'; if ($preview and in_array($post_format, array('video', 'gallery'))) { $output .= '<span class="w-blog-entry-preview">' . $preview . '</span>'; } $output .= '<a class="w-blog-entry-link" href="' . get_permalink() . '">'; if ($preview and !in_array($post_format, array('video', 'gallery'))) { $output .= '<span class="w-blog-entry-preview">' . $preview . '</span>'; } if ($post_format == 'quote') { $output .= '<div class="w-blog-entry-title"> <blockquote class="w-blog-entry-title-h entry-title">' . get_the_title() . '</blockquote> </div>'; } else { $output .= '<h2 class="w-blog-entry-title"> <span class="w-blog-entry-title-h entry-title">' . get_the_title() . '</span> </h2>'; } $output .= '</a> <div class="w-blog-entry-body"> <div class="w-blog-meta">'; $output .= '<time class="w-blog-meta-date'; if ($attributes['show_date'] != 1 and $attributes['show_date'] != 'yes') { $output .= ' hidden'; } $output .= '"> <i class="fa fa-clock-o"></i> <span class="date updated">' . get_the_date() . '</span> </time>'; $output .= '<div class="w-blog-meta-author vcard author'; if ($attributes['show_author'] != 1 and $attributes['show_author'] != 'yes') { $output .= ' hidden'; } $output .= '"> <i class="fa fa-user"></i>'; if (get_the_author_meta('url')) { $output .= '<a href="' . esc_url(get_the_author_meta('url')) . '" class="fn">' . get_the_author() . '</a>'; } else { $output .= '<span class="fn">' . get_the_author() . '</span>'; } $output .= '</div>'; if ($attributes['show_categories'] == 1 or $attributes['show_categories'] == 'yes') { $output .= '<div class="w-blog-meta-category"> <i class="fa fa-folder-open"></i>'; $categories = get_the_category(); $categories_output = ''; $separator = ', '; if ($categories) { foreach ($categories as $category) { $categories_output .= '<a href="' . get_category_link($category->term_id) . '" title="' . esc_attr(sprintf(__("View all posts in %s"), $category->name)) . '">' . $category->cat_name . '</a>' . $separator; } } $output .= trim($categories_output, $separator) . ' </div>'; } if ($attributes['show_tags'] == 1 or $attributes['show_tags'] == 'yes') { $tags = wp_get_post_tags($post->ID); if ($tags) { $output .= '<div class="w-blog-meta-tags"> <i class="fa fa-tags"></i>'; $tags_output = ''; $separator = ', '; foreach ($tags as $tag) { $tags_output .= '<a href="' . get_tag_link($tag->term_id) . '">' . $tag->name . '</a>' . $separator; } $output .= trim($tags_output, $separator) . ' </div>'; } } if ($attributes['show_comments'] == 1 or $attributes['show_comments'] == 'yes') { if (!(get_comments_number() == 0 and !comments_open() and !pings_open())) { $output .= '<div class="w-blog-meta-comments">'; $output .= '<i class="fa fa-comments"></i>'; $number = get_comments_number(); if (0 == $number) { $comments_link = get_permalink() . '#respond'; } else { $comments_link = esc_url(get_comments_link()); } $output .= '<a href="' . $comments_link . '" class="w-blog-entry-meta-comments-h">'; if ($number > 1) { $output .= str_replace('%', number_format_i18n($number), __('% Comments', 'us')); } elseif ($number == 0) { $output .= __('No Comments', 'us'); } else { // must be one $output .= __('1 Comment', 'us'); } $output .= '</a></div>'; } } $output .= '</div>'; if ($attributes['post_content'] != 'none') { $output .= '<div class="w-blog-entry-short">'; global $disable_section_shortcode; $original_section_shortcode_state = $disable_section_shortcode; $disable_section_shortcode = TRUE; if ($attributes['post_content'] != 'full' or $attributes['type'] == 'masonry_paginated') { $excerpt = $post->post_excerpt; if ($excerpt == '') { $excerpt = get_the_content(); $excerpt = do_shortcode($excerpt); $excerpt = $this->sections_fix($excerpt); $excerpt = apply_filters('the_excerpt', $excerpt); $excerpt = str_replace(']]>', ']]>', $excerpt); $excerpt_length = apply_filters('excerpt_length', 55); $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]'); $excerpt = wp_trim_words($excerpt, $excerpt_length, $excerpt_more); } else { $excerpt = apply_filters('the_excerpt', $excerpt); $excerpt = str_replace(']]>', ']]>', $excerpt); } $output .= $excerpt; } else { $excerpt = $post->post_content; if (preg_match('/<!--more(.*?)?-->/', $excerpt, $matches)) { $excerpt = explode($matches[0], $excerpt, 2); $excerpt = $excerpt[0]; } $excerpt = do_shortcode($excerpt); $excerpt = $this->sections_fix($excerpt); $excerpt = str_replace(']]>', ']]>', $excerpt); $output .= $excerpt; } $disable_section_shortcode = $original_section_shortcode_state; $output .= '</div>'; } if ($attributes['show_read_more'] == 1 or $attributes['show_read_more'] == 'yes') { $output .= '<a class="w-blog-entry-more g-btn color_default size_small outlined" href="' . get_permalink() . '"><span>' . __('Read More', 'us') . '</span></a>'; } $output .= '</div></div></div>'; } $output .= '</div></div>'; if ($attributes['pagination'] == 1 or $attributes['pagination'] == 'yes' or $attributes['pagination'] == 'regular') { $output .= '<div class="w-blog-pagination"> ' . get_the_posts_pagination(array('prev_text' => '<', 'next_text' => '>', 'before_page_number' => '<span>', 'after_page_number' => '</span>')) . ' </div>'; } elseif ($attributes['pagination'] == 'ajax') { $max_num_pages = $wp_query->max_num_pages; if ($max_num_pages > 1) { $output .= '<div class="w-loadmore" id="us_load_more_' . $rand_id . '"> <a href="javascript:void(0);" id="grid_load_more" class="g-btn color_contrast outlined size_small"><span>' . __('Load More Posts', 'us') . '</span></a> <i class="fa fa-refresh fa-spin"></i> </div>'; $output .= '<script type="text/javascript"> jQuery(document).ready(function(){ var page = 1, max_page = ' . $max_num_pages . '; jQuery("#us_load_more_' . $rand_id . ' .g-btn").click(function(){ jQuery("#us_load_more_' . $rand_id . '").addClass("loading"); jQuery.ajax({ type: "POST", url: "' . admin_url("admin-ajax.php") . '", data: { action: "blogAjaxPagination", type: "' . $us_thumbnail_size . '", post_content: "' . $attributes['post_content'] . '", show_date: "' . $attributes['show_date'] . '", show_author: "' . $attributes['show_author'] . '", show_comments: "' . $attributes['show_comments'] . '", show_categories: "' . $attributes['show_categories'] . '", show_tags: "' . $attributes['show_tags'] . '", show_read_more: "' . $attributes['show_read_more'] . '", category: "' . $attributes['category'] . '", items: "' . $attributes['items'] . '", page: page+1 }, success: function(data, textStatus, XMLHttpRequest){ page++; var newItems = jQuery("<div>", {html:data}), blogList = jQuery("#us_blog_' . $rand_id . ' .w-blog-list");'; if ($us_thumbnail_size == 'blog-grid') { $output .= ' newItems.imagesLoaded(function() { newItems.children().each(function(childIndex,child){ blogList.append(jQuery(child)).isotope("appended", jQuery(child)); blogList.find(".fotorama").fotorama().on("fotorama:ready", function (e, fotorama) { blogList.isotope("layout"); }); }); });'; } else { $output .= ' newItems.children().each(function(childIndex,child){ blogList.append(jQuery(child)); if (jQuery().fotorama){ blogList.find(".fotorama").fotorama(); } });'; } $output .= ' jQuery("#us_load_more_' . $rand_id . '").removeClass("loading"); if (max_page <= page) { jQuery("#us_load_more_' . $rand_id . '").addClass("done"); } }, error: function(MLHttpRequest, textStatus, errorThrown){ jQuery("#us_load_more_' . $rand_id . '").removeClass("loading"); } }); }); }); </script>'; } } wp_reset_query(); return $output; }