{"id":18841277,"url":"https://github.com/dmhendricks/wordpress-network-subdomain-updater-plugin","last_synced_at":"2026-03-16T22:32:36.893Z","repository":{"id":88694430,"uuid":"123221363","full_name":"dmhendricks/wordpress-network-subdomain-updater-plugin","owner":"dmhendricks","description":"A WordPress mu-plugin that updates network (multisite) sub-domains after MySQL data import.","archived":false,"fork":false,"pushed_at":"2020-06-07T16:22:27.000Z","size":21,"stargazers_count":5,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T12:07:18.365Z","etag":null,"topics":["mu-plugins","multisite","multisite-network","staging","staging-environment","sync","wordpress","wordpress-network","wordpress-plugin","wordpress-sync"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dmhendricks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-28T03:06:08.000Z","updated_at":"2025-01-27T11:50:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"95f59171-2fe9-46f0-b883-a800fee023c1","html_url":"https://github.com/dmhendricks/wordpress-network-subdomain-updater-plugin","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmhendricks%2Fwordpress-network-subdomain-updater-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmhendricks%2Fwordpress-network-subdomain-updater-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmhendricks%2Fwordpress-network-subdomain-updater-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmhendricks%2Fwordpress-network-subdomain-updater-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmhendricks","download_url":"https://codeload.github.com/dmhendricks/wordpress-network-subdomain-updater-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248837287,"owners_count":21169374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mu-plugins","multisite","multisite-network","staging","staging-environment","sync","wordpress","wordpress-network","wordpress-plugin","wordpress-sync"],"created_at":"2024-11-08T02:50:38.709Z","updated_at":"2026-03-16T22:32:36.847Z","avatar_url":"https://github.com/dmhendricks.png","language":"PHP","funding_links":["https://paypal.me/danielhendricks"],"categories":[],"sub_categories":[],"readme":"[![Author](https://img.shields.io/badge/author-Daniel%20M.%20Hendricks-lightgrey.svg?colorB=9900cc )](https://www.danhendricks.com?utm_source=github.com\u0026utm_medium=campaign\u0026utm_content=button\u0026utm_campaign=wordpress-network-subdomain-updater-plugin)\n[![Latest Release](https://img.shields.io/github/release/dmhendricks/wordpress-network-subdomain-updater-plugin.svg)](https://github.com/dmhendricks/wordpress-network-subdomain-updater-plugin/releases)\n[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://paypal.me/danielhendricks)\n[![License](https://img.shields.io/badge/license-GPLv2-yellow.svg)](https://raw.githubusercontent.com/dmhendricks/wordpress-network-subdomain-updater-plugin/master/LICENSE)\n[![FlyWheel](https://img.shields.io/badge/style-FlyWheel-green.svg?style=flat\u0026label=get%20hosted\u0026colorB=AE2A21)](https://share.getf.ly/e25g6k?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=button\u0026utm_campaign=wordpress-network-subdomain-updater-plugin)\n[![Twitter](https://img.shields.io/twitter/url/https/github.com/dmhendricks/wordpress-network-subdomain-updater-plugin.svg?style=social)](https://twitter.com/danielhendricks)\n\n# Network Sub-domain Updater for WordPress\n\nA simple MU plugin that updates the primary domain on WordPress Network installations. It was primarily created for development and staging environments to make it easier when you sync data from a production site.\n\n**Use are your own risk. This plugin is useless to you if you are *not* running a [WordPress Network](https://codex.wordpress.org/Create_A_Network) in [Subdomain mode](https://codex.wordpress.org/Create_A_Network#Installing_a_Network)!**\n\n:pushpin: Use in conjunction with: [Rewrite Content URLs](https://github.com/dmhendricks/wordpress-rewrite-content-urls-plugin?utm_source=github.com\u0026utm_medium=campaign\u0026utm_content=button\u0026utm_campaign=wordpress-network-subdomain-updater-plugin)\n\n### How It Works\n\nLet's say you run a WordPress Network of sub-domains. If you did a MySQL dump from your production server (example.com) and then imported to your staging (staging.example.com) or local development (example.local) instance, the primary domain would no longer match the environment.\n\nThis plugin checks to see if the primary domain changed, and if so, updates the sub-sites and relevant database fields.\n\nFor example, I use [Local by Flywheel](https://local.getflywheel.com/?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=button\u0026utm_campaign=wordpress-network-subdomain-updater-plugin) for local WordPress development:\n\n1. Create a local WordPress multisite instance.\n2. Copy necessary file assets (plugins, themes, uploads, etc) from the remote site.\n3. Add this mu-plugin to your local instance's `mu-plugins` directory.\n4. Define the appropriate [constants](https://github.com/dmhendricks/wordpress-network-subdomain-updater-plugin#configuration) in `wp-config.php`.\n\nNow, each time that you import MySQL dumps from your remote server to your local development database, this plugin will update the primary network and sub-sites to your local domain.\n\n#### Important Note\n\nThis plugin will only update the domains in `wp_site`, `wp_blogs`, `wp_options`, etc to that your web site will load properly. It **will not** do a global find-and-replace for other/hard-coded domains. If you wish to do that **after** running this plugin, I recommend [Better Search Replace](https://wordpress.org/plugins/better-search-replace/).\n\n## Installation\n\n**NB!** This plugin is only intended to be used in staging and development environments! It is not intended to be run on production servers as it will incur a performance hit. You **can** use it to rename the primary domain on a production instance (create a MySQL backup first!), but once it's run and the domains are renamed, you should remove the plugin (or at least disable it with `NETWORK_LOCAL_DOMAIN_DISABLE`).\n\nTo install, simply download the `network-subdomain-updater.php` file and place it in your `wp-content/mu-plugins` directory (create one if it doesn't exist). Don't copy the other files - they are not necessary.\n\n## Configuration\n\n### Constants\n\nThis plugin is configured with constants that you defined in your development/staging environments `wp-config.php` files. **Why constants and not settings in WP Admin?** Because they would get blown away every time you import a fresh database dump.\n\n**SITE_ID_CURRENT_SITE** *(required)*\n\n```php\ndefine( 'SITE_ID_CURRENT_SITE', 1 );\n```\n\n**NOBLOGREDIRECT** *(required)*\n\n```php\ndefine( 'NOBLOGREDIRECT', true ); // Must be set to true!\n```\n\n**NETWORK_LOCAL_DOMAIN_DISABLE**\n\n```php\ndefine( 'NETWORK_LOCAL_DOMAIN_DISABLE', true );\n```\n\nAllows you to temporarily disable the plugin from loading at all, useful if you do not sync your data frequently.\n\n**NETWORK_LOCAL_DOMAIN_SCHEME**\n\nExamples:\n```php\ndefine( 'NETWORK_LOCAL_DOMAIN_SCHEME', 'https' ); // Prefix site URLs with: https\ndefine( 'NETWORK_LOCAL_DOMAIN_SCHEME', 'http' ); // Prefix site URLs with: http\n```\n\n(This allows you to force HTTP or HTTPS on updated site URLs, depending on what your LAMP environment supports. If not defined or set to `false`, original URL prefixes will be preserved.)\n\n**NETWORK_LOCAL_DOMAIN_STRIP_WWW**\n\nExamples:\n```php\ndefine( 'NETWORK_LOCAL_DOMAIN_STRIP_WWW', true );\n```\n\nStrips `www.` from domains, useful if your local development environment doesn't alias it.\n\n**WP_ADMIN_EMAIL**\n\nIf specified, changes the `admin_mail` value in `wp_options`, useful for debugging:\n```php\ndefine( 'WP_ADMIN_EMAIL', 'you@example.com' );\n```\n\n(This is irrelevant if you are using something like [MailHog](https://github.com/mailhog/MailHog) to intercept e-mails.)\n\n**NETWORK_UPDATE_SUBSITE_ADMIN_EMAIL**\n\nIf set to true, plugin will update the `admin_email` for all sub-sites to `WP_ADMIN_EMAIL` (rather than only the network admin e-mail):\n```php\ndefine( 'NETWORK_UPDATE_SUBSITE_ADMIN_EMAIL', true );\n```\n\nUsed in conjunction with `WP_ADMIN_EMAIL`, which must also be set.\n\n**NETWORK_LOCAL_UPDATE_NOTIFY**\n\nIf defined, sends a notification e-mail stating that an update was performed.\n\nSend to `admin_email` using plugin defaults:\n```php\ndefine( 'NETWORK_LOCAL_UPDATE_NOTIFY', true );\n```\n\nSend to specific e-mail address:\n```php\ndefine( 'NETWORK_LOCAL_UPDATE_NOTIFY', 'you@example.com' );\n```\n\nPHP 7 or higher Options:\n```php\ndefine( 'NETWORK_LOCAL_UPDATE_NOTIFY', [ 'email' =\u003e 'you@yourdomain.com', 'subject' =\u003e 'Site sync!', 'message' =\u003e 'This space intentionally left blank.' ] );\n```\n\n### Use Case\n\nLet's assume the following:\n\n- Your production sites are at: `*.example.com`\n- Your staging environment sites are at: `*.staging.example.com`\n- Your development environment sites are at: `*.example.local`\n\nIn your *staging* environment's `wp-config.php`, you might define `DOMAIN_CURRENT_SITE` as follows:\n```php\ndefine( 'DOMAIN_CURRENT_SITE', 'staging.example.com' );\n```\n\nIn your *development* environment's `wp-config.php`, you might define `DOMAIN_CURRENT_SITE` as follows:\n```php\ndefine( 'DOMAIN_CURRENT_SITE', 'example.local' );\n```\n\n### Typical Example\n\nBelow is a typical example of the constants that you'd add/change in `wp-config.php`:\n\n```php\n// Defined for multisite\ndefine( 'DOMAIN_CURRENT_SITE', 'mysite.local' );\n// ...\n\n// Constants specific to this plugin\ndefine( 'WP_ADMIN_EMAIL', 'webmaster@mysite.local' ); // Optional\ndefine( 'NETWORK_LOCAL_DOMAIN_STRIP_WWW', true );\ndefine( 'NETWORK_LOCAL_DOMAIN_SCHEME', 'https' ); // Optional\ndefine( 'NOBLOGREDIRECT', true ); // Required\n```\n\n### Last Sync Date\n\nThis plugin will store the last sync date in a network settings field named `_nsu_last_data_sync`. In development and staging, I display this date in the [WP Admin footer](https://web-design-weekly.com/snippets/modify-footer-text-in-wordpress-admin-area/), but you may use as you wish.\n\n```php\necho get_site_option( '_nsu_last_data_sync', 'unknown' );\n```\n\n## Change Log\n\nRelease changes are noted on the [Releases](https://github.com/dmhendricks/wordpress-network-subdomain-updater-plugin/releases) page.\n\n#### Branch: `master`\n\n* None since release\n\n[![Analytics](https://ga-beacon.appspot.com/UA-67333102-2/dmhendricks/wordpress-network-subdomain-updater-plugin)](https://github.com/dmhendricks/wordpress-network-subdomain-updater-plugin)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmhendricks%2Fwordpress-network-subdomain-updater-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmhendricks%2Fwordpress-network-subdomain-updater-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmhendricks%2Fwordpress-network-subdomain-updater-plugin/lists"}