Commit a23b8868 authored by lucha's avatar lucha

noblogs-wp-ssl plugin

parent 27f009b2
Plugin Name: Noblogs Wp SSL
Plugin URI:
Description: Rewrite internal URLS to use HTTPS.
Version: 0.1
Author: Cloudflare, sand
License: GPLv2
Heavily copied from:
if ( !function_exists('add_action') ) {
echo "This is a Wordpress plugin and should not be called directly";
function rewrite_links($buffer) {
// replace href or src attributes within script, link, base, and img tags with just "//" for protocol
$re = "#(<(?:script|link|base|img|form|a)(?:[^>]*)(?:href|src|action)=[\"'])http://([^.]+\.noblogs\.org)#i";
$subst = "$1https://$2";
return preg_replace($re, $subst, $buffer);
// This is a filter function that act on the post $content
function noblogs_wp_ssl_content_filter($content) {
// skip rewrite if not on HTTPS
if (empty($_SERVER['HTTPS'])) {
return $content;
$return = rewrite_links($content);
if ($return) {
$content = $return;
return $content;
add_filter('the_content', 'noblogs_wp_ssl_content_filter');
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment