Skip to content

Commit aed15db

Browse files
committed
Test Imagick and GD like WordPress does, versions and modules
1 parent e472152 commit aed15db

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

phpwpinfo.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function test_versions() {
119119
$this->html_table_row( 'PHP Version', $this->php_version, '> 5.4', $php_version, 'error' );
120120
}
121121

122-
// Test MYSQL Client extensions/version
122+
// Test MYSQL Client extensions/version.
123123
if ( ! extension_loaded( 'mysqli' ) || ! is_callable( 'mysqli_connect' ) ) {
124124
$this->html_table_row( 'PHP MySQLi Extension', 'Yes', 'Yes', 'Not installed', 'error' );
125125
} else {
@@ -148,14 +148,22 @@ public function test_versions() {
148148
public function test_php_extensions() {
149149
$this->html_table_open( 'PHP Extensions', '', 'Required', 'Recommended','Current' );
150150

151-
// GD/Imagick lib
152-
if ( is_callable( 'gd_info' ) ) {
151+
/**
152+
* Check GD and Imagick like WordPress does.
153+
*/
154+
$gd = extension_loaded( 'gd' ) && function_exists( 'gd_info' );
155+
$imagick = extension_loaded( 'imagick' ) && class_exists( 'Imagick', false ) && class_exists( 'ImagickPixel', false ) && version_compare( phpversion( 'imagick' ), '2.2.0', '>=' );
156+
157+
// GD/Imagick lib.
158+
if ( $gd ) {
153159
$this->html_table_row( 'Image manipulation (GD)', 'Yes', 'Yes', 'Installed', 'success' );
154160
}
155-
if ( class_exists('Imagick') ) {
161+
162+
if ( $imagick ) {
156163
$this->html_table_row( 'Image manipulation (Imagick)', 'Yes', 'Yes', 'Installed', 'success' );
157164
}
158-
if ( ! is_callable( 'gd_info' ) && !class_exists('Imagick') ) {
165+
166+
if ( ! $gd && ! $imagick ) {
159167
$this->html_table_row( 'Image manipulation (GD, Imagick)', 'Yes', 'Yes', 'Not installed', 'error' );
160168
}
161169

@@ -536,7 +544,7 @@ public function get_header() {
536544
$output .= '<meta charset="utf-8">' . "\n";
537545
$output .= '<meta name="robots" content="noindex,nofollow">' . "\n";
538546
$output .= '<title>PHP WordPress Info</title>' . "\n";
539-
$output .= '<link href="https//maxcdn.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">' . "\n";
547+
$output .= '<link href="https://maxcdn.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">' . "\n";
540548
$output .= '<style>.table tbody tr.warning td{background-color:#FCF8E3;} .description{margin:-10px 0 20px 0;} caption{font-weight: 700;font-size: 18px}</style>' . "\n";
541549
$output .= '<!--[if lt IE 9]> <script src="https://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]-->' . "\n";
542550
$output .= '</head>' . "\n";

0 commit comments

Comments
 (0)