問題描述
我最近升級到 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 輔助翻譯的英文資料結果。如果您對結果不滿意,可以加入我們改善翻譯效果:薇曉朵技術論壇。

