/** * Handles user Authentication actions Ex. login, register, logout etc. * * @since 1.0.0 * @since 1.5.7 It allows login by email also if site is using SSL. * @package GeoDirectory * @global object $errors WordPress Error object. */ function geodir_user_signup() { global $errors; $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login'; $errors = new WP_Error(); if (isset($_GET['key'])) { $action = 'resetpass'; } // validate action so as to default to the login screen if (!in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login')) && false === has_filter('login_form_' . $action)) { $action = 'login'; } nocache_headers(); if (defined('RELOCATE')) { // Move flag is set if (isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']) { $_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF']); } $schema = isset($_SERVER['HTTPS']) && geodir_strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://'; if (dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != home_url()) { update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'])); } } //Set a cookie now to see if they are supported by the browser. //setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN); if (SITECOOKIEPATH != COOKIEPATH) { setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN); } /** * Allow plugins to override the default actions, and to add extra actions if they want on the register/signin page. * * Used dynamic hook login_form_$action * * @since 1.0.0 */ do_action('login_form_' . $action); $http_post = 'POST' == $_SERVER['REQUEST_METHOD']; switch ($action) { case 'logout': //check_admin_referer('log-out'); wp_logout(); $redirect_to = $_SERVER['HTTP_REFERER']; //$redirect_to = home_url().'/?ptype=login&loggedout=true'; if (isset($_REQUEST['redirect_to'])) { $redirect_to = $_REQUEST['redirect_to']; } $redirect_to = home_url(); wp_safe_redirect($redirect_to); exit; break; case 'lostpassword': case 'retrievepassword': if ($http_post) { $errors = geodir_retrieve_password(); $error_message = isset($errors->errors['invalid_email'][0]) ? $errors->errors['invalid_email'][0] : ''; if (!is_wp_error($errors)) { wp_redirect(geodir_login_url(array('checkemail' => 'confirm'))); exit; } else { wp_redirect(geodir_login_url(array('emsg' => 'fw'))); exit; } } if (isset($_GET['error']) && 'invalidkey' == $_GET['error']) { $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.', 'geodirectory')); } /** * Called in the geodir_user_signup() function during the lostpassword case. * * @since 1.0.0 */ do_action('lost_password'); $message = '<div class="sucess_msg">' . ENTER_USER_EMAIL_NEW_PW_MSG . '</div>'; $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : ''; break; case 'resetpass': case 'rp': $errors = reset_password($_GET['key'], $_GET['login']); if (!is_wp_error($errors)) { wp_redirect(geodir_login_url(array('checkemail' => 'newpass'))); exit; } wp_redirect(geodir_login_url(array('error' => 'invalidkey', 'action' => 'lostpassword'))); exit; break; case 'register': ############################### fix by Stiofan - HebTech.co.uk ### SECURITY FIX ############################## if (!get_option('users_can_register')) { wp_redirect(geodir_login_url(array('emsg' => 'regnewusr'))); exit; } ############################### fix by Stiofan - HebTech.co.uk ### SECURITY FIX ############################## global $user_email, $user_fname; $user_login = ''; $user_email = ''; if ($http_post) { $user_login = $_POST['user_email']; $user_email = $_POST['user_email']; $user_fname = $_POST['user_fname']; $errors = geodir_register_new_user($user_login, $user_email); /* display error in registration form */ if (is_wp_error($errors)) { $error_code = $errors->get_error_code(); $error_message = $errors->get_error_message($error_code); if (!isset($_POST['user_login']) && ($error_code == 'empty_username' || $error_code == 'invalid_username' || $error_code == 'username_exists')) { if ($error_code == 'empty_username') { $error_code = 'empty_email'; } else { if ($error_code == 'invalid_username') { $error_code = 'invalid_email'; } else { if ($error_code == 'username_exists') { $error_code = 'email_exists'; } } } $error_message = $errors->get_error_message($error_code); } global $geodir_signup_error; $geodir_signup_error = $error_message; } if (!is_wp_error($errors)) { $_POST['log'] = $user_login; $_POST['pwd'] = $errors[1]; $_POST['testcookie'] = 1; $secure_cookie = ''; // If the user wants ssl but the session is not ssl, force a secure cookie. if (!empty($_POST['log'])) { $user_name = sanitize_user($_POST['log']); if ($user = get_user_by('email', $user_name)) { if (get_user_option('use_ssl', $user->ID)) { $secure_cookie = true; force_ssl_admin(true); } } } $redirect_to = $_REQUEST['redirect_to']; if (!isset($_REQUEST['redirect_to']) || $_REQUEST['redirect_to'] == '') { if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], home_url())) { $redirect_to = $_SERVER['HTTP_REFERER']; } else { $redirect_to = home_url(); } } if (isset($_REQUEST['redirect_add_listing']) && $_REQUEST['redirect_add_listing'] != '') { $redirect_to = $_REQUEST['redirect_add_listing']; } if (!$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && 0 !== strpos($redirect_to, 'https') && 0 === strpos($redirect_to, 'http')) { $secure_cookie = false; } $user = wp_signon('', $secure_cookie); $requested_redirect_to = isset($_REQUEST['redirect_add_listing']) && $_REQUEST['redirect_add_listing'] != '' ? $_REQUEST['redirect_add_listing'] : (isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : ''); /** * Filter the login redirect URL. * * @since 1.4.9 * @param string $redirect_to The redirect destination URL. * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter. * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise. */ $redirect_to = apply_filters('login_redirect', $redirect_to, $requested_redirect_to, $user); if (!is_wp_error($user)) { wp_safe_redirect($redirect_to); exit; } exit; } } break; case 'login': default: $secure_cookie = ''; if (!empty($_POST['log'])) { $user_name = sanitize_user($_POST['log']); if ($user = get_user_by('login', $user_name)) { if (get_user_option('use_ssl', $user->ID)) { $secure_cookie = true; force_ssl_admin(true); } } elseif ($user = get_user_by('email', $user_name)) { $_POST['log'] = $user->user_login; // If signing in by email, set the username for normal WP login if (get_user_option('use_ssl', $user->ID)) { $secure_cookie = true; force_ssl_admin(true); } } } /////////////////////////// if (isset($_REQUEST['redirect_add_listing'])) { $_REQUEST['redirect_to'] = $_REQUEST['redirect_add_listing']; } if (!isset($_REQUEST['redirect_to']) || $_REQUEST['redirect_to'] == '') { if (is_user_logged_in()) { $user_ID = isset($user->ID) ? $user->ID : ''; $author_link = get_author_posts_url($user_ID); $default_author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => 'gd_place'), false); /** * Filter the author link. * * @since 1.0.0 * * @param string $default_author_link Default author link. * @param int $user_ID The user ID. */ $default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_ID); $_REQUEST['redirect_to'] = $default_author_link; } else { $_REQUEST['redirect_to'] = home_url(); } } if (isset($_REQUEST['redirect_to'])) { $redirect_to = $_REQUEST['redirect_to']; // Redirect to https if user wants ssl if ($secure_cookie && false !== strpos($redirect_to, 'wp-admin')) { $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to); } } else { $redirect_to = admin_url(); } if (!$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && 0 !== strpos($redirect_to, 'https') && 0 === strpos($redirect_to, 'http')) { $secure_cookie = false; } $user = wp_signon('', $secure_cookie); /** * Filter the login redirect URL. * * @since 1.4.9 * @param string $redirect_to The redirect destination URL. * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise. */ $redirect_to = apply_filters('login_redirect', $redirect_to, isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '', $user); if (is_wp_error($user)) { if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], 'ptype=property_submit') && $_POST['log'] != '' && $_POST['pwd'] != '') { wp_redirect($_SERVER['HTTP_REFERER'] . '&emsg=1'); } } if (!is_wp_error($user)) { // Some servers are not logging the user in properly after wp_signon, se we set the user here. //wp_set_current_user($user->ID); //echo '###';exit; if ($redirect_to) { wp_redirect($redirect_to); } else { wp_redirect(home_url()); } exit; } $errors = $user; // Clear errors if loggedout is set. if (!empty($_GET['loggedout'])) { $errors = new WP_Error(); } // If cookies are disabled we can't log in even with a valid user+pass if (isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE])) { $errors->add('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress.", 'geodirectory')); } // Some parts of this script use the main login form to display a message if (isset($_GET['loggedout']) && TRUE == $_GET['loggedout']) { $successmsg = '<div class="sucess_msg">' . YOU_ARE_LOGED_OUT_MSG . '</div>'; } elseif (isset($_GET['registration']) && 'disabled' == $_GET['registration']) { $successmsg = USER_REG_NOT_ALLOW_MSG; } elseif (isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail']) { $successmsg = EMAIL_CONFIRM_LINK_MSG; } elseif (isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail']) { $successmsg = NEW_PW_EMAIL_MSG; } elseif (isset($_GET['checkemail']) && 'registered' == $_GET['checkemail']) { $successmsg = REG_COMPLETE_MSG; } if (isset($_POST['log']) && $_POST['log'] != '' && $errors || (!isset($_POST['log']) || $_POST['log'] == '') && isset($_REQUEST['testcookie']) && $_REQUEST['testcookie']) { if (isset($_REQUEST['pagetype']) && $_REQUEST['pagetype'] != '') { wp_redirect($_REQUEST['pagetype'] . '&emsg=1'); } else { wp_redirect(geodir_login_url(array('logemsg' => '1', 'redirect_to' => urlencode($_REQUEST['redirect_to'])))); } exit; } break; } // end action switch }
/** * Loads template based on the current page. * * @since 1.0.0 * @package GeoDirectory * @global object $wp_query WordPress Query object. * @todo $wp_query declared twice - fix it. * @global object $post The current post object. * @global object $current_user Current user object. * @param string $template The template path. * @return bool|string The template path. */ function geodir_template_loader($template) { global $wp_query; /** * Filter the custom page list. * * @since 1.0.0 */ $geodir_custom_page_list = apply_filters('geodir_set_custom_pages', array('geodir_signup_page' => apply_filters('geodir_set_custom_signup_page', false), 'geodir_add_listing_page' => apply_filters('geodir_set_custom_add_listing_page', false), 'geodir_preview_page' => apply_filters('geodir_set_custom_preview_page', false), 'geodir_listing_success_page' => apply_filters('geodir_set_custom_listing_success_page', false), 'geodir_listing_detail_page' => apply_filters('geodir_set_custom_listing_detail_page', false), 'geodir_listing_page' => apply_filters('geodir_set_custom_listing_page', false), 'geodir_search_page' => apply_filters('geodir_set_custom_search_page', false), 'geodir_author_page' => apply_filters('geodir_set_custom_author_page', false), 'geodir_home_map_page' => apply_filters('geodir_set_custom_home_map_page', false))); if (geodir_is_page('login') || $geodir_custom_page_list['geodir_signup_page']) { $template = geodir_locate_template('signup'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/geodir-signup.php'; } /** * Filter the signup template path. * * @since 1.0.0 * @param string $template The template path. */ return $template = apply_filters('geodir_template_signup', $template); } if (geodir_is_page('add-listing') || $geodir_custom_page_list['geodir_add_listing_page']) { if (!geodir_is_default_location_set()) { global $information; $information = sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>'); $template = geodir_locate_template('information'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php'; } /** * Filter the information template path. * * @since 1.0.0 * @param string $template The template path. */ return $template = apply_filters('geodir_template_information', $template); } // check if pid exists in the record if yes then check if this post belongs to the user who is logged in. if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { global $information; $information = __('This listing does not belong to your account, please check the listing id carefully.', 'geodirectory'); $is_current_user_owner = geodir_listing_belong_to_current_user(); if (!$is_current_user_owner) { $template = geodir_locate_template('information'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php'; } /** * Filter the information template path. * * @since 1.0.0 * @param string $template The template path. */ return $template = apply_filters('geodir_template_information', $template); } } //geodir_is_login(true); global $current_user; if (!$current_user->ID) { wp_redirect(geodir_login_url(array('redirect_add_listing' => urlencode(geodir_curPageURL()))), 302); exit; } $template = geodir_locate_template('add-listing'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/add-listing.php'; } /** * Filter the add listing template path. * * @since 1.0.0 * @param string $template The template path. */ return $template = apply_filters('geodir_template_add_listing', $template); } if (geodir_is_page('preview') || $geodir_custom_page_list['geodir_preview_page']) { global $preview; $preview = true; $template = geodir_locate_template('preview'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php'; } /** * Filter the preview template path. * * @since 1.0.0 * @param string $template The template path. */ return $template = apply_filters('geodir_template_preview', $template); } if (geodir_is_page('listing-success') || $geodir_custom_page_list['geodir_listing_success_page']) { $template = geodir_locate_template('success'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/listing-success.php'; } /** * Filter the success template path. * * @since 1.0.0 * @param string $template The template path. */ return $template = apply_filters('geodir_template_success', $template); } if (geodir_is_page('detail') || $geodir_custom_page_list['geodir_listing_detail_page']) { $template = geodir_locate_template('detail'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php'; } /** * Filter the detail template path. * * @since 1.0.0 * @param string $template The template path. */ return $template = apply_filters('geodir_template_detail', $template); } if (geodir_is_page('listing') || $geodir_custom_page_list['geodir_listing_page']) { $template = geodir_locate_template('listing'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/geodir-listing.php'; } /** * Filter the listing template path. * * @since 1.0.0 * @param string $template The template path. */ return $template = apply_filters('geodir_template_listing', $template); } if (geodir_is_page('search') || $geodir_custom_page_list['geodir_search_page']) { $template = geodir_locate_template('search'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/geodir-search.php'; } /** * Filter the search template path. * * @since 1.0.0 * @param string $template The template path. */ return $template = apply_filters('geodir_template_search', $template); } if (geodir_is_page('author') || $geodir_custom_page_list['geodir_author_page']) { $template = geodir_locate_template('author'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/geodir-author.php'; } /** * Filter the author template path. * * @since 1.0.0 * @param string $template The template path. */ return $template = apply_filters('geodir_template_author', $template); } if (get_option('geodir_set_as_home') || geodir_is_page('home') || geodir_is_page('location')) { global $post, $wp_query; if (geodir_is_page('home') || 'page' == get_option('show_on_front') && isset($post->ID) && $post->ID == get_option('page_on_front') || is_home() && !$wp_query->is_posts_page) { $template = geodir_locate_template('geodir-home'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/geodir-home.php'; } /** * Filter the home page template path. * * @since 1.0.0 * @param string $template The template path. */ return $template = apply_filters('geodir_template_homepage', $template); } elseif (geodir_is_page('location')) { $template = geodir_locate_template('location'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/geodir-location.php'; } /** * Filter the location template path. * * @since 1.0.0 * @param string $template The template path. */ return $template = apply_filters('geodir_template_location', $template); } else { return $template; } } return $template; }
/** * This function would display the html content for add to favorite or remove from favorite. * * @since 1.0.0 * @package GeoDirectory * @global object $current_user Current user object. * @global object $post The current post object. * @param int $user_id The user ID. * @param int $post_id The post ID. */ function geodir_favourite_html($user_id, $post_id) { global $current_user, $post; /** * Filter to modify "Add to Favorites" text * * You can use this filter to rename "Add to Favorites" text to something else. * * @since 1.0.0 * @package GeoDirectory */ $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT); /** * Filter to modify "Favourite" text * * You can use this filter to rename "Favourite" text to something else. * * @since 1.0.0 * @package GeoDirectory */ $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT); /** * Filter to modify "Unfavorite" text * * You can use this filter to rename "Unfavorite" text to something else. * * @since 1.0.0 * @package GeoDirectory */ $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT); /** * Filter to modify "Remove from Favorites" text * * You can use this filter to rename "Remove from Favorites" text to something else. * * @since 1.0.0 * @package GeoDirectory */ $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT); /** * Filter to modify "fa fa-heart" icon * * You can use this filter to change "fa fa-heart" icon to something else. * * @since 1.0.0 * @package GeoDirectory */ $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart'); /** * Filter to modify "fa fa-heart" icon for "remove from favorites" link * * You can use this filter to change "fa fa-heart" icon to something else. * * @since 1.0.0 * @package GeoDirectory */ $unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart'); $user_meta_data = ''; if (isset($current_user->data->ID)) { $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true); } if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) { ?> <span class="geodir-addtofav favorite_property_<?php echo $post_id; ?> " ><a class="geodir-removetofav-icon" href="javascript:void(0);" onclick="javascript:addToFavourite(<?php echo $post_id; ?> ,'remove');" title="<?php echo $remove_favourite_text; ?> "><i class="<?php echo $unfavourite_icon; ?> "></i> <?php echo $unfavourite_text; ?> </a> </span><?php } else { if (!isset($current_user->data->ID) || $current_user->data->ID == '') { $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\''; } else { $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')'; } ?> <span class="geodir-addtofav favorite_property_<?php echo $post_id; ?> "><a class="geodir-addtofav-icon" href="javascript:void(0);" onclick="<?php echo $script_text; ?> " title="<?php echo $add_favourite_text; ?> "><i class="<?php echo $favourite_icon; ?> "></i> <?php echo $favourite_text; ?> </a></span> <?php } }
/** * Generates login box HTML. * * @since 1.0.0 * @package GeoDirectory * @global object $current_user Current user object. * @param array|string $args Display arguments including before_title, after_title, before_widget, and after_widget. * @param array|string $instance The settings for the particular instance of the widget. */ function geodir_loginwidget_output($args = '', $instance = '') { //print_r($args); //print_r($instance); // prints the widget extract($args, EXTR_SKIP); /** This filter is documented in geodirectory_widgets.php */ $title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory')); echo $before_widget; echo $before_title . $title . $after_title; if (is_user_logged_in()) { global $current_user; $login_url = geodir_login_url(); $add_listurl = get_permalink(geodir_add_listing_page_id()); $add_listurl = geodir_getlink($add_listurl, array('listing_type' => 'gd_place')); $author_link = get_author_posts_url($current_user->data->ID); $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false); echo '<ul class="geodir-loginbox-list">'; ob_start(); ?> <li><a class="signin" href="<?php echo wp_logout_url(home_url()); ?> "><?php _e('Logout', 'geodirectory'); ?> </a></li> <?php $post_types = geodir_get_posttypes('object'); $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_user_dashboard'); $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend'); if (!empty($show_add_listing_post_types_main_nav)) { $addlisting_links = ''; foreach ($post_types as $key => $postobj) { if (in_array($key, $show_add_listing_post_types_main_nav)) { if ($add_link = geodir_get_addlisting_link($key)) { $name = $postobj->labels->name; $selected = ''; if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing')) { $selected = 'selected="selected"'; } /** * Filter add listing link. * * @since 1.0.0 * @param string $add_link Add listing link. * @param string $key Add listing array key. * @param int $current_user->ID Current user ID. */ $add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID); $addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>'; } } } if ($addlisting_links != '') { ?> <li><select id="geodir_add_listing" class="chosen_select" onchange="window.location.href=this.value" option-autoredirect="1" name="geodir_add_listing" option-ajaxchosen="false" data-placeholder="<?php echo esc_attr(__('Add Listing', 'geodirectory')); ?> "> <option value="" disabled="disabled" selected="selected" style='display:none;'><?php echo esc_attr(__('Add Listing', 'geodirectory')); ?> </option> <?php echo $addlisting_links; ?> </select></li> <?php } } // My Favourites in Dashboard $show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard'); $user_favourite = geodir_user_favourite_listing_count(); if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) { $favourite_links = ''; foreach ($post_types as $key => $postobj) { if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) { $name = $postobj->labels->name; $post_type_link = geodir_getlink($author_link, array('stype' => $key, 'list' => 'favourite'), false); $selected = ''; if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) { $selected = 'selected="selected"'; } /** * Filter favorite listing link. * * @since 1.0.0 * @param string $post_type_link Favorite listing link. * @param string $key Favorite listing array key. * @param int $current_user->ID Current user ID. */ $post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID); $favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>'; } } if ($favourite_links != '') { ?> <li> <select id="geodir_my_favourites" class="chosen_select" onchange="window.location.href=this.value" option-autoredirect="1" name="geodir_my_favourites" option-ajaxchosen="false" data-placeholder="<?php echo esc_attr(__('My Favorites', 'geodirectory')); ?> "> <option value="" disabled="disabled" selected="selected" style='display:none;'><?php echo esc_attr(__('My Favorites', 'geodirectory')); ?> </option> <?php echo $favourite_links; ?> </select> </li> <?php } } $show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard'); $user_listing = geodir_user_post_listing_count(); if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) { $listing_links = ''; foreach ($post_types as $key => $postobj) { if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) { $name = $postobj->labels->name; $listing_link = geodir_getlink($author_link, array('stype' => $key), false); $selected = ''; if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) { $selected = 'selected="selected"'; } /** * Filter my listing link. * * @since 1.0.0 * @param string $listing_link My listing link. * @param string $key My listing array key. * @param int $current_user->ID Current user ID. */ $listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID); $listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>'; } } if ($listing_links != '') { ?> <li> <select id="geodir_my_listings" class="chosen_select" onchange="window.location.href=this.value" option-autoredirect="1" name="geodir_my_listings" option-ajaxchosen="false" data-placeholder="<?php echo esc_attr(__('My Listings', 'geodirectory')); ?> "> <option value="" disabled="disabled" selected="selected" style='display:none;'><?php echo esc_attr(__('My Listings', 'geodirectory')); ?> </option> <?php echo $listing_links; ?> </select> </li> <?php } } $dashboard_link = ob_get_clean(); /** * Filter dashboard links HTML. * * @since 1.0.0 * @param string $dashboard_link Dashboard links HTML. */ echo apply_filters('geodir_dashboard_links', $dashboard_link); echo '</ul>'; } else { ?> <?php /** * Filter signup form action link. * * @since 1.0.0 */ ?> <form name="loginform" class="loginform1" action="<?php echo geodir_login_url(); ?> " method="post"> <div class="geodir_form_row"><input placeholder="<?php _e('Email', 'geodirectory'); ?> " name="log" type="text" class="textfield user_login1"/> <span class="user_loginInfo"></span></div> <div class="geodir_form_row"><input placeholder="<?php _e('Password', 'geodirectory'); ?> " name="pwd" type="password" class="textfield user_pass1 input-text"/><span class="user_passInfo"></span></div> <input type="hidden" name="redirect_to" value="<?php echo htmlspecialchars(geodir_curPageURL()); ?> "/> <input type="hidden" name="testcookie" value="1"/> <div class="geodir_form_row clearfix"><input type="submit" name="submit" value="<?php echo SIGN_IN_BUTTON; ?> " class="b_signin"/> <p class="geodir-new-forgot-link"> <?php /** * Filter signup page register form link. * * @since 1.0.0 */ ?> <a href="<?php echo geodir_login_url(array('signup' => true)); ?> " class="goedir-newuser-link"><?php echo NEW_USER_TEXT; ?> </a> <?php /** * Filter signup page forgot password form link. * * @since 1.0.0 */ ?> <a href="<?php echo geodir_login_url(array('forgot' => true)); ?> " class="goedir-forgot-link"><?php echo FORGOT_PW_TEXT; ?> </a></p></div> </form> <?php } echo $after_widget; }
* @since 1.5.7 Added db translations for post success message. * @package GeoDirectory * @global object $wpdb WordPress Database object. */ ?> <div class="geodir_preview_section"> <?php global $wpdb; $post_id = $_REQUEST['pid']; $post_info = get_post($post_id); $posted_date = $post_info->post_date; $productlink = get_permalink($post_id); $siteName = get_bloginfo('name'); $siteurl = home_url(); $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>'; $loginurl = geodir_login_url(); $loginurl_link = '<a href="' . $loginurl . '">login</a>'; $post_author = $post_info->post_author; $user_info = get_userdata($post_author); $username = $user_info->user_login; $user_email = $user_info->user_email; $message = wpautop(__(stripslashes_deep(get_option('geodir_post_added_success_msg_content')), 'geodirectory')); /* * Filter the success page message before variable replacements. * * @since 1.5.7 * @param string The message string. * @param object $post_info Post object. * @param object $user_info User object. */ $message = apply_filters('geodir_success_page_msg_before_var_replace', $message, $post_info, $user_info);
function widget($args, $instance) { // prints the widget extract($args, EXTR_SKIP); $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']); global $current_user; if (function_exists('geodir_getlink')) { $login_url = geodir_login_url(); $logout_url = wp_logout_url(home_url()); $add_listurl = get_permalink(get_option('geodir_add_listing_page')); $add_listurl = geodir_getlink($add_listurl, array('listing_type' => 'gd_place')); if (get_current_user_id()) { $author_link = get_author_posts_url($current_user->data->ID); $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => 'gd_place'), false); $authorfav_link = geodir_getlink($author_link, array('stype' => 'gd_place', 'list' => 'favourite'), false); } } else { $login_url = wp_login_url(get_permalink()); $logout_url = wp_logout_url(home_url()); } ?> <div class="gdf_welcome_login_wrap" ><ul class="gdf_welcome_login"><?php if (get_current_user_id()) { $display_name = $current_user->data->display_name; ?> <li class="welcome"> <span><?php _e('Welcome', GEODIRECTORY_FRAMEWORK); ?> , </span> <a href="<?php echo esc_url($author_link); ?> " title="<?php echo $display_name; ?> "> <?php echo $display_name; ?> </a></li> <li class="userin"><a href="<?php echo $logout_url; ?> " class="signin"><?php _e('Logout', GEODIRECTORY_FRAMEWORK); ?> </a></li> <?php } else { ?> <li class="welcome"><span><?php _e('Welcome', GEODIRECTORY_FRAMEWORK); ?> , <strong><?php _e('Guest', GEODIRECTORY_FRAMEWORK); ?> </strong></span> </li> <!-- <li class="userin"><a href="<?php //echo $login_url; ?> " class="signin"><?php //_e('Sign in',GEODIRECTORY_FRAMEWORK); ?> </a></li> --> <li class="userin"><a href="" id="show_login" class="signin"><?php _e('Sign in', GEODIRECTORY_FRAMEWORK); ?> </a></li> <?php } ?> </ul> </div> <?php }
* Also If you would like to wrap "reviews" inside a div this is the best place to print your closing div. @see geodir_before_review_list to print your open div. * * @since 1.5.7 */ do_action('geodir_before_review_form'); ?> <?php /** * Filters comment form args * * If you would like to modify your comment form args, use this filter. @see https://codex.wordpress.org/Function_Reference/comment_form for accepted args. * * @since 1.0.0 */ $args = apply_filters('geodir_review_form_args', array('title_reply' => __('Leave a Review', 'geodirectory'), 'label_submit' => __('Post Review', 'geodirectory'), 'comment_field' => '<p class="comment-form-comment"><label for="comment">' . __('Review text', 'geodirectory') . '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>', 'must_log_in' => '<p class="must-log-in">' . sprintf(__('You must be <a href="%s">logged in</a> to post a comment.', 'geodirectory'), geodir_login_url()) . '</p>')); comment_form($args); ?> <?php /** * Called after displaying "Leave a review form". * * If you would like to wrap "review form" inside a div this is the best place to print your closing div. @see geodir_before_review_form to print your open div. * * @since 1.5.7 */ do_action('geodir_after_review_form'); ?> </div><!-- #comments .comments-area -->
/** * Processes GeoDirectory ajax url calls. * * @see geodir_get_ajax_url() * @since 1.0.0 * @package GeoDirectory * @global object $wpdb WordPress Database object. * @global object $current_user Current user object. * @todo check if nonce is required here and if so add one. */ function geodir_ajax_handler() { global $wpdb; if (isset($_REQUEST['gd_listing_view']) && $_REQUEST['gd_listing_view'] != '') { $_SESSION['gd_listing_view'] = $_REQUEST['gd_listing_view']; echo '1'; } if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'category_ajax') { if (isset($_REQUEST['main_catid']) && isset($_REQUEST['cat_tax']) && isset($_REQUEST['exclude'])) { geodir_addpost_categories_html($_REQUEST['cat_tax'], $_REQUEST['main_catid'], '', '', '', $_REQUEST['exclude']); } elseif (isset($_REQUEST['catpid']) && isset($_REQUEST['cat_tax'])) { geodir_editpost_categories_html($_REQUEST['cat_tax'], $_REQUEST['catpid']); } } if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'admin_ajax' || isset($_REQUEST['create_field']) || isset($_REQUEST['sort_create_field'])) { if (current_user_can('manage_options')) { /** * Contains admin ajax handling functions. * * @since 1.0.0 * @package GeoDirectory */ include_once geodir_plugin_path() . '/geodirectory-admin/geodir_admin_ajax.php'; } else { wp_redirect(geodir_login_url()); exit; } } if (isset($_REQUEST['geodir_autofill']) && $_REQUEST['geodir_autofill'] != '' && isset($_REQUEST['_wpnonce'])) { if (current_user_can('manage_options')) { switch ($_REQUEST['geodir_autofill']) { case "geodir_dummy_delete": if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir_dummy_posts_delete_noncename')) { return; } if (isset($_REQUEST['posttype'])) { /** * Used to delete the dummy post data per post type. * * Uses dynamic hook, geodir_delete_dummy_posts_$_REQUEST['posttype']. * * @since 1.0.0 */ do_action('geodir_delete_dummy_posts_' . $_REQUEST['posttype']); } break; case "geodir_dummy_insert": if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir_dummy_posts_insert_noncename')) { return; } global $dummy_post_index, $city_bound_lat1, $city_bound_lng1, $city_bound_lat2, $city_bound_lng2; $dummy_post_index = $_REQUEST['insert_dummy_post_index']; $city_bound_lat1 = $_REQUEST['city_bound_lat1']; $city_bound_lng1 = $_REQUEST['city_bound_lng1']; $city_bound_lat2 = $_REQUEST['city_bound_lat2']; $city_bound_lng2 = $_REQUEST['city_bound_lng2']; if (isset($_REQUEST['posttype'])) { /** * Used to insert the dummy post data per post type. * * Uses dynamic hook, geodir_insert_dummy_posts_$_REQUEST['posttype']. * * @since 1.0.0 */ do_action('geodir_insert_dummy_posts_' . $_REQUEST['posttype']); } break; } } else { wp_redirect(geodir_login_url()); exit; } } if (isset($_REQUEST['geodir_import_data']) && $_REQUEST['geodir_import_data'] != '') { if (current_user_can('manage_options')) { geodir_import_data(); } else { wp_redirect(geodir_login_url()); exit; } } if (isset($_REQUEST['popuptype']) && $_REQUEST['popuptype'] != '' && isset($_REQUEST['post_id']) && $_REQUEST['post_id'] != '') { if ($_REQUEST['popuptype'] == 'b_send_inquiry' || $_REQUEST['popuptype'] == 'b_sendtofriend') { require_once geodir_plugin_path() . '/geodirectory-templates/popup-forms.php'; } exit; } /*if(isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'filter_ajax'){ include_once ( geodir_plugin_path() . '/geodirectory-templates/advance-search-form.php'); }*/ if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'map_ajax') { /** * Contains map marker functions. * * @since 1.0.0 * @package GeoDirectory */ include_once geodir_plugin_path() . '/geodirectory-functions/map-functions/get_markers.php'; } if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'favorite') { if (is_user_logged_in()) { switch ($_REQUEST['ajax_action']) { case "add": geodir_add_to_favorite($_REQUEST['pid']); break; case "remove": geodir_remove_from_favorite($_REQUEST['pid']); break; } } else { wp_redirect(geodir_login_url()); exit; } } if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'add_listing') { $is_current_user_owner = true; if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { $is_current_user_owner = geodir_listing_belong_to_current_user($_REQUEST['pid']); } $request = isset($_SESSION['listing']) ? unserialize($_SESSION['listing']) : ''; if (is_user_logged_in() && $is_current_user_owner) { switch ($_REQUEST['ajax_action']) { case "add": case "update": if (isset($request['geodir_spamblocker']) && $request['geodir_spamblocker'] == '64' && isset($request['geodir_filled_by_spam_bot']) && $request['geodir_filled_by_spam_bot'] == '') { $last_id = geodir_save_listing(); if ($last_id) { //$redirect_to = get_permalink( $last_id ); $redirect_to = geodir_getlink(get_permalink(geodir_success_page_id()), array('pid' => $last_id)); } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { $redirect_to = get_permalink(geodir_add_listing_page_id()); $redirect_to = geodir_getlink($redirect_to, array('pid' => $post->pid), false); } else { $redirect_to = get_permalink(geodir_add_listing_page_id()); } wp_redirect($redirect_to); } else { if (isset($_SESSION['listing'])) { unset($_SESSION['listing']); } wp_redirect(home_url()); } break; case "cancel": unset($_SESSION['listing']); if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '' && get_permalink($_REQUEST['pid'])) { wp_redirect(get_permalink($_REQUEST['pid'])); } else { geodir_remove_temp_images(); wp_redirect(geodir_getlink(get_permalink(geodir_add_listing_page_id()), array('listing_type' => $_REQUEST['listing_type']))); } break; case "publish": if (isset($request['geodir_spamblocker']) && $request['geodir_spamblocker'] == '64' && isset($request['geodir_filled_by_spam_bot']) && $request['geodir_filled_by_spam_bot'] == '') { if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { $new_post = array(); $new_post['ID'] = $_REQUEST['pid']; //$new_post['post_status'] = 'publish'; $lastid = wp_update_post($new_post); if (isset($_SESSION['listing'])) { unset($_SESSION['listing']); } wp_redirect(get_permalink($lastid)); } else { $last_id = geodir_save_listing(); if ($last_id) { //$redirect_to = get_permalink( $last_id ); $redirect_to = geodir_getlink(get_permalink(geodir_success_page_id()), array('pid' => $last_id)); } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { $redirect_to = get_permalink(geodir_add_listing_page_id()); $redirect_to = geodir_getlink($redirect_to, array('pid' => $post->pid), false); } else { $redirect_to = get_permalink(geodir_add_listing_page_id()); } if (isset($_SESSION['listing'])) { unset($_SESSION['listing']); } wp_redirect($redirect_to); } } else { if (isset($_SESSION['listing'])) { unset($_SESSION['listing']); } wp_redirect(home_url()); } break; case "delete": if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { global $current_user; get_currentuserinfo(); if (get_option('geodir_disable_perm_delete')) { $lastid = wp_trash_post($_REQUEST['pid']); } else { $lastid = wp_delete_post($_REQUEST['pid']); } if ($lastid && !is_wp_error($lastid)) { wp_redirect($_SERVER['HTTP_REFERER']); } //wp_redirect( geodir_getlink(get_author_posts_url($current_user->ID),array('geodir_dashbord'=>'true','stype'=>$post_type ),false) ); } break; } if (isset($_SESSION['listing'])) { unset($_SESSION['listing']); } } else { if (isset($_SESSION['listing'])) { unset($_SESSION['listing']); } wp_redirect(geodir_login_url()); exit; } } if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'user_login') { /** * Contains registration and login functions. * @todo Fix the file path. * * @since 1.0.0 * @package GeoDirectory */ include_once geodir_plugin_path() . '/geodirectory-functions/geodirectory_reg.php'; } if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'geodir_get_term_list') { $terms_o = get_terms(sanitize_text_field($_REQUEST['term'])); // Skip terms which has no listing if (!empty($terms_o)) { $filter_terms = array(); foreach ($terms_o as $term) { if ($term->count > 0) { $filter_terms[] = $term; } } $terms_o = $filter_terms; } $terms = geodir_sort_terms($terms_o, 'count'); geodir_helper_cat_list_output($terms, intval($_REQUEST['limit'])); exit; } die; }