What it does
Finding where a function is defined, which plugin loads a certain script, or whether a string someone warned you about appears in your plugins or theme usually takes FTP or SSH and a command line. File Scan Code Search runs that search inside WordPress, on one admin screen under Tools → File Scan.
You choose where to look: the whole WordPress folder, wp-content, all plugins, one plugin or theme, the uploads folder, or a folder you type in. You choose which file types to read (PHP, JavaScript and CSS by default) and whether to search for plain text or a regular expression. Each match comes back with its file path, its line number and the line itself, with the match highlighted, and the list downloads as CSV or JSON.
It is a search tool, not a malware scanner: it has no list of known threats and does not judge what it finds. You decide what to look for.
It never writes to a file or to the database, and folders outside WordPress stay locked until you unlock them in wp-config.php.
- Read-only
- Plain text or regex
- CSV · JSON export
- Admins only
- Nothing stored
Install
- Download the ZIP.
- In WordPress go to Plugins → Add Plugin (called Add New Plugin or Add New in older versions), click Upload Plugin, choose the ZIP, click Install Now, then Activate Plugin.
- Open Tools → File Scan. The Settings link under the plugin's name on the Plugins screen opens the same screen.
No setup is needed before the first search: the plugin saves no settings of its own. Only users with the manage_options capability (Administrators by default) can open the screen.
A wordpress.org listing is planned; for now the plugin installs from the ZIP on this page.
How to use
Everything happens on one screen, Tools → File Scan, with three tabs: Search for the search itself,
Advanced with the wp-config.php line that unlocks folders outside WordPress (in English, Arabic, French and Spanish),
and Help with short tips. There is no shortcode, block or widget, and nothing is added to the public site.
- On the Search tab, type what you are looking for in Search Text, for example a function name or
base64_decode. - Pick a Directory. The narrower the folder, the faster and more complete the search, so a single Plugin: … or Theme: … entry beats Plugins or WordPress root.
- Check File Extensions (
php,js,cssby default). Add others such ashtml,txtorjson, orhtaccessto read.htaccessfiles. - Leave Max depth at 0 to search every subfolder, or enter a number N to search the chosen folder and only N levels of subfolders below it: 1 adds the folders directly inside it, 2 also the folders inside those, and so on (see Settings). Tick Case sensitive or Regex if you need them, then click Search.
- Wait for the answer. The whole search runs as one request and can take up to about 20 seconds (60 for WordPress root and Site home); the bar on screen does not measure progress. Matches appear in a table with File Path, Line and Snippet. If there are none, a browser pop-up says “No matches found”.
- Click CSV or JSON above the table to download the results. Nothing is kept: leaving the page clears them.
The exported snippet is the highlighted HTML, so it contains
<mark>tags and HTML entities such as".
Directory entrywhat it searches
- WordPress root · Site home
- The folder WordPress is installed in, and your site's home folder. They are the same folder unless WordPress sits in a subfolder. Both get higher limits (see Settings).
- wp-admin · wp-includes
- The WordPress core folders.
- wp-content · Plugins · Must-use plugins · Themes · Uploads · Languages
- The usual content folders.
- Plugin: … · Theme: …
- One entry per plugin folder and per theme folder, for the first 50 of each in alphabetical order. A plugin made of a single file gets no entry of its own; Plugins covers it.
- Active theme · Parent theme
- The theme your site uses and, for a child theme, its parent.
- (advanced) entries
- The folder above WordPress (Account root), up to five folders allowed by the server's
open_basedir, the system temp folder, the server root and, where they exist,/home,/var/www,/varand/tmp. They are listed but greyed out until advanced mode is on. - Custom path (below)
- Opens a box for a folder you type. See Settings for what it accepts.
Each entry other than Custom path shows its full server path, most entries appear only when their folder exists, and a search includes all subfolders of the chosen folder (or as many levels as Max depth allows), except folders that are symbolic links and folders PHP cannot open.
Settings
The plugin saves no settings. Each search is set on the form, one optional line in wp-config.php unlocks folders outside WordPress, and the limits are fixed in the code.
Settingdefault
- Search Text
- Required, no default. Plain text, or a pattern when Regex is ticked. It is cleaned like any form input before the search:
HTML tags are removed, so a search containing < (such as <?php or <script) will not find it in your code; tabs and repeated spaces become one space;
and %-codes such as
%20are removed. - Directory
- WordPress root. Any enabled entry from the list above, or Custom path (below).
- Custom path
- Empty. A folder that exists inside your site's folder; a file path searches the folder the file is in. Without advanced mode, your site's top folder itself (or a file sitting directly in it) is refused, so use WordPress root or Site home for it. Custom paths get the standard limits.
- File Extensions
php,js,css, also used when the box is left empty. A comma-separated list without dots, in any case. A file is read only when its name ends in one of them:min.jsworks,htaccessfinds.htaccessfiles, and files without an extension cannot be searched.- Max depth
- 0, which searches every subfolder. A number N from 1 to 100 searches the chosen folder and N levels of subfolders below it: 1 adds the folders directly inside it, 2 also the folders inside those, and so on. Files deeper down are not read, so a lower number makes a search in a deep folder faster.
- Case sensitive
- Off. When ticked, upper and lower case must match exactly, in plain text and in regex mode.
- Regex
- Off. When ticked, Search Text is a PHP (PCRE) regular expression without delimiters, for example
eval\s*\(. Type forward slashes as they are; the plugin escapes them. An invalid pattern stops the search with “Invalid regex pattern”. Each line is tested on its own, so a pattern cannot span lines. - Advanced mode
- Off. Add
define( 'FSC_ALLOW_OUTSIDE_WP', true );towp-config.php, above the “stop editing” line, to enable the (advanced) entries and custom paths outside your site. Typed outside paths must still be readable folders, inside the server'sopen_basedirfolders if it sets any. Subfolders PHP cannot open are skipped; if it cannot open the chosen folder itself, the search stops with a message saying the directory cannot be read. The plugin never writes this line itself; delete it to lock those folders again. - Limits (fixed)
- 800 matches per search. The search also stops after 12,000 files and folders or 20 seconds, whichever comes first; WordPress root and Site home allow 60,000 and 60 seconds. Files over 1 MB are skipped. No option changes these, and the screen does not say when a limit cut a search short.
How it works
- When you open the screen, the server builds the list of locations it can find: the WordPress folders, up to 50 plugin folders and 50 theme folders, and the (advanced) server folders, which stay disabled until you opt in.
- Clicking Search sends one request to WordPress (
admin-ajax.php) with your text, the ID of the chosen location, your options and a security token. - The server checks the request (see How it stays safe) and takes the folder path from its own list, not from the browser. A custom path is validated first.
- It walks through the folder and its subfolders, all of them or as many levels as Max depth allows, without entering folders that are symbolic links. It reads each file whose name ends in one of your extensions and is 1 MB or smaller, and tests it line by line. Folders and files PHP cannot open are skipped, and if it cannot open the chosen folder itself, the search stops with “This directory cannot be read. Check that it exists and that PHP has permission to read it.”
- At 800 matches, 12,000 files and folders, or 20 seconds (60,000 and 60 seconds for WordPress root and Site home), it stops and returns what it has found so far.
- Each match comes back with its path (relative to the WordPress folder when it is inside it), its line number and the line, escaped for display with the match highlighted.
The highlight is added after escaping, so a match that contains a quote,
&,<or>is listed but not highlighted. The table and the CSV or JSON files are built in your browser, and nothing is saved on the server.
How it stays safe
- Admin only. The plugin loads its search code only in wp-admin, and both the screen and every search require the
manage_optionscapability. There is no endpoint for visitors who are not logged in. - Every search is verified. Each request carries a WordPress nonce that is checked before anything else, and every value from the browser is unslashed and sanitized before use.
- The server chooses the folder. The browser sends only the ID of a location, and the server takes the path from its own list.
A typed path is resolved to its real location first, so
../cannot climb out, and it must sit inside your site's folder. - Outside WordPress is off by default. Server folders are listed greyed out and refused, and custom paths outside your site are rejected,
until you add the
wp-config.phpline. Even then, a typed outside path must be a readable folder within the server'sopen_basedirlimits, if it sets any. - Read-only. Files are only read. The plugin has no code that writes, renames or deletes a file, and it stores nothing in the database.
- Safe output. Each line is HTML-escaped before the match is highlighted, and file paths are inserted as plain text, so code found in a file is displayed, never run in your browser.
- Hard limits. Caps on matches, files and time, and skipping files over 1 MB, keep a search from running without end.
- Know what it can show. Anyone who can open the screen can display any line of any file the search reaches. The WordPress root entry usually includes
wp-config.php, with your database password and security keys, so keep administrator accounts to people you trust. On multisite, that includes the administrators of every site where the plugin is active.
For developers
file_scan_code_search_filter: receives the location list, keyed by ID, where each entry isdetected_locations ['label' => string, 'path' => string, 'enabled' => bool]. It runs when the screen is built and again when a search looks up its folder, so an entry you add or enable here can be searched. Use lowercase IDs (letters, numbers,_and-), because the ID sent back by the browser goes throughsanitize_key(). An entry enabled here is searchable even withoutFSC_ALLOW_OUTSIDE_WP, and it gets the standard limits.- Searches go to
admin-ajax.phpwith the actionfsc_search_code, for logged-in users only, checked against the nonce actionfsc_admin_nonce. A search answers withwp_send_json_success()and a list of{file, line, snippet}, orwp_send_json_error()and a message; a failed nonce check returns-1with HTTP 403. - The CSS and the jQuery-based script load only on the plugin's own screen (
tools_page_file-scan-code-search). - Storage: none. No options, transients, custom tables, meta, cron events or files.
uninstall.phphas nothing to remove, so deleting the plugin leaves nothing behind apart from thewp-config.phpline, if you added it. - Translatable strings use the
file-scan-code-searchtext domain. The browser pop-ups (“No matches found”, “AJAX error”) are hard-coded in English.
Questions
Does it change or delete any files?
No. It opens files only to read them. It has no code that writes, renames or deletes a file, and it writes nothing to the database.
Is it a malware scanner?
No. It has no list of known malware and does not rate what it finds. During a cleanup it helps you look for a string you were given,
such as a suspicious domain or a function like base64_decode, plugin by plugin or across a folder, and shows the exact files and lines.
Deciding whether a match is harmful is up to you.
Why does it say “No matches found” when I know the text is there?
Usually one of these: the file's extension is not in File Extensions, the file is larger than 1 MB, the text runs over two lines, the file sits deeper than Max depth allows or under a folder that is a symbolic link or that PHP cannot open, the input cleaning changed your search text (see the next question and Settings), or the folder is so big that the search hit one of its limits (see Settings) before it reached the file. The screen does not say when a limit was hit, so pick a narrower Directory, such as one plugin, and search again.
Why does a search for <?php or <script find nothing?
The search text is cleaned like any form input: HTML tags are removed and a lone < is turned into the code <, so the search no longer contains the bracket.
Search without it (script src), or tick Regex and write the bracket as \x3c: \x3cscript finds <script.
Does it slow down my site?
Not for visitors: outside wp-admin it hooks into nothing and loads no scripts or styles. A search keeps one PHP process busy until it ends, up to about 20 seconds, or 60 for WordPress root and Site home. Some servers stop long requests sooner, which shows as “AJAX error”; if that happens, search a smaller folder.