From aed15dbc4f63f3358313d4879cd0afb0500cfad2 Mon Sep 17 00:00:00 2001 From: Nicolas Juen Date: Tue, 14 Mar 2017 13:03:48 +0100 Subject: [PATCH] Test Imagick and GD like WordPress does, versions and modules --- phpwpinfo.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/phpwpinfo.php b/phpwpinfo.php index 57edfd1..ec41a27 100644 --- a/phpwpinfo.php +++ b/phpwpinfo.php @@ -119,7 +119,7 @@ public function test_versions() { $this->html_table_row( 'PHP Version', $this->php_version, '> 5.4', $php_version, 'error' ); } - // Test MYSQL Client extensions/version + // Test MYSQL Client extensions/version. if ( ! extension_loaded( 'mysqli' ) || ! is_callable( 'mysqli_connect' ) ) { $this->html_table_row( 'PHP MySQLi Extension', 'Yes', 'Yes', 'Not installed', 'error' ); } else { @@ -148,14 +148,22 @@ public function test_versions() { public function test_php_extensions() { $this->html_table_open( 'PHP Extensions', '', 'Required', 'Recommended','Current' ); - // GD/Imagick lib - if ( is_callable( 'gd_info' ) ) { + /** + * Check GD and Imagick like WordPress does. + */ + $gd = extension_loaded( 'gd' ) && function_exists( 'gd_info' ); + $imagick = extension_loaded( 'imagick' ) && class_exists( 'Imagick', false ) && class_exists( 'ImagickPixel', false ) && version_compare( phpversion( 'imagick' ), '2.2.0', '>=' ); + + // GD/Imagick lib. + if ( $gd ) { $this->html_table_row( 'Image manipulation (GD)', 'Yes', 'Yes', 'Installed', 'success' ); } - if ( class_exists('Imagick') ) { + + if ( $imagick ) { $this->html_table_row( 'Image manipulation (Imagick)', 'Yes', 'Yes', 'Installed', 'success' ); } - if ( ! is_callable( 'gd_info' ) && !class_exists('Imagick') ) { + + if ( ! $gd && ! $imagick ) { $this->html_table_row( 'Image manipulation (GD, Imagick)', 'Yes', 'Yes', 'Not installed', 'error' ); } @@ -536,7 +544,7 @@ public function get_header() { $output .= '' . "\n"; $output .= '' . "\n"; $output .= 'PHP WordPress Info' . "\n"; - $output .= '' . "\n"; + $output .= '' . "\n"; $output .= '' . "\n"; $output .= '' . "\n"; $output .= '' . "\n";