Skip to content

Commit 12b1f63

Browse files
committed
HTML API: Fix code style issues in WP_HTML_Template
Apply WordPress Coding Standards formatting: - Align equals signs in assignment blocks - Format multi-line function calls (strtr) per PEAR standard
1 parent fc75174 commit 12b1f63

1 file changed

Lines changed: 24 additions & 18 deletions

File tree

src/wp-includes/html-api/class-wp-html-template.php

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private function compile(): void {
8989

9090
$this->compiled = array();
9191
$this->edits = array();
92-
$this->placeholder_names = array();
92+
$this->placeholder_names = array();
9393

9494
$processor = ( new class( '', WP_HTML_Processor::CONSTRUCTOR_UNLOCK_CODE ) extends WP_HTML_Processor {
9595
public function get_html(): string {
@@ -164,7 +164,7 @@ public function get_tag_attributes(): array {
164164
$this->compiled[ $placeholder ]['offsets'][] = array( $start, $length );
165165

166166
// New: append placeholder edit and register name.
167-
$this->edits[] = array(
167+
$this->edits[] = array(
168168
'start' => $start,
169169
'length' => $length,
170170
'placeholder' => $placeholder,
@@ -212,13 +212,16 @@ public function get_tag_attributes(): array {
212212
$seg_length = $match_start - $last_offset;
213213
$original = substr( $html, $last_offset, $seg_length );
214214
$decoded = WP_HTML_Decoder::decode_attribute( $original );
215-
$escaped = strtr( $decoded, array(
216-
'&' => '&',
217-
'<' => '&lt;',
218-
'>' => '&gt;',
219-
"'" => '&apos;',
220-
'"' => '&quot;',
221-
) );
215+
$escaped = strtr(
216+
$decoded,
217+
array(
218+
'&' => '&amp;',
219+
'<' => '&lt;',
220+
'>' => '&gt;',
221+
"'" => '&apos;',
222+
'"' => '&quot;',
223+
)
224+
);
222225
// Only add edit if escaping actually changes the text.
223226
if ( $escaped !== $original ) {
224227
$this->edits[] = array(
@@ -242,7 +245,7 @@ public function get_tag_attributes(): array {
242245
$this->compiled[ $placeholder ]['offsets'][] = array( $match_start, $match_length );
243246

244247
// New: append placeholder edit and register name.
245-
$this->edits[] = array(
248+
$this->edits[] = array(
246249
'start' => $match_start,
247250
'length' => $match_length,
248251
'placeholder' => $placeholder,
@@ -259,13 +262,16 @@ public function get_tag_attributes(): array {
259262
$seg_length = $end - $last_offset;
260263
$original = substr( $html, $last_offset, $seg_length );
261264
$decoded = WP_HTML_Decoder::decode_attribute( $original );
262-
$escaped = strtr( $decoded, array(
263-
'&' => '&amp;',
264-
'<' => '&lt;',
265-
'>' => '&gt;',
266-
"'" => '&apos;',
267-
'"' => '&quot;',
268-
) );
265+
$escaped = strtr(
266+
$decoded,
267+
array(
268+
'&' => '&amp;',
269+
'<' => '&lt;',
270+
'>' => '&gt;',
271+
"'" => '&apos;',
272+
'"' => '&quot;',
273+
)
274+
);
269275
// Only add edit if escaping actually changes the text.
270276
if ( $escaped !== $original ) {
271277
$this->edits[] = array(
@@ -372,7 +378,7 @@ public function bind( array $replacements ): static {
372378
}
373379
}
374380

375-
$new = new static( $this->template_string, $replacements );
381+
$new = new static( $this->template_string, $replacements );
376382
$new->compiled = $this->compiled;
377383
$new->edits = $this->edits;
378384
$new->placeholder_names = $this->placeholder_names;

0 commit comments

Comments
 (0)