/**
  * convert an options array into an object
  *
  * @since 1.1
  *
  * @param array $values associative array
  * @return Facebook_Send_Button send button object
  */
 public static function fromArray($values)
 {
     if (!is_array($values) || empty($values)) {
         return;
     }
     $send_button = new Facebook_Send_Button();
     if (isset($values['href']) && is_string($values['href'])) {
         $send_button->setURL($values['href']);
     }
     if (isset($values['font'])) {
         $send_button->setFont($values['font']);
     }
     if (isset($values['colorscheme'])) {
         $send_button->setColorScheme($values['colorscheme']);
     }
     if (isset($values['ref'])) {
         $send_button->setReference($values['ref']);
     }
     if (isset($values['kid_directed_site']) && ($values['kid_directed_site'] === true || $values['kid_directed_site'] === 'true' || $values['kid_directed_site'] == 1)) {
         $send_button->isKidDirectedSite();
     }
     return $send_button;
 }
Ejemplo n.º 2
0
 /**
  * Sanitize widget form values as they are saved.
  *
  * @see WP_Widget::update()
  *
  * @since 1.0
  *
  * @param array $new_instance Values just sent to be saved.
  * @param array $old_instance Previously saved values from database.
  *
  * @return array Updated safe values to be saved.
  */
 public function update($new_instance, $old_instance)
 {
     $instance = array();
     $new_instance = (array) $new_instance;
     if (!empty($new_instance['title'])) {
         $instance['title'] = strip_tags($new_instance['title']);
     }
     if (!class_exists('Facebook_Send_Button')) {
         require_once dirname(dirname(__FILE__)) . '/class-facebook-send-button.php';
     }
     $send_button = Facebook_Send_Button::fromArray($new_instance);
     if ($send_button) {
         return array_merge($instance, $send_button->toHTMLDataArray());
     }
     return $instance;
 }
 /**
  * Sanitize widget form values as they are saved.
  *
  * @see WP_Widget::update()
  *
  * @param array $new_instance Values just sent to be saved.
  * @param array $old_instance Previously saved values from database.
  *
  * @return array Updated safe values to be saved.
  */
 public function update($new_instance, $old_instance)
 {
     $instance = array();
     if (!empty($new_instance['title'])) {
         $instance['title'] = strip_tags($new_instance['title']);
     }
     if (!class_exists('Facebook_Send_Button')) {
         require_once dirname(dirname(__FILE__)) . '/class-facebook-send-button.php';
     }
     $send_button = Facebook_Send_Button::fromArray($new_instance);
     if ($send_button) {
         $send_button_options = $send_button->toHTMLDataArray();
         foreach ($send_button_options as $key => $value) {
             $instance[str_replace('-', '_', $key)] = $value;
         }
     }
     return $instance;
 }
 /**
  * convert an options array into an object
  *
  * @since 1.1
  * @param array $values associative array
  * @return Facebook_Send_Button send button object
  */
 public static function fromArray($values)
 {
     if (!is_array($values) || empty($values)) {
         return;
     }
     $send_button = new Facebook_Send_Button();
     if (isset($values['href']) && is_string($values['href'])) {
         $send_button->setURL($values['href']);
     }
     if (isset($values['font'])) {
         $send_button->setFont($values['font']);
     }
     if (isset($values['colorscheme'])) {
         $send_button->setColorScheme($values['colorscheme']);
     }
     if (isset($values['ref'])) {
         $send_button->setReference($values['ref']);
     }
     return $send_button;
 }
Ejemplo n.º 5
0
/**
 * Generate HTML for a send button based on passed options
 *
 * @since 1.1
 * @param array $options customizations
 * @return string send button HTML for use with the JavaScript SDK
 */
function facebook_get_send_button($options = array())
{
    if (!class_exists('Facebook_Send_Button')) {
        require_once dirname(__FILE__) . '/class-facebook-send-button.php';
    }
    $send_button = Facebook_Send_Button::fromArray($options);
    if (!$send_button) {
        return '';
    }
    $html = $send_button->asHTML(array('class' => array('fb-social-plugin')));
    if ($html) {
        return "\n" . $html . "\n";
    }
    return '';
}
Ejemplo n.º 6
0
 /**
  * Sanitize Send Button settings before they are saved to the database
  *
  * @since 1.1
  *
  * @param array $options Send Button options
  * @return array clean option sets. note: we remove Send Button social plugin default options, storing only custom settings (e.g. dark color scheme stored, light is default and therefore not stored)
  */
 public static function sanitize_options($options)
 {
     if (!is_array($options) || empty($options)) {
         return array();
     }
     if (!class_exists('Facebook_Send_Button')) {
         require_once dirname(dirname(__FILE__)) . '/social-plugins/class-facebook-send-button.php';
     }
     // Handle display preferences first
     $clean_options = parent::sanitize_options($options);
     if (isset($clean_options['show_on'])) {
         self::update_display_conditionals('send', $clean_options['show_on'], self::get_show_on_choices('all'));
         unset($clean_options['show_on']);
     }
     unset($options['show_on']);
     $send_button = Facebook_Send_Button::fromArray($options);
     $send_button_options = $send_button->toHTMLDataArray();
     if (!empty($send_button_options)) {
         return array_merge($clean_options, $send_button_options);
     }
     return $clean_options;
 }