I want to edit the content before save to database for the first time only when add a new post, so i check the path if it's at the post-new.php i want to apply the filter, but it's not working. anyone know how to solve this ?
$pagePath = parse_url( $_SERVER['REQUEST_URI'] );
$pagePath = $pagePath['path'];
$pagePath = substr($pagePath, 1);
if($pagePath === 'wp-admin/post-new.php'){
function my_filter_function_name( $content ) {
return $content . 'text before save to db';
}
add_filter( 'content_save_pre', 'my_filter_function_name', 10, 1 );
}
$page_now
or current_screen() to know which page is running, to be sure that the filter can fires.