You need a post_meta
field to let an author decide after how many paragraphs the ad is inserted, if you want to do it like that, and not with a shortcode.
So create a custom field called f711_insert_after_no_p
, and use your function like this:
if ( is_single() && ! is_admin() ) {
$show_after = get_field('show_after');
return prefix_insert_after_paragraph( $ad_code, get_post_meta( get_the_ID(), 'f711_insert_after_no_p', true ), $content );
}
Be sure to validate the input to only allow integers, or do this in the output.
I think for ACF the code (instead of get_post_meta( get_the_ID(), 'f711_insert_after_no_p', true )
) would be
get_the_field( 'f711_insert_after_no_p' )