Last active
December 5, 2017 13:40
-
-
Save jmdrawneek/6d67281a0b7e256c9f523413bd44d280 to your computer and use it in GitHub Desktop.
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 move_element( $markup, $selector, $direction, $levels ) { | |
// Load it | |
$html = new DOMDocument(); | |
$html->loadHTML( $markup ); | |
$finder = new DomXPath($html); | |
$firstItem = $finder->query("//*[contains(@class, 'hero-quiz__user-detail__label gfield_label')]")->item(0); | |
$node = $finder->query("//*[contains(@class, '" . $selector . "')]")->item(0); | |
$copy = $node->cloneNode(true); | |
$ul = $finder->query("//input")->item(0); | |
$ul->insertBefore($copy, $firstItem); | |
// Show it | |
return $html->saveHTML(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment