Function Reference: register_geodir_neighbourhood_posts_widgets
Filters
‘geodir_template_part-listing-listview’ [Line: 419]
Source File
register_geodir_neighbourhood_posts_widgets() is located in geodir_location_manager/geodir_location_widgets.php [Line: 277]
Source Code
function register_geodir_neighbourhood_posts_widgets(){
class geodir_neighbourhood_posts extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'geodir_neighbourhood_posts', 'description' => __('GD > Popular Neighbourhood Post', GEODIRLOCATION_TEXTDOMAIN) );
parent::__construct(
'neighbourhood_posts', // Base ID
__('GD > Popular Neighbourhood Post', GEODIRLOCATION_TEXTDOMAIN), // Name
$widget_ops// Args
);
}
/**
*
* @global object $wpdb WordPress Database object.
*
* @param array $args
* @param array $instance
*/
public function widget($args, $instance)
{
extract($args, EXTR_SKIP);
echo $before_widget;
$title = empty($instance['title']) ? $instance['category_title'] : apply_filters('widget_title', $instance['title']);
$hood_post_type = empty($instance['hood_post_type']) ? 'gd_place' : apply_filters('widget_hood_post_type', $instance['hood_post_type']);
$hood_category = empty($instance['hood_category']) ? '0' : apply_filters('widget_hood_category', $instance['hood_category']);
$post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
$layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']);
$add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_layout', $instance['add_location_filter']);
$list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
$character_count = empty($instance['character_count']) ? 20 : apply_filters('widget_list_sort', $instance['character_count']);
if(empty($title) || $title == 'All' ){
$title .= ' Neighbourhood '.get_post_type_plural_label($hood_post_type);
}
global $wpdb,$post,$geodir_post_type;
if($geodir_post_type == '')
$geodir_post_type = 'gd_place';
$all_postypes = geodir_get_posttypes();
$location_id = '';
$not_in_array = array();
if(geodir_is_page('detail') || geodir_is_page('preview') || geodir_is_page('add-listing')){
if(isset($post->post_type) && $post->post_type == $hood_post_type && isset($post->post_location_id)){
$not_in_array[] = $post->ID;
$location_id = $post->post_location_id;
}
}elseif(in_array($geodir_post_type, $all_postypes) && $geodir_post_type == $hood_post_type){
if(isset($_SESSION['gd_city']) && $_SESSION['gd_city'] != ''){
$location_id = $wpdb->get_var(
$wpdb->prepare(
"SELECT location_id FROM ".POST_LOCATION_TABLE." WHERE city_slug = %s",
array($_SESSION['gd_city'])
)
);
}else{
$default_location = geodir_get_default_location();
$location_id = $default_location->location_id;
}
}
$gd_neighbourhoods = geodir_get_neighbourhoods($location_id);
if( $gd_neighbourhoods){ ?>
hood_slug;
}
}
$query_args = array(
'posts_per_page' => $post_number,
'is_geodir_loop' => true,
'post__not_in' => $not_in_array,
'gd_neighbourhood' => $hood_slug_arr,
'gd_location' => ($add_location_filter) ? true : false,
'post_type' => $hood_post_type,
'order_by' =>$list_sort,
'excerpt_length' => $character_count);
if( $hood_category != 0 || $hood_category != ''){
$category_taxonomy = geodir_get_taxonomies($hood_post_type);
$tax_query = array( 'taxonomy' => $category_taxonomy[0],
'field' => 'id',
'terms' => $hood_category);
$query_args['tax_query'] = array( $tax_query );
}
global $gridview_columns;
query_posts( $query_args );
if(strstr($layout,'gridview')){
$listing_view_exp = explode('_',$layout);
$gridview_columns = $layout;
$layout = $listing_view_exp[0];
}
$template = apply_filters( "geodir_template_part-listing-listview", geodir_plugin_path() . '/geodirectory-templates/listing-listview.php' );
include( $template );
wp_reset_query();
?>
'',
'hood_post_type' => '',
'hood_category'=>'',
'category_title'=>'',
'list_sort'=>'',
'list_order'=>'',
'post_number' => '5',
'layout'=> 'gridview_onehalf',
'add_location_filter'=>'1',
'character_count'=>'20'
)
);
$title = strip_tags($instance['title']);
$hood_post_type = strip_tags($instance['hood_post_type']);
$hood_category = strip_tags($instance['hood_category']);
$category_title = strip_tags($instance['category_title']);
$list_sort = strip_tags($instance['list_sort']);
$list_order = strip_tags($instance['list_order']);
$post_number = strip_tags($instance['post_number']);
$layout = strip_tags($instance['layout']);
$add_location_filter = strip_tags($instance['add_location_filter']);
$character_count = $instance['character_count'];
?>