<?php

/**
 * @package CsvImporterPlusforACF
 */

namespace CIPFA\base;

// make sure we don't expose any info if called directly
if (!defined('ABSPATH')) exit; // Exit if accessed directly

class CIPFA_SettingsLinks extends CIPFA_BaseController
{
   //register plugin upgarde link
   public static function cipfa_register()
   {
      add_filter('plugin_action_links_' . parent::$plugin_name, array(__CLASS__, 'cipfa_settingLinks'));
      add_filter('plugin_row_meta', array(__CLASS__, 'cipfa_plugin_meta_links'), 10, 2);
   }

   //add upgrade link
   public static function cipfa_settingLinks($links)
   {
      //add dashboard link
      $upgardeLink = '<a href="' . esc_url('https://csvimporterplusforacf.com/') . '" target="_blank">' . esc_html__('CSV Importer Plus Pro for ACF', 'csv-importer-plus-for-acf') . '</a>';

      array_push($links, $upgardeLink);
      return $links;
   }

   //add links to plugin's description
   public static function cipfa_plugin_meta_links($links, $file)
   {
      // Ensure that we're only modifying this plugin's links
      if (strpos($file, 'csv-importer-plus-for-acf') !== false) {
         $support_link = '<a href="' . esc_url('https://wordpress.org/support/plugin/csv-importer-plus-for-acf') . '" target="_blank" title="' . esc_html__('Get help', 'csv-importer-plus-for-acf') . '">' . esc_html__('Support', 'csv-importer-plus-for-acf') . '</a>';
         $home_link = '<a href="' . esc_url('https://csvimporterplusforacf.com/') . '" target="_blank" title="' . esc_html__('Plugin Homepage', 'csv-importer-plus-for-acf') . '">' . esc_html__('Plugin Homepage', 'csv-importer-plus-for-acf') . '</a>';
         $rate_link = '<a href="' . esc_url('https://wordpress.org/support/plugin/csv-importer-plus-for-acf/reviews/?rate=5#new-post') . '" target="_blank" title="' . esc_html__('Rate the plugin', 'csv-importer-plus-for-acf') . '">' . esc_html__('Rate the plugin ★★★★★', 'csv-importer-plus-for-acf') . '</a>';

         // Add the custom links to the existing ones
         $links[] = $support_link;
         $links[] = $home_link;
         $links[] = $rate_link;
      }
      return $links;
   }
}
