/**
  * Sanitize social plugin button common settings before they are saved to the database
  *
  * @since 1.1
  *
  * @uses Facebook_Social_Plugin_Settings::sanitize_options()
  * @param array $options social plugin button options
  * @return array clean option set
  */
 public static function sanitize_options($options)
 {
     $clean_options = parent::sanitize_options($options);
     if (isset($options['position']) && in_array($options['position'], self::$position_choices, true)) {
         $clean_options['position'] = $options['position'];
     } else {
         $clean_options['position'] = 'both';
     }
     return $clean_options;
 }
 /**
  * Sanitize Comments Box settings before they are saved to the database
  *
  * @since 1.1
  * @param array $options Comments Box options
  * @return array clean option sets. note: we remove Comments Box 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_Comments_Box')) {
         require_once dirname(dirname(__FILE__)) . '/social-plugins/class-facebook-comments-box.php';
     }
     // Handle display preferences first
     $clean_options = parent::sanitize_options($options);
     if (isset($clean_options['show_on'])) {
         self::update_display_conditionals('comments', $clean_options['show_on'], self::post_types_supporting_comments());
         if (empty($clean_options['show_on'])) {
             delete_option('facebook_comments_enabled');
         } else {
             update_option('facebook_comments_enabled', '1');
         }
         unset($clean_options['show_on']);
     } else {
         delete_option('facebook_comments_enabled');
     }
     unset($options['show_on']);
     $comments_box = Facebook_Comments_Box::fromArray($options);
     if ($comments_box) {
         return array_merge($clean_options, self::html_data_to_options($comments_box->toHTMLDataArray()));
     }
     return $clean_options;
 }
 /**
  * Sanitize Recommendations Bar settings before they are saved to the database.
  *
  * @since 1.1
  *
  * @param array $options recommendation bar options
  * @return array clean option sets. note: we remove Recommendation Button social plugin default options, storing only custom settings (e.g. recommend action preference value stored, like is not stored)
  */
 public static function sanitize_options($options)
 {
     if (!is_array($options) || empty($options)) {
         return array();
     }
     if (isset($options['trigger']) && $options['trigger'] === 'pct') {
         $pct = 0;
         if (isset($options['trigger_pct'])) {
             $pct = absint($options['trigger_pct']);
             unset($options['trigger_pct']);
         }
         if ($pct > 0) {
             $options['trigger'] = $pct . '%';
         } else {
             $options['trigger'] = 'onvisible';
         }
     }
     foreach (array('read_time', 'num_recommendations', 'max_age') as $option) {
         if (isset($options[$option])) {
             $options[$option] = absint($options[$option]);
         }
     }
     self::require_recommendations_bar_builder();
     // Handle like button display preferences first
     $clean_options = parent::sanitize_options($options);
     if (isset($clean_options['show_on'])) {
         self::update_display_conditionals('recommendations_bar', $clean_options['show_on'], self::get_show_on_choices());
         unset($clean_options['show_on']);
     }
     unset($options['show_on']);
     $bar = Facebook_Recommendations_Bar::fromArray($options);
     if ($bar) {
         return array_merge($clean_options, self::html_data_to_options($bar->toHTMLDataArray()));
     }
     return $clean_options;
 }