/** * 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; }
/** * 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 ''; }
/** * 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; }