| 1 |
<?php |
| 2 |
namespace UninstallerForm\Support; |
| 3 |
|
| 4 |
/** |
| 5 |
* Localizer class for the uninstaller form. |
| 6 |
* |
| 7 |
* @since 1.0.0 |
| 8 |
* |
| 9 |
* @package UNINSTALLER_FORM |
| 10 |
*/ |
| 11 |
class Localizer { |
| 12 |
protected $name, $text_domain, $plugin_file, $script_handle; |
| 13 |
|
| 14 |
/** |
| 15 |
* Localizer Constructor. |
| 16 |
* |
| 17 |
* @param string $name The name of the plugin. |
| 18 |
* @param string $slug The slug of the plugin. |
| 19 |
* @param string $plugin_file The path to the plugin file. |
| 20 |
* @param string $script_handle The handle of the script to enqueue. |
| 21 |
* |
| 22 |
* @since 1.0.0 |
| 23 |
*/ |
| 24 |
public function __construct($name, $text_domain, $plugin_file, $script_handle) { |
| 25 |
$this->name = $name; |
| 26 |
$this->text_domain = $text_domain; |
| 27 |
$this->plugin_file = $plugin_file; |
| 28 |
$this->script_handle = $script_handle; |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* Handle localization for the uninstaller form. |
| 33 |
* |
| 34 |
* @since 1.0.0 |
| 35 |
*/ |
| 36 |
public function handle() { |
| 37 |
$data = [ |
| 38 |
'nonce' => wp_create_nonce('wp_rest'), |
| 39 |
]; |
| 40 |
|
| 41 |
wp_add_inline_script($this->script_handle, 'window.arraytics_feedback = ' . wp_json_encode($data) . ';', 'before'); |
| 42 |
} |
| 43 |
} |