@@ -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 | * @param $content |
| 13 | 13 | * @return string Content with retina-enriched image tags. |
| 14 | 14 | */ |
| 15 | -function imgix_add_retina( $content ) { |
|
| 15 | +function imgix_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 imgix_apply_parameters_to_url( $url, $params, $content ) { |
|
| 50 | - $parts = explode( '?', $url . '?' ); |
|
| 49 | +function imgix_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 | 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 imgix_ensure_valid_url( $url ) { |
|
| 96 | - $slash = strpos( $url, '//' ) == 0 ? '//' : ''; |
|
| 95 | +function imgix_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 = wp_parse_url( $url ); |
|
| 103 | - $pref = array_key_exists( 'scheme', $urlp ) ? $urlp['scheme'] . '://' : $slash; |
|
| 102 | + $urlp = wp_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 ( false !== $result ) { |
|
| 112 | - return trailingslashit( $result ); |
|
| 111 | + if (false !== $result) { |
|
| 112 | + return trailingslashit($result); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | return null; |
@@ -133,35 +133,35 @@ discard block |
||
| 133 | 133 | * @return array An array of arrays that has extracted the URL's inferred w', |
| 134 | 134 | * 'h', and 'type' |
| 135 | 135 | */ |
| 136 | -function imgix_extract_img_details( $content ) { |
|
| 137 | - preg_match_all( '/-([0-9]+)x([0-9]+)\.([^"\']+)/', $content, $matches ); |
|
| 136 | +function imgix_extract_img_details($content) { |
|
| 137 | + preg_match_all('/-([0-9]+)x([0-9]+)\.([^"\']+)/', $content, $matches); |
|
| 138 | 138 | |
| 139 | - $lookup = array( 'raw', 'w', 'h', 'type' ); |
|
| 139 | + $lookup = array('raw', 'w', 'h', 'type'); |
|
| 140 | 140 | $data = array(); |
| 141 | 141 | |
| 142 | - if ( ! is_array($matches) ) { |
|
| 142 | + if ( ! is_array($matches)) { |
|
| 143 | 143 | return $data; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - foreach ( $matches as $k => $v ) { |
|
| 147 | - foreach ( $v as $index => $value ) { |
|
| 148 | - if ( ! array_key_exists( $index, $data ) ) { |
|
| 149 | - $data[ $index ] = array(); |
|
| 146 | + foreach ($matches as $k => $v) { |
|
| 147 | + foreach ($v as $index => $value) { |
|
| 148 | + if ( ! array_key_exists($index, $data)) { |
|
| 149 | + $data[$index] = array(); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - $key = $lookup[ $k ]; |
|
| 152 | + $key = $lookup[$k]; |
|
| 153 | 153 | |
| 154 | - if ( $key === 'type' ) { |
|
| 155 | - if ( strpos( $value, '?' ) !== false ) { |
|
| 156 | - $parts = explode( '?', $value ); |
|
| 157 | - $data[ $index ]['type'] = $parts[0]; |
|
| 158 | - $data[ $index ]['extra'] = $parts[1]; |
|
| 154 | + if ($key === 'type') { |
|
| 155 | + if (strpos($value, '?') !== false) { |
|
| 156 | + $parts = explode('?', $value); |
|
| 157 | + $data[$index]['type'] = $parts[0]; |
|
| 158 | + $data[$index]['extra'] = $parts[1]; |
|
| 159 | 159 | } else { |
| 160 | - $data[ $index ]['type'] = $value; |
|
| 161 | - $data[ $index ]['extra'] = ''; |
|
| 160 | + $data[$index]['type'] = $value; |
|
| 161 | + $data[$index]['extra'] = ''; |
|
| 162 | 162 | } |
| 163 | 163 | } else { |
| 164 | - $data[ $index ][ $key ] = $value; |
|
| 164 | + $data[$index][$key] = $value; |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | } |
@@ -176,47 +176,47 @@ discard block |
||
| 176 | 176 | * @return array An array countaining the final string, and a boolean value |
| 177 | 177 | * indicating if it's different from the given input string. |
| 178 | 178 | */ |
| 179 | -function imgix_replace_host( $str, $require_prefix = false ) { |
|
| 179 | +function imgix_replace_host($str, $require_prefix = false) { |
|
| 180 | 180 | global $imgix_options; |
| 181 | 181 | |
| 182 | - if ( ! isset( $imgix_options['cdn_link'] ) || ! $imgix_options['cdn_link'] ) { |
|
| 183 | - return array( $str, false ); |
|
| 182 | + if ( ! isset($imgix_options['cdn_link']) || ! $imgix_options['cdn_link']) { |
|
| 183 | + return array($str, false); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - $new_host = imgix_ensure_valid_url( $imgix_options['cdn_link'] ); |
|
| 187 | - if ( ! $new_host ) { |
|
| 188 | - return array( $str, false ); |
|
| 186 | + $new_host = imgix_ensure_valid_url($imgix_options['cdn_link']); |
|
| 187 | + if ( ! $new_host) { |
|
| 188 | + return array($str, false); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | // As soon as srcset is supported… |
| 192 | 192 | // $prefix = $require_prefix? 'srcs?e?t?=[\'"]|,[\S+\n\r\s]*': ''; |
| 193 | 193 | $prefix = $require_prefix ? 'src=[\'"]' : ''; |
| 194 | - $src = '(' . preg_quote( home_url( '/' ), '/' ) . '|\/\/)'; |
|
| 194 | + $src = '(' . preg_quote(home_url('/'), '/') . '|\/\/)'; |
|
| 195 | 195 | $patt = '/(' . $prefix . ' )' . $src . '/i'; |
| 196 | - $str = preg_replace( $patt, '$1' . $new_host, $str, -1, $count ); |
|
| 196 | + $str = preg_replace($patt, '$1' . $new_host, $str, -1, $count); |
|
| 197 | 197 | |
| 198 | - return array( $str, (boolean) $count ); |
|
| 198 | + return array($str, (boolean) $count); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | -function imgix_file_url( $url ) { |
|
| 201 | +function imgix_file_url($url) { |
|
| 202 | 202 | |
| 203 | 203 | global $imgix_options; |
| 204 | 204 | |
| 205 | 205 | $imgix_url = $imgix_options['cdn_link']; |
| 206 | - $file = pathinfo( $url ); |
|
| 206 | + $file = pathinfo($url); |
|
| 207 | 207 | |
| 208 | - if ( ! $imgix_url ) { |
|
| 208 | + if ( ! $imgix_url) { |
|
| 209 | 209 | return $url; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - if ( in_array( $file['extension'], array( 'jpg', 'gif', 'png', 'jpeg' ) ) ) { |
|
| 213 | - return str_replace( get_bloginfo( 'wpurl' ), $imgix_url, $url ); |
|
| 212 | + if (in_array($file['extension'], array('jpg', 'gif', 'png', 'jpeg'))) { |
|
| 213 | + return str_replace(get_bloginfo('wpurl'), $imgix_url, $url); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | return $url; |
| 217 | 217 | } |
| 218 | -add_filter( 'wp_get_attachment_url', 'imgix_file_url' ); |
|
| 219 | -add_filter( 'imgix/add-image-url', 'imgix_file_url' ); |
|
| 218 | +add_filter('wp_get_attachment_url', 'imgix_file_url'); |
|
| 219 | +add_filter('imgix/add-image-url', 'imgix_file_url'); |
|
| 220 | 220 | |
| 221 | 221 | /** |
| 222 | 222 | * |
@@ -228,63 +228,63 @@ discard block |
||
| 228 | 228 | * |
| 229 | 229 | * @return array $sources |
| 230 | 230 | */ |
| 231 | -function imgix_cdn_srcset( $sources, $size_array, $image_src, $image_meta, $attachment_id ) { |
|
| 231 | +function imgix_cdn_srcset($sources, $size_array, $image_src, $image_meta, $attachment_id) { |
|
| 232 | 232 | |
| 233 | - foreach ( $sources as $source ) { |
|
| 233 | + foreach ($sources as $source) { |
|
| 234 | 234 | |
| 235 | - $sources[ $source['value'] ]['url'] = apply_filters( 'imgix/add-image-url', $sources[ $source['value'] ]['url'] ); |
|
| 235 | + $sources[$source['value']]['url'] = apply_filters('imgix/add-image-url', $sources[$source['value']]['url']); |
|
| 236 | 236 | |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | return $sources; |
| 240 | 240 | } |
| 241 | -add_filter( 'wp_calculate_image_srcset', 'imgix_cdn_srcset', 10, 5 ); |
|
| 241 | +add_filter('wp_calculate_image_srcset', 'imgix_cdn_srcset', 10, 5); |
|
| 242 | 242 | |
| 243 | -function imgix_replace_non_wp_images( $content ) { |
|
| 244 | - list( $content, $match ) = imgix_replace_host( $content, true ); |
|
| 243 | +function imgix_replace_non_wp_images($content) { |
|
| 244 | + list($content, $match) = imgix_replace_host($content, true); |
|
| 245 | 245 | |
| 246 | - if ( $match ) { |
|
| 246 | + if ($match) { |
|
| 247 | 247 | // Apply image-tag-encoded params for every image in $content. |
| 248 | - foreach ( imgix_extract_img_details( $content ) as $img ) { |
|
| 248 | + foreach (imgix_extract_img_details($content) as $img) { |
|
| 249 | 249 | $to_replace = $img['raw']; |
| 250 | 250 | $extra_params = $img['extra'] ? '&' . $img['extra'] : ''; |
| 251 | 251 | $new_url = '.' . $img['type'] . '?h=' . $img['h'] . '&w=' . $img['w'] . $extra_params; |
| 252 | - $content = str_replace( $to_replace, $new_url, $content ); |
|
| 252 | + $content = str_replace($to_replace, $new_url, $content); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | // Apply global parameters. |
| 256 | 256 | $g_params = imgix_get_global_params_string(); |
| 257 | - foreach ( imgix_extract_imgs( $content ) as $img_url ) { |
|
| 258 | - $content = imgix_apply_parameters_to_url( $img_url, $g_params, $content ); |
|
| 257 | + foreach (imgix_extract_imgs($content) as $img_url) { |
|
| 258 | + $content = imgix_apply_parameters_to_url($img_url, $g_params, $content); |
|
| 259 | 259 | } |
| 260 | 260 | } |
| 261 | 261 | return $content; |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | -add_filter( 'the_content', 'imgix_replace_non_wp_images' ); |
|
| 264 | +add_filter('the_content', 'imgix_replace_non_wp_images'); |
|
| 265 | 265 | |
| 266 | 266 | function imgix_wp_head() { |
| 267 | 267 | global $imgix_options; |
| 268 | 268 | |
| 269 | - if ( isset( $imgix_options['cdn_link'] ) && $imgix_options['cdn_link'] ) { |
|
| 270 | - printf( "<link rel='dns-prefetch' href='%s'/>", |
|
| 271 | - esc_url( preg_replace( '/^https?:/', '', untrailingslashit( $imgix_options['cdn_link'] ) ) ) |
|
| 269 | + if (isset($imgix_options['cdn_link']) && $imgix_options['cdn_link']) { |
|
| 270 | + printf("<link rel='dns-prefetch' href='%s'/>", |
|
| 271 | + esc_url(preg_replace('/^https?:/', '', untrailingslashit($imgix_options['cdn_link']))) |
|
| 272 | 272 | ); |
| 273 | 273 | } |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | -add_action( 'wp_head', 'imgix_wp_head', 1 ); |
|
| 276 | +add_action('wp_head', 'imgix_wp_head', 1); |
|
| 277 | 277 | |
| 278 | -if ( isset( $imgix_options['add_dpi2_srcset'] ) && $imgix_options['add_dpi2_srcset'] ) { |
|
| 278 | +if (isset($imgix_options['add_dpi2_srcset']) && $imgix_options['add_dpi2_srcset']) { |
|
| 279 | 279 | function imgix_buffer_start() { |
| 280 | - ob_start( 'imgix_add_retina' ); |
|
| 280 | + ob_start('imgix_add_retina'); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | function imgix_buffer_end() { |
| 284 | 284 | ob_end_flush(); |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - add_action( 'after_setup_theme', 'imgix_buffer_start' ); |
|
| 288 | - add_action( 'shutdown', 'imgix_buffer_end' ); |
|
| 289 | - add_filter( 'the_content', 'imgix_add_retina' ); |
|
| 287 | + add_action('after_setup_theme', 'imgix_buffer_start'); |
|
| 288 | + add_action('shutdown', 'imgix_buffer_end'); |
|
| 289 | + add_filter('the_content', 'imgix_add_retina'); |
|
| 290 | 290 | } |
@@ -15,25 +15,25 @@ |
||
| 15 | 15 | * Author URI: http://github.com/wladston |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -define('IMGIX_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
|
| 18 | +define('IMGIX_PLUGIN_URL', plugin_dir_url(__FILE__)); |
|
| 19 | 19 | |
| 20 | -$imgix_options = get_option( 'imgix_settings' ); |
|
| 20 | +$imgix_options = get_option('imgix_settings'); |
|
| 21 | 21 | |
| 22 | -include( 'includes/do-functions.php' ); |
|
| 23 | -include( 'includes/options-page.php' ); |
|
| 22 | +include('includes/do-functions.php'); |
|
| 23 | +include('includes/options-page.php'); |
|
| 24 | 24 | |
| 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); |
|
@@ -18,37 +18,37 @@ discard block |
||
| 18 | 18 | <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> |
| 19 | 19 | |
| 20 | 20 | <form method="post" action="options.php"> |
| 21 | - <?php settings_fields( 'imgix_settings_group' ); ?> |
|
| 21 | + <?php settings_fields('imgix_settings_group'); ?> |
|
| 22 | 22 | |
| 23 | 23 | <table class="form-table"> |
| 24 | 24 | |
| 25 | 25 | <tbody> |
| 26 | 26 | |
| 27 | 27 | <tr> |
| 28 | - <th><label class="description" for="imgix_settings[cdn_link]"><?php esc_html_e( 'imgix Source', 'imgix_domain' ); ?></th> |
|
| 29 | - <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'] ) ? esc_url( $imgix_options['cdn_link'] ) : ''; ?>" class="regular-text code" /></td> |
|
| 28 | + <th><label class="description" for="imgix_settings[cdn_link]"><?php esc_html_e('imgix Source', 'imgix_domain'); ?></th> |
|
| 29 | + <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']) ? esc_url($imgix_options['cdn_link']) : ''; ?>" class="regular-text code" /></td> |
|
| 30 | 30 | </tr> |
| 31 | 31 | |
| 32 | 32 | <tr> |
| 33 | - <th><label class="description" for="imgix_settings[auto_format]"><?php esc_html_e( 'Auto Format Images', 'auto_format' ); ?></label></th> |
|
| 34 | - <td><input id="imgix_settings[auto_format]" type="checkbox" name="imgix_settings[auto_format]" value="1" <?php echo isset( $imgix_options['auto_format'] ) && '1' === $imgix_options['auto_format'] ? 'checked="checked"' : ''; ?> /></td> |
|
| 33 | + <th><label class="description" for="imgix_settings[auto_format]"><?php esc_html_e('Auto Format Images', 'auto_format'); ?></label></th> |
|
| 34 | + <td><input id="imgix_settings[auto_format]" type="checkbox" name="imgix_settings[auto_format]" value="1" <?php echo isset($imgix_options['auto_format']) && '1' === $imgix_options['auto_format'] ? 'checked="checked"' : ''; ?> /></td> |
|
| 35 | 35 | </tr> |
| 36 | 36 | |
| 37 | 37 | <tr> |
| 38 | - <th><label class="description" for="imgix_settings[auto_enhance]"><?php esc_html_e( 'Auto Enhance Images', 'auto_enhance' ); ?></label></th> |
|
| 39 | - <td><input id="imgix_settings[auto_enhance]" type="checkbox" name="imgix_settings[auto_enhance]" value="1" <?php echo isset( $imgix_options['auto_enhance'] ) && '1' === $imgix_options['auto_enhance'] ? 'checked="checked"' : ''; ?> /></td> |
|
| 38 | + <th><label class="description" for="imgix_settings[auto_enhance]"><?php esc_html_e('Auto Enhance Images', 'auto_enhance'); ?></label></th> |
|
| 39 | + <td><input id="imgix_settings[auto_enhance]" type="checkbox" name="imgix_settings[auto_enhance]" value="1" <?php echo isset($imgix_options['auto_enhance']) && '1' === $imgix_options['auto_enhance'] ? 'checked="checked"' : ''; ?> /></td> |
|
| 40 | 40 | </tr> |
| 41 | 41 | |
| 42 | 42 | <tr> |
| 43 | - <th><label class="description" for="imgix_settings[add_dpi2_srcset]"><?php esc_html_e( 'Automatically add retina images using srcset', 'add_dpi2_srcset' ); ?></label></th> |
|
| 44 | - <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'] ) && '1' === $imgix_options['add_dpi2_srcset'] ? 'checked="checked"' : ''; ?> /></td> |
|
| 43 | + <th><label class="description" for="imgix_settings[add_dpi2_srcset]"><?php esc_html_e('Automatically add retina images using srcset', 'add_dpi2_srcset'); ?></label></th> |
|
| 44 | + <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']) && '1' === $imgix_options['add_dpi2_srcset'] ? 'checked="checked"' : ''; ?> /></td> |
|
| 45 | 45 | </tr> |
| 46 | 46 | |
| 47 | 47 | </tbody> |
| 48 | 48 | </table> |
| 49 | 49 | |
| 50 | 50 | <p class="submit"> |
| 51 | - <input type="submit" class="button-primary" value="<?php esc_html_e( 'Save Options', 'imgix_domain' ); ?>" /> |
|
| 51 | + <input type="submit" class="button-primary" value="<?php esc_html_e('Save Options', 'imgix_domain'); ?>" /> |
|
| 52 | 52 | </p> |
| 53 | 53 | </form> |
| 54 | 54 | |
@@ -63,15 +63,15 @@ discard block |
||
| 63 | 63 | * Adds link to options page in Admin > Settings menu. |
| 64 | 64 | */ |
| 65 | 65 | function imgix_add_options_link() { |
| 66 | - add_options_page( 'imgix', 'imgix', 'manage_options', 'imgix-options', 'imgix_options_page' ); |
|
| 66 | + add_options_page('imgix', 'imgix', 'manage_options', 'imgix-options', 'imgix_options_page'); |
|
| 67 | 67 | } |
| 68 | -add_action( 'admin_menu', 'imgix_add_options_link' ); |
|
| 68 | +add_action('admin_menu', 'imgix_add_options_link'); |
|
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * Creates our settings in the options table. |
| 72 | 72 | */ |
| 73 | 73 | function imgix_register_settings() { |
| 74 | - register_setting( 'imgix_settings_group', 'imgix_settings' ); |
|
| 74 | + register_setting('imgix_settings_group', 'imgix_settings'); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | -add_action( 'admin_init', 'imgix_register_settings' ); |
|
| 77 | +add_action('admin_init', 'imgix_register_settings'); |
|