path, strlen( $ctx->muPluginsDir ) + 1 ); if ( false !== strpos( $rel, '/' ) || ! Text::isPhpFile( $rel ) ) { return array(); } $text = $f->text(); $args = array( $f->path, self::headerOrDash( $text, 'Plugin Name' ), self::headerOrDash( $text, 'Author' ), (string) $f->size, null === $f->mtime ? '-' : gmdate( 'Y-m-d H:i', $f->mtime ) . ' UTC', ); $hit = Text::firstMarker( $text, Assumptions::OBF ); if ( null !== $hit ) { $args[] = $hit[0]; return array( Finding::make( 'mu_plugin_marker', $f->path, $args, Text::excerptAround( $text, $hit[1] ) ) ); } return array( Finding::make( 'mu_plugin', $f->path, $args ) ); } /** * A file directly in the content folder (not in a sub-folder). * * @return Finding[] */ public static function inspectContentTop( FileEntry $f, Context $ctx ): array { $rel = substr( $f->path, strlen( $ctx->contentDir ) + 1 ); if ( false !== strpos( $rel, '/' ) || ! Text::isPhpFile( $rel ) ) { return array(); } if ( in_array( $rel, $ctx->dropins, true ) ) { $text = $f->text(); return array( Finding::make( 'dropin', $f->path, array( $f->path, self::headerOrDash( $text, 'Plugin Name' ), self::headerOrDash( $text, 'Author' ) ) ) ); } if ( 'index.php' === $rel ) { return array(); } if ( isset( Assumptions::KNOWN_CONFIG_FILES[ $rel ] ) && in_array( Assumptions::KNOWN_CONFIG_FILES[ $rel ], $ctx->installedSlugs(), true ) ) { return array( Finding::make( 'content_dir_plugin_config', $f->path, array( $f->path, Assumptions::KNOWN_CONFIG_FILES[ $rel ] ) ) ); } return array( Finding::make( 'content_dir_unknown_php', $f->path, array( $f->path ) ) ); } private static function headerOrDash( string $text, string $name ): string { $v = Patterns::header( $text, $name ); return '' === $v ? '-' : Text::cut( $v, 100 ); } }