Created
September 25, 2013 14:44
-
-
Save mdamien/6700684 to your computer and use it in GitHub Desktop.
Parse a wordpress shortcode into a PHP array
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
function get_atts_from_shortcode_with_a_good_old_regex($content) { | |
$regexp = '/(.?)\[(shop)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)/s'; | |
$m = array(); | |
preg_match($regexp, $content, $m); | |
$arr = array('content' => $m[5]); | |
$arr = array_merge(shortcode_parse_atts($m[3]),$arr); | |
return $arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment