@@ -38,6 +38,31 @@ function phpwpinfo() {
38
38
$ info ->init_all_tests ();
39
39
}
40
40
41
+ function command_exists ($ command ) {
42
+ $ whereIsCommand = (PHP_OS == 'WINNT ' ) ? 'where ' : 'which ' ;
43
+
44
+ $ process = proc_open (
45
+ "$ whereIsCommand $ command " ,
46
+ array (
47
+ 0 => array ("pipe " , "r " ), //STDIN
48
+ 1 => array ("pipe " , "w " ), //STDOUT
49
+ 2 => array ("pipe " , "w " ), //STDERR
50
+ ),
51
+ $ pipes
52
+ );
53
+ if ($ process !== false ) {
54
+ $ stdout = stream_get_contents ($ pipes [1 ]);
55
+ $ stderr = stream_get_contents ($ pipes [2 ]);
56
+ fclose ($ pipes [1 ]);
57
+ fclose ($ pipes [2 ]);
58
+ proc_close ($ process );
59
+
60
+ return $ stdout != '' ;
61
+ }
62
+
63
+ return false ;
64
+ }
65
+
41
66
/**
42
67
* TODO: Use or not session for save DB configuration
43
68
*/
@@ -92,10 +117,10 @@ public function init_all_tests() {
92
117
$ this ->test_form_mail ();
93
118
94
119
$ this ->get_footer ();
95
- }
120
+ }
96
121
97
122
/**
98
- * Main test, check if php/mysql are installed and right version for WP
123
+ * Main test, check if php/mysql/git are installed and right version for WP
99
124
*/
100
125
public function test_versions () {
101
126
$ this ->html_table_open ( 'General informations & tests PHP/MySQL Version ' , '' , 'Required ' , 'Recommended ' , 'Current ' );
@@ -142,6 +167,13 @@ public function test_versions() {
142
167
$ this ->html_table_row ( 'MySQL Version ' , $ this ->mysqli_version , '- ' , 'Not available, needs credentials. ' , 'warning ' );
143
168
}
144
169
170
+ //Test if the command 'git' exists, so it tests if Git is installed
171
+ if (command_exists ('git ' ) == 1 ){
172
+ $ this ->html_table_row ('Presence of Git ' , 'No ' , 'Yes ' , 'Yes ' );
173
+ }else {
174
+ $ this ->html_table_row ('Presence of Git ' , 'No ' , 'Yes ' , 'No ' , 'error ' );
175
+ }
176
+
145
177
$ this ->html_table_close ();
146
178
}
147
179
0 commit comments