function sfc_base_meta() { global $post; $options = get_option('sfc_options'); // exclude bbPress post types if (function_exists('bbp_is_custom_post_type') && bbp_is_custom_post_type()) { return; } $excerpt = ''; if (is_singular()) { global $wp_the_query; if ($id = $wp_the_query->get_queried_object_id()) { $post = get_post($id); } // get the content from the main post on the page $content = sfc_base_make_excerpt($post); $images = sfc_base_find_images($post); $video = sfc_base_find_video($post); $title = get_the_title(); $permalink = get_permalink(); echo "<meta property='og:type' content='article' />\n"; echo "<meta property='og:title' content='" . esc_attr($title) . "' />\n"; echo "<meta property='og:url' content='" . esc_url($permalink) . "' />\n"; echo "<meta property='og:description' content='" . esc_attr($content) . "' />\n"; if (!empty($images)) { foreach ($images as $image) { echo "<meta property='og:image' content='{$image}' />\n"; } } if (!empty($video)) { foreach ($video as $type => $value) { echo "<meta property='og:video{$type}' href='{$value}' />\n"; } } } else { if (is_home()) { echo "<meta property='og:type' content='blog' />\n"; echo "<meta property='og:title' content='" . get_bloginfo("name") . "' />\n"; echo "<meta property='og:url' content='" . esc_url(get_bloginfo("url")) . "' />\n"; } } // stuff on all pages echo "<meta property='og:site_name' content='" . get_bloginfo("name") . "' />\n"; echo "<meta property='fb:app_id' content='" . esc_attr($options["appid"]) . "' />\n"; }
function sfc_publish_meta_box($post) { $options = get_option('sfc_options'); if ($post->post_status == 'private') { echo '<p>' . __('Why would you put private posts on Facebook, for all to see?', 'sfc') . '</p>'; return; } if ($post->post_status !== 'publish') { echo '<p>' . __('After publishing the post, you can send it to Facebook from here.', 'sfc') . '</p>'; return; } // apply the content filters, in case some plugin is doing weird image stuff $content = apply_filters('the_content', $post->post_content); // look for the images to add with image_src $images = sfc_base_find_images($post); // build the attachment $permalink = apply_filters('sfc_publish_permalink', wp_get_shortlink($post->ID), $post->ID); $attachment['name'] = $post->post_title; $attachment['href'] = $permalink; if (!empty($post->post_excerpt)) { $attachment['description'] = sfc_publish_make_excerpt($post->post_excerpt); } else { $attachment['description'] = sfc_publish_make_excerpt($post->post_content); } // image attachments (up to 5, as that's all FB allows) $count = 0; foreach ($images as $image) { $attachment['media'][$count]['type'] = 'image'; $attachment['media'][$count]['src'] = $image; $attachment['media'][$count]['href'] = $permalink; $count++; if ($count == 5) { break; } } // Share link $action_links[0]['text'] = 'Share'; $action_links[0]['href'] = 'http://www.facebook.com/share.php?u=' . urlencode($permalink); $ui['method'] = 'stream.publish'; $ui['attachment'] = $attachment; $ui['action_links'] = $action_links; ?> <script type="text/javascript"> function sfcPersonalPublish() { FB.ui(<?php echo json_encode($ui); ?> ); } <?php if ($options['fanpage']) { $ui['actor_id'] = $options['fanpage']; } else { $ui['actor_id'] = $options['appid']; } ?> function sfcPublish() { FB.ui(<?php echo json_encode($ui); ?> ); } function sfcShowPubButtons() { jQuery('#sfc-publish-buttons').html('<input type="button" class="button-primary" onclick="sfcPublish(); return false;" value="<?php if ($options["fanpage"]) { echo addslashes(__('Publish to Facebook Fan Page', 'sfc')); } else { echo addslashes(__('Publish to Facebook Application', 'sfc')); } ?> " /><input type="button" class="button-primary" onclick="sfcPersonalPublish(); return false;" value="<?php echo addslashes(__('Publish to your Facebook Profile', 'sfc')); ?> " />'); } </script> <div id="sfc-publish-buttons"><p><?php _e('If you can see this, then there is some form of problem showing you the Facebook publishing buttons. This may be caused by a plugin conflict or some form of bad javascript on this page. Try reloading or disabling other plugins to find the source of the problem.', 'sfc'); ?> </p></div> <?php add_action('sfc_async_init', 'sfc_publish_show_buttons'); }