/**
  * convert an options array into an object
  *
  * @since 1.5
  *
  * @param array $values associative array
  * @return Facebook_Embedded_Post embedded post object
  */
 public static function fromArray($values)
 {
     if (!(is_array($values) && isset($values['href']))) {
         return;
     }
     $embed = new Facebook_Embedded_Post();
     if (isset($values['href']) && $values['href']) {
         $embed->setURL($values['href']);
     }
     if (isset($values['width'])) {
         $embed->setWidth(absint($values['width']));
     }
     if (isset($values['show_border']) && ($values['show_border'] === false || $values['show_border'] === 'false' || $values['show_border'] == 0)) {
         $embed->hideBorder();
     } else {
         $embed->showBorder();
     }
     return $embed;
 }
 /**
  * Generate a HTML div element with data-* attributes to be converted into a Facebook embedded post
  *
  * @since 1.5
  *
  * @param array $attributes shortcode attributes. overrides site options for specific button attributes
  * @param string $content shortcode content. no effect
  * @return string Follow Button div HTML or empty string if minimum requirements not met
  */
 public static function embedded_post($attributes, $content = null)
 {
     global $content_width;
     $options = shortcode_atts(array('href' => '', 'width' => 0, 'show_border' => true), $attributes, 'facebook_embedded_post');
     $options['href'] = trim($options['href']);
     if (!$options['href']) {
         return '';
     }
     if (!class_exists('Facebook_Embedded_Post')) {
         require_once dirname(__FILE__) . '/class-facebook-embedded-post.php';
     }
     $options['width'] = absint($options['width']);
     if (!Facebook_Embedded_Post::isValidWidth($options['width'])) {
         unset($options['width']);
         if (isset($content_width)) {
             $width = absint($content_width);
             if (Facebook_Embedded_Post::isValidWidth($width)) {
                 $options['width'] = $width;
             }
         }
     }
     $embed = Facebook_Embedded_Post::fromArray($options);
     if (!$embed) {
         return '';
     }
     return $embed->asHTML(array('class' => array('fb-social-plugin')));
 }
Example #3
0
 /**
  * Generate a HTML div element with data-* attributes to be converted into a Facebook embedded post
  *
  * @since 1.5
  *
  * @param array $attributes shortcode attributes. overrides site options for specific button attributes
  * @param string $content shortcode content. no effect
  * @return string Follow Button div HTML or empty string if minimum requirements not met
  */
 public static function embedded_post($attributes, $content = null)
 {
     $options = shortcode_atts(array('href' => '', 'show_border' => true), $attributes, 'facebook_embed_post');
     $options['href'] = trim($options['href']);
     if (!$options['href']) {
         return '';
     }
     if (!class_exists('Facebook_Embedded_Post')) {
         require_once dirname(__FILE__) . '/class-facebook-embedded-post.php';
     }
     $embed = Facebook_Embedded_Post::fromArray($options);
     if (!$embed) {
         return '';
     }
     return $embed->asHTML(array('class' => array('fb-social-plugin')));
 }