Change permalink structure hidden button edit

The post_link hook has a third parameter named $leavename:

$leavename
(bool) Whether to keep the post name.

So what that means is, if $leavename is true, then the post name/slug should be kept in the permalink and thus it needs to contain %postname% (or %pagename% for the page post type) instead of being replaced with the actual post slug (or something else).

Because if that placeholder is missing, the permalink will become non-editable on the post editing screen, therefore the Edit button is disabled. (See get_sample_permalink_html(), specifically this part, and that function is the one which generates the post permalink editor)

So to fix the issue, define the variable: function idinheiro_custom_permalink( $permalink, $post, $leavename ) and change the "https://wordpress.stackexchange.com/" . $post->post_name ."https://wordpress.stackexchange.com/" to:

"https://wordpress.stackexchange.com/" . ( $leavename ? '%postname%' : $post->post_name ) ."https://wordpress.stackexchange.com/"