<?php

defined('ABSPATH') || exit;

class BundlePress_Deactivation_Survey
{
    public static function init()
    {
        add_action('admin_footer', [__CLASS__, 'render_survey_modal']);
    }

    public static function render_survey_modal()
    {
        $screen = get_current_screen();
        if ($screen->id === 'plugins') {
            ?>
            <script type="text/javascript">
                (function($) {
                    $(function() {
                        var $deactivateLink = $('#the-list').find('[data-slug="shopcentral"] .deactivate a');
                        if (!$deactivateLink.length) {
                            $deactivateLink = $('#the-list').find('[data-slug="bundlepress"] .deactivate a');
                        }

                        $deactivateLink.on('click', function(e) {
                            // Deactivation survey logic here
                        });
                    });
                })(jQuery);
            </script>
            <?php
        }
    }
}
