@@ -68,6 +68,8 @@ public static function getPagination($callback_data, $current_page, $max_pages,
68
68
foreach ($ labels as $ key => &$ label ) {
69
69
if (strpos ($ label , '%d ' ) !== false ) {
70
70
$ label = sprintf ($ label , $ pages [$ key ]);
71
+ } elseif ($ label === '' ) {
72
+ $ label = null ;
71
73
}
72
74
}
73
75
unset($ label );
@@ -79,19 +81,21 @@ public static function getPagination($callback_data, $current_page, $max_pages,
79
81
80
82
$ buttons = [];
81
83
82
- if ($ current_page > 1 ) {
84
+ if ($ current_page > 1 && $ labels [ ' first ' ] !== null ) {
83
85
$ buttons [] = new InlineKeyboardButton (['text ' => $ labels ['first ' ], 'callback_data ' => $ callbacks_data ['first ' ]]);
84
86
}
85
- if ($ current_page > 2 ) {
87
+ if ($ current_page > 2 && $ labels [ ' previous ' ] !== null ) {
86
88
$ buttons [] = new InlineKeyboardButton (['text ' => $ labels ['previous ' ], 'callback_data ' => $ callbacks_data ['previous ' ]]);
87
89
}
88
90
89
- $ buttons [] = new InlineKeyboardButton (['text ' => $ labels ['current ' ], 'callback_data ' => $ callbacks_data ['current ' ]]);
91
+ if ($ labels ['current ' ] !== null ) {
92
+ $ buttons [] = new InlineKeyboardButton (['text ' => $ labels ['current ' ], 'callback_data ' => $ callbacks_data ['current ' ]]);
93
+ }
90
94
91
- if ($ current_page < $ max_pages - 1 ) {
95
+ if ($ current_page < $ max_pages - 1 && $ labels [ ' next ' ] !== null ) {
92
96
$ buttons [] = new InlineKeyboardButton (['text ' => $ labels ['next ' ], 'callback_data ' => $ callbacks_data ['next ' ]]);
93
97
}
94
- if ($ current_page < $ max_pages ) {
98
+ if ($ current_page < $ max_pages && $ labels [ ' last ' ] !== null ) {
95
99
$ buttons [] = new InlineKeyboardButton (['text ' => $ labels ['last ' ], 'callback_data ' => $ callbacks_data ['last ' ]]);
96
100
}
97
101
0 commit comments