Error passing post_content to function

Hi @Scott B:

Here’s a modified version of what you have that resolves the error (although the XPath does not match; I’m not an XPath guru so can’t help with the proper XPath syntax):

add_filter('wp_insert_post_data', 'my_bold_keyword', 10, 2 );
function my_bold_keyword( $data, $postarr ) {
  $myKeyword = "test 123";
  $d = new DOMDocument();
  $d->loadHTML($postarr['post_content']); //ERROR NO LONGER OCCURS HERE
  $x = new DOMXpath($d);
  $Matches = $x->query("//text()[contains(.,$myKeyword) and not(ancestor::h1) and not(ancestor::h2) and not(ancestor::h3) and not(ancestor::h4) and not(ancestor::h5) and not(ancestor::h6)]");
  if($Matches && $Matches->length > 0){
    $myText = $Matches->item(0);
    // need to wrap #myText in <b> wrapper
  }
  return $content;
}

P.S. About that PhpStorm… ‘-)