允许divi主题摘录中的所有html标签和样式

问题描述

我该如何允许使用截短后置而非常规摘录功能的divi主题摘录中的所有hmtl,简码和样式。我试图注释掉某些行,但是它不起作用

if ( ! function_exists( 'truncate_post' ) ) {

function truncate_post( $amount,$echo = true,$post = '',$strip_shortcodes = false ) {
    global $shortname;

    if ( empty( $post ) ) global $post;

    if ( post_password_required( $post ) ) {
        $post_excerpt = get_the_password_form();

        if ( $echo ) {
            echo et_core_intentionally_unescaped( $post_excerpt,'html' );
            return;
        }

        return $post_excerpt;
    }

    $post_excerpt = apply_filters( 'the_excerpt',$post->post_excerpt );

    if ( 'on' === et_get_option( $shortname . '_use_excerpt' ) && ! empty( $post_excerpt ) ) {
        if ( $echo ) {
            echo et_core_intentionally_unescaped( $post_excerpt,'html' );
        } 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 );

        // remove post nav shortcode from the post content
        $truncate = preg_replace( '@\[et_pb_post_nav[^\]]*?\].*?\[\/et_pb_post_nav]@si',$truncate );

        // Remove audio shortcode from post content to prevent unwanted audio file on the excerpt
        // due to unparsed audio shortcode
        $truncate = preg_replace( '@\[audio[^\]]*?\].*?\[\/audio]@si',$truncate );

        // Remove embed shortcode from post content
        $truncate = preg_replace( '@\[embed[^\]]*?\].*?\[\/embed]@si',$truncate );

        // Remove script and style tags from the post content
        $truncate = wp_strip_all_tags( $truncate );

        if ( $strip_shortcodes ) {
            $truncate = et_strip_shortcodes( $truncate );
            $truncate = et_builder_strip_dynamic_content( $truncate );
        } else {
            // Check if content should be overridden with a custom value.
            $custom = apply_filters( 'et_truncate_post_use_custom_content',false,$truncate,$post );
            // apply content filters
            $truncate = false === $custom ? apply_filters( 'the_content',$truncate ) : $custom;
        }

        /**
         * Filter automatically generated post excerpt before it gets truncated.
         *
         * @since 3.17.2
         *
         * @param string $excerpt
         * @param integer $post_id
         */
        $truncate = apply_filters( 'et_truncate_post',$post->ID );

        // 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 )
        $truncate = rtrim( et_wp_trim_words( $truncate,$amount,'' ) );

        // remove the last word to make sure we display all words correctly
        if ( ! empty( $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 et_core_intentionally_unescaped( $truncate,'html' );
        } else {
            return $truncate;
        }
    };
}

}

if(!function_exists('et_wp_trim_words')){

function et_wp_trim_words( $text,$num_words = 55,$more = null ) {
    if ( null === $more )
        $more = esc_html__( '…' );
    // Completely remove icons so that unicode hex entities representing the icons do not get included in words.
    $text = preg_replace( '/<span class="et-pb-icon .*<\/span>/',$text );
    $text = wp_strip_all_tags( $text );

    $text = trim( preg_replace( "/[\n\r\t ]+/",' ',$text ),' ' );
    preg_match_all( '/./u',$text,$words_array );
    $words_array = array_slice( $words_array[0],$num_words + 1 );
    $sep = '';

    if ( count( $words_array ) > $num_words ) {
        array_pop( $words_array );
        $text = implode( $sep,$words_array );
        $text = $text . $more;
    } else {
        $text = implode( $sep,$words_array );
    }

    return $text;
}

} *

我想知道如何在divi主题摘录中允许所有html标签和样式。我了解到divi不是使用正常的专家功能,而是使用截断后的功能

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)