1 | <?php |
||
18 | class ExitModal |
||
19 | { |
||
20 | |||
21 | /** |
||
22 | * @var Registry |
||
23 | */ |
||
24 | private $assets_registry; |
||
25 | |||
26 | /** |
||
27 | * ExitModal constructor. |
||
28 | * |
||
29 | * @param Registry $assets_registry |
||
30 | */ |
||
31 | public function __construct(Registry $assets_registry) |
||
37 | |||
38 | |||
39 | /** |
||
40 | * Callback on in_admin_footer that is used to output the exit modal container. |
||
41 | */ |
||
42 | public function modalContainer() |
||
46 | |||
47 | |||
48 | /** |
||
49 | * Callback for `admin_enqueue_scripts` to take care of enqueueing scripts and styles specific to the modal. |
||
50 | * |
||
51 | * @throws InvalidArgumentException |
||
52 | */ |
||
53 | public function enqueues() |
||
54 | { |
||
55 | $current_user = new WP_User(get_current_user_id()); |
||
56 | $this->assets_registry->addData( |
||
57 | 'exitModalInfo', |
||
58 | array( |
||
59 | 'firstname' => htmlspecialchars($current_user->user_firstname), |
||
60 | 'emailaddress' => htmlspecialchars($current_user->user_email), |
||
61 | 'website' => htmlspecialchars(site_url()), |
||
62 | 'isModalActive' => $this->isModalActive() |
||
63 | ) |
||
64 | ); |
||
65 | |||
66 | wp_enqueue_script('ee-wp-plugins-page'); |
||
67 | wp_enqueue_style('ee-wp-plugins-page'); |
||
68 | } |
||
69 | |||
70 | |||
71 | /** |
||
72 | * Exposes a filter switch for turning off the enqueueing of the modal script. |
||
73 | * @return bool |
||
74 | */ |
||
75 | private function isModalActive() |
||
85 | } |