Created
November 19, 2015 00:38
-
-
Save bkeating/9d981ac0b84589daa71c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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