jetpack_facebook_embed_handler

The Jetpack by WordPress.com jetpack facebook embed handler function.

Description

jetpack_facebook_embed_handler( $matches, $attr, $url ); 

Parameters (3)

0. $matches
The matches.
1. $attr
The attr.
2. $url
The url.

Usage

  1. if ( !function_exists( 'jetpack_facebook_embed_handler' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/modules/shortcodes/facebook.php'; 
  3.  
  4. // The matches. 
  5. $matches = null; 
  6.  
  7. // The attr. 
  8. $attr = null; 
  9.  
  10. // The url. 
  11. $url = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = jetpack_facebook_embed_handler($matches, $attr, $url); 
  15.  

Defined (1)

The function is defined in the following location(s).

/modules/shortcodes/facebook.php  
  1. function jetpack_facebook_embed_handler( $matches, $attr, $url ) { 
  2. if ( false !== strpos( $url, 'video.php' ) || false !== strpos( $url, '/videos/' ) ) { 
  3. $embed = sprintf( '<div class="fb-video" data-allowfullscreen="true" data-href="%s"></div>', esc_url( $url ) ); 
  4. } else { 
  5. $embed = sprintf( '<fb:post href="%s"></fb:post>', esc_url( $url ) ); 
  6.  
  7. // since Facebook is a faux embed, we need to load the JS SDK in the wpview embed iframe 
  8. if ( defined( 'DOING_AJAX' ) && DOING_AJAX && ! empty( $_POST['action'] ) && 'parse-embed' == $_POST['action'] ) { 
  9. return $embed . '<script src="//connect.facebook.net/en_US/all.js#xfbml=1"></script>'; 
  10. } else { 
  11. wp_enqueue_script( 'jetpack-facebook-embed', plugins_url( 'js/facebook.js', __FILE__ ), array( 'jquery' ), null, true ); 
  12. /** This filter is documented in modules/sharedaddy/sharing-sources.php */ 
  13. $fb_app_id = apply_filters( 'jetpack_sharing_facebook_app_id', '249643311490' ); 
  14. if ( ! is_numeric( $fb_app_id ) ) { 
  15. $fb_app_id = ''; 
  16. wp_localize_script( 
  17. 'jetpack-facebook-embed',  
  18. 'jpfbembed',  
  19. array( 
  20. 'appid' => $fb_app_id 
  21. ); 
  22. return $embed;