Completed
Pull Request — develop (#1436)
by
unknown
15:35
created
includes/class-admin-installer.php 1 patch
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function add_downloads_data_filters() {
68 68
 
69
-	    $downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT );
69
+		$downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT );
70 70
 
71
-	    if ( ! $downloads_data && ! isset( $_GET['cache'] ) ) {
71
+		if ( ! $downloads_data && ! isset( $_GET['cache'] ) ) {
72 72
 			return;
73 73
 		}
74 74
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function add_admin_menu() {
99 99
 
100
-	    $menu_text = _x( 'Manage Add-Ons', 'Extensions are WordPress plugins that add functionality to GravityView and Gravity Forms', 'gravityview' );
100
+		$menu_text = _x( 'Manage Add-Ons', 'Extensions are WordPress plugins that add functionality to GravityView and Gravity Forms', 'gravityview' );
101 101
 
102 102
 		$menu_text = sprintf( '<span title="%s" style="margin: 0">%s</span>', esc_attr__( 'Plugins that extend GravityView and Gravity Forms functionality.', 'gravityview' ), $menu_text );
103 103
 
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 	}
113 113
 
114 114
 	/**
115
-     * When on the Installer page, show a different notice than on the Settings page
116
-     *
115
+	 * When on the Installer page, show a different notice than on the Settings page
116
+	 *
117 117
 	 * @param array $notice
118 118
 	 *
119 119
 	 * @return string License notice
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
 	public function maybe_modify_license_notice( $notice = '' ) {
122 122
 
123 123
 		if ( ! gravityview()->request->is_admin( '', 'downloads' ) ) {
124
-            return $notice;
125
-        }
124
+			return $notice;
125
+		}
126 126
 
127
-        return esc_html__( 'Your license %s. Do you want access to these plugins? %sActivate your license%s or %sget a license here%s.', 'gravityview' );
127
+		return esc_html__( 'Your license %s. Do you want access to these plugins? %sActivate your license%s or %sget a license here%s.', 'gravityview' );
128 128
 	}
129 129
 
130 130
 	/**
@@ -162,43 +162,43 @@  discard block
 block discarded – undo
162 162
 	 * Get downloads data from transient or from API; save transient after getting data from API
163 163
 	 *
164 164
 	 * @return WP_Error|array If error, returns WP_Error. If not valid JSON, empty array. Otherwise, this structure: {
165
-     *   @type array  $info {
166
-     *       @type string $id int 17
167
-     *       @type string $slug Extension slug
168
-     *       @type string $title Extension title
169
-     *       @type string $create_date in '2018-07-19 20:03:10' format
170
-     *       @type string $modified_date
171
-     *       @type string $status
172
-     *       @type string $link URL to public plugin page
173
-     *       @type string $content
174
-     *       @type string $excerpt
175
-     *       @type string $thumbnail URL to thumbnail
176
-     *       @type array  $category Taxonomy details for the plugin's category {
177
-     *         @type int $term_id => int 30
178
-     *         @type string $name => string 'Plugins' (length=7)
179
-     *         @type string $slug => string 'plugins' (length=7)
180
-     *         @type int $term_group => int 0
181
-     *         @type int $term_taxonomy_id => int 30
182
-     *         @type string $taxonomy => string 'download_category' (length=17)
183
-     *         @type string $description => string '' (length=0)
184
-     *         @type int $parent => int 0
185
-     *         @type int $count => int 4
186
-     *         @type string $filter => string 'raw' (length=3)
187
-     *       }
188
-     *       @type array $tags {see $category above}
189
-     *       @type string $textdomain string 'gravityview' (length=11)
190
-     *   }
191
-     *   @type array $pricing array of `price_name_slugs` => '00.00' values, if price options exist
192
-     *   @type array $licensing {
193
-     *       @type bool   $enabled Is licensing enabled for the extension
194
-     *       @type string $version Version number
195
-     *       @type string $exp_unit Expiration unit ('years')
196
-     *       @type string $exp_length Expiration length ('1')
197
-     *   }
198
-     *   @type array $files Array of files. Empty if user has no access to the file. {
199
-     *       @type string $file string URL of the file download
200
-     *   }
201
-     * }
165
+	 *   @type array  $info {
166
+	 *       @type string $id int 17
167
+	 *       @type string $slug Extension slug
168
+	 *       @type string $title Extension title
169
+	 *       @type string $create_date in '2018-07-19 20:03:10' format
170
+	 *       @type string $modified_date
171
+	 *       @type string $status
172
+	 *       @type string $link URL to public plugin page
173
+	 *       @type string $content
174
+	 *       @type string $excerpt
175
+	 *       @type string $thumbnail URL to thumbnail
176
+	 *       @type array  $category Taxonomy details for the plugin's category {
177
+	 *         @type int $term_id => int 30
178
+	 *         @type string $name => string 'Plugins' (length=7)
179
+	 *         @type string $slug => string 'plugins' (length=7)
180
+	 *         @type int $term_group => int 0
181
+	 *         @type int $term_taxonomy_id => int 30
182
+	 *         @type string $taxonomy => string 'download_category' (length=17)
183
+	 *         @type string $description => string '' (length=0)
184
+	 *         @type int $parent => int 0
185
+	 *         @type int $count => int 4
186
+	 *         @type string $filter => string 'raw' (length=3)
187
+	 *       }
188
+	 *       @type array $tags {see $category above}
189
+	 *       @type string $textdomain string 'gravityview' (length=11)
190
+	 *   }
191
+	 *   @type array $pricing array of `price_name_slugs` => '00.00' values, if price options exist
192
+	 *   @type array $licensing {
193
+	 *       @type bool   $enabled Is licensing enabled for the extension
194
+	 *       @type string $version Version number
195
+	 *       @type string $exp_unit Expiration unit ('years')
196
+	 *       @type string $exp_length Expiration length ('1')
197
+	 *   }
198
+	 *   @type array $files Array of files. Empty if user has no access to the file. {
199
+	 *       @type string $file string URL of the file download
200
+	 *   }
201
+	 * }
202 202
 	 */
203 203
 	public function get_downloads_data() {
204 204
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 		) );
231 231
 
232 232
 		if ( is_wp_error( $response ) ) {
233
-		    gravityview()->log->error( "Extension data response is an error", array( 'data' => $response ) );
233
+			gravityview()->log->error( "Extension data response is an error", array( 'data' => $response ) );
234 234
 			return $response;
235 235
 		}
236 236
 
@@ -283,10 +283,10 @@  discard block
 block discarded – undo
283 283
                 <div class="gv-admin-installer-notice notice inline error">
284 284
                     <h3><?php esc_html_e( 'Extensions and plugins data cannot be loaded at the moment. Please try again later.', 'gravityview' ); ?></h3>
285 285
                     <?php
286
-                    if ( is_wp_error( $downloads_data ) ) {
287
-	                    echo wpautop( '<pre>' . esc_html( $downloads_data->get_error_message() ) . '</pre>' );
288
-                    }
289
-                    ?>
286
+					if ( is_wp_error( $downloads_data ) ) {
287
+						echo wpautop( '<pre>' . esc_html( $downloads_data->get_error_message() ) . '</pre>' );
288
+					}
289
+					?>
290 290
                 </div>
291 291
             </div>
292 292
 			<?php
@@ -362,9 +362,9 @@  discard block
 block discarded – undo
362 362
 	 */
363 363
 	protected function render_download( $download, $wp_plugins ) {
364 364
 
365
-        $details = $this->get_download_display_details( $download, $wp_plugins );
365
+		$details = $this->get_download_display_details( $download, $wp_plugins );
366 366
 
367
-        $download_info = $details['download_info'];
367
+		$download_info = $details['download_info'];
368 368
 
369 369
 		?>
370 370
         <div class="item <?php echo esc_attr( $details['item_class'] ); ?>">
@@ -386,43 +386,43 @@  discard block
 block discarded – undo
386 386
 
387 387
                 <div class="addon-excerpt"><?php
388 388
 
389
-                    $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] );
389
+					$excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] );
390 390
 
391
-                    // Allow some pure HTML tags, but remove everything else from the excerpt.
392
-                    $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' );
393
-                    $replacements = array( '[b]', '[/b]', '[i]', '[/i]', '[code]', '[/code]' );
391
+					// Allow some pure HTML tags, but remove everything else from the excerpt.
392
+					$tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' );
393
+					$replacements = array( '[b]', '[/b]', '[i]', '[/i]', '[code]', '[/code]' );
394 394
 
395
-                    $excerpt = str_replace( $tags, $replacements, $excerpt );
396
-                    $excerpt = esc_html( strip_tags( $excerpt ) );
395
+					$excerpt = str_replace( $tags, $replacements, $excerpt );
396
+					$excerpt = esc_html( strip_tags( $excerpt ) );
397 397
 					$excerpt = str_replace( $replacements, $tags, $excerpt );
398 398
 
399 399
 					echo wpautop( $excerpt );
400
-                ?></div>
400
+				?></div>
401 401
             </div>
402 402
         </div>
403 403
 		<?php
404 404
 	}
405 405
 
406 406
 	/**
407
-     * Generates details array for the download to keep the render_download() method a bit tidier
408
-     *
407
+	 * Generates details array for the download to keep the render_download() method a bit tidier
408
+	 *
409 409
 	 * @param array $download Single download, as returned by {@see get_downloads_data}
410 410
 	 * @param array $wp_plugins All active plugins, as returned by {@see get_plugins()}
411 411
 	 *
412 412
 	 * @return array {
413
-     *   @type array $download_info
414
-     *   @type string $plugin_path
415
-     *   @type string $status License status returned by Easy Digital Downloads ("active", "inactive", "expired", "revoked", etc)
416
-     *   @type string $status_label
417
-     *   @type string $button_title Title attribute to show when hovering over the download's button
418
-     *   @type string $button_class CSS class to use for the button
419
-     *   @type string $button_label Text to use for the download's anchor link
420
-     *   @type string $href URL for the download's button
421
-     *   @type bool   $spinner Whether to show the spinner icon
422
-     *   @type string $item_class CSS class for the download container
423
-     *   @type string $required_license The name of the required license for the download ("All Access" or "Core + Extensions")
424
-     *   @type bool   $is_active Is the current GravityView license (as entered in Settings) active?
425
-     * }
413
+	 *   @type array $download_info
414
+	 *   @type string $plugin_path
415
+	 *   @type string $status License status returned by Easy Digital Downloads ("active", "inactive", "expired", "revoked", etc)
416
+	 *   @type string $status_label
417
+	 *   @type string $button_title Title attribute to show when hovering over the download's button
418
+	 *   @type string $button_class CSS class to use for the button
419
+	 *   @type string $button_label Text to use for the download's anchor link
420
+	 *   @type string $href URL for the download's button
421
+	 *   @type bool   $spinner Whether to show the spinner icon
422
+	 *   @type string $item_class CSS class for the download container
423
+	 *   @type string $required_license The name of the required license for the download ("All Access" or "Core + Extensions")
424
+	 *   @type bool   $is_active Is the current GravityView license (as entered in Settings) active?
425
+	 * }
426 426
 	 */
427 427
 	private function get_download_display_details( $download, $wp_plugins ) {
428 428
 
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 			'slug' => '',
434 434
 			'excerpt' => '',
435 435
 			'link' => '',
436
-            'coming_soon' => false,
436
+			'coming_soon' => false,
437 437
 			'installer_title' => null, // May not be defined
438 438
 			'installer_excerpt' => null, // May not be defined
439 439
 		) );
@@ -476,14 +476,14 @@  discard block
 block discarded – undo
476 476
 			$href         = 'https://gravityview.co/pricing/?utm_source=admin-installer&utm_medium=admin&utm_campaign=Admin%20Notice&utm_content=' . $required_license;
477 477
 		}
478 478
 
479
-        elseif ( ! empty( $download_info['coming_soon'] ) ) {
480
-	        $spinner      = false;
481
-	        $status       = 'notinstalled';
482
-	        $status_label = __( 'Coming Soon', 'gravityview' );
483
-	        $button_label = __( 'Learn More', 'gravityview' );
484
-	        $button_class = 'button-primary button-large';
485
-	        $href         = \GV\Utils::get( $download_info, 'link', 'https://gravityview.co/extensions/' );
486
-        }
479
+		elseif ( ! empty( $download_info['coming_soon'] ) ) {
480
+			$spinner      = false;
481
+			$status       = 'notinstalled';
482
+			$status_label = __( 'Coming Soon', 'gravityview' );
483
+			$button_label = __( 'Learn More', 'gravityview' );
484
+			$button_class = 'button-primary button-large';
485
+			$href         = \GV\Utils::get( $download_info, 'link', 'https://gravityview.co/extensions/' );
486
+		}
487 487
 
488 488
 		// Access but the plugin is not installed
489 489
 		elseif ( ! $wp_plugin ) {
@@ -523,18 +523,18 @@  discard block
 block discarded – undo
523 523
 		}
524 524
 
525 525
 		return compact( 'download_info','plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' );
526
-    }
526
+	}
527 527
 
528 528
 	/**
529
-     * Returns the base price for an extension
530
-     *
529
+	 * Returns the base price for an extension
530
+	 *
531 531
 	 * @param array $download
532 532
 	 *
533 533
 	 * @return float Base price for an extension. If not for sale separately, returns 0
534 534
 	 */
535 535
 	private function get_download_base_price( $download ) {
536 536
 
537
-	    $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 );
537
+		$base_price = \GV\Utils::get( $download, 'pricing/amount', 0 );
538 538
 		$base_price = \GFCommon::to_number( $base_price );
539 539
 
540 540
 		unset( $download['pricing']['amount'] );
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 		}
546 546
 
547 547
 		return floatval( $base_price );
548
-    }
548
+	}
549 549
 
550 550
 	/**
551 551
 	 * Handle AJAX request to activate extension
@@ -563,8 +563,8 @@  discard block
 block discarded – undo
563 563
 
564 564
 		if ( is_wp_error( $result ) || ! is_plugin_active( $data['path'] ) ) {
565 565
 			wp_send_json_error( array(
566
-                'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() )
567
-            ) );
566
+				'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() )
567
+			) );
568 568
 		}
569 569
 
570 570
 		wp_send_json_success();
@@ -585,10 +585,10 @@  discard block
 block discarded – undo
585 585
 		deactivate_plugins( $data['path'] );
586 586
 
587 587
 		if( is_plugin_active( $data['path'] ) ) {
588
-            wp_send_json_error( array(
589
-                'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) )
590
-            ) );
591
-        }
588
+			wp_send_json_error( array(
589
+				'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) )
590
+			) );
591
+		}
592 592
 
593 593
 		wp_send_json_success();
594 594
 	}
Please login to merge, or discard this patch.