Changeset 965010 for https-redirection/trunk/https-redirection.php
- Timestamp:
- 08/13/2014 09:16:12 AM (12 years ago)
- File:
-
- 1 edited
-
https-redirection/trunk/https-redirection.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
https-redirection/trunk/https-redirection.php
r957989 r965010 5 5 Description: The plugin HTTPS Redirection allows an automatic redirection to the "HTTPS" version/URL of the site. 6 6 Author: Tips and Tricks HQ 7 Version: 1. 17 Version: 1.2 8 8 Author URI: http://www.tipsandtricks-hq.com/ 9 9 License: GPLv2 or later … … 35 35 if ( ! function_exists ( 'httpsrdrctn_plugin_init' ) ) { 36 36 function httpsrdrctn_plugin_init() { 37 global $httpsrdrctn_options; 37 38 /* Internationalization, first(!) */ 38 39 load_plugin_textdomain( 'https_redirection', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 40 if( empty( $httpsrdrctn_options ) ){ 41 $httpsrdrctn_options = get_option( 'httpsrdrctn_options' ); 42 } 43 if( isset($httpsrdrctn_options['force_resources']) && $httpsrdrctn_options['force_resources'] == '1' ){ 44 //Handle the appropriate content filters to force the static resources to use HTTPS URL 45 add_filter( 'the_content', 'httpsrdrctn_the_content' ); 46 add_filter( 'get_the_content', 'httpsrdrctn_the_content' ); 47 add_filter( 'the_excerpt', 'httpsrdrctn_the_content' ); 48 add_filter( 'get_the_excerpt', 'httpsrdrctn_the_content' ); 49 } 39 50 } 40 51 } … … 79 90 'https_domain' => 0, 80 91 'https_pages_array' => array(), 92 'force_resources' => 0, 81 93 'plugin_option_version' => $httpsrdrctn_plugin_info["Version"] 82 94 ); … … 142 154 $httpsrdrctn_options['https'] = isset( $_REQUEST['httpsrdrctn_https'] ) ? $_REQUEST['httpsrdrctn_https'] : 0 ; 143 155 $httpsrdrctn_options['https_domain'] = isset( $_REQUEST['httpsrdrctn_https_domain'] ) ? $_REQUEST['httpsrdrctn_https_domain'] : 0 ; 156 $httpsrdrctn_options['force_resources'] = isset( $_REQUEST['httpsrdrctn_force_resources'] ) ? $_REQUEST['httpsrdrctn_force_resources'] : 0 ; 144 157 145 158 if( isset( $_REQUEST['httpsrdrctn_https_pages_array'] ) ){ … … 187 200 <td> 188 201 <label><input type="checkbox" name="httpsrdrctn_https" value="1" <?php if ( '1' == $httpsrdrctn_options['https'] ) echo "checked=\"checked\" "; ?>/></label><br /> 202 <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> 203 204 <br /> 205 <p>You can apply a force HTTPS redirection on your entire domain or just a few pages.</p> 189 206 <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 /> 190 207 <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 /> … … 196 213 <span class="rewrite_new_item <?php if( '1' == $httpsrdrctn_options['https_domain'] || '0' == $httpsrdrctn_options['https'] ) echo 'hidden'; ?>" > 197 214 <?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 /> 198 </span> 215 </span> 216 </td> 217 </tr> 218 <tr valign="top"> 219 <th scope="row"><?php _e( 'Force resources to use HTTPS URL', 'https_redirection' ); ?></th> 220 <td> 221 <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 /> 222 <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> 199 223 </td> 200 224 </tr> … … 352 376 } 353 377 378 if ( ! function_exists ( 'httpsrdrctn_the_content' ) ) { 379 function httpsrdrctn_the_content( $content ) { 380 global $httpsrdrctn_options; 381 if( empty( $httpsrdrctn_options ) ){ 382 $httpsrdrctn_options = get_option( 'httpsrdrctn_options' ); 383 } 384 if( $httpsrdrctn_options['force_resources'] == '1' && $httpsrdrctn_options['https'] == 1 ){ 385 if( $httpsrdrctn_options['https_domain'] == 1 ){ 386 if( strpos( home_url(), 'https' ) !== false ){ 387 $http_domain = str_replace( 'https', 'http', home_url() ); 388 $https_domain = home_url(); 389 } 390 else{ 391 $http_domain = home_url(); 392 $https_domain = str_replace( 'http', 'https', home_url() ); 393 } 394 $content = str_replace( $http_domain, $https_domain, $content ); 395 } 396 else if( ! empty( $httpsrdrctn_options['https_pages_array'] ) ) { 397 foreach( $httpsrdrctn_options['https_pages_array'] as $https_page ) { 398 if( strpos( home_url(), 'https' ) !== false ){ 399 $http_domain = str_replace( 'https', 'http', home_url() ); 400 $https_domain = home_url(); 401 } 402 else{ 403 $http_domain = home_url(); 404 $https_domain = str_replace( 'http', 'https', home_url() ); 405 } 406 $content = str_replace( $http_domain . '/' . $https_page, $https_domain . '/' . $https_page, $content ); 407 } 408 } 409 } 410 return $content; 411 } 412 } 413 354 414 if ( ! function_exists ( 'httpsrdrctn_admin_head' ) ) { 355 415 function httpsrdrctn_admin_head() {
Note: See TracChangeset
for help on using the changeset viewer.