When do we use wp_slash?

Correct, if you are duplicating a post in WordPress, you do not need to use wp_slash() to escape the data.

The purpose of wp_slash() is to add slashes to the data to prepare it for storage in the database. When you are duplicating a post, you are not directly inserting or updating data in the database, so wp_slash() is not necessary.

The caution against using wp_slash() to escape data going directly into an SQL query is because it is not a secure way to protect against SQL injection attacks. Instead, you should use prepared statements or other techniques to properly escape data before including it in an SQL query.

tech