Skip to content

Instantly share code, notes, and snippets.

@bkeating
Created November 19, 2015 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bkeating/9d981ac0b84589daa71c to your computer and use it in GitHub Desktop.
Save bkeating/9d981ac0b84589daa71c to your computer and use it in GitHub Desktop.
"""
Examples:
update_option( "foobar" )
update_option( 'your_mom_lol' )
update_option("another_func")
update_option('some_long_name')
Regex:
update_option\(\s*('|")(.*)('|")\s*\)
"""
import fnmatch
import os
import re
# Recursively walk the plugins folder and build a lits of PHP files
file_list = []
for root, dirnames, filenames in os.walk('wp_plugins'):
for filename in fnmatch.filter(filenames, '*.php'):
file_list.append(os.path.join(root, filename))
# Search each file for matching regex pattern
regex = re.compile('update_option\(\s*\'|"(.*)\'|"')
for filename in file_list:
with open(filename) as fobj:
output = re.search(regex, fobj.read())
if output:
print filename
print output.group()
print "=============================="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment