
內容簡介
這個外掛程式可以將路徑(URL)轉換為相對路徑而非絕對路徑。這個外掛程式對於使用相對路徑特別有用。以下是這個外掛程式可以輕易轉換為相對路徑的永久連結和 src 清單:
文章永久連結
封存頁面的永久連結
作者永久連結
標籤永久連結
腳本路徑(src)
樣式路徑(src)
圖像路徑(src)
這個外掛程式可以將上述所有的永久連結和 src 都轉換為相對路徑。您可以從外掛程式的設定頁面選擇選項。
過濾器
如果您想要排除某些永久連結或 src 的相對轉換,您可以在您的佈景主題的 functions.php 或您自己的自訂外掛程式中使用 paths_relative 過濾器。
以下是範例過濾器(如下面的過濾器將把 jquery.js 的路徑轉換為絕對路徑):
function yasglobal_change_path( $link ) {
if( $link == '/wp-includes/js/jquery/jquery.js?ver=1.12.4' ) {
$link = site_url().'/wp-includes/js/jquery/jquery.js?ver=1.12.4';
}
return $link;
}
add_filter( 'paths_relative', 'yasglobal_change_path' );
如果您不想將 srcset(響應式圖像)的路徑轉換為相對路徑,只需要在您的佈景主題的 functions.php 中加入以下提及的行。
add_filter( 'srcset_paths_relative', '__return_false' );
如果您想要讓外掛程式在不需要檢查/訪問設定頁面的情況下即可將所有路徑轉換為相對路徑,只需要在您的佈景主題的 functions.php 中加入以下行。
add_filter( 'make_paths_relative_activate_all', '__return_true' );
請確認設定頁面
感謝您的支援
喜愛 Make Paths Relative 的使用者提供的支援非常重要。您可以給我一則 5 星評價和一條漂亮的留言,以支援 Make Paths Relative 未來的發展,並使其更加完善。
錯誤報告
錯誤報告可以在 GitHub 上提交(Make Paths Relative)。請注意,GitHub 不是支援論壇,未被正確歸類為錯誤的問題將被關閉。
外掛標籤
開發者團隊
📦 歷史版本下載
原文外掛簡介
This plugin can make(convert) the paths(URLs) to a relative instead of absolute. This plugin is useful for using relative URLs. The given below list of permalinks and src can be easily converted to a relative:
Post Permalinks
Archive Permalinks
Author Permalinks
Term Permalinks
Scripts Paths(src)
Styles Paths(src)
Image Paths(src)
All the above permalinks and src can be converted to a relative instead of absolute by using this plugin. You can select the options from the plugin settings page.
Filters
If you want to exclude some Permalink or src to be relative then you can use paths_relative filter in your theme’s functions.php or in your custom plugin.
Your filter may look like this (Below filter would make the jquery.js Path to absolute):
function yasglobal_change_path( $link ) {
if( $link == '/wp-includes/js/jquery/jquery.js?ver=1.12.4' ) {
$link = site_url().'/wp-includes/js/jquery/jquery.js?ver=1.12.4';
}
return $link;
}
add_filter( 'paths_relative', 'yasglobal_change_path' );
If you don’t want to Make the Paths relative for srcset(Responsive Images) then just add the below-mentioned line in your theme’s functions.php.
add_filter( 'srcset_paths_relative', '__return_false' );
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' );
Make sure to check the settings Page
Thanks for the Support
The support from the users that love Make Paths Relative is huge. You can support Make Paths Relative future development and help to make it even better by giving a 5-star rating with a nice message to me 🙂
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.
