/** * Set custom page title. * * @since 1.0.0 * @package GeoDirectory * @global object $wp WordPress object. * @param string $title Old title. * @param string $sep Title separator. * @return string Modified title. */ function geodir_custom_page_title($title = '', $sep = '') { global $wp; if ($sep == '') { /** * Filter the pae title separator. * * @since 1.0.0 * @package GeoDirectory * @param string $sep The separator, default: `|`. */ $sep = apply_filters('geodir_page_title_separator', '|'); } if ($title == '') { $sitename = get_bloginfo('name'); $site_description = get_bloginfo('description'); $title = $sitename . ' ' . $sep . ' ' . $site_description; } if (is_search() && isset($_REQUEST['geodir_search'])) { $all_postypes = geodir_get_posttypes(); $keyword = esc_sql(strip_tags(get_query_var('s'))); $stype = esc_sql(strip_tags(esc_attr($_REQUEST['stype']))); $snear = esc_sql(strip_tags(esc_attr($_REQUEST['snear']))); if ($stype && in_array($stype, $all_postypes)) { $title = $keyword; if (!empty($stype)) { $posttype_obj = get_post_type_object($stype); $title = $title . ' ' . $sep . ' ' . ucfirst($posttype_obj->labels->name); } if (!empty($snear)) { $title = $title . ' ' . $sep . ' ' . __('Near', 'geodirectory') . ' ' . $snear; } $sitename = get_bloginfo('name'); $title = $title . ' ' . $sep . ' ' . __('Search Results', 'geodirectory') . ' ' . $sep . ' ' . $sitename; } } //print_r($wp->query_vars) ; if (isset($wp->query_vars['pagename']) && $wp->query_vars['pagename'] != '') { $page = get_page_by_path($wp->query_vars['pagename']); } if (!empty($page)) { $listing_page_id = geodir_add_listing_page_id(); if ($listing_page_id != '' && $page->ID == $listing_page_id) { if (isset($_REQUEST['listing_type']) && $_REQUEST['listing_type'] != '') { $listing_type = esc_attr($_REQUEST['listing_type']); $post_type_info = geodir_get_posttype_info($listing_type); if (!empty($title)) { $title_array = explode($sep, $title); $title_array[0] = ucwords(__('Add', 'geodirectory') . ' ' . __($post_type_info['labels']['singular_name'], 'geodirectory')) . ' '; $title = implode($sep, $title_array); } else { $title = ucwords(__('Add', 'geodirectory') . ' ' . __($post_type_info['labels']['singular_name'], 'geodirectory')); } //$title .= " " . $gd_country . $gd_region . $gd_city . "$sep "; } } } return $title; }
" class="geodir-pcomments"><i class="fa fa-comments"></i> <?php geodir_comments_number($post->rating_count); ?> </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"
/** * 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; }
/** * 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); } }
/** * 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; }
function geodir_publish_payment_listing_form_before_msg() { global $post, $wpdb; $post_type = $post->listing_type; if (isset($_REQUEST['package_id']) && $_REQUEST['package_id'] != '') { $package_price_info = geodir_get_post_package_info($_REQUEST['package_id']); } else { if (!empty($post) && isset($post->package_id)) { $package_price_info = geodir_get_post_package_info($post->package_id); } } $package_id = isset($package_price_info['pid']) ? $package_price_info['pid'] : ''; $payable_amount = isset($package_price_info['amount']) ? $package_price_info['amount'] : 0; $alive_days = isset($package_price_info['days']) ? $package_price_info['days'] : 0; $type_title = isset($package_price_info['title']) ? $package_price_info['title'] : ''; $sub_active = isset($package_price_info['sub_active']) ? $package_price_info['sub_active'] : ''; if ($sub_active) { $sub_units_num_var = $package_price_info['sub_units_num']; $sub_units_var = $package_price_info['sub_units']; $alive_days = geodir_payment_get_units_to_days($sub_units_num_var, $sub_units_var); // paypal free trial $sub_num_trial_days_var = $package_price_info['sub_num_trial_days']; $sub_num_trial_units_var = $package_price_info['sub_num_trial_units']; if ($sub_num_trial_days_var > 0) { $alive_days = geodir_payment_get_units_to_days($sub_num_trial_days_var, $sub_num_trial_units_var); } } $org_payable_amount = $payable_amount; /* -------- START LISTING FORM MESSAGE*/ ob_start(); if (isset($_REQUEST['coupon_code']) && $_REQUEST['coupon_code'] != '') { if (geodir_is_valid_coupon($post_type, $_REQUEST['coupon_code'])) { $payable_amount = geodir_get_payable_amount_with_coupon($payable_amount, $_REQUEST['coupon_code']); } else { echo '<p class="error_msg_fix">' . WRONG_COUPON_MSG . '</p>'; } } if ($payable_amount > 0) { if ($alive_days == 0) { $alive_days = UNLIMITED; } echo '<h5 class="geodir_information">'; printf(GOING_TO_PAY_MSG, geodir_get_currency_sym() . $payable_amount, $alive_days, $type_title); echo '</h5>'; } else { if ($alive_days == 0) { $alive_days = UNLIMITED; } echo '<h5 class="geodir_information">'; if (!isset($_REQUEST['pid']) || $_REQUEST['pid'] == '') { printf(GOING_TO_FREE_MSG, $type_title, $alive_days); } else { printf(GOING_TO_UPDATE_MSG, geodir_get_currency_sym() . $payable_amount, $alive_days, $type_title); } echo '</h5>'; } echo $form_message = ob_get_clean(); /* -------- END LISTING FORM MESSAGE*/ /* -------- START LISTING FORM PAYMENT OPTIONS*/ ob_start(); ?> <input type="hidden" name="price_select" value="<?php if (isset($package_id)) { echo $package_id; } ?> " /> <input type="hidden" name="coupon_code" value="<?php if (isset($_REQUEST['coupon_code'])) { echo $_REQUEST['coupon_code']; } ?> " /> <?php if ($payable_amount > 0) { if ($sub_active) { $sub_m_arr = apply_filters('geodir_subscription_methods', array('payment_method_paypal')); $method_names = implode(',', array_fill(0, count($sub_m_arr), '%s')); $paymentsql = $wpdb->prepare("select * from {$wpdb->options} where option_name in ({$method_names}) order by option_id", $sub_m_arr); } else { $paymentsql = $wpdb->prepare("select * from {$wpdb->options} where option_name like %s order by option_id", array('payment_method_%')); } $paymentinfo = $wpdb->get_results($paymentsql); if ($paymentinfo) { ?> <h5 class="geodir_payment_head"> <?php echo SELECT_PAY_MEHTOD_TEXT; ?> </h5> <ul class="geodir_payment_method"> <?php $paymentOptionArray = array(); $paymethodKeyarray = array(); foreach ($paymentinfo as $paymentinfoObj) { $paymentInfo = unserialize($paymentinfoObj->option_value); if ($paymentInfo['isactive']) { $paymethodKeyarray[] = $paymentInfo['key']; $paymentOptionArray[$paymentInfo['display_order']][] = $paymentInfo; } } ksort($paymentOptionArray); if ($paymentOptionArray) { $poa = 0; foreach ($paymentOptionArray as $key => $paymentInfoval) { $poa++; for ($i = 0; $i < count($paymentInfoval); $i++) { $paymentInfo = $paymentInfoval[$i]; $jsfunction = 'onclick="showoptions(this.value);"'; $chked = ''; if ($poa == 1) { $chked = 'checked="checked"'; } ?> <li id="<?php echo $paymentInfo['key']; ?> "> <input <?php echo $jsfunction; ?> type="radio" value="<?php echo $paymentInfo['key']; ?> " id="<?php echo $paymentInfo['key']; ?> _id" name="paymentmethod" <?php echo $chked; ?> /> <?php echo $paymentInfo['name']; ?> <?php if (file_exists(GEODIR_PAYMENT_MANAGER_PATH . $paymentInfo['key'] . '/' . $paymentInfo['key'] . '.php')) { include_once GEODIR_PAYMENT_MANAGER_PATH . $paymentInfo['key'] . '/' . $paymentInfo['key'] . '.php'; } ?> </li><?php } } if (isset($paymethodKeyarray)) { ?> <script type="application/x-javascript"> jQuery(document).ready(function($){ var submit_button = $('#publish_listing .geodir_publish_button'); submit_button.on('click', function(event){ var payment_method = $('#publish_listing input[name="paymentmethod"]:checked').val(); if( payment_method === 'authorizenet' ) { if($('#cardholder_name').val()==''){ alert('<?php _e('Please enter Cardholder name', GEODIRPAYMENT_TEXTDOMAIN); ?> ');return false; } if($('#cc_number').val()==''){ alert('<?php _e('Please enter card number', GEODIRPAYMENT_TEXTDOMAIN); ?> ');return false; } if($('#cc_month').val()=='' || $('#cc_year').val()=='' ){ alert('<?php _e('Please enter expire date', GEODIRPAYMENT_TEXTDOMAIN); ?> ');return false; } return true; }else { return true; } }); }); function showoptions(paymethod){ <?php for ($i = 0; $i < count($paymethodKeyarray); $i++) { ?> showoptvar = '<?php echo $paymethodKeyarray[$i]; ?> options'; if(eval(document.getElementById(showoptvar))) { document.getElementById(showoptvar).style.display = 'none'; if(paymethod=='<?php echo $paymethodKeyarray[$i]; ?> ') { document.getElementById(showoptvar).style.display = ''; } } <?php } ?> } <?php for ($i = 0; $i < count($paymethodKeyarray); $i++) { ?> if(document.getElementById('<?php echo $paymethodKeyarray[$i]; ?> _id').checked) { showoptions(document.getElementById('<?php echo $paymethodKeyarray[$i]; ?> _id').value);} <?php } ?> </script> <?php } } else { ?> <li><?php echo NO_PAYMENT_METHOD_MSG; ?> </li> <?php } ?> </ul> <?php } } echo $html = ob_get_clean(); /* -------- END LISTING FORM PAYMENT OPTIONS*/ /* -------- START LISTING FORM BUTTON*/ ob_start(); if ((!isset($_REQUEST['pid']) || $_REQUEST['pid'] == '') && $payable_amount == 0) { ?> <input type="submit" name="Submit and Pay" value="<?php echo PRO_SUBMIT_BUTTON; ?> " class="geodir_button geodir_publish_button" /><?php } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '' && $payable_amount == 0) { ?> <input type="submit" name="Submit and Pay" value="<?php echo PRO_UPDATE_BUTTON; ?> " class="geodir_button geodir_publish_button" /><?php } elseif (isset($_REQUEST['package_id']) && $_REQUEST['package_id'] != '' && $payable_amount > 0 && (!isset($_REQUEST['pid']) || $_REQUEST['pid'] == '')) { ?> <input type="submit" name="Submit and Pay" value="<?php echo PRO_SUBMIT_PAY_BUTTON; ?> " class=" geodir_button geodir_publish_button" /><?php } elseif (isset($_REQUEST['package_id']) && $_REQUEST['package_id'] != '' && $org_payable_amount > 0 && (isset($_REQUEST['pid']) || $_REQUEST['pid'] != '')) { $post_status = get_post_status($_REQUEST['pid']); if ($post_status == 'draft') { ?> <input type="submit" name="Submit and Pay" value="<?php echo PRO_RENEW_BUTTON; ?> " class="geodir_button geodir_publish_button" /><?php } else { ?> <input type="submit" name="Submit and Pay" value="<?php echo PRO_UPGRADE_BUTTON; ?> " class="geodir_button geodir_publish_button" /><?php } } echo $listing_form_button = ob_get_clean(); /* -------- END LISTING FORM BUTTON*/ /* -------- START LISTING GO BACK LINK*/ $post_id = ''; if (isset($post->pid)) { $post_id = $post->pid; } elseif (isset($_REQUEST['pid'])) { $post_id = $_REQUEST['pid']; } if (isset($_REQUEST['add_listing_page_id'])) { $page_id = $_REQUEST['add_listing_page_id']; } else { $page_id = get_option('geodir_add_listing_page'); } //$postlink = get_permalink( $page_id ); $postlink = get_permalink(geodir_add_listing_page_id()); $postlink = geodir_getlink($postlink, array('pid' => $post_id, 'backandedit' => '1', 'listing_type' => $post_type), false); if (isset($_REQUEST['package_id']) && $_REQUEST['package_id'] != '') { $postlink = geodir_getlink($postlink, array('package_id' => $_REQUEST['package_id']), false); } ob_start(); ?> <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 cancle_button" onclick="window.location.href='<?php echo geodir_get_ajax_url() . '&geodir_ajax=add_listing&ajax_action=cancel&pid=' . $post_id . '&listing_type=' . $post_type; ?> '" /> <?php echo $listing_form_go_back = ob_get_clean(); }
/** * 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; }
$publish_listing_form_button = ob_get_clean(); /** * 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; ?> "