PluginProbe
Flying Scripts: Delay JavaScript to Improve Site Speed & Performance / 1.1.9
Flying Scripts: Delay JavaScript to Improve Site Speed & Performance v1.1.9
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 / settings.php

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

59 lines 2.8 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", "", sanitize_textarea_field($list)))) : [];
5 return $list;
6 }
7
8 function flying_scripts_view_settings() {
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 = esc_attr(get_option('flying_scripts_timeout'));
16
17 $include_list = get_option('flying_scripts_include_list');
18 $include_list = implode("\n", $include_list);
19 $include_list = esc_textarea($include_list);
20
21 ?>
22 <form method="POST">
23 <?php wp_nonce_field('flying-scripts', 'flying-scripts-settings-form'); ?>
24 <table class="form-table" role="presentation">
25 <tbody>
26 <tr>
27 <th scope="row"><label>Include Keywords</label></th>
28 <td>
29 <textarea name="flying_scripts_include_list" rows="4" cols="50"><?php echo $include_list ?></textarea>
30 <p class="description">Keywords that identify scripts that should load on user interaction. One keyword per line.</p>
31 </td>
32 </tr>
33 <tr>
34 <th scope="row"><label>Timeout</label></th>
35 <td>
36 <select name="flying_scripts_timeout" value="<?php echo $timeout; ?>">
37 <option value="1" <?php if ($timeout == 1) {echo 'selected';} ?>>1s</option>
38 <option value="2" <?php if ($timeout == 2) {echo 'selected';} ?>>2s</option>
39 <option value="3" <?php if ($timeout == 3) {echo 'selected';} ?>>3s</option>
40 <option value="4" <?php if ($timeout == 4) {echo 'selected';} ?>>4s</option>
41 <option value="5" <?php if ($timeout == 5) {echo 'selected';} ?>>5s</option>
42 <option value="6" <?php if ($timeout == 6) {echo 'selected';} ?>>6s</option>
43 <option value="7" <?php if ($timeout == 7) {echo 'selected';} ?>>7s</option>
44 <option value="8" <?php if ($timeout == 8) {echo 'selected';} ?>>8s</option>
45 <option value="9" <?php if ($timeout == 9) {echo 'selected';} ?>>9s</option>
46 <option value="10" <?php if ($timeout == 10) {echo 'selected';} ?>>10s</option>
47 </select>
48 <p class="description">Load scripts after a timeout when there is no user interaction</p>
49 <td>
50 </tr>
51 </tbody>
52 </table>
53 <p class="submit">
54 <input type="submit" name="submit" id="submit" class="button button-primary" value="Save Changes">
55 </p>
56 </form>
57 <?php
58 }
59