= 5.8 ) { $advgb_blocks_list = get_option( 'advgb_blocks_list' ) && !empty( get_option( 'advgb_blocks_list' ) ) ? get_option( 'advgb_blocks_list' ) : []; $advgb_blocks_user_roles = get_option( 'advgb_blocks_user_roles' ) && !empty( get_option( 'advgb_blocks_user_roles' ) ) ? get_option( 'advgb_blocks_user_roles' ) : []; $current_user = wp_get_current_user(); $current_user_role = $current_user->roles[0]; if( count( $advgb_blocks_list ) && count( $advgb_blocks_user_roles ) ) { foreach( $widget_blocks as $item ) { if( is_array( $advgb_blocks_user_roles[$current_user_role]['active_blocks'] ) && is_array($advgb_blocks_user_roles[$current_user_role]['inactive_blocks'] ) && ! in_array( $item, $advgb_blocks_user_roles[$current_user_role]['active_blocks'] ) && ! in_array( $item, $advgb_blocks_user_roles[$current_user_role]['inactive_blocks'] ) && ! empty( $current_user_role ) ) { array_push( $advgb_blocks_user_roles[$current_user_role]['active_blocks'], $item ); update_option( 'advgb_blocks_user_roles', $advgb_blocks_user_roles, false ); } } } } } } add_action( 'admin_init', 'advg_check_legacy_widget_block_init' );