https-redirection
Last commit date
css
12 years ago
images
12 years ago
js
12 years ago
languages
12 years ago
https-redirection-settings.php
9 years ago
https-redirection.php
9 years ago
https-rules-helper.php
11 years ago
https-utillity-functions.php
11 years ago
readme.txt
9 years ago
screenshot-1.png
12 years ago
https-redirection-settings.php
121 lines
| 1 | <?php |
| 2 | |
| 3 | /* Function for display htaccess settings page in the admin area */ |
| 4 | |
| 5 | function httpsrdrctn_settings_page() { |
| 6 | global $httpsrdrctn_admin_fields_enable, $httpsrdrctn_options; |
| 7 | //global $wp_rewrite; echo "<pre>"; var_dump($wp_rewrite); |
| 8 | $error = ""; |
| 9 | /* Save data for settings page */ |
| 10 | if (isset($_REQUEST['httpsrdrctn_form_submit']) && check_admin_referer(plugin_basename(__FILE__), 'httpsrdrctn_nonce_name')) { |
| 11 | $httpsrdrctn_options['https'] = isset($_REQUEST['httpsrdrctn_https']) ? $_REQUEST['httpsrdrctn_https'] : 0; |
| 12 | $httpsrdrctn_options['https_domain'] = isset($_REQUEST['httpsrdrctn_https_domain']) ? $_REQUEST['httpsrdrctn_https_domain'] : 0; |
| 13 | $httpsrdrctn_options['force_resources'] = isset($_REQUEST['httpsrdrctn_force_resources']) ? $_REQUEST['httpsrdrctn_force_resources'] : 0; |
| 14 | |
| 15 | if (isset($_REQUEST['httpsrdrctn_https_pages_array'])) { |
| 16 | $httpsrdrctn_options['https_pages_array'] = array(); |
| 17 | //var_dump($httpsrdrctn_options['https_pages_array']); |
| 18 | foreach ($_REQUEST['httpsrdrctn_https_pages_array'] as $httpsrdrctn_https_page) { |
| 19 | if (!empty($httpsrdrctn_https_page) && $httpsrdrctn_https_page != '') { |
| 20 | $httpsrdrctn_https_page = str_replace('https', 'http', $httpsrdrctn_https_page); |
| 21 | $httpsrdrctn_options['https_pages_array'][] = trim(str_replace(home_url(), '', $httpsrdrctn_https_page), '/'); |
| 22 | } |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | if ("" == $error) { |
| 27 | /* Update options in the database */ |
| 28 | update_option('httpsrdrctn_options', $httpsrdrctn_options, '', 'yes'); |
| 29 | $message = __("Settings saved.", 'https_redirection'); |
| 30 | $httpsrdrctn_obj = new HTTPSRDRCTN_RULES(); |
| 31 | $httpsrdrctn_obj->write_to_htaccess(); |
| 32 | //httpsrdrctn_generate_htaccess(); |
| 33 | } |
| 34 | } |
| 35 | /* Display form on the setting page */ |
| 36 | ?> |
| 37 | <div class="wrap"> |
| 38 | <div class="icon32 icon32-bws" id="icon-options-general"></div> |
| 39 | <h2><?php _e('HTTPS Redirection Settings', 'https_redirection'); ?></h2> |
| 40 | |
| 41 | <div style="background: #fff6d5; border: 1px solid #d1b655; color: #3f2502; margin: 10px 0; padding: 5px 5px 5px 10px; text-shadow: 1px 1px #ffffff;"> |
| 42 | <p>When you enable the HTTPS redirection, the plugin will force redirect the URL to the HTTPS version of the URL. |
| 43 | So before enabling this plugin's feature, enter your site's HTTPS URL (example: https://yoursite.com/some-page) in the browser's address bar to make sure the page loads correctly. |
| 44 | 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. |
| 45 | </p> |
| 46 | </div> |
| 47 | |
| 48 | <?php |
| 49 | if ( get_option('permalink_structure') ) { |
| 50 | //Pretty permalink is enabled. So allow HTTPS redirection feature. |
| 51 | ?> |
| 52 | <div id="httpsrdrctn_settings_notice" class="updated fade" style="display:none"><p><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'); ?></p></div> |
| 53 | <div class="updated fade" <?php if (!isset($_REQUEST['httpsrdrctn_form_submit']) || $error != "") echo "style=\"display:none\""; ?>><p><strong><?php echo $message; ?></strong></p></div> |
| 54 | <div class="error" <?php if ("" == $error) echo "style=\"display:none\""; ?>><p><?php echo $error; ?></p></div> |
| 55 | <form id="httpsrdrctn_settings_form" method="post" action=""> |
| 56 | <table class="form-table"> |
| 57 | <tr valign="top"> |
| 58 | <th scope="row"><?php _e('Enable automatic redirection to the "HTTPS"', 'https_redirection'); ?></th> |
| 59 | <td> |
| 60 | <label><input type="checkbox" name="httpsrdrctn_https" value="1" <?php if ('1' == $httpsrdrctn_options['https']) echo "checked=\"checked\" "; ?>/></label><br /> |
| 61 | <p class="description">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.</p> |
| 62 | |
| 63 | <br /> |
| 64 | <p>You can apply a force HTTPS redirection on your entire domain or just a few pages.</p> |
| 65 | <label <?php if ('0' == $httpsrdrctn_options['https']) echo 'class="hidden"'; ?>><input type="radio" name="httpsrdrctn_https_domain" value="1" <?php if ('1' == $httpsrdrctn_options['https_domain']) echo "checked=\"checked\" "; ?>/> The whole domain</label><br /> |
| 66 | <label <?php if ('0' == $httpsrdrctn_options['https']) echo 'class="hidden"'; ?>><input type="radio" name="httpsrdrctn_https_domain" value="0" <?php if ('0' == $httpsrdrctn_options['https_domain']) echo "checked=\"checked\" "; ?>/> A few pages</label><br /> |
| 67 | <?php foreach ($httpsrdrctn_options['https_pages_array'] as $https_page) { ?> |
| 68 | <span class="<?php if ('1' == $httpsrdrctn_options['https_domain'] || '0' == $httpsrdrctn_options['https']) echo 'hidden'; ?>" > |
| 69 | <?php echo str_replace("http://", "https://", home_url()); ?>/<input type="text" name="httpsrdrctn_https_pages_array[]" value="<?php echo $https_page; ?>" /> <span class="rewrite_delete_item"> </span> <span class="rewrite_item_blank_error"><?php _e('Please, fill field', 'list'); ?></span><br /> |
| 70 | </span> |
| 71 | <?php } ?> |
| 72 | <span class="rewrite_new_item <?php if ('1' == $httpsrdrctn_options['https_domain'] || '0' == $httpsrdrctn_options['https']) echo 'hidden'; ?>" > |
| 73 | <?php echo str_replace("http://", "https://", home_url()); ?>/<input type="text" name="httpsrdrctn_https_pages_array[]" value="" /> <span class="rewrite_add_item"> </span> <span class="rewrite_item_blank_error"><?php _e('Please, fill field', 'list'); ?></span><br /> |
| 74 | </span> |
| 75 | </td> |
| 76 | </tr> |
| 77 | <tr valign="top"> |
| 78 | <th scope="row"><?php _e('Force resources to use HTTPS URL', 'https_redirection'); ?></th> |
| 79 | <td> |
| 80 | <label><input type="checkbox" name="httpsrdrctn_force_resources" value="1" <?php if (isset($httpsrdrctn_options['force_resources']) && $httpsrdrctn_options['force_resources'] == '1') echo "checked=\"checked\" "; ?>/></label><br /> |
| 81 | <p class="description">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.</p> |
| 82 | </td> |
| 83 | </tr> |
| 84 | </table> |
| 85 | <input type="hidden" name="httpsrdrctn_form_submit" value="submit" /> |
| 86 | <p class="submit"> |
| 87 | <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /> |
| 88 | </p> |
| 89 | <?php wp_nonce_field(plugin_basename(__FILE__), 'httpsrdrctn_nonce_name'); ?> |
| 90 | </form> |
| 91 | |
| 92 | <div style="background: #FFEBE8; border: 1px solid #CC0000; color: #333333; margin: 10px 0; padding: 5px 5px 5px 10px;"> |
| 93 | <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> |
| 94 | <p>If after making changes your site stops functioning, do the following:</p> |
| 95 | <p>Step #1: Open .htaccess file in the root directory of the WordPress install and delete everything between the following two lines</p> |
| 96 | <p style="border: 1px solid #ccc; padding: 10px;"> |
| 97 | # BEGIN HTTPS Redirection Plugin<br /> |
| 98 | # END HTTPS Redirection Plugin |
| 99 | </p> |
| 100 | <p>Step #2: Save the htaccess file (this will erase any change this plugin made to that file).</p> |
| 101 | <p>Step #3: Deactivate the plugin or rename this plugin's folder (which will deactivate the plugin).</p> |
| 102 | |
| 103 | <p>The changes will be applied immediately after saving the changes, if you are not sure - do not click the "Save changes" button.</p> |
| 104 | </div> |
| 105 | |
| 106 | <?php |
| 107 | } else { |
| 108 | //pretty permalink is NOT enabled. This plugin can't work. |
| 109 | ?> |
| 110 | <div class="error"> |
| 111 | <p><?php _e('HTTPS redirection only works if you have pretty permalinks enabled.', 'https_redirection'); ?></p> |
| 112 | <p><?php _e('To enable pretty permalinks go to <em>Settings > Permalinks</em> and select any option other than "default".', 'https_redirection'); ?></p> |
| 113 | <p><a href="options-permalink.php">Enable Permalinks</a></p> |
| 114 | </div> |
| 115 | <?php |
| 116 | } |
| 117 | ?> |
| 118 | </div> |
| 119 | <?php |
| 120 | } |
| 121 |