Author: Seth Shoultes
Author URI: http://www.shoultes.net
Copyright 2010 Seth Shoultes (email : seth@eventespresso.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//Define the version of the plugin
function espresso_social_version() {
return '1.1.4';
}
//Update notifications
add_action('action_hook_espresso_social_update_api', 'ee_social_load_pue_update');
function ee_social_load_pue_update() {
global $org_options, $espresso_check_for_updates;
if ( $espresso_check_for_updates == false )
return;
if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'class/pue/pue-client.php')) { //include the file
require(EVENT_ESPRESSO_PLUGINFULLPATH . 'class/pue/pue-client.php' );
$api_key = $org_options['site_license_key'];
$host_server_url = 'http://eventespresso.com';
$plugin_slug = 'espresso-social';
$options = array(
'apikey' => $api_key,
'lang_domain' => 'event_espresso',
'checkPeriod' => '24',
'option_key' => 'site_license_key',
'options_page_slug' => 'event_espresso'
);
$check_for_updates = new PluginUpdateEngineChecker($host_server_url, $plugin_slug, $options); //initiate the class and start the plugin update engine!
}
}
if (is_admin()) {
add_action('plugins_loaded', 'espresso_social_load_admin_file');
}
function espresso_social_load_admin_file() {
if ( function_exists('espresso_version') && espresso_version() >= '3.2' ){
require_once('social_admin.php');
} else {
require_once('social_admin_classic.php');
}
}
define("ESPRESSO_SOCIAL_VERSION", espresso_social_version());
//Define the plugin directory and path
define("ESPRESSO_SOCIAL_PLUGINPATH", "/" . plugin_basename(dirname(__FILE__)) . "/");
define("ESPRESSO_SOCIAL_PLUGINFULLPATH", WP_PLUGIN_DIR . ESPRESSO_SOCIAL_PLUGINPATH);
define("ESPRESSO_SOCIAL_PLUGINFULLURL", WP_PLUGIN_URL . ESPRESSO_SOCIAL_PLUGINPATH);
//Globals
global $espresso_facebook;
$espresso_facebook = get_option('espresso_facebook_settings');
global $espresso_twitter;
$espresso_twitter = get_option('espresso_twitter_settings');
global $espresso_google;
$espresso_google = get_option('espresso_google_settings');
/* just say no to stumbleupon - cb #626
global $espresso_stumbleupon;
$espresso_stumbleupon = get_option('espresso_stumbleupon_settings');
*/
//Install the plugin
function espresso_social_install() {
// Install Facebook Options
$espresso_facebook = array(
'espresso_facebook_layout' => 'button_count',
'espresso_facebook_faces' => 'true',
'espresso_facebook_action' => 'like',
'espresso_facebook_font' => 'arial',
'espresso_facebook_colorscheme' => 'light',
'espresso_facebook_height' => '21',
'espresso_facebook_width' => '450'
);
add_option('espresso_facebook_settings', $espresso_facebook);
// Install Twitter Options
$espresso_twitter = array(
'espresso_twitter_text' => get_bloginfo('name'),
'espresso_twitter_username' => 'EventEspresso',
'espresso_twitter_count_box' => 'none',
'espresso_twitter_lang' => 'en'
);
add_option('espresso_twitter_settings', $espresso_twitter);
// Install google+1 options
$espresso_google = array(
'espresso_google_button_size' => 'small',
'espresso_google_url' => '',
'espresso_google_annotation' => 'bubble'
);
update_option('espresso_google_settings', $espresso_google);
// Install stumbleupon options
/* just say no to stumbleupon - cb #626
$espresso_stumbleupon = array(
'espresso_stumbleupon_button_style' => '2',
'espresso_stumbleupon_button_url' => ''
);
update_option('espresso_stumbleupon_settings', $espresso_stumbleupon); */
}
register_activation_hook(__FILE__, 'espresso_social_install');
/* * **********************
* Facebook Button *
* ********************** */
if (!function_exists('espresso_facebook_button')) {
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;
//Build the URl to the page
// this is broken in facebook, so let's create the url a different way
//$registration_url = espresso_reg_url($event_id); //get_option('siteurl') . '/?ee='. $event_id;
$permalink = get_permalink();
$registration_url = $permalink . '?ee=' . $event_id; // this breaks if they aren't using pretty permalinks
// wow, this is a pile of poo. let's fix it.
/* old button
$button = '';
*/
// new button
if (is_ssl()) {
$button = '