Function Reference: geodir_bestof_callback
Summary
Get the best of widget content using ajax.
Return Values
- (string)
- Html content.
Change Log
Since: 1.3.9
1.5.1 Added filter to view all link.
Filters
‘geodir_bestof_widget_view_all_link’ [Line: 665]
Source File
geodir_bestof_callback() is located in geodirectory-widgets/geodirectory_bestof_widget.php [Line: 630]
Source Code
function geodir_bestof_callback() { check_ajax_referer('geodir-bestof-nonce', 'geodir_bestof_nonce'); //set variables $post_type = strip_tags(esc_sql($_POST['post_type'])); $post_limit = strip_tags(esc_sql($_POST['post_limit'])); $character_count = strip_tags(esc_sql($_POST['char_count'])); $taxonomy = strip_tags(esc_sql($_POST['taxonomy'])); $add_location_filter = strip_tags(esc_sql($_POST['add_location_filter'])); $term_id = strip_tags(esc_sql($_POST['term_id'])); $excerpt_type = strip_tags(esc_sql($_POST['excerpt_type'])); $query_args = array( 'posts_per_page' => $post_limit, 'is_geodir_loop' => true, 'post_type' => $post_type, 'gd_location' => $add_location_filter ? true : false, 'order_by' => 'high_review' ); if ($character_count >= 0) { $query_args['excerpt_length'] = $character_count; } $tax_query = array( 'taxonomy' => $taxonomy, 'field' => 'id', 'terms' => $term_id ); $query_args['tax_query'] = array($tax_query); if ($term_id && $taxonomy) { $term = get_term_by('id', $term_id, $taxonomy); $view_all_link = add_query_arg(array('sort_by' => 'rating_count_desc'), get_term_link($term)); /** This filter is documented in geodirectory-widgets/geodirectory_bestof_widget.php */ $view_all_link = apply_filters('geodir_bestof_widget_view_all_link', $view_all_link, $post_type, $term); echo '' . wp_sprintf(__('Best of %s', 'geodirectory'), $term->name) . '' . __("View all", 'geodirectory') . '
'; } if ($excerpt_type == 'show-reviews') { add_filter('get_the_excerpt', 'best_of_show_review_in_excerpt'); } geodir_bestof_places_by_term($query_args); if ($excerpt_type == 'show-reviews') { remove_filter('get_the_excerpt', 'best_of_show_review_in_excerpt'); } gd_die(); }