/** * Generate markup suitable for the Facebook SDK for JavaScript based on site options. * * @since 1.1 * * @param array $options site options for the comments box social plugin * @return string HTML5 div with data attributes for interpretation by the Facebook SDK for JavaScript at runtime */ public static function js_sdk_markup($options) { if (!is_array($options)) { return ''; } if (!empty($options['href'])) { $options['href'] = apply_filters('facebook_rel_canonical', get_permalink()); } if (!class_exists('Facebook_Comments_Box')) { require_once dirname(__FILE__) . '/class-facebook-comments-box.php'; } $comments_box = Facebook_Comments_Box::fromArray($options); if ($comments_box) { $comments_box_attributes = array('class' => array('fb-social-plugin', 'comment-form')); $wp_comment_form_args = apply_filters('comment_form_defaults', array('source' => 'facebook', 'id_form' => 'commentform')); if (is_array($wp_comment_form_args) && isset($wp_comment_form_args['id_form'])) { $comments_box_attributes['id'] = $wp_comment_form_args['id_form']; } unset($wp_comment_form_args); $comments_jssdk_div = $comments_box->asHTML($comments_box_attributes); if ($comments_jssdk_div) { return "\n" . $comments_jssdk_div . "\n"; } } return ''; }
/** * 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; }
/** * Generate markup suitable for the Facebook JavaScript SDK based on site options * * @since 1.1 * @param array $options site options for the comments box social plugin * @return string HTML5 div with data attributes for interpretation by the Facebook JavaScript SDK at runtime */ public static function js_sdk_markup($options) { if (!is_array($options)) { return ''; } if (!empty($options['href'])) { $options['href'] = apply_filters('facebook_rel_canonical', get_permalink()); } if (!class_exists('Facebook_Comments_Box')) { require_once dirname(__FILE__) . '/class-facebook-comments-box.php'; } $comments_box = Facebook_Comments_Box::fromArray($options); if ($comments_box) { $comments_jssdk_div = $comments_box->asHTML(array('class' => array('fb-social-plugin'))); if ($comments_jssdk_div) { return "\n" . $comments_jssdk_div . "\n"; } } return ''; }