get_version(); // skip if latest version if ( $current_version == self::VERSION ) { return; } for ( $i = $current_version + 1; $i <= self::VERSION; $i ++ ) { $method = "update_{$i}"; if ( method_exists( $this, $method ) ) { $this->$method(); $this->set_version( $i ); } } } function update_1(){ install(); global $wpdb; $query = " INSERT INTO ".tablename()." (post_id, author_id) SELECT DISTINCT post_id, meta_value as author_id FROM {$wpdb->postmeta} WHERE meta_key = %s AND meta_value IS NOT NULL "; $wpdb->query( $wpdb->prepare($query, '_additional_authors')); } }