[WordPress] 外掛分享: Dynamic Hostname

WordPress 外掛 Dynamic Hostname 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「Dynamic Hostname」是 2014-03-17 上架。
  • 目前有 300 個安裝啟用數。
  • 上一次更新是 2015-04-26,距離現在已有 3661 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 3.8 以上版本才可以安裝。
  • 尚未有人給過這款外掛評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

tekapo | inc2734 | miyauchi | toro_unit | megumithemes |

外掛標籤

wp_home | hostname | site_url | vagrant cloud |

內容簡介

這個外掛會自動動態更改 WordPress 使用的主機名稱。例如,當你在不同的伺服器上運行 WordPress,例如生產、開發或預發行版本,主機名稱將會自動更改,每個網站都不會有失效連結。當你配合 Vagrant Cloud 使用時,它非常有用。

一些功能

暫時將主機名稱更改為當前的主機名稱 ($_SERVER[‘HTTP_HOST’])。
同時還會更換連結到相同網站內容和圖像的主機名稱。
在開發伺服器上的內容中包含的主機名稱會更改為生產伺服器的主機名稱。(當你移動到生產伺服器時,不需要在資料庫中替換主機名稱。)
編輯窗口中的主機名稱會暫時替換為當前的主機名稱,因此當你在開發伺服器上進行編輯時,永遠不會有失效的連結。

替換使用的勾子

這個外掛使用以下濾鏡勾子來替換 URL 中的主機名稱。

$hooks = array(
"home_url",
"site_url",
"stylesheet_directory_uri",
"template_directory_uri",
"plugins_url",
"wp_get_attachment_url",
"theme_mod_header_image",
"theme_mod_background_image",
"the_content",
"upload_dir",
"widget_text",
);

這些勾子也有自己的濾鏡勾子,因此你可以與你正在使用的其他外掛進行自定義。

add_filter('dynamic_hostname_filters' function($hooks){
$hooks[] = 'some_filter_hook';
return $hooks;
});

原文外掛簡介

This plugin changes dynamically and automatically the host name which WordPress uses. For example, when you run WordPress on your different servers, for production, development or staging, the host name will be changed dynamically and each site won’t have broken links. It’s very useful when you use it with Vagrant Cloud.
Some features

Temporarily changes the host name to the current host name ($_SERVER[‘HTTP_HOST’]).
Also replaces the host name of the links to the contents and the images in the same site.
The host name included in the contents on the development server will be changed to the one for the production server. (You don’t need to replace the host name in the database when you move it to the production server.)
The host name in the editor window is temporarily replaced with the current host name, so when you edit some on the development server, you never have broken links.

Hooks to use for replacing
This plugin uses the filter hooks below to replace the host name in URL.
$hooks = array(
"home_url",
"site_url",
"stylesheet_directory_uri",
"template_directory_uri",
"plugins_url",
"wp_get_attachment_url",
"theme_mod_header_image",
"theme_mod_background_image",
"the_content",
"upload_dir",
"widget_text",
);

Those hooks also have their own filter hooks, so you can customize with other plugins you are using, etc.
add_filter('dynamic_hostname_filters' function($hooks){
$hooks[] = 'some_filter_hook';
return $hooks;
});

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Dynamic Hostname」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


0.1.0 | 0.2.0 | 0.3.0 | 0.4.0 | 0.4.1 | 0.4.2 | trunk |

延伸相關外掛(你可能也想知道)

  • Site Address Migrator 》如果您在 WordPress 設置中更改了網站地址,您可能會注意到所有頁面和文章中的鏈接仍然使用舊的網站 URL。此外掛當您更改站點地址時,會在 WordPress 數據庫...。
  • Fix API URL 》使用 site_url() 代替 home_url() 來構建 API URL。對於將 WordPress 用作無頭 CMS(Headless CMS)非常有用。。
  • Widget Fixer 》Widget-fixer 透過重新計算小工具字串的長度,並更新相關數字於資料庫,使您的小工具能夠再次正常載入。, 免責聲明, 此外掛程式是「按現狀提供」。它是根據 [...。

文章
Filter
Mastodon