forked from Michel2/wp-jquery-datatable
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:
@@ -92,6 +92,7 @@ Is this plugin prepared for multisites? Yes.
|
|||||||
* Removed some unnecessary <br> tags.
|
* Removed some unnecessary <br> tags.
|
||||||
* Removed the extra Select option from the page lenght menu.
|
* 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 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 =
|
= 4.1.0 =
|
||||||
* Compatibility with WordPress version 6.7.1
|
* Compatibility with WordPress version 6.7.1
|
||||||
|
|||||||
@@ -230,6 +230,25 @@ function wp_jdt_shortcode($atts)
|
|||||||
$table_searching = ($atts['searching'] === 'true') ? 'true' : 'false';
|
$table_searching = ($atts['searching'] === 'true') ? 'true' : 'false';
|
||||||
|
|
||||||
$table_length_menu = array(10, 25, 50, 100, -1);
|
$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
|
// css and js
|
||||||
wp_enqueue_style('jdt-style-data-tables');
|
wp_enqueue_style('jdt-style-data-tables');
|
||||||
|
|||||||
Reference in New Issue
Block a user