Skip to content

Commit

Permalink
Merge pull request #2657 from kprajapatii/master
Browse files Browse the repository at this point in the history
2.3.73
  • Loading branch information
kprajapatii authored Aug 15, 2024
2 parents a8405da + 14c1305 commit 6bfb451
Show file tree
Hide file tree
Showing 8 changed files with 808 additions and 146 deletions.
4 changes: 2 additions & 2 deletions geodirectory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Plugin Name: GeoDirectory
* Plugin URI: https://wpgeodirectory.com/
* Description: GeoDirectory - Business Directory Plugin for WordPress.
* Version: 2.3.72
* Version: 2.3.73
* Author: AyeCode - WP Business Directory Plugins
* Author URI: https://wpgeodirectory.com
* Text Domain: geodirectory
Expand All @@ -34,7 +34,7 @@ final class GeoDirectory {
*
* @var string
*/
public $version = '2.3.72';
public $version = '2.3.73';

/**
* GeoDirectory instance.
Expand Down
59 changes: 59 additions & 0 deletions includes/class-geodir-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public function __construct() {
add_filter( 'split_the_query', array( $this, 'split_the_query' ), 100, 2 );
add_action( 'wp', array( $this, 'set_wp_the_query' ), 1, 1 );

add_filter( 'geodir_main_query_posts_where', array( $this, 'main_query_posts_where' ), 10, 3 );
add_filter( 'geodir_posts_order_by_sort', array( $this, 'posts_order_by_sort' ), 10, 4 );

$this->init_query_vars();
}

Expand Down Expand Up @@ -1710,4 +1713,60 @@ public function set_wp_the_query( $the_wp ) {
}
}
}

/**
* Set GD posts main query post where clause.
*
* @since 2.3.73
*
* @global object $wpdb WordPress database object.
*
* @param string $where Query posts where clause.
* @param object $query WP_Query object.
* @param string $geodir_post_type Current post type.
* @return string Query posts where clause.
*/
public function main_query_posts_where( $where, $query, $geodir_post_type ) {
global $wpdb;

// A-Z Search value.
$value = geodir_az_search_value();

if ( $value != '' ) {
$where .= $wpdb->prepare(" AND `{$wpdb->posts}`.`post_title` LIKE %s ", $wpdb->esc_like( $value ) . '%' );
}

return $where;
}

/**
* Set GD posts main query post orderby clause.
*
* @since 2.3.73
*
* @global object $wpdb WordPress database object.
*
* @param string $orderby Query posts orderby clause.
* @param string $sort_by Current sort by parameter.
* @param string $table Details database table.
* @param object $query WP_Query object.
* @return string Query posts orderby clause.
*/
public function posts_order_by_sort( $orderby, $sort_by, $table, $query ) {
global $wpdb;

$value = geodir_az_search_value();

if ( $value != '' ) {
$_orderby = "`{$wpdb->posts}`.`post_title` ASC";

if ( trim( $orderby ) != "" ) {
$_orderby .= "," . $orderby;
}

$orderby = $_orderby;
}

return $orderby;
}
}
1 change: 1 addition & 0 deletions includes/core-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ function goedir_register_widgets() {
function geodir_get_widgets(){

$widgets = array(
'GeoDir_Widget_AZ_Search',
'GeoDir_Widget_Search',
'GeoDir_Widget_Best_Of',
'GeoDir_Widget_Categories',
Expand Down
75 changes: 71 additions & 4 deletions includes/template-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,16 @@ function geodir_loop_paging( $args = array() ) {
$end_no = min( $paged * $posts_per_page, $numposts );
if ( $listing_type_name ) {
$listing_type_name = __( $listing_type_name, 'geodirectory' );
$pegination_desc = wp_sprintf( __( 'Showing %1$s %2$d-%3$d of %4$d', 'geodirectory' ), $listing_type_name, $start_no, $end_no, $numposts );
$pagination_desc = wp_sprintf( __( 'Showing %1$s %2$d-%3$d of %4$d', 'geodirectory' ), $listing_type_name, $start_no, $end_no, $numposts );
} else {
$pegination_desc = wp_sprintf( __( 'Showing listings %1$d-%2$d of %3$d', 'geodirectory' ), $start_no, $end_no, $numposts );
$pagination_desc = wp_sprintf( __( 'Showing listings %1$d-%2$d of %3$d', 'geodirectory' ), $start_no, $end_no, $numposts );
}
$bs_class = $design_style ? 'text-muted pb-2' : '';

if( ! empty( $args['advanced_pagination_class'] ) ) {
$bs_class = esc_attr( $args['advanced_pagination_class'] );
}
$pagination_info = '<div class="gd-pagination-details ' . $bs_class . '">' . $pegination_desc . '</div>';
$pagination_info = '<div class="gd-pagination-details ' . $bs_class . '">' . $pagination_desc . '</div>';

/**
* Adds an extra pagination info above/under pagination.
Expand Down Expand Up @@ -1348,4 +1348,71 @@ function geodir_filter_textarea_output( $text, $context = '', $args = array() )
}

return apply_filters( 'geodir_filtered_textarea_output', $text, $orig_text, $context, $args );
}
}

/**
* Get A-Z search options.
*
* @since 2.3.73
*
* @param string $post_type Current post type. Default empty.
* @return array A-Z options array.
*/
function geodir_az_search_options( $post_type = '' ) {
$range = range( 'A', 'Z' );

$options = array();

foreach ( $range as $char ) {
$options[] = $char;
}

/**
* Filter A-Z search options.
*
* @since 2.3.73
*
* @param array $options A-Z options array.
* @param string $post_type Current post type. Default empty.
*/
return apply_filters( 'geodir_az_search_options', $options, $post_type );
}

/**
* Get A-Z search hidden input.
*
* @since 2.3.73
*
* @param array $args Input args.
*/
function geodir_az_search_input( $args ) {
if ( geodir_is_page( 'search' ) ) {
$options = geodir_az_search_options();

$value = ! empty( $_REQUEST['saz'] ) && in_array( $_REQUEST['saz'], $options ) ? sanitize_text_field( $_REQUEST['saz'] ) : '';

echo '<input type="hidden" name="saz" value="' . esc_attr( $value ) . '">';
}
}
add_action( 'geodir_before_search_form', 'geodir_az_search_input', 10, 1 );

/**
* Get A-Z searched value.
*
* @since 2.3.73
*
* @return string Searched character.
*/
function geodir_az_search_value() {
$value = '';

if ( isset( $_REQUEST['saz'] ) && isset( $_REQUEST['geodir_search'] ) && geodir_is_page( 'search' ) ) {
$_value = sanitize_text_field( $_REQUEST['saz'] );

if ( in_array( $_value, geodir_az_search_options() ) ) {
$value = $_value;
}
}

return $value;
}
Loading

0 comments on commit 6bfb451

Please sign in to comment.