[WordPress] 外掛分享: Dynamic Hostname

首頁外掛目錄 › Dynamic Hostname
WordPress 外掛 Dynamic Hostname 的封面圖片
300+
安裝啟用
尚無評分
3968 天前
最後更新
問題解決
WordPress 3.8+ v0.4.2 上架:2014-03-17

內容簡介

這個外掛會自動動態更改 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;
});

外掛標籤

開發者團隊

⬇ 下載最新版 (v0.4.2) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Dynamic Hostname」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

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;
});

延伸相關外掛

文章
Filter
Apply Filters
Mastodon