Added the choosen page lenght as an option to the dropdown if it's not one of the default options

This commit is contained in:
2026-07-21 23:01:50 +02:00
parent 3f85ed6f74
commit dbe5b03e9e
2 changed files with 20 additions and 0 deletions
+1
View File
@@ -92,6 +92,7 @@ Is this plugin prepared for multisites? Yes.
* Removed some unnecessary <br> tags.
* Removed the extra Select option from the page lenght menu.
* Added the default page lenghts and the option for All in the page lenght dropdown.
* Added the choosen page lenght as an option to the dropdown if it's not one of the default options.
= 4.1.0 =
* Compatibility with WordPress version 6.7.1
+19
View File
@@ -230,6 +230,25 @@ function wp_jdt_shortcode($atts)
$table_searching = ($atts['searching'] === 'true') ? 'true' : 'false';
$table_length_menu = array(10, 25, 50, 100, -1);
if (!in_array($table_page_length, $table_length_menu)) {
// Add the missing page length option to the array
$table_length_menu[] = (int)$table_page_length;
// Temporarily remove -1 ("All") if present to preserve its position at the end
$has_all = false;
if (($key = array_search(-1, $table_length_menu)) !== false) {
unset($table_length_menu[$key]);
$has_all = true;
}
// Sort the remaining numeric options in ascending order
sort($table_length_menu);
// Append -1 back to the end of the array
if ($has_all) {
$table_length_menu[] = -1;
}
}
// css and js
wp_enqueue_style('jdt-style-data-tables');