Ticket #43986: 43986-final.2.diff
File 43986-final.2.diff, 9.8 KB (added by , 6 years ago) |
---|
-
src/wp-admin/css/list-tables.css
diff --git src/wp-admin/css/list-tables.css src/wp-admin/css/list-tables.css index 8d78983993..dce42a4ea4 100644
div.action-links, 1510 1510 content: "\f158"; 1511 1511 } 1512 1512 1513 .plugin-card .column-compatibility .compatibility-incompatible:before { 1514 color: #f00; 1515 } 1516 1513 1517 .plugin-card .compatibility-compatible:before { 1514 1518 content: "\f147"; 1515 1519 } 1516 1520 1521 .plugin-card .column-compatibility .compatibility-compatible:before { 1522 color: #008000; 1523 } 1524 1525 .plugin-card .notice-error.incompatible { 1526 margin: 12px 20px 0 20px; 1527 padding: 12px 20px; 1528 border-left: 5px solid #dc3232; 1529 } 1530 1531 .plugin-card .notice-error.incompatible a { 1532 text-decoration: underline; 1533 } 1534 1517 1535 .plugin-icon { 1518 1536 position: absolute; 1519 1537 top: 20px; -
src/wp-admin/includes/class-wp-plugin-install-list-table.php
diff --git src/wp-admin/includes/class-wp-plugin-install-list-table.php src/wp-admin/includes/class-wp-plugin-install-list-table.php index a19729b1d4..b2db5c5da2 100644
class WP_Plugin_Install_List_Table extends WP_List_Table { 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( PHP_VERSION, 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 499 505 $action_links = array(); 500 506 501 507 if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) { … … class WP_Plugin_Install_List_Table extends WP_List_Table { 504 510 switch ( $status['status'] ) { 505 511 case 'install': 506 512 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 ); 513 if ( $compatible_php && $compatible_wp ) { 514 $action_links[] = sprintf( 515 '<a class="install-now button" data-slug="%s" href="%s" aria-label="%s" data-name="%s">%s</a>', 516 esc_attr( $plugin['slug'] ), 517 esc_url( $status['url'] ), 518 /* translators: %s: plugin name and version */ 519 esc_attr( sprintf( __( 'Install %s now' ), $name ) ), 520 esc_attr( $name ), 521 __( 'Install Now' ) 522 ); 523 } else { 524 $action_links[] = sprintf( 525 '<button type="button" class="button button-disabled" disabled="disabled">%s</button>', 526 _x( 'Cannot Install', 'plugin' ) 527 ); 528 } 516 529 } 517 530 break; 518 531 … … class WP_Plugin_Install_List_Table extends WP_List_Table { 610 623 $last_updated_timestamp = strtotime( $plugin['last_updated'] ); 611 624 ?> 612 625 <div class="plugin-card plugin-card-<?php echo sanitize_html_class( $plugin['slug'] ); ?>"> 626 <?php 627 if ( ! $compatible_php || ! $compatible_wp ) { 628 // Remove style section for commit. 629 echo '<style> 630 .plugin-card .notice-error.incompatible { 631 margin: 12px 20px 0 20px; 632 padding: 12px 20px; 633 border-left: 5px solid #dc3232; 634 } 635 .plugin-card .notice-error.incompatible a { text-decoration: underline; } 636 .plugin-card .column-compatibility .compatibility-incompatible:before { color: #f00; } 637 .plugin-card .column-compatibility .compatibility-compatible:before { color: #008000; } 638 </style>'; 639 // End remove for commit. 640 641 echo '<div class="notice-error notice-alt incompatible">'; 642 if ( ! $compatible_php && ! $compatible_wp ) { 643 echo __( 'This plugin doesn’t work with your versions of WordPress and PHP. ' ); 644 printf( 645 /* translators: 1: link to update-core.php 2: Upgrading PHP page URL */ 646 __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about upgrading PHP.</a>' ), 647 self_admin_url( 'update-core.php' ), 648 esc_url( __( 'https://wordpress.org/support/upgrade-php/' ) ) 649 ); 650 } elseif ( ! $compatible_wp ) { 651 echo __( 'This plugin doesn’t work with your version of WordPress. ' ); 652 printf( 653 /* translators: %s: Link to update-core.php */ 654 __( '<a href="%s" >Please update WordPress.</a>' ), 655 self_admin_url( 'update-core.php' ) 656 ); 657 } elseif ( ! $compatible_php ) { 658 echo __( 'This plugin doesn’t work with your version of PHP. ' ); 659 printf( 660 /* translators: %s: Upgrading PHP page URL */ 661 __( '<a href="%s">Learn more about upgrading PHP.</a>' ), 662 esc_url( __( 'https://wordpress.org/support/upgrade-php/' ) ) 663 ); 664 } 665 echo '</div>'; 666 } ?> 613 667 <div class="plugin-card-top"> 614 668 <div class="name column-name"> 615 669 <h3> … … class WP_Plugin_Install_List_Table extends WP_List_Table { 623 677 <?php 624 678 if ( $action_links ) { 625 679 echo '<ul class="plugin-action-buttons"><li>' . implode( '</li><li>', $action_links ) . '</li></ul>'; 626 } 627 ?> 680 } ?> 628 681 </div> 629 682 <div class="desc column-description"> 630 683 <p><?php echo $description; ?></p> … … class WP_Plugin_Install_List_Table extends WP_List_Table { 641 694 'number' => $plugin['num_ratings'], 642 695 ) 643 696 ); 644 ?>697 ?> 645 698 <span class="num-ratings" aria-hidden="true">(<?php echo number_format_i18n( $plugin['num_ratings'] ); ?>)</span> 646 699 </div> 647 700 <div class="column-updated"> … … class WP_Plugin_Install_List_Table extends WP_List_Table { 665 718 </div> 666 719 <div class="column-compatibility"> 667 720 <?php 668 $wp_version = get_bloginfo( 'version' ); 669 670 if ( ! empty( $plugin['tested'] ) && version_compare( substr( $wp_version, 0, strlen( $plugin['tested'] ) ), $plugin['tested'], '>' ) ) { 721 if ( ! $tested_wp ) { 671 722 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'], '<' )) {723 } elseif ( ! $compatible_wp ) { 673 724 echo '<span class="compatibility-incompatible">' . __( '<strong>Incompatible</strong> with your version of WordPress' ) . '</span>'; 674 725 } else { 675 726 echo '<span class="compatibility-compatible">' . __( '<strong>Compatible</strong> with your version of WordPress' ) . '</span>'; 676 } 677 ?> 727 } ?> 678 728 </div> 679 729 </div> 680 730 </div> -
src/wp-admin/includes/plugin-install.php
diff --git src/wp-admin/includes/plugin-install.php src/wp-admin/includes/plugin-install.php index f765fb286e..4f1c56b86a 100644
if ( ! empty( $api->contributors ) ) { 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( PHP_VERSION, 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 760 if ( ! $tested_wp ) { 761 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>'; 762 } elseif ( ! $compatible_wp ) { 763 echo '<div class="notice notice-error notice-alt"><p>' . __( '<strong>Error:</strong> This plugin <strong>doesn’t work</strong> with your version of WordPress.' ) . '</p></div>'; 764 } 765 if ( ! $compatible_php ) { 766 echo '<div class="notice notice-error notice-alt"><p>' . sprintf( 767 /* translators: %s: Upgrading PHP page URL */ 768 __( '<strong>Error:</strong> This plugin <strong>requires a newer version of PHP</strong>, so unfortunately you cannot install it. <a href="%s">Learn more about upgrading PHP.</a>' ), 769 esc_url( __( 'https://wordpress.org/support/upgrade-php/' ) ) 770 ) . '</p></div>'; 760 771 } 761 772 762 773 foreach ( (array) $api->sections as $section_name => $content ) { … … if ( ! empty( $api->contributors ) ) { 779 790 $status = install_plugin_install_status( $api ); 780 791 switch ( $status['status'] ) { 781 792 case 'install': 782 if ( $ status['url']) {793 if ( $compatible_php && $compatible_wp ) { 783 794 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>'; 795 } else { 796 printf( 797 '<button type="button" class="button button-primary button-disabled right" disabled="disabled">%s</button>', 798 _x( 'Cannot Install', 'plugin' ) 799 ); 784 800 } 785 801 break; 786 802 case 'update_available':