Ticket #50867: 50867.2.diff
File 50867.2.diff, 4.6 KB (added by , 4 years ago) |
---|
-
src/wp-includes/class-html-builder-dangerous-html.php
1 <?php 2 3 class WP_HTML_Builder_Dangerous_HTML extends WP_HTML_Builder_Node { 4 public function __construct( $html ) { 5 $this->html = $html; 6 } 7 8 public function to_html() { 9 return $this->html; 10 } 11 } -
src/wp-includes/class-html-builder-element.php
Property changes on: src/wp-includes/class-html-builder-dangerous-html.php ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
1 <?php 2 3 class WP_HTML_Builder_Element extends WP_HTML_Builder_Node { 4 protected $tag_name; 5 6 protected $attributes = array(); 7 8 protected $children = array(); 9 10 public function __construct( $tag_name, $attributes = null, $children = null ) { 11 $this->tag_name = $tag_name; 12 13 if ( is_array( $attributes ) ) { 14 $this->attributes = $attributes; 15 } elseif ( $attributes ) { 16 $this->attributes = array( $attributes ); 17 } 18 19 if ( is_array( $children ) ) { 20 $this->children = $children; 21 } elseif ( $children ) { 22 $this->children = array( $children ); 23 } 24 } 25 26 public function to_html() { 27 $html = '<' . esc_html( $this->tag_name ); 28 29 if ( ! empty( $this->attributes ) ) { 30 foreach ( $this->attributes as $attribute_name => $attribute_value ) { 31 if ( is_int( $attribute_name ) ) { 32 $html .= ' ' . esc_html( $attribute_value ); 33 } else { 34 $html .= sprintf( 35 ' %s="%s"', 36 esc_html( $attribute_name ), 37 esc_attr( $attribute_value ) 38 ); 39 } 40 } 41 } 42 43 if ( empty( $this->children ) ) { 44 $html .= ' />'; 45 } else { 46 $html .= '>'; 47 48 foreach ( $this->children as $child ) { 49 if ( $child instanceof WP_HTML_Builder_Node ) { 50 $html .= $child->to_html(); 51 } else { 52 $html .= esc_html( $child ); 53 } 54 } 55 56 $html .= '</' . esc_html( $this->tag_name ) . '>'; 57 } 58 59 return $html; 60 } 61 } -
src/wp-includes/class-html-builder-node.php
Property changes on: src/wp-includes/class-html-builder-element.php ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
1 <?php 2 3 abstract class WP_HTML_Builder_Node { 4 abstract public function to_html(); 5 6 public function __toString() { 7 return $this->to_html(); 8 } 9 } -
src/wp-includes/formatting.php
Property changes on: src/wp-includes/class-html-builder-node.php ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
6060 6060 6061 6061 return $color; 6062 6062 } 6063 6064 function wp_el( $tag_name, $attributes = null, $children = null ) { 6065 return new WP_HTML_Builder_Element( $tag_name, $attributes, $children ); 6066 } 6067 6068 function wp_dangerous_html( $html ) { 6069 return new WP_HTML_Builder_Dangerous_HTML( $html ); 6070 } 6071 6072 function wp_classnames( ...$arguments ) { 6073 $classes = array(); 6074 6075 foreach ( $arguments as $argument ) { 6076 if ( is_array( $argument ) ) { 6077 foreach ( $argument as $key => $value ) { 6078 if ( is_int( $key ) ) { 6079 $classes[] = $value; 6080 } elseif ( $value ) { 6081 $classes[] = $key; 6082 } 6083 } 6084 } else { 6085 $classes[] = $argument; 6086 } 6087 } 6088 6089 return implode( ' ', $classes ); 6090 } -
src/wp-settings.php
287 287 require ABSPATH . WPINC . '/blocks.php'; 288 288 require ABSPATH . WPINC . '/blocks/index.php'; 289 289 require ABSPATH . WPINC . '/block-patterns.php'; 290 require ABSPATH . WPINC . '/class-html-builder-node.php'; 291 require ABSPATH . WPINC . '/class-html-builder-dangerous-html.php'; 292 require ABSPATH . WPINC . '/class-html-builder-element.php'; 290 293 291 294 $GLOBALS['wp_embed'] = new WP_Embed(); 292 295