/** * Generates popular postview HTML. * * @since 1.0.0 * @since 1.5.1 View all link fixed for location filter disabled. * @package GeoDirectory * @global object $post The current post object. * @global string $gridview_columns_widget The girdview style of the listings for widget. * @global bool $geodir_is_widget_listing Is this a widget listing?. Default: false. * @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_popular_postview_output($args = '', $instance = '') { //print_r($args); //print_r($instance); // prints the widget extract($args, EXTR_SKIP); echo $before_widget; /** This filter is documented in geodirectory_widgets.php */ $title = empty($instance['title']) ? ucwords($instance['category_title']) : apply_filters('widget_title', __($instance['title'], 'geodirectory')); /** * Filter the widget post type. * * @since 1.0.0 * @param string $instance['post_type'] Post type of listing. */ $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']); /** * Filter the widget's term. * * @since 1.0.0 * @param string $instance['category'] Filter by term. Can be any valid term. */ $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']); /** * Filter the widget listings limit. * * @since 1.0.0 * @param string $instance['post_number'] Number of listings to display. */ $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']); /** * Filter widget's "layout" type. * * @since 1.0.0 * @param string $instance['layout'] Widget layout type. */ $layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']); /** * Filter widget's "add_location_filter" value. * * @since 1.0.0 * @param string|bool $instance['add_location_filter'] Do you want to add location filter? Can be 1 or 0. */ $add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']); /** * Filter widget's listing width. * * @since 1.0.0 * @param string $instance['listing_width'] Listing width. */ $listing_width = empty($instance['listing_width']) ? '' : apply_filters('widget_listing_width', $instance['listing_width']); /** * Filter widget's "list_sort" type. * * @since 1.0.0 * @param string $instance['list_sort'] Listing sort by type. */ $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']); $use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false; // set post type to current viewing post type if ($use_viewing_post_type) { $current_post_type = geodir_get_current_posttype(); if ($current_post_type != '' && $current_post_type != $post_type) { $post_type = $current_post_type; $category = array(); // old post type category will not work for current changed post type } } // replace widget title dynamically $posttype_plural_label = __(get_post_type_plural_label($post_type), 'geodirectory'); $posttype_singular_label = __(get_post_type_singular_label($post_type), 'geodirectory'); $title = str_replace("%posttype_plural_label%", $posttype_plural_label, $title); $title = str_replace("%posttype_singular_label%", $posttype_singular_label, $title); if (isset($instance['character_count'])) { /** * Filter the widget's excerpt character count. * * @since 1.0.0 * @param int $instance['character_count'] Excerpt character count. */ $character_count = apply_filters('widget_list_character_count', $instance['character_count']); } else { $character_count = ''; } if (empty($title) || $title == 'All') { $title .= ' ' . __(get_post_type_plural_label($post_type), 'geodirectory'); } $location_url = array(); $city = get_query_var('gd_city'); if (!empty($city)) { if (get_option('geodir_show_location_url') == 'all') { $country = get_query_var('gd_country'); $region = get_query_var('gd_region'); if (!empty($country)) { $location_url[] = $country; } if (!empty($region)) { $location_url[] = $region; } } $location_url[] = $city; } $location_url = implode("/", $location_url); $skip_location = false; if (!$add_location_filter && !empty($_SESSION['gd_multi_location'])) { $skip_location = true; unset($_SESSION['gd_multi_location']); } if (get_option('permalink_structure')) { $viewall_url = get_post_type_archive_link($post_type); } else { $viewall_url = get_post_type_archive_link($post_type); } if (!empty($category) && $category[0] != '0') { global $geodir_add_location_url; $geodir_add_location_url = '0'; if ($add_location_filter != '0') { $geodir_add_location_url = '1'; } $viewall_url = get_term_link((int) $category[0], $post_type . 'category'); $geodir_add_location_url = NULL; } if ($skip_location) { $_SESSION['gd_multi_location'] = 1; } $query_args = array('posts_per_page' => $post_number, 'is_geodir_loop' => true, 'gd_location' => $add_location_filter ? true : false, 'post_type' => $post_type, 'order_by' => $list_sort); if ($character_count) { $query_args['excerpt_length'] = $character_count; } if (!empty($instance['show_featured_only'])) { $query_args['show_featured_only'] = 1; } if (!empty($instance['show_special_only'])) { $query_args['show_special_only'] = 1; } if (!empty($instance['with_pics_only'])) { $query_args['with_pics_only'] = 0; $query_args['featured_image_only'] = 1; } if (!empty($instance['with_videos_only'])) { $query_args['with_videos_only'] = 1; } $with_no_results = !empty($instance['without_no_results']) ? false : true; if (!empty($category) && $category[0] != '0') { $category_taxonomy = geodir_get_taxonomies($post_type); ######### WPML ######### if (function_exists('icl_object_id')) { $category = gd_lang_object_ids($category, $category_taxonomy[0]); } ######### WPML ######### $tax_query = array('taxonomy' => $category_taxonomy[0], 'field' => 'id', 'terms' => $category); $query_args['tax_query'] = array($tax_query); } global $gridview_columns_widget, $geodir_is_widget_listing; $widget_listings = geodir_get_widget_listings($query_args); if (!empty($widget_listings) || $with_no_results) { ?> <div class="geodir_locations geodir_location_listing"> <?php /** * Called before the div containing the title and view all link in popular post view widget. * * @since 1.0.0 */ do_action('geodir_before_view_all_link_in_widget'); ?> <div class="geodir_list_heading clearfix"> <?php if ($title == 'ร้านอาหาร') { echo '<img src = "/wordpress/wp-content/food.png" width="100%">'; } else { echo '<img src = "/wordpress/wp-content/u.png" width="100%">'; } ?> <?php //echo $before_title . $title . $after_title; ?> <a href="<?php echo $viewall_url; ?> " class="geodir-viewall"><?php _e('View all', 'geodirectory'); ?> </a> </div> <?php /** * Called after the div containing the title and view all link in popular post view widget. * * @since 1.0.0 */ do_action('geodir_after_view_all_link_in_widget'); ?> <?php if (strstr($layout, 'gridview')) { $listing_view_exp = explode('_', $layout); $gridview_columns_widget = $layout; $layout = $listing_view_exp[0]; } else { $gridview_columns_widget = ''; } /** * Filter the widget listing listview template path. * * @since 1.0.0 */ $template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview')); if (!isset($character_count)) { /** * Filter the widget's excerpt character count. * * @since 1.0.0 * @param int $instance['character_count'] Excerpt character count. */ $character_count = $character_count == '' ? 50 : apply_filters('widget_character_count', $character_count); } global $post, $map_jason, $map_canvas_arr; $current_post = $post; $current_map_jason = $map_jason; $current_map_canvas_arr = $map_canvas_arr; $geodir_is_widget_listing = true; /** * Includes related listing listview template. * * @since 1.0.0 */ include $template; $geodir_is_widget_listing = false; $GLOBALS['post'] = $current_post; if (!empty($current_post)) { setup_postdata($current_post); } $map_jason = $current_map_jason; $map_canvas_arr = $current_map_canvas_arr; ?> </div> <?php } echo $after_widget; }
/** * Returns listing nav menu Items. * * When WP Admin -> * Geodirectory -> * Design -> * Navigation -> * Show add listing navigation in menu and/or Show listings navigation in menu * checked this function returns listing and add listing links. * * @since 1.0.0 * @package GeoDirectory * @return string The Menu HTML. */ function geodir_add_nav_menu_items() { $items = ''; // apply filter to add more navigations // -Filter-Location-Manager if (get_option('geodir_show_listing_nav')) { $menu_class = ''; if (geodir_is_page('listing')) { $menu_class = 'current-menu-item'; } //SHOW LISTING OF POST TYPE IN MAIN NAVIGATION $post_types = geodir_get_posttypes('object'); $show_post_type_main_nav = get_option('geodir_add_posttype_in_main_nav'); if (!empty($post_types)) { foreach ($post_types as $post_type => $args) { if (!empty($show_post_type_main_nav)) { if (in_array($post_type, $show_post_type_main_nav)) { if (get_post_type_archive_link($post_type)) { $menu_class = ''; if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing')) { $menu_class = 'current-menu-item'; } /** * Filter the menu li class. * * @since 1.0.0 * @param string $menu_class The menu HTML class. */ $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class); /** * Filter the menu a class. * * @since 1.0.0 */ $a_class = apply_filters('geodir_menu_a_class', ''); $items .= '<li class="' . $li_class . '"> <a href="' . get_post_type_archive_link($post_type) . '" class="' . $a_class . '"> ' . __(ucfirst($args->labels->name)) . ' </a> </li>'; } } } } } //END LISTING OF POST TYPE IN MAIN NAVIGATION $view_posttype_listing = get_option('geodir_add_posttype_in_listing_nav'); $is_listing_sub_meny_exists = !empty($view_posttype_listing) ? true : false; if ($is_listing_sub_meny_exists) { /** * Filter the menu li class. * * @since 1.0.0 * @param string $menu_class The menu HTML class. */ $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class); /** * Filter the sub menu li class. * * @since 1.0.0 * @param string $menu_class The menu HTML class. */ $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class); /** * Filter the sub menu ul class. * * @since 1.0.0 */ $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu'); /** * Filter the menu a class. * * @since 1.0.0 */ $a_class = apply_filters('geodir_menu_a_class', ''); /** * Filter the sub menu a class. * * @since 1.0.0 */ $sub_a_class = apply_filters('geodir_sub_menu_a_class', ''); $items .= '<li class="' . $li_class . '"> <a href="#" class="' . $a_class . '">' . __('Listing', 'geodirectory') . '</a> <ul class="' . $sub_ul_class . '">'; $post_types = geodir_get_posttypes('object'); $show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav'); if (!empty($post_types)) { global $geodir_add_location_url; $geodir_add_location_url = true; foreach ($post_types as $post_type => $args) { if (!empty($show_listing_post_types)) { if (in_array($post_type, $show_listing_post_types)) { if (get_post_type_archive_link($post_type)) { $menu_class = ''; if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing')) { $menu_class = 'current-menu-item'; } $items .= '<li class="' . $sub_li_class . '"> <a href="' . get_post_type_archive_link($post_type) . '" class="' . $sub_a_class . '"> ' . __(ucfirst($args->labels->name)) . ' </a> </li>'; } } } } $geodir_add_location_url = NULL; } $items .= ' </ul> </li>'; } } if (get_option('geodir_show_addlisting_nav')) { $menu_class = ''; if (geodir_is_page('add-listing')) { $menu_class = 'current-menu-item'; } //SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION $post_types = geodir_get_posttypes('object'); $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_main_nav'); $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend'); if (!empty($post_types)) { foreach ($post_types as $post_type => $args) { if (!empty($geodir_allow_posttype_frontend)) { if (in_array($post_type, $geodir_allow_posttype_frontend)) { if (!empty($show_add_listing_post_types_main_nav)) { if (in_array($post_type, $show_add_listing_post_types_main_nav)) { if (geodir_get_addlisting_link($post_type)) { $menu_class = ''; if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing')) { $menu_class = 'current-menu-item'; } /** * Filter the menu li class. * * @since 1.0.0 * @param string $menu_class The menu HTML class. */ $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class); /** * Filter the menu a class. * * @since 1.0.0 */ $a_class = apply_filters('geodir_menu_a_class', ''); $cpt_name = __($args->labels->singular_name, 'geodirectory'); $items .= '<li class="' . $li_class . '"> <a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $a_class . '"> ' . sprintf(__('Add %s', 'geodirectory'), $cpt_name) . ' </a> </li>'; } } } } } } } //END SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION } $view_add_posttype_listing = get_option('geodir_add_listing_link_add_listing_nav'); $is_add_listing_sub_meny_exists = !empty($view_add_posttype_listing) ? true : false; if ($is_add_listing_sub_meny_exists) { if (get_option('geodir_show_addlisting_nav')) { /** * Filter the menu li class. * * @since 1.0.0 * @param string $menu_class The menu HTML class. */ $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class); /** * Filter the sub menu li class. * * @since 1.0.0 * @param string $menu_class The menu HTML class. */ $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class); /** * Filter the sub menu ul class. * * @since 1.0.0 */ $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu'); /** * Filter the menu a class. * * @since 1.0.0 */ $a_class = apply_filters('geodir_menu_a_class', ''); /** * Filter the sub menu a class. * * @since 1.0.0 */ $sub_a_class = apply_filters('geodir_sub_menu_a_class', ''); $items .= '<li class="' . $li_class . '"> <a href="#" class="' . $a_class . '">' . __('Add Listing', 'geodirectory') . '</a> <ul class="' . $sub_ul_class . '">'; $post_types = geodir_get_posttypes('object'); $show_add_listing_post_types = get_option('geodir_add_listing_link_add_listing_nav'); if (!empty($post_types)) { foreach ($post_types as $post_type => $args) { if (!empty($geodir_allow_posttype_frontend)) { if (in_array($post_type, $geodir_allow_posttype_frontend)) { if (!empty($show_add_listing_post_types)) { if (in_array($post_type, $show_add_listing_post_types)) { if (geodir_get_addlisting_link($post_type)) { $menu_class = ''; if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing')) { $menu_class = 'current-menu-item'; } /** * Filter the menu li class. * * @since 1.0.0 * @param string $menu_class The menu HTML class. */ $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class); $cpt_name = __($args->labels->singular_name, 'geodirectory'); $items .= '<li class="' . $li_class . '"> <a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $sub_a_class . '"> ' . sprintf(__('Add %s', 'geodirectory'), $cpt_name) . ' </a> </li>'; } } } } } } } $items .= ' </ul> </li>'; } } // apply filter to add more navigations // -Filter-Location-Manager return $items; }
function geodir_autocompleter_ajax_url($type = '', $near = false) { $gd_post_type = geodir_get_current_posttype(); if ($gd_post_type == '') { $gd_post_type = 'gd_place'; } if ($near) { return admin_url('admin-ajax.php?action=geodir_autocompleter_near_ajax_action'); } else { return admin_url('admin-ajax.php?action=geodir_autocompleter_ajax_action'); } }
/** * Adds listing description to the page. * * @since 1.0.0 * @package GeoDirectory_Location_Manager * * @global object $wpdb WordPress Database object. * @global object $wp_query WordPress Query object. */ function geodir_location_action_listings_description() { global $wpdb, $wp_query; $current_term = $wp_query->get_queried_object(); $gd_post_type = geodir_get_current_posttype(); if (isset($current_term->term_id) && $current_term->term_id != '') { $term_desc = term_description($current_term->term_id, $gd_post_type . '_tags'); $saved_data = stripslashes(get_tax_meta($current_term->term_id, 'ct_cat_top_desc', false, $gd_post_type)); if ($term_desc && !$saved_data) { $saved_data = $term_desc; } $default_location = geodir_get_default_location(); $location_type = geodir_what_is_current_location(); $replace_location = __('Everywhere', GEODIRLOCATION_TEXTDOMAIN); $gd_country = get_query_var('gd_country'); $gd_region = get_query_var('gd_region'); $gd_city = get_query_var('gd_city'); $current_location = ''; if ($gd_country != '') { $location_type = 'country'; $current_location = get_actual_location_name('country', $gd_country, true); } if ($gd_region != '') { $location_type = 'region'; $current_location = get_actual_location_name('region', $gd_region); } if ($gd_city != '') { $location_type = 'city'; $current_location = get_actual_location_name('city', $gd_city); } if ($location_type == 'city') { $replace_location = geodir_get_current_location(array('what' => 'city', 'echo' => false)); $option_name = 'geodir_cat_loc_' . $gd_post_type . '_' . $current_term->term_id; $cat_loc_option = get_option($option_name); $gd_cat_loc_default = !empty($cat_loc_option) && isset($cat_loc_option['gd_cat_loc_default']) && $cat_loc_option['gd_cat_loc_default'] > 0 ? true : false; if (!$gd_cat_loc_default && $gd_city != '') { $post_type = $gd_post_type; $term_id = $current_term->term_id; $sql = $wpdb->prepare("SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array($gd_city)); $location_id = $wpdb->get_var($sql); if ($location_id > 0) { $option_name = 'geodir_cat_loc_' . $post_type . '_' . $term_id . '_' . $location_id; $option = get_option($option_name); $gd_cat_loc_desc = !empty($option) && isset($option['gd_cat_loc_desc']) ? trim($option['gd_cat_loc_desc']) : ''; if ($gd_cat_loc_desc != '') { $saved_data = stripslashes_deep($gd_cat_loc_desc); } } } } else { if ($location_type == 'region') { $replace_location = geodir_get_current_location(array('what' => 'region', 'echo' => false)); } else { if ($location_type == 'country') { $replace_location = geodir_get_current_location(array('what' => 'country', 'echo' => false)); $replace_location = __($replace_location, GEODIRECTORY_TEXTDOMAIN); } } } $replace_location = $current_location != '' ? $current_location : $replace_location; $saved_data = str_replace('%location%', $replace_location, $saved_data); $cat_description = apply_filters('the_content', $saved_data); if ($cat_description) { echo '<div class="term_description">' . $cat_description . '</div>'; } } }
/** * Output the home page title including HTML wrappers. * * @since 1.0.0 * @package GeoDirectory * @param string $list_title The home page title. * @return string */ function geodir_filter_listing_page_title($list_title) { if (is_search() && trim(get_search_query()) == '') { $gd_post_type = geodir_get_current_posttype(); $post_type_info = get_post_type_object($gd_post_type); $list_title = __('Search', GEODIRECTORY_TEXTDOMAIN) . ' ' . __(ucfirst($post_type_info->labels->name), GEODIRECTORY_TEXTDOMAIN) . __(' :', GEODIRECTORY_TEXTDOMAIN); } return $list_title; }
<?php /** * Template for search bar used in the GD Search widget * * You can make most changes via hooks or see the link below for info on how to replace the template in your theme. * * @link http://docs.wpgeodirectory.com/customizing-geodirectory-templates/ * @since 1.0.0 * @package GeoDirectory * @global object $wp_query WordPress Query object. * @global object $wpdb WordPress Database object. */ global $wp_query, $current_term, $query; $curr_post_type = geodir_get_current_posttype(); if (function_exists('geodir_location_geo_home_link')) { remove_filter('home_url', 'geodir_location_geo_home_link', 100000); } $search_url = trailingslashit(get_home_url()); if (function_exists('geodir_location_geo_home_link')) { add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); } ?> <form class="<?php /** * Filters the GD search form class. * * @since 1.0.0 * @param string $class The class for the search form, default: 'geodir-listing-search'.
function mhk_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); $post_package_id = $package_info->pid; ob_start(); $fields_info = geodir_post_custom_fields($post_package_id, 'default', geodir_get_current_posttype(), $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) { $html = ''; $html_var = ''; $field_icon = ''; $variables_array = array(); if ($type['type'] != 'fieldset') { $variables_array['post_id'] = $post->ID; $variables_array['label'] = __($type['site_title'], GEODIRECTORY_TEXTDOMAIN); $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_TEXTDOMAIN) . '</h2>'; } else { echo '<h2>' . __($type['site_title'], GEODIRECTORY_TEXTDOMAIN) . '</h2>'; $field_set_start = 1; } 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++; } $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" ><strong>' . stripslashes(__($type['site_title'], GEODIRECTORY_TEXTDOMAIN)) . '</strong></a></span></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'])); } 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_TEXTDOMAIN) . ': ' : ' '; $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', 'mm', 'yy'); $replace = array('d', 'm', 'Y'); $date_format = str_replace($search, $replace, $date_format); $value = ''; if ($post->{$type}['htmlvar_name'] != '') { $value = date($date_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-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_TEXTDOMAIN) . ': ' : ''; $html .= '</span>' . $value . '</div>'; } break; case 'text': $html_var = $type['htmlvar_name']; if ($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_TEXTDOMAIN).': ' : ' '; $html .= '</span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>'; } elseif ($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_TEXTDOMAIN) . ': ' : ''; $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_TEXTDOMAIN); } elseif ($post->{$type}['htmlvar_name'] == 't' || $post->{$type}['htmlvar_name'] == '1') { $html_val = __('Yes', GEODIRECTORY_TEXTDOMAIN); } 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_TEXTDOMAIN) . ': ' : ''; $html .= '</span>' . $html_val . '</div>'; } break; case 'checkbox': $html_var = $type['htmlvar_name']; $html_val = $type['htmlvar_name']; if ($post->{$type}['htmlvar_name'] != '') { if ($post->{$type}['htmlvar_name'] == '1') { $html_val = __('Yes', GEODIRECTORY_TEXTDOMAIN); } else { $html_val = __('No', GEODIRECTORY_TEXTDOMAIN); } 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_TEXTDOMAIN) . ': ' : ''; $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_TEXTDOMAIN) . ': ' : ''; $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_TEXTDOMAIN) . ': <br />' : ''; $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 '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_TEXTDOMAIN).': ' : ''; $html .= '</span>' . 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_more_info_html' . $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_TEXTDOMAIN) . ': ' : ''; $html .= '</span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>'; } break; } if ($html) { do_action('geodir_before_show_' . $html_var); if ($html) { echo apply_filters('geodir_show_' . $html_var, $html, $variables_array); } do_action('geodir_after_show_' . $html_var); } } //echo '</div>'; } return $html = ob_get_clean(); }
/** * Remove terms from location search request. * * @since 1.1.6 * * @global int $dist Distance in range to search. * @global string $mylat Geo latitude * @global string $mylon Geo longitude * @global string $snear Nearest place to search. */ function geodir_cpt_remove_location_search() { $search_posttype = isset($_REQUEST['stype']) ? $_REQUEST['stype'] : geodir_get_current_posttype(); if (geodir_cpt_no_location($search_posttype)) { global $dist, $mylat, $mylon, $snear; $dist = $mylat = $mylon = $snear = ''; if (isset($_REQUEST['snear'])) { unset($_REQUEST['snear']); } if (isset($_REQUEST['sgeo_lat'])) { unset($_REQUEST['sgeo_lat']); } if (isset($_REQUEST['sgeo_lon'])) { unset($_REQUEST['sgeo_lon']); } } }
function geodir_filter_title_variables($title, $gd_page, $sep = '') { if (!$gd_page || !$title) { return $title; } // if no a GD page then bail. global $post; //print_r($post); /* %%date%% Replaced with the date of the post/page %%title%% Replaced with the title of the post/page %%sitename%% The site's name %%sitedesc%% The site's tagline / description %%excerpt%% Replaced with the post/page excerpt (or auto-generated if it does not exist) %%tag%% Replaced with the current tag/tags %%category%% Replaced with the post categories (comma separated) %%category_description%% Replaced with the category description %%tag_description%% Replaced with the tag description %%term_description%% Replaced with the term description %%term_title%% Replaced with the term name %%searchphrase%% Replaced with the current search phrase %%sep%% The separator defined in your theme's wp_title() tag. ADVANCED %%pt_single%% Replaced with the post type single label %%pt_plural%% Replaced with the post type plural label %%modified%% Replaced with the post/page modified time %%id%% Replaced with the post/page ID %%name%% Replaced with the post/page author's 'nicename' %%userid%% Replaced with the post/page author's userid %%page%% Replaced with the current page number (i.e. page 2 of 4) %%pagetotal%% Replaced with the current page total %%pagenumber%% Replaced with the current page number */ if ($sep == '') { /** * Filter the page title separator. * * @since 1.0.0 * @package GeoDirectory * @param string $sep The separator, default: `|`. */ $sep = apply_filters('geodir_page_title_separator', '|'); } if (strpos($title, '%%title%%') !== false) { $title = str_replace("%%title%%", $post->post_title, $title); } if (strpos($title, '%%sitename%%') !== false) { $title = str_replace("%%sitename%%", get_bloginfo('name'), $title); } if (strpos($title, '%%sitedesc%%') !== false) { $title = str_replace("%%sitedesc%%", get_bloginfo('description'), $title); } if (strpos($title, '%%excerpt%%') !== false) { $title = str_replace("%%excerpt%%", strip_tags(get_the_excerpt()), $title); } if (strpos($title, '%%pt_single%%') !== false) { $single_name = ''; if ($gd_page == 'search' || $gd_page == 'author') { $geodir_post_types = get_option('geodir_post_types'); $spt = esc_attr($_REQUEST['stype']); if (isset($geodir_post_types[$spt]['labels']['singular_name'])) { $single_name = __($geodir_post_types[$spt]['labels']['singular_name'], 'geodirectory'); } } elseif ($gd_page == 'add-listing') { $geodir_post_types = get_option('geodir_post_types'); $spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : ''; if (!$spt && isset($_REQUEST['pid'])) { $spt = get_post_type($_REQUEST['pid']); } if (!$spt) { $spt = 'gd_place'; } if (isset($geodir_post_types[$spt]['labels']['singular_name'])) { $single_name = __($geodir_post_types[$spt]['labels']['singular_name'], 'geodirectory'); } } elseif ($post->post_type) { $geodir_post_types = get_option('geodir_post_types'); if (isset($geodir_post_types[$post->post_type]['labels']['singular_name'])) { $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'], 'geodirectory'); } } $title = str_replace("%%pt_single%%", $single_name, $title); } if (strpos($title, '%%pt_plural%%') !== false) { $plural_name = ''; if ($gd_page == 'search' || $gd_page == 'author') { $geodir_post_types = get_option('geodir_post_types'); $spt = esc_attr($_REQUEST['stype']); if (isset($geodir_post_types[$spt]['labels']['name'])) { $plural_name = __($geodir_post_types[$spt]['labels']['name'], 'geodirectory'); } } elseif ($gd_page == 'add-listing') { $geodir_post_types = get_option('geodir_post_types'); $spt = esc_attr($_REQUEST['listing_type']); if (!$spt) { $spt = 'gd_place'; } if (isset($geodir_post_types[$spt]['labels']['name'])) { $plural_name = __($geodir_post_types[$spt]['labels']['name'], 'geodirectory'); } } elseif (isset($post->post_type) && $post->post_type) { $geodir_post_types = get_option('geodir_post_types'); if (isset($geodir_post_types[$post->post_type]['labels']['name'])) { $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'], 'geodirectory'); } } $title = str_replace("%%pt_plural%%", $plural_name, $title); } if (strpos($title, '%%category%%') !== false) { $cat_name = ''; if ($gd_page == 'detail') { if ($post->default_category) { $cat = get_term($post->default_category, $post->post_type . 'category'); $cat_name = isset($cat->name) ? $cat->name : ''; } } elseif ($gd_page == 'listing') { $queried_object = get_queried_object(); if (isset($queried_object->name)) { $cat_name = $queried_object->name; } } $title = str_replace("%%category%%", $cat_name, $title); } if (strpos($title, '%%tag%%') !== false) { $cat_name = ''; if ($gd_page == 'detail') { if ($post->default_category) { $cat = get_term($post->default_category, $post->post_type . 'category'); $cat_name = isset($cat->name) ? $cat->name : ''; } } elseif ($gd_page == 'listing') { $queried_object = get_queried_object(); if (isset($queried_object->name)) { $cat_name = $queried_object->name; } } $title = str_replace("%%tag%%", $cat_name, $title); } if (strpos($title, '%%id%%') !== false) { $ID = isset($post->ID) ? $post->ID : ''; $title = str_replace("%%id%%", $ID, $title); } /* if(strpos($title,'') !== false){ $title = str_replace("",,$title); } if(strpos($title,'') !== false){ $title = str_replace("",,$title); } */ if (strpos($title, '%%sep%%') !== false) { $title = str_replace("%%sep%%", $sep, $title); } global $wp; // location variables $gd_post_type = geodir_get_current_posttype(); $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type); /** * Filter the title variables location variables array * * @since 1.5.5 * @package GeoDirectory * @param array $location_array The array of location variables. * @param string $title The title with variables.. * @param string $gd_page The page being filtered. * @param string $sep The separator, default: `|`. */ $location_array = apply_filters('geodir_filter_title_variables_location_arr', $location_array, $title, $gd_page, $sep); $location_titles = array(); if ($gd_page == 'location' && get_query_var('gd_country_full')) { if (get_query_var('gd_country_full')) { $location_array['gd_country'] = get_query_var('gd_country_full'); } if (get_query_var('gd_region_full')) { $location_array['gd_region'] = get_query_var('gd_region_full'); } if (get_query_var('gd_city_full')) { $location_array['gd_city'] = get_query_var('gd_city_full'); } } $location_single = ''; $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'] : ''; $gd_country_actual = $gd_region_actual = $gd_city_actual = ''; if (function_exists('get_actual_location_name')) { $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country; $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region; $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city; } if ($gd_city != '') { if ($gd_city_actual != '') { $gd_city = $gd_city_actual; } else { $gd_city = preg_replace('/-(\\d+)$/', '', $gd_city); $gd_city = preg_replace('/[_-]/', ' ', $gd_city); $gd_city = __(geodir_ucwords($gd_city), 'geodirectory'); } $location_single = $gd_city; } else { if ($gd_region != '') { if ($gd_region_actual != '') { $gd_region = $gd_region_actual; } else { $gd_region = preg_replace('/-(\\d+)$/', '', $gd_region); $gd_region = preg_replace('/[_-]/', ' ', $gd_region); $gd_region = __(geodir_ucwords($gd_region), 'geodirectory'); } $location_single = $gd_region; } else { if ($gd_country != '') { if ($gd_country_actual != '') { $gd_country = $gd_country_actual; } else { $gd_country = preg_replace('/-(\\d+)$/', '', $gd_country); $gd_country = preg_replace('/[_-]/', ' ', $gd_country); $gd_country = __(geodir_ucwords($gd_country), 'geodirectory'); } $location_single = $gd_country; } } } if (!empty($location_array)) { $actual_location_name = function_exists('get_actual_location_name') ? true : false; $location_array = array_reverse($location_array); foreach ($location_array as $location_type => $location) { $gd_location_link_text = preg_replace('/-(\\d+)$/', '', $location); $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text); $location_name = geodir_ucwords($gd_location_link_text); $location_name = __($location_name, 'geodirectory'); if ($actual_location_name) { $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type; $location_name = get_actual_location_name($location_type, $location, true); } $location_titles[] = $location_name; } if (!empty($location_titles)) { $location_titles = array_unique($location_titles); } } if (strpos($title, '%%location%%') !== false) { $location = ''; if ($location_titles) { $location = implode(", ", $location_titles); } $title = str_replace("%%location%%", $location, $title); } if (strpos($title, '%%in_location%%') !== false) { $location = ''; if ($location_titles) { $location = __('in ', 'geodirectory') . implode(", ", $location_titles); } $title = str_replace("%%in_location%%", $location, $title); } if (strpos($title, '%%in_location_single%%') !== false) { if ($location_single) { $location_single = __('in', 'geodirectory') . ' ' . $location_single; } $title = str_replace("%%in_location_single%%", $location_single, $title); } if (strpos($title, '%%location_single%%') !== false) { $title = str_replace("%%location_single%%", $location_single, $title); } if (strpos($title, '%%search_term%%') !== false) { $search_term = ''; if (isset($_REQUEST['s'])) { $search_term = esc_attr($_REQUEST['s']); } $title = str_replace("%%search_term%%", $search_term, $title); } if (strpos($title, '%%search_near%%') !== false) { $search_term = ''; if (isset($_REQUEST['snear'])) { $search_term = esc_attr($_REQUEST['snear']); } $title = str_replace("%%search_near%%", $search_term, $title); } if (strpos($title, '%%name%%') !== false) { $author_name = ''; if ($author_name = get_the_author()) { } else { $queried_object = get_queried_object(); if (isset($queried_object->data->user_nicename)) { $author_name = $queried_object->data->user_nicename; } } $title = str_replace("%%name%%", $author_name, $title); } $title = wptexturize($title); $title = convert_chars($title); $title = esc_html($title); /** * Filter the title variables after standard ones have been filtered. * * @since 1.5.7 * @package GeoDirectory * @param string $title The title with variables. * @param array $location_array The array of location variables. * @param string $gd_page The page being filtered. * @param string $sep The separator, default: `|`. */ return apply_filters('geodir_filter_title_variables_vars', $title, $location_array, $gd_page, $sep); }
/** * 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_listing_page_title($list_title) { if (!geodir_is_page('search')) { return $list_title; } $gd_post_type = geodir_get_current_posttype(); $post_type_info = get_post_type_object($gd_post_type); if (trim(get_search_query()) == '') { $list_title = __('Search', GEODIRECTORY_TEXTDOMAIN) . ' ' . __(ucfirst($post_type_info->labels->name), GEODIRECTORY_TEXTDOMAIN) . __(' :', GEODIRECTORY_TEXTDOMAIN); } if (!get_option('geodir_search_display_searched_params')) { return $list_title; } $custom_fields = geodir_advance_search_get_advance_search_fields($gd_post_type); $search_title = array(); if (isset($_REQUEST['snear']) && $_REQUEST['snear'] != '') { $search_title[] = '<label class="gd-adv-search-label gd-adv-search-near">' . $_REQUEST['snear'] . '</label>'; } if (!empty($custom_fields)) { foreach ($custom_fields as $custom_field) { $site_htmlvar_name = $custom_field->site_htmlvar_name; $field_site_name = $custom_field->field_site_name; $field_site_type = $custom_field->field_site_type; $front_search_title = $custom_field->front_search_title != '' ? $custom_field->front_search_title : $field_site_name; $field_input_type = $custom_field->field_input_type; $search_condition = $custom_field->search_condition; $field_data_type = $custom_field->field_data_type; switch ($field_input_type) { case 'RANGE': switch ($search_condition) { case 'SINGLE': if (isset($_REQUEST['s' . $site_htmlvar_name]) && $_REQUEST['s' . $site_htmlvar_name] != '') { $extra_attrs = 'data-name="s' . $site_htmlvar_name . '"'; $search_title[] = '<label class="gd-adv-search-label gd-adv-search-range gd-adv-search-' . $site_htmlvar_name . '" ' . $extra_attrs . '>' . $_REQUEST['s' . $site_htmlvar_name] . '</label>'; } break; case 'FROM': $minvalue = isset($_REQUEST['smin' . $site_htmlvar_name]) && !empty($_REQUEST['smin' . $site_htmlvar_name]) ? $_REQUEST['smin' . $site_htmlvar_name] : ''; $maxvalue = isset($_REQUEST['smax' . $site_htmlvar_name]) && !empty($_REQUEST['smax' . $site_htmlvar_name]) ? $_REQUEST['smax' . $site_htmlvar_name] : ''; $this_search = ''; if ($minvalue != '' && $maxvalue != '') { $this_search = $minvalue . ' - ' . $maxvalue; } else { if ($minvalue != '' && $maxvalue == '') { $this_search = __('From:', GEODIRADVANCESEARCH_TEXTDOMAIN) . ' ' . $minvalue; } else { if ($minvalue == '' && $maxvalue != '') { $this_search = __('To:', GEODIRADVANCESEARCH_TEXTDOMAIN) . ' ' . $maxvalue; } } } if ($this_search != '') { $extra_attrs = 'data-name="smin' . $site_htmlvar_name . '" data-names="smax' . $site_htmlvar_name . '"'; $search_title[] = '<label class="gd-adv-search-label gd-adv-search-range gd-adv-search-' . $site_htmlvar_name . '" ' . $extra_attrs . '>' . $this_search . '</label>'; } break; case 'RADIO': if (isset($_REQUEST['s' . $site_htmlvar_name]) && $_REQUEST['s' . $site_htmlvar_name] != '') { $uom = get_option('geodir_search_dist_1'); $extra_attrs = 'data-name="s' . $site_htmlvar_name . '"'; $search_title[] = '<label class="gd-adv-search-label gd-adv-search-range gd-adv-search-' . $site_htmlvar_name . '" ' . $extra_attrs . '>' . __('Within', GEODIRADVANCESEARCH_TEXTDOMAIN) . ' ' . (int) $_REQUEST['s' . $site_htmlvar_name] . ' ' . __($uom, GEODIRECTORY_TEXTDOMAIN) . '</label>'; } break; default: if (isset($_REQUEST['s' . $site_htmlvar_name]) && $_REQUEST['s' . $site_htmlvar_name] != '') { $serchlist = explode("-", $_REQUEST['s' . $site_htmlvar_name]); if (!empty($serchlist)) { $first_value = $serchlist[0]; $second_value = isset($serchlist[1]) ? trim($serchlist[1], ' ') : ''; $rest = substr($second_value, 0, 4); $this_search = ''; if ($rest == 'Less') { $this_search = __('To:', GEODIRADVANCESEARCH_TEXTDOMAIN) . ' ' . $first_value; } else { if ($rest == 'More') { $this_search = __('From:', GEODIRADVANCESEARCH_TEXTDOMAIN) . ' ' . $first_value; } else { if ($second_value != '') { $this_search = $first_value . ' - ' . $second_value; } } } if ($this_search != '') { $extra_attrs = 'data-name="s' . $site_htmlvar_name . '"'; $search_title[] = '<label class="gd-adv-search-label gd-adv-search-range gd-adv-search-' . $site_htmlvar_name . '" ' . $extra_attrs . '>' . $this_search . '</label>'; } } } break; } break; case 'DATE': $search_date = ''; $single = ''; $this_search = ''; $value = isset($_REQUEST['s' . $site_htmlvar_name]) && !empty($_REQUEST['s' . $site_htmlvar_name]) ? $_REQUEST['s' . $site_htmlvar_name] : ''; $extra_attrs = 'data-name="s' . $site_htmlvar_name . '"'; if ($value) { $minvalue = $value; $maxvalue = ''; $single = '1'; } else { $minvalue = isset($_REQUEST['smin' . $site_htmlvar_name]) && !empty($_REQUEST['smin' . $site_htmlvar_name]) ? $_REQUEST['smin' . $site_htmlvar_name] : ''; $maxvalue = isset($_REQUEST['smax' . $site_htmlvar_name]) && !empty($_REQUEST['smax' . $site_htmlvar_name]) ? $_REQUEST['smax' . $site_htmlvar_name] : ''; $extra_attrs = 'data-name="smin' . $site_htmlvar_name . '" data-names="smax' . $site_htmlvar_name . '"'; } if ($site_htmlvar_name == 'event') { $event_start = isset($_REQUEST['event_start']) && !empty($_REQUEST['event_start']) ? $_REQUEST['event_start'] : ''; $event_end = isset($_REQUEST['event_end']) && !empty($_REQUEST['event_end']) ? $_REQUEST['event_end'] : ''; $extra_attrs = 'data-name="event_start" data-names="event_end"'; if ($event_start != '' && $event_end == '') { $this_search = __('From:', GEODIRADVANCESEARCH_TEXTDOMAIN) . ' ' . $event_start; } else { if ($event_start == '' && $event_end != '') { $this_search = __('To:', GEODIRADVANCESEARCH_TEXTDOMAIN) . ' ' . $event_end; } else { if ($event_start != '' && $event_end != '') { $this_search = $event_start . ' - ' . $event_end; } } } if ($this_search != '') { $search_title[] = '<label class="gd-adv-search-label gd-adv-search-date gd-adv-search-' . $site_htmlvar_name . '" ' . $extra_attrs . '>' . $this_search . '</label>'; } } else { if ($field_data_type == 'DATE' || $field_data_type == 'TIME') { $start_date = date('Y-m-d', strtotime($minvalue)); $start_end = date('Y-m-d', strtotime($maxvalue)); if ($single == '1') { $search_title[] = '<label class="gd-adv-search-label gd-adv-search-date gd-adv-search-' . $site_htmlvar_name . '" ' . $extra_attrs . '>' . $minvalue . '</label>'; } else { $this_search = ''; if ($minvalue != '' && $maxvalue == '') { $this_search = __('From:', GEODIRADVANCESEARCH_TEXTDOMAIN) . ' ' . $minvalue; } else { if ($minvalue == '' && $maxvalue != '') { $this_search = __('To:', GEODIRADVANCESEARCH_TEXTDOMAIN) . ' ' . $maxvalue; } else { if ($minvalue != '' && $maxvalue != '') { $this_search = $minvalue . ' - ' . $maxvalue; } } } if ($this_search != '') { $search_title[] = '<label class="gd-adv-search-label gd-adv-search-date gd-adv-search-' . $site_htmlvar_name . '" ' . $extra_attrs . '>' . $this_search . '</label>'; } } } } break; default: if (isset($_REQUEST['s' . $site_htmlvar_name]) && (is_array($_REQUEST['s' . $site_htmlvar_name]) && !empty($_REQUEST['s' . $site_htmlvar_name]) || !is_array($_REQUEST['s' . $site_htmlvar_name]) && $_REQUEST['s' . $site_htmlvar_name] != '')) { $value = $_REQUEST['s' . $site_htmlvar_name]; if (is_array($_REQUEST['s' . $site_htmlvar_name])) { $extra_attrs = 'data-name="s' . $site_htmlvar_name . '[]"'; $values = $_REQUEST['s' . $site_htmlvar_name]; $value = ''; if ($site_htmlvar_name == $gd_post_type . 'category') { $value = array(); foreach ($values as $value_id) { $value_term = get_term($value_id, $site_htmlvar_name); if (!empty($value_term) && isset($value_term->name)) { $value[] = $value_term->name; } } $value = !empty($value) ? implode(', ', $value) : ''; } else { $field_option_values = geodir_advance_search_field_option_values($gd_post_type, $site_htmlvar_name); $field_option_values = geodir_string_values_to_options($field_option_values); if (!empty($field_option_values)) { $value = array(); foreach ($field_option_values as $option_value) { $option_label = isset($option_value['label']) ? $option_value['label'] : ''; $option_val = isset($option_value['value']) ? $option_value['value'] : $option_label; if ($option_label != '' && $option_val != '' && in_array($option_val, $_REQUEST['s' . $site_htmlvar_name])) { $value[] = __(ucfirst($option_label), GEODIRECTORY_TEXTDOMAIN); } } $value = !empty($value) ? implode(', ', $value) : ''; } else { $value = implode(', ', $values); } } } else { $extra_attrs = 'data-name="s' . $site_htmlvar_name . '"'; if ($site_htmlvar_name == $gd_post_type . 'category') { $value = ''; $value_term = get_term($_REQUEST['s' . $site_htmlvar_name], $site_htmlvar_name); if (!empty($value_term) && isset($value_term->name)) { $value = $value_term->name; } } else { $field_option_values = geodir_advance_search_field_option_values($gd_post_type, $site_htmlvar_name); $field_option_values = geodir_string_values_to_options($field_option_values); if (!empty($field_option_values)) { $value = array(); foreach ($field_option_values as $option_value) { $option_label = isset($option_value['label']) ? $option_value['label'] : ''; $option_val = isset($option_value['value']) ? $option_value['value'] : $option_label; if ($option_label != '' && $option_val != '' && $option_val == $_REQUEST['s' . $site_htmlvar_name]) { $value[] = __(ucfirst($option_label), GEODIRECTORY_TEXTDOMAIN); } } $value = !empty($value) ? implode(', ', $value) : ''; } if ($field_site_type == 'checkbox' && (int) $_REQUEST['s' . $site_htmlvar_name] == 1) { $value = __($front_search_title, GEODIRADVANCESEARCH_TEXTDOMAIN); } } } if ($value != '') { $search_title[] = '<label class="gd-adv-search-label gd-adv-search-default gd-adv-search-' . $site_htmlvar_name . '" ' . $extra_attrs . '>' . $value . '</label>'; } } break; } } } if (!empty($search_title)) { $search_title = '<div class="gd-adv-search-labels">' . implode($search_title, '') . '</div>'; $search_title = apply_filters('geodir_advance_search_filter_title', $search_title); $list_title .= $search_title; } return $list_title; }
/** * Front-end display content for best of widget. * * @since 1.3.9 * @since 1.5.1 Added filter to view all link. * @since 1.5.1 Declare function public. * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { extract($args); /** * Filter the best of widget tab layout. * * @since 1.3.9 * * @param string $instance['tab_layout'] Best of widget tab layout name. */ $tab_layout = empty($instance['tab_layout']) ? 'bestof-tabs-on-top' : apply_filters('bestof_widget_tab_layout', $instance['tab_layout']); echo '<div class="bestof-widget-tab-layout ' . $tab_layout . '">'; echo $before_widget; $loc_terms = geodir_get_current_location_terms(); if ($loc_terms) { $cur_location = ' : ' . ucwords(str_replace('-', ' ', end($loc_terms))); } else { $cur_location = ''; } /** * Filter the current location name. * * @since 1.3.9 * * @param string $cur_location Current location name. */ $cur_location = apply_filters('bestof_widget_cur_location', $cur_location); /** * Filter the widget title. * * @since 1.3.9 * * @param string $instance['title'] The widget title. */ $title = empty($instance['title']) ? wp_sprintf(__('Best of %s', 'geodirectory'), get_bloginfo('name') . $cur_location) : apply_filters('bestof_widget_title', __($instance['title'], 'geodirectory')); /** * Filter the post type. * * @since 1.3.9 * * @param string $instance['post_type'] The post type. */ $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('bestof_widget_post_type', $instance['post_type']); /** * Filter the listing limit. * * @since 1.3.9 * * @param int $instance['post_limit'] No. of posts to display. */ $post_limit = empty($instance['post_limit']) ? '5' : apply_filters('bestof_widget_post_limit', $instance['post_limit']); /** * Filter the category limit. * * @since 1.3.9 * * @param int $instance['categ_limit'] No. of categories to display. */ $categ_limit = empty($instance['categ_limit']) ? '3' : apply_filters('bestof_widget_categ_limit', $instance['categ_limit']); $use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false; /** * Filter the use of location filter. * * @since 1.3.9 * * @param int|bool $instance['add_location_filter'] Filter listings using current location. */ $add_location_filter = empty($instance['add_location_filter']) ? '1' : apply_filters('bestof_widget_location_filter', $instance['add_location_filter']); // set post type to current viewing post type if ($use_viewing_post_type) { $current_post_type = geodir_get_current_posttype(); if ($current_post_type != '' && $current_post_type != $post_type) { $post_type = $current_post_type; } } if (isset($instance['character_count'])) { /** * Filter the widget's excerpt character count. * * @since 1.3.9 * * @param int $instance['character_count'] Excerpt character count. */ $character_count = apply_filters('bestof_widget_list_character_count', $instance['character_count']); } else { $character_count = ''; } $category_taxonomy = geodir_get_taxonomies($post_type); $term_args = array('hide_empty' => true, 'parent' => 0); if (is_tax()) { $taxonomy = get_query_var('taxonomy'); $cur_term = get_query_var('term'); $term_data = get_term_by('name', $cur_term, $taxonomy); $term_args['parent'] = $term_data->term_id; } $terms = get_terms($category_taxonomy[0], $term_args); $term_reviews = geodir_count_reviews_by_terms(); $a_terms = array(); foreach ($terms as $term) { if ($term->count > 0) { if (isset($term_reviews[$term->term_id])) { $term->review_count = $term_reviews[$term->term_id]; } else { $term->review_count = '0'; } $a_terms[] = $term; } } $terms = geodir_sort_terms($a_terms, 'review_count'); $query_args = array('posts_per_page' => $post_limit, 'is_geodir_loop' => true, 'post_type' => $post_type, 'gd_location' => $add_location_filter ? true : false, 'order_by' => 'high_review'); if ($character_count >= 0) { $query_args['excerpt_length'] = $character_count; } $layout = array(); if ($tab_layout == 'bestof-tabs-as-dropdown') { $layout[] = $tab_layout; } else { $layout[] = 'bestof-tabs-as-dropdown'; $layout[] = $tab_layout; } echo $before_title . __($title) . $after_title; //term navigation - start echo '<div class="geodir-tabs gd-bestof-tabs" id="gd-bestof-tabs" style="position:relative;">'; $final_html = ''; foreach ($layout as $tab_layout) { $nav_html = ''; $is_dropdown = $tab_layout == 'bestof-tabs-as-dropdown' ? true : false; if ($is_dropdown) { $nav_html .= '<select id="geodir_bestof_tab_dd" class="chosen_select" name="geodir_bestof_tab_dd" data-placeholder="' . esc_attr(__('Select Category', 'geodirectory')) . '">'; } else { $nav_html .= '<dl class="geodir-tab-head geodir-bestof-cat-list">'; $nav_html .= '<dt></dt>'; } $term_icon = geodir_get_term_icon(); $cat_count = 0; foreach ($terms as $cat) { $cat_count++; if ($cat_count > $categ_limit) { break; } if ($is_dropdown) { $selected = $cat_count == 1 ? 'selected="selected"' : ''; $nav_html .= '<option ' . $selected . ' value="' . $cat->term_id . '">' . ucwords($cat->name) . '</option>'; } else { if ($cat_count == 1) { $nav_html .= '<dd class="geodir-tab-active">'; } else { $nav_html .= '<dd class="">'; } $term_icon_url = !empty($term_icon) && isset($term_icon[$cat->term_id]) ? $term_icon[$cat->term_id] : ''; $nav_html .= '<a data-termid="' . $cat->term_id . '" href="' . get_term_link($cat, $cat->taxonomy) . '">'; $nav_html .= '<img alt="' . $cat->name . ' icon" class="bestof-cat-icon" src="' . $term_icon_url . '"/>'; $nav_html .= '<span>'; $nav_html .= ucwords($cat->name); $nav_html .= '<small>'; if (isset($cat->review_count)) { $num_reviews = $cat->review_count; if ($num_reviews == 0) { $reviews = __('No Reviews', 'geodirectory'); } elseif ($num_reviews > 1) { $reviews = $num_reviews . __(' Reviews', 'geodirectory'); } else { $reviews = __('1 Review', 'geodirectory'); } $nav_html .= $reviews; } $nav_html .= '</small>'; $nav_html .= '</span>'; $nav_html .= '</a>'; $nav_html .= '</dd>'; } } if ($is_dropdown) { $nav_html .= '</select>'; } else { $nav_html .= '</dl>'; } $final_html .= $nav_html; } if ($terms) { echo $final_html; } echo '</div>'; //term navigation - end //first term listings by default - start $first_term = ''; if ($terms) { $first_term = $terms[0]; $tax_query = array('taxonomy' => $category_taxonomy[0], 'field' => 'id', 'terms' => $first_term->term_id); $query_args['tax_query'] = array($tax_query); } ?> <input type="hidden" id="bestof_widget_post_type" name="bestof_widget_post_type" value="<?php echo $post_type; ?> "> <input type="hidden" id="bestof_widget_post_limit" name="bestof_widget_post_limit" value="<?php echo $post_limit; ?> "> <input type="hidden" id="bestof_widget_taxonomy" name="bestof_widget_taxonomy" value="<?php echo $category_taxonomy[0]; ?> "> <input type="hidden" id="bestof_widget_location_filter" name="bestof_widget_location_filter" value="<?php if ($add_location_filter) { echo 1; } else { echo 0; } ?> "> <input type="hidden" id="bestof_widget_char_count" name="bestof_widget_char_count" value="<?php echo $character_count; ?> "> <div class="geo-bestof-contentwrap geodir-tabs-content" style="position: relative; z-index: 0;"> <p id="geodir-bestof-loading" class="geodir-bestof-loading"><i class="fa fa-cog fa-spin"></i></p> <?php echo '<div id="geodir-bestof-places">'; if ($terms) { $view_all_link = add_query_arg(array('sort_by' => 'rating_count_desc'), get_term_link($first_term, $first_term->taxonomy)); /** * Filter the page link to view all lisitngs. * * @since 1.5.1 * * @param array $view_all_link View all listings page link. * @param array $post_type The Post type. * @param array $first_term The category term object. */ $view_all_link = apply_filters('geodir_bestof_widget_view_all_link', $view_all_link, $post_type, $first_term); echo '<h3 class="bestof-cat-title">' . wp_sprintf(__('Best of %s', 'geodirectory'), $first_term->name) . '<a href="' . esc_url($view_all_link) . '">' . __("View all", 'geodirectory') . '</a></h3>'; } geodir_bestof_places_by_term($query_args); echo "</div>"; ?> </div> <?php //first term listings by default - end ?> <?php echo $after_widget; echo "</div>"; }
function geodir_detail_page_tab_headings_change_ctp($tabs_arr) { global $wpdb; $post_type = geodir_get_current_posttype(); $all_postypes = geodir_get_posttypes(); if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes)) { $geodir_post_types = get_option('geodir_post_types'); if (empty($geodir_post_types[$post_type])) { return $tabs_arr; } $post_type_array = $geodir_post_types[$post_type]; if (array_key_exists('post_profile', $tabs_arr) && !empty($post_type_array['labels']['label_post_profile'])) { $field_title = stripslashes_deep($post_type_array['labels']['label_post_profile']); if (isset($tabs_arr['post_profile']['heading_text']) && $field_title != '') { $tabs_arr['post_profile']['heading_text'] = __($field_title, GEODIR_CP_TEXTDOMAIN); } } if (array_key_exists('post_info', $tabs_arr) && !empty($post_type_array['labels']['label_post_info'])) { $field_title = stripslashes_deep($post_type_array['labels']['label_post_info']); if (isset($tabs_arr['post_info']['heading_text']) && $field_title != '') { $tabs_arr['post_info']['heading_text'] = __($field_title, GEODIR_CP_TEXTDOMAIN); } } if (array_key_exists('post_images', $tabs_arr) && !empty($post_type_array['labels']['label_post_images'])) { $field_title = stripslashes_deep($post_type_array['labels']['label_post_images']); if (isset($tabs_arr['post_images']['heading_text']) && $field_title != '') { $tabs_arr['post_images']['heading_text'] = __($field_title, GEODIR_CP_TEXTDOMAIN); } } if (array_key_exists('post_map', $tabs_arr) && !empty($post_type_array['labels']['label_post_map'])) { $field_title = stripslashes_deep($post_type_array['labels']['label_post_map']); if (isset($tabs_arr['post_map']['heading_text']) && $field_title != '') { $tabs_arr['post_map']['heading_text'] = __($field_title, GEODIR_CP_TEXTDOMAIN); } } if (array_key_exists('reviews', $tabs_arr) && !empty($post_type_array['labels']['label_reviews'])) { $field_title = stripslashes_deep($post_type_array['labels']['label_reviews']); if (isset($tabs_arr['reviews']['heading_text']) && $field_title != '') { $tabs_arr['reviews']['heading_text'] = __($field_title, GEODIR_CP_TEXTDOMAIN); } } if (array_key_exists('related_listing', $tabs_arr) && !empty($post_type_array['labels']['label_related_listing'])) { $field_title = stripslashes_deep($post_type_array['labels']['label_related_listing']); if (isset($tabs_arr['related_listing']['heading_text']) && $field_title != '') { $tabs_arr['related_listing']['heading_text'] = __($field_title, GEODIR_CP_TEXTDOMAIN); } } } return $tabs_arr; }
/** * Adds meta keywords and description for SEO. * * @since 1.0.0 * @since 1.5.4 Modified to replace %location% from meta when Yoast SEO plugin active. * @package GeoDirectory * @global object $wpdb WordPress Database object. * @global object $post The current post object. * @global object $wp_query WordPress Query object. * @global array $geodir_addon_list List of active GeoDirectory extensions. */ function geodir_add_meta_keywords() { global $wp, $post, $wp_query, $wpdb, $geodir_addon_list; $is_geodir_page = geodir_is_geodir_page(); if (!$is_geodir_page) { return; } // if non GD page, bail $use_gd_meta = true; if (class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) { $use_gd_meta = false; if (geodir_is_page('search')) { $use_gd_meta = true; } } if (!$use_gd_meta) { return; } // bail if Yoast Wordpress SEO or All_in_One_SEO_Pack active. $current_term = $wp_query->get_queried_object(); $all_postypes = geodir_get_posttypes(); $geodir_taxonomies = geodir_get_taxonomies('', true); $meta_desc = ''; $meta_key = ''; if (isset($current_term->ID) && $current_term->ID == geodir_location_page_id()) { /** * Filter SEO meta location description. * * @since 1.0.0 */ $meta_desc = apply_filters('geodir_seo_meta_location_description', ''); $meta_desc .= ''; } if (have_posts() && is_single() or is_page()) { while (have_posts()) { the_post(); if (has_excerpt()) { $out_excerpt = strip_tags(strip_shortcodes(get_the_excerpt())); if (empty($out_excerpt)) { $out_excerpt = strip_tags(do_shortcode(get_the_excerpt())); } $out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $out_excerpt); } else { $out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $post->post_content); $out_excerpt = strip_tags(strip_shortcodes($out_excerpt)); if (empty($out_excerpt)) { $out_excerpt = strip_tags(do_shortcode($out_excerpt)); // parse short code from content } $out_excerpt = trim(wp_trim_words($out_excerpt, 35, ''), '.!?,;:-'); } $meta_desc .= $out_excerpt; } } elseif ((is_category() || is_tag()) && isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) { if (is_category()) { $meta_desc .= __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE)); } elseif (is_tag()) { $meta_desc .= __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE)); } } elseif (isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) { $meta_desc .= isset($current_term->description) ? $current_term->description : ''; } $geodir_post_type = geodir_get_current_posttype(); $geodir_post_type_info = get_post_type_object($geodir_post_type); $geodir_is_page_listing = geodir_is_page('listing') ? true : false; $category_taxonomy = geodir_get_taxonomies($geodir_post_type); $tag_taxonomy = geodir_get_taxonomies($geodir_post_type, true); $geodir_is_category = isset($category_taxonomy[0]) && get_query_var($category_taxonomy[0]) ? get_query_var($category_taxonomy[0]) : false; $geodir_is_tag = isset($tag_taxonomy[0]) && get_query_var($tag_taxonomy[0]) ? true : false; $geodir_is_search = geodir_is_page('search') ? true : false; $geodir_is_location = geodir_is_page('location') ? true : false; $geodir_location_manager = isset($geodir_addon_list['geodir_location_manager']) && ($geodir_addon_list['geodir_location_manager'] = 'yes' ? true : false); $godir_location_terms = geodir_get_current_location_terms('query_vars'); $gd_city = $geodir_location_manager && isset($godir_location_terms['gd_city']) ? $godir_location_terms['gd_city'] : NULL; $gd_region = $geodir_location_manager && isset($godir_location_terms['gd_region']) ? $godir_location_terms['gd_region'] : NULL; $gd_country = $geodir_location_manager && isset($godir_location_terms['gd_country']) ? $godir_location_terms['gd_country'] : NULL; $replace_location = __('Everywhere', 'geodirectory'); $location_id = NULL; if ($geodir_location_manager) { $sql = $wpdb->prepare("SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array($gd_city)); $location_id = (int) $wpdb->get_var($sql); $location_type = geodir_what_is_current_location(); if ($location_type == 'city') { $replace_location = geodir_get_current_location(array('what' => 'city', 'echo' => false)); } elseif ($location_type == 'region') { $replace_location = geodir_get_current_location(array('what' => 'region', 'echo' => false)); } elseif ($location_type == 'country') { $replace_location = geodir_get_current_location(array('what' => 'country', 'echo' => false)); $replace_location = __($replace_location, 'geodirectory'); } $country = get_query_var('gd_country'); $region = get_query_var('gd_region'); $city = get_query_var('gd_city'); $current_location = ''; if ($country != '') { $current_location = get_actual_location_name('country', $country, true); } if ($region != '') { $current_location = get_actual_location_name('region', $region); } if ($city != '') { $current_location = get_actual_location_name('city', $city); } $replace_location = $current_location != '' ? $current_location : $replace_location; } $geodir_meta_keys = ''; $geodir_meta_desc = ''; if ($is_geodir_page && !empty($geodir_post_type_info)) { if ($geodir_is_page_listing || $geodir_is_search || geodir_is_page('add-listing')) { $geodir_meta_keys = isset($geodir_post_type_info->seo['meta_keyword']) && $geodir_post_type_info->seo['meta_keyword'] != '' ? $geodir_post_type_info->seo['meta_keyword'] : $geodir_meta_keys; $geodir_meta_desc = isset($geodir_post_type_info->description) ? $geodir_post_type_info->description : $geodir_meta_desc; $geodir_meta_desc = isset($geodir_post_type_info->seo['meta_description']) && $geodir_post_type_info->seo['meta_description'] != '' ? $geodir_post_type_info->seo['meta_description'] : $geodir_meta_desc; if ($geodir_is_category) { $category = $geodir_is_category ? get_term_by('slug', $geodir_is_category, $category_taxonomy[0]) : NULL; if (isset($category->term_id) && !empty($category->term_id)) { $category_id = $category->term_id; $category_desc = trim($category->description) != '' ? trim($category->description) : get_tax_meta($category_id, 'ct_cat_top_desc', false, $geodir_post_type); if ($location_id) { $option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id; $cat_loc_option = get_option($option_name); $gd_cat_loc_default = !empty($cat_loc_option) && isset($cat_loc_option['gd_cat_loc_default']) && $cat_loc_option['gd_cat_loc_default'] > 0 ? true : false; if (!$gd_cat_loc_default) { $option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id . '_' . $location_id; $option = get_option($option_name); $category_desc = isset($option['gd_cat_loc_desc']) && trim($option['gd_cat_loc_desc']) != '' ? trim($option['gd_cat_loc_desc']) : $category_desc; } } $geodir_meta_desc = __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE)) . '. ' . $category_desc; } } else { if ($geodir_is_tag) { $geodir_meta_desc = __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE)) . '. ' . $geodir_meta_desc; } } } } $gd_page = ''; if (geodir_is_page('home')) { $gd_page = 'home'; $meta_desc = get_option('geodir_meta_desc_homepage') ? get_option('geodir_meta_desc_homepage') : $meta_desc; } elseif (geodir_is_page('detail')) { $gd_page = 'detail'; $meta_desc = get_option('geodir_meta_desc_detail') ? get_option('geodir_meta_desc_detail') : $meta_desc; } elseif (geodir_is_page('pt')) { $gd_page = 'pt'; $meta_desc = get_option('geodir_meta_desc_pt') ? get_option('geodir_meta_desc_pt') : $meta_desc; } elseif (geodir_is_page('listing')) { $gd_page = 'listing'; $meta_desc = get_option('geodir_meta_desc_listing') ? get_option('geodir_meta_desc_listing') : $meta_desc; } elseif (geodir_is_page('location')) { $gd_page = 'location'; $meta_desc = get_option('geodir_meta_desc_location') ? get_option('geodir_meta_desc_location') : $meta_desc; $meta_desc = apply_filters('geodir_seo_meta_location_description', $meta_desc); } elseif (geodir_is_page('search')) { $gd_page = 'search'; $meta_desc = get_option('geodir_meta_desc_search') ? get_option('geodir_meta_desc_search') : $meta_desc; } elseif (geodir_is_page('add-listing')) { $gd_page = 'add-listing'; $meta_desc = get_option('geodir_meta_desc_add-listing') ? get_option('geodir_meta_desc_add-listing') : $meta_desc; } elseif (geodir_is_page('author')) { $gd_page = 'author'; $meta_desc = get_option('geodir_meta_desc_author') ? get_option('geodir_meta_desc_author') : $meta_desc; } elseif (geodir_is_page('login')) { $gd_page = 'login'; $meta_desc = get_option('geodir_meta_desc_login') ? get_option('geodir_meta_desc_login') : $meta_desc; } elseif (geodir_is_page('listing-success')) { $gd_page = 'listing-success'; $meta_desc = get_option('geodir_meta_desc_listing-success') ? get_option('geodir_meta_desc_listing-success') : $meta_desc; } /* $geodir_meta_desc = $geodir_meta_desc != '' ? $geodir_meta_desc : $meta_desc; if ($geodir_meta_desc != '') { $geodir_meta_desc = strip_tags($geodir_meta_desc); $geodir_meta_desc = esc_html($geodir_meta_desc); $geodir_meta_desc = wp_html_excerpt($geodir_meta_desc, 1000, '.'); $geodir_meta_desc = isset($replace_location) ? str_replace('%location%', $replace_location, $geodir_meta_desc) : $geodir_meta_desc; $meta_desc = $geodir_meta_desc != '' ? $geodir_meta_desc : $meta_desc; } */ if ($meta_desc) { $meta_desc = stripslashes_deep($meta_desc); /** * Filter page description to replace variables. * * @since 1.5.4 * @param string $title The page description including variables. * @param string $gd_page The GeoDirectory page type if any. */ $meta_desc = apply_filters('geodir_seo_meta_description_pre', __($meta_desc, 'geodirectory'), $gd_page, ''); /** * Filter SEO meta description. * * @since 1.0.0 * @param string $meta_desc Meta description content. */ echo apply_filters('geodir_seo_meta_description', '<meta name="description" content="' . $meta_desc . '" />', $meta_desc); } // meta keywords if (isset($post->post_type) && in_array($post->post_type, $all_postypes)) { $place_tags = wp_get_post_terms($post->ID, $post->post_type . '_tags', array("fields" => "names")); $place_cats = wp_get_post_terms($post->ID, $post->post_type . 'category', array("fields" => "names")); $meta_key .= implode(", ", array_merge((array) $place_cats, (array) $place_tags)); } else { $posttags = get_the_tags(); if ($posttags) { foreach ($posttags as $tag) { $meta_key .= $tag->name . ' '; } } else { $tags = get_tags(array('orderby' => 'count', 'order' => 'DESC')); $xt = 1; foreach ($tags as $tag) { if ($xt <= 20) { $meta_key .= $tag->name . ", "; } $xt++; } } } $meta_key = $meta_key != '' ? rtrim(trim($meta_key), ",") : $meta_key; $geodir_meta_keys = $geodir_meta_keys != '' ? $meta_key != '' ? $meta_key . ', ' . $geodir_meta_keys : $geodir_meta_keys : $meta_key; if ($geodir_meta_keys != '') { $geodir_meta_keys = strip_tags($geodir_meta_keys); $geodir_meta_keys = esc_html($geodir_meta_keys); $geodir_meta_keys = geodir_strtolower($geodir_meta_keys); $geodir_meta_keys = wp_html_excerpt($geodir_meta_keys, 1000, ''); $geodir_meta_keys = str_replace('%location%', $replace_location, $geodir_meta_keys); $meta_key = rtrim(trim($geodir_meta_keys), ","); } if ($meta_key) { $meta_key = stripslashes_deep($meta_key); /** * Filter SEO meta keywords. * * @since 1.0.0 * @param string $meta_desc Meta keywords. */ echo apply_filters('geodir_seo_meta_keywords', '<meta name="keywords" content="' . $meta_key . '" />', $meta_key); } }
/** * GeoDirectory Listing loop filters. * * @since 1.0.0 * @package GeoDirectory * @global object $wp_query WordPress Query object. * @global string $table Listing table name. * @todo $wp_query declared twice - fix it. * @global string $plugin_prefix Geodirectory plugin table prefix. * @param object $query Current query object. * @return object Modified query object. */ function geodir_listing_loop_filter($query) { global $wp_query, $geodir_post_type, $table, $plugin_prefix, $table, $term; // fix wp_reset_query for popular post view widget if (!geodir_is_geodir_page()) { return; } $geodir_post_type = geodir_get_current_posttype(); if (isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries) { $taxonomies = wp_list_pluck($wp_query->tax_query->queries, 'taxonomy'); if (isset($wp_query->query[$taxonomies[0]])) { $request_term = explode("/", $wp_query->query[$taxonomies[0]]); $request_term = end($request_term); if (!term_exists($request_term)) { $args = array('number' => '1'); $terms_arr = get_terms($taxonomies[0], $args); foreach ($terms_arr as $location_term) { $term_arr = $location_term; $term_arr->name = ucwords(str_replace('-', ' ', $request_term)); } $wp_query->queried_object_id = 1; $wp_query->queried_object = $term_arr; //print_r($wp_query) ; } } } if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']) { $table = $plugin_prefix . $geodir_post_type . '_detail'; add_filter('posts_fields', 'geodir_posts_fields', 1); add_filter('posts_join', 'geodir_posts_join', 1); geodir_post_where(); if (!is_admin()) { add_filter('posts_orderby', 'geodir_posts_orderby', 1); } // advanced filter for popular post view widget global $wp_query; if (!is_admin()) { if (!empty($wp_query->query['with_pics_only'])) { add_filter('posts_join', 'geodir_filter_widget_join', 1000); } add_filter('posts_where', 'geodir_filter_widget_where', 1000); } } return $query; }
/** * Details page tab custom fields. * * @since 1.0.0 * @package GeoDirectory * @global object $post The current post object. * @param array $tabs_arr Tabs array {@see geodir_detail_page_tab_headings_change()}. * @return array Modified tabs array. */ function geodir_detail_page_custom_field_tab($tabs_arr) { global $post; $post_type = geodir_get_current_posttype(); $all_postypes = geodir_get_posttypes(); if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes) && (geodir_is_page('detail') || geodir_is_page('preview'))) { $package_info = array(); $package_info = geodir_post_package_info($package_info, $post); $post_package_id = $package_info->pid; $fields_location = 'detail'; $custom_fields = geodir_post_custom_fields($post_package_id, 'default', $post_type, $fields_location); if (!empty($custom_fields)) { $parse_custom_fields = array(); foreach ($custom_fields as $field) { $field = stripslashes_deep($field); // strip slashes $type = $field; $field_name = $field['htmlvar_name']; if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) { $post->{$field_name} = $_REQUEST[$field_name]; } if (isset($field['show_as_tab']) && $field['show_as_tab'] == 1 && (isset($post->{$field_name}) && $post->{$field_name} != '' || $field['type'] == 'fieldset') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) { if ($type['type'] == 'datepicker' && ($post->{$type}['htmlvar_name'] == '' || $post->{$type}['htmlvar_name'] == '0000-00-00')) { continue; } $parse_custom_fields[] = $field; } } $custom_fields = $parse_custom_fields; } if (!empty($custom_fields)) { $field_set_start = 0; $fieldset_count = 0; $fieldset = ''; $total_fields = count($custom_fields); $count_field = 0; $fieldset_arr = array(); $i = 0; $geodir_post_info = isset($post->ID) && !empty($post->ID) ? geodir_get_post_info($post->ID) : NULL; foreach ($custom_fields as $field) { $count_field++; $field_name = $field['htmlvar_name']; if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) { $post->{$field_name} = $_REQUEST[$field_name]; } if (isset($field['show_as_tab']) && $field['show_as_tab'] == 1 && (isset($post->{$field_name}) && $post->{$field_name} != '' || $field['type'] == 'fieldset') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) { $label = $field['site_title'] != '' ? $field['site_title'] : $field['admin_title']; $site_title = trim($field['site_title']); $type = $field; $html = ''; $html_var = $field_name; $field_icon = ''; $variables_array = array(); if ($type['type'] == 'datepicker' && ($post->{$type}['htmlvar_name'] == '' || $post->{$type}['htmlvar_name'] == '0000-00-00')) { continue; } if ($type['type'] != 'fieldset') { $i++; $variables_array['post_id'] = $post->ID; $variables_array['label'] = __($type['site_title'], 'geodirectory'); $variables_array['value'] = ''; $variables_array['value'] = $post->{$type}['htmlvar_name']; } 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>'; } switch ($type['type']) { case 'fieldset': $i = 0; $fieldset_count++; $field_set_start = 1; $fieldset_arr[$fieldset_count]['htmlvar_name'] = 'gd_tab_' . $fieldset_count; $fieldset_arr[$fieldset_count]['label'] = $label; break; case 'url': 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 = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; // 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"'; $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': 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 = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; $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; if ($field_set_start == 1 && $site_title != '') { $html .= ' ' . __($site_title, 'geodirectory') . ': '; } $html .= ' </span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>'; break; case 'time': $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 = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; $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; if ($field_set_start == 1 && $site_title != '') { $html .= ' ' . __($site_title, 'geodirectory') . ': '; } $html .= ' </span>' . stripslashes($value) . '</div>'; break; case 'datepicker': $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'] != '') { $value = date($date_format, strtotime($post_htmlvar_value)); } 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 = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; $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; if ($field_set_start == 1 && $site_title != '') { $html .= ' ' . __($site_title, 'geodirectory') . ': '; } $html .= ' </span>' . $value . '</div>'; break; case 'text': 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 = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; $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; if ($field_set_start == 1 && $site_title != '') { $html .= ' ' . __($site_title, 'geodirectory') . ': '; } $html .= ' </span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>'; break; case 'radio': if ($post->{$type}['htmlvar_name'] != '') { if ($post->{$type}['htmlvar_name'] == 'f' || $post->{$type}['htmlvar_name'] == '0') { $html_val = __('No', 'geodirectory'); } else { if ($post->{$type}['htmlvar_name'] == 't' || $post->{$type}['htmlvar_name'] == '1') { $html_val = __('Yes', 'geodirectory'); } } 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 = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; $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; if ($field_set_start == 1 && $site_title != '') { $html .= ' ' . __($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 = ''; } else { if ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } } $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; $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; if ($field_set_start == 1 && $site_title != '') { $html .= ' ' . __($site_title, 'geodirectory') . ': '; } $html .= ' </span>' . $html_val . '</div>'; } break; case 'select': 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 = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; $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; if ($field_set_start == 1 && $site_title != '') { $html .= ' ' . __($site_title, 'geodirectory') . ': '; } $html .= ' </span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>'; break; case 'multiselect': 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 = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; $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; if ($field_set_start == 1 && $site_title != '') { $html .= ' ' . __($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 (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 = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; $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; if ($field_set_start == 1 && $site_title != '') { $html .= ' ' . __($site_title, 'geodirectory') . ': '; } $html .= ' </span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>'; break; case 'textarea': 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 = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; $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; if ($field_set_start == 1 && $site_title != '') { $html .= ' ' . __($site_title, 'geodirectory') . ': '; } $html .= '</span>' . wpautop(stripslashes($post->{$type}['htmlvar_name'])) . '</div>'; break; case 'html': 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 = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; $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; if ($field_set_start == 1 && $site_title != '') { $html .= ' ' . __($site_title, 'geodirectory') . ': '; } $html .= ' </span>' . wpautop(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 .= '</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 = ''; } else { if ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } } $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . ' geodir-custom-file-box" style="clear:both;"><span class="geodir-i-file" style="display:inline-block;vertical-align:top;padding-right:14px;' . $field_icon . '">' . $field_icon_af; if ($field_set_start == 1 && $site_title != '') { $html .= ' ' . __($site_title, 'geodirectory') . ': '; } $html .= ' </span>' . $file_paths . '</div>'; } } break; } if ($field_set_start == 1) { $add_html = false; if ($type['type'] == 'fieldset' && $fieldset_count > 1) { if ($fieldset != '') { $add_html = true; $label = $fieldset_arr[$fieldset_count - 1]['label']; $htmlvar_name = $fieldset_arr[$fieldset_count - 1]['htmlvar_name']; } $fieldset_html = $fieldset; $fieldset = ''; } else { $fieldset .= $html; if ($total_fields == $count_field && $fieldset != '') { $add_html = true; $label = $fieldset_arr[$fieldset_count]['label']; $htmlvar_name = $fieldset_arr[$fieldset_count]['htmlvar_name']; $fieldset_html = $fieldset; } } if ($add_html) { $tabs_arr[$htmlvar_name] = array('heading_text' => __($label, 'geodirectory'), 'is_active_tab' => false, 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $htmlvar_name), 'tab_content' => '<div class="geodir-company_info field-group">' . $fieldset_html . '</html>'); } } else { if ($html != '') { $tabs_arr[$field['htmlvar_name']] = array('heading_text' => __($label, 'geodirectory'), 'is_active_tab' => false, 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $field['htmlvar_name']), 'tab_content' => $html); } } } } } } return $tabs_arr; }
/** * Get the cpt categories content. * * @since 1.5.4 * * @param array $params An array of cpt categories parameters. * @return string CPT categories content. */ function geodir_cpt_categories_output($params) { $args = wp_parse_args((array) $params, array('title' => '', 'post_type' => array(), 'hide_empty' => '', 'show_count' => '', 'hide_icon' => '', 'cpt_left' => '', 'sort_by' => 'count', 'max_count' => 'all', 'max_level' => '1')); $sort_by = isset($args['sort_by']) && in_array($args['sort_by'], array('az', 'count')) ? $args['sort_by'] : 'count'; $gd_post_types = geodir_get_posttypes('array'); $post_type_arr = !is_array($args['post_type']) ? explode(',', $args['post_type']) : $args['post_type']; $current_posttype = geodir_get_current_posttype(); $is_listing = false; $is_category = false; if (geodir_is_page('listing')) { $current_posttype = geodir_get_current_posttype(); if ($current_posttype != '' && isset($gd_post_types[$current_posttype])) { $is_listing = true; if (is_tax()) { // category page $current_term_id = get_queried_object_id(); $current_taxonomy = get_query_var('taxonomy'); $current_posttype = geodir_get_current_posttype(); if ($current_term_id && $current_posttype && get_query_var('taxonomy') == $current_posttype . 'category') { $is_category = true; } } } } $parent_category = 0; if ($is_listing) { $post_type_arr = array($current_posttype); if ($is_category) { $parent_category = $current_term_id; } } $post_types = array(); if (!empty($post_type_arr)) { if (in_array('0', $post_type_arr)) { $post_types = $gd_post_types; } else { foreach ($post_type_arr as $cpt) { if (isset($gd_post_types[$cpt])) { $post_types[$cpt] = $gd_post_types[$cpt]; } } } } if (empty($post_type_arr)) { $post_types = $gd_post_types; } $hide_empty = !empty($args['hide_empty']) ? true : false; $max_count = strip_tags($args['max_count']); $all_childs = $max_count == 'all' ? true : false; $max_count = $max_count > 0 ? (int) $max_count : 0; $max_level = strip_tags($args['max_level']); $show_count = !empty($args['show_count']) ? true : false; $hide_icon = !empty($args['hide_icon']) ? true : false; $cpt_left = !empty($args['cpt_left']) ? true : false; if (!$cpt_left) { $cpt_left = "gd-cpt-flat"; } else { $cpt_left = ''; } $orderby = 'count'; $order = 'DESC'; if ($sort_by == 'az') { $orderby = 'name'; $order = 'ASC'; } $output = ''; if (!empty($post_types)) { foreach ($post_types as $cpt => $cpt_info) { $cat_taxonomy = $cpt . 'category'; $categories = get_terms($cat_taxonomy, array('orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'parent' => $parent_category)); if ($hide_empty) { $categories = geodir_filter_empty_terms($categories); } if ($sort_by == 'count') { $categories = geodir_sort_terms($categories, 'count'); } if (!empty($categories)) { $term_icons = !$hide_icon ? geodir_get_term_icon() : array(); $row_class = ''; if ($is_listing) { $row_class = $is_category ? ' gd-cptcat-categ' : ' gd-cptcat-listing'; } $cpt_row = '<div class="gd-cptcat-row gd-cptcat-' . $cpt . $row_class . ' ' . $cpt_left . '">'; if ($is_category) { $term_info = get_term($current_term_id, $cat_taxonomy); $term_icon_url = !empty($term_icons) && isset($term_icons[$term_info->term_id]) ? $term_icons[$term_info->term_id] : ''; $term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($term_info->name) . ' icon" src="' . $term_icon_url . '" /> ' : ''; $count = $show_count ? ' <span class="gd-cptcat-count">(' . $term_info->count . ')</span>' : ''; $cpt_row .= '<h2 class="gd-cptcat-title">' . $term_icon_url . $term_info->name . $count . '</h2>'; } else { $cpt_row .= '<h2 class="gd-cptcat-title">' . __($cpt_info['labels']['name'], 'geodirectory') . '</h2>'; } foreach ($categories as $category) { $term_icon_url = !empty($term_icons) && isset($term_icons[$category->term_id]) ? $term_icons[$category->term_id] : ''; $term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($category->name) . ' icon" src="' . $term_icon_url . '" /> ' : ''; $term_link = get_term_link($category, $category->taxonomy); /** Filter documented in geodirectory-functions/general_functions.php **/ $term_link = apply_filters('geodir_category_term_link', $term_link, $category->term_id, $cpt); $cpt_row .= '<ul class="gd-cptcat-ul gd-cptcat-parent ' . $cpt_left . '">'; $cpt_row .= '<li class="gd-cptcat-li gd-cptcat-li-main">'; $count = $show_count ? ' <span class="gd-cptcat-count">(' . $category->count . ')</span>' : ''; $cpt_row .= '<h3 class="gd-cptcat-cat"><a href="' . esc_url($term_link) . '" title="' . esc_attr($category->name) . '">' . $term_icon_url . $category->name . $count . '</a></h3>'; if (($all_childs || $max_count > 0) && ($max_level == 'all' || (int) $max_level > 0)) { $cpt_row .= geodir_cpt_categories_child_cats($category->term_id, $cpt, $hide_empty, $show_count, $sort_by, $max_count, $max_level, $term_icons); } $cpt_row .= '</li>'; $cpt_row .= '</ul>'; } $cpt_row .= '</ul></div>'; $output .= $cpt_row; } } } return $output; }