Edit WordPress Theme File
wordpress_theme_fileRead and safely edit the ACTIVE THEME's own files on a connected WordPress site — the last resort for things baked into a theme PHP/CSS file that nothing else can reach: a Google tag hard-coded into header.php (a duplicate gtag the theme prints on every page), a wrong heading level in a template, a stray inline style. wordpress_option reaches plugin/theme SETTINGS and wordpress_snippet adds NEW PHP through WPCode, but neither can change a line the theme itself ships.
action: 'list' = the theme's source files with size and whether each is writable; 'get' (path) = one file's contents; 'edit' (path) = change it; 'restore' (path) = undo the last edit to that file. Scope is deliberately narrow and safe: only files INSIDE the active or parent theme folder, only .php/.css/.js/.html/.txt, no path escapes ('..' is refused), and only files that already exist (it never creates one). Pass path as list/get reports it — e.g. 'wp-content/themes/construction/header.php' or just 'header.php'.
edit has two modes. mode='remove_block' with contains='AW-851563016' removes every / block that contains that text — the clean way to strip a hard-coded gtag / GTM / Google Ads tag out of a theme file (find the id first with wordpress_tracking, which now detects AW- / G- / GT- ids in theme files as well). mode='replace' with find + replace makes a literal text change; count caps how many occurrences may match, and if find appears more times than that nothing is written, so you can make find more specific — this is how you turn an H4 into an H2. SAFETY on every edit: the whole file is backed up first, PHP files are re-checked with php -l and the write is AUTOMATICALLY REVERTED if it would break the syntax, and restore brings the previous version back. confirm=false previews (match count and size delta) without writing; confirm=true applies. Needs Connector 0.9.0 or newer.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| find | No | ||
| mode | No | replace | |
| path | No | ||
| count | No | ||
| action | No | list | |
| confirm | No | ||
| replace | No | ||
| contains | No | ||
| site_url | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||