@@ -38,6 +38,31 @@ function phpwpinfo() {
3838 $ info ->init_all_tests ();
3939}
4040
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+
4166/**
4267 * TODO: Use or not session for save DB configuration
4368 */
@@ -92,10 +117,10 @@ public function init_all_tests() {
92117 $ this ->test_form_mail ();
93118
94119 $ this ->get_footer ();
95- }
120+ }
96121
97122 /**
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
99124 */
100125 public function test_versions () {
101126 $ this ->html_table_open ( 'General informations & tests PHP/MySQL Version ' , '' , 'Required ' , 'Recommended ' , 'Current ' );
@@ -142,6 +167,13 @@ public function test_versions() {
142167 $ this ->html_table_row ( 'MySQL Version ' , $ this ->mysqli_version , '- ' , 'Not available, needs credentials. ' , 'warning ' );
143168 }
144169
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+
145177 $ this ->html_table_close ();
146178 }
147179
0 commit comments