|
@@ -53,7 +53,7 @@ discard block |
|
|
block discarded – undo |
|
53
|
53
|
*/ |
|
54
|
54
|
public function register_noconflict( $items ) { |
|
55
|
55
|
|
|
56
|
|
- $items[] = 'gravityview-admin-installer'; |
|
|
56
|
+ $items[ ] = 'gravityview-admin-installer'; |
|
57
|
57
|
|
|
58
|
58
|
return $items; |
|
59
|
59
|
} |
|
@@ -72,17 +72,17 @@ discard block |
|
|
block discarded – undo |
|
72
|
72
|
return; |
|
73
|
73
|
} |
|
74
|
74
|
|
|
75
|
|
- add_filter( 'plugins_api', function ( $data, $action, $args ) use ( $downloads_data ) { |
|
|
75
|
+ add_filter( 'plugins_api', function( $data, $action, $args ) use ( $downloads_data ) { |
|
76
|
76
|
foreach ( $downloads_data as $extension ) { |
|
77
|
|
- if ( empty( $extension['info'] ) || empty( $args->slug ) || $args->slug !== $extension['info']['slug'] ) { |
|
|
77
|
+ if ( empty( $extension[ 'info' ] ) || empty( $args->slug ) || $args->slug !== $extension[ 'info' ][ 'slug' ] ) { |
|
78
|
78
|
continue; |
|
79
|
79
|
} |
|
80
|
80
|
|
|
81
|
|
- return (object) array( |
|
82
|
|
- 'slug' => $extension['info']['slug'], |
|
83
|
|
- 'name' => $extension['info']['title'], |
|
84
|
|
- 'version' => $extension['licensing']['version'], |
|
85
|
|
- 'download_link' => $extension['files'][0]['file'], |
|
|
81
|
+ return (object)array( |
|
|
82
|
+ 'slug' => $extension[ 'info' ][ 'slug' ], |
|
|
83
|
+ 'name' => $extension[ 'info' ][ 'title' ], |
|
|
84
|
+ 'version' => $extension[ 'licensing' ][ 'version' ], |
|
|
85
|
+ 'download_link' => $extension[ 'files' ][ 0 ][ 'file' ], |
|
86
|
86
|
); |
|
87
|
87
|
} |
|
88
|
88
|
|
|
@@ -144,13 +144,13 @@ discard block |
|
|
block discarded – undo |
|
144
|
144
|
|
|
145
|
145
|
foreach ( $all_plugins as $path => $plugin ) { |
|
146
|
146
|
|
|
147
|
|
- if ( empty( $plugin['TextDomain'] ) ) { |
|
|
147
|
+ if ( empty( $plugin[ 'TextDomain' ] ) ) { |
|
148
|
148
|
continue; |
|
149
|
149
|
} |
|
150
|
150
|
|
|
151
|
|
- $wp_plugins[ $plugin['TextDomain'] ] = array( |
|
|
151
|
+ $wp_plugins[ $plugin[ 'TextDomain' ] ] = array( |
|
152
|
152
|
'path' => $path, |
|
153
|
|
- 'version' => $plugin['Version'], |
|
|
153
|
+ 'version' => $plugin[ 'Version' ], |
|
154
|
154
|
'activated' => is_plugin_active( $path ) |
|
155
|
155
|
); |
|
156
|
156
|
} |
|
@@ -208,7 +208,7 @@ discard block |
|
|
block discarded – undo |
|
208
|
208
|
return $downloads_data; |
|
209
|
209
|
} |
|
210
|
210
|
|
|
211
|
|
- if( \GV\Plugin::is_network_activated() ) { |
|
|
211
|
+ if ( \GV\Plugin::is_network_activated() ) { |
|
212
|
212
|
$home_url = network_home_url(); |
|
213
|
213
|
} else { |
|
214
|
214
|
$home_url = home_url(); |
|
@@ -236,13 +236,13 @@ discard block |
|
|
block discarded – undo |
|
236
|
236
|
|
|
237
|
237
|
$downloads_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
238
|
238
|
|
|
239
|
|
- if ( empty( $downloads_data['products'] ) ) { |
|
|
239
|
+ if ( empty( $downloads_data[ 'products' ] ) ) { |
|
240
|
240
|
return array(); |
|
241
|
241
|
} |
|
242
|
242
|
|
|
243
|
|
- $this->set_downloads_data( $downloads_data['products'] ); |
|
|
243
|
+ $this->set_downloads_data( $downloads_data[ 'products' ] ); |
|
244
|
244
|
|
|
245
|
|
- return $downloads_data['products']; |
|
|
245
|
+ return $downloads_data[ 'products' ]; |
|
246
|
246
|
} |
|
247
|
247
|
|
|
248
|
248
|
/** |
|
@@ -315,7 +315,7 @@ discard block |
|
|
block discarded – undo |
|
315
|
315
|
|
|
316
|
316
|
foreach ( $downloads_data as $extension ) { |
|
317
|
317
|
|
|
318
|
|
- if ( empty( $extension['info'] ) ) { |
|
|
318
|
+ if ( empty( $extension[ 'info' ] ) ) { |
|
319
|
319
|
continue; |
|
320
|
320
|
} |
|
321
|
321
|
|
|
@@ -344,29 +344,29 @@ discard block |
|
|
block discarded – undo |
|
344
|
344
|
|
|
345
|
345
|
$details = $this->get_download_display_details( $download, $wp_plugins ); |
|
346
|
346
|
|
|
347
|
|
- $download_info = $details['download_info']; |
|
|
347
|
+ $download_info = $details[ 'download_info' ]; |
|
348
|
348
|
|
|
349
|
349
|
?> |
|
350
|
|
- <div class="item <?php echo esc_attr( $details['item_class'] ); ?>"> |
|
|
350
|
+ <div class="item <?php echo esc_attr( $details[ 'item_class' ] ); ?>"> |
|
351
|
351
|
<div class="addon-inner"> |
|
352
|
|
- <a href="<?php echo esc_url( $download_info['link'] ); ?>" rel="external noreferrer noopener" title="<?php esc_html_e( 'Visit the plugin page', 'gravityview' ); ?>"><img class="thumbnail" src="<?php echo esc_attr( $download_info['thumbnail'] ); ?>" alt="" /></a> |
|
353
|
|
- <h3><?php echo esc_html( \GV\Utils::get( $download_info, 'installer_title', $download_info['title'] ) ); ?></h3> |
|
|
352
|
+ <a href="<?php echo esc_url( $download_info[ 'link' ] ); ?>" rel="external noreferrer noopener" title="<?php esc_html_e( 'Visit the plugin page', 'gravityview' ); ?>"><img class="thumbnail" src="<?php echo esc_attr( $download_info[ 'thumbnail' ] ); ?>" alt="" /></a> |
|
|
353
|
+ <h3><?php echo esc_html( \GV\Utils::get( $download_info, 'installer_title', $download_info[ 'title' ] ) ); ?></h3> |
|
354
|
354
|
<div> |
|
355
|
|
- <?php if( ! empty( $details['status_label'] ) ) { ?> |
|
356
|
|
- <div class="status <?php echo esc_attr( $details['status'] ); ?>" title="<?php printf( esc_attr__( 'Plugin status: %s', 'gravityview' ), esc_html( $details['status_label'] ) ); ?>"> |
|
357
|
|
- <span class="dashicons dashicons-admin-plugins"></span> <span class="status-label"><?php echo esc_html( $details['status_label'] ); ?></span> |
|
|
355
|
+ <?php if ( ! empty( $details[ 'status_label' ] ) ) { ?> |
|
|
356
|
+ <div class="status <?php echo esc_attr( $details[ 'status' ] ); ?>" title="<?php printf( esc_attr__( 'Plugin status: %s', 'gravityview' ), esc_html( $details[ 'status_label' ] ) ); ?>"> |
|
|
357
|
+ <span class="dashicons dashicons-admin-plugins"></span> <span class="status-label"><?php echo esc_html( $details[ 'status_label' ] ); ?></span> |
|
358
|
358
|
</div> |
|
359
|
359
|
<?php } ?> |
|
360
|
360
|
|
|
361
|
|
- <a data-status="<?php echo esc_attr( $details['status'] ); ?>" data-plugin-path="<?php echo esc_attr( $details['plugin_path'] ); ?>" href="<?php echo esc_url( $details['href'] ); ?>" class="button <?php echo esc_attr( $details['button_class'] ); ?>" title="<?php echo esc_attr( $details['button_title'] ); ?>"> |
|
362
|
|
- <span class="title"><?php echo esc_html( $details['button_label'] ); ?></span> |
|
363
|
|
- <?php if( $details['spinner'] ) { ?><span class="spinner"></span><?php } ?> |
|
|
361
|
+ <a data-status="<?php echo esc_attr( $details[ 'status' ] ); ?>" data-plugin-path="<?php echo esc_attr( $details[ 'plugin_path' ] ); ?>" href="<?php echo esc_url( $details[ 'href' ] ); ?>" class="button <?php echo esc_attr( $details[ 'button_class' ] ); ?>" title="<?php echo esc_attr( $details[ 'button_title' ] ); ?>"> |
|
|
362
|
+ <span class="title"><?php echo esc_html( $details[ 'button_label' ] ); ?></span> |
|
|
363
|
+ <?php if ( $details[ 'spinner' ] ) { ?><span class="spinner"></span><?php } ?> |
|
364
|
364
|
</a> |
|
365
|
365
|
</div> |
|
366
|
366
|
|
|
367
|
367
|
<div class="addon-excerpt"><?php |
|
368
|
368
|
|
|
369
|
|
- $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] ); |
|
|
369
|
+ $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info[ 'excerpt' ] ); |
|
370
|
370
|
|
|
371
|
371
|
// Allow some pure HTML tags, but remove everything else from the excerpt. |
|
372
|
372
|
$tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' ); |
|
@@ -406,7 +406,7 @@ discard block |
|
|
block discarded – undo |
|
406
|
406
|
*/ |
|
407
|
407
|
private function get_download_display_details( $download, $wp_plugins ) { |
|
408
|
408
|
|
|
409
|
|
- $download_info = wp_parse_args( (array) $download['info'], array( |
|
|
409
|
+ $download_info = wp_parse_args( (array)$download[ 'info' ], array( |
|
410
|
410
|
'thumbnail' => '', |
|
411
|
411
|
'title' => '', |
|
412
|
412
|
'textdomain' => '', |
|
@@ -418,9 +418,9 @@ discard block |
|
|
block discarded – undo |
|
418
|
418
|
'installer_excerpt' => null, // May not be defined |
|
419
|
419
|
) ); |
|
420
|
420
|
|
|
421
|
|
- $wp_plugin = \GV\Utils::get( $wp_plugins, $download_info['textdomain'], false ); |
|
|
421
|
+ $wp_plugin = \GV\Utils::get( $wp_plugins, $download_info[ 'textdomain' ], false ); |
|
422
|
422
|
|
|
423
|
|
- $has_access = ! empty( $download['files'] ); |
|
|
423
|
+ $has_access = ! empty( $download[ 'files' ] ); |
|
424
|
424
|
$spinner = true; |
|
425
|
425
|
$href = $plugin_path = '#'; |
|
426
|
426
|
$status = $item_class = $button_title = $button_class = ''; |
|
@@ -430,7 +430,7 @@ discard block |
|
|
block discarded – undo |
|
430
|
430
|
$required_license = $galactic_only ? __( 'All Access', 'gravityview' ) : __( 'Core + Extensions', 'gravityview' ); |
|
431
|
431
|
|
|
432
|
432
|
// The license is not active - no matter what level, this should not work |
|
433
|
|
- if( ! $is_active && empty( $base_price ) ) { |
|
|
433
|
+ if ( ! $is_active && empty( $base_price ) ) { |
|
434
|
434
|
$spinner = false; |
|
435
|
435
|
$status_label = ''; |
|
436
|
436
|
$button_class = 'disabled disabled-license'; |
|
@@ -443,7 +443,7 @@ discard block |
|
|
block discarded – undo |
|
443
|
443
|
$status_label = ''; |
|
444
|
444
|
$button_label = sprintf( __( 'Purchase Now for %s', 'gravityview' ), '$' . $base_price ); |
|
445
|
445
|
$button_class = 'button-primary button-large'; |
|
446
|
|
- $href = $download_info['link']; |
|
|
446
|
+ $href = $download_info[ 'link' ]; |
|
447
|
447
|
$item_class = 'featured'; |
|
448
|
448
|
} |
|
449
|
449
|
|
|
@@ -456,7 +456,7 @@ discard block |
|
|
block discarded – undo |
|
456
|
456
|
$href = 'https://gravityview.co/pricing/?utm_source=admin-installer&utm_medium=admin&utm_campaign=Admin%20Notice&utm_content=' . $required_license; |
|
457
|
457
|
} |
|
458
|
458
|
|
|
459
|
|
- elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
|
459
|
+ elseif ( ! empty( $download_info[ 'coming_soon' ] ) ) { |
|
460
|
460
|
$spinner = false; |
|
461
|
461
|
$status = 'notinstalled'; |
|
462
|
462
|
$status_label = __( 'Coming Soon', 'gravityview' ); |
|
@@ -471,8 +471,8 @@ discard block |
|
|
block discarded – undo |
|
471
|
471
|
$href = add_query_arg( |
|
472
|
472
|
array( |
|
473
|
473
|
'action' => 'install-plugin', |
|
474
|
|
- 'plugin' => $download_info['slug'], |
|
475
|
|
- '_wpnonce' => wp_create_nonce( 'install-plugin_' . $download_info['slug'] ), |
|
|
474
|
+ 'plugin' => $download_info[ 'slug' ], |
|
|
475
|
+ '_wpnonce' => wp_create_nonce( 'install-plugin_' . $download_info[ 'slug' ] ), |
|
476
|
476
|
), |
|
477
|
477
|
self_admin_url( 'update.php' ) |
|
478
|
478
|
); |
|
@@ -484,25 +484,25 @@ discard block |
|
|
block discarded – undo |
|
484
|
484
|
} |
|
485
|
485
|
|
|
486
|
486
|
// Access and the plugin is installed but not active |
|
487
|
|
- elseif ( false === $wp_plugin['activated'] ) { |
|
|
487
|
+ elseif ( false === $wp_plugin[ 'activated' ] ) { |
|
488
|
488
|
$status = 'inactive'; |
|
489
|
489
|
$status_label = __( 'Inactive', 'gravityview' ); |
|
490
|
490
|
$button_label = __( 'Activate', 'gravityview' ); |
|
491
|
|
- $plugin_path = $wp_plugin['path']; |
|
|
491
|
+ $plugin_path = $wp_plugin[ 'path' ]; |
|
492
|
492
|
|
|
493
|
493
|
} |
|
494
|
494
|
|
|
495
|
495
|
// Access and the plugin is installed and active |
|
496
|
496
|
else { |
|
497
|
497
|
|
|
498
|
|
- $plugin_path = $wp_plugin['path']; |
|
|
498
|
+ $plugin_path = $wp_plugin[ 'path' ]; |
|
499
|
499
|
$status = 'active'; |
|
500
|
500
|
$status_label = __( 'Active', 'gravityview' ); |
|
501
|
501
|
$button_label = __( 'Deactivate', 'gravityview' ); |
|
502
|
502
|
|
|
503
|
503
|
} |
|
504
|
504
|
|
|
505
|
|
- return compact( 'download_info','plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
|
|
505
|
+ return compact( 'download_info', 'plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
|
506
|
506
|
} |
|
507
|
507
|
|
|
508
|
508
|
/** |
|
@@ -517,11 +517,11 @@ discard block |
|
|
block discarded – undo |
|
517
|
517
|
$base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
|
518
|
518
|
$base_price = \GFCommon::to_number( $base_price ); |
|
519
|
519
|
|
|
520
|
|
- unset( $download['pricing']['amount'] ); |
|
|
520
|
+ unset( $download[ 'pricing' ][ 'amount' ] ); |
|
521
|
521
|
|
|
522
|
522
|
// Price options array, not single price |
|
523
|
|
- if ( ! $base_price && ! empty( $download['pricing'] ) ) { |
|
524
|
|
- $base_price = array_shift( $download['pricing'] ); |
|
|
523
|
+ if ( ! $base_price && ! empty( $download[ 'pricing' ] ) ) { |
|
|
524
|
+ $base_price = array_shift( $download[ 'pricing' ] ); |
|
525
|
525
|
} |
|
526
|
526
|
|
|
527
|
527
|
return floatval( $base_price ); |
|
@@ -535,13 +535,13 @@ discard block |
|
|
block discarded – undo |
|
535
|
535
|
public function activate_download() { |
|
536
|
536
|
$data = \GV\Utils::_POST( 'data', array() ); |
|
537
|
537
|
|
|
538
|
|
- if ( empty( $data['path'] ) ) { |
|
|
538
|
+ if ( empty( $data[ 'path' ] ) ) { |
|
539
|
539
|
return; |
|
540
|
540
|
} |
|
541
|
541
|
|
|
542
|
|
- $result = activate_plugin( $data['path'] ); |
|
|
542
|
+ $result = activate_plugin( $data[ 'path' ] ); |
|
543
|
543
|
|
|
544
|
|
- if ( is_wp_error( $result ) || ! is_plugin_active( $data['path'] ) ) { |
|
|
544
|
+ if ( is_wp_error( $result ) || ! is_plugin_active( $data[ 'path' ] ) ) { |
|
545
|
545
|
wp_send_json_error( array( |
|
546
|
546
|
'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
|
547
|
547
|
) ); |
|
@@ -558,13 +558,13 @@ discard block |
|
|
block discarded – undo |
|
558
|
558
|
public function deactivate_download() { |
|
559
|
559
|
$data = \GV\Utils::_POST( 'data', array() ); |
|
560
|
560
|
|
|
561
|
|
- if ( empty( $data['path'] ) ) { |
|
|
561
|
+ if ( empty( $data[ 'path' ] ) ) { |
|
562
|
562
|
return; |
|
563
|
563
|
} |
|
564
|
564
|
|
|
565
|
|
- deactivate_plugins( $data['path'] ); |
|
|
565
|
+ deactivate_plugins( $data[ 'path' ] ); |
|
566
|
566
|
|
|
567
|
|
- if( is_plugin_active( $data['path'] ) ) { |
|
|
567
|
+ if ( is_plugin_active( $data[ 'path' ] ) ) { |
|
568
|
568
|
wp_send_json_error( array( |
|
569
|
569
|
'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
|
570
|
570
|
) ); |