<?php

namespace Itgalaxy\Elementor\Form\Infusionsoft\Integration\Admin;

use Itgalaxy\Elementor\Form\Infusionsoft\Integration\Includes\Bootstrap;

class PluginActionLinksFilter
{
    /**
     * @see https://developer.wordpress.org/reference/hooks/plugin_action_links/
     */
    public function __construct()
    {
        add_filter('plugin_action_links', [$this, 'pluginActionLinks'], 10, 2);
    }

    /**
     * @param array  $actions
     * @param string $pluginFile
     *
     * @return array
     */
    public function pluginActionLinks($actions, $pluginFile)
    {
        if (strpos($pluginFile, 'elementor-pro-form-widget-infusionsoft-integration.php') === false) {
            return $actions;
        }

        $settingsLink = '<a href="'
            . admin_url()
            . 'admin.php?page=' . Bootstrap::OPTIONS_KEY . '">'
            . esc_html__('Settings', 'el-pro-form-infusionsoft-integration')
            . '</a>';

        $documentationLink = '<a href="'
            . esc_url(
                __(
                    'https://itgalaxy.company/en/software/elementor-pro-form-widget-infusionsoft-keap-crm-integration/elementor-pro-form-widget-infusionsoft-keap-crm-integration-instructions/',
                    'el-pro-form-infusionsoft-integration'
                )
            )
            . '" target="_blank">'
            . esc_html__('Documentation', 'el-pro-form-infusionsoft-integration')
            . '</a>';

        array_push(
            $actions,
            $settingsLink,
            $documentationLink
        );

        return $actions;
    }
}
