@@ -53,7 +53,7 @@ discard block |
||
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 | } |
@@ -68,21 +68,21 @@ discard block |
||
68 | 68 | |
69 | 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 | |
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 | |
@@ -149,13 +149,13 @@ discard block |
||
149 | 149 | |
150 | 150 | foreach ( $all_plugins as $path => $plugin ) { |
151 | 151 | |
152 | - if ( empty( $plugin['TextDomain'] ) ) { |
|
152 | + if ( empty( $plugin[ 'TextDomain' ] ) ) { |
|
153 | 153 | continue; |
154 | 154 | } |
155 | 155 | |
156 | - $wp_plugins[ $plugin['TextDomain'] ] = array( |
|
156 | + $wp_plugins[ $plugin[ 'TextDomain' ] ] = array( |
|
157 | 157 | 'path' => $path, |
158 | - 'version' => $plugin['Version'], |
|
158 | + 'version' => $plugin[ 'Version' ], |
|
159 | 159 | 'activated' => is_plugin_active( $path ) |
160 | 160 | ); |
161 | 161 | } |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | |
210 | 210 | $downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT ); |
211 | 211 | |
212 | - if ( $downloads_data && ! isset( $_GET['cache'] ) ) { |
|
212 | + if ( $downloads_data && ! isset( $_GET[ 'cache' ] ) ) { |
|
213 | 213 | return $downloads_data; |
214 | 214 | } |
215 | 215 | |
216 | - if( \GV\Plugin::is_network_activated() ) { |
|
216 | + if ( \GV\Plugin::is_network_activated() ) { |
|
217 | 217 | $home_url = network_home_url(); |
218 | 218 | } else { |
219 | 219 | $home_url = home_url(); |
@@ -241,13 +241,13 @@ discard block |
||
241 | 241 | |
242 | 242 | $downloads_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
243 | 243 | |
244 | - if ( empty( $downloads_data['products'] ) ) { |
|
244 | + if ( empty( $downloads_data[ 'products' ] ) ) { |
|
245 | 245 | return array(); |
246 | 246 | } |
247 | 247 | |
248 | - $this->set_downloads_data( $downloads_data['products'] ); |
|
248 | + $this->set_downloads_data( $downloads_data[ 'products' ] ); |
|
249 | 249 | |
250 | - return $downloads_data['products']; |
|
250 | + return $downloads_data[ 'products' ]; |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | |
308 | 308 | <h2><?php esc_html_e( 'The following plugins extend GravityView and Gravity Forms functionality:', 'gravityview' ); ?></h2> |
309 | 309 | |
310 | - <a class="button button-secondary gv-admin-installer-refresh-link" href="<?php echo add_query_arg(array( 'cache' => 1 ) ); ?>"><i class="dashicons dashicons-update" style="margin-top: .2em"></i> <?php esc_html_e( 'Refresh', 'gravityview' ); ?></a> |
|
310 | + <a class="button button-secondary gv-admin-installer-refresh-link" href="<?php echo add_query_arg( array( 'cache' => 1 ) ); ?>"><i class="dashicons dashicons-update" style="margin-top: .2em"></i> <?php esc_html_e( 'Refresh', 'gravityview' ); ?></a> |
|
311 | 311 | |
312 | 312 | <hr class="wp-header-end" /> |
313 | 313 | |
@@ -324,9 +324,9 @@ discard block |
||
324 | 324 | |
325 | 325 | $this->render_section( 'extensions', esc_html__( 'GravityView Extensions', 'gravityview' ), $downloads_data, $wp_plugins ); |
326 | 326 | |
327 | - $this->render_section( 'plugins', esc_html__( 'Gravity Forms Add-Ons', 'gravityview' ), $downloads_data, $wp_plugins ); |
|
327 | + $this->render_section( 'plugins', esc_html__( 'Gravity Forms Add-Ons', 'gravityview' ), $downloads_data, $wp_plugins ); |
|
328 | 328 | |
329 | - $this->render_section( 'friends', esc_html__( 'Friends of GravityView', 'gravityview' ), $downloads_data, $wp_plugins ); |
|
329 | + $this->render_section( 'friends', esc_html__( 'Friends of GravityView', 'gravityview' ), $downloads_data, $wp_plugins ); |
|
330 | 330 | ?> |
331 | 331 | </div> |
332 | 332 | </div> |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | continue; |
354 | 354 | } |
355 | 355 | |
356 | - if ( empty( $download['info'] ) ) { |
|
356 | + if ( empty( $download[ 'info' ] ) ) { |
|
357 | 357 | continue; |
358 | 358 | } |
359 | 359 | |
@@ -381,31 +381,31 @@ discard block |
||
381 | 381 | |
382 | 382 | $details = $this->get_download_display_details( $download, $wp_plugins ); |
383 | 383 | |
384 | - $download_info = $details['download_info']; |
|
384 | + $download_info = $details[ 'download_info' ]; |
|
385 | 385 | |
386 | 386 | ?> |
387 | - <div class="item <?php echo esc_attr( $details['item_class'] ); ?>"> |
|
387 | + <div class="item <?php echo esc_attr( $details[ 'item_class' ] ); ?>"> |
|
388 | 388 | <div class="addon-inner"> |
389 | - <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> |
|
390 | - <h3><?php echo esc_html( \GV\Utils::get( $download_info, 'installer_title', $download_info['title'] ) ); ?></h3> |
|
389 | + <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> |
|
390 | + <h3><?php echo esc_html( \GV\Utils::get( $download_info, 'installer_title', $download_info[ 'title' ] ) ); ?></h3> |
|
391 | 391 | <div> |
392 | - <?php if( ! empty( $details['status_label'] ) ) { ?> |
|
393 | - <div class="status <?php echo esc_attr( $details['status'] ); ?>" title="<?php printf( esc_attr__( 'Plugin status: %s', 'gravityview' ), esc_html( $details['status_label'] ) ); ?>"> |
|
394 | - <span class="dashicons dashicons-admin-plugins"></span> <span class="status-label"><?php echo esc_html( $details['status_label'] ); ?></span> |
|
392 | + <?php if ( ! empty( $details[ 'status_label' ] ) ) { ?> |
|
393 | + <div class="status <?php echo esc_attr( $details[ 'status' ] ); ?>" title="<?php printf( esc_attr__( 'Plugin status: %s', 'gravityview' ), esc_html( $details[ 'status_label' ] ) ); ?>"> |
|
394 | + <span class="dashicons dashicons-admin-plugins"></span> <span class="status-label"><?php echo esc_html( $details[ 'status_label' ] ); ?></span> |
|
395 | 395 | </div> |
396 | 396 | <?php } ?> |
397 | 397 | |
398 | - <?php if ( 'gravityview' !== $download_info['slug'] ) { ?> |
|
399 | - <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'] ); ?>"> |
|
400 | - <span class="title"><?php echo esc_html( $details['button_label'] ); ?></span> |
|
401 | - <?php if( $details['spinner'] ) { ?><span class="spinner"></span><?php } ?> |
|
398 | + <?php if ( 'gravityview' !== $download_info[ 'slug' ] ) { ?> |
|
399 | + <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' ] ); ?>"> |
|
400 | + <span class="title"><?php echo esc_html( $details[ 'button_label' ] ); ?></span> |
|
401 | + <?php if ( $details[ 'spinner' ] ) { ?><span class="spinner"></span><?php } ?> |
|
402 | 402 | </a> |
403 | 403 | <?php } ?> |
404 | 404 | </div> |
405 | 405 | |
406 | 406 | <div class="addon-excerpt"><?php |
407 | 407 | |
408 | - $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] ); |
|
408 | + $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info[ 'excerpt' ] ); |
|
409 | 409 | |
410 | 410 | // Allow some pure HTML tags, but remove everything else from the excerpt. |
411 | 411 | $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' ); |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | */ |
448 | 448 | private function get_download_display_details( $download, $wp_plugins ) { |
449 | 449 | |
450 | - $download_info = wp_parse_args( (array) $download['info'], array( |
|
450 | + $download_info = wp_parse_args( (array)$download[ 'info' ], array( |
|
451 | 451 | 'thumbnail' => '', |
452 | 452 | 'title' => '', |
453 | 453 | 'textdomain' => '', |
@@ -459,9 +459,9 @@ discard block |
||
459 | 459 | 'installer_excerpt' => null, // May not be defined |
460 | 460 | ) ); |
461 | 461 | |
462 | - $wp_plugin = \GV\Utils::get( $wp_plugins, $download_info['textdomain'], false ); |
|
462 | + $wp_plugin = \GV\Utils::get( $wp_plugins, $download_info[ 'textdomain' ], false ); |
|
463 | 463 | |
464 | - $has_access = ! empty( $download['files'] ); |
|
464 | + $has_access = ! empty( $download[ 'files' ] ); |
|
465 | 465 | $spinner = true; |
466 | 466 | $href = $plugin_path = '#'; |
467 | 467 | $status = $item_class = $button_title = $button_class = ''; |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | $required_license = $galactic_only ? __( 'All Access', 'gravityview' ) : __( 'Core + Extensions', 'gravityview' ); |
472 | 472 | |
473 | 473 | // The license is not active - no matter what level, this should not work |
474 | - if( ! $is_active && empty( $base_price ) ) { |
|
474 | + if ( ! $is_active && empty( $base_price ) ) { |
|
475 | 475 | $spinner = false; |
476 | 476 | $status_label = ''; |
477 | 477 | $button_label = sprintf( __( 'Active %s License is Required.', 'gravityview' ), $required_license ); |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | $status_label = ''; |
484 | 484 | $button_label = sprintf( __( 'Purchase Now for %s', 'gravityview' ), '$' . $base_price ); |
485 | 485 | $button_class = 'button-primary button-large'; |
486 | - $href = $download_info['link']; |
|
486 | + $href = $download_info[ 'link' ]; |
|
487 | 487 | $item_class = 'featured'; |
488 | 488 | } |
489 | 489 | |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | $href = 'https://gravityview.co/pricing/?utm_source=admin-installer&utm_medium=admin&utm_campaign=Admin%20Notice&utm_content=' . $required_license; |
497 | 497 | } |
498 | 498 | |
499 | - elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
499 | + elseif ( ! empty( $download_info[ 'coming_soon' ] ) ) { |
|
500 | 500 | $spinner = false; |
501 | 501 | $status = 'notinstalled'; |
502 | 502 | $status_label = __( 'Coming Soon', 'gravityview' ); |
@@ -511,8 +511,8 @@ discard block |
||
511 | 511 | $href = add_query_arg( |
512 | 512 | array( |
513 | 513 | 'action' => 'install-plugin', |
514 | - 'plugin' => $download_info['slug'], |
|
515 | - '_wpnonce' => wp_create_nonce( 'install-plugin_' . $download_info['slug'] ), |
|
514 | + 'plugin' => $download_info[ 'slug' ], |
|
515 | + '_wpnonce' => wp_create_nonce( 'install-plugin_' . $download_info[ 'slug' ] ), |
|
516 | 516 | ), |
517 | 517 | self_admin_url( 'update.php' ) |
518 | 518 | ); |
@@ -528,17 +528,17 @@ discard block |
||
528 | 528 | $status = 'inactive'; |
529 | 529 | $status_label = __( 'Inactive', 'gravityview' ); |
530 | 530 | $button_label = __( 'Activate', 'gravityview' ); |
531 | - $plugin_path = $wp_plugin['path']; |
|
531 | + $plugin_path = $wp_plugin[ 'path' ]; |
|
532 | 532 | } |
533 | 533 | // The plugin is installed and active |
534 | - elseif ( ! empty( $wp_plugin['path'] ) ) { |
|
535 | - $plugin_path = $wp_plugin['path']; |
|
534 | + elseif ( ! empty( $wp_plugin[ 'path' ] ) ) { |
|
535 | + $plugin_path = $wp_plugin[ 'path' ]; |
|
536 | 536 | $status = 'active'; |
537 | 537 | $status_label = __( 'Active', 'gravityview' ); |
538 | 538 | $button_label = __( 'Deactivate', 'gravityview' ); |
539 | 539 | } |
540 | 540 | |
541 | - return compact( 'download_info','plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
|
541 | + return compact( 'download_info', 'plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | /** |
@@ -553,11 +553,11 @@ discard block |
||
553 | 553 | $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
554 | 554 | $base_price = \GFCommon::to_number( $base_price ); |
555 | 555 | |
556 | - unset( $download['pricing']['amount'] ); |
|
556 | + unset( $download[ 'pricing' ][ 'amount' ] ); |
|
557 | 557 | |
558 | 558 | // Price options array, not single price |
559 | - if ( ! $base_price && ! empty( $download['pricing'] ) ) { |
|
560 | - $base_price = array_shift( $download['pricing'] ); |
|
559 | + if ( ! $base_price && ! empty( $download[ 'pricing' ] ) ) { |
|
560 | + $base_price = array_shift( $download[ 'pricing' ] ); |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | return floatval( $base_price ); |
@@ -571,13 +571,13 @@ discard block |
||
571 | 571 | public function activate_download() { |
572 | 572 | $data = \GV\Utils::_POST( 'data', array() ); |
573 | 573 | |
574 | - if ( empty( $data['path'] ) ) { |
|
574 | + if ( empty( $data[ 'path' ] ) ) { |
|
575 | 575 | return; |
576 | 576 | } |
577 | 577 | |
578 | - $result = activate_plugin( $data['path'] ); |
|
578 | + $result = activate_plugin( $data[ 'path' ] ); |
|
579 | 579 | |
580 | - if ( is_wp_error( $result ) || ! is_plugin_active( $data['path'] ) ) { |
|
580 | + if ( is_wp_error( $result ) || ! is_plugin_active( $data[ 'path' ] ) ) { |
|
581 | 581 | wp_send_json_error( array( |
582 | 582 | 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
583 | 583 | ) ); |
@@ -594,13 +594,13 @@ discard block |
||
594 | 594 | public function deactivate_download() { |
595 | 595 | $data = \GV\Utils::_POST( 'data', array() ); |
596 | 596 | |
597 | - if ( empty( $data['path'] ) ) { |
|
597 | + if ( empty( $data[ 'path' ] ) ) { |
|
598 | 598 | return; |
599 | 599 | } |
600 | 600 | |
601 | - deactivate_plugins( $data['path'] ); |
|
601 | + deactivate_plugins( $data[ 'path' ] ); |
|
602 | 602 | |
603 | - if( is_plugin_active( $data['path'] ) ) { |
|
603 | + if ( is_plugin_active( $data[ 'path' ] ) ) { |
|
604 | 604 | wp_send_json_error( array( |
605 | 605 | 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
606 | 606 | ) ); |