function add_builder_content_wrapper($content)
    {
        if (!et_pb_is_pagebuilder_used(get_the_ID()) && !is_et_pb_preview()) {
            return $content;
        }
        // Divi builder layout should only be used in singular template
        if (!is_singular()) {
            // get_the_excerpt() for excerpt retrieval causes infinite loop; thus we're using excerpt from global $post variable
            global $post;
            $read_more = sprintf(' <a href="%1$s" title="%2$s" class="more-link">%3$s</a>', esc_url(get_permalink()), sprintf(esc_attr__('Read more on %1%s', 'et_builder'), esc_html(get_the_title())), esc_html__('read more', 'et_builder'));
            // Use post excerpt if there's any. If there is no excerpt defined,
            // Generate from post content by stripping all shortcode first
            if (!empty($post->post_excerpt)) {
                return wpautop($post->post_excerpt . $read_more);
            } else {
                $shortcodeless_content = preg_replace('/\\[[^\\]]+\\]/', '', $content);
                return wpautop(et_wp_trim_words($shortcodeless_content, 270, $read_more));
            }
        }
        $outer_class = apply_filters('et_builder_outer_content_class', array('et_builder_outer_content'));
        $outer_classes = implode(' ', $outer_class);
        $outer_id = apply_filters("et_builder_outer_content_id", "et_builder_outer_content");
        $inner_class = apply_filters('et_builder_inner_content_class', array('et_builder_inner_content'));
        $inner_classes = implode(' ', $inner_class);
        $content = sprintf('<div class="%2$s" id="%4$s">
				<div class="%3$s">
					%1$s
				</div>
			</div>', $content, esc_attr($outer_classes), esc_attr($inner_classes), esc_attr($outer_id));
        return $content;
    }
Example #2
0
 function truncate_title($amount, $echo = true, $post = '')
 {
     if ($post == '') {
         $truncate = get_the_title();
     } else {
         $truncate = $post->post_title;
     }
     if (strlen($truncate) <= $amount) {
         $echo_out = '';
     } else {
         $echo_out = '...';
     }
     $truncate = et_wp_trim_words($truncate, $amount, '');
     if ('' != $echo_out) {
         $truncate .= $echo_out;
     }
     if ($echo) {
         echo $truncate;
     } else {
         return $truncate;
     }
 }
Example #3
0
 function truncate_post($amount, $echo = true, $post = '')
 {
     global $shortname;
     if ('' == $post) {
         global $post;
     }
     $post_excerpt = '';
     $post_excerpt = apply_filters('the_excerpt', $post->post_excerpt);
     if ('on' == et_get_option($shortname . '_use_excerpt') && '' != $post_excerpt) {
         if ($echo) {
             echo $post_excerpt;
         } else {
             return $post_excerpt;
         }
     } else {
         // get the post content
         $truncate = $post->post_content;
         // remove caption shortcode from the post content
         $truncate = preg_replace('@\\[caption[^\\]]*?\\].*?\\[\\/caption]@si', '', $truncate);
         // apply content filters
         $truncate = apply_filters('the_content', $truncate);
         // decide if we need to append dots at the end of the string
         if (strlen($truncate) <= $amount) {
             $echo_out = '';
         } else {
             $echo_out = '...';
             // $amount = $amount - 3;
         }
         // trim text to a certain number of characters, also remove spaces from the end of a string ( space counts as a character )
         if (!$echo) {
             $truncate = rtrim(et_wp_trim_words($truncate, $amount, ''));
         } else {
             $truncate = rtrim(wp_trim_words($truncate, $amount, ''));
         }
         // remove the last word to make sure we display all words correctly
         if ('' != $echo_out) {
             $new_words_array = (array) explode(' ', $truncate);
             array_pop($new_words_array);
             $truncate = implode(' ', $new_words_array);
             // append dots to the end of the string
             $truncate .= $echo_out;
         }
         if ($echo) {
             echo $truncate;
         } else {
             return $truncate;
         }
     }
 }