Skip to content

Commit 1b6e6a7

Browse files
committed
Use OptionRender option fns in views
This doesn't change any behavior but just lets Plugin Check Plugin verify that we are escaping the echoed HTML.
1 parent 60a767f commit 1b6e6a7

File tree

4 files changed

+65
-56
lines changed

4 files changed

+65
-56
lines changed

views/advanced-options-page.php

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@
1010
*/
1111

1212
/**
13-
* @var array<string, mixed> $options
13+
* @var array<string, \StaticDeploy\OptionData> $options
1414
*/
1515
$options = $view['options'];
1616

17-
$row = function ( $name ) use ( $options ) {
18-
$opt = $options[ $name ];
19-
return '<tr><td style="width: 50%">' . OptionRenderer::optionLabel( $opt, true ) .
20-
'</td><td>' . OptionRenderer::optionInput( $opt ) . '</td></tr>';
21-
}
22-
17+
$row = function ( $option_name ) use ( $options ) {
18+
$option_data = $options[ $option_name ];
19+
echo '<tr><td style="width: 50%">';
20+
OptionRenderer::echoLabel( $option_data, true );
21+
echo '</td><td>';
22+
OptionRenderer::echoInput( $option_data );
23+
echo '</td></tr>';
24+
};
2325
?>
2426

2527
<div class="wrap">
@@ -34,7 +36,7 @@
3436

3537
<table class="widefat striped">
3638
<tbody>
37-
<?php echo $row( 'maxLogRows' ); ?>
39+
<?php $row( 'maxLogRows' ); ?>
3840
</tbody>
3941
</table>
4042

@@ -44,7 +46,7 @@
4446

4547
<table class="widefat striped">
4648
<tbody>
47-
<?php echo $row( 'pathsToIgnore' ); ?>
49+
<?php $row( 'pathsToIgnore' ); ?>
4850
</tbody>
4951
</table>
5052

@@ -54,8 +56,8 @@
5456

5557
<table class="widefat striped">
5658
<tbody>
57-
<?php echo $row( 'crawledSitePath' ); ?>
58-
<?php echo $row( 'crawlConcurrency' ); ?>
59+
<?php $row( 'crawledSitePath' ); ?>
60+
<?php $row( 'crawlConcurrency' ); ?>
5961
</tbody>
6062
</table>
6163

@@ -65,9 +67,9 @@
6567

6668
<table class="widefat striped">
6769
<tbody>
68-
<?php echo $row( 'processedSitePath' ); ?>
69-
<?php echo $row( 'skipURLRewrite' ); ?>
70-
<?php echo $row( 'hostsToRewrite' ); ?>
70+
<?php $row( 'processedSitePath' ); ?>
71+
<?php $row( 'skipURLRewrite' ); ?>
72+
<?php $row( 'hostsToRewrite' ); ?>
7173
</tbody>
7274
</table>
7375

@@ -77,7 +79,7 @@
7779

7880
<table class="widefat striped">
7981
<tbody>
80-
<?php echo $row( 'adminBarMenuItems' ); ?>
82+
<?php $row( 'adminBarMenuItems' ); ?>
8183
</tbody>
8284
</table>
8385

views/jobs-page.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
$jobs = $view['jobs'];
1717

1818
/**
19-
* @var array<string, mixed> $options
19+
* @var array<string, \StaticDeploy\OptionData> $options
2020
*/
2121
$options = $view['jobOptions'];
2222

23-
$input = ( fn( $name ): string => OptionRenderer::optionInput( $options[ $name ] ) );
24-
$label = ( fn( $name, $description = false ): string => OptionRenderer::optionLabel( $options[ $name ], $description ) );
23+
$input = ( fn( string $name ) => OptionRenderer::echoInput( $options[ $name ] ) );
2524

25+
$label = ( fn( string $name, bool $description = false ) => OptionRenderer::echoLabel( $options[ $name ], $description ) );
2626
?>
2727

2828
<div class="wrap">
@@ -50,24 +50,24 @@
5050
<tbody>
5151
<tr>
5252
<td style="width:33%;">
53-
<?php echo $label( 'queueJobOnPostSave' ); ?>
53+
<?php $label( 'queueJobOnPostSave' ); ?>
5454
</td>
5555
<td>
5656
<?php echo $options['queueJobOnPostSave']->option_spec->description; ?>
5757
</td>
5858
<td>
59-
<?php echo $input( 'queueJobOnPostSave' ); ?>
59+
<?php $input( 'queueJobOnPostSave' ); ?>
6060
</td>
6161
</tr>
6262
<tr>
6363
<td style="width:33%;">
64-
<?php echo $label( 'queueJobOnPostDelete' ); ?>
64+
<?php $label( 'queueJobOnPostDelete' ); ?>
6565
</td>
6666
<td>
6767
<?php echo $options['queueJobOnPostDelete']->option_spec->description; ?>
6868
</td>
6969
<td>
70-
<?php echo $input( 'queueJobOnPostDelete' ); ?>
70+
<?php $input( 'queueJobOnPostDelete' ); ?>
7171
</td>
7272
</tr>
7373
</tbody>
@@ -80,33 +80,33 @@
8080
<thead>
8181
<tr>
8282
<td style="text-align:center;">
83-
<?php echo $label( 'autoJobQueueDetection' ); ?>
83+
<?php $label( 'autoJobQueueDetection' ); ?>
8484
</td>
8585
<td style="text-align:center;">
86-
<?php echo $label( 'autoJobQueueCrawling' ); ?>
86+
<?php $label( 'autoJobQueueCrawling' ); ?>
8787
</td>
8888
<td style="text-align:center;">
89-
<?php echo $label( 'autoJobQueuePostProcessing' ); ?>
89+
<?php $label( 'autoJobQueuePostProcessing' ); ?>
9090
</td>
9191
<td style="text-align:center;">
92-
<?php echo $label( 'autoJobQueueDeployment' ); ?>
92+
<?php $label( 'autoJobQueueDeployment' ); ?>
9393
</td>
9494
<td style="text-align:center;">
95-
<?php echo $label( 'autoJobQueueDirectDeploy' ); ?>
95+
<?php $label( 'autoJobQueueDirectDeploy' ); ?>
9696
</td>
9797
<td style="text-align:center;">
98-
<?php echo $label( 'autoJobQueueDirectDeployPost' ); ?>
98+
<?php $label( 'autoJobQueueDirectDeployPost' ); ?>
9999
</td>
100100
</tr>
101101
</thead>
102102
<tbody>
103103
<tr style="text-align:center;">
104-
<td><?php echo $input( 'autoJobQueueDetection' ); ?></td>
105-
<td><?php echo $input( 'autoJobQueueCrawling' ); ?></td>
106-
<td><?php echo $input( 'autoJobQueuePostProcessing' ); ?></td>
107-
<td><?php echo $input( 'autoJobQueueDeployment' ); ?></td>
108-
<td><?php echo $input( 'autoJobQueueDirectDeploy' ); ?></td>
109-
<td><?php echo $input( 'autoJobQueueDirectDeployPost' ); ?></td>
104+
<td><?php $input( 'autoJobQueueDetection' ); ?></td>
105+
<td><?php $input( 'autoJobQueueCrawling' ); ?></td>
106+
<td><?php $input( 'autoJobQueuePostProcessing' ); ?></td>
107+
<td><?php $input( 'autoJobQueueDeployment' ); ?></td>
108+
<td><?php $input( 'autoJobQueueDirectDeploy' ); ?></td>
109+
<td><?php $input( 'autoJobQueueDirectDeployPost' ); ?></td>
110110
</tr>
111111
</tbody>
112112
</table>
@@ -117,7 +117,7 @@
117117
<tbody>
118118
<tr>
119119
<td style="width: 50%">
120-
<?php echo $label( 'processQueueInterval', true ); ?>
120+
<?php $label( 'processQueueInterval', true ); ?>
121121
<p><i>If WP-Cron is not expected to be triggered by site visitors, you can also call `wp-cron.php` directly, run the WP-CLI command `wp static-deploy process_queue` or call the hook `<?php echo Controller::getHookName( 'process_queue' ); ?>` from within your own theme or plugin.</i></p>
122122
</td>
123123
<td>
@@ -143,7 +143,7 @@
143143
</tr>
144144
<tr>
145145
<td style="width: 50%">
146-
<?php echo $label( 'processQueueImmediately', true ); ?>
146+
<?php $label( 'processQueueImmediately', true ); ?>
147147
</td>
148148
<td>
149149
<select

views/options-page.php

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@
1010
*/
1111

1212
/**
13-
* @var array<string, mixed> $options
13+
* @var array<string, \StaticDeploy\OptionData> $options
1414
*/
1515
$options = $view['options'];
1616

17-
$row = function ( $name ) use ( $options ) {
18-
$opt = $options[ $name ];
19-
return '<tr><td style="width: 50%">' . OptionRenderer::optionLabel( $opt, true ) .
20-
'</td><td>' . OptionRenderer::optionInput( $opt ) . '</td></tr>';
21-
}
22-
17+
$row = function ( $option_name ) use ( $options ) {
18+
$option_data = $options[ $option_name ];
19+
echo '<tr><td style="width: 50%">';
20+
OptionRenderer::echoLabel( $option_data, true );
21+
echo '</td><td>';
22+
OptionRenderer::echoInput( $option_data );
23+
echo '</td></tr>';
24+
};
2325
?>
2426

2527
<div class="wrap">
@@ -42,35 +44,35 @@
4244
</tr>
4345
</thead>
4446
<tbody>
45-
<?php echo $row( 'detectCustomPostTypes' ); ?>
46-
<?php echo $row( 'detectPages' ); ?>
47-
<?php echo $row( 'detectPosts' ); ?>
48-
<?php echo $row( 'detectUploads' ); ?>
47+
<?php $row( 'detectCustomPostTypes' ); ?>
48+
<?php $row( 'detectPages' ); ?>
49+
<?php $row( 'detectPosts' ); ?>
50+
<?php $row( 'detectUploads' ); ?>
4951
</tbody>
5052
</table>
5153

5254
<h2>Crawling Options</h2>
5355

5456
<table class="widefat striped">
5557
<tbody>
56-
<?php echo $row( 'basicAuthUser' ); ?>
57-
<?php echo $row( 'basicAuthPassword' ); ?>
58+
<?php $row( 'basicAuthUser' ); ?>
59+
<?php $row( 'basicAuthPassword' ); ?>
5860
</tbody>
5961
</table>
6062

6163
<h2>Post-processing Options</h2>
6264

6365
<table class="widefat striped">
6466
<tbody>
65-
<?php echo $row( 'deploymentURL' ); ?>
67+
<?php $row( 'deploymentURL' ); ?>
6668
</tbody>
6769
</table>
6870

6971
<h2>Deployment Options</h2>
7072

7173
<table class="widefat striped">
7274
<tbody>
73-
<?php echo $row( 'completionEmail' ); ?>
75+
<?php $row( 'completionEmail' ); ?>
7476
<tr>
7577
<td style="width:50%;">
7678
<?php echo OptionRenderer::optionLabel( $options['completionWebhook'] ); ?>

views/render-options-page.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,20 @@
88
* @var mixed[] $view
99
*/
1010

11+
/**
12+
* @var array<string, \StaticDeploy\OptionData> $options
13+
*/
1114
$options = $view['options'];
1215

1316
$row = function ( $option_name ) use ( $options ) {
14-
$opt = $options[ $option_name ];
15-
return '<tr><td style="width: 50%">' . OptionRenderer::optionLabel( $opt, true ) .
16-
'</td><td>' . OptionRenderer::optionInput( $opt ) . '</td></tr>';
17+
$option_data = $options[ $option_name ];
18+
echo '<tr><td style="width: 50%">';
19+
OptionRenderer::echoLabel( $option_data, true );
20+
echo '</td><td>';
21+
OptionRenderer::echoInput( $option_data );
22+
echo '</td></tr>';
1723
};
1824

19-
2025
echo '<h2>' . $view['title'] . '</h2>';
2126
?>
2227

@@ -33,7 +38,7 @@
3338
echo '<h3>' . $section['title'] . '</h3>';
3439
echo '<table class="widefat striped"><tbody>';
3540
foreach ( $section['options'] as $option_name ) {
36-
echo $row( $option_name );
41+
$row( $option_name );
3742
}
3843
echo '</tbody></table>';
3944
}

0 commit comments

Comments
 (0)