@@ -31,7 +31,8 @@ class File_Type_Check extends Abstract_File_Check {
31
31
const TYPE_APPLICATION = 16 ;
32
32
const TYPE_BADLY_NAMED = 32 ;
33
33
const TYPE_LIBRARY_CORE = 64 ;
34
- const TYPE_ALL = 127 ; // Same as all of the above with bitwise OR.
34
+ const TYPE_COMPOSER = 128 ;
35
+ const TYPE_ALL = 255 ; // Same as all of the above with bitwise OR.
35
36
36
37
/**
37
38
* Bitwise flags to control check behavior.
@@ -99,6 +100,9 @@ protected function check_files( Check_Result $result, array $files ) {
99
100
if ( $ this ->flags & self ::TYPE_LIBRARY_CORE ) {
100
101
$ this ->look_for_library_core_files ( $ result , $ files );
101
102
}
103
+ if ( $ this ->flags & self ::TYPE_COMPOSER ) {
104
+ $ this ->look_for_composer_files ( $ result , $ files );
105
+ }
102
106
}
103
107
104
108
/**
@@ -372,6 +376,44 @@ function ( $file ) use ( $plugin_path ) {
372
376
}
373
377
}
374
378
379
+ /**
380
+ * Looks for composer files.
381
+ *
382
+ * @since 1.4.0
383
+ *
384
+ * @param Check_Result $result The check result to amend, including the plugin context to check.
385
+ * @param array $files List of absolute file paths.
386
+ */
387
+ protected function look_for_composer_files ( Check_Result $ result , array $ files ) {
388
+ if ( $ result ->plugin ()->is_single_file_plugin () ) {
389
+ return ;
390
+ }
391
+
392
+ $ plugin_path = $ result ->plugin ()->path ();
393
+
394
+ if (
395
+ is_dir ( $ plugin_path . 'vendor ' ) &&
396
+ file_exists ( $ plugin_path . 'vendor/autoload.php ' ) &&
397
+ ! file_exists ( $ plugin_path . 'composer.json ' )
398
+ ) {
399
+ $ this ->add_result_warning_for_file (
400
+ $ result ,
401
+ sprintf (
402
+ /* translators: 1: directory, 2: filename */
403
+ esc_html__ ( 'The "%1$s" directory exists, but "%2$s" is missing. ' , 'plugin-check ' ),
404
+ '/vendor ' ,
405
+ 'composer.json '
406
+ ),
407
+ 'missing_composer_json_file ' ,
408
+ 'composer.json ' ,
409
+ 0 ,
410
+ 0 ,
411
+ 'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#included-unneeded-folders ' ,
412
+ 6
413
+ );
414
+ }
415
+ }
416
+
375
417
/**
376
418
* Gets the description for the check.
377
419
*
0 commit comments