WP Discourse 错误消息:超过 32000 个字符

你好
@simon 也许你了解这个问题

我尝试将 这篇帖子 更新到关联的 Discourse 话题中,但收到了错误提示,说内容超过了 32000 字符,而实际上并没有。将帖子发布到 Discourse 是正常工作的。

顺便一提,我使用了以下 functions.php 中的函数:

// 通过 iframe 显示嵌入在 Discourse 中的 WordPress 帖子
// https://meta.discourse.org/t/wp-discourse-how-to-deal-with-shortcodes-in-post/58838/5
add_filter( 'discourse_publish_format_html', 'wpdc_custom_discourse_publish_format_html', 10, 2 );
function wpdc_custom_discourse_publish_format_html( $output, $post_id ) {
    $permalink = get_the_permalink( $post_id );
	$content_post = get_post( $post_id );
	$content = $content_post->post_content;
	$content = apply_filters('the_content', $content);
	$content = str_replace(']]>', ']]>', $content);

	ob_start();
	?>
		
    <iframe width="690" height="2000" src="<?php echo esc_url( $permalink ); ?>" frameborder="0"></iframe>
	<div data-hide="true"><?php echo $content; ?></div>
		
	
	<?php
		
    $output = ob_get_clean();

    return $output;

}

// 由 njegos vukadin 提供

add_action( "wp_head", "detect_embedding", 1 );
add_action( "wp_head", "modify_embedded_links", 11 );

function detect_embedding()
{
?>
<script>
    function isEmbedded () {
	    try {
	        return window.self !== window.top;
	    } catch (e) {
	        return true;
	    }
	}
	if( isEmbedded() ){
		document.documentElement.className = document.documentElement.className + " embedded";
	}
</script>
<style>
	.embedded body > *:not(#page),
	.embedded #main > *:not(article),
	.embedded #right-sidebar {
		display:none!important;
		visibility:hidden!important;
	}

	.embedded #main {
		margin:0;
	}

</style>
<?php
}

function modify_embedded_links(){
?>
<script>
    jQuery(document).ready(function($){
		if( isEmbedded() ){
			$("a").filter(function(){
				return this.href.split("#")[0] !== window.location.href.split("#")[0];
			}).attr("target","_blank");
		}
	})
</script>
<?php
}

错误消息是您在发布帖子时从 Discourse 返回的响应。令我惊讶的是,帖子竟然在出现错误的情况下成功发布了。

由于您是将整个帖子作为 iframe 发布的,我不明白为什么您还要在 iframe 之后添加帖子内容。

确保帖子在话语搜索中获得一定的关联性