Generating embed code for users to share

Try following code. This will display embed code in the bottom of the page.

<?php
add_filter('the_content','my_custom_embed_code');
function my_custom_embed_code( $content ){
  global $post;

  if ( 'page' == $post->post_type ) {
    $embed_code="";
    $page_url = esc_url( get_permalink($post->ID ) ) ;
    $embed_code .= '<object data="https://wordpress.stackexchange.com/questions/160604/.$page_url." width="100%" height="500"><embed src="https://wordpress.stackexchange.com/questions/160604/.$page_url." width="100%"   height="500"></embed> Error: Embedded data could not be displayed.     Visit <a title="'.esc_attr($post->        post_title).'" href=""https://wordpress.stackexchange.com/questions/160604/.$page_url."">Visit</a></object>';
    $content = $content . '<div class="embed-wrap">'.esc_html($embed_code).'</div>';
  }
  return $content;

}