<?php

/**
 * Fired during plugin activation
 *
 * @link       https://autoserve.io
 * @since      1.0.0
 *
 * @package    Messageflow
 * @subpackage Messageflow/includes
 */

/**
 * Fired during plugin activation.
 *
 * This class defines all code necessary to run during the plugin's activation.
 *
 * @since      1.0.0
 * @package    Messageflow
 * @subpackage Messageflow/includes
 * @author     Autoserve <support@autoserve.io>
 */
class Messageflow_Activator {

	/**
	 * Short Description. (use period)
	 *
	 * Long Description.
	 *
	 * @since    1.0.0
	 */
	public static function activate() {
		$default_plugin_visibility_roles = array( 'administrator', 'shop_manager', 'editor' );

		update_option( 'messageflow-settings-visibility-permission', $default_plugin_visibility_roles );

		foreach ( $default_plugin_visibility_roles as $slug ) {
			$role = get_role( $slug );

			// Add capability for default roles to view MessageFlow plugin
			$role->add_cap( 'can_view_messageflow', true );
			// Add capability for default roles to call MessageFlow's APIs
			$role->add_cap( 'can_call_messageflow_api', true );
		}
	}

}
