Plugin Directory

Changeset 676447


Ignore:
Timestamp:
03/05/2013 01:52:15 PM (13 years ago)
Author:
O-Zone
Message:

BUGFIX for scheduled events

Location:
wp-meetup-activity/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-meetup-activity/trunk/readme.txt

    r668363 r676447  
    4040== Changelog ==
    4141
     42= 0.1.5 =
     43* Fixed a bug with scheduled events (wp-cron)
     44
    4245= 0.1.4 =
    4346* Added Meetup events support
     
    6467== Upgrade Notice ==
    6568
     69= 0.1.5 =
     70Bugfix release: scheduled events should not duplicate anymore
     71
    6672= 0.1.4 =
    6773Added Meetup events support. Can you miss it ?
  • wp-meetup-activity/trunk/wp-meetup-activity.php

    r668363 r676447  
    44Plugin URI: http://www.zerozone.it/wordpress-meetup-plugin/
    55Description: Display group activity and events from Meetup.com in a widget for your wordpress
    6 Version: 0.1.4
     6Version: 0.1.5
    77Author: Michele "O-Zone" Pinassi
    88Author URI: http://www.zerozone.it/
     
    3333
    3434add_option('wpmeetupactivity_apikey', '', '', 'yes');
     35add_option('wpmeetupactivity_events_desc', 'at %ADDRESS%. There are already %RSVP_YES% booked friends !', '', 'yes');
    3536add_action('admin_menu', 'wpmeetupactivity_plugin_menu');
    3637add_action('plugins_loaded', 'wpmeetupactivity_widget_init');
    37 add_action('plugins_loaded', 'wpmeetupactivity_update_db_check');
    3838add_action('init', 'wpmeetupactivity_register_styles');
    3939add_action('init', 'wpmeetupactivity_fb_init');
    4040
    41 register_activation_hook(__FILE__,'wpmeetupactivity_install');
    42 register_deactivation_hook( __FILE__,'wpmeetupactivity_uninstall');
     41register_activation_hook(__FILE__,'wpmeetupactivity_activate');
     42register_deactivation_hook( __FILE__,'wpmeetupactivity_deactivate');
     43register_uninstall_hook( __FILE__, 'wpmeetupactivity_uninstall');
    4344
    4445global $wpdb;
    4546
    46 define(WP_MEETUP_ACTIVITY,'0.1.4');
     47define(WP_MEETUP_ACTIVITY,'0.1.5');
    4748define(WP_MEETUP_ACTIVITY_TABLE, $wpdb->prefix."meetup_activity");
    4849
    4950/*
    5051
    51 wpmeetupactivity_install() - Install plugin DATABASE
     52CRON procedures that run every hours to fetch new activity
    5253
    5354*/
    54 function wpmeetupactivity_install() {
     55
     56add_action('wpmeetupactivity_hourly', 'wpmeetupactivity_plugin_cron_hourly');
     57
     58function wpmeetupactivity_plugin_cron_hourly() {
     59    wpmeetupactivity_fetch_activity();
     60    wpmeetupactivity_fetch_events();
     61}
     62
     63/*
     64
     65wpmeetupactivity_activate() - Install plugin DATABASE
     66
     67*/
     68function wpmeetupactivity_activate() {
     69    if(!wp_next_scheduled('wpmeetupactivity_hourly')) {
     70    wp_schedule_event( current_time( 'timestamp' ), 'hourly', 'wpmeetupactivity_hourly');
     71    }
     72}
     73
     74function wpmeetupactivity_update_db_check() {
    5575    global $wpdb;
    5676
    57     $sql = "CREATE TABLE ".WP_MEETUP_ACTIVITY_TABLE."_act (
     77    if (get_site_option('wpmeetupactivity_db_version') != WP_MEETUP_ACTIVITY) {
     78    $sql = "CREATE TABLE ".WP_MEETUP_ACTIVITY_TABLE."_act (
    5879    id int(10) NOT NULL AUTO_INCREMENT,
    5980    group_id int(12) NOT NULL,
     
    6889    add_date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
    6990    UNIQUE KEY id (id)
    70     ) DEFAULT CHARSET = utf8;
    71 
    72     CREATE TABLE ".WP_MEETUP_ACTIVITY_TABLE."_events (
     91    ) DEFAULT CHARSET = utf8;
     92
     93    CREATE TABLE ".WP_MEETUP_ACTIVITY_TABLE."_events (
    7394    id int(10) NOT NULL AUTO_INCREMENT,
    7495    group_id INT(12) NOT NULL,
     
    86107    PRIMARY KEY id (id),
    87108    UNIQUE KEY event_id (event_id)
    88     ) DEFAULT CHARSET = utf8;
    89 
    90     CREATE TABLE ".WP_MEETUP_ACTIVITY_TABLE."_groups (
     109    ) DEFAULT CHARSET = utf8;
     110
     111    CREATE TABLE ".WP_MEETUP_ACTIVITY_TABLE."_groups (
    91112    group_id mediumint(10) NOT NULL,
    92113    group_name text NOT NULL,
    93114    add_date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
    94115    UNIQUE KEY group_id (group_id)
    95     ) DEFAULT CHARSET = utf8;";
    96 
    97 
    98     require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    99     dbDelta($sql);
    100     add_option("wpmeetupactivity_db_version", WP_MEETUP_ACTIVITY);
    101 }
    102 
    103 function wpmeetupactivity_update_db_check() {
    104     if (get_site_option('wpmeetupactivity_db_version') != WP_MEETUP_ACTIVITY) {
    105     wpmeetupactivity_install();
    106     }
     116    ) DEFAULT CHARSET = utf8;";
     117   
     118    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
     119        dbDelta($sql);
     120    add_option("wpmeetupactivity_db_version", WP_MEETUP_ACTIVITY);
     121   
     122    echo "<div class=\"updated\"><p><strong>";
     123    echo __('Updated DB to '.WP_MEETUP_ACTIVITY, $wpmeetupactivity_textdomain);
     124    echo "</strong></p></div>";
     125
     126    wpmeetupactivity_activate();
     127    }
     128}
     129
     130function wpmeetupactivity_deactivate() {
     131    global $wpdb;
     132    $timestamp = wp_next_scheduled('wpmeetupactivity_hourly');
     133    wp_unschedule_event($timestamp, 'hourly', 'wpmeetupactivity_hourly');
    107134}
    108135
     
    111138    /* Perform a complete uninstall of DB tables on UNINSTALL */
    112139    $wpdb->query($wpdb->prepare("DROP ".WP_MEETUP_ACTIVITY_TABLE."_groups; DROP ".WP_MEETUP_ACTIVITY_TABLE."_act;"));
     140    /* Disable CRON */
     141    $timestamp = wp_next_scheduled('wpmeetupactivity_hourly');
     142   
     143    while($timestamp) {
     144    wp_unschedule_event($timestamp, 'hourly', 'wpmeetupactivity_hourly');
     145    $timestamp = wp_next_scheduled('wpmeetupactivity_hourly');
     146    }
     147
     148   
     149    wp_clear_scheduled_hook( 'wpmeetupactivity_hourly' );
     150   
    113151}
    114152
     
    355393function wpmeetupactivity_widget_init() {
    356394    if ( function_exists( 'wp_register_sidebar_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');
     395    wp_register_sidebar_widget('wpmeetupactivity','WP-Meetup-Activity', 'wpmeetupactivity_widget_activity',array('description' => 'Display latest activity on your Meetups'));
     396    wp_register_sidebar_widget('wpmeetupevents','WP-Meetup-Events', 'wpmeetupactivity_widget_events',array('description' => 'Display upcoming Meetups'));
    359397    } else {
    360398    // Deprecated function for older WP...
     
    530568}
    531569
    532 /*
    533 
    534 CRON procedures that run every hours to fetch new activity
    535 
    536 */
    537 
    538 register_activation_hook(__FILE__, 'wpmeetupactivity_plugin_cron_activation');
    539 add_action('wpmeetupactivity_hourly', 'wpmeetupactivity_plugin_cron_hourly');
    540 
    541 function wpmeetupactivity_plugin_cron_activation() {
    542     wp_schedule_event( current_time( 'timestamp' ), 'hourly', 'wpmeetupactivity_hourly');
    543 }
    544 
    545 function wpmeetupactivity_plugin_cron_hourly() {
    546     wpmeetupactivity_fetch_activity();
    547     wpmeetupactivity_fetch_events();
    548 }
    549570
    550571/*
     
    718739    global $wpdb;
    719740    global $facebook;
     741
    720742
    721743    load_plugin_textdomain($wpmeetupactivity_textdomain, PLUGINDIR . '/' . dirname(plugin_basename(__FILE__)), dirname(plugin_basename(__FILE__)));
Note: See TracChangeset for help on using the changeset viewer.