<?php global $current_user; get_currentuserinfo(); $userID = $current_user->ID; $user_login = $current_user->user_login; $add_link = wpestate_get_dasboard_add_listing(); $dash_profile = wpestate_get_dashboard_profile_link(); $dash_pack = get_wpestate_packages_link(); $dash_favorite = wpestate_get_dashboard_favorites(); $dash_link = wpestate_get_dashboard_link(); $dash_searches = wpestate_get_searches_link(); $dash_inbox = get_inbox_wpestate_booking(); $dash_invoice = get_invoices_wpestate(); $dash_my_bookings = wpestate_my_booking_link(); $dash_my_reservations = wpestate_my_reservations_link(); $activeprofile = ''; $activeedit = ''; $activedash = ''; $activeadd = ''; $activefav = ''; $activesearch = ''; $activemypack = ''; $activeedit = ''; $activeprice = ''; $activedetails = ''; $activeimages = ''; $activeamm = ''; $activecalendar = ''; $activemybookins = ''; $activemyreservations = '';
function wpestate_ajax_listing_pay() { global $current_user; $is_featured = intval($_POST['is_featured']); $prop_id = intval($_POST['propid']); $is_upgrade = intval($_POST['is_upgrade']); get_currentuserinfo(); $userID = $current_user->ID; $post = get_post($prop_id); if ($post->post_author != $userID) { exit('get out of my cloud'); } $paypal_status = esc_html(get_option('wp_estate_paypal_api', '')); $host = 'https://api.sandbox.paypal.com'; $price_submission = floatval(get_option('wp_estate_price_submission', '')); $price_featured_submission = floatval(get_option('wp_estate_price_featured_submission', '')); $submission_curency_status = esc_html(get_option('wp_estate_submission_curency', '')); $pay_description = esc_html__('Listing payment on ', 'wpestate') . esc_html(home_url()); if ($is_featured == 0) { $total_price = number_format($price_submission, 2, '.', ''); } else { $total_price = $price_submission + $price_featured_submission; $total_price = number_format($total_price, 2, '.', ''); } if ($is_upgrade == 1) { $total_price = number_format($price_featured_submission, 2, '.', ''); $pay_description = esc_html__('Upgrade to featured listing on ', 'wpestate') . esc_html(home_url()); } if ($paypal_status == 'live') { $host = 'https://api.paypal.com'; } $url = $host . '/v1/oauth2/token'; $postArgs = 'grant_type=client_credentials'; $token = wpestate_get_access_token($url, $postArgs); $url = $host . '/v1/payments/payment'; $dash_link = wpestate_get_dashboard_link(); $processor_link = wpestate_get_procesor_link(); $payment = array('intent' => 'sale', "redirect_urls" => array("return_url" => $processor_link, "cancel_url" => $dash_link), 'payer' => array("payment_method" => "paypal")); $payment['transactions'][0] = array('amount' => array('total' => $total_price, 'currency' => $submission_curency_status, 'details' => array('subtotal' => $total_price, 'tax' => '0.00', 'shipping' => '0.00')), 'description' => $pay_description); // prepare individual items if ($is_upgrade == 1) { $payment['transactions'][0]['item_list']['items'][] = array('quantity' => '1', 'name' => esc_html__('Upgrade to Featured Listing', 'wpestate'), 'price' => $total_price, 'currency' => $submission_curency_status, 'sku' => 'Upgrade Featured Listing'); } else { if ($is_featured == 0) { $payment['transactions'][0]['item_list']['items'][] = array('quantity' => '1', 'name' => esc_html__('Listing Payment', 'wpestate'), 'price' => $total_price, 'currency' => $submission_curency_status, 'sku' => 'Paid Listing'); } else { $payment['transactions'][0]['item_list']['items'][] = array('quantity' => '1', 'name' => esc_html__('Listing Payment with Featured option', 'wpestate'), 'price' => $total_price, 'currency' => $submission_curency_status, 'sku' => 'Featured Paid Listing'); } // end is featured } // end is upgrade $json = json_encode($payment); $json_resp = wpestate_make_post_call($url, $json, $token); foreach ($json_resp['links'] as $link) { if ($link['rel'] == 'execute') { $payment_execute_url = $link['href']; $payment_execute_method = $link['method']; } else { if ($link['rel'] == 'approval_url') { $payment_approval_url = $link['href']; $payment_approval_method = $link['method']; } } } $executor['paypal_execute'] = $payment_execute_url; $executor['paypal_token'] = $token; $executor['listing_id'] = $prop_id; $executor['is_featured'] = $is_featured; $executor['is_upgrade'] = $is_upgrade; $save_data[$current_user->ID] = $executor; update_option('paypal_transfer', $save_data); print $payment_approval_url; die; }
if ($admin_submission_status == 'no' && $paid_submission_status == 'per listing') { $post = array('ID' => $listing_id, 'post_status' => 'publish'); $post_id = wp_update_post($post); } // end make post publish if ($is_featured == 1) { update_post_meta($listing_id, 'prop_featured', 1); $invoice_id = wpestate_insert_invoice('Publish Listing with Featured', 'One Time', $listing_id, $date, $current_user->ID, 1, 0, ''); update_post_meta($invoice_id, 'invoice_status', 'confirmed'); } else { $invoice_id = wpestate_insert_invoice('Listing', 'One Time', $listing_id, $date, $current_user->ID, 0, 0, ''); update_post_meta($invoice_id, 'invoice_status', 'confirmed'); } wpestate_email_to_admin(0); } $redirect = wpestate_get_dashboard_link(); wp_redirect($redirect); } catch (Exception $e) { $error = '<div class="alert alert-danger"> <strong>Error!</strong> ' . $e->getMessage() . ' </div>'; print $error; } } else { if (isset($_POST['stripe_recuring']) && $_POST['stripe_recuring'] == 1) { //////////////////////////////////////////////////////////////////////////////// ////////////////// payment for pack recuring //////////////////////////////////////////////////////////////////////////////// try { $dash_profile_link = wpestate_get_dashboard_profile_link(); $token = $_POST['stripeToken'];
function estate_edit_property() { global $_POST; global $userID; global $user_pack; global $status_values; global $status_values_array; global $feature_list_array; global $feature_list; global $custom_fields; global $current_user; $allowed_html = array(); if (!isset($_POST['new_estate']) || !wp_verify_nonce($_POST['new_estate'], 'submit_new_estate')) { exit('Sorry, your not submiting from site'); } $has_errors = false; $show_err = ''; $edited = 0; $edit_id = intval($_POST['edit_id']); $post = get_post($edit_id); $author_id = $post->post_author; if ($current_user->ID != $author_id) { exit('you don\'t have the rights to edit'); } $images_todelete = wp_kses($_POST['images_todelete'], $allowed_html); $images_delete_arr = explode(',', $images_todelete); foreach ($images_delete_arr as $key => $value) { $img = get_post($value); $author_id = $img->post_author; if ($current_user->ID != $author_id) { exit('you don\'t have the rights to delete images'); } else { wp_delete_post($value); } } if (!isset($_POST['prop_category'])) { $prop_category = 0; } else { $prop_category = intval($_POST['prop_category']); } if (!isset($_POST['prop_action_category'])) { $prop_action_category = 0; } else { $prop_action_category = wp_kses($_POST['prop_action_category'], $allowed_html); } if (!isset($_POST['property_city'])) { $property_city = 0; } else { $property_city = wp_kses($_POST['property_city'], $allowed_html); } if (!isset($_POST['property_area'])) { $property_area = 0; } else { $property_area = wp_kses($_POST['property_area'], $allowed_html); } $submit_title = wp_kses($_POST['title'], $allowed_html); $submit_description = wp_kses($_POST['description'], $allowed_html); $property_address = wp_kses($_POST['property_address'], $allowed_html); $property_county = wp_kses($_POST['property_county'], $allowed_html); $property_state = wp_kses($_POST['property_state'], $allowed_html); $property_zip = wp_kses($_POST['property_zip'], $allowed_html); $country_selected = wp_kses($_POST['property_country'], $allowed_html); $prop_stat = wp_kses($_POST['property_status'], $allowed_html); $property_status = ''; foreach ($status_values_array as $key => $value) { $value = trim($value); $property_status .= '<option value="' . $value . '"'; if ($value == $prop_stat) { $property_status .= 'selected="selected"'; } $property_status .= '>' . $value . '</option>'; } $property_price = wp_kses($_POST['property_price'], $allowed_html); $property_label = wp_kses($_POST['property_label'], $allowed_html); $property_size = wp_kses($_POST['property_size'], $allowed_html); $property_lot_size = wp_kses($_POST['property_lot_size'], $allowed_html); $property_year = wp_kses($_POST['property_year'], $allowed_html); $property_rooms = wp_kses($_POST['property_rooms'], $allowed_html); $property_bedrooms = wp_kses($_POST['property_bedrooms'], $allowed_html); $property_bathrooms = wp_kses($_POST['property_bathrooms'], $allowed_html); $option_video = ''; $video_values = array('vimeo', 'youtube'); $video_type = wp_kses($_POST['embed_video_type'], $allowed_html); $google_camera_angle = wp_kses($_POST['google_camera_angle'], $allowed_html); foreach ($video_values as $value) { $option_video .= '<option value="' . $value . '"'; if ($value == $video_type) { $option_video .= 'selected="selected"'; } $option_video .= '>' . $value . '</option>'; } $option_slider = ''; $slider_values = array('full top slider', 'small slider'); $slider_type = wp_kses($_POST['prop_slider_type'], $allowed_html); foreach ($slider_values as $value) { $option_slider .= '<option value="' . $value . '"'; if ($value == $slider_type) { $option_slider .= 'selected="selected"'; } $option_slider .= '>' . $value . '</option>'; } $embed_video_id = wp_kses($_POST['embed_video_id'], $allowed_html); $property_latitude = floatval($_POST['property_latitude']); $property_longitude = floatval($_POST['property_longitude']); if ($google_view == 1) { $google_view_check = ' checked="checked" '; } else { $google_view_check = ' '; } $prop_featured = intval(get_post_meta($edit_id, 'prop_featured', true)); if ($prop_featured == 1) { $prop_featured_check = ' checked="checked" '; } else { $prop_featured_check = ' '; } $google_camera_angle = intval($_POST['google_camera_angle']); $prop_category = get_term($prop_category, 'property_category'); $prop_action_category = get_term($prop_action_category, 'property_action_category'); if ($submit_title == '') { $has_errors = true; $errors[] = esc_html__('Please submit a title for your property', 'wpestate'); } if ($submit_description == '') { $has_errors = true; $errors[] = esc_html__('*Please submit a description for your property', 'wpestate'); } if ($_FILES['upload_attachment']['name'][0] == '') { // $has_errors=true; // $errors[]=esc_html__( '*Please submit an image for your property','wpestate'); } if ($property_address == '') { $has_errors = true; $errors[] = esc_html__('*Please submit an address for your property', 'wpestate'); } if ($property_address == '') { $has_errors = true; $errors[] = esc_html__('*Please submit the price', 'wpestate'); } if ($has_errors) { foreach ($errors as $key => $value) { $show_err .= $value . '</br>'; } } else { $new_status = 'pending'; $admin_submission_status = esc_html(get_option('wp_estate_admin_submission', '')); $paid_submission_status = esc_html(get_option('wp_estate_paid_submission', '')); if ($admin_submission_status == 'no' && $paid_submission_status != 'per listing') { $new_status = 'publish'; } $post = array('ID' => $edit_id, 'post_title' => $submit_title, 'post_content' => $submit_description, 'post_type' => 'estate_property', 'post_status' => $new_status); $post_id = wp_update_post($post); $edited = 1; } if ($edited == 1) { if ($_FILES) { $counter = 0; $files = array_reverse($_FILES['upload_attachment']); foreach ($files['name'] as $key => $value) { if ($files['name'][$key]) { $file = array('name' => $files['name'][$key], 'type' => $files['type'][$key], 'tmp_name' => $files['tmp_name'][$key], 'error' => $files['error'][$key], 'size' => $files['size'][$key]); $_FILES = array("upload_featured_attachment" => $file); foreach ($_FILES as $file => $array) { $newupload = wpestate_insert_attachment($file, $post_id); } set_post_thumbnail($post_id, $newupload); } } } // end if files if (isset($prop_category->name)) { wp_set_object_terms($post_id, $prop_category->name, 'property_category'); } if (isset($prop_action_category->name)) { wp_set_object_terms($post_id, $prop_action_category->name, 'property_action_category'); } if (isset($property_city)) { wp_set_object_terms($post_id, $property_city, 'property_city'); } if (isset($property_area)) { wp_set_object_terms($post_id, $property_area, 'property_area'); } update_post_meta($post_id, 'property_address', $property_address); update_post_meta($post_id, 'property_area', $property_area); update_post_meta($post_id, 'property_county', $property_county); update_post_meta($post_id, 'property_state', $property_state); update_post_meta($post_id, 'property_zip', $property_zip); update_post_meta($post_id, 'property_country', $country_selected); update_post_meta($post_id, 'property_size', $property_size); update_post_meta($post_id, 'property_lot_size', $property_lot_size); update_post_meta($post_id, 'property_rooms', $property_rooms); update_post_meta($post_id, 'property_bedrooms', $property_bedrooms); update_post_meta($post_id, 'property_bathrooms', $property_bathrooms); update_post_meta($post_id, 'property_year', $property_year); update_post_meta($post_id, 'property_status', $prop_stat); update_post_meta($post_id, 'property_price', $property_price); update_post_meta($post_id, 'property_label', $property_label); update_post_meta($post_id, 'embed_video_type', $video_type); update_post_meta($post_id, 'embed_video_id', $embed_video_id); update_post_meta($post_id, 'prop_slider_type', $slider_type); update_post_meta($post_id, 'property_latitude', $property_latitude); update_post_meta($post_id, 'property_longitude', $property_longitude); update_post_meta($post_id, 'prop_featured', $prop_featured); update_post_meta($post_id, 'google_camera_angle', $google_camera_angle); foreach ($feature_list_array as $key => $value) { $post_var_name = str_replace(' ', '_', trim($value)); $feature_value = wp_kses($_POST[$post_var_name], $allowed_html); update_post_meta($post_id, $post_var_name, $feature_value); } // save custom fields $i = 0; while ($i < count($custom_fields)) { $name = $custom_fields[$i][0]; $type = $custom_fields[$i][1]; $slug = str_replace(' ', '_', $name); if ($type == 'numeric') { $value_custom = intval(wp_kses($_POST[$slug], $allowed_html)); update_post_meta($post_id, $slug, $value_custom); } else { $value_custom = esc_html(wp_kses($_POST[$slug], $allowed_html)); update_post_meta($post_id, $slug, $value_custom); } $custom_fields_array[$slug] = wp_kses($_POST[$slug], $allowed_html); $i++; } // get user dashboard link $redirect = wpestate_get_dashboard_link(); wp_reset_query(); $headers = 'From: No Reply <noreply@' . $_SERVER['HTTP_HOST'] . '>' . "\r\n"; $message = esc_html__('Hi there,', 'wpestate') . "\r\n\r\n"; $message .= sprintf(esc_html__("A user has edited one of his listings! You should go check it out.", 'wpestate'), get_option('blogname')) . "\r\n\r\n"; $message .= esc_html__('The property name is : ', 'wpestate') . $submit_title; @wp_mail(get_option('admin_email'), sprintf(esc_html__('[%s] Listing Edited', 'wpestate'), get_option('blogname')), $message, $headers); wp_redirect($redirect); exit; } // end if edited }
function widget($args, $instance) { extract($args); $display = ''; global $post; print $before_widget; $facebook_status = esc_html(get_option('wp_estate_facebook_login', '')); $google_status = esc_html(get_option('wp_estate_google_login', '')); $yahoo_status = esc_html(get_option('wp_estate_yahoo_login', '')); $mess = ''; $display .= ' <div class="login_sidebar"> <h3 class="widget-title-sidebar" id="login-div-title">' . esc_html__('Login', 'wpestate') . '</h3> <div class="login_form" id="login-div"> <div class="loginalert" id="login_message_area_wd" >' . $mess . '</div> <input type="text" class="form-control" name="log" id="login_user_wd" placeholder="' . esc_html__('Username', 'wpestate') . '"/> <input type="password" class="form-control" name="pwd" id="login_pwd_wd" placeholder="' . esc_html__('Password', 'wpestate') . '"/> <input type="hidden" name="loginpop" id="loginpop_wd" value="0"> ' . wp_nonce_field('login_ajax_nonce', 'security-login', false, false) . ' <button class="wpb_button wpb_btn-info wpb_regularsize wpestate_vc_button vc_button" id="wp-login-but-wd" >' . esc_html__('Login', 'wpestate') . '</button> <div class="navigation_links"> <a href="#" id="widget_register_sw">' . esc_html__("Don't have an account?", 'wpestate') . '</a> | <a href="#" id="forgot_pass_widget">' . esc_html__('Forgot Password?', 'wpestate') . '</a> </div> <div class="login-links"> '; if ($facebook_status == 'yes') { $display .= '<div id="facebooklogin_wd" data-social="facebook"><i class="fa fa-facebook"></i>' . esc_html__('Login with Facebook', 'wpestate') . '</div>'; } if ($google_status == 'yes') { $display .= '<div id="googlelogin_wd" data-social="google"><i class="fa fa-google"></i>' . esc_html__('Login with Google', 'wpestate') . '</div>'; } if ($yahoo_status == 'yes') { $display .= '<div id="yahoologin_wd" data-social="yahoo"><i class="fa fa-yahoo"></i>' . esc_html__('Login with Yahoo', 'wpestate') . '</div>'; } $display .= '</div> </div> <h3 class="widget-title-sidebar" id="register-div-title">' . esc_html__('Register', 'wpestate') . '</h3> <div class="login_form" id="register-div"> <div class="loginalert" id="register_message_area_wd" ></div> <input type="text" name="user_login_register" id="user_login_register_wd" class="form-control" placeholder="' . esc_html__('Username', 'wpestate') . '"/> <input type="text" name="user_email_register" id="user_email_register_wd" class="form-control" placeholder="' . esc_html__('Email', 'wpestate') . '" /> <input type="checkbox" name="terms" id="user_terms_register_wd"><label id="user_terms_register_wd_label" for="user_terms_register_wd">' . esc_html__('I agree with ', 'wpestate') . '<a href="' . wpestate_get_terms_links() . '" target="_blank" id="user_terms_register_topbar_link">' . esc_html__('terms & conditions', 'wpestate') . '</a> </label> <p id="reg_passmail">' . esc_html__('A password will be e-mailed to you', 'wpestate') . '</p> ' . wp_nonce_field('register_ajax_nonce', 'security-register', false, false) . ' <button class="wpb_button wpb_btn-info wpb_regularsize wpestate_vc_button vc_button" id="wp-submit-register_wd">' . esc_html__('Register', 'wpestate') . '</button> <div class="login-links"> <a href="#" id="widget_login_sw">' . esc_html__('Back to Login', 'wpestate') . '</a> </div> </div> </div> <h3 class="widget-title-sidebar" id="forgot-div-title_shortcode">' . esc_html__('Reset Password', 'wpestate') . '</h3> <div class="login_form" id="forgot-pass-div_shortcode"> <div class="loginalert" id="forgot_pass_area_shortcode_wd"></div> <div class="loginrow"> <input type="text" class="form-control" name="forgot_email" id="forgot_email_shortcode" placeholder="' . esc_html__('Enter Your Email Address', 'wpestate') . '" size="20" /> </div> ' . wp_nonce_field('login_ajax_nonce_forgot_wd', 'security-login-forgot_wd', true) . ' <input type="hidden" id="postid" value="0"> <button class="wpb_btn-info wpb_regularsize wpestate_vc_button vc_button" id="wp-forgot-but_shortcode" name="forgot" >' . esc_html__('Reset Password', 'wpestate') . '</button> <div class="login-links shortlog"> <a href="#" id="return_login_shortcode">' . esc_html__('Return to Login', 'wpestate') . '</a> </div> </div> '; global $current_user; get_currentuserinfo(); $userID = $current_user->ID; $user_login = $current_user->user_login; $user_email = get_the_author_meta('user_email', $userID); $activeprofile = $activedash = $activeadd = $activefav = ''; $add_link = wpestate_get_dasboard_add_listing(); $dash_profile = wpestate_get_dashboard_profile_link(); $dash_link = wpestate_get_dashboard_link(); $dash_favorite = wpestate_get_dashboard_favorites(); $dash_searches = wpestate_get_searches_link(); $dash_reservation = wpestate_get_my_reservation_link(); $dash_bookings = wpestate_get_my_bookings_link(); $dash_inbox = get_inbox_wpestate_booking(); $dash_invoices = get_invoices_wpestate(); $home_url = esc_html(home_url()); $logged_display = ' <h3 class="widget-title-sidebar" >' . esc_html__('Hello ', 'wpestate') . ' ' . $user_login . ' </h3> <ul class="wd_user_menu">'; if ($home_url != $dash_profile) { $logged_display .= '<li> <a href="' . $dash_profile . '" class="' . $activeprofile . '"><i class="fa fa-cogs"></i> ' . esc_html__('My Profile', 'wpestate') . '</a> </li>'; } if ($home_url != $dash_link) { $logged_display .= ' <li> <a href="' . $dash_link . '" class="' . $activedash . '"><i class="fa fa-map-marker"></i>' . esc_html__('My Properties', 'wpestate') . '</a> </li>'; } if ($home_url != $add_link) { $logged_display .= ' <li> <a href="' . $add_link . '" class="' . $activeadd . '"><i class="fa fa-plus"></i>' . esc_html__('Add New Property', 'wpestate') . '</a> </li>'; } if ($home_url != $dash_favorite) { $logged_display .= ' <li> <a href="' . $dash_favorite . '" class="' . $activefav . '"><i class="fa fa-heart"></i>' . esc_html__('Favorites', 'wpestate') . '</a> </li>'; } if ($home_url != $dash_reservation) { $logged_display .= ' <li> <a href="' . $dash_reservation . '" class="' . $activefav . '"><i class="fa fa-folder-open"></i>' . esc_html__('Reservations', 'wpestate') . '</a> </li>'; } if ($home_url != $dash_bookings) { $logged_display .= ' <li> <a href="' . $dash_bookings . '" class="' . $activefav . '"><i class="fa fa-folder-open-o"></i>' . esc_html__('Bookings', 'wpestate') . '</a> </li>'; } if ($home_url != $dash_inbox) { $logged_display .= ' <li> <a href="' . $dash_inbox . '" class="' . $activefav . '"><i class="fa fa-inbox"></i>' . esc_html__('Inbox', 'wpestate') . '</a> </li>'; } if ($home_url != $dash_favorite) { $logged_display .= ' <li> <a href="' . $dash_invoices . '" class="' . $activefav . '"><i class="fa fa-file-o"></i>' . esc_html__('Invoices', 'wpestate') . '</a> </li>'; } $logged_display .= ' <li> <a href="' . wp_logout_url() . '" title="Logout"><i class="fa fa-power-off"></i>' . esc_html__('Log Out', 'wpestate') . '</a> </li> </ul> '; if (is_user_logged_in()) { print $logged_display; } else { print $display; } print $after_widget; }