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 / settings.php

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

72 lines 3.5 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 update_option('flying_scripts_disabled_pages', flying_scripts_format_list($_POST['flying_scripts_disabled_pages']));
14 }
15
16 $timeout = esc_attr(get_option('flying_scripts_timeout'));
17
18 $include_list = get_option('flying_scripts_include_list');
19 $include_list = implode("\n", $include_list);
20 $include_list = esc_textarea($include_list);
21
22 $disabled_pages = get_option('flying_scripts_disabled_pages');
23 $disabled_pages = implode("\n", $disabled_pages);
24 $disabled_pages = esc_textarea($disabled_pages);
25
26 ?>
27 <form method="POST">
28 <?php wp_nonce_field('flying-scripts', 'flying-scripts-settings-form'); ?>
29 <table class="form-table" role="presentation">
30 <tbody>
31 <tr>
32 <th scope="row"><label>Include Keywords</label></th>
33 <td>
34 <textarea name="flying_scripts_include_list" rows="4" cols="50"><?php echo $include_list ?></textarea>
35 <p class="description">Keywords that identify scripts that should load on user interaction. One keyword per line.</p>
36 </td>
37 </tr>
38 <tr>
39 <th scope="row"><label>Timeout</label></th>
40 <td>
41 <select name="flying_scripts_timeout" value="<?php echo $timeout; ?>">
42 <option value="1" <?php if ($timeout == 1) {echo 'selected';} ?>>1s</option>
43 <option value="2" <?php if ($timeout == 2) {echo 'selected';} ?>>2s</option>
44 <option value="3" <?php if ($timeout == 3) {echo 'selected';} ?>>3s</option>
45 <option value="4" <?php if ($timeout == 4) {echo 'selected';} ?>>4s</option>
46 <option value="5" <?php if ($timeout == 5) {echo 'selected';} ?>>5s</option>
47 <option value="6" <?php if ($timeout == 6) {echo 'selected';} ?>>6s</option>
48 <option value="7" <?php if ($timeout == 7) {echo 'selected';} ?>>7s</option>
49 <option value="8" <?php if ($timeout == 8) {echo 'selected';} ?>>8s</option>
50 <option value="9" <?php if ($timeout == 9) {echo 'selected';} ?>>9s</option>
51 <option value="10" <?php if ($timeout == 10) {echo 'selected';} ?>>10s</option>
52 <option value="5000" <?php if ($timeout == 5000) {echo 'selected';} ?>>Never</option>
53 </select>
54 <p class="description">Load scripts after a timeout when there is no user interaction</p>
55 <td>
56 </tr>
57 <tr>
58 <th scope="row"><label>Disable on pages</label></th>
59 <td>
60 <textarea name="flying_scripts_disabled_pages" rows="4" cols="50"><?php echo $disabled_pages; ?></textarea>
61 <p class="description">Keywords of URLs where Flying Scripts should be disabled</p>
62 </td>
63 </tr>
64 </tbody>
65 </table>
66 <p class="submit">
67 <input type="submit" name="submit" id="submit" class="button button-primary" value="Save Changes">
68 </p>
69 </form>
70 <?php
71 }
72