Skip to content

Commit

Permalink
Removed deprecated checkbox filter for terms.php
Browse files Browse the repository at this point in the history
  • Loading branch information
crftwrk committed Mar 19, 2024
1 parent f615aec commit c19e90f
Showing 1 changed file with 0 additions and 60 deletions.
60 changes: 0 additions & 60 deletions woocommerce/inc/wc-deprecated.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,63 +11,3 @@
// Exit if accessed directly
defined('ABSPATH') || exit;


/**
* Remove this when deleting terms.php
* Correct hooked checkboxes in checkout
* Get the corrected terms for Woocommerce.
*
* @param string $html The original terms.
*
* @return string The corrected terms.
*/
function bootscore_wc_get_corrected_terms($html) {
$doc = new DOMDocument();
if (!empty($html) && $doc->loadHtml($html)) {
$documentElement = $doc->documentElement; // Won't find the right child-notes without that line. ads html and body tag as a wrapper
$somethingWasCorrected = false;
foreach ($documentElement->childNodes[0]->childNodes as $mainNode) {
if ($mainNode->childNodes->length && strpos($mainNode->getAttribute("class"), "form-row") !== false) {
if (strpos($mainNode->getAttribute("class"), "required") !== false) {
$mainNode->setAttribute("class", "form-row validate-required"); // You could try to keep the original class and only add the string, but I think that could ruin the design
} else {
$mainNode->setAttribute("class", "form-row woocommerce-validated");
}
$nodesLabel = $mainNode->getElementsByTagName("label");
if ($nodesLabel->length) {
$nodesLabel[0]->setAttribute("class", "woocommerce-form__label woocommerce-form__label-for-checkbox checkbox form-check display-inline-block d-inline-block");
}
$nodesInput = $mainNode->getElementsByTagName("input");
if ($nodesInput->length) {
$nodesInput[0]->setAttribute("class", "woocommerce-form__input woocommerce-form__input-checkbox input-checkbox form-check-input");
}
$somethingWasCorrected = true;
}
}
if ($somethingWasCorrected) {
return $doc->saveHTML();
} else {
return $html;
}
} else {
//error maybe return $html?
}
}


/**
* Remove this when deleting terms.php
* Capture the output of a hook.
*
* @param string $hookName The name of the hook to capture.
*
* @return string The output of the hook.
*/
function bootscore_wc_capture_hook_output($hookName) {
ob_start();
do_action($hookName);
$hookContent = ob_get_contents();
ob_end_clean();

return $hookContent;
}

0 comments on commit c19e90f

Please sign in to comment.