Advertisement
Guest User

FB events

a guest
Apr 26th, 2011
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.31 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: FOSS events
  4. Plugin URI: http://foss.hr/
  5. Description: FOSS.hr - Facebook events plugin
  6. Author: Ivan Miletic
  7. Version: 0.1
  8. */
  9.  
  10.  
  11. function widget_foss_events() {
  12.     $arr = array("146484685417821", "216357155045991", "194868703891407", "192361117473020", "169587856429569");
  13.     if(empty($arr)) {
  14.     // if $arr empty do nothing
  15.     }
  16.     else {
  17.     // if data is present in $arr
  18.        
  19. ?>
  20.     <div class="widget-container">
  21.         <h3 class="widget-title">Događ‘anja</h3>
  22.         <ul>
  23. <?php
  24.         foreach ($arr as $value) {
  25.        
  26.             $jsonurl = "https://graph.facebook.com/" .$value;
  27.             $json = file_get_contents($jsonurl,0,null,null);
  28.             $json_output = json_decode($json);
  29.             $event_name = $json_output->name;
  30.             $event_time = strtotime($json_output->start_time);
  31.             $now = time();
  32.             if($now < $event_time) {
  33.                 // checks if event has passed or ivalid
  34. ?>
  35.             <li><a class="events-box" href="<?php bloginfo('url'); ?>/wordpress/wp-content/plugins/foss-events/show-event.php?show=event&amp;id=<?php echo $value; ?>"><?php echo $event_name; ?></a></li>
  36. <?php
  37.             }
  38.             else {
  39.             // do nothing if event passed or invalid
  40.             }
  41.         }
  42. ?>
  43.         </ul>
  44.     </div>
  45. <?php
  46.     }
  47. }
  48.  
  49. function foss_events_init()
  50. {
  51.   register_sidebar_widget(__('FOSS events'), 'widget_foss_events');
  52. }
  53. add_action("plugins_loaded", "foss_events_init");
  54.  
  55. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement