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

This commit is contained in:
Laurel Fulford 2019-02-08 13:15:29 -08:00
parent 9ad17a39c7
commit a194f1804e

View file

@ -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;
}