Function Reference: gdsc_validate_sort_choice
Summary
Validate & get the correct sorting option.
Global Values
- $plugin_prefix
- (string) (required) Geodirectory plugin table prefix.
- Default: None
Parameters
- $sort_choice
- (string) (required) Listing sort option.
- Default: None
- $post_type
- (string) (required) Post type to validate custom field sort.
- Default: None
Return Values
- (string)
- Listing sort.
Change Log
Since: 1.0.0
1.6.18 Allow order by custom field in widget listings results sorting.
Source File
gdsc_validate_sort_choice() is located in geodirectory-functions/shortcode_functions.php [Line: 473]
Source Code
function gdsc_validate_sort_choice($sort_choice, $post_type = '') { global $plugin_prefix; $sorts = array( 'az', 'latest', 'featured', 'high_review', 'high_rating', 'random', ); if (in_array($sort_choice, $sorts)) { return $sort_choice; } if (!empty($post_type)) { $table = $plugin_prefix . $post_type . '_detail'; if (!geodir_prepare_custom_sorting($sort_choice, $table)) { $sort_choice = ''; } } if (empty($post_type) || empty($sort_choice)) { $sort_choice = 'latest'; } return $sort_choice; }