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… ‘-)
Related Posts:
- How to make a plugin require another plugin?
- Why does WordPress use outdated jQuery v1.12.4?
- Is it possible to reuse wp.media.editor Modal for dialogs other than media
- How do i best handle custom plugin page actions?
- Automatically determine minimum WordPress version required for a plugin?
- How to prevent Composer dependency conflicts amongst WP plugins?
- Using a plugin class inside a template
- Change admin language based on user (in single-site)
- Widget development – Drop down options won’t save
- Global Objects and Public Methods
- Does using set_transient() function can lead to MySQL problems?
- Check for featured image in WP_Query
- Enqueue script only when shortcode is used, with WP Plugin Boilerplate
- add_filter OO with parameters
- permalinks with get variables
- dbDelta ALTER TABLE syntax?
- I should hide the API Key in a plugin?
- Some nav-menu filters do nothing
- Shortcodes, output buffering, and WordPress functions
- Auto update specifick plugin
- Get returned variable from a function to add_shortcode function
- What is the difference between current_page_parent and current_page_ancestor?
- Using the component outside the editor. select(‘core’) is null
- Gutenberg is there a way to know if the current block is reusable?
- Tips for targeting widget dragable for WP Pointer on widgets.php page
- Any ideas how to make unit test read the theme functions.php?
- Scheduling a task using class methods
- StackExchange clone using WordPress?
- Add a panel to edit post
- Auto-Update Plugin Creating .tmp directory, not overwriting old version
- Cannot update …/tags folder in SVN Repository
- Register a sidebar in a WordPress plugin
- Is there a way to ensure plugin script loads before another script?
- ORDER BY wp_post custom column name in wp_query
- Verify if user is wordpress logged in from another app since wordpress 4.0
- How to stop your plugin from executing on certain pages?
- Is it necessary to sanitize plugin options?
- Search the product by tag or category not working
- How to filter content for specific content variable
- PowerPress mobile media player
- You do not have sufficient permissions to access this page on a submenu
- WordPress function get_the_terms() returns ‘Invalid taxonomy’ error
- Trying to Implement .pdf File Upload in Admin for plugin
- Writing a wordpress plugin and trying to include the Facebook PHP SDK
- Codex Version Focus on Production or Nightly?
- how to invoke wordpress API from other existing PHP system
- How to cancel update messages from a changed plugin
- How to get the post excerpt using post object?
- jquery & ajax sending data to php
- Fatal error: Uncaught Error: Call to undefined function convert_to_screen()
- How to import the css in the plugin admin area?
- how to get the post id in plugin
- What’s the impact on WordPress’ performance regarding the amount of classes/files in a plugin?
- Using add_sub_menu to put into Appearance Section
- Show content without a post
- WP ajax requests not stacking?
- In wordpress plugin wp_signon shows error
- Full documentation about $args for register_rest_route?
- Is it possible to load the css just on my plugin admin page?
- Problem with autoloader and namespaces
- How can I control if post updated
- How to create taxonomy without using register_taxonomy () function
- AJAX call returns ‘testtest0’ instead of ‘test’ – why?
- Proper Prepare Statement for ALTER TABLE and using AFTER
- Get audio metadata on file upload
- Clean way to initialize plugin in newly-added site when plugin has been network activated?
- Bootstrap Error in WordPress plugin
- Loading Images from Javascript on the Front End
- How to deal with different jQuery versions?
- Can I attach a plugin via my add_filter callback contents?
- Custom payment method after payment user is logged out on thank you page
- The URL of images on my website changed after being set as featured image
- extraprops override existing props
- converting a node.js project into a wp plugin
- Is “document loaded” different on admin side than public side?
- how to handle premium features in a wordpress plugin?
- Yoast and another plugin
- Custom premium registration form and profile page for a WordPress Web Application
- Unexpected issue when using attachment_fields_to_edit filter
- How Can I Update wp_enqueue_scripts () From WordPress Option Page Radio Buttons
- Proper structure for first WP plugin?
- Handle changed Woocommerce function
- Load textdomain from global languages directory
- WP Cron as Fast as WordPress AJAX?
- Tie specific functions to options-update for limiting API requests
- How to set custom homepage via a plugin
- Add placeholder into contact form 7 recaptcha text field
- add_rewrite_rule not working
- dbDelta not doing what it says
- How to parse without changing the characters case (lower and upper) in wordpress the_content?
- Options don’t save, validation callback not executed
- Add admin settings and options
- mysql_real_escape_string() error using xml2ary in WordPress plugin
- How can I make my website with wordpress having on-spot editing feature as compared to concrete5 CMS?
- Developing a wordpress.com shortcode [closed]
- Modify a Themes Appearance >> Header admin screen from a plugin
- correct way to include an external HTML page in WP-admin
- Making a user platform reachable by a qr code on a pin-back-button [closed]
- how to add contact form 7 shortcode in javascript variable
- select rows based on exact time (hours, minutes and seconds)