yasglobal / make-paths-relative

This powerful plugin simplifies website maintenance by automatically converting absolute paths (URLs) for resources like links, scripts, stylesheets, and images to relative paths. This ensures your website functions flawlessly regardless of its location on a server or domain.
https://wordpress.org/plugins/make-paths-relative/
GNU General Public License v3.0
4 stars 1 forks source link

Plugin breaks "Make title link to home" option for Site Title block #13

Open aaronpinero opened 1 month ago

aaronpinero commented 1 month ago

I am working with a mostly clean install of WordPress 6.6 and the Twenty Twenty-Four theme. By default, the theme has a Site Title block in the header with the option "Make title link to home" enabled. This feature works until installing the Make Paths Relative plugin. After installing and configuring the plugin to act on all the links in the body, the site title no longer links to the home page. Inspecting the code I can see the href attribute of this link has become empty. Seems like the plugin is a little too good at removing the absolute URL and doesn't allow for a '/' href to match the home page.

aaronpinero commented 1 month ago

don't know if this is the right solution, but I tried adding the following code at line 169 of class-make-paths-relative-frontend.php:

                $body_content = preg_replace(
                    '/"(http:\/\/|https:\/\/|\/\/)' . preg_quote( $internal_domain, '/' ) . '"/is',
                    '"/"',
                    $body_content
                );

It seems to work in limited testing.

samiahmedsiddiqui commented 1 month ago

@aaronpinero Please remove trailing slash from the "Site Addresses" field. In this way, you no longer need to change anything in the code.

aaronpinero commented 1 month ago

There are no trailing slashes in the Site Addresses field.

samiahmedsiddiqui commented 1 month ago

@aaronpinero Do you have staging website where you can show me the issue? If yes, please connect with me on LinkedIn and share the website details there.