/** * wrapper close functions. * * @since 1.0.0 * @package GeoDirectory */ function geodir_divi_action_wrapper_close() { if (geodir_is_page('login')) { // We need to close extra divs generated by WRAPPER BEFORE MAIN CONTENT (below) because there is no sidebar on this page echo '</div></div>'; } }
function geodir_reviewrating_comments_script() { wp_enqueue_script('jquery'); wp_register_script('geodir-reviewrating-rating-js', GEODIR_REVIEWRATING_PLUGINDIR_URL . '/js/rating-script.js'); wp_enqueue_script('geodir-reviewrating-rating-js'); if (geodir_is_page('detail')) { wp_register_script('geodir-reviewrating-review-script', GEODIR_REVIEWRATING_PLUGINDIR_URL . '/js/comments-script.js'); wp_enqueue_script('geodir-reviewrating-review-script'); wp_register_style('geodir-reviewratingrating-style', GEODIR_REVIEWRATING_PLUGINDIR_URL . '/css/style.css'); wp_enqueue_style('geodir-reviewratingrating-style'); } // SCRIPT FOR UPLOAD wp_enqueue_script('plupload-all'); wp_enqueue_script('jquery-ui-sortable'); wp_register_script('geodir-reviewrating-plupload-script', GEODIR_REVIEWRATING_PLUGINDIR_URL . '/js/geodir-plupload.js'); wp_enqueue_script('geodir-reviewrating-plupload-script'); // place js config array for plupload $geodir_plupload_init = array('runtimes' => 'html5,silverlight,flash,html4', 'browse_button' => 'plupload-browse-button', 'container' => 'plupload-upload-ui', 'drop_element' => 'dropbox', 'file_data_name' => 'async-upload', 'multiple_queues' => true, 'max_file_size' => '2mb', 'url' => admin_url('admin-ajax.php'), 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), 'filters' => array(array('title' => __('Allowed Files', GEODIRREVIEWRATING_TEXTDOMAIN), 'extensions' => '*')), 'multipart' => true, 'urlstream_upload' => true, 'multi_selection' => false, 'multipart_params' => array('_ajax_nonce' => "", 'action' => 'geodir_reviewrating_plupload', 'imgid' => 0)); $geodir_reviewrating_plupload_config = json_encode($geodir_plupload_init); $geodir_plupload_init = array('geodir_reviewrating_plupload_config' => $geodir_reviewrating_plupload_config, 'geodir_totalImg' => 0, 'geodir_image_limit' => 10, 'geodir_upload_img_size' => '2mb'); wp_localize_script('geodir-reviewrating-plupload-script', 'geodir_reviewrating_plupload_localize', $geodir_plupload_init); }
/** * breadcrumbs. * * @since 1.0.0 * @package GeoDirectory */ function x_breadcrumbs() { if (x_get_option('x_breadcrumb_display', '1')) { // // 1. Delimiter between crumbs. // 2. Output text for the "Home" link. // 3. Link to the home page. // 4. Tag before the current crumb. // 5. Tag after the current crumb. // 6. Get page title. // 7. Get blog title. // 8. Get shop title. // global $post, $wp; if (geodir_is_page('detail') || geodir_is_page('listing') || isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id()) { geodir_breadcrumb(); } else { $stack = x_get_stack(); $delimiter = ' <span class="delimiter"><i class="x-icon-angle-right"></i></span> '; // 1 $home_text = '<span class="home"><i class="x-icon-home"></i></span>'; // 2 $home_link = home_url(); // 3 $current_before = '<span class="current">'; // 4 $current_after = '</span>'; // 5 $page_title = get_the_title(); // 6 $blog_title = get_the_title(get_option('page_for_posts', true)); // 7 $shop_title = get_theme_mod('x_' . $stack . '_shop_title'); // 8 if (function_exists('woocommerce_get_page_id')) { $shop_url = x_get_shop_link(); $shop_link = '<a href="' . $shop_url . '">' . $shop_title . '</a>'; } if (is_front_page()) { echo '<div class="x-breadcrumbs">' . $current_before . $home_text . $current_after . '</div>'; } elseif (is_home()) { echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter . $current_before . $blog_title . $current_after . '</div>'; } else { echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter; if (is_category()) { $the_cat = get_category(get_query_var('cat'), false); if ($the_cat->parent != 0) { echo get_category_parents($the_cat->parent, TRUE, $delimiter); } echo $current_before . single_cat_title('', false) . $current_after; } elseif (x_is_product_category()) { echo $shop_link . $delimiter . $current_before . single_cat_title('', false) . $current_after; } elseif (x_is_product_tag()) { echo $shop_link . $delimiter . $current_before . single_tag_title('', false) . $current_after; } elseif (is_search()) { echo $current_before . __('Search Results for ', '__x__') . '“' . get_search_query() . '”' . $current_after; } elseif (is_singular('post')) { if (get_option('page_for_posts') == is_front_page()) { echo $current_before . $page_title . $current_after; } else { echo '<a href="' . get_permalink(get_option('page_for_posts')) . '" title="' . esc_attr(__('See All Posts', '__x__')) . '">' . $blog_title . '</a>' . $delimiter . $current_before . $page_title . $current_after; } } elseif (x_is_portfolio()) { echo $current_before . get_the_title() . $current_after; } elseif (x_is_portfolio_item()) { $link = x_get_parent_portfolio_link(); $title = x_get_parent_portfolio_title(); echo '<a href="' . $link . '" title="' . esc_attr(__('See All Posts', '__x__')) . '">' . $title . '</a>' . $delimiter . $current_before . $page_title . $current_after; } elseif (x_is_product()) { echo $shop_link . $delimiter . $current_before . $page_title . $current_after; } elseif (is_page() && !$post->post_parent) { echo $current_before . $page_title . $current_after; } elseif (is_page() && $post->post_parent) { $parent_id = $post->post_parent; $breadcrumbs = array(); while ($parent_id) { $page = get_page($parent_id); $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>'; $parent_id = $page->post_parent; } $breadcrumbs = array_reverse($breadcrumbs); for ($i = 0; $i < count($breadcrumbs); $i++) { echo $breadcrumbs[$i]; if ($i != count($breadcrumbs) - 1) { echo $delimiter; } } echo $delimiter . $current_before . $page_title . $current_after; } elseif (is_tag()) { echo $current_before . single_tag_title('', false) . $current_after; } elseif (is_author()) { global $author; $userdata = get_userdata($author); echo $current_before . __('Posts by ', '__x__') . '“' . $userdata->display_name . $current_after . '”'; } elseif (is_404()) { echo $current_before . __('404 (Page Not Found)', '__x__') . $current_after; } elseif (is_archive()) { if (x_is_shop()) { echo $current_before . $shop_title . $current_after; } else { echo $current_before . __('Archives ', '__x__') . $current_after; } } if (get_query_var('paged')) { echo ' <span class="current" style="white-space: nowrap;">(' . __('Page', '__x__') . ' ' . get_query_var('paged') . ')</span>'; } echo '</div>'; } } } }
/** * * @global object $wpdb WordPress Database object. * * @param $atts * @return string */ function geodir_sc_popular_in_neighbourhood($atts) { ob_start(); $defaults = array('post_type' => 'gd_place', 'category' => '0', 'list_sort' => 'latest', 'post_number' => 5, 'layout' => 'gridview_onehalf', 'character_count' => 20, 'add_location_filter' => 1); $params = shortcode_atts($defaults, $atts); /** * Being validating $params */ // Check we have a valid post_type if (!gdsc_is_post_type_valid($params['post_type'])) { $params['post_type'] = 'gd_place'; } // Manage the entered categories if (0 != $params['category'] || '' != $params['category']) { $params['category'] = gdsc_manage_category_choice($params['post_type'], $params['category']); } // Validate our sorting choice $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); // Post_number needs to be a positive integer $params['post_number'] = absint($params['post_number']); if (0 == $params['post_number']) { $params['post_number'] = 1; } // Validate our layout choice // Outside of the norm, I added some more simple terms to match the existing // So now I just run the switch to set it properly. $params['layout'] = gdsc_validate_layout_choice($params['layout']); // Validate character_count $params['character_count'] = absint($params['character_count']); if (20 > $params['character_count']) { $params['character_count'] = 20; } /** * End validation */ global $wpdb, $post, $geodir_post_type; if ($geodir_post_type == '') { $geodir_post_type = 'gd_place'; } $all_postypes = geodir_get_posttypes(); $location_id = ''; $not_in_array = array(); if (geodir_is_page('detail') || geodir_is_page('preview') || geodir_is_page('add-listing')) { if (isset($post->post_type) && $post->post_type == $params['post_type'] && isset($post->post_location_id)) { $not_in_array[] = $post->ID; $location_id = $post->post_location_id; } } elseif (in_array($geodir_post_type, $all_postypes) && $geodir_post_type == $params['post_type']) { if (isset($_SESSION['gd_city']) && $_SESSION['gd_city'] != '') { $location_id = $wpdb->get_var($wpdb->prepare("SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug = %s", array($_SESSION['gd_city']))); } else { $default_location = geodir_get_default_location(); $location_id = $default_location->location_id; } } $gd_neighbourhoods = geodir_get_neighbourhoods($location_id); if ($gd_neighbourhoods) { ?> <div class="geodir_locations geodir_location_listing"> <?php $hood_slug_arr = array(); if (!empty($gd_neighbourhoods)) { foreach ($gd_neighbourhoods as $hoodslug) { $hood_slug_arr[] = $hoodslug->hood_slug; } } $query_args = array('posts_per_page' => $params['post_number'], 'is_geodir_loop' => true, 'post__not_in' => $not_in_array, 'gd_neighbourhood' => $hood_slug_arr, 'gd_location' => $params['add_location_filter'] ? true : false, 'post_type' => $params['post_type'], 'order_by' => $params['list_sort'], 'excerpt_length' => $params['character_count']); if ($params['category'] != 0 || $params['category'] != '') { $category_taxonomy = geodir_get_taxonomies($params['post_type']); $tax_query = array('taxonomy' => $category_taxonomy[0], 'field' => 'id', 'terms' => $params['category']); $query_args['tax_query'] = array($tax_query); } global $gridview_columns; query_posts($query_args); if (strstr($params['layout'], 'gridview')) { $listing_view_exp = explode('_', $params['layout']); $gridview_columns = $params['layout']; $layout = $listing_view_exp[0]; } $template = apply_filters("geodir_template_part-listing-listview", geodir_plugin_path() . '/geodirectory-templates/listing-listview.php'); include $template; wp_reset_query(); ?> </div> <?php } $output = ob_get_contents(); ob_end_clean(); return $output; }
/** * Returns paginated HTML string based on the given parameters. * * @since 1.0.0 * @since 1.5.5 Fixed pagination links when location selected. * @package GeoDirectory * @global object $wpdb WordPress Database object. * @global object $wp_query WordPress Query object. * @param string $before The HTML to prepend. * @param string $after The HTML to append. * @param string $prelabel The previous link label. * @param string $nxtlabel The next link label. * @param int $pages_to_show Number of pages to display on the pagination. Default: 5. * @param bool $always_show Do you want to show the pagination always? Default: false. */ function geodir_pagination($before = '', $after = '', $prelabel = '', $nxtlabel = '', $pages_to_show = 5, $always_show = false) { global $wp_query, $posts_per_page, $wpdb, $paged, $blog_id; if (empty($prelabel)) { $prelabel = '<strong>«</strong>'; } if (empty($nxtlabel)) { $nxtlabel = '<strong>»</strong>'; } $half_pages_to_show = round($pages_to_show / 2); if (geodir_is_page('home') || get_option('geodir_set_as_home') && is_home()) { // dont apply default pagination for geodirectory home page. return; } if (!is_single()) { if (function_exists('geodir_location_geo_home_link')) { remove_filter('home_url', 'geodir_location_geo_home_link', 100000); } $numposts = $wp_query->found_posts; $max_page = ceil($numposts / $posts_per_page); if (empty($paged)) { $paged = 1; } if ($max_page > 1 || $always_show) { // Extra pagination info $geodir_pagination_more_info = get_option('geodir_pagination_advance_info'); $start_no = ($paged - 1) * $posts_per_page + 1; $end_no = min($paged * $posts_per_page, $numposts); if ($geodir_pagination_more_info != '') { $pagination_info = '<div class="gd-pagination-details">' . wp_sprintf(__('Showing listings %d-%d of %d', 'geodirectory'), $start_no, $end_no, $numposts) . '</div>'; if ($geodir_pagination_more_info == 'before') { $before = $before . $pagination_info; } else { if ($geodir_pagination_more_info == 'after') { $after = $pagination_info . $after; } } } echo "{$before} <div class='Navi'>"; if ($paged >= $pages_to_show - 1) { echo '<a href="' . str_replace('&paged', '&paged', get_pagenum_link()) . '">«</a>'; } previous_posts_link($prelabel); for ($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) { if ($i >= 1 && $i <= $max_page) { if ($i == $paged) { echo "<strong class='on'>{$i}</strong>"; } else { echo ' <a href="' . str_replace('&paged', '&paged', get_pagenum_link($i)) . '">' . $i . '</a> '; } } } next_posts_link($nxtlabel, $max_page); if ($paged + $half_pages_to_show < $max_page) { echo '<a href="' . str_replace('&paged', '&paged', get_pagenum_link($max_page)) . '">»</a>'; } echo "</div> {$after}"; } if (function_exists('geodir_location_geo_home_link')) { add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); } } }
/** * 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; }
/** * Filters the auto change address fields values when moving the map pin. * * @since 1.0.0 * @package GeoDirectory_Location_Manager * * @param bool $val Whether to change the country, state, city values in fields. * @return string|bool */ function geodir_location_set_pin_disable($val) { if (geodir_is_page('add-listing') && get_option('location_set_pin_disable')) { return '0'; //return false } return $val; }
/** * breadcrumb plus items. * * @since 1.0.0 * @package GeoDirectory * @param array $items Breadcrumb items array. * @return array Modified breadcrumb items array. */ function gd_breadcrumbs_plus_items($items) { //print_r($items);exit; $bits = array(); $pieces = gd_get_breadcrum_links(); //unset($pieces[0]); $bits = $pieces; $title = $items['last']; if (is_page_geodir_home() || geodir_is_page('location')) { } elseif (geodir_is_page('listing')) { } elseif (geodir_is_page('detail')) { ob_start(); geodir_action_page_title(); $title = ob_get_contents(); ob_end_clean(); } elseif (geodir_is_page('search')) { } elseif (geodir_is_page('author')) { } $title = strip_tags($title); $items = gd_breadcrumbs_plus_items_add($items, $bits, $title); return $items; }
/** * The geodirectory advanced search widget shortcode. * * This implements the functionality of the shortcode for displaying advanced search widget. * * @since 1.0.0 * @package GeoDirectory * @param array $atts { * Attributes of the shortcode. * * @type string $before_widget HTML content to prepend to each widget's HTML output. Default. <section id="geodir_advanced_search-1" class="widget geodir-widget geodir_advanced_search_widget">. * @type string $after_widget HTML content to append to each widget's HTML output. Default. </section>. * @type string $before_title HTML content to prepend to the title when displayed. Default. <h3 class="widget-title">. * @type string $after_title HTML content to append to the title when displayed. Default. </h3>. * @type string $show_adv_search Show advanced search? Default. default. * @type string $title Widget title. Default. Empty. * * } * @return string Advanced search widget HTML. */ function geodir_sc_advanced_search($atts) { $defaults = array('title' => '', 'before_widget' => '<section id="geodir_advanced_search-1" class="widget geodir-widget geodir_advanced_search_widget">', 'after_widget' => '</section>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', 'show_adv_search' => 'default'); $params = shortcode_atts($defaults, $atts); $show_adv_search = isset($params['show_adv_search']) && in_array($params['show_adv_search'], array('default', 'always', 'searched')) ? $params['show_adv_search'] : ''; if ($show_adv_search != '') { $show_adv_class = 'geodir-advance-search-' . $show_adv_search . ' '; if ($show_adv_search == 'searched' && geodir_is_page('search')) { $show_adv_search = 'search'; } $show_adv_attrs = 'data-show-adv="' . $show_adv_search . '"'; $params['before_widget'] = str_replace('class="', $show_adv_attrs . ' class="' . $show_adv_class, $params['before_widget']); } ob_start(); //geodir_get_template_part('listing', 'filter-form'); the_widget('geodir_advance_search_widget', $params, $params); $output = ob_get_contents(); ob_end_clean(); return $output; }
/** * Show listing info depending on field location. * * @since 1.0.0 * @package GeoDirectory * @global object $wpdb WordPress Database object. * @global object $post The current post object. * @param string $fields_location In which page you are going to place this custom fields?. Ex: listing, detail etc. * @return string Returns listing info html. */ function geodir_show_listing_info($fields_location = '') { global $post, $preview, $wpdb; $payment_info = array(); $package_info = array(); $package_info = geodir_post_package_info($package_info, $post); //return; $post_package_id = $package_info->pid; $p_type = geodir_get_current_posttype() ? geodir_get_current_posttype() : $post->post_type; ob_start(); $fields_info = geodir_post_custom_fields($post_package_id, 'default', $p_type, $fields_location); if (!empty($fields_info)) { //echo '<div class="geodir-company_info field-group">'; $field_set_start = 0; if ($fields_location == 'detail') { $i = 1; } foreach ($fields_info as $type) { $type = stripslashes_deep($type); // strip slashes $html = ''; $html_var = ''; $field_icon = ''; $variables_array = array(); if ($fields_location == 'detail' && isset($type['show_as_tab']) && (int) $type['show_as_tab'] == 1 && in_array($type['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) { continue; } if ($type['type'] != 'fieldset') { $variables_array['post_id'] = $post->ID; $variables_array['label'] = __($type['site_title'], 'geodirectory'); $variables_array['value'] = ''; if (isset($post->{$type}['htmlvar_name'])) { $variables_array['value'] = $post->{$type}['htmlvar_name']; } } //if($type['field_icon']) if (strpos($type['field_icon'], 'http') !== false) { $field_icon = ' background: url(' . $type['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;'; } elseif (strpos($type['field_icon'], 'fa fa-') !== false) { $field_icon = '<i class="' . $type['field_icon'] . '"></i>'; } //else{$field_icon = $type['field_icon'];} switch ($type['type']) { case 'fieldset': if ($field_set_start == 1) { echo '</div><div class="geodir-company_info field-group ' . $type['htmlvar_name'] . '"><h2>' . __($type['site_title'], 'geodirectory') . '</h2>'; } else { echo '<h2>' . __($type['site_title'], 'geodirectory') . '</h2>'; $field_set_start = 1; } break; case 'address': $html_var = $type['htmlvar_name'] . '_address'; if ($type['extra_fields']) { $extra_fields = unserialize($type['extra_fields']); $addition_fields = ''; if (!empty($extra_fields)) { /** * Filter "show city in address" value. * * @since 1.0.0 */ $show_city_in_address = apply_filters('geodir_show_city_in_address', false); if (isset($extra_fields['show_city']) && $extra_fields['show_city'] && $show_city_in_address) { $field = $type['htmlvar_name'] . '_city'; if ($post->{$field}) { $addition_fields .= ', ' . $post->{$field}; } } if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) { $field = $type['htmlvar_name'] . '_zip'; if ($post->{$field}) { $addition_fields .= ', ' . $post->{$field}; } } } } /*if($type['extra_fields']) { $extra_fields = unserialize($type['extra_fields']); $addition_fields = ''; if(!empty($extra_fields)) { if($extra_fields['show_city']) { $field = $type['htmlvar_name'].'_city'; if($post->$field) { $addition_fields .= ', '.$post->$field; } } if($extra_fields['show_region']) { $field = $type['htmlvar_name'].'_region'; if($post->$field) { $addition_fields .= ', '.$post->$field; } } if($extra_fields['show_country']) { $field = $type['htmlvar_name'].'_country'; if($post->$field) { $addition_fields .= ', '.$post->$field; } } if($extra_fields['show_zip']) { $field = $type['htmlvar_name'].'_zip'; if($post->$field) { $addition_fields .= ', '.$post->$field; } } } }*/ if ($post->{$html_var}) { if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = '<i class="fa fa-home"></i>'; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;" itemscope itemtype="http://schema.org/PostalAddress">'; $html .= '<span class="geodir-i-location" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ' '; $html .= '</span>'; //print_r($_POST); if ($preview) { $html .= stripslashes($post->{$html_var}) . $addition_fields . '</p>'; } else { if ($post->post_address) { $html .= '<span itemprop="streetAddress">' . $post->post_address . '</span><br>'; } if ($post->post_city) { $html .= '<span itemprop="addressLocality">' . $post->post_city . '</span><br>'; } if ($post->post_region) { $html .= '<span itemprop="addressRegion">' . $post->post_region . '</span><br>'; } if ($post->post_zip) { $html .= '<span itemprop="postalCode">' . $post->post_zip . '</span><br>'; } if ($post->post_country) { $html .= '<span itemprop="addressCountry">' . __($post->post_country, 'geodirectory') . '</span><br>'; } $html .= '</div>'; } } $variables_array['value'] = $post->{$html_var}; break; case 'url': $html_var = $type['htmlvar_name']; if ($post->{$type}['htmlvar_name']) { if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { if ($type['name'] == 'geodir_facebook') { $field_icon_af = '<i class="fa fa-facebook-square"></i>'; } elseif ($type['name'] == 'geodir_twitter') { $field_icon_af = '<i class="fa fa-twitter-square"></i>'; } else { $field_icon_af = '<i class="fa fa-link"></i>'; } } else { $field_icon_af = $field_icon; $field_icon = ''; } if (!strstr($post->{$type}['htmlvar_name'], 'http')) { $website = 'http://' . $post->{$type}['htmlvar_name']; } else { $website = $post->{$type}['htmlvar_name']; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } // all search engines that use the nofollow value exclude links that use it from their ranking calculation $rel = strpos($website, get_site_url()) !== false ? '' : 'rel="nofollow"'; /** * Filter custom field website name. * * @since 1.0.0 * * @param string $type['site_title'] Website Title. * @param string $website Website URL. * @param int $post->ID Post ID. */ $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '"><span class="geodir-i-website" style="' . $field_icon . '">' . $field_icon_af . '<a href="' . $website . '" target="_blank" ' . $rel . ' ><strong>' . apply_filters('geodir_custom_field_website_name', stripslashes(__($type['site_title'], 'geodirectory')), $website, $post->ID) . '</strong></a></span></div>'; } break; case 'phone': $html_var = $type['htmlvar_name']; if ($post->{$type}['htmlvar_name']) { if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = '<i class="fa fa-phone"></i>'; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-contact" style="' . $field_icon . '">' . $field_icon_af . ($html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ' '); $html .= '</span><a href="tel:' . stripslashes($post->{$type}['htmlvar_name']) . '">' . stripslashes($post->{$type}['htmlvar_name']) . '</a></div>'; } break; case 'time': $html_var = $type['htmlvar_name']; if ($post->{$type}['htmlvar_name']) { $value = ''; if ($post->{$type}['htmlvar_name'] != '') { //$value = date('h:i',strtotime($post->$type['htmlvar_name'])); $value = date(get_option('time_format'), strtotime($post->{$type}['htmlvar_name'])); } if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = '<i class="fa fa-clock-o"></i>'; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-time" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ' '; $html .= '</span>' . stripslashes($value) . '</div>'; } break; case 'datepicker': if ($post->{$type}['htmlvar_name']) { $date_format = geodir_default_date_format(); if ($type['extra_fields'] != '') { $date_format = unserialize($type['extra_fields']); $date_format = $date_format['date_format']; } $search = array('dd', 'd', 'DD', 'mm', 'm', 'MM', 'yy'); //jQuery UI datepicker format $replace = array('d', 'j', 'l', 'm', 'n', 'F', 'Y'); //PHP date format $date_format = str_replace($search, $replace, $date_format); $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $post->{$type}['htmlvar_name']) : $post->{$type}['htmlvar_name']; // PHP doesn't work well with dd/mm/yyyy format $value = ''; if ($post->{$type}['htmlvar_name'] != '' && $post->{$type}['htmlvar_name'] != "0000-00-00") { $value = date($date_format, strtotime($post_htmlvar_value)); } else { continue; } if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = '<i class="fa fa-calendar"></i>'; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-datepicker" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ''; $html .= '</span>' . $value . '</div>'; } break; case 'text': $html_var = $type['htmlvar_name']; if (isset($post->{$type}['htmlvar_name']) && $post->{$type}['htmlvar_name'] != '' && $type['htmlvar_name'] == 'geodir_timing') { if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = '<i class="fa fa-clock-o"></i>'; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-time" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ' '; $html .= '</span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>'; } elseif (isset($post->{$type}['htmlvar_name']) && $post->{$type}['htmlvar_name']) { if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ''; $html .= '</span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>'; } break; case 'radio': $html_var = $type['htmlvar_name']; $html_val = $post->{$type}['htmlvar_name']; if ($post->{$type}['htmlvar_name'] != '') { if ($post->{$type}['htmlvar_name'] == 'f' || $post->{$type}['htmlvar_name'] == '0') { $html_val = __('No', 'geodirectory'); } elseif ($post->{$type}['htmlvar_name'] == 't' || $post->{$type}['htmlvar_name'] == '1') { $html_val = __('Yes', 'geodirectory'); } if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-radio" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ''; $html .= '</span>' . $html_val . '</div>'; } break; case 'checkbox': $html_var = $type['htmlvar_name']; $html_val = $type['htmlvar_name']; if ((int) $post->{$html_var} == 1) { if ($post->{$type}['htmlvar_name'] == '1') { $html_val = __('Yes', 'geodirectory'); } else { $html_val = __('No', 'geodirectory'); } if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-checkbox" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ''; $html .= '</span>' . $html_val . '</div>'; } break; case 'select': $html_var = $type['htmlvar_name']; if ($post->{$type}['htmlvar_name']) { if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ''; $html .= '</span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>'; } break; case 'multiselect': $html_var = $type['htmlvar_name']; if (!empty($post->{$type}['htmlvar_name'])) { if (is_array($post->{$type}['htmlvar_name'])) { $post->{$type}['htmlvar_name'] = implode(', ', $post->{$type}['htmlvar_name']); } if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } $option_values = explode(',', $post->{$type}['htmlvar_name']); if ($type['option_values']) { if (strstr($type['option_values'], "/")) { $option_values = array(); $field_values = explode(',', $type['option_values']); foreach ($field_values as $data) { $val = explode('/', $data); if (isset($val[1]) && in_array($val[1], explode(',', $post->{$type}['htmlvar_name']))) { $option_values[] = $val[0]; } } } } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ''; $html .= '</span>'; if (count($option_values) > 1) { $html .= '<ul>'; foreach ($option_values as $val) { $html .= '<li>' . stripslashes($val) . '</li>'; } $html .= '</ul>'; } else { $html .= stripslashes(trim($post->{$type}['htmlvar_name'], ',')); } $html .= '</div>'; } break; case 'email': if ($type['htmlvar_name'] == 'geodir_email' && !(geodir_is_page('detail') || geodir_is_page('preview'))) { continue; // Remove Send Enquiry | Send To Friend from listings page } if ($type['htmlvar_name'] == 'geodir_email' && (isset($package_info->sendtofriend) && $package_info->sendtofriend || $post->{$type}['htmlvar_name'])) { $b_send_inquiry = ''; $b_sendtofriend = ''; $html = ''; if (!$preview) { $b_send_inquiry = 'b_send_inquiry'; $b_sendtofriend = 'b_sendtofriend'; $html = '<input type="hidden" name="geodir_popup_post_id" value="' . $post->ID . '" /><div class="geodir_display_popup_forms"></div>'; } if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = '<i class="fa fa-envelope"></i>'; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html .= '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af; $seperator = ''; if ($post->{$type}['htmlvar_name']) { $html .= '<a href="javascript:void(0);" class="' . $b_send_inquiry . '" >' . SEND_INQUIRY . '</a>'; $seperator = ' | '; } if (isset($package_info->sendtofriend) && $package_info->sendtofriend) { $html .= $seperator . '<a href="javascript:void(0);" class="' . $b_sendtofriend . '">' . SEND_TO_FRIEND . '</a>'; } $html .= '</span></div>'; if (isset($_REQUEST['send_inquiry']) && $_REQUEST['send_inquiry'] == 'success') { $html .= '<p class="sucess_msg">' . SEND_INQUIRY_SUCCESS . '</p>'; } elseif (isset($_REQUEST['sendtofrnd']) && $_REQUEST['sendtofrnd'] == 'success') { $html .= '<p class="sucess_msg">' . SEND_FRIEND_SUCCESS . '</p>'; } elseif (isset($_REQUEST['emsg']) && $_REQUEST['emsg'] == 'captch') { $html .= '<p class="error_msg_fix">' . WRONG_CAPTCH_MSG . '</p>'; } /*if(!$preview){require_once (geodir_plugin_path().'/geodirectory-templates/popup-forms.php');}*/ } else { if ($post->{$type}['htmlvar_name']) { if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = '<i class="fa fa-envelope"></i>'; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ''; $html .= '</span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>'; } } break; case 'file': $html_var = $type['htmlvar_name']; if (!empty($post->{$type}['htmlvar_name'])) { $files = explode(",", $post->{$type}['htmlvar_name']); if (!empty($files)) { $extra_fields = !empty($type['extra_fields']) ? maybe_unserialize($type['extra_fields']) : NULL; $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : ''; $file_paths = ''; foreach ($files as $file) { if (!empty($file)) { $filetype = wp_check_filetype($file); $image_name_arr = explode('/', $file); $curr_img_dir = $image_name_arr[count($image_name_arr) - 2]; $filename = end($image_name_arr); $img_name_arr = explode('.', $filename); $arr_file_type = wp_check_filetype($filename); if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) { continue; } $uploaded_file_type = $arr_file_type['type']; $uploaded_file_ext = $arr_file_type['ext']; if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) { continue; // Invalid file type. } //$allowed_file_types = array('application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain'); $image_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/x-icon'); // If the uploaded file is image if (in_array($uploaded_file_type, $image_file_types)) { $file_paths .= '<div class="geodir-custom-post-gallery" class="clearfix">'; $file_paths .= '<a href="' . $file . '">'; $file_paths .= geodir_show_image(array('src' => $file), 'thumbnail', false, false); $file_paths .= '</a>'; //$file_paths .= '<img src="'.$file.'" />'; $file_paths .= '</div>'; } else { $ext_path = '_' . $html_var . '_'; $filename = explode($ext_path, $filename); $file_paths .= '<a href="' . $file . '" target="_blank">' . $filename[count($filename) - 1] . '</a>'; } } } if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' geodir-custom-file-box ' . $type['htmlvar_name'] . '"><div class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af; $html .= '<span style="display: inline-block; vertical-align: top; padding-right: 14px;">'; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ''; $html .= '</span>'; $html .= $file_paths . '</div></div>'; } } break; case 'textarea': if (!empty($post->{$type}['htmlvar_name'])) { if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ''; $html .= '</span>' . wpautop(stripslashes($post->{$type}['htmlvar_name'])) . '</div>'; } break; case 'html': if (!empty($post->{$type}['htmlvar_name'])) { if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ''; $html .= '</span>' . wpautop(stripslashes($post->{$type}['htmlvar_name'])) . '</div>'; } break; case 'taxonomy': $html_var = $type['htmlvar_name']; if ($html_var == $post->post_type . 'category' && !empty($post->{$html_var})) { $post_taxonomy = $post->post_type . 'category'; $field_value = $post->{$html_var}; $links = array(); $terms = array(); $termsOrdered = array(); if (!is_array($field_value)) { $field_value = explode(",", trim($field_value, ",")); } $field_value = array_unique($field_value); if (!empty($field_value)) { foreach ($field_value as $term) { $term = trim($term); if ($term != '') { $term = get_term_by('id', $term, $html_var); if (is_object($term)) { $links[] = "<a href='" . esc_attr(get_term_link($term, $post_taxonomy)) . "'>" . $term->name . "</a>"; $terms[] = $term; } } } if (!empty($links)) { // order alphabetically asort($links); foreach (array_keys($links) as $key) { $termsOrdered[$key] = $terms[$key]; } $terms = $termsOrdered; } } $html_value = !empty($links) && !empty($terms) ? wp_sprintf('%l', $links, (object) $terms) : ''; if ($html_value != '') { if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } else { if ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $html_var . '" style="clear:both;"><span class="geodir-i-taxonomy geodir-i-category" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ''; $html .= '</span> ' . $html_value . '</div>'; } } break; } if ($html) { /** * Called before a custom fields is output on the frontend. * * @since 1.0.0 * @param string $html_var The HTML variable name for the field. */ do_action("geodir_before_show_{$html_var}"); /** * Filter custom field output. * * @since 1.0.0 * * @param string $html_var The HTML variable name for the field. * @param string $html Custom field unfiltered HTML. * @param array $variables_array Custom field variables array. */ if ($html) { echo apply_filters("geodir_show_{$html_var}", $html, $variables_array); } /** * Called after a custom fields is output on the frontend. * * @since 1.0.0 * @param string $html_var The HTML variable name for the field. */ do_action("geodir_after_show_{$html_var}"); } } //echo '</div>'; } return $html = ob_get_clean(); }
function geodir_advance_search_widget_display_callback($instance = '', $widget_instance = '', $args = '') { if (!empty($widget_instance) && is_object($widget_instance) && isset($widget_instance->id_base) && $widget_instance->id_base == 'geodir_advance_search') { $show_adv_search = !empty($instance) && !empty($instance['show_adv_search']) ? $instance['show_adv_search'] : 'default'; $classname = $widget_instance->widget_options['classname']; $show_adv_class = 'geodir-advance-search-' . $show_adv_search; if ($show_adv_search == 'searched' && geodir_is_page('search')) { $show_adv_search = 'search'; } $show_adv_attrs = 'data-show-adv="' . $show_adv_search . '"'; $args['before_widget'] = str_replace($classname, "{$classname} {$show_adv_class}", $args['before_widget']); $args['before_widget'] = str_replace('class="', $show_adv_attrs . ' class="', $args['before_widget']); $widget_instance->widget($args, $instance); return false; } return $instance; }
/** * Add the location variables in session. * * @since 1.0.0 * * @param object $wp The WordPress object. */ function geodir_set_location_var_in_session_in_core($wp) { //$wp->geodir_query_vars = $wp->query_vars ; // this code will determine when a user wants to switch location // Fix for WPML removing page_id query var: if (isset($wp->query_vars['page']) && !isset($wp->query_vars['page_id']) && isset($wp->query_vars['pagename']) && !is_home()) { global $wpdb; $page_for_posts = get_option('page_for_posts'); $real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type='page' AND post_name=%s", $wp->query_vars['pagename'])); if (function_exists('icl_object_id')) { $real_page_id = icl_object_id($real_page_id, 'page', true, ICL_LANGUAGE_CODE); } if ($real_page_id && $real_page_id != $page_for_posts) { $wp->query_vars['page_id'] = $real_page_id; } } // Query Vars will have page_id parameter // check if query var has page_id and that page id is location page geodir_set_is_geodir_page($wp); // if is GD homepage set the page ID if (geodir_is_page('home')) { $wp->query_vars['page_id'] = get_option('page_on_front'); } // The location url format (all or country_city or region_city or city). $geodir_show_location_url = get_option('geodir_show_location_url'); if (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id()) { $gd_country = ''; $gd_region = ''; $gd_city = ''; if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') { $gd_country = urldecode($wp->query_vars['gd_country']); } if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') { $gd_region = urldecode($wp->query_vars['gd_region']); } if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') { $gd_city = urldecode($wp->query_vars['gd_city']); } if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) { $default_location = geodir_get_default_location(); if (get_option('geodir_add_location_url')) { if ($geodir_show_location_url != 'all') { if ($gd_region == '') { if (isset($_SESSION['gd_region'])) { $gd_region = $_SESSION['gd_region']; } else { $gd_region = $default_location->region_slug; } } if ($gd_city == '') { if (isset($_SESSION['gd_city'])) { $gd_city = $_SESSION['gd_city']; } else { $gd_city = $default_location->city_slug; } $base_location_link = geodir_get_location_link('base'); wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city); exit; } } } $args = array('what' => 'city', 'city_val' => $gd_city, 'region_val' => $gd_region, 'country_val' => $gd_country, 'country_column_name' => 'country_slug', 'region_column_name' => 'region_slug', 'city_column_name' => 'city_slug', 'location_link_part' => false, 'compare_operator' => ''); $location_array = function_exists('geodir_get_location_array') ? geodir_get_location_array($args) : array(); if (!empty($location_array)) { $_SESSION['gd_multi_location'] = 1; $_SESSION['gd_country'] = $gd_country; $_SESSION['gd_region'] = $gd_region; $_SESSION['gd_city'] = $gd_city; $wp->query_vars['gd_country'] = $gd_country; $wp->query_vars['gd_region'] = $gd_region; $wp->query_vars['gd_city'] = $gd_city; } else { unset($_SESSION['gd_multi_location'], $_SESSION['gd_city'], $_SESSION['gd_region'], $_SESSION['gd_country']); } } else { unset($_SESSION['gd_multi_location'], $_SESSION['gd_city'], $_SESSION['gd_region'], $_SESSION['gd_country']); } } else { if (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') { if (!is_admin()) { $requested_post_type = $wp->query_vars['post_type']; // check if this post type is geodirectory post types $post_type_array = geodir_get_posttypes(); if (in_array($requested_post_type, $post_type_array)) { // now u can apply geodirectory related manipulation. } } } else { // check if a geodirectory taxonomy is set $gd_country = ''; $gd_region = ''; $gd_city = ''; $is_geodir_taxonomy = false; $is_geodir_taxonomy_term = false; // the last term is real geodirectory taxonomy term or not $is_geodir_location_found = false; $geodir_taxonomy = ''; $geodir_post_type = ''; $geodir_term = ''; $geodir_set_location_session = true; $geodir_taxonomis = geodir_get_taxonomies('', true); foreach ($geodir_taxonomis as $taxonomy) { if (array_key_exists($taxonomy, $wp->query_vars)) { $is_geodir_taxonomy = true; $geodir_taxonomy = $taxonomy; $geodir_post_type = str_replace('category', '', $taxonomy); $geodir_post_type = str_replace('_tags', '', $geodir_post_type); $geodir_term = $wp->query_vars[$geodir_taxonomy]; break; } } // now get an array of all terms seperated by '/' $geodir_terms = explode('/', $geodir_term); $geodir_last_term = end($geodir_terms); if ($is_geodir_taxonomy) { // do all these only when it is a geodirectory taxonomy $wp->query_vars['post_type'] = $geodir_post_type; // now check if last term is a post of geodirectory post types $geodir_post = get_posts(array('name' => $geodir_last_term, 'posts_per_page' => 1, 'post_type' => $geodir_post_type)); if (empty($geodir_post)) { $geodir_post = get_posts(array('name' => $geodir_last_term, 'posts_per_page' => 1, 'post_type' => $geodir_post_type, 'post_status' => 'draft', 'suppress_filters' => false)); } if (!empty($geodir_post)) { if ($geodir_post[0]->post_status != 'publish') { foreach ($wp->query_vars as $key => $vars) { unset($wp->query_vars[$key]); } $wp->query_vars['error'] = '404'; // set it as 404 if post exists but its status is not published yet } else { //$wp->query_vars[$geodir_taxonomy] = str_replace( '/'.$geodir_last_term , '' , $geodir_term); $wp->query_vars[$geodir_post_type] = $geodir_last_term; $wp->query_vars['name'] = $geodir_last_term; } $geodir_term = str_replace('/' . $geodir_last_term, '', $geodir_term, $post_title_replace_count); if (!$post_title_replace_count) { $geodir_term = str_replace($geodir_last_term, '', $geodir_term, $post_title_replace_count); } $geodir_terms = explode('/', $geodir_term); $geodir_last_term = end($geodir_terms); $geodir_set_location_session = false; //return ; } $geodir_location_terms = ''; // if last term is not a post then check if last term is a term of the specific texonomy or not if (geodir_term_exists($geodir_last_term, $geodir_taxonomy)) { $is_geodir_taxonomy_term = true; $geodir_set_location_session = false; } // now check if there is location parts in the url or not if (get_option('geodir_add_location_url')) { $default_location = geodir_get_default_location(); if ($geodir_show_location_url == 'all') { if (count($geodir_terms) >= 3) { $gd_country = urldecode($geodir_terms[0]); $gd_region = urldecode($geodir_terms[1]); $gd_city = urldecode($geodir_terms[2]); } else { if (count($geodir_terms) >= 2) { $gd_country = urldecode($geodir_terms[0]); $gd_region = urldecode($geodir_terms[1]); } else { if (count($geodir_terms) >= 1) { $gd_country = urldecode($geodir_terms[0]); } } } if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) { $is_geodir_location_found = true; } // if location has not been found for country , region and city then search for country and region only if (!$is_geodir_location_found) { $gd_city = ''; if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)) { $is_geodir_location_found = true; } } // if location has not been found for country , region then search for country only if (!$is_geodir_location_found) { $gd_city = ''; $gd_region = ''; if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) { $is_geodir_location_found = true; } } } else { if ($geodir_show_location_url == 'country_city') { if (count($geodir_terms) >= 2) { $gd_country = urldecode($geodir_terms[0]); $gd_city = urldecode($geodir_terms[1]); } else { if (count($geodir_terms) >= 1) { $gd_country = urldecode($geodir_terms[0]); } } if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) { $is_geodir_location_found = true; } // if location has not been found for country and city then search for country only if (!$is_geodir_location_found) { $gd_city = ''; if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) { $is_geodir_location_found = true; } } } else { if ($geodir_show_location_url == 'region_city') { if (count($geodir_terms) >= 2) { $gd_region = urldecode($geodir_terms[0]); $gd_city = urldecode($geodir_terms[1]); } else { if (count($geodir_terms) >= 1) { $gd_region = urldecode($geodir_terms[0]); } } if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) { $is_geodir_location_found = true; } // if location has not been found for region and city then search for region only if (!$is_geodir_location_found) { $gd_city = ''; if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)) { $is_geodir_location_found = true; } } } else { $gd_city = $geodir_terms[0]; if (geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) { $is_geodir_location_found = true; $gd_region = $default_location->region_slug; $gd_country = $default_location->country_slug; } } } } // if locaton still not found then clear location related session variables if ($is_geodir_location_found && $geodir_set_location_session) { $_SESSION['gd_multi_location'] = 1; $_SESSION['gd_country'] = $gd_country; $_SESSION['gd_region'] = $gd_region; $_SESSION['gd_city'] = $gd_city; } if ($geodir_show_location_url == 'all') { } else { if ($geodir_show_location_url == 'country_city') { $gd_region = ''; } else { if ($geodir_show_location_url == 'region_city') { $gd_country = ''; } else { $gd_country = ''; $gd_region = ''; } } } if ($is_geodir_location_found) { $wp->query_vars['gd_country'] = $gd_country; $wp->query_vars['gd_region'] = $gd_region; $wp->query_vars['gd_city'] = $gd_city; } else { $gd_country = ''; $gd_region = ''; $gd_city = ''; } } $wp->query_vars[$geodir_taxonomy] = $geodir_term; // eliminate location related terms from taxonomy term if ($gd_country != '') { $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1); } if ($gd_region != '') { $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1); } if ($gd_city != '') { $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1); } $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]); $wp->query_vars[$geodir_taxonomy] = str_replace('//', '', $wp->query_vars[$geodir_taxonomy]); $wp->query_vars[$geodir_taxonomy] = trim($wp->query_vars[$geodir_taxonomy], '/'); if ($wp->query_vars[$geodir_taxonomy] == '') { unset($wp->query_vars[$geodir_taxonomy]); } else { if (!$is_geodir_taxonomy_term) { foreach ($wp->query_vars as $key => $vars) { unset($wp->query_vars[$key]); } $wp->query_vars['error'] = '404'; } } } } } // Unset location session if gd page and location not set. if (isset($wp->query_vars['gd_is_geodir_page']) && !isset($wp->query_vars['gd_country'])) { unset($_SESSION['gd_multi_location'], $_SESSION['gd_city'], $_SESSION['gd_region'], $_SESSION['gd_country']); } if (isset($_SESSION['gd_multi_location']) && $_SESSION['gd_multi_location'] == 1) { $wp->query_vars['gd_country'] = $_SESSION['gd_country']; $wp->query_vars['gd_region'] = $_SESSION['gd_region']; $wp->query_vars['gd_city'] = $_SESSION['gd_city']; } // now check if there is location parts in the url or not if (get_option('geodir_add_location_url')) { if ($geodir_show_location_url == 'all') { } else { if ($geodir_show_location_url == 'country_city') { if (isset($wp->query_vars['gd_region'])) { $wp->query_vars['gd_region'] = ''; } } else { if ($geodir_show_location_url == 'region_city') { if (isset($wp->query_vars['gd_country'])) { $wp->query_vars['gd_country'] = ''; } } else { if (isset($wp->query_vars['gd_country'])) { $wp->query_vars['gd_country'] = ''; } if (isset($wp->query_vars['gd_region'])) { $wp->query_vars['gd_region'] = ''; } } } } } else { if (isset($wp->query_vars['gd_country'])) { $wp->query_vars['gd_country'] = ''; } if (isset($wp->query_vars['gd_region'])) { $wp->query_vars['gd_region'] = ''; } if (isset($wp->query_vars['gd_city'])) { $wp->query_vars['gd_city'] = ''; } } }
/** * * * @global object $wp WordPress object. * * @param $breadcrumb * @param $saprator * @param bool $echo * @return string */ function geodir_location_breadcrumb($breadcrumb, $saprator, $echo = false) { global $wp; if (geodir_is_page('location')) { $saprator = str_replace(' ', ' ', $saprator); $location_link = geodir_get_location_link('base'); $location_prefix = get_option('geodir_location_prefix'); $breadcrumb = ''; $breadcrumb .= '<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">'; $breadcrumb .= '<li><a href="' . get_option('home') . '">' . __('Home', GEODIRLOCATION_TEXTDOMAIN) . '</a></li>'; $breadcrumb .= '<li>' . $saprator; $breadcrumb .= '<a href="' . $location_link . '">' . GD_LOCATION . '</a>'; $breadcrumb .= '</li>'; /* $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] !='') ? $wp->query_vars['gd_country'] : '' ; $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] !='') ? $wp->query_vars['gd_region'] : '' ; $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] !='') ? $wp->query_vars['gd_city'] : '' ; */ $locations = geodir_get_current_location_terms(); $breadcrumb .= '<li>'; foreach ($locations as $key => $location) { if (get_option('permalink_structure') != '') { $location_link .= $location; } else { $location_link .= '&' . $key . '=' . $location; } $location_link = geodir_location_permalink_url($location_link); $location = urldecode($location); $location_actual_text = ''; if ($key == 'gd_country' && ($location_actual = get_actual_location_name('country', $location))) { $location_actual_text = get_actual_location_name('country', $location, true); } else { if ($key == 'gd_region' && ($location_actual = get_actual_location_name('region', $location))) { $location_actual_text = get_actual_location_name('region', $location, true); } else { if ($key == 'gd_city' && ($location_actual = get_actual_location_name('city', $location))) { $location_actual_text = get_actual_location_name('city', $location, true); } } } if ($location != end($locations)) { $location = preg_replace('/-(\\d+)$/', '', $location); $location = preg_replace('/[_-]/', ' ', $location); $location = ucwords($location); $location = __($location, GEODIRECTORY_TEXTDOMAIN); $location_text = $location_actual_text != '' ? $location_actual_text : $location; $breadcrumb .= $saprator . '<a href="' . $location_link . '">' . $location_text . '</a>'; } else { $location = preg_replace('/-(\\d+)$/', '', $location); $location = preg_replace('/[_-]/', ' ', $location); $location = ucwords($location); $location = __($location, GEODIRECTORY_TEXTDOMAIN); $location_text = $location_actual_text != '' ? $location_actual_text : $location; $breadcrumb .= $saprator . $location_text; } } $breadcrumb .= '</li>'; $breadcrumb .= '</ul></div>'; } if ($echo) { echo $breadcrumb; } else { return $breadcrumb; } }
/** * Filter the listing map should to be displayed or not. * * @since 1.1.6 * * @global WP_Query $wp_query WordPress Query object. * @global object $post The current post object. * * @param bool $display true if map should be displayed, false if not. * @return bool true if map should be displayed, false if not. */ function geodir_cpt_remove_map_listing($display = true) { if (geodir_is_page('listing') || geodir_is_page('detail') || geodir_is_page('search')) { global $wp_query, $post; $gd_post_type = ''; if (geodir_is_page('detail')) { $gd_post_type = !empty($post) && isset($post->post_type) ? $post->post_type : $gd_post_type; } else { if (geodir_is_page('search')) { $gd_post_type = isset($_REQUEST['stype']) ? $_REQUEST['stype'] : $gd_post_type; } else { $gd_post_type = !empty($wp_query) && isset($wp_query->query_vars) && isset($wp_query->query_vars['post_type']) ? $wp_query->query_vars['post_type'] : ''; } } if ($gd_post_type && geodir_cpt_no_location($gd_post_type)) { $display = false; } } return $display; }
/** * Adds page title based on current page type. * * @since 1.0.0 * @package GeoDirectory * @global object $wp WordPress object. */ function gd_mk_page_title() { global $wp; if (is_page_geodir_home() || geodir_is_page('location')) { jupiter_geodir_page_title(); } elseif (geodir_is_page('listing')) { ob_start(); // Start buffering; geodir_action_listings_title(); $gd_title = ob_get_clean(); $title_p = explode('">', $gd_title); $title = str_replace('</h1></header>', "", $title_p[2]); jupiter_geodir_page_title($title); } elseif (geodir_is_page('search')) { ob_start(); // Start buffering; geodir_action_listings_title(); $gd_title = ob_get_clean(); $title_p = explode('">', $gd_title); $title = str_replace('</h1></header>', "", $title_p[2]); jupiter_geodir_page_title($title); } elseif (geodir_is_page('author')) { ob_start(); // Start buffering; geodir_action_author_page_title(); $gd_title = ob_get_clean(); $gd_title = str_replace('<h1>', "", $gd_title); $gd_title = str_replace('</h1>', "", $gd_title); jupiter_geodir_page_title($gd_title); } else { mk_page_title(); } }
/** * Changing excerpt length. * * @since 1.0.0 * @package GeoDirectory * @global object $wp_query WordPress Query object. * @param int $length Optional. Old length. * @return mixed|void Returns length. */ function geodir_excerpt_length($length) { global $wp_query; if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit')) { $length = get_option('geodir_desc_word_limit'); } elseif (get_query_var('excerpt_length')) { $length = get_query_var('excerpt_length'); } if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit')) { $length = get_option('geodir_author_desc_word_limit'); } return $length; }
/** * Adds top section based on current page type. * * @since 1.0.0 * @package GeoDirectory */ function gd_enfold_compat_add_top_section_back() { if (is_page_geodir_home() || geodir_is_page('location')) { add_action('geodir_wrapper_open', 'geodir_action_geodir_sidebar_home_top', 8); } elseif (geodir_is_page('listing')) { add_action('geodir_wrapper_open', 'geodir_action_geodir_sidebar_listings_top', 8); } elseif (geodir_is_page('detail')) { add_action('geodir_wrapper_open', 'geodir_action_geodir_sidebar_detail_top', 8); } elseif (geodir_is_page('search')) { add_action('geodir_wrapper_open', 'geodir_action_geodir_sidebar_search_top', 8); } elseif (geodir_is_page('author')) { add_action('geodir_wrapper_open', 'geodir_action_geodir_sidebar_author_top', 8); } }
/** * Custom taxonomy walker function. * * @since 1.0.0 * @package GeoDirectory * @global object $post WordPress Post object. * @param string $cat_taxonomy The taxonomy name. * @param string $cat_limit Number of categories to display. */ function geodir_custom_taxonomy_walker2($cat_taxonomy, $cat_limit = '') { $post_category = ''; $post_category_str = ''; global $exclude_cats; $cat_exclude = ''; if (is_array($exclude_cats) && !empty($exclude_cats)) { $cat_exclude = serialize($exclude_cats); } if (isset($_REQUEST['backandedit'])) { $post = (object) unserialize($_SESSION['listing']); if (!is_array($post->post_category[$cat_taxonomy])) { $post_category = $post->post_category[$cat_taxonomy]; } $post_categories = $post->post_category_str; if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) { $post_category_str = $post_categories[$cat_taxonomy]; } } elseif (geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '' || is_admin()) { global $post; $post_category = geodir_get_post_meta($post->ID, $cat_taxonomy, true); if (empty($post_category) && isset($post->{$cat_taxonomy})) { $post_category = $post->{$cat_taxonomy}; } $post_categories = get_post_meta($post->ID, 'post_categories', true); if (empty($post_category) && !empty($post_categories) && !empty($post_categories[$cat_taxonomy])) { foreach (explode(",", $post_categories[$cat_taxonomy]) as $cat_part) { if (is_numeric($cat_part)) { $cat_part_arr[] = $cat_part; } } if (is_array($cat_part_arr)) { $post_category = implode(',', $cat_part_arr); } } if (!empty($post_category)) { $cat1 = array_filter(explode(',', $post_category)); $post_category = ',' . implode(',', $cat1) . ','; } if ($post_category != '' && is_array($exclude_cats) && !empty($exclude_cats)) { $post_category_upd = explode(',', $post_category); $post_category_change = ''; foreach ($post_category_upd as $cat) { if (!in_array($cat, $exclude_cats) && $cat != '') { $post_category_change .= ',' . $cat; } } $post_category = $post_category_change; } if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) { $post_category_str = $post_categories[$cat_taxonomy]; } } echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']" />'; echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']" />'; echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']" />'; ?> <div class="cat_sublist"> <?php $post_id = isset($post->ID) ? $post->ID : ''; if ((geodir_is_page('add-listing') || is_admin()) && !empty($post_categories[$cat_taxonomy])) { geodir_editpost_categories_html($cat_taxonomy, $post_id, $post_categories); } ?> </div> <script type="text/javascript"> function show_subcatlist(main_cat, catObj) { if (main_cat != '') { var url = '<?php echo geodir_get_ajax_url(); ?> '; var cat_taxonomy = '<?php echo $cat_taxonomy; ?> '; var cat_exclude = '<?php echo base64_encode($cat_exclude); ?> '; var cat_limit = jQuery('#' + cat_taxonomy).find('#cat_limit').val(); <?php if ((int) $cat_limit > 0) { ?> var selected = parseInt(jQuery('#' + cat_taxonomy).find('.cat_sublist > div.post_catlist_item').length); if (cat_limit != '' && selected > 0 && selected >= cat_limit && cat_limit != 0) { alert("<?php echo esc_attr(wp_sprintf(__('You have reached category limit of %d categories.', GEODIRECTORY_TEXTDOMAIN), (int) $cat_limit)); ?> "); return false; } <?php } ?> jQuery.post(url, { geodir_ajax: 'category_ajax', cat_tax: cat_taxonomy, main_catid: main_cat, exclude: cat_exclude }, function (data) { if (data != '') { jQuery('#' + cat_taxonomy).find('.cat_sublist').append(data); setTimeout(function () { jQuery('#' + cat_taxonomy).find('.cat_sublist').find('.chosen_select').chosen(); }, 200); } maincat_obj = jQuery('#' + cat_taxonomy).find('.main_cat_list'); if (cat_limit != '' && jQuery('#' + cat_taxonomy).find('.cat_sublist .chosen_select').length >= cat_limit) { maincat_obj.find('.chosen_select').chosen('destroy'); maincat_obj.hide(); } else { maincat_obj.show(); maincat_obj.find('.chosen_select').chosen('destroy'); maincat_obj.find('.chosen_select').prop('selectedIndex', 0); maincat_obj.find('.chosen_select').chosen(); } update_listing_cat(); }); } update_listing_cat(); } function update_listing_cat(el) { var cat_taxonomy = '<?php echo $cat_taxonomy; ?> '; var cat_ids = ''; var main_cat = ''; var sub_cat = ''; var post_cat_str = ''; var cat_limit = jQuery('#' + cat_taxonomy).find('#cat_limit').val(); var delEl = jQuery(el).closest('.post_catlist_item').find('input.listing_main_cat'); if (typeof el != 'undefined' && jQuery(delEl).val()) { jQuery('.geodir_taxonomy_field').find('select > option[_hc="f"][value="'+jQuery(delEl).val()+'"]').attr('disabled', false); } jQuery('.geodir_taxonomy_field').find('input.listing_main_cat:checked').each(function() { var cV = jQuery(this).val(); if (parseInt(cV) > 0) { jQuery('.geodir_taxonomy_field').find('select > option[_hc="f"][value="'+cV+'"]').attr('disabled', true); } }); jQuery('#' + cat_taxonomy).find('.cat_sublist > div').each(function () { main_cat = jQuery(this).find('.listing_main_cat').val(); if (jQuery(this).find('.chosen_select').length > 0) sub_cat = jQuery(this).find('.chosen_select').val() if (post_cat_str != '') post_cat_str = post_cat_str + '#'; post_cat_str = post_cat_str + main_cat; if (jQuery(this).find('.listing_main_cat').is(':checked')) { cat_ids = cat_ids + ',' + main_cat; post_cat_str = post_cat_str + ',y'; if (jQuery(this).find('.post_default_category input').is(':checked')) post_cat_str = post_cat_str + ',d'; } else { post_cat_str = post_cat_str + ',n'; } if (sub_cat != '' && sub_cat) { cat_ids = cat_ids + ',' + sub_cat; post_cat_str = post_cat_str + ':' + sub_cat; } else { post_cat_str = post_cat_str + ':'; } }); maincat_obj = jQuery('#' + cat_taxonomy).find('.main_cat_list'); if (cat_limit != '' && jQuery('#' + cat_taxonomy).find('.cat_sublist > div.post_catlist_item').length >= cat_limit && cat_limit != 0) { maincat_obj.find('.chosen_select').chosen('destroy'); maincat_obj.hide(); } else { maincat_obj.show(); maincat_obj.find('.chosen_select').chosen('destroy'); maincat_obj.find('.chosen_select').prop('selectedIndex', 0); maincat_obj.find('.chosen_select').chosen(); } maincat_obj.find('.chosen_select').trigger("chosen:updated"); jQuery('#' + cat_taxonomy).find('#post_category').val(cat_ids); jQuery('#' + cat_taxonomy).find('#post_category_str').val(post_cat_str); } jQuery(function () { update_listing_cat(); }) </script> <?php if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) { $post_cat_str = $post_categories[$cat_taxonomy]; $post_cat_array = explode("#", $post_cat_str); if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) { $style = "display:none;"; } } ?> <div class="main_cat_list" style=" <?php if (isset($style)) { echo $style; } ?> "> <?php geodir_get_catlist($cat_taxonomy, 0); // print main categories list ?> </div> <?php }
/** * Adds top section based on current page type. * * @since 1.0.0 * @package GeoDirectory */ function gd_compat_add_top_section_back() { if (is_page_geodir_home() || geodir_is_page('location')) { geodir_action_geodir_sidebar_home_top(); } elseif (geodir_is_page('listing')) { geodir_action_geodir_sidebar_listings_top(); } elseif (geodir_is_page('detail')) { geodir_action_geodir_sidebar_detail_top(); } elseif (geodir_is_page('search')) { geodir_action_geodir_sidebar_search_top(); } elseif (geodir_is_page('author')) { geodir_action_geodir_sidebar_author_top(); } }
/** * post status on author listing page. * * @since 1.0.0 * @package GeoDirectory_BuddyPress_Integration * * @global object $wpdb WordPress Database object. * @global object $post The current post object. */ function geodir_buddypress_post_status_on_listing() { global $wpdb, $post; $html = ''; if (get_current_user_id() && !empty($post) && isset($post->post_author) && $post->post_author == get_current_user_id() && !geodir_is_page('author')) { // we need to query real status direct as we dynamically change the status for author on author page so even non author status can view them. $real_status = $wpdb->get_var("SELECT post_status from {$wpdb->posts} WHERE ID={$post->ID}"); $status = "<strong>("; $status_icon = '<i class="fa fa-play"></i>'; if ($real_status == 'publish') { $status .= __('Published', GDBUDDYPRESS_TEXTDOMAIN); } else { $status .= __('Not published', GDBUDDYPRESS_TEXTDOMAIN); $status_icon = '<i class="fa fa-pause"></i>'; } $status .= ")</strong>"; $html = '<span class="geodir-post-status">' . $status_icon . ' <font class="geodir-status-label">' . __('Status: ', GDBUDDYPRESS_TEXTDOMAIN) . '</font>' . $status . '</span>'; } echo $html; }
/** * * @global object $wpdb WordPress Database object. * * @param array $args * @param array $instance */ public function widget($args, $instance) { extract($args, EXTR_SKIP); echo $before_widget; $title = empty($instance['title']) ? $instance['category_title'] : apply_filters('widget_title', $instance['title']); $hood_post_type = empty($instance['hood_post_type']) ? 'gd_place' : apply_filters('widget_hood_post_type', $instance['hood_post_type']); $hood_category = empty($instance['hood_category']) ? '0' : apply_filters('widget_hood_category', $instance['hood_category']); $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']); $layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']); $add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_layout', $instance['add_location_filter']); $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']); $character_count = empty($instance['character_count']) ? 20 : apply_filters('widget_list_sort', $instance['character_count']); if (empty($title) || $title == 'All') { $title .= ' Neighbourhood ' . get_post_type_plural_label($hood_post_type); } global $wpdb, $post, $geodir_post_type; if ($geodir_post_type == '') { $geodir_post_type = 'gd_place'; } $all_postypes = geodir_get_posttypes(); $location_id = ''; $not_in_array = array(); if (geodir_is_page('detail') || geodir_is_page('preview') || geodir_is_page('add-listing')) { if (isset($post->post_type) && $post->post_type == $hood_post_type && isset($post->post_location_id)) { $not_in_array[] = $post->ID; $location_id = $post->post_location_id; } } elseif (in_array($geodir_post_type, $all_postypes) && $geodir_post_type == $hood_post_type) { if (isset($_SESSION['gd_city']) && $_SESSION['gd_city'] != '') { $location_id = $wpdb->get_var($wpdb->prepare("SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug = %s", array($_SESSION['gd_city']))); } else { $default_location = geodir_get_default_location(); $location_id = $default_location->location_id; } } $gd_neighbourhoods = geodir_get_neighbourhoods($location_id); if ($gd_neighbourhoods) { ?> <div class="geodir_locations geodir_location_listing"> <div class="locatin_list_heading clearfix"> <h3><?php _e(ucfirst($title), GEODIRLOCATION_TEXTDOMAIN); ?> </h3> </div> <?php $hood_slug_arr = array(); if (!empty($gd_neighbourhoods)) { foreach ($gd_neighbourhoods as $hoodslug) { $hood_slug_arr[] = $hoodslug->hood_slug; } } $query_args = array('posts_per_page' => $post_number, 'is_geodir_loop' => true, 'post__not_in' => $not_in_array, 'gd_neighbourhood' => $hood_slug_arr, 'gd_location' => $add_location_filter ? true : false, 'post_type' => $hood_post_type, 'order_by' => $list_sort, 'excerpt_length' => $character_count); if ($hood_category != 0 || $hood_category != '') { $category_taxonomy = geodir_get_taxonomies($hood_post_type); $tax_query = array('taxonomy' => $category_taxonomy[0], 'field' => 'id', 'terms' => $hood_category); $query_args['tax_query'] = array($tax_query); } global $gridview_columns; query_posts($query_args); if (strstr($layout, 'gridview')) { $listing_view_exp = explode('_', $layout); $gridview_columns = $layout; $layout = $listing_view_exp[0]; } $template = apply_filters("geodir_template_part-listing-listview", geodir_plugin_path() . '/geodirectory-templates/listing-listview.php'); include $template; wp_reset_query(); ?> </div> <?php } echo $after_widget; }
/** * Filter to hide the listing excerpt. * * @since 1.5.7 * @param bool $display Display the excerpt or not. * @param string $view The view type, Ex: 'listview'. * @param object $post The post object. * @return bool Modified value for display the excerpt. */ function geodir_show_listing_post_excerpt($display, $view, $post) { if ($view == 'listview') { if (geodir_is_page('author')) { $word_limit = get_option('geodir_author_desc_word_limit'); } else { $word_limit = get_option('geodir_desc_word_limit'); } if ($word_limit !== '' && ($word_limit == 0 || $word_limit == '0')) { $display = false; } } return $display; }
/** * Current page title bar. * * @since 1.0.0 * @package GeoDirectory */ function gd_genesis_current_page_title_bar() { $title = ''; $subtitle = ''; if (geodir_is_page('listing')) { echo '<div class="wrap gd-title-wrap">'; geodir_action_listings_title(); echo '</div>'; } if (geodir_is_page('add-listing')) { echo '<div class="wrap gd-title-wrap">'; geodir_action_add_listing_page_title(); echo '</div>'; } if (geodir_is_page('author')) { echo '<div class="wrap gd-title-wrap">'; geodir_action_author_page_title(); echo '</div>'; } if (geodir_is_page('detail') || geodir_is_page('preview')) { echo '<div class="wrap gd-title-wrap">'; echo get_the_title(); echo '</div>'; } if (geodir_is_page('search')) { echo '<div class="wrap gd-title-wrap">'; geodir_action_search_page_title(); echo '</div>'; } }
/** * Front-end display content for listing page map widget. * * @since 1.0.0 * @since 1.5.1 Declare function public. * * @global object $post The current post object. * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { if (geodir_is_page('listing') || geodir_is_page('author') || geodir_is_page('search') || geodir_is_page('detail')) { extract($args, EXTR_SKIP); /** This action is documented in geodirectory_shortcodes.php */ $width = empty($instance['width']) ? '294' : apply_filters('widget_width', $instance['width']); /** This action is documented in geodirectory_shortcodes.php */ $height = empty($instance['heigh']) ? '370' : apply_filters('widget_heigh', $instance['heigh']); /** This action is documented in geodirectory_shortcodes.php */ $maptype = empty($instance['maptype']) ? 'ROADMAP' : apply_filters('widget_maptype', $instance['maptype']); /** This action is documented in geodirectory_shortcodes.php */ $zoom = empty($instance['zoom']) ? '13' : apply_filters('widget_zoom', $instance['zoom']); /** This action is documented in geodirectory_shortcodes.php */ $autozoom = empty($instance['autozoom']) ? '' : apply_filters('widget_autozoom', $instance['autozoom']); /** * Filter the listing map value widget_sticky, to set if the map should be sticky or not (scroll with page). * * @since 1.0.0 * @param bool $sticky True if should be sticky, false if not */ $sticky = empty($instance['sticky']) ? '' : apply_filters('widget_sticky', $instance['sticky']); /** This action is documented in geodirectory_shortcodes.php */ $scrollwheel = empty($instance['scrollwheel']) ? '0' : apply_filters('widget_scrollwheel', $instance['scrollwheel']); $showall = empty($instance['showall']) ? '0' : apply_filters('widget_showall', $instance['showall']); /** * Filter the listing map should to be displayed or not. * * @since 1.4.6 * * @param bool $display true if map should be displayed, false if not. */ $show_map = apply_filters('geodir_show_map_listing', $display = true); if (!$show_map) { return; } $map_args = array(); $map_args['map_canvas_name'] = str_replace('-', '_', $args['widget_id']); $map_args['width'] = $width; $map_args['height'] = $height; $map_args['scrollwheel'] = $scrollwheel; $map_args['showall'] = $showall; $map_args['child_collapse'] = '0'; $map_args['sticky'] = $sticky; $map_args['enable_cat_filters'] = false; $map_args['enable_text_search'] = false; $map_args['enable_post_type_filters'] = false; $map_args['enable_location_filters'] = false; $map_args['enable_jason_on_load'] = true; if (is_single()) { global $post; $map_default_lat = $address_latitude = $post->post_latitude; $map_default_lng = $address_longitude = $post->post_longitude; $mapview = $post->post_mapview; $mapzoom = $post->post_mapzoom; $map_args['map_class_name'] = 'geodir-map-listing-page-single'; } else { $default_location = geodir_get_default_location(); $map_default_lat = isset($default_location->city_latitude) ? $default_location->city_latitude : ''; $map_default_lng = isset($default_location->city_longitude) ? $default_location->city_longitude : ''; $map_args['map_class_name'] = 'geodir-map-listing-page'; $mapview = $maptype; } if (empty($mapview)) { $mapview = 'ROADMAP'; } if (empty($mapzoom)) { $mapzoom = $zoom; } // Set default map options $map_args['ajax_url'] = geodir_get_ajax_url(); $map_args['latitude'] = $map_default_lat; $map_args['longitude'] = $map_default_lng; $map_args['zoom'] = $zoom; //$map_args['scrollwheel'] = true; $map_args['scrollwheel'] = $scrollwheel; $map_args['showall'] = $showall; $map_args['streetViewControl'] = true; $map_args['maptype'] = $mapview; $map_args['showPreview'] = '0'; $map_args['maxZoom'] = 21; $map_args['autozoom'] = $autozoom; $map_args['bubble_size'] = 'small'; echo $before_widget; geodir_draw_map($map_args); echo $after_widget; } }
/** * 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; }
/** * wrapper content open functions. * * @since 1.0.0 * @package GeoDirectory * @param string $type Page type. * @param string $id The id of the HTML element. * @param string $class The class of the HTML element. */ function enfold_action_wrapper_content_open($type = '', $id = '', $class = '') { if (geodir_is_page('login')) { echo "<main class='template-page content twelve alpha units " . $class . "' " . avia_markup_helper(array('context' => 'content', 'post_type' => 'page', 'echo' => false)) . ">"; } else { echo "<main class='template-page content " . avia_layout_class('content', false) . " units " . $class . "' " . avia_markup_helper(array('context' => 'content', 'post_type' => 'page', 'echo' => false)) . ">"; } echo '<div class="entry-content-wrapper">'; }
/** * The main function responsible for displaying tabs in frontend detail page. * * @since 1.0.0 * @package GeoDirectory * @global object $post The current post object. * @global array $post_images List of images attached to the post. * @global string $video The video embed content. * @global string $special_offers Special offers content. * @global string $related_listing Related listing html. * @global string $geodir_post_detail_fields Detail field html. */ function geodir_show_detail_page_tabs() { global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields; $post_id = !empty($post) && isset($post->ID) ? (int) $post->ID : 0; $request_post_id = !empty($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0; $is_backend_preview = is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p']) && is_super_admin() ? true : false; // skip if preview from backend if ($is_backend_preview && !$post_id > 0 && $request_post_id > 0) { $post = geodir_get_post_info($request_post_id); setup_postdata($post); } $geodir_post_detail_fields = geodir_show_listing_info('detail'); if (geodir_is_page('detail')) { $video = geodir_get_video($post->ID); $special_offers = geodir_get_special_offers($post->ID); $related_listing_array = array(); if (get_option('geodir_add_related_listing_posttypes')) { $related_listing_array = get_option('geodir_add_related_listing_posttypes'); } $related_listing = ''; if (in_array($post->post_type, $related_listing_array)) { $request = array('post_number' => get_option('geodir_related_post_count'), 'relate_to' => get_option('geodir_related_post_relate_to'), 'layout' => get_option('geodir_related_post_listing_view'), 'add_location_filter' => get_option('geodir_related_post_location_filter'), 'list_sort' => get_option('geodir_related_post_sortby'), 'character_count' => get_option('geodir_related_post_excerpt')); $related_listing = geodir_related_posts_display($request); } $post_images = geodir_get_images($post->ID, 'thumbnail'); $thumb_image = ''; if (!empty($post_images)) { foreach ($post_images as $image) { $caption = !empty($image->caption) ? $image->caption : ''; $thumb_image .= '<a href="' . $image->src . '" title="' . $caption . '">'; $thumb_image .= geodir_show_image($image, 'thumbnail', true, false); $thumb_image .= '</a>'; } } $map_args = array(); $map_args['map_canvas_name'] = 'detail_page_map_canvas'; $map_args['width'] = '600'; $map_args['height'] = '300'; if ($post->post_mapzoom) { $map_args['zoom'] = '' . $post->post_mapzoom . ''; } $map_args['autozoom'] = false; $map_args['child_collapse'] = '0'; $map_args['enable_cat_filters'] = false; $map_args['enable_text_search'] = false; $map_args['enable_post_type_filters'] = false; $map_args['enable_location_filters'] = false; $map_args['enable_jason_on_load'] = true; $map_args['enable_map_direction'] = true; $map_args['map_class_name'] = 'geodir-map-detail-page'; $map_args['maptype'] = !empty($post->post_mapview) ? $post->post_mapview : 'ROADMAP'; } elseif (geodir_is_page('preview')) { $video = isset($post->geodir_video) ? $post->geodir_video : ''; $special_offers = isset($post->geodir_special_offers) ? $post->geodir_special_offers : ''; if (isset($post->post_images)) { $post->post_images = trim($post->post_images, ","); } if (isset($post->post_images) && !empty($post->post_images)) { $post_images = explode(",", $post->post_images); } $thumb_image = ''; if (!empty($post_images)) { foreach ($post_images as $image) { if ($image != '') { $thumb_image .= '<a href="' . $image . '">'; $thumb_image .= geodir_show_image(array('src' => $image), 'thumbnail', true, false); $thumb_image .= '</a>'; } } } global $map_jason; $map_jason[] = $post->marker_json; $address_latitude = isset($post->post_latitude) ? $post->post_latitude : ''; $address_longitude = isset($post->post_longitude) ? $post->post_longitude : ''; $mapview = isset($post->post_mapview) ? $post->post_mapview : ''; $mapzoom = isset($post->post_mapzoom) ? $post->post_mapzoom : ''; if (!$mapzoom) { $mapzoom = 12; } $map_args = array(); $map_args['map_canvas_name'] = 'preview_map_canvas'; $map_args['width'] = '950'; $map_args['height'] = '300'; $map_args['child_collapse'] = '0'; $map_args['maptype'] = $mapview; $map_args['autozoom'] = false; $map_args['zoom'] = "{$mapzoom}"; $map_args['latitude'] = $address_latitude; $map_args['longitude'] = $address_longitude; $map_args['enable_cat_filters'] = false; $map_args['enable_text_search'] = false; $map_args['enable_post_type_filters'] = false; $map_args['enable_location_filters'] = false; $map_args['enable_jason_on_load'] = true; $map_args['enable_map_direction'] = true; $map_args['map_class_name'] = 'geodir-map-preview-page'; } $arr_detail_page_tabs = geodir_detail_page_tabs_list(); // get this sooner so we can get the active tab for the user $active_tab_name = ''; foreach ($arr_detail_page_tabs as $tabs) { if (isset($tabs['is_active_tab']) && $tabs['is_active_tab'] && isset($tabs['heading_text']) && $tabs['heading_text']) { $active_tab_name = __($tabs['heading_text'], 'geodirectory'); } } ?> <div class="geodir-tabs" id="gd-tabs" style="position:relative;"> <div id="geodir-tab-mobile-menu" > <i class="fa fa-bars"></i> <span class="geodir-mobile-active-tab"><?php echo $active_tab_name; ?> </span> <i class="fa fa-sort-desc"></i> </div> <dl class="geodir-tab-head"> <?php /** * Called before the details page tab list headings, inside the `dl` tag. * * @since 1.0.0 * @see 'geodir_after_tab_list' */ do_action('geodir_before_tab_list'); ?> <?php foreach ($arr_detail_page_tabs as $tab_index => $detail_page_tab) { if ($detail_page_tab['is_display']) { ?> <dt></dt> <!-- added to comply with validation --> <dd <?php if ($detail_page_tab['is_active_tab']) { ?> class="geodir-tab-active"<?php } ?> > <a data-tab="#<?php echo $tab_index; ?> " data-status="enable"><?php _e($detail_page_tab['heading_text'], 'geodirectory'); ?> </a> </dd> <?php ob_start(); ?> <li id="<?php echo $tab_index; ?> Tab" <?php if ($tab_index == 'post_profile') { //echo 'itemprop="description"'; } ?> > <div id="<?php echo $tab_index; ?> " class="hash-offset"></div> <?php /** * Called before the details tab content is output per tab. * * @since 1.0.0 * @param string $tab_index The tab name ID. */ do_action('geodir_before_tab_content', $tab_index); /** * Called before the details tab content is output per tab. * * Uses dynamic hook name: geodir_before_$tab_index_tab_content * * @since 1.0.0 * @todo do we need this if we have the hook above? 'geodir_before_tab_content' */ do_action('geodir_before_' . $tab_index . '_tab_content'); /// write a code to generate content of each tab switch ($tab_index) { case 'post_profile': /** * Called before the listing description content on the details page tab. * * @since 1.0.0 */ do_action('geodir_before_description_on_listing_detail'); if (geodir_is_page('detail')) { the_content(); } else { /** This action is documented in geodirectory_template_actions.php */ echo apply_filters('the_content', stripslashes($post->post_desc)); } /** * Called after the listing description content on the details page tab. * * @since 1.0.0 */ do_action('geodir_after_description_on_listing_detail'); break; case 'post_info': echo $geodir_post_detail_fields; break; case 'post_images': echo $thumb_image; break; case 'post_video': /** This action is documented in geodirectory_template_actions.php */ echo apply_filters('the_content', stripslashes($video)); // we apply the_content filter so oembed works also; break; case 'special_offers': echo wpautop(stripslashes($special_offers)); break; case 'post_map': geodir_draw_map($map_args); break; case 'reviews': comments_template(); break; case 'related_listing': echo $related_listing; break; default: if ((isset($post->{$tab_index}) || !isset($post->{$tab_index}) && (strpos($tab_index, 'gd_tab_') !== false || $tab_index == 'link_business')) && !empty($detail_page_tab['tab_content'])) { echo $detail_page_tab['tab_content']; } break; } /** * Called after the details tab content is output per tab. * * @since 1.0.0 */ do_action('geodir_after_tab_content', $tab_index); /** * Called after the details tab content is output per tab. * * Uses dynamic hook name: geodir_after_$tab_index_tab_content * * @since 1.0.0 * @todo do we need this if we have the hook above? 'geodir_after_tab_content' */ do_action('geodir_after_' . $tab_index . '_tab_content'); ?> </li> <?php /** * Filter the current tab content. * * @since 1.0.0 */ $arr_detail_page_tabs[$tab_index]['tab_content'] = apply_filters("geodir_modify_" . $detail_page_tab['tab_content'] . "_tab_content", ob_get_clean()); } // end of if for is_display } // end of foreach /** * Called after the details page tab list headings, inside the `dl` tag. * * @since 1.0.0 * @see 'geodir_before_tab_list' */ do_action('geodir_after_tab_list'); ?> </dl> <ul class="geodir-tabs-content entry-content" style="position:relative;"> <?php foreach ($arr_detail_page_tabs as $detail_page_tab) { if ($detail_page_tab['is_display'] && !empty($detail_page_tab['tab_content'])) { echo $detail_page_tab['tab_content']; } // end of if } // end of foreach /** * Called after all the tab content is output in `li` tags, called before the closing `ul` tag. * * @since 1.0.0 */ do_action('geodir_add_tab_content'); ?> </ul> <!--gd-tabs-content ul end--> </div> <script> if (window.location.hash && window.location.hash.indexOf('&') === -1 && jQuery(window.location.hash + 'Tab').length) { hashVal = window.location.hash; } else { hashVal = jQuery('dl.geodir-tab-head dd.geodir-tab-active').find('a').attr('data-tab'); } jQuery('dl.geodir-tab-head dd').each(function () { //Get all tabs var tabs = jQuery(this).children('dd'); var tab = ''; tab = jQuery(this).find('a').attr('data-tab'); if (hashVal != tab) { jQuery(tab + 'Tab').hide(); } }); </script> <?php }
/** * Listing where filter. * * @since 1.0.0 * @package GeoDirectory * @global object $wpdb WordPress Database object. * @global string $table Listing table name. */ function geodir_post_where() { global $wpdb, $geodir_post_type, $table, $s, $snear; if (!is_admin()) { if (geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { add_filter('posts_where', 'geodir_edit_listing_where', 1); } elseif (is_search() && $_REQUEST['geodir_search']) { add_filter('posts_where', 'searching_filter_where', 1); if ($snear != '') { add_filter('posts_where', 'searching_filter_where', 1); } add_filter('posts_orderby', 'geodir_posts_orderby', 1); } elseif (geodir_is_page('author')) { add_filter('posts_where', 'author_filter_where', 1); } //if (!geodir_is_page('detail')) add_filter('posts_where', 'geodir_default_where', 1); /**/ //add_filter( 'user_has_cap', 'geodir_preview_post_cap', 10, 3 );// let subscribers edit their own posts } }
/** * Adds post status on author page when the author is current user. * * @since 1.0.0 * @package GeoDirectory * @global object $wpdb WordPress Database object. * @global object $post The current post object. */ function geodir_add_post_status_author_page() { global $wpdb, $post; $html = ''; if (get_current_user_id()) { if (geodir_is_page('author') && !empty($post) && isset($post->post_author) && $post->post_author == get_current_user_id()) { // we need to query real status direct as we dynamically change the status for author on author page so even non author status can view them. $real_status = $wpdb->get_var("SELECT post_status from {$wpdb->posts} WHERE ID={$post->ID}"); $status = "<strong>("; $status_icon = '<i class="fa fa-play"></i>'; if ($real_status == 'publish') { $status .= __('Published', 'geodirectory'); } else { $status .= __('Not published', 'geodirectory'); $status_icon = '<i class="fa fa-pause"></i>'; } $status .= ")</strong>"; $html = '<span class="geodir-post-status">' . $status_icon . ' <font class="geodir-status-label">' . __('Status: ', 'geodirectory') . '</font>' . $status . '</span>'; } } if ($html != '') { /** * Filter the post status text on the author page. * * @since 1.0.0 * @param string $html The HTML of the status. */ echo apply_filters('geodir_filter_status_text_on_author_page', $html); } }
/** * Filter the related listing tab should be displayed on detail page or not. * * @since 1.2.3 * * @global WP_Post $post WP Post object. Default current post. * * @param bool $is_display True if related listing should be displayed, otherwise false. * @param string $tab The listing detail page tab. * @return True if related listing should be displayed, otherwise false. */ function geodir_payment_related_listing_is_display($is_display, $tab) { global $post; if ($tab == 'related_listing' && (geodir_is_page('detail') || geodir_is_page('preview')) && !empty($post)) { if (geodir_payments_hide_related_tab($post)) { $is_display = false; } } return $is_display; }