Encrypt / Decrypt Post Title and Details

To change post content before it gets saved you can use wp_insert_post_data filter.

I’m using in this example just a simple/dummy way to represent the encryption, I’m just replacing each char with the correspondent ascii code. It should be replaced by your encryption method.

add_filter( 'wp_insert_post_data' , 'encrypt_post' , 99, 1 );
function encrypt_post( $data ) {
    // check if it's a post
    if('post' !== $data['post_type']) {
            return $data;
    }

    // this is just for demonstration purposes (a simple char to ascii code conversion), it should be replaced by your encryption method
    $title = str_split( $data['post_title'] );
    $title = array_map( function($n) { return ord( $n ); }, $title );
    $title = implode( ".", $title );
    $data['post_title'] =  $title;

    return $data;
}

And then to decrypt the post title on edit page, you can use title_edit_pre filter:

function decrypt_post_title( $title, $post_id ) {
    if( 'post' !== get_post_type( $post_id ) ) {
        return $title;
    }

    // same dummy ascii code to char conversion
    $title = explode( '.', $title );
    $title = array_map( function($n) { return chr( $n ); }, $title );
    $title = implode( "", $title );

    return $title;
}
add_filter( 'title_edit_pre', 'decrypt_post_title', 99, 2 );

To decrypt other post fields you would need to check the other dynamic *_edit_pre filters.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)