Save relative URLs to database. Present absolute URLs for viewing.
- Develop/stage in one domain, go live in another.
- Backup a production site from one domain, restore to a test site at another domain.
- Migrate from one domain to another with minimal effort.
- Ease migration between stand alone and multi-site installations.
- Ease migration between domain and sub-folder installations.
- Switch between ssl and non-ssl sites.
- Always present your content in an SEO friendly way.
We aim to achieve these capabilities with this plugin. The idea is to remove creator urls as content is produced, and play the current url when content is viewed. By default, WordPress saves the local url with content, and that makes it a challenge to access your content from a different domaim, even when you have a legitimate reason to do so.
This plugin makes your WordPress content adaptable in that you can present content from a domain other than the one in it which it was produced. It achieves this by saving URLs as relative URLs. At the same time it supports SEO requirements by reverting to absolute URLs when content is viewed.
In addition to moving the whole site to a new domain, you can identify specific domains as being related. This allows you to copy raw content from one related site and paste it into another. The plugin will recognize the related domain and remove it as it gets saved. Then it will display the absolute URLs of the current domain when it is viewed.
For the technically inclined, the plugin removes the get_bloginfo(‘url’) and get_bloginfo(‘wpurl’) parts of a URL as content is saved and inserts them again as content is viewed.
We use context and some configurable rules to determine when to apply conversions in both directions. Most of the time you can go with the defaults. If you have a situation where something doesn’t appear to work, let me know your experience (with as much detail as possible please).
ChangeLog
1.6.1
- Modified filter to specify related sites_path
- Converted plugin to singleton class
- Introduced related plugin to manage settings
- Added a public function to return current plugin version
1.6.0
- Fixed things so that urls are converted to absolute urls when editing content using the block editor
- Added feature to remove and restore the ‘sites/’ part of the upload path when running in a multi-site environment
- Added ability to disable either relative or absolute conversions
- Restructured the code where filters are set, in part to simplify and in part to make it easier to disable relative or absolute conversions
- Added ability to convert related sites in real time
- Dropped the ability to filter ‘all’ options, now only supports identifying options to be filtered (this was always the default)
- We now parse ‘data-link’ urls used by the gallery in the block editor
1.5.6
- Fixed problems displaying urls when WordPress Address and Site Address in General Settings are not the same url
1.5.5
- Fixed array definition to use array() instead of square brackets and be compatible with php prior to version 5.4
- Updated Description documentation
1.5.4
- Add related sites to list of urls that can be saved as relative urls (thanks @tythewebguy)
- Reinstated conversion of urls that are the only content in a field (affects things like header image urls)
- Reduced both save and view conversions to run in a single grep_replace
- Put copy on github in case anyone wants to fork or contribute, https://github.com/intuitart/Absolute-Relative-URLs
- Tested WordPress version 4.9.x
1.5.3
- Ignore // at beginning of url when displaying urls as this is sometimes used for schema relative urls (thanks @ublac)
- Ignore urls in content that is not prefixed by src, href, etc. when saving urls (thanks @timbobo)
- Created a single pattern that is used for all save and display filters
- Appended a / when saving a url and a domain without a trailing slash was used
- Tested WordPress version 4.8
1.5.2
- Tweaked algorithm that generates absolute urls to better catch edge cases.
- Move WP options, for exclusion from ‘all’ options, into separate file.
- Moved derivation of 1st and 2nd urls required when creating absolute urls so it only runs once, on class init().
1.5.1
- Enable ‘all’ options filter wasn’t working. Fixed.
- Added filter to allow additional option exclusions when ‘all’ options are enabled.
- Updated readme.txt.
1.5.0
- Tested up to WP 4.7
- Wrapped code in a class.
- Added a couple more editor option hooks to catch more urls.
- Included img ‘srcset’ attribute when viewing content.
- Added filters to allow additional view/save hooks or options to be added.
- Added ability to filter all options, with exclusions, instead of filtering specific options. This is not enabled by default. Excluded are the built in WordPress options.
1.4.2
- Tested up to WP 4.6.1
- Updated readme.txt
- Added icon to display on plugins page
1.4.1
- Updated readme.txt to include wordpress.org installation and format correctly in validator
- Renamed plugin file and folder to match plugin name submitted to WordPress
1.4
- Added function to more reliably determine site’s base upload path (typically ‘wp-content/uploads’)
- Distinguished between wordpress and site urls so that wordpress can run separate from domain root
- Tested and confirmed the following scenarios work, all from the same database:
- WordPress and site urls are the same and running from root (http or https)
- WordPress and site urls are the same and running from a subdirectory (e.g ~/wordpress)
- WordPress url is subdirectory and site url is root directory
1.3
- Cleaned up to meet wordpress.org coding standards
- Tweaked the code to use trailingslashit($string) rather than hard code $string . ‘/’
1.2
- Add filters for ‘stylesheet’ and ‘template’ options to catch things like header image
- Moved view filter for tinymce to option so save and view are at the same level
- Added ability to parse object data types when saving and viewing
- Explicitly handle string data type rather than assuming string
- Return content unfiltered for data types other than array, object and string
- Put view, save and options filters in arrays to document and make it easier to add/remove filters
- Updated description and installation
1.1
- Added updates to the excerpt field when it is entered separately from the content
1.0
- First release, catches post_content and widget_black-studio-tinymce updates