Ticket #43986: 43986v2-4.diff
File 43986v2-4.diff, 5.5 KB (added by , 6 years ago) |
---|
-
src/wp-admin/css/list-tables-rtl.css
diff --git src/wp-admin/css/list-tables-rtl.css src/wp-admin/css/list-tables-rtl.css index a262405bd7..85d8a75aec 100644
div.action-links, 1523 1523 .plugin-card .compatibility-incompatible:before { 1524 1524 content: "\f158"; 1525 1525 } 1526 .plugin-card .column-compatibility .compatibility-incompatible:before { 1527 color: #f00; 1528 } 1526 1529 1527 1530 .plugin-card .compatibility-compatible:before { 1528 1531 content: "\f147"; 1529 1532 } 1530 1533 1534 .plugin-card .column-compatibility .compatibility-compatible:before { 1535 color: #008000; 1536 } 1537 1531 1538 .plugin-icon { 1532 1539 position: absolute; 1533 1540 top: 20px; -
src/wp-admin/css/list-tables.css
diff --git src/wp-admin/css/list-tables.css src/wp-admin/css/list-tables.css index 1f463e6e54..950e3948e5 100644
div.action-links, 1524 1524 content: "\f158"; 1525 1525 } 1526 1526 1527 .plugin-card .column-compatibility .compatibility-incompatible:before { 1528 color: #f00; 1529 } 1530 1527 1531 .plugin-card .compatibility-compatible:before { 1528 1532 content: "\f147"; 1529 1533 } 1530 1534 1535 .plugin-card .column-compatibility .compatibility-compatible:before { 1536 color: #008000; 1537 } 1538 1531 1539 .plugin-icon { 1532 1540 position: absolute; 1533 1541 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..1767244f9e 100644
class WP_Plugin_Install_List_Table extends WP_List_Table { 456 456 457 457 $group = null; 458 458 459 $this->load_requires_php(); 460 459 461 foreach ( (array) $this->items as $plugin ) { 460 462 if ( is_object( $plugin ) ) { 461 463 $plugin = (array) $plugin; … … class WP_Plugin_Install_List_Table extends WP_List_Table { 665 667 </div> 666 668 <div class="column-compatibility"> 667 669 <?php 670 echo '<strong>' . __( 'Requirements' ) . '</strong><br>'; 668 671 $wp_version = get_bloginfo( 'version' ); 669 672 670 if ( ! empty( $plugin['tested'] ) && version_compare( substr( $wp_version, 0, strlen( $plugin['tested'] ) ),$plugin['tested'], '>' ) ) {673 if ( $this->is_wordpress_compatible( $plugin['tested'], '>' ) ) { 671 674 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'], '<' ) ) {673 echo '<span class="compatibility-incompatible">' . __( '<strong>Incompatible</strong> with your version of WordPress' ) . '</span>';675 } elseif ( $this->is_wordpress_compatible( $plugin['requires'], '<' ) ) { 676 printf( '<span class="compatibility-incompatible">' . __( 'WordPress %s' ) . '</span>', $plugin['requires'] ); 674 677 } else { 675 echo '<span class="compatibility-compatible">' . __( '<strong>Compatible</strong> with your version of WordPress' ) . '</span>';678 printf( '<span class="compatibility-compatible">' . __( 'WordPress %s' ) . '</span>', $plugin['requires'] ); 676 679 } 680 681 /** 682 * Add additional compatibility information to bottom of plugin card. 683 * 684 * @since 4.9.x 685 * 686 * @param array $plugin Readme.txt data from current plugin. 687 */ 688 do_action( 'plugin_install_compatibilty_information', $plugin ); 677 689 ?> 678 690 </div> 679 691 </div> … … class WP_Plugin_Install_List_Table extends WP_List_Table { 686 698 echo '</div></div>'; 687 699 } 688 700 } 701 702 /** 703 * Test if current version of WordPress is compatible with plugin requirements. 704 * 705 * @param mixed $version Version required. 706 * @param mixed $operator `version_compare` operator. 707 * @return bool 708 */ 709 public function is_wordpress_compatible( $version, $operator ) { 710 global $wp_version; 711 return ! empty( $version ) && version_compare( substr( $wp_version, 0, strlen( $version ) ), $version, $operator ); 712 } 713 714 /** 715 * Loads the filter hook to disable the plugin install button if PHP version not sufficient. 716 */ 717 public function load_requires_php(){ 718 add_filter( 'plugin_install_action_links', array( $this, 'disable_install_button' ), 10, 2 ); 719 add_filter( 'wp_ajax_search-install-plugins', array( $this, 'disable_install_button' ), 10, 2 ); 720 add_action( 'plugin_install_compatibilty_information', array( $this, 'add_compatibility_text' ), 10, 1 ); 721 } 722 723 /** 724 * Filter plugin action links in Install Plugin page. 725 * 726 * @param array $action_links 727 * @param array $plugin 728 * 729 * @return array $action_links 730 */ 731 public function disable_install_button( $action_links, $plugin ) { 732 $disable_button = '<button type="button" class="button button-disabled" disabled="disabled">'; 733 $disable_button .= __( 'Cannot install' ); 734 $disable_button .= '</button>'; 735 736 if ( $plugin['requires_php'] && 737 version_compare( PHP_VERSION, $plugin['requires_php'], '<=' ) 738 ) { 739 $action_links[0] = $disable_button; 740 } 741 742 return $action_links; 743 } 744 745 /** 746 * Add PHP version compatibility text to plugin card bottom. 747 * 748 * @uses `plugin_install_compatibilty_information` action hook. 749 * 750 * @param mixed $plugin Current plugin data. 751 * 752 * @return string 753 */ 754 public function add_compatibility_text( $plugin ) { 755 if ( $plugin['requires_php'] && 756 version_compare( PHP_VERSION, $plugin['requires_php'], '<=' ) 757 ) { 758 printf( '<br><span class="compatibility-incompatible">' . __( 'PHP %s' ) . '</span>', $plugin['requires_php'] ); 759 } else { 760 printf( '<br><span class="compatibility-compatible">' . __( 'PHP %s' ) . '</span>', $plugin['requires_php'] ); 761 } 762 } 763 689 764 }