Title: [Plugin: Google Calendar Feed Parser] A small hack
Last modified: August 19, 2016

---

# [Plugin: Google Calendar Feed Parser] A small hack

 *  [disobedience](https://wordpress.org/support/users/disobedience/)
 * (@disobedience)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/plugin-google-calendar-feed-parser-a-small-hack/)
 * Here is a small modification to the display part of the plugin. I needed to display
   the items in day order with the weekday as a header. Instead of display´ing the
   day today as “Tuesday” it is displayed as “Today” and “Wednesday” is displayed“
   Tomorrow”.
 * It´s in Icelandic so just change the string 🙂
 * Replace all string in the ‘gcalparse.php’ below the comment part:
 * /**
    * gcal_parse_feed – Main function parses and displays the calendar feed */
 * To make it arty just modify your CSS 🙂
 *     ```
       /**
        * gcal_parse_feed - Main function parses and displays the calendar feed
        */
       function gcal_parse_feed() {
       	$feed_url = get_option('gcal_feed_url');
       	$feed_url .= '&max-results=' . (( get_option('gcal_max_results') == '' ) ? '4' : get_option('gcal_max_results'));
   
       	$xmlstr = wp_remote_fopen($feed_url);
       	$static_url = get_option('gcal_static_url_option');
   
       	$xml = new SimpleXMLElement($xmlstr);
   
            echo '<div id="events">';
       	foreach($xml->entry as $entry) {
   
       		$gd = $entry->children('http://schemas.google.com/g/2005');
   
       		$event_link = $entry->link->attributes()->href;
   
       		/* if ( $static_url ) {
       			echo '<a href="' . get_option('gcal_static_url') . '">' . $entry->title . "</a>\n";
       		}
       		else {
       			echo '<a href="' . $event_link  . '">' . $entry->title . "</a>\n";
       		}
         */
       		if (($offset = get_option('gcal_timezone_offset')) == '')
       		   $offset = 0;
   
       		$classstarts = date("H:i", strtotime($gd->when->attributes()->startTime) + $offset);
       		$classfinishes = date("H:i", strtotime($gd->when->attributes()->endTime) + $offset);
               $classdate = date("j. F", strtotime($gd->when->attributes()->startTime) + $offset);
   
               switch ($classdate) {
   
                   case (date("j. F")):
                        if ($settitle0 <> true) {
                        	echo '<lh>Í dag</lh>';
                        }
                        	echo '<div class="event"><ul>';
       		            echo '<li>'.$classstarts.' til '.$classfinishes.' - '.$entry->title.'</li>';         			echo '</ul></div>';
       					$settitle0 = true;
       					break;
   
                   case (date("j. F", strtotime("+1 days"))):
                        if ($settitle1 <> true) {
                        	echo '<lh>Á morgun</lh>';
                        }
                        	echo '<div class="event"><ul>';
                           echo '<li>'.$classstarts.' til '.$classfinishes.' - '.$entry->title.'</li>';
                			echo '</ul></div>';
       					$settitle1 = true;
       					break;
   
                   case (date("j. F", strtotime("+2 days"))):
                        if ($settitle2 <> true) {
                        	echo '<lh>'.date("l", strtotime("+2 days")).'</lh>';
                        }
                        	echo '<div class="event"><ul>';
                           echo '<li>'.$classstarts.' til '.$classfinishes.' - '.$entry->title.'</li>';
                			echo '</ul></div>';
       					$settitle2 = true;
       					break;
   
                   case (date("j. F", strtotime("+3 days"))):
                        if ($settitle3 <> true) {
                        	echo '<lh>'.date("l", strtotime("+3 days")).'</lh>';                 }
                        	echo '<div class="event"><ul>';
                           echo '<li>'.$classstarts.' til '.$classfinishes.' - '.$entry->title.'</li>';
                			echo '</ul></div>';
       					$settitle3 = true;
       					break;
   
                   case (date("j. F", strtotime("+4 days"))):
                        if ($settitle4 <> true) {
                        	echo '<lh>'.date("l", strtotime("+4 days")).'</lh>';
                        }
                        	echo '<div class="event"><ul>';
                           echo '<li>'.$classstarts.' til '.$classfinishes.' - '.$entry->title.'</li>';
                			echo '</ul></div>';
       					$settitle4 = true;
       					break;
                                      }        
   
               }
   
       	echo '</div>';
       }
       ?>
       ```
   
 * [http://wordpress.org/extend/plugins/google-calendar-feed-parser/](http://wordpress.org/extend/plugins/google-calendar-feed-parser/)

Viewing 1 replies (of 1 total)

 *  [bennettj1087](https://wordpress.org/support/users/bennettj1087/)
 * (@bennettj1087)
 * [16 years ago](https://wordpress.org/support/topic/plugin-google-calendar-feed-parser-a-small-hack/#post-1327886)
 * disobedience:
 * This is an excellent idea. I’m thinking I may add this display format as an option
   so that other users can take advantage of your customizations. I’m hoping to 
   have some time to work on the plugin in the coming weeks with the goal of making
   a release soon so keep checking back!
 * Also, if you have any other input from your time using the plugin, please feel
   free to post here, on my blog or email me.
 * Thanks,
    Justin Bennett

Viewing 1 replies (of 1 total)

The topic ‘[Plugin: Google Calendar Feed Parser] A small hack’ is closed to new 
replies.

 * 1 reply
 * 2 participants
 * Last reply from: [bennettj1087](https://wordpress.org/support/users/bennettj1087/)
 * Last activity: [16 years ago](https://wordpress.org/support/topic/plugin-google-calendar-feed-parser-a-small-hack/#post-1327886)
 * Status: not a support question

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
