Skip to content

Commit 5d12ef7

Browse files
committed
Add docs for requirement for valid HTML passed into methods
1 parent 38a4c6b commit 5d12ef7

File tree

3 files changed

+32
-22
lines changed

3 files changed

+32
-22
lines changed

plugins/optimization-detective/class-od-html-tag-processor.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -702,29 +702,33 @@ public function is_admin_bar(): bool {
702702
}
703703

704704
/**
705-
* Append HTML to the HEAD.
705+
* Appends raw HTML to the HEAD.
706706
*
707-
* The provided HTML must be valid! No validation is performed.
707+
* The provided HTML must be valid for insertion in the HEAD. No validation is currently performed. However, in the
708+
* future the HTML Processor may be used to ensure the validity of the provided HTML. At that time, when invalid
709+
* HTML is provided, this method may emit a `_doing_it_wrong()` warning.
708710
*
709711
* @since 0.4.0
710712
*
711-
* @param string $html HTML to inject.
713+
* @param string $raw_html Raw HTML to inject.
712714
*/
713-
public function append_head_html( string $html ): void {
714-
$this->buffered_text_replacements[ self::END_OF_HEAD_BOOKMARK ][] = $html;
715+
public function append_head_html( string $raw_html ): void {
716+
$this->buffered_text_replacements[ self::END_OF_HEAD_BOOKMARK ][] = $raw_html;
715717
}
716718

717719
/**
718-
* Append HTML to the BODY.
720+
* Appends raw HTML to the BODY.
719721
*
720-
* The provided HTML must be valid! No validation is performed.
722+
* The provided HTML must be valid for insertion in the BODY. No validation is currently performed. However, in the
723+
* future the HTML Processor may be used to ensure the validity of the provided HTML. At that time, when invalid
724+
* HTML is provided, this method may emit a `_doing_it_wrong()` warning.
721725
*
722726
* @since 0.4.0
723727
*
724-
* @param string $html HTML to inject.
728+
* @param string $raw_html Raw HTML to inject.
725729
*/
726-
public function append_body_html( string $html ): void {
727-
$this->buffered_text_replacements[ self::END_OF_BODY_BOOKMARK ][] = $html;
730+
public function append_body_html( string $raw_html ): void {
731+
$this->buffered_text_replacements[ self::END_OF_BODY_BOOKMARK ][] = $raw_html;
728732
}
729733

730734
/**

plugins/optimization-detective/class-od-tag-visitor-context.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function track_tag(): void {
110110
* @throws Error When property is unknown.
111111
*/
112112
public function __get( string $name ) {
113-
// Note that there is intentionally not a case for 'visited_tag_state'.
113+
// Note: There is intentionally not a 'visited_tag_state' case to expose $this->visited_tag_state.
114114
switch ( $name ) {
115115
case 'processor':
116116
return $this->processor;

plugins/optimization-detective/class-od-template-optimization-context.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,29 +101,35 @@ public function __construct( OD_HTML_Tag_Processor $processor, OD_URL_Metric_Gro
101101
}
102102

103103
/**
104-
* Append HTML to the HEAD.
104+
* Appends raw HTML to the HEAD.
105105
*
106-
* The provided HTML must be valid! No validation is performed.
106+
* The provided HTML must be valid for insertion in the HEAD. No validation is currently performed. However, in the
107+
* future the HTML Processor may be used to ensure the validity of the provided HTML. At that time, when invalid
108+
* HTML is provided, this method may emit a `_doing_it_wrong()` warning.
107109
*
108110
* @since n.e.x.t
111+
* @see OD_HTML_Tag_Processor::append_head_html()
109112
*
110-
* @param non-empty-string $html HTML to inject.
113+
* @param string $raw_html Raw HTML to inject.
111114
*/
112-
public function append_head_html( string $html ): void {
113-
$this->processor->append_head_html( $html );
115+
public function append_head_html( string $raw_html ): void {
116+
$this->processor->append_head_html( $raw_html );
114117
}
115118

116119
/**
117-
* Append HTML to the BODY.
120+
* Appends raw HTML to the BODY.
118121
*
119-
* The provided HTML must be valid! No validation is performed.
122+
* The provided HTML must be valid for insertion in the BODY. No validation is currently performed. However, in the
123+
* future the HTML Processor may be used to ensure the validity of the provided HTML. At that time, when invalid
124+
* HTML is provided, this method may emit a `_doing_it_wrong()` warning.
120125
*
121126
* @since n.e.x.t
127+
* @see OD_HTML_Tag_Processor::append_body_html()
122128
*
123-
* @param non-empty-string $html HTML to inject.
129+
* @param string $raw_html HTML to inject.
124130
*/
125-
public function append_body_html( string $html ): void {
126-
$this->processor->append_body_html( $html );
131+
public function append_body_html( string $raw_html ): void {
132+
$this->processor->append_body_html( $raw_html );
127133
}
128134

129135
/**
@@ -137,7 +143,7 @@ public function append_body_html( string $html ): void {
137143
* @throws Error When property is unknown.
138144
*/
139145
public function __get( string $name ) {
140-
// Note: The $processor is intentionally not exposed.
146+
// Note: There is intentionally not a 'processor' case to expose $this->processor.
141147
switch ( $name ) {
142148
case 'url_metrics_id':
143149
return $this->url_metrics_id;

0 commit comments

Comments
 (0)