| 1 |
<?php |
| 2 |
function flying_scripts_format_list($list) { |
| 3 |
$list = trim($list); |
| 4 |
$list = $list ? array_map('trim', explode("\n", str_replace("\r", "", $list))) : []; |
| 5 |
return $list; |
| 6 |
} |
| 7 |
|
| 8 |
function flying_scripts_settings_scripts() { |
| 9 |
|
| 10 |
if (isset($_POST['submit'])) { |
| 11 |
update_option('flying_scripts_group_1_delay', sanitize_text_field($_POST['flying_scripts_group_1_delay'])); |
| 12 |
update_option('flying_scripts_group_2_delay', sanitize_text_field($_POST['flying_scripts_group_2_delay'])); |
| 13 |
update_option('flying_scripts_group_3_delay', sanitize_text_field($_POST['flying_scripts_group_3_delay'])); |
| 14 |
|
| 15 |
update_option('flying_scripts_group_1_include_list', flying_scripts_format_list($_POST['flying_scripts_group_1_include_list'])); |
| 16 |
update_option('flying_scripts_group_2_include_list', flying_scripts_format_list($_POST['flying_scripts_group_2_include_list'])); |
| 17 |
update_option('flying_scripts_group_3_include_list', flying_scripts_format_list($_POST['flying_scripts_group_3_include_list'])); |
| 18 |
} |
| 19 |
|
| 20 |
$group_1_delay = get_option('flying_scripts_group_1_delay'); |
| 21 |
$group_2_delay = get_option('flying_scripts_group_2_delay'); |
| 22 |
$group_3_delay = get_option('flying_scripts_group_3_delay'); |
| 23 |
|
| 24 |
$group_1_include_list = get_option('flying_scripts_group_1_include_list'); |
| 25 |
$group_2_include_list = get_option('flying_scripts_group_2_include_list'); |
| 26 |
$group_3_include_list = get_option('flying_scripts_group_3_include_list'); |
| 27 |
|
| 28 |
?> |
| 29 |
<form method="POST"> |
| 30 |
<?php wp_nonce_field('flying-scripts', 'flying-scripts-settings-form'); ?> |
| 31 |
<table class="form-table" role="presentation"> |
| 32 |
<tbody> |
| 33 |
<tr> |
| 34 |
<th scope="row"><label>Group 1 Delay</label></th> |
| 35 |
<td> |
| 36 |
<select name="flying_scripts_group_1_delay" value="<?php echo $group_1_delay; ?>"> |
| 37 |
<option value="1" <?php if ($group_1_delay == 1) {echo 'selected';} ?>>1s</option> |
| 38 |
<option value="2" <?php if ($group_1_delay == 2) {echo 'selected';} ?>>2s</option> |
| 39 |
<option value="3" <?php if ($group_1_delay == 3) {echo 'selected';} ?>>3s</option> |
| 40 |
<option value="4" <?php if ($group_1_delay == 4) {echo 'selected';} ?>>4s</option> |
| 41 |
<option value="5" <?php if ($group_1_delay == 5) {echo 'selected';} ?>>5s</option> |
| 42 |
<option value="6" <?php if ($group_1_delay == 6) {echo 'selected';} ?>>6s</option> |
| 43 |
<option value="7" <?php if ($group_1_delay == 7) {echo 'selected';} ?>>7s</option> |
| 44 |
<option value="8" <?php if ($group_1_delay == 8) {echo 'selected';} ?>>8s</option> |
| 45 |
<option value="9" <?php if ($group_1_delay == 9) {echo 'selected';} ?>>9s</option> |
| 46 |
<option value="10" <?php if ($group_1_delay == 10) {echo 'selected';} ?>>10s</option> |
| 47 |
</select> |
| 48 |
<td> |
| 49 |
</tr> |
| 50 |
<tr> |
| 51 |
<th scope="row"><label>Group 1 Include Keywords</label></th> |
| 52 |
<td> |
| 53 |
<textarea name="flying_scripts_group_1_include_list" rows="4" cols="50"><?php echo implode(' ', $group_1_include_list); ?></textarea> |
| 54 |
</td> |
| 55 |
</tr> |
| 56 |
<td></td> |
| 57 |
<tr> |
| 58 |
<th scope="row"><label>Group 2 Delay</label></th> |
| 59 |
<td> |
| 60 |
<select name="flying_scripts_group_2_delay" value="<?php echo $group_2_delay; ?>"> |
| 61 |
<option value="1" <?php if ($group_2_delay == 1) {echo 'selected';} ?>>1s</option> |
| 62 |
<option value="2" <?php if ($group_2_delay == 2) {echo 'selected';} ?>>2s</option> |
| 63 |
<option value="3" <?php if ($group_2_delay == 3) {echo 'selected';} ?>>3s</option> |
| 64 |
<option value="4" <?php if ($group_2_delay == 4) {echo 'selected';} ?>>4s</option> |
| 65 |
<option value="5" <?php if ($group_2_delay == 5) {echo 'selected';} ?>>5s</option> |
| 66 |
<option value="6" <?php if ($group_2_delay == 6) {echo 'selected';} ?>>6s</option> |
| 67 |
<option value="7" <?php if ($group_2_delay == 7) {echo 'selected';} ?>>7s</option> |
| 68 |
<option value="8" <?php if ($group_2_delay == 8) {echo 'selected';} ?>>8s</option> |
| 69 |
<option value="9" <?php if ($group_2_delay == 9) {echo 'selected';} ?>>9s</option> |
| 70 |
<option value="10" <?php if ($group_2_delay == 10) {echo 'selected';} ?>>10s</option> |
| 71 |
</select> |
| 72 |
<td> |
| 73 |
</tr> |
| 74 |
<tr> |
| 75 |
<th scope="row"><label>Group 2 Include Keywords</label></th> |
| 76 |
<td> |
| 77 |
<textarea name="flying_scripts_group_2_include_list" rows="4" cols="50"><?php echo implode(' ', $group_2_include_list); ?></textarea> |
| 78 |
</td> |
| 79 |
</tr> |
| 80 |
<td></td> |
| 81 |
<tr> |
| 82 |
<th scope="row"><label>Group 3 Delay</label></th> |
| 83 |
<td> |
| 84 |
<select name="flying_scripts_group_3_delay" value="<?php echo $group_3_delay; ?>"> |
| 85 |
<option value="1" <?php if ($group_3_delay == 1) {echo 'selected';} ?>>1s</option> |
| 86 |
<option value="2" <?php if ($group_3_delay == 2) {echo 'selected';} ?>>2s</option> |
| 87 |
<option value="3" <?php if ($group_3_delay == 3) {echo 'selected';} ?>>3s</option> |
| 88 |
<option value="4" <?php if ($group_3_delay == 4) {echo 'selected';} ?>>4s</option> |
| 89 |
<option value="5" <?php if ($group_3_delay == 5) {echo 'selected';} ?>>5s</option> |
| 90 |
<option value="6" <?php if ($group_3_delay == 6) {echo 'selected';} ?>>6s</option> |
| 91 |
<option value="7" <?php if ($group_3_delay == 7) {echo 'selected';} ?>>7s</option> |
| 92 |
<option value="8" <?php if ($group_3_delay == 8) {echo 'selected';} ?>>8s</option> |
| 93 |
<option value="9" <?php if ($group_3_delay == 9) {echo 'selected';} ?>>9s</option> |
| 94 |
<option value="10" <?php if ($group_3_delay == 10) {echo 'selected';} ?>>10s</option> |
| 95 |
</select> |
| 96 |
<td> |
| 97 |
</tr> |
| 98 |
<tr> |
| 99 |
<th scope="row"><label>Group 3 Include Keywords</label></th> |
| 100 |
<td> |
| 101 |
<textarea name="flying_scripts_group_3_include_list" rows="4" cols="50"><?php echo implode(' ', $group_3_include_list); ?></textarea> |
| 102 |
</td> |
| 103 |
</tr> |
| 104 |
</tbody> |
| 105 |
</table> |
| 106 |
<p class="submit"> |
| 107 |
<input type="submit" name="submit" id="submit" class="button button-primary" value="Save Changes"> |
| 108 |
</p> |
| 109 |
</form> |
| 110 |
<?php |
| 111 |
} |
| 112 |
|