PluginProbe ʕ •ᴥ•ʔ
External Links – nofollow, noopener & new window / trunk
External Links – nofollow, noopener & new window vtrunk
0.31 0.32 0.33 0.34 0.35 1.01 1.02 1.03 1.10 1.20 1.21 1.30 1.31 1.40 1.41 1.50 1.51 1.52 1.53 1.54 1.55 1.56 1.60 1.61 1.62 1.70 1.80 1.81 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.1.0 2.1.1 2.1.2 2.1.3 2.2.0 2.3 2.32 2.35 2.40 2.42 2.43 2.45 2.46 2.47 2.48 2.50 2.51 2.55 2.56 2.57 2.58 2.59 2.60 2.61 2.62 2.63 2.64 2.65 trunk 0.10 0.11 0.12 0.20 0.21 0.30
wp-external-links / includes / admin / settings-fields / class-wpel-exit-confirmation-fields.php
wp-external-links / includes / admin / settings-fields Last commit date
class-wpel-admin-fields.php 2 years ago class-wpel-exceptions-fields.php 1 year ago class-wpel-excluded-link-fields.php 3 years ago class-wpel-exit-confirmation-fields.php 1 year ago class-wpel-external-link-fields.php 3 years ago class-wpel-internal-link-fields.php 3 years ago class-wpel-link-fields-base.php 1 year ago
class-wpel-exit-confirmation-fields.php
256 lines
1 <?php
2
3 /**
4 * Class WPEL_Exit_Confirmation_Fields
5 *
6 * @package WPEL
7 * @category WordPress Plugin
8 * @version 2.3
9 * @link https://www.webfactoryltd.com/
10 * @license Dual licensed under the MIT and GPLv2+ licenses
11 */
12 final class WPEL_Exit_Confirmation_Fields extends WPEL_Link_Fields_Base
13 {
14
15 /**
16 * Initialize
17 */
18 protected function init()
19 {
20 $this->set_settings(array(
21 'section_id' => 'wpel-exit-confirmation-fields',
22 'page_id' => 'wpel-exit-confirmation-fields',
23 'option_name' => 'wpel-exit-confirmation-settings',
24 'option_group' => 'wpel-exit-confirmation-settings',
25 'title' => __('Exit Confirmation', 'wp-external-links'),
26 'fields' => array(
27 'exit_preview' => array(
28 'label' => __('Exit Confirmation Preview', 'wp-external-links'),
29 'default_value' => ''
30
31 ),
32 'background' => array(
33 'label' => __('Popup Background Color:', 'wp-external-links'),
34 'default_value' => '#FFFFFF'
35
36 ),
37 'title' => array(
38 'label' => __('Title:', 'wp-external-links'),
39 'default_value' => __('You are leaving our website', 'wp-external-links'),
40 ),
41 'title_color' => array(
42 'label' => __('Title Text Color:', 'wp-external-links'),
43 'default_value' => '#FFF'
44
45 ),
46 'title_background' => array(
47 'label' => __('Title Background Color:', 'wp-external-links'),
48 'default_value' => '#999'
49
50 ),
51 'title_size' => array(
52 'label' => __('Title Size:', 'wp-external-links'),
53 'default_value' => '18'
54 ),
55 'text' => array(
56 'label' => __('Text:', 'wp-external-links'),
57 'default_value' => 'This link leads outside our website and we are not responsible for its content. If you still want to visit the link, click here:'
58 ),
59 'text_color' => array(
60 'label' => __('Text Color:', 'wp-external-links'),
61 'default_value' => '#444'
62 ),
63 'text_size' => array(
64 'label' => __('Text Size:', 'wp-external-links'),
65 'default_value' => '14'
66 ),
67 'popup_width' => array(
68 'label' => __('Popup Width:', 'wp-external-links'),
69 'default_value' => '400'
70 ),
71 'popup_height' => array(
72 'label' => __('Popup Height:', 'wp-external-links'),
73 'default_value' => '200'
74 ),
75 'overlay' => array(
76 'label' => __('Show overlay:', 'wp-external-links'),
77 'class' => 'js-wpel-apply',
78 'default_value' => '1',
79 ),
80 'overlay_color' => array(
81 'label' => __('Overlay Color:', 'wp-external-links'),
82 'default_value' => '#000'
83 ),
84 'button_text' => array(
85 'label' => __('Button Text:', 'wp-external-links'),
86 'default_value' => 'Stay on the site'
87 ),
88 'button_size' => array(
89 'label' => __('Button Text Size:', 'wp-external-links'),
90 'default_value' => '14'
91 ),
92 'button_color' => array(
93 'label' => __('Button Text Color:', 'wp-external-links'),
94 'default_value' => '#FFF'
95 ),
96 'button_background' => array(
97 'label' => __('Button Background:', 'wp-external-links'),
98 'default_value' => '#1e73be'
99 ),
100 ),
101 ));
102
103 parent::init();
104 }
105
106 /**
107 * Show field methods
108 */
109 protected function show_exit_preview(array $args)
110 {
111 echo '<div id="exit-confirmation-preview"></div>Click <a href="#" class="wpel-exit-confirmation">this link</a> to view a preview of the popup';
112 }
113
114
115 protected function show_title(array $args)
116 {
117 $this->get_html_fields()->text($args['key'], array(
118 'class' => 'regular-text',
119 ));
120
121 echo '<p class="description">'
122 . esc_html__('Title of the Exit Confirmation popup. Leave empty for no title.', 'wp-external-links')
123 . '</p>';
124 }
125
126 protected function show_text(array $args)
127 {
128 $this->get_html_fields()->text_area($args['key'], array(
129 'class' => 'large-text',
130 'rows' => 4,
131 'placeholder' => '',
132 ));
133
134 echo '<p class="description">' . esc_html__('Text of the Exit Confirmation popup. Leave empty for no text.', 'wp-external-links') . '</p>';
135 }
136
137 protected function show_text_color(array $args)
138 {
139 $this->get_html_fields()->color($args['key'], array());
140
141 echo '<p class="description">' . esc_html__('Color of the Exit Confirmation popup text.', 'wp-external-links') . '</p>';
142 }
143
144 protected function show_title_color(array $args)
145 {
146 $this->get_html_fields()->color($args['key'], array());
147
148 echo '<p class="description">' . esc_html__('Color of the Exit Confirmation popup title.', 'wp-external-links') . '</p>';
149 }
150
151 protected function show_title_size(array $args)
152 {
153 $this->get_html_fields()->number($args['key'], array('class' => 'wpel-field-number', 'unit' => 'px'));
154
155 echo '<p class="description">' . esc_html__('Text size of the Exit Confirmation popup title.', 'wp-external-links') . '</p>';
156 }
157
158 protected function show_text_size(array $args)
159 {
160 $this->get_html_fields()->number($args['key'], array('class' => 'wpel-field-number', 'unit' => 'px'));
161
162 echo '<p class="description">' . esc_html__('Text size of the Exit Confirmation popup text.', 'wp-external-links') . '</p>';
163 }
164
165 protected function show_popup_width(array $args)
166 {
167 $this->get_html_fields()->number($args['key'], array('class' => 'wpel-field-number', 'unit' => 'px'));
168
169 echo '<p class="description">' . esc_html__('Width of the Exit Confirmation popup.', 'wp-external-links') . '</p>';
170 }
171
172 protected function show_popup_height(array $args)
173 {
174 $this->get_html_fields()->number($args['key'], array('class' => 'wpel-field-number', 'unit' => 'px'));
175
176 echo '<p class="description">' . esc_html__('Height of the Exit Confirmation popup. Leave empty for auto.', 'wp-external-links') . '</p>';
177 }
178
179 protected function show_overlay(array $args)
180 {
181 $this->get_html_fields()->check_with_label(
182 $args['key'],
183 esc_html__('Show transparent overlay behind popup', 'wp-external-links'),
184 '1',
185 ''
186 );
187 }
188
189 protected function show_background(array $args)
190 {
191 $this->get_html_fields()->color($args['key'], array());
192
193 echo '<p class="description">' . esc_html__('Background color of the Exit Confirmation popup.', 'wp-external-links') . '</p>';
194 }
195
196 protected function show_title_background(array $args)
197 {
198 $this->get_html_fields()->color($args['key'], array());
199
200 echo '<p class="description">' . esc_html__('Background color of the Exit Confirmation popup title.', 'wp-external-links') . '</p>';
201 }
202
203
204 protected function show_overlay_color(array $args)
205 {
206 $this->get_html_fields()->color($args['key'], array());
207 }
208
209 protected function show_button_color(array $args)
210 {
211 $this->get_html_fields()->color($args['key'], array());
212 }
213
214 protected function show_button_background(array $args)
215 {
216 $this->get_html_fields()->color($args['key'], array());
217 }
218
219 protected function show_button_text(array $args)
220 {
221 $this->get_html_fields()->text($args['key'], array(
222 'class' => 'regular-text',
223 ));
224
225 echo '<p class="description">' . esc_html__('Text of the button that will cancel leaving website.', 'wp-external-links') . '</p>';
226 }
227
228 protected function show_button_size(array $args)
229 {
230 $this->get_html_fields()->number($args['key'], array('class' => 'wpel-field-number', 'unit' => 'px'));
231
232 echo '<p class="description">' . esc_html__('Text size of the Exit Confirmation popup button.', 'wp-external-links') . '</p>';
233 }
234
235 /**
236 * Validate and sanitize user input before saving to database
237 * @param array $new_values
238 * @param array $old_values
239 * @return array
240 */
241 protected function before_update(array $new_values, array $old_values)
242 {
243 $update_values = $new_values;
244 $is_valid = true;
245
246
247 if (false === $is_valid) {
248 // error when user input is not valid conform the UI, probably tried to "hack"
249 $this->add_error(esc_html__('Something went wrong. One or more values were invalid.', 'wp-external-links'));
250 return $old_values;
251 }
252
253 return $update_values;
254 }
255 }
256