Changeset 668363
- Timestamp:
- 02/15/2013 09:15:35 AM (13 years ago)
- Location:
- wp-meetup-activity
- Files:
-
- 3 edited
- 9 copied
-
tags/0.1.4 (copied) (copied from wp-meetup-activity/trunk)
-
tags/0.1.4/default.css (copied) (copied from wp-meetup-activity/trunk/default.css) (1 diff)
-
tags/0.1.4/facebook-sdk (copied) (copied from wp-meetup-activity/trunk/facebook-sdk)
-
tags/0.1.4/facebook-sdk/base_facebook.php (copied) (copied from wp-meetup-activity/trunk/facebook-sdk/base_facebook.php)
-
tags/0.1.4/facebook-sdk/class-facebook-wp.php (copied) (copied from wp-meetup-activity/trunk/facebook-sdk/class-facebook-wp.php)
-
tags/0.1.4/facebook-sdk/facebook.php (copied) (copied from wp-meetup-activity/trunk/facebook-sdk/facebook.php)
-
tags/0.1.4/img (copied) (copied from wp-meetup-activity/trunk/img)
-
tags/0.1.4/readme.txt (copied) (copied from wp-meetup-activity/trunk/readme.txt) (4 diffs)
-
tags/0.1.4/wp-meetup-activity.php (copied) (copied from wp-meetup-activity/trunk/wp-meetup-activity.php) (19 diffs)
-
trunk/default.css (modified) (1 diff)
-
trunk/readme.txt (modified) (4 diffs)
-
trunk/wp-meetup-activity.php (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-meetup-activity/tags/0.1.4/default.css
r589800 r668363 19 19 color: #fff; 20 20 } 21 22 .wpmeetupactivity-event-widget-box { 23 clear: both; 24 } 25 26 .wpmeetupactivity-event-widget-box-title { 27 font-size: 1.2em; 28 padding: 1px; 29 } 30 31 .wpmeetupactivity-event-widget-cal-box { 32 float: left; 33 width: 54px; 34 height: 54px; 35 border-radius: 5px; 36 padding: 4px; 37 margin: 2px; 38 background: #3B5998; 39 text-align: center; 40 } 41 42 .wpmeetupactivity-event-widget-cal-box-day { 43 font-size: 2em; 44 color: #fff; 45 text-align: center; 46 } 47 48 .wpmeetupactivity-event-widget-cal-box-month { 49 font-size: 0.8em; 50 color: #fff; 51 text-align: center; 52 } 53 54 .wpmeetupactivity-event-widget-detail-box { 55 font-size: 1.0em; 56 text-align: justify; 57 margin: 2px; 58 } 59 60 .wpmeetupactivity-tipbox { 61 padding: 8px; 62 color: #333; 63 font-size: 0.8em; 64 background: #FF9; 65 border: 1px solid #FC0; 66 -moz-border-radius: 2px; 67 border-radius: 2px; 68 text-align: justify; 69 } -
wp-meetup-activity/tags/0.1.4/readme.txt
r592392 r668363 2 2 Contributors: o-zone 3 3 Donate link: http://www.zerozone.it 4 Tags: meetup, activity, meetup.com, group, facebook4 Tags: meetup, activity, meetup.com, events, group 5 5 Requires at least: 3.0 6 Tested up to: 3. 4.16 Tested up to: 3.5.1 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html 9 9 10 WP-Meetup-Activity display your groups latest activities (discussions, photos...) in a sidebar widget. Can also post directly to facebook pages new threads and replies10 WP-Meetup-Activity display your groups latest activities (discussions, photos...) and events in a sidebar widget 11 11 12 12 == Description == … … 22 22 2. Activate the plugin through the 'Plugins' menu in WordPress 23 23 3. Add the widget wherever you want 24 25 if you want to enable facebook Post-to-page feature, you need to create a new app: 26 27 1. Open your browser to https://developers.facebook.com/apps 28 2. Click on "Create new application" on top right 29 3. Set domain URLs 30 4. Write app Id and app secret on wp-meetup-activity setup page 31 5. Connect widget with your Facebook application, allowing manage_pages and offline_access rights 24 4. Set it up ! 32 25 33 26 == Frequently Asked Questions == … … 47 40 == Changelog == 48 41 49 = 0.1.3 = 50 * Enable/disable Facebook support 51 * Fixed some Facebook issue with other plugins (like "Facebook for Wordpress") 52 53 = 0.1.2 = 54 * Facebook support for Post-in-Page on new topics / reply 55 * Minor bugs fixed 42 = 0.1.4 = 43 * Added Meetup events support 44 * Some bugs fixed and minor code cleanups 56 45 57 46 = 0.1.1 = … … 75 64 == Upgrade Notice == 76 65 66 = 0.1.4 = 67 Added Meetup events support. Can you miss it ? 68 77 69 = 0.1.1 = 78 70 Database should upgrade automatically but please deactivate and reactivate the plugin after upgrade. -
wp-meetup-activity/tags/0.1.4/wp-meetup-activity.php
r592392 r668363 3 3 Plugin Name: WP Meetup Activity 4 4 Plugin URI: http://www.zerozone.it/wordpress-meetup-plugin/ 5 Description: Display group activity from Meetup.com in a widget for your wordpress6 Version: 0.1. 35 Description: Display group activity and events from Meetup.com in a widget for your wordpress 6 Version: 0.1.4 7 7 Author: Michele "O-Zone" Pinassi 8 8 Author URI: http://www.zerozone.it/ 9 9 10 Copyright 2012 Michele "O-Zone" Pinassi10 Copyright 2012-2013 Michele "O-Zone" Pinassi 11 11 12 12 This program is free software; you can redistribute it and/or modify … … 44 44 global $wpdb; 45 45 46 define(WP_MEETUP_ACTIVITY,'0.1. 3');46 define(WP_MEETUP_ACTIVITY,'0.1.4'); 47 47 define(WP_MEETUP_ACTIVITY_TABLE, $wpdb->prefix."meetup_activity"); 48 48 … … 70 70 ) DEFAULT CHARSET = utf8; 71 71 72 CREATE TABLE ".WP_MEETUP_ACTIVITY_TABLE."_events ( 73 id int(10) NOT NULL AUTO_INCREMENT, 74 group_id INT(12) NOT NULL, 75 event_id INT(12) NOT NULL, 76 event_title TEXT NOT NULL, 77 event_address TEXT NOT NULL, 78 event_description TEXT NOT NULL, 79 event_datetime DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL, 80 event_updated DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL, 81 is_public SMALLINT(1) NOT NULL, 82 event_status VARCHAR(16) NOT NULL, 83 event_url TEXT NOT NULL, 84 yes_rsvp INT(5) NOT NULL, 85 add_date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, 86 PRIMARY KEY id (id), 87 UNIQUE KEY event_id (event_id) 88 ) DEFAULT CHARSET = utf8; 89 72 90 CREATE TABLE ".WP_MEETUP_ACTIVITY_TABLE."_groups ( 73 91 group_id mediumint(10) NOT NULL, … … 77 95 ) DEFAULT CHARSET = utf8;"; 78 96 97 79 98 require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 80 99 dbDelta($sql); … … 118 137 $groupsArray[$act['group_id']] = $act['group_name']; 119 138 120 $wpdb->query($wpdb->prepare("INSERT I NTO ".WP_MEETUP_ACTIVITY_TABLE."_groups (group_id, group_name, add_date) VALUES ( %d, %s, NOW())", $act['group_id'], $act['group_name']));139 $wpdb->query($wpdb->prepare("INSERT IGNORE INTO ".WP_MEETUP_ACTIVITY_TABLE."_groups (group_id, group_name, add_date) VALUES ( %d, %s, NOW())", $act['group_id'], $act['group_name'])); 121 140 } 122 141 } … … 230 249 } 231 250 251 function wpmeetupactivity_fetch_events($verbose=false) { 252 global $wpdb; 253 254 $apikey = get_option('wpmeetupactivity_apikey'); 255 256 $fb_options = get_option('wpmeetupactivity_fb_options'); 257 $fb_pages = $fb_options['pages']; 258 259 $groupsArray = get_option('wpmeetupactivity_groups'); 260 261 if(count($groupsArray) > 0) { 262 if($apikey) { 263 try { 264 $connection = new MeetupKeyAuthConnection($apikey); 265 $m = new MeetupEvents($connection); 266 foreach($groupsArray as $groupId) { 267 $events = $m->getEvents(array('group_id' => $groupId)); 268 269 foreach($events as $event) { 270 /* Array ( [visibility] => public 271 [status] => upcoming 272 [maybe_rsvp_count] => 0 273 [venue] => Array ( 274 [id] => 11656882 275 [lon] => 11.35083 276 [repinned] => 277 [name] => Circolo CRAL 278 [address_1] => via Algero Rosi 6 279 [lat] => 43.31786 280 [country] => it 281 [city] => Siena 282 ) 283 [id] => 103939182 284 [utc_offset] => 3600000 285 [time] => 1360958400000 286 [waitlist_count] => 0 287 [created] => 1360515889000 288 [yes_rsvp_count] => 10 289 [updated] => 1360617331000 290 [event_url] => http://www.meetup.com/Gruppo-di-Siena/events/[id]/ 291 [description] => descrizione evento.... 292 [headcount] => 0 293 [name] => Incontro con l'economista Filippo Abbate 294 [group] => Array ( 295 [id] => 209457 296 [group_lat] => 43.319999694824 297 [name] => Forum di Siena 298 [group_lon] => 11.329999923706 299 [join_mode] => open 300 [urlname] => Gruppo-di-Siena 301 [who] => Amici di Siena 302 ) 303 ) */ 304 305 $eventId = $event['id']; 306 307 $eventUpdated = gmdate("Y-m-d H:i:s",intval($event['updated'])/1000); 308 309 $eventVenue = $event['venue']['name'].','.$event['venue']['city']; 310 311 /* If event_id is already present, check for update. Else add new event_id row. */ 312 $result = $wpdb->get_row("SELECT id,TIMESTAMPDIFF(MINUTE,event_updated,'$eventUpdated') AS tDelta FROM ".WP_MEETUP_ACTIVITY_TABLE."_events WHERE group_id='$groupId' AND event_id='$eventId';", ARRAY_A); 313 314 if($result) { 315 // L'evento esiste gia 316 if($result['tDelta'] > 0) { 317 $result = $wpdb->query( $wpdb->prepare( "UPDATE ".WP_MEETUP_ACTIVITY_TABLE."_events SET event_title='%s', event_address='%s', event_description='%s', event_datetime='%s', event_updated='%s', event_status='%s', yes_rsvp=%d WHERE event_id=$eventId;", $event['name'], $eventVenue, $event['description'], gmdate("Y-m-d H:i:s",intval($event['time'])/1000), $eventUpdated, $event['status'], intval($event['yes_rsvp_count']))); 318 if($verbose) { 319 echo "<div class=\"updated\"><p><strong>"; 320 if($result) { 321 echo __('Updated event '.$eventId.': '.$event['name'], $wpmeetupactivity_textdomain); 322 } else { 323 echo __('DB SQL Error: '.$wpdb->print_error(), $wpmeetupactivity_textdomain); 324 } 325 echo "</strong></p></div>"; 326 } 327 } 328 } else { 329 // L'evento non esiste: aggiungilo al DB ! 330 $result = $wpdb->query( $wpdb->prepare("INSERT INTO ".WP_MEETUP_ACTIVITY_TABLE."_events (group_id, event_id, event_title, event_address, event_description, event_datetime, event_updated, is_public, event_status, event_url, yes_rsvp, add_date) VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', 1, '%s', '%s', %d, NOW())", $groupId, $eventId, $event['name'], $eventVenue, $event['description'], gmdate("Y-m-d H:i:s",intval($event['time'])/1000), $eventUpdated, $event['status'], $event['event_url'], intval($event['yes_rsvp_count']))); 331 if($verbose) { 332 echo "<div class=\"updated\"><p><strong>"; 333 if($result) { 334 echo __('Added new event '.$eventId.': '.$event['name'], $wpmeetupactivity_textdomain); 335 } else { 336 echo __('DB SQL Error: '.$wpdb->print_error(), $wpmeetupactivity_textdomain); 337 } 338 echo "</strong></p></div>"; 339 } 340 } 341 } 342 } 343 } catch (Exception $e) { 344 echo "Meetup API error: $e"; 345 } 346 } 347 } 348 } 349 350 232 351 function wpmeetupactivity_plugin_menu() { 233 352 add_options_page('WP-Meetup-Activity Plugin Options', 'WP-Meetup-Activity', 8, __FILE__, 'wpmeetupactivity_plugin_options'); … … 236 355 function wpmeetupactivity_widget_init() { 237 356 if ( function_exists( 'wp_register_sidebar_widget' ) ) { 238 wp_register_sidebar_widget('wpmeetupactivity','WP-Meetup-Activity', 'wpmeetupactivity_widget'); 357 wp_register_sidebar_widget('wpmeetupactivity','WP-Meetup-Activity', 'wpmeetupactivity_widget_activity'); 358 wp_register_sidebar_widget('wpmeetupevents','WP-Meetup-Events', 'wpmeetupactivity_widget_events'); 239 359 } else { 240 register_sidebar_widget('WP-Meetup-Activity', 'wpmeetupactivity_widget'); 360 // Deprecated function for older WP... 361 register_sidebar_widget('WP-Meetup-Activity', 'wpmeetupactivity_widget_activity'); 362 register_sidebar_widget('WP-Meetup-Events', 'wpmeetupactivity_widget_events'); 241 363 } 242 364 } 243 365 244 366 function wpmeetupactivity_register_styles() { 245 wp_register_style('wpmeetupactivity', plugins_url('default.css', __FILE__), array(), '201 20822', 'all' );367 wp_register_style('wpmeetupactivity', plugins_url('default.css', __FILE__), array(), '20130215', 'all' ); 246 368 wp_enqueue_style('wpmeetupactivity'); 247 369 } … … 262 384 } 263 385 264 function wpmeetupactivity_widget($args) { 386 function wpmeetupactivity_widget_events($args) { 387 global $wpdb; 388 389 $monthArray = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); 390 391 extract($args); 392 393 $title = get_option('wpmeetupactivity_events_title'); 394 $desc = get_option('wpmeetupactivity_events_desc'); 395 396 $groupsArray = get_option('wpmeetupactivity_groups'); 397 $my_prefs = get_option('wpmeetupactivity_prefs'); 398 399 echo $before_widget; 400 echo $before_title . $title . $after_title; 401 402 if(count($groupsArray) > 0) { 403 $events = $wpdb->get_results("SELECT * FROM ".WP_MEETUP_ACTIVITY_TABLE."_events WHERE DATEDIFF(event_datetime,NOW()) >= 0 ORDER BY event_datetime ASC LIMIT 3;",ARRAY_A); 404 405 if($events) { 406 $c=0; 407 foreach($events as $event) { 408 $eventUrl = $event['event_url']; 409 $eventDate = date_parse($event['event_datetime']); 410 $eventTitle = $event['event_title']; 411 412 echo "<div class='wpmeetupactivity-event-widget-box'> 413 <div class='wpmeetupactivity-event-widget-cal-box'> 414 <div class='wpmeetupactivity-event-widget-cal-box-day'>".$eventDate['day']."</div> 415 <div class='wpmeetupactivity-event-widget-cal-box-month'>".$monthArray[$eventDate['month']-1]." ".$eventDate['year']."</div> 416 </div> 417 <div class='wpmeetupactivity-event-widget-detail-box'> 418 <a href='$eventUrl' title='$eventTitle' alt='$eventTitle' target=_new'><b class='wpmeetupactivity-event-widget-box-title'>".((strlen($eventTitle) > 35) ? substr($eventTitle,0,32).'...' : $eventTitle)."</b></a> 419 <p>"; 420 echo str_replace(array("%ADDRESS%","%RSVP_YES%"),array($event['event_address'],$event['yes_rsvp']),$desc); 421 echo " </p> 422 </div> 423 </div>"; 424 $c = $c+1; 425 if($c >= $my_prefs['displayEvents']) { 426 break; 427 } 428 } 429 } else { 430 echo "<b>No events planned yet !</b>"; 431 } 432 } else { 433 echo "<b>No groups selected: did you set up the plugin ?</b>"; 434 } 435 436 echo $after_widget; 437 } 438 439 440 function wpmeetupactivity_widget_activity($args) { 265 441 global $wpdb; 266 442 … … 328 504 329 505 $disp_cnt = $disp_cnt+1; 330 if($disp_cnt > $my_prefs[ "displayAct"]) {506 if($disp_cnt > $my_prefs['displayAct']) { 331 507 break; 332 508 } … … 369 545 function wpmeetupactivity_plugin_cron_hourly() { 370 546 wpmeetupactivity_fetch_activity(); 547 wpmeetupactivity_fetch_events(); 371 548 } 372 549 … … 585 762 586 763 $my_prefs["displayAct"] = intval($_POST["wpmeetupactivity_prefs_displayact"]); 764 $my_prefs["displayEvents"] = intval($_POST["wpmeetupactivity_prefs_displayevents"]); 587 765 $my_prefs["orderBy"] = intval($_POST["wpmeetupactivity_prefs_orderby"]); 588 766 589 767 // Salva opzioni 590 768 update_option('wpmeetupactivity_apikey',$_POST['wpmeetupactivity_apikey']); 591 update_option('wpmeetupactivity_title',$_POST['wpmeetupactivity_title']); 769 update_option('wpmeetupactivity_title',$_POST['wpmeetupactivity_activity_title']); 770 update_option('wpmeetupactivity_events_title',$_POST['wpmeetupactivity_events_title']); 771 update_option('wpmeetupactivity_events_desc',$_POST['wpmeetupactivity_events_desc']); 592 772 update_option('wpmeetupactivity_groups',$myGroups); 593 773 update_option('wpmeetupactivity_prefs',$my_prefs); … … 635 815 echo __('Activities DB purged.', $wpmeetupactivity_textdomain); 636 816 echo "</strong></p></div>"; 817 818 $wpdb->get_results("TRUNCATE ".WP_MEETUP_ACTIVITY_TABLE."_events;"); 819 820 echo "<div class=\"updated\"><p><strong>"; 821 echo __('Events DB purged.', $wpmeetupactivity_textdomain); 822 echo "</strong></p></div>"; 637 823 } 638 824 … … 643 829 echo "</strong></p></div>"; 644 830 } 831 832 if($_POST["wpmeetupactivity_force_event_fetch"] == 'on') { 833 wpmeetupactivity_fetch_events(true); 834 echo "<div class=\"updated\"><p><strong>"; 835 echo __('Events fetched successfully.', $wpmeetupactivity_textdomain); 836 echo "</strong></p></div>"; 837 } 645 838 646 839 } … … 648 841 $apikey = get_option('wpmeetupactivity_apikey'); 649 842 $title = get_option('wpmeetupactivity_title'); 843 $title_events = get_option('wpmeetupactivity_events_title'); 844 $events_desc = get_option('wpmeetupactivity_events_desc'); 650 845 651 846 echo "<div class='wrap'><!-- WRAP --> … … 687 882 </p> 688 883 <p> 689 <input type='checkbox' name='wpmeetupactivity_purge_act_db'> Purge activity database 884 <input type='checkbox' name='wpmeetupactivity_force_event_fetch'> Force events fetch on save changes 885 </p> 886 <p> 887 <input type='checkbox' name='wpmeetupactivity_purge_act_db'> Purge database 690 888 </p> 691 889 <p> 692 <i>TIP: Select both checkboxes to re-initialize activities db with new, fresh, data !</i>890 <i>TIP: Select all checkboxes to re-initialize activities and events db with new, fresh, data !</i> 693 891 </p> 694 892 </fieldset>"; … … 696 894 echo "<fieldset class='wpmeetupactivity-setup-fieldset'><legend> Miscellaneous settings </legend> 697 895 <p> 698 Widget title: <input type='text' size='64' name='wpmeetupactivity_title' value='$title' /> 699 </p> 700 <p> 896 Activity widget title: <input type='text' size='64' name='wpmeetupactivity_activity_title' value='$title' /> 897 </p><p> 898 Events widget title: <input type='text' size='64' name='wpmeetupactivity_events_title' value='$title_events' /> 899 </p><p> 701 900 <input type='checkbox' name='wpmeetupactivity_prefs_opennewwindows' ".wpmeetupactivity_is_checked($my_prefs["openInNewWindow"])."> Open link in a new window 702 </p> 703 <p> 901 </p><p> 704 902 <input type='checkbox' name='wpmeetupactivity_prefs_displayauthor' ".wpmeetupactivity_is_checked($my_prefs["displayAuthor"])."> Display post author name 705 </p> 706 <p> 903 </p><p> 707 904 <input type='checkbox' name='wpmeetupactivity_prefs_displaydate' ".wpmeetupactivity_is_checked($my_prefs["displayDate"])."> Display post date 708 </p> 709 <p> 905 </p><p> 710 906 Max number of activities to show: <select name='wpmeetupactivity_prefs_displayact'> 711 907 <option value=2 ".wpmeetupactivity_is_selected($my_prefs["displayAct"],2).">2</option> … … 715 911 <option value=20 ".wpmeetupactivity_is_selected($my_prefs["displayAct"],20).">20</option> 716 912 </select> 717 </p> 718 <p> 913 </p><p> 719 914 Order activities by: <select name='wpmeetupactivity_prefs_orderby'> 720 915 <option value='add_date' ".wpmeetupactivity_is_selected($my_prefs["orderBy"],'add_date').">Add date</option> 721 916 <option value='chg_date' ".wpmeetupactivity_is_selected($my_prefs["orderBy"],'chg_date').">Change date</option> 722 917 <option value='ranking' ".wpmeetupactivity_is_selected($my_prefs["orderBy"],'ranking').">Ranking</option> 918 </select> 919 </p><p> 920 Events widget description: <input type='text' size='128' name='wpmeetupactivity_events_desc' value='".((strlen($events_desc) > 0) ? $events_desc : "at %ADDRESS%. There are already %RSVP_YES% booked friends !")."' /> 921 <p class='wpmeetupactivity-tipbox'>You can use HTML tags and the following special variables: %ADDRESS%=Venue of the event | %RSVP_YES%=How many peoples will partecipate</p> 922 </p><p> 923 Max number of events to show: <select name='wpmeetupactivity_prefs_displayevents'> 924 <option value=1 ".wpmeetupactivity_is_selected($my_prefs["displayEvents"],1).">1</option> 925 <option value=2 ".wpmeetupactivity_is_selected($my_prefs["displayEvents"],2).">2</option> 926 <option value=3 ".wpmeetupactivity_is_selected($my_prefs["displayEvents"],3).">3</option> 927 <option value=4 ".wpmeetupactivity_is_selected($my_prefs["displayEvents"],4).">4</option> 928 <option value=5 ".wpmeetupactivity_is_selected($my_prefs["displayEvents"],5).">5</option> 723 929 </select> 724 930 </p> … … 751 957 </p><p> 752 958 App Secret: <input type='text' size='128' name='wpmeetupactivity_fb_appsecret' value='".$fb_options['app_secret']."' /> 753 </p> </fieldset>";959 </p>"; 754 960 if ($fb_user) { 755 961 echo "<fieldset class='wpmeetupactivity-setup-fieldset'><legend> Facebook Post-on-Page </legend> … … 782 988 } 783 989 } 784 echo "<p class='submit'><input type='submit' name='Submit' value='Save changes' /></p> 785 </form> 786 </div><!-- /WRAP -->"; 990 echo "</fieldset><p class='submit'><input type='submit' name='Submit' value='Save changes' /></p> 991 </form></div><!-- /WRAP -->"; 787 992 } 788 993 -
wp-meetup-activity/trunk/default.css
r589800 r668363 19 19 color: #fff; 20 20 } 21 22 .wpmeetupactivity-event-widget-box { 23 clear: both; 24 } 25 26 .wpmeetupactivity-event-widget-box-title { 27 font-size: 1.2em; 28 padding: 1px; 29 } 30 31 .wpmeetupactivity-event-widget-cal-box { 32 float: left; 33 width: 54px; 34 height: 54px; 35 border-radius: 5px; 36 padding: 4px; 37 margin: 2px; 38 background: #3B5998; 39 text-align: center; 40 } 41 42 .wpmeetupactivity-event-widget-cal-box-day { 43 font-size: 2em; 44 color: #fff; 45 text-align: center; 46 } 47 48 .wpmeetupactivity-event-widget-cal-box-month { 49 font-size: 0.8em; 50 color: #fff; 51 text-align: center; 52 } 53 54 .wpmeetupactivity-event-widget-detail-box { 55 font-size: 1.0em; 56 text-align: justify; 57 margin: 2px; 58 } 59 60 .wpmeetupactivity-tipbox { 61 padding: 8px; 62 color: #333; 63 font-size: 0.8em; 64 background: #FF9; 65 border: 1px solid #FC0; 66 -moz-border-radius: 2px; 67 border-radius: 2px; 68 text-align: justify; 69 } -
wp-meetup-activity/trunk/readme.txt
r592392 r668363 2 2 Contributors: o-zone 3 3 Donate link: http://www.zerozone.it 4 Tags: meetup, activity, meetup.com, group, facebook4 Tags: meetup, activity, meetup.com, events, group 5 5 Requires at least: 3.0 6 Tested up to: 3. 4.16 Tested up to: 3.5.1 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html 9 9 10 WP-Meetup-Activity display your groups latest activities (discussions, photos...) in a sidebar widget. Can also post directly to facebook pages new threads and replies10 WP-Meetup-Activity display your groups latest activities (discussions, photos...) and events in a sidebar widget 11 11 12 12 == Description == … … 22 22 2. Activate the plugin through the 'Plugins' menu in WordPress 23 23 3. Add the widget wherever you want 24 25 if you want to enable facebook Post-to-page feature, you need to create a new app: 26 27 1. Open your browser to https://developers.facebook.com/apps 28 2. Click on "Create new application" on top right 29 3. Set domain URLs 30 4. Write app Id and app secret on wp-meetup-activity setup page 31 5. Connect widget with your Facebook application, allowing manage_pages and offline_access rights 24 4. Set it up ! 32 25 33 26 == Frequently Asked Questions == … … 47 40 == Changelog == 48 41 49 = 0.1.3 = 50 * Enable/disable Facebook support 51 * Fixed some Facebook issue with other plugins (like "Facebook for Wordpress") 52 53 = 0.1.2 = 54 * Facebook support for Post-in-Page on new topics / reply 55 * Minor bugs fixed 42 = 0.1.4 = 43 * Added Meetup events support 44 * Some bugs fixed and minor code cleanups 56 45 57 46 = 0.1.1 = … … 75 64 == Upgrade Notice == 76 65 66 = 0.1.4 = 67 Added Meetup events support. Can you miss it ? 68 77 69 = 0.1.1 = 78 70 Database should upgrade automatically but please deactivate and reactivate the plugin after upgrade. -
wp-meetup-activity/trunk/wp-meetup-activity.php
r592392 r668363 3 3 Plugin Name: WP Meetup Activity 4 4 Plugin URI: http://www.zerozone.it/wordpress-meetup-plugin/ 5 Description: Display group activity from Meetup.com in a widget for your wordpress6 Version: 0.1. 35 Description: Display group activity and events from Meetup.com in a widget for your wordpress 6 Version: 0.1.4 7 7 Author: Michele "O-Zone" Pinassi 8 8 Author URI: http://www.zerozone.it/ 9 9 10 Copyright 2012 Michele "O-Zone" Pinassi10 Copyright 2012-2013 Michele "O-Zone" Pinassi 11 11 12 12 This program is free software; you can redistribute it and/or modify … … 44 44 global $wpdb; 45 45 46 define(WP_MEETUP_ACTIVITY,'0.1. 3');46 define(WP_MEETUP_ACTIVITY,'0.1.4'); 47 47 define(WP_MEETUP_ACTIVITY_TABLE, $wpdb->prefix."meetup_activity"); 48 48 … … 70 70 ) DEFAULT CHARSET = utf8; 71 71 72 CREATE TABLE ".WP_MEETUP_ACTIVITY_TABLE."_events ( 73 id int(10) NOT NULL AUTO_INCREMENT, 74 group_id INT(12) NOT NULL, 75 event_id INT(12) NOT NULL, 76 event_title TEXT NOT NULL, 77 event_address TEXT NOT NULL, 78 event_description TEXT NOT NULL, 79 event_datetime DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL, 80 event_updated DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL, 81 is_public SMALLINT(1) NOT NULL, 82 event_status VARCHAR(16) NOT NULL, 83 event_url TEXT NOT NULL, 84 yes_rsvp INT(5) NOT NULL, 85 add_date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, 86 PRIMARY KEY id (id), 87 UNIQUE KEY event_id (event_id) 88 ) DEFAULT CHARSET = utf8; 89 72 90 CREATE TABLE ".WP_MEETUP_ACTIVITY_TABLE."_groups ( 73 91 group_id mediumint(10) NOT NULL, … … 77 95 ) DEFAULT CHARSET = utf8;"; 78 96 97 79 98 require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 80 99 dbDelta($sql); … … 118 137 $groupsArray[$act['group_id']] = $act['group_name']; 119 138 120 $wpdb->query($wpdb->prepare("INSERT I NTO ".WP_MEETUP_ACTIVITY_TABLE."_groups (group_id, group_name, add_date) VALUES ( %d, %s, NOW())", $act['group_id'], $act['group_name']));139 $wpdb->query($wpdb->prepare("INSERT IGNORE INTO ".WP_MEETUP_ACTIVITY_TABLE."_groups (group_id, group_name, add_date) VALUES ( %d, %s, NOW())", $act['group_id'], $act['group_name'])); 121 140 } 122 141 } … … 230 249 } 231 250 251 function wpmeetupactivity_fetch_events($verbose=false) { 252 global $wpdb; 253 254 $apikey = get_option('wpmeetupactivity_apikey'); 255 256 $fb_options = get_option('wpmeetupactivity_fb_options'); 257 $fb_pages = $fb_options['pages']; 258 259 $groupsArray = get_option('wpmeetupactivity_groups'); 260 261 if(count($groupsArray) > 0) { 262 if($apikey) { 263 try { 264 $connection = new MeetupKeyAuthConnection($apikey); 265 $m = new MeetupEvents($connection); 266 foreach($groupsArray as $groupId) { 267 $events = $m->getEvents(array('group_id' => $groupId)); 268 269 foreach($events as $event) { 270 /* Array ( [visibility] => public 271 [status] => upcoming 272 [maybe_rsvp_count] => 0 273 [venue] => Array ( 274 [id] => 11656882 275 [lon] => 11.35083 276 [repinned] => 277 [name] => Circolo CRAL 278 [address_1] => via Algero Rosi 6 279 [lat] => 43.31786 280 [country] => it 281 [city] => Siena 282 ) 283 [id] => 103939182 284 [utc_offset] => 3600000 285 [time] => 1360958400000 286 [waitlist_count] => 0 287 [created] => 1360515889000 288 [yes_rsvp_count] => 10 289 [updated] => 1360617331000 290 [event_url] => http://www.meetup.com/Gruppo-di-Siena/events/[id]/ 291 [description] => descrizione evento.... 292 [headcount] => 0 293 [name] => Incontro con l'economista Filippo Abbate 294 [group] => Array ( 295 [id] => 209457 296 [group_lat] => 43.319999694824 297 [name] => Forum di Siena 298 [group_lon] => 11.329999923706 299 [join_mode] => open 300 [urlname] => Gruppo-di-Siena 301 [who] => Amici di Siena 302 ) 303 ) */ 304 305 $eventId = $event['id']; 306 307 $eventUpdated = gmdate("Y-m-d H:i:s",intval($event['updated'])/1000); 308 309 $eventVenue = $event['venue']['name'].','.$event['venue']['city']; 310 311 /* If event_id is already present, check for update. Else add new event_id row. */ 312 $result = $wpdb->get_row("SELECT id,TIMESTAMPDIFF(MINUTE,event_updated,'$eventUpdated') AS tDelta FROM ".WP_MEETUP_ACTIVITY_TABLE."_events WHERE group_id='$groupId' AND event_id='$eventId';", ARRAY_A); 313 314 if($result) { 315 // L'evento esiste gia 316 if($result['tDelta'] > 0) { 317 $result = $wpdb->query( $wpdb->prepare( "UPDATE ".WP_MEETUP_ACTIVITY_TABLE."_events SET event_title='%s', event_address='%s', event_description='%s', event_datetime='%s', event_updated='%s', event_status='%s', yes_rsvp=%d WHERE event_id=$eventId;", $event['name'], $eventVenue, $event['description'], gmdate("Y-m-d H:i:s",intval($event['time'])/1000), $eventUpdated, $event['status'], intval($event['yes_rsvp_count']))); 318 if($verbose) { 319 echo "<div class=\"updated\"><p><strong>"; 320 if($result) { 321 echo __('Updated event '.$eventId.': '.$event['name'], $wpmeetupactivity_textdomain); 322 } else { 323 echo __('DB SQL Error: '.$wpdb->print_error(), $wpmeetupactivity_textdomain); 324 } 325 echo "</strong></p></div>"; 326 } 327 } 328 } else { 329 // L'evento non esiste: aggiungilo al DB ! 330 $result = $wpdb->query( $wpdb->prepare("INSERT INTO ".WP_MEETUP_ACTIVITY_TABLE."_events (group_id, event_id, event_title, event_address, event_description, event_datetime, event_updated, is_public, event_status, event_url, yes_rsvp, add_date) VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', 1, '%s', '%s', %d, NOW())", $groupId, $eventId, $event['name'], $eventVenue, $event['description'], gmdate("Y-m-d H:i:s",intval($event['time'])/1000), $eventUpdated, $event['status'], $event['event_url'], intval($event['yes_rsvp_count']))); 331 if($verbose) { 332 echo "<div class=\"updated\"><p><strong>"; 333 if($result) { 334 echo __('Added new event '.$eventId.': '.$event['name'], $wpmeetupactivity_textdomain); 335 } else { 336 echo __('DB SQL Error: '.$wpdb->print_error(), $wpmeetupactivity_textdomain); 337 } 338 echo "</strong></p></div>"; 339 } 340 } 341 } 342 } 343 } catch (Exception $e) { 344 echo "Meetup API error: $e"; 345 } 346 } 347 } 348 } 349 350 232 351 function wpmeetupactivity_plugin_menu() { 233 352 add_options_page('WP-Meetup-Activity Plugin Options', 'WP-Meetup-Activity', 8, __FILE__, 'wpmeetupactivity_plugin_options'); … … 236 355 function wpmeetupactivity_widget_init() { 237 356 if ( function_exists( 'wp_register_sidebar_widget' ) ) { 238 wp_register_sidebar_widget('wpmeetupactivity','WP-Meetup-Activity', 'wpmeetupactivity_widget'); 357 wp_register_sidebar_widget('wpmeetupactivity','WP-Meetup-Activity', 'wpmeetupactivity_widget_activity'); 358 wp_register_sidebar_widget('wpmeetupevents','WP-Meetup-Events', 'wpmeetupactivity_widget_events'); 239 359 } else { 240 register_sidebar_widget('WP-Meetup-Activity', 'wpmeetupactivity_widget'); 360 // Deprecated function for older WP... 361 register_sidebar_widget('WP-Meetup-Activity', 'wpmeetupactivity_widget_activity'); 362 register_sidebar_widget('WP-Meetup-Events', 'wpmeetupactivity_widget_events'); 241 363 } 242 364 } 243 365 244 366 function wpmeetupactivity_register_styles() { 245 wp_register_style('wpmeetupactivity', plugins_url('default.css', __FILE__), array(), '201 20822', 'all' );367 wp_register_style('wpmeetupactivity', plugins_url('default.css', __FILE__), array(), '20130215', 'all' ); 246 368 wp_enqueue_style('wpmeetupactivity'); 247 369 } … … 262 384 } 263 385 264 function wpmeetupactivity_widget($args) { 386 function wpmeetupactivity_widget_events($args) { 387 global $wpdb; 388 389 $monthArray = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); 390 391 extract($args); 392 393 $title = get_option('wpmeetupactivity_events_title'); 394 $desc = get_option('wpmeetupactivity_events_desc'); 395 396 $groupsArray = get_option('wpmeetupactivity_groups'); 397 $my_prefs = get_option('wpmeetupactivity_prefs'); 398 399 echo $before_widget; 400 echo $before_title . $title . $after_title; 401 402 if(count($groupsArray) > 0) { 403 $events = $wpdb->get_results("SELECT * FROM ".WP_MEETUP_ACTIVITY_TABLE."_events WHERE DATEDIFF(event_datetime,NOW()) >= 0 ORDER BY event_datetime ASC LIMIT 3;",ARRAY_A); 404 405 if($events) { 406 $c=0; 407 foreach($events as $event) { 408 $eventUrl = $event['event_url']; 409 $eventDate = date_parse($event['event_datetime']); 410 $eventTitle = $event['event_title']; 411 412 echo "<div class='wpmeetupactivity-event-widget-box'> 413 <div class='wpmeetupactivity-event-widget-cal-box'> 414 <div class='wpmeetupactivity-event-widget-cal-box-day'>".$eventDate['day']."</div> 415 <div class='wpmeetupactivity-event-widget-cal-box-month'>".$monthArray[$eventDate['month']-1]." ".$eventDate['year']."</div> 416 </div> 417 <div class='wpmeetupactivity-event-widget-detail-box'> 418 <a href='$eventUrl' title='$eventTitle' alt='$eventTitle' target=_new'><b class='wpmeetupactivity-event-widget-box-title'>".((strlen($eventTitle) > 35) ? substr($eventTitle,0,32).'...' : $eventTitle)."</b></a> 419 <p>"; 420 echo str_replace(array("%ADDRESS%","%RSVP_YES%"),array($event['event_address'],$event['yes_rsvp']),$desc); 421 echo " </p> 422 </div> 423 </div>"; 424 $c = $c+1; 425 if($c >= $my_prefs['displayEvents']) { 426 break; 427 } 428 } 429 } else { 430 echo "<b>No events planned yet !</b>"; 431 } 432 } else { 433 echo "<b>No groups selected: did you set up the plugin ?</b>"; 434 } 435 436 echo $after_widget; 437 } 438 439 440 function wpmeetupactivity_widget_activity($args) { 265 441 global $wpdb; 266 442 … … 328 504 329 505 $disp_cnt = $disp_cnt+1; 330 if($disp_cnt > $my_prefs[ "displayAct"]) {506 if($disp_cnt > $my_prefs['displayAct']) { 331 507 break; 332 508 } … … 369 545 function wpmeetupactivity_plugin_cron_hourly() { 370 546 wpmeetupactivity_fetch_activity(); 547 wpmeetupactivity_fetch_events(); 371 548 } 372 549 … … 585 762 586 763 $my_prefs["displayAct"] = intval($_POST["wpmeetupactivity_prefs_displayact"]); 764 $my_prefs["displayEvents"] = intval($_POST["wpmeetupactivity_prefs_displayevents"]); 587 765 $my_prefs["orderBy"] = intval($_POST["wpmeetupactivity_prefs_orderby"]); 588 766 589 767 // Salva opzioni 590 768 update_option('wpmeetupactivity_apikey',$_POST['wpmeetupactivity_apikey']); 591 update_option('wpmeetupactivity_title',$_POST['wpmeetupactivity_title']); 769 update_option('wpmeetupactivity_title',$_POST['wpmeetupactivity_activity_title']); 770 update_option('wpmeetupactivity_events_title',$_POST['wpmeetupactivity_events_title']); 771 update_option('wpmeetupactivity_events_desc',$_POST['wpmeetupactivity_events_desc']); 592 772 update_option('wpmeetupactivity_groups',$myGroups); 593 773 update_option('wpmeetupactivity_prefs',$my_prefs); … … 635 815 echo __('Activities DB purged.', $wpmeetupactivity_textdomain); 636 816 echo "</strong></p></div>"; 817 818 $wpdb->get_results("TRUNCATE ".WP_MEETUP_ACTIVITY_TABLE."_events;"); 819 820 echo "<div class=\"updated\"><p><strong>"; 821 echo __('Events DB purged.', $wpmeetupactivity_textdomain); 822 echo "</strong></p></div>"; 637 823 } 638 824 … … 643 829 echo "</strong></p></div>"; 644 830 } 831 832 if($_POST["wpmeetupactivity_force_event_fetch"] == 'on') { 833 wpmeetupactivity_fetch_events(true); 834 echo "<div class=\"updated\"><p><strong>"; 835 echo __('Events fetched successfully.', $wpmeetupactivity_textdomain); 836 echo "</strong></p></div>"; 837 } 645 838 646 839 } … … 648 841 $apikey = get_option('wpmeetupactivity_apikey'); 649 842 $title = get_option('wpmeetupactivity_title'); 843 $title_events = get_option('wpmeetupactivity_events_title'); 844 $events_desc = get_option('wpmeetupactivity_events_desc'); 650 845 651 846 echo "<div class='wrap'><!-- WRAP --> … … 687 882 </p> 688 883 <p> 689 <input type='checkbox' name='wpmeetupactivity_purge_act_db'> Purge activity database 884 <input type='checkbox' name='wpmeetupactivity_force_event_fetch'> Force events fetch on save changes 885 </p> 886 <p> 887 <input type='checkbox' name='wpmeetupactivity_purge_act_db'> Purge database 690 888 </p> 691 889 <p> 692 <i>TIP: Select both checkboxes to re-initialize activities db with new, fresh, data !</i>890 <i>TIP: Select all checkboxes to re-initialize activities and events db with new, fresh, data !</i> 693 891 </p> 694 892 </fieldset>"; … … 696 894 echo "<fieldset class='wpmeetupactivity-setup-fieldset'><legend> Miscellaneous settings </legend> 697 895 <p> 698 Widget title: <input type='text' size='64' name='wpmeetupactivity_title' value='$title' /> 699 </p> 700 <p> 896 Activity widget title: <input type='text' size='64' name='wpmeetupactivity_activity_title' value='$title' /> 897 </p><p> 898 Events widget title: <input type='text' size='64' name='wpmeetupactivity_events_title' value='$title_events' /> 899 </p><p> 701 900 <input type='checkbox' name='wpmeetupactivity_prefs_opennewwindows' ".wpmeetupactivity_is_checked($my_prefs["openInNewWindow"])."> Open link in a new window 702 </p> 703 <p> 901 </p><p> 704 902 <input type='checkbox' name='wpmeetupactivity_prefs_displayauthor' ".wpmeetupactivity_is_checked($my_prefs["displayAuthor"])."> Display post author name 705 </p> 706 <p> 903 </p><p> 707 904 <input type='checkbox' name='wpmeetupactivity_prefs_displaydate' ".wpmeetupactivity_is_checked($my_prefs["displayDate"])."> Display post date 708 </p> 709 <p> 905 </p><p> 710 906 Max number of activities to show: <select name='wpmeetupactivity_prefs_displayact'> 711 907 <option value=2 ".wpmeetupactivity_is_selected($my_prefs["displayAct"],2).">2</option> … … 715 911 <option value=20 ".wpmeetupactivity_is_selected($my_prefs["displayAct"],20).">20</option> 716 912 </select> 717 </p> 718 <p> 913 </p><p> 719 914 Order activities by: <select name='wpmeetupactivity_prefs_orderby'> 720 915 <option value='add_date' ".wpmeetupactivity_is_selected($my_prefs["orderBy"],'add_date').">Add date</option> 721 916 <option value='chg_date' ".wpmeetupactivity_is_selected($my_prefs["orderBy"],'chg_date').">Change date</option> 722 917 <option value='ranking' ".wpmeetupactivity_is_selected($my_prefs["orderBy"],'ranking').">Ranking</option> 918 </select> 919 </p><p> 920 Events widget description: <input type='text' size='128' name='wpmeetupactivity_events_desc' value='".((strlen($events_desc) > 0) ? $events_desc : "at %ADDRESS%. There are already %RSVP_YES% booked friends !")."' /> 921 <p class='wpmeetupactivity-tipbox'>You can use HTML tags and the following special variables: %ADDRESS%=Venue of the event | %RSVP_YES%=How many peoples will partecipate</p> 922 </p><p> 923 Max number of events to show: <select name='wpmeetupactivity_prefs_displayevents'> 924 <option value=1 ".wpmeetupactivity_is_selected($my_prefs["displayEvents"],1).">1</option> 925 <option value=2 ".wpmeetupactivity_is_selected($my_prefs["displayEvents"],2).">2</option> 926 <option value=3 ".wpmeetupactivity_is_selected($my_prefs["displayEvents"],3).">3</option> 927 <option value=4 ".wpmeetupactivity_is_selected($my_prefs["displayEvents"],4).">4</option> 928 <option value=5 ".wpmeetupactivity_is_selected($my_prefs["displayEvents"],5).">5</option> 723 929 </select> 724 930 </p> … … 751 957 </p><p> 752 958 App Secret: <input type='text' size='128' name='wpmeetupactivity_fb_appsecret' value='".$fb_options['app_secret']."' /> 753 </p> </fieldset>";959 </p>"; 754 960 if ($fb_user) { 755 961 echo "<fieldset class='wpmeetupactivity-setup-fieldset'><legend> Facebook Post-on-Page </legend> … … 782 988 } 783 989 } 784 echo "<p class='submit'><input type='submit' name='Submit' value='Save changes' /></p> 785 </form> 786 </div><!-- /WRAP -->"; 990 echo "</fieldset><p class='submit'><input type='submit' name='Submit' value='Save changes' /></p> 991 </form></div><!-- /WRAP -->"; 787 992 } 788 993
Note: See TracChangeset
for help on using the changeset viewer.