I can’t comment yet… so I will use an answer, I think you need to do it with ‘wp_insert_post_data’ filter.
You can see this in line 3523 here: https://developer.wordpress.org/reference/functions/wp_insert_post/
Your function need to have a parameter, which is an array. From there you should get the content from ‘post_content’ key.
add_filter( 'wp_insert_post_data', 'example' );
function example( $data ){
$post_content = $data['post_content'];
// ... do your stuff
$data['post_content'] = $post_content;
return $data
}
Note: this will not get the tinymce content, This will get the data right before it’s introduced in database. You should also take some attention at shortcodes, I don’t think that you can modify the content in shortcodes via that filter.
Hope it helps you, or someone else.
Related Posts:
- Detect a focus on wp_editor
- How to load WP_Editor JS files manually (with AJAX)?
- What do ++ and *+ mean?
- Matching a space in regex
- WordPress Visual Editor Stripping HTML Changes
- Add a class to links in the visual editor (how to get old dialog back)
- Correct regex for wp_embed_register_handler
- Shortcode to insert
- Hide old attachments from wp media library
- Add post class to the TinyMCE iframe?
- Add a wp editor to custom plugin and save data
- sql query to put quotes around numbers in img tag
- Dynamically add styles to WP TinyMCE editor
- Adding dropdowns to the tinyMCE editor
- Wrap First Character after in a tag
- wp_editor and WPAlchemy messes up tags when updating
- Removing unneccessary p-tags (Not every p)
- Bridging TinyMCE js and WordPress PHP?
- Applying A Category to Existing Posts Where Page Title Matches Regex
- trigger html cleanup for all posts
- Extend PHP regex to cover “srcset” and “style” attributes
- Change tinyMCE editor to allow marked content when pasting from Word
- how to remove colon and white space in a string by php
- Get URL from shortcode tag
- get_users meta_query: REGEXP not working for matching new lines
- Preg_Match(): compilation failed unknown property name
- preg_replace regex problem
- How to add no follow to specific links?
- php preg_match with multiple patterns
- Extract links from content
- Wp_editor doesn’t send the required data
- How to make the WordPress Editor not accept HTML?
- Testing a Form’s Zipcode Field with Regular Expressions to Determine WordPress Page Behaviour
- Using wp_editor() when not logged stopped working
- Make wp_editor required
- Deny php execution in /wp-includes – using .htaccess in /wp-includes VS root folder
- WordPress add_rewrite_rule
- RegExp to EXCLUDE strip HTML (FOR SOMME) comments
- Add php function into .js file (for tinyMCE button)
- WordPress TinyMCE Add Button To The Full Screen Mode Editor
- Trouble using wordpress functions in a pop-up modal form
- Dynamically append custom post type to end of url
- Replace TinyMCE with Custom Built Editor
- How to strip/remove all blank spaces at the beginning/end of a search string
- Having trouble customizing toolbar on wp_editor
- How to cut a section of a URL from a string with a regular expression?
- WordPress Theme file editor – error with sleep() php function
- Problems with plugin that fetches data from database with ajax
- if conditional in sidebar plugin Password content shortcode
- WordPress – registering sidebar and adding a button directly after .textwidget
- How to get values from wordpress listings and use them in javascript array?
- Make an array listing custom taxonomy
- Get category id for a custom category and display it in a class
- Save data of select list after clicking save
- retrieve wordpress post-meta using php not wordpress functions
- Merge / Combine two php functions for Previous and Next Link with Thumbnail
- Migrate php folder to WordPress
- Automatically create a loop for post ID
- WP Knowledge Base Theme bug – Subcategories and Articles, Need to change WP_Query
- How to have Function of a plugin using global vars into a shortcode?
- set new link as permalink
- How to add a code for lastpostdate after/inside a specific menu link?
- Repeatable field within repeatable group of fields
- See output of a sql query while plugin installation in wordpress
- Shortcode Display From WordPress Dashboard Page Without Using post_id
- On selecting shortcode generate selected shortcode table inside page editor worrdpress
- Adding theme support for a custom header image
- Dynamic Post Type Variable echo as string?
- Undefined index notice when using the $args parameter in add_settings_field()
- Saving category as insert post
- WordPress plugin creating sidebar on the theme/page
- How do I / Is it possible to execute an external PHP file / function inside WordPress?
- Closed html class after counter = multiple of 3
- List sibling pages widget, exclude current page
- Ninja Forms – pull in some post related information
- Change taxonomy for categories
- Query category-specific, paginated posts and allow viewer to change sort order
- Accessing Variables Used In a Plugin Using PHPStorm + XDebug
- Make first child link default instead of its parent
- How to save the output of php variables used in inline css code to the main style.css?
- Echo the featured image of page assigned to blog in index.php
- Limit ads appearing more than three times
- Functions are causing errors
- How to set a cookie based on a page Get variable?
- Select All not working in a WordPress search filter
- Editing the contents of just one div on a page from wordpress
- How to show all of aspecific post type that has taxonomy and a specific term
- Headers for Contact Form are wrong
- White screen after login attempt
- Insert wordpress tags below posts via functions.php
- Why this plugin is not working?
- Multiple URL from Custom post name
- Adding header function to theme
- Why isn’t my custom function kicking in from my functions.php file?
- Revision History for Entire WordPress Site
- Admin-area broken through weird issues
- Postmeta not saving
- Display a query with multiple post types and same relationship on a single page
- magic-quotes – breaks admin totally
- wp_customize_image_control default value