class="comment-list"><?php /** * List comments using the default WordPress comments output * Allow parameter overrides through facebook_wp_list_comments filter */ wp_list_comments($_comment_options); ?> </<?php echo $_comment_options['style']; ?> ><?php unset($_comment_options); } // have_comments() // generate Facebook Comments Box markup $_facebook_comments = Facebook_Comments::comments_box(); if ($_facebook_comments) { /** * Output content before the Facebook Comments Box display area * * @since 1.3 */ do_action('facebook_comment_form_before'); echo '<div id="respond" class="comment-respond">'; echo $_facebook_comments; echo '</div>'; /** * Output content after the Facebook Comments Box display area * * @since 1.3 */
/** * Add Facebook functionality to the WordPress admin bar * * @since 1.1 * @param WP_Admin_Bar $wp_admin_bar existing WordPress admin bar object */ public function admin_bar() { if (isset($this->credentials) && isset($this->credentials['app_id'])) { if (get_option('facebook_comments_enabled')) { if (!class_exists('Facebook_Comments')) { require_once $this->plugin_directory . 'social-plugins/class-facebook-comments.php'; } Facebook_Comments::admin_bar_menu(); } } }
/** * Add Open Graph protocol markup to <head> * We use full IRIs for consistent mapping between mapped CURIE prefixes defined in a parent element and self-contained properties using a full IRI * * @since 1.0 * @link http://www.w3.org/TR/rdfa-syntax/#s_curieprocessing RDFa Core 1.1 CURIE and IRI processing */ public static function add_og_protocol() { global $post, $facebook_loader; $meta_tags = array(self::OGP_NS . 'site_name' => get_bloginfo('name'), self::OGP_NS . 'type' => 'website'); if (isset($facebook_loader)) { if (isset($facebook_loader->locale)) { $meta_tags[self::OGP_NS . 'locale'] = $facebook_loader->locale; } if (isset($facebook_loader->credentials) && isset($facebook_loader->credentials['app_id']) && $facebook_loader->credentials['app_id']) { $meta_tags[self::FB_NS . 'app_id'] = $facebook_loader->credentials['app_id']; } } if (is_home() || is_front_page()) { $meta_tags[self::OGP_NS . 'title'] = get_bloginfo('name'); $meta_tags[self::OGP_NS . 'description'] = get_bloginfo('description'); $meta_tags[self::OGP_NS . 'url'] = home_url(); } else { if (is_single() && empty($post->post_password)) { setup_postdata($post); $post_type = get_post_type(); $meta_tags[self::OGP_NS . 'url'] = apply_filters('facebook_rel_canonical', get_permalink()); if (post_type_supports($post_type, 'title')) { $meta_tags[self::OGP_NS . 'title'] = get_the_title(); } if (post_type_supports($post_type, 'excerpt')) { $description = ''; // did the publisher specify a custom excerpt? use it if (!empty($post->post_excerpt)) { $description = apply_filters('get_the_excerpt', $post->post_excerpt); } else { $description = $post->post_content; } $description = self::clean_description($description); if ($description) { $meta_tags[self::OGP_NS . 'description'] = $description; } } $meta_tags[self::OGP_NS . 'type'] = 'article'; $meta_tags[self::ARTICLE_NS . 'published_time'] = date('c', strtotime($post->post_date_gmt)); $meta_tags[self::ARTICLE_NS . 'modified_time'] = date('c', strtotime($post->post_modified_gmt)); if (post_type_supports($post_type, 'author') && isset($post->post_author)) { $meta_tags[self::ARTICLE_NS . 'author'] = get_author_posts_url($post->post_author); // adding an fb:admin grants comment moderation permissions for Comment Box if (get_option('facebook_comments_enabled') && user_can($post->post_author, 'moderate_comments')) { if (!class_exists('Facebook_Comments')) { require_once dirname(__FILE__) . '/social-plugins/class-facebook-comments.php'; } if (Facebook_Comments::comments_enabled_for_post_type($post)) { if (!class_exists('Facebook_User')) { require_once dirname(__FILE__) . '/facebook-user.php'; } $facebook_user_data = Facebook_User::get_user_meta($post->post_author, 'fb_data', true); if (is_array($facebook_user_data) && isset($facebook_user_data['fb_uid'])) { $meta_tags[self::FB_NS . 'admins'] = $facebook_user_data['fb_uid']; } unset($facebook_user_data); } } } // add the first category as a section. all other categories as tags $cat_ids = get_the_category(); if (!empty($cat_ids)) { $no_category = apply_filters('the_category', __('Uncategorized')); $cat = get_category($cat_ids[0]); if (!empty($cat) && isset($cat->name) && $cat->name !== $no_category) { $meta_tags[self::ARTICLE_NS . 'section'] = $cat->name; } //output the rest of the categories as tags unset($cat_ids[0]); if (!empty($cat_ids)) { $meta_tags[self::ARTICLE_NS . 'tag'] = array(); foreach ($cat_ids as $cat_id) { $cat = get_category($cat_id); if (isset($cat->name) && $cat->name !== $no_category) { $meta_tags[self::ARTICLE_NS . 'tag'][] = $cat->name; } unset($cat); } } } // add tags. treat tags as lower priority than multiple categories $tags = get_the_tags(); if ($tags) { if (!array_key_exists(self::ARTICLE_NS . 'tag', $meta_tags)) { $meta_tags[self::ARTICLE_NS . 'tag'] = array(); } foreach ($tags as $tag) { $meta_tags[self::ARTICLE_NS . 'tag'][] = $tag->name; } } // does current post type and the current theme support post thumbnails? if (post_type_supports($post_type, 'thumbnail') && function_exists('has_post_thumbnail') && has_post_thumbnail()) { list($post_thumbnail_url, $post_thumbnail_width, $post_thumbnail_height) = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full'); if (!empty($post_thumbnail_url)) { $image = array('url' => $post_thumbnail_url); if (!empty($post_thumbnail_width)) { $image['width'] = absint($post_thumbnail_width); } if (!empty($post_thumbnail_height)) { $image['height'] = absint($post_thumbnail_height); } $meta_tags[self::OGP_NS . 'image'] = array($image); } } $gallery_images = self::gallery_images($post); if (!empty($gallery_images)) { foreach ($gallery_images as $gallery_image) { // do not repeat the thumbnail if (isset($post_thumbnail_url) && $post_thumbnail_url === $gallery_image['url']) { continue; } $meta_tags[self::OGP_NS . 'image'][] = $gallery_image; } } unset($gallery_images); } else { if (is_author()) { $author = get_queried_object(); if (!($author && isset($author->ID))) { break; } $author_id = $author->ID; $meta_tags[self::OGP_NS . 'type'] = 'profile'; $meta_tags[self::OGP_NS . 'title'] = get_the_author_meta('display_name', $author_id); $meta_tags[self::OGP_NS . 'url'] = get_author_posts_url(get_the_author_meta('ID', $author_id)); $meta_tags[self::PROFILE_NS . 'first_name'] = get_the_author_meta('first_name', $author_id); $meta_tags[self::PROFILE_NS . 'last_name'] = get_the_author_meta('last_name', $author_id); $description = self::clean_description(get_the_author_meta('description', $author_id)); if ($description) { $meta_tags[self::OGP_NS . 'description'] = $description; } if (!class_exists('Facebook_User')) { require_once dirname(__FILE__) . '/facebook-user.php'; } $facebook_user_data = Facebook_User::get_user_meta($author_id, 'fb_data', true); if (is_array($facebook_user_data) && isset($facebook_user_data['third_party_id'])) { $meta_tags[self::FB_NS . 'profile_id'] = $facebook_user_data['third_party_id']; } unset($facebook_user_data); // no need to show username if there is only one if (is_multi_author()) { $meta_tags[self::PROFILE_NS . 'username'] = get_the_author_meta('login', $author_id); } } else { if (is_page()) { $meta_tags[self::OGP_NS . 'type'] = 'article'; $meta_tags[self::OGP_NS . 'title'] = get_the_title(); $meta_tags[self::OGP_NS . 'url'] = apply_filters('facebook_rel_canonical', get_permalink()); } } } } $meta_tags = apply_filters('fb_meta_tags', $meta_tags, $post); // default: true while Facebook crawler corrects its indexing of full IRI values if (apply_filters('facebook_ogp_prefixed', true)) { $meta_tags = self::prefixed_properties($meta_tags); } foreach ($meta_tags as $property => $content) { self::meta_elements($property, $content); } }
/** * Add Open Graph protocol markup to <head> * We use full IRIs for consistent mapping between mapped CURIE prefixes defined in a parent element and self-contained properties using a full IRI * * @since 1.0 * * @link http://www.w3.org/TR/rdfa-syntax/#s_curieprocessing RDFa Core 1.1 CURIE and IRI processing * @global stdClass|WP_Post $post WordPress post object for the current view * @global Facebook_Loader $facebook_loader * @return void */ public static function add_og_protocol() { global $post, $facebook_loader; $meta_tags = array(self::OGP_NS . 'site_name' => get_bloginfo('name'), self::OGP_NS . 'type' => 'website'); if (isset($facebook_loader)) { if (isset($facebook_loader->locale)) { $meta_tags[self::OGP_NS . 'locale'] = $facebook_loader->locale; } if (isset($facebook_loader->credentials) && isset($facebook_loader->credentials['app_id']) && $facebook_loader->credentials['app_id']) { $meta_tags[self::FB_NS . 'app_id'] = $facebook_loader->credentials['app_id']; } } if (is_home() || is_front_page()) { $meta_tags[self::OGP_NS . 'title'] = get_bloginfo('name'); $meta_tags[self::OGP_NS . 'description'] = get_bloginfo('description'); $meta_tags[self::OGP_NS . 'url'] = home_url(); } else { if (is_singular() && empty($post->post_password)) { setup_postdata($post); $post_type = get_post_type($post); /** * Canonical URL for the singular page. * * @since 1.1.6 * @param string absolute URI of the current post context */ $meta_tags[self::OGP_NS . 'url'] = apply_filters('facebook_rel_canonical', get_permalink($post->ID)); if (post_type_supports($post_type, 'title')) { $meta_tags[self::OGP_NS . 'title'] = get_the_title(); } if (post_type_supports($post_type, 'excerpt')) { $description = ''; // did the publisher specify a custom excerpt? use it if (!empty($post->post_excerpt)) { $description = apply_filters('get_the_excerpt', $post->post_excerpt); } else { $description = $post->post_content; } $description = self::clean_description($description); if ($description) { $meta_tags[self::OGP_NS . 'description'] = $description; } } $meta_tags[self::OGP_NS . 'type'] = self::get_post_og_type($post); $images = self::get_og_images($post); if (!empty($images)) { $meta_tags[self::OGP_NS . 'image'] = array_values($images); } unset($images); if ($meta_tags[self::OGP_NS . 'type'] === 'article') { // add article-specific properties $meta_tags = array_merge($meta_tags, self::get_article_properties($post)); } else { if ($meta_tags[self::OGP_NS . 'type'] === 'video.other') { // attempt to declare a video or videos $videos = self::get_og_videos($post); if (!empty($videos)) { $videos = array_values($videos); if (count($videos) === 1) { $video = array_shift($videos); if ($video && isset($video[self::VIDEO_NS])) { foreach ($video[self::VIDEO_NS] as $property => $value) { $meta_tags[self::VIDEO_NS . $property] = $value; } unset($video[self::VIDEO_NS]); } $meta_tags[self::OGP_NS . 'video'] = array($video); unset($video); } else { $videos_only = array(); foreach ($videos as $video) { unset($video[self::VIDEO_NS]); $videos_only[] = $video; } $meta_tags[self::OGP_NS . 'video'] = $videos_only; unset($videos_only); } } unset($videos); if (empty($meta_tags[self::OGP_NS . 'video'])) { // try to find well-known and easily mapped video provider WP_Embeds $videos = self::get_embed_videos($post); if (!empty($videos)) { foreach ($videos as $video_url => $video) { if (empty($video)) { continue; } if (isset($video['image'])) { $meta_tags[self::OGP_NS . 'image'][] = $video['image']; unset($video['image']); } $meta_tags[self::OGP_NS . 'video'] = array_values($video); } } unset($videos); } } } // include MP3s for audio post formats if (has_post_format('audio', $post)) { $audios = self::get_og_audio($post); if (!empty($audios)) { $meta_tags[self::OGP_NS . 'audio'] = array_values($audios); } unset($audios); } if (post_type_supports($post_type, 'author') && isset($post->post_author)) { // Facebook user helper if (!class_exists('Facebook_User')) { require_once $facebook_loader->plugin_directory . 'facebook-user.php'; } $facebook_user_data = Facebook_User::get_user_meta($post->post_author, 'fb_data', true); $author_fbid = ''; if (is_array($facebook_user_data) && isset($facebook_user_data['fb_uid'])) { $author_fbid = $facebook_user_data['fb_uid']; } unset($facebook_user_data); if ($author_fbid) { $meta_tags[self::FB_NS . 'profile_id'] = $author_fbid; // adding an fb:admin grants comment moderation permissions for Comment Box if (get_option('facebook_comments_enabled') && user_can($post->post_author, 'moderate_comments')) { if (!class_exists('Facebook_Comments')) { require_once $facebook_loader->plugin_directory . 'social-plugins/class-facebook-comments.php'; } if (Facebook_Comments::comments_enabled_for_post_type($post)) { $meta_tags[self::FB_NS . 'admins'] = $author_fbid; } } } unset($author_fbid); } } else { if (is_author()) { $author = get_queried_object(); if ($author && isset($author->ID)) { $author_id = $author->ID; $meta_tags[self::OGP_NS . 'type'] = 'profile'; $meta_tags[self::OGP_NS . 'title'] = get_the_author_meta('display_name', $author_id); $meta_tags[self::OGP_NS . 'url'] = get_author_posts_url(get_the_author_meta('ID', $author_id)); $meta_tags[self::PROFILE_NS . 'first_name'] = get_the_author_meta('first_name', $author_id); $meta_tags[self::PROFILE_NS . 'last_name'] = get_the_author_meta('last_name', $author_id); $description = self::clean_description(get_the_author_meta('description', $author_id)); if ($description) { $meta_tags[self::OGP_NS . 'description'] = $description; } // Facebook user helper if (!class_exists('Facebook_User')) { require_once $facebook_loader->plugin_directory . 'facebook-user.php'; } $facebook_user_data = Facebook_User::get_user_meta($author_id, 'fb_data', true); if (is_array($facebook_user_data) && isset($facebook_user_data['fb_uid'])) { $meta_tags[self::FB_NS . 'profile_id'] = $facebook_user_data['fb_uid']; } unset($facebook_user_data); // no need to show username if there is only one if (is_multi_author()) { $meta_tags[self::PROFILE_NS . 'username'] = get_the_author_meta('login', $author_id); } } unset($author); } else { if (is_page()) { $meta_tags[self::OGP_NS . 'type'] = 'article'; $meta_tags[self::OGP_NS . 'title'] = get_the_title(); // duplicate_hook $meta_tags[self::OGP_NS . 'url'] = apply_filters('facebook_rel_canonical', get_permalink()); } } } } /** * Customize Open Graph protocol for the site or page before output. * * Add, change, and delete Open Graph protocol values used to summarize a link shared on Facebook and create new Open Graph objects. * * @since 1.0 * @param array $meta_tags { * Open Graph protocol values to be output * * @type string Full IRI RDFa Core property * @type mixed property value or multiple values * } * @param stdClass|WP_Post $post the current post global if set */ $meta_tags = apply_filters('fb_meta_tags', $meta_tags, $post); /** * Control auto-prefixing or full IRI RDFa Core 1.1 properties output for the page. * * Use prefixed values (e.g. og:image) by default to maximize compatibility with indexers. Assumes prefix CURIE mappings will be set on <head> or <html> to properly map the prefixes or the publisher is not concerned with RDFa Core 1.1 compatibility and reserved prefixes. * * @since 1.1.6 * @param bool default true */ if (apply_filters('facebook_ogp_prefixed', true)) { $meta_tags = self::prefixed_properties($meta_tags); } foreach ($meta_tags as $property => $content) { self::meta_elements($property, $content); } }