| 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 | |