[wp-trac] [WordPress Trac] #34233: There is not a body class filter within the customizer.

WordPress Trac noreply at wordpress.org
Fri Oct 9 16:23:41 UTC 2015


#34233: There is not a body class filter within the customizer.
--------------------------+-----------------------------
 Reporter:  scofennell@…  |      Owner:
     Type:  enhancement   |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Customize     |    Version:  4.3.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 I'm hoping for a way to filter the body classes for the customizer panel.

 https://core.trac.wordpress.org/browser/trunk/src/wp-
 admin/customize.php#L112

 My particular use: I happen to have some custom controls on my widgets.
 I'd like to style them differently for superadmins versus other users.
 The rest of my application handles this as a body class, and does so in
 pure php via filtering.

 I know that's a pretty specific use, but I do find it surprising that
 there's not a filter here, given how useful it is in wp-admin and the
 front end.

 If it were to mimic admin body classes, where the classes are a new
 string, it would look something like

 {{{
 $customizer_body_classes = apply_filters( 'customizer_body_classes', '' );
 ?>
 <body class="<?php echo esc_attr( $body_class ); ?> <?php echo
 $customizer_body_classes; ?>">
 }}}

 I happen to prefer the front-end treatment, where existing classes are
 passed in as an array.  In that case it would look more like

 {{{
 $classes = array_map( 'sanitize_html_class', $classes );

 $classes = apply_filters( 'customizer_body_classes', $classes );

 array_unique( $classes );

 $classes_str = implode( ' ', $classes );

 <body class="<?php echo esc_attr( $classes_str ); ?> ">
 }}}

 I see some objections to a similar ticket here:
 https://core.trac.wordpress.org/ticket/32623

 But my request is slightly different because I'm not advocating that we
 re-use the admin_body_class fliter.  Rather, I'm suggesting a new filter
 just for the customizer body class.

 This is my first ticket!  I would be happy to attempt to make it my first
 patch as well if there is traction for this enhancement.

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


More information about the wp-trac mailing list