/** * Sanitize Like Button settings before they are saved to the database * * @since 1.1 * @param array $options Like Button options * @return array clean option sets. note: we remove Like 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(); } self::require_like_button_builder(); // Handle like button display preferences first $clean_options = parent::sanitize_options($options); if (isset($clean_options['show_on'])) { self::update_display_conditionals('like', $clean_options['show_on'], self::get_show_on_choices('all')); unset($clean_options['show_on']); } unset($options['show_on']); $like_button = Facebook_Like_Button::fromArray($options); if ($like_button) { $like_button->validate(); return array_merge($clean_options, self::html_data_to_options($like_button->toHTMLDataArray())); } return $clean_options; }
/** * Sanitize Follow Button settings before they are saved to the database. * * @since 1.1 * * @param array $options Follow Button options * @return array clean option sets. note: we remove Follow 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(); } self::require_follow_button_builder(); // Handle display preferences first $clean_options = parent::sanitize_options($options); if (isset($clean_options['show_on'])) { self::update_display_conditionals('follow', $clean_options['show_on'], self::get_show_on_choices()); unset($clean_options['show_on']); } unset($options['show_on']); if (isset($options['show_faces'])) { $options['show_faces'] = true; } else { $options['show_faces'] = false; } if (isset($options['width'])) { $options['width'] = absint($options['width']); } // href required for follow button // set href contextual to the post author, not at settings // fake it here to pass sanitization, then remove before save $options['href'] = 'https://www.facebook.com/zuck'; $follow_button = Facebook_Follow_Button::fromArray($options); if ($follow_button) { $follow_button_options = self::html_data_to_options($follow_button->toHTMLDataArray()); // remove the dummy value set above // remove here instead of html_data_to_options to separate widget usage with its real href unset($follow_button_options['href']); return array_merge($clean_options, $follow_button_options); } return $clean_options; }
/** * 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; }
/** * Process changes to mentions options * * @since 1.1 * @param array $options form options */ public static function sanitize_mentions_options($options) { if (!is_array($options) || empty($options)) { return array(); } if (isset($options['show_on']) || isset($options['position'])) { if (!class_exists('Facebook_Social_Plugin_Button_Settings')) { require_once dirname(__FILE__) . '/settings-social-plugin-button.php'; } $options = Facebook_Social_Plugin_Button_Settings::sanitize_options($options); if (isset($options['show_on'])) { Facebook_Social_Plugin_Button_Settings::update_display_conditionals('mentions', $options['show_on'], Facebook_Social_Plugin_Button_Settings::get_show_on_choices('all')); unset($options['show_on']); } // limit what is stored to our whitelist of properties if (isset($options['position'])) { return array('position' => $options['position']); } } return array(); }