WP指针不再显示

时间:2013-11-09 05:36:14

标签: wordpress pointers

我在我的代码中使用WP指针...指针在我解除它之后不再显示...我删除了我的插件并再次激活它但wp指针不再显示...如果我安装新的wordpress然后WP指针显示,但当我解雇它,然后它永远不会再来..有一种方式,当插件被激活时,wp指针再次出现......?这是我的代码

 function thsp_enqueue_pointer_script_style( $hook_suffix ) {
    // Assume pointer shouldn't be shown

$enqueue_pointer_script_style = false;

    // Get array list of dismissed pointers for current user and convert it to array

$dismissed_pointers = explode( ',', get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );

    // Check if our pointer is not among dismissed ones
if( !in_array( 'thsp_pointer', $dismissed_pointers ) ) {
    $enqueue_pointer_script_style = true;

    // Add footer scripts using callback function
    add_action( 'admin_print_footer_scripts', 'thsp_pointer_print_scripts' );
}

    // Enqueue pointer CSS and JS files, if needed
if( $enqueue_pointer_script_style ) {
    wp_enqueue_style( 'wp-pointer' );
    wp_enqueue_script( 'wp-pointer' );
}}add_action( 'admin_enqueue_scripts', 'thsp_enqueue_pointer_script_style' );

function thsp_pointer_print_scripts() {

$pointer_content  = "<h3>My New Plugin</h3>";
$pointer_content .= "<p>If you ever activated a plugin, then had no idea where its settings page is, raise your hand.</p>";
?>

<script type="text/javascript">
//<![CDATA[
jQuery(document).ready( function($) {
    $('#toplevel_page_settings').pointer({
        content:'<?php echo $pointer_content; ?>',
        position:{
            edge:   'left', // arrow direction
            align:  'center' // vertical alignment
            },
        pointerWidth:   350,
        close:function() {
            $.post( ajaxurl, {
                pointer: 'thsp_pointer', // pointer ID
                action: 'dismiss-wp-pointer'
                });
        }
    }).pointer('open');
});
//]]>
</script>

1 个答案:

答案 0 :(得分:0)

对于每个用户,子元组密钥wp_usermeta,已解散的指针存储在dismissed_wp_pointers表中。理想情况下,您的插件应该在停用时删除每个用户的指针ID(请参阅register_deactivation_hook),如果您希望它们在重新激活时重新出现。