PATH:
home
/
letacommog
/
laindinois
/
OLD
/
wp-content
/
plugins
/
dwt-listing-rest-api
/
classes
<?php add_action( 'rest_api_init', 'dwt_listing_event_ser', 0 ); function dwt_listing_event_ser() { register_rest_route( 'downtown/app', '/event-search/', array( 'methods' => WP_REST_Server::EDITABLE, 'callback' => 'dwt_listing_get_eventz_public', 'permission_callback' => function () { return dwt_listing_basic_auth(); }, ) ); } // Listing Detial Service if (!function_exists('dwt_listing_get_eventz_public')) { function dwt_listing_get_eventz_public($request) { global $dwt_listing_api; //listings $params = array(); $params = $request->get_json_params(); $limit = 15; if(isset( $dwt_listing_api['app_listing_event_page'] ) && $dwt_listing_api['app_listing_event_page'] !="") { $limit = $dwt_listing_api['app_listing_event_page']; } //Listing Title $event_title = ''; if( isset( $params['by_title'] ) && $params['by_title'] != "" ) { $event_title = $params['by_title']; } //Categories $category = ''; if( isset( $params['event_cat'] ) && $params['event_cat'] != "") { $category = array( array( 'taxonomy' => 'l_event_cat', 'field' => 'term_id', 'terms' => $params['event_cat'], ), ); } //Listing Street Address $street_address = ''; if( isset( $params['by_location'] ) && $params['by_location'] != "" ) { $street_address = array( 'key' => 'dwt_listing_event_venue', 'value' => trim( $params['by_location'] ), 'compare' => 'LIKE', ); } //only active events $active_events = array( 'key' => 'dwt_listing_event_status', 'value' => '1', 'compare' => '=' ); $order = 'DESC'; $order_by = 'date'; if( isset( $params['sort_by'] ) && $params['sort_by'] != "" ) { $orde_arr = explode('-', $params['sort_by']); $order = isset($orde_arr[1]) ? $orde_arr[1] : 'desc'; { $orderBy = isset($orde_arr[0]) ? $orde_arr[0] : 'ID'; } } $page = 1; if(!empty($params['next_page'])) { $page = $params['next_page']; } else { $page = 1; } //query $args = array ( 's' => $event_title, 'post_type' => 'events', 'post_status' => 'publish', 'posts_per_page' => $limit, 'tax_query' => array( $category, ), 'meta_query' => array( $active_events, $street_address, ), 'order'=> $order, 'orderby' => $order_by, 'paged' => $page, ); $results = new WP_Query($args); if ( $results->have_posts() ) { $posted_on = __("Posted on ", "dwt-listing-api"); $views = __("Views ", "dwt-listing-api"); $eventz = $data = array(); $toal_results = ''; $toal_results = esc_attr($results->found_posts); $data['total_events'] = $toal_results . esc_html__(" Results found ", "dwt-listing-api"); $data['no_more'] = esc_html__('No more events','dwt-listing-api'); $data['from'] = esc_html__('From ','dwt-listing-api'); $data['to'] = esc_html__('To ','dwt-listing-api'); $data['venue'] = esc_html__('Venue ','dwt-listing-api'); $lists = array(); $event_end = $event_start = $pieces = $eventz_cats = $event_venue = $event_end_date = $event_start_date = $media = $category_name = $categor_id = $fetch_listingz =''; while( $results->have_posts() ) { $results->the_post(); $event_id = get_the_ID(); $media = dwt_listing_fetch_event_gallery($event_id); $event_start_date = get_post_meta($event_id, 'dwt_listing_event_start_date', true ); $event_end_date = get_post_meta($event_id, 'dwt_listing_event_end_date', true ); $event_venue = get_post_meta($event_id, 'dwt_listing_event_venue', true); $eventz_cats = dwt_listing_events_assigned_cats_app($event_id); if(count((array) $eventz_cats) > 0 && !empty($eventz_cats)) { $pieces = explode(',', $eventz_cats); $categor_id = $pieces[0]; $category_name = $pieces[1]; } if($event_start_date !="" && $event_end_date !="") { $event_start = date_i18n( get_option( 'date_format'), strtotime( $event_start_date ) ); $event_end = date_i18n( get_option( 'date_format'), strtotime( $event_end_date ) ); } $final_title = $limited_title = ''; global $dwt_listing_api; if(isset($dwt_listing_api['app_title_limit']) && $dwt_listing_api['app_title_limit'] !="") { $limited_title = dwt_listing_words_count(get_the_title($event_id), $dwt_listing_api['app_title_limit']); $final_title = stripslashes_deep(wp_strip_all_tags(str_replace("|"," ",$limited_title))); } else { $final_title = get_the_title($event_id); } $eventz[] = array( "event_id" => $event_id, "event_category_id" => $categor_id, "event_category_name" => dwt_listing_convert_uniText($category_name), "event_title" => dwt_listing_convert_uniText($final_title), "image" => dwt_listing_return_event_idz_app($media,'dwt_listing_locations-thumb'), "event_loc" => $event_venue, "event_start_date" => $event_start, "event_end_date" => $event_end, ); } wp_reset_postdata(); $data['eventz'] = $eventz; //pagination $next = $page + 1; $lastpage = ceil($results->found_posts/$limit); $has_next_page = ($next <= (int)$lastpage) ? true : false; $data['pagination'] = array("total_listings" => $results->found_posts, "current_page" => (int)$page, "next_page" => (int)$next, "has_next_page" => $has_next_page ); return $response = array( 'success' => true, 'data' => $data, 'message' =>'' ); } else { $msg = esc_html__("No result found.", "dwt-listing-api"); return $response = array( 'success' => false, 'data' => '', 'message' => $msg); } } } add_action( 'rest_api_init', 'dwt_listing_event_ser_filters', 0 ); function dwt_listing_event_ser_filters() { register_rest_route( 'downtown/app', '/events-filters/', array( 'methods' => WP_REST_Server::EDITABLE, 'callback' => 'dwt_listing_get_events_filters', 'permission_callback' => function () { return dwt_listing_basic_auth(); }, ) ); } // Listing Detial Service if (!function_exists('dwt_listing_get_events_filters')) { function dwt_listing_get_events_filters($request) { global $dwt_listing_api; //listings $price_type = $event_cats = ''; $sort_types = $get_types = $l_cats = $search_filters = array(); $params = $request->get_json_params(); //common filters if(isset( $dwt_listing_api['dwt_app_event_title']) && $dwt_listing_api['dwt_app_event_title'] == true) { $title = esc_html__("Search By Keyword", "dwt-listing-api"); if(isset( $dwt_listing_api['dwt_app_event_title_label']) && $dwt_listing_api['dwt_app_event_title_label'] !="") { $title = $dwt_listing_api['dwt_app_event_title_label']; } $placeholder = esc_html__("What Are You Looking For...", "dwt-listing-api"); if(isset( $dwt_listing_api['dwt_app_event_title_place']) && $dwt_listing_api['dwt_app_event_title_place'] !="") { $placeholder = $dwt_listing_api['dwt_app_event_title_place']; } $search_filters[] = dwt_listing_get_fields($title, $placeholder, 'input', 'by_title', '', ''); } //google places location if(isset( $dwt_listing_api['dwt_app_event_google_loc']) && $dwt_listing_api['dwt_app_event_google_loc'] == true) { $e_title = esc_html__("Where to look?", "dwt-listing-api"); if(isset( $dwt_listing_api['dwt_app_event_google_loc_label']) && $dwt_listing_api['dwt_app_event_google_loc_label'] !="") { $e_title = $dwt_listing_api['dwt_app_event_google_loc_label']; } $e_placeholder = esc_html__("Address Or City", "dwt-listing-api"); if(isset( $dwt_listing_api['dwt_app_event_google_loc_place']) && $dwt_listing_api['dwt_app_event_google_loc_place'] !="") { $e_placeholder = $dwt_listing_api['dwt_app_event_google_loc_place']; } $search_filters[] = dwt_listing_get_fields($e_title, $e_placeholder, 'input', 'by_location', '', ''); } //event categories if(isset( $dwt_listing_api['dwt_app_event_category']) && $dwt_listing_api['dwt_app_event_category'] == true) { //Get cats $event_cats = dwt_listing_categories_fetch('l_event_cat' , 0 ); if(!empty($event_cats) && count((array) $event_cats ) > 0 ) { $l_cats[] = array("key" => "", "value" => __("Select an option", "dwt-listing-api")); foreach( $event_cats as $cats ) { $l_cats[] = array("key" => esc_attr( $cats->term_id ), "value" => dwt_listing_convert_uniText( $cats->name )); } } $e_c_placeholder = esc_html__("Select Category", "dwt-listing-api"); if(isset( $dwt_listing_api['dwt_app_event_category_place']) && $dwt_listing_api['dwt_app_event_category_place'] !="") { $e_c_placeholder = $dwt_listing_api['dwt_app_event_category_place']; } $search_filters[] = dwt_listing_get_fields('', $e_c_placeholder, 'dropdown', 'event_cat', '', $l_cats); } $data['all_filters'] = $search_filters; $scr_title = esc_html__("Events Search", "dwt-listing-api"); $btn_txt = esc_html__("Search", "dwt-listing-api"); if(isset( $dwt_listing_api['dwt_app_event_scr_title']) && $dwt_listing_api['dwt_app_event_scr_title'] !="") { $scr_title = $dwt_listing_api['dwt_app_event_scr_title']; } if(isset( $dwt_listing_api['dwt_app_event_btn_txt']) && $dwt_listing_api['dwt_app_event_btn_txt'] !="") { $btn_txt = $dwt_listing_api['dwt_app_event_btn_txt']; } $screen_txt['screen_title'] = $scr_title; $data['filter_btn'] = $btn_txt; return $response = array( 'success' => true, "screen_text" => $screen_txt, 'data' => $data, 'message' => ''); } }
[+]
..
[-] events.php
[edit]
[-] author-listings.php
[edit]
[-] fetch_data.php
[edit]
[-] forget.php
[edit]
[-] categories.php
[edit]
[-] listing-detail.php
[edit]
[-] packages.php
[edit]
[-] home.php
[edit]
[+]
packages
[-] reviews.php
[edit]
[+]
submit-listing
[-] profile.php
[edit]
[-] register.php
[edit]
[-] settings.php
[edit]
[-] events-search.php
[edit]
[-] listing-search.php
[edit]
[+]
profile
[-] event-detail.php
[edit]
[-] login.php
[edit]
[+]
payments
[-] blog.php
[edit]