Skip to content

Commit db88528

Browse files
committed
Save scan options and persist between page loads
1 parent b51f509 commit db88528

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

src/wpephpcompat.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,6 @@ public function clean_after_scan() {
396396
// Delete options created during the scan.
397397
delete_option( 'wpephpcompat.lock' );
398398
delete_option( 'wpephpcompat.status' );
399-
delete_option( 'wpephpcompat.only_active' );
400399
delete_option( 'wpephpcompat.numdirs' );
401400

402401
// Clear scheduled cron.

wpengine-phpcompat.php

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ function check_status() {
106106
$count_jobs = wp_count_posts( 'wpephpcompat_jobs' );
107107
$total_jobs = get_option( 'wpephpcompat.numdirs' );
108108
$test_version = get_option( 'wpephpcompat.test_version' );
109+
$only_active = get_option( 'wpephpcompat.only_active' );
109110

110111
$active_job = false;
111112
$jobs = get_posts( array(
@@ -118,12 +119,13 @@ function check_status() {
118119
}
119120

120121
$to_encode = array(
121-
'status' => $scan_status,
122-
'count' => $count_jobs->publish,
123-
'total' => $total_jobs,
124-
'progress' => 100 - ( ( $count_jobs->publish / $total_jobs ) * 100 ),
125-
'activeJob' => $active_job,
126-
'version' => $test_version,
122+
'status' => $scan_status,
123+
'count' => $count_jobs->publish,
124+
'total' => $total_jobs,
125+
'progress' => 100 - ( ( $count_jobs->publish / $total_jobs ) * 100 ),
126+
'activeJob' => $active_job,
127+
'version' => $test_version,
128+
'onlyActive' => $only_active,
127129
);
128130

129131
// If the scan is still running.
@@ -210,6 +212,8 @@ function create_menu() {
210212
* @return null
211213
*/
212214
function settings_page() {
215+
$test_version = get_option( 'wpephpcompat.test_version' );
216+
$only_active = get_option( 'wpephpcompat.only_active' );
213217
?>
214218
<div class="wrap">
215219
<div style="float: left;">
@@ -225,16 +229,16 @@ function settings_page() {
225229
<tr>
226230
<th scope="row"><label for="phptest_version">PHP Version</label></th>
227231
<td>
228-
<label><input type="radio" name="phptest_version" value="7.0" checked="checked"> PHP 7.0</label><br>
229-
<label><input type="radio" name="phptest_version" value="5.5"> PHP 5.5</label><br>
230-
<label><input type="radio" name="phptest_version" value="5.4"> PHP 5.4</label><br>
231-
<label><input type="radio" name="phptest_version" value="5.3"> PHP 5.3</label>
232+
<label><input type="radio" name="phptest_version" value="7.0" <?php checked( $test_version, '7.0', true ); ?>> PHP 7.0</label><br>
233+
<label><input type="radio" name="phptest_version" value="5.5" <?php checked( $test_version, '5.5', true ); ?>> PHP 5.5</label><br>
234+
<label><input type="radio" name="phptest_version" value="5.4" <?php checked( $test_version, '5.4', true ); ?>> PHP 5.4</label><br>
235+
<label><input type="radio" name="phptest_version" value="5.3" <?php checked( $test_version, '5.3', true ); ?>> PHP 5.3</label>
232236
</td>
233237
</tr>
234238
<tr>
235239
<th scope="row"><label for="active_plugins">Only Active</label></th>
236-
<td><label><input type="radio" name="active_plugins" value="yes" checked="checked"> Only scan active plugins and themes</label><br>
237-
<label><input type="radio" name="active_plugins" value="no"> Scan all plugins and themes</label>
240+
<td><label><input type="radio" name="active_plugins" value="yes" <?php checked( $only_active, 'yes', true ); ?>> Only scan active plugins and themes</label><br>
241+
<label><input type="radio" name="active_plugins" value="no" <?php checked( $only_active, 'no', true ); ?>> Scan all plugins and themes</label>
238242
</td>
239243
</tr>
240244
</tbody>

0 commit comments

Comments
 (0)