-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathoptions-generic.php
210 lines (196 loc) · 10.9 KB
/
options-generic.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<script type="text/javascript">
function confirm_reset() {
var answer = confirm("<?php _e('All of options will return to default settings. Are you sure you want to reset all settings?'); ?>");
if(answer)
return true;
else
return false;
}
jQuery(document).ready(function($){
$("#wpm_options_toggle_advanced").click(function(e){
e.preventDefault();
state = $(this).attr("state");
if(state == "visible"){
$(".wpm_advanced").slideUp();
$("#wpm_options_reset").fadeOut();
$(this).attr("state", "hidden");
$(this).attr("value", "<?php echo __('Show Advanced Options', $this->name); ?>" + " " + String.fromCharCode(187));
$.ajax({
type : "POST",
url : "admin-ajax.php",
data : { action : "wpm", _ajax_nonce: "<?php echo wp_create_nonce($this->name); ?>", wpm_action : "hide_advanced" },
success : function(resp){
// do nothing visually
},
error : function(resp){
alert("Error:" + resp);
}
});
}
else{
$(".wpm_advanced").slideDown();
$("#wpm_options_reset").fadeIn();
$(this).attr("state", "visible");
$(this).attr("value", "<?php echo __('Hide Advanced Options', $this->name); ?>" + " " + String.fromCharCode(187));
$.ajax({
type : "POST",
url : "admin-ajax.php",
data : { action : "wpm", _ajax_nonce: "<?php echo wp_create_nonce($this->name); ?>", wpm_action : "show_advanced" },
success : function(resp){
// do nothing visually
},
error : function(resp){
alert("Error:" + resp);
}
});
}
});
$('#cache_external_checkbox').click(function(e) {
state = $(this).attr("state");
if (state == "on") {
$(".wpm_include").slideDown();
$(this).attr("state", "off");
} else {
$(".wpm_include").slideUp();
$(this).attr("state", "on");
}
});
});
</script>
<form method="post"><fieldset>
<?php
// take care of advanced options
if ($wpm_options['show_advanced']) {
$advanced_style = '';
$advanced_toggle_text = __('Hide Advanced Options', $this->name);
$advanced_toggle_state = 'visible';
}
else {
$advanced_style = 'style="display:none"';
$advanced_toggle_text = __('Show Advanced Options', $this->name);
$advanced_toggle_state = 'hidden';
}
if ($wpm_options['cache_external']) {
$include_style = 'style="display:none"';
$include_toggle_state = 'on';
} else {
$include_style = '';
$include_toggle_state = 'off';
}
printf('
<h2>%s</h2>
<p><label>%s <input name="wpm_options_update[show_link]" value="on" type="radio" '.checked(true, $wpm_options['show_link'], false).'/></label></p>
<p><label>%s <input name="wpm_options_update[show_link]" value="off" type="radio" '.checked(false, $wpm_options['show_link'], false).'/></label></p>
',
__('Support this plugin!', $this->name),
__('Display "Page optimized by WP Minify" link in the footer', $this->name),
__('Do not display "Page optimized by WP Minify" link.', $this->name)
);
printf('
<h2>%s</h2>
<p><label>%s <input name="wpm_options_update[enable_js]" type="checkbox" '.checked(true, $wpm_options['enable_js'], false).'/></label></p>
<p><label>%s <input name="wpm_options_update[enable_css]" type="checkbox" '.checked(true, $wpm_options['enable_css'], false).'/></label></p>
<p><label>%s <input name="wpm_options_update[enable_html]" type="checkbox" '.checked(true, $wpm_options['enable_html'], false).'/></label></p>
',
__('General Configuration', $this->name),
__('Enable JavaScript Minification', $this->name),
__('Enable CSS Minification', $this->name),
__('Enable HTML Minification', $this->name)
);
printf('
<h2 class="wpm_advanced" '.$advanced_style.'>%s</h2>
<p class="wpm_advanced" '.$advanced_style.'><label>%s <input name="wpm_options_update[debug_nominify]" type="checkbox" '.checked(true, $wpm_options['debug_nominify'], false).'/></label></p>
<p class="wpm_advanced" '.$advanced_style.'><label><a href="http://omninoggin.com/wordpress-posts/troubleshooting-wp-minify-with-firephp/">%s</a> <input name="wpm_options_update[debug_firephp]" type="checkbox" '.checked(true, $wpm_options['debug_firephp'], false).'/></label></p>
',
__('Debugging', $this->name),
__('Combine files but do not minify', $this->name),
__('Show minify errors through FirePHP', $this->name)
);
printf('
<h2 class="wpm_advanced" '.$advanced_style.'>%s</h2>
<p><label>%s<br/><textarea name="wpm_options_update[js_exclude]" style="width:600px" rows="5">'.esc_attr(implode(chr(10), $wpm_options['js_exclude'])).'</textarea></label></p>
<p><label>%s<br/><textarea name="wpm_options_update[css_exclude]" style="width:600px" rows="5">'.esc_attr(implode(chr(10), $wpm_options['css_exclude'])).'</textarea></label></p>
<p class="wpm_advanced" '.$advanced_style.'><label>%s<br/><textarea name="wpm_options_update[uri_exclude]" style="width:600px" rows="5">'.esc_attr(implode(chr(10), $wpm_options['uri_exclude'])).'</textarea></label></p>
',
__('Local Files Minification', $this->name),
__('JavaScript files to exclude from minify (line delimited).', $this->name),
__('CSS files to exclude from minify (line delimited).', $this->name),
__('URIs on which WP-Minify-Fix parsing will be disabled (line delimited)', $this->name)
);
printf('
<h2 class="wpm_advanced" '.$advanced_style.'>%s</h2>
<p class="wpm_advanced" '.$advanced_style.'><label>%s <input name="wpm_options_update[cache_external]" id="cache_external_checkbox" state="'.$include_toggle_state.'" type="checkbox" '.checked(true, $wpm_options['cache_external'], false).'/> (%s)</label></p>
<p class="wpm_advanced wpm_include" '.$advanced_style.' '.$include_style.'><label>%s (%s, <a href="http://omninoggin.com/wordpress-posts/tutorial-wp-minify-options/#include_external_files">%s</a>)<br/><textarea name="wpm_options_update[js_include]" style="width:600px" rows="5">'.esc_attr(implode(chr(10), $wpm_options['js_include'])).'</textarea></label></p>
<p class="wpm_advanced wpm_include" '.$advanced_style.' '.$include_style.'><label>%s (%s, <a href="http://omninoggin.com/wordpress-posts/tutorial-wp-minify-options/#include_external_files">%s</a>)<br/><textarea name="wpm_options_update[css_include]" style="width:600px" rows="5">'.esc_attr(implode(chr(10), $wpm_options['css_include'])).'</textarea></label></p>
',
__('Non-Local Files Minification', $this->name),
__('Enable minification on external files', $this->name),
__('Not recommended unless you want to exclude a bunch of external .js/.css files', $this->name),
__('External JavaScript files to include into minify.', $this->name),
__('Only useful if "Minification on external files" is unchecked', $this->name),
__('more info', $this->name),
__('External CSS files to include into minify.', $this->name),
__('Only useful if "Minification on external files" is unchecked', $this->name),
__('more info', $this->name)
);
printf('
<h2 class="wpm_advanced" '.$advanced_style.'>%s</h2>
<p class="wpm_advanced" '.$advanced_style.'><label>%s<input name="wpm_options_update[cache_interval]" type="text" size="4" value="'.esc_attr($wpm_options['cache_interval']).'"/>%s <span class="submit"><input type="submit" name="wpm_options_clear_cache_submit" value="%s"/></span></p></label>
',
__('Caching', $this->name),
__('Cache expires after every', $this->name),
__('seconds', $this->name),
__('Manually Clear Cache', $this->name)
);
printf('
<h2 class="wpm_advanced" '.$advanced_style.'>%s</h2>
<p class="wpm_advanced" '.$advanced_style.'><label>%s <input name="wpm_options_update[js_placement]" value="header-footer" type="radio" '.checked('header-footer', $wpm_options['js_placement'], false).'/></label></p>
<p class="wpm_advanced" '.$advanced_style.'><label>%s <input name="wpm_options_update[js_placement]" value="header" type="radio" '.checked('header', $wpm_options['js_placement'], false).'/></label></p>
<p class="wpm_advanced" '.$advanced_style.'><label>%s <input name="wpm_options_update[js_placement]" value="footer" type="radio" '.checked('footer', $wpm_options['js_placement'], false).'/></label></p>
',
__('JavaScript Placement', $this->name),
__('In the header, and if necessary also in the footer (recommended)', $this->name),
__('Everything in the header', $this->name),
__('Everything in the footer', $this->name)
);
printf('
<h2 class="wpm_advanced" '.$advanced_style.'>%s</h2>
<p class="wpm_advanced" '.$advanced_style.'><label>%s <input name="wpm_options_update[pretty_url]" type="checkbox" '.checked(true, $wpm_options['pretty_url'], false).'/> (%s)</label></p>',
__('Tweaking/Tuning', $this->name),
__('Use "pretty" URL"', $this->name),
__('i.e. use "wp-minify-fix/cache/1234abcd.js" instead of "wp-minify-fix/min/?f=file1.js,file2.js,...,fileN.js"', $this->name)
);
printf('
<p class="wpm_advanced" '.$advanced_style.'><label>%s <input name="wpm_options_update[js_async]" type="checkbox" '.checked(true, $wpm_options['js_async'], false).'/> (%s, <a href="http://css-tricks.com/async-attribute-scripts-bottom/" target="_blank">%s</a>)</label></p>
',
__('Add the HTML5 async tag', $this->name),
__('Only for the header', $this->name),
__('more info', $this->name)
);
printf('
<p class="wpm_advanced" '.$advanced_style.'><label>%s <input name="wpm_options_update[force_https]" type="checkbox" '.checked(true, $wpm_options['force_https'], false).'/></label></p>
',
__('Force all JavaScript/CSS calls to be HTTPS on HTTPS pages', $this->name)
);
printf('
<p class="wpm_advanced" '.$advanced_style.'><label>%s <input name="wpm_options_update[auto_base]" type="checkbox" '.checked(true, $wpm_options['auto_base'], false).'/></label></p>
<p class="wpm_advanced" '.$advanced_style.'><label>%s<br/><input name="wpm_options_update[extra_minify_options]" type="text" size="100" value="'.esc_attr($wpm_options['extra_minify_options']).'"/><br/><em>%s</em></label></p>
',
__('Automatically set your Minify base per siteurl setting (recommended)', $this->name),
__('Extra arguments to pass to minify engine. This value will get append to calls to URL "wp-minify-fix/min/?f=file1.js,file2.js,...,fileN.js".', $this->name),
__('e.g. You can specify this value to be b=somepath to specify the base path for all files passed into Minify.', $this->name)
);
if ( function_exists( 'wp_nonce_field' ) && wp_nonce_field( $this->name ) ) {
printf('
<p class="submit">
<input type="submit" name="wpm_options_update_submit" value="%s »" />
<input type="submit" name="wpm_options_reset_submit" id="wpm_options_reset" value="%s »" onclick="return confirm_reset()" '.$advanced_style.'/>
<input type="button" id="wpm_options_toggle_advanced" state="'.$advanced_toggle_state.'" value="'.$advanced_toggle_text.' »"/>
</p>
',
__('Update Options', $this->name),
__('Reset ALL Options', $this->name)
);
}
?>
</fieldset></form>