/** * 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 }
/** * Outputs the edit post link. * * Outputs the edit post link if the current logged in user owns the post. * * @global bool $preview True if the current page is add listing preview page. False if not. * @global WP_Post|null $post The current post, if available. * @since 1.0.0 * @package GeoDirectory */ function geodir_edit_post_link() { global $post, $preview; ob_start(); // Start buffering; /** * This is called before the edit post link html in the function geodir_edit_post_link() * * @since 1.0.0 */ do_action('geodir_before_edit_post_link'); if (!$preview) { //if(is_user_logged_in() && $post->post_author == get_current_user_id()) $is_current_user_owner = geodir_listing_belong_to_current_user(); if ($is_current_user_owner) { $post_id = $post->ID; if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { $post_id = esc_attr($_REQUEST['pid']); } $postlink = get_permalink(geodir_add_listing_page_id()); $editlink = geodir_getlink($postlink, array('pid' => $post_id), false); echo ' <p class="edit_link"><i class="fa fa-pencil"></i> <a href="' . $editlink . '">' . __('Edit this Post', 'geodirectory') . '</a></p>'; } } // end of if, if its a preview or not /** * This is called after the edit post link html in the function geodir_edit_post_link() * * @since 1.0.0 */ do_action('geodir_after_edit_post_link'); $content_html = ob_get_clean(); if (trim($content_html) != '') { $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>'; } if ((int) get_option('geodir_disable_user_links_section') != 1) { /** * Filter the geodir_edit_post_link() function content. * * @param string $content_html The output html of the geodir_edit_post_link() function. */ echo $content_html = apply_filters('geodir_edit_post_link_html', $content_html); } }
/** * Returns the post type link with parameters. * * @since 1.0.0 * @since 1.5.5 Fixed post type archive link for selected location. * @package GeoDirectory * * @global bool $geodir_add_location_url If true it will add location name in url. * @global object $post WordPress Post object. * * @param string $link The post link. * @param string $post_type The post type. * @return string The modified link. */ function geodir_posttype_link($link, $post_type) { global $geodir_add_location_url, $post; $location_terms = array(); if (in_array($post_type, geodir_get_posttypes())) { if (get_option('geodir_add_location_url') && isset($_SESSION['gd_multi_location']) && $_SESSION['gd_multi_location'] == 1) { if (geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) { $location_terms = array('gd_country' => $post->country_slug, 'gd_region' => $post->region_slug, 'gd_city' => $post->city_slug); } else { $location_terms = geodir_get_current_location_terms('query_vars'); } $location_terms = geodir_remove_location_terms($location_terms); if (!empty($location_terms)) { if (get_option('permalink_structure') != '') { $location_terms = implode("/", $location_terms); $location_terms = rtrim($location_terms, '/'); $link .= urldecode($location_terms) . '/'; } else { $link = geodir_getlink($link, $location_terms); } } } } return $link; }
function geodir_user_add_claim() { global $wp_query, $post, $General, $wpdb, $plugin_prefix, $current_user; if (isset($_REQUEST['add_claim_nonce_field']) && isset($_REQUEST['geodir_pid']) && is_user_logged_in()) { if (!wp_verify_nonce($_REQUEST['add_claim_nonce_field'], 'add_claim_nonce' . $_REQUEST['geodir_pid'])) { return; } $list_id = $pid = $_POST['geodir_pid']; $claim_post = get_post($pid); if (isset($_POST['geodir_sendact']) && $_POST['geodir_sendact'] == 'add_claim') { $uid = $claim_post->post_author; $list_title = $claim_post->post_title; $user_id = $current_user->ID; $user_name = $current_user->user_login; $user_email = $current_user->user_email; $user_fullname = $_POST['geodir_full_name']; $user_number = $_POST['geodir_user_number']; $user_position = $_POST['geodir_user_position']; $user_comments = $_POST['geodir_user_comments']; $claim_date = date("F j, Y, g:i a"); $org_author = get_the_author_meta('login', $uid); $org_authorid = $claim_post->post_author; $rand_string = createRandomString(); $user_ip = getenv("REMOTE_ADDR"); // Force to upgrade to complete claim listing $force_upgrade = geodir_claim_force_upgrade(); $package_list = geodir_claim_payment_package_list($claim_post->post_type); if ($force_upgrade && !empty($package_list)) { $geodir_upgrade_pkg = isset($_POST['geodir_claim_pkg']) ? $_POST['geodir_claim_pkg'] : ''; $package_info = geodir_get_package_info_by_id($geodir_upgrade_pkg); if (empty($package_info) || !$list_id) { return; } } if ($_REQUEST['geodir_pid']) { $claimsql = $wpdb->prepare("INSERT INTO " . GEODIR_CLAIM_TABLE . " (list_id, list_title, user_id, user_name, user_email, user_fullname, user_number, user_position, user_comments, claim_date, org_author, org_authorid, rand_string, user_ip ) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s, %s )", array($list_id, $list_title, $user_id, $user_name, $user_email, $user_fullname, $user_number, $user_position, $user_comments, $claim_date, $org_author, $org_authorid, $rand_string, $user_ip)); $claim = $wpdb->query($claimsql); // Force to upgrade to complete claim listing if ($force_upgrade && !empty($package_list) && $claim && $wpdb->insert_id) { if (!(double) $package_info->amount > 0) { // Free price package plan $upgrade_pkg_data = array(); $upgrade_pkg_data['post_id'] = $list_id; $upgrade_pkg_data['package_id'] = $geodir_upgrade_pkg; $upgrade_pkg_data['pid'] = $wpdb->insert_id; $upgrade_pkg_data['date'] = date_i18n('Y-m-d H:i:s', time()); $upgrade_pkg_data['amount'] = $package_info->amount; $upgrade_pkg_data['user_id'] = $user_id; $upgrade_pkg_data['author_id'] = $org_authorid; $upgrade_pkg_data = maybe_serialize($upgrade_pkg_data); $sql = $wpdb->prepare("UPDATE " . GEODIR_CLAIM_TABLE . " SET `upgrade_pkg_id`=%d, `upgrade_pkg_data`=%s WHERE `pid`=%d", array($geodir_upgrade_pkg, $upgrade_pkg_data, $wpdb->insert_id)); $wpdb->query($sql); } } geodir_adminEmail($list_id, $user_id, 'claim_requested'); /* email to admin*/ geodir_clientEmail($list_id, $user_id, 'claim_requested'); /* email to client*/ } if (get_option('geodir_claim_auto_approve') == 'yes') { geodir_clientEmail($list_id, $user_id, 'auto_claim', $rand_string); /* email to client*/ } $postlink = get_permalink($claim_post->ID); $url = geodir_getlink($postlink, array('geodir_claim_request' => 'success'), false); wp_redirect($url); } } else { wp_redirect(home_url() . '/?geodir_signup=true'); exit; } }
</a> <?php } geodir_favourite_html($post->post_author, $post->ID); /** * Called after printing favorite html. * * @since 1.0.0 */ do_action('geodir_after_favorite_html', $post->ID, 'widget'); if ($post->post_author == get_current_user_id()) { $addplacelink = get_permalink(geodir_add_listing_page_id()); $editlink = geodir_getlink($addplacelink, array('pid' => $post->ID), false); $upgradelink = geodir_getlink($editlink, array('upgrade' => '1'), false); $ajaxlink = geodir_get_ajax_url(); $deletelink = geodir_getlink($ajaxlink, array('geodir_ajax' => 'add_listing', 'ajax_action' => 'delete', 'pid' => $post->ID), false); ?> <span class="geodir-authorlink clearfix"> <?php if (isset($_REQUEST['geodir_dashbord']) && $_REQUEST['geodir_dashbord']) { /** This action is documented in geodirectory-templates/listing-listview.php */ do_action('geodir_before_edit_post_link_on_listing'); ?> <a href="<?php echo $editlink; ?> " class="geodir-edit" title="<?php _e('Edit Listing', 'geodirectory'); ?> ">
/** * 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_getlink(home_url(), array('geodir_signup' => 'true'), false); $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 apply_filters('geodir_signup_reg_submit_link', home_url() . '/index.php?geodir_signup=true'); ?> " 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 apply_filters('geodir_signup_reg_form_link', home_url() . '/?geodir_signup=true&page1=sign_up'); ?> " 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 apply_filters('geodir_signup_forgot_form_link', home_url() . '/?geodir_signup=true&page1=sign_in'); ?> " class="goedir-forgot-link"><?php echo FORGOT_PW_TEXT; ?> </a></p></div> </form> <?php } echo $after_widget; }
function geodir_display_post_upgrade_link_on_listing() { global $post; $addplacelink = get_permalink(get_option('geodir_add_listing_page')); $editlink = geodir_getlink($addplacelink, array('pid' => $post->ID), false); $upgradelink = geodir_getlink($editlink, array('package_id' => $post->package_id), false); $post_status = get_post_status($post->ID); // show renew link before pre expiry days * 2 $post_expire_date = isset($post->expire_date) ? $post->expire_date : ''; $preexpiry_notice = false; if (get_option('geodir_listing_preexpiry_notice_disable') && get_option('geodir_listing_preexpiry_notice_days') != '' && $post_expire_date != '0000-00-00' && $post_expire_date != '' && strtolower($post_expire_date) != 'never' && strtotime($post_expire_date) > strtotime(date('01-01-1970'))) { $preexpiry_date = strtotime($post_expire_date) - DAY_IN_SECONDS * get_option('geodir_listing_preexpiry_notice_days') * 2; $preexpiry_notice = $preexpiry_date <= strtotime(date('Y-m-d')) ? true : false; } $action_link = __('Upgrade Listing', GEODIRPAYMENT_TEXTDOMAIN); $action_type = 'upgrade'; if ($post_status == 'draft' || $preexpiry_notice) { $action_link = __('Renew Listing', GEODIRPAYMENT_TEXTDOMAIN); $action_type = 'renew'; } if ($action_type == 'upgrade') { ?> <a href="<?php echo $upgradelink; ?> " class="geodir-upgrade" title="<?php echo $action_link; ?> "> <?php $geodir_listing_upgrade_icon = apply_filters('geodir_listing_upgrade_icon', 'fa fa-chevron-circle-up'); echo '<i class="' . $geodir_listing_upgrade_icon . '"></i>'; ?> <?php echo $action_link; ?> </a> <?php } else { ?> <a href="<?php echo $upgradelink; ?> " class="geodir-upgrade" title="<?php echo $action_link; ?> "> <?php $geodir_listing_renew_icon = apply_filters('geodir_listing_renew_icon', 'fa fa-chevron-circle-up'); echo '<i class="' . $geodir_listing_renew_icon . '"></i>'; ?> <?php echo $action_link; ?> </a> <?php } }
/** * 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(home_url() . '/?geodir_signup=true'); 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(home_url() . '/?geodir_signup=true'); exit; } } if (isset($_REQUEST['geodir_import_data']) && $_REQUEST['geodir_import_data'] != '') { if (current_user_can('manage_options')) { geodir_import_data(); } else { wp_redirect(home_url() . '/?geodir_signup=true'); 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(home_url() . '/?geodir_signup=true'); 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(); $post_type = get_post_type($_REQUEST['pid']); $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(home_url() . '/?geodir_signup=true'); 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; }
/** * GeoDirectory Backend Admin Panel. * * Handles the display of the main GeoDirectory admin panel. * * @since 1.0.0 * @package GeoDirectory * @global string $current_tab Current tab in geodirectory settings. * @global object $geodirectory GeoDirectory plugin object. */ function geodir_admin_panel() { global $geodirectory; global $current_tab; ?> <div id="gd-wrapper-main" class="wrap geodirectory"> <?php /** * Called just after the opening wrapper div for the GD settings page in the admin area. * * @since 1.0.0 */ do_action('geodir_before_admin_panel'); ?> <div class="gd-wrapper gd-wrapper-vr clearfix"> <div class="gd-left-nav"> <img src="<?php echo geodir_plugin_url(); ?> /geodirectory-assets/images/geo-logo.png" alt="geo-logo" class="geo-logo"/> <img src="<?php echo geodir_plugin_url(); ?> /geodirectory-assets/images/geo-logoalter.png" alt="geo-logo" class="geo-logoalter"/> <ul> <?php $tabs = array(); /** * Filter the GD admin settings tabs on the left of the admin menu. * * @since 1.0.0 * @param array $tabs The array of tabs to display. */ $tabs = apply_filters('geodir_settings_tabs_array', $tabs); update_option('geodir_tabs', $tabs); // Important to show settings menu dropdown foreach ($tabs as $name => $args) { $label = $args['label']; $query_string = ''; if (isset($args['subtabs']) && !empty($args['subtabs'])) { $subtabs = $args['subtabs']; $query_string = '&subtab=' . $subtabs[0]['subtab']; } $tab_link = admin_url('admin.php?page=geodirectory&tab=' . $name . $query_string); if (isset($args['url']) && $args['url'] != '') { $tab_link = $args['url']; } if (!empty($args['request'])) { $tab_link = geodir_getlink($tab_link, $args['request']); } if (isset($args['target']) && $args['target'] != '') { $tab_target = " target='" . $args['target'] . "' "; } else { $tab_target = ''; } $tab_active = ''; if ($current_tab == $name) { $tab_active = ' class="tab-active" '; } /** * Called before the individual settings tabs are output. * * @since 1.0.0 * @param string $name The name of the settings tab. * @see 'geodir_after_settings_tabs' */ do_action('geodir_before_settings_tabs', $name); echo '<li ' . $tab_active . ' ><a href="' . $tab_link . '" ' . $tab_target . ' >' . $label . '</a></li>'; /** * Called after the individual settings tabs are output. * * @since 1.0.0 * @param string $name The name of the settings tab. * @see 'geodir_before_settings_tabs' */ do_action('geodir_after_settings_tabs', $name); } /** * Called after the GD settings tabs have been output. * * Called before the closing `ul` so can be used to add new settings tab links. * * @since 1.0.0 */ do_action('geodir_settings_tabs'); ?> </ul> </div> <!--gd-left-nav ends here--> <div class="gd-content-wrapper"> <div class="gd-tabs-main"> <?php unset($subtabs); if (isset($tabs[$current_tab]['subtabs'])) { $subtabs = $tabs[$current_tab]['subtabs']; } $form_action = ''; if (!empty($subtabs)) { ?> <dl class="gd-tab-head"> <?php foreach ($subtabs as $sub) { $subtab_active = ''; if (isset($_REQUEST['subtab']) && $sub['subtab'] == $_REQUEST['subtab']) { $subtab_active = 'class="gd-tab-active"'; $form_action = isset($sub['form_action']) ? $sub['form_action'] : ''; } $sub_tabs_link = admin_url() . 'admin.php?page=geodirectory&tab=' . $current_tab . '&subtab=' . $sub['subtab']; if (isset($sub['request']) && is_array($sub['request']) && !empty($sub['request'])) { $sub_tabs_link = geodir_getlink($sub_tabs_link, $sub['request']); } echo '<dd ' . $subtab_active . ' id="claim_listing"><a href="' . $sub_tabs_link . '" >' . $sub['label'] . '</a></dd>'; } ?> </dl> <?php } ?> <div class="gd-tab-content <?php if (empty($subtabs)) { echo "inner_contet_tabs"; } ?> "> <form method="post" id="mainform" class="geodir_optionform <?php echo $current_tab . ' '; if (isset($sub['subtab'])) { echo $sub['subtab']; } ?> " action="<?php echo $form_action; ?> " enctype="multipart/form-data"> <input type="hidden" class="active_tab" name="active_tab" value="<?php if (isset($_REQUEST['active_tab'])) { echo $_REQUEST['active_tab']; } ?> "/> <?php wp_nonce_field('geodir-settings', '_wpnonce', true, true); ?> <?php wp_nonce_field('geodir-settings-' . $current_tab, '_wpnonce-' . $current_tab, true, true); ?> <?php /** * Used to call the content of each GD settings tab page. * * @since 1.0.0 */ do_action('geodir_admin_option_form', $current_tab); ?> </form> </div> </div> </div> </div> </div> <script type="text/javascript"> jQuery(window).load(function () { // Subsubsub tabs jQuery('ul.subsubsub li a:eq(0)').addClass('current'); jQuery('.subsubsub_section .section:gt(0)').hide(); jQuery('ul.subsubsub li a').click(function () { /*jQuery('a', jQuery(this).closest('ul.subsubsub')).removeClass('current'); jQuery(this).addClass('current'); jQuery('.section', jQuery(this).closest('.subsubsub_section')).hide(); jQuery( jQuery(this).attr('href') ).show(); jQuery('#last_tab').val( jQuery(this).attr('href') ); return false;*/ }); <?php if (isset($_GET['subtab']) && $_GET['subtab']) { echo 'jQuery("ul.subsubsub li a[href=#' . $_GET['subtab'] . ']").click();'; } ?> // Countries jQuery('select#geodirectory_allowed_countries').change(function () { if (jQuery(this).val() == "specific") { jQuery(this).parent().parent().next('tr').show(); } else { jQuery(this).parent().parent().next('tr').hide(); } }).change(); // Color picker jQuery('.colorpick').each(function () { jQuery('.colorpickdiv', jQuery(this).parent()).farbtastic(this); jQuery(this).click(function () { if (jQuery(this).val() == "") jQuery(this).val('#'); jQuery('.colorpickdiv', jQuery(this).parent()).show(); }); }); jQuery(document).mousedown(function () { jQuery('.colorpickdiv').hide(); }); // Edit prompt jQuery(function () { var changed = false; jQuery('input, textarea, select, checkbox').change(function () { changed = true; }); jQuery('.geodirectory-nav-tab-wrapper a').click(function () { if (changed) { window.onbeforeunload = function () { return '<?php echo __('The changes you made will be lost if you navigate away from this page.', 'geodirectory'); ?> '; } } else { window.onbeforeunload = ''; } }); jQuery('.submit input').click(function () { window.onbeforeunload = ''; }); }); // Sorting jQuery('table.wd_gateways tbody').sortable({ items: 'tr', cursor: 'move', axis: 'y', handle: 'td', scrollSensitivity: 40, helper: function (e, ui) { ui.children().each(function () { jQuery(this).width(jQuery(this).width()); }); ui.css('left', '0'); return ui; }, start: function (event, ui) { ui.item.css('background-color', '#f6f6f6'); }, stop: function (event, ui) { ui.item.removeAttr('style'); } }); // Chosen selects jQuery("select.chosen_select").chosen(); jQuery("select.chosen_select_nostd").chosen({ allow_single_deselect: 'true' }); }); </script> <?php }
/** * Returns location link based on location type. * * @since 1.0.0 * @package GeoDirectory * @param string $which_location Location link type. Default: 'current'. * @return bool|string */ function geodir_get_location_link($which_location = 'current') { $location_link = get_permalink(geodir_location_page_id()); if (get_option('permalink_structure') != '') { //$location_prefix = get_option('geodir_location_prefix'); //$location_link = substr_replace($location_link, $location_prefix, strpos($location_link, 'location'), strlen('location')); } if ($which_location == 'base') { return $location_link; } else { $location_terms = geodir_get_current_location_terms(); if (!empty($location_terms)) { if (get_option('permalink_structure') != '') { $location_terms = implode("/", $location_terms); $location_terms = rtrim($location_terms, '/'); $location_link .= $location_terms; } else { $location_link = geodir_getlink($location_link, $location_terms); } } } return $location_link; }
function payment_handler() { if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'add_listing') { switch ($_REQUEST['ajax_action']) { case "paynow": $request = isset($_SESSION['listing']) ? unserialize($_SESSION['listing']) : ''; 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['paymentmethod']) && isset($_SESSION['listing'])) { $last_id = geodir_save_listing(); $invoice_id = geodir_create_invoice($last_id, $_REQUEST['price_select'], $_REQUEST['paymentmethod'], $_REQUEST['coupon_code']); geodir_update_invoice_status($invoice_id, 'unpaid'); $paymentmethod = $_REQUEST['paymentmethod']; do_action('geodir_payment_form_handler_' . $paymentmethod, $invoice_id); } else { $postlink = get_permalink(get_option('geodir_add_listing_page')); $redirect_url = geodir_getlink($postlink, array('listing_type' => $_REQUEST['listing_type']), false); wp_redirect($redirect_url); } } else { if (isset($_SESSION['listing'])) { unset($_SESSION['listing']); } wp_redirect(home_url()); } break; } } }
/** * Locates template based on the template type. * * @since 1.0.0 * @package GeoDirectory * @global string $post_type The post type. * @global object $wp WordPress object. * @global object $post WordPress post object. * @param string $template The template type. * @return bool|string The template path. */ function geodir_locate_template($template = '') { global $post_type, $wp, $post; $fields = array(); switch ($template) { case 'signup': return $template = locate_template(array("geodirectory/geodir-signup.php")); break; case 'add-listing': $sc_post_type = ''; if (is_page() && isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) { $listing_page_id = $post->ID; $regex_pattern = get_shortcode_regex(); preg_match('/' . $regex_pattern . '/s', $post->post_content, $regex_matches); if (!empty($regex_matches) && isset($regex_matches[2]) == 'gd_add_listing' && isset($regex_matches[3])) { $shortcode_atts = shortcode_parse_atts($regex_matches[3]); $sc_post_type = !empty($shortcode_atts) && isset($shortcode_atts['listing_type']) && !empty($shortcode_atts['listing_type']) ? $shortcode_atts['listing_type'] : ''; } } else { $listing_page_id = geodir_add_listing_page_id(); } $is_wpml = function_exists('icl_object_id') ? true : false; if ($listing_page_id != '' && (is_page($listing_page_id) || $is_wpml && !empty($wp->query_vars['page_id'])) && isset($_REQUEST['listing_type']) && in_array($_REQUEST['listing_type'], geodir_get_posttypes())) { $post_type = $_REQUEST['listing_type']; } if (empty($post_type) && !isset($_REQUEST['pid'])) { $pagename = $wp->query_vars['pagename']; $post_types = geodir_get_posttypes(); if (!empty($post_types)) { $post_type = $post_types[0]; } if ($sc_post_type != '') { $post_type = $sc_post_type; } if ($is_wpml && !empty($wp->query_vars['page_id'])) { wp_redirect(geodir_getlink(get_permalink($wp->query_vars['page_id']), array('listing_type' => $post_type))); } else { wp_redirect(trailingslashit(get_site_url()) . $pagename . '/?listing_type=' . $post_type); } exit; } return $template = locate_template(array("geodirectory/add-{$post_type}.php", "geodirectory/add-listing.php")); break; case 'success': $success_page_id = geodir_success_page_id(); if ($success_page_id != '' && is_page($success_page_id) && isset($_REQUEST['listing_type']) && in_array($_REQUEST['listing_type'], geodir_get_posttypes())) { $post_type = $_REQUEST['listing_type']; } return $template = locate_template(array("geodirectory/{$post_type}-success.php", "geodirectory/listing-success.php")); break; case 'detail': case 'preview': if (in_array(get_post_type(), geodir_get_posttypes())) { $post_type = get_post_type(); } return $template = locate_template(array("geodirectory/single-{$post_type}.php", "geodirectory/listing-detail.php")); break; case 'listing': $templates = array(); if (is_post_type_archive() && in_array(get_post_type(), geodir_get_posttypes())) { $post_type = get_post_type(); $templates[] = "geodirectory/archive-{$post_type}.php"; } if (is_tax() && geodir_get_taxonomy_posttype()) { $query_obj = get_queried_object(); $curr_taxonomy = isset($query_obj->taxonomy) ? $query_obj->taxonomy : ''; $curr_term = isset($query_obj->slug) ? $query_obj->slug : ''; $templates[] = "geodirectory/taxonomy-{$curr_taxonomy}-{$curr_term}.php"; $templates[] = "geodirectory/taxonomy-{$curr_taxonomy}.php"; } $templates[] = "geodirectory/geodir-listing.php"; return $template = locate_template($templates); break; case 'information': return $template = locate_template(array("geodirectory/geodir-information.php")); break; case 'author': return $template = locate_template(array("geodirectory/geodir-author.php")); break; case 'search': return $template = locate_template(array("geodirectory/geodir-search.php")); break; case 'location': return $template = locate_template(array("geodirectory/geodir-location.php")); break; case 'geodir-home': return $template = locate_template(array("geodirectory/geodir-home.php")); break; case 'listing-listview': $template = locate_template(array("geodirectory/listing-listview.php")); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/listing-listview.php'; } return $template; break; case 'widget-listing-listview': $template = locate_template(array("geodirectory/widget-listing-listview.php")); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/widget-listing-listview.php'; } return $template; break; } return false; }
/** * Returns the post type link with parameters. * * @since 1.0.0 * @package GeoDirectory * @param string $link The post link. * @param string $post_type The post type. * @return string The modified link. */ function geodir_posttype_link($link, $post_type) { global $geodir_add_location_url; $location_terms = array(); if (in_array($post_type, geodir_get_posttypes())) { if (get_option('geodir_add_location_url') && isset($_SESSION['gd_multi_location']) && $_SESSION['gd_multi_location'] == 1) { $location_terms = geodir_get_current_location_terms('query_vars'); if (!empty($location_terms)) { if (get_option('permalink_structure') != '') { $location_terms = implode("/", $location_terms); $location_terms = rtrim($location_terms, '/'); return $link . urldecode($location_terms) . '/'; } else { return geodir_getlink($link, $location_terms); } } } } return $link; }
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 }
/** * Filter the HTML button for publishing the listing on the preview page. * * @since 1.0.0 * @param string $publish_listing_form_button The HTML for the submit button. */ $publish_listing_form_button = apply_filters('geodir_publish_listing_form_button', $publish_listing_form_button); echo $publish_listing_form_button; $post_id = ''; if (isset($post->pid)) { $post_id = $post->pid; } elseif (isset($_REQUEST['pid'])) { $post_id = $_REQUEST['pid']; } $postlink = get_permalink(geodir_add_listing_page_id()); $postlink = geodir_getlink($postlink, array('pid' => $post_id, 'backandedit' => '1', 'listing_type' => $post_type), false); ob_start(); // start go back and edit / cancel buffering ?> <a href="<?php echo $postlink; ?> " class="geodir_goback"><?php echo PRO_BACK_AND_EDIT_TEXT; ?> </a> <input type="button" name="Cancel" value="<?php echo PRO_CANCEL_BUTTON; ?> " class="geodir_button geodir_cancle_button"