PATH:
home
/
letacommog
/
laindinois
/
OLD
/
wp-content
/
plugins
/
dwt-listing-rest-api
/
classes
<?php /*----- Home Screen Starts Here -----*/ add_action( 'rest_api_init', 'dwt_listing_event_detial', 0 ); function dwt_listing_event_detial() { register_rest_route( 'downtown/app', '/event-detial/', array( 'methods' => WP_REST_Server::EDITABLE, 'callback' => 'dwt_listing_event_detial_get', 'permission_callback' => function () { return dwt_listing_basic_auth(); }, ) ); } if (!function_exists('dwt_listing_event_detial_get')) { function dwt_listing_event_detial_get($request) { global $dwt_listing_api; $get_user_location = $get_user_id = $get_user_name = $get_user_dp = $thumb_imgs = $full_img = $media = $enent_post = $title = $description = $event_long = $event_lat = $category_name = $categor_id = $fetch_listingz =''; $gallery = array(); $json_data = $request->get_json_params(); $event_id = (isset($json_data['event_id'])) ? trim($json_data['event_id']) : ''; $page_num = (isset( $json_data['page_num'] ) && $json_data['page_num'] != "" ) ? $json_data['page_num'] : 1; $enent_post = get_post($event_id); $description = $enent_post->post_content; $title = $enent_post->post_title; $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]; } $event_venue = get_post_meta($event_id, 'dwt_listing_event_venue', true); $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 ); 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 ) ); } if( get_post_meta($event_id, 'dwt_listing_event_lat', true ) !="") { $event_lat = get_post_meta($event_id, 'dwt_listing_event_lat', true ); } if( get_post_meta($event_id, 'dwt_listing_event_long', true ) !="") { $event_long = get_post_meta($event_id, 'dwt_listing_event_long', true ); } $has_gallery = false; $media = dwt_listing_fetch_event_gallery($event_id); if( count((array) $media ) > 0 ) { $has_gallery = true; foreach( $media as $m ) { $mid = ''; if ( isset( $m->ID ) ) { $mid = $m->ID; } else { $mid = $m; } $full_img = $thumb_imgs = ''; $full_img = wp_get_attachment_image_src($mid, 'dwt_listing_blogsingle-post'); $gallery[] = array( "url" => esc_url($full_img[0]), ); } } $get_user_dp = dwt_listing_listing_owner($event_id,'dp'); $get_user_name = dwt_listing_listing_owner($event_id,'name'); $get_user_id = dwt_listing_listing_owner($event_id,'id'); $get_user_location = dwt_listing_listing_owner($event_id,'location'); $data['event_detial']['event_id'] = $event_id; $data['event_detial']['event_title'] = dwt_listing_convert_uniText($title); $data['event_detial']['event_category_id'] = $categor_id; $data['event_detial']['event_category_name'] = dwt_listing_convert_uniText($category_name); $data['event_detial']['event_posted_date'] = get_the_date(); $data['event_detial']['event_location'] = $event_venue; $data['event_detial']['event_start_date'] = $event_start; $data['event_detial']['event_end_date'] = $event_end; $data['event_detial']['event_latitude'] = $event_lat; $data['event_detial']['event_longitude'] = $event_long; $data['event_detial']['event_timer_detial'] = $event_start_date; $data['event_detial']['has_gallery'] = $has_gallery; $data['event_detial']['gallery_images'] = $gallery; $data['event_detial']['event_desc'] = $description; $data['event_detial']['event_author_id'] = esc_attr($get_user_id); $data['event_detial']['event_author_name'] = esc_attr($get_user_name); $data['event_detial']['event_author_location'] = esc_attr($get_user_location); $data['event_detial']['event_author_img'] = esc_url($get_user_dp); //comments $blog_detial = get_post($event_id); $comments = wp_count_comments($event_id); $comments_status = false; $status_msg = esc_html__("Comment are closed.", "dwt-listing-api"); if($blog_detial->comment_status == "open") { $comments_status = true; $status_msg = ''; } $has_comments = false; if($comments->approved > 0) { $has_comments = true; } else { $no_comments = esc_html__("No Comment Found.", "dwt-listing-api"); } $logged_in = false; $logged_in_msg = esc_html__("You must be logged in to post a comment.", "dwt-listing-api"); if (is_user_logged_in()) { $logged_in = true; } //screen text $screen_txt['screen_title'] = __("Event Detial", "dwt-listing-api"); $screen_txt['desc'] = __("Description", "dwt-listing-api"); $screen_txt['days'] = __("Days", "dwt-listing-api"); $screen_txt['hours'] = __("Hours", "dwt-listing-api"); $screen_txt['mintes'] = __("Minutes", "dwt-listing-api"); $screen_txt['seconds'] = __("Seconds", "dwt-listing-api"); $screen_txt['profile_btn'] = __("View Profile", "dwt-listing-api"); $data['comment_status'] = $comments_status; $data['status_msg'] = $status_msg; $data['total_comments'] = sprintf( esc_html__( '%s Comments', 'dwt-listing-api' ), $comments->approved ); $data['has_comments'] = $has_comments; $data['no_comments'] = $no_comments; $data['is_user_logged_in'] = $logged_in; $data['not_logged_in_msg'] = $logged_in_msg; $data['comments'] = dwt_listing_fetch_comments_app( $event_id,'',$page_num ); $data['comment_form']['txt'] = __("Leave your comment", "dwt-listing-api" ); $data['comment_form']['title'] = __("Enter your name", "dwt-listing-api" ); $data['comment_form']['email'] = __("Enter your email", "dwt-listing-api" ); $data['comment_form']['textarea'] = __("Your comments", "dwt-listing-api" ); $data['comment_form']['btn_submit'] = __("Post Comment", "dwt-listing-api" ); $data['comment_form']['btn_cancel'] = __("Cancel Comment", "dwt-listing-api" ); return $response = array( 'success' => true, "screen_text" => $screen_txt, 'data' => $data, 'message' => ''); } } // Listing Reviews Reactions add_action( 'rest_api_init', 'dwt_listing_events_comments', 0 ); function dwt_listing_events_comments() { register_rest_route( 'downtown/app', '/event-comments/', array( 'methods' => WP_REST_Server::EDITABLE, 'callback' => 'dwt_listing_events_signle_comment', 'permission_callback' => function () { return dwt_listing_basic_auth(); }, ) ); } if (!function_exists('dwt_listing_events_signle_comment')) { function dwt_listing_events_signle_comment($request) { $message_s = $message = $msg = $event_id = ''; $param = $request->get_json_params(); if ( !is_user_logged_in() ) { return $response = array( 'success' => false, 'data' => '', 'message' => __("You need to logged in", "dwt-listing-api") ); } if(!empty($param['event_id'])) { if(isset($param['message_content']) && $param['message_content'] !="") { $event_id = $param['event_id']; $message = $param['message_content']; $user = wp_get_current_user(); $user_id = $user->data->ID; $display_name = $user->data->display_name; $user_email = $user->data->user_email; // save comment now $save_comments = array( 'comment_post_ID' => $event_id, 'comment_author' => $display_name, 'comment_author_email' => $user_email, 'comment_content' => $message, 'comment_author_url' => $user->user_url, 'comment_type' => 'comments', 'comment_parent' => '0', 'user_id' => $user_id, ); /*Insert new comment and get the comment ID*/ $comment_id = wp_new_comment($save_comments); if($comment_id) { $data['comments'] = dwt_listing_latest_comment($event_id,true); $status = wp_get_comment_status( $comment_id ); if ($status == "approved") { $message_s = __("Comment Posted Successfully.", "dwt-listing-api"); } else { $message_s = __("Waiting for admin approval." , "dwt-listing-api"); } } return $response = array( 'success' => true, 'data' => $data, 'message' => $message_s ); } else { $msg = esc_html__("Please type a comment.", "dwt-listing-api"); return $response = array( 'success' => false, 'data' => '', 'message' => $msg ); } } else { $msg = esc_html__("Event ID is required to post comments.", "dwt-listing-api"); return $response = array( 'success' => false, 'data' => '', 'message' => $msg ); } } }
[+]
..
[-] 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]