前言介紹
- 這款 WordPress 外掛「Dropdown Menus」是 2011-07-15 上架。
- 目前有 400 個安裝啟用數。
- 上一次更新是 2013-01-16,距離現在已有 4490 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 3.0 以上版本才可以安裝。
- 有 5 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
ui | menus | mobile | dropdowns | navigation |
內容簡介
對於行動版或一般小螢幕設計,使用下拉式導覽可以節省空間。這個外掛程式提供了一種顯示自訂選單作為下拉式選單的方式,可以使用小工具或函數呼叫,並且可以作為任何主題的 include。
使用方法
如果您正在使用此外掛程式與主題,您可以使用 dropdown_menu() 函數來取代 wp_nav_menu() 的呼叫。
dropdown_menu() 函數帶有與 wp_nav_menu() 相同的引數,並增加了三個額外選項:
dropdown_menu( array(
// 您可以使用以下方式更改空白文字,例如 "- 選單名稱 -"
'dropdown_title' => '-- 主選單 --',
// indent_string 是在子選單項目標題之前輸出的字符串。子子菜單項目重複兩次,以此類推
'indent_string' => '- ',
// 如果項目是子選單項目,indent_after 是可選的字符串,在 indent_string 之後輸出
'indent_after' => ''
) );
?>
您可以使用程式碼中提供的輸出過濾器來擴展和更改下拉式選單的輸出。
此外掛程式還提供了許多樣式鉤子,例如在標準列表類型選單中,增加了用於針對菜單中某個深度的項目的類別 (例如 .menu-item-depth-1) 以及通常的 .current-menu-item 和 .current-menu-ancestor 類別。
過濾器 / 鉤子
dropdown_blank_item_text
add_filter( 'dropdown_blank_item_text', 10, 2 );
function my_dropdown_blank_text( $title, $args ) {
return __( '- 瀏覽 -' );
}
?>
如果要在空白項目中顯示菜單標題,請使用以下代碼:
add_filter( 'dropdown_blank_item_text', 'dropdown_menu_use_menu_title', 10, 2 );
function dropdown_menu_use_menu_title( $title, $args ) {
return '- ' . $args->menu->name . ' -';
}
?>
dropdown_menus_indent_string
add_filter( 'dropdown_menus_indent_string', 10, 4 );
function my_dropdown_indent_string( $indent_string, $item, $depth, $args ) {
return str_repeat( ' ', $depth );
}
?>
dropdown_menus_indent_after
add_filter( 'dropdown_menus_indent_after', 10, 4 );
function my_dropdown_indent_after( $indent_after, $item, $depth, $args ) {
return '-';
}
?>
dropdown_menus_class
如果您發現類名稱或 CSS 衝突,例如 Twitter Bootstrap,請使用此類過濾器。
add_filter( 'dropdown_menus_class', create_function( '$c', 'return "my-dropdown-menu-class";' ) );
?>
dropdown_menus_select_current
如果您喜歡在每個頁面中顯示空白選項,請使用此過濾器停止輸出 selected="selected" 屬性。
add_filter( 'dropdown_menus_select_current', create_function( '$bool', 'return false;' ) );
?>
我可以確認此外掛程式可以使用我的主題嗎?
如果您的主題需要此外掛程式可用,請將其作為簡單的 include 使用。只需將外掛程式放入您的主題目錄中,並從您的 functions.php 檔案中包含 dropdown-menus.php。
如果您將外掛程式資料夾放入主題目錄中,您可以使用以下程式碼在 functions.php 檔案中引用:
原文外掛簡介
Sometimes for mobile design or more generally small-screen design it can be beneficial to save space by using a dropdown for your navigation.
This plugin provides a way to display your custom menus as dropdowns either using a widget or a function call and can be used as an include in any theme.
Usage
If you are using the plugin with a theme you can use the function dropdown_menu() in place of calls to wp_nav_menu().
The dropdown_menu() function takes the same arguments as wp_nav_menu() with the addition of three extras:
'-- Main Menu --',
// indent_string is a string that gets output before the title of a
// sub-menu item. It is repeated twice for sub-sub-menu items and so on
'indent_string' => '- ',
// indent_after is an optional string to output after the indent_string
// if the item is a sub-menu item
'indent_after' => ''
) );
?>
You can extend and alter the output of the dropdowns using the output filters available in the code.
There are also plenty of styling hooks like in the standard list type menus with the addition of classes for targetting items at a certain depth in the menu (.menu-item-depth-1 for example) aswell the usual .current-menu-item and .current-menu-ancestor classes.
Filters/Hooks
dropdown_blank_item_text
If you want to show the menu title as the blank item text use the follwing code:
menu->name . ' -';
}
?>
dropdown_menus_indent_string
dropdown_menus_indent_after
dropdown_menus_class
Use this if you find you get class name or CSS conflicts, for example with Twitter Bootstrap.
dropdown_menus_select_current
Use this filter to stop the output of the selected="selected" attribute. Useful if you prefer to show the blank option on every page.
Can I make sure this plugin is available to my theme?
If your theme requires this plugin to be available it will work as a simple include. Just place the plugin into your theme directory and include dropdown-menus.php from your functions.php file.
If you place the plugin folder into your theme’s directory you would use the following code in your functions.php file:
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Dropdown Menus」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
0.1 | 0.2 | 0.3 | 0.4 | 0.5 | 0.6 | 0.7 | 0.8 | 0.9 | 1.0 | trunk |
延伸相關外掛(你可能也想知道)
Radio Buttons for Taxonomies 》此外掛可將預設的分類方塊替換為使用單選按鈕的自訂 metabox…從而限制每篇文章在該分類中只能選擇一個術語。, 插件選項頁面允許使用者選擇要切換為使用...。
Category Checklist Tree 》在文章編輯畫面中,儲存文章後,您會發現被勾選的類別顯示在頂部,破壞了分類層次結構。此外,此外掛還會自動滾動到第一個被勾選的類別。, 可以與自訂分類一...。
WP Admin UI 》WP Admin UI 讓您可以自訂、優化和管理:, , 登入畫面:自定義徽標、自定義背景圖像、自定義 CSS、在登出後將使用者重新導向到特定網址、為使用者禁用以電子...。
Fancy Admin UI 》WordPress 的管理介面主題非常好用,但是我們想更進一步。我們提供了一個乾淨的藍灰色預設主題,為用戶簡化界面,使界面更易於操作。您可以通過訪問「設置」>...。
Admin Bar Toggle 》Admin Bar toggle 外掛能夠在前端添加一個開關按鈕,以顯示/隱藏管理列。這樣做不會過於影響使用者體驗,同時還能充分利用管理列的方便功能。, , 預設情況下...。
Material Design Icons 》這款外掛可以在 WordPress 的頁面和文章中使用超過 1000 個 Material Design 圖示,使用者可以透過簡易的縮寫或 HTML 標籤插入圖示。, 功能, , 縮寫產生器 - ...。
Collapsible Categories in the Dashboard 》必須使用經典編輯器外掛 - 這是我對古騰堡的抱怨清單之一,因為它使用 REST API 來顯示分類,對用戶來說無法為分類框添加任何東西,從而使 wp_terms_checklis...。
Intuitive Category Checklist 》Intuitive Category Checklist 外掛可使在擁有大量類別和子類別的網站中更輕鬆地選擇分類。此外掛在快速編輯模式和完整文章模式下均可以使用。, 相關鏈結:外...。
Admin Branding and Tweaks 》這個外掛讓您可以輕鬆控制WordPress管理介面以及登入畫面的某些微調。, 啟用外掛之後,一個名為"代理品牌"的新菜單項目將被添加到"設定"菜單下面。, 功能列表...。
Admin Bar Wrap Fix 》當 WordPress 後台工具列項目過多時,此外掛可修正工具列的換行行為。保持整潔,避免淹出或溢出內容。, 在 GitHub 上查看更多詳情:https://github.com/KZeni...。
WP-Nicescroll 》這個外掛讓你可以在 WordPress 網站中加入 nicescroll 捲軸效果。。
Block Revealer 》強調您的區塊,停止到處點擊以找到它們。, 透過新的鍵盤快捷鍵 (Ctrl + Alt + R) 或頂部欄中的按鈕來顯示您的區塊。, 您也可以透過在按鈕上按右鍵來更改大綱...。
WordPress Plugin Framework Reloaded 》這是一個專為 WordPress 外掛開發者所製作的外掛程式。僅當某些其他外掛需要時,使用者才需要安裝它。因此,我們必須對 WordPress Plugin Framework Reloaded...。
Category Checklist Expander 》這個外掛會增加文章編輯畫面中「分類勾選清單」的高度,以顯示所有分類,讓您無須再捲動畫面!所有分類都會一覽無遺,如果您已經對不斷捲動畫面來找到正確的...。
Slider CAPTCHA 》Slider CAPTCHA 是一個 WordPress 外掛,可將 CAPTCHA 添加到您的 WordPress 表單,包括預設添加到模板的評論表單。您也可以將滑桿添加到註冊表單、密碼恢復...。