Skip to content

Commit

Permalink
uses datetime adjusted by timezone for google requests, use imagesloa…
Browse files Browse the repository at this point in the history
…ded again
  • Loading branch information
unfulvio committed Aug 24, 2015
1 parent 1803209 commit 7305993
Show file tree
Hide file tree
Showing 7 changed files with 940 additions and 9 deletions.
17 changes: 16 additions & 1 deletion google-calendar-events/class-google-calendar-events.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Google_Calendar_Events {
*
* @var string
*/
protected $version = '2.2.91';
protected $version = '2.3.0';

/**
* Unique identifier for the plugin.
Expand Down Expand Up @@ -86,6 +86,7 @@ private function __construct() {

// Load scripts when posts load so we know if we need to include them or not
add_action( 'wp_enqueue_scripts', array( $this, 'load_scripts' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'theme_compatibility' ), 1000 );
}

/**
Expand Down Expand Up @@ -161,6 +162,20 @@ public function load_scripts() {
'loadingText' => __( 'Loading...', 'gce' ),
) );
}

}

public function theme_compatibility() {
if ( wp_script_is( $this->plugin_slug . '-public', 'enqueued' ) ) {
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
wp_enqueue_script(
'gce-imagesloaded',
plugins_url( 'js/imagesloaded.pkgd' . $min . '.js', __FILE__ ),
array( $this->plugin_slug . '-qtip' ),
'3.1.8',
true
);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion google-calendar-events/google-calendar-events.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: Show off your Google calendar in grid (month) or list view, in a post, page or widget, and in a style that matches your site.
* Author: Moonstone Media
* Author URI: http://moonstonemediagroup.com
* Version: 2.2.91
* Version: 2.3.0
* Text Domain: gce
* Domain Path: /languages/
*
Expand Down
22 changes: 17 additions & 5 deletions google-calendar-events/includes/class-gce-feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,31 @@ private function create_feed() {
$query .= '?key=' . $api_key;

// Timezone.
$timezone = esc_attr( get_post_meta( $this->id, '_feed_timezone_setting', true ) );
if ( 'use_site' == $timezone ) {
$args['timeZone'] = gce_get_wp_timezone();
$timezone_option = esc_attr( get_post_meta( $this->id, '_feed_timezone_setting', true ) );
$timezone = gce_get_wp_timezone();
if ( 'use_site' == $timezone_option ) {
$args['timeZone'] = $timezone;
}
$args['timeMin'] = urlencode( date( 'c', $this->feed_start ) );
$args['timeMax'] = urlencode( date( 'c', $this->feed_end ) );

// Time boundaries.
$time = new DateTime();
if ( 'use_site' == $timezone_option ) {
$time->setTimezone( new DateTimeZone( $timezone ) );
}
$time->setTimestamp( $this->feed_start );
$args['timeMin'] = urlencode( $time->format( 'c' ) );
$time->setTimestamp( $this->feed_end );
$args['timeMax'] = urlencode( $time->format( 'c' ) );

// Max no. of events.
$args['maxResults'] = 2500;

// Google search query terms.
if ( ! empty( $this->search_query ) ) {
$args['q'] = rawurlencode( $this->search_query );
}

// Show recurring.
if( ! empty( $this->expand_recurring ) ) {
$args['singleEvents'] = 'true';
}
Expand Down
Loading

0 comments on commit 7305993

Please sign in to comment.