PATH:
home
/
letacommog
/
laindinois
/
OLD
/
wp-content
/
plugins
/
dwt-listing-rest-api
/
classes
<?php /*DWT Listing Event Form Screen */ add_action( 'rest_api_init', 'dwt_listing_eventz_api_hooks_get', 0 ); function dwt_listing_eventz_api_hooks_get() { register_rest_route( 'downtown/app', '/events/', array( 'methods' => WP_REST_Server::READABLE, 'callback' => 'dwt_listing_get_eventz', 'permission_callback' => function () { return dwt_listing_basic_auth(); }, ) ); register_rest_route( 'downtown/app', '/events/is_update/', array( 'methods' => WP_REST_Server::EDITABLE, 'callback' => 'dwt_listing_get_eventz', 'permission_callback' => function () { return dwt_listing_basic_auth(); }, ) ); } if (!function_exists('dwt_listing_get_eventz')) { function dwt_listing_get_eventz($request) { global $dwt_listing_api; $user = wp_get_current_user(); $user_id = $user->ID; $event_cat = $post = $event_desc = $event_title = $event_catz = $term_listz = $parent_listing = $listing_longitide = $listing_lattitude = $event_venue =$event_end_date =$event_start_date = $event_email =$event_contact = $event_id = ''; $json_data = $request->get_json_params(); $is_update = isset($json_data['is_update']) ? sanitize_text_field($json_data['is_update']) : ''; $update_id = ''; //check if there is event in progess $listing_lattitude = dwt_listing_text('dwt_listing_default_lat'); $listing_longitide = dwt_listing_text('dwt_listing_default_long'); if($is_update !="") { $event_id = $is_update; $update_id = $is_update; $post = get_post($event_id); $event_title = $post->post_title; $event_desc = $post->post_content; $event_contact = get_post_meta($event_id, 'dwt_listing_event_contact', true); $event_email = get_post_meta($event_id, 'dwt_listing_event_email', 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); $event_venue = get_post_meta($event_id, 'dwt_listing_event_venue', true); $listing_lattitude = get_post_meta($event_id, 'dwt_listing_event_lat', true); $listing_longitide = get_post_meta($event_id, 'dwt_listing_event_long', true); $parent_listing = get_post_meta($event_id, 'dwt_listing_event_listing_id', true); //event term $term_list = wp_get_post_terms($event_id, 'l_event_cat', array("fields" => "ids")); if(!empty($term_list)) { $event_cat = $term_list[0]; } } else { if(get_user_meta ($user_id, 'event_in_progress', true ) !="") { $event_id = get_user_meta ($user_id, 'event_in_progress', true ); } else { $new_event = array('post_status' => 'pending','post_author' => $user_id,'post_type' => 'events'); $last_inserted_id = wp_insert_post( $new_event ); if(!empty($last_inserted_id)) { update_user_meta($user_id, 'event_in_progress', $last_inserted_id ); $event_id = $last_inserted_id; } } } //event_id $event_arr['event_id'] = $event_id; $event_arr['is_update'] = $update_id; //publish events $user_eventz['active_events'] = dwt_listing_fetch_owner_eventz_inapp('publish','',$user_id); //pending listingz $user_eventz['pending_events'] = dwt_listing_fetch_owner_eventz_inapp('pending','',$user_id); //expired listingz $user_eventz['expired_events'] = dwt_listing_fetch_owner_eventz_inapp('expired','',$user_id); $event_arr['event_types'] = $user_eventz; //Categories $event_cats = dwt_listing_categories_fetch('l_event_cat' , 0 ); $event_categories = array(); if(!empty($event_cats) && is_array($event_cats) && count($event_cats) > 0) { foreach($event_cats as $eventz) { $event_categories[] = array("category_id" =>$eventz->term_id,"category_name" =>$eventz->name); } } //get user listings $my_listings = dwt_listing_fetch_my_listings_inapp($user_id); $event_creatz[] = dwt_listing_get_profile_fields(__("Event Title", "dwt-listing-api"), __("Food festival in lahore", "dwt-listing-api"), 'input', 'event_title', $event_title, '', true); $event_creatz[] = dwt_listing_get_profile_fields(__("Select Category", "dwt-listing-api"), __("Listing Event name", "dwt-listing-api"), 'select', 'event_cat', $event_catz, $event_categories, true); $event_creatz[] = dwt_listing_get_profile_fields(__("Phone Number", "dwt-listing-api"), __("+99 3331 234567", "dwt-listing-api"), 'input', 'event_number', $event_contact, '', true); $event_creatz[] = dwt_listing_get_profile_fields(__("Contact Email", "dwt-listing-api"), __("abc@xyz.com", "dwt-listing-api"), 'input', 'event_email', $event_email, '', true); $event_creatz[] = dwt_listing_get_profile_fields(__("Description", "dwt-listing-api"), __("Event detials here...", "dwt-listing-api"), 'textarea', 'event_desc', $event_desc, '', true); $event_creatz[] = dwt_listing_get_profile_fields(__("Event Start Date", "dwt-listing-api"), __("Event starting date", "dwt-listing-api"), 'input', 'event_start_date', $event_start_date, '', true); $event_creatz[] = dwt_listing_get_profile_fields(__("Event End Date", "dwt-listing-api"), __("Event ending date", "dwt-listing-api"), 'input', 'event_end_date', $event_end_date, '', true); $event_creatz[] = dwt_listing_get_profile_fields(__("Event Location", "dwt-listing-api"), dwt_listing_text('dwt_listing_list_google_loc_place'), 'input', 'event_venue', $event_venue, '', true); $event_creatz[] = dwt_listing_get_profile_fields(__("Latitude", "dwt-listing-api"), dwt_listing_text('dwt_listing_list_lati_place'), 'input', 'event_lat', $listing_lattitude, '', true); $event_creatz[] = dwt_listing_get_profile_fields(__("Longitude", "dwt-listing-api"), dwt_listing_text('dwt_listing_list_longi_place'), 'input', 'event_long', $listing_longitide, '', true); $event_creatz[] = dwt_listing_get_profile_fields(__("Related Listing (Optional)", "dwt-listing-api"), dwt_listing_text('dwt_listing_list_longi_place'), 'select', 'event_parent_listing', $parent_listing, $my_listings, false); $event_arr['create_event'] =$event_creatz; //Profile $event_arr['profile_data'] = dwt_listing_basic_profile_data(); //screen button texts $screen_txt['edit'] = __("Edit", "dwt-listing-api"); $screen_txt['delete'] = __("Delete", "dwt-listing-api"); $screen_txt['expired'] = __("Expired", "dwt-listing-api"); $screen_txt['re-active'] = __("Re Active Event", "dwt-listing-api"); $screen_txt['views'] = __("Views", "dwt-listing-api"); $screen_txtz['screen_txt'] = __("Events", "dwt-listing-api"); $response = array( 'success' => true, 'data' => $event_arr, 'buttons_txt'=>$screen_txt, "screen_txt" => $screen_txtz, "message" => ""); return $response; } } /*DWT Listing Event Form Submission */ add_action( 'rest_api_init', 'dwt_listing_eventz_api_hooks_submit', 0 ); function dwt_listing_eventz_api_hooks_submit() { register_rest_route( 'downtown/app', '/events/', array( 'methods' => WP_REST_Server::EDITABLE, 'callback' => 'dwt_listing_eventz_submission', 'permission_callback' => function () { return dwt_listing_basic_auth(); }, ) ); } if (!function_exists('dwt_listing_eventz_submission')) { function dwt_listing_eventz_submission($request) { global $dwt_listing_options; $user = wp_get_current_user(); $user_id = $user->data->ID; $json_data = $request->get_json_params(); $event_id = isset($json_data['event_id']) ? sanitize_text_field($json_data['event_id']) : ''; if($event_id == '') { return array( 'success' => false, 'data' => '', 'message' => __( "Event ID is required", 'dwt-listing-api' )); } $event_title = isset($json_data['event_title']) ? sanitize_text_field($json_data['event_title']) : ''; $event_cat = isset($json_data['event_cat']) ? sanitize_text_field($json_data['event_cat']) : ''; $event_number = isset($json_data['event_number']) ? sanitize_text_field($json_data['event_number']) : ''; $event_email = isset($json_data['event_email']) ? sanitize_text_field($json_data['event_email']) : ''; $event_desc = isset($json_data['event_desc']) ? sanitize_text_field($json_data['event_desc']) : ''; $event_start_date = isset($json_data['event_start_date']) ? sanitize_text_field($json_data['event_start_date']) : ''; $event_end_date = isset($json_data['event_end_date']) ? sanitize_text_field($json_data['event_end_date']) : ''; $event_venue = isset($json_data['event_venue']) ? sanitize_text_field($json_data['event_venue']) : ''; $event_lat = isset($json_data['event_lat']) ? sanitize_text_field($json_data['event_lat']) : ''; $event_long = isset($json_data['event_long']) ? sanitize_text_field($json_data['event_long']) : ''; $event_parent_listing = isset($json_data['event_parent_listing']) ? sanitize_text_field($json_data['event_parent_listing']) : ''; $is_update = isset($json_data['is_update']) ? sanitize_text_field($json_data['is_update']) : ''; if($event_title == '' || $event_cat == '' ||$event_number == '' ||$event_email == '' ||$event_desc == '' ||$event_start_date == '' ||$event_end_date == '' ||$event_venue == '' || $event_lat == '' || $event_long == '') { return array( 'success' => false, 'data' => '', 'message' => __( "Please fill out all fields", 'dwt-listing-api' )); } $event_status = 'publish'; if( $is_update != "" ) { if( $dwt_listing_options['dwt_listing_event_up_approval'] == 'manual' ) { $event_status = 'pending'; } else if( get_post_status( $event_id ) == 'pending' ) { $event_status = 'pending'; } } else { if( $dwt_listing_options['dwt_listing_event_approval'] == '0' ) { $event_status = 'pending'; } else { $event_status = 'publish'; } if(get_user_meta ($user_id, 'event_in_progress', true ) != "") { // Now user can post new ad //send email on event creation delete_user_meta($user_id, 'event_in_progress'); dwt_listing_notify_on_new_event($event_id); } } $my_eventz = array( 'ID' => $event_id, 'post_title' => $event_title, 'post_status' => $event_status, 'post_content' => $event_desc, 'post_name' =>$event_title ); wp_update_post($my_eventz); update_post_meta($event_id, 'dwt_listing_event_status', '1' ); update_post_meta($event_id, 'dwt_listing_event_contact', $event_number); update_post_meta($event_id, 'dwt_listing_event_email', $event_email); update_post_meta($event_id, 'dwt_listing_event_start_date', $event_start_date); update_post_meta($event_id, 'dwt_listing_event_end_date', $event_end_date); update_post_meta($event_id, 'dwt_listing_event_venue', $event_venue); update_post_meta($event_id, 'dwt_listing_event_lat', $event_lat); update_post_meta($event_id, 'dwt_listing_event_long', $event_long); update_post_meta($event_id, 'dwt_listing_event_listing_id', $event_parent_listing); wp_set_post_terms( $event_id, $event_cat, 'l_event_cat' ); return array( 'success' => true, 'data' => '', 'message' => __( "Event Created Successfully", 'dwt-listing-api' )); } }
[+]
..
[-] 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]