php推送示例wordpress,给WordPress的编辑后台添加提示框的代码实例分享
WordPress 3.5 新添加了一個提示框功能,可以創建一個提示框,然后指向任何元素,比如下邊的例子:
本文就來教你怎么創建一個這樣的提示框。
首先需要添加提示框
的腳本,這樣才能使用提示框的 JS 方法。
//掛載提示框腳本
function Bing_admin_pointer_enqueue_scripts(){
wp_enqueue_style( 'wp-pointer' );
wp_enqueue_script( 'wp-pointer' );
}
add_action( 'admin_enqueue_scripts', 'Bing_admin_pointer_enqueue_scripts' );
然后使用 pointer() 方法創建一個簡單的提示框:
/**
*WordPress 后臺添加提示框
*http://www.endskin.com/admin-help-box/
*/
function Bing_add_pointer_scripts(){
$content = '
請設置主題
';$content .= '
請為新主題進行簡單的配置!';
?>
//
jQuery(document).ready(function($){
$('#menu-appearance').pointer({//可以指向任何元素
content: '<?php echo $content; ?>',
position: {
edge: 'left',
align: 'center'
},
close: function(){
//提示框打開之后做的事情
}
}).pointer('open');
});
//]]>
}
add_action( 'admin_print_footer_scripts', 'Bing_add_pointer_scripts' );
綜合代碼:
/**
*WordPress 后臺添加提示框
*http://www.endskin.com/admin-help-box/
*/
function Bing_add_pointer_scripts(){
$content = '
請設置主題
';$content .= '
請為新主題進行簡單的配置!';
?>
//
jQuery(document).ready(function($){
$('#menu-appearance').pointer({//可以指向任何元素
content: '<?php echo $content; ?>',
position: {
edge: 'left',
align: 'center'
},
close: function(){
//提示框打開之后做的事情
}
}).pointer('open');
});
//]]>
}
add_action( 'admin_print_footer_scripts', 'Bing_add_pointer_scripts' );
//掛載提示框腳本
function Bing_admin_pointer_enqueue_scripts(){
wp_enqueue_style( 'wp-pointer' );
wp_enqueue_script( 'wp-pointer' );
}
add_action( 'admin_enqueue_scripts', 'Bing_admin_pointer_enqueue_scripts' );
總結
以上是生活随笔為你收集整理的php推送示例wordpress,给WordPress的编辑后台添加提示框的代码实例分享的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 由 go orm 引发的探索
- 下一篇: 动态规划算法php,php算法学习之动态