Как это вы можете сделать это
function action_post_draft_to_publish($post){
if( $post->post_type == 'post' ) : //Check Post Type, You may update it accordingly for your need
$title = $post->post_title;
// Convert title to lowercase
$lowTitle = mb_convert_case($title, MB_CASE_LOWER, "UTF-8");
// Synonymous for replace
$synonymous = array(
'beautiful' => 'perect',
'vehicle' => 'car',
);
// Loop with word check and replace
foreach($synonymous as $key => $value) {
if( is_string($key) ) {
$stringKey = $key;
// Replace in title
if (strpos($lowTitle, $stringKey) !== false) {
$lowTitle = str_replace($stringKey, $value, $lowTitle);
}
}
}
wp_update_post( array(
'ID' => $post->ID,
'post_title' => $lowTitle //Use Your Updated Title Which You Want to Use
) );
endif; //Endif
}
add_action('draft_to_publish', 'action_post_draft_to_publish', 20);