Skip to content

Instantly share code, notes, and snippets.

@rosshanney
Created October 2, 2012 20:51
Show Gist options
  • Save rosshanney/3823235 to your computer and use it in GitHub Desktop.
Save rosshanney/3823235 to your computer and use it in GitHub Desktop.
Expand GCE widget lists
<?php
/*
Plugin name: Expand GCE List
*/
function gce_expand() {
?>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('.gce-widget-list').find('.gce-list>li:gt(2)').hide();
jQuery('.gce-show-more-events').toggle(function(){
jQuery(this).siblings('.gce-widget-list').find('.gce-list>li:gt(2)').show();
jQuery(this).html('Show less events');
}, function() {
jQuery(this).siblings('.gce-widget-list').find('.gce-list>li:gt(2)').hide();
jQuery(this).html('Show more events');
})
});
</script>
<?php
}
add_action( 'wp_head', 'gce_expand' );
function gce_after_widget_stuff( $params ) {
if ( ! is_admin() ) {
if ( 'Google Calendar Events' == $params[0]['widget_name'] ) {
$params[0]['after_widget'] = '<br /><a href="#" class="gce-show-more-events">Show more events</a>' . $params[0]['after_widget'];
}
}
return $params;
}
add_filter( 'dynamic_sidebar_params', 'gce_after_widget_stuff' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment