Changeset 1929933
- Timestamp:
- 08/24/2018 08:48:24 PM (8 years ago)
- Location:
- automatic-domain-changer/trunk
- Files:
-
- 2 edited
-
auto-domain-change.php (modified) (9 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
automatic-domain-changer/trunk/auto-domain-change.php
r1505955 r1929933 5 5 Description: Automatically changes the domain of a WordPress blog 6 6 Author: NuageLab <wordpress-plugins@nuagelab.com> 7 Version: 2.0. 17 Version: 2.0.2 8 8 License: GPLv2 or later 9 9 Author URI: http://www.nuagelab.com/wordpress-plugins … … 169 169 $error_terms = true; 170 170 } else { 171 return $this->do_change($_POST['old-domain'], $_POST['new-domain'] );171 return $this->do_change($_POST['old-domain'], $_POST['new-domain'], $_POST['force-protocol'] ? $_POST['force-protocol'] : null); 172 172 } 173 173 break; … … 191 191 echo '<input type="hidden" name="action" value="'.$action.'" />'; 192 192 193 if (array_key_exists('force-protocol', $_POST)) { 194 $force_protocol = $_POST['force-protocol']; 195 } else if (array_key_exists('HTTPS', $_SERVER)) { 196 $force_protocol = 'https'; 197 } else if (array_key_exists('HTTP_X_FORWARDED_PROTO', $_SERVER) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') { 198 $force_protocol = 'https'; 199 } else { 200 $force_protocol = 'http'; 201 } 202 203 echo '<style>'; 204 echo '.adc-widefat { height:28px; padding:2px; position:relative; top:2px; width:250px; max-width:100%;}'; 205 echo '.adc-select { text-align:right;}'; 206 echo '</style>'; 207 193 208 echo '<table class="form-table">'; 194 209 echo '<tbody>'; 195 210 echo '<tr valign="top">'; 196 211 echo '<th scope="row"><label for="old-domain">'.__('Change domain from: ','auto-domain-change').'</label></th>'; 197 echo '<td>http://<input class=" regular-text" type="text" name="old-domain" id="old-domain" value="'.esc_html(get_option('auto_domain_change-domain')).'" /></td>';212 echo '<td>http://<input class="adc-widefat" class="regular-text" type="text" name="old-domain" id="old-domain" value="'.esc_html(get_option('auto_domain_change-domain')).'" /></td>'; 198 213 echo '</tr>'; 199 214 200 215 echo '<tr valign="top">'; 201 216 echo '<th scope="row"><label for="new-domain">'.__('Change domain to: ','auto-domain-change').'</label></th>'; 202 echo '<td>http://<input class="regular-text" type="text" name="new-domain" id="new-domain" value="'.esc_html($_SERVER['HTTP_HOST']).'" /></td>'; 217 echo '<td>'; 218 echo '<select name="force-protocol" id="force-protocol" class="adc-select">'; 219 foreach (array( 220 'https'=>__('https://', 'auto-domain-change'), 221 'http'=>__('http://', 'auto-domain-change'), 222 ''=>__('(same)', 'auto-domain-change'), 223 ) as $protocol=>$name) { 224 printf('<option value="%1$s"%3$s>%2$s</option>', 225 $protocol, 226 $name, 227 ($force_protocol == $protocol ? ' selected' : '') 228 ); 229 } 230 echo '</select>'; 231 echo '<input class="adc-widefat" class="regular-text" type="text" name="new-domain" id="new-domain" value="'.esc_html($_SERVER['HTTP_HOST']).'" /></td>'; 203 232 echo '</tr>'; 204 233 … … 260 289 * @access private 261 290 */ 262 private function do_change($old, $new )291 private function do_change($old, $new, $forceProtocol=null) 263 292 { 264 293 global $wpdb; … … 325 354 326 355 // Process value 327 $v = $this->processValue( $v, $old, $new );356 $v = $this->processValue( $v, $old, $new, $forceProtocol ); 328 357 329 358 // If value changed, replace it … … 351 380 352 381 353 private function processValue($v, $old, $new )382 private function processValue($v, $old, $new, $forceProtocol) 354 383 { 355 384 $sfalse = serialize(false); … … 374 403 if (($serialized) && (is_string($v))) { 375 404 // Reprocess in case of double serialize done by sketchy plugins 376 $v = $this->processValue($v, $old, $new );405 $v = $this->processValue($v, $old, $new, $forceProtocol); 377 406 } else { 378 407 // Replace 379 $this->replace($v, $old, $new );408 $this->replace($v, $old, $new, $forceProtocol); 380 409 } 381 410 … … 539 568 * @access private 540 569 */ 541 private function replace(&$v, $old, $new )570 private function replace(&$v, $old, $new, $forceProtocol=null) 542 571 { 543 572 $protocols = array('http'); … … 553 582 if ((is_array($v)) || (is_object($v))) { 554 583 foreach ($v as &$vv) { 555 $this->replace($vv, $old, $new );584 $this->replace($vv, $old, $new, $forceProtocol); 556 585 } 557 586 } else if (is_string($v)) { 558 587 foreach ($protocols as $protocol) { 559 588 foreach ($domains as $o=>$n) { 560 $v = preg_replace(','.$protocol.'://'.preg_quote($o,',').',i',$protocol.'://'.$n, $v); 589 $toProtocol = $forceProtocol ? $forceProtocol : $protocol; 590 $v = preg_replace(','.$protocol.'://'.preg_quote($o,',').',i',$toProtocol.'://'.$n, $v); 561 591 } 562 592 } -
automatic-domain-changer/trunk/readme.txt
r1505955 r1929933 4 4 Tags: admin, administration, links, resources, domain change, migration 5 5 Requires at least: 3.0 6 Tested up to: 4. 5.16 Tested up to: 4.9.8 7 7 Stable tag: trunk 8 8 License: GPLv2 or later … … 83 83 84 84 == Changelog == 85 = 2.0.2 = 86 * Tested up to WordPress 4.9.8 87 * Added a way to change the protocol to HTTP or HTTPS 88 85 89 = 2.0.1 = 86 90 * Tested up to WordPress 4.6.1 … … 89 93 = 2.0.0 = 90 94 * Tested up to WordPress 4.4.2 91 * Added backup function nality95 * Added backup functionality 92 96 * Removed usage of mysql_* functions in favor of $wpdb 93 97
Note: See TracChangeset
for help on using the changeset viewer.