Coder Social home page Coder Social logo

yasglobal / make-paths-relative Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 1.0 578 KB

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.

Home Page: https://wordpress.org/plugins/make-paths-relative/

License: GNU General Public License v3.0

PHP 86.95% CSS 10.82% JavaScript 2.23%
seo-friendly-urls wordpress-plugins domain-move multisite-compatibility portable-urls relative-links subdomain-migration url-migration links optimization

make-paths-relative's Introduction

Make Paths Relative

Description

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.

Enhanced Efficiency and Flexibility

  • Seamless Relocation: Move your website with confidence, knowing all paths will adjust accordingly, preventing broken links and preserving a seamless user - experience.
  • Centralized Control: Update paths once in a central location, eliminating the need for tedious, site-wide modifications.
  • Potential Performance Boost: Relative paths can, in some cases, improve website loading times.

Whitelist Your Domains (Optional)

For extra control, you can specify a list of domains that will always be converted to relative paths. This ensures internal links are always optimized while allowing external resources to function properly.

Embrace a Streamlined Approach

This plugin empowers you to focus on creating exceptional content while eliminating the burden of managing absolute paths. Take control, optimize your workflow, and ensure your website's continued success!

Filters

If you want to make plugin works and all the paths relative without going to check/visit Settings Page so, just add this line in your theme's functions.php.

add_filter( 'make_paths_relative_activate_all', '__return_true' );

Note: Make sure to check the settings Page.

Bug reports

Bug reports for Make Paths Relative are welcomed on GitHub. Please note GitHub is not a support forum, and issues that aren't properly qualified as bugs will be closed.

Installation

This process defines you the steps to follow either you are installing through WordPress or Manually from FTP.

From within WordPress

  1. Visit 'Plugins > Add New'
  2. Search for Make Paths Relative
  3. Activate Make Paths Relative from your Plugins page.
  4. Go to "after activation" below.

Manually

  1. Upload the make-paths-relative folder to the /wp-content/plugins/ directory
  2. Activate Make Paths Relative through the 'Plugins' menu in WordPress
  3. Go to "after activation" below.

After activation

  1. Go to the plugin settings page and set up the plugin for your site.
  2. You're done!

make-paths-relative's People

Contributors

samiahmedsiddiqui avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

make-paths-relative's Issues

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

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.

Option for folder

Your plugin looks promising.
But I need add folder to final url.

For example from domainA.com -> domainB.com/folder/

Is it possible?

Thanks

Incompatible with Jetpack in WP6 (self-hosted)

Spent an afternoon isolating which plug-in was disconnecting JetPack, but its 100% reproducible with all other plug-ins deactivated.

With make-paths-relative on, Jetpack will become disconnected. Turning make-paths-relative off fixes the issue.

When attempting to connect Jetpack with make-paths-relative on, the error message is: There was an error reconnecting Jetpack. Error: The required "siteurl" parameter is missing.
I have a value specified in the Site Address field in Make Paths Relative settings.

Disable link modification for specific domain

We are using the make paths relative plugin to manage multiple subdomain sites. While it works on front-end flawlessly, it messes up with all admin-related tasks.

  1. WMPL plugin doesn't show the translation list since it's unable to process relative URLs
  2. RankMath plugin's IndexNow feature fails since it requires absolute URLs

I've come across add_filter( "paths_relative", ... ) and have absolutely no clue on how to get it to work.

If site_url() contains a path, the plugin replaces too much

Hi,

I've encountered an issue with path replacements in WordPress. When the site_url() is set to http://10.10.10.10/blog, all absolute paths are incorrectly being replaced. For example:

Current behavior:

URL http://10.10.10.10/blog/wp-content/uploads/test.jpg is being replaced with /wp-content/uploads/test.jpg.

Desired behavior:
URL http://10.10.10.10/blog/wp-content/uploads/test.jpg should be replaced with /blog/wp-content/uploads/test.jpg.

Current Workaround:
We've implemented a temporary fix using a dirty hack by substituting site_url() with $_SERVER['HTTP_HOST']. The current code looks like this:

$host_name = $_SERVER['HTTP_HOST']; // Temporary hack

Instead of:
$host_name = site_url();

Request:
I'm looking for a more robust and cleaner solution to ensure that paths are replaced correctly without resorting to this hack. Any guidance or suggestions would be greatly appreciated.

Thank you!

Make available from Packagist

It appears the plugin has been removed from the WordPress plugin directory and has therefore stopped working with WPackagist.

As you have a well defined composer.json and suitable tags in the GitHub repo could you please submit it to https://packagist.org so that we can continue to install via Composer please?

HREF Pointing to Root Becomes Empty String

I noticed that if there are links pointing back to the site root, the href attribute of these links is set to an empty string:
<a href="">

The expected behavior would be that it would be a single forward slash:
<a href-"/">

As a result of this problem, such a link which is intended as a link to the site root ends up functioning as a link to the current page.

Make Paths Relative conflicts with Yoast Sitemap in last version of both plugins

I am using the Pantheon Workflow (Dev > Test > Live) and Make Paths Relative (MPR) is super useful to keep links to images, and urls relative from an environment to another.
Recently I found an issue, however.
When MPR is activated for all content types, then the Sitemaps generated by Yoast plugin will contain only "relative" paths which is a serious issue for SEO. Indeed Google guidance for sitemaps recomments full absolute URLs, and not relative URLs.
I saw that a previous release supposedly tackled this issue, but the benefit is not visible in the latest release of MPR.

Replication steps :

  • Install Yoast, activate it and enable Sitemap
  • Install MPR, activate it, and check all to make paths relative
  • Go to your sitemaps URL

Actual result : Sitemaps urls are relative
Expected result : Sitemaps urls should be absolute

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.