<?php
/**
 * The plugin bootstrap file
 *
 * @link              https://www.francescopepe.com
 * @since             1.0.0
 * @package           Popper
 *
 * @wordpress-plugin
 * Plugin Name:       Popper
 * Plugin URI:        https://popperwp.com
 * Description:       Popup builder with exit-intent powered by Gutenberg.
 * Version:           0.9.7
 * Author:            Tropicalista
 * Author URI:        https://www.francescopepe.com/
 * License:           GPL-2.0+
 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
 * Text Domain:       popper
 * Domain Path:       /languages
 */

// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
	die;
}

require __DIR__ . '/lib/vendor/autoload.php';

/**
 * The code that runs during plugin activation.
 * This action is documented in includes/class-popper-activator.php
 */
function popper_activate() {
	Popper\Activator::activate();
}

/**
 * The code that runs during plugin deactivation.
 * This action is documented in includes/class-popper-deactivator.php
 */
function popper_deactivate() {
	Popper\Deactivator::deactivate();
}

register_activation_hook( __FILE__, 'popper_activate' );
register_deactivation_hook( __FILE__, 'popper_deactivate' );

/**
 * Begins execution of the plugin.
 *
 * Since everything within the plugin is registered via hooks,
 * then kicking off the plugin from this point in the file does
 * not affect the page life cycle.
 *
 * @since    1.0.0
 */
function popper_run() {
	$plugin = new Popper\Plugin( __FILE__ );
	$plugin->run();

	$client = new Popper\Appsero\Client( '3cf9fb47-a835-47f8-be36-df7bdfceda26', 'Popup with exit intent, scroll triggered and anchor click for opt-ins, lead gen &amp; more', __FILE__ );

	// Active insights.
	$client->insights()
		->add_plugin_data()
		->init();
}
popper_run();

/**
 * Register blocks
 *
 * @return void
 */
function popper_init() {

	wp_register_block_metadata_collection(
		__DIR__ . '/build',
		__DIR__ . '/build/blocks-manifest.php'
	);

	register_block_type_from_metadata( __DIR__ . '/build/blocks/popper' );
	register_block_type_from_metadata( __DIR__ . '/build/blocks/popper-body' );
	register_block_type_from_metadata( __DIR__ . '/build/blocks/button' );
	register_block_type_from_metadata( __DIR__ . '/build/blocks/form' );
	register_block_type_from_metadata( __DIR__ . '/build/blocks/form-input' );
	register_block_type_from_metadata( __DIR__ . '/build/blocks/form-select' );
	register_block_type_from_metadata( __DIR__ . '/build/blocks/form-multichoices' );
	register_block_type_from_metadata( __DIR__ . '/build/blocks/form-button' );
}
add_action( 'init', 'popper_init' );
