
內容簡介
WordPress 工具列讓在網站檢視與編輯之前互相切換很容易,但有時這個工具列本身可能會顯得很突兀。
「Show Me The Admin」是一個 WordPress 外掛,它可以隱藏工具列並讓你使用多種方式讓它出現與消失。
功能包括:
隱藏工具列,並透過輸入特定單字讓其出現
隱藏工具列,讓 WordPress 按鈕出現在左上角,點擊即可顯示
隱藏工具列,當滑鼠接近視窗頂部時讓其出現
「Show Me The Admin」也支援多站點,請到Show Me The Admin GitHub 庫參與討論、提交問題,並提出建議。
你需要啟用「當檢視網站時顯示工具列」的使用者設定。
篩選器
「Show Me The Admin」使用特定篩選器,讓你微調外掛。
篩選設定
/**
* 篩選「Show Me The Admin」的設定。
*
* @param array - $settings - 原始設定
* @return array - 篩選後的設定
*/
add_filter( 'show_me_the_admin_settings', 'filter_show_me_the_admin_settings' );
function filter_show_me_the_admin_settings( $settings ) {
// 修改設定
// 例如,將顯示工具列的單字改成「showme」
$settings[ 'show_phrase' ] = 'hello';
// 或者,將隱藏工具列的單字改成「hideme」
$settings[ 'hide_phrase' ] = 'goodbye';
// 回傳設定
return $settings;
}
篩選顯示工具列的單字
/**
* 篩選顯示工具列的單字。
*
* @param string - $show_phrase - 原始單字
* @return string - 篩選後的單字
*/
add_filter( 'show_me_the_admin_show_phrase', 'filter_show_me_the_admin_show_phrase' );
function filter_show_me_the_admin_show_phrase( $show_phrase ) {
// 修改單字,預設為「showme」
$show_phrase = 'hello';
// 回傳單字
return $show_phrase;
}
篩選隱藏工具列的單字
/**
* 篩選隱藏工具列的單字。
*
* @param string - $hide_phrase - 原始單字
* @return string - 篩選後的單字
*/
add_filter( 'show_me_the_admin_hide_phrase', 'filter_show_me_the_admin_hide_phrase' );
function filter_show_me_the_admin_hide_phrase( $hide_phrase ) {
// 修改單字,預設為「hideme」
$hide_phrase = 'goodbye';
// 回傳單字
return $hide_phrase;
}
篩選下拉式登入按鈕文字
/**
* 篩選「Show Me The Admin」下拉式登入按鈕文字。
*
* @param string - $text - 原始文字
* @return string - 篩選後的文字
*/
add_filter( 'show_me_the_admin_login_text', 'filter_show_me_the_admin_login_text' );
function filter_show_me_the_admin_login_text( $text ) {
// 修改文字,預設為「Login to WordPress」
$text = 'Login to the admin';
// 回傳文字
return $text;
}
外掛標籤
開發者團隊
原文外掛簡介
The WordPress toolbar makes it really easy to move between viewing your site and editing your site but sometimes the toolbar itself can be intrusive.
“Show Me The Admin” is a WordPress plugin that hides your toolbar and enables you to make it appear, and disappear, using a variety of methods.
Features include:
Hide your toolbar and make it appear by typing a phrase
Hide your toolbar and show WordPress button in top left corner to click to appear
Hide your toolbar and make it appear when mouse hovers near top of window
Show Me The Admin is also multisite-friendly. Please use the Show Me The Admin GitHub repo to contribute, submit issues, and suggest features.
Your “Show Toolbar when viewing site” profile setting must be enabled.
Filters
Show Me The Admin has filters setup to allow you to tweak the plugin.
Filter the settings
/**
* Filters the "Show Me The Admin" settings.
*
* @param array - $settings - the original settings
* @return array - the filtered settings
*/
add_filter( 'show_me_the_admin_settings', 'filter_show_me_the_admin_settings' );
function filter_show_me_the_admin_settings( $settings ) {
// Change the settings
// For example, change the phrase you type to show the toolbar, default is 'showme'
$settings[ 'show_phrase' ] = 'hello';
// Or change the phrase you type to hide the toolbar, default is 'hideme'
$settings[ 'hide_phrase' ] = 'goodbye';
// Return the settings
return $settings;
}
Filter the phrase to show the toolbar
/**
* Filters the phrase to show the toolbar.
*
* @param string - $show_phrase - the original phrase
* @return string - the filtered phrase
*/
add_filter( 'show_me_the_admin_show_phrase', 'filter_show_me_the_admin_show_phrase' );
function filter_show_me_the_admin_show_phrase( $show_phrase ) {
// Change the phrase, default is 'showme'
$show_phrase = 'hello';
// Return the phrase
return $show_phrase;
}
Filter the phrase to hide the toolbar
/**
* Filters the phrase to hide the toolbar.
*
* @param string - $hide_phrase - the original phrase
* @return string - the filtered phrase
*/
add_filter( 'show_me_the_admin_hide_phrase', 'filter_show_me_the_admin_hide_phrase' );
function filter_show_me_the_admin_hide_phrase( $hide_phrase ) {
// Change the phrase, default is 'hideme'
$hide_phrase = 'goodbye';
// Return the phrase
return $hide_phrase;
}
Filter the text for the dropdown login button
/**
* Filters the text for the "Show Me The Admin"
* dropdown login button.
*
* @param string - $text - the original text
* @return string - the filtered text
*/
add_filter( 'show_me_the_admin_login_text', 'filter_show_me_the_admin_login_text' );
function filter_show_me_the_admin_login_text( $text ) {
// Change the text, default is 'Login to WordPress'
$text = 'Login to the admin';
// Return the text
return $text;
}
