<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
function drop_print_plugin_activation() {
	if ( function_exists( 'drop_print_create_global_attribute' ) ) {
		if ( ! drop_print_create_global_attribute( __( 'Print Dimensions', 'drop-print' ), 'print_dimensions' ) ) {
		}
	} else {
		wp_safe_redirect( admin_url( 'plugins.php?error=drop_print_missing_utils' ) );
		exit;
	}
	if ( false === get_option( 'drop_print_files' ) ) {
		add_option( 'drop_print_files', array( 'schema_version' => 2, 'files' => array() ), '', 'no' );
	}
	$activating_user = get_current_user_id();
	if ( $activating_user > 0 ) {
		set_transient( 'drop_print_activation_redirect', $activating_user, 5 * MINUTE_IN_SECONDS );
	}
}
function drop_print_show_activation_notice() {
	$error_param = isset($_GET['error']) ? sanitize_key($_GET['error']) : '';
	if ( 'drop_print_woocommerce_required' === $error_param ) {
		?>
		<div class="notice notice-error is-dismissible">
			<p><?php esc_html_e( 'The Drop Print Plugin requires WooCommerce to be installed and activated.', 'drop-print' ); ?></p>
		</div>
		<?php
	}
	if ( 'drop_print_attribute_creation_failed' === $error_param ) {
		?>
		<div class="notice notice-error is-dismissible">
			<p><?php esc_html_e( 'Failed to create the "Print Dimensions" attribute. Please ensure WooCommerce is functioning correctly.', 'drop-print' ); ?></p>
		</div>
		<?php
	}
	if ( 'drop_print_missing_utils' === $error_param ) {
		?>
		<div class="notice notice-error is-dismissible">
			<p><?php esc_html_e( 'Drop Print critical file missing (utils.php). Please reinstall the plugin.', 'drop-print' ); ?></p>
		</div>
		<?php
	}
}
add_action( 'admin_notices', 'drop_print_show_activation_notice' );
function drop_print_plugin_deactivate() {
}
