Beispiel #1
0
$post_link = !isset($show_links) || $show_links ? get_permalink($post_id) : '';
$output .= '<article class="post_item' . ($show_image == 0 ? ' no_thumb' : ' with_thumb') . ($post_number == 1 ? ' first' : '') . '">';
if ($show_image) {
    $post_thumb = axiom_get_resized_image_tag($post_id, 75, 75);
    if ($post_thumb) {
        $output .= '<div class="post_thumb">' . $post_thumb . '</div>';
    }
}
$output .= '<div class="post_content">' . '<h6 class="post_title">' . ($post_link ? '<a href="' . esc_url($post_link) . '">' : '') . $post_title . ($post_link ? '</a>' : '') . '</h6>';
if ($show_counters) {
    if (axiom_strpos($show_counters, 'views') !== false) {
        $post_counters = axiom_get_post_views($post_id);
        $post_counters_icon = 'post_counters_views icon-eye';
    } else {
        if (axiom_strpos($show_counters, 'likes') !== false) {
            $post_counters = axiom_get_post_likes($post_id);
            $post_counters_icon = 'post_counters_likes icon-heart-1';
        } else {
            if (axiom_strpos($show_counters, 'stars') !== false || axiom_strpos($show_counters, 'rating') !== false) {
                $post_counters = axiom_reviews_marks_to_display(get_post_meta($post_id, $post_rating, true));
                $post_counters_icon = 'post_counters_rating icon-star-1';
            } else {
                $post_counters = get_comments_number($post_id);
                $post_counters_icon = 'post_counters_comments icon-comment-1';
            }
        }
    }
    if (axiom_strpos($show_counters, 'stars') !== false && $post_counters > 0) {
        if (axiom_strpos($post_counters, '.') === false) {
            $post_counters .= '.0';
        }
Beispiel #2
0
 function axiom_get_post_data(&$opt, $post_obj = null)
 {
     $opt = axiom_get_post_data_options($opt);
     global $post, $wp_query;
     $old_post = null;
     if (!empty($post) && is_object($post)) {
         $old_post = clone $post;
     }
     if ($post_obj != null) {
         $post = $post_obj;
         setup_postdata($post);
     }
     $cur_post = clone $post;
     $post_id = get_the_ID();
     $post_parent_id = wp_get_post_parent_id($post_id);
     if (!$post_parent_id) {
         $post_parent_id = 0;
     }
     $post_type = get_post_type();
     $post_protected = post_password_required();
     $post_format = get_post_format();
     if (empty($post_format)) {
         $post_format = 'standard';
     }
     $post_icon = axiom_get_custom_option('icon', axiom_get_post_format_icon($post_format), $post_id, $post_type);
     //!!!!! Get option from specified post
     $post_flags = array('sticky' => is_sticky());
     $post_link = get_permalink();
     $post_comments_link = get_comments_link();
     $post_date_sql = get_the_date('Y-m-d H:i:s');
     $post_date_stamp = get_the_date('U');
     $post_date = axiom_get_date_or_difference($post_date_sql);
     if (!empty($opt['date_format'])) {
         $parts = explode('+', $opt['date_format']);
         $post_date_part1 = empty($parts[0]) ? '' : date($parts[0], $post_date_stamp);
         $post_date_part2 = empty($parts[1]) ? '' : date($parts[1], $post_date_stamp);
         if ($post_date_part1 . $post_date_part2 != '') {
             $post_date = $post_date_part1 . ($post_date_part2 != '' ? ' ' . $post_date_part2 : '');
         }
     }
     $post_comments = $post_views = $post_likes = 0;
     if ($opt['counters'] != '') {
         $post_comments = get_comments_number();
         $post_views = axiom_get_post_views($post_id);
         $post_likes = axiom_get_post_likes($post_id);
     }
     $post_reviews_author = $post_reviews_users = 0;
     if ($opt['reviews']) {
         $post_reviews_author = axiom_reviews_marks_to_display(get_post_meta($post_id, 'reviews_avg', true));
         $post_reviews_users = axiom_reviews_marks_to_display(get_post_meta($post_id, 'reviews_avg2', true));
     }
     $post_author = get_the_author();
     $post_author_id = get_the_author_meta('ID');
     $post_author_url = get_author_posts_url($post_author_id, '');
     // Is user can edit and/or delete this post?
     $allow_editor = axiom_get_theme_option("allow_editor") == 'yes';
     $post_edit_enable = $allow_editor && ($post_type == 'post' && current_user_can('edit_posts', $post_id) || $post_type == 'page' && current_user_can('edit_pages', $post_id));
     $post_delete_enable = $allow_editor && ($post_type == 'post' && current_user_can('delete_posts', $post_id) || $post_type == 'page' && current_user_can('delete_pages', $post_id));
     // Post content
     global $more;
     $old_more = $more;
     $more = -1;
     $post_content_original = trim(chop($post->post_content));
     $post_content_plain = trim(chop(get_the_content()));
     $more = $old_more;
     $post_content = trim(chop(get_the_content($opt['more_tag'], $opt['strip_teaser'])));
     // Substitute WP [gallery] shortcode
     $thumb_sizes = axiom_get_thumb_sizes(array('layout' => $opt['layout']));
     if ($opt['content']) {
         if ($opt['substitute_gallery']) {
             $post_content = axiom_substitute_gallery($post_content, $post_id, $thumb_sizes['w'], $thumb_sizes['h_crop'], 'none', true);
         }
         $post_content = apply_filters('the_content', $post_content);
         if ($post_id != get_the_ID()) {
             // Fix bug in the WPML
             $post = $cur_post;
             setup_postdata($post);
         }
         if ($opt['substitute_video']) {
             $post_content = axiom_substitute_video($post_content, $thumb_sizes['w'], $thumb_sizes['h_crop']);
         }
         if ($opt['substitute_audio']) {
             $post_content = axiom_substitute_audio($post_content);
         }
     }
     // Post excerpt
     $post_excerpt_original = $post->post_excerpt;
     $post_excerpt = has_excerpt() || $post_protected ? get_the_excerpt() : '';
     if (empty($post_excerpt)) {
         if (($more_pos = axiom_strpos($post_content_plain, '<span id="more-')) !== false) {
             $post_excerpt = axiom_substr($post_content_plain, 0, $more_pos);
         } else {
             $post_excerpt = in_array($post_format, array('quote', 'link')) ? $post_content : strip_shortcodes(strip_tags(get_the_excerpt()));
         }
     }
     if ($opt['substitute_gallery']) {
         $post_excerpt = axiom_substitute_gallery($post_excerpt, $post_id, $thumb_sizes['w'], $thumb_sizes['h_crop']);
     }
     $post_excerpt = apply_filters('axiom_filter_sc_clear_around', $post_excerpt);
     $post_excerpt = apply_filters('the_excerpt', $post_excerpt);
     $post_excerpt = apply_filters('axiom_filter_p_clear_around', $post_excerpt);
     if ($post_id != get_the_ID()) {
         // Fix bug in the WPML
         $post = $cur_post;
         setup_postdata($post);
     }
     if ($opt['substitute_video']) {
         $post_excerpt = axiom_substitute_video($post_excerpt, $thumb_sizes['w'], $thumb_sizes['h_crop']);
     }
     if ($opt['substitute_audio']) {
         $post_excerpt = axiom_substitute_audio($post_excerpt);
     }
     $post_excerpt = trim(chop(str_replace(array('[...]', '[&hellip;]'), array('', ''), $post_excerpt)));
     // Post Title
     $post_title = $post_title_plain = trim(chop(get_the_title()));
     $post_title = apply_filters('the_title', $post_title);
     if ($post_id != get_the_ID()) {
         // Fix bug in the WPML
         $post = $cur_post;
         setup_postdata($post);
     }
     // Prepare dedicated content
     $opt['dedicated'] = axiom_sc_get_dedicated_content();
     $opt['location'] = !empty($opt['location']) ? $opt['location'] : axiom_get_custom_option('dedicated_location');
     if (empty($opt['location']) || $opt['location'] == 'default') {
         $opt['location'] = axiom_get_custom_option('dedicated_location', '', $post_id, $post_type);
     }
     //!!!!! Get option from specified post
     if ($opt['location'] == 'alter' && !is_single() && (!is_page() || isset($wp_query->is_posts_page) && $wp_query->is_posts_page == 1)) {
         $loc = array('center', 'right', 'left');
         $opt['location'] = $loc[($opt['number'] - 1) % count($loc)];
     }
     if (!empty($opt['dedicated'])) {
         $class = axiom_get_tag_attrib($opt['dedicated'], '<div class="sc_section>', 'class');
         if ($opt['location'] == 'default') {
             if (($pos = axiom_strpos($class, 'sc_align')) !== false) {
                 $pos += 8;
                 $pos2 = axiom_strpos($class, ' ', $pos);
                 $opt['location'] = $pos2 === false ? axiom_substr($class, $pos) : axiom_substr($class, $pos, $pos2 - $pos);
             }
             if ($opt['location'] == '' || $opt['location'] == 'default') {
                 $opt['location'] = 'center';
             }
         }
         if (!is_singular() || axiom_get_global('blog_streampage') || axiom_sc_in_shortcode_blogger(true) || axiom_strpos($class, 'sc_align') !== false && axiom_strpos($class, 'columns') === false) {
             $class = str_replace(array('sc_alignright', 'sc_alignleft', 'sc_aligncenter'), array('', '', ''), $class) . ' sc_align' . esc_attr($opt['location']);
             //if ($opt['location'] == 'center' && axiom_strpos($class, 'column-2_3')===false && $opt['sidebar'])
             //	$class = str_replace('columns', '_columns', $class) . ' column-2_3';
             //else if (($opt['location'] == 'left' || $opt['location'] == 'right') && axiom_strpos($class, 'column-1_2')===false)// && $opt['sidebar'])
             //	$class = str_replace('columns', '_columns', $class) . ' column-1_2';
             $opt['dedicated'] = axiom_set_tag_attrib($opt['dedicated'], '<div class="sc_section>', 'class', $class);
         }
     }
     //else if ($opt['location']=='' || $opt['location']=='default')
     //$opt['location'] = 'center';
     //if ($opt['location']=='default') $opt['location']='center';
     $opt['post_class'] = $opt['location'];
     // Substitute <video> tags to <iframe> in dedicated content
     if ($opt['substitute_video']) {
         $opt['dedicated'] = axiom_substitute_video($opt['dedicated'], $thumb_sizes['w'], $thumb_sizes['h_crop']);
     }
     // Substitute <audio> tags with src from soundcloud to <iframe>
     if ($opt['substitute_audio']) {
         $opt['dedicated'] = axiom_substitute_audio($opt['dedicated']);
     }
     // Extract gallery, video and audio from full post content
     $post_thumb = $post_thumb_url = $post_attachment = $post_gallery = $post_video = $post_video_image = $post_audio = $post_audio_image = $post_url = $post_url_target = '';
     $post_attachment = wp_get_attachment_url(get_post_thumbnail_id($post_id));
     if (axiom_substr($opt['layout'], 0, 6) == 'single') {
         $post_thumb = axiom_get_resized_image_tag($post_id, $thumb_sizes['w'], $thumb_sizes['h'], null, false, false, true);
     } else {
         if (axiom_substr($opt['layout'], 0, 10) == 'attachment') {
             $post_thumb = axiom_get_resized_image_tag($post_attachment, $thumb_sizes['w'], $thumb_sizes['h'], null, false, false, true);
         } else {
             $post_thumb = axiom_get_resized_image_tag($post_id, $thumb_sizes['w'], $post_type == 'product' && axiom_get_theme_option('crop_product_thumb') == 'no' ? null : $thumb_sizes['h']);
         }
     }
     $post_thumb_url = axiom_get_tag_attrib($post_thumb, '<img>', 'src');
     if ($post_format == 'gallery') {
         $post_gallery = axiom_build_gallery_tag(axiom_get_post_gallery($post_content_plain, $post_id, max(2, axiom_get_custom_option('gallery_max_slides'))), $thumb_sizes['w'], $thumb_sizes['h_crop'], false, $post_link);
     } else {
         if ($post_format == 'video') {
             $src = '';
             $post_video = axiom_get_post_video($post_content_original, false);
             if ($post_video == '') {
                 $src = axiom_get_post_video($post_content_original, true);
                 if (!axiom_is_youtube_url($src) && !axiom_is_vimeo_url($src)) {
                     $src = '';
                 }
             } else {
                 if (axiom_substr($post_video, 0, 1) == '[') {
                     $src = axiom_get_tag_attrib($post_video, '[trx_video]', 'src');
                     if (empty($src)) {
                         $src = axiom_get_tag_attrib($post_video, '[trx_video]', 'url');
                     }
                     if (empty($src)) {
                         $src = axiom_get_post_video($post_video, true);
                     }
                     $post_video_image = axiom_get_tag_attrib($post_video, '[trx_video]', 'image');
                     if ($post_video_image > 0) {
                         $attach = wp_get_attachment_image_src($post_video_image, 'full');
                         if (isset($attach[0]) && $attach[0] != '') {
                             $post_video_image = $attach[0];
                         }
                     }
                     if (empty($post_video_image)) {
                         $post_video_image = axiom_get_video_cover_image($src);
                     }
                     if (empty($post_video_image)) {
                         $post_video_image = $post_thumb;
                     }
                     $post_video_image = axiom_get_resized_image_tag($post_video_image, $thumb_sizes['w'], $thumb_sizes['h']);
                 } else {
                     $src = axiom_get_post_video($post_video, true);
                 }
             }
             if ($src) {
                 $src = axiom_get_video_player_url($src, $post_thumb != '' || $post_video_image != '');
                 $post_video = '<video src="' . esc_url($src) . '" width="' . esc_attr($thumb_sizes['w']) . '" height="' . round($thumb_sizes['w'] / 16 * 9) . '"></video>';
             }
             if ($post_video != '' && $opt['substitute_video']) {
                 $post_video = axiom_substitute_video($post_video, $thumb_sizes['w'], round($thumb_sizes['w'] / 16 * 9), false);
                 //$thumb_sizes['h_crop']);
             }
         } else {
             if ($post_format == 'audio') {
                 $src = $data = '';
                 $post_audio = axiom_get_post_audio($post_content_original, false);
                 if ($post_audio == '') {
                     $src = axiom_get_post_audio($post_content_original, true);
                 } else {
                     if (axiom_substr($post_audio, 0, 1) == '[') {
                         $src = axiom_get_tag_attrib($post_audio, '[trx_audio]', 'src');
                         if (empty($src)) {
                             $src = axiom_get_tag_attrib($post_audio, '[trx_audio]', 'url');
                         }
                         if (empty($src)) {
                             $src = axiom_get_post_audio($post_audio, true);
                         }
                         $post_audio_image = axiom_get_tag_attrib($post_audio, '[trx_audio]', 'image');
                         if ($post_audio_image > 0) {
                             $attach = wp_get_attachment_image_src($post_audio_image, 'full');
                             if (isset($attach[0]) && $attach[0] != '') {
                                 $post_audio_image = $attach[0];
                             }
                         }
                         if (empty($post_audio_image)) {
                             $post_audio_image = $post_thumb;
                         }
                         if ($post_audio_image) {
                             $post_audio_image = axiom_get_resized_image_url($post_audio_image, $thumb_sizes['w'], $thumb_sizes['h']);
                         }
                         $post_audio_title = axiom_get_tag_attrib($post_audio, '[trx_audio]', 'title');
                         $post_audio_author = axiom_get_tag_attrib($post_audio, '[trx_audio]', 'author');
                         $data = ($post_audio_title != '' ? ' data-title="' . esc_attr($post_audio_title) . '"' : '') . ($post_audio_author != '' ? ' data-author="' . esc_attr($post_audio_author) . '"' : '') . ($post_audio_image != '' ? ' data-image="' . esc_attr($post_audio_image) . '"' : '');
                     } else {
                         $src = axiom_get_post_audio($post_audio, true);
                     }
                 }
                 if ($src) {
                     $post_audio = '<audio class="sc_audio" src="' . esc_url($src) . '"' . $data . '></audio>';
                 }
                 if ($post_audio != '' && $opt['substitute_audio'] == 'yes') {
                     $post_audio = axiom_substitute_audio($post_audio, false);
                 }
             }
         }
     }
     if ($post_format == 'image' && !$post_thumb && !is_single()) {
         if (($src = axiom_get_post_image($post_content_original, $post_id)) != '') {
             $post_thumb = axiom_get_resized_image_tag($src, $thumb_sizes['w'], $thumb_sizes['h_crop']);
         }
     }
     if ($post_format == 'link') {
         $post_url_data = axiom_get_post_link($post_content_original, false);
         $post_link = $post_url = $post_url_data['url'];
         $post_url_target = $post_url_data['target'];
     }
     // Get all post's terms
     $post_taxonomy = axiom_get_taxonomy_categories_by_post_type($post_type);
     $post_taxonomy_tags = axiom_get_taxonomy_tags_by_post_type($post_type);
     $post_terms = array();
     if ($opt['terms_list']) {
         $post_terms = axiom_get_terms_by_post_id(array('post_id' => $post_id, 'parent_id' => $post_type == 'post' ? $opt['parent_tax_id'] : 0, 'exclude' => $post_type == 'post' ? explode(',', axiom_get_theme_option('exclude_cats')) : array()));
     }
     if ($old_post != null) {
         $post = $old_post;
         setup_postdata($post);
     }
     $post_data = compact('post_id', 'post_parent_id', 'post_protected', 'post_type', 'post_taxonomy', 'post_taxonomy_tags', 'post_format', 'post_flags', 'post_icon', 'post_link', 'post_comments_link', 'post_date_sql', 'post_date_stamp', 'post_date', 'post_date_part1', 'post_date_part2', 'post_comments', 'post_views', 'post_likes', 'post_reviews_author', 'post_reviews_users', 'post_author', 'post_author_id', 'post_author_url', 'post_title', 'post_title_plain', 'post_content_plain', 'post_content_original', 'post_content', 'post_excerpt_original', 'post_excerpt', 'post_thumb', 'post_thumb_url', 'post_attachment', 'post_gallery', 'post_video', 'post_video_image', 'post_audio', 'post_audio_image', 'post_url', 'post_url_target', 'post_terms', 'post_edit_enable', 'post_delete_enable');
     return apply_filters('axiom_filter_get_post_data', $post_data, $opt, $post_obj);
 }