|
@@ 532-551 (lines=20) @@
|
| 529 |
|
* @global object $wpdb WordPress Database object.
|
| 530 |
|
* @return bool|null|string Returns default sort results, when the post type is valid. Otherwise returns false.
|
| 531 |
|
*/
|
| 532 |
|
function geodir_get_posts_default_sort( $post_type ) {
|
| 533 |
|
|
| 534 |
|
global $wpdb;
|
| 535 |
|
|
| 536 |
|
if ( $post_type != '' ) {
|
| 537 |
|
|
| 538 |
|
$all_postypes = geodir_get_posttypes();
|
| 539 |
|
|
| 540 |
|
if ( ! in_array( $post_type, $all_postypes ) ) {
|
| 541 |
|
return false;
|
| 542 |
|
}
|
| 543 |
|
|
| 544 |
|
$sort_field_info = $wpdb->get_var( $wpdb->prepare( "select default_order from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type= %s and is_active=%d and is_default=%d", array(
|
| 545 |
|
$post_type,
|
| 546 |
|
1,
|
| 547 |
|
1
|
| 548 |
|
) ) );
|
| 549 |
|
|
| 550 |
|
if ( ! empty( $sort_field_info ) ) {
|
| 551 |
|
return $sort_field_info;
|
| 552 |
|
}
|
| 553 |
|
|
| 554 |
|
}
|
|
@@ 570-593 (lines=24) @@
|
| 567 |
|
* @global object $wpdb WordPress Database object.
|
| 568 |
|
* @return bool|mixed|void Returns sort results, when the post type is valid. Otherwise returns false.
|
| 569 |
|
*/
|
| 570 |
|
function geodir_get_sort_options( $post_type ) {
|
| 571 |
|
global $wpdb;
|
| 572 |
|
|
| 573 |
|
if ( $post_type != '' ) {
|
| 574 |
|
$all_postypes = geodir_get_posttypes();
|
| 575 |
|
|
| 576 |
|
if ( ! in_array( $post_type, $all_postypes ) ) {
|
| 577 |
|
return false;
|
| 578 |
|
}
|
| 579 |
|
|
| 580 |
|
$sort_field_info = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type=%s AND is_active=%d AND (sort_asc=1 || sort_desc=1 || field_type='random') AND field_type != 'address' ORDER BY sort_order ASC", array(
|
| 581 |
|
$post_type,
|
| 582 |
|
1
|
| 583 |
|
) ) );
|
| 584 |
|
|
| 585 |
|
/**
|
| 586 |
|
* Filter post sort options.
|
| 587 |
|
*
|
| 588 |
|
* @since 1.0.0
|
| 589 |
|
*
|
| 590 |
|
* @param array $sort_field_info Unfiltered sort field array.
|
| 591 |
|
* @param string $post_type Post type.
|
| 592 |
|
*/
|
| 593 |
|
return apply_filters( 'geodir_get_sort_options', $sort_field_info, $post_type );
|
| 594 |
|
}
|
| 595 |
|
|
| 596 |
|
}
|