[wp-trac] [WordPress Trac] #28477: New Built-in Customizer Control Types

WordPress Trac noreply at wordpress.org
Thu Jun 12 15:43:24 UTC 2014


#28477: New Built-in Customizer Control Types
------------------------------------+---------------------------------
 Reporter:  celloexpressions        |       Owner:
     Type:  enhancement             |      Status:  new
 Priority:  normal                  |   Milestone:  Awaiting Review
Component:  Appearance              |     Version:  3.4
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |     Focuses:  ui, administration
------------------------------------+---------------------------------

Comment (by celloexpressions):

 Replying to [comment:3 westonruter]:
 > For feedback, what if instead of a `$numerical` property, it instead
 implemented an array of `input` attrbutes (e.g.`$input_attrs`), and then
 all provided attributes would get serialized and inserted into the
 `<input>` element. This would make it easy to add support for `pattern`
 and other attributes.

 Great idea! [attachment:28477.2.diff] adds the `textarea` type and generic
 handling for arbitrary types and input attributes. I put in a whitelist of
 allowed attributes, not sure if that's needed. I'd rather not do that for
 input types, as that might imply explicit support for those (in terms of
 styling, supporting JS, etc.).

 In terms of validation, I don't think we can do anything here since that's
 up to the setting (other than maybe making additional functions
 available).

 Usage (not that you would ever use all of these attrs together):
 {{{
 $wp_customize->add_control( $setting_id, array(
         'label'     => $label,
         'section'   => $section_id,
         'type'      => $type,
         'input_attrs' => array(
                 'min' => 0,
                 'max' => 10,
                 'step' => 2,
                 'class' => 'test-class test',
                 'style' => 'width: 50%;',
                 'placeholder' => __( 'Placeholder' ),
                 'pattern' => '[a-zA-Z0-9]+',
         ),
 ) );
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/28477#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list