本文整理汇总了PHP中WC_Payment_Gateway::has_fields方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Payment_Gateway::has_fields方法的具体用法?PHP WC_Payment_Gateway::has_fields怎么用?PHP WC_Payment_Gateway::has_fields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Payment_Gateway
的用法示例。
在下文中一共展示了WC_Payment_Gateway::has_fields方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sanitize_payment_fields
/**
* Sanitize payment fields
* - some gateways include js in their payment fields
*
* @param WC_Payment_Gateway $gateway
* @return mixed|string
*/
protected function sanitize_payment_fields(WC_Payment_Gateway $gateway)
{
$html = '';
if ($gateway->has_fields() || $gateway->get_description()) {
ob_start();
$gateway->payment_fields();
$html = ob_get_contents();
ob_end_clean();
// remove script tags
$html = $this->removeDomNodes($html, '//script');
}
return self::trim_html_string($html);
}
示例2: sanitize_payment_fields
/**
* Sanitize payment fields
* - some gateways include js in their payment fields
* @param WC_Payment_Gateway $gateway
* @return mixed|string
*/
protected function sanitize_payment_fields(WC_Payment_Gateway $gateway)
{
$html = '';
if ($gateway->has_fields() || $gateway->get_description()) {
ob_start();
$gateway->payment_fields();
$html = ob_get_contents();
ob_end_clean();
// remove any javascript
// note: DOMDocument causes more problems than it's worth
// $doc = new DOMDocument();
// $doc->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
// $script_tags = $doc->getElementsByTagName('script');
// $length = $script_tags->length;
// for ($i = 0; $i < $length; $i++) {
// $script_tags->item($i)->parentNode->removeChild($script_tags->item($i));
// }
// echo $doc->saveHTML();
// simple preg_replace
$html = preg_replace('/<script.+?<\\/script>/im', '', $html);
}
return $html;
}