Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
noblogs-wp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
39
Issues
39
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ai
noblogs-wp
Commits
a23b8868
Commit
a23b8868
authored
Nov 05, 2016
by
lucha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
noblogs-wp-ssl plugin
parent
27f009b2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
wp-content/mu-plugins/noblogs-wp-ssl.php
wp-content/mu-plugins/noblogs-wp-ssl.php
+43
-0
No files found.
wp-content/mu-plugins/noblogs-wp-ssl.php
0 → 100644
View file @
a23b8868
<?php
/*
Plugin Name: Noblogs Wp SSL
Plugin URI: https://git.autistici.org/ai/noblogs-wp-ssl
Description: Rewrite internal URLS to use HTTPS.
Version: 0.1
Author: Cloudflare, sand
License: GPLv2
*/
/*
Heavily copied from: https://wordpress.org/plugins/cloudflare/
*/
if
(
!
function_exists
(
'add_action'
)
)
{
echo
"This is a Wordpress plugin and should not be called directly"
;
exit
;
}
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'
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment