浏览代码

Dyad 2: Update how widgets are counted, to exclude the non visible ones (Cookies and Mailchimp). Fixes #287.

Laurel Fulford 6 年之前
父节点
当前提交
a194f1804e
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      dyad-2/functions.php

+ 7 - 1
dyad-2/functions.php

@@ -191,7 +191,13 @@ function dyad_2_count_widgets( $id ) {
 	$sidebars_widgets = wp_get_sidebars_widgets();
 
 	if ( array_key_exists( $id, $sidebars_widgets ) ) {
-		$count = ( int ) count( ( array ) $sidebars_widgets[ $id ] );
+
+		foreach ( ( array ) $sidebars_widgets[ $id ] as $value ) {
+			// Don't count the Cookies or Mailchimp widgets, since they're not visible in the widget area.
+			if ( strpos( $value, 'eu_cookie_law_widget' ) === 0 || strpos( $value, 'widget_mailchimp_subscriber_popup' ) === 0 ) {
+				$count++;
+			}
+		}
 	}
 	return $count;
 }