plugins - How to create WordPress nonce in the foreach loop?

In my plugin list of email page, I need to remove email using Ajax call. I can delete it using Ajax call but how I can s

In my plugin list of email page, I need to remove email using Ajax call. I can delete it using Ajax call but how I can secure this ajax call?

I need to create nonce, right? Well, then how?

If I create a nonce inside foreach loop to the data attribute then it's showing me the same value!

foreach ( $results as $result ) {                   
    echo "<tr>";
        echo "<td>" . intval ( $count )."</td>";
        echo "<td>" . esc_html ( $result['email_address'] ) ."</td>";
        echo "<td>" . esc_html ( $result['added_time'] ) ."</td>";
        echo "<td><a href='?page=simple-newsletter-send-email&e=".esc_url ( $result['email_address'] ) ."'>Send Email</a> | <a href='#' data-nonce='".wp_create_nonce( 'sn_email_list_tab' )."' id='sn_remove_email'>Remove</a></td>";
    echo "</tr>";
    $count++;   
}

My questions are

1) what is the correct way to secure the ajax call in this scenario?
2) Is there any way to add a nonce to the ajax URL?

Email List with remove button:

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745296992a4621203.html

相关推荐

  • plugins - How to create WordPress nonce in the foreach loop?

    In my plugin list of email page, I need to remove email using Ajax call. I can delete it using Ajax call but how I can s

    9小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信