$menu_item ) { // We are checking at index 5 because it is the position of the menu-dashboard slug and it is not affected by translation. if ( isset( $menu_item[5] ) && 'menu-dashboard' === $menu_item[5] ) { $dashboard_priority = (float) $position; break; } } // If we couldn't find the dashboard priority, set it to 2.0. if ( null === $dashboard_priority ) { $dashboard_priority = 2.0; } // Check if the Astra priority is numeric. // If not, set it to 2.0. if ( ! is_numeric( $astra_priority ) ) { $astra_priority = 2.0; } else { $astra_priority = (float) $astra_priority; } // If the Astra priority is already less than the dashboard priority, return it. if ( $astra_priority < $dashboard_priority ) { return $astra_priority; } // Increase the Astra priority by 0.1 so that it is placed right after the Dashboard. $astra_priority = $dashboard_priority + 0.1; $existing_priorities = array_keys( $menu ); // If the computed astra_priority already exists, just default to 2.0. // We are converting the existing priorities to string to make sure the type is always same. if ( in_array( Helper::get_string_value( $astra_priority ), array_map( 'strval', $existing_priorities ), true ) ) { $astra_priority = 2.0; } return $astra_priority; } }