Make WordPress Core

Ticket #43986: 43986.diff

File 43986.diff, 1.8 KB (added by afragen, 6 years ago)
  • 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..3f73dbb6ed 100644
    class WP_Plugin_Install_List_Table extends WP_List_Table { 
    686686                        echo '</div></div>';
    687687                }
    688688        }
     689
     690        /**
     691         * Loads the filter hook to disable the plugin install button if PHP version not sufficient.
     692         */
     693        public function load_requires_php(){
     694                add_filter( 'plugin_install_action_links', array( $this, 'disable_install_button' ), 10, 2 );
     695        }
     696
     697        /**
     698         * Filter plugin action links in Install Plugin page.
     699         *
     700         * @param array $action_links
     701         * @param array $plugin
     702         *
     703         * @return array $action_links
     704         */
     705        public function disable_install_button( $action_links, $plugin ) {
     706                $disable_button = '<button type="button" class="button button-disabled" disabled="disabled">';
     707                $disable_button .= __( 'Cannot install' );
     708                $disable_button .= '</button>';
     709
     710                if ( $plugin['requires_php'] &&
     711                     version_compare( PHP_VERSION, $plugin['requires_php'], '<=' )
     712                ) {
     713                        unset( $action_links[0] );
     714                        $action_links[] = __( 'PHP version too low' );
     715                        $action_links[] = $disable_button;
     716                        $action_links   = array_reverse( $action_links );
     717                }
     718
     719                return $action_links;
     720        }
     721
    689722}
  • wp-admin/plugin-install.php

    diff --git a/wp-admin/plugin-install.php b/wp-admin/plugin-install.php
    index fe5f414cd1..b07e6aa1b9 100644
    a b if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) { 
    3939}
    4040
    4141$wp_list_table->prepare_items();
     42$wp_list_table->load_requires_php();
    4243
    4344$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
    4445