public function sections_fix($content) { remove_shortcode('section'); $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); global $disable_section_shortcode; if ($disable_section_shortcode) { add_shortcode('section', array($this, 'section_dummy')); $content = $content . us_wp_link_pages($link_pages_args); return do_shortcode($content); } add_shortcode('section', array($this, 'section')); if (strpos($content, '[section') !== FALSE) { $content = strtr($content, array('[section' => '[/section automatic_end_section="1"][section')); $content = strtr($content, array('[/section]' => '[/section][section]')); $content = strtr($content, array('[/section automatic_end_section="1"]' => '[/section]')); $content = '[section]' . $content . us_wp_link_pages($link_pages_args) . '[/section]'; } else { $content = '[section]' . $content . us_wp_link_pages($link_pages_args) . '[/section]'; } $content = preg_replace('%\\[section\\](\\s)*\\[/section\\]%i', '', $content); return do_shortcode($content); }
<?php comments_popup_link(); ?> </div> <?php } ?> </div> <div class="w-blog-text i-cf"> <?php $content = apply_filters('the_content', $post_content); $content = str_replace(']]>', ']]>', $content); echo $content; $link_pages_args = array('before' => '<div class="w-blog-pagination"><nav class="navigation pagination" role="navigation">', 'after' => '</nav></div>', 'next_or_number' => 'next_and_number', 'nextpagelink' => '>', 'previouspagelink' => '<', 'link_before' => '<span>', 'link_after' => '</span>', 'echo' => 1); if (function_exists('us_wp_link_pages')) { us_wp_link_pages($link_pages_args); } else { wp_link_pages(); } ?> </div> </div> <?php if (has_tag()) { ?> <?php if (!isset($smof_data['post_meta_tags']) or $smof_data['post_meta_tags'] == 1) { ?> <div class="w-tags"> <i class="mdfi_action_turned_in_not"></i>
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; }
} elseif ($preview_type == 'modern') { if ($post_thumbnail_id) { $image = wp_get_attachment_image_src($post_thumbnail_id, 'full'); $preview_bg = $image[0]; } elseif ($post_format == 'image') { // Retreiving image from post content to use it as preview background $preview_bg_html = us_get_post_preview($the_content, TRUE); if (preg_match('~src=\\"([^\\"]+)\\"~u', $preview_bg_html, $matches)) { $preview_bg = $matches[1]; } } } } $the_content = apply_filters('the_content', $the_content); // The post itself may be paginated via <!--nextpage--> tags $pagination = us_wp_link_pages(array('before' => '<div class="g-pagination"><nav class="navigation pagination" role="navigation">', 'after' => '</nav></div>', 'next_or_number' => 'next_and_number', 'nextpagelink' => '>', 'previouspagelink' => '<', 'link_before' => '<span>', 'link_after' => '</span>', 'echo' => 0)); // If content has no sections, we'll create them manually $has_own_sections = strpos($the_content, ' class="l-section') !== FALSE; if (!$has_own_sections) { $the_content = '<section class="l-section"><div class="l-section-h i-cf">' . $the_content . $pagination . '</div></section>'; } elseif (!empty($pagination)) { $the_content .= '<section class="l-section"><div class="l-section-h i-cf">' . $pagination . '</div></section>'; } // Meta => certain html in a proper order $meta_html = array_fill_keys($metas, ''); // Preparing post metas separately because we might want to order them inside the .w-blog-post-meta in future $meta_html['date'] = '<time class="w-blog-post-meta-date date updated'; if (!in_array('date', $metas)) { // Hiding from users but not from search engines $meta_html['date'] .= ' hidden'; }