Created
August 3, 2012 04:22
-
-
Save thenbrent/3244346 to your computer and use it in GitHub Desktop.
Regex to replace *_user_meta() API function calls with *_user_option() API function calls (to improve WordPress Network Compatability)
This file contains 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
# For get_user_meta: replace the function name, argument order & make sure no default value (3rd parameter) is passed to the get_user_option function | |
# FIND: | |
get_user_meta\(\s?(.*?),\s?([^,\)\s]*)\s?(,(.*?))?\) | |
# REPLACE: | |
get_user_option( $2, $1 ) | |
# For update_user_meta: replace the function name & don't carry over the 4th $prev_value argument | |
# FIND: | |
update_user_meta\(\s?([^,\)\s]*?),\s?([^,\)\s]*),\s?([^,\)\s]*),?\s?([^\)]*?)?\) | |
# REPLACE: | |
update_user_option( $1, $2, $3 ) | |
# Bonus | |
# Code output from the regex will have standards compliant whitespace, even if the offending function did not. | |
# --- | |
# Reference: http://wordpress.stackexchange.com/questions/33456/get-user-meta-to-return-user-meta-only-for-current-blog-in-multi-site |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment