@@ -44,6 +44,7 @@ |
||
44 | 44 | * querystring parameters to the URL, preserving existing querystring |
45 | 45 | * parameters. |
46 | 46 | * |
47 | + * @param string $params |
|
47 | 48 | * @return string Content with matching URLs having the new querystrings. |
48 | 49 | */ |
49 | 50 | function apply_parameters_to_url( $url, $params, $content ) { |
@@ -12,13 +12,13 @@ discard block |
||
12 | 12 | * @return string Content with retina-enriched image tags. |
13 | 13 | */ |
14 | 14 | |
15 | -function add_retina( $content ) { |
|
15 | +function add_retina($content) { |
|
16 | 16 | $pattern = '/<img((?![^>]+srcset )([^>]*)'; |
17 | 17 | $pattern .= 'src=[\'"]([^\'"]*imgix.net[^\'"]*\?[^\'"]*w=[^\'"]*)[\'"]([^>]*)*?)>/i'; |
18 | 18 | $repl = '<img$2src="$3" srcset="${3}, ${3}&dpr=2 2x, ${3}&dpr=3 3x,"$4>'; |
19 | - $content = preg_replace( $pattern, $repl, $content ); |
|
19 | + $content = preg_replace($pattern, $repl, $content); |
|
20 | 20 | |
21 | - return preg_replace( $pattern, $repl, $content ); |
|
21 | + return preg_replace($pattern, $repl, $content); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return array An array of matching arrays with two keys: 'url' and 'params' |
28 | 28 | */ |
29 | -function imgix_extract_imgs( $content ) { |
|
30 | - preg_match_all( '/src=["\']http.+\/([^\s]+?)["\']/', $content, $matches ); |
|
29 | +function imgix_extract_imgs($content) { |
|
30 | + preg_match_all('/src=["\']http.+\/([^\s]+?)["\']/', $content, $matches); |
|
31 | 31 | $results = array(); |
32 | 32 | |
33 | - if ( $matches ) { |
|
34 | - foreach ( $matches[1] as $url ) { |
|
35 | - array_push( $results, $url ); |
|
33 | + if ($matches) { |
|
34 | + foreach ($matches[1] as $url) { |
|
35 | + array_push($results, $url); |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
@@ -46,17 +46,17 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return string Content with matching URLs having the new querystrings. |
48 | 48 | */ |
49 | -function apply_parameters_to_url( $url, $params, $content ) { |
|
50 | - $parts = explode( '?', $url . '?' ); |
|
49 | +function apply_parameters_to_url($url, $params, $content) { |
|
50 | + $parts = explode('?', $url . '?'); |
|
51 | 51 | |
52 | - list( $base_url, $base_params ) = array( $parts[0], $parts[1] ); |
|
52 | + list($base_url, $base_params) = array($parts[0], $parts[1]); |
|
53 | 53 | |
54 | 54 | $new_url = $old_url = $base_url; |
55 | 55 | $new_url .= '?' . $params; |
56 | 56 | $new_url .= $base_params ? '&' . $base_params : ''; |
57 | - $old_url .= $base_params ? '?'. $base_params : ''; |
|
57 | + $old_url .= $base_params ? '?' . $base_params : ''; |
|
58 | 58 | |
59 | - return str_replace( $old_url, $new_url, $content ); |
|
59 | + return str_replace($old_url, $new_url, $content); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -71,19 +71,19 @@ discard block |
||
71 | 71 | // For now, only "auto" is supported. |
72 | 72 | $auto = array(); |
73 | 73 | |
74 | - if ( isset( $imgix_options['auto_format'] ) && $imgix_options['auto_format'] ) { |
|
75 | - array_push( $auto, 'format' ); |
|
74 | + if (isset($imgix_options['auto_format']) && $imgix_options['auto_format']) { |
|
75 | + array_push($auto, 'format'); |
|
76 | 76 | } |
77 | 77 | |
78 | - if ( isset( $imgix_options['auto_enhance'] ) && $imgix_options['auto_enhance'] ) { |
|
79 | - array_push( $auto, 'enhance' ); |
|
78 | + if (isset($imgix_options['auto_enhance']) && $imgix_options['auto_enhance']) { |
|
79 | + array_push($auto, 'enhance'); |
|
80 | 80 | } |
81 | 81 | |
82 | - if ( ! empty( $auto ) ) { |
|
83 | - array_push( $params, 'auto=' . implode( '%2C', $auto ) ); |
|
82 | + if ( ! empty($auto)) { |
|
83 | + array_push($params, 'auto=' . implode('%2C', $auto)); |
|
84 | 84 | } |
85 | 85 | |
86 | - return implode( '&', $params ); |
|
86 | + return implode('&', $params); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -92,24 +92,24 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return string A sanitized URL. |
94 | 94 | */ |
95 | -function ensure_valid_url( $url ) { |
|
96 | - $slash = strpos( $url, '//' ) == 0 ? '//' : ''; |
|
95 | +function ensure_valid_url($url) { |
|
96 | + $slash = strpos($url, '//') == 0 ? '//' : ''; |
|
97 | 97 | |
98 | - if ( $slash ) { |
|
99 | - $url = substr( $url, 2 ); |
|
98 | + if ($slash) { |
|
99 | + $url = substr($url, 2); |
|
100 | 100 | } |
101 | 101 | |
102 | - $urlp = parse_url( $url ); |
|
103 | - $pref = array_key_exists( 'scheme', $urlp ) ? $urlp['scheme'] . '://' : $slash; |
|
102 | + $urlp = parse_url($url); |
|
103 | + $pref = array_key_exists('scheme', $urlp) ? $urlp['scheme'] . '://' : $slash; |
|
104 | 104 | |
105 | - if ( ! $slash && strpos( $pref, 'http' ) !== 0 ) { |
|
105 | + if ( ! $slash && strpos($pref, 'http') !== 0) { |
|
106 | 106 | $pref = 'http://'; |
107 | 107 | } |
108 | 108 | |
109 | 109 | $result = $urlp['host'] ? $pref . $urlp['host'] : false; |
110 | 110 | |
111 | - if ( $result ) { |
|
112 | - return trailingslashit( $result ); |
|
111 | + if ($result) { |
|
112 | + return trailingslashit($result); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | return NULL; |
@@ -120,29 +120,29 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return array Size's width, height and crop values. |
122 | 122 | */ |
123 | -function get_size_info( $size ) { |
|
123 | +function get_size_info($size) { |
|
124 | 124 | global $_wp_additional_image_sizes; |
125 | 125 | |
126 | - if ( $size === 'original' ) { |
|
126 | + if ($size === 'original') { |
|
127 | 127 | return array( |
128 | 128 | 'width' => '', |
129 | 129 | 'height' => '', |
130 | 130 | 'crop' => false, |
131 | 131 | ); |
132 | - } elseif ( is_array( $size ) ) { |
|
132 | + } elseif (is_array($size)) { |
|
133 | 133 | return array( |
134 | 134 | 'width' => $size[1], |
135 | 135 | 'height' => $size[0], |
136 | 136 | 'crop' => false, |
137 | 137 | ); |
138 | - } elseif ( in_array( $size, array( 'thumbnail', 'medium', 'large' ) ) ) { |
|
138 | + } elseif (in_array($size, array('thumbnail', 'medium', 'large'))) { |
|
139 | 139 | return array( |
140 | - 'width' => get_option( $size . '_size_w' ), |
|
141 | - 'height' => get_option( $size . '_size_h' ), |
|
142 | - 'crop' => (boolean) get_option( $size . '_crop' ), |
|
140 | + 'width' => get_option($size . '_size_w'), |
|
141 | + 'height' => get_option($size . '_size_h'), |
|
142 | + 'crop' => (boolean) get_option($size . '_crop'), |
|
143 | 143 | ); |
144 | 144 | } |
145 | - elseif ( isset( $_wp_additional_image_sizes[$size] ) ) { |
|
145 | + elseif (isset($_wp_additional_image_sizes[$size])) { |
|
146 | 146 | return array( |
147 | 147 | 'width' => $_wp_additional_image_sizes[$size]['width'], |
148 | 148 | 'height' => $_wp_additional_image_sizes[$size]['height'], |
@@ -171,25 +171,25 @@ discard block |
||
171 | 171 | * @return array An array of arrays that has extracted the URL's inferred w', |
172 | 172 | * 'h', and 'type' |
173 | 173 | */ |
174 | -function imgix_extract_img_details( $content ) { |
|
175 | - preg_match_all( '/-([0-9]+)x([0-9]+)\.([^"\']+)/', $content, $matches ); |
|
174 | +function imgix_extract_img_details($content) { |
|
175 | + preg_match_all('/-([0-9]+)x([0-9]+)\.([^"\']+)/', $content, $matches); |
|
176 | 176 | |
177 | - $lookup = array( 'raw', 'w', 'h', 'type' ); |
|
177 | + $lookup = array('raw', 'w', 'h', 'type'); |
|
178 | 178 | $data = array(); |
179 | 179 | |
180 | - foreach ( $matches as $k => $v ) { |
|
180 | + foreach ($matches as $k => $v) { |
|
181 | 181 | |
182 | - foreach ( $v as $index => $value ) { |
|
182 | + foreach ($v as $index => $value) { |
|
183 | 183 | |
184 | - if (!array_key_exists( $index, $data ) ) { |
|
184 | + if ( ! array_key_exists($index, $data)) { |
|
185 | 185 | $data[$index] = array(); |
186 | 186 | } |
187 | 187 | |
188 | 188 | $key = $lookup[$k]; |
189 | 189 | |
190 | - if ( $key === 'type' ) { |
|
191 | - if ( strpos( $value, '?' ) !== false ) { |
|
192 | - $parts = explode( '?', $value ); |
|
190 | + if ($key === 'type') { |
|
191 | + if (strpos($value, '?') !== false) { |
|
192 | + $parts = explode('?', $value); |
|
193 | 193 | $data[$index]['type'] = $parts[0]; |
194 | 194 | $data[$index]['extra'] = $parts[1]; |
195 | 195 | } else { |
@@ -212,26 +212,26 @@ discard block |
||
212 | 212 | * @return array An array countaining the final string, and a boolean value |
213 | 213 | * indicating if it's different from the given input string. |
214 | 214 | */ |
215 | -function replace_host( $str, $require_prefix = false ) { |
|
215 | +function replace_host($str, $require_prefix = false) { |
|
216 | 216 | global $imgix_options; |
217 | 217 | |
218 | - if ( ! isset( $imgix_options['cdn_link'] ) || ! $imgix_options['cdn_link'] ) { |
|
219 | - return array( $str, false ); |
|
218 | + if ( ! isset($imgix_options['cdn_link']) || ! $imgix_options['cdn_link']) { |
|
219 | + return array($str, false); |
|
220 | 220 | } |
221 | 221 | |
222 | - $new_host = ensure_valid_url( $imgix_options['cdn_link'] ); |
|
223 | - if ( ! $new_host ) { |
|
224 | - return array( $str, false ); |
|
222 | + $new_host = ensure_valid_url($imgix_options['cdn_link']); |
|
223 | + if ( ! $new_host) { |
|
224 | + return array($str, false); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | // As soon as srcset is supported… |
228 | 228 | //$prefix = $require_prefix? 'srcs?e?t?=[\'"]|,[\S+\n\r\s]*': ''; |
229 | - $prefix = $require_prefix? 'src=[\'"]': ''; |
|
230 | - $src = '(' . preg_quote( home_url( '/' ), '/' ) . '|\/\/)'; |
|
229 | + $prefix = $require_prefix ? 'src=[\'"]' : ''; |
|
230 | + $src = '(' . preg_quote(home_url('/'), '/') . '|\/\/)'; |
|
231 | 231 | $patt = '/(' . $prefix . ' )' . $src . '/i'; |
232 | - $str = preg_replace( $patt, '$1' . $new_host, $str, -1, $count ); |
|
232 | + $str = preg_replace($patt, '$1' . $new_host, $str, -1, $count); |
|
233 | 233 | |
234 | - return array( $str, (boolean) $count ); |
|
234 | + return array($str, (boolean) $count); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -240,57 +240,57 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return string equivalent imgix source with correct parameters. |
242 | 242 | */ |
243 | -function replace_src( $src, $size ) { |
|
244 | - $size_info = get_size_info( $size ); |
|
243 | +function replace_src($src, $size) { |
|
244 | + $size_info = get_size_info($size); |
|
245 | 245 | |
246 | - if ( $size_info ) { |
|
246 | + if ($size_info) { |
|
247 | 247 | |
248 | - list( $src, $match_src ) = replace_host( $src, false ); |
|
248 | + list($src, $match_src) = replace_host($src, false); |
|
249 | 249 | |
250 | - if ( $match_src ) { |
|
250 | + if ($match_src) { |
|
251 | 251 | $g_params = get_global_params_string(); |
252 | 252 | $params = array(); |
253 | 253 | |
254 | - if ( isset( $size_info['crop'] ) && $size_info['crop'] ) { |
|
255 | - array_push( $params, 'fit=crop' ); |
|
254 | + if (isset($size_info['crop']) && $size_info['crop']) { |
|
255 | + array_push($params, 'fit=crop'); |
|
256 | 256 | } |
257 | 257 | |
258 | - if ( isset( $size_info['width'] ) && $size_info['width'] ) { |
|
259 | - array_push( $params, 'w=' . $size_info['width'] ); |
|
258 | + if (isset($size_info['width']) && $size_info['width']) { |
|
259 | + array_push($params, 'w=' . $size_info['width']); |
|
260 | 260 | } |
261 | 261 | |
262 | - if ( isset( $size_info['height'] ) && $size_info['height'] ) { |
|
263 | - array_push( $params, 'h=' . $size_info['height'] ); |
|
262 | + if (isset($size_info['height']) && $size_info['height']) { |
|
263 | + array_push($params, 'h=' . $size_info['height']); |
|
264 | 264 | } |
265 | 265 | |
266 | - $p = implode( '&', $params ); |
|
267 | - $p = ( $p && $g_params ) ? $p . '&' . $g_params : $p . $g_params; |
|
268 | - $src = apply_parameters_to_url( $src, $p, $src ); |
|
266 | + $p = implode('&', $params); |
|
267 | + $p = ($p && $g_params) ? $p . '&' . $g_params : $p . $g_params; |
|
268 | + $src = apply_parameters_to_url($src, $p, $src); |
|
269 | 269 | } |
270 | 270 | } |
271 | 271 | |
272 | 272 | return $src; |
273 | 273 | } |
274 | 274 | |
275 | -function imgix_file_url( $url ) { |
|
275 | +function imgix_file_url($url) { |
|
276 | 276 | |
277 | 277 | global $imgix_options; |
278 | 278 | |
279 | 279 | $imgix_url = $imgix_options['cdn_link']; |
280 | - $file = pathinfo( $url ); |
|
280 | + $file = pathinfo($url); |
|
281 | 281 | |
282 | - if ( ! $imgix_url ) { |
|
282 | + if ( ! $imgix_url) { |
|
283 | 283 | return $url; |
284 | 284 | } |
285 | 285 | |
286 | - if ( in_array( $file['extension'], array( 'jpg','gif','png','jpeg' ) ) ) { |
|
287 | - return str_replace( get_bloginfo( 'wpurl' ), $imgix_url, $url ); |
|
286 | + if (in_array($file['extension'], array('jpg', 'gif', 'png', 'jpeg'))) { |
|
287 | + return str_replace(get_bloginfo('wpurl'), $imgix_url, $url); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | return $url; |
291 | 291 | } |
292 | -add_filter( 'wp_get_attachment_url', 'imgix_file_url' ); |
|
293 | -add_filter( 'imgix/add-image-url', 'imgix_file_url' ); |
|
292 | +add_filter('wp_get_attachment_url', 'imgix_file_url'); |
|
293 | +add_filter('imgix/add-image-url', 'imgix_file_url'); |
|
294 | 294 | |
295 | 295 | /** |
296 | 296 | * |
@@ -302,61 +302,61 @@ discard block |
||
302 | 302 | * |
303 | 303 | * @return array $sources |
304 | 304 | */ |
305 | -function imgix_cdn_srcset( $sources, $size_array, $image_src, $image_meta, $attachment_id ) { |
|
305 | +function imgix_cdn_srcset($sources, $size_array, $image_src, $image_meta, $attachment_id) { |
|
306 | 306 | |
307 | 307 | global $imgix_options; |
308 | 308 | |
309 | 309 | $imgix_url = $imgix_options['cdn_link']; |
310 | 310 | |
311 | - foreach ( $sources as $source ) { |
|
311 | + foreach ($sources as $source) { |
|
312 | 312 | |
313 | - $sources[$source['value']]['url'] = apply_filters( 'imgix/add-image-url', $sources[ $source['value'] ]['url'] ); |
|
313 | + $sources[$source['value']]['url'] = apply_filters('imgix/add-image-url', $sources[$source['value']]['url']); |
|
314 | 314 | |
315 | 315 | } |
316 | 316 | |
317 | 317 | return $sources; |
318 | 318 | } |
319 | -add_filter( 'wp_calculate_image_srcset', 'imgix_cdn_srcset', 10, 5 ); |
|
319 | +add_filter('wp_calculate_image_srcset', 'imgix_cdn_srcset', 10, 5); |
|
320 | 320 | |
321 | -function imgix_replace_non_wp_images( $content ) { |
|
322 | - list( $content, $match ) = replace_host( $content, true ); |
|
321 | +function imgix_replace_non_wp_images($content) { |
|
322 | + list($content, $match) = replace_host($content, true); |
|
323 | 323 | |
324 | - if ( $match ) { |
|
324 | + if ($match) { |
|
325 | 325 | // Apply image-tag-encoded params for every image in $content. |
326 | - foreach ( imgix_extract_img_details( $content ) as $img ) { |
|
326 | + foreach (imgix_extract_img_details($content) as $img) { |
|
327 | 327 | $to_replace = $img['raw']; |
328 | 328 | $extra_params = $img['extra'] ? '&' . $img['extra'] : ''; |
329 | 329 | $new_url = '.' . $img['type'] . '?h=' . $img['h'] . '&w=' . $img['w'] . $extra_params; |
330 | - $content = str_replace( $to_replace, $new_url, $content ); |
|
330 | + $content = str_replace($to_replace, $new_url, $content); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | // Apply global parameters. |
334 | 334 | $g_params = get_global_params_string(); |
335 | - foreach ( imgix_extract_imgs( $content ) as $img_url ) { |
|
336 | - $content = apply_parameters_to_url( $img_url, $g_params, $content ); |
|
335 | + foreach (imgix_extract_imgs($content) as $img_url) { |
|
336 | + $content = apply_parameters_to_url($img_url, $g_params, $content); |
|
337 | 337 | } |
338 | 338 | } |
339 | 339 | return $content; |
340 | 340 | } |
341 | 341 | |
342 | -add_filter( 'the_content', 'imgix_replace_non_wp_images' ); |
|
342 | +add_filter('the_content', 'imgix_replace_non_wp_images'); |
|
343 | 343 | |
344 | 344 | function imgix_wp_head() { |
345 | 345 | global $imgix_options; |
346 | 346 | |
347 | - if ( isset( $imgix_options['cdn_link'] ) && $imgix_options['cdn_link'] ) { |
|
348 | - printf( "<link rel='dns-prefetch' href='%s'/>", |
|
349 | - preg_replace( '/^https?:/', '', untrailingslashit( $imgix_options['cdn_link'] ) ) |
|
347 | + if (isset($imgix_options['cdn_link']) && $imgix_options['cdn_link']) { |
|
348 | + printf("<link rel='dns-prefetch' href='%s'/>", |
|
349 | + preg_replace('/^https?:/', '', untrailingslashit($imgix_options['cdn_link'])) |
|
350 | 350 | ); |
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
354 | -add_action( 'wp_head', 'imgix_wp_head', 1 ); |
|
354 | +add_action('wp_head', 'imgix_wp_head', 1); |
|
355 | 355 | |
356 | -if (isset( $imgix_options['add_dpi2_srcset'] ) && $imgix_options['add_dpi2_srcset'] ) { |
|
356 | +if (isset($imgix_options['add_dpi2_srcset']) && $imgix_options['add_dpi2_srcset']) { |
|
357 | 357 | function buffer_start() { ob_start("add_retina"); } |
358 | 358 | function buffer_end() { ob_end_flush(); } |
359 | - add_action('after_setup_theme', 'buffer_start' ); |
|
360 | - add_action('shutdown', 'buffer_end' ); |
|
361 | - add_filter('the_content', 'add_retina' ); |
|
359 | + add_action('after_setup_theme', 'buffer_start'); |
|
360 | + add_action('shutdown', 'buffer_end'); |
|
361 | + add_filter('the_content', 'add_retina'); |
|
362 | 362 | } |
@@ -141,8 +141,7 @@ |
||
141 | 141 | 'height' => get_option( $size . '_size_h' ), |
142 | 142 | 'crop' => (boolean) get_option( $size . '_crop' ), |
143 | 143 | ); |
144 | - } |
|
145 | - elseif ( isset( $_wp_additional_image_sizes[$size] ) ) { |
|
144 | + } elseif ( isset( $_wp_additional_image_sizes[$size] ) ) { |
|
146 | 145 | return array( |
147 | 146 | 'width' => $_wp_additional_image_sizes[$size]['width'], |
148 | 147 | 'height' => $_wp_additional_image_sizes[$size]['height'], |
@@ -16,24 +16,24 @@ |
||
16 | 16 | */ |
17 | 17 | |
18 | 18 | // Variables |
19 | -$imgix_options = get_option( 'imgix_settings' ); |
|
19 | +$imgix_options = get_option('imgix_settings'); |
|
20 | 20 | |
21 | -include( 'includes/do-functions.php' ); |
|
22 | -include( 'includes/options_page.php' ); |
|
21 | +include('includes/do-functions.php'); |
|
22 | +include('includes/options_page.php'); |
|
23 | 23 | |
24 | 24 | // Settings |
25 | -function imgix_plugin_admin_action_links( $links, $file ) { |
|
25 | +function imgix_plugin_admin_action_links($links, $file) { |
|
26 | 26 | static $my_plugin; |
27 | 27 | |
28 | - if ( ! $my_plugin ) { |
|
29 | - $my_plugin = plugin_basename( __FILE__ ); |
|
28 | + if ( ! $my_plugin) { |
|
29 | + $my_plugin = plugin_basename(__FILE__); |
|
30 | 30 | } |
31 | 31 | |
32 | - if ( $file === $my_plugin ) { |
|
32 | + if ($file === $my_plugin) { |
|
33 | 33 | $settings_link = '<a href="options-general.php?page=imgix-options">Settings</a>'; |
34 | - array_unshift( $links, $settings_link ); |
|
34 | + array_unshift($links, $settings_link); |
|
35 | 35 | } |
36 | 36 | return $links; |
37 | 37 | } |
38 | 38 | |
39 | -add_filter( 'plugin_action_links', 'imgix_plugin_admin_action_links', 10, 2 ); |
|
39 | +add_filter('plugin_action_links', 'imgix_plugin_admin_action_links', 10, 2); |
@@ -14,37 +14,37 @@ discard block |
||
14 | 14 | <p><strong>Need help getting started?</strong> It's easy! Check out our <a href="https://github.com/imgix-wordpress/imgix-wordpress#getting-started" target="_blank">instructions.</a></p> |
15 | 15 | |
16 | 16 | <form method="post" action="options.php"> |
17 | - <?php settings_fields( 'imgix_settings_group' ); ?> |
|
17 | + <?php settings_fields('imgix_settings_group'); ?> |
|
18 | 18 | |
19 | 19 | <table class="form-table"> |
20 | 20 | |
21 | 21 | <tbody> |
22 | 22 | |
23 | 23 | <tr> |
24 | - <th><label class="description" for="imgix_settings[cdn_link]"><?php _e( 'imgix Source', 'imgix_domain' ); ?></th> |
|
25 | - <td><input id="imgix_settings[cdn_link]" type="url" name="imgix_settings[cdn_link]" placeholder="https://yourcompany.imgix.net" value="<?php echo isset( $imgix_options['cdn_link'] ) ? $imgix_options['cdn_link'] : ''; ?>" class="regular-text code" /></td> |
|
24 | + <th><label class="description" for="imgix_settings[cdn_link]"><?php _e('imgix Source', 'imgix_domain'); ?></th> |
|
25 | + <td><input id="imgix_settings[cdn_link]" type="url" name="imgix_settings[cdn_link]" placeholder="https://yourcompany.imgix.net" value="<?php echo isset($imgix_options['cdn_link']) ? $imgix_options['cdn_link'] : ''; ?>" class="regular-text code" /></td> |
|
26 | 26 | </tr> |
27 | 27 | |
28 | 28 | <tr> |
29 | - <th><label class="description" for="imgix_settings[auto_format]"><?php _e( '<a href="http://blog.imgix.com/post/90838796454/webp-jpeg-xr-progressive-jpg-support-w-auto" target="_blank">Auto Format</a> Images', 'auto_format' ); ?></label></th> |
|
30 | - <td><input id="imgix_settings[auto_format]" type="checkbox" name="imgix_settings[auto_format]" value="1" <?php echo isset( $imgix_options['auto_format'] ) && $imgix_options['auto_format'] === "1" ? 'checked="checked"' : ''; ?> /></td> |
|
29 | + <th><label class="description" for="imgix_settings[auto_format]"><?php _e('<a href="http://blog.imgix.com/post/90838796454/webp-jpeg-xr-progressive-jpg-support-w-auto" target="_blank">Auto Format</a> Images', 'auto_format'); ?></label></th> |
|
30 | + <td><input id="imgix_settings[auto_format]" type="checkbox" name="imgix_settings[auto_format]" value="1" <?php echo isset($imgix_options['auto_format']) && $imgix_options['auto_format'] === "1" ? 'checked="checked"' : ''; ?> /></td> |
|
31 | 31 | </tr> |
32 | 32 | |
33 | 33 | <tr> |
34 | - <th><label class="description" for="imgix_settings[auto_enhance]"><?php _e( '<a href="http://blog.imgix.com/post/85095931364/autoenhance" target="_blank">Auto Enhance</a> Images', 'auto_enhance' ); ?></label></th> |
|
35 | - <td><input id="imgix_settings[auto_enhance]" type="checkbox" name="imgix_settings[auto_enhance]" value="1" <?php echo isset( $imgix_options['auto_enhance'] ) && $imgix_options['auto_enhance'] === "1" ? 'checked="checked"' : ''; ?> /></td> |
|
34 | + <th><label class="description" for="imgix_settings[auto_enhance]"><?php _e('<a href="http://blog.imgix.com/post/85095931364/autoenhance" target="_blank">Auto Enhance</a> Images', 'auto_enhance'); ?></label></th> |
|
35 | + <td><input id="imgix_settings[auto_enhance]" type="checkbox" name="imgix_settings[auto_enhance]" value="1" <?php echo isset($imgix_options['auto_enhance']) && $imgix_options['auto_enhance'] === "1" ? 'checked="checked"' : ''; ?> /></td> |
|
36 | 36 | </tr> |
37 | 37 | |
38 | 38 | <tr> |
39 | - <th><label class="description" for="imgix_settings[add_dpi2_srcset]"><?php _e( 'Automatically add retina images using srcset', 'add_dpi2_srcset' ); ?></label></th> |
|
40 | - <td><input id="imgix_settings[add_dpi2_srcset]" type="checkbox" name="imgix_settings[add_dpi2_srcset]" value="1" <?php echo isset( $imgix_options['add_dpi2_srcset'] ) && $imgix_options['add_dpi2_srcset'] === "1" ? 'checked="checked"' : ''; ?> /></td> |
|
39 | + <th><label class="description" for="imgix_settings[add_dpi2_srcset]"><?php _e('Automatically add retina images using srcset', 'add_dpi2_srcset'); ?></label></th> |
|
40 | + <td><input id="imgix_settings[add_dpi2_srcset]" type="checkbox" name="imgix_settings[add_dpi2_srcset]" value="1" <?php echo isset($imgix_options['add_dpi2_srcset']) && $imgix_options['add_dpi2_srcset'] === "1" ? 'checked="checked"' : ''; ?> /></td> |
|
41 | 41 | </tr> |
42 | 42 | |
43 | 43 | </tbody> |
44 | 44 | </table> |
45 | 45 | |
46 | 46 | <p class="submit"> |
47 | - <input type="submit" class="button-primary" value="<?php _e( 'Save Options', 'imgix_domain' ); ?>" /> |
|
47 | + <input type="submit" class="button-primary" value="<?php _e('Save Options', 'imgix_domain'); ?>" /> |
|
48 | 48 | </p> |
49 | 49 | </form> |
50 | 50 | |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | function imgix_add_options_link() { |
59 | - add_options_page( 'imgix', 'imgix', 'manage_options', 'imgix-options', 'imgix_options_page' ); |
|
59 | + add_options_page('imgix', 'imgix', 'manage_options', 'imgix-options', 'imgix_options_page'); |
|
60 | 60 | } |
61 | -add_action( 'admin_menu', 'imgix_add_options_link' ); |
|
61 | +add_action('admin_menu', 'imgix_add_options_link'); |
|
62 | 62 | |
63 | 63 | function imgix_register_settings() { |
64 | 64 | // creates our settings in the options table |
65 | - register_setting( 'imgix_settings_group', 'imgix_settings' ); |
|
65 | + register_setting('imgix_settings_group', 'imgix_settings'); |
|
66 | 66 | } |
67 | 67 | |
68 | -add_action( 'admin_init', 'imgix_register_settings' ); |
|
68 | +add_action('admin_init', 'imgix_register_settings'); |