<?php

/**
 * 
 * Migrate custom post type switch options to checkbox list
 *
 */
class Intense_Migration_2_5_2 extends Intense_Migration {
	public function up(){
		parent::up();	

		//Migrate shortcode CSS keys

		$intense_visions_options = get_option( 'intense_visions_options' );	

		$cpt_types = array(
			'intense_cpt_books',
			'intense_cpt_clients',
			'intense_cpt_coupons',
			'intense_cpt_events',
			'intense_cpt_faq',
			'intense_cpt_jobs',
			'intense_cpt_locations',
			'intense_cpt_movies',
			'intense_cpt_music',
			'intense_cpt_news',
			'intense_cpt_portfolio',
			'intense_cpt_project',
			'intense_cpt_quotes',
			'intense_cpt_recipes',
			'intense_cpt_snippets',
			'intense_cpt_team',
			'intense_cpt_templates',
			'intense_cpt_testimonials',
		);

		$intense_visions_options['intense_active_cpt'] = array();

		foreach ($cpt_types as $key => $value) {
			if ( !empty ( $intense_visions_options[ $value ] ) ) {
				$intense_visions_options['intense_active_cpt'][ $value ] = '1';
			}
		}		

		update_option( 'intense_visions_options', $intense_visions_options );
	}

	public function down() {
		parent::down();	

		$intense_visions_options = get_option( 'intense_visions_options' );		

		foreach ( $intense_visions_options['intense_active_cpt'] as $key => $value) {
			$intense_visions_options[ $key ] = $value;
		}

		update_option( 'intense_visions_options', $intense_visions_options );
	}
}
