Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: FOSS events
- Plugin URI: http://foss.hr/
- Description: FOSS.hr - Facebook events plugin
- Author: Ivan Miletic
- Version: 0.1
- */
- function widget_foss_events() {
- $arr = array("146484685417821", "216357155045991", "194868703891407", "192361117473020", "169587856429569");
- if(empty($arr)) {
- // if $arr empty do nothing
- }
- else {
- // if data is present in $arr
- ?>
- <div class="widget-container">
- <h3 class="widget-title">Događanja</h3>
- <ul>
- <?php
- foreach ($arr as $value) {
- $jsonurl = "https://graph.facebook.com/" .$value;
- $json = file_get_contents($jsonurl,0,null,null);
- $json_output = json_decode($json);
- $event_name = $json_output->name;
- $event_time = strtotime($json_output->start_time);
- $now = time();
- if($now < $event_time) {
- // checks if event has passed or ivalid
- ?>
- <li><a class="events-box" href="<?php bloginfo('url'); ?>/wordpress/wp-content/plugins/foss-events/show-event.php?show=event&id=<?php echo $value; ?>"><?php echo $event_name; ?></a></li>
- <?php
- }
- else {
- // do nothing if event passed or invalid
- }
- }
- ?>
- </ul>
- </div>
- <?php
- }
- }
- function foss_events_init()
- {
- register_sidebar_widget(__('FOSS events'), 'widget_foss_events');
- }
- add_action("plugins_loaded", "foss_events_init");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement