本文整理匯總了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;
}