: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
class Directory_Iterator {
* Directory that will be searched.
* The search term being used.
* A check if regex searches are enabled or not.
* DirectoryIterator constructor.
public function __construct( $directory, $search, $regex ) {
$this->directory = $directory;
* Build the folder structure.
public function get_structure() {
$scan_path = $this->prepare_scan_path( $this->directory );
if ( is_file( $scan_path->path ) ) {
$files = array( $scan_path->path );
$files = $this->ajax_scan_path( $scan_path->path );
* Make sure each chunk of file arrays never exceeds 500 files
* This is to prevent the SQL string from being too large and crashing everything
$back_compat_filter = apply_filters( 'string-locator-files-per-array', 500 ); //phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
$file_chunks = array_chunk( $files, apply_filters( 'string_locator_files_per_array', $back_compat_filter ), true );
'scan_path' => $scan_path,
'search' => $this->search,
'directory' => $this->directory,
'chunks' => count( $file_chunks ),
'total' => count( $files ),
'directory' => $scan_path,
'chunks' => count( $file_chunks ),
set_transient( 'string-locator-search-overview', $store );
update_option( 'string-locator-search-history', array(), false );
foreach ( $file_chunks as $count => $file_chunk ) {
set_transient( 'string-locator-search-files-' . $count, $file_chunk );
* Parse the search option to determine what kind of search we are performing and what directory to start in.
* @param string $option The search-type identifier.
private function prepare_scan_path( $option ) {
case ( 't--' === $option ):
$data['path'] = WP_CONTENT_DIR . '/themes/';
case ( strlen( $option ) > 3 && 't-' === substr( $option, 0, 2 ) ):
$data['path'] = WP_CONTENT_DIR . '/themes/' . substr( $option, 2 );
$data['slug'] = substr( $option, 2 );
case ( 'p--' === $option ):
$data['path'] = WP_CONTENT_DIR . '/plugins/';
$data['type'] = 'plugin';
case ( 'mup--' === $option ):
$data['path'] = WP_CONTENT_DIR . '/mu-plugins/';
$data['type'] = 'mu-plugin';
case ( strlen( $option ) > 3 && 'p-' === substr( $option, 0, 2 ) ):
$slug = explode( '/', substr( $option, 2 ) );
$data['path'] = WP_CONTENT_DIR . '/plugins/' . $slug[0];
$data['type'] = 'plugin';
$data['slug'] = $slug[0];
case ( 'core' === $option ):
case ( 'wp-content' === $option ):
$data['path'] = WP_CONTENT_DIR;
if ( empty( $data['path'] ) ) {
private function ajax_scan_path( $path ) {
$paths = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator( $path ),
\RecursiveIteratorIterator::SELF_FIRST
foreach ( $paths as $name => $location ) {
if ( is_dir( $location->getPathname() ) ) {
$files[] = $location->getPathname();