Skip to content

Instantly share code, notes, and snippets.

@jmdrawneek
Last active December 5, 2017 13:40
Show Gist options
  • Save jmdrawneek/6d67281a0b7e256c9f523413bd44d280 to your computer and use it in GitHub Desktop.
Save jmdrawneek/6d67281a0b7e256c9f523413bd44d280 to your computer and use it in GitHub Desktop.
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