- Timestamp:
- 07/09/2018 01:44:53 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-plugin-install-list-table.php
r43178 r43436 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 499 505 $action_links = array(); 500 506 … … 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; … … 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 echo '<div class="notice inline notice-error notice-alt"><p>'; 629 if ( ! $compatible_php && ! $compatible_wp ) { 630 _e( 'This plugin doesn’t work with your versions of WordPress and PHP. ' ); 631 if ( current_user_can( 'update_core' ) ) { 632 printf( 633 /* translators: 1: "Update WordPress" screen URL, 2: "Updating PHP" page URL */ 634 __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ), 635 self_admin_url( 'update-core.php' ), 636 esc_url( __( 'https://wordpress.org/support/upgrade-php/' ) ) 637 ); 638 } else { 639 printf( 640 /* translators: %s: "Updating PHP" page URL */ 641 __( '<a href="%s">Learn more about updating PHP</a>.' ), 642 esc_url( __( 'https://wordpress.org/support/upgrade-php/' ) ) 643 ); 644 } 645 } elseif ( ! $compatible_wp ) { 646 _e( 'This plugin doesn’t work with your version of WordPress. ' ); 647 if ( current_user_can( 'update_core' ) ) { 648 printf( 649 /* translators: %s: "Update WordPress" screen URL */ 650 __( '<a href="%s">Please update WordPress</a>.' ), 651 self_admin_url( 'update-core.php' ) 652 ); 653 } 654 } elseif ( ! $compatible_php ) { 655 _e( 'This plugin doesn’t work with your version of PHP. ' ); 656 printf( 657 /* translators: %s: "Updating PHP" page URL */ 658 __( '<a href="%s">Learn more about updating PHP</a>.' ), 659 esc_url( __( 'https://wordpress.org/support/upgrade-php/' ) ) 660 ); 661 } 662 echo '</p></div>'; 663 } 664 ?> 613 665 <div class="plugin-card-top"> 614 666 <div class="name column-name"> … … 642 694 ) 643 695 ); 644 ?>696 ?> 645 697 <span class="num-ratings" aria-hidden="true">(<?php echo number_format_i18n( $plugin['num_ratings'] ); ?>)</span> 646 698 </div> … … 666 718 <div class="column-compatibility"> 667 719 <?php 668 $wp_version = get_bloginfo( 'version' ); 669 670 if ( ! empty( $plugin['tested'] ) && version_compare( substr( $wp_version, 0, strlen( $plugin['tested'] ) ), $plugin['tested'], '>' ) ) { 720 if ( ! $tested_wp ) { 671 721 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'], '<' )) {722 } elseif ( ! $compatible_wp ) { 673 723 echo '<span class="compatibility-incompatible">' . __( '<strong>Incompatible</strong> with your version of WordPress' ) . '</span>'; 674 724 } else {
Note: See TracChangeset
for help on using the changeset viewer.