WordPress.org

Ready to get started?Download WordPress

Forums

Custom List Table Example
Adding nonce fields (4 posts)

  1. ianhaycox
    Member
    Posted 2 years ago #

    Firstly a big thank you for the example code. It's saved me hours of coding pagination, formatting etc. and keeps the tables looking consistent with WP admin

    I'm not sure if it's necessary, but I added a

    wp_nonce_url(..., 'delete')

    call around the delete URL where actions are setup in the column_name() function. Then I added a check in my delete code to

    check_admin_referer('delete');

    to verify the nonce.

    I also noticed the bulk delete automatically added a nonce argument to the URL so also added a check delete bulk deletion,

    check_admin_referer('bulk-' . $this->_args['plurals');

    Hopefully this is the correct thing to do. Can you confirm ?

    Thanks,

    Ian.

    http://wordpress.org/extend/plugins/custom-list-table-example/

  2. Matt van Andel
    Member
    Plugin Author

    Posted 2 years ago #

    I usually use wp_verify_nonce() to verify the nonce (returns a boolean, which I can handle explicitly), but check_admin_referer() will also work (one difference being that it calls die() if not executed from an admin page, as opposed to simply returning false).

    Everything should work perfectly as you've written it.

  3. michalskiluc
    Member
    Posted 2 years ago #

    Where did you used these functions ?

    Cheers
    Luc

  4. Brent Christensen
    Member
    Posted 1 year ago #

    @michalskiluc they're talking about the WP native List tables class for generating the tables you see in the WP admin, for example: the list of all posts ( /wp-admin/edit.php ).

    You can learn more about list tables here: http://codex.wordpress.org/Class_Reference/WP_List_Table

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic