Ticket #43986: 43986.2.diff
File 43986.2.diff, 7.8 KB (added by , 6 years ago) |
---|
-
src/wp-admin/css/list-tables.css
1373 1373 margin-right: 0; 1374 1374 } 1375 1375 1376 .plugin-card.cannot-install { 1377 background-color: #fbeaea; 1378 } 1379 1376 1380 @media screen and ( min-width: 1600px ) { 1377 1381 .plugin-card { 1378 1382 width: 30%; -
src/wp-admin/includes/class-wp-plugin-install-list-table.php
496 496 $author = ' <cite>' . sprintf( __( 'By %s' ), $author ) . '</cite>'; 497 497 } 498 498 499 $wp_version = get_bloginfo( 'version' ); 500 501 $compatible_php = ( ! empty( $plugin['requires_php'] ) && version_compare( substr( phpversion(), 0, strlen( $plugin['requires_php'] ) ), $plugin['requires_php'], '>=' ) ); 502 $tested_wp = ( ! empty( $plugin['tested'] ) && version_compare( substr( $wp_version, 0, strlen( $plugin['tested'] ) ), $plugin['tested'], '<=' ) ); 503 $compatible_wp = ( ! empty( $plugin['requires'] ) && version_compare( substr( $wp_version, 0, strlen( $plugin['requires'] ) ), $plugin['requires'], '>=' ) ); 504 $can_install = $compatible_php && $compatible_wp; 505 499 506 $action_links = array(); 500 507 501 508 if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) { … … 504 511 switch ( $status['status'] ) { 505 512 case 'install': 506 513 if ( $status['url'] ) { 507 $action_links[] = sprintf( 508 '<a class="install-now button" data-slug="%s" href="%s" aria-label="%s" data-name="%s">%s</a>', 509 esc_attr( $plugin['slug'] ), 510 esc_url( $status['url'] ), 511 /* translators: %s: plugin name and version */ 512 esc_attr( sprintf( __( 'Install %s now' ), $name ) ), 513 esc_attr( $name ), 514 __( 'Install Now' ) 515 ); 514 if ( $can_install ) { 515 $action_links[] = sprintf( 516 '<a class="install-now button" data-slug="%s" href="%s" aria-label="%s" data-name="%s">%s</a>', 517 esc_attr( $plugin['slug'] ), 518 esc_url( $status['url'] ), 519 /* translators: %s: plugin name and version */ 520 esc_attr( sprintf( __( 'Install %s now' ), $name ) ), 521 esc_attr( $name ), 522 __( 'Install Now' ) 523 ); 524 } else { 525 $action_links[] = sprintf( 526 '<button type="button" class="button button-disabled" disabled="disabled">%s</button>', 527 _x( 'Cannot Install', 'plugin' ) 528 ); 529 } 516 530 } 517 531 break; 518 532 … … 608 622 $action_links = apply_filters( 'plugin_install_action_links', $action_links, $plugin ); 609 623 610 624 $last_updated_timestamp = strtotime( $plugin['last_updated'] ); 625 626 $classes = array( 627 'plugin-card', 628 'plugin-card-' . sanitize_html_class( $plugin['slug'] ), 629 ); 630 631 if ( ! $can_install ) { 632 $classes[] = 'cannot-install'; 633 } 611 634 ?> 612 <div class=" plugin-card plugin-card-<?php echo sanitize_html_class( $plugin['slug']); ?>">635 <div class="<?php echo implode( ' ', $classes ); ?>"> 613 636 <div class="plugin-card-top"> 614 637 <div class="name column-name"> 615 638 <h3> … … 665 688 </div> 666 689 <div class="column-compatibility"> 667 690 <?php 668 $wp_version = get_bloginfo( 'version' ); 669 670 if ( ! empty( $plugin['tested'] ) && version_compare( substr( $wp_version, 0, strlen( $plugin['tested'] ) ), $plugin['tested'], '>' ) ) { 691 if ( ! $compatible_php ) { 692 echo '<span class="compatibility-incompatible">' . sprintf( 693 /* translators: 1: Upgrading PHP page URL, 2: accessibility text */ 694 __( '<strong>Incompatible</strong> with your version of PHP. <a href="%1$s" aria-label="%2$s">Learn more</a>' ), 695 esc_url( __( 'https://wordpress.org/support/upgrade-php/' ) ), 696 esc_attr__( 'Learn more about upgrading PHP' ) 697 ) . '</span>'; 698 } elseif ( ! $tested_wp ) { 671 699 echo '<span class="compatibility-untested">' . __( 'Untested with your version of WordPress' ) . '</span>'; 672 } elseif ( ! empty( $plugin['requires'] ) && version_compare( substr( $wp_version, 0, strlen( $plugin['requires'] ) ), $plugin['requires'], '<' )) {700 } elseif ( ! $compatible_wp ) { 673 701 echo '<span class="compatibility-incompatible">' . __( '<strong>Incompatible</strong> with your version of WordPress' ) . '</span>'; 674 702 } else { 675 703 echo '<span class="compatibility-compatible">' . __( '<strong>Compatible</strong> with your version of WordPress' ) . '</span>'; -
src/wp-admin/includes/plugin-install.php
753 753 <?php 754 754 $wp_version = get_bloginfo( 'version' ); 755 755 756 if ( ! empty( $api->tested ) && version_compare( substr( $wp_version, 0, strlen( $api->tested ) ), $api->tested, '>' ) ) { 757 echo '<div class="notice notice-warning notice-alt"><p>' . __( '<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.' ) . '</p></div>'; 758 } elseif ( ! empty( $api->requires ) && version_compare( substr( $wp_version, 0, strlen( $api->requires ) ), $api->requires, '<' ) ) { 759 echo '<div class="notice notice-warning notice-alt"><p>' . __( '<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.' ) . '</p></div>'; 756 $compatible_php = ( ! empty( $api->requires_php ) && version_compare( substr( phpversion(), 0, strlen( $api->requires_php ) ), $api->requires_php, '>=' ) ); 757 $tested_wp = ( ! empty( $api->tested ) && version_compare( substr( $wp_version, 0, strlen( $api->tested ) ), $api->tested, '<=' ) ); 758 $compatible_wp = ( ! empty( $api->requires ) && version_compare( substr( $wp_version, 0, strlen( $api->requires ) ), $api->requires, '>=' ) ); 759 $can_install = $compatible_php && $compatible_wp; 760 761 if ( ! $compatible_php ) { 762 echo '<div class="notice notice-error notice-alt"><p>' . sprintf( 763 /* translators: Upgrading PHP page URL */ 764 __( '<strong>Warning:</strong> This plugin <strong>requires a newer version of PHP</strong>, so unfortunately you cannot install it. <a href="%s">Click here to learn more about upgrading PHP.</a>' ), 765 esc_url( __( 'https://wordpress.org/support/upgrade-php/' ) ) 766 ) . '</p></div>'; 767 } elseif ( ! $tested_wp ) { 768 echo '<div class="notice notice-warning notice-alt"><p>' . __( '<strong>Warning:</strong> This plugin <strong>has not been tested</strong> with your current version of WordPress.' ) . '</p></div>'; 769 } elseif ( ! $compatible_wp ) { 770 echo '<div class="notice notice-warning notice-alt"><p>' . __( '<strong>Warning:</strong> This plugin <strong>has not been marked as compatible</strong> with your version of WordPress.' ) . '</p></div>'; 760 771 } 761 772 762 773 foreach ( (array) $api->sections as $section_name => $content ) { … … 780 791 switch ( $status['status'] ) { 781 792 case 'install': 782 793 if ( $status['url'] ) { 783 echo '<a data-slug="' . esc_attr( $api->slug ) . '" id="plugin_install_from_iframe" class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Now' ) . '</a>'; 794 if ( $can_install ) { 795 echo '<a data-slug="' . esc_attr( $api->slug ) . '" id="plugin_install_from_iframe" class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Now' ) . '</a>'; 796 } else { 797 printf( 798 '<button type="button" class="button button-primary button-disabled right" disabled="disabled">%s</button>', 799 _x( 'Cannot Install', 'plugin' ) 800 ); 801 } 784 802 } 785 803 break; 786 804 case 'update_available':