Skip to content

Commit

Permalink
Orders the forms alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
omarkasem committed Feb 19, 2025
1 parent d6381d3 commit c813c7b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion includes/class-admin-views.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public function add_view_dropdown() {
return;
}

$forms = gravityview_get_forms();
$forms = gravityview_get_forms(true, false, 'title', 'ASC');
$current_form = \GV\Utils::_GET( 'gravityview_form_id' );

// If there are no forms to select, show no forms.
Expand Down
11 changes: 10 additions & 1 deletion includes/class-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,16 @@ public static function get_forms( $active = true, $trash = false, $order_by = 'i
$forms = GFAPI::get_forms( $active, $trash );
}

$forms = wp_list_sort( $forms, $order_by, $order, true );

// Handle case-insensitive title sorting with uppercase/lowercase letters
if ( 'title' === $order_by ) {
usort( $forms, function( $a, $b ) use ( $order ) {
$result = strcasecmp( $a['title'], $b['title'] );
return ( 'DESC' === $order ) ? -$result : $result;
});
} else {
$forms = wp_list_sort( $forms, $order_by, $order, true );
}

/**
* Modify the forms returned by GFAPI::get_forms().
Expand Down

0 comments on commit c813c7b

Please sign in to comment.