Place a URL parameter value inside a WordPress short code

If it is a shortcode you’re developing yourself, then you could add the url parameter checking / getting for example like this,

add_shortcode( 'EmbedMe', 'embedme_callback' );
function embedme_callback( $atts ) {

  $defaults = array(
    'file' => ''
  );
  $atts = shortcode_atts( $defaults, $atts, 'EmbedMe' );

  if ( 
    'source' === $atts['file']
    && ! empty( $_GET['source'] )
    && $file = esc_url_raw( $_GET['source'], array( 'http', 'https' ) ) 
  ) {
    $atts['file'] = $file;
  }

  // some code

  return $html;  
}

Above we check, if the file attribute is set to “source” and that it is also set as a GET (url) parameter. And for good measures the url parameter is passed through escape function to make sure it is in proper format.

If the shortcode is developed by someone else, then you should check, if it provides a filter for modifying the attributes (or output). If so, then you can hook a custom function to the filter and do the GET parameter checking inside your function. Like so,

add_filter( 'shortcode_atts_EmbedMe', 'filter_EmbedMe_atts' );
function filter_EmbedMe_atts( $atts ) {
  if (
    isset( $atts['file'] )
    && 'source' === $atts['file']
    && ! empty( $_GET['source'] )
    && $file = esc_url_raw( $_GET['source'], array( 'http', 'https' ) )
  ) {
    $atts['file'] = $file;
  }
  return $atts;
}