Skip to content
Snippets Groups Projects
Commit 439a3c03 authored by lucha's avatar lucha
Browse files

replace http with https in siteurl and home options

parent 41bed9d1
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -72,6 +72,9 @@ Known commands: ...@@ -72,6 +72,9 @@ Known commands:
Convert Next Gen Gallery (NGG) photo galleries to stardard Wordpress Convert Next Gen Gallery (NGG) photo galleries to stardard Wordpress
galleries, and then notify (via email) admins of the fact. galleries, and then notify (via email) admins of the fact.
https-siteurl BLOG
Adds https (instead of http) to siteurl and home options.
<?php <?php
exit(1); exit(1);
} }
...@@ -435,6 +438,36 @@ function do_ngg_convert($args) { ...@@ -435,6 +438,36 @@ function do_ngg_convert($args) {
} }
} }
// replaces http with https, and removes ending slash
function add_https_to_uri($uri){
$re = "http[s]?:\/\/([^.]+\.noblogs\.org)[/]?/i";
$subst = "https://$1";
return preg_replace($re,$subst,$uri);
}
// adds https to siteurl and home options
function do_https_siteurl($args){
foreach ($args as $arg) {
$blog = noblogs_get_blog($arg);
if (!$blog) {
echo "Blog {$arg} not found.\n";
continue;
}
switch_to_blog($blog->blog_id);
$siteurl = get_option('siteurl');
$home = get_option('home');
$siteurl = add_https_to_uri($siteurl);
$home = add_https_to_uri($home);
update_option('siteurl', $siteurl);
update_option('home', $home);
echo "{$arg}: ${siteurl} | ${home}\n";
restore_current_blog();
}
}
// Command-line parsing. // Command-line parsing.
$cmd = $argv[1]; $cmd = $argv[1];
...@@ -448,4 +481,3 @@ if (!function_exists($cmd_func)) { ...@@ -448,4 +481,3 @@ if (!function_exists($cmd_func)) {
help(); help();
} }
call_user_func($cmd_func, array_slice($argv, 2)); call_user_func($cmd_func, array_slice($argv, 2));
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment