[wp-trac] [WordPress Trac] #57420: Add filter for wp_theme_get_element_class_name

WordPress Trac noreply at wordpress.org
Wed Jan 4 10:09:25 UTC 2023


#57420: Add filter for wp_theme_get_element_class_name
--------------------------+-----------------------------
 Reporter:  benjgrolleau  |      Owner:  (none)
     Type:  enhancement   |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Editor        |    Version:
 Severity:  minor         |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Hello,

 I think it would be a good idea to add a filter to the
 wp_theme_get_element_class_name or WP_Theme_JSON::get_element_class_name
 function return. This would allow to add classes programmatically to the
 elements.

 It could be something like that :


 {{{#!php
 <?php
 public static function get_element_class_name( $element ) {
         $class_name = '';

         if ( array_key_exists( $element,
 static::__EXPERIMENTAL_ELEMENT_CLASS_NAMES ) ) {
                 $class_name = static::__EXPERIMENTAL_ELEMENT_CLASS_NAMES[
 $element ];
         }

         return apply_filters( "element_{$element}class_name", $class_name
 );

         // Or another option, without dynamic part.
         return apply_filters( "element_class_name", $class_name, $element
 );


 }
 }}}



 Have a nice day.

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


More information about the wp-trac mailing list