Ejemplo n.º 1
0
        public function get_posts_result($args)
        {
            $slide_image_target = isset($args['image_from']) ? $args['image_from'] : 'auto';
            $th_wp_query = $this->get_query_results($args);
            ob_start();
            if ($th_wp_query->have_posts()) {
                while ($th_wp_query->have_posts()) {
                    $th_wp_query->the_post();
                    $the_excerpt = get_the_excerpt();
                    $excerpt_length = isset($args['excerpt_length']) ? $args['excerpt_length'] : '';
                    if (!empty($excerpt_length)) {
                        $the_excerpt = msp_get_trimmed_string(get_the_excerpt(), (int) $excerpt_length);
                    }
                    $the_media = '';
                    $the_media_src = msp_get_auto_post_thumbnail_src($th_wp_query->post->ID, $slide_image_target);
                    if (!empty($the_media_src)) {
                        $the_media_tag = msp_get_the_resized_image($the_media_src, 80, 80, true, 100);
                        $the_media = sprintf('<div class="msp-entry-media" ><a href="%s" target="_blank">%s</a></div>', get_the_permalink(), $the_media_tag);
                    }
                    ?>
  

		<article class="msp-post msp-post-<?php 
                    echo $th_wp_query->post->ID;
                    ?>
 msp-post-<?php 
                    echo $th_wp_query->post->post_type;
                    ?>
">
           <figure>
           		<?php 
                    echo $the_media;
                    ?>
           		
                <figcaption>
                    <div class="msp-entry-header">
                        <h4 class="msp-entry-title"><a href="<?php 
                    the_permalink();
                    ?>
" target="_blank"><?php 
                    the_title();
                    ?>
</a></h4>
                    </div>
                    
                    <div class="msp-entry-content">
                        <time datetime="<?php 
                    the_time('Y-m-d');
                    ?>
" title="<?php 
                    the_time('Y-m-d');
                    ?>
" ><?php 
                    the_time('F j, Y');
                    ?>
</time>
                        ( <span class="ps-post-id">Post ID: <?php 
                    the_ID();
                    ?>
</span> )
                        <p><?php 
                    echo $the_excerpt;
                    ?>
</p>
                    </div>
                </figcaption>
           </figure>
		</article>   

		<?php 
                }
            }
            return ob_get_clean();
        }
Ejemplo n.º 2
0
 function msp_get_the_trim_excerpt($post_id = null, $char_length = null, $exclude_strip_shortcode_tags = null)
 {
     $post = get_post($post_id);
     if (!isset($post)) {
         return "";
     }
     $excerpt = $post->post_content;
     $raw_excerpt = $excerpt;
     $excerpt = apply_filters('the_content', $excerpt);
     // If char length is defined use it, otherwise use default char length
     $char_length = empty($char_length) ? apply_filters('masterslider_excerpt_char_length', 250) : $char_length;
     $excerpt_more = apply_filters('excerpt_more', ' ...');
     // Clean post content
     $excerpt = strip_tags(msp_strip_shortcodes($excerpt, $exclude_strip_shortcode_tags));
     $text = msp_get_trimmed_string($excerpt, $char_length, $excerpt_more);
     return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
 }
        public function get_posts_result($args)
        {
            $slide_image_target = isset($args['image_from']) ? $args['image_from'] : 'auto';
            $th_wp_query = $this->get_query_results($args);
            ob_start();
            if ($th_wp_query->have_posts()) {
                while ($th_wp_query->have_posts()) {
                    $th_wp_query->the_post();
                    $product = get_product($th_wp_query->post->ID);
                    $the_excerpt = apply_filters('woocommerce_short_description', $product->get_post_data()->post_excerpt);
                    $excerpt_length = isset($args['excerpt_length']) ? $args['excerpt_length'] : '';
                    if (!empty($excerpt_length)) {
                        $the_excerpt = msp_get_trimmed_string($the_excerpt, (int) $excerpt_length);
                    }
                    $the_media = '';
                    $the_media_src = msp_get_auto_post_thumbnail_url($th_wp_query->post->ID, $slide_image_target);
                    $premalink = $product->get_permalink();
                    if (!empty($the_media_src)) {
                        $the_media_tag = msp_get_the_resized_image($the_media_src, 80, 80, true, 100);
                        $the_media = sprintf('<div class="msp-entry-media" ><a href="%s" target="_blank">%s</a></div>', $premalink, $the_media_tag);
                    }
                    ?>

		<article class="msp-post msp-post-<?php 
                    echo $th_wp_query->post->ID;
                    ?>
 msp-post-<?php 
                    echo $th_wp_query->post->post_type;
                    ?>
">
           <figure>
           		<?php 
                    echo $the_media;
                    ?>

                <figcaption>
                    <div class="msp-entry-header">
                        <h4 class="msp-entry-title"><a href="<?php 
                    echo $premalink;
                    ?>
" target="_blank"><?php 
                    the_title();
                    ?>
</a></h4>
                    </div>

                    <div class="msp-entry-content">
                        <time datetime="<?php 
                    the_time('Y-m-d');
                    ?>
" title="<?php 
                    the_time('Y-m-d');
                    ?>
" ><?php 
                    the_time('F j, Y');
                    ?>
</time>
                        ( <span class="ps-post-id">Post ID: <?php 
                    the_ID();
                    ?>
</span> )
                        <?php 
                    if ($regular_price = wc_format_decimal($product->get_regular_price(), 2)) {
                        ?>
							( <span class="regular-price"><?php 
                        _e('Regular Price', MSWP_TEXT_DOMAIN);
                        echo ': ' . $regular_price;
                        ?>
</span> )
						<?php 
                    }
                    ?>
						<?php 
                    if ($sale_price = $product->get_sale_price() ? wc_format_decimal($product->get_sale_price(), 2) : null) {
                        ?>
							( <span class="sale-price"><?php 
                        _e('Sale Price', MSWP_TEXT_DOMAIN);
                        echo ': ' . $sale_price;
                        ?>
</span> )
						<?php 
                    }
                    ?>
                        <p><?php 
                    echo $the_excerpt;
                    ?>
</p>
                    </div>
                </figcaption>
           </figure>
		</article>

		<?php 
                }
            }
            // Restore original Post Data
            wp_reset_query();
            return ob_get_clean();
        }
Ejemplo n.º 4
0
 /**
  * Get excerpt by post ID
  * @param  int|object $post_id     Tge post id or post object
  * @param  int        $char_length Maximum excerpt char length limit
  * @return string                  The excerpt
  */
 function msp_get_the_excerpt_by_id($post_id = null, $char_length = null)
 {
     $post = get_post($post_id);
     if (!isset($post)) {
         return "";
     }
     $excerpt = apply_filters('the_excerpt', get_post_field('post_excerpt', $post->ID));
     $excerpt_more = apply_filters('excerpt_more', ' ...');
     // If post have excerpt, return it
     if (!empty($excerpt)) {
         // if the max char limit was set, trim the excerpt
         if ($char_length) {
             $excerpt = msp_get_trimmed_string($excerpt, $char_length, $excerpt_more);
         }
         return $excerpt;
     }
     // If the excerpt was not created, generate the excerpt by post content
     return msp_get_the_trim_excerpt($post, $char_length);
 }
        public function get_posts_result($args)
        {
            $slide_image_target = isset($args['image_from']) ? $args['image_from'] : 'auto';
            $exclude_posts_without_image = isset($args['exclude_post_no_image']) ? $args['exclude_post_no_image'] : false;
            $th_wp_query = $this->get_query_results($args);
            ob_start();
            if ($th_wp_query->have_posts()) {
                while ($th_wp_query->have_posts()) {
                    $th_wp_query->the_post();
                    $the_excerpt = get_the_excerpt();
                    $excerpt_length = isset($args['excerpt_length']) ? $args['excerpt_length'] : '';
                    if (!empty($excerpt_length)) {
                        $the_excerpt = msp_get_trimmed_string(get_the_excerpt(), (int) $excerpt_length);
                    }
                    $the_media = '';
                    // get featured on first image in post
                    $the_media_src = msp_get_auto_post_thumbnail_url($th_wp_query->post->ID, $slide_image_target);
                    if (!empty($the_media_src)) {
                        $the_media_tag = msp_get_the_resized_image($the_media_src, 80, 80, true, 85);
                        // skip this post if
                        if (empty($the_media_tag) && $exclude_posts_without_image) {
                            continue;
                        }
                        $the_media = sprintf('<div class="msp-entry-media" ><a href="%s" target="_blank">%s</a></div>', get_the_permalink(), $the_media_tag);
                        // exclude posts without image
                    } elseif ($exclude_posts_without_image) {
                        continue;
                    }
                    ?>

		<article class="msp-post msp-post-<?php 
                    echo $th_wp_query->post->ID;
                    ?>
 msp-post-<?php 
                    echo $th_wp_query->post->post_type;
                    ?>
">
           <figure>
           		<?php 
                    echo $the_media;
                    ?>

                <figcaption>
                    <div class="msp-entry-header">
                        <h4 class="msp-entry-title"><a href="<?php 
                    the_permalink();
                    ?>
" target="_blank"><?php 
                    the_title();
                    ?>
</a></h4>
                    </div>

                    <div class="msp-entry-content">
                        <time datetime="<?php 
                    the_time('Y-m-d');
                    ?>
" title="<?php 
                    the_time('Y-m-d');
                    ?>
" ><?php 
                    the_time('F j, Y');
                    ?>
</time>
                        ( <span class="ps-post-id">Post ID: <?php 
                    the_ID();
                    ?>
</span> )
                        <p><?php 
                    echo $the_excerpt;
                    ?>
</p>
                    </div>
                </figcaption>
           </figure>
		</article>

		<?php 
                }
            }
            // Restore original Post Data
            wp_reset_query();
            return ob_get_clean();
        }