PluginProbe
Flying Scripts: Delay JavaScript to Improve Site Speed & Performance / trunk
Flying Scripts: Delay JavaScript to Improve Site Speed & Performance vtrunk
trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4
flying-scripts / settings / scripts.php

scripts.php in Flying Scripts: Delay JavaScript to Improve Site Speed & Performance trunk, at settings/scripts.php

54 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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_timeout', sanitize_text_field($_POST['flying_scripts_timeout']));
12 update_option('flying_scripts_include_list', flying_scripts_format_list($_POST['flying_scripts_include_list']));
13 }
14
15 $timeout = get_option('flying_scripts_timeout');
16 $include_list = get_option('flying_scripts_include_list');
17
18 ?>
19 <form method="POST">
20 <?php wp_nonce_field('flying-scripts', 'flying-scripts-settings-form'); ?>
21 <table class="form-table" role="presentation">
22 <tbody>
23 <tr>
24 <th scope="row"><label>Include Keywords</label></th>
25 <td>
26 <textarea name="flying_scripts_include_list" rows="4" cols="50"><?php echo implode('&#10;', $include_list); ?></textarea>
27 </td>
28 </tr>
29 <tr>
30 <th scope="row"><label>Timeout</label></th>
31 <td>
32 <select name="flying_scripts_timeout" value="<?php echo $timeout; ?>">
33 <option value="1" <?php if ($timeout == 1) {echo 'selected';} ?>>1s</option>
34 <option value="2" <?php if ($timeout == 2) {echo 'selected';} ?>>2s</option>
35 <option value="3" <?php if ($timeout == 3) {echo 'selected';} ?>>3s</option>
36 <option value="4" <?php if ($timeout == 4) {echo 'selected';} ?>>4s</option>
37 <option value="5" <?php if ($timeout == 5) {echo 'selected';} ?>>5s</option>
38 <option value="6" <?php if ($timeout == 6) {echo 'selected';} ?>>6s</option>
39 <option value="7" <?php if ($timeout == 7) {echo 'selected';} ?>>7s</option>
40 <option value="8" <?php if ($timeout == 8) {echo 'selected';} ?>>8s</option>
41 <option value="9" <?php if ($timeout == 9) {echo 'selected';} ?>>9s</option>
42 <option value="10" <?php if ($timeout == 10) {echo 'selected';} ?>>10s</option>
43 </select>
44 <td>
45 </tr>
46 </tbody>
47 </table>
48 <p class="submit">
49 <input type="submit" name="submit" id="submit" class="button button-primary" value="Save Changes">
50 </p>
51 </form>
52 <?php
53 }
54