<?php
/**
 * Import class.
 *
 * @package Social_Post_Flow
 * @author Social Post Flow
 */

/**
 * Imports a JSON configuration file generated by the Plugin's export functionality.
 *
 * @package Social_Post_Flow
 * @author  Social Post Flow
 */
class Social_Post_Flow_Import {

	/**
	 * Constructor.
	 *
	 * @since   1.0.0
	 */
	public function __construct() {

		// Import.
		add_action( 'social_post_flow_import', array( $this, 'import' ), 10, 2 );

	}

	/**
	 * Import data created by this Plugin's export functionality
	 *
	 * @since   1.0.0
	 *
	 * @param   bool  $success    Success.
	 * @param   array $import     Array.
	 * @return  mixed               WP_Error | bool
	 */
	public function import( $success, $import ) {

		foreach ( $import['data'] as $key => $value ) {
			update_option( $key, $value );
		}

		return $success;

	}

}
