fb_embed_posts

Plugin Name: Facebook Posts Embedded.

Defined (1)

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

/plugin.php  
  1. class fb_embed_posts { 
  2. public function __construct() { 
  3. add_shortcode ('fb_embed_post', array (&$this, 'shortcode') ); 
  4. add_action ('admin_init', array (&$this, 'add_shortcode_button')); 
  5.  
  6. public function shortcode ($atts) { 
  7. extract( shortcode_atts( array( 
  8. 'href' => false,  
  9. 'width' => '550',  
  10. ), $atts ) ); 
  11.  
  12. if (!$href) 
  13. return ''; 
  14.  
  15. ob_start (); 
  16. ?> 
  17. <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> 
  18. <fb:post href="<?php echo $href?>" width="<?php echo $width?>"></fb:post> 
  19. <?php 
  20.  
  21. $c = ob_get_contents (); ob_clean (); 
  22. return $c; 
  23.  
  24. function add_shortcode_button () { 
  25. if (current_user_can('edit_posts') && current_user_can ('edit_pages')) { 
  26. add_filter ('mce_external_plugins', array ($this, 'add_shortcode_plugin')); 
  27. add_filter ('mce_buttons', array ($this, 'register_shortcode_button')); 
  28. function register_shortcode_button ($buttons) { 
  29. array_push ($buttons, "fb_embed_post"); 
  30. return $buttons; 
  31. function add_shortcode_plugin ($plugin_array) { 
  32. if (function_exists ('wp_enqueue_media')) { 
  33. wp_enqueue_media (); 
  34. } else { 
  35. wp_enqueue_style ('thickbox'); 
  36. wp_enqueue_script ('media-upload'); 
  37. wp_enqueue_script ('thickbox'); 
  38.  
  39. $plugin_array['fb_embed_post'] = plugins_url ('js/shortcode.js', plugin_basename (__FILE__)); 
  40. return $plugin_array;