| @@ -311,13 +311,19 @@ | ||
| 311 | 311 | |
| 312 | 312 | foreach ( $options as $value ) { |
| 313 | 313 | if ( is_array( $value ) && ! empty( $value ) ) { |
| 314 | 314 | |
| 315 | - // Restricted for User Roles | |
| 315 | + // Allowed User Roles. An empty list means the widget is not limited to | |
| 316 | + // particular roles, so it shows for everyone — that is the field's | |
| 317 | + // default, and without this check a newly created widget would never | |
| 318 | + // appear. Anything else is treated as an allow list. | |
| 319 | + // | |
| 320 | + // `continue`, not `return`: skipping one widget must not stop the rest | |
| 321 | + // of the list from being registered. | |
| 316 | 322 | $restricted_for_dash_widget = ! empty( $value['user_roles'] ) ? $value['user_roles'] : ''; |
| 317 | 323 | |
| 318 | - if ( ! Utils::restricted_for( $restricted_for_dash_widget ) ) { | |
| 319 | - return; | |
| 324 | + if ( ! empty( $restricted_for_dash_widget ) && ! Utils::restricted_for( $restricted_for_dash_widget ) ) { | |
| 325 | + continue; | |
| 320 | 326 | } |
| 321 | 327 | |
| 322 | 328 | $dash_widget_title = isset( $value['title'] ) ? $value['title'] : ''; |
| 323 | 329 | $dash_widget_position = isset( $value['widget_pos'] ) ? $value['widget_pos'] : 'normal'; |