javascript - Wordpress 的指针
问题描述
我在我的子主题中的 functions.php 文件中插入了一个代码,以在 wordpress 管理区域中创建一个指针。代码是这样的:
add_action( 'admin_enqueue_scripts', 'my_admin_enqueue_scripts' );
function my_admin_enqueue_scripts() {
wp_enqueue_style( 'wp-pointer' );
wp_enqueue_script( 'wp-pointer' );
add_action( 'admin_print_footer_scripts', 'my_admin_print_footer_scripts' );
}
function my_admin_print_footer_scripts() {
$pointer_content = '<h3>Notice:</h3>';
$pointer_content .= '<p>This is a message that I will still customize"</strong>.</p>';
?>
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready( function($) {
$('#wp-admin-bar-breeze-topbar').pointer({
content: '<?php echo $pointer_content; ?>',
position: 'top',
close: function() {
// Once the close button is hit
}
}).pointer('open');
});
//]]>
</script>
<?php
}
该代码完美运行。我需要的是,当用户单击关闭按钮时,该指针不再出现。我应该在这里添加什么来解决这个问题吗?非常感谢!
解决方案
这应该得到它:
<script type="text/javascript">
jQuery(document).ready( function($) {
$('#wp-admin-bar-breeze-topbar').pointer({
content: '<?php echo $pointer_content; ?>',
position: 'top',
}
}).pointer('open');
$('#wp-admin-bar-breeze-topbar').click(function(){
$(this).remove();
});
});
</script>
推荐阅读
- javascript - iOS 上的缩放控件不再可见
- django - 如何在 Django 中管理快速增长的 postgres 表?
- encryption - Travis 使用 openssl 解密加密文件失败
- javascript - 如何设置来自 API 的 JSON 数据计数以允许列表中的那么多?
- node.js - 防止 express 中间件为相同的父路径执行
- c# - 如何从本地文件播放音乐
- android - TextView 中的偏移文本
- dialogflow-es - 如何在手机表面的谷歌操作中显示列表卡时删除简单响应
- terraform - 具有计数的资源的 Terraform 输出
- python - 如何将 iris.csv 转换为带有数据和目标的 sci kit 格式?