PluginProbe ʕ •ᴥ•ʔ
Easy HTTPS Redirection (SSL) / 2.0.1
Easy HTTPS Redirection (SSL) v2.0.1
trunk 1.5 1.6 1.8 1.9.1 1.9.2 2.0.0 2.0.1
https-redirection / admin / ehssl-settings-menu.php
https-redirection / admin Last commit date
ehssl-admin-init.php 1 year ago ehssl-admin-menu.php 1 day ago ehssl-certificate-expiry-menu.php 1 day ago ehssl-dashboard-menu.php 1 day ago ehssl-settings-menu-old.php 1 year ago ehssl-settings-menu.php 1 day ago ehssl-ssl-management-menu.php 1 year ago index.php 1 year ago
ehssl-settings-menu.php
592 lines
1 <?php
2
3 class EHSSL_Settings_Menu extends EHSSL_Admin_Menu
4 {
5 public $menu_page_slug = EHSSL_SETTINGS_MENU_SLUG;
6
7 // Specify all the tabs of this menu in the following array.
8 public $dashboard_menu_tabs = array('general' => 'General', 'mixed-contents' => 'Mixed Contents');
9
10 public function get_current_tab()
11 {
12 $tab = isset($_GET['tab']) ? $_GET['tab'] : array_keys($this->dashboard_menu_tabs)[0];
13 return $tab;
14 }
15
16 /**
17 * Renders our tabs of this menu as nav items
18 */
19 public function render_page_tabs()
20 {
21 $current_tab = $this->get_current_tab();
22 foreach ($this->dashboard_menu_tabs as $tab_key => $tab_caption) {
23 $active = $current_tab == $tab_key ? 'nav-tab-active' : '';
24 echo '<a class="nav-tab ' . $active . '" href="?page=' . $this->menu_page_slug . '&tab=' . $tab_key . '">' . $tab_caption . '</a>';
25 }
26 }
27
28 /**
29 * The menu rendering goes here
30 */
31 public function render_menu_page()
32 {
33 $tab = $this->get_current_tab();
34
35 ?>
36 <div class="wrap">
37 <h2><?php _e("Settings", 'https-redirection')?></h2>
38 <h2 class="nav-tab-wrapper"><?php $this->render_page_tabs();?></h2>
39 <div id="poststuff"><div id="post-body">
40 <?php
41
42 switch ($tab) {
43 case 'mixed-contents':
44 //include_once('file-to-handle-this-tab-rendering.php');//If you want to include a file
45 $this->render_mixed_content_tab();
46 break;
47 case 'general':
48 default:
49 //include_once('file-to-handle-this-tab-rendering.php');//If you want to include a file
50 $this->render_general_tab();
51 break;
52 }
53 ?>
54 </div>
55 </div>
56 <?php $this->documentation_link_box();?>
57 </div><!-- end or wrap -->
58 <?php
59 }
60
61 public function render_general_tab()
62 {
63 $settings = get_option('httpsrdrctn_options', array());
64
65 // Save data for settings page.
66 if (isset($_REQUEST['httpsrdrctn_form_submit']) && check_admin_referer(plugin_basename(__FILE__), 'httpsrdrctn_nonce_name')) {
67 $settings['https'] = isset($_REQUEST['httpsrdrctn_https']) ? $_REQUEST['httpsrdrctn_https'] : 0;
68 $settings['https_domain'] = isset($_REQUEST['httpsrdrctn_https_domain']) ? $_REQUEST['httpsrdrctn_https_domain'] : 0;
69
70 $settings['hsts_enabled'] = isset($_REQUEST['hsts_enabled']) ? 1 : 0;
71 $settings['hsts_max_age'] = isset($_REQUEST['hsts_max_age']) && !empty($_REQUEST['hsts_max_age']) ? absint(sanitize_text_field($_REQUEST['hsts_max_age'])) : 31536000;
72 $settings['hsts_include_sub_domains'] = isset($_REQUEST['hsts_include_sub_domains']) ? 1 : 0;
73 $settings['hsts_preload'] = isset($_REQUEST['hsts_preload']) ? 1 : 0;
74
75 if (isset($_REQUEST['httpsrdrctn_https_pages_array'])) {
76 $settings['https_pages_array'] = array();
77 // var_dump($httpsrdrctn_options['https_pages_array']);
78 foreach ($_REQUEST['httpsrdrctn_https_pages_array'] as $httpsrdrctn_https_page) {
79 if (!empty($httpsrdrctn_https_page) && $httpsrdrctn_https_page != '') {
80 $httpsrdrctn_https_page = str_replace('https', 'http', $httpsrdrctn_https_page);
81 $settings['https_pages_array'][] = trim(str_replace(home_url(), '', $httpsrdrctn_https_page), '/');
82 }
83 }
84 }
85
86 // Update options in the database.
87 update_option('httpsrdrctn_options', $settings, '', 'yes');
88
89 echo '<div class="notice notice-success"><p>'.__("Settings Saved.", 'https-redirection').'</p></div>';
90
91 $httpsrdrctn_obj = new EHSSL_Htaccess();
92 $httpsrdrctn_obj->write_to_htaccess();
93
94 // clear caching plugins cache if needed
95 // WP Fastest Cache
96 if (isset($GLOBALS["wp_fastest_cache"])) {
97 $wpfc = $GLOBALS["wp_fastest_cache"];
98 if (method_exists($wpfc, 'deleteCache') && is_callable(array($wpfc, 'deleteCache'))) {
99 $wpfc->deleteCache(true);
100 }
101 }
102 // httpsrdrctn_generate_htaccess();
103
104 }
105 $siteSSLurl = get_home_url(null, '', 'https');
106
107 $hsta_enabled = isset($settings['hsts_enabled']) && !empty($settings['hsts_enabled']) ? 1 : 0;
108 $hsta_max_age = isset($settings['hsts_max_age']) && !empty($settings['hsts_max_age']) ? absint(sanitize_text_field($settings['hsts_max_age'])) : 31536000;
109 $hsta_include_sub_domains = isset($settings['hsts_include_sub_domains']) && !empty($settings['hsts_include_sub_domains']) ? 1 : 0;
110 $hsta_preload = isset($settings['hsts_preload']) && !empty($settings['hsts_preload']) ? 1 : 0;
111
112 // Save data for settings page.
113 if (isset($_POST['ehssl_debug_log_form_submit']) && check_admin_referer('ehssl_debug_settings_nonce')) {
114 $settings['enable_debug_logging'] = isset($_POST['enable_debug_logging']) ? esc_attr($_POST['enable_debug_logging']) : 0;
115
116 update_option('httpsrdrctn_options', $settings)
117
118 ?>
119 <div class="notice notice-success">
120 <p><?php _e("Settings Saved.", 'https-redirection');?></p>
121 </div>
122 <?php
123 }
124
125 $is_debug_logging_enabled = isset($settings['enable_debug_logging']) ? esc_attr($settings['enable_debug_logging']) : 0;
126
127 if ( empty($this->is_ssl_installed) ) { ?>
128 <div class="ehssl-yellow-box">
129 <p>
130 <?php echo sprintf(__("When you enable the HTTPS redirection, the plugin will force redirect the URL to the HTTPS version of the URL. So before enabling this plugin's feature, visit your site's HTTPS URL %s to make sure the page loads correctly. Otherwise you may get locked out if your SSL certificate is not installed correctly on your site or the HTTPS URL is not working and this plugin is auto redirecting to the HTTPS URL.", 'https-redirection'), '<a href="' . $siteSSLurl . '" target="_blank">' . $siteSSLurl . '</a>'); ?>
131 </p>
132 <p>
133 <span style="font-weight:bold; color:red;"><?php _e('Important!', 'https-redirection');?></span>
134 <?php _e("If you're using caching plugins similar to W3 Total Cache or WP Super Cache, you need to clear their cache after you enable or disable automatic redirection option. Failing to do so may result in mixed content warning from browser.", 'https-redirection');?>
135 </p>
136 </div>
137 <?php } ?>
138
139 <div class="postbox">
140 <h3 class="hndle"><label for="title"><?php _e("HTTPS Redirection", 'https-redirection');?></label></h3>
141 <div class="inside">
142 <?php
143 // Display form on the setting page.
144 if (get_option('permalink_structure')) {
145 // Pretty permalink is enabled. So allow HTTPS redirection feature.
146 ?>
147 <div id="httpsrdrctn_settings_notice" class="updated fade" style="display:none">
148 <p>
149 <strong><?php _e("Notice:", 'https-redirection');?></strong><?php _e("The plugin's settings have been changed. In order to save them please don't forget to click the 'Save Changes' button.", 'https-redirection');?>
150 </p>
151 </div>
152
153 <form id="httpsrdrctn_settings_form" method="post" action="">
154 <div style="position: relative">
155 <table class="form-table">
156 <tr valign="top">
157 <th scope="row"><?php _e('Enable Automatic Redirection to HTTPS', 'https-redirection');?></th>
158 <td>
159 <label>
160 <input type="checkbox" id="httpsrdrctn-checkbox" name="httpsrdrctn_https" value="1" <?php if ('1' == $settings['https']) {echo "checked=\"checked\" ";}?> />
161 </label>
162 <br />
163 <p class="description"><?php _e("Use this option to make your webpage(s) load in HTTPS version only. If someone enters a non-https URL in the browser's address bar then the plugin will automatically redirect to the HTTPS version of that URL.", 'https-redirection');?></p>
164 </td>
165 </tr>
166 </table>
167
168 <div class="ehssl-enable-automatic-redirection httpsrdrctn-overlay <?php echo ($this->is_ssl_installed ? 'hidden' : ''); ?>"></div>
169 </div>
170
171 <div style="position: relative">
172 <table class="form-table">
173 <tr>
174 <th scope="row"><?php _e('Apply HTTPS Redirection To:', 'https-redirection');?></th>
175 <td>
176 <div style="margin-bottom: 6px">
177 <label><input type="radio" name="httpsrdrctn_https_domain" value="1" <?php if ('1' == $settings['https_domain']) {echo "checked=\"checked\" ";}?> /> <?php _e('The whole domain', 'https-redirection');?></label>
178 </div>
179 <div style="margin-bottom: 6px">
180 <label><input type="radio" name="httpsrdrctn_https_domain" value="0" <?php if ('0' == $settings['https_domain']) {echo "checked=\"checked\" ";}?> /> <?php _e('A few pages', 'https-redirection');?></label>
181 </div>
182 <?php foreach ($settings['https_pages_array'] as $https_page) { ?>
183 <div style="margin-bottom: 5px">
184 <?php echo str_replace("http://", "https://", home_url()); ?>/<input type="text" name="httpsrdrctn_https_pages_array[]" value="<?php echo $https_page; ?>" /> <span class="button-secondary rewrite_item_delete_btn"><i class="dashicons dashicons-trash"></i></span> <span class="rewrite_item_blank_error"><?php _e('Please enter a page slug value in the field before adding it.', 'https-redirection');?></span>
185 </div>
186 <?php } ?>
187 <div class="rewrite_new_item">
188 <?php echo str_replace("http://", "https://", home_url()); ?>/<input type="text" name="httpsrdrctn_https_pages_array[]" placeholder="<?php _e('Enter the page slug','https-redirection'); ?>" value="" /> <span class="button-secondary rewrite_item_add_btn"><i class="dashicons dashicons-plus-alt2"></i></span> <span class="rewrite_item_blank_error"><?php _e('Please enter a page slug value in the field before adding it.', 'https-redirection');?></span>
189 </div>
190 </td>
191 </tr>
192 </table>
193
194 <div class="ehssl-apply-redirection-on httpsrdrctn-overlay <?php echo ($settings['https'] == 1 ? 'hidden' : ''); ?>"></div>
195 </div>
196
197 <hr>
198
199 <h3 style="font-size: 16px"><?php _e('HTTP Strict Transport Security (HSTS) (Optional)', 'https-redirection'); ?></h3>
200 <p class="description"><?php _e("Only enable the HSTS option if your entire website is fully accessible over HTTPS.", 'https-redirection');?></p>
201 <div style="position: relative">
202 <table class="form-table">
203 <tr>
204 <th scope="row"><?php _e('Enable HTTP Strict Transport Security (HSTS):', 'https-redirection');?></th>
205 <td>
206 <input type="checkbox" id="https-hsts-checkbox" name="hsts_enabled" <?php echo $hsta_enabled ? "checked" : ''; ?> min="0" />
207 <p class="description"><?php _e("Once a visitor accesses your site over HTTPS, their browser will automatically use HTTPS for future visits for the configured period.", 'https-redirection');?></p>
208
209 <div class="description" style="position: relative;">
210 <p class="description">
211 <?php _e('Max age (in seconds):', 'https-redirection');?>
212 <input type="number" id="ehssl-hsts-max-age" name="hsts_max_age" value="<?php echo esc_attr($hsta_max_age); ?>" style="width: 140px"/>
213 <?php _e(' Specifies how long browsers should remember to use HTTPS only. The recommended value is 31536000 seconds (1 year).', 'https-redirection');?>
214 </p>
215 <p class="description">
216 <input type="checkbox" id="ehssl-hsts-include-sub-domain" name="hsts_include_sub_domains" <?php echo $hsta_include_sub_domains ? "checked" : ''; ?> />
217 <?php printf(__("Apply the HSTS policy to all subdomains of this site.", 'https-redirection'), $siteSSLurl);?>
218 </p>
219 <p class="description">
220 <input type="checkbox" id="https-hsts-preload" name="hsts_preload" <?php echo $hsta_preload ? "checked" : ''; ?> />
221 <?php
222 printf(
223 __("Include the preload directive. This alone does not add your site to browser preload lists, you must also manually submit your domain using the %s.", 'https-redirection'),
224 '<a href="https://hstspreload.org/#submission-form" target="_blank">link here</a>'
225 );
226 ?>
227 </p>
228
229 <div class="ehssl-apply-hsts-directives httpsrdrctn-overlay <?php echo ($hsta_enabled ? 'hidden' : ''); ?>"></div>
230 </div>
231 </td>
232 </tr>
233 </table>
234
235 <div class="ehssl-apply-hsts httpsrdrctn-overlay <?php echo ($settings['https'] == 1 && $settings['https_domain'] == 1 ? 'hidden' : ''); ?>"></div>
236 </div>
237
238 <input type="hidden" name="httpsrdrctn_form_submit" value="submit" />
239
240 <p class="submit">
241 <input type="submit" class="button-primary" value="<?php _e('Save Changes')?>" <?php echo !is_ssl() ? 'disabled' : '' ?>/>
242 </p>
243 <?php wp_nonce_field(plugin_basename(__FILE__), 'httpsrdrctn_nonce_name');?>
244 </form>
245 <script>
246 jQuery('input#httpsrdrctn-checkbox').change(function() {
247 if (jQuery(this).is(':checked')) {
248 jQuery('div.ehssl-apply-redirection-on.httpsrdrctn-overlay').fadeOut('fast');
249 } else {
250 jQuery('div.ehssl-apply-redirection-on.httpsrdrctn-overlay').fadeIn('fast');
251 }
252 });
253
254 jQuery('input#httpsrdrctn-checkbox').on('change', function() {
255 if (jQuery(this).is(':checked') && jQuery('input[name="httpsrdrctn_https_domain"]:checked').val() == 1) {
256 jQuery('div.ehssl-apply-hsts.httpsrdrctn-overlay').fadeOut('fast');
257 } else {
258 jQuery('div.ehssl-apply-hsts.httpsrdrctn-overlay').fadeIn('fast');
259 }
260 });
261
262 jQuery('input[name="httpsrdrctn_https_domain"]').on('change', function() {
263 if (jQuery(this).val() == 1 && jQuery('input#httpsrdrctn-checkbox').is(':checked')) {
264 jQuery('div.ehssl-apply-hsts.httpsrdrctn-overlay').fadeOut('fast');
265 } else {
266 jQuery('div.ehssl-apply-hsts.httpsrdrctn-overlay').fadeIn('fast');
267 }
268 });
269
270 jQuery('input#https-hsts-checkbox').change(function() {
271 if (jQuery(this).is(':checked')) {
272 jQuery('div.ehssl-apply-hsts-directives.httpsrdrctn-overlay').fadeOut('fast');
273 } else {
274 jQuery('div.ehssl-apply-hsts-directives.httpsrdrctn-overlay').fadeIn('fast');
275 }
276 });
277 </script>
278 <style>
279 .httpsrdrctn-overlay {
280 position: absolute;
281 top: 10px;
282 background-color: white;
283 width: 100%;
284 height: 100%;
285 opacity: 0.5;
286 text-align: center;
287 }
288 </style>
289
290 <div class="ehssl-red-box">
291 <p><strong><?php _e("Notice:", 'https-redirection');?></strong> <?php _e("It is very important to be extremely attentive when making changes to .htaccess file.", 'https-redirection');?></p>
292 <p><?php _e('If after making changes your site stops functioning, do the following:', 'https-redirection');?></p>
293 <p><?php _e('Step #1: Open .htaccess file in the root directory of the WordPress install and delete everything between the following two lines', 'https-redirection');?></p>
294 <p style="border: 1px solid #ccc; padding: 10px;">
295 # BEGIN HTTPS Redirection Plugin<br />
296 # END HTTPS Redirection Plugin
297 </p>
298 <p><?php _e('Step #2: Save the htaccess file (this will erase any change this plugin made to that file).', 'https-redirection');?></p>
299 <p><?php _e("Step #3: Deactivate the plugin or rename this plugin's folder (which will deactivate the plugin).", 'https-redirection');?></p>
300
301 <p><?php _e('The changes will be applied immediately after saving the changes, if you are not sure - do not click the "Save changes" button.', 'https-redirection');?></p>
302 </div>
303
304 <?php } else {?>
305 <!-- pretty permalink is NOT enabled. This plugin can't work. -->
306 <div class="error">
307 <p><?php _e('HTTPS redirection only works if you have pretty permalinks enabled.', 'https-redirection');?></p>
308 <p><?php _e('To enable pretty permalinks go to <em>Settings > Permalinks</em> and select any option other than "default".', 'https-redirection');?></p>
309 <p><a href="options-permalink.php"><?php _e('Enable Permalinks', 'https-redirection');?></a></p>
310 </div>
311 <?php }?>
312 </div>
313 </div>
314 <div class="postbox">
315 <h3 class="hndle"><label for="title"><?php _e("Debug Logging", 'https-redirection');?></label></h3>
316 <div class="inside">
317 <p>
318 <?php _e('Debug logging can be useful to troubleshoot issues on your site. keep it disabled unless you are troubleshooting.', 'https-redirection');?>
319 </p>
320 <form id="ehssl_debug_settings_form" method="post" action="">
321 <table class="form-table">
322 <tr valign="top">
323 <th scope="row">
324 <label for="ehssl-debug-enable-checkbox">
325 <?php _e('Enable Debug Logging', 'https-redirection');?>
326 </label>
327 </th>
328 <td>
329 <input type="checkbox" id="ehssl-debug-enable-checkbox" name="enable_debug_logging" value="1" <?php if ('1' == $is_debug_logging_enabled) {echo "checked=\"checked\" ";}?> />
330 <br />
331 <p class="description"><?php _e("Check this option to enable debug logging.", 'https-redirection');?></p>
332 <p class="description">
333 <a href="<?php echo wp_nonce_url(get_admin_url() . '?ehssl-debug-action=view_log', 'ehssl_view_log_nonce'); ?>" target="_blank">
334 <?php _e('Click here', 'https-redirection')?>
335 </a>
336 <?php _e(' to view log file.', 'https-redirection');?>
337 <br>
338 <a id="ehssl-reset-log" href="#0" style="color: red">
339 <?php _e('Click here', 'https-redirection');?>
340 </a>
341 <?php _e(' to reset log file.', 'https-redirection');?>
342 </p>
343 </td>
344 </tr>
345 </table>
346
347 <input type="submit" name="ehssl_debug_log_form_submit" class="button-primary" value="<?php _e('Save Changes')?>" />
348 <?php wp_nonce_field('ehssl_debug_settings_nonce');?>
349 </form>
350 </div><!-- end of inside -->
351 </div><!-- end of postbox -->
352 <script>
353 jQuery( document ).ready( function( $ ) {
354 const ehssl_ajaxurl = "<?php echo get_admin_url() . 'admin-ajax.php' ?>";
355 const ehssl_ajax_nonce = "<?php echo wp_create_nonce('ehssl_settings_ajax_nonce') ?>";
356 $( '#ehssl-reset-log' ).on('click', function( e ) {
357 e.preventDefault();
358 $.post( ehssl_ajaxurl,
359 {
360 action: 'ehssl_reset_log',
361 nonce: ehssl_ajax_nonce
362 },
363 function( result ) {
364 if ( result === '1' ) {
365 alert( '<?php _e('Log file has been reset.', 'https-redirection') ?>' );
366 } else {
367 alert( '<?php _e('Error trying to reset log: ' , 'https-redirection') ?>' + result );
368 }
369 } );
370 } );
371 } );
372 </script>
373 <?php
374 }
375
376 public function render_mixed_content_tab()
377 {
378 global $httpsrdrctn_options;
379
380 $is_https_redirection_enabled = isset($httpsrdrctn_options['https']) && esc_attr($httpsrdrctn_options['https']) == '1' ? true : false;
381
382 if (isset($_POST['ehssl_mixed_content_form_submit']) && check_admin_referer('ehssl_mixed_content_settings_nonce')) {
383 $httpsrdrctn_options['force_resources'] = isset($_POST['httpsrdrctn_force_resources']) ? esc_attr($_POST['httpsrdrctn_force_resources']) : 0;
384 update_option('httpsrdrctn_options', $httpsrdrctn_options)
385
386 ?>
387 <div class="notice notice-success">
388 <p><?php _e("Settings Saved.", 'https-redirection');?></p>
389 </div>
390 <?php
391 }
392 ?>
393 <div class="postbox">
394 <h3 class="hndle"><label for="title"><?php _e("Static Resources", 'https-redirection');?></label></h3>
395 <div class="inside">
396 <?php if(!$is_https_redirection_enabled){ ?>
397 <div class="ehssl-yellow-box">
398 <p>
399 <?php _e("HTTPS redirection is turned off. Turn it on first to change these settings below!", 'https-redirection');?>
400 </p>
401 </div>
402 <?php } ?>
403 <form action="" method="POST">
404 <table class="form-table">
405 <tr valign="top">
406 <th scope="row"><?php _e('Force Resources to Use HTTPS URL', 'https-redirection');?></th>
407 <td>
408 <label>
409 <input type="checkbox" <?php echo !$is_https_redirection_enabled ? "disabled" : ''; ?> name="httpsrdrctn_force_resources" value="1" <?php echo (isset($httpsrdrctn_options['force_resources']) && $httpsrdrctn_options['force_resources'] == '1') ? 'checked="checked"' : ''; ?> />
410 </label>
411 <br />
412 <p class="description"><?php _e('When checked, the plugin will force load HTTPS URL for any static resources in your content. Example: if you have have an image embedded in a post with a NON-HTTPS URL, this option will change that to a HTTPS URL.', 'https-redirection');?></p>
413 </td>
414 </tr>
415 </table>
416 <input type="submit" name="ehssl_mixed_content_form_submit" class="button-primary" value="<?php _e('Save Changes')?>" <?php if (!$is_https_redirection_enabled) {echo "disabled";}?>/>
417 <?php wp_nonce_field('ehssl_mixed_content_settings_nonce');?>
418 </form>
419 </div><!-- end of inside -->
420 </div><!-- end of postbox -->
421 <?php
422 $post_types = get_post_types(
423 array(
424 'show_ui' => true,
425 ),
426 'objects'
427 );
428
429 $exclude = array(
430 'attachment',
431 'revision',
432 'nav_menu_item',
433 'custom_css',
434 'customize_changeset',
435 'oembed_cache',
436 'user_request',
437 'wp_block',
438 'wp_template',
439 'wp_template_part',
440 'wp_navigation',
441 'wp_font_family',
442 'wp_font_face',
443 );
444
445 $scannable_post_types = array();
446 foreach ( $post_types as $post_type ) {
447 if ( in_array( $post_type->name, $exclude ) ) {
448 continue;
449 }
450 $scannable_post_types[] = array(
451 'type' => 'post_type',
452 'name' => $post_type->name,
453 'label' => $post_type->label,
454 );
455 }
456
457 $other_tables = array(
458 array(
459 'name' => 'wp_options_table',
460 'label' => 'WP Options',
461 ),
462 );
463
464 $flags = array(
465 array(
466 'name' => 'include_post_meta',
467 'label' => 'Include Post Meta for Selected Post Types',
468 ),
469 );
470
471 $has_previous_scan_data = EHSSL_Non_HTTPS_Resources_Scan_Update::get_scan_results_count(true) > 0;
472 $rescan_btn_text = __('Re-scan', 'https-redirection');
473 $scan_btn_text = $has_previous_scan_data ? $rescan_btn_text :__('Scan', 'https-redirection');
474 ?>
475
476 <div class="postbox">
477 <h3 class="hndle"><label for="title"><?php _e("Scan and Update Non-HTTPS URLs", 'https-redirection');?></label></h3>
478 <div class="inside">
479 <p class="description"><?php _e('Use this tool to scan for non-https URLs and update them to HTTPS version. Please take a backup of your database before updating the URLs.', 'https-redirection');?></p>
480 <br>
481 <form action="" method="POST" id="ehssl_non_https_resources_scan_form">
482 <fieldset>
483 <legend><strong><?php _e('Post Types:', 'https-redirection')?></strong></legend>
484 <ul>
485 <?php foreach ($scannable_post_types as $index => $item) { ?>
486 <li>
487 <input
488 id="<?php echo esc_attr('ehssl-'.$item['name'].'-'.$index) ?>"
489 type="checkbox"
490 name="ehssl_post_types[]"
491 value="<?php echo esc_attr($item['name']); ?>"
492 />
493 <label for="<?php echo esc_attr('ehssl-'.$item['name'].'-'.$index) ?>"><?php echo esc_attr($item['label']) . ' ('.esc_attr($item['name']).')' ?></label>
494 </li>
495 <?php } ?>
496 </ul>
497 </fieldset>
498
499 <fieldset>
500 <legend><strong><?php _e('Other Database Tables:', 'https-redirection')?></strong></legend>
501 <ul>
502 <?php foreach ($other_tables as $index => $item) { ?>
503 <li>
504 <input
505 id="<?php echo esc_attr('ehssl-'.$item['name'].'-'.$index) ?>"
506 type="checkbox"
507 name="ehssl_other_tables[]"
508 value="<?php echo esc_attr($item['name']); ?>"
509 />
510 <label for="<?php echo esc_attr('ehssl-'.$item['name'].'-'.$index) ?>"><?php echo esc_attr($item['label']) ?></label>
511 </li>
512 <?php } ?>
513 </ul>
514 </fieldset>
515
516 <fieldset>
517 <legend><strong><?php _e('Additional Flags:', 'https-redirection')?></strong></legend>
518 <ul>
519 <?php foreach ($flags as $index => $item) { ?>
520 <li>
521 <input
522 id="<?php echo esc_attr('ehssl-'.$item['name'].'-'.$index) ?>"
523 type="checkbox"
524 name="ehssl_additional_flags[]"
525 value="<?php echo esc_attr($item['name']); ?>"
526 />
527 <label for="<?php echo esc_attr('ehssl-'.$item['name'].'-'.$index) ?>"><?php echo esc_attr($item['label']) ?></label>
528 </li>
529 <?php } ?>
530 </ul>
531 </fieldset>
532
533 <fieldset>
534 <legend><strong><?php _e('Scan Type:', 'https-redirection')?></strong></legend>
535 <ul>
536 <li>
537 <label>
538 <input type="radio" name="ehssl_scan_type" value="scan_static_resources_only" checked>
539 <?php _e('Scan Static Resources Only', 'https-redirection')?>
540 </label>
541 </li>
542 <li>
543 <label>
544 <input type="radio" name="ehssl_scan_type" value="scan_all">
545 <?php _e('Scan All', 'https-redirection')?>
546 </label>
547 </li>
548 </ul>
549
550 </fieldset>
551
552 <?php wp_nonce_field('ehssl_non_https_resources_scan_form_nonce');?>
553
554 <p class="description">
555 <button
556 type="submit"
557 id="ehssl_non_https_resources_scan_btn"
558 class="button-primary"
559 ><?php echo esc_attr($scan_btn_text) ?></button>
560 </p>
561
562 </form>
563 <div id="ehssl_scan_results" style="margin-top:20px;">
564 <!-- table renders here -->
565 <?php
566 if ($has_previous_scan_data){
567 EHSSL_Non_HTTPS_Resources_Scan_Update::render_http_scan_result_table();
568 }
569 ?>
570
571 </div>
572 </div><!-- end of inside -->
573 </div><!-- end of postbox -->
574 <?php
575 wp_enqueue_script('ehssl_non_https_resources_scan_update', EASY_HTTPS_SSL_URL . '/js/ehssl-static-resources-scan-update.js', null, EASY_HTTPS_SSL_VERSION, array(
576 'in_footer' => true,
577 'strategy' => 'defer'
578 ));
579
580 wp_localize_script('ehssl_non_https_resources_scan_update', 'ehssl_non_https_resources_scan_update_js_data', array(
581 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
582 'texts' => array(
583 'nothing_found' => __('Nothing Found!', 'https-redirection'),
584 'pls_select_an_item' => __('Please select an item to scan!', 'https-redirection'),
585 'confirm_update' => __('Are you sure? This will permanently update urls in databases.', 'https-redirection'),
586 'scan_btn_loading' => __('Scanning...', 'https-redirection'),
587 'rescan_btn' => $rescan_btn_text,
588 'update_btn_loading' => __('Updating...', 'https-redirection'),
589 ),
590 ));
591 }
592 } // End class