在 WordPress 上啟用 SyntaxHighlighter 這類程式碼高亮外掛後,每個程式碼區塊的右上角都會浮出一個小小的問號圖示,點下去會跳到外掛作者的說明頁。
這情形和 Popularity Contest 外掛類似,差別在於後者可以從後台把「Show the [?] help link」設為 No 直接關掉,而 SyntaxHighlighter 並沒有提供對應的設定選項。既然介面裡關不掉,就只能從樣式檔下手。
先到外掛的安裝目錄,路徑是:
wp-content/plugins/syntaxhighlighter/3.0.83/css/
其中的 3.0.83 是版本號,請依你實際安裝的版本進入對應資料夾,找到 shCore.css(或壓縮版的 shCore.min.css)並打開。
接著搜尋 .syntaxhighlighter .toolbar,你會看到類似這段規則:
.syntaxhighlighter .toolbar {
position: absolute !important;
right: 1px !important;
top: 1px !important;
width: 11px !important;
height: 11px !important;
font-size: 10px !important;
z-index: 10 !important;
}
在最尾端加上一行 display: none;:
.syntaxhighlighter .toolbar {
position: absolute !important;
right: 1px !important;
top: 1px !important;
width: 11px !important;
height: 11px !important;
font-size: 10px !important;
z-index: 10 !important;
display: none;
}
由於整個工具列被隱藏起來,右上角那個問號圖示自然就不會再出現了。
直接改外掛原始碼雖然有效,但外掛一更新,修改就會被覆蓋掉,得重做一次。更省事的寫法是把樣式寫進自己主題的 style.css(或子主題)裡:
.syntaxhighlighter .toolbar {
display: none !important;
}
因為主題樣式通常在後載入,加上 !important 就能蓋過外掛的規則,更新外掛也不受影響。
順帶一提,這個工具列除了問號之外,還包含「複製程式碼」、「列印」等按鈕。隱藏前先想想使用者是否還需要這些功能,如果只是單純閱讀的技術筆記,關掉通常沒問題。