Make WordPress Core

Ticket #43986: 43986-3.diff

File 43986-3.diff, 1.7 KB (added by afragen, 6 years ago)

Just a fix for proper spacing. No other differences from 43986-2.diff

  • 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..0c567a85e8 100644
    class WP_Plugin_Install_List_Table extends WP_List_Table { 
    456456
    457457                $group = null;
    458458
     459                $this->load_requires_php();
     460
    459461                foreach ( (array) $this->items as $plugin ) {
    460462                        if ( is_object( $plugin ) ) {
    461463                                $plugin = (array) $plugin;
    class WP_Plugin_Install_List_Table extends WP_List_Table { 
    686688                        echo '</div></div>';
    687689                }
    688690        }
     691
     692        /**
     693         * Loads the filter hook to disable the plugin install button if PHP version not sufficient.
     694         */
     695        public function load_requires_php(){
     696                add_filter( 'plugin_install_action_links', array( $this, 'disable_install_button' ), 10, 2 );
     697                add_filter( 'wp_ajax_search-install-plugins', array( $this, 'disable_install_button' ), 10, 2 );
     698        }
     699
     700        /**
     701         * Filter plugin action links in Install Plugin page.
     702         *
     703         * @param array $action_links
     704         * @param array $plugin
     705         *
     706         * @return array $action_links
     707         */
     708        public function disable_install_button( $action_links, $plugin ) {
     709                $disable_button = '<button type="button" class="button button-disabled" disabled="disabled">';
     710                $disable_button .= __( 'Cannot install' );
     711                $disable_button .= '</button>';
     712
     713                if ( $plugin['requires_php'] &&
     714                     version_compare( PHP_VERSION, $plugin['requires_php'], '<=' )
     715                ) {
     716                        unset( $action_links[0] );
     717                        $action_links[] = __( 'PHP version too low' );
     718                        $action_links[] = $disable_button;
     719                        $action_links   = array_reverse( $action_links );
     720                }
     721
     722                return $action_links;
     723        }
     724
    689725}