コード例 #1
0
/**
 * Upgrade routine. Hooked onto admin_init
 *
 *@since 1.1
 *@access private
 *@ignore
*/
function eventorganiser_upgradecheck()
{
    global $wpdb, $EO_Errors;
    $eventorganiser_db_version = defined('EVENT_ORGANISER_VER') ? EVENT_ORGANISER_VER : false;
    $installed_ver = get_option('eventorganiser_version');
    if (empty($installed_ver)) {
        //This is a fresh install. Add current database version
        add_option('eventorganiser_version', $eventorganiser_db_version);
        //But a bug in 1.5 means that it could be that they first installed in 1.5 (as no db version was added)
        //So set to 1.5.  Fresh installs will have to go through the 1.6 (and above) update, but this is ok.
        $installed_ver = '1.5';
    }
    //If this is an old version, perform some updates.
    if (!empty($installed_ver) && $installed_ver != $eventorganiser_db_version) {
        if ($installed_ver < '1.3') {
            wp_die('You cannot upgrade to this version from 1.3 or before. Please upgrade to 1.5.7 first.');
        }
        if ($installed_ver < '1.4') {
            eventorganiser_140_update();
        }
        if ($installed_ver < '1.5') {
            eventorganiser_150_update();
        }
        if ($installed_ver < '1.6') {
            //Remove columns:
            $columns = $wpdb->get_col("DESC {$wpdb->eo_events}", 0);
            $remove_columns = array('Venue', 'event_schedule', 'event_schedule_meta', 'event_frequency', 'reoccurrence_start', 'reoccurrence_end');
            $delete_columns = array_intersect($remove_columns, $columns);
            if (!empty($delete_columns)) {
                $sql = $wpdb->query("ALTER TABLE {$wpdb->eo_events} DROP COLUMN " . implode(', DROP COLUMN ', $delete_columns) . ';');
            }
            eventorganiser_install();
        }
        if ($installed_ver < '1.6.2') {
            $options = get_option('eventorganiser_options');
            if (!empty($options['eventtag'])) {
                $options['supports'][] = 'eventtag';
                update_option('eventorganiser_options', $options);
            }
        }
        if ($installed_ver < '1.7.1') {
            //Forgot to remove event_allday in 1.6 upgrade. This causes problems no Windows servers.
            $columns = $wpdb->get_col("DESC {$wpdb->eo_events}", 0);
            $remove_columns = array('event_allday');
            if (!empty($delete_columns)) {
                $sql = $wpdb->query("ALTER TABLE {$wpdb->eo_events} DROP COLUMN " . implode(', DROP COLUMN ', $delete_columns) . ';');
            }
            flush_rewrite_rules();
        }
        update_option('eventorganiser_version', $eventorganiser_db_version);
        //Run upgrade checks
        add_action('admin_notices', 'eventorganiser_db_checks', 0);
    }
}
コード例 #2
0
/**
 * Upgrade routine. Hooked onto admin_init
 *
 *@since 1.1
 *@access private
 *@ignore
*/
function eventorganiser_upgradecheck()
{
    global $wpdb, $EO_Errors;
    $eventorganiser_db_version = defined('EVENT_ORGANISER_VER') ? EVENT_ORGANISER_VER : false;
    $installed_ver = get_option('eventorganiser_version');
    if (empty($installed_ver)) {
        //This is a fresh install. Add current database version
        add_option('eventorganiser_version', $eventorganiser_db_version);
        //But a bug in 1.5 means that it could be that they first installed in 1.5 (as no db version was added)
        //So set to 1.5.  Fresh installs will have to go through the 1.6 (and above) update, but this is ok.
        $installed_ver = '1.5';
        eventorganiser_install();
    }
    //If this is an old version, perform some updates.
    if (!empty($installed_ver) && $installed_ver != $eventorganiser_db_version) {
        if (version_compare($installed_ver, '1.3', '<')) {
            wp_die('You cannot upgrade to this version from 1.3 or before. Please upgrade to 1.5.7 first.');
        }
        if (version_compare($installed_ver, '1.4', '<')) {
            eventorganiser_140_update();
        }
        if (version_compare($installed_ver, '1.5', '<')) {
            eventorganiser_150_update();
        }
        if (version_compare($installed_ver, '1.6', '<')) {
            //Remove columns:
            $columns = $wpdb->get_col("DESC {$wpdb->eo_events}", 0);
            $remove_columns = array('Venue', 'event_schedule', 'event_schedule_meta', 'event_frequency', 'reoccurrence_start', 'reoccurrence_end');
            $delete_columns = array_intersect($remove_columns, $columns);
            if (!empty($delete_columns)) {
                $sql = $wpdb->query("ALTER TABLE {$wpdb->eo_events} DROP COLUMN " . implode(', DROP COLUMN ', $delete_columns) . ';');
            }
            eventorganiser_install();
        }
        if (version_compare($installed_ver, '1.6.2', '<')) {
            $options = get_option('eventorganiser_options');
            if (!empty($options['eventtag'])) {
                $options['supports'][] = 'eventtag';
                update_option('eventorganiser_options', $options);
            }
        }
        if (version_compare($installed_ver, '2.7.3', '<')) {
            //Ensure event_allday columns is removed. This causes problems on Windows servers.
            $columns = $wpdb->get_col("DESC {$wpdb->eo_events}", 0);
            $remove_columns = array('event_allday');
            $delete_columns = array_intersect($remove_columns, $columns);
            if (!empty($delete_columns)) {
                $sql = $wpdb->query("ALTER TABLE {$wpdb->eo_events} DROP COLUMN " . implode(', DROP COLUMN ', $delete_columns) . ';');
            }
            flush_rewrite_rules();
        }
        if (version_compare($installed_ver, '2.12.0', '<') && version_compare(get_bloginfo('version'), '4.2-alpha-31007-src', '>=')) {
            //If the user is upgrading from an earlier version (without the split term fix)
            //and they have already upgraded to WP 4.2.0, then run the update routine
            eventorganiser_021200_update();
        }
        update_option('eventorganiser_version', $eventorganiser_db_version);
        //Run upgrade checks
        add_action('admin_notices', 'eventorganiser_db_checks', 0);
    }
    //eventorganiser_021200_update();
}