Ejemplo n.º 1
0
/**
 * 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);
    }
}
Ejemplo n.º 2
0
/**
 * add location variables in geodirectory title parameter for single post.
 *
 * @since 1.0.0
 * @package GeoDirectory
 * @global object $wp WordPress object.
 * @param string $title The title parameter.
 * @param object $post Post object.
 * @return string Modified post title.
 */
function geodir_single_post_title($title, $post)
{
    global $wp;
    if ($post->post_title == 'Location' && geodir_is_geodir_page()) {
        $title = defined('GD_LOCATION') ? GD_LOCATION : __('Location', 'geodirectory');
        $location_array = geodir_get_current_location_terms('query_vars');
        if (!empty($location_array)) {
            $location_array = array_reverse($location_array);
            $actual_location_name = function_exists('get_actual_location_name') ? true : false;
            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);
                $gd_location_link_text = ucwords($gd_location_link_text);
                $gd_location_link_text = __($gd_location_link_text, 'geodirectory');
                if ($actual_location_name) {
                    $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
                    $gd_location_link_text = get_actual_location_name($location_type, $location, true);
                }
                $title .= ' ' . $gd_location_link_text;
            }
            $gd_post_type = geodir_get_current_posttype();
            $post_type_info = get_post_type_object($gd_post_type);
            if (get_query_var($gd_post_type . 'category')) {
                $gd_taxonomy = $gd_post_type . 'category';
            } else {
                if (get_query_var($gd_post_type . '_tags')) {
                    $gd_taxonomy = $gd_post_type . '_tags';
                }
            }
            if (!empty($gd_taxonomy)) {
                $term_array = explode("/", trim($wp->query_vars[$gd_taxonomy], "/"));
                if (!empty($term_array)) {
                    foreach ($term_array as $term) {
                        $term_link_text = preg_replace('/-(\\d+)$/', '', $term);
                        $term_link_text = preg_replace('/[_-]/', ' ', $term_link_text);
                    }
                    $title .= ' ' . ucwords($term_link_text);
                }
            }
        }
    }
    return $title;
}
/**
 * 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>';
        }
    }
}
Ejemplo n.º 4
0
/**
 * Sanitize location name.
 *
 * @since 1.0.0
 * @package GeoDirectory
 * @param string $type Location type. Can be gd_country, gd_region, gd_city.
 * @param string $name Location name.
 * @param bool $translate Do you want to translate the name? Default: true.
 * @return string Sanitized name.
 */
function geodir_sanitize_location_name($type, $name, $translate = true)
{
    if ($name == '') {
        return NULL;
    }
    $type = $type == 'gd_country' ? 'country' : $type;
    $type = $type == 'gd_region' ? 'region' : $type;
    $type = $type == 'gd_city' ? 'city' : $type;
    $return = $name;
    if (function_exists('get_actual_location_name')) {
        $return = get_actual_location_name($type, $name, $translate);
    } else {
        $return = preg_replace('/-(\\d+)$/', '', $return);
        $return = preg_replace('/[_-]/', ' ', $return);
        $return = ucwords($return);
        $return = $translate ? __($return, 'geodirectory') : $return;
    }
    return $return;
}
/**
 * Outputs the listings template title.
 *
 * @since 1.0.0
 * @package GeoDirectory
 * @global object $wp The WordPress object.
 * @global string $term Current term slug.
 */
function geodir_action_listings_title()
{
    global $wp, $term;
    $gd_post_type = geodir_get_current_posttype();
    $post_type_info = get_post_type_object($gd_post_type);
    $add_string_in_title = __('All', GEODIRECTORY_TEXTDOMAIN) . ' ';
    if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
        $add_string_in_title = __('My Favorite', GEODIRECTORY_TEXTDOMAIN) . ' ';
    }
    $list_title = $add_string_in_title . __(ucfirst($post_type_info->labels->name), GEODIRECTORY_TEXTDOMAIN);
    $single_name = $post_type_info->labels->singular_name;
    $taxonomy = geodir_get_taxonomies($gd_post_type, true);
    $gd_country = get_query_var('gd_country');
    $gd_region = get_query_var('gd_region');
    $gd_city = get_query_var('gd_city');
    if (!empty($term)) {
        $location_name = '';
        if ($gd_country != '' || $gd_region != '' || $gd_city != '') {
            if ($gd_country != '') {
                $location_name = geodir_sanitize_location_name('gd_country', $gd_country);
            }
            if ($gd_region != '') {
                $location_name = geodir_sanitize_location_name('gd_region', $gd_region);
            }
            if ($gd_city != '') {
                $location_name = geodir_sanitize_location_name('gd_city', $gd_city);
            }
        }
        $current_term = get_term_by('slug', $term, $taxonomy[0]);
        if (!empty($current_term)) {
            $current_term_name = __(ucfirst($current_term->name), GEODIRECTORY_TEXTDOMAIN);
            if ($current_term_name != '' && $location_name != '' && isset($current_term->taxonomy) && $current_term->taxonomy == $gd_post_type . 'category') {
                $location_last_char = substr($location_name, -1);
                $location_name_attach = strtolower($location_last_char) == 's' ? __("'", GEODIRECTORY_TEXTDOMAIN) : __("'s", GEODIRECTORY_TEXTDOMAIN);
                $list_title .= __(' in', GEODIRECTORY_TEXTDOMAIN) . ' ' . $location_name . $location_name_attach . ' ' . $current_term_name;
            } else {
                $list_title .= __(' in', GEODIRECTORY_TEXTDOMAIN) . " '" . $current_term_name . "'";
            }
        } else {
            if (count($taxonomy) > 1) {
                $current_term = get_term_by('slug', $term, $taxonomy[1]);
                if (!empty($current_term)) {
                    $current_term_name = __(ucfirst($current_term->name), GEODIRECTORY_TEXTDOMAIN);
                    if ($current_term_name != '' && $location_name != '' && isset($current_term->taxonomy) && $current_term->taxonomy == $gd_post_type . 'category') {
                        $location_last_char = substr($location_name, -1);
                        $location_name_attach = strtolower($location_last_char) == 's' ? __("'", GEODIRECTORY_TEXTDOMAIN) : __("'s", GEODIRECTORY_TEXTDOMAIN);
                        $list_title .= __(' in', GEODIRECTORY_TEXTDOMAIN) . ' ' . $location_name . $location_name_attach . ' ' . $current_term_name;
                    } else {
                        $list_title .= __(' in', GEODIRECTORY_TEXTDOMAIN) . " '" . $current_term_name . "'";
                    }
                }
            }
        }
    } else {
        $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 = __(ucwords($gd_city), GEODIRECTORY_TEXTDOMAIN);
            }
            $list_title .= __(' in', GEODIRECTORY_TEXTDOMAIN) . " '" . $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 = __(ucwords($gd_region), GEODIRECTORY_TEXTDOMAIN);
                }
                $list_title .= __(' in', GEODIRECTORY_TEXTDOMAIN) . " '" . $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 = __(ucwords($gd_country), GEODIRECTORY_TEXTDOMAIN);
                    }
                    $list_title .= __(' in', GEODIRECTORY_TEXTDOMAIN) . " '" . $gd_country . "'";
                }
            }
        }
    }
    if (is_search()) {
        $list_title = __('Search', GEODIRECTORY_TEXTDOMAIN) . ' ' . __(ucfirst($post_type_info->labels->name), GEODIRECTORY_TEXTDOMAIN) . __(' For :', GEODIRECTORY_TEXTDOMAIN) . " '" . get_search_query() . "'";
    }
    /** This action is documented in geodirectory_template_actions.php */
    $class = apply_filters('geodir_page_title_class', 'entry-title fn');
    /** This action is documented in geodirectory_template_actions.php */
    $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
    echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' . apply_filters('geodir_listing_page_title', wptexturize($list_title)) . '</h1></header>';
}
Ejemplo n.º 6
0
/**
 * Get location countries.
 *
 * @since 1.0.0
 * @package GeoDirectory_Location_Manager
 *
 * @global object $wpdb WordPress Database object.
 *
 * @param bool $list Return as list? Default: false.
 * @return array|mixed
 */
function geodir_post_location_countries($list = false)
{
    global $wpdb;
    $sql = "SELECT country, country_slug, count(location_id) AS total FROM " . POST_LOCATION_TABLE . " WHERE country_slug != '' && country != '' GROUP BY country_slug ORDER BY country ASC";
    $rows = $wpdb->get_results($sql);
    $items = array();
    if ($list && !empty($rows)) {
        foreach ($rows as $row) {
            $items[$row->country_slug] = get_actual_location_name('country', $row->country_slug, true);
        }
        asort($items);
        $rows = $items;
    }
    return $rows;
}
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);
}
/**
 *
 *
 * @global object $wp WordPress object.
 *
 * @param $breadcrumb
 * @param $saprator
 * @param bool $echo
 * @return string
 */
function geodir_location_breadcrumb($breadcrumb, $saprator, $echo = false)
{
    global $wp;
    if (geodir_is_page('location')) {
        $saprator = str_replace(' ', '&nbsp;', $saprator);
        $location_link = geodir_get_location_link('base');
        $location_prefix = get_option('geodir_location_prefix');
        $breadcrumb = '';
        $breadcrumb .= '<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">';
        $breadcrumb .= '<li><a href="' . get_option('home') . '">' . __('Home', GEODIRLOCATION_TEXTDOMAIN) . '</a></li>';
        $breadcrumb .= '<li>' . $saprator;
        $breadcrumb .= '<a href="' . $location_link . '">' . GD_LOCATION . '</a>';
        $breadcrumb .= '</li>';
        /*
        $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] !='') ? $wp->query_vars['gd_country'] : '' ;	
        $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] !='') ? $wp->query_vars['gd_region'] : '' ;
        $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] !='') ? $wp->query_vars['gd_city'] : '' ;
        */
        $locations = geodir_get_current_location_terms();
        $breadcrumb .= '<li>';
        foreach ($locations as $key => $location) {
            if (get_option('permalink_structure') != '') {
                $location_link .= $location;
            } else {
                $location_link .= '&' . $key . '=' . $location;
            }
            $location_link = geodir_location_permalink_url($location_link);
            $location = urldecode($location);
            $location_actual_text = '';
            if ($key == 'gd_country' && ($location_actual = get_actual_location_name('country', $location))) {
                $location_actual_text = get_actual_location_name('country', $location, true);
            } else {
                if ($key == 'gd_region' && ($location_actual = get_actual_location_name('region', $location))) {
                    $location_actual_text = get_actual_location_name('region', $location, true);
                } else {
                    if ($key == 'gd_city' && ($location_actual = get_actual_location_name('city', $location))) {
                        $location_actual_text = get_actual_location_name('city', $location, true);
                    }
                }
            }
            if ($location != end($locations)) {
                $location = preg_replace('/-(\\d+)$/', '', $location);
                $location = preg_replace('/[_-]/', ' ', $location);
                $location = ucwords($location);
                $location = __($location, GEODIRECTORY_TEXTDOMAIN);
                $location_text = $location_actual_text != '' ? $location_actual_text : $location;
                $breadcrumb .= $saprator . '<a href="' . $location_link . '">' . $location_text . '</a>';
            } else {
                $location = preg_replace('/-(\\d+)$/', '', $location);
                $location = preg_replace('/[_-]/', ' ', $location);
                $location = ucwords($location);
                $location = __($location, GEODIRECTORY_TEXTDOMAIN);
                $location_text = $location_actual_text != '' ? $location_actual_text : $location;
                $breadcrumb .= $saprator . $location_text;
            }
        }
        $breadcrumb .= '</li>';
        $breadcrumb .= '</ul></div>';
    }
    if ($echo) {
        echo $breadcrumb;
    } else {
        return $breadcrumb;
    }
}
/**
 * Outputs the listings template title.
 *
 * @since 1.0.0
 * @package GeoDirectory
 * @global object $wp The WordPress object.
 * @global string $term Current term slug.
 */
function geodir_action_listings_title()
{
    global $wp, $term;
    $gd_post_type = geodir_get_current_posttype();
    $post_type_info = get_post_type_object($gd_post_type);
    $add_string_in_title = __('All', 'geodirectory') . ' ';
    if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
        $add_string_in_title = __('My Favorite', 'geodirectory') . ' ';
    }
    $list_title = $add_string_in_title . __(ucfirst($post_type_info->labels->name), 'geodirectory');
    $single_name = $post_type_info->labels->singular_name;
    $taxonomy = geodir_get_taxonomies($gd_post_type, true);
    $gd_country = get_query_var('gd_country');
    $gd_region = get_query_var('gd_region');
    $gd_city = get_query_var('gd_city');
    if (!empty($term)) {
        $location_name = '';
        if ($gd_country != '' || $gd_region != '' || $gd_city != '') {
            if ($gd_country != '') {
                $location_name = geodir_sanitize_location_name('gd_country', $gd_country);
            }
            if ($gd_region != '') {
                $location_name = geodir_sanitize_location_name('gd_region', $gd_region);
            }
            if ($gd_city != '') {
                $location_name = geodir_sanitize_location_name('gd_city', $gd_city);
            }
        }
        $current_term = get_term_by('slug', $term, $taxonomy[0]);
        if (!empty($current_term)) {
            $current_term_name = __(ucfirst($current_term->name), 'geodirectory');
            if ($current_term_name != '' && $location_name != '' && isset($current_term->taxonomy) && $current_term->taxonomy == $gd_post_type . 'category') {
                $location_last_char = substr($location_name, -1);
                $location_name_attach = geodir_strtolower($location_last_char) == 's' ? __("'", 'geodirectory') : __("'s", 'geodirectory');
                $list_title .= __(' in', 'geodirectory') . ' ' . $location_name . $location_name_attach . ' ' . $current_term_name;
            } else {
                $list_title .= __(' in', 'geodirectory') . " '" . $current_term_name . "'";
            }
        } else {
            if (count($taxonomy) > 1) {
                $current_term = get_term_by('slug', $term, $taxonomy[1]);
                if (!empty($current_term)) {
                    $current_term_name = __(ucfirst($current_term->name), 'geodirectory');
                    if ($current_term_name != '' && $location_name != '' && isset($current_term->taxonomy) && $current_term->taxonomy == $gd_post_type . 'category') {
                        $location_last_char = substr($location_name, -1);
                        $location_name_attach = geodir_strtolower($location_last_char) == 's' ? __("'", 'geodirectory') : __("'s", 'geodirectory');
                        $list_title .= __(' in', 'geodirectory') . ' ' . $location_name . $location_name_attach . ' ' . $current_term_name;
                    } else {
                        $list_title .= __(' in', 'geodirectory') . " '" . $current_term_name . "'";
                    }
                }
            }
        }
    } else {
        $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');
            }
            $list_title .= __(' in', 'geodirectory') . " '" . $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');
                }
                $list_title .= __(' in', 'geodirectory') . " '" . $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');
                    }
                    $list_title .= __(' in', 'geodirectory') . " '" . $gd_country . "'";
                }
            }
        }
    }
    if (is_search()) {
        $list_title = __('Search', 'geodirectory') . ' ' . __(ucfirst($post_type_info->labels->name), 'geodirectory') . __(' For :', 'geodirectory') . " '" . get_search_query() . "'";
    }
    /** This action is documented in geodirectory_template_actions.php */
    $class = apply_filters('geodir_page_title_class', 'entry-title fn');
    /** This action is documented in geodirectory_template_actions.php */
    $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
    $title = $list_title;
    if (geodir_is_page('pt')) {
        $gd_page = 'pt';
        $title = get_option('geodir_page_title_pt') ? get_option('geodir_page_title_pt') : $title;
    } elseif (geodir_is_page('listing')) {
        $gd_page = 'listing';
        global $wp_query;
        $current_term = $wp_query->get_queried_object();
        if (strpos($current_term->taxonomy, '_tags') !== false) {
            $title = get_option('geodir_page_title_tag-listing') ? get_option('geodir_page_title_tag-listing') : $title;
        } else {
            $title = get_option('geodir_page_title_cat-listing') ? get_option('geodir_page_title_cat-listing') : $title;
        }
    } elseif (geodir_is_page('author')) {
        $gd_page = 'author';
        if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
            $title = get_option('geodir_page_title_favorite') ? get_option('geodir_page_title_favorite') : $title;
        } else {
            $title = get_option('geodir_page_title_author') ? get_option('geodir_page_title_author') : $title;
        }
    }
    /**
     * Filter page title to replace variables.
     *
     * @since 1.5.4
     * @param string $title The page title including variables.
     * @param string $gd_page The GeoDirectory page type if any.
     */
    $title = apply_filters('geodir_seo_page_title', __($title, 'geodirectory'), $gd_page);
    echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' . apply_filters('geodir_listing_page_title', $title) . '</h1></header>';
}