[wp-trac] [WordPress Trac] #51301: Add class field to wp_nonce_field

WordPress Trac noreply at wordpress.org
Sun Sep 13 18:21:25 UTC 2020


#51301: Add class field to wp_nonce_field
-------------------------+-----------------------------------
 Reporter:  dingo_d      |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  General      |    Version:
 Severity:  normal       |   Keywords:  has-patch 2nd-opinion
  Focuses:               |
-------------------------+-----------------------------------
 It would be great to have an optional `$class` field when generating nonce
 field. That way, when I'm referencing the field in my JS scripts, I can
 add a class that specifies that this field will be used in JS.

 For instance, every element that is used in JS script has a `js-` prefix.
 It's a common practice in JS development.

 So I'd have

 {{{#!php
 <?php
 wp_nonce_field('action', 'name', true, true, 'js-nonce-field');
 }}}

 The class field would be optional, and by default empty. If it would be
 empty it wouldn't be displayed.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/51301>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list