PluginProbe
Autoptimize / 1.8.2
Autoptimize v1.8.2
2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 All 107 releases
← All changes | autoptimize_helper.php_example +5 -113 2.7.61.8.2 View file →
@@ -1,143 +1,35 @@
1 1 <?php
2 -/*
3 -Plugin Name: Autoptimize Helper
4 -Plugin URI: http://blog.futtta.be/autoptimize
5 -Description: Autoptimize Helper contains some helper functions to make Autoptimize even more flexible
6 -Author: Frank Goossens (futtta)
7 -Version: 0.2
8 -Author URI: http://blog.futtta.be/
9 -*/
10 -
11 -/* autoptimize_filter_css_datauri_maxsize: change the threshold at which background images are turned into data uri's;
12 -
13 -@param $urisize: default size
14 -@return: your own preferred size */
15 2 // add_filter('autoptimize_filter_css_datauri_maxsize','my_ao_override_dataursize',10,1);
16 3 function my_ao_override_dataursize($urisizeIn) {
17 - return 100000;
4 + return 10000;
18 5 }
19 6
20 -/* autoptimize_filter_css_datauri_exclude: exclude background images from being turned into data uri's;
21 -
22 -@param $imageexcl: default images excluded (empty)
23 -@return: comma-seperated list of images to exclude */
24 -// add_filter('autoptimize_filter_css_datauri_exclude','my_ao_exclude_image',10,1);
25 -function my_ao_exclude_image($imageexcl) {
26 - return $imageexcl . ", adfreebutton.jpg, otherimage.png";
27 - }
28 -
29 -/* autoptimize_filter_js_defer: change flag added to javascript
30 -
31 -@param $defer: default value, "" when forced in head, "defer " when not forced in head
32 -@return: new value */
33 7 // add_filter('autoptimize_filter_js_defer','my_ao_override_defer',10,1);
34 8 function my_ao_override_defer($defer) {
35 9 return $defer."async ";
36 10 }
37 11
38 -/* autoptimize_filter_noptimize: stop autoptimize from optimizing, e.g. based on URL as in example
39 -
40 -@return: boolean, true or false */
41 -// add_filter('autoptimize_filter_noptimize','my_ao_noptimize',10,1);
42 -function my_ao_noptimize( $flag_in ) {
12 +// add_filter('autoptimize_filter_noptimize','my_ao_noptimize',10,0);
13 +function my_ao_noptimize() {
43 14 if (strpos($_SERVER['REQUEST_URI'],'no-autoptimize-now')!==false) {
44 15 return true;
45 16 } else {
46 - return $flag_in;
17 + return false;
47 18 }
48 19 }
49 20
50 -/* autoptimize_filter_js_exclude; JS optimization exclude strings, as configured in admin page
51 -
52 -@param $exclude: comma-seperated list of exclude strings
53 -@return: comma-seperated list of exclude strings */
54 21 // add_filter('autoptimize_filter_js_exclude','my_ao_override_jsexclude',10,1);
55 22 function my_ao_override_jsexclude($exclude) {
56 23 return $exclude.", customize-support";
57 24 }
58 25
59 -/* autoptimize_filter_css_exclude: CSS optimization exclude strings, as configured in admin page
60 -
61 -@param $exclude: comma-seperated list of exclude strings
62 -@return: comma-seperated list of exclude strings */
63 26 // add_filter('autoptimize_filter_css_exclude','my_ao_override_cssexclude',10,1);
64 27 function my_ao_override_cssexclude($exclude) {
65 28 return $exclude.", recentcomments";
66 29 }
67 30
68 -/* autoptimize_filter_js_movelast: internal array of what script can be moved to the bottom of the HTML
69 -
70 -@param array $movelast
71 -@return: updated array */
72 31 // add_filter('autoptimize_filter_js_movelast','my_ao_override_movelast',10,1);
73 32 function my_ao_override_movelast($movelast) {
74 33 $movelast[]="console.log";
75 34 return $movelast;
76 - }
77 -
78 -/* autoptimize_filter_css_replacetag: where in the HTML is optimized CSS injected
79 -
80 -@param array $replacetag, containing the html-tag and the method (inject "before", "after" or "replace")
81 -@return array with updated values */
82 -// add_filter('autoptimize_filter_css_replacetag','my_ao_override_css_replacetag',10,1);
83 -function my_ao_override_css_replacetag($replacetag) {
84 - return array("<head>","after");
85 - }
86 -
87 -/* autoptimize_filter_js_replacetag: where in the HTML is optimized JS injected
88 -
89 -@param array $replacetag, containing the html-tag and the method (inject "before", "after" or "replace")
90 -@return array with updated values */
91 -// add_filter('autoptimize_filter_js_replacetag','my_ao_override_js_replacetag',10,1);
92 -function my_ao_override_js_replacetag($replacetag) {
93 - return array("<injectjs />","replace");
94 - }
95 -
96 -/* autoptimize_js_do_minify: do we want to minify? if set to false autoptimize effectively only aggregates, but does not minify
97 -
98 -@return: boolean true or false */
99 -// add_filter('autoptimize_js_do_minify','my_ao_js_minify',10,1);
100 -function my_ao_js_minify() {
101 - return false;
102 - }
103 -
104 -/* autoptimize_css_do_minify: do we want to minify? if set to false autoptimize effectively only aggregates, but does not minify
105 -
106 -@return: boolean true or false */
107 -// add_filter('autoptimize_css_do_minify','my_ao_css_minify',10,1);
108 -function my_ao_css_minify() {
109 - return false;
110 - }
111 -
112 -/* autoptimize_js_include_inline: do we want AO to also aggregate inline JS?
113 -
114 -@return: boolean true or false */
115 -// add_filter('autoptimize_js_include_inline','my_ao_js_include_inline',10,1);
116 -function my_ao_js_include_inline() {
117 - return false;
118 - }
119 -
120 -/* autoptimize_css_include_inline: do we want AO to also aggregate inline CSS?
121 -
122 -@return: boolean true or false */
123 -// add_filter('autoptimize_css_include_inline','my_ao_css_include_inline',10,1);
124 -function my_ao_css_include_inline() {
125 - return false;
126 - }
127 -
128 -/* autoptimize_filter_css_defer_inline: what CSS to inline when "defer and inline" is activated
129 -
130 -@param $inlined: string with above the fold CSS as configured in admin
131 -@return: updated string with above the fold CSS */
132 -// add_filter('autoptimize_filter_css_defer_inline','my_ao_css_defer_inline',10,1);
133 -function my_ao_css_defer_inline($inlined) {
134 - return $inlined."h2,h1{color:red !important;}";
135 - }
136 -
137 -/* autoptimize_filter_css_fonts_cdn: do we want to move fonts to the CDN-url as well
138 -
139 -@return: false (default) or true */
140 -// add_filter('autoptimize_filter_css_fonts_cdn','my_css_cdnfont',10,0);
141 -function my_css_cdnfont(){
142 - return true;
143 -}
35 + }