/**
  * @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
0
 /**
  * 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;
 }