Exemplo n.º 1
0
 function snpshpwp_insert_posts($atts, $content = null)
 {
     extract(shortcode_atts(array('related' => 'false', 'post' => '0', 'type' => 1, 'category' => "-1", 'rows' => 1, 'orderby' => 'date', 'order' => 'DESC', 'meta_key' => '', 'ajax' => 'true', 'pagination' => 'true', 'ignoresticky' => 1, 'excerpt_lenght' => 128, 'align' => 'left', 'show_category' => 'true', 'show_date' => 'true', 'show_author' => 'true', 'show_comments' => 'true', 'bot_margin' => 36, 'class' => '', 'shortcode_id' => '', 'animate' => 'none', 'animation_delay' => 0, 'animation_group' => ''), $atts));
     $out = '';
     $post_counter = 0;
     $add_class = '';
     $bot_margin = (int) $bot_margin;
     $margin = ' style="margin-bottom:' . $bot_margin . 'px"';
     if ($ignoresticky == 'false') {
         $ignoresticky = 0;
     } else {
         $ignoresticky = 1;
     }
     global $paged;
     if (empty($paged)) {
         $paged = 1;
     }
     $columns = $type == '0' ? '1' : $type;
     $format = get_post_format();
     $image_size = get_theme_mod('fimage_override') == 1 && $format !== 'gallery' ? 'full' : 'snpshpwp-fullblog';
     $words = $excerpt_lenght;
     if ($related == 'true') {
         if ($post == 0) {
             if (is_single()) {
                 $post = get_the_ID();
             } else {
                 return 'No posts set.';
             }
         }
         $tags = wp_get_post_tags($post);
         $related_ids = array();
         if ($tags) {
             $tag_ids = array();
             foreach ($tags as $individual_tag) {
                 $tag_ids[] = $individual_tag->term_id;
             }
             $args = array('post_type' => 'post', 'post_status' => 'publish', 'tag__in' => $tag_ids, 'post__not_in' => array($post), 'ignore_sticky_posts' => 1);
             $related_posts = get_posts($args);
             foreach ($related_posts as $related_post) {
                 $related_ids[] = $related_post->ID;
             }
             shuffle($related_ids);
         }
         $query_string = array('post__in' => $related_ids, 'posts_per_page' => $columns * $rows, 'orderby' => 'post__in', 'ignore_sticky_posts' => 1);
     } else {
         $query_string = array('post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $columns * $rows, 'paged' => $paged, 'orderby' => $orderby, 'order' => $order, 'ignore_sticky_posts' => $ignoresticky);
         if ($category !== "-1") {
             $query_string = $query_string + array('cat' => $category);
         }
         if ($orderby == 'meta_value' || $orderby == 'meta_value_num') {
             $query_string = $query_string + array('meta_key' => $meta_key);
         }
     }
     $query_string_ajax = str_replace('&', '&', http_build_query($query_string));
     $query_string_ajax = str_replace('&', '&', http_build_query($query_string));
     $snpshpwp_posts = new WP_Query($query_string);
     $count = $snpshpwp_posts->post_count;
     if ($snpshpwp_posts->have_posts()) {
         $out .= "<div class='snpshpwp_blog snpshpwp_type_{$type} snpshpwp_align_{$align}' data-string='{$query_string_ajax}' data-shortcode='{$words}|{$columns}|{$align}|{$pagination}|{$show_category}|{$show_date}|{$show_author}|{$show_comments}'>";
         $out .= '<div class="snpshpwp_blog_separate anivia_row fbuilder_row"><div>';
         while ($snpshpwp_posts->have_posts()) {
             $snpshpwp_posts->the_post();
             if ($add_class !== '') {
                 $out .= '</div></div><div class="snpshpwp_blog_separate anivia_row fbuilder_row"><div>';
             }
             $feat_area = '';
             $heading = '';
             $post_counter++;
             if ($ignoresticky == 0 && is_sticky()) {
                 $sticky_icon = '<i class="fa fa-pushpin"></i> ';
             } else {
                 $sticky_icon = '';
             }
             if (false === $format || $format == 'aside' || $format == 'chat' || $format == 'status') {
                 $format = 'standard';
             }
             $out .= '<div class="' . implode(' ', get_post_class()) . ' snpshpwp_post fbuilder_column fbuilder_column-1-' . $columns . '">';
             if ($type !== '0') {
                 $feat_area .= snpshpwp_get_featarea($image_size, $format);
             } else {
                 $feat_area .= get_the_post_thumbnail(get_the_ID(), 'snpshpwp-square');
             }
             if ($format !== 'quote') {
                 $heading .= '<h3 class="snpshpwp_blog_title"><a href="' . get_permalink() . '" rel="bookmark">' . $sticky_icon . get_the_title() . '</a></h3>';
             }
             if ($show_category == 'true' || $show_date == 'true' || $show_author == 'true' || $show_comments == 'true') {
                 $heading .= '<div class="snpshpwp_posts_meta">';
                 if ($show_category == 'true') {
                     $heading .= '<div class="snpshpwp_category_meta">' . __('Published in', 'snpshpwp') . ' ' . get_the_category_list(', ') . '</div> ';
                 }
                 if ($show_date == 'true') {
                     $timecode = get_the_date();
                     $heading .= '<div class="snpshpwp_date_meta">' . __('on ') . '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '" title="' . __('View all posts this month', 'snpshpwp') . '">' . $timecode . '</a></div> ';
                 }
                 if ($show_author == 'true') {
                     $heading .= '<div class="snpshpwp_author_meta">' . __('by', 'snpshpwp') . ' ' . get_the_author_link() . '</div> ';
                 }
                 if ($show_comments == 'true') {
                     $num_comments = get_comments_number();
                     if (comments_open()) {
                         if ($num_comments == 0) {
                             $comments = __('still no comments', 'snpshpwp');
                         } elseif ($num_comments > 1) {
                             $comments = $num_comments . ' ' . __('Comments', 'snpshpwp');
                         } else {
                             $comments = __('1 Comment', 'snpshpwp');
                         }
                         $write_comments = __('with', 'snpshpwp') . ' ' . '<a href="' . get_comments_link() . '">' . $comments . '</a>';
                     } else {
                         $write_comments = __('Comments are off for this post.', 'snpshpwp');
                     }
                     $heading .= '<div class="snpshpwp_comment_meta">' . $write_comments . '</div>';
                 }
                 $heading .= '</div>';
             }
             $out .= $feat_area . '<div class="snpshpwp_post">' . $heading;
             if ($format !== 'quote') {
                 if ($words !== '0') {
                     $excerpt = get_the_excerpt();
                     $out .= '<div class="snpshpwp_excerpt">' . snpshpwp_string_limit_words($excerpt, $words) . '</div>';
                 }
             }
             $out .= '</div><div class="clearfix"></div></div>';
             if ($post_counter == $columns) {
                 $post_counter = 0;
                 $add_class = 'new_row';
             } else {
                 $add_class = '';
             }
         }
         $out .= '</div></div>';
         $out .= '<div class="clearfix"></div>';
         $out .= '</div>';
         if ($pagination == 'true') {
             $out .= snpshpwp_mini_pagination($snpshpwp_posts->max_num_pages, $paged, 3, $ajax, '');
         } else {
             $out .= '';
         }
     }
     wp_reset_query();
     if ($animate != 'none') {
         $animate = ' frb_animated frb_' . $animate . '"';
         if ($animation_delay != 0) {
             $animation_delay = (int) $animation_delay;
             $animate .= ' data-adelay="' . $animation_delay . '"';
         }
         if ($animation_group != '') {
             $animate .= ' data-agroup="' . $animation_group . '"';
         }
     } else {
         $animate = '"';
     }
     $html_animated = '<div ' . ($shortcode_id != '' ? 'id="' . $shortcode_id . '"' : '') . ' class="snpshpwp_div_inherit_width snpshpwp_div_touch_optimized ' . $class . $animate . ' style="padding-bottom:' . $bot_margin . 'px !important;">' . $out . '</div>';
     return $html_animated;
 }
Exemplo n.º 2
0
    $feat_area .= get_the_post_thumbnail(get_the_ID(), 'snpshpwp-square');
}
if ($format !== 'quote') {
    $heading .= '<h3 class="snpshpwp_blog_title"><a href="' . get_permalink() . '" rel="bookmark">' . $sticky_icon . get_the_title() . '</a></h3>';
}
$timecode = get_the_date();
$num_comments = get_comments_number();
if (comments_open()) {
    if ($num_comments == 0) {
        $comments = __('still no comments', 'snpshpwp');
    } elseif ($num_comments > 1) {
        $comments = $num_comments . ' ' . __('Comments', 'snpshpwp');
    } else {
        $comments = __('1 Comment', 'snpshpwp');
    }
    $write_comments = __('with', 'snpshpwp') . ' ' . '<a href="' . get_comments_link() . '">' . $comments . '</a>';
} else {
    $write_comments = __('Comments are off for this post.', 'snpshpwp');
}
$heading .= '<div class="snpshpwp_posts_meta"><div class="snpshpwp_category_meta">' . __('Published in', 'snpshpwp') . ' ' . get_the_category_list(', ') . '</div> <div class="snpshpwp_date_meta">' . __('on ') . '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '" title="' . __('View all posts this month', 'snpshpwp') . '">' . $timecode . '</a></div> <div class="snpshpwp_author_meta">' . __('by', 'snpshpwp') . ' ' . get_the_author_link() . '</div> <div class="snpshpwp_comment_meta">' . $write_comments . '</div></div>';
$out .= $feat_area . '<div class="snpshpwp_post">' . $heading;
if ($format !== 'quote') {
    if ($snpshpwp_data['blog_layout'] !== '1') {
        $excerpt = get_the_excerpt();
        $out .= '<div class="snpshpwp_excerpt">' . snpshpwp_string_limit_words($excerpt, $snpshpwp_data['blog_excerpt']) . '</div>';
    } else {
        $out .= '<div class="snpshpwp_moretag">' . get_the_content_with_formatting('<a href="' . get_permalink() . '" class="snpshpwp_readmore">' . __('Read More', 'snpshpwp') . '</a>') . '</div>';
    }
}
$out .= '</div><div class="clearfix"></div></div>';
echo $out;
Exemplo n.º 3
0
 function snpshpwp_ajaxload_send()
 {
     $out = '';
     $post_counter = 0;
     $add_class = '';
     $query_string = $_POST['data'];
     $current_page = snpshpwp_get_between($query_string, 'paged=', '&');
     $type = $_POST['type'];
     $page = $_POST['page'];
     $ajax = $_POST['ajax'];
     $words = $_POST['excerpt'];
     $columns = $_POST['columns'];
     $align = $_POST['align'];
     $pagination = $_POST['pagination'];
     $show_category = $_POST['show_category'];
     $show_date = $_POST['show_date'];
     $show_author = $_POST['show_author'];
     $show_comments = $_POST['show_comments'];
     $format = get_post_format();
     $image_size = get_theme_mod('fimage_override') == 1 && $format !== 'gallery' ? 'full' : 'snpshpwp-fullblog';
     $query_string = str_replace('paged=' . $current_page . '&', 'paged=' . $page . '&', $query_string);
     $snpshpwp_posts = new WP_Query($query_string);
     if ($snpshpwp_posts->have_posts()) {
         $out .= "@@@!SPLIT!@@@<div class='snpshpwp_blog {$type}' data-string='{$query_string}' data-shortcode='{$words}|{$columns}|{$align}|{$pagination}|{$show_category}|{$show_date}|{$show_author}|{$show_comments}'>";
         $out .= '<div class="snpshpwp_blog_separate anivia_row fbuilder_row"><div>';
         while ($snpshpwp_posts->have_posts()) {
             $snpshpwp_posts->the_post();
             if ($add_class !== '') {
                 $out .= '</div></div><div class="snpshpwp_blog_separate anivia_row fbuilder_row"><div>';
             }
             $feat_area = '';
             $heading = '';
             $post_counter++;
             if (false === $format || $format == 'aside' || $format == 'chat' || $format == 'status') {
                 $format = 'standard';
             }
             $out .= '<div class="' . implode(' ', get_post_class()) . ' snpshpwp_post fbuilder_column fbuilder_column-1-' . $columns . '">';
             if (!strpos($type, 'snpshpwp_type_0')) {
                 $feat_area .= snpshpwp_get_featarea($image_size, $format);
             } else {
                 $feat_area .= get_the_post_thumbnail(get_the_ID(), 'snpshpwp-square');
             }
             if ($format !== 'quote') {
                 $heading .= '<h3 class="snpshpwp_blog_title"><a href="' . get_permalink() . '" rel="bookmark">' . get_the_title() . '</a></h3>';
             }
             if ($show_category == 'true' || $show_date == 'true' || $show_author == 'true' || $show_comments == 'true') {
                 $heading .= '<div class="snpshpwp_posts_meta">';
                 if ($show_category == 'true') {
                     $heading .= '<div class="snpshpwp_category_meta">' . __('Published in', 'snpshpwp') . ' ' . get_the_category_list(', ') . '</div> ';
                 }
                 if ($show_date == 'true') {
                     $timecode = get_the_date();
                     $heading .= '<div class="snpshpwp_date_meta">' . __('on ') . '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '" title="' . __('View all posts this month', 'snpshpwp') . '">' . $timecode . '</a></div> ';
                 }
                 if ($show_author == 'true') {
                     $heading .= '<div class="snpshpwp_author_meta">' . __('by', 'snpshpwp') . ' ' . get_the_author_link() . '</div> ';
                 }
                 if ($show_comments == 'true') {
                     $num_comments = get_comments_number();
                     if (comments_open()) {
                         if ($num_comments == 0) {
                             $comments = __('still no comments', 'snpshpwp');
                         } elseif ($num_comments > 1) {
                             $comments = $num_comments . ' ' . __('Comments', 'snpshpwp');
                         } else {
                             $comments = __('1 Comment', 'snpshpwp');
                         }
                         $write_comments = __('with', 'snpshpwp') . ' ' . '<a href="' . get_comments_link() . '">' . $comments . '</a>';
                     } else {
                         $write_comments = __('Comments are off for this post.', 'snpshpwp');
                     }
                     $heading .= '<div class="snpshpwp_comment_meta">' . $write_comments . '</div>';
                 }
                 $heading .= '</div>';
             }
             $out .= $feat_area . '<div class="snpshpwp_post">' . $heading;
             if ($format !== 'quote') {
                 if ($words !== '0') {
                     $excerpt = get_the_excerpt();
                     $out .= '<div class="snpshpwp_excerpt">' . snpshpwp_string_limit_words($excerpt, $words) . '</div>';
                 }
             }
             $out .= '</div><div class="clearfix"></div></div>';
             if ($post_counter == $columns) {
                 $post_counter = 0;
                 $add_class = 'new_row';
             } else {
                 $add_class = '';
             }
         }
         $out .= '</div></div>';
         $out .= '<div class="clearfix"></div>';
         $out .= '</div>';
         if ($pagination == 'true') {
             $out .= snpshpwp_mini_pagination($snpshpwp_posts->max_num_pages, $page, 3, $ajax, '');
         }
     }
     die($out);
     exit;
 }