https-redirection
Last commit date
css
12 years ago
images
12 years ago
js
6 years ago
languages
12 years ago
https-redirection-settings.php
6 years ago
https-redirection.php
3 years ago
https-rules-helper.php
3 years ago
https-utillity-functions.php
6 years ago
readme.txt
1 year ago
screenshot-1.png
12 years ago
https-utillity-functions.php
39 lines
| 1 | <?php |
| 2 | |
| 3 | function httpsrdrctn_force_https_embeds( $content ) { |
| 4 | $files_to_check = array( 'jpg', 'jpeg', 'gif', 'png', 'js', 'css' ); |
| 5 | |
| 6 | if ( strpos( home_url(), 'https' ) !== false ) { |
| 7 | $http_domain = str_replace( 'https', 'http', home_url() ); |
| 8 | } else { |
| 9 | $http_domain = home_url(); |
| 10 | } |
| 11 | |
| 12 | $matches = array(); |
| 13 | $pattern = '/' . str_replace( '/', '\/', quotemeta( $http_domain ) ) . '\/[^\"\']*\.[' . implode( "|", $files_to_check ) . ']+/'; |
| 14 | |
| 15 | preg_match_all( $pattern, $content, $matches ); |
| 16 | |
| 17 | if ( ! empty( $matches ) ) { |
| 18 | foreach ( $matches[ 0 ] as $match ) { |
| 19 | $match_https = str_replace( 'http', 'https', $match ); |
| 20 | $content = str_replace( $match, $match_https, $content ); |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | return $content; |
| 25 | } |
| 26 | |
| 27 | /*** |
| 28 | * Test Code |
| 29 | */ |
| 30 | /* |
| 31 | echo httpsrdrctn_force_https_embeds( '<img src="http://test.com/image.jpg" /> |
| 32 | <a href="http://test.com/image.jpeg"></a> |
| 33 | "http://test.com/image.gif" |
| 34 | <img src="http://test.com/image.png" /> |
| 35 | <link rel="javascript" type="text/javascript" href="http://test.com/somescript.js" /> |
| 36 | <link rel="stylesheet" type="text/css" href="http://test.com/somestyles.css" /> |
| 37 | http://test.com/somescript.bmp' ); |
| 38 | */ |
| 39 |