/**
 *
 * @global object $wpdb WordPress Database object.
 *
 * @param $atts
 * @return null|string
 *
 * @global object $wp WordPress object.
 */
function geodir_sc_location_description($atts)
{
    global $wpdb, $wp;
    ob_start();
    $gd_country = isset($wp->query_vars['gd_country']) ? $wp->query_vars['gd_country'] : '';
    $gd_region = isset($wp->query_vars['gd_region']) ? $wp->query_vars['gd_region'] : '';
    $gd_city = isset($wp->query_vars['gd_city']) ? $wp->query_vars['gd_city'] : '';
    $location_title = '';
    $seo_title = '';
    $seo_desc = '';
    if ($gd_city) {
        $info = geodir_city_info_by_slug($gd_city, $gd_country, $gd_region);
        if (!empty($info)) {
            $location_title = $info->city;
            $seo_title = $info->city_meta;
            $seo_desc = $info->city_desc;
        }
    } else {
        if (!$gd_city && $gd_region) {
            $info = geodir_location_seo_by_slug($gd_region, 'region', $gd_country);
            if (!empty($info)) {
                $seo_title = $info->seo_title;
                $seo_desc = $info->seo_desc;
                $location_title = $wpdb->get_var($wpdb->prepare("SELECT region FROM " . POST_LOCATION_TABLE . " WHERE region_slug!='' AND region_slug=%s ORDER BY location_id ASC", array($gd_region)));
            }
        } else {
            if (!$gd_city && !$gd_region && $gd_country) {
                $info = geodir_location_seo_by_slug($gd_country, 'country');
                if (!empty($info)) {
                    $seo_title = $info->seo_title;
                    $seo_desc = $info->seo_desc;
                    $location_title = $wpdb->get_var($wpdb->prepare("SELECT country FROM " . POST_LOCATION_TABLE . " WHERE country_slug!='' AND country_slug=%s ORDER BY location_id ASC", array($gd_country)));
                }
            }
        }
    }
    $location_desc = $seo_desc;
    if ($location_desc == '') {
        return null;
    }
    $location_desc = stripslashes_deep($location_desc);
    echo '<div class="geodir-category-list-in clearfix geodir-location-desc">' . $location_desc . '</div>';
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
/**
 * Add location information to the meta description.
 *
 * @since 1.0.0
 * @package GeoDirectory_Location_Manager
 *
 * @global object $wpdb WordPress Database object.
 * @global object $wp WordPress object.
 *
 * @param string $seo_desc Meta description text.
 * @return null|string Altered meta desc.
 */
function geodir_set_location_meta_desc($seo_desc = '')
{
    global $wpdb, $wp;
    $gd_country = get_query_var('gd_country');
    $gd_region = get_query_var('gd_region');
    $gd_city = get_query_var('gd_city');
    if ($gd_city) {
        $info = geodir_city_info_by_slug($gd_city, $gd_country, $gd_region);
        if (!empty($info)) {
            $seo_desc .= $info->city_meta != '' ? $info->city_meta : $info->city_meta;
        }
    } else {
        if (!$gd_city && $gd_region) {
            $info = geodir_location_seo_by_slug($gd_region, 'region', $gd_country);
            if (!empty($info)) {
                $seo_desc .= $info->seo_desc != '' ? $info->seo_desc : $info->seo_title;
            }
        } else {
            if (!$gd_city && !$gd_region && $gd_country) {
                $info = geodir_location_seo_by_slug($gd_country, 'country');
                if (!empty($info)) {
                    $seo_desc .= $info->seo_desc != '' ? $info->seo_desc : $info->seo_title;
                }
            }
        }
    }
    $location_desc = $seo_desc;
    if ($location_desc == '') {
        return NULL;
    } else {
        return $location_desc;
    }
}
 /**
  * @global object $wpdb WordPress Database object.
  *
  * @param array $args
  * @param array $instance
  * @return null
  */
 public function widget($args, $instance)
 {
     global $wpdb, $wp;
     extract($args, EXTR_SKIP);
     $gd_country = isset($wp->query_vars['gd_country']) ? $wp->query_vars['gd_country'] : '';
     $gd_region = isset($wp->query_vars['gd_region']) ? $wp->query_vars['gd_region'] : '';
     $gd_city = isset($wp->query_vars['gd_city']) ? $wp->query_vars['gd_city'] : '';
     $location_title = '';
     //$seo_title = '';
     $seo_desc = '';
     if ($gd_city) {
         $info = geodir_city_info_by_slug($gd_city, $gd_country, $gd_region);
         if (!empty($info)) {
             $location_title = $info->city;
             $seo_title = $info->city_meta;
             $seo_desc = $info->city_desc;
         }
     } else {
         if (!$gd_city && $gd_region) {
             $info = geodir_location_seo_by_slug($gd_region, 'region', $gd_country);
             if (!empty($info)) {
                 //$seo_title = $info->seo_title;
                 $seo_desc = $info->seo_desc;
                 $location_title = $wpdb->get_var($wpdb->prepare("SELECT region FROM " . POST_LOCATION_TABLE . " WHERE region_slug!='' AND region_slug=%s ORDER BY location_id ASC", array($gd_region)));
             }
         } else {
             if (!$gd_city && !$gd_region && $gd_country) {
                 $info = geodir_location_seo_by_slug($gd_country, 'country');
                 if (!empty($info)) {
                     //$seo_title = $info->seo_title;
                     $seo_desc = $info->seo_desc;
                     $location_title = $wpdb->get_var($wpdb->prepare("SELECT country FROM " . POST_LOCATION_TABLE . " WHERE country_slug!='' AND country_slug=%s ORDER BY location_id ASC", array($gd_country)));
                 }
             }
         }
     }
     $location_desc = $seo_desc;
     if ($location_desc == '') {
         return NULL;
     }
     $title = empty($instance['title']) ? __('Location Description', GEODIRECTORY_TEXTDOMAIN) : apply_filters('geodir_location_description_widget_title', __($instance['title'], GEODIRECTORY_TEXTDOMAIN));
     $title = str_replace('%s', $location_title, $title);
     $title = str_replace('%location%', $location_title, $title);
     echo $before_widget;
     if (!empty($title)) {
         echo $before_title . __($title) . $after_title;
     }
     $location_desc = stripslashes_deep($location_desc);
     echo '<div class="geodir-category-list-in clearfix geodir-location-desc">' . $location_desc . '</div>';
     echo $after_widget;
 }
示例#4
0
</textarea></td>
				<td><textarea class="geodir_meta_description" cols="25"><?php 
        echo stripslashes_deep($desc);
        ?>
</textarea></td>
			</tr>
			<?php 
        $get_states = $wpdb->get_results("select * from " . POST_LOCATION_TABLE . " WHERE country_slug='" . $get_countriesobj->country_slug . "' GROUP BY region ORDER BY region ASC");
        if (!empty($get_states)) {
            foreach ($get_states as $get_statesobj) {
                $nonce = wp_create_nonce('geodir_set_location_seo' . $get_statesobj->region_slug);
                $title = $get_statesobj->region;
                $desc = $get_statesobj->region;
                $slug = $get_statesobj->region_slug;
                $country_slug = $get_statesobj->country_slug;
                $info = geodir_location_seo_by_slug($slug, 'region', $country_slug);
                if (!empty($info)) {
                    $title = $info->seo_title != '' ? $info->seo_title : $title;
                    $desc = $info->seo_desc != '' ? $info->seo_desc : $title;
                }
                if ($title == '') {
                    $title = $get_statesobj->region;
                }
                ?>
			<tr class="geodir_set_location_seo_region geodir_location_seo<?php 
                echo $get_countriesobj->country_slug;
                ?>
" style="display:none;">
				<td>&nbsp;</td>
				<td width="5"><a class="show_div" style="margin-top:2px; margin-left:5px; float:left;width:16px;" href="javascript:void(0);"><img src="<?php 
                echo plugins_url('', __FILE__);