Created
October 2, 2012 20:51
-
-
Save rosshanney/3823235 to your computer and use it in GitHub Desktop.
Expand GCE widget lists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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