Created
July 29, 2016 09:50
-
-
Save khaledsaikat/b8be09b7f837fff7f0e0491d5827ef0f to your computer and use it in GitHub Desktop.
Replace label and input order
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
add_filter('user_meta_field_display', function ($html) { | |
// Get label html | |
preg_match("/<label.*>.*<\/label>/", $html, $matches); | |
$label = $matches[0]; | |
// Get input html | |
preg_match("/<input.*\/>/", $html, $matches); | |
$input = $matches[0]; | |
// Create new html | |
$newHtml = "<div>{$input}{$label}</div>"; | |
// Replace with pattern | |
$html = preg_replace("/<label.*>.*<\/label><input.*\/>/", $newHtml, $html); | |
return $html; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment