Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
noblogs-wp-ssl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Noblogs
noblogs-wp-ssl
Commits
b3073907
Commit
b3073907
authored
9 years ago
by
sand
Browse files
Options
Downloads
Patches
Plain Diff
Initial import
parents
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+4
-0
4 additions, 0 deletions
README.md
noblogs-wp-ssl.php
+49
-0
49 additions, 0 deletions
noblogs-wp-ssl.php
with
53 additions
and
0 deletions
README.md
0 → 100644
+
4
−
0
View file @
b3073907
# noblogs-wp-ssl
A Wordpress plugin that rewrite the protocol of all internal links to use https.
It's shamlessy copied from https://wordpress.org/plugins/cloudflare/
This diff is collapsed.
Click to expand it.
noblogs-wp-ssl.php
0 → 100644
+
49
−
0
View file @
b3073907
<?php
/*
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
wp_ssl_buffer_wrapup
(
$buffer
)
{
// skip rewrite if not on HTTPS
if
(
empty
(
$_SERVER
[
'HTTPS'
]))
{
return
$buffer
;
}
// Check for a Content-Type header. Currently only apply rewriting to "text/html" or undefined
$headers
=
headers_list
();
$content_type
=
null
;
foreach
(
$headers
as
$header
)
{
if
(
strpos
(
strtolower
(
$header
),
'content-type:'
)
===
0
)
{
$pieces
=
explode
(
':'
,
strtolower
(
$header
));
$content_type
=
trim
(
$pieces
[
1
]);
break
;
}
}
if
(
is_null
(
$content_type
)
||
substr
(
$content_type
,
0
,
9
)
===
'text/html'
)
{
// replace href or src attributes within script, link, base, and img tags with just "//" for protocol
$re
=
"/(<(?:script|link|base|img|form)(?:[^>]*)(?:href|src|action)=[
\"
'])http:
\\
/
\\
/([^.]+\.noblogs\.org)/i"
;
$subst
=
"$1https://$2"
;
$return
=
preg_replace
(
$re
,
$subst
,
$buffer
);
// on regex error, skip overwriting buffer
if
(
$return
)
{
$buffer
=
$return
;
}
}
return
$buffer
;
}
function
wp_ssl_buffer_init
()
{
ob_start
(
'wp_ssl_buffer_wrapup'
);
}
add_action
(
'plugins_loaded'
,
'wp_ssl_buffer_init'
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment