Skip to content

Instantly share code, notes, and snippets.


Igor Buyanov artifex404

  • Finland
View GitHub Profile
artifex404 / wordpress_change_domains.sql
Last active Apr 21, 2016
This query will find and replace URLs in all standard WordPress installation SQL tables. Remember to save the permalinks from the administration panel after doing this query.
View wordpress_change_domains.sql
SET @olddomain = "''";
SET @newdomain = "''";
SET @prefix = "wp_";
SET @postmeta = CONCAT('UPDATE ', @prefix, 'postmeta SET meta_value = REPLACE(meta_value,', @olddomain, ',',@newdomain,')');
SET @excerpt = CONCAT('UPDATE ', @prefix, 'posts SET post_excerpt = REPLACE(post_excerpt,', @olddomain, ',',@newdomain,')');
SET @content = CONCAT('UPDATE ', @prefix, 'posts SET post_content = REPLACE(post_content,', @olddomain, ',',@newdomain,')');
SET @guid = CONCAT('UPDATE ', @prefix, 'posts SET guid = REPLACE(guid,', @olddomain, ',',@newdomain,')');
SET @options = CONCAT('UPDATE ', @prefix, 'options SET option_value = REPLACE(option_value,', @olddomain, ',',@newdomain,') WHERE option_name = "siteurl" OR option_name = "home"');
View get-ip-address-optimized.php
function get_ip_address() {
foreach ($ip_keys as $key) {
if (array_key_exists($key, $_SERVER) === true) {
$items = explode(',', $_SERVER[$key]);
You can’t perform that action at this time.