Passed
Push — main ( 16d49b...d78e29 )
by TARIQ
111:03
created
brighty/wp-admin/includes/class-automatic-upgrader-skin.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 	 * @param bool          $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false.
38 38
 	 * @return bool True on success, false on failure.
39 39
 	 */
40
-	public function request_filesystem_credentials( $error = false, $context = '', $allow_relaxed_file_ownership = false ) {
41
-		if ( $context ) {
40
+	public function request_filesystem_credentials($error = false, $context = '', $allow_relaxed_file_ownership = false) {
41
+		if ($context) {
42 42
 			$this->options['context'] = $context;
43 43
 		}
44 44
 		/*
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		 * This will output a credentials form in event of failure. We don't want that, so just hide with a buffer.
47 47
 		 */
48 48
 		ob_start();
49
-		$result = parent::request_filesystem_credentials( $error, $context, $allow_relaxed_file_ownership );
49
+		$result = parent::request_filesystem_credentials($error, $context, $allow_relaxed_file_ownership);
50 50
 		ob_end_clean();
51 51
 		return $result;
52 52
 	}
@@ -71,26 +71,26 @@  discard block
 block discarded – undo
71 71
 	 * @param string|array|WP_Error $feedback Message data.
72 72
 	 * @param mixed                 ...$args  Optional text replacements.
73 73
 	 */
74
-	public function feedback( $feedback, ...$args ) {
75
-		if ( is_wp_error( $feedback ) ) {
74
+	public function feedback($feedback, ...$args) {
75
+		if (is_wp_error($feedback)) {
76 76
 			$string = $feedback->get_error_message();
77
-		} elseif ( is_array( $feedback ) ) {
77
+		} elseif (is_array($feedback)) {
78 78
 			return;
79 79
 		} else {
80 80
 			$string = $feedback;
81 81
 		}
82 82
 
83
-		if ( ! empty( $this->upgrader->strings[ $string ] ) ) {
84
-			$string = $this->upgrader->strings[ $string ];
83
+		if (!empty($this->upgrader->strings[$string])) {
84
+			$string = $this->upgrader->strings[$string];
85 85
 		}
86 86
 
87
-		if ( strpos( $string, '%' ) !== false ) {
88
-			if ( ! empty( $args ) ) {
89
-				$string = vsprintf( $string, $args );
87
+		if (strpos($string, '%') !== false) {
88
+			if (!empty($args)) {
89
+				$string = vsprintf($string, $args);
90 90
 			}
91 91
 		}
92 92
 
93
-		$string = trim( $string );
93
+		$string = trim($string);
94 94
 
95 95
 		// Only allow basic HTML in the messages, as it'll be used in emails/logs rather than direct browser output.
96 96
 		$string = wp_kses(
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 			)
106 106
 		);
107 107
 
108
-		if ( empty( $string ) ) {
108
+		if (empty($string)) {
109 109
 			return;
110 110
 		}
111 111
 
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	public function footer() {
130 130
 		$output = ob_get_clean();
131
-		if ( ! empty( $output ) ) {
132
-			$this->feedback( $output );
131
+		if (!empty($output)) {
132
+			$this->feedback($output);
133 133
 		}
134 134
 	}
135 135
 }
Please login to merge, or discard this patch.
brighty/wp-admin/includes/class-wp-post-comments-list-table.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
 	protected function get_column_info() {
24 24
 		return array(
25 25
 			array(
26
-				'author'  => __( 'Author' ),
27
-				'comment' => _x( 'Comment', 'column name' ),
26
+				'author'  => __('Author'),
27
+				'comment' => _x('Comment', 'column name'),
28 28
 			),
29 29
 			array(),
30 30
 			array(),
@@ -45,21 +45,21 @@  discard block
 block discarded – undo
45 45
 	/**
46 46
 	 * @param bool $output_empty
47 47
 	 */
48
-	public function display( $output_empty = false ) {
48
+	public function display($output_empty = false) {
49 49
 		$singular = $this->_args['singular'];
50 50
 
51
-		wp_nonce_field( 'fetch-list-' . get_class( $this ), '_ajax_fetch_list_nonce' );
51
+		wp_nonce_field('fetch-list-' . get_class($this), '_ajax_fetch_list_nonce');
52 52
 		?>
53
-<table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" style="display:none;">
53
+<table class="<?php echo implode(' ', $this->get_table_classes()); ?>" style="display:none;">
54 54
 	<tbody id="the-comment-list"
55 55
 		<?php
56
-		if ( $singular ) {
56
+		if ($singular) {
57 57
 			echo " data-wp-lists='list:$singular'";
58 58
 		}
59 59
 		?>
60 60
 		>
61 61
 		<?php
62
-		if ( ! $output_empty ) {
62
+		if (!$output_empty) {
63 63
 			$this->display_rows_or_placeholder();
64 64
 		}
65 65
 		?>
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 * @param bool $comment_status
73 73
 	 * @return int
74 74
 	 */
75
-	public function get_per_page( $comment_status = false ) {
75
+	public function get_per_page($comment_status = false) {
76 76
 		return 10;
77 77
 	}
78 78
 }
Please login to merge, or discard this patch.
brighty/wp-admin/includes/class-walker-category-checklist.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
 	 * @param int    $depth  Depth of category. Used for tab indentation.
35 35
 	 * @param array  $args   An array of arguments. @see wp_terms_checklist()
36 36
 	 */
37
-	public function start_lvl( &$output, $depth = 0, $args = array() ) {
38
-		$indent  = str_repeat( "\t", $depth );
37
+	public function start_lvl(&$output, $depth = 0, $args = array()) {
38
+		$indent  = str_repeat("\t", $depth);
39 39
 		$output .= "$indent<ul class='children'>\n";
40 40
 	}
41 41
 
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 	 * @param int    $depth  Depth of category. Used for tab indentation.
51 51
 	 * @param array  $args   An array of arguments. @see wp_terms_checklist()
52 52
 	 */
53
-	public function end_lvl( &$output, $depth = 0, $args = array() ) {
54
-		$indent  = str_repeat( "\t", $depth );
53
+	public function end_lvl(&$output, $depth = 0, $args = array()) {
54
+		$indent  = str_repeat("\t", $depth);
55 55
 		$output .= "$indent</ul>\n";
56 56
 	}
57 57
 
@@ -70,33 +70,33 @@  discard block
 block discarded – undo
70 70
 	 * @param array   $args              An array of arguments. @see wp_terms_checklist()
71 71
 	 * @param int     $current_object_id Optional. ID of the current term. Default 0.
72 72
 	 */
73
-	public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_object_id = 0 ) {
73
+	public function start_el(&$output, $data_object, $depth = 0, $args = array(), $current_object_id = 0) {
74 74
 		// Restores the more descriptive, specific name for use within this method.
75 75
 		$category = $data_object;
76 76
 
77
-		if ( empty( $args['taxonomy'] ) ) {
77
+		if (empty($args['taxonomy'])) {
78 78
 			$taxonomy = 'category';
79 79
 		} else {
80 80
 			$taxonomy = $args['taxonomy'];
81 81
 		}
82 82
 
83
-		if ( 'category' === $taxonomy ) {
83
+		if ('category' === $taxonomy) {
84 84
 			$name = 'post_category';
85 85
 		} else {
86 86
 			$name = 'tax_input[' . $taxonomy . ']';
87 87
 		}
88 88
 
89
-		$args['popular_cats'] = ! empty( $args['popular_cats'] ) ? array_map( 'intval', $args['popular_cats'] ) : array();
89
+		$args['popular_cats'] = !empty($args['popular_cats']) ? array_map('intval', $args['popular_cats']) : array();
90 90
 
91
-		$class = in_array( $category->term_id, $args['popular_cats'], true ) ? ' class="popular-category"' : '';
91
+		$class = in_array($category->term_id, $args['popular_cats'], true) ? ' class="popular-category"' : '';
92 92
 
93
-		$args['selected_cats'] = ! empty( $args['selected_cats'] ) ? array_map( 'intval', $args['selected_cats'] ) : array();
93
+		$args['selected_cats'] = !empty($args['selected_cats']) ? array_map('intval', $args['selected_cats']) : array();
94 94
 
95
-		if ( ! empty( $args['list_only'] ) ) {
95
+		if (!empty($args['list_only'])) {
96 96
 			$aria_checked = 'false';
97 97
 			$inner_class  = 'category';
98 98
 
99
-			if ( in_array( $category->term_id, $args['selected_cats'], true ) ) {
99
+			if (in_array($category->term_id, $args['selected_cats'], true)) {
100 100
 				$inner_class .= ' selected';
101 101
 				$aria_checked = 'true';
102 102
 			}
@@ -105,17 +105,17 @@  discard block
 block discarded – undo
105 105
 				'<div class="' . $inner_class . '" data-term-id=' . $category->term_id .
106 106
 				' tabindex="0" role="checkbox" aria-checked="' . $aria_checked . '">' .
107 107
 				/** This filter is documented in wp-includes/category-template.php */
108
-				esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</div>';
108
+				esc_html(apply_filters('the_category', $category->name, '', '')) . '</div>';
109 109
 		} else {
110
-			$is_selected = in_array( $category->term_id, $args['selected_cats'], true );
111
-			$is_disabled = ! empty( $args['disabled'] );
110
+			$is_selected = in_array($category->term_id, $args['selected_cats'], true);
111
+			$is_disabled = !empty($args['disabled']);
112 112
 
113 113
 			$output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" .
114 114
 				'<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="' . $name . '[]" id="in-' . $taxonomy . '-' . $category->term_id . '"' .
115
-				checked( $is_selected, true, false ) .
116
-				disabled( $is_disabled, true, false ) . ' /> ' .
115
+				checked($is_selected, true, false) .
116
+				disabled($is_disabled, true, false) . ' /> ' .
117 117
 				/** This filter is documented in wp-includes/category-template.php */
118
-				esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</label>';
118
+				esc_html(apply_filters('the_category', $category->name, '', '')) . '</label>';
119 119
 		}
120 120
 	}
121 121
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 * @param int     $depth       Depth of the term in reference to parents. Default 0.
133 133
 	 * @param array   $args        An array of arguments. @see wp_terms_checklist()
134 134
 	 */
135
-	public function end_el( &$output, $data_object, $depth = 0, $args = array() ) {
135
+	public function end_el(&$output, $data_object, $depth = 0, $args = array()) {
136 136
 		$output .= "</li>\n";
137 137
 	}
138 138
 }
Please login to merge, or discard this patch.
brighty/wp-admin/includes/theme-install.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
 		'title'  => array(),
13 13
 		'target' => array(),
14 14
 	),
15
-	'abbr'    => array( 'title' => array() ),
16
-	'acronym' => array( 'title' => array() ),
15
+	'abbr'    => array('title' => array()),
16
+	'acronym' => array('title' => array()),
17 17
 	'code'    => array(),
18 18
 	'pre'     => array(),
19 19
 	'em'      => array(),
@@ -60,23 +60,23 @@  discard block
 block discarded – undo
60 60
  * @return array
61 61
  */
62 62
 function install_themes_feature_list() {
63
-	_deprecated_function( __FUNCTION__, '3.1.0', 'get_theme_feature_list()' );
63
+	_deprecated_function(__FUNCTION__, '3.1.0', 'get_theme_feature_list()');
64 64
 
65
-	$cache = get_transient( 'wporg_theme_feature_list' );
66
-	if ( ! $cache ) {
67
-		set_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS );
65
+	$cache = get_transient('wporg_theme_feature_list');
66
+	if (!$cache) {
67
+		set_transient('wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS);
68 68
 	}
69 69
 
70
-	if ( $cache ) {
70
+	if ($cache) {
71 71
 		return $cache;
72 72
 	}
73 73
 
74
-	$feature_list = themes_api( 'feature_list', array() );
75
-	if ( is_wp_error( $feature_list ) ) {
74
+	$feature_list = themes_api('feature_list', array());
75
+	if (is_wp_error($feature_list)) {
76 76
 		return array();
77 77
 	}
78 78
 
79
-	set_transient( 'wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS );
79
+	set_transient('wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS);
80 80
 
81 81
 	return $feature_list;
82 82
 }
@@ -88,42 +88,42 @@  discard block
 block discarded – undo
88 88
  *
89 89
  * @param bool $type_selector
90 90
  */
91
-function install_theme_search_form( $type_selector = true ) {
92
-	$type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term';
93
-	$term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : '';
94
-	if ( ! $type_selector ) {
95
-		echo '<p class="install-help">' . __( 'Search for themes by keyword.' ) . '</p>';
91
+function install_theme_search_form($type_selector = true) {
92
+	$type = isset($_REQUEST['type']) ? wp_unslash($_REQUEST['type']) : 'term';
93
+	$term = isset($_REQUEST['s']) ? wp_unslash($_REQUEST['s']) : '';
94
+	if (!$type_selector) {
95
+		echo '<p class="install-help">' . __('Search for themes by keyword.') . '</p>';
96 96
 	}
97 97
 	?>
98 98
 <form id="search-themes" method="get">
99 99
 	<input type="hidden" name="tab" value="search" />
100
-	<?php if ( $type_selector ) : ?>
101
-	<label class="screen-reader-text" for="typeselector"><?php _e( 'Type of search' ); ?></label>
100
+	<?php if ($type_selector) : ?>
101
+	<label class="screen-reader-text" for="typeselector"><?php _e('Type of search'); ?></label>
102 102
 	<select	name="type" id="typeselector">
103
-	<option value="term" <?php selected( 'term', $type ); ?>><?php _e( 'Keyword' ); ?></option>
104
-	<option value="author" <?php selected( 'author', $type ); ?>><?php _e( 'Author' ); ?></option>
105
-	<option value="tag" <?php selected( 'tag', $type ); ?>><?php _ex( 'Tag', 'Theme Installer' ); ?></option>
103
+	<option value="term" <?php selected('term', $type); ?>><?php _e('Keyword'); ?></option>
104
+	<option value="author" <?php selected('author', $type); ?>><?php _e('Author'); ?></option>
105
+	<option value="tag" <?php selected('tag', $type); ?>><?php _ex('Tag', 'Theme Installer'); ?></option>
106 106
 	</select>
107 107
 	<label class="screen-reader-text" for="s">
108 108
 		<?php
109
-		switch ( $type ) {
109
+		switch ($type) {
110 110
 			case 'term':
111
-				_e( 'Search by keyword' );
111
+				_e('Search by keyword');
112 112
 				break;
113 113
 			case 'author':
114
-				_e( 'Search by author' );
114
+				_e('Search by author');
115 115
 				break;
116 116
 			case 'tag':
117
-				_e( 'Search by tag' );
117
+				_e('Search by tag');
118 118
 				break;
119 119
 		}
120 120
 		?>
121 121
 	</label>
122 122
 	<?php else : ?>
123
-	<label class="screen-reader-text" for="s"><?php _e( 'Search by keyword' ); ?></label>
123
+	<label class="screen-reader-text" for="s"><?php _e('Search by keyword'); ?></label>
124 124
 	<?php endif; ?>
125
-	<input type="search" name="s" id="s" size="30" value="<?php echo esc_attr( $term ); ?>" autofocus="autofocus" />
126
-	<?php submit_button( __( 'Search' ), '', 'search', false ); ?>
125
+	<input type="search" name="s" id="s" size="30" value="<?php echo esc_attr($term); ?>" autofocus="autofocus" />
126
+	<?php submit_button(__('Search'), '', 'search', false); ?>
127 127
 </form>
128 128
 	<?php
129 129
 }
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
  * @since 2.8.0
135 135
  */
136 136
 function install_themes_dashboard() {
137
-	install_theme_search_form( false );
137
+	install_theme_search_form(false);
138 138
 	?>
139
-<h4><?php _e( 'Feature Filter' ); ?></h4>
140
-<p class="install-help"><?php _e( 'Find a theme based on specific features.' ); ?></p>
139
+<h4><?php _e('Feature Filter'); ?></h4>
140
+<p class="install-help"><?php _e('Find a theme based on specific features.'); ?></p>
141 141
 
142 142
 <form method="get">
143 143
 	<input type="hidden" name="tab" value="search" />
@@ -145,14 +145,14 @@  discard block
 block discarded – undo
145 145
 	$feature_list = get_theme_feature_list();
146 146
 	echo '<div class="feature-filter">';
147 147
 
148
-	foreach ( (array) $feature_list as $feature_name => $features ) {
149
-		$feature_name = esc_html( $feature_name );
148
+	foreach ((array) $feature_list as $feature_name => $features) {
149
+		$feature_name = esc_html($feature_name);
150 150
 		echo '<div class="feature-name">' . $feature_name . '</div>';
151 151
 
152 152
 		echo '<ol class="feature-group">';
153
-		foreach ( $features as $feature => $feature_name ) {
154
-			$feature_name = esc_html( $feature_name );
155
-			$feature      = esc_attr( $feature );
153
+		foreach ($features as $feature => $feature_name) {
154
+			$feature_name = esc_html($feature_name);
155
+			$feature      = esc_attr($feature);
156 156
 			?>
157 157
 
158 158
 <li>
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 
170 170
 </div>
171 171
 <br class="clear" />
172
-	<?php submit_button( __( 'Find Themes' ), '', 'search' ); ?>
172
+	<?php submit_button(__('Find Themes'), '', 'search'); ?>
173 173
 </form>
174 174
 	<?php
175 175
 }
@@ -179,12 +179,12 @@  discard block
 block discarded – undo
179 179
  */
180 180
 function install_themes_upload() {
181 181
 	?>
182
-<p class="install-help"><?php _e( 'If you have a theme in a .zip format, you may install or update it by uploading it here.' ); ?></p>
183
-<form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url( 'update.php?action=upload-theme' ); ?>">
184
-	<?php wp_nonce_field( 'theme-upload' ); ?>
185
-	<label class="screen-reader-text" for="themezip"><?php _e( 'Theme zip file' ); ?></label>
182
+<p class="install-help"><?php _e('If you have a theme in a .zip format, you may install or update it by uploading it here.'); ?></p>
183
+<form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url('update.php?action=upload-theme'); ?>">
184
+	<?php wp_nonce_field('theme-upload'); ?>
185
+	<label class="screen-reader-text" for="themezip"><?php _e('Theme zip file'); ?></label>
186 186
 	<input type="file" id="themezip" name="themezip" accept=".zip" />
187
-	<?php submit_button( __( 'Install Now' ), '', 'install-theme-submit', false ); ?>
187
+	<?php submit_button(__('Install Now'), '', 'install-theme-submit', false); ?>
188 188
 </form>
189 189
 	<?php
190 190
 }
@@ -198,14 +198,14 @@  discard block
 block discarded – undo
198 198
  *
199 199
  * @param object $theme
200 200
  */
201
-function display_theme( $theme ) {
202
-	_deprecated_function( __FUNCTION__, '3.4.0' );
201
+function display_theme($theme) {
202
+	_deprecated_function(__FUNCTION__, '3.4.0');
203 203
 	global $wp_list_table;
204
-	if ( ! isset( $wp_list_table ) ) {
205
-		$wp_list_table = _get_list_table( 'WP_Theme_Install_List_Table' );
204
+	if (!isset($wp_list_table)) {
205
+		$wp_list_table = _get_list_table('WP_Theme_Install_List_Table');
206 206
 	}
207 207
 	$wp_list_table->prepare_items();
208
-	$wp_list_table->single_row( $theme );
208
+	$wp_list_table->single_row($theme);
209 209
 }
210 210
 
211 211
 /**
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
 function display_themes() {
219 219
 	global $wp_list_table;
220 220
 
221
-	if ( ! isset( $wp_list_table ) ) {
222
-		$wp_list_table = _get_list_table( 'WP_Theme_Install_List_Table' );
221
+	if (!isset($wp_list_table)) {
222
+		$wp_list_table = _get_list_table('WP_Theme_Install_List_Table');
223 223
 	}
224 224
 	$wp_list_table->prepare_items();
225 225
 	$wp_list_table->display();
@@ -236,17 +236,17 @@  discard block
 block discarded – undo
236 236
 function install_theme_information() {
237 237
 	global $wp_list_table;
238 238
 
239
-	$theme = themes_api( 'theme_information', array( 'slug' => wp_unslash( $_REQUEST['theme'] ) ) );
239
+	$theme = themes_api('theme_information', array('slug' => wp_unslash($_REQUEST['theme'])));
240 240
 
241
-	if ( is_wp_error( $theme ) ) {
242
-		wp_die( $theme );
241
+	if (is_wp_error($theme)) {
242
+		wp_die($theme);
243 243
 	}
244 244
 
245
-	iframe_header( __( 'Theme Installation' ) );
246
-	if ( ! isset( $wp_list_table ) ) {
247
-		$wp_list_table = _get_list_table( 'WP_Theme_Install_List_Table' );
245
+	iframe_header(__('Theme Installation'));
246
+	if (!isset($wp_list_table)) {
247
+		$wp_list_table = _get_list_table('WP_Theme_Install_List_Table');
248 248
 	}
249
-	$wp_list_table->theme_installer_single( $theme );
249
+	$wp_list_table->theme_installer_single($theme);
250 250
 	iframe_footer();
251 251
 	exit;
252 252
 }
Please login to merge, or discard this patch.
brighty/wp-admin/includes/class-ftp-sockets.php 1 patch
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
  */
28 28
 class ftp_sockets extends ftp_base {
29 29
 
30
-	function __construct($verb=FALSE, $le=FALSE) {
30
+	function __construct($verb = FALSE, $le = FALSE) {
31 31
 		parent::__construct(true, $verb, $le);
32 32
 	}
33 33
 
@@ -36,13 +36,13 @@  discard block
 block discarded – undo
36 36
 // <!-- --------------------------------------------------------------------------------------- -->
37 37
 
38 38
 	function _settimeout($sock) {
39
-		if(!@socket_set_option($sock, SOL_SOCKET, SO_RCVTIMEO, array("sec"=>$this->_timeout, "usec"=>0))) {
40
-			$this->PushError('_connect','socket set receive timeout',socket_strerror(socket_last_error($sock)));
39
+		if (!@socket_set_option($sock, SOL_SOCKET, SO_RCVTIMEO, array("sec"=>$this->_timeout, "usec"=>0))) {
40
+			$this->PushError('_connect', 'socket set receive timeout', socket_strerror(socket_last_error($sock)));
41 41
 			@socket_close($sock);
42 42
 			return FALSE;
43 43
 		}
44
-		if(!@socket_set_option($sock, SOL_SOCKET , SO_SNDTIMEO, array("sec"=>$this->_timeout, "usec"=>0))) {
45
-			$this->PushError('_connect','socket set send timeout',socket_strerror(socket_last_error($sock)));
44
+		if (!@socket_set_option($sock, SOL_SOCKET, SO_SNDTIMEO, array("sec"=>$this->_timeout, "usec"=>0))) {
45
+			$this->PushError('_connect', 'socket set send timeout', socket_strerror(socket_last_error($sock)));
46 46
 			@socket_close($sock);
47 47
 			return FALSE;
48 48
 		}
@@ -51,118 +51,118 @@  discard block
 block discarded – undo
51 51
 
52 52
 	function _connect($host, $port) {
53 53
 		$this->SendMSG("Creating socket");
54
-		if(!($sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) {
55
-			$this->PushError('_connect','socket create failed',socket_strerror(socket_last_error($sock)));
54
+		if (!($sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) {
55
+			$this->PushError('_connect', 'socket create failed', socket_strerror(socket_last_error($sock)));
56 56
 			return FALSE;
57 57
 		}
58
-		if(!$this->_settimeout($sock)) return FALSE;
59
-		$this->SendMSG("Connecting to \"".$host.":".$port."\"");
58
+		if (!$this->_settimeout($sock)) return FALSE;
59
+		$this->SendMSG("Connecting to \"" . $host . ":" . $port . "\"");
60 60
 		if (!($res = @socket_connect($sock, $host, $port))) {
61
-			$this->PushError('_connect','socket connect failed',socket_strerror(socket_last_error($sock)));
61
+			$this->PushError('_connect', 'socket connect failed', socket_strerror(socket_last_error($sock)));
62 62
 			@socket_close($sock);
63 63
 			return FALSE;
64 64
 		}
65
-		$this->_connected=true;
65
+		$this->_connected = true;
66 66
 		return $sock;
67 67
 	}
68 68
 
69
-	function _readmsg($fnction="_readmsg"){
70
-		if(!$this->_connected) {
71
-			$this->PushError($fnction,'Connect first');
69
+	function _readmsg($fnction = "_readmsg") {
70
+		if (!$this->_connected) {
71
+			$this->PushError($fnction, 'Connect first');
72 72
 			return FALSE;
73 73
 		}
74
-		$result=true;
75
-		$this->_message="";
76
-		$this->_code=0;
77
-		$go=true;
74
+		$result = true;
75
+		$this->_message = "";
76
+		$this->_code = 0;
77
+		$go = true;
78 78
 		do {
79
-			$tmp=@socket_read($this->_ftp_control_sock, 4096, PHP_BINARY_READ);
80
-			if($tmp===false) {
81
-				$go=$result=false;
82
-				$this->PushError($fnction,'Read failed', socket_strerror(socket_last_error($this->_ftp_control_sock)));
79
+			$tmp = @socket_read($this->_ftp_control_sock, 4096, PHP_BINARY_READ);
80
+			if ($tmp === false) {
81
+				$go = $result = false;
82
+				$this->PushError($fnction, 'Read failed', socket_strerror(socket_last_error($this->_ftp_control_sock)));
83 83
 			} else {
84
-				$this->_message.=$tmp;
85
-				$go = !preg_match("/^([0-9]{3})(-.+\\1)? [^".CRLF."]+".CRLF."$/Us", $this->_message, $regs);
84
+				$this->_message .= $tmp;
85
+				$go = !preg_match("/^([0-9]{3})(-.+\\1)? [^" . CRLF . "]+" . CRLF . "$/Us", $this->_message, $regs);
86 86
 			}
87
-		} while($go);
88
-		if($this->LocalEcho) echo "GET < ".rtrim($this->_message, CRLF).CRLF;
89
-		$this->_code=(int)$regs[1];
87
+		} while ($go);
88
+		if ($this->LocalEcho) echo "GET < " . rtrim($this->_message, CRLF) . CRLF;
89
+		$this->_code = (int) $regs[1];
90 90
 		return $result;
91 91
 	}
92 92
 
93
-	function _exec($cmd, $fnction="_exec") {
94
-		if(!$this->_ready) {
95
-			$this->PushError($fnction,'Connect first');
93
+	function _exec($cmd, $fnction = "_exec") {
94
+		if (!$this->_ready) {
95
+			$this->PushError($fnction, 'Connect first');
96 96
 			return FALSE;
97 97
 		}
98
-		if($this->LocalEcho) echo "PUT > ",$cmd,CRLF;
99
-		$status=@socket_write($this->_ftp_control_sock, $cmd.CRLF);
100
-		if($status===false) {
101
-			$this->PushError($fnction,'socket write failed', socket_strerror(socket_last_error($this->stream)));
98
+		if ($this->LocalEcho) echo "PUT > ", $cmd, CRLF;
99
+		$status = @socket_write($this->_ftp_control_sock, $cmd . CRLF);
100
+		if ($status === false) {
101
+			$this->PushError($fnction, 'socket write failed', socket_strerror(socket_last_error($this->stream)));
102 102
 			return FALSE;
103 103
 		}
104
-		$this->_lastaction=time();
105
-		if(!$this->_readmsg($fnction)) return FALSE;
104
+		$this->_lastaction = time();
105
+		if (!$this->_readmsg($fnction)) return FALSE;
106 106
 		return TRUE;
107 107
 	}
108 108
 
109
-	function _data_prepare($mode=FTP_ASCII) {
110
-		if(!$this->_settype($mode)) return FALSE;
109
+	function _data_prepare($mode = FTP_ASCII) {
110
+		if (!$this->_settype($mode)) return FALSE;
111 111
 		$this->SendMSG("Creating data socket");
112 112
 		$this->_ftp_data_sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
113 113
 		if ($this->_ftp_data_sock < 0) {
114
-			$this->PushError('_data_prepare','socket create failed',socket_strerror(socket_last_error($this->_ftp_data_sock)));
114
+			$this->PushError('_data_prepare', 'socket create failed', socket_strerror(socket_last_error($this->_ftp_data_sock)));
115 115
 			return FALSE;
116 116
 		}
117
-		if(!$this->_settimeout($this->_ftp_data_sock)) {
117
+		if (!$this->_settimeout($this->_ftp_data_sock)) {
118 118
 			$this->_data_close();
119 119
 			return FALSE;
120 120
 		}
121
-		if($this->_passive) {
122
-			if(!$this->_exec("PASV", "pasv")) {
121
+		if ($this->_passive) {
122
+			if (!$this->_exec("PASV", "pasv")) {
123 123
 				$this->_data_close();
124 124
 				return FALSE;
125 125
 			}
126
-			if(!$this->_checkCode()) {
126
+			if (!$this->_checkCode()) {
127 127
 				$this->_data_close();
128 128
 				return FALSE;
129 129
 			}
130 130
 			$ip_port = explode(",", preg_replace("/^.+ \\(?([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+)\\)?.*$/s", "\\1", $this->_message));
131
-			$this->_datahost=$ip_port[0].".".$ip_port[1].".".$ip_port[2].".".$ip_port[3];
132
-			$this->_dataport=(((int)$ip_port[4])<<8) + ((int)$ip_port[5]);
133
-			$this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport);
134
-			if(!@socket_connect($this->_ftp_data_sock, $this->_datahost, $this->_dataport)) {
135
-				$this->PushError("_data_prepare","socket_connect", socket_strerror(socket_last_error($this->_ftp_data_sock)));
131
+			$this->_datahost = $ip_port[0] . "." . $ip_port[1] . "." . $ip_port[2] . "." . $ip_port[3];
132
+			$this->_dataport = (((int) $ip_port[4]) << 8) + ((int) $ip_port[5]);
133
+			$this->SendMSG("Connecting to " . $this->_datahost . ":" . $this->_dataport);
134
+			if (!@socket_connect($this->_ftp_data_sock, $this->_datahost, $this->_dataport)) {
135
+				$this->PushError("_data_prepare", "socket_connect", socket_strerror(socket_last_error($this->_ftp_data_sock)));
136 136
 				$this->_data_close();
137 137
 				return FALSE;
138 138
 			}
139
-			else $this->_ftp_temp_sock=$this->_ftp_data_sock;
139
+			else $this->_ftp_temp_sock = $this->_ftp_data_sock;
140 140
 		} else {
141
-			if(!@socket_getsockname($this->_ftp_control_sock, $addr, $port)) {
142
-				$this->PushError("_data_prepare","cannot get control socket information", socket_strerror(socket_last_error($this->_ftp_control_sock)));
141
+			if (!@socket_getsockname($this->_ftp_control_sock, $addr, $port)) {
142
+				$this->PushError("_data_prepare", "cannot get control socket information", socket_strerror(socket_last_error($this->_ftp_control_sock)));
143 143
 				$this->_data_close();
144 144
 				return FALSE;
145 145
 			}
146
-			if(!@socket_bind($this->_ftp_data_sock,$addr)){
147
-				$this->PushError("_data_prepare","cannot bind data socket", socket_strerror(socket_last_error($this->_ftp_data_sock)));
146
+			if (!@socket_bind($this->_ftp_data_sock, $addr)) {
147
+				$this->PushError("_data_prepare", "cannot bind data socket", socket_strerror(socket_last_error($this->_ftp_data_sock)));
148 148
 				$this->_data_close();
149 149
 				return FALSE;
150 150
 			}
151
-			if(!@socket_listen($this->_ftp_data_sock)) {
152
-				$this->PushError("_data_prepare","cannot listen data socket", socket_strerror(socket_last_error($this->_ftp_data_sock)));
151
+			if (!@socket_listen($this->_ftp_data_sock)) {
152
+				$this->PushError("_data_prepare", "cannot listen data socket", socket_strerror(socket_last_error($this->_ftp_data_sock)));
153 153
 				$this->_data_close();
154 154
 				return FALSE;
155 155
 			}
156
-			if(!@socket_getsockname($this->_ftp_data_sock, $this->_datahost, $this->_dataport)) {
157
-				$this->PushError("_data_prepare","cannot get data socket information", socket_strerror(socket_last_error($this->_ftp_data_sock)));
156
+			if (!@socket_getsockname($this->_ftp_data_sock, $this->_datahost, $this->_dataport)) {
157
+				$this->PushError("_data_prepare", "cannot get data socket information", socket_strerror(socket_last_error($this->_ftp_data_sock)));
158 158
 				$this->_data_close();
159 159
 				return FALSE;
160 160
 			}
161
-			if(!$this->_exec('PORT '.str_replace('.',',',$this->_datahost.'.'.($this->_dataport>>8).'.'.($this->_dataport&0x00FF)), "_port")) {
161
+			if (!$this->_exec('PORT ' . str_replace('.', ',', $this->_datahost . '.' . ($this->_dataport >> 8) . '.' . ($this->_dataport&0x00FF)), "_port")) {
162 162
 				$this->_data_close();
163 163
 				return FALSE;
164 164
 			}
165
-			if(!$this->_checkCode()) {
165
+			if (!$this->_checkCode()) {
166 166
 				$this->_data_close();
167 167
 				return FALSE;
168 168
 			}
@@ -170,61 +170,61 @@  discard block
 block discarded – undo
170 170
 		return TRUE;
171 171
 	}
172 172
 
173
-	function _data_read($mode=FTP_ASCII, $fp=NULL) {
174
-		$NewLine=$this->_eol_code[$this->OS_local];
175
-		if(is_resource($fp)) $out=0;
176
-		else $out="";
177
-		if(!$this->_passive) {
178
-			$this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport);
179
-			$this->_ftp_temp_sock=socket_accept($this->_ftp_data_sock);
180
-			if($this->_ftp_temp_sock===FALSE) {
181
-				$this->PushError("_data_read","socket_accept", socket_strerror(socket_last_error($this->_ftp_temp_sock)));
173
+	function _data_read($mode = FTP_ASCII, $fp = NULL) {
174
+		$NewLine = $this->_eol_code[$this->OS_local];
175
+		if (is_resource($fp)) $out = 0;
176
+		else $out = "";
177
+		if (!$this->_passive) {
178
+			$this->SendMSG("Connecting to " . $this->_datahost . ":" . $this->_dataport);
179
+			$this->_ftp_temp_sock = socket_accept($this->_ftp_data_sock);
180
+			if ($this->_ftp_temp_sock === FALSE) {
181
+				$this->PushError("_data_read", "socket_accept", socket_strerror(socket_last_error($this->_ftp_temp_sock)));
182 182
 				$this->_data_close();
183 183
 				return FALSE;
184 184
 			}
185 185
 		}
186 186
 
187
-		while(($block=@socket_read($this->_ftp_temp_sock, $this->_ftp_buff_size, PHP_BINARY_READ))!==false) {
188
-			if($block==="") break;
189
-			if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block);
190
-			if(is_resource($fp)) $out+=fwrite($fp, $block, strlen($block));
191
-			else $out.=$block;
187
+		while (($block = @socket_read($this->_ftp_temp_sock, $this->_ftp_buff_size, PHP_BINARY_READ)) !== false) {
188
+			if ($block === "") break;
189
+			if ($mode != FTP_BINARY) $block = preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block);
190
+			if (is_resource($fp)) $out += fwrite($fp, $block, strlen($block));
191
+			else $out .= $block;
192 192
 		}
193 193
 		return $out;
194 194
 	}
195 195
 
196
-	function _data_write($mode=FTP_ASCII, $fp=NULL) {
197
-		$NewLine=$this->_eol_code[$this->OS_local];
198
-		if(is_resource($fp)) $out=0;
199
-		else $out="";
200
-		if(!$this->_passive) {
201
-			$this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport);
202
-			$this->_ftp_temp_sock=socket_accept($this->_ftp_data_sock);
203
-			if($this->_ftp_temp_sock===FALSE) {
204
-				$this->PushError("_data_write","socket_accept", socket_strerror(socket_last_error($this->_ftp_temp_sock)));
196
+	function _data_write($mode = FTP_ASCII, $fp = NULL) {
197
+		$NewLine = $this->_eol_code[$this->OS_local];
198
+		if (is_resource($fp)) $out = 0;
199
+		else $out = "";
200
+		if (!$this->_passive) {
201
+			$this->SendMSG("Connecting to " . $this->_datahost . ":" . $this->_dataport);
202
+			$this->_ftp_temp_sock = socket_accept($this->_ftp_data_sock);
203
+			if ($this->_ftp_temp_sock === FALSE) {
204
+				$this->PushError("_data_write", "socket_accept", socket_strerror(socket_last_error($this->_ftp_temp_sock)));
205 205
 				$this->_data_close();
206 206
 				return false;
207 207
 			}
208 208
 		}
209
-		if(is_resource($fp)) {
210
-			while(!feof($fp)) {
211
-				$block=fread($fp, $this->_ftp_buff_size);
212
-				if(!$this->_data_write_block($mode, $block)) return false;
209
+		if (is_resource($fp)) {
210
+			while (!feof($fp)) {
211
+				$block = fread($fp, $this->_ftp_buff_size);
212
+				if (!$this->_data_write_block($mode, $block)) return false;
213 213
 			}
214
-		} elseif(!$this->_data_write_block($mode, $fp)) return false;
214
+		} elseif (!$this->_data_write_block($mode, $fp)) return false;
215 215
 		return true;
216 216
 	}
217 217
 
218 218
 	function _data_write_block($mode, $block) {
219
-		if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block);
219
+		if ($mode != FTP_BINARY) $block = preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block);
220 220
 		do {
221
-			if(($t=@socket_write($this->_ftp_temp_sock, $block))===FALSE) {
222
-				$this->PushError("_data_write","socket_write", socket_strerror(socket_last_error($this->_ftp_temp_sock)));
221
+			if (($t = @socket_write($this->_ftp_temp_sock, $block)) === FALSE) {
222
+				$this->PushError("_data_write", "socket_write", socket_strerror(socket_last_error($this->_ftp_temp_sock)));
223 223
 				$this->_data_close();
224 224
 				return FALSE;
225 225
 			}
226
-			$block=substr($block, $t);
227
-		} while(!empty($block));
226
+			$block = substr($block, $t);
227
+		} while (!empty($block));
228 228
 		return true;
229 229
 	}
230 230
 
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
 	}
237 237
 
238 238
 	function _quit() {
239
-		if($this->_connected) {
239
+		if ($this->_connected) {
240 240
 			@socket_close($this->_ftp_control_sock);
241
-			$this->_connected=false;
241
+			$this->_connected = false;
242 242
 			$this->SendMSG("Socket closed");
243 243
 		}
244 244
 	}
Please login to merge, or discard this patch.
brighty/wp-admin/includes/admin.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
  * @since 2.3.0
8 8
  */
9 9
 
10
-if ( ! defined( 'WP_ADMIN' ) ) {
10
+if (!defined('WP_ADMIN')) {
11 11
 	/*
12 12
 	 * This file is being included from a file other than wp-admin/admin.php, so
13 13
 	 * some setup was skipped. Make sure the admin message catalog is loaded since
14 14
 	 * load_default_textdomain() will not have done so in this context.
15 15
 	 */
16
-	load_textdomain( 'default', WP_LANG_DIR . '/admin-' . get_locale() . '.mo' );
16
+	load_textdomain('default', WP_LANG_DIR . '/admin-' . get_locale() . '.mo');
17 17
 }
18 18
 
19 19
 /** WordPress Administration Hooks */
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 require_once ABSPATH . 'wp-admin/includes/deprecated.php';
93 93
 
94 94
 /** WordPress Multisite support API */
95
-if ( is_multisite() ) {
95
+if (is_multisite()) {
96 96
 	require_once ABSPATH . 'wp-admin/includes/ms-admin-filters.php';
97 97
 	require_once ABSPATH . 'wp-admin/includes/ms.php';
98 98
 	require_once ABSPATH . 'wp-admin/includes/ms-deprecated.php';
Please login to merge, or discard this patch.
brighty/wp-admin/includes/class-wp-filesystem-ftpext.php 1 patch
Spacing   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -28,49 +28,49 @@  discard block
 block discarded – undo
28 28
 	 *
29 29
 	 * @param array $opt
30 30
 	 */
31
-	public function __construct( $opt = '' ) {
31
+	public function __construct($opt = '') {
32 32
 		$this->method = 'ftpext';
33 33
 		$this->errors = new WP_Error();
34 34
 
35 35
 		// Check if possible to use ftp functions.
36
-		if ( ! extension_loaded( 'ftp' ) ) {
37
-			$this->errors->add( 'no_ftp_ext', __( 'The ftp PHP extension is not available' ) );
36
+		if (!extension_loaded('ftp')) {
37
+			$this->errors->add('no_ftp_ext', __('The ftp PHP extension is not available'));
38 38
 			return;
39 39
 		}
40 40
 
41 41
 		// This class uses the timeout on a per-connection basis, others use it on a per-action basis.
42
-		if ( ! defined( 'FS_TIMEOUT' ) ) {
43
-			define( 'FS_TIMEOUT', 240 );
42
+		if (!defined('FS_TIMEOUT')) {
43
+			define('FS_TIMEOUT', 240);
44 44
 		}
45 45
 
46
-		if ( empty( $opt['port'] ) ) {
46
+		if (empty($opt['port'])) {
47 47
 			$this->options['port'] = 21;
48 48
 		} else {
49 49
 			$this->options['port'] = $opt['port'];
50 50
 		}
51 51
 
52
-		if ( empty( $opt['hostname'] ) ) {
53
-			$this->errors->add( 'empty_hostname', __( 'FTP hostname is required' ) );
52
+		if (empty($opt['hostname'])) {
53
+			$this->errors->add('empty_hostname', __('FTP hostname is required'));
54 54
 		} else {
55 55
 			$this->options['hostname'] = $opt['hostname'];
56 56
 		}
57 57
 
58 58
 		// Check if the options provided are OK.
59
-		if ( empty( $opt['username'] ) ) {
60
-			$this->errors->add( 'empty_username', __( 'FTP username is required' ) );
59
+		if (empty($opt['username'])) {
60
+			$this->errors->add('empty_username', __('FTP username is required'));
61 61
 		} else {
62 62
 			$this->options['username'] = $opt['username'];
63 63
 		}
64 64
 
65
-		if ( empty( $opt['password'] ) ) {
66
-			$this->errors->add( 'empty_password', __( 'FTP password is required' ) );
65
+		if (empty($opt['password'])) {
66
+			$this->errors->add('empty_password', __('FTP password is required'));
67 67
 		} else {
68 68
 			$this->options['password'] = $opt['password'];
69 69
 		}
70 70
 
71 71
 		$this->options['ssl'] = false;
72 72
 
73
-		if ( isset( $opt['connection_type'] ) && 'ftps' === $opt['connection_type'] ) {
73
+		if (isset($opt['connection_type']) && 'ftps' === $opt['connection_type']) {
74 74
 			$this->options['ssl'] = true;
75 75
 		}
76 76
 	}
@@ -83,18 +83,18 @@  discard block
 block discarded – undo
83 83
 	 * @return bool True on success, false on failure.
84 84
 	 */
85 85
 	public function connect() {
86
-		if ( isset( $this->options['ssl'] ) && $this->options['ssl'] && function_exists( 'ftp_ssl_connect' ) ) {
87
-			$this->link = @ftp_ssl_connect( $this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT );
86
+		if (isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect')) {
87
+			$this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT);
88 88
 		} else {
89
-			$this->link = @ftp_connect( $this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT );
89
+			$this->link = @ftp_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT);
90 90
 		}
91 91
 
92
-		if ( ! $this->link ) {
92
+		if (!$this->link) {
93 93
 			$this->errors->add(
94 94
 				'connect',
95 95
 				sprintf(
96 96
 					/* translators: %s: hostname:port */
97
-					__( 'Failed to connect to FTP Server %s' ),
97
+					__('Failed to connect to FTP Server %s'),
98 98
 					$this->options['hostname'] . ':' . $this->options['port']
99 99
 				)
100 100
 			);
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
 			return false;
103 103
 		}
104 104
 
105
-		if ( ! @ftp_login( $this->link, $this->options['username'], $this->options['password'] ) ) {
105
+		if (!@ftp_login($this->link, $this->options['username'], $this->options['password'])) {
106 106
 			$this->errors->add(
107 107
 				'auth',
108 108
 				sprintf(
109 109
 					/* translators: %s: Username. */
110
-					__( 'Username/Password incorrect for %s' ),
110
+					__('Username/Password incorrect for %s'),
111 111
 					$this->options['username']
112 112
 				)
113 113
 			);
@@ -116,10 +116,10 @@  discard block
 block discarded – undo
116 116
 		}
117 117
 
118 118
 		// Set the connection to use Passive FTP.
119
-		ftp_pasv( $this->link, true );
119
+		ftp_pasv($this->link, true);
120 120
 
121
-		if ( @ftp_get_option( $this->link, FTP_TIMEOUT_SEC ) < FS_TIMEOUT ) {
122
-			@ftp_set_option( $this->link, FTP_TIMEOUT_SEC, FS_TIMEOUT );
121
+		if (@ftp_get_option($this->link, FTP_TIMEOUT_SEC) < FS_TIMEOUT) {
122
+			@ftp_set_option($this->link, FTP_TIMEOUT_SEC, FS_TIMEOUT);
123 123
 		}
124 124
 
125 125
 		return true;
@@ -134,30 +134,30 @@  discard block
 block discarded – undo
134 134
 	 * @return string|false Read data on success, false if no temporary file could be opened,
135 135
 	 *                      or if the file couldn't be retrieved.
136 136
 	 */
137
-	public function get_contents( $file ) {
138
-		$tempfile   = wp_tempnam( $file );
139
-		$temphandle = fopen( $tempfile, 'w+' );
137
+	public function get_contents($file) {
138
+		$tempfile   = wp_tempnam($file);
139
+		$temphandle = fopen($tempfile, 'w+');
140 140
 
141
-		if ( ! $temphandle ) {
142
-			unlink( $tempfile );
141
+		if (!$temphandle) {
142
+			unlink($tempfile);
143 143
 			return false;
144 144
 		}
145 145
 
146
-		if ( ! ftp_fget( $this->link, $temphandle, $file, FTP_BINARY ) ) {
147
-			fclose( $temphandle );
148
-			unlink( $tempfile );
146
+		if (!ftp_fget($this->link, $temphandle, $file, FTP_BINARY)) {
147
+			fclose($temphandle);
148
+			unlink($tempfile);
149 149
 			return false;
150 150
 		}
151 151
 
152
-		fseek( $temphandle, 0 ); // Skip back to the start of the file being written to.
152
+		fseek($temphandle, 0); // Skip back to the start of the file being written to.
153 153
 		$contents = '';
154 154
 
155
-		while ( ! feof( $temphandle ) ) {
156
-			$contents .= fread( $temphandle, 8 * KB_IN_BYTES );
155
+		while (!feof($temphandle)) {
156
+			$contents .= fread($temphandle, 8 * KB_IN_BYTES);
157 157
 		}
158 158
 
159
-		fclose( $temphandle );
160
-		unlink( $tempfile );
159
+		fclose($temphandle);
160
+		unlink($tempfile);
161 161
 
162 162
 		return $contents;
163 163
 	}
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
 	 * @param string $file Path to the file.
171 171
 	 * @return array|false File contents in an array on success, false on failure.
172 172
 	 */
173
-	public function get_contents_array( $file ) {
174
-		return explode( "\n", $this->get_contents( $file ) );
173
+	public function get_contents_array($file) {
174
+		return explode("\n", $this->get_contents($file));
175 175
 	}
176 176
 
177 177
 	/**
@@ -185,36 +185,36 @@  discard block
 block discarded – undo
185 185
 	 *                            Default false.
186 186
 	 * @return bool True on success, false on failure.
187 187
 	 */
188
-	public function put_contents( $file, $contents, $mode = false ) {
189
-		$tempfile   = wp_tempnam( $file );
190
-		$temphandle = fopen( $tempfile, 'wb+' );
188
+	public function put_contents($file, $contents, $mode = false) {
189
+		$tempfile   = wp_tempnam($file);
190
+		$temphandle = fopen($tempfile, 'wb+');
191 191
 
192
-		if ( ! $temphandle ) {
193
-			unlink( $tempfile );
192
+		if (!$temphandle) {
193
+			unlink($tempfile);
194 194
 			return false;
195 195
 		}
196 196
 
197 197
 		mbstring_binary_safe_encoding();
198 198
 
199
-		$data_length   = strlen( $contents );
200
-		$bytes_written = fwrite( $temphandle, $contents );
199
+		$data_length   = strlen($contents);
200
+		$bytes_written = fwrite($temphandle, $contents);
201 201
 
202 202
 		reset_mbstring_encoding();
203 203
 
204
-		if ( $data_length !== $bytes_written ) {
205
-			fclose( $temphandle );
206
-			unlink( $tempfile );
204
+		if ($data_length !== $bytes_written) {
205
+			fclose($temphandle);
206
+			unlink($tempfile);
207 207
 			return false;
208 208
 		}
209 209
 
210
-		fseek( $temphandle, 0 ); // Skip back to the start of the file being written to.
210
+		fseek($temphandle, 0); // Skip back to the start of the file being written to.
211 211
 
212
-		$ret = ftp_fput( $this->link, $file, $temphandle, FTP_BINARY );
212
+		$ret = ftp_fput($this->link, $file, $temphandle, FTP_BINARY);
213 213
 
214
-		fclose( $temphandle );
215
-		unlink( $tempfile );
214
+		fclose($temphandle);
215
+		unlink($tempfile);
216 216
 
217
-		$this->chmod( $file, $mode );
217
+		$this->chmod($file, $mode);
218 218
 
219 219
 		return $ret;
220 220
 	}
@@ -227,10 +227,10 @@  discard block
 block discarded – undo
227 227
 	 * @return string|false The current working directory on success, false on failure.
228 228
 	 */
229 229
 	public function cwd() {
230
-		$cwd = ftp_pwd( $this->link );
230
+		$cwd = ftp_pwd($this->link);
231 231
 
232
-		if ( $cwd ) {
233
-			$cwd = trailingslashit( $cwd );
232
+		if ($cwd) {
233
+			$cwd = trailingslashit($cwd);
234 234
 		}
235 235
 
236 236
 		return $cwd;
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
 	 * @param string $dir The new current directory.
245 245
 	 * @return bool True on success, false on failure.
246 246
 	 */
247
-	public function chdir( $dir ) {
248
-		return @ftp_chdir( $this->link, $dir );
247
+	public function chdir($dir) {
248
+		return @ftp_chdir($this->link, $dir);
249 249
 	}
250 250
 
251 251
 	/**
@@ -260,11 +260,11 @@  discard block
 block discarded – undo
260 260
 	 *                             Default false.
261 261
 	 * @return bool True on success, false on failure.
262 262
 	 */
263
-	public function chmod( $file, $mode = false, $recursive = false ) {
264
-		if ( ! $mode ) {
265
-			if ( $this->is_file( $file ) ) {
263
+	public function chmod($file, $mode = false, $recursive = false) {
264
+		if (!$mode) {
265
+			if ($this->is_file($file)) {
266 266
 				$mode = FS_CHMOD_FILE;
267
-			} elseif ( $this->is_dir( $file ) ) {
267
+			} elseif ($this->is_dir($file)) {
268 268
 				$mode = FS_CHMOD_DIR;
269 269
 			} else {
270 270
 				return false;
@@ -272,20 +272,20 @@  discard block
 block discarded – undo
272 272
 		}
273 273
 
274 274
 		// chmod any sub-objects if recursive.
275
-		if ( $recursive && $this->is_dir( $file ) ) {
276
-			$filelist = $this->dirlist( $file );
275
+		if ($recursive && $this->is_dir($file)) {
276
+			$filelist = $this->dirlist($file);
277 277
 
278
-			foreach ( (array) $filelist as $filename => $filemeta ) {
279
-				$this->chmod( $file . '/' . $filename, $mode, $recursive );
278
+			foreach ((array) $filelist as $filename => $filemeta) {
279
+				$this->chmod($file . '/' . $filename, $mode, $recursive);
280 280
 			}
281 281
 		}
282 282
 
283 283
 		// chmod the file or directory.
284
-		if ( ! function_exists( 'ftp_chmod' ) ) {
285
-			return (bool) ftp_site( $this->link, sprintf( 'CHMOD %o %s', $mode, $file ) );
284
+		if (!function_exists('ftp_chmod')) {
285
+			return (bool) ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file));
286 286
 		}
287 287
 
288
-		return (bool) ftp_chmod( $this->link, $mode, $file );
288
+		return (bool) ftp_chmod($this->link, $mode, $file);
289 289
 	}
290 290
 
291 291
 	/**
@@ -296,10 +296,10 @@  discard block
 block discarded – undo
296 296
 	 * @param string $file Path to the file.
297 297
 	 * @return string|false Username of the owner on success, false on failure.
298 298
 	 */
299
-	public function owner( $file ) {
300
-		$dir = $this->dirlist( $file );
299
+	public function owner($file) {
300
+		$dir = $this->dirlist($file);
301 301
 
302
-		return $dir[ $file ]['owner'];
302
+		return $dir[$file]['owner'];
303 303
 	}
304 304
 
305 305
 	/**
@@ -310,10 +310,10 @@  discard block
 block discarded – undo
310 310
 	 * @param string $file Path to the file.
311 311
 	 * @return string Mode of the file (the last 3 digits).
312 312
 	 */
313
-	public function getchmod( $file ) {
314
-		$dir = $this->dirlist( $file );
313
+	public function getchmod($file) {
314
+		$dir = $this->dirlist($file);
315 315
 
316
-		return $dir[ $file ]['permsn'];
316
+		return $dir[$file]['permsn'];
317 317
 	}
318 318
 
319 319
 	/**
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
 	 * @param string $file Path to the file.
325 325
 	 * @return string|false The group on success, false on failure.
326 326
 	 */
327
-	public function group( $file ) {
328
-		$dir = $this->dirlist( $file );
327
+	public function group($file) {
328
+		$dir = $this->dirlist($file);
329 329
 
330
-		return $dir[ $file ]['group'];
330
+		return $dir[$file]['group'];
331 331
 	}
332 332
 
333 333
 	/**
@@ -343,18 +343,18 @@  discard block
 block discarded – undo
343 343
 	 *                               0755 for dirs. Default false.
344 344
 	 * @return bool True on success, false on failure.
345 345
 	 */
346
-	public function copy( $source, $destination, $overwrite = false, $mode = false ) {
347
-		if ( ! $overwrite && $this->exists( $destination ) ) {
346
+	public function copy($source, $destination, $overwrite = false, $mode = false) {
347
+		if (!$overwrite && $this->exists($destination)) {
348 348
 			return false;
349 349
 		}
350 350
 
351
-		$content = $this->get_contents( $source );
351
+		$content = $this->get_contents($source);
352 352
 
353
-		if ( false === $content ) {
353
+		if (false === $content) {
354 354
 			return false;
355 355
 		}
356 356
 
357
-		return $this->put_contents( $destination, $content, $mode );
357
+		return $this->put_contents($destination, $content, $mode);
358 358
 	}
359 359
 
360 360
 	/**
@@ -368,8 +368,8 @@  discard block
 block discarded – undo
368 368
 	 *                            Default false.
369 369
 	 * @return bool True on success, false on failure.
370 370
 	 */
371
-	public function move( $source, $destination, $overwrite = false ) {
372
-		return ftp_rename( $this->link, $source, $destination );
371
+	public function move($source, $destination, $overwrite = false) {
372
+		return ftp_rename($this->link, $source, $destination);
373 373
 	}
374 374
 
375 375
 	/**
@@ -384,28 +384,28 @@  discard block
 block discarded – undo
384 384
 	 *                                Default false.
385 385
 	 * @return bool True on success, false on failure.
386 386
 	 */
387
-	public function delete( $file, $recursive = false, $type = false ) {
388
-		if ( empty( $file ) ) {
387
+	public function delete($file, $recursive = false, $type = false) {
388
+		if (empty($file)) {
389 389
 			return false;
390 390
 		}
391 391
 
392
-		if ( 'f' === $type || $this->is_file( $file ) ) {
393
-			return ftp_delete( $this->link, $file );
392
+		if ('f' === $type || $this->is_file($file)) {
393
+			return ftp_delete($this->link, $file);
394 394
 		}
395 395
 
396
-		if ( ! $recursive ) {
397
-			return ftp_rmdir( $this->link, $file );
396
+		if (!$recursive) {
397
+			return ftp_rmdir($this->link, $file);
398 398
 		}
399 399
 
400
-		$filelist = $this->dirlist( trailingslashit( $file ) );
400
+		$filelist = $this->dirlist(trailingslashit($file));
401 401
 
402
-		if ( ! empty( $filelist ) ) {
403
-			foreach ( $filelist as $delete_file ) {
404
-				$this->delete( trailingslashit( $file ) . $delete_file['name'], $recursive, $delete_file['type'] );
402
+		if (!empty($filelist)) {
403
+			foreach ($filelist as $delete_file) {
404
+				$this->delete(trailingslashit($file) . $delete_file['name'], $recursive, $delete_file['type']);
405 405
 			}
406 406
 		}
407 407
 
408
-		return ftp_rmdir( $this->link, $file );
408
+		return ftp_rmdir($this->link, $file);
409 409
 	}
410 410
 
411 411
 	/**
@@ -416,14 +416,14 @@  discard block
 block discarded – undo
416 416
 	 * @param string $file Path to file or directory.
417 417
 	 * @return bool Whether $file exists or not.
418 418
 	 */
419
-	public function exists( $file ) {
420
-		$list = ftp_nlist( $this->link, $file );
419
+	public function exists($file) {
420
+		$list = ftp_nlist($this->link, $file);
421 421
 
422
-		if ( empty( $list ) && $this->is_dir( $file ) ) {
422
+		if (empty($list) && $this->is_dir($file)) {
423 423
 			return true; // File is an empty directory.
424 424
 		}
425 425
 
426
-		return ! empty( $list ); // Empty list = no file, so invert.
426
+		return !empty($list); // Empty list = no file, so invert.
427 427
 	}
428 428
 
429 429
 	/**
@@ -434,8 +434,8 @@  discard block
 block discarded – undo
434 434
 	 * @param string $file File path.
435 435
 	 * @return bool Whether $file is a file.
436 436
 	 */
437
-	public function is_file( $file ) {
438
-		return $this->exists( $file ) && ! $this->is_dir( $file );
437
+	public function is_file($file) {
438
+		return $this->exists($file) && !$this->is_dir($file);
439 439
 	}
440 440
 
441 441
 	/**
@@ -446,12 +446,12 @@  discard block
 block discarded – undo
446 446
 	 * @param string $path Directory path.
447 447
 	 * @return bool Whether $path is a directory.
448 448
 	 */
449
-	public function is_dir( $path ) {
449
+	public function is_dir($path) {
450 450
 		$cwd    = $this->cwd();
451
-		$result = @ftp_chdir( $this->link, trailingslashit( $path ) );
451
+		$result = @ftp_chdir($this->link, trailingslashit($path));
452 452
 
453
-		if ( $result && $path === $this->cwd() || $this->cwd() !== $cwd ) {
454
-			@ftp_chdir( $this->link, $cwd );
453
+		if ($result && $path === $this->cwd() || $this->cwd() !== $cwd) {
454
+			@ftp_chdir($this->link, $cwd);
455 455
 			return true;
456 456
 		}
457 457
 
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 	 * @param string $file Path to file.
467 467
 	 * @return bool Whether $file is readable.
468 468
 	 */
469
-	public function is_readable( $file ) {
469
+	public function is_readable($file) {
470 470
 		return true;
471 471
 	}
472 472
 
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 	 * @param string $file Path to file or directory.
479 479
 	 * @return bool Whether $file is writable.
480 480
 	 */
481
-	public function is_writable( $file ) {
481
+	public function is_writable($file) {
482 482
 		return true;
483 483
 	}
484 484
 
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 	 * @param string $file Path to file.
491 491
 	 * @return int|false Unix timestamp representing last access time, false on failure.
492 492
 	 */
493
-	public function atime( $file ) {
493
+	public function atime($file) {
494 494
 		return false;
495 495
 	}
496 496
 
@@ -502,8 +502,8 @@  discard block
 block discarded – undo
502 502
 	 * @param string $file Path to file.
503 503
 	 * @return int|false Unix timestamp representing modification time, false on failure.
504 504
 	 */
505
-	public function mtime( $file ) {
506
-		return ftp_mdtm( $this->link, $file );
505
+	public function mtime($file) {
506
+		return ftp_mdtm($this->link, $file);
507 507
 	}
508 508
 
509 509
 	/**
@@ -514,8 +514,8 @@  discard block
 block discarded – undo
514 514
 	 * @param string $file Path to file.
515 515
 	 * @return int|false Size of the file in bytes on success, false on failure.
516 516
 	 */
517
-	public function size( $file ) {
518
-		return ftp_size( $this->link, $file );
517
+	public function size($file) {
518
+		return ftp_size($this->link, $file);
519 519
 	}
520 520
 
521 521
 	/**
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 	 *                      Default 0.
533 533
 	 * @return bool True on success, false on failure.
534 534
 	 */
535
-	public function touch( $file, $time = 0, $atime = 0 ) {
535
+	public function touch($file, $time = 0, $atime = 0) {
536 536
 		return false;
537 537
 	}
538 538
 
@@ -550,18 +550,18 @@  discard block
 block discarded – undo
550 550
 	 *                                Default false.
551 551
 	 * @return bool True on success, false on failure.
552 552
 	 */
553
-	public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
554
-		$path = untrailingslashit( $path );
553
+	public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
554
+		$path = untrailingslashit($path);
555 555
 
556
-		if ( empty( $path ) ) {
556
+		if (empty($path)) {
557 557
 			return false;
558 558
 		}
559 559
 
560
-		if ( ! ftp_mkdir( $this->link, $path ) ) {
560
+		if (!ftp_mkdir($this->link, $path)) {
561 561
 			return false;
562 562
 		}
563 563
 
564
-		$this->chmod( $path, $chmod );
564
+		$this->chmod($path, $chmod);
565 565
 
566 566
 		return true;
567 567
 	}
@@ -576,33 +576,33 @@  discard block
 block discarded – undo
576 576
 	 *                          Default false.
577 577
 	 * @return bool True on success, false on failure.
578 578
 	 */
579
-	public function rmdir( $path, $recursive = false ) {
580
-		return $this->delete( $path, $recursive );
579
+	public function rmdir($path, $recursive = false) {
580
+		return $this->delete($path, $recursive);
581 581
 	}
582 582
 
583 583
 	/**
584 584
 	 * @param string $line
585 585
 	 * @return array
586 586
 	 */
587
-	public function parselisting( $line ) {
587
+	public function parselisting($line) {
588 588
 		static $is_windows = null;
589 589
 
590
-		if ( is_null( $is_windows ) ) {
591
-			$is_windows = stripos( ftp_systype( $this->link ), 'win' ) !== false;
590
+		if (is_null($is_windows)) {
591
+			$is_windows = stripos(ftp_systype($this->link), 'win') !== false;
592 592
 		}
593 593
 
594
-		if ( $is_windows && preg_match( '/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/', $line, $lucifer ) ) {
594
+		if ($is_windows && preg_match('/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/', $line, $lucifer)) {
595 595
 			$b = array();
596 596
 
597
-			if ( $lucifer[3] < 70 ) {
597
+			if ($lucifer[3] < 70) {
598 598
 				$lucifer[3] += 2000;
599 599
 			} else {
600 600
 				$lucifer[3] += 1900; // 4-digit year fix.
601 601
 			}
602 602
 
603
-			$b['isdir'] = ( '<DIR>' === $lucifer[7] );
603
+			$b['isdir'] = ('<DIR>' === $lucifer[7]);
604 604
 
605
-			if ( $b['isdir'] ) {
605
+			if ($b['isdir']) {
606 606
 				$b['type'] = 'd';
607 607
 			} else {
608 608
 				$b['type'] = 'f';
@@ -614,17 +614,17 @@  discard block
 block discarded – undo
614 614
 			$b['year']   = $lucifer[3];
615 615
 			$b['hour']   = $lucifer[4];
616 616
 			$b['minute'] = $lucifer[5];
617
-			$b['time']   = mktime( $lucifer[4] + ( strcasecmp( $lucifer[6], 'PM' ) === 0 ? 12 : 0 ), $lucifer[5], 0, $lucifer[1], $lucifer[2], $lucifer[3] );
617
+			$b['time']   = mktime($lucifer[4] + (strcasecmp($lucifer[6], 'PM') === 0 ? 12 : 0), $lucifer[5], 0, $lucifer[1], $lucifer[2], $lucifer[3]);
618 618
 			$b['am/pm']  = $lucifer[6];
619 619
 			$b['name']   = $lucifer[8];
620
-		} elseif ( ! $is_windows ) {
621
-			$lucifer = preg_split( '/[ ]/', $line, 9, PREG_SPLIT_NO_EMPTY );
620
+		} elseif (!$is_windows) {
621
+			$lucifer = preg_split('/[ ]/', $line, 9, PREG_SPLIT_NO_EMPTY);
622 622
 
623
-			if ( $lucifer ) {
623
+			if ($lucifer) {
624 624
 				// echo $line."\n";
625
-				$lcount = count( $lucifer );
625
+				$lcount = count($lucifer);
626 626
 
627
-				if ( $lcount < 8 ) {
627
+				if ($lcount < 8) {
628 628
 					return '';
629 629
 				}
630 630
 
@@ -632,33 +632,33 @@  discard block
 block discarded – undo
632 632
 				$b['isdir']  = 'd' === $lucifer[0][0];
633 633
 				$b['islink'] = 'l' === $lucifer[0][0];
634 634
 
635
-				if ( $b['isdir'] ) {
635
+				if ($b['isdir']) {
636 636
 					$b['type'] = 'd';
637
-				} elseif ( $b['islink'] ) {
637
+				} elseif ($b['islink']) {
638 638
 					$b['type'] = 'l';
639 639
 				} else {
640 640
 					$b['type'] = 'f';
641 641
 				}
642 642
 
643 643
 				$b['perms']  = $lucifer[0];
644
-				$b['permsn'] = $this->getnumchmodfromh( $b['perms'] );
644
+				$b['permsn'] = $this->getnumchmodfromh($b['perms']);
645 645
 				$b['number'] = $lucifer[1];
646 646
 				$b['owner']  = $lucifer[2];
647 647
 				$b['group']  = $lucifer[3];
648 648
 				$b['size']   = $lucifer[4];
649 649
 
650
-				if ( 8 === $lcount ) {
651
-					sscanf( $lucifer[5], '%d-%d-%d', $b['year'], $b['month'], $b['day'] );
652
-					sscanf( $lucifer[6], '%d:%d', $b['hour'], $b['minute'] );
650
+				if (8 === $lcount) {
651
+					sscanf($lucifer[5], '%d-%d-%d', $b['year'], $b['month'], $b['day']);
652
+					sscanf($lucifer[6], '%d:%d', $b['hour'], $b['minute']);
653 653
 
654
-					$b['time'] = mktime( $b['hour'], $b['minute'], 0, $b['month'], $b['day'], $b['year'] );
654
+					$b['time'] = mktime($b['hour'], $b['minute'], 0, $b['month'], $b['day'], $b['year']);
655 655
 					$b['name'] = $lucifer[7];
656 656
 				} else {
657 657
 					$b['month'] = $lucifer[5];
658 658
 					$b['day']   = $lucifer[6];
659 659
 
660
-					if ( preg_match( '/([0-9]{2}):([0-9]{2})/', $lucifer[7], $l2 ) ) {
661
-						$b['year']   = gmdate( 'Y' );
660
+					if (preg_match('/([0-9]{2}):([0-9]{2})/', $lucifer[7], $l2)) {
661
+						$b['year']   = gmdate('Y');
662 662
 						$b['hour']   = $l2[1];
663 663
 						$b['minute'] = $l2[2];
664 664
 					} else {
@@ -667,15 +667,15 @@  discard block
 block discarded – undo
667 667
 						$b['minute'] = 0;
668 668
 					}
669 669
 
670
-					$b['time'] = strtotime( sprintf( '%d %s %d %02d:%02d', $b['day'], $b['month'], $b['year'], $b['hour'], $b['minute'] ) );
670
+					$b['time'] = strtotime(sprintf('%d %s %d %02d:%02d', $b['day'], $b['month'], $b['year'], $b['hour'], $b['minute']));
671 671
 					$b['name'] = $lucifer[8];
672 672
 				}
673 673
 			}
674 674
 		}
675 675
 
676 676
 		// Replace symlinks formatted as "source -> target" with just the source name.
677
-		if ( isset( $b['islink'] ) && $b['islink'] ) {
678
-			$b['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $b['name'] );
677
+		if (isset($b['islink']) && $b['islink']) {
678
+			$b['name'] = preg_replace('/(\s*->\s*.*)$/', '', $b['name']);
679 679
 		}
680 680
 
681 681
 		return $b;
@@ -706,64 +706,64 @@  discard block
 block discarded – undo
706 706
 	 *     @type mixed  $files       If a directory and `$recursive` is true, contains another array of files.
707 707
 	 * }
708 708
 	 */
709
-	public function dirlist( $path = '.', $include_hidden = true, $recursive = false ) {
710
-		if ( $this->is_file( $path ) ) {
711
-			$limit_file = basename( $path );
712
-			$path       = dirname( $path ) . '/';
709
+	public function dirlist($path = '.', $include_hidden = true, $recursive = false) {
710
+		if ($this->is_file($path)) {
711
+			$limit_file = basename($path);
712
+			$path       = dirname($path) . '/';
713 713
 		} else {
714 714
 			$limit_file = false;
715 715
 		}
716 716
 
717
-		$pwd = ftp_pwd( $this->link );
717
+		$pwd = ftp_pwd($this->link);
718 718
 
719
-		if ( ! @ftp_chdir( $this->link, $path ) ) { // Can't change to folder = folder doesn't exist.
719
+		if (!@ftp_chdir($this->link, $path)) { // Can't change to folder = folder doesn't exist.
720 720
 			return false;
721 721
 		}
722 722
 
723
-		$list = ftp_rawlist( $this->link, '-a', false );
723
+		$list = ftp_rawlist($this->link, '-a', false);
724 724
 
725
-		@ftp_chdir( $this->link, $pwd );
725
+		@ftp_chdir($this->link, $pwd);
726 726
 
727
-		if ( empty( $list ) ) { // Empty array = non-existent folder (real folder will show . at least).
727
+		if (empty($list)) { // Empty array = non-existent folder (real folder will show . at least).
728 728
 			return false;
729 729
 		}
730 730
 
731 731
 		$dirlist = array();
732 732
 
733
-		foreach ( $list as $k => $v ) {
734
-			$entry = $this->parselisting( $v );
733
+		foreach ($list as $k => $v) {
734
+			$entry = $this->parselisting($v);
735 735
 
736
-			if ( empty( $entry ) ) {
736
+			if (empty($entry)) {
737 737
 				continue;
738 738
 			}
739 739
 
740
-			if ( '.' === $entry['name'] || '..' === $entry['name'] ) {
740
+			if ('.' === $entry['name'] || '..' === $entry['name']) {
741 741
 				continue;
742 742
 			}
743 743
 
744
-			if ( ! $include_hidden && '.' === $entry['name'][0] ) {
744
+			if (!$include_hidden && '.' === $entry['name'][0]) {
745 745
 				continue;
746 746
 			}
747 747
 
748
-			if ( $limit_file && $entry['name'] !== $limit_file ) {
748
+			if ($limit_file && $entry['name'] !== $limit_file) {
749 749
 				continue;
750 750
 			}
751 751
 
752
-			$dirlist[ $entry['name'] ] = $entry;
752
+			$dirlist[$entry['name']] = $entry;
753 753
 		}
754 754
 
755 755
 		$ret = array();
756 756
 
757
-		foreach ( (array) $dirlist as $struc ) {
758
-			if ( 'd' === $struc['type'] ) {
759
-				if ( $recursive ) {
760
-					$struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive );
757
+		foreach ((array) $dirlist as $struc) {
758
+			if ('d' === $struc['type']) {
759
+				if ($recursive) {
760
+					$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
761 761
 				} else {
762 762
 					$struc['files'] = array();
763 763
 				}
764 764
 			}
765 765
 
766
-			$ret[ $struc['name'] ] = $struc;
766
+			$ret[$struc['name']] = $struc;
767 767
 		}
768 768
 
769 769
 		return $ret;
@@ -775,8 +775,8 @@  discard block
 block discarded – undo
775 775
 	 * @since 2.5.0
776 776
 	 */
777 777
 	public function __destruct() {
778
-		if ( $this->link ) {
779
-			ftp_close( $this->link );
778
+		if ($this->link) {
779
+			ftp_close($this->link);
780 780
 		}
781 781
 	}
782 782
 }
Please login to merge, or discard this patch.
brighty/wp-admin/includes/image-edit.php 1 patch
Spacing   +314 added lines, -314 removed lines patch added patch discarded remove patch
@@ -15,31 +15,31 @@  discard block
 block discarded – undo
15 15
  * @param false|object $msg     Optional. Message to display for image editor updates or errors.
16 16
  *                              Default false.
17 17
  */
18
-function wp_image_editor( $post_id, $msg = false ) {
19
-	$nonce     = wp_create_nonce( "image_editor-$post_id" );
20
-	$meta      = wp_get_attachment_metadata( $post_id );
21
-	$thumb     = image_get_intermediate_size( $post_id, 'thumbnail' );
22
-	$sub_sizes = isset( $meta['sizes'] ) && is_array( $meta['sizes'] );
18
+function wp_image_editor($post_id, $msg = false) {
19
+	$nonce     = wp_create_nonce("image_editor-$post_id");
20
+	$meta      = wp_get_attachment_metadata($post_id);
21
+	$thumb     = image_get_intermediate_size($post_id, 'thumbnail');
22
+	$sub_sizes = isset($meta['sizes']) && is_array($meta['sizes']);
23 23
 	$note      = '';
24 24
 
25
-	if ( isset( $meta['width'], $meta['height'] ) ) {
26
-		$big = max( $meta['width'], $meta['height'] );
25
+	if (isset($meta['width'], $meta['height'])) {
26
+		$big = max($meta['width'], $meta['height']);
27 27
 	} else {
28
-		die( __( 'Image data does not exist. Please re-upload the image.' ) );
28
+		die(__('Image data does not exist. Please re-upload the image.'));
29 29
 	}
30 30
 
31 31
 	$sizer = $big > 400 ? 400 / $big : 1;
32 32
 
33
-	$backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
33
+	$backup_sizes = get_post_meta($post_id, '_wp_attachment_backup_sizes', true);
34 34
 	$can_restore  = false;
35
-	if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) {
36
-		$can_restore = wp_basename( $meta['file'] ) !== $backup_sizes['full-orig']['file'];
35
+	if (!empty($backup_sizes) && isset($backup_sizes['full-orig'], $meta['file'])) {
36
+		$can_restore = wp_basename($meta['file']) !== $backup_sizes['full-orig']['file'];
37 37
 	}
38 38
 
39
-	if ( $msg ) {
40
-		if ( isset( $msg->error ) ) {
39
+	if ($msg) {
40
+		if (isset($msg->error)) {
41 41
 			$note = "<div class='notice notice-error' tabindex='-1' role='alert'><p>$msg->error</p></div>";
42
-		} elseif ( isset( $msg->msg ) ) {
42
+		} elseif (isset($msg->msg)) {
43 43
 			$note = "<div class='notice notice-success' tabindex='-1' role='alert'><p>$msg->msg</p></div>";
44 44
 		}
45 45
 	}
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 *
52 52
 	 * @param bool|string[] $edit_custom_sizes True if custom sizes can be edited or array of custom size names.
53 53
 	 */
54
-	$edit_custom_sizes = apply_filters( 'edit_custom_thumbnail_sizes', $edit_custom_sizes );
54
+	$edit_custom_sizes = apply_filters('edit_custom_thumbnail_sizes', $edit_custom_sizes);
55 55
 	?>
56 56
 	<div class="imgedit-wrap wp-clearfix">
57 57
 	<div id="imgedit-panel-<?php echo $post_id; ?>">
@@ -59,34 +59,34 @@  discard block
 block discarded – undo
59 59
 	<div class="imgedit-panel-content wp-clearfix">
60 60
 		<?php echo $note; ?>
61 61
 		<div class="imgedit-menu wp-clearfix">
62
-			<button type="button" onclick="imageEdit.handleCropToolClick( <?php echo "$post_id, '$nonce'"; ?>, this )" class="imgedit-crop button disabled" disabled><?php esc_html_e( 'Crop' ); ?></button>
62
+			<button type="button" onclick="imageEdit.handleCropToolClick( <?php echo "$post_id, '$nonce'"; ?>, this )" class="imgedit-crop button disabled" disabled><?php esc_html_e('Crop'); ?></button>
63 63
 			<?php
64 64
 
65 65
 			// On some setups GD library does not provide imagerotate() - Ticket #11536.
66
-			if ( wp_image_editor_supports(
66
+			if (wp_image_editor_supports(
67 67
 				array(
68
-					'mime_type' => get_post_mime_type( $post_id ),
69
-					'methods'   => array( 'rotate' ),
68
+					'mime_type' => get_post_mime_type($post_id),
69
+					'methods'   => array('rotate'),
70 70
 				)
71
-			) ) {
71
+			)) {
72 72
 				$note_no_rotate = '';
73 73
 				?>
74
-				<button type="button" class="imgedit-rleft button" onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)"><?php esc_html_e( 'Rotate left' ); ?></button>
75
-				<button type="button" class="imgedit-rright button" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)"><?php esc_html_e( 'Rotate right' ); ?></button>
74
+				<button type="button" class="imgedit-rleft button" onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)"><?php esc_html_e('Rotate left'); ?></button>
75
+				<button type="button" class="imgedit-rright button" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)"><?php esc_html_e('Rotate right'); ?></button>
76 76
 				<?php
77 77
 			} else {
78
-				$note_no_rotate = '<p class="note-no-rotate"><em>' . __( 'Image rotation is not supported by your web host.' ) . '</em></p>';
78
+				$note_no_rotate = '<p class="note-no-rotate"><em>' . __('Image rotation is not supported by your web host.') . '</em></p>';
79 79
 				?>
80 80
 				<button type="button" class="imgedit-rleft button disabled" disabled></button>
81 81
 				<button type="button" class="imgedit-rright button disabled" disabled></button>
82 82
 			<?php } ?>
83 83
 
84
-			<button type="button" onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-flipv button"><?php esc_html_e( 'Flip vertical' ); ?></button>
85
-			<button type="button" onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-fliph button"><?php esc_html_e( 'Flip horizontal' ); ?></button>
84
+			<button type="button" onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-flipv button"><?php esc_html_e('Flip vertical'); ?></button>
85
+			<button type="button" onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-fliph button"><?php esc_html_e('Flip horizontal'); ?></button>
86 86
 
87 87
 			<br class="imgedit-undo-redo-separator" />
88
-			<button type="button" id="image-undo-<?php echo $post_id; ?>" onclick="imageEdit.undo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-undo button disabled" disabled><?php esc_html_e( 'Undo' ); ?></button>
89
-			<button type="button" id="image-redo-<?php echo $post_id; ?>" onclick="imageEdit.redo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-redo button disabled" disabled><?php esc_html_e( 'Redo' ); ?></button>
88
+			<button type="button" id="image-undo-<?php echo $post_id; ?>" onclick="imageEdit.undo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-undo button disabled" disabled><?php esc_html_e('Undo'); ?></button>
89
+			<button type="button" id="image-redo-<?php echo $post_id; ?>" onclick="imageEdit.redo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-redo button disabled" disabled><?php esc_html_e('Redo'); ?></button>
90 90
 			<?php echo $note_no_rotate; ?>
91 91
 		</div>
92 92
 
@@ -94,34 +94,34 @@  discard block
 block discarded – undo
94 94
 		<input type="hidden" id="imgedit-history-<?php echo $post_id; ?>" value="" />
95 95
 		<input type="hidden" id="imgedit-undone-<?php echo $post_id; ?>" value="0" />
96 96
 		<input type="hidden" id="imgedit-selection-<?php echo $post_id; ?>" value="" />
97
-		<input type="hidden" id="imgedit-x-<?php echo $post_id; ?>" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" />
98
-		<input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" />
97
+		<input type="hidden" id="imgedit-x-<?php echo $post_id; ?>" value="<?php echo isset($meta['width']) ? $meta['width'] : 0; ?>" />
98
+		<input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo isset($meta['height']) ? $meta['height'] : 0; ?>" />
99 99
 
100 100
 		<div id="imgedit-crop-<?php echo $post_id; ?>" class="imgedit-crop-wrap">
101 101
 		<img id="image-preview-<?php echo $post_id; ?>" onload="imageEdit.imgLoaded('<?php echo $post_id; ?>')"
102
-			src="<?php echo esc_url( admin_url( 'admin-ajax.php', 'relative' ) ) . '?action=imgedit-preview&amp;_ajax_nonce=' . $nonce . '&amp;postid=' . $post_id . '&amp;rand=' . rand( 1, 99999 ); ?>" alt="" />
102
+			src="<?php echo esc_url(admin_url('admin-ajax.php', 'relative')) . '?action=imgedit-preview&amp;_ajax_nonce=' . $nonce . '&amp;postid=' . $post_id . '&amp;rand=' . rand(1, 99999); ?>" alt="" />
103 103
 		</div>
104 104
 
105 105
 		<div class="imgedit-submit">
106
-			<input type="button" onclick="imageEdit.close(<?php echo $post_id; ?>, 1)" class="button imgedit-cancel-btn" value="<?php esc_attr_e( 'Cancel' ); ?>" />
107
-			<input type="button" onclick="imageEdit.save(<?php echo "$post_id, '$nonce'"; ?>)" disabled="disabled" class="button button-primary imgedit-submit-btn" value="<?php esc_attr_e( 'Save' ); ?>" />
106
+			<input type="button" onclick="imageEdit.close(<?php echo $post_id; ?>, 1)" class="button imgedit-cancel-btn" value="<?php esc_attr_e('Cancel'); ?>" />
107
+			<input type="button" onclick="imageEdit.save(<?php echo "$post_id, '$nonce'"; ?>)" disabled="disabled" class="button button-primary imgedit-submit-btn" value="<?php esc_attr_e('Save'); ?>" />
108 108
 		</div>
109 109
 	</div>
110 110
 
111 111
 	<div class="imgedit-settings">
112 112
 	<div class="imgedit-group">
113 113
 	<div class="imgedit-group-top">
114
-		<h2><?php _e( 'Scale Image' ); ?></h2>
115
-		<button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e( 'Scale Image Help' ); ?></span></button>
114
+		<h2><?php _e('Scale Image'); ?></h2>
115
+		<button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e('Scale Image Help'); ?></span></button>
116 116
 		<div class="imgedit-help">
117
-		<p><?php _e( 'You can proportionally scale the original image. For best results, scaling should be done before you crop, flip, or rotate. Images can only be scaled down, not up.' ); ?></p>
117
+		<p><?php _e('You can proportionally scale the original image. For best results, scaling should be done before you crop, flip, or rotate. Images can only be scaled down, not up.'); ?></p>
118 118
 		</div>
119
-		<?php if ( isset( $meta['width'], $meta['height'] ) ) : ?>
119
+		<?php if (isset($meta['width'], $meta['height'])) : ?>
120 120
 		<p>
121 121
 			<?php
122 122
 			printf(
123 123
 				/* translators: %s: Image width and height in pixels. */
124
-				__( 'Original dimensions %s' ),
124
+				__('Original dimensions %s'),
125 125
 				'<span class="imgedit-original-dimensions">' . $meta['width'] . ' &times; ' . $meta['height'] . '</span>'
126 126
 			);
127 127
 			?>
@@ -130,15 +130,15 @@  discard block
 block discarded – undo
130 130
 		<div class="imgedit-submit">
131 131
 
132 132
 		<fieldset class="imgedit-scale">
133
-		<legend><?php _e( 'New dimensions:' ); ?></legend>
133
+		<legend><?php _e('New dimensions:'); ?></legend>
134 134
 		<div class="nowrap">
135
-		<label for="imgedit-scale-width-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e( 'scale width' ); ?></label>
136
-		<input type="text" id="imgedit-scale-width-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1, this)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1, this)" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" />
135
+		<label for="imgedit-scale-width-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e('scale width'); ?></label>
136
+		<input type="text" id="imgedit-scale-width-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1, this)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1, this)" value="<?php echo isset($meta['width']) ? $meta['width'] : 0; ?>" />
137 137
 		<span class="imgedit-separator" aria-hidden="true">&times;</span>
138
-		<label for="imgedit-scale-height-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e( 'scale height' ); ?></label>
139
-		<input type="text" id="imgedit-scale-height-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0, this)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0, this)" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" />
138
+		<label for="imgedit-scale-height-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e('scale height'); ?></label>
139
+		<input type="text" id="imgedit-scale-height-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0, this)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0, this)" value="<?php echo isset($meta['height']) ? $meta['height'] : 0; ?>" />
140 140
 		<span class="imgedit-scale-warn" id="imgedit-scale-warn-<?php echo $post_id; ?>">!</span>
141
-		<div class="imgedit-scale-button-wrapper"><input id="imgedit-scale-button" type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'scale')" class="button button-primary" value="<?php esc_attr_e( 'Scale' ); ?>" /></div>
141
+		<div class="imgedit-scale-button-wrapper"><input id="imgedit-scale-button" type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'scale')" class="button button-primary" value="<?php esc_attr_e('Scale'); ?>" /></div>
142 142
 		</div>
143 143
 		</fieldset>
144 144
 
@@ -146,23 +146,23 @@  discard block
 block discarded – undo
146 146
 	</div>
147 147
 	</div>
148 148
 
149
-	<?php if ( $can_restore ) { ?>
149
+	<?php if ($can_restore) { ?>
150 150
 
151 151
 	<div class="imgedit-group">
152 152
 	<div class="imgedit-group-top">
153
-		<h2><button type="button" onclick="imageEdit.toggleHelp(this);" class="button-link" aria-expanded="false"><?php _e( 'Restore original image' ); ?> <span class="dashicons dashicons-arrow-down imgedit-help-toggle"></span></button></h2>
153
+		<h2><button type="button" onclick="imageEdit.toggleHelp(this);" class="button-link" aria-expanded="false"><?php _e('Restore original image'); ?> <span class="dashicons dashicons-arrow-down imgedit-help-toggle"></span></button></h2>
154 154
 		<div class="imgedit-help imgedit-restore">
155 155
 		<p>
156 156
 			<?php
157
-			_e( 'Discard any changes and restore the original image.' );
157
+			_e('Discard any changes and restore the original image.');
158 158
 
159
-			if ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE ) {
160
-				echo ' ' . __( 'Previously edited copies of the image will not be deleted.' );
159
+			if (!defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE) {
160
+				echo ' ' . __('Previously edited copies of the image will not be deleted.');
161 161
 			}
162 162
 			?>
163 163
 		</p>
164 164
 		<div class="imgedit-submit">
165
-		<input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'restore')" class="button button-primary" value="<?php esc_attr_e( 'Restore image' ); ?>" <?php echo $can_restore; ?> />
165
+		<input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'restore')" class="button button-primary" value="<?php esc_attr_e('Restore image'); ?>" <?php echo $can_restore; ?> />
166 166
 		</div>
167 167
 		</div>
168 168
 	</div>
@@ -172,38 +172,38 @@  discard block
 block discarded – undo
172 172
 
173 173
 	<div class="imgedit-group">
174 174
 	<div class="imgedit-group-top">
175
-		<h2><?php _e( 'Image Crop' ); ?></h2>
176
-		<button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e( 'Image Crop Help' ); ?></span></button>
175
+		<h2><?php _e('Image Crop'); ?></h2>
176
+		<button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e('Image Crop Help'); ?></span></button>
177 177
 
178 178
 		<div class="imgedit-help">
179
-		<p><?php _e( 'To crop the image, click on it and drag to make your selection.' ); ?></p>
179
+		<p><?php _e('To crop the image, click on it and drag to make your selection.'); ?></p>
180 180
 
181
-		<p><strong><?php _e( 'Crop Aspect Ratio' ); ?></strong><br />
182
-		<?php _e( 'The aspect ratio is the relationship between the width and height. You can preserve the aspect ratio by holding down the shift key while resizing your selection. Use the input box to specify the aspect ratio, e.g. 1:1 (square), 4:3, 16:9, etc.' ); ?></p>
181
+		<p><strong><?php _e('Crop Aspect Ratio'); ?></strong><br />
182
+		<?php _e('The aspect ratio is the relationship between the width and height. You can preserve the aspect ratio by holding down the shift key while resizing your selection. Use the input box to specify the aspect ratio, e.g. 1:1 (square), 4:3, 16:9, etc.'); ?></p>
183 183
 
184
-		<p><strong><?php _e( 'Crop Selection' ); ?></strong><br />
185
-		<?php _e( 'Once you have made your selection, you can adjust it by entering the size in pixels. The minimum selection size is the thumbnail size as set in the Media settings.' ); ?></p>
184
+		<p><strong><?php _e('Crop Selection'); ?></strong><br />
185
+		<?php _e('Once you have made your selection, you can adjust it by entering the size in pixels. The minimum selection size is the thumbnail size as set in the Media settings.'); ?></p>
186 186
 		</div>
187 187
 	</div>
188 188
 
189 189
 	<fieldset class="imgedit-crop-ratio">
190
-		<legend><?php _e( 'Aspect ratio:' ); ?></legend>
190
+		<legend><?php _e('Aspect ratio:'); ?></legend>
191 191
 		<div class="nowrap">
192
-		<label for="imgedit-crop-width-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e( 'crop ratio width' ); ?></label>
192
+		<label for="imgedit-crop-width-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e('crop ratio width'); ?></label>
193 193
 		<input type="text" id="imgedit-crop-width-<?php echo $post_id; ?>" onkeyup="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 0, this)" onblur="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 0, this)" />
194 194
 		<span class="imgedit-separator" aria-hidden="true">:</span>
195
-		<label for="imgedit-crop-height-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e( 'crop ratio height' ); ?></label>
195
+		<label for="imgedit-crop-height-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e('crop ratio height'); ?></label>
196 196
 		<input type="text" id="imgedit-crop-height-<?php echo $post_id; ?>" onkeyup="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 1, this)" onblur="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 1, this)" />
197 197
 		</div>
198 198
 	</fieldset>
199 199
 
200 200
 	<fieldset id="imgedit-crop-sel-<?php echo $post_id; ?>" class="imgedit-crop-sel">
201
-		<legend><?php _e( 'Selection:' ); ?></legend>
201
+		<legend><?php _e('Selection:'); ?></legend>
202 202
 		<div class="nowrap">
203
-		<label for="imgedit-sel-width-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e( 'selection width' ); ?></label>
203
+		<label for="imgedit-sel-width-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e('selection width'); ?></label>
204 204
 		<input type="text" id="imgedit-sel-width-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" onblur="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" />
205 205
 		<span class="imgedit-separator" aria-hidden="true">&times;</span>
206
-		<label for="imgedit-sel-height-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e( 'selection height' ); ?></label>
206
+		<label for="imgedit-sel-height-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e('selection height'); ?></label>
207 207
 		<input type="text" id="imgedit-sel-height-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" onblur="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" />
208 208
 		</div>
209 209
 	</fieldset>
@@ -211,56 +211,56 @@  discard block
 block discarded – undo
211 211
 	</div>
212 212
 
213 213
 	<?php
214
-	if ( $thumb && $sub_sizes ) {
215
-		$thumb_img = wp_constrain_dimensions( $thumb['width'], $thumb['height'], 160, 120 );
214
+	if ($thumb && $sub_sizes) {
215
+		$thumb_img = wp_constrain_dimensions($thumb['width'], $thumb['height'], 160, 120);
216 216
 		?>
217 217
 
218 218
 	<div class="imgedit-group imgedit-applyto">
219 219
 	<div class="imgedit-group-top">
220
-		<h2><?php _e( 'Thumbnail Settings' ); ?></h2>
221
-		<button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e( 'Thumbnail Settings Help' ); ?></span></button>
220
+		<h2><?php _e('Thumbnail Settings'); ?></h2>
221
+		<button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e('Thumbnail Settings Help'); ?></span></button>
222 222
 		<div class="imgedit-help">
223
-		<p><?php _e( 'You can edit the image while preserving the thumbnail. For example, you may wish to have a square thumbnail that displays just a section of the image.' ); ?></p>
223
+		<p><?php _e('You can edit the image while preserving the thumbnail. For example, you may wish to have a square thumbnail that displays just a section of the image.'); ?></p>
224 224
 		</div>
225 225
 	</div>
226 226
 
227 227
 	<figure class="imgedit-thumbnail-preview">
228 228
 		<img src="<?php echo $thumb['url']; ?>" width="<?php echo $thumb_img[0]; ?>" height="<?php echo $thumb_img[1]; ?>" class="imgedit-size-preview" alt="" draggable="false" />
229
-		<figcaption class="imgedit-thumbnail-preview-caption"><?php _e( 'Current thumbnail' ); ?></figcaption>
229
+		<figcaption class="imgedit-thumbnail-preview-caption"><?php _e('Current thumbnail'); ?></figcaption>
230 230
 	</figure>
231 231
 
232 232
 	<div id="imgedit-save-target-<?php echo $post_id; ?>" class="imgedit-save-target">
233 233
 	<fieldset>
234
-		<legend><?php _e( 'Apply changes to:' ); ?></legend>
234
+		<legend><?php _e('Apply changes to:'); ?></legend>
235 235
 
236 236
 		<span class="imgedit-label">
237 237
 			<input type="radio" id="imgedit-target-all" name="imgedit-target-<?php echo $post_id; ?>" value="all" checked="checked" />
238
-			<label for="imgedit-target-all"><?php _e( 'All image sizes' ); ?></label>
238
+			<label for="imgedit-target-all"><?php _e('All image sizes'); ?></label>
239 239
 		</span>
240 240
 
241 241
 		<span class="imgedit-label">
242 242
 			<input type="radio" id="imgedit-target-thumbnail" name="imgedit-target-<?php echo $post_id; ?>" value="thumbnail" />
243
-			<label for="imgedit-target-thumbnail"><?php _e( 'Thumbnail' ); ?></label>
243
+			<label for="imgedit-target-thumbnail"><?php _e('Thumbnail'); ?></label>
244 244
 		</span>
245 245
 
246 246
 		<span class="imgedit-label">
247 247
 			<input type="radio" id="imgedit-target-nothumb" name="imgedit-target-<?php echo $post_id; ?>" value="nothumb" />
248
-			<label for="imgedit-target-nothumb"><?php _e( 'All sizes except thumbnail' ); ?></label>
248
+			<label for="imgedit-target-nothumb"><?php _e('All sizes except thumbnail'); ?></label>
249 249
 		</span>
250 250
 		<?php
251
-		if ( $edit_custom_sizes ) {
252
-			if ( ! is_array( $edit_custom_sizes ) ) {
251
+		if ($edit_custom_sizes) {
252
+			if (!is_array($edit_custom_sizes)) {
253 253
 				$edit_custom_sizes = get_intermediate_image_sizes();
254 254
 			}
255
-			foreach ( array_unique( $edit_custom_sizes ) as $key => $size ) {
256
-				if ( array_key_exists( $size, $meta['sizes'] ) ) {
257
-					if ( 'thumbnail' === $size ) {
255
+			foreach (array_unique($edit_custom_sizes) as $key => $size) {
256
+				if (array_key_exists($size, $meta['sizes'])) {
257
+					if ('thumbnail' === $size) {
258 258
 						continue;
259 259
 					}
260 260
 					?>
261 261
 					<span class="imgedit-label">
262
-						<input type="radio" id="imgedit-target-custom<?php echo esc_attr( $key ); ?>" name="imgedit-target-<?php echo $post_id; ?>" value="<?php echo esc_attr( $size ); ?>" />
263
-						<label for="imgedit-target-custom<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $size ); ?></label>
262
+						<input type="radio" id="imgedit-target-custom<?php echo esc_attr($key); ?>" name="imgedit-target-<?php echo $post_id; ?>" value="<?php echo esc_attr($size); ?>" />
263
+						<label for="imgedit-target-custom<?php echo esc_attr($key); ?>"><?php echo esc_html($size); ?></label>
264 264
 					</span>
265 265
 					<?php
266 266
 				}
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 
278 278
 	</div>
279 279
 	<div class="imgedit-wait" id="imgedit-wait-<?php echo $post_id; ?>"></div>
280
-	<div class="hidden" id="imgedit-leaving-<?php echo $post_id; ?>"><?php _e( "There are unsaved changes that will be lost. 'OK' to continue, 'Cancel' to return to the Image Editor." ); ?></div>
280
+	<div class="hidden" id="imgedit-leaving-<?php echo $post_id; ?>"><?php _e("There are unsaved changes that will be lost. 'OK' to continue, 'Cancel' to return to the Image Editor."); ?></div>
281 281
 	</div>
282 282
 	<?php
283 283
 }
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
  * @param int             $attachment_id The image's attachment post ID.
293 293
  * @return bool True on success, false on failure.
294 294
  */
295
-function wp_stream_image( $image, $mime_type, $attachment_id ) {
296
-	if ( $image instanceof WP_Image_Editor ) {
295
+function wp_stream_image($image, $mime_type, $attachment_id) {
296
+	if ($image instanceof WP_Image_Editor) {
297 297
 
298 298
 		/**
299 299
 		 * Filters the WP_Image_Editor instance for the image to be streamed to the browser.
@@ -303,16 +303,16 @@  discard block
 block discarded – undo
303 303
 		 * @param WP_Image_Editor $image         The image editor instance.
304 304
 		 * @param int             $attachment_id The attachment post ID.
305 305
 		 */
306
-		$image = apply_filters( 'image_editor_save_pre', $image, $attachment_id );
306
+		$image = apply_filters('image_editor_save_pre', $image, $attachment_id);
307 307
 
308
-		if ( is_wp_error( $image->stream( $mime_type ) ) ) {
308
+		if (is_wp_error($image->stream($mime_type))) {
309 309
 			return false;
310 310
 		}
311 311
 
312 312
 		return true;
313 313
 	} else {
314 314
 		/* translators: 1: $image, 2: WP_Image_Editor */
315
-		_deprecated_argument( __FUNCTION__, '3.5.0', sprintf( __( '%1$s needs to be a %2$s object.' ), '$image', 'WP_Image_Editor' ) );
315
+		_deprecated_argument(__FUNCTION__, '3.5.0', sprintf(__('%1$s needs to be a %2$s object.'), '$image', 'WP_Image_Editor'));
316 316
 
317 317
 		/**
318 318
 		 * Filters the GD image resource to be streamed to the browser.
@@ -323,22 +323,22 @@  discard block
 block discarded – undo
323 323
 		 * @param resource|GdImage $image         Image resource to be streamed.
324 324
 		 * @param int              $attachment_id The attachment post ID.
325 325
 		 */
326
-		$image = apply_filters_deprecated( 'image_save_pre', array( $image, $attachment_id ), '3.5.0', 'image_editor_save_pre' );
326
+		$image = apply_filters_deprecated('image_save_pre', array($image, $attachment_id), '3.5.0', 'image_editor_save_pre');
327 327
 
328
-		switch ( $mime_type ) {
328
+		switch ($mime_type) {
329 329
 			case 'image/jpeg':
330
-				header( 'Content-Type: image/jpeg' );
331
-				return imagejpeg( $image, null, 90 );
330
+				header('Content-Type: image/jpeg');
331
+				return imagejpeg($image, null, 90);
332 332
 			case 'image/png':
333
-				header( 'Content-Type: image/png' );
334
-				return imagepng( $image );
333
+				header('Content-Type: image/png');
334
+				return imagepng($image);
335 335
 			case 'image/gif':
336
-				header( 'Content-Type: image/gif' );
337
-				return imagegif( $image );
336
+				header('Content-Type: image/gif');
337
+				return imagegif($image);
338 338
 			case 'image/webp':
339
-				if ( function_exists( 'imagewebp' ) ) {
340
-					header( 'Content-Type: image/webp' );
341
-					return imagewebp( $image, null, 90 );
339
+				if (function_exists('imagewebp')) {
340
+					header('Content-Type: image/webp');
341
+					return imagewebp($image, null, 90);
342 342
 				}
343 343
 				return false;
344 344
 			default:
@@ -358,11 +358,11 @@  discard block
 block discarded – undo
358 358
  * @param int             $post_id   Attachment post ID.
359 359
  * @return bool True on success, false on failure.
360 360
  */
361
-function wp_save_image_file( $filename, $image, $mime_type, $post_id ) {
362
-	if ( $image instanceof WP_Image_Editor ) {
361
+function wp_save_image_file($filename, $image, $mime_type, $post_id) {
362
+	if ($image instanceof WP_Image_Editor) {
363 363
 
364 364
 		/** This filter is documented in wp-admin/includes/image-edit.php */
365
-		$image = apply_filters( 'image_editor_save_pre', $image, $post_id );
365
+		$image = apply_filters('image_editor_save_pre', $image, $post_id);
366 366
 
367 367
 		/**
368 368
 		 * Filters whether to skip saving the image file.
@@ -378,19 +378,19 @@  discard block
 block discarded – undo
378 378
 		 * @param string          $mime_type The mime type of the image.
379 379
 		 * @param int             $post_id   Attachment post ID.
380 380
 		 */
381
-		$saved = apply_filters( 'wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id );
381
+		$saved = apply_filters('wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id);
382 382
 
383
-		if ( null !== $saved ) {
383
+		if (null !== $saved) {
384 384
 			return $saved;
385 385
 		}
386 386
 
387
-		return $image->save( $filename, $mime_type );
387
+		return $image->save($filename, $mime_type);
388 388
 	} else {
389 389
 		/* translators: 1: $image, 2: WP_Image_Editor */
390
-		_deprecated_argument( __FUNCTION__, '3.5.0', sprintf( __( '%1$s needs to be a %2$s object.' ), '$image', 'WP_Image_Editor' ) );
390
+		_deprecated_argument(__FUNCTION__, '3.5.0', sprintf(__('%1$s needs to be a %2$s object.'), '$image', 'WP_Image_Editor'));
391 391
 
392 392
 		/** This filter is documented in wp-admin/includes/image-edit.php */
393
-		$image = apply_filters_deprecated( 'image_save_pre', array( $image, $post_id ), '3.5.0', 'image_editor_save_pre' );
393
+		$image = apply_filters_deprecated('image_save_pre', array($image, $post_id), '3.5.0', 'image_editor_save_pre');
394 394
 
395 395
 		/**
396 396
 		 * Filters whether to skip saving the image file.
@@ -409,26 +409,26 @@  discard block
 block discarded – undo
409 409
 		 */
410 410
 		$saved = apply_filters_deprecated(
411 411
 			'wp_save_image_file',
412
-			array( null, $filename, $image, $mime_type, $post_id ),
412
+			array(null, $filename, $image, $mime_type, $post_id),
413 413
 			'3.5.0',
414 414
 			'wp_save_image_editor_file'
415 415
 		);
416 416
 
417
-		if ( null !== $saved ) {
417
+		if (null !== $saved) {
418 418
 			return $saved;
419 419
 		}
420 420
 
421
-		switch ( $mime_type ) {
421
+		switch ($mime_type) {
422 422
 			case 'image/jpeg':
423 423
 				/** This filter is documented in wp-includes/class-wp-image-editor.php */
424
-				return imagejpeg( $image, $filename, apply_filters( 'jpeg_quality', 90, 'edit_image' ) );
424
+				return imagejpeg($image, $filename, apply_filters('jpeg_quality', 90, 'edit_image'));
425 425
 			case 'image/png':
426
-				return imagepng( $image, $filename );
426
+				return imagepng($image, $filename);
427 427
 			case 'image/gif':
428
-				return imagegif( $image, $filename );
428
+				return imagegif($image, $filename);
429 429
 			case 'image/webp':
430
-				if ( function_exists( 'imagewebp' ) ) {
431
-					return imagewebp( $image, $filename );
430
+				if (function_exists('imagewebp')) {
431
+					return imagewebp($image, $filename);
432 432
 				}
433 433
 				return false;
434 434
 			default:
@@ -447,9 +447,9 @@  discard block
 block discarded – undo
447 447
  * @param int $h Image height in pixels.
448 448
  * @return float|int Image preview ratio.
449 449
  */
450
-function _image_get_preview_ratio( $w, $h ) {
451
-	$max = max( $w, $h );
452
-	return $max > 400 ? ( 400 / $max ) : 1;
450
+function _image_get_preview_ratio($w, $h) {
451
+	$max = max($w, $h);
452
+	return $max > 400 ? (400 / $max) : 1;
453 453
 }
454 454
 
455 455
 /**
@@ -464,14 +464,14 @@  discard block
 block discarded – undo
464 464
  * @param float|int         $angle Image rotation angle, in degrees.
465 465
  * @return resource|GdImage|false GD image resource or GdImage instance, false otherwise.
466 466
  */
467
-function _rotate_image_resource( $img, $angle ) {
468
-	_deprecated_function( __FUNCTION__, '3.5.0', 'WP_Image_Editor::rotate()' );
467
+function _rotate_image_resource($img, $angle) {
468
+	_deprecated_function(__FUNCTION__, '3.5.0', 'WP_Image_Editor::rotate()');
469 469
 
470
-	if ( function_exists( 'imagerotate' ) ) {
471
-		$rotated = imagerotate( $img, $angle, 0 );
470
+	if (function_exists('imagerotate')) {
471
+		$rotated = imagerotate($img, $angle, 0);
472 472
 
473
-		if ( is_gd_image( $rotated ) ) {
474
-			imagedestroy( $img );
473
+		if (is_gd_image($rotated)) {
474
+			imagedestroy($img);
475 475
 			$img = $rotated;
476 476
 		}
477 477
 	}
@@ -492,21 +492,21 @@  discard block
 block discarded – undo
492 492
  * @param bool             $vert Whether to flip vertically.
493 493
  * @return resource|GdImage (maybe) flipped image resource or GdImage instance.
494 494
  */
495
-function _flip_image_resource( $img, $horz, $vert ) {
496
-	_deprecated_function( __FUNCTION__, '3.5.0', 'WP_Image_Editor::flip()' );
495
+function _flip_image_resource($img, $horz, $vert) {
496
+	_deprecated_function(__FUNCTION__, '3.5.0', 'WP_Image_Editor::flip()');
497 497
 
498
-	$w   = imagesx( $img );
499
-	$h   = imagesy( $img );
500
-	$dst = wp_imagecreatetruecolor( $w, $h );
498
+	$w   = imagesx($img);
499
+	$h   = imagesy($img);
500
+	$dst = wp_imagecreatetruecolor($w, $h);
501 501
 
502
-	if ( is_gd_image( $dst ) ) {
503
-		$sx = $vert ? ( $w - 1 ) : 0;
504
-		$sy = $horz ? ( $h - 1 ) : 0;
502
+	if (is_gd_image($dst)) {
503
+		$sx = $vert ? ($w - 1) : 0;
504
+		$sy = $horz ? ($h - 1) : 0;
505 505
 		$sw = $vert ? -$w : $w;
506 506
 		$sh = $horz ? -$h : $h;
507 507
 
508
-		if ( imagecopyresampled( $dst, $img, 0, 0, $sx, $sy, $w, $h, $sw, $sh ) ) {
509
-			imagedestroy( $img );
508
+		if (imagecopyresampled($dst, $img, 0, 0, $sx, $sy, $w, $h, $sw, $sh)) {
509
+			imagedestroy($img);
510 510
 			$img = $dst;
511 511
 		}
512 512
 	}
@@ -527,12 +527,12 @@  discard block
 block discarded – undo
527 527
  * @param float            $h   Source height.
528 528
  * @return resource|GdImage (maybe) cropped image resource or GdImage instance.
529 529
  */
530
-function _crop_image_resource( $img, $x, $y, $w, $h ) {
531
-	$dst = wp_imagecreatetruecolor( $w, $h );
530
+function _crop_image_resource($img, $x, $y, $w, $h) {
531
+	$dst = wp_imagecreatetruecolor($w, $h);
532 532
 
533
-	if ( is_gd_image( $dst ) ) {
534
-		if ( imagecopy( $dst, $img, 0, 0, $x, $y, $w, $h ) ) {
535
-			imagedestroy( $img );
533
+	if (is_gd_image($dst)) {
534
+		if (imagecopy($dst, $img, 0, 0, $x, $y, $w, $h)) {
535
+			imagedestroy($img);
536 536
 			$img = $dst;
537 537
 		}
538 538
 	}
@@ -549,61 +549,61 @@  discard block
 block discarded – undo
549 549
  * @param array           $changes Array of change operations.
550 550
  * @return WP_Image_Editor WP_Image_Editor instance with changes applied.
551 551
  */
552
-function image_edit_apply_changes( $image, $changes ) {
553
-	if ( is_gd_image( $image ) ) {
552
+function image_edit_apply_changes($image, $changes) {
553
+	if (is_gd_image($image)) {
554 554
 		/* translators: 1: $image, 2: WP_Image_Editor */
555
-		_deprecated_argument( __FUNCTION__, '3.5.0', sprintf( __( '%1$s needs to be a %2$s object.' ), '$image', 'WP_Image_Editor' ) );
555
+		_deprecated_argument(__FUNCTION__, '3.5.0', sprintf(__('%1$s needs to be a %2$s object.'), '$image', 'WP_Image_Editor'));
556 556
 	}
557 557
 
558
-	if ( ! is_array( $changes ) ) {
558
+	if (!is_array($changes)) {
559 559
 		return $image;
560 560
 	}
561 561
 
562 562
 	// Expand change operations.
563
-	foreach ( $changes as $key => $obj ) {
564
-		if ( isset( $obj->r ) ) {
563
+	foreach ($changes as $key => $obj) {
564
+		if (isset($obj->r)) {
565 565
 			$obj->type  = 'rotate';
566 566
 			$obj->angle = $obj->r;
567
-			unset( $obj->r );
568
-		} elseif ( isset( $obj->f ) ) {
567
+			unset($obj->r);
568
+		} elseif (isset($obj->f)) {
569 569
 			$obj->type = 'flip';
570 570
 			$obj->axis = $obj->f;
571
-			unset( $obj->f );
572
-		} elseif ( isset( $obj->c ) ) {
571
+			unset($obj->f);
572
+		} elseif (isset($obj->c)) {
573 573
 			$obj->type = 'crop';
574 574
 			$obj->sel  = $obj->c;
575
-			unset( $obj->c );
575
+			unset($obj->c);
576 576
 		}
577
-		$changes[ $key ] = $obj;
577
+		$changes[$key] = $obj;
578 578
 	}
579 579
 
580 580
 	// Combine operations.
581
-	if ( count( $changes ) > 1 ) {
582
-		$filtered = array( $changes[0] );
583
-		for ( $i = 0, $j = 1, $c = count( $changes ); $j < $c; $j++ ) {
581
+	if (count($changes) > 1) {
582
+		$filtered = array($changes[0]);
583
+		for ($i = 0, $j = 1, $c = count($changes); $j < $c; $j++) {
584 584
 			$combined = false;
585
-			if ( $filtered[ $i ]->type == $changes[ $j ]->type ) {
586
-				switch ( $filtered[ $i ]->type ) {
585
+			if ($filtered[$i]->type == $changes[$j]->type) {
586
+				switch ($filtered[$i]->type) {
587 587
 					case 'rotate':
588
-						$filtered[ $i ]->angle += $changes[ $j ]->angle;
588
+						$filtered[$i]->angle += $changes[$j]->angle;
589 589
 						$combined               = true;
590 590
 						break;
591 591
 					case 'flip':
592
-						$filtered[ $i ]->axis ^= $changes[ $j ]->axis;
592
+						$filtered[$i]->axis ^= $changes[$j]->axis;
593 593
 						$combined              = true;
594 594
 						break;
595 595
 				}
596 596
 			}
597
-			if ( ! $combined ) {
598
-				$filtered[ ++$i ] = $changes[ $j ];
597
+			if (!$combined) {
598
+				$filtered[ ++$i] = $changes[$j];
599 599
 			}
600 600
 		}
601 601
 		$changes = $filtered;
602
-		unset( $filtered );
602
+		unset($filtered);
603 603
 	}
604 604
 
605 605
 	// Image resource before applying the changes.
606
-	if ( $image instanceof WP_Image_Editor ) {
606
+	if ($image instanceof WP_Image_Editor) {
607 607
 
608 608
 		/**
609 609
 		 * Filters the WP_Image_Editor instance before applying changes to the image.
@@ -613,8 +613,8 @@  discard block
 block discarded – undo
613 613
 		 * @param WP_Image_Editor $image   WP_Image_Editor instance.
614 614
 		 * @param array           $changes Array of change operations.
615 615
 		 */
616
-		$image = apply_filters( 'wp_image_editor_before_change', $image, $changes );
617
-	} elseif ( is_gd_image( $image ) ) {
616
+		$image = apply_filters('wp_image_editor_before_change', $image, $changes);
617
+	} elseif (is_gd_image($image)) {
618 618
 
619 619
 		/**
620 620
 		 * Filters the GD image resource before applying changes to the image.
@@ -625,42 +625,42 @@  discard block
 block discarded – undo
625 625
 		 * @param resource|GdImage $image   GD image resource or GdImage instance.
626 626
 		 * @param array            $changes Array of change operations.
627 627
 		 */
628
-		$image = apply_filters_deprecated( 'image_edit_before_change', array( $image, $changes ), '3.5.0', 'wp_image_editor_before_change' );
628
+		$image = apply_filters_deprecated('image_edit_before_change', array($image, $changes), '3.5.0', 'wp_image_editor_before_change');
629 629
 	}
630 630
 
631
-	foreach ( $changes as $operation ) {
632
-		switch ( $operation->type ) {
631
+	foreach ($changes as $operation) {
632
+		switch ($operation->type) {
633 633
 			case 'rotate':
634
-				if ( 0 != $operation->angle ) {
635
-					if ( $image instanceof WP_Image_Editor ) {
636
-						$image->rotate( $operation->angle );
634
+				if (0 != $operation->angle) {
635
+					if ($image instanceof WP_Image_Editor) {
636
+						$image->rotate($operation->angle);
637 637
 					} else {
638
-						$image = _rotate_image_resource( $image, $operation->angle );
638
+						$image = _rotate_image_resource($image, $operation->angle);
639 639
 					}
640 640
 				}
641 641
 				break;
642 642
 			case 'flip':
643
-				if ( 0 != $operation->axis ) {
644
-					if ( $image instanceof WP_Image_Editor ) {
645
-						$image->flip( ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 );
643
+				if (0 != $operation->axis) {
644
+					if ($image instanceof WP_Image_Editor) {
645
+						$image->flip(($operation->axis & 1) != 0, ($operation->axis & 2) != 0);
646 646
 					} else {
647
-						$image = _flip_image_resource( $image, ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 );
647
+						$image = _flip_image_resource($image, ($operation->axis & 1) != 0, ($operation->axis & 2) != 0);
648 648
 					}
649 649
 				}
650 650
 				break;
651 651
 			case 'crop':
652 652
 				$sel = $operation->sel;
653 653
 
654
-				if ( $image instanceof WP_Image_Editor ) {
654
+				if ($image instanceof WP_Image_Editor) {
655 655
 					$size = $image->get_size();
656 656
 					$w    = $size['width'];
657 657
 					$h    = $size['height'];
658 658
 
659
-					$scale = 1 / _image_get_preview_ratio( $w, $h ); // Discard preview scaling.
660
-					$image->crop( $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale );
659
+					$scale = 1 / _image_get_preview_ratio($w, $h); // Discard preview scaling.
660
+					$image->crop($sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale);
661 661
 				} else {
662
-					$scale = 1 / _image_get_preview_ratio( imagesx( $image ), imagesy( $image ) ); // Discard preview scaling.
663
-					$image = _crop_image_resource( $image, $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale );
662
+					$scale = 1 / _image_get_preview_ratio(imagesx($image), imagesy($image)); // Discard preview scaling.
663
+					$image = _crop_image_resource($image, $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale);
664 664
 				}
665 665
 				break;
666 666
 		}
@@ -679,20 +679,20 @@  discard block
 block discarded – undo
679 679
  * @param int $post_id Attachment post ID.
680 680
  * @return bool True on success, false on failure.
681 681
  */
682
-function stream_preview_image( $post_id ) {
683
-	$post = get_post( $post_id );
682
+function stream_preview_image($post_id) {
683
+	$post = get_post($post_id);
684 684
 
685
-	wp_raise_memory_limit( 'admin' );
685
+	wp_raise_memory_limit('admin');
686 686
 
687
-	$img = wp_get_image_editor( _load_image_to_edit_path( $post_id ) );
687
+	$img = wp_get_image_editor(_load_image_to_edit_path($post_id));
688 688
 
689
-	if ( is_wp_error( $img ) ) {
689
+	if (is_wp_error($img)) {
690 690
 		return false;
691 691
 	}
692 692
 
693
-	$changes = ! empty( $_REQUEST['history'] ) ? json_decode( wp_unslash( $_REQUEST['history'] ) ) : null;
694
-	if ( $changes ) {
695
-		$img = image_edit_apply_changes( $img, $changes );
693
+	$changes = !empty($_REQUEST['history']) ? json_decode(wp_unslash($_REQUEST['history'])) : null;
694
+	if ($changes) {
695
+		$img = image_edit_apply_changes($img, $changes);
696 696
 	}
697 697
 
698 698
 	// Scale the image.
@@ -700,15 +700,15 @@  discard block
 block discarded – undo
700 700
 	$w    = $size['width'];
701 701
 	$h    = $size['height'];
702 702
 
703
-	$ratio = _image_get_preview_ratio( $w, $h );
704
-	$w2    = max( 1, $w * $ratio );
705
-	$h2    = max( 1, $h * $ratio );
703
+	$ratio = _image_get_preview_ratio($w, $h);
704
+	$w2    = max(1, $w * $ratio);
705
+	$h2    = max(1, $h * $ratio);
706 706
 
707
-	if ( is_wp_error( $img->resize( $w2, $h2 ) ) ) {
707
+	if (is_wp_error($img->resize($w2, $h2))) {
708 708
 		return false;
709 709
 	}
710 710
 
711
-	return wp_stream_image( $img, $post->post_mime_type, $post_id );
711
+	return wp_stream_image($img, $post->post_mime_type, $post_id);
712 712
 }
713 713
 
714 714
 /**
@@ -719,35 +719,35 @@  discard block
 block discarded – undo
719 719
  * @param int $post_id Attachment post ID.
720 720
  * @return stdClass Image restoration message object.
721 721
  */
722
-function wp_restore_image( $post_id ) {
723
-	$meta             = wp_get_attachment_metadata( $post_id );
724
-	$file             = get_attached_file( $post_id );
725
-	$backup_sizes     = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
722
+function wp_restore_image($post_id) {
723
+	$meta             = wp_get_attachment_metadata($post_id);
724
+	$file             = get_attached_file($post_id);
725
+	$backup_sizes     = get_post_meta($post_id, '_wp_attachment_backup_sizes', true);
726 726
 	$old_backup_sizes = $backup_sizes;
727 727
 	$restored         = false;
728 728
 	$msg              = new stdClass;
729 729
 
730
-	if ( ! is_array( $backup_sizes ) ) {
731
-		$msg->error = __( 'Cannot load image metadata.' );
730
+	if (!is_array($backup_sizes)) {
731
+		$msg->error = __('Cannot load image metadata.');
732 732
 		return $msg;
733 733
 	}
734 734
 
735
-	$parts         = pathinfo( $file );
736
-	$suffix        = time() . rand( 100, 999 );
735
+	$parts         = pathinfo($file);
736
+	$suffix        = time() . rand(100, 999);
737 737
 	$default_sizes = get_intermediate_image_sizes();
738 738
 
739
-	if ( isset( $backup_sizes['full-orig'] ) && is_array( $backup_sizes['full-orig'] ) ) {
739
+	if (isset($backup_sizes['full-orig']) && is_array($backup_sizes['full-orig'])) {
740 740
 		$data = $backup_sizes['full-orig'];
741 741
 
742
-		if ( $parts['basename'] != $data['file'] ) {
743
-			if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE ) {
742
+		if ($parts['basename'] != $data['file']) {
743
+			if (defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE) {
744 744
 
745 745
 				// Delete only if it's an edited image.
746
-				if ( preg_match( '/-e[0-9]{13}\./', $parts['basename'] ) ) {
747
-					wp_delete_file( $file );
746
+				if (preg_match('/-e[0-9]{13}\./', $parts['basename'])) {
747
+					wp_delete_file($file);
748 748
 				}
749
-			} elseif ( isset( $meta['width'], $meta['height'] ) ) {
750
-				$backup_sizes[ "full-$suffix" ] = array(
749
+			} elseif (isset($meta['width'], $meta['height'])) {
750
+				$backup_sizes["full-$suffix"] = array(
751 751
 					'width'  => $meta['width'],
752 752
 					'height' => $meta['height'],
753 753
 					'file'   => $parts['basename'],
@@ -755,47 +755,47 @@  discard block
 block discarded – undo
755 755
 			}
756 756
 		}
757 757
 
758
-		$restored_file = path_join( $parts['dirname'], $data['file'] );
759
-		$restored      = update_attached_file( $post_id, $restored_file );
758
+		$restored_file = path_join($parts['dirname'], $data['file']);
759
+		$restored      = update_attached_file($post_id, $restored_file);
760 760
 
761
-		$meta['file']   = _wp_relative_upload_path( $restored_file );
761
+		$meta['file']   = _wp_relative_upload_path($restored_file);
762 762
 		$meta['width']  = $data['width'];
763 763
 		$meta['height'] = $data['height'];
764 764
 	}
765 765
 
766
-	foreach ( $default_sizes as $default_size ) {
767
-		if ( isset( $backup_sizes[ "$default_size-orig" ] ) ) {
768
-			$data = $backup_sizes[ "$default_size-orig" ];
769
-			if ( isset( $meta['sizes'][ $default_size ] ) && $meta['sizes'][ $default_size ]['file'] != $data['file'] ) {
770
-				if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE ) {
766
+	foreach ($default_sizes as $default_size) {
767
+		if (isset($backup_sizes["$default_size-orig"])) {
768
+			$data = $backup_sizes["$default_size-orig"];
769
+			if (isset($meta['sizes'][$default_size]) && $meta['sizes'][$default_size]['file'] != $data['file']) {
770
+				if (defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE) {
771 771
 
772 772
 					// Delete only if it's an edited image.
773
-					if ( preg_match( '/-e[0-9]{13}-/', $meta['sizes'][ $default_size ]['file'] ) ) {
774
-						$delete_file = path_join( $parts['dirname'], $meta['sizes'][ $default_size ]['file'] );
775
-						wp_delete_file( $delete_file );
773
+					if (preg_match('/-e[0-9]{13}-/', $meta['sizes'][$default_size]['file'])) {
774
+						$delete_file = path_join($parts['dirname'], $meta['sizes'][$default_size]['file']);
775
+						wp_delete_file($delete_file);
776 776
 					}
777 777
 				} else {
778
-					$backup_sizes[ "$default_size-{$suffix}" ] = $meta['sizes'][ $default_size ];
778
+					$backup_sizes["$default_size-{$suffix}"] = $meta['sizes'][$default_size];
779 779
 				}
780 780
 			}
781 781
 
782
-			$meta['sizes'][ $default_size ] = $data;
782
+			$meta['sizes'][$default_size] = $data;
783 783
 		} else {
784
-			unset( $meta['sizes'][ $default_size ] );
784
+			unset($meta['sizes'][$default_size]);
785 785
 		}
786 786
 	}
787 787
 
788
-	if ( ! wp_update_attachment_metadata( $post_id, $meta ) ||
789
-		( $old_backup_sizes !== $backup_sizes && ! update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes ) ) ) {
788
+	if (!wp_update_attachment_metadata($post_id, $meta) ||
789
+		($old_backup_sizes !== $backup_sizes && !update_post_meta($post_id, '_wp_attachment_backup_sizes', $backup_sizes))) {
790 790
 
791
-		$msg->error = __( 'Cannot save image metadata.' );
791
+		$msg->error = __('Cannot save image metadata.');
792 792
 		return $msg;
793 793
 	}
794 794
 
795
-	if ( ! $restored ) {
796
-		$msg->error = __( 'Image metadata is inconsistent.' );
795
+	if (!$restored) {
796
+		$msg->error = __('Image metadata is inconsistent.');
797 797
 	} else {
798
-		$msg->msg = __( 'Image restored successfully.' );
798
+		$msg->msg = __('Image restored successfully.');
799 799
 	}
800 800
 
801 801
 	return $msg;
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
  * @param int $post_id Attachment post ID.
811 811
  * @return stdClass
812 812
  */
813
-function wp_save_image( $post_id ) {
813
+function wp_save_image($post_id) {
814 814
 	$_wp_additional_image_sizes = wp_get_additional_image_sizes();
815 815
 
816 816
 	$return  = new stdClass;
@@ -818,83 +818,83 @@  discard block
 block discarded – undo
818 818
 	$delete  = false;
819 819
 	$scaled  = false;
820 820
 	$nocrop  = false;
821
-	$post    = get_post( $post_id );
821
+	$post    = get_post($post_id);
822 822
 
823
-	$img = wp_get_image_editor( _load_image_to_edit_path( $post_id, 'full' ) );
824
-	if ( is_wp_error( $img ) ) {
825
-		$return->error = esc_js( __( 'Unable to create new image.' ) );
823
+	$img = wp_get_image_editor(_load_image_to_edit_path($post_id, 'full'));
824
+	if (is_wp_error($img)) {
825
+		$return->error = esc_js(__('Unable to create new image.'));
826 826
 		return $return;
827 827
 	}
828 828
 
829
-	$fwidth  = ! empty( $_REQUEST['fwidth'] ) ? (int) $_REQUEST['fwidth'] : 0;
830
-	$fheight = ! empty( $_REQUEST['fheight'] ) ? (int) $_REQUEST['fheight'] : 0;
831
-	$target  = ! empty( $_REQUEST['target'] ) ? preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['target'] ) : '';
832
-	$scale   = ! empty( $_REQUEST['do'] ) && 'scale' === $_REQUEST['do'];
829
+	$fwidth  = !empty($_REQUEST['fwidth']) ? (int) $_REQUEST['fwidth'] : 0;
830
+	$fheight = !empty($_REQUEST['fheight']) ? (int) $_REQUEST['fheight'] : 0;
831
+	$target  = !empty($_REQUEST['target']) ? preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['target']) : '';
832
+	$scale   = !empty($_REQUEST['do']) && 'scale' === $_REQUEST['do'];
833 833
 
834
-	if ( $scale && $fwidth > 0 && $fheight > 0 ) {
834
+	if ($scale && $fwidth > 0 && $fheight > 0) {
835 835
 		$size = $img->get_size();
836 836
 		$sX   = $size['width'];
837 837
 		$sY   = $size['height'];
838 838
 
839 839
 		// Check if it has roughly the same w / h ratio.
840
-		$diff = round( $sX / $sY, 2 ) - round( $fwidth / $fheight, 2 );
840
+		$diff = round($sX / $sY, 2) - round($fwidth / $fheight, 2);
841 841
 		if ( -0.1 < $diff && $diff < 0.1 ) {
842 842
 			// Scale the full size image.
843
-			if ( $img->resize( $fwidth, $fheight ) ) {
843
+			if ($img->resize($fwidth, $fheight)) {
844 844
 				$scaled = true;
845 845
 			}
846 846
 		}
847 847
 
848
-		if ( ! $scaled ) {
849
-			$return->error = esc_js( __( 'Error while saving the scaled image. Please reload the page and try again.' ) );
848
+		if (!$scaled) {
849
+			$return->error = esc_js(__('Error while saving the scaled image. Please reload the page and try again.'));
850 850
 			return $return;
851 851
 		}
852
-	} elseif ( ! empty( $_REQUEST['history'] ) ) {
853
-		$changes = json_decode( wp_unslash( $_REQUEST['history'] ) );
854
-		if ( $changes ) {
855
-			$img = image_edit_apply_changes( $img, $changes );
852
+	} elseif (!empty($_REQUEST['history'])) {
853
+		$changes = json_decode(wp_unslash($_REQUEST['history']));
854
+		if ($changes) {
855
+			$img = image_edit_apply_changes($img, $changes);
856 856
 		}
857 857
 	} else {
858
-		$return->error = esc_js( __( 'Nothing to save, the image has not changed.' ) );
858
+		$return->error = esc_js(__('Nothing to save, the image has not changed.'));
859 859
 		return $return;
860 860
 	}
861 861
 
862
-	$meta         = wp_get_attachment_metadata( $post_id );
863
-	$backup_sizes = get_post_meta( $post->ID, '_wp_attachment_backup_sizes', true );
862
+	$meta         = wp_get_attachment_metadata($post_id);
863
+	$backup_sizes = get_post_meta($post->ID, '_wp_attachment_backup_sizes', true);
864 864
 
865
-	if ( ! is_array( $meta ) ) {
866
-		$return->error = esc_js( __( 'Image data does not exist. Please re-upload the image.' ) );
865
+	if (!is_array($meta)) {
866
+		$return->error = esc_js(__('Image data does not exist. Please re-upload the image.'));
867 867
 		return $return;
868 868
 	}
869 869
 
870
-	if ( ! is_array( $backup_sizes ) ) {
870
+	if (!is_array($backup_sizes)) {
871 871
 		$backup_sizes = array();
872 872
 	}
873 873
 
874 874
 	// Generate new filename.
875
-	$path = get_attached_file( $post_id );
875
+	$path = get_attached_file($post_id);
876 876
 
877
-	$basename = pathinfo( $path, PATHINFO_BASENAME );
878
-	$dirname  = pathinfo( $path, PATHINFO_DIRNAME );
879
-	$ext      = pathinfo( $path, PATHINFO_EXTENSION );
880
-	$filename = pathinfo( $path, PATHINFO_FILENAME );
881
-	$suffix   = time() . rand( 100, 999 );
877
+	$basename = pathinfo($path, PATHINFO_BASENAME);
878
+	$dirname  = pathinfo($path, PATHINFO_DIRNAME);
879
+	$ext      = pathinfo($path, PATHINFO_EXTENSION);
880
+	$filename = pathinfo($path, PATHINFO_FILENAME);
881
+	$suffix   = time() . rand(100, 999);
882 882
 
883
-	if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE &&
884
-		isset( $backup_sizes['full-orig'] ) && $backup_sizes['full-orig']['file'] != $basename ) {
883
+	if (defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE &&
884
+		isset($backup_sizes['full-orig']) && $backup_sizes['full-orig']['file'] != $basename) {
885 885
 
886
-		if ( 'thumbnail' === $target ) {
886
+		if ('thumbnail' === $target) {
887 887
 			$new_path = "{$dirname}/{$filename}-temp.{$ext}";
888 888
 		} else {
889 889
 			$new_path = $path;
890 890
 		}
891 891
 	} else {
892
-		while ( true ) {
893
-			$filename     = preg_replace( '/-e([0-9]+)$/', '', $filename );
892
+		while (true) {
893
+			$filename     = preg_replace('/-e([0-9]+)$/', '', $filename);
894 894
 			$filename    .= "-e{$suffix}";
895 895
 			$new_filename = "{$filename}.{$ext}";
896 896
 			$new_path     = "{$dirname}/$new_filename";
897
-			if ( file_exists( $new_path ) ) {
897
+			if (file_exists($new_path)) {
898 898
 				$suffix++;
899 899
 			} else {
900 900
 				break;
@@ -903,59 +903,59 @@  discard block
 block discarded – undo
903 903
 	}
904 904
 
905 905
 	// Save the full-size file, also needed to create sub-sizes.
906
-	if ( ! wp_save_image_file( $new_path, $img, $post->post_mime_type, $post_id ) ) {
907
-		$return->error = esc_js( __( 'Unable to save the image.' ) );
906
+	if (!wp_save_image_file($new_path, $img, $post->post_mime_type, $post_id)) {
907
+		$return->error = esc_js(__('Unable to save the image.'));
908 908
 		return $return;
909 909
 	}
910 910
 
911
-	if ( 'nothumb' === $target || 'all' === $target || 'full' === $target || $scaled ) {
911
+	if ('nothumb' === $target || 'all' === $target || 'full' === $target || $scaled) {
912 912
 		$tag = false;
913
-		if ( isset( $backup_sizes['full-orig'] ) ) {
914
-			if ( ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE ) && $backup_sizes['full-orig']['file'] !== $basename ) {
913
+		if (isset($backup_sizes['full-orig'])) {
914
+			if ((!defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE) && $backup_sizes['full-orig']['file'] !== $basename) {
915 915
 				$tag = "full-$suffix";
916 916
 			}
917 917
 		} else {
918 918
 			$tag = 'full-orig';
919 919
 		}
920 920
 
921
-		if ( $tag ) {
922
-			$backup_sizes[ $tag ] = array(
921
+		if ($tag) {
922
+			$backup_sizes[$tag] = array(
923 923
 				'width'  => $meta['width'],
924 924
 				'height' => $meta['height'],
925 925
 				'file'   => $basename,
926 926
 			);
927 927
 		}
928
-		$success = ( $path === $new_path ) || update_attached_file( $post_id, $new_path );
928
+		$success = ($path === $new_path) || update_attached_file($post_id, $new_path);
929 929
 
930
-		$meta['file'] = _wp_relative_upload_path( $new_path );
930
+		$meta['file'] = _wp_relative_upload_path($new_path);
931 931
 
932 932
 		$size           = $img->get_size();
933 933
 		$meta['width']  = $size['width'];
934 934
 		$meta['height'] = $size['height'];
935 935
 
936
-		if ( $success ) {
936
+		if ($success) {
937 937
 			$sizes = get_intermediate_image_sizes();
938
-			if ( 'nothumb' === $target || 'all' === $target ) {
939
-				if ( 'nothumb' === $target ) {
940
-					$sizes = array_diff( $sizes, array( 'thumbnail' ) );
938
+			if ('nothumb' === $target || 'all' === $target) {
939
+				if ('nothumb' === $target) {
940
+					$sizes = array_diff($sizes, array('thumbnail'));
941 941
 				}
942
-			} elseif ( 'thumbnail' !== $target ) {
943
-				$sizes = array_diff( $sizes, array( $target ) );
942
+			} elseif ('thumbnail' !== $target) {
943
+				$sizes = array_diff($sizes, array($target));
944 944
 			}
945 945
 		}
946 946
 
947 947
 		$return->fw = $meta['width'];
948 948
 		$return->fh = $meta['height'];
949
-	} elseif ( 'thumbnail' === $target ) {
950
-		$sizes   = array( 'thumbnail' );
949
+	} elseif ('thumbnail' === $target) {
950
+		$sizes   = array('thumbnail');
951 951
 		$success = true;
952 952
 		$delete  = true;
953 953
 		$nocrop  = true;
954 954
 	} else {
955
-		$sizes   = array( $target );
955
+		$sizes   = array($target);
956 956
 		$success = true;
957 957
 		$delete  = true;
958
-		$nocrop  = $_wp_additional_image_sizes[ $size ]['crop'];
958
+		$nocrop  = $_wp_additional_image_sizes[$size]['crop'];
959 959
 	}
960 960
 
961 961
 	/*
@@ -964,70 +964,70 @@  discard block
 block discarded – undo
964 964
 	 * keeping the new resized images from overwriting the existing image files.
965 965
 	 * https://core.trac.wordpress.org/ticket/32171
966 966
 	 */
967
-	if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE && ! empty( $meta['sizes'] ) ) {
968
-		foreach ( $meta['sizes'] as $size ) {
969
-			if ( ! empty( $size['file'] ) && preg_match( '/-e[0-9]{13}-/', $size['file'] ) ) {
970
-				$delete_file = path_join( $dirname, $size['file'] );
971
-				wp_delete_file( $delete_file );
967
+	if (defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE && !empty($meta['sizes'])) {
968
+		foreach ($meta['sizes'] as $size) {
969
+			if (!empty($size['file']) && preg_match('/-e[0-9]{13}-/', $size['file'])) {
970
+				$delete_file = path_join($dirname, $size['file']);
971
+				wp_delete_file($delete_file);
972 972
 			}
973 973
 		}
974 974
 	}
975 975
 
976
-	if ( isset( $sizes ) ) {
976
+	if (isset($sizes)) {
977 977
 		$_sizes = array();
978 978
 
979
-		foreach ( $sizes as $size ) {
979
+		foreach ($sizes as $size) {
980 980
 			$tag = false;
981
-			if ( isset( $meta['sizes'][ $size ] ) ) {
982
-				if ( isset( $backup_sizes[ "$size-orig" ] ) ) {
983
-					if ( ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE ) && $backup_sizes[ "$size-orig" ]['file'] != $meta['sizes'][ $size ]['file'] ) {
981
+			if (isset($meta['sizes'][$size])) {
982
+				if (isset($backup_sizes["$size-orig"])) {
983
+					if ((!defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE) && $backup_sizes["$size-orig"]['file'] != $meta['sizes'][$size]['file']) {
984 984
 						$tag = "$size-$suffix";
985 985
 					}
986 986
 				} else {
987 987
 					$tag = "$size-orig";
988 988
 				}
989 989
 
990
-				if ( $tag ) {
991
-					$backup_sizes[ $tag ] = $meta['sizes'][ $size ];
990
+				if ($tag) {
991
+					$backup_sizes[$tag] = $meta['sizes'][$size];
992 992
 				}
993 993
 			}
994 994
 
995
-			if ( isset( $_wp_additional_image_sizes[ $size ] ) ) {
996
-				$width  = (int) $_wp_additional_image_sizes[ $size ]['width'];
997
-				$height = (int) $_wp_additional_image_sizes[ $size ]['height'];
998
-				$crop   = ( $nocrop ) ? false : $_wp_additional_image_sizes[ $size ]['crop'];
995
+			if (isset($_wp_additional_image_sizes[$size])) {
996
+				$width  = (int) $_wp_additional_image_sizes[$size]['width'];
997
+				$height = (int) $_wp_additional_image_sizes[$size]['height'];
998
+				$crop   = ($nocrop) ? false : $_wp_additional_image_sizes[$size]['crop'];
999 999
 			} else {
1000
-				$height = get_option( "{$size}_size_h" );
1001
-				$width  = get_option( "{$size}_size_w" );
1002
-				$crop   = ( $nocrop ) ? false : get_option( "{$size}_crop" );
1000
+				$height = get_option("{$size}_size_h");
1001
+				$width  = get_option("{$size}_size_w");
1002
+				$crop   = ($nocrop) ? false : get_option("{$size}_crop");
1003 1003
 			}
1004 1004
 
1005
-			$_sizes[ $size ] = array(
1005
+			$_sizes[$size] = array(
1006 1006
 				'width'  => $width,
1007 1007
 				'height' => $height,
1008 1008
 				'crop'   => $crop,
1009 1009
 			);
1010 1010
 		}
1011 1011
 
1012
-		$meta['sizes'] = array_merge( $meta['sizes'], $img->multi_resize( $_sizes ) );
1012
+		$meta['sizes'] = array_merge($meta['sizes'], $img->multi_resize($_sizes));
1013 1013
 	}
1014 1014
 
1015
-	unset( $img );
1015
+	unset($img);
1016 1016
 
1017
-	if ( $success ) {
1018
-		wp_update_attachment_metadata( $post_id, $meta );
1019
-		update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes );
1017
+	if ($success) {
1018
+		wp_update_attachment_metadata($post_id, $meta);
1019
+		update_post_meta($post_id, '_wp_attachment_backup_sizes', $backup_sizes);
1020 1020
 
1021
-		if ( 'thumbnail' === $target || 'all' === $target || 'full' === $target ) {
1021
+		if ('thumbnail' === $target || 'all' === $target || 'full' === $target) {
1022 1022
 			// Check if it's an image edit from attachment edit screen.
1023
-			if ( ! empty( $_REQUEST['context'] ) && 'edit-attachment' === $_REQUEST['context'] ) {
1024
-				$thumb_url         = wp_get_attachment_image_src( $post_id, array( 900, 600 ), true );
1023
+			if (!empty($_REQUEST['context']) && 'edit-attachment' === $_REQUEST['context']) {
1024
+				$thumb_url         = wp_get_attachment_image_src($post_id, array(900, 600), true);
1025 1025
 				$return->thumbnail = $thumb_url[0];
1026 1026
 			} else {
1027
-				$file_url = wp_get_attachment_url( $post_id );
1028
-				if ( ! empty( $meta['sizes']['thumbnail'] ) ) {
1027
+				$file_url = wp_get_attachment_url($post_id);
1028
+				if (!empty($meta['sizes']['thumbnail'])) {
1029 1029
 					$thumb             = $meta['sizes']['thumbnail'];
1030
-					$return->thumbnail = path_join( dirname( $file_url ), $thumb['file'] );
1030
+					$return->thumbnail = path_join(dirname($file_url), $thumb['file']);
1031 1031
 				} else {
1032 1032
 					$return->thumbnail = "$file_url?w=128&h=128";
1033 1033
 				}
@@ -1037,10 +1037,10 @@  discard block
 block discarded – undo
1037 1037
 		$delete = true;
1038 1038
 	}
1039 1039
 
1040
-	if ( $delete ) {
1041
-		wp_delete_file( $new_path );
1040
+	if ($delete) {
1041
+		wp_delete_file($new_path);
1042 1042
 	}
1043 1043
 
1044
-	$return->msg = esc_js( __( 'Image saved' ) );
1044
+	$return->msg = esc_js(__('Image saved'));
1045 1045
 	return $return;
1046 1046
 }
Please login to merge, or discard this patch.
brighty/wp-admin/includes/class-bulk-plugin-upgrader-skin.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -21,22 +21,22 @@  discard block
 block discarded – undo
21 21
 	public function add_strings() {
22 22
 		parent::add_strings();
23 23
 		/* translators: 1: Plugin name, 2: Number of the plugin, 3: Total number of plugins being updated. */
24
-		$this->upgrader->strings['skin_before_update_header'] = __( 'Updating Plugin %1$s (%2$d/%3$d)' );
24
+		$this->upgrader->strings['skin_before_update_header'] = __('Updating Plugin %1$s (%2$d/%3$d)');
25 25
 	}
26 26
 
27 27
 	/**
28 28
 	 * @param string $title
29 29
 	 */
30
-	public function before( $title = '' ) {
31
-		parent::before( $this->plugin_info['Title'] );
30
+	public function before($title = '') {
31
+		parent::before($this->plugin_info['Title']);
32 32
 	}
33 33
 
34 34
 	/**
35 35
 	 * @param string $title
36 36
 	 */
37
-	public function after( $title = '' ) {
38
-		parent::after( $this->plugin_info['Title'] );
39
-		$this->decrement_update_count( 'plugin' );
37
+	public function after($title = '') {
38
+		parent::after($this->plugin_info['Title']);
39
+		$this->decrement_update_count('plugin');
40 40
 	}
41 41
 
42 42
 	/**
@@ -47,18 +47,18 @@  discard block
 block discarded – undo
47 47
 		$update_actions = array(
48 48
 			'plugins_page' => sprintf(
49 49
 				'<a href="%s" target="_parent">%s</a>',
50
-				self_admin_url( 'plugins.php' ),
51
-				__( 'Go to Plugins page' )
50
+				self_admin_url('plugins.php'),
51
+				__('Go to Plugins page')
52 52
 			),
53 53
 			'updates_page' => sprintf(
54 54
 				'<a href="%s" target="_parent">%s</a>',
55
-				self_admin_url( 'update-core.php' ),
56
-				__( 'Go to WordPress Updates page' )
55
+				self_admin_url('update-core.php'),
56
+				__('Go to WordPress Updates page')
57 57
 			),
58 58
 		);
59 59
 
60
-		if ( ! current_user_can( 'activate_plugins' ) ) {
61
-			unset( $update_actions['plugins_page'] );
60
+		if (!current_user_can('activate_plugins')) {
61
+			unset($update_actions['plugins_page']);
62 62
 		}
63 63
 
64 64
 		/**
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
 		 * @param string[] $update_actions Array of plugin action links.
70 70
 		 * @param array    $plugin_info    Array of information for the last-updated plugin.
71 71
 		 */
72
-		$update_actions = apply_filters( 'update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info );
72
+		$update_actions = apply_filters('update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info);
73 73
 
74
-		if ( ! empty( $update_actions ) ) {
75
-			$this->feedback( implode( ' | ', (array) $update_actions ) );
74
+		if (!empty($update_actions)) {
75
+			$this->feedback(implode(' | ', (array) $update_actions));
76 76
 		}
77 77
 	}
78 78
 }
Please login to merge, or discard this patch.