<?php

/**
 * Fired during plugin activation.
 *
 * @link    https://aiopodcasting.com
 * @since   1.0.0
 *
 * @package AiO_Podcast_Studio
 */

// Exit if accessed directly
if ( ! defined( 'WPINC' ) ) {
	die;
}

/**
 * AIOPOD_Activator class.
 *
 * @since 1.0.0
 */
class AIOPOD_Activator {

	/**
	 * Called when the plugin is activated.
	 *
	 * @since 1.0.0
	 */
	public static function activate() {	
		// Insert the plugin settings and default values for the first time
		$defaults = aiopod_get_default_settings();

		foreach ( $defaults as $option_name => $values ) {
			if ( false === get_option( $option_name ) ) {	
        		add_option( $option_name, $values );						
    		}
		}
		
		// Add custom AIOPOD capabilities
		if ( false === get_option( 'aiopod_version' ) ) {
			$roles = new AIOPOD_Roles;
			$roles->add_caps();
		}
		
		// Remove the unfiltered_html capability from editors
		aiopod_remove_unfiltered_html_capability_from_editors();

		// Create custom database tables
		AIOPOD_Statistics_Helper::get_instance()->create_custom_tables();

		// Insert the plugin version
		add_option( 'aiopod_version', AIOPOD_PLUGIN_VERSION );
	}

}
