Completed
Push — master ( 64afc7...75e1d1 )
by LA
03:54
created
imgix.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -16,17 +16,17 @@
 block discarded – undo
16 16
  * Author URI:  http://github.com/imgix-wordpress
17 17
  */
18 18
 
19
-include( 'includes/compability.php' );
20
-include( 'includes/class-images-via-imgix.php' );
21
-include( 'includes/options-page.php' );
19
+include('includes/compability.php');
20
+include('includes/class-images-via-imgix.php');
21
+include('includes/options-page.php');
22 22
 
23
-function imgix_plugin_admin_action_links( $links, $file ) {
24
-	if ( $file === plugin_basename( __FILE__ ) ) {
23
+function imgix_plugin_admin_action_links($links, $file) {
24
+	if ($file === plugin_basename(__FILE__)) {
25 25
 		$settings_link = '<a href="options-general.php?page=imgix-options">Settings</a>';
26
-		array_unshift( $links, $settings_link );
26
+		array_unshift($links, $settings_link);
27 27
 	}
28 28
 
29 29
 	return $links;
30 30
 }
31 31
 
32
-add_filter( 'plugin_action_links', 'imgix_plugin_admin_action_links', 10, 2 );
32
+add_filter('plugin_action_links', 'imgix_plugin_admin_action_links', 10, 2);
Please login to merge, or discard this patch.
includes/compability.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @package imgix
6 6
  */
7 7
 
8
-if ( ! function_exists( 'http_build_url' ) ) {
8
+if ( ! function_exists('http_build_url')) {
9 9
 	/**
10 10
 	 * This is a simplified version of http_build_url if pecl_http is missing
11 11
 	 *
@@ -13,22 +13,22 @@  discard block
 block discarded – undo
13 13
 	 *
14 14
 	 * @return string
15 15
 	 */
16
-	function http_build_url( $parsed_url ) {
17
-		$scheme   = isset( $parsed_url['scheme'] ) ? $parsed_url['scheme'] . '://' : '';
18
-		$host     = isset( $parsed_url['host'] ) ? $parsed_url['host'] : '';
19
-		$port     = isset( $parsed_url['port'] ) ? ':' . $parsed_url['port'] : '';
20
-		$user     = isset( $parsed_url['user'] ) ? $parsed_url['user'] : '';
21
-		$pass     = isset( $parsed_url['pass'] ) ? ':' . $parsed_url['pass'] : '';
22
-		$pass     = ( $user || $pass ) ? "$pass@" : '';
23
-		$path     = isset( $parsed_url['path'] ) ? $parsed_url['path'] : '';
24
-		$query    = isset( $parsed_url['query'] ) ? '?' . $parsed_url['query'] : '';
25
-		$fragment = isset( $parsed_url['fragment'] ) ? '#' . $parsed_url['fragment'] : '';
16
+	function http_build_url($parsed_url) {
17
+		$scheme   = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
18
+		$host     = isset($parsed_url['host']) ? $parsed_url['host'] : '';
19
+		$port     = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
20
+		$user     = isset($parsed_url['user']) ? $parsed_url['user'] : '';
21
+		$pass     = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : '';
22
+		$pass     = ($user || $pass) ? "$pass@" : '';
23
+		$path     = isset($parsed_url['path']) ? $parsed_url['path'] : '';
24
+		$query    = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
25
+		$fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
26 26
 
27 27
 		return "$scheme$user$pass$host$port$path$query$fragment";
28 28
 	}
29 29
 }
30 30
 
31
-if ( ! function_exists( 'wp_get_additional_image_sizes' ) ) {
31
+if ( ! function_exists('wp_get_additional_image_sizes')) {
32 32
 	/**
33 33
 	 * Retrieve additional image sizes.
34 34
 	 *
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	function wp_get_additional_image_sizes() {
42 42
 		global $_wp_additional_image_sizes;
43
-		if ( ! $_wp_additional_image_sizes ) {
43
+		if ( ! $_wp_additional_image_sizes) {
44 44
 			$_wp_additional_image_sizes = [];
45 45
 		}
46 46
 
Please login to merge, or discard this patch.
includes/options-page.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -18,9 +18,9 @@  discard block
 block discarded – undo
18 18
 
19 19
 
20 20
 	public function __construct() {
21
-		$this->options = get_option( 'imgix_settings', [] );
22
-		add_action( 'admin_init', [ $this, 'imgix_register_settings' ] );
23
-		add_action( 'admin_menu', [ $this, 'imgix_add_options_link' ] );
21
+		$this->options = get_option('imgix_settings', []);
22
+		add_action('admin_init', [$this, 'imgix_register_settings']);
23
+		add_action('admin_menu', [$this, 'imgix_add_options_link']);
24 24
 	}
25 25
 
26 26
 	/**
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * @return Imgix_Options_page
30 30
 	 */
31 31
 	public static function instance() {
32
-		if ( ! isset( self::$instance ) ) {
32
+		if ( ! isset(self::$instance)) {
33 33
 			self::$instance = new self;
34 34
 		}
35 35
 
@@ -44,62 +44,62 @@  discard block
 block discarded – undo
44 44
 		<div class="wrap">
45 45
 
46 46
 			<h1>
47
-				<img src="<?php echo plugins_url( 'assets/images/imgix-logo.png', __DIR__ ); ?>" alt="imgix Logo">
47
+				<img src="<?php echo plugins_url('assets/images/imgix-logo.png', __DIR__); ?>" alt="imgix Logo">
48 48
 			</h1>
49 49
 
50 50
 			<p><strong>Need help getting started?</strong> It's easy! Check out our
51 51
 				<a href="https://github.com/imgix-wordpress/imgix-wordpress#getting-started" target="_blank">instructions.</a>
52 52
 			</p>
53 53
 
54
-			<form method="post" action="<?php echo admin_url( 'options.php' ); ?>">
55
-				<?php settings_fields( 'imgix_settings_group' ); ?>
54
+			<form method="post" action="<?php echo admin_url('options.php'); ?>">
55
+				<?php settings_fields('imgix_settings_group'); ?>
56 56
 				<table class="form-table">
57 57
 					<tbody>
58 58
 						<tr>
59 59
 							<th>
60
-								<label class="description" for="imgix_settings[cdn_link]"><?php esc_html_e( 'imgix Source', 'imgix' ); ?>
60
+								<label class="description" for="imgix_settings[cdn_link]"><?php esc_html_e('imgix Source', 'imgix'); ?>
61 61
 							</th>
62 62
 							<td>
63
-								<input id="imgix_settings[cdn_link]" type="url" name="imgix_settings[cdn_link]" placeholder="https://yourcompany.imgix.net" value="<?php echo $this->get_option( 'cdn_link' ); ?>" class="regular-text code"/>
63
+								<input id="imgix_settings[cdn_link]" type="url" name="imgix_settings[cdn_link]" placeholder="https://yourcompany.imgix.net" value="<?php echo $this->get_option('cdn_link'); ?>" class="regular-text code"/>
64 64
 							</td>
65 65
 						</tr>
66 66
 						<tr>
67 67
 							<th>
68
-								<label class="description" for="imgix_settings[auto_format]"><?php esc_html_e( 'Auto Format Images', 'imgix' ); ?></label>
68
+								<label class="description" for="imgix_settings[auto_format]"><?php esc_html_e('Auto Format Images', 'imgix'); ?></label>
69 69
 							</th>
70 70
 							<td>
71
-								<input id="imgix_settings[auto_format]" type="checkbox" name="imgix_settings[auto_format]" value="1" <?php checked( $this->get_option( 'auto_format' ) ) ?> />
71
+								<input id="imgix_settings[auto_format]" type="checkbox" name="imgix_settings[auto_format]" value="1" <?php checked($this->get_option('auto_format')) ?> />
72 72
 							</td>
73 73
 						</tr>
74 74
 						<tr>
75 75
 							<th>
76
-								<label class="description" for="imgix_settings[auto_enhance]"><?php esc_html_e( 'Auto Enhance Images', 'imgix' ); ?></label>
76
+								<label class="description" for="imgix_settings[auto_enhance]"><?php esc_html_e('Auto Enhance Images', 'imgix'); ?></label>
77 77
 							</th>
78 78
 							<td>
79
-								<input id="imgix_settings[auto_enhance]" type="checkbox" name="imgix_settings[auto_enhance]" value="1" <?php checked( $this->get_option( 'auto_enhance' ) ) ?> />
79
+								<input id="imgix_settings[auto_enhance]" type="checkbox" name="imgix_settings[auto_enhance]" value="1" <?php checked($this->get_option('auto_enhance')) ?> />
80 80
 							</td>
81 81
 						</tr>
82 82
 						<tr>
83 83
 							<th>
84
-								<label class="description" for="imgix_settings[auto_compress]"><?php esc_html_e( 'Auto Compress Images', 'imgix' ); ?></label>
84
+								<label class="description" for="imgix_settings[auto_compress]"><?php esc_html_e('Auto Compress Images', 'imgix'); ?></label>
85 85
 							</th>
86 86
 							<td>
87
-								<input id="imgix_settings[auto_compress]" type="checkbox" name="imgix_settings[auto_compress]" value="1" <?php checked( $this->get_option( 'auto_compress' ) ) ?> />
87
+								<input id="imgix_settings[auto_compress]" type="checkbox" name="imgix_settings[auto_compress]" value="1" <?php checked($this->get_option('auto_compress')) ?> />
88 88
 							</td>
89 89
 						</tr>
90 90
 						<tr>
91 91
 							<th>
92
-								<label class="description" for="imgix_settings[add_dpi2_srcset]"><?php esc_html_e( 'Automatically add retina images using srcset', 'imgix' ); ?></label>
92
+								<label class="description" for="imgix_settings[add_dpi2_srcset]"><?php esc_html_e('Automatically add retina images using srcset', 'imgix'); ?></label>
93 93
 							</th>
94 94
 							<td>
95
-								<input id="imgix_settings[add_dpi2_srcset]" type="checkbox" name="imgix_settings[add_dpi2_srcset]" value="1" <?php checked( $this->get_option( 'add_dpi2_srcset' ) ) ?> />
95
+								<input id="imgix_settings[add_dpi2_srcset]" type="checkbox" name="imgix_settings[add_dpi2_srcset]" value="1" <?php checked($this->get_option('add_dpi2_srcset')) ?> />
96 96
 							</td>
97 97
 						</tr>
98 98
 					</tbody>
99 99
 				</table>
100 100
 
101 101
 				<p class="submit">
102
-					<input type="submit" class="button-primary" value="<?php esc_html_e( 'Save Options', 'imgix' ); ?>"/>
102
+					<input type="submit" class="button-primary" value="<?php esc_html_e('Save Options', 'imgix'); ?>"/>
103 103
 				</p>
104 104
 			</form>
105 105
 
@@ -116,14 +116,14 @@  discard block
 block discarded – undo
116 116
 	 *  Adds link to options page in Admin > Settings menu.
117 117
 	 */
118 118
 	public function imgix_add_options_link() {
119
-		add_options_page( 'imgix', 'imgix', 'manage_options', 'imgix-options', [ $this, 'imgix_options_page' ] );
119
+		add_options_page('imgix', 'imgix', 'manage_options', 'imgix-options', [$this, 'imgix_options_page']);
120 120
 	}
121 121
 
122 122
 	/**
123 123
 	 *  Creates our settings in the options table.
124 124
 	 */
125 125
 	public function imgix_register_settings() {
126
-		register_setting( 'imgix_settings_group', 'imgix_settings' );
126
+		register_setting('imgix_settings_group', 'imgix_settings');
127 127
 	}
128 128
 
129 129
 	/**
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @return mixed
135 135
 	 */
136
-	protected function get_option( $key ) {
137
-		return isset( $this->options[ $key ] ) ? $this->options[ $key ] : '';
136
+	protected function get_option($key) {
137
+		return isset($this->options[$key]) ? $this->options[$key] : '';
138 138
 	}
139 139
 }
140 140
 
Please login to merge, or discard this patch.
includes/class-images-via-imgix.php 1 patch
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -27,20 +27,20 @@  discard block
 block discarded – undo
27 27
 	 * ImagesViaImgix constructor.
28 28
 	 */
29 29
 	public function __construct() {
30
-		$this->options = get_option( 'imgix_settings', [] );
30
+		$this->options = get_option('imgix_settings', []);
31 31
 
32
-		add_filter( 'wp_get_attachment_url', [ $this, 'replace_image_url' ] );
33
-		add_filter( 'imgix/add-image-url', [ $this, 'replace_image_url' ] );
32
+		add_filter('wp_get_attachment_url', [$this, 'replace_image_url']);
33
+		add_filter('imgix/add-image-url', [$this, 'replace_image_url']);
34 34
 
35
-		add_filter( 'image_downsize', [ $this, 'image_downsize' ], 10, 3 );
35
+		add_filter('image_downsize', [$this, 'image_downsize'], 10, 3);
36 36
 
37
-		add_filter( 'wp_calculate_image_srcset', [ $this, 'calculate_image_srcset' ], 10, 3 );
37
+		add_filter('wp_calculate_image_srcset', [$this, 'calculate_image_srcset'], 10, 3);
38 38
 
39
-		add_filter( 'the_content', [ $this, 'replace_images_in_content' ] );
40
-		add_action( 'wp_head', [ $this, 'prefetch_cdn' ], 1 );
39
+		add_filter('the_content', [$this, 'replace_images_in_content']);
40
+		add_action('wp_head', [$this, 'prefetch_cdn'], 1);
41 41
 
42
-		add_action( 'after_setup_theme', [ $this, 'buffer_start_for_retina' ] );
43
-		add_action( 'shutdown', [ $this, 'buffer_end_for_retina' ] );
42
+		add_action('after_setup_theme', [$this, 'buffer_start_for_retina']);
43
+		add_action('shutdown', [$this, 'buffer_end_for_retina']);
44 44
 	}
45 45
 
46 46
 	/**
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @return Images_Via_Imgix
50 50
 	 */
51 51
 	public static function instance() {
52
-		if ( ! isset( self::$instance ) ) {
52
+		if ( ! isset(self::$instance)) {
53 53
 			self::$instance = new self;
54 54
 		}
55 55
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @param array $options
64 64
 	 */
65
-	public function set_options( $options ) {
65
+	public function set_options($options) {
66 66
 		$this->options = $options;
67 67
 	}
68 68
 
@@ -75,13 +75,13 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @return string Content with retina-enriched image tags.
77 77
 	 */
78
-	public function add_retina( $content ) {
78
+	public function add_retina($content) {
79 79
 		$pattern = '/<img((?![^>]+srcset )([^>]*)';
80 80
 		$pattern .= 'src=[\'"]([^\'"]*imgix.net[^\'"]*\?[^\'"]*w=[^\'"]*)[\'"]([^>]*)*?)>/i';
81 81
 		$repl    = '<img$2src="$3" srcset="${3}, ${3}&amp;dpr=2 2x, ${3}&amp;dpr=3 3x,"$4>';
82
-		$content = preg_replace( $pattern, $repl, $content );
82
+		$content = preg_replace($pattern, $repl, $content);
83 83
 
84
-		return preg_replace( $pattern, $repl, $content );
84
+		return preg_replace($pattern, $repl, $content);
85 85
 	}
86 86
 
87 87
 	/**
@@ -91,22 +91,22 @@  discard block
 block discarded – undo
91 91
 	 *
92 92
 	 * @return string
93 93
 	 */
94
-	public function replace_image_url( $url ) {
95
-		if ( ! empty ( $this->options['cdn_link'] ) ) {
96
-			$parsed_url = parse_url( $url );
97
-
98
-			if ( isset( $parsed_url['host'], $parsed_url['path'] ) && $parsed_url['host'] === parse_url( home_url( '/' ), PHP_URL_HOST ) && preg_match( '/\.(jpg|jpeg|gif|png)$/', $parsed_url['path'] ) ) {
99
-				$cdn = parse_url( $this->options['cdn_link'] );
100
-				foreach ( [ 'scheme', 'host', 'port' ] as $url_part ) {
101
-					if ( isset( $cdn[ $url_part ] ) ) {
102
-						$parsed_url[ $url_part ] = $cdn[ $url_part ];
94
+	public function replace_image_url($url) {
95
+		if ( ! empty ($this->options['cdn_link'])) {
96
+			$parsed_url = parse_url($url);
97
+
98
+			if (isset($parsed_url['host'], $parsed_url['path']) && $parsed_url['host'] === parse_url(home_url('/'), PHP_URL_HOST) && preg_match('/\.(jpg|jpeg|gif|png)$/', $parsed_url['path'])) {
99
+				$cdn = parse_url($this->options['cdn_link']);
100
+				foreach (['scheme', 'host', 'port'] as $url_part) {
101
+					if (isset($cdn[$url_part])) {
102
+						$parsed_url[$url_part] = $cdn[$url_part];
103 103
 					} else {
104
-						unset( $parsed_url[ $url_part ] );
104
+						unset($parsed_url[$url_part]);
105 105
 					}
106 106
 				}
107
-				$url = http_build_url( $parsed_url );
107
+				$url = http_build_url($parsed_url);
108 108
 
109
-				$url = add_query_arg( $this->get_global_params(), $url );
109
+				$url = add_query_arg($this->get_global_params(), $url);
110 110
 			}
111 111
 		}
112 112
 
@@ -122,35 +122,35 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @return false|array
124 124
 	 */
125
-	public function image_downsize( $return, $attachment_id, $size ) {
126
-		if ( ! empty ( $this->options['cdn_link'] ) ) {
127
-			$img_url = wp_get_attachment_url( $attachment_id );
125
+	public function image_downsize($return, $attachment_id, $size) {
126
+		if ( ! empty ($this->options['cdn_link'])) {
127
+			$img_url = wp_get_attachment_url($attachment_id);
128 128
 
129 129
 			$params = [];
130
-			if ( is_array( $size ) ) {
131
-				$params['w'] = $width = isset( $size[0] ) ? $size[0] : 0;
132
-				$params['h'] = $height = isset( $size[1] ) ? $size[1] : 0;
130
+			if (is_array($size)) {
131
+				$params['w'] = $width = isset($size[0]) ? $size[0] : 0;
132
+				$params['h'] = $height = isset($size[1]) ? $size[1] : 0;
133 133
 			} else {
134 134
 				$available_sizes = $this->get_all_defined_sizes();
135
-				if ( isset( $available_sizes[ $size ] ) ) {
136
-					$size        = $available_sizes[ $size ];
135
+				if (isset($available_sizes[$size])) {
136
+					$size        = $available_sizes[$size];
137 137
 					$params['w'] = $width = $size['width'];
138 138
 					$params['h'] = $height = $size['height'];
139 139
 				}
140 140
 			}
141 141
 
142
-			$params = array_filter( $params );
142
+			$params = array_filter($params);
143 143
 
144
-			$img_url = add_query_arg( $params, $img_url );
144
+			$img_url = add_query_arg($params, $img_url);
145 145
 
146
-			if ( ! isset( $width ) || ! isset( $height ) ) {
146
+			if ( ! isset($width) || ! isset($height)) {
147 147
 				// any other type: use the real image
148
-				$meta   = wp_get_attachment_metadata( $attachment_id );
149
-				$width  = isset( $width ) ? $width : $meta['width'];
150
-				$height = isset( $height ) ? $height : $meta['height'];
148
+				$meta   = wp_get_attachment_metadata($attachment_id);
149
+				$width  = isset($width) ? $width : $meta['width'];
150
+				$height = isset($height) ? $height : $meta['height'];
151 151
 			}
152 152
 
153
-			$return = [ $img_url, $width, $height, true ];
153
+			$return = [$img_url, $width, $height, true];
154 154
 		}
155 155
 
156 156
 		return $return;
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
 	 *
166 166
 	 * @return array
167 167
 	 */
168
-	public function calculate_image_srcset( $image_meta, $size_array, $image_src ) {
169
-		foreach ( $image_meta as $i => $image_size ) {
170
-			if ( $image_size['descriptor'] === 'w' ) {
171
-				$image_meta[ $i ]['url'] = add_query_arg( 'w', $image_size['value'], $image_src );
168
+	public function calculate_image_srcset($image_meta, $size_array, $image_src) {
169
+		foreach ($image_meta as $i => $image_size) {
170
+			if ($image_size['descriptor'] === 'w') {
171
+				$image_meta[$i]['url'] = add_query_arg('w', $image_size['value'], $image_src);
172 172
 			}
173 173
 		}
174 174
 
@@ -182,28 +182,28 @@  discard block
 block discarded – undo
182 182
 	 *
183 183
 	 * @return string
184 184
 	 */
185
-	public function replace_images_in_content( $content ) {
186
-		if ( ! empty ( $this->options['cdn_link'] ) ) {
187
-			if ( preg_match_all( '/<img\s[^>]*src=([\"\']??)([^\" >]*?)\1[^>]*>/iU', $content, $matches ) ) {
188
-				foreach ( $matches[2] as $image_src ) {
189
-					$content = str_replace( $image_src, $this->replace_image_url( $image_src ), $content );
185
+	public function replace_images_in_content($content) {
186
+		if ( ! empty ($this->options['cdn_link'])) {
187
+			if (preg_match_all('/<img\s[^>]*src=([\"\']??)([^\" >]*?)\1[^>]*>/iU', $content, $matches)) {
188
+				foreach ($matches[2] as $image_src) {
189
+					$content = str_replace($image_src, $this->replace_image_url($image_src), $content);
190 190
 				}
191 191
 			}
192 192
 
193
-			if ( preg_match_all( '/<img\s[^>]*srcset=([\"\']??)([^\">]*?)\1[^>]*\/?>/iU', $content, $matches ) ) {
193
+			if (preg_match_all('/<img\s[^>]*srcset=([\"\']??)([^\">]*?)\1[^>]*\/?>/iU', $content, $matches)) {
194 194
 
195
-				foreach ( $matches[2] as $image_srcset ) {
196
-					$new_image_srcset = preg_replace_callback( '/(\S+)(\s\d+\w)/', function ( $srcset_matches ) {
197
-						return $this->replace_image_url( $srcset_matches[1] ) . $srcset_matches[2];
198
-					}, $image_srcset );
195
+				foreach ($matches[2] as $image_srcset) {
196
+					$new_image_srcset = preg_replace_callback('/(\S+)(\s\d+\w)/', function($srcset_matches) {
197
+						return $this->replace_image_url($srcset_matches[1]) . $srcset_matches[2];
198
+					}, $image_srcset);
199 199
 
200
-					$content = str_replace( $image_srcset, $new_image_srcset, $content );
200
+					$content = str_replace($image_srcset, $new_image_srcset, $content);
201 201
 				}
202 202
 			}
203 203
 
204
-			if ( preg_match_all( '/<a\s[^>]*href=([\"\']??)([^\" >]*?)\1[^>]*>(.*)<\/a>/iU', $content, $matches ) ) {
205
-				foreach ( $matches[0] as $link ) {
206
-					$content = str_replace( $link[2], $this->replace_image_url( $link[2] ), $content );
204
+			if (preg_match_all('/<a\s[^>]*href=([\"\']??)([^\" >]*?)\1[^>]*>(.*)<\/a>/iU', $content, $matches)) {
205
+				foreach ($matches[0] as $link) {
206
+					$content = str_replace($link[2], $this->replace_image_url($link[2]), $content);
207 207
 				}
208 208
 			}
209 209
 		}
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
 	 * Add tag to dns prefetch cdn host
216 216
 	 */
217 217
 	public function prefetch_cdn() {
218
-		if ( ! empty ( $this->options['cdn_link'] ) ) {
219
-			$host = parse_url( $this->options['cdn_link'], PHP_URL_HOST );
218
+		if ( ! empty ($this->options['cdn_link'])) {
219
+			$host = parse_url($this->options['cdn_link'], PHP_URL_HOST);
220 220
 
221 221
 			printf(
222 222
 				'<link rel="dns-prefetch" href="%s"/>',
223
-				esc_attr( '//' . $host )
223
+				esc_attr('//' . $host)
224 224
 			);
225 225
 		}
226 226
 	}
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
 	 * Start output buffer if auto retina is enabled
230 230
 	 */
231 231
 	public function buffer_start_for_retina() {
232
-		if ( ! empty ( $this->options['add_dpi2_srcset'] ) ) {
232
+		if ( ! empty ($this->options['add_dpi2_srcset'])) {
233 233
 			$this->buffer_started = true;
234
-			ob_start( [ $this, 'add_retina' ] );
234
+			ob_start([$this, 'add_retina']);
235 235
 		}
236 236
 	}
237 237
 
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	 * Stop output buffer if it was enabled by the plugin
240 240
 	 */
241 241
 	public function buffer_end_for_retina() {
242
-		if ( $this->buffer_started === true ) {
242
+		if ($this->buffer_started === true) {
243 243
 			ob_end_flush();
244 244
 		}
245 245
 	}
@@ -255,20 +255,20 @@  discard block
 block discarded – undo
255 255
 
256 256
 		// For now, only "auto" is supported.
257 257
 		$auto = [];
258
-		if ( ! empty ( $this->options['auto_format'] ) ) {
259
-			array_push( $auto, 'format' );
258
+		if ( ! empty ($this->options['auto_format'])) {
259
+			array_push($auto, 'format');
260 260
 		}
261 261
 
262
-		if ( ! empty ( $this->options['auto_enhance'] ) ) {
263
-			array_push( $auto, 'enhance' );
262
+		if ( ! empty ($this->options['auto_enhance'])) {
263
+			array_push($auto, 'enhance');
264 264
 		}
265 265
 
266
-		if ( ! empty ( $this->options['auto_compress'] ) ) {
267
-			array_push( $auto, 'compress' );
266
+		if ( ! empty ($this->options['auto_compress'])) {
267
+			array_push($auto, 'compress');
268 268
 		}
269 269
 
270
-		if ( ! empty( $auto ) ) {
271
-			$params['auto'] = implode( '%2C', $auto );
270
+		if ( ! empty($auto)) {
271
+			$params['auto'] = implode('%2C', $auto);
272 272
 		}
273 273
 
274 274
 		return $params;
@@ -284,18 +284,18 @@  discard block
 block discarded – undo
284 284
 		$theme_image_sizes = wp_get_additional_image_sizes();
285 285
 
286 286
 		$sizes = [];
287
-		foreach ( get_intermediate_image_sizes() as $s ) {
288
-			$sizes[ $s ] = [ 'width' => '', 'height' => '', 'crop' => false ];
289
-			if ( isset( $theme_image_sizes[ $s ] ) ) {
287
+		foreach (get_intermediate_image_sizes() as $s) {
288
+			$sizes[$s] = ['width' => '', 'height' => '', 'crop' => false];
289
+			if (isset($theme_image_sizes[$s])) {
290 290
 				// For theme-added sizes
291
-				$sizes[ $s ]['width']  = intval( $theme_image_sizes[ $s ]['width'] );
292
-				$sizes[ $s ]['height'] = intval( $theme_image_sizes[ $s ]['height'] );
293
-				$sizes[ $s ]['crop']   = $theme_image_sizes[ $s ]['crop'];
291
+				$sizes[$s]['width']  = intval($theme_image_sizes[$s]['width']);
292
+				$sizes[$s]['height'] = intval($theme_image_sizes[$s]['height']);
293
+				$sizes[$s]['crop']   = $theme_image_sizes[$s]['crop'];
294 294
 			} else {
295 295
 				// For default sizes set in options
296
-				$sizes[ $s ]['width']  = get_option( "{$s}_size_w" );
297
-				$sizes[ $s ]['height'] = get_option( "{$s}_size_h" );
298
-				$sizes[ $s ]['crop']   = get_option( "{$s}_crop" );
296
+				$sizes[$s]['width']  = get_option("{$s}_size_w");
297
+				$sizes[$s]['height'] = get_option("{$s}_size_h");
298
+				$sizes[$s]['crop']   = get_option("{$s}_crop");
299 299
 			}
300 300
 		}
301 301
 
Please login to merge, or discard this patch.