<?php

if ( ! PWP_EDD::is_wpcom() && ! PWP_EDD::is_woo() ) {
	add_action( 'admin_init', 'pwp_activation' );
	add_action( 'after_switch_theme', 'pwp_redirect_on_activation' );
}

function pwp_redirect_on_activation() {
	// Set the option to redirect
	add_option('pwp_has_been_activated', true);
}
function pwp_activation() {

    if ( get_option('pwp_has_been_activated', false ) ) {
        // Delete the option to prevent subsequent redirects
        delete_option('pwp_has_been_activated');

        // Decide the correct menu link based on free vs. premium
        if ( PWP_EDD::is_wpcom() || PWP_EDD::is_woo() ) {
            $pwp_url = 'themes.php?page=portfolio-wp';
        } else {
            $pwp_url = 'admin.php?page=portfolio-wp';
        }

        // Redirect to the desired page using safe redirect
        wp_safe_redirect( admin_url( $pwp_url ) );
        exit;
    }
}

