Skip to content

Commit

Permalink
Issue #839: bug fix + code improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
ThierryA committed Jan 15, 2018
1 parent 975e3d1 commit dba75ca
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions bin/add-test-widgets-to-sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ function amp_menu() {
$menus = wp_get_nav_menus();
$minimum_count = 4;
foreach ( $menus as $menu ) {
if ( $menu->count > $minimum_count ) {
if ( $menu->count >= $minimum_count ) {
return $menu->term_id;
}
}
Expand All @@ -330,15 +330,14 @@ function amp_menu() {
*/
function amp_widget_already_in_sidebar( $widget, $sidebar ) {
$sidebars = wp_get_sidebars_widgets();
$widgets_in_sidebar = $sidebars[ $sidebar ];
if ( empty( $widgets_in_sidebar ) ) {
if ( empty( $sidebars[ $sidebar ] ) ) {
return false;
}

$id_base = $widget['widget'];
$all_widget_data = get_option( 'widget_' . $id_base, array() );

foreach ( $widgets_in_sidebar as $possible_widget ) {
foreach ( $sidebars[ $sidebar ] as $possible_widget ) {
if ( false !== strpos( $possible_widget, $id_base ) ) {
/*
* If there aren't any settings for the widget, any instance of it is enough.
Expand Down

0 comments on commit dba75ca

Please sign in to comment.