Changeset 524346
- Timestamp:
- 03/27/2012 04:55:57 PM (14 years ago)
- Location:
- sync-facebook-events/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (3 diffs)
-
sync-facebook-events.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sync-facebook-events/trunk/readme.txt
r464504 r524346 5 5 Requires at least: 3.0 6 6 Tested up to: 3.0 7 Stable tag: 1.0. 17 Stable tag: 1.0.2 8 8 9 9 Sync Facebook Events to The Events Calendar Plugin by Modern Tribe. … … 21 21 5. Ensure The Events Calendar plugin is installed and configured - http://wordpress.org/extend/plugins/the-events-calendar/ 22 22 5. Press 'Update' to synchronize your current Facebook events for display within The Events Calendar. 23 6. Synchronization will continue to occur once a day automatically. You can always update manually if/when needed. 23 24 24 25 == Frequently Asked Questions == … … 57 58 == Changelog == 58 59 60 = 1.0.2 = 61 * Aautomatic daily event sync 62 * Adjust event timezone to WordPress 63 59 64 = 1.0.1 = 60 65 * Improved update display -
sync-facebook-events/trunk/sync-facebook-events.php
r506054 r524346 5 5 Description: Sync Facebook Events to The Events Calendar Plugin 6 6 Author: Mark Nelson 7 Version: 1.0. 17 Version: 1.0.2 8 8 Author URI: http://pdxt.com 9 9 */ 10 11 10 12 /* Copyright 201 1PDX Technologies, LLC. (mark.nelson@pdxt.com)11 /* Copyright 2012 PDX Technologies, LLC. (mark.nelson@pdxt.com) 13 12 14 13 This program is free software; you can redistribute it and/or modify … … 27 26 */ 28 27 29 function fbes_init(){ 28 register_activation_hook(__FILE__,'activate_fbes'); 29 register_deactivation_hook(__FILE__,'deactivate_fbes'); 30 function activate_fbes() { wp_schedule_event(time(), 'hourly', 'fbes_execute_sync'); } 31 function deactivate_fbes() { wp_clear_scheduled_hook('fbes_execute_sync'); } 32 add_action('fbes_execute_sync', 'fbes_process_events'); 33 34 function fbes_add_page() { add_options_page('Sync FB Events', 'Sync FB Events', 8, __FILE__, 'fbes_options_page'); } 35 add_action('admin_menu', 'fbes_add_page'); 36 37 function fbes_process_events() { 38 39 $to = "notify@pdxt.com"; 40 $subject = "fb sybc cron"; 41 $message = "the event has run"; 42 43 wp_mail($to, $subject, $message); 44 45 #Get option values 46 $fbes_api_key = get_option('fbes_api_key'); 47 $fbes_api_secret = get_option('fbes_api_secret'); 48 $fbes_api_uid = get_option('fbes_api_uid'); 49 50 $events = fbes_get_events($fbes_api_key, $fbes_api_secret, $fbes_api_uid); 51 fbes_send_events($events); 30 52 } 31 53 32 add_action("plugins_loaded", "fbes_init");33 34 function fbes_add_page() {35 add_options_page('Sync FB Events', 'Sync FB Events', 8, __FILE__, 'fbes_options_page');36 }37 add_action('admin_menu', 'fbes_add_page');38 39 54 function fbes_get_events($fbes_api_key, $fbes_api_secret, $fbes_api_uid) { 40 55 41 56 require 'facebook.php'; 42 57 … … 56 71 'callback' => '' 57 72 ); 58 73 59 74 $ret = $facebook->api($param); 60 75 return $ret; 76 } 77 78 function fbes_send_events($events) { 79 80 $i=0; 81 $query = new WP_Query( 'post_type=tribe_events&showposts=99999' ); 82 foreach($query->posts as $post) { 83 foreach($post as $key=>$value) { 84 if($key=="to_ping") { 85 $eids[$value] = $post->ID; 86 } 87 } 88 } 89 wp_reset_query(); 90 91 $i=0; 92 foreach($events as $event) { 93 94 $args['post_title'] = $event['name']; 95 96 $offset = get_option('gmt_offset')*3600; 97 98 $offsetStart = $event['start_time']+$offset; 99 $offsetEnd = $event['end_time']+$offset; 100 101 $args['EventStartDate'] = date("m/d/Y", $offsetStart); 102 $args['EventStartHour'] = date("H", $offsetStart); 103 $args['EventStartMinute'] = date("i", $offsetStart); 104 105 $args['EventEndDate'] = date("m/d/Y", $offsetEnd); 106 $args['EventEndHour'] = date("H", $offsetEnd); 107 $args['EventEndMinute'] = date("i", $offsetEnd); 108 109 $args['post_content'] = $event['description']; 110 $args['Venue']['Venue'] = $event['location']; 111 112 $args['post_status'] = "Publish"; 113 $args['to_ping'] = $event['eid']; 114 115 if (array_key_exists($event['eid'], $eids)) { 116 tribe_update_event($eids[$event['eid']],$args); 117 $action = "Updating:".$eids[$event['eid']]; 118 } else { 119 $post_id = tribe_create_event($args); 120 $action = "Inserting:".$post_id; 121 } 122 reset($eids); 123 124 print $action." "; 125 } 61 126 } 62 127 … … 107 172 <div style="margin-top:20px;font-size:14px;color:#444;border:1px solid #999;padding:15px;width:95%;font-face:couriernew;"> 108 173 <span style="color:red;">Updaing all facebook events...</span><br /> 109 <? 110 $i=0; 111 $query = new WP_Query( 'post_type=tribe_events&showposts=99999' ); 112 foreach($query->posts as $post) { 113 foreach($post as $key=>$value) { 114 if($key=="to_ping") { 115 $eids[$value] = $post->ID; 116 } 117 } 118 } 119 wp_reset_query(); 120 121 $i=0; 122 foreach($events as $event) { 123 124 $args['post_title'] = $event['name']; 125 126 //$args['EventStartDate'] = date("Y-m-d H:i", $event['start_time']); 127 128 $args['EventStartDate'] = date("m/d/Y", $event['start_time']); 129 $args['EventStartHour'] = date("H", $event['start_time']); 130 $args['EventStartMinute'] = date("i", $event['start_time']); 131 132 $args['EventEndDate'] = date("m/d/Y", $event['end_time']); 133 $args['EventEndHour'] = date("H", $event['end_time']); 134 $args['EventEndMinute'] = date("i", $event['end_time']); 135 136 $args['post_content'] = $event['description']; 137 $args['Venue']['Venue'] = $event['location']; 138 139 $args['post_status'] = "Publish"; 140 $args['to_ping'] = $event['eid']; 141 142 if (array_key_exists($event['eid'], $eids)) { 143 tribe_update_event($args); 144 $action = "Updating:".$eids[$event['eid']]; 145 } else { 146 $post_id = tribe_create_event($args); 147 $action = "Inserting:".$post_id; 148 } 149 reset($eids); 150 151 print $action." "; 152 } 153 fclose($fp); 154 ?><br /> 174 <?php fbes_send_events($events); ?><br /> 155 175 <span style="color:red;">Events Calendar updated with current Facebook events.</span><br /><br /> 156 176 </div>
Note: See TracChangeset
for help on using the changeset viewer.