Completed
Pull Request — master (#1055)
by Rami
19:01
created
includes/admin/shortcodes/abstract-shortcode-generator.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -62,12 +62,12 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @since 1.0
64 64
 	 */
65
-	public function __construct( $shortcode ) {
65
+	public function __construct($shortcode) {
66 66
 
67 67
 
68 68
 		$this->shortcode_tag = $shortcode;
69 69
 
70
-		add_action( 'admin_init', array( $this, 'init' ) );
70
+		add_action('admin_init', array($this, 'init'));
71 71
 
72 72
 	}
73 73
 
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
 	 */
79 79
 	public function init() {
80 80
 
81
-		if ( $this->shortcode_tag ) {
81
+		if ($this->shortcode_tag) {
82 82
 
83
-			$this->self = get_class( $this );
83
+			$this->self = get_class($this);
84 84
 
85 85
 			$this->errors   = array();
86 86
 			$this->required = array();
@@ -89,18 +89,18 @@  discard block
 block discarded – undo
89 89
 			$fields = $this->get_fields();
90 90
 
91 91
 			$defaults = array(
92
-				'btn_close' => esc_html__( 'Close', 'give' ),
93
-				'btn_okay'  => esc_html__( 'Insert Shortcode', 'give' ),
92
+				'btn_close' => esc_html__('Close', 'give'),
93
+				'btn_okay'  => esc_html__('Insert Shortcode', 'give'),
94 94
 				'errors'    => $this->errors,
95 95
 				'fields'    => $fields,
96
-				'label'     => '[' . $this->shortcode_tag . ']',
96
+				'label'     => '['.$this->shortcode_tag.']',
97 97
 				'required'  => $this->required,
98
-				'title'     => esc_html__( 'Insert Shortcode', 'give' ),
98
+				'title'     => esc_html__('Insert Shortcode', 'give'),
99 99
 			);
100 100
 
101
-			if ( user_can_richedit() ) {
101
+			if (user_can_richedit()) {
102 102
 
103
-				Give_Shortcode_Button::$shortcodes[ $this->shortcode_tag ] = wp_parse_args( $this->shortcode, $defaults );
103
+				Give_Shortcode_Button::$shortcodes[$this->shortcode_tag] = wp_parse_args($this->shortcode, $defaults);
104 104
 
105 105
 			}
106 106
 		}
@@ -129,13 +129,13 @@  discard block
 block discarded – undo
129 129
 	 *
130 130
 	 * @since 1.0
131 131
 	 */
132
-	protected function generate_fields( $defined_fields ) {
132
+	protected function generate_fields($defined_fields) {
133 133
 
134 134
 		$fields = array();
135 135
 
136
-		if ( is_array( $defined_fields ) ) {
136
+		if (is_array($defined_fields)) {
137 137
 
138
-			foreach ( $defined_fields as $field ) {
138
+			foreach ($defined_fields as $field) {
139 139
 
140 140
 				$defaults = array(
141 141
 					'label'       => false,
@@ -146,14 +146,14 @@  discard block
 block discarded – undo
146 146
 					'type'        => '',
147 147
 				);
148 148
 
149
-				$field  = wp_parse_args( (array) $field, $defaults );
150
-				$method = 'generate_' . strtolower( $field['type'] );
149
+				$field  = wp_parse_args((array) $field, $defaults);
150
+				$method = 'generate_'.strtolower($field['type']);
151 151
 
152
-				if ( method_exists( $this, $method ) ) {
152
+				if (method_exists($this, $method)) {
153 153
 
154
-					$field = call_user_func( array( $this, $method ), $field );
154
+					$field = call_user_func(array($this, $method), $field);
155 155
 
156
-					if ( $field ) {
156
+					if ($field) {
157 157
 						$fields[] = $field;
158 158
 					}
159 159
 				}
@@ -173,22 +173,22 @@  discard block
 block discarded – undo
173 173
 	protected function get_fields() {
174 174
 
175 175
 		$defined_fields   = $this->define_fields();
176
-		$generated_fields = $this->generate_fields( $defined_fields );
176
+		$generated_fields = $this->generate_fields($defined_fields);
177 177
 
178 178
 		$errors = array();
179 179
 
180
-		if ( ! empty( $this->errors ) ) {
181
-			foreach ( $this->required as $name => $alert ) {
182
-				if ( false === array_search( $name, array_column( $generated_fields, 'name' ) ) ) {
180
+		if ( ! empty($this->errors)) {
181
+			foreach ($this->required as $name => $alert) {
182
+				if (false === array_search($name, array_column($generated_fields, 'name'))) {
183 183
 
184
-					$errors[] = $this->errors[ $name ];
184
+					$errors[] = $this->errors[$name];
185 185
 				}
186 186
 			}
187 187
 
188 188
 			$this->errors = $errors;
189 189
 		}
190 190
 
191
-		if ( ! empty( $errors ) ) {
191
+		if ( ! empty($errors)) {
192 192
 
193 193
 			return $errors;
194 194
 		}
@@ -205,9 +205,9 @@  discard block
 block discarded – undo
205 205
 	 *
206 206
 	 * @since 1.0
207 207
 	 */
208
-	protected function generate_container( $field ) {
208
+	protected function generate_container($field) {
209 209
 
210
-		if ( array_key_exists( 'html', $field ) ) {
210
+		if (array_key_exists('html', $field)) {
211 211
 
212 212
 			return array(
213 213
 				'type' => $field['type'],
@@ -227,36 +227,36 @@  discard block
 block discarded – undo
227 227
 	 *
228 228
 	 * @since 1.0
229 229
 	 */
230
-	protected function generate_listbox( $field ) {
230
+	protected function generate_listbox($field) {
231 231
 
232
-		$listbox = shortcode_atts( array(
232
+		$listbox = shortcode_atts(array(
233 233
 			'label'    => '',
234 234
 			'minWidth' => '',
235 235
 			'name'     => false,
236 236
 			'tooltip'  => '',
237 237
 			'type'     => '',
238 238
 			'value'    => '',
239
-		), $field );
239
+		), $field);
240 240
 
241
-		if ( $this->validate( $field ) ) {
241
+		if ($this->validate($field)) {
242 242
 
243 243
 			$new_listbox = array();
244 244
 
245
-			foreach ( $listbox as $key => $value ) {
245
+			foreach ($listbox as $key => $value) {
246 246
 
247
-				if ( $key == 'value' && empty( $value ) ) {
248
-					$new_listbox[ $key ] = $listbox['name'];
249
-				} else if ( $value ) {
250
-					$new_listbox[ $key ] = $value;
247
+				if ($key == 'value' && empty($value)) {
248
+					$new_listbox[$key] = $listbox['name'];
249
+				} else if ($value) {
250
+					$new_listbox[$key] = $value;
251 251
 				}
252 252
 			}
253 253
 
254 254
 			// do not reindex array!
255 255
 			$field['options'] = array(
256
-				                    '' => ( $field['placeholder'] ? $field['placeholder'] : esc_attr__( '- Select -', 'give' ) ),
256
+				                    '' => ($field['placeholder'] ? $field['placeholder'] : esc_attr__('- Select -', 'give')),
257 257
 			                    ) + $field['options'];
258 258
 
259
-			foreach ( $field['options'] as $value => $text ) {
259
+			foreach ($field['options'] as $value => $text) {
260 260
 				$new_listbox['values'][] = array(
261 261
 					'text'  => $text,
262 262
 					'value' => $value,
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 *
279 279
 	 * @since 1.0
280 280
 	 */
281
-	protected function generate_post( $field ) {
281
+	protected function generate_post($field) {
282 282
 
283 283
 		$args = array(
284 284
 			'post_type'      => 'post',
@@ -287,23 +287,23 @@  discard block
 block discarded – undo
287 287
 			'posts_per_page' => 30,
288 288
 		);
289 289
 
290
-		$args    = wp_parse_args( (array) $field['query_args'], $args );
291
-		$posts   = get_posts( $args );
290
+		$args    = wp_parse_args((array) $field['query_args'], $args);
291
+		$posts   = get_posts($args);
292 292
 		$options = array();
293 293
 
294
-		if ( $posts ) {
295
-			foreach ( $posts as $post ) {
296
-				$options[ absint( $post->ID ) ] = $post->post_title;
294
+		if ($posts) {
295
+			foreach ($posts as $post) {
296
+				$options[absint($post->ID)] = $post->post_title;
297 297
 			}
298 298
 
299 299
 			$field['type']    = 'listbox';
300 300
 			$field['options'] = $options;
301 301
 
302
-			return $this->generate_listbox( $field );
302
+			return $this->generate_listbox($field);
303 303
 		}
304 304
 
305 305
 		// perform validation here before returning false
306
-		$this->validate( $field );
306
+		$this->validate($field);
307 307
 
308 308
 		return false;
309 309
 	}
@@ -317,9 +317,9 @@  discard block
 block discarded – undo
317 317
 	 *
318 318
 	 * @since 1.0
319 319
 	 */
320
-	protected function generate_textbox( $field ) {
320
+	protected function generate_textbox($field) {
321 321
 
322
-		$textbox = shortcode_atts( array(
322
+		$textbox = shortcode_atts(array(
323 323
 			'label'     => '',
324 324
 			'maxLength' => '',
325 325
 			'minHeight' => '',
@@ -329,10 +329,10 @@  discard block
 block discarded – undo
329 329
 			'tooltip'   => '',
330 330
 			'type'      => '',
331 331
 			'value'     => '',
332
-		), $field );
332
+		), $field);
333 333
 
334
-		if ( $this->validate( $field ) ) {
335
-			return array_filter( $textbox, array( $this, 'return_textbox_value' ) );
334
+		if ($this->validate($field)) {
335
+			return array_filter($textbox, array($this, 'return_textbox_value'));
336 336
 		}
337 337
 
338 338
 		return false;
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 	 *
346 346
 	 * @return bool
347 347
 	 */
348
-	function return_textbox_value( $value ) {
348
+	function return_textbox_value($value) {
349 349
 		return $value !== '';
350 350
 	}
351 351
 
@@ -361,9 +361,9 @@  discard block
 block discarded – undo
361 361
 	 *
362 362
 	 * @since 1.0
363 363
 	 */
364
-	protected function validate( $field ) {
364
+	protected function validate($field) {
365 365
 
366
-		extract( shortcode_atts(
366
+		extract(shortcode_atts(
367 367
 				array(
368 368
 					'name'     => false,
369 369
 					'required' => false,
@@ -371,36 +371,36 @@  discard block
 block discarded – undo
371 371
 				), $field )
372 372
 		);
373 373
 
374
-		if ( $name ) {
374
+		if ($name) {
375 375
 
376
-			if ( isset( $required['error'] ) ) {
376
+			if (isset($required['error'])) {
377 377
 
378 378
 				$error = array(
379 379
 					'type' => 'container',
380 380
 					'html' => $required['error'],
381 381
 				);
382 382
 
383
-				$this->errors[ $name ] = $this->generate_container( $error );
383
+				$this->errors[$name] = $this->generate_container($error);
384 384
 			}
385 385
 
386
-			if ( ! ! $required || is_array( $required ) ) {
386
+			if ( ! ! $required || is_array($required)) {
387 387
 
388
-				$alert = esc_html__( 'Some of the shortcode options are required.', 'give' );
388
+				$alert = esc_html__('Some of the shortcode options are required.', 'give');
389 389
 
390
-				if ( isset( $required['alert'] ) ) {
390
+				if (isset($required['alert'])) {
391 391
 
392 392
 					$alert = $required['alert'];
393 393
 
394
-				} else if ( ! empty( $label ) ) {
394
+				} else if ( ! empty($label)) {
395 395
 
396 396
 					$alert = sprintf(
397 397
 					/* translators: %s: option label */
398
-						esc_html__( 'The "%s" option is required.', 'give' ),
399
-						str_replace( ':', '', $label )
398
+						esc_html__('The "%s" option is required.', 'give'),
399
+						str_replace(':', '', $label)
400 400
 					);
401 401
 				}
402 402
 
403
-				$this->required[ $name ] = $alert;
403
+				$this->required[$name] = $alert;
404 404
 			}
405 405
 
406 406
 			return true;
Please login to merge, or discard this patch.
includes/admin/shortcodes/shortcode-give-donation-history.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	public function __construct() {
23 23
 
24
-		$this->shortcode['label'] = esc_html__( 'Donation History', 'give' );
24
+		$this->shortcode['label'] = esc_html__('Donation History', 'give');
25 25
 
26
-		parent::__construct( 'donation_history' );
26
+		parent::__construct('donation_history');
27 27
 	}
28 28
 }
29 29
 
Please login to merge, or discard this patch.
includes/admin/shortcodes/shortcode-give-register.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	public function __construct() {
23 23
 
24
-		$this->shortcode['title'] = esc_html__( 'Register', 'give' );
25
-		$this->shortcode['label'] = esc_html__( 'Register', 'give' );
24
+		$this->shortcode['title'] = esc_html__('Register', 'give');
25
+		$this->shortcode['label'] = esc_html__('Register', 'give');
26 26
 
27
-		parent::__construct( 'give_register' );
27
+		parent::__construct('give_register');
28 28
 	}
29 29
 
30 30
 	/**
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
 		return array(
38 38
 			array(
39 39
 				'type' => 'container',
40
-				'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Redirect URL (optional):', 'give' ) ),
40
+				'html' => sprintf('<p class="no-margin">%s</p>', esc_html__('Redirect URL (optional):', 'give')),
41 41
 			),
42 42
 			array(
43 43
 				'type'     => 'textbox',
44 44
 				'name'     => 'redirect',
45 45
 				'minWidth' => 320,
46
-				'tooltip'  => esc_attr__( 'Enter an URL here to redirect to after registering.', 'give' ),
46
+				'tooltip'  => esc_attr__('Enter an URL here to redirect to after registering.', 'give'),
47 47
 			),
48 48
 		);
49 49
 	}
Please login to merge, or discard this patch.
includes/admin/shortcodes/shortcode-give-login.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	public function __construct() {
23 23
 
24
-		$this->shortcode['title'] = esc_html__( 'Login', 'give' );
25
-		$this->shortcode['label'] = esc_html__( 'Login', 'give' );
24
+		$this->shortcode['title'] = esc_html__('Login', 'give');
25
+		$this->shortcode['label'] = esc_html__('Login', 'give');
26 26
 
27
-		parent::__construct( 'give_login' );
27
+		parent::__construct('give_login');
28 28
 	}
29 29
 
30 30
 	/**
@@ -37,23 +37,23 @@  discard block
 block discarded – undo
37 37
 		return array(
38 38
 			array(
39 39
 				'type' => 'container',
40
-				'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Login Redirect URL (optional):', 'give' ) ),
40
+				'html' => sprintf('<p class="no-margin">%s</p>', esc_html__('Login Redirect URL (optional):', 'give')),
41 41
 			),
42 42
 			array(
43 43
 				'type'     => 'textbox',
44 44
 				'name'     => 'login-redirect',
45 45
 				'minWidth' => 320,
46
-				'tooltip'  => esc_attr__( 'Enter an URL here to redirect to after login.', 'give' ),
46
+				'tooltip'  => esc_attr__('Enter an URL here to redirect to after login.', 'give'),
47 47
 			),
48 48
             array(
49 49
                 'type' => 'container',
50
-                'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Logout Redirect URL (optional):', 'give' ) ),
50
+                'html' => sprintf('<p class="no-margin">%s</p>', esc_html__('Logout Redirect URL (optional):', 'give')),
51 51
             ),
52 52
             array(
53 53
                 'type'     => 'textbox',
54 54
                 'name'     => 'logout-redirect',
55 55
                 'minWidth' => 320,
56
-                'tooltip'  => esc_attr__( 'Enter an URL here to redirect to after logout.', 'give' ),
56
+                'tooltip'  => esc_attr__('Enter an URL here to redirect to after logout.', 'give'),
57 57
             ),
58 58
 		);
59 59
 	}
Please login to merge, or discard this patch.
includes/admin/shortcodes/shortcode-give-receipt.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
 	 */
25 25
 	public function __construct() {
26 26
 
27
-		$this->shortcode['title'] = esc_html__( 'Donation Receipt', 'give' );
28
-		$this->shortcode['label'] = esc_html__( 'Donation Receipt', 'give' );
27
+		$this->shortcode['title'] = esc_html__('Donation Receipt', 'give');
28
+		$this->shortcode['label'] = esc_html__('Donation Receipt', 'give');
29 29
 
30
-		parent::__construct( 'give_receipt' );
30
+		parent::__construct('give_receipt');
31 31
 	}
32 32
 
33 33
 	/**
@@ -40,60 +40,60 @@  discard block
 block discarded – undo
40 40
 		return array(
41 41
 			array(
42 42
 				'type' => 'container',
43
-				'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'Optional settings', 'give' ) ),
43
+				'html' => sprintf('<p class="strong">%s</p>', esc_html__('Optional settings', 'give')),
44 44
 			),
45 45
 			array(
46 46
 				'type'    => 'listbox',
47 47
 				'name'    => 'price',
48
-				'label'   => esc_html__( 'Show Donation Amount:', 'give' ),
48
+				'label'   => esc_html__('Show Donation Amount:', 'give'),
49 49
 				'options' => array(
50
-					'true'  => esc_html__( 'Show', 'give' ),
51
-					'false' => esc_html__( 'Hide', 'give' ),
50
+					'true'  => esc_html__('Show', 'give'),
51
+					'false' => esc_html__('Hide', 'give'),
52 52
 				),
53 53
 			),
54 54
 			array(
55 55
 				'type'    => 'listbox',
56 56
 				'name'    => 'donor',
57
-				'label'   => esc_html__( 'Show Donor Name:', 'give' ),
57
+				'label'   => esc_html__('Show Donor Name:', 'give'),
58 58
 				'options' => array(
59
-					'true'  => esc_html__( 'Show', 'give' ),
60
-					'false' => esc_html__( 'Hide', 'give' ),
59
+					'true'  => esc_html__('Show', 'give'),
60
+					'false' => esc_html__('Hide', 'give'),
61 61
 				),
62 62
 			),
63 63
 			array(
64 64
 				'type'    => 'listbox',
65 65
 				'name'    => 'date',
66
-				'label'   => esc_html__( 'Show Date:', 'give' ),
66
+				'label'   => esc_html__('Show Date:', 'give'),
67 67
 				'options' => array(
68
-					'true'  => esc_html__( 'Show', 'give' ),
69
-					'false' => esc_html__( 'Hide', 'give' ),
68
+					'true'  => esc_html__('Show', 'give'),
69
+					'false' => esc_html__('Hide', 'give'),
70 70
 				),
71 71
 			),
72 72
 			array(
73 73
 				'type'    => 'listbox',
74 74
 				'name'    => 'payment_key',
75
-				'label'   => esc_html__( 'Show Payment Key:', 'give' ),
75
+				'label'   => esc_html__('Show Payment Key:', 'give'),
76 76
 				'options' => array(
77
-					'true'  => esc_html__( 'Show', 'give' ),
78
-					'false' => esc_html__( 'Hide', 'give' ),
77
+					'true'  => esc_html__('Show', 'give'),
78
+					'false' => esc_html__('Hide', 'give'),
79 79
 				),
80 80
 			),
81 81
 			array(
82 82
 				'type'    => 'listbox',
83 83
 				'name'    => 'payment_method',
84
-				'label'   => esc_html__( 'Show Payment Method:', 'give' ),
84
+				'label'   => esc_html__('Show Payment Method:', 'give'),
85 85
 				'options' => array(
86
-					'true'  => esc_html__( 'Show', 'give' ),
87
-					'false' => esc_html__( 'Hide', 'give' ),
86
+					'true'  => esc_html__('Show', 'give'),
87
+					'false' => esc_html__('Hide', 'give'),
88 88
 				),
89 89
 			),
90 90
 			array(
91 91
 				'type'    => 'listbox',
92 92
 				'name'    => 'payment_id',
93
-				'label'   => esc_html__( 'Show Payment ID:', 'give' ),
93
+				'label'   => esc_html__('Show Payment ID:', 'give'),
94 94
 				'options' => array(
95
-					'true'  => esc_html__( 'Show', 'give' ),
96
-					'false' => esc_html__( 'Hide', 'give' ),
95
+					'true'  => esc_html__('Show', 'give'),
96
+					'false' => esc_html__('Hide', 'give'),
97 97
 				),
98 98
 			),
99 99
 		);
Please login to merge, or discard this patch.
includes/admin/shortcodes/class-shortcode-button.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -33,16 +33,16 @@  discard block
 block discarded – undo
33 33
 	 */
34 34
 	public function __construct() {
35 35
 
36
-		if ( is_admin() ) {
37
-			add_filter( 'mce_external_plugins', array( $this, 'mce_external_plugins' ), 15 );
36
+		if (is_admin()) {
37
+			add_filter('mce_external_plugins', array($this, 'mce_external_plugins'), 15);
38 38
 
39
-			add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_assets' ) );
40
-			add_action( 'admin_enqueue_scripts', array( $this, 'admin_localize_scripts' ), 13 );
41
-			add_action( 'media_buttons', array( $this, 'shortcode_button' ) );
39
+			add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_assets'));
40
+			add_action('admin_enqueue_scripts', array($this, 'admin_localize_scripts'), 13);
41
+			add_action('media_buttons', array($this, 'shortcode_button'));
42 42
 		}
43 43
 
44
-		add_action( "wp_ajax_give_shortcode", array( $this, 'shortcode_ajax' ) );
45
-		add_action( "wp_ajax_nopriv_give_shortcode", array( $this, 'shortcode_ajax' ) );
44
+		add_action("wp_ajax_give_shortcode", array($this, 'shortcode_ajax'));
45
+		add_action("wp_ajax_nopriv_give_shortcode", array($this, 'shortcode_ajax'));
46 46
 	}
47 47
 
48 48
 	/**
@@ -54,15 +54,15 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @since 1.0
56 56
 	 */
57
-	public function mce_external_plugins( $plugin_array ) {
57
+	public function mce_external_plugins($plugin_array) {
58 58
 
59
-		if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) {
59
+		if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages')) {
60 60
 			return false;
61 61
 		}
62 62
 
63
-		$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
63
+		$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
64 64
 
65
-		$plugin_array['give_shortcode'] = GIVE_PLUGIN_URL . 'assets/js/admin/tinymce/mce-plugin' . $suffix . '.js';
65
+		$plugin_array['give_shortcode'] = GIVE_PLUGIN_URL.'assets/js/admin/tinymce/mce-plugin'.$suffix.'.js';
66 66
 
67 67
 		return $plugin_array;
68 68
 	}
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	public function admin_enqueue_assets() {
78 78
 
79
-		$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
79
+		$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
80 80
 
81 81
 		wp_enqueue_script(
82 82
 			'give_shortcode',
83
-			GIVE_PLUGIN_URL . 'assets/js/admin/admin-shortcodes' . $suffix . '.js',
84
-			array( 'jquery' ),
83
+			GIVE_PLUGIN_URL.'assets/js/admin/admin-shortcodes'.$suffix.'.js',
84
+			array('jquery'),
85 85
 			GIVE_VERSION,
86 86
 			true
87 87
 		);
@@ -96,17 +96,17 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	public function admin_localize_scripts() {
98 98
 
99
-		if ( ! empty( self::$shortcodes ) ) {
99
+		if ( ! empty(self::$shortcodes)) {
100 100
 
101 101
 			$variables = array();
102 102
 
103
-			foreach ( self::$shortcodes as $shortcode => $values ) {
104
-				if ( ! empty( $values['required'] ) ) {
105
-					$variables[ $shortcode ] = $values['required'];
103
+			foreach (self::$shortcodes as $shortcode => $values) {
104
+				if ( ! empty($values['required'])) {
105
+					$variables[$shortcode] = $values['required'];
106 106
 				}
107 107
 			}
108 108
 
109
-			wp_localize_script( 'give_shortcode', 'scShortcodes', $variables );
109
+			wp_localize_script('give_shortcode', 'scShortcodes', $variables);
110 110
 		}
111 111
 	}
112 112
 
@@ -121,31 +121,31 @@  discard block
 block discarded – undo
121 121
 
122 122
 		global $pagenow;
123 123
 
124
-		$shortcode_button_pages = apply_filters( 'give_shortcode_button_pages', array(
124
+		$shortcode_button_pages = apply_filters('give_shortcode_button_pages', array(
125 125
 			'post.php',
126 126
 			'page.php',
127 127
 			'post-new.php',
128 128
 			'post-edit.php'
129
-		) );
129
+		));
130 130
 
131 131
 		// Only run in admin post/page creation and edit screens
132
-		if ( in_array( $pagenow, $shortcode_button_pages )
133
-		     && apply_filters( 'give_shortcode_button_condition', true )
134
-		     && ! empty( self::$shortcodes )
132
+		if (in_array($pagenow, $shortcode_button_pages)
133
+		     && apply_filters('give_shortcode_button_condition', true)
134
+		     && ! empty(self::$shortcodes)
135 135
 		) {
136 136
 
137 137
 			$shortcodes = array();
138 138
 
139
-			foreach ( self::$shortcodes as $shortcode => $values ) {
139
+			foreach (self::$shortcodes as $shortcode => $values) {
140 140
 
141 141
 				/**
142 142
 				 * Filters the condition for including the current shortcode
143 143
 				 *
144 144
 				 * @since 1.0
145 145
 				 */
146
-				if ( apply_filters( sanitize_title( $shortcode ) . '_condition', true ) ) {
146
+				if (apply_filters(sanitize_title($shortcode).'_condition', true)) {
147 147
 
148
-					$shortcodes[ $shortcode ] = sprintf(
148
+					$shortcodes[$shortcode] = sprintf(
149 149
 						'<div class="sc-shortcode mce-menu-item give-shortcode-item-%1$s" data-shortcode="%s">%s</div>',
150 150
 						$shortcode,
151 151
 						$values['label'],
@@ -154,37 +154,37 @@  discard block
 block discarded – undo
154 154
 				}
155 155
 			}
156 156
 
157
-			if ( ! empty( $shortcodes ) ) {
157
+			if ( ! empty($shortcodes)) {
158 158
 
159 159
 				// check current WP version
160
-				$img = ( version_compare( get_bloginfo( 'version' ), '3.5', '<' ) )
161
-					? '<img src="' . GIVE_PLUGIN_URL . 'assets/images/give-media.png" />'
162
-					: '<span class="wp-media-buttons-icon" id="give-media-button" style="background-image: url(' . give_svg_icons( 'give_grey' ) . ');"></span>';
160
+				$img = (version_compare(get_bloginfo('version'), '3.5', '<'))
161
+					? '<img src="'.GIVE_PLUGIN_URL.'assets/images/give-media.png" />'
162
+					: '<span class="wp-media-buttons-icon" id="give-media-button" style="background-image: url('.give_svg_icons('give_grey').');"></span>';
163 163
 
164
-				reset( $shortcodes );
164
+				reset($shortcodes);
165 165
 
166
-				if ( count( $shortcodes ) == 1 ) {
166
+				if (count($shortcodes) == 1) {
167 167
 
168
-					$shortcode = key( $shortcodes );
168
+					$shortcode = key($shortcodes);
169 169
 
170 170
 					printf(
171 171
 						'<button class="button sc-shortcode" data-shortcode="%s">%s</button>',
172 172
 						$shortcode,
173
-						sprintf( '%s %s %s',
173
+						sprintf('%s %s %s',
174 174
 							$img,
175
-							esc_html__( 'Insert', 'give' ),
176
-							self::$shortcodes[ $shortcode ]['label']
175
+							esc_html__('Insert', 'give'),
176
+							self::$shortcodes[$shortcode]['label']
177 177
 						)
178 178
 					);
179 179
 				} else {
180 180
 					printf(
181
-						'<div class="sc-wrap">' .
182
-						'<button class="button sc-button">%s %s</button>' .
183
-						'<div class="sc-menu mce-menu">%s</div>' .
181
+						'<div class="sc-wrap">'.
182
+						'<button class="button sc-button">%s %s</button>'.
183
+						'<div class="sc-menu mce-menu">%s</div>'.
184 184
 						'</div>',
185 185
 						$img,
186
-						esc_html__( 'Give Shortcodes', 'give' ),
187
-						implode( '', array_values( $shortcodes ) )
186
+						esc_html__('Give Shortcodes', 'give'),
187
+						implode('', array_values($shortcodes))
188 188
 					);
189 189
 				}
190 190
 			}
@@ -200,15 +200,15 @@  discard block
 block discarded – undo
200 200
 	 */
201 201
 	public function shortcode_ajax() {
202 202
 
203
-		$shortcode = isset( $_POST['shortcode'] ) ? $_POST['shortcode'] : false;
203
+		$shortcode = isset($_POST['shortcode']) ? $_POST['shortcode'] : false;
204 204
 		$response  = false;
205 205
 
206
-		if ( $shortcode && array_key_exists( $shortcode, self::$shortcodes ) ) {
206
+		if ($shortcode && array_key_exists($shortcode, self::$shortcodes)) {
207 207
 
208
-			$data = self::$shortcodes[ $shortcode ];
208
+			$data = self::$shortcodes[$shortcode];
209 209
 
210
-			if ( ! empty( $data['errors'] ) ) {
211
-				$data['btn_okay'] = array( esc_html__( 'Okay', 'give' ) );
210
+			if ( ! empty($data['errors'])) {
211
+				$data['btn_okay'] = array(esc_html__('Okay', 'give'));
212 212
 			}
213 213
 
214 214
 			$response = array(
@@ -220,10 +220,10 @@  discard block
 block discarded – undo
220 220
 			);
221 221
 		} else {
222 222
 			// todo: handle error
223
-			error_log( print_r( 'AJAX error!', 1 ) );
223
+			error_log(print_r('AJAX error!', 1));
224 224
 		}
225 225
 
226
-		wp_send_json( $response );
226
+		wp_send_json($response);
227 227
 	}
228 228
 }
229 229
 
Please login to merge, or discard this patch.
includes/admin/shortcodes/shortcode-give-goal.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 // Exit if accessed directly
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
 	 */
24 24
 	public function __construct() {
25 25
 
26
-		$this->shortcode['title'] = esc_html__( 'Donation Form Goal', 'give' );
27
-		$this->shortcode['label'] = esc_html__( 'Donation Form Goal', 'give' );
26
+		$this->shortcode['title'] = esc_html__('Donation Form Goal', 'give');
27
+		$this->shortcode['label'] = esc_html__('Donation Form Goal', 'give');
28 28
 
29
-		parent::__construct( 'give_goal' );
29
+		parent::__construct('give_goal');
30 30
 	}
31 31
 
32 32
 	/**
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 
39 39
 		$create_form_link = sprintf(
40 40
 		/* translators: %s: create new form URL */
41
-			__( '<a href="%s">Create</a> a new Donation Form.', 'give' ),
42
-			admin_url( 'post-new.php?post_type=give_forms' )
41
+			__('<a href="%s">Create</a> a new Donation Form.', 'give'),
42
+			admin_url('post-new.php?post_type=give_forms')
43 43
 		);
44 44
 
45 45
 		return array(
@@ -49,35 +49,35 @@  discard block
 block discarded – undo
49 49
 					'post_type' => 'give_forms',
50 50
 				),
51 51
 				'name'        => 'id',
52
-				'tooltip'     => esc_attr__( 'Select a Donation Form', 'give' ),
53
-				'placeholder' => esc_attr__( '- Select a Form -', 'give' ),
52
+				'tooltip'     => esc_attr__('Select a Donation Form', 'give'),
53
+				'placeholder' => esc_attr__('- Select a Form -', 'give'),
54 54
 				'required'    => array(
55
-					'alert' => esc_html__( 'You must first select a Form!', 'give' ),
56
-					'error' => sprintf( '<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__( 'No forms found.', 'give' ), $create_form_link ),
55
+					'alert' => esc_html__('You must first select a Form!', 'give'),
56
+					'error' => sprintf('<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__('No forms found.', 'give'), $create_form_link),
57 57
 				),
58 58
 			),
59 59
 			array(
60 60
 				'type' => 'container',
61
-				'html' => sprintf( '<p class="strong margin-top">%s</p>', esc_html__( 'Optional settings', 'give' ) ),
61
+				'html' => sprintf('<p class="strong margin-top">%s</p>', esc_html__('Optional settings', 'give')),
62 62
 			),
63 63
 			array(
64 64
 				'type'    => 'listbox',
65 65
 				'name'    => 'show_text',
66
-				'label'   => esc_attr__( 'Show Text:', 'give' ),
67
-				'tooltip' => esc_attr__( 'This text displays the amount of income raised compared to the goal.', 'give' ),
66
+				'label'   => esc_attr__('Show Text:', 'give'),
67
+				'tooltip' => esc_attr__('This text displays the amount of income raised compared to the goal.', 'give'),
68 68
 				'options' => array(
69
-					'true'  => esc_html__( 'Show', 'give' ),
70
-					'false' => esc_html__( 'Hide', 'give' ),
69
+					'true'  => esc_html__('Show', 'give'),
70
+					'false' => esc_html__('Hide', 'give'),
71 71
 				),
72 72
 			),
73 73
 			array(
74 74
 				'type'    => 'listbox',
75 75
 				'name'    => 'show_bar',
76
-				'label'   => esc_attr__( 'Show Progress Bar:', 'give' ),
77
-				'tooltip' => esc_attr__( 'Do you want to display the goal\'s progress bar?', 'give' ),
76
+				'label'   => esc_attr__('Show Progress Bar:', 'give'),
77
+				'tooltip' => esc_attr__('Do you want to display the goal\'s progress bar?', 'give'),
78 78
 				'options' => array(
79
-					'true'  => esc_html__( 'Show', 'give' ),
80
-					'false' => esc_html__( 'Hide', 'give' ),
79
+					'true'  => esc_html__('Show', 'give'),
80
+					'false' => esc_html__('Hide', 'give'),
81 81
 				),
82 82
 			),
83 83
 		);
Please login to merge, or discard this patch.
includes/admin/shortcodes/shortcode-give-profile-editor.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	public function __construct() {
23 23
 
24
-		$this->shortcode['label'] = esc_html__( 'Profile Editor', 'give' );
24
+		$this->shortcode['label'] = esc_html__('Profile Editor', 'give');
25 25
 
26
-		parent::__construct( 'give_profile_editor' );
26
+		parent::__construct('give_profile_editor');
27 27
 	}
28 28
 }
29 29
 
Please login to merge, or discard this patch.
includes/admin/EDD_SL_Plugin_Updater.php 2 patches
Indentation   +259 added lines, -259 removed lines patch added patch discarded remove patch
@@ -15,326 +15,326 @@
 block discarded – undo
15 15
  * @version 1.6
16 16
  */
17 17
 class EDD_SL_Plugin_Updater {
18
-    private $api_url   = '';
19
-    private $api_data  = array();
20
-    private $name      = '';
21
-    private $slug      = '';
22
-
23
-    /**
24
-     * Class constructor.
25
-     *
26
-     * @param string  $_api_url     The URL pointing to the custom API endpoint.
27
-     * @param string  $_plugin_file Path to the plugin file.
28
-     * @param array   $_api_data    Optional data to send with API calls.
29
-     */
30
-    function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
31
-        $this->api_url  = trailingslashit( $_api_url );
32
-        $this->api_data = $_api_data;
33
-        $this->name     = plugin_basename( $_plugin_file );
34
-        $this->slug     = basename( $_plugin_file, '.php' );
35
-        $this->version  = $_api_data['version'];
36
-
37
-        // Set up hooks.
38
-        $this->init();
39
-        add_action( 'admin_init', array( $this, 'show_changelog' ) );
40
-    }
41
-
42
-    /**
43
-     * Set up WordPress filters to hook into WP's update process.
44
-     *
45
-     * @return void
46
-     */
47
-    public function init() {
48
-
49
-        add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
50
-        add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
51
-
52
-        add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
53
-    }
54
-
55
-    /**
56
-     * Check for Updates at the defined API endpoint and modify the update array.
57
-     *
58
-     * This function dives into the update API just when WordPress creates its update array,
59
-     * then adds a custom API call and injects the custom plugin data retrieved from the API.
60
-     * It is reassembled from parts of the native WordPress plugin update code.
61
-     * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
62
-     *
63
-     * @uses api_request()
18
+	private $api_url   = '';
19
+	private $api_data  = array();
20
+	private $name      = '';
21
+	private $slug      = '';
22
+
23
+	/**
24
+	 * Class constructor.
25
+	 *
26
+	 * @param string  $_api_url     The URL pointing to the custom API endpoint.
27
+	 * @param string  $_plugin_file Path to the plugin file.
28
+	 * @param array   $_api_data    Optional data to send with API calls.
29
+	 */
30
+	function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
31
+		$this->api_url  = trailingslashit( $_api_url );
32
+		$this->api_data = $_api_data;
33
+		$this->name     = plugin_basename( $_plugin_file );
34
+		$this->slug     = basename( $_plugin_file, '.php' );
35
+		$this->version  = $_api_data['version'];
36
+
37
+		// Set up hooks.
38
+		$this->init();
39
+		add_action( 'admin_init', array( $this, 'show_changelog' ) );
40
+	}
41
+
42
+	/**
43
+	 * Set up WordPress filters to hook into WP's update process.
64 44
 	 *
65
-     * @global $pagenow
66
-     *
67
-     * @param array   $_transient_data Update array build by WordPress.
68
-     * @return array Modified update array with custom plugin data.
69
-     */
70
-    function check_update( $_transient_data ) {
45
+	 * @return void
46
+	 */
47
+	public function init() {
71 48
 
72
-        global $pagenow;
49
+		add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
50
+		add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
73 51
 
74
-        if( ! is_object( $_transient_data ) ) {
75
-            $_transient_data = new stdClass;
76
-        }
52
+		add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
53
+	}
77 54
 
78
-        if( 'plugins.php' == $pagenow && is_multisite() ) {
79
-            return $_transient_data;
80
-        }
55
+	/**
56
+	 * Check for Updates at the defined API endpoint and modify the update array.
57
+	 *
58
+	 * This function dives into the update API just when WordPress creates its update array,
59
+	 * then adds a custom API call and injects the custom plugin data retrieved from the API.
60
+	 * It is reassembled from parts of the native WordPress plugin update code.
61
+	 * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
62
+	 *
63
+	 * @uses api_request()
64
+	 *
65
+	 * @global $pagenow
66
+	 *
67
+	 * @param array   $_transient_data Update array build by WordPress.
68
+	 * @return array Modified update array with custom plugin data.
69
+	 */
70
+	function check_update( $_transient_data ) {
81 71
 
82
-        if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) {
72
+		global $pagenow;
83 73
 
84
-            $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
74
+		if( ! is_object( $_transient_data ) ) {
75
+			$_transient_data = new stdClass;
76
+		}
85 77
 
86
-            if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
78
+		if( 'plugins.php' == $pagenow && is_multisite() ) {
79
+			return $_transient_data;
80
+		}
87 81
 
88
-                $this->did_check = true;
82
+		if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) {
89 83
 
90
-                if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
84
+			$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
91 85
 
92
-                    $_transient_data->response[ $this->name ] = $version_info;
86
+			if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
93 87
 
94
-                }
88
+				$this->did_check = true;
95 89
 
96
-                $_transient_data->last_checked = time();
97
-                $_transient_data->checked[ $this->name ] = $this->version;
90
+				if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
98 91
 
99
-            }
92
+					$_transient_data->response[ $this->name ] = $version_info;
100 93
 
101
-        }
94
+				}
102 95
 
103
-        return $_transient_data;
104
-    }
96
+				$_transient_data->last_checked = time();
97
+				$_transient_data->checked[ $this->name ] = $this->version;
105 98
 
106
-    /**
107
-     * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
108
-     *
109
-     * @param string  $file
110
-     * @param array   $plugin
111
-     */
112
-    public function show_update_notification( $file, $plugin ) {
99
+			}
113 100
 
114
-        if( ! current_user_can( 'update_plugins' ) ) {
115
-            return;
116
-        }
101
+		}
117 102
 
118
-        if( ! is_multisite() ) {
119
-            return;
120
-        }
103
+		return $_transient_data;
104
+	}
121 105
 
122
-        if ( $this->name != $file ) {
123
-            return;
124
-        }
106
+	/**
107
+	 * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
108
+	 *
109
+	 * @param string  $file
110
+	 * @param array   $plugin
111
+	 */
112
+	public function show_update_notification( $file, $plugin ) {
125 113
 
126
-        // Remove our filter on the site transient
127
-        remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
114
+		if( ! current_user_can( 'update_plugins' ) ) {
115
+			return;
116
+		}
128 117
 
129
-        $update_cache = get_site_transient( 'update_plugins' );
118
+		if( ! is_multisite() ) {
119
+			return;
120
+		}
130 121
 
131
-        if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
122
+		if ( $this->name != $file ) {
123
+			return;
124
+		}
132 125
 
133
-            $cache_key    = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' );
134
-            $version_info = get_transient( $cache_key );
126
+		// Remove our filter on the site transient
127
+		remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
135 128
 
136
-            if( false === $version_info ) {
129
+		$update_cache = get_site_transient( 'update_plugins' );
137 130
 
138
-                $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
131
+		if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
139 132
 
140
-                set_transient( $cache_key, $version_info, 3600 );
141
-            }
133
+			$cache_key    = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' );
134
+			$version_info = get_transient( $cache_key );
142 135
 
136
+			if( false === $version_info ) {
143 137
 
144
-            if( ! is_object( $version_info ) ) {
145
-                return;
146
-            }
138
+				$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
147 139
 
148
-            if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
140
+				set_transient( $cache_key, $version_info, 3600 );
141
+			}
149 142
 
150
-                $update_cache->response[ $this->name ] = $version_info;
151 143
 
152
-            }
144
+			if( ! is_object( $version_info ) ) {
145
+				return;
146
+			}
153 147
 
154
-            $update_cache->last_checked = time();
155
-            $update_cache->checked[ $this->name ] = $this->version;
148
+			if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
156 149
 
157
-            set_site_transient( 'update_plugins', $update_cache );
150
+				$update_cache->response[ $this->name ] = $version_info;
158 151
 
159
-        } else {
152
+			}
160 153
 
161
-            $version_info = $update_cache->response[ $this->name ];
154
+			$update_cache->last_checked = time();
155
+			$update_cache->checked[ $this->name ] = $this->version;
162 156
 
163
-        }
157
+			set_site_transient( 'update_plugins', $update_cache );
164 158
 
165
-        // Restore our filter
166
-        add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
159
+		} else {
167 160
 
168
-        if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
161
+			$version_info = $update_cache->response[ $this->name ];
169 162
 
170
-            // build a plugin list row, with update notification
171
-            $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
172
-            echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
163
+		}
173 164
 
174
-            $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
165
+		// Restore our filter
166
+		add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
175 167
 
176
-            if ( empty( $version_info->download_link ) ) {
177
-                printf(
168
+		if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
169
+
170
+			// build a plugin list row, with update notification
171
+			$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
172
+			echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
173
+
174
+			$changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
175
+
176
+			if ( empty( $version_info->download_link ) ) {
177
+				printf(
178 178
 					/* translators: 1: name 2: changelog URL 3: version */
179
-                    __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'give' ),
180
-                    esc_html( $version_info->name ),
181
-                    esc_url( $changelog_link ),
182
-                    esc_html( $version_info->new_version )
183
-                );
184
-            } else {
185
-                printf(
179
+					__( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'give' ),
180
+					esc_html( $version_info->name ),
181
+					esc_url( $changelog_link ),
182
+					esc_html( $version_info->new_version )
183
+				);
184
+			} else {
185
+				printf(
186 186
 					/* translators: 1: name 2: changelog URL 3: version 4: update URL */
187
-                    __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'give' ),
188
-                    esc_html( $version_info->name ),
189
-                    esc_url( $changelog_link ),
190
-                    esc_html( $version_info->new_version ),
191
-                    esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) )
192
-                );
193
-            }
194
-
195
-            echo '</div></td></tr>';
196
-        }
197
-    }
198
-
199
-
200
-    /**
201
-     * Updates information on the "View version x.x details" page with custom data.
202
-     *
203
-     * @uses api_request()
204
-     *
205
-     * @param mixed   $_data
206
-     * @param string  $_action
207
-     * @param object  $_args
208
-     * @return object $_data
209
-     */
210
-    function plugins_api_filter( $_data, $_action = '', $_args = null ) {
211
-
212
-
213
-        if ( $_action != 'plugin_information' ) {
214
-
215
-            return $_data;
216
-
217
-        }
218
-
219
-        if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
220
-
221
-            return $_data;
222
-
223
-        }
224
-
225
-        $to_send = array(
226
-            'slug'   => $this->slug,
227
-            'is_ssl' => is_ssl(),
228
-            'fields' => array(
229
-                'banners' => false, // These will be supported soon hopefully
230
-                'reviews' => false
231
-            )
232
-        );
233
-
234
-        $api_response = $this->api_request( 'plugin_information', $to_send );
235
-
236
-        if ( false !== $api_response ) {
237
-            $_data = $api_response;
238
-        }
239
-
240
-        return $_data;
241
-    }
242
-
243
-
244
-    /**
245
-     * Disable SSL verification in order to prevent download update failures
246
-     *
247
-     * @param array   $args
248
-     * @param string  $url
249
-     * @return object $array
250
-     */
251
-    function http_request_args( $args, $url ) {
252
-        // If it is an https request and we are performing a package download, disable ssl verification
253
-        if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
254
-            $args['sslverify'] = false;
255
-        }
256
-        return $args;
257
-    }
258
-
259
-    /**
260
-     * Calls the API and, if successfull, returns the object delivered by the API.
261
-     *
262
-     * @uses get_bloginfo()
263
-     * @uses wp_remote_post()
264
-     * @uses is_wp_error()
265
-     *
266
-     * @param string  $_action The requested action.
267
-     * @param array   $_data   Parameters for the API action.
268
-     * @return false||object
269
-     */
270
-    private function api_request( $_action, $_data ) {
271
-
272
-        $data = array_merge( $this->api_data, $_data );
273
-
274
-        if ( $data['slug'] != $this->slug ) {
275
-            return;
187
+					__( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'give' ),
188
+					esc_html( $version_info->name ),
189
+					esc_url( $changelog_link ),
190
+					esc_html( $version_info->new_version ),
191
+					esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) )
192
+				);
193
+			}
194
+
195
+			echo '</div></td></tr>';
276 196
 		}
197
+	}
198
+
199
+
200
+	/**
201
+	 * Updates information on the "View version x.x details" page with custom data.
202
+	 *
203
+	 * @uses api_request()
204
+	 *
205
+	 * @param mixed   $_data
206
+	 * @param string  $_action
207
+	 * @param object  $_args
208
+	 * @return object $_data
209
+	 */
210
+	function plugins_api_filter( $_data, $_action = '', $_args = null ) {
211
+
212
+
213
+		if ( $_action != 'plugin_information' ) {
214
+
215
+			return $_data;
277 216
 
278
-        if ( empty( $data['license'] ) ) {
279
-            return;
280 217
 		}
281 218
 
282
-        if( $this->api_url == home_url() ) {
283
-            return false; // Don't allow a plugin to ping itself
284
-        }
219
+		if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
285 220
 
286
-        $api_params = array(
287
-            'edd_action' => 'get_version',
288
-            'license'    => $data['license'],
289
-            'item_name'  => isset( $data['item_name'] ) ? $data['item_name'] : false,
290
-            'item_id'    => isset( $data['item_id'] ) ? $data['item_id'] : false,
291
-            'slug'       => $data['slug'],
292
-            'author'     => $data['author'],
293
-            'url'        => home_url()
294
-        );
221
+			return $_data;
295 222
 
296
-        $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
223
+		}
297 224
 
298
-        if ( ! is_wp_error( $request ) ) {
299
-            $request = json_decode( wp_remote_retrieve_body( $request ) );
300
-        }
225
+		$to_send = array(
226
+			'slug'   => $this->slug,
227
+			'is_ssl' => is_ssl(),
228
+			'fields' => array(
229
+				'banners' => false, // These will be supported soon hopefully
230
+				'reviews' => false
231
+			)
232
+		);
301 233
 
302
-        if ( $request && isset( $request->sections ) ) {
303
-            $request->sections = maybe_unserialize( $request->sections );
304
-        } else {
305
-            $request = false;
306
-        }
234
+		$api_response = $this->api_request( 'plugin_information', $to_send );
307 235
 
308
-        return $request;
309
-    }
236
+		if ( false !== $api_response ) {
237
+			$_data = $api_response;
238
+		}
310 239
 
311
-    public function show_changelog() {
240
+		return $_data;
241
+	}
312 242
 
313 243
 
314
-        if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
315
-            return;
316
-        }
244
+	/**
245
+	 * Disable SSL verification in order to prevent download update failures
246
+	 *
247
+	 * @param array   $args
248
+	 * @param string  $url
249
+	 * @return object $array
250
+	 */
251
+	function http_request_args( $args, $url ) {
252
+		// If it is an https request and we are performing a package download, disable ssl verification
253
+		if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
254
+			$args['sslverify'] = false;
255
+		}
256
+		return $args;
257
+	}
258
+
259
+	/**
260
+	 * Calls the API and, if successfull, returns the object delivered by the API.
261
+	 *
262
+	 * @uses get_bloginfo()
263
+	 * @uses wp_remote_post()
264
+	 * @uses is_wp_error()
265
+	 *
266
+	 * @param string  $_action The requested action.
267
+	 * @param array   $_data   Parameters for the API action.
268
+	 * @return false||object
269
+	 */
270
+	private function api_request( $_action, $_data ) {
271
+
272
+		$data = array_merge( $this->api_data, $_data );
273
+
274
+		if ( $data['slug'] != $this->slug ) {
275
+			return;
276
+		}
277
+
278
+		if ( empty( $data['license'] ) ) {
279
+			return;
280
+		}
281
+
282
+		if( $this->api_url == home_url() ) {
283
+			return false; // Don't allow a plugin to ping itself
284
+		}
285
+
286
+		$api_params = array(
287
+			'edd_action' => 'get_version',
288
+			'license'    => $data['license'],
289
+			'item_name'  => isset( $data['item_name'] ) ? $data['item_name'] : false,
290
+			'item_id'    => isset( $data['item_id'] ) ? $data['item_id'] : false,
291
+			'slug'       => $data['slug'],
292
+			'author'     => $data['author'],
293
+			'url'        => home_url()
294
+		);
295
+
296
+		$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
317 297
 
318
-        if( empty( $_REQUEST['plugin'] ) ) {
319
-            return;
320
-        }
298
+		if ( ! is_wp_error( $request ) ) {
299
+			$request = json_decode( wp_remote_retrieve_body( $request ) );
300
+		}
301
+
302
+		if ( $request && isset( $request->sections ) ) {
303
+			$request->sections = maybe_unserialize( $request->sections );
304
+		} else {
305
+			$request = false;
306
+		}
307
+
308
+		return $request;
309
+	}
321 310
 
322
-        if( empty( $_REQUEST['slug'] ) ) {
323
-            return;
324
-        }
311
+	public function show_changelog() {
325 312
 
326
-        if( ! current_user_can( 'update_plugins' ) ) {
327
-            wp_die( esc_html__( 'You do not have permission to install plugin updates.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
328
-        }
329 313
 
330
-        $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) );
314
+		if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
315
+			return;
316
+		}
317
+
318
+		if( empty( $_REQUEST['plugin'] ) ) {
319
+			return;
320
+		}
331 321
 
332
-        if( $response && isset( $response->sections['changelog'] ) ) {
333
-            echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>';
334
-        }
322
+		if( empty( $_REQUEST['slug'] ) ) {
323
+			return;
324
+		}
325
+
326
+		if( ! current_user_can( 'update_plugins' ) ) {
327
+			wp_die( esc_html__( 'You do not have permission to install plugin updates.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
328
+		}
329
+
330
+		$response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) );
331
+
332
+		if( $response && isset( $response->sections['changelog'] ) ) {
333
+			echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>';
334
+		}
335 335
 
336 336
 
337
-        exit;
338
-    }
337
+		exit;
338
+	}
339 339
 
340 340
 }
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 //set_site_transient( 'update_plugins', null );
5 5
 
6 6
 // Exit if accessed directly
7
-if ( ! defined( 'ABSPATH' ) ) {
7
+if ( ! defined('ABSPATH')) {
8 8
 	exit;
9 9
 }
10 10
 
@@ -27,16 +27,16 @@  discard block
 block discarded – undo
27 27
      * @param string  $_plugin_file Path to the plugin file.
28 28
      * @param array   $_api_data    Optional data to send with API calls.
29 29
      */
30
-    function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
31
-        $this->api_url  = trailingslashit( $_api_url );
30
+    function __construct($_api_url, $_plugin_file, $_api_data = null) {
31
+        $this->api_url  = trailingslashit($_api_url);
32 32
         $this->api_data = $_api_data;
33
-        $this->name     = plugin_basename( $_plugin_file );
34
-        $this->slug     = basename( $_plugin_file, '.php' );
33
+        $this->name     = plugin_basename($_plugin_file);
34
+        $this->slug     = basename($_plugin_file, '.php');
35 35
         $this->version  = $_api_data['version'];
36 36
 
37 37
         // Set up hooks.
38 38
         $this->init();
39
-        add_action( 'admin_init', array( $this, 'show_changelog' ) );
39
+        add_action('admin_init', array($this, 'show_changelog'));
40 40
     }
41 41
 
42 42
     /**
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function init() {
48 48
 
49
-        add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
50
-        add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
49
+        add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'));
50
+        add_filter('plugins_api', array($this, 'plugins_api_filter'), 10, 3);
51 51
 
52
-        add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
52
+        add_action('after_plugin_row_'.$this->name, array($this, 'show_update_notification'), 10, 2);
53 53
     }
54 54
 
55 55
     /**
@@ -67,34 +67,34 @@  discard block
 block discarded – undo
67 67
      * @param array   $_transient_data Update array build by WordPress.
68 68
      * @return array Modified update array with custom plugin data.
69 69
      */
70
-    function check_update( $_transient_data ) {
70
+    function check_update($_transient_data) {
71 71
 
72 72
         global $pagenow;
73 73
 
74
-        if( ! is_object( $_transient_data ) ) {
74
+        if ( ! is_object($_transient_data)) {
75 75
             $_transient_data = new stdClass;
76 76
         }
77 77
 
78
-        if( 'plugins.php' == $pagenow && is_multisite() ) {
78
+        if ('plugins.php' == $pagenow && is_multisite()) {
79 79
             return $_transient_data;
80 80
         }
81 81
 
82
-        if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) {
82
+        if (empty($_transient_data->response) || empty($_transient_data->response[$this->name])) {
83 83
 
84
-            $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
84
+            $version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug));
85 85
 
86
-            if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
86
+            if (false !== $version_info && is_object($version_info) && isset($version_info->new_version)) {
87 87
 
88 88
                 $this->did_check = true;
89 89
 
90
-                if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
90
+                if (version_compare($this->version, $version_info->new_version, '<')) {
91 91
 
92
-                    $_transient_data->response[ $this->name ] = $version_info;
92
+                    $_transient_data->response[$this->name] = $version_info;
93 93
 
94 94
                 }
95 95
 
96 96
                 $_transient_data->last_checked = time();
97
-                $_transient_data->checked[ $this->name ] = $this->version;
97
+                $_transient_data->checked[$this->name] = $this->version;
98 98
 
99 99
             }
100 100
 
@@ -109,86 +109,86 @@  discard block
 block discarded – undo
109 109
      * @param string  $file
110 110
      * @param array   $plugin
111 111
      */
112
-    public function show_update_notification( $file, $plugin ) {
112
+    public function show_update_notification($file, $plugin) {
113 113
 
114
-        if( ! current_user_can( 'update_plugins' ) ) {
114
+        if ( ! current_user_can('update_plugins')) {
115 115
             return;
116 116
         }
117 117
 
118
-        if( ! is_multisite() ) {
118
+        if ( ! is_multisite()) {
119 119
             return;
120 120
         }
121 121
 
122
-        if ( $this->name != $file ) {
122
+        if ($this->name != $file) {
123 123
             return;
124 124
         }
125 125
 
126 126
         // Remove our filter on the site transient
127
-        remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
127
+        remove_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'), 10);
128 128
 
129
-        $update_cache = get_site_transient( 'update_plugins' );
129
+        $update_cache = get_site_transient('update_plugins');
130 130
 
131
-        if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
131
+        if ( ! is_object($update_cache) || empty($update_cache->response) || empty($update_cache->response[$this->name])) {
132 132
 
133
-            $cache_key    = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' );
134
-            $version_info = get_transient( $cache_key );
133
+            $cache_key    = md5('edd_plugin_'.sanitize_key($this->name).'_version_info');
134
+            $version_info = get_transient($cache_key);
135 135
 
136
-            if( false === $version_info ) {
136
+            if (false === $version_info) {
137 137
 
138
-                $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
138
+                $version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug));
139 139
 
140
-                set_transient( $cache_key, $version_info, 3600 );
140
+                set_transient($cache_key, $version_info, 3600);
141 141
             }
142 142
 
143 143
 
144
-            if( ! is_object( $version_info ) ) {
144
+            if ( ! is_object($version_info)) {
145 145
                 return;
146 146
             }
147 147
 
148
-            if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
148
+            if (version_compare($this->version, $version_info->new_version, '<')) {
149 149
 
150
-                $update_cache->response[ $this->name ] = $version_info;
150
+                $update_cache->response[$this->name] = $version_info;
151 151
 
152 152
             }
153 153
 
154 154
             $update_cache->last_checked = time();
155
-            $update_cache->checked[ $this->name ] = $this->version;
155
+            $update_cache->checked[$this->name] = $this->version;
156 156
 
157
-            set_site_transient( 'update_plugins', $update_cache );
157
+            set_site_transient('update_plugins', $update_cache);
158 158
 
159 159
         } else {
160 160
 
161
-            $version_info = $update_cache->response[ $this->name ];
161
+            $version_info = $update_cache->response[$this->name];
162 162
 
163 163
         }
164 164
 
165 165
         // Restore our filter
166
-        add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
166
+        add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'));
167 167
 
168
-        if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
168
+        if ( ! empty($update_cache->response[$this->name]) && version_compare($this->version, $version_info->new_version, '<')) {
169 169
 
170 170
             // build a plugin list row, with update notification
171
-            $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
172
-            echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
171
+            $wp_list_table = _get_list_table('WP_Plugins_List_Table');
172
+            echo '<tr class="plugin-update-tr"><td colspan="'.$wp_list_table->get_column_count().'" class="plugin-update colspanchange"><div class="update-message">';
173 173
 
174
-            $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
174
+            $changelog_link = self_admin_url('index.php?edd_sl_action=view_plugin_changelog&plugin='.$this->name.'&slug='.$this->slug.'&TB_iframe=true&width=772&height=911');
175 175
 
176
-            if ( empty( $version_info->download_link ) ) {
176
+            if (empty($version_info->download_link)) {
177 177
                 printf(
178 178
 					/* translators: 1: name 2: changelog URL 3: version */
179
-                    __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'give' ),
180
-                    esc_html( $version_info->name ),
181
-                    esc_url( $changelog_link ),
182
-                    esc_html( $version_info->new_version )
179
+                    __('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'give'),
180
+                    esc_html($version_info->name),
181
+                    esc_url($changelog_link),
182
+                    esc_html($version_info->new_version)
183 183
                 );
184 184
             } else {
185 185
                 printf(
186 186
 					/* translators: 1: name 2: changelog URL 3: version 4: update URL */
187
-                    __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'give' ),
188
-                    esc_html( $version_info->name ),
189
-                    esc_url( $changelog_link ),
190
-                    esc_html( $version_info->new_version ),
191
-                    esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) )
187
+                    __('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'give'),
188
+                    esc_html($version_info->name),
189
+                    esc_url($changelog_link),
190
+                    esc_html($version_info->new_version),
191
+                    esc_url(wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=').$this->name, 'upgrade-plugin_'.$this->name))
192 192
                 );
193 193
             }
194 194
 
@@ -207,16 +207,16 @@  discard block
 block discarded – undo
207 207
      * @param object  $_args
208 208
      * @return object $_data
209 209
      */
210
-    function plugins_api_filter( $_data, $_action = '', $_args = null ) {
210
+    function plugins_api_filter($_data, $_action = '', $_args = null) {
211 211
 
212 212
 
213
-        if ( $_action != 'plugin_information' ) {
213
+        if ($_action != 'plugin_information') {
214 214
 
215 215
             return $_data;
216 216
 
217 217
         }
218 218
 
219
-        if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
219
+        if ( ! isset($_args->slug) || ($_args->slug != $this->slug)) {
220 220
 
221 221
             return $_data;
222 222
 
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
             )
232 232
         );
233 233
 
234
-        $api_response = $this->api_request( 'plugin_information', $to_send );
234
+        $api_response = $this->api_request('plugin_information', $to_send);
235 235
 
236
-        if ( false !== $api_response ) {
236
+        if (false !== $api_response) {
237 237
             $_data = $api_response;
238 238
         }
239 239
 
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
      * @param string  $url
249 249
      * @return object $array
250 250
      */
251
-    function http_request_args( $args, $url ) {
251
+    function http_request_args($args, $url) {
252 252
         // If it is an https request and we are performing a package download, disable ssl verification
253
-        if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
253
+        if (strpos($url, 'https://') !== false && strpos($url, 'edd_action=package_download')) {
254 254
             $args['sslverify'] = false;
255 255
         }
256 256
         return $args;
@@ -267,40 +267,40 @@  discard block
 block discarded – undo
267 267
      * @param array   $_data   Parameters for the API action.
268 268
      * @return false||object
269 269
      */
270
-    private function api_request( $_action, $_data ) {
270
+    private function api_request($_action, $_data) {
271 271
 
272
-        $data = array_merge( $this->api_data, $_data );
272
+        $data = array_merge($this->api_data, $_data);
273 273
 
274
-        if ( $data['slug'] != $this->slug ) {
274
+        if ($data['slug'] != $this->slug) {
275 275
             return;
276 276
 		}
277 277
 
278
-        if ( empty( $data['license'] ) ) {
278
+        if (empty($data['license'])) {
279 279
             return;
280 280
 		}
281 281
 
282
-        if( $this->api_url == home_url() ) {
282
+        if ($this->api_url == home_url()) {
283 283
             return false; // Don't allow a plugin to ping itself
284 284
         }
285 285
 
286 286
         $api_params = array(
287 287
             'edd_action' => 'get_version',
288 288
             'license'    => $data['license'],
289
-            'item_name'  => isset( $data['item_name'] ) ? $data['item_name'] : false,
290
-            'item_id'    => isset( $data['item_id'] ) ? $data['item_id'] : false,
289
+            'item_name'  => isset($data['item_name']) ? $data['item_name'] : false,
290
+            'item_id'    => isset($data['item_id']) ? $data['item_id'] : false,
291 291
             'slug'       => $data['slug'],
292 292
             'author'     => $data['author'],
293 293
             'url'        => home_url()
294 294
         );
295 295
 
296
-        $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
296
+        $request = wp_remote_post($this->api_url, array('timeout' => 15, 'sslverify' => false, 'body' => $api_params));
297 297
 
298
-        if ( ! is_wp_error( $request ) ) {
299
-            $request = json_decode( wp_remote_retrieve_body( $request ) );
298
+        if ( ! is_wp_error($request)) {
299
+            $request = json_decode(wp_remote_retrieve_body($request));
300 300
         }
301 301
 
302
-        if ( $request && isset( $request->sections ) ) {
303
-            $request->sections = maybe_unserialize( $request->sections );
302
+        if ($request && isset($request->sections)) {
303
+            $request->sections = maybe_unserialize($request->sections);
304 304
         } else {
305 305
             $request = false;
306 306
         }
@@ -311,26 +311,26 @@  discard block
 block discarded – undo
311 311
     public function show_changelog() {
312 312
 
313 313
 
314
-        if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
314
+        if (empty($_REQUEST['edd_sl_action']) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action']) {
315 315
             return;
316 316
         }
317 317
 
318
-        if( empty( $_REQUEST['plugin'] ) ) {
318
+        if (empty($_REQUEST['plugin'])) {
319 319
             return;
320 320
         }
321 321
 
322
-        if( empty( $_REQUEST['slug'] ) ) {
322
+        if (empty($_REQUEST['slug'])) {
323 323
             return;
324 324
         }
325 325
 
326
-        if( ! current_user_can( 'update_plugins' ) ) {
327
-            wp_die( esc_html__( 'You do not have permission to install plugin updates.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
326
+        if ( ! current_user_can('update_plugins')) {
327
+            wp_die(esc_html__('You do not have permission to install plugin updates.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
328 328
         }
329 329
 
330
-        $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) );
330
+        $response = $this->api_request('plugin_latest_version', array('slug' => $_REQUEST['slug']));
331 331
 
332
-        if( $response && isset( $response->sections['changelog'] ) ) {
333
-            echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>';
332
+        if ($response && isset($response->sections['changelog'])) {
333
+            echo '<div style="background:#fff;padding:10px;">'.$response->sections['changelog'].'</div>';
334 334
         }
335 335
 
336 336
 
Please login to merge, or discard this patch.