Skip to content

Instantly share code, notes, and snippets.

@Apina
Created March 14, 2013 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Apina/30ee474d2a340b55416c to your computer and use it in GitHub Desktop.
Save Apina/30ee474d2a340b55416c to your computer and use it in GitHub Desktop.
This needs to replace the default Facebook code in the social addons espresso-social.php file. An API key will be needed from Facebook ( https://developers.facebook.com/ ) to replace the text XXX_API_XXX on line 26
/* * **********************
* Facebook Button *
* ********************** */
if (!function_exists('espresso_facebook_button')) {
function espresso_insert_to_head() {
ob_start();
// this will add the FB scripts needed and a style for the comment box that pops up.
?>
<style>
.facebook-button div span iframe {
min-width:450px;
}
</style>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=XXX_API_XXX";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<?php
$espresso_fb_scripts = ob_get_clean();
echo $espresso_fb_scripts;
}
add_action ('wp_head', 'espresso_insert_to_head');
function espresso_facebook_button($event_id) {
//Override this function using the Custom Files Addon (http://eventespresso.com/download/add-ons/custom-files-addon/)
global $espresso_facebook;
$registration_url = $permalink . '?ee=' . $event_id; // this breaks if they aren't using pretty permalinks
//http://kovshenin.com/2012/current-url-in-wordpress/
global $wp;
$espresso_url = add_query_arg( $wp->query_string, '', home_url( $wp->request ) );
$espresso_combined_url = $espresso_url . $registration_url;
// new button
$button = '<div style="overflow:visible;" class="fb-like"';
$button .= ' data-href="' . urldecode($espresso_combined_url) . '"';
$button .= ' data-send="false"';
$button .= ' data-width="' . $espresso_facebook['espresso_facebook_width'] . '"';
$button .= ' data-show-faces="' . $espresso_facebook['espresso_facebook_faces'] . '"';
$button .= ' data-layout="' .$espresso_facebook['espresso_facebook_layout']. '"';
$button .= ' data-font="' .$espresso_facebook['espresso_facebook_font']. '"';
$button .= ' data-colorscheme="' .$espresso_facebook['espresso_facebook_colorscheme']. '"';
$button .= '></div>';
return $button;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment