File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -128,21 +128,27 @@ static function ( DOMNode $child ) {
128128 }
129129
130130 /**
131- * Replace the node's parent with itself if the parent is a <p> tag, has no attributes and has no other children.
131+ * Replace an element's parent with itself if the parent is a <p> tag which has no attributes and has no other children.
132+ *
132133 * This usually happens while `wpautop()` processes the element.
133134 *
134135 * @since 2.0.6
136+ * @see AMP_Tag_And_Attribute_Sanitizer::remove_node()
135137 *
136138 * @param DOMElement $node Node.
137139 */
138140 protected function unwrap_p_element ( DOMElement $ node ) {
139141 $ parent_node = $ node ->parentNode ;
140-
141- if ( $ parent_node instanceof DOMElement && 'p ' === $ parent_node ->tagName && false === $ parent_node ->hasAttributes () ) {
142- $ child_element_count = count ( $ this ->get_child_elements ( $ parent_node ) );
143- if ( 1 === $ child_element_count ) {
144- $ parent_node ->parentNode ->replaceChild ( $ node , $ parent_node );
145- }
142+ if (
143+ $ parent_node instanceof DOMElement
144+ &&
145+ 'p ' === $ parent_node ->tagName
146+ &&
147+ false === $ parent_node ->hasAttributes ()
148+ &&
149+ 1 === count ( $ this ->get_child_elements ( $ parent_node ) )
150+ ) {
151+ $ parent_node ->parentNode ->replaceChild ( $ node , $ parent_node );
146152 }
147153 }
148154}
You can’t perform that action at this time.
0 commit comments