Changeset 43436
- Timestamp:
- 07/09/2018 01:44:53 PM (6 years ago)
- Location:
- trunk/src/wp-admin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/css/list-tables.css
r43309 r43436 1515 1515 } 1516 1516 1517 .plugin-card .notice { 1518 margin: 20px 20px 0 20px; 1519 } 1520 1517 1521 .plugin-icon { 1518 1522 position: absolute; -
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 { -
trunk/src/wp-admin/includes/plugin-install.php
r43179 r43436 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 760 if ( ! $compatible_php ) { 761 echo '<div class="notice notice-error notice-alt"><p>'; 762 printf( 763 /* translators: "Updating PHP" page URL */ 764 __( '<strong>Error:</strong> This plugin <strong>requires a newer version of PHP</strong>, so unfortunately you cannot install it. <a href="%s" target="_blank">Click here to learn more about updating PHP</a>.' ), 765 esc_url( __( 'https://wordpress.org/support/upgrade-php/' ) ) 766 ); 767 echo '</p></div>'; 768 } 769 770 if ( ! $tested_wp ) { 771 echo '<div class="notice notice-warning notice-alt"><p>'; 772 _e( '<strong>Warning:</strong> This plugin <strong>has not been tested</strong> with your current version of WordPress.' ); 773 echo '</p></div>'; 774 } elseif ( ! $compatible_wp ) { 775 echo '<div class="notice notice-error notice-alt"><p>'; 776 _e( '<strong>Error:</strong> This plugin <strong>requires a newer version of WordPress</strong>.' ); 777 if ( current_user_can( 'update_core' ) ) { 778 printf( 779 /* translators: %s: "Update WordPress" screen URL */ 780 ' ' . __( '<a href="%s" target="_parent">Click here to update WordPress</a>.' ), 781 self_admin_url( 'update-core.php' ) 782 ); 783 } 784 echo '</p></div>'; 760 785 } 761 786 … … 781 806 case 'install': 782 807 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>'; 808 if ( $compatible_php && $compatible_wp ) { 809 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>'; 810 } else { 811 printf( 812 '<button type="button" class="button button-primary button-disabled right" disabled="disabled">%s</button>', 813 _x( 'Cannot Install', 'plugin' ) 814 ); 815 } 784 816 } 785 817 break;
Note: See TracChangeset
for help on using the changeset viewer.