联系表格7不以包裹形式显示在Wordpress上的none div中

时间:2018-07-10 14:18:45

标签: php html wordpress

我们有一个已购买的主题,但是每次我们尝试输入联系表7时,该表单都不会显示。尝试与开发人员讨论此问题后,他说联系表单7适用于他的主题,但不愿告诉我们为什么当您将表单放入带有display:none的div包裹后,表单不会显示,在代码中,但是此div显示没有阻止它显示

花了几个小时,然后在下面的functions.php中找到了,想知道这是否是问题所在。任何帮助将不胜感激。

    /* Disable SPAN wrapper for CF7
=============================================*/




add_filter('wpcf7_form_elements', function($content) {
    $content = preg_replace('/<(span).*?class="\s*(?:.*\s)?wpcf7-form-    control-wrap(?:\s[^"]+)?\s*"[^\>]*>(.*)<\/\1>/i', '\2', $content);
    return $content;
});

add_filter('wpcf7_form_elements', function( $content ) {
  $dom = new DOMDocument();
  $dom->preserveWhiteSpace = false;
   $dom->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'),  LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);

  $xpath = new DomXPath($dom);
  $spans = $xpath->query("//span[contains(@class, 'wpcf7-form-control-    wrap')]" );

  foreach ( $spans as $span ) :
    $children = $span->firstChild;
    $span->parentNode->replaceChild( $children, $span );
  endforeach;

  return $dom->saveHTML();
});

0 个答案:

没有答案