Skip to content

Instantly share code, notes, and snippets.

@rosshanney
Created September 30, 2013 19:28
Show Gist options
  • Save rosshanney/6768839 to your computer and use it in GitHub Desktop.
Save rosshanney/6768839 to your computer and use it in GitHub Desktop.
Remove tooltip stuff from GCE JavaScript.
<?php
/*
Plugin name: GCE - Remove tooltip JS
*/
function gce_remove_tooltip_js() {
if ( defined( 'GCE_GENERAL_OPTIONS_NAME' ) ) {
$options = get_option( GCE_GENERAL_OPTIONS_NAME );
wp_deregister_script( 'gce_scripts' );
wp_enqueue_script( 'gce_scripts', plugins_url( '/gce-script.js', __FILE__ ), array( 'jquery' ), null, (bool) $options['javascript'] );
wp_localize_script( 'gce_scripts', 'GoogleCalendarEvents', array(
'ajaxurl' => admin_url( 'admin-ajax.php', is_ssl() ? 'https' : 'http' ),
'loading' => $options['loading']
) );
}
}
add_action( 'wp_enqueue_scripts', 'gce_remove_tooltip_js', 99 );
function gce_ajaxify(target, feed_ids, max_events, title_text, type){
//Add click event to change month links
jQuery('#' + target + ' .gce-change-month').click(function(){
//Extract month and year
var month_year = jQuery(this).attr('name').split('-', 2);
//Add loading text to table caption
jQuery('#' + target + ' caption').html(GoogleCalendarEvents.loading);
//Send AJAX request
jQuery.get(GoogleCalendarEvents.ajaxurl,{
action:'gce_ajax',
gce_type:type,
gce_feed_ids:feed_ids,
gce_title_text:title_text,
gce_widget_id:target,
gce_max_events:max_events,
gce_month:month_year[0],
gce_year:month_year[1]
}, function(data){
//Replace existing data with returned AJAX data
if(type == 'widget'){
jQuery('#' + target).html(data);
}else{
jQuery('#' + target).replaceWith(data);
}
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment