Completed
Push — develop ( dae086...f9d8a0 )
by Zack
18:24
created
includes/class-admin-installer.php 1 patch
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 */
96 96
 	public function add_admin_menu() {
97 97
 
98
-	    $menu_text = _x( 'Extensions', 'Extensions are WordPress plugins that add functionality to GravityView and Gravity Forms', 'gravityview' );
98
+		$menu_text = _x( 'Extensions', 'Extensions are WordPress plugins that add functionality to GravityView and Gravity Forms', 'gravityview' );
99 99
 
100 100
 		$menu_text = sprintf( '<span title="%s">%s</span>', esc_attr__( 'Plugins that extend GravityView and Gravity Forms functionality.', 'gravityview' ), $menu_text );
101 101
 
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
 	}
111 111
 
112 112
 	/**
113
-     * When on the Installer page, show a different notice than on the Settings page
114
-     *
113
+	 * When on the Installer page, show a different notice than on the Settings page
114
+	 *
115 115
 	 * @param array $notice
116 116
 	 *
117 117
 	 * @return string License notice
@@ -119,10 +119,10 @@  discard block
 block discarded – undo
119 119
 	public function maybe_modify_license_notice( $notice = '' ) {
120 120
 
121 121
 		if ( ! gravityview()->request->is_admin( '', 'downloads' ) ) {
122
-            return $notice;
123
-        }
122
+			return $notice;
123
+		}
124 124
 
125
-        return esc_html__( 'Your license %s. Do you want access to these plugins? %sActivate your license%s or %sget a license here%s.', 'gravityview' );
125
+		return esc_html__( 'Your license %s. Do you want access to these plugins? %sActivate your license%s or %sget a license here%s.', 'gravityview' );
126 126
 	}
127 127
 
128 128
 	/**
@@ -160,43 +160,43 @@  discard block
 block discarded – undo
160 160
 	 * Get downloads data from transient or from API; save transient after getting data from API
161 161
 	 *
162 162
 	 * @return WP_Error|array If error, returns WP_Error. If not valid JSON, empty array. Otherwise, this structure: {
163
-     *   @type array  $info {
164
-     *       @type string $id int 17
165
-     *       @type string $slug Extension slug
166
-     *       @type string $title Extension title
167
-     *       @type string $create_date in '2018-07-19 20:03:10' format
168
-     *       @type string $modified_date
169
-     *       @type string $status
170
-     *       @type string $link URL to public plugin page
171
-     *       @type string $content
172
-     *       @type string $excerpt
173
-     *       @type string $thumbnail URL to thumbnail
174
-     *       @type array  $category Taxonomy details for the plugin's category {
175
-     *         @type int $term_id => int 30
176
-     *         @type string $name => string 'Plugins' (length=7)
177
-     *         @type string $slug => string 'plugins' (length=7)
178
-     *         @type int $term_group => int 0
179
-     *         @type int $term_taxonomy_id => int 30
180
-     *         @type string $taxonomy => string 'download_category' (length=17)
181
-     *         @type string $description => string '' (length=0)
182
-     *         @type int $parent => int 0
183
-     *         @type int $count => int 4
184
-     *         @type string $filter => string 'raw' (length=3)
185
-     *       }
186
-     *       @type array $tags {see $category above}
187
-     *       @type string $textdomain string 'gravityview' (length=11)
188
-     *   }
189
-     *   @type array $pricing array of `price_name_slugs` => '00.00' values, if price options exist
190
-     *   @type array $licensing {
191
-     *       @type bool   $enabled Is licensing enabled for the extension
192
-     *       @type string $version Version number
193
-     *       @type string $exp_unit Expiration unit ('years')
194
-     *       @type string $exp_length Expiration length ('1')
195
-     *   }
196
-     *   @type array $files Array of files. Empty if user has no access to the file. {
197
-     *       @type string $file string URL of the file download
198
-     *   }
199
-     * }
163
+	 *   @type array  $info {
164
+	 *       @type string $id int 17
165
+	 *       @type string $slug Extension slug
166
+	 *       @type string $title Extension title
167
+	 *       @type string $create_date in '2018-07-19 20:03:10' format
168
+	 *       @type string $modified_date
169
+	 *       @type string $status
170
+	 *       @type string $link URL to public plugin page
171
+	 *       @type string $content
172
+	 *       @type string $excerpt
173
+	 *       @type string $thumbnail URL to thumbnail
174
+	 *       @type array  $category Taxonomy details for the plugin's category {
175
+	 *         @type int $term_id => int 30
176
+	 *         @type string $name => string 'Plugins' (length=7)
177
+	 *         @type string $slug => string 'plugins' (length=7)
178
+	 *         @type int $term_group => int 0
179
+	 *         @type int $term_taxonomy_id => int 30
180
+	 *         @type string $taxonomy => string 'download_category' (length=17)
181
+	 *         @type string $description => string '' (length=0)
182
+	 *         @type int $parent => int 0
183
+	 *         @type int $count => int 4
184
+	 *         @type string $filter => string 'raw' (length=3)
185
+	 *       }
186
+	 *       @type array $tags {see $category above}
187
+	 *       @type string $textdomain string 'gravityview' (length=11)
188
+	 *   }
189
+	 *   @type array $pricing array of `price_name_slugs` => '00.00' values, if price options exist
190
+	 *   @type array $licensing {
191
+	 *       @type bool   $enabled Is licensing enabled for the extension
192
+	 *       @type string $version Version number
193
+	 *       @type string $exp_unit Expiration unit ('years')
194
+	 *       @type string $exp_length Expiration length ('1')
195
+	 *   }
196
+	 *   @type array $files Array of files. Empty if user has no access to the file. {
197
+	 *       @type string $file string URL of the file download
198
+	 *   }
199
+	 * }
200 200
 	 */
201 201
 	public function get_downloads_data() {
202 202
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		) );
225 225
 
226 226
 		if ( is_wp_error( $response ) ) {
227
-		    gravityview()->log->error( "Extension data response is an error", array( 'data' => $response ) );
227
+			gravityview()->log->error( "Extension data response is an error", array( 'data' => $response ) );
228 228
 			return $response;
229 229
 		}
230 230
 
@@ -277,10 +277,10 @@  discard block
 block discarded – undo
277 277
                 <div class="gv-admin-installer-notice notice inline error">
278 278
                     <h3><?php esc_html_e( 'Extensions and plugins data cannot be loaded at the moment. Please try again later.', 'gravityview' ); ?></h3>
279 279
                     <?php
280
-                    if ( is_wp_error( $downloads_data ) ) {
281
-	                    echo wpautop( '<pre>' . esc_html( $downloads_data->get_error_message() ) . '</pre>' );
282
-                    }
283
-                    ?>
280
+					if ( is_wp_error( $downloads_data ) ) {
281
+						echo wpautop( '<pre>' . esc_html( $downloads_data->get_error_message() ) . '</pre>' );
282
+					}
283
+					?>
284 284
                 </div>
285 285
             </div>
286 286
 			<?php
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
 	protected function render_download( $download, $wp_plugins ) {
337 337
 
338 338
 
339
-        $details = $this->get_download_display_details( $download, $wp_plugins );
339
+		$details = $this->get_download_display_details( $download, $wp_plugins );
340 340
 
341
-        $download_info = $details['download_info'];
341
+		$download_info = $details['download_info'];
342 342
 
343 343
 		?>
344 344
         <div class="item <?php echo esc_attr( $details['item_class'] ); ?>">
@@ -360,43 +360,43 @@  discard block
 block discarded – undo
360 360
 
361 361
                 <div class="addon-excerpt"><?php
362 362
 
363
-                    $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] );
363
+					$excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] );
364 364
 
365
-                    // Allow some pure HTML tags, but remove everything else from the excerpt.
366
-                    $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' );
367
-                    $replacements = array( '[b]', '[/b]', '[i]', '[/i]', '[code]', '[/code]' );
365
+					// Allow some pure HTML tags, but remove everything else from the excerpt.
366
+					$tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' );
367
+					$replacements = array( '[b]', '[/b]', '[i]', '[/i]', '[code]', '[/code]' );
368 368
 
369
-                    $excerpt = str_replace( $tags, $replacements, $excerpt );
370
-                    $excerpt = esc_html( strip_tags( $excerpt ) );
369
+					$excerpt = str_replace( $tags, $replacements, $excerpt );
370
+					$excerpt = esc_html( strip_tags( $excerpt ) );
371 371
 					$excerpt = str_replace( $replacements, $tags, $excerpt );
372 372
 
373 373
 					echo wpautop( $excerpt );
374
-                ?></div>
374
+				?></div>
375 375
             </div>
376 376
         </div>
377 377
 		<?php
378 378
 	}
379 379
 
380 380
 	/**
381
-     * Generates details array for the download to keep the render_download() method a bit tidier
382
-     *
381
+	 * Generates details array for the download to keep the render_download() method a bit tidier
382
+	 *
383 383
 	 * @param array $download Single download, as returned by {@see get_downloads_data}
384 384
 	 * @param array $wp_plugins All active plugins, as returned by {@see get_plugins()}
385 385
 	 *
386 386
 	 * @return array {
387
-     *   @type array $download_info
388
-     *   @type string $plugin_path
389
-     *   @type string $status License status returned by Easy Digital Downloads ("active", "inactive", "expired", "revoked", etc)
390
-     *   @type string $status_label
391
-     *   @type string $button_title Title attribute to show when hovering over the download's button
392
-     *   @type string $button_class CSS class to use for the button
393
-     *   @type string $button_label Text to use for the download's anchor link
394
-     *   @type string $href URL for the download's button
395
-     *   @type bool   $spinner Whether to show the spinner icon
396
-     *   @type string $item_class CSS class for the download container
397
-     *   @type string $required_license The name of the required license for the download ("Galactic" or "Interstellar")
398
-     *   @type bool   $is_active Is the current GravityView license (as entered in Settings) active?
399
-     * }
387
+	 *   @type array $download_info
388
+	 *   @type string $plugin_path
389
+	 *   @type string $status License status returned by Easy Digital Downloads ("active", "inactive", "expired", "revoked", etc)
390
+	 *   @type string $status_label
391
+	 *   @type string $button_title Title attribute to show when hovering over the download's button
392
+	 *   @type string $button_class CSS class to use for the button
393
+	 *   @type string $button_label Text to use for the download's anchor link
394
+	 *   @type string $href URL for the download's button
395
+	 *   @type bool   $spinner Whether to show the spinner icon
396
+	 *   @type string $item_class CSS class for the download container
397
+	 *   @type string $required_license The name of the required license for the download ("Galactic" or "Interstellar")
398
+	 *   @type bool   $is_active Is the current GravityView license (as entered in Settings) active?
399
+	 * }
400 400
 	 */
401 401
 	private function get_download_display_details( $download, $wp_plugins ) {
402 402
 
@@ -487,18 +487,18 @@  discard block
 block discarded – undo
487 487
 		}
488 488
 
489 489
 		return compact( 'download_info','plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' );
490
-    }
490
+	}
491 491
 
492 492
 	/**
493
-     * Returns the base price for an extension
494
-     *
493
+	 * Returns the base price for an extension
494
+	 *
495 495
 	 * @param array $download
496 496
 	 *
497 497
 	 * @return float Base price for an extension. If not for sale separately, returns 0
498 498
 	 */
499 499
 	private function get_download_base_price( $download ) {
500 500
 
501
-	    $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 );
501
+		$base_price = \GV\Utils::get( $download, 'pricing/amount', 0 );
502 502
 		$base_price = \GFCommon::to_number( $base_price );
503 503
 
504 504
 		unset( $download['pricing']['amount'] );
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 		}
510 510
 
511 511
 		return floatval( $base_price );
512
-    }
512
+	}
513 513
 
514 514
 	/**
515 515
 	 * Handle AJAX request to activate extension
@@ -527,8 +527,8 @@  discard block
 block discarded – undo
527 527
 
528 528
 		if ( is_wp_error( $result ) || ! is_plugin_active( $data['path'] ) ) {
529 529
 			wp_send_json_error( array(
530
-                'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() )
531
-            ) );
530
+				'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() )
531
+			) );
532 532
 		}
533 533
 
534 534
 		wp_send_json_success();
@@ -549,10 +549,10 @@  discard block
 block discarded – undo
549 549
 		deactivate_plugins( $data['path'] );
550 550
 
551 551
 		if( is_plugin_active( $data['path'] ) ) {
552
-            wp_send_json_error( array(
553
-                'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) )
554
-            ) );
555
-        }
552
+			wp_send_json_error( array(
553
+				'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) )
554
+			) );
555
+		}
556 556
 
557 557
 		wp_send_json_success();
558 558
 	}
Please login to merge, or discard this patch.