Skip to content

Instantly share code, notes, and snippets.

@jasperf
Last active March 6, 2026 00:58
Show Gist options
  • Select an option

  • Save jasperf/10700a900311e45c61cb476c5a8dff13 to your computer and use it in GitHub Desktop.

Select an option

Save jasperf/10700a900311e45c61cb476c5a8dff13 to your computer and use it in GitHub Desktop.
python3 - <<'EOF'
import re, os
theme_patterns = '/Users/user/code/site.com/demo/web/app/themes/elayne/patterns'
files = [
'header-standard.php',
'header-standard-with-tel-number.php',
'header-social-logo-hamburger.php',
'header-social-logo-hamburger-light.php',
'header-mobile.php',
'header-double-bar.php',
]
keys_to_remove = ['openSubmenusOnClick', 'hasClickableParents', 'hasImprovedChevrons']
for fname in files:
path = os.path.join(theme_patterns, fname)
with open(path, 'r') as f:
text = f.read()
original = text
for key in keys_to_remove:
# Remove "key":value, (trailing comma — key in middle of object)
text = re.sub(r'"' + key + r'"\s*:\s*(?:true|false),\s*', '', text)
# Remove ,"key":value (leading comma — key at end of object)
text = re.sub(r',\s*"' + key + r'"\s*:\s*(?:true|false)', '', text)
if text != original:
with open(path, 'w') as f:
f.write(text)
print(f'Updated: {fname}')
else:
print(f'No change: {fname}')
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment