Edit settings. Version: 1.4 Author: April Hodge Silver Author URI: http://springthistle.com */ function ahsfl_options() { add_submenu_page('themes.php', 'Facebook Like', 'Facebook Like', 8, basename(__FILE__), 'ahsfl_options_page'); } /** * Build up all the params for the button */ function ahsfl_build_options() { // get the post varibale (should be in the loop) global $post; // get the permalink if (get_post_status($post->ID) == 'publish') { $url = get_permalink(); } $button = '?href=' . urlencode($url); // which style if (get_option('ahsfl_version') == 'button_count') { $button .= '&layout=button_count'; } else { $button .= '&layout=standard'; } // show faces? if (get_option('ahsfl_faces') == 'false') { $button .= '&show_faces=false'; } else { $button .= '&show_faces=true'; } // which verb if (get_option('ahsfl_verb') == 'recommend') { $button .= '&action=recommend'; } else { $button .= '&action=like'; } // which colors if (get_option('ahsfl_colorscheme') == 'dark') { $button .= '&colorscheme=dark'; } else if (get_option('ahsfl_colorscheme') == 'evil'){ $button .= '&colorscheme=evil'; } else { $button .= '&colorscheme=light'; } // which size $button .= '&width='.get_option('ahsfl_width'); // return all the params return $button; } /** * Generate the iFrame render of the button */ function ahsfl_generate_button() { // build up the outer style $button = '
'; $button .= '
'; // return the iframe code return $button; } /** * Gets run when the content is loaded in the loop */ function ahsfl_update($content) { global $post; // add the manual option, code added by kovshenin if (get_option('ahsfl_where') == 'manual') { return $content; } // is it a page if (get_option('ahsfl_display_page') == null && is_page()) { return $content; } // are we on the front page if (get_option('ahsfl_display_front') == null && is_home()) { return $content; } // are we in a feed if (is_feed()) { return $content; } // are we in a feed - for future investigation if (is_feed()) { $button = ahsfl_generate_static_button(); $where = 'ahsfl_rss_where'; } else { $button = ahsfl_generate_button(); $where = 'ahsfl_where'; } // are we displaying in a feed if (is_feed() && get_option('ahsfl_display_rss') == null) { return $content; } // are we just using the shortcode if (get_option($where) == 'shortcode') { return str_replace('[facebook-like-button]', $button, $content); } else { // if we have switched the button off if (get_post_meta($post->ID, 'facebooklikebutton') == null) { if (get_option($where) == 'beforeandafter') { // adding it before and after return $button . $content . $button; } else if (get_option($where) == 'before') { // just before return $button . $content; } else { // just after return $content . $button; } } else { // not at all return $content; } } } // Manual output function facebooklikebutton() { if (get_option('ahsfl_where') == 'manual') { return ahsfl_generate_button(); } else { return false; } } // Remove the filter excerpts function ahsfl_remove_filter($content) { if (!is_feed()) { remove_action('the_content', 'ahsfl_update'); } return $content; } function ahsfl_get_image($postid,$size='thumbnail') { if (function_exists('has_post_thumbnail')) { if (has_post_thumbnail($postid)) { $image_id = get_post_thumbnail_id(); $image_url = wp_get_attachment_image_src($image_id,$size); $image_url = $image_url[0]; return $image_url; } } $arrImages =& get_children('post_type=attachment&post_mime_type=image&post_parent='.$postid ); if ($arrImages) { // Get array keys representing attached image numbers $arrKeys = array_keys($arrImages); // Get the first image attachment $iNum = $arrKeys[0]; // return the url for the attachment $imginfo = wp_get_attachment_image_src($iNum,$size); return $imginfo[0]; } else { return ''; } } function ahsfl_head() { global $post; if (get_option('ahsfl_defaultimg') == null) $defaultimg = get_bloginfo('stylesheet_directory').'/images/default_icon.jpg'; else $defaultimg = get_option('ahsfl_defaultimg'); $postimg = ahsfl_get_image($post->ID); if (empty($postimg)) $postimg = $defaultimg; ?>

Settings for Facebook 'Like' button

Display name="ahsfl_display_page" id="ahsfl_display_page" group="ahsfl_display"/>
name="ahsfl_display_front" id="ahsfl_display_front" group="ahsfl_display"/>
Position
If you choose "manual," just put <?php echo ahsfl_generate_button(); ?>
in your theme file where you want your button to show up.
Type name="ahsfl_version" id="ahsfl_version_standard" group="ahsfl_version"/>
name="ahsfl_version" id="ahsfl_version_button_count" group="ahsfl_version" />
Verb to use name="ahsfl_verb" id="ahsfl_verb_like" group="ahsfl_verb"/>
name="ahsfl_verb" id="ahsfl_verb_recommend" group="ahsfl_verb" />
Show faces below button? name="ahsfl_faces" id="ahsfl_faces_true" group="ahsfl_faces"/>
name="ahsfl_faces" id="ahsfl_faces_true" group="ahsfl_faces" />
Color Scheme name="ahsfl_colorscheme" id="ahsfl_colorscheme_light" group="ahsfl_colorscheme"/>
name="ahsfl_colorscheme" id="ahsfl_colorscheme_dark" group="ahsfl_colorscheme" />
name="ahsfl_colorscheme" id="ahsfl_colorscheme_evil" group="ahsfl_colorscheme" />
px wide   by   px high
What width do you want it to be? Generally, you'll want 200-450 for the standard widget and 100 for the small version. The default height is 40px; if you're using the small version of the button 20px is tall enough; if you're showing faces, you'll want more height.

Add style to the div that surrounds the button E.g. float: left; margin-right: 10px;.
Or you can add .facebook_like_button to your stylesheet.

What is the default image for your website, in case the single post doesn't have an image, or in case the user wants to 'like' a whole page. Use a full URL, starting with http://