問題描述
我最近升級到 3.3.1 版本,並注意到一個很好的功能,對我們的 non-Wordpress 精明的客戶將是偉大的 – 建立一個如何使用 Wordpress 的旅程。
我已經使用了 Yoast SEO 外掛很長一段時間,他們新增了一個旅遊功能,當您點選下一個按鈕時,它會遍歷各種功能 (見螢幕截圖):
有可能建立一個自定義的 WordPress 瀏覽如何新增頁面,帖子等,並建立我們自己的幫助內容去與它。
我有一套我傾向於使用的標準外掛,所以旅遊 (如果可能的話) 需要跳過標準的 Wordpress 設定以及所有不同的外掛。
更新:
我在網路上挖了一下,找到了以下程式碼。這將建立一個可以放置自定義內容的一個指標。唯一的問題是彈出視窗出現每次重新載入,即使它被解僱 (有一種方法來提高這個的可用性),也是一個視窗而不是旅遊。
只需使用 Firebug 來找到要附加指標的 div 。
/*
Display custom WordPress Dashboard Pointers alerts
Usage: Modify the $pointer_content message to the message you wished displayed
*/
add_action('admin_enqueue_scripts', 'enqueue_custom_admin_scripts');
function enqueue_custom_admin_scripts() {
wp_enqueue_style('wp-pointer');
wp_enqueue_script('wp-pointer');
add_action('admin_print_footer_scripts', 'custom_print_footer_scripts' );
}
function custom_print_footer_scripts() {
$pointer_content = '<h3>The Works http://www.teamworksdesign.com</h3>';
$pointer_content .= '<p>Welcome to your custom WordPress installation. Please navigate to the settings page to change your site preferences</p>';
?>
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready( function($) {
$('#menu-posts-events').pointer({
content: '<?php echo $pointer_content; ?>',
position: 'left',
close: function() {
// This function is fired when you click the close button
}
}).pointer('open');
});
//]]>
</script>
<?php
}
最佳解決方案
如果你看這個外掛,我寫了一個使用指標的演示,你會看到如何建立它們並使它們正確關閉:
https://github.com/Tarendai/WP-Pointer-Pointers
此外掛建立’pointer pointers’:
次佳解決方案
WordPress 指標 API 僅供核心使用,有些事情可能會在 API 中更改,並且可能導致您的外掛網站中斷或錯誤。您應該避免使用,直到 API 將被標準化並準備外掛/主題使用。
康斯坦丁·科夫申寧 (Konstantin Kovshenin) 撰寫了關於指標的介紹性文章,您可能會發現有趣的閱讀。 Introducing Pointers in WordPress 3.3
參考文獻
注:本文內容整合自 Google/Baidu/Bing 輔助翻譯的英文資料結果。如果您對結果不滿意,可以加入我們改善翻譯效果:薇曉朵技術論壇。

