本文整理汇总了PHP中WPSEO_Utils::trim_nbsp_from_string方法的典型用法代码示例。如果您正苦于以下问题:PHP WPSEO_Utils::trim_nbsp_from_string方法的具体用法?PHP WPSEO_Utils::trim_nbsp_from_string怎么用?PHP WPSEO_Utils::trim_nbsp_from_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPSEO_Utils
的用法示例。
在下文中一共展示了WPSEO_Utils::trim_nbsp_from_string方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_wpseo_trim_nbsp_from_string
/**
* @covers WPSEO_Utils::trim_nbsp_from_string()
*/
public function test_wpseo_trim_nbsp_from_string()
{
$old_string = ' This is an old string with as spaces. ';
$expected = 'This is an old string with as spaces.';
$this->assertEquals($expected, WPSEO_Utils::trim_nbsp_from_string($old_string));
}
示例2: get_body
/**
* Retrieve the body from the post.
*
* @param object $post The post object.
*
* @return string The post content.
*/
function get_body($post)
{
// This filter allows plugins to add their content to the content to be analyzed.
$post_content = apply_filters('wpseo_pre_analysis_post_content', $post->post_content, $post);
// Strip shortcodes, for obvious reasons, if plugins think their content should be in the analysis, they should
// hook into the above filter.
$post_content = WPSEO_Utils::trim_nbsp_from_string(WPSEO_Utils::strip_shortcode($post_content));
if (trim($post_content) == '') {
return '';
}
$htmdata3 = preg_replace('`<(?:\\x20*script|script).*?(?:/>|/script>)`', '', $post_content);
if ($htmdata3 == null) {
$htmdata3 = $post_content;
} else {
unset($post_content);
}
$htmdata4 = preg_replace('`<!--.*?-->`', '', $htmdata3);
if ($htmdata4 == null) {
$htmdata4 = $htmdata3;
} else {
unset($htmdata3);
}
$htmdata5 = preg_replace('`<(?:\\x20*style|style).*?(?:/>|/style>)`', '', $htmdata4);
if ($htmdata5 == null) {
$htmdata5 = $htmdata4;
} else {
unset($htmdata4);
}
return $htmdata5;
}