| @@ -10,7 +10,7 @@ discard block | ||
| 10 | 10 | /** | 
| 11 | 11 | * Get All Plugin functions from WordPress | 
| 12 | 12 | */ | 
| 13 | -include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); | |
| 13 | +include_once(ABSPATH.'wp-admin/includes/plugin.php'); | |
| 14 | 14 | |
| 15 | 15 | /*-----------------------------------------------------------------------------------*/ | 
| 16 | 16 | /* Helper functions */ | 
| @@ -27,10 +27,10 @@ discard block | ||
| 27 | 27 | */ | 
| 28 | 28 |  function geodir_plugin_url() {
 | 
| 29 | 29 | |
| 30 | - if ( is_ssl() ) : | |
| 31 | - return str_replace( 'http://', 'https://', WP_PLUGIN_URL ) . "/" . plugin_basename( dirname( dirname( __FILE__ ) ) ); | |
| 30 | + if (is_ssl()) : | |
| 31 | +		return str_replace('http://', 'https://', WP_PLUGIN_URL)."/".plugin_basename(dirname(dirname(__FILE__)));
 | |
| 32 | 32 | else : | 
| 33 | - return WP_PLUGIN_URL . "/" . plugin_basename( dirname( dirname( __FILE__ ) ) ); | |
| 33 | + return WP_PLUGIN_URL."/".plugin_basename(dirname(dirname(__FILE__))); | |
| 34 | 34 | endif; | 
| 35 | 35 | } | 
| 36 | 36 | |
| @@ -45,10 +45,10 @@ discard block | ||
| 45 | 45 | * @return string example url eg: /home/geo/public_html/wp-content/plugins/geodirectory | 
| 46 | 46 | */ | 
| 47 | 47 |  function geodir_plugin_path() {
 | 
| 48 | -	if ( defined( 'GD_TESTING_MODE' ) && GD_TESTING_MODE ) {
 | |
| 49 | - return dirname( dirname( __FILE__ ) ); | |
| 48 | +	if (defined('GD_TESTING_MODE') && GD_TESTING_MODE) {
 | |
| 49 | + return dirname(dirname(__FILE__)); | |
| 50 | 50 |  	} else {
 | 
| 51 | - return WP_PLUGIN_DIR . "/" . plugin_basename( dirname( dirname( __FILE__ ) ) ); | |
| 51 | + return WP_PLUGIN_DIR."/".plugin_basename(dirname(dirname(__FILE__))); | |
| 52 | 52 | } | 
| 53 | 53 | } | 
| 54 | 54 | |
| @@ -63,10 +63,10 @@ discard block | ||
| 63 | 63 | * @return bool true or false. | 
| 64 | 64 | * @todo check if this is faster than normal WP check and remove if not. | 
| 65 | 65 | */ | 
| 66 | -function geodir_is_plugin_active( $plugin ) {
 | |
| 67 | - $active_plugins = get_option( 'active_plugins' ); | |
| 68 | -	foreach ( $active_plugins as $key => $active_plugin ) {
 | |
| 69 | -		if ( strstr( $active_plugin, $plugin ) ) {
 | |
| 66 | +function geodir_is_plugin_active($plugin) {
 | |
| 67 | +	$active_plugins = get_option('active_plugins');
 | |
| 68 | +	foreach ($active_plugins as $key => $active_plugin) {
 | |
| 69 | +		if (strstr($active_plugin, $plugin)) {
 | |
| 70 | 70 | return true; | 
| 71 | 71 | } | 
| 72 | 72 | } | 
| @@ -88,8 +88,8 @@ discard block | ||
| 88 | 88 | * | 
| 89 | 89 | * @return bool|int|string the formatted date. | 
| 90 | 90 | */ | 
| 91 | -function geodir_get_formated_date( $date ) {
 | |
| 92 | - return mysql2date( get_option( 'date_format' ), $date ); | |
| 91 | +function geodir_get_formated_date($date) {
 | |
| 92 | +	return mysql2date(get_option('date_format'), $date);
 | |
| 93 | 93 | } | 
| 94 | 94 | |
| 95 | 95 | /** | 
| @@ -105,8 +105,8 @@ discard block | ||
| 105 | 105 | * | 
| 106 | 106 | * @return bool|int|string the formatted time. | 
| 107 | 107 | */ | 
| 108 | -function geodir_get_formated_time( $time ) {
 | |
| 109 | - return mysql2date( get_option( 'time_format' ), $time, $translate = true ); | |
| 108 | +function geodir_get_formated_time($time) {
 | |
| 109 | +	return mysql2date(get_option('time_format'), $time, $translate = true);
 | |
| 110 | 110 | } | 
| 111 | 111 | |
| 112 | 112 | |
| @@ -124,35 +124,35 @@ discard block | ||
| 124 | 124 | * | 
| 125 | 125 | * @return string Formatted link. | 
| 126 | 126 | */ | 
| 127 | -function geodir_getlink( $url, $params = array(), $use_existing_arguments = false ) {
 | |
| 128 | -	if ( $use_existing_arguments ) {
 | |
| 127 | +function geodir_getlink($url, $params = array(), $use_existing_arguments = false) {
 | |
| 128 | +	if ($use_existing_arguments) {
 | |
| 129 | 129 | $params = $params + $_GET; | 
| 130 | 130 | } | 
| 131 | -	if ( ! $params ) {
 | |
| 131 | +	if (!$params) {
 | |
| 132 | 132 | return $url; | 
| 133 | 133 | } | 
| 134 | 134 | $link = $url; | 
| 135 | -	if ( strpos( $link, '?' ) === false ) {
 | |
| 135 | +	if (strpos($link, '?') === false) {
 | |
| 136 | 136 | $link .= '?'; | 
| 137 | 137 | } //If there is no '?' add one at the end | 
| 138 | -	elseif ( strpos( $link, '//maps.google.com/maps/api/js?language=' ) ) {
 | |
| 138 | +	elseif (strpos($link, '//maps.google.com/maps/api/js?language=')) {
 | |
| 139 | 139 | $link .= '&'; | 
| 140 | 140 | } //If there is no '&' at the END, add one. | 
| 141 | -	elseif ( ! preg_match( '/(\?|\&(amp;)?)$/', $link ) ) {
 | |
| 141 | +	elseif (!preg_match('/(\?|\&(amp;)?)$/', $link)) {
 | |
| 142 | 142 | $link .= '&'; | 
| 143 | 143 | } //If there is no '&' at the END, add one. | 
| 144 | 144 | |
| 145 | 145 | $params_arr = array(); | 
| 146 | -	foreach ( $params as $key => $value ) {
 | |
| 147 | -		if ( gettype( $value ) == 'array' ) { //Handle array data properly
 | |
| 148 | -			foreach ( $value as $val ) {
 | |
| 149 | - $params_arr[] = $key . '[]=' . urlencode( $val ); | |
| 146 | +	foreach ($params as $key => $value) {
 | |
| 147 | +		if (gettype($value) == 'array') { //Handle array data properly
 | |
| 148 | +			foreach ($value as $val) {
 | |
| 149 | + $params_arr[] = $key.'[]='.urlencode($val); | |
| 150 | 150 | } | 
| 151 | 151 |  		} else {
 | 
| 152 | - $params_arr[] = $key . '=' . urlencode( $value ); | |
| 152 | + $params_arr[] = $key.'='.urlencode($value); | |
| 153 | 153 | } | 
| 154 | 154 | } | 
| 155 | - $link .= implode( '&', $params_arr ); | |
| 155 | +	$link .= implode('&', $params_arr);
 | |
| 156 | 156 | |
| 157 | 157 | return $link; | 
| 158 | 158 | } | 
| @@ -169,18 +169,18 @@ discard block | ||
| 169 | 169 | * | 
| 170 | 170 | * @return string Listing page url if valid. Otherwise home url will be returned. | 
| 171 | 171 | */ | 
| 172 | -function geodir_get_addlisting_link( $post_type = '' ) {
 | |
| 172 | +function geodir_get_addlisting_link($post_type = '') {
 | |
| 173 | 173 | global $wpdb; | 
| 174 | 174 | |
| 175 | 175 |  	//$check_pkg  = $wpdb->get_var("SELECT pid FROM ".GEODIR_PRICE_TABLE." WHERE post_type='".$post_type."' and status != '0'");
 | 
| 176 | 176 | $check_pkg = 1; | 
| 177 | -	if ( post_type_exists( $post_type ) && $check_pkg ) {
 | |
| 177 | +	if (post_type_exists($post_type) && $check_pkg) {
 | |
| 178 | 178 | |
| 179 | - $add_listing_link = get_page_link( geodir_add_listing_page_id() ); | |
| 179 | + $add_listing_link = get_page_link(geodir_add_listing_page_id()); | |
| 180 | 180 | |
| 181 | - return esc_url( add_query_arg( array( 'listing_type' => $post_type ), $add_listing_link ) ); | |
| 181 | +		return esc_url(add_query_arg(array('listing_type' => $post_type), $add_listing_link));
 | |
| 182 | 182 |  	} else {
 | 
| 183 | - return get_bloginfo( 'url' ); | |
| 183 | +		return get_bloginfo('url');
 | |
| 184 | 184 | } | 
| 185 | 185 | } | 
| 186 | 186 | |
| @@ -194,11 +194,11 @@ discard block | ||
| 194 | 194 | */ | 
| 195 | 195 |  function geodir_curPageURL() {
 | 
| 196 | 196 | $pageURL = 'http'; | 
| 197 | -	if ( isset( $_SERVER["HTTPS"] ) && $_SERVER["HTTPS"] == "on" ) {
 | |
| 197 | +	if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
 | |
| 198 | 198 | $pageURL .= "s"; | 
| 199 | 199 | } | 
| 200 | 200 | $pageURL .= "://"; | 
| 201 | - $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; | |
| 201 | + $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; | |
| 202 | 202 | |
| 203 | 203 | /** | 
| 204 | 204 | * Filter the current page URL returned by function geodir_curPageURL(). | 
| @@ -207,7 +207,7 @@ discard block | ||
| 207 | 207 | * | 
| 208 | 208 | * @param string $pageURL The URL of the current page. | 
| 209 | 209 | */ | 
| 210 | - return apply_filters( 'geodir_curPageURL', $pageURL ); | |
| 210 | +	return apply_filters('geodir_curPageURL', $pageURL);
 | |
| 211 | 211 | } | 
| 212 | 212 | |
| 213 | 213 | |
| @@ -223,12 +223,12 @@ discard block | ||
| 223 | 223 | * | 
| 224 | 224 | * @return string Cleaned variable. | 
| 225 | 225 | */ | 
| 226 | -function geodir_clean( $string ) {
 | |
| 226 | +function geodir_clean($string) {
 | |
| 227 | 227 | |
| 228 | - $string = trim( strip_tags( stripslashes( $string ) ) ); | |
| 229 | - $string = str_replace( " ", "-", $string ); // Replaces all spaces with hyphens. | |
| 230 | - $string = preg_replace( '/[^A-Za-z0-9\-\_]/', '', $string ); // Removes special chars. | |
| 231 | - $string = preg_replace( '/-+/', '-', $string ); // Replaces multiple hyphens with single one. | |
| 228 | + $string = trim(strip_tags(stripslashes($string))); | |
| 229 | +	$string = str_replace(" ", "-", $string); // Replaces all spaces with hyphens.
 | |
| 230 | +	$string = preg_replace('/[^A-Za-z0-9\-\_]/', '', $string); // Removes special chars.
 | |
| 231 | +	$string = preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one.
 | |
| 232 | 232 | |
| 233 | 233 | return $string; | 
| 234 | 234 | } | 
| @@ -242,13 +242,13 @@ discard block | ||
| 242 | 242 | */ | 
| 243 | 243 |  function geodir_get_weekday() {
 | 
| 244 | 244 | return array( | 
| 245 | - __( 'Sunday', 'geodirectory' ), | |
| 246 | - __( 'Monday', 'geodirectory' ), | |
| 247 | - __( 'Tuesday', 'geodirectory' ), | |
| 248 | - __( 'Wednesday', 'geodirectory' ), | |
| 249 | - __( 'Thursday', 'geodirectory' ), | |
| 250 | - __( 'Friday', 'geodirectory' ), | |
| 251 | - __( 'Saturday', 'geodirectory' ) | |
| 245 | +		__('Sunday', 'geodirectory'),
 | |
| 246 | +		__('Monday', 'geodirectory'),
 | |
| 247 | +		__('Tuesday', 'geodirectory'),
 | |
| 248 | +		__('Wednesday', 'geodirectory'),
 | |
| 249 | +		__('Thursday', 'geodirectory'),
 | |
| 250 | +		__('Friday', 'geodirectory'),
 | |
| 251 | +		__('Saturday', 'geodirectory')
 | |
| 252 | 252 | ); | 
| 253 | 253 | } | 
| 254 | 254 | |
| @@ -261,11 +261,11 @@ discard block | ||
| 261 | 261 | */ | 
| 262 | 262 |  function geodir_get_weeks() {
 | 
| 263 | 263 | return array( | 
| 264 | - __( 'First', 'geodirectory' ), | |
| 265 | - __( 'Second', 'geodirectory' ), | |
| 266 | - __( 'Third', 'geodirectory' ), | |
| 267 | - __( 'Fourth', 'geodirectory' ), | |
| 268 | - __( 'Last', 'geodirectory' ) | |
| 264 | +		__('First', 'geodirectory'),
 | |
| 265 | +		__('Second', 'geodirectory'),
 | |
| 266 | +		__('Third', 'geodirectory'),
 | |
| 267 | +		__('Fourth', 'geodirectory'),
 | |
| 268 | +		__('Last', 'geodirectory')
 | |
| 269 | 269 | ); | 
| 270 | 270 | } | 
| 271 | 271 | |
| @@ -284,112 +284,112 @@ discard block | ||
| 284 | 284 | * | 
| 285 | 285 | * @return bool If valid returns true. Otherwise false. | 
| 286 | 286 | */ | 
| 287 | -function geodir_is_page( $gdpage = '' ) {
 | |
| 287 | +function geodir_is_page($gdpage = '') {
 | |
| 288 | 288 | |
| 289 | 289 | global $wp_query, $post, $wp; | 
| 290 | 290 | //if(!is_admin()): | 
| 291 | 291 | |
| 292 | - switch ( $gdpage ): | |
| 292 | + switch ($gdpage): | |
| 293 | 293 | case 'add-listing': | 
| 294 | 294 | |
| 295 | -			if ( is_page() && get_query_var( 'page_id' ) == geodir_add_listing_page_id() ) {
 | |
| 295 | +			if (is_page() && get_query_var('page_id') == geodir_add_listing_page_id()) {
 | |
| 296 | 296 | return true; | 
| 297 | -			} elseif ( is_page() && isset( $post->post_content ) && has_shortcode( $post->post_content, 'gd_add_listing' ) ) {
 | |
| 297 | +			} elseif (is_page() && isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
 | |
| 298 | 298 | return true; | 
| 299 | 299 | } | 
| 300 | 300 | |
| 301 | 301 | break; | 
| 302 | 302 | case 'preview': | 
| 303 | - if ( ( is_page() && get_query_var( 'page_id' ) == geodir_preview_page_id() ) && isset( $_REQUEST['listing_type'] ) | |
| 304 | - && in_array( $_REQUEST['listing_type'], geodir_get_posttypes() ) | |
| 303 | +			if ((is_page() && get_query_var('page_id') == geodir_preview_page_id()) && isset($_REQUEST['listing_type'])
 | |
| 304 | + && in_array($_REQUEST['listing_type'], geodir_get_posttypes()) | |
| 305 | 305 |  			) {
 | 
| 306 | 306 | return true; | 
| 307 | 307 | } | 
| 308 | 308 | break; | 
| 309 | 309 | case 'listing-success': | 
| 310 | -			if ( is_page() && get_query_var( 'page_id' ) == geodir_success_page_id() ) {
 | |
| 310 | +			if (is_page() && get_query_var('page_id') == geodir_success_page_id()) {
 | |
| 311 | 311 | return true; | 
| 312 | 312 | } | 
| 313 | 313 | break; | 
| 314 | 314 | case 'detail': | 
| 315 | - $post_type = get_query_var( 'post_type' ); | |
| 316 | -			if ( is_array( $post_type ) ) {
 | |
| 317 | - $post_type = reset( $post_type ); | |
| 315 | +			$post_type = get_query_var('post_type');
 | |
| 316 | +			if (is_array($post_type)) {
 | |
| 317 | + $post_type = reset($post_type); | |
| 318 | 318 | } | 
| 319 | -			if ( is_single() && in_array( $post_type, geodir_get_posttypes() ) ) {
 | |
| 319 | +			if (is_single() && in_array($post_type, geodir_get_posttypes())) {
 | |
| 320 | 320 | return true; | 
| 321 | 321 | } | 
| 322 | 322 | break; | 
| 323 | 323 | case 'pt': | 
| 324 | - $post_type = get_query_var( 'post_type' ); | |
| 325 | -			if ( is_array( $post_type ) ) {
 | |
| 326 | - $post_type = reset( $post_type ); | |
| 324 | +			$post_type = get_query_var('post_type');
 | |
| 325 | +			if (is_array($post_type)) {
 | |
| 326 | + $post_type = reset($post_type); | |
| 327 | 327 | } | 
| 328 | -			if ( is_post_type_archive() && in_array( $post_type, geodir_get_posttypes() ) && ! is_tax() ) {
 | |
| 328 | +			if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes()) && !is_tax()) {
 | |
| 329 | 329 | return true; | 
| 330 | 330 | } | 
| 331 | 331 | |
| 332 | 332 | break; | 
| 333 | 333 | case 'listing': | 
| 334 | -			if ( is_tax() && geodir_get_taxonomy_posttype() ) {
 | |
| 334 | +			if (is_tax() && geodir_get_taxonomy_posttype()) {
 | |
| 335 | 335 | global $current_term, $taxonomy, $term; | 
| 336 | 336 | |
| 337 | 337 | return true; | 
| 338 | 338 | } | 
| 339 | - $post_type = get_query_var( 'post_type' ); | |
| 340 | -			if ( is_array( $post_type ) ) {
 | |
| 341 | - $post_type = reset( $post_type ); | |
| 339 | +			$post_type = get_query_var('post_type');
 | |
| 340 | +			if (is_array($post_type)) {
 | |
| 341 | + $post_type = reset($post_type); | |
| 342 | 342 | } | 
| 343 | -			if ( is_post_type_archive() && in_array( $post_type, geodir_get_posttypes() ) ) {
 | |
| 343 | +			if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes())) {
 | |
| 344 | 344 | return true; | 
| 345 | 345 | } | 
| 346 | 346 | |
| 347 | 347 | break; | 
| 348 | 348 | case 'home': | 
| 349 | 349 | |
| 350 | -			if ( ( is_page() && get_query_var( 'page_id' ) == geodir_home_page_id() ) || is_page_geodir_home() ) {
 | |
| 350 | +			if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home()) {
 | |
| 351 | 351 | return true; | 
| 352 | 352 | } | 
| 353 | 353 | |
| 354 | 354 | break; | 
| 355 | 355 | case 'location': | 
| 356 | -			if ( is_page() && get_query_var( 'page_id' ) == geodir_location_page_id() ) {
 | |
| 356 | +			if (is_page() && get_query_var('page_id') == geodir_location_page_id()) {
 | |
| 357 | 357 | return true; | 
| 358 | 358 | } | 
| 359 | 359 | break; | 
| 360 | 360 | case 'author': | 
| 361 | -			if ( is_author() && isset( $_REQUEST['geodir_dashbord'] ) ) {
 | |
| 361 | +			if (is_author() && isset($_REQUEST['geodir_dashbord'])) {
 | |
| 362 | 362 | return true; | 
| 363 | 363 | } | 
| 364 | 364 | |
| 365 | -			if ( function_exists( 'bp_loggedin_user_id' ) && function_exists( 'bp_displayed_user_id' ) && $my_id = (int) bp_loggedin_user_id() ) {
 | |
| 366 | -				if ( ( (bool) bp_is_current_component( 'listings' ) || (bool) bp_is_current_component( 'favorites' ) ) && $my_id > 0 && $my_id == (int) bp_displayed_user_id() ) {
 | |
| 365 | +			if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int) bp_loggedin_user_id()) {
 | |
| 366 | +				if (((bool) bp_is_current_component('listings') || (bool) bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int) bp_displayed_user_id()) {
 | |
| 367 | 367 | return true; | 
| 368 | 368 | } | 
| 369 | 369 | } | 
| 370 | 370 | break; | 
| 371 | 371 | case 'search': | 
| 372 | -			if ( is_search() && isset( $_REQUEST['geodir_search'] ) ) {
 | |
| 372 | +			if (is_search() && isset($_REQUEST['geodir_search'])) {
 | |
| 373 | 373 | return true; | 
| 374 | 374 | } | 
| 375 | 375 | break; | 
| 376 | 376 | case 'info': | 
| 377 | -			if ( is_page() && get_query_var( 'page_id' ) == geodir_info_page_id() ) {
 | |
| 377 | +			if (is_page() && get_query_var('page_id') == geodir_info_page_id()) {
 | |
| 378 | 378 | return true; | 
| 379 | 379 | } | 
| 380 | 380 | break; | 
| 381 | 381 | case 'login': | 
| 382 | -			if ( is_page() && get_query_var( 'page_id' ) == geodir_login_page_id() ) {
 | |
| 382 | +			if (is_page() && get_query_var('page_id') == geodir_login_page_id()) {
 | |
| 383 | 383 | return true; | 
| 384 | 384 | } | 
| 385 | 385 | break; | 
| 386 | 386 | case 'checkout': | 
| 387 | -			if ( is_page() && function_exists( 'geodir_payment_checkout_page_id' ) && get_query_var( 'page_id' ) == geodir_payment_checkout_page_id() ) {
 | |
| 387 | +			if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id()) {
 | |
| 388 | 388 | return true; | 
| 389 | 389 | } | 
| 390 | 390 | break; | 
| 391 | 391 | case 'invoices': | 
| 392 | -			if ( is_page() && function_exists( 'geodir_payment_invoices_page_id' ) && get_query_var( 'page_id' ) == geodir_payment_invoices_page_id() ) {
 | |
| 392 | +			if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id()) {
 | |
| 393 | 393 | return true; | 
| 394 | 394 | } | 
| 395 | 395 | break; | 
| @@ -414,28 +414,28 @@ discard block | ||
| 414 | 414 | * | 
| 415 | 415 | * @param object $wp WordPress object. | 
| 416 | 416 | */ | 
| 417 | -function geodir_set_is_geodir_page( $wp ) {
 | |
| 418 | -	if ( ! is_admin() ) {
 | |
| 417 | +function geodir_set_is_geodir_page($wp) {
 | |
| 418 | +	if (!is_admin()) {
 | |
| 419 | 419 | //$wp->query_vars['gd_is_geodir_page'] = false; | 
| 420 | 420 | //print_r() | 
| 421 | - if ( empty( $wp->query_vars ) || ! array_diff( array_keys( $wp->query_vars ), array( | |
| 421 | + if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array( | |
| 422 | 422 | 'preview', | 
| 423 | 423 | 'page', | 
| 424 | 424 | 'paged', | 
| 425 | 425 | 'cpage' | 
| 426 | - ) ) | |
| 426 | + )) | |
| 427 | 427 |  		) {
 | 
| 428 | -			if ( get_option( 'geodir_set_as_home' ) ) {
 | |
| 428 | +			if (get_option('geodir_set_as_home')) {
 | |
| 429 | 429 | $wp->query_vars['gd_is_geodir_page'] = true; | 
| 430 | 430 | } | 
| 431 | -			if ( geodir_is_page( 'home' ) ) {
 | |
| 431 | +			if (geodir_is_page('home')) {
 | |
| 432 | 432 | $wp->query_vars['gd_is_geodir_page'] = true; | 
| 433 | 433 | } | 
| 434 | 434 | |
| 435 | 435 | |
| 436 | 436 | } | 
| 437 | 437 | |
| 438 | -		if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) && isset( $wp->query_vars['page_id'] ) ) {
 | |
| 438 | +		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['page_id'])) {
 | |
| 439 | 439 | if ( | 
| 440 | 440 | $wp->query_vars['page_id'] == geodir_add_listing_page_id() | 
| 441 | 441 | || $wp->query_vars['page_id'] == geodir_preview_page_id() | 
| @@ -444,26 +444,26 @@ discard block | ||
| 444 | 444 | || $wp->query_vars['page_id'] == geodir_home_page_id() | 
| 445 | 445 | || $wp->query_vars['page_id'] == geodir_info_page_id() | 
| 446 | 446 | || $wp->query_vars['page_id'] == geodir_login_page_id() | 
| 447 | - || ( function_exists( 'geodir_payment_checkout_page_id' ) && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id() ) | |
| 448 | - || ( function_exists( 'geodir_payment_invoices_page_id' ) && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id() ) | |
| 447 | +				|| (function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
 | |
| 448 | +				|| (function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
 | |
| 449 | 449 |  			) {
 | 
| 450 | 450 | $wp->query_vars['gd_is_geodir_page'] = true; | 
| 451 | 451 | } | 
| 452 | 452 | } | 
| 453 | 453 | |
| 454 | -		if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) && isset( $wp->query_vars['pagename'] ) ) {
 | |
| 455 | - $page = get_page_by_path( $wp->query_vars['pagename'] ); | |
| 454 | +		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['pagename'])) {
 | |
| 455 | + $page = get_page_by_path($wp->query_vars['pagename']); | |
| 456 | 456 | |
| 457 | - if ( ! empty( $page ) && ( | |
| 457 | + if (!empty($page) && ( | |
| 458 | 458 | $page->ID == geodir_add_listing_page_id() | 
| 459 | 459 | || $page->ID == geodir_preview_page_id() | 
| 460 | 460 | || $page->ID == geodir_success_page_id() | 
| 461 | 461 | || $page->ID == geodir_location_page_id() | 
| 462 | - || ( isset( $wp->query_vars['page_id'] ) && $wp->query_vars['page_id'] == geodir_home_page_id() ) | |
| 463 | - || ( isset( $wp->query_vars['page_id'] ) && $wp->query_vars['page_id'] == geodir_info_page_id() ) | |
| 464 | - || ( isset( $wp->query_vars['page_id'] ) && $wp->query_vars['page_id'] == geodir_login_page_id() ) | |
| 465 | - || ( isset( $wp->query_vars['page_id'] ) && function_exists( 'geodir_payment_checkout_page_id' ) && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id() ) | |
| 466 | - || ( isset( $wp->query_vars['page_id'] ) && function_exists( 'geodir_payment_invoices_page_id' ) && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id() ) | |
| 462 | + || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_home_page_id()) | |
| 463 | + || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_info_page_id()) | |
| 464 | + || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_login_page_id()) | |
| 465 | +					|| (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
 | |
| 466 | +					|| (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
 | |
| 467 | 467 | ) | 
| 468 | 468 |  			) {
 | 
| 469 | 469 | $wp->query_vars['gd_is_geodir_page'] = true; | 
| @@ -471,20 +471,20 @@ discard block | ||
| 471 | 471 | } | 
| 472 | 472 | |
| 473 | 473 | |
| 474 | -		if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) && isset( $wp->query_vars['post_type'] ) && $wp->query_vars['post_type'] != '' ) {
 | |
| 474 | +		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
 | |
| 475 | 475 | $requested_post_type = $wp->query_vars['post_type']; | 
| 476 | 476 | // check if this post type is geodirectory post types | 
| 477 | 477 | $post_type_array = geodir_get_posttypes(); | 
| 478 | -			if ( in_array( $requested_post_type, $post_type_array ) ) {
 | |
| 478 | +			if (in_array($requested_post_type, $post_type_array)) {
 | |
| 479 | 479 | $wp->query_vars['gd_is_geodir_page'] = true; | 
| 480 | 480 | } | 
| 481 | 481 | } | 
| 482 | 482 | |
| 483 | -		if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) ) {
 | |
| 484 | - $geodir_taxonomis = geodir_get_taxonomies( '', true ); | |
| 485 | -			if ( ! empty( $geodir_taxonomis ) ) {
 | |
| 486 | -				foreach ( $geodir_taxonomis as $taxonomy ) {
 | |
| 487 | -					if ( array_key_exists( $taxonomy, $wp->query_vars ) ) {
 | |
| 483 | +		if (!isset($wp->query_vars['gd_is_geodir_page'])) {
 | |
| 484 | +			$geodir_taxonomis = geodir_get_taxonomies('', true);
 | |
| 485 | +			if (!empty($geodir_taxonomis)) {
 | |
| 486 | +				foreach ($geodir_taxonomis as $taxonomy) {
 | |
| 487 | +					if (array_key_exists($taxonomy, $wp->query_vars)) {
 | |
| 488 | 488 | $wp->query_vars['gd_is_geodir_page'] = true; | 
| 489 | 489 | break; | 
| 490 | 490 | } | 
| @@ -493,20 +493,20 @@ discard block | ||
| 493 | 493 | |
| 494 | 494 | } | 
| 495 | 495 | |
| 496 | -		if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) && isset( $wp->query_vars['author_name'] ) && isset( $_REQUEST['geodir_dashbord'] ) ) {
 | |
| 496 | +		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord'])) {
 | |
| 497 | 497 | $wp->query_vars['gd_is_geodir_page'] = true; | 
| 498 | 498 | } | 
| 499 | 499 | |
| 500 | 500 | |
| 501 | -		if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) && isset( $_REQUEST['geodir_search'] ) ) {
 | |
| 501 | +		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search'])) {
 | |
| 502 | 502 | $wp->query_vars['gd_is_geodir_page'] = true; | 
| 503 | 503 | } | 
| 504 | 504 | |
| 505 | 505 | |
| 506 | 506 | //check if homepage | 
| 507 | - if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) | |
| 508 | - && ! isset( $wp->query_vars['page_id'] ) | |
| 509 | - && ! isset( $wp->query_vars['pagename'] ) | |
| 507 | + if (!isset($wp->query_vars['gd_is_geodir_page']) | |
| 508 | + && !isset($wp->query_vars['page_id']) | |
| 509 | + && !isset($wp->query_vars['pagename']) | |
| 510 | 510 | && is_page_geodir_home() | 
| 511 | 511 |  		) {
 | 
| 512 | 512 | $wp->query_vars['gd_is_geodir_page'] = true; | 
| @@ -530,14 +530,14 @@ discard block | ||
| 530 | 530 | */ | 
| 531 | 531 |  function geodir_is_geodir_page() {
 | 
| 532 | 532 | global $wp; | 
| 533 | -	if ( isset( $wp->query_vars['gd_is_geodir_page'] ) && $wp->query_vars['gd_is_geodir_page'] ) {
 | |
| 533 | +	if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page']) {
 | |
| 534 | 534 | return true; | 
| 535 | 535 |  	} else {
 | 
| 536 | 536 | return false; | 
| 537 | 537 | } | 
| 538 | 538 | } | 
| 539 | 539 | |
| 540 | -if ( ! function_exists( 'geodir_get_imagesize' ) ) {
 | |
| 540 | +if (!function_exists('geodir_get_imagesize')) {
 | |
| 541 | 541 | /** | 
| 542 | 542 | * Get image size using the size key . | 
| 543 | 543 | * | 
| @@ -548,13 +548,13 @@ discard block | ||
| 548 | 548 | * | 
| 549 | 549 | * @return array|mixed|void|WP_Error If valid returns image size. Else returns error. | 
| 550 | 550 | */ | 
| 551 | -	function geodir_get_imagesize( $size = '' ) {
 | |
| 551 | +	function geodir_get_imagesize($size = '') {
 | |
| 552 | 552 | |
| 553 | 553 | $imagesizes = array( | 
| 554 | - 'list-thumb' => array( 'w' => 283, 'h' => 188 ), | |
| 555 | - 'thumbnail' => array( 'w' => 125, 'h' => 125 ), | |
| 556 | - 'widget-thumb' => array( 'w' => 50, 'h' => 50 ), | |
| 557 | - 'slider-thumb' => array( 'w' => 100, 'h' => 100 ) | |
| 554 | +			'list-thumb'   => array('w' => 283, 'h' => 188),
 | |
| 555 | +			'thumbnail'    => array('w' => 125, 'h' => 125),
 | |
| 556 | +			'widget-thumb' => array('w' => 50, 'h' => 50),
 | |
| 557 | +			'slider-thumb' => array('w' => 100, 'h' => 100)
 | |
| 558 | 558 | ); | 
| 559 | 559 | |
| 560 | 560 | /** | 
| @@ -564,9 +564,9 @@ discard block | ||
| 564 | 564 | * | 
| 565 | 565 | * @param array $imagesizes Image size array. | 
| 566 | 566 | */ | 
| 567 | - $imagesizes = apply_filters( 'geodir_imagesizes', $imagesizes ); | |
| 567 | +		$imagesizes = apply_filters('geodir_imagesizes', $imagesizes);
 | |
| 568 | 568 | |
| 569 | -		if ( ! empty( $size ) && array_key_exists( $size, $imagesizes ) ) {
 | |
| 569 | +		if (!empty($size) && array_key_exists($size, $imagesizes)) {
 | |
| 570 | 570 | /** | 
| 571 | 571 | * Filters image size of the passed key. | 
| 572 | 572 | * | 
| @@ -574,11 +574,11 @@ discard block | ||
| 574 | 574 | * | 
| 575 | 575 | * @param array $imagesizes [$size] Image size array of the passed key. | 
| 576 | 576 | */ | 
| 577 | - return apply_filters( 'geodir_get_imagesize_' . $size, $imagesizes[ $size ] ); | |
| 577 | +			return apply_filters('geodir_get_imagesize_'.$size, $imagesizes[$size]);
 | |
| 578 | 578 | |
| 579 | -		} elseif ( ! empty( $size ) ) {
 | |
| 579 | +		} elseif (!empty($size)) {
 | |
| 580 | 580 | |
| 581 | - return new WP_Error( 'geodir_no_imagesize', __( "Given image size is not valid", 'geodirectory' ) ); | |
| 581 | +			return new WP_Error('geodir_no_imagesize', __("Given image size is not valid", 'geodirectory'));
 | |
| 582 | 582 | |
| 583 | 583 | } | 
| 584 | 584 | |
| @@ -602,7 +602,7 @@ discard block | ||
| 602 | 602 | */ | 
| 603 | 603 | |
| 604 | 604 | |
| 605 | -if ( ! function_exists( 'createRandomString' ) ) {
 | |
| 605 | +if (!function_exists('createRandomString')) {
 | |
| 606 | 606 | /** | 
| 607 | 607 | * Creates random string. | 
| 608 | 608 | * | 
| @@ -612,21 +612,21 @@ discard block | ||
| 612 | 612 | */ | 
| 613 | 613 |  	function createRandomString() {
 | 
| 614 | 614 | $chars = "abcdefghijkmlnopqrstuvwxyz1023456789"; | 
| 615 | - srand( (double) microtime() * 1000000 ); | |
| 615 | + srand((double) microtime() * 1000000); | |
| 616 | 616 | $i = 0; | 
| 617 | 617 | $rstring = ''; | 
| 618 | -		while ( $i <= 25 ) {
 | |
| 618 | +		while ($i <= 25) {
 | |
| 619 | 619 | $num = rand() % 33; | 
| 620 | - $tmp = substr( $chars, $num, 1 ); | |
| 621 | - $rstring = $rstring . $tmp; | |
| 622 | - $i ++; | |
| 620 | + $tmp = substr($chars, $num, 1); | |
| 621 | + $rstring = $rstring.$tmp; | |
| 622 | + $i++; | |
| 623 | 623 | } | 
| 624 | 624 | |
| 625 | 625 | return $rstring; | 
| 626 | 626 | } | 
| 627 | 627 | } | 
| 628 | 628 | |
| 629 | -if ( ! function_exists( 'geodir_getDistanceRadius' ) ) {
 | |
| 629 | +if (!function_exists('geodir_getDistanceRadius')) {
 | |
| 630 | 630 | /** | 
| 631 | 631 | * Calculates the distance radius. | 
| 632 | 632 | * | 
| @@ -637,9 +637,9 @@ discard block | ||
| 637 | 637 | * | 
| 638 | 638 | * @return float The mean radius. | 
| 639 | 639 | */ | 
| 640 | -	function geodir_getDistanceRadius( $uom = 'km' ) {
 | |
| 640 | +	function geodir_getDistanceRadius($uom = 'km') {
 | |
| 641 | 641 | // Use Haversine formula to calculate the great circle distance between two points identified by longitude and latitude | 
| 642 | - switch ( geodir_strtolower( $uom ) ): | |
| 642 | + switch (geodir_strtolower($uom)): | |
| 643 | 643 | case 'km' : | 
| 644 | 644 | $earthMeanRadius = 6371.009; // km | 
| 645 | 645 | break; | 
| @@ -671,7 +671,7 @@ discard block | ||
| 671 | 671 | } | 
| 672 | 672 | |
| 673 | 673 | |
| 674 | -if ( ! function_exists( 'geodir_calculateDistanceFromLatLong' ) ) {
 | |
| 674 | +if (!function_exists('geodir_calculateDistanceFromLatLong')) {
 | |
| 675 | 675 | /** | 
| 676 | 676 | * Calculate the great circle distance between two points identified by longitude and latitude. | 
| 677 | 677 | * | 
| @@ -684,17 +684,17 @@ discard block | ||
| 684 | 684 | * | 
| 685 | 685 | * @return float The distance. | 
| 686 | 686 | */ | 
| 687 | -	function geodir_calculateDistanceFromLatLong( $point1, $point2, $uom = 'km' ) {
 | |
| 687 | +	function geodir_calculateDistanceFromLatLong($point1, $point2, $uom = 'km') {
 | |
| 688 | 688 | // Use Haversine formula to calculate the great circle distance between two points identified by longitude and latitude | 
| 689 | 689 | |
| 690 | - $earthMeanRadius = geodir_getDistanceRadius( $uom ); | |
| 690 | + $earthMeanRadius = geodir_getDistanceRadius($uom); | |
| 691 | 691 | |
| 692 | - $deltaLatitude = deg2rad( (float) $point2['latitude'] - (float) $point1['latitude'] ); | |
| 693 | - $deltaLongitude = deg2rad( (float) $point2['longitude'] - (float) $point1['longitude'] ); | |
| 694 | - $a = sin( $deltaLatitude / 2 ) * sin( $deltaLatitude / 2 ) + | |
| 695 | - cos( deg2rad( (float) $point1['latitude'] ) ) * cos( deg2rad( (float) $point2['latitude'] ) ) * | |
| 696 | - sin( $deltaLongitude / 2 ) * sin( $deltaLongitude / 2 ); | |
| 697 | - $c = 2 * atan2( sqrt( $a ), sqrt( 1 - $a ) ); | |
| 692 | + $deltaLatitude = deg2rad((float) $point2['latitude'] - (float) $point1['latitude']); | |
| 693 | + $deltaLongitude = deg2rad((float) $point2['longitude'] - (float) $point1['longitude']); | |
| 694 | + $a = sin($deltaLatitude / 2) * sin($deltaLatitude / 2) + | |
| 695 | + cos(deg2rad((float) $point1['latitude'])) * cos(deg2rad((float) $point2['latitude'])) * | |
| 696 | + sin($deltaLongitude / 2) * sin($deltaLongitude / 2); | |
| 697 | + $c = 2 * atan2(sqrt($a), sqrt(1 - $a)); | |
| 698 | 698 | $distance = $earthMeanRadius * $c; | 
| 699 | 699 | |
| 700 | 700 | return $distance; | 
| @@ -703,7 +703,7 @@ discard block | ||
| 703 | 703 | } | 
| 704 | 704 | |
| 705 | 705 | |
| 706 | -if ( ! function_exists( 'geodir_sendEmail' ) ) {
 | |
| 706 | +if (!function_exists('geodir_sendEmail')) {
 | |
| 707 | 707 | /** | 
| 708 | 708 | * The main function that send transactional emails using the args provided. | 
| 709 | 709 | * | 
| @@ -722,83 +722,83 @@ discard block | ||
| 722 | 722 | * @param string $post_id The post ID. | 
| 723 | 723 | * @param string $user_id The user ID. | 
| 724 | 724 | */ | 
| 725 | -	function geodir_sendEmail( $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '' ) {
 | |
| 725 | +	function geodir_sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '') {
 | |
| 726 | 726 | $login_details = ''; | 
| 727 | 727 | |
| 728 | 728 | // strip slashes from subject & message text | 
| 729 | - $to_subject = stripslashes_deep( $to_subject ); | |
| 730 | - $to_message = stripslashes_deep( $to_message ); | |
| 731 | - | |
| 732 | -		if ( $message_type == 'send_friend' ) {
 | |
| 733 | - $subject = get_option( 'geodir_email_friend_subject' ); | |
| 734 | - $message = get_option( 'geodir_email_friend_content' ); | |
| 735 | -		} elseif ( $message_type == 'send_enquiry' ) {
 | |
| 736 | - $subject = get_option( 'geodir_email_enquiry_subject' ); | |
| 737 | - $message = get_option( 'geodir_email_enquiry_content' ); | |
| 738 | -		} elseif ( $message_type == 'forgot_password' ) {
 | |
| 739 | - $subject = get_option( 'geodir_forgot_password_subject' ); | |
| 740 | - $message = get_option( 'geodir_forgot_password_content' ); | |
| 729 | + $to_subject = stripslashes_deep($to_subject); | |
| 730 | + $to_message = stripslashes_deep($to_message); | |
| 731 | + | |
| 732 | +		if ($message_type == 'send_friend') {
 | |
| 733 | +			$subject = get_option('geodir_email_friend_subject');
 | |
| 734 | +			$message = get_option('geodir_email_friend_content');
 | |
| 735 | +		} elseif ($message_type == 'send_enquiry') {
 | |
| 736 | +			$subject = get_option('geodir_email_enquiry_subject');
 | |
| 737 | +			$message = get_option('geodir_email_enquiry_content');
 | |
| 738 | +		} elseif ($message_type == 'forgot_password') {
 | |
| 739 | +			$subject       = get_option('geodir_forgot_password_subject');
 | |
| 740 | +			$message       = get_option('geodir_forgot_password_content');
 | |
| 741 | 741 | $login_details = $to_message; | 
| 742 | -		} elseif ( $message_type == 'registration' ) {
 | |
| 743 | - $subject = get_option( 'geodir_registration_success_email_subject' ); | |
| 744 | - $message = get_option( 'geodir_registration_success_email_content' ); | |
| 742 | +		} elseif ($message_type == 'registration') {
 | |
| 743 | +			$subject       = get_option('geodir_registration_success_email_subject');
 | |
| 744 | +			$message       = get_option('geodir_registration_success_email_content');
 | |
| 745 | 745 | $login_details = $to_message; | 
| 746 | -		} elseif ( $message_type == 'post_submit' ) {
 | |
| 747 | - $subject = get_option( 'geodir_post_submited_success_email_subject' ); | |
| 748 | - $message = get_option( 'geodir_post_submited_success_email_content' ); | |
| 749 | -		} elseif ( $message_type == 'listing_published' ) {
 | |
| 750 | - $subject = get_option( 'geodir_post_published_email_subject' ); | |
| 751 | - $message = get_option( 'geodir_post_published_email_content' ); | |
| 752 | -		} elseif ( $message_type == 'listing_edited' ) {
 | |
| 753 | - $subject = get_option( 'geodir_post_edited_email_subject_admin' ); | |
| 754 | - $message = get_option( 'geodir_post_edited_email_content_admin' ); | |
| 746 | +		} elseif ($message_type == 'post_submit') {
 | |
| 747 | +			$subject = get_option('geodir_post_submited_success_email_subject');
 | |
| 748 | +			$message = get_option('geodir_post_submited_success_email_content');
 | |
| 749 | +		} elseif ($message_type == 'listing_published') {
 | |
| 750 | +			$subject = get_option('geodir_post_published_email_subject');
 | |
| 751 | +			$message = get_option('geodir_post_published_email_content');
 | |
| 752 | +		} elseif ($message_type == 'listing_edited') {
 | |
| 753 | +			$subject = get_option('geodir_post_edited_email_subject_admin');
 | |
| 754 | +			$message = get_option('geodir_post_edited_email_content_admin');
 | |
| 755 | 755 | } | 
| 756 | 756 | |
| 757 | -		if ( ! empty( $subject ) ) {
 | |
| 758 | - $subject = __( stripslashes_deep( $subject ), 'geodirectory' ); | |
| 757 | +		if (!empty($subject)) {
 | |
| 758 | + $subject = __(stripslashes_deep($subject), 'geodirectory'); | |
| 759 | 759 | } | 
| 760 | 760 | |
| 761 | -		if ( ! empty( $message ) ) {
 | |
| 762 | - $message = __( stripslashes_deep( $message ), 'geodirectory' ); | |
| 761 | +		if (!empty($message)) {
 | |
| 762 | + $message = __(stripslashes_deep($message), 'geodirectory'); | |
| 763 | 763 | } | 
| 764 | 764 | |
| 765 | - $to_message = nl2br( $to_message ); | |
| 766 | - $sitefromEmail = get_option( 'site_email' ); | |
| 765 | + $to_message = nl2br($to_message); | |
| 766 | +		$sitefromEmail     = get_option('site_email');
 | |
| 767 | 767 | $sitefromEmailName = get_site_emailName(); | 
| 768 | - $productlink = get_permalink( $post_id ); | |
| 768 | + $productlink = get_permalink($post_id); | |
| 769 | 769 | |
| 770 | 770 | $user_login = ''; | 
| 771 | -		if ( $user_id > 0 && $user_info = get_userdata( $user_id ) ) {
 | |
| 771 | +		if ($user_id > 0 && $user_info = get_userdata($user_id)) {
 | |
| 772 | 772 | $user_login = $user_info->user_login; | 
| 773 | 773 | } | 
| 774 | 774 | |
| 775 | 775 | $posted_date = ''; | 
| 776 | 776 | $listingLink = ''; | 
| 777 | 777 | |
| 778 | - $post_info = get_post( $post_id ); | |
| 778 | + $post_info = get_post($post_id); | |
| 779 | 779 | |
| 780 | -		if ( $post_info ) {
 | |
| 780 | +		if ($post_info) {
 | |
| 781 | 781 | $posted_date = $post_info->post_date; | 
| 782 | - $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>'; | |
| 782 | + $listingLink = '<a href="'.$productlink.'"><b>'.$post_info->post_title.'</b></a>'; | |
| 783 | 783 | } | 
| 784 | 784 | $siteurl = home_url(); | 
| 785 | - $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>'; | |
| 785 | + $siteurl_link = '<a href="'.$siteurl.'">'.$siteurl.'</a>'; | |
| 786 | 786 | $loginurl = geodir_login_url(); | 
| 787 | - $loginurl_link = '<a href="' . $loginurl . '">login</a>'; | |
| 787 | + $loginurl_link = '<a href="'.$loginurl.'">login</a>'; | |
| 788 | 788 | |
| 789 | - $post_author_id = ! empty( $post_info ) ? $post_info->post_author : 0; | |
| 790 | - $post_author_name = geodir_get_client_name( $post_author_id ); | |
| 791 | - $current_date = date_i18n( 'Y-m-d H:i:s', current_time( 'timestamp' ) ); | |
| 789 | + $post_author_id = !empty($post_info) ? $post_info->post_author : 0; | |
| 790 | + $post_author_name = geodir_get_client_name($post_author_id); | |
| 791 | +		$current_date     = date_i18n('Y-m-d H:i:s', current_time('timestamp'));
 | |
| 792 | 792 | |
| 793 | -		if ( $fromEmail == '' ) {
 | |
| 794 | - $fromEmail = get_option( 'site_email' ); | |
| 793 | +		if ($fromEmail == '') {
 | |
| 794 | +			$fromEmail = get_option('site_email');
 | |
| 795 | 795 | } | 
| 796 | 796 | |
| 797 | -		if ( $fromEmailName == '' ) {
 | |
| 798 | - $fromEmailName = get_option( 'site_email_name' ); | |
| 797 | +		if ($fromEmailName == '') {
 | |
| 798 | +			$fromEmailName = get_option('site_email_name');
 | |
| 799 | 799 | } | 
| 800 | 800 | |
| 801 | - $search_array = array( | |
| 801 | + $search_array = array( | |
| 802 | 802 | '[#listing_link#]', | 
| 803 | 803 | '[#site_name_url#]', | 
| 804 | 804 | '[#post_id#]', | 
| @@ -838,7 +838,7 @@ discard block | ||
| 838 | 838 | $post_author_name, | 
| 839 | 839 | $current_date | 
| 840 | 840 | ); | 
| 841 | - $message = str_replace( $search_array, $replace_array, $message ); | |
| 841 | + $message = str_replace($search_array, $replace_array, $message); | |
| 842 | 842 | |
| 843 | 843 | $search_array = array( | 
| 844 | 844 | '[#listing_link#]', | 
| @@ -874,12 +874,12 @@ discard block | ||
| 874 | 874 | $post_author_name, | 
| 875 | 875 | $current_date | 
| 876 | 876 | ); | 
| 877 | - $subject = str_replace( $search_array, $replace_array, $subject ); | |
| 877 | + $subject = str_replace($search_array, $replace_array, $subject); | |
| 878 | 878 | |
| 879 | - $headers = 'MIME-Version: 1.0' . "\r\n"; | |
| 880 | - $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; | |
| 881 | - $headers .= "Reply-To: " . $fromEmail . "\r\n"; | |
| 882 | - $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n"; | |
| 879 | + $headers = 'MIME-Version: 1.0'."\r\n"; | |
| 880 | + $headers .= 'Content-type: text/html; charset=UTF-8'."\r\n"; | |
| 881 | + $headers .= "Reply-To: ".$fromEmail."\r\n"; | |
| 882 | + $headers .= 'From: '.$sitefromEmailName.' <'.$sitefromEmail.'>'."\r\n"; | |
| 883 | 883 | |
| 884 | 884 | $to = $toEmail; | 
| 885 | 885 | |
| @@ -901,7 +901,7 @@ discard block | ||
| 901 | 901 | * @param string $post_id The post ID. | 
| 902 | 902 | * @param string $user_id The user ID. | 
| 903 | 903 | */ | 
| 904 | - $to = apply_filters( 'geodir_sendEmail_to', $to, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id ); | |
| 904 | +		$to = apply_filters('geodir_sendEmail_to', $to, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id);
 | |
| 905 | 905 | /** | 
| 906 | 906 | * Filter the client email subject. | 
| 907 | 907 | * | 
| @@ -920,7 +920,7 @@ discard block | ||
| 920 | 920 | * @param string $post_id The post ID. | 
| 921 | 921 | * @param string $user_id The user ID. | 
| 922 | 922 | */ | 
| 923 | - $subject = apply_filters( 'geodir_sendEmail_subject', $subject, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id ); | |
| 923 | +		$subject = apply_filters('geodir_sendEmail_subject', $subject, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id);
 | |
| 924 | 924 | /** | 
| 925 | 925 | * Filter the client email message. | 
| 926 | 926 | * | 
| @@ -939,7 +939,7 @@ discard block | ||
| 939 | 939 | * @param string $post_id The post ID. | 
| 940 | 940 | * @param string $user_id The user ID. | 
| 941 | 941 | */ | 
| 942 | - $message = apply_filters( 'geodir_sendEmail_message', $message, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id ); | |
| 942 | +		$message = apply_filters('geodir_sendEmail_message', $message, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id);
 | |
| 943 | 943 | /** | 
| 944 | 944 | * Filter the client email headers. | 
| 945 | 945 | * | 
| @@ -958,39 +958,39 @@ discard block | ||
| 958 | 958 | * @param string $post_id The post ID. | 
| 959 | 959 | * @param string $user_id The user ID. | 
| 960 | 960 | */ | 
| 961 | - $headers = apply_filters( 'geodir_sendEmail_headers', $headers, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id ); | |
| 961 | +		$headers = apply_filters('geodir_sendEmail_headers', $headers, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id);
 | |
| 962 | 962 | |
| 963 | - $sent = wp_mail( $to, $subject, $message, $headers ); | |
| 963 | + $sent = wp_mail($to, $subject, $message, $headers); | |
| 964 | 964 | |
| 965 | -		if ( ! $sent ) {
 | |
| 966 | -			if ( is_array( $to ) ) {
 | |
| 967 | - $to = implode( ',', $to ); | |
| 965 | +		if (!$sent) {
 | |
| 966 | +			if (is_array($to)) {
 | |
| 967 | +				$to = implode(',', $to);
 | |
| 968 | 968 | } | 
| 969 | 969 | $log_message = sprintf( | 
| 970 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), | |
| 970 | +				__("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
 | |
| 971 | 971 | $message_type, | 
| 972 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), | |
| 972 | +				date_i18n('F j Y H:i:s', current_time('timestamp')),
 | |
| 973 | 973 | $to, | 
| 974 | 974 | $subject | 
| 975 | 975 | ); | 
| 976 | - geodir_error_log( $log_message ); | |
| 976 | + geodir_error_log($log_message); | |
| 977 | 977 | } | 
| 978 | 978 | |
| 979 | 979 | ///////// ADMIN BCC EMIALS | 
| 980 | - $adminEmail = get_bloginfo( 'admin_email' ); | |
| 980 | +		$adminEmail = get_bloginfo('admin_email');
 | |
| 981 | 981 | $to = $adminEmail; | 
| 982 | 982 | |
| 983 | 983 | $admin_bcc = false; | 
| 984 | -		if ( $message_type == 'registration' ) {
 | |
| 985 | - $message_raw = explode( __( "Password:", 'geodirectory' ), $message ); | |
| 986 | - $message_raw2 = explode( "</p>", $message_raw[1], 2 ); | |
| 987 | - $message = $message_raw[0] . __( 'Password:', 'geodirectory' ) . ' **********</p>' . $message_raw2[1]; | |
| 984 | +		if ($message_type == 'registration') {
 | |
| 985 | +			$message_raw  = explode(__("Password:", 'geodirectory'), $message);
 | |
| 986 | +			$message_raw2 = explode("</p>", $message_raw[1], 2);
 | |
| 987 | +			$message      = $message_raw[0].__('Password:', 'geodirectory').' **********</p>'.$message_raw2[1];
 | |
| 988 | 988 | } | 
| 989 | -		if ( $message_type == 'post_submit' ) {
 | |
| 990 | - $subject = __( stripslashes_deep( get_option( 'geodir_post_submited_success_email_subject_admin' ) ), 'geodirectory' ); | |
| 991 | - $message = __( stripslashes_deep( get_option( 'geodir_post_submited_success_email_content_admin' ) ), 'geodirectory' ); | |
| 989 | +		if ($message_type == 'post_submit') {
 | |
| 990 | +			$subject = __(stripslashes_deep(get_option('geodir_post_submited_success_email_subject_admin')), 'geodirectory');
 | |
| 991 | +			$message = __(stripslashes_deep(get_option('geodir_post_submited_success_email_content_admin')), 'geodirectory');
 | |
| 992 | 992 | |
| 993 | - $search_array = array( | |
| 993 | + $search_array = array( | |
| 994 | 994 | '[#listing_link#]', | 
| 995 | 995 | '[#site_name_url#]', | 
| 996 | 996 | '[#post_id#]', | 
| @@ -1022,7 +1022,7 @@ discard block | ||
| 1022 | 1022 | $user_login, | 
| 1023 | 1023 | $user_login | 
| 1024 | 1024 | ); | 
| 1025 | - $message = str_replace( $search_array, $replace_array, $message ); | |
| 1025 | + $message = str_replace($search_array, $replace_array, $message); | |
| 1026 | 1026 | |
| 1027 | 1027 | $search_array = array( | 
| 1028 | 1028 | '[#listing_link#]', | 
| @@ -1050,40 +1050,40 @@ discard block | ||
| 1050 | 1050 | $user_login, | 
| 1051 | 1051 | $user_login | 
| 1052 | 1052 | ); | 
| 1053 | - $subject = str_replace( $search_array, $replace_array, $subject ); | |
| 1053 | + $subject = str_replace($search_array, $replace_array, $subject); | |
| 1054 | 1054 | |
| 1055 | 1055 | $subject .= ' - ADMIN BCC COPY'; | 
| 1056 | 1056 | $admin_bcc = true; | 
| 1057 | 1057 | |
| 1058 | -		} elseif ( $message_type == 'registration' && get_option( 'geodir_bcc_new_user' ) ) {
 | |
| 1058 | +		} elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
 | |
| 1059 | 1059 | $subject .= ' - ADMIN BCC COPY'; | 
| 1060 | 1060 | $admin_bcc = true; | 
| 1061 | -		} elseif ( $message_type == 'send_friend' && get_option( 'geodir_bcc_friend' ) ) {
 | |
| 1061 | +		} elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
 | |
| 1062 | 1062 | $subject .= ' - ADMIN BCC COPY'; | 
| 1063 | 1063 | $admin_bcc = true; | 
| 1064 | -		} elseif ( $message_type == 'send_enquiry' && get_option( 'geodir_bcc_enquiry' ) ) {
 | |
| 1064 | +		} elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
 | |
| 1065 | 1065 | $subject .= ' - ADMIN BCC COPY'; | 
| 1066 | 1066 | $admin_bcc = true; | 
| 1067 | -		} elseif ( $message_type == 'listing_published' && get_option( 'geodir_bcc_listing_published' ) ) {
 | |
| 1067 | +		} elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
 | |
| 1068 | 1068 | $subject .= ' - ADMIN BCC COPY'; | 
| 1069 | 1069 | $admin_bcc = true; | 
| 1070 | 1070 | } | 
| 1071 | 1071 | |
| 1072 | -		if ( $admin_bcc === true ) {
 | |
| 1073 | - $sent = wp_mail( $to, $subject, $message, $headers ); | |
| 1072 | +		if ($admin_bcc === true) {
 | |
| 1073 | + $sent = wp_mail($to, $subject, $message, $headers); | |
| 1074 | 1074 | |
| 1075 | -			if ( ! $sent ) {
 | |
| 1076 | -				if ( is_array( $to ) ) {
 | |
| 1077 | - $to = implode( ',', $to ); | |
| 1075 | +			if (!$sent) {
 | |
| 1076 | +				if (is_array($to)) {
 | |
| 1077 | +					$to = implode(',', $to);
 | |
| 1078 | 1078 | } | 
| 1079 | 1079 | $log_message = sprintf( | 
| 1080 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), | |
| 1080 | +					__("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
 | |
| 1081 | 1081 | $message_type, | 
| 1082 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), | |
| 1082 | +					date_i18n('F j Y H:i:s', current_time('timestamp')),
 | |
| 1083 | 1083 | $to, | 
| 1084 | 1084 | $subject | 
| 1085 | 1085 | ); | 
| 1086 | - geodir_error_log( $log_message ); | |
| 1086 | + geodir_error_log($log_message); | |
| 1087 | 1087 | } | 
| 1088 | 1088 | } | 
| 1089 | 1089 | |
| @@ -1099,58 +1099,58 @@ discard block | ||
| 1099 | 1099 | */ | 
| 1100 | 1100 |  function geodir_taxonomy_breadcrumb() {
 | 
| 1101 | 1101 | |
| 1102 | - $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); | |
| 1102 | +	$term   = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
 | |
| 1103 | 1103 | $parent = $term->parent; | 
| 1104 | 1104 | |
| 1105 | - while ( $parent ): | |
| 1105 | + while ($parent): | |
| 1106 | 1106 | $parents[] = $parent; | 
| 1107 | - $new_parent = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ) ); | |
| 1107 | +		$new_parent = get_term_by('id', $parent, get_query_var('taxonomy'));
 | |
| 1108 | 1108 | $parent = $new_parent->parent; | 
| 1109 | 1109 | endwhile; | 
| 1110 | 1110 | |
| 1111 | - if ( ! empty( $parents ) ): | |
| 1112 | - $parents = array_reverse( $parents ); | |
| 1111 | + if (!empty($parents)): | |
| 1112 | + $parents = array_reverse($parents); | |
| 1113 | 1113 | |
| 1114 | - foreach ( $parents as $parent ): | |
| 1115 | - $item = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ) ); | |
| 1116 | - $url = get_term_link( $item, get_query_var( 'taxonomy' ) ); | |
| 1117 | - echo '<li> > <a href="' . $url . '">' . $item->name . '</a></li>'; | |
| 1114 | + foreach ($parents as $parent): | |
| 1115 | +			$item = get_term_by('id', $parent, get_query_var('taxonomy'));
 | |
| 1116 | +			$url  = get_term_link($item, get_query_var('taxonomy'));
 | |
| 1117 | + echo '<li> > <a href="'.$url.'">'.$item->name.'</a></li>'; | |
| 1118 | 1118 | endforeach; | 
| 1119 | 1119 | |
| 1120 | 1120 | endif; | 
| 1121 | 1121 | |
| 1122 | - echo '<li> > ' . $term->name . '</li>'; | |
| 1122 | + echo '<li> > '.$term->name.'</li>'; | |
| 1123 | 1123 | } | 
| 1124 | 1124 | |
| 1125 | -function geodir_wpml_post_type_archive_link($link, $post_type){
 | |
| 1125 | +function geodir_wpml_post_type_archive_link($link, $post_type) {
 | |
| 1126 | 1126 | |
| 1127 | -	if(function_exists('icl_object_id')) {
 | |
| 1128 | - $post_types = get_option( 'geodir_post_types' ); | |
| 1129 | - $slug = $post_types[ $post_type ]['rewrite']['slug']; | |
| 1127 | +	if (function_exists('icl_object_id')) {
 | |
| 1128 | +		$post_types   = get_option('geodir_post_types');
 | |
| 1129 | + $slug = $post_types[$post_type]['rewrite']['slug']; | |
| 1130 | 1130 | |
| 1131 | - echo $link.'###'.gd_wpml_get_lang_from_url( $link) ; | |
| 1131 | + echo $link.'###'.gd_wpml_get_lang_from_url($link); | |
| 1132 | 1132 | |
| 1133 | 1133 | // Alter the CPT slug if WPML is set to do so | 
| 1134 | -		if ( function_exists( 'icl_object_id' ) ) {
 | |
| 1135 | -			if ( gd_wpml_slug_translation_turned_on( $post_type ) && $language_code = gd_wpml_get_lang_from_url( $link) ) {
 | |
| 1134 | +		if (function_exists('icl_object_id')) {
 | |
| 1135 | +			if (gd_wpml_slug_translation_turned_on($post_type) && $language_code = gd_wpml_get_lang_from_url($link)) {
 | |
| 1136 | 1136 | |
| 1137 | 1137 | $org_slug = $slug; | 
| 1138 | - $slug = apply_filters( 'wpml_translate_single_string', | |
| 1138 | +				$slug     = apply_filters('wpml_translate_single_string',
 | |
| 1139 | 1139 | $slug, | 
| 1140 | 1140 | 'WordPress', | 
| 1141 | - 'URL slug: ' . $slug, | |
| 1142 | - $language_code ); | |
| 1141 | + 'URL slug: '.$slug, | |
| 1142 | + $language_code); | |
| 1143 | 1143 | |
| 1144 | -				if ( ! $slug ) {
 | |
| 1144 | +				if (!$slug) {
 | |
| 1145 | 1145 | $slug = $org_slug; | 
| 1146 | 1146 |  				} else {
 | 
| 1147 | - $link = str_replace( $org_slug, $slug, $link ); | |
| 1147 | + $link = str_replace($org_slug, $slug, $link); | |
| 1148 | 1148 | } | 
| 1149 | 1149 | |
| 1150 | 1150 | } | 
| 1151 | 1151 | } | 
| 1152 | 1152 | |
| 1153 | - echo $link.'####'.gd_wpml_get_lang_from_url( $link) ; | |
| 1153 | + echo $link.'####'.gd_wpml_get_lang_from_url($link); | |
| 1154 | 1154 | } | 
| 1155 | 1155 | |
| 1156 | 1156 | return $link; | 
| @@ -1175,9 +1175,9 @@ discard block | ||
| 1175 | 1175 | * | 
| 1176 | 1176 | * @since 1.0.0 | 
| 1177 | 1177 | */ | 
| 1178 | - $separator = apply_filters( 'geodir_breadcrumb_separator', ' > ' ); | |
| 1178 | +	$separator = apply_filters('geodir_breadcrumb_separator', ' > ');
 | |
| 1179 | 1179 | |
| 1180 | -	if ( ! geodir_is_page( 'home' ) ) {
 | |
| 1180 | +	if (!geodir_is_page('home')) {
 | |
| 1181 | 1181 | $breadcrumb = ''; | 
| 1182 | 1182 | $url_categoris = ''; | 
| 1183 | 1183 | $breadcrumb .= '<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">'; | 
| @@ -1186,162 +1186,162 @@ discard block | ||
| 1186 | 1186 | * | 
| 1187 | 1187 | * @since 1.0.0 | 
| 1188 | 1188 | */ | 
| 1189 | - $breadcrumb .= '<li>' . apply_filters( 'geodir_breadcrumb_first_link', '<a href="' . home_url() . '">' . __( 'Home', 'geodirectory' ) . '</a>' ) . '</li>'; | |
| 1189 | +		$breadcrumb .= '<li>'.apply_filters('geodir_breadcrumb_first_link', '<a href="'.home_url().'">'.__('Home', 'geodirectory').'</a>').'</li>';
 | |
| 1190 | 1190 | |
| 1191 | 1191 | $gd_post_type = geodir_get_current_posttype(); | 
| 1192 | - $post_type_info = get_post_type_object( $gd_post_type ); | |
| 1192 | + $post_type_info = get_post_type_object($gd_post_type); | |
| 1193 | 1193 | |
| 1194 | - remove_filter( 'post_type_archive_link', 'geodir_get_posttype_link' ); | |
| 1194 | +		remove_filter('post_type_archive_link', 'geodir_get_posttype_link');
 | |
| 1195 | 1195 | |
| 1196 | - $listing_link = get_post_type_archive_link( $gd_post_type ); | |
| 1196 | + $listing_link = get_post_type_archive_link($gd_post_type); | |
| 1197 | 1197 | |
| 1198 | - add_filter( 'post_type_archive_link', 'geodir_get_posttype_link', 10, 2 ); | |
| 1199 | - $listing_link = rtrim( $listing_link, '/' ); | |
| 1198 | +		add_filter('post_type_archive_link', 'geodir_get_posttype_link', 10, 2);
 | |
| 1199 | + $listing_link = rtrim($listing_link, '/'); | |
| 1200 | 1200 | $listing_link .= '/'; | 
| 1201 | 1201 | |
| 1202 | 1202 | $post_type_for_location_link = $listing_link; | 
| 1203 | - $location_terms = geodir_get_current_location_terms( 'query_vars', $gd_post_type ); | |
| 1203 | +		$location_terms              = geodir_get_current_location_terms('query_vars', $gd_post_type);
 | |
| 1204 | 1204 | |
| 1205 | 1205 | global $wp, $gd_session; | 
| 1206 | 1206 | $location_link = $post_type_for_location_link; | 
| 1207 | 1207 | |
| 1208 | -		if ( geodir_is_page( 'detail' ) || geodir_is_page( 'listing' ) ) {
 | |
| 1208 | +		if (geodir_is_page('detail') || geodir_is_page('listing')) {
 | |
| 1209 | 1209 | global $post; | 
| 1210 | - $location_manager = defined( 'POST_LOCATION_TABLE' ) ? true : false; | |
| 1211 | - $neighbourhood_active = $location_manager && get_option( 'location_neighbourhoods' ) ? true : false; | |
| 1210 | +			$location_manager     = defined('POST_LOCATION_TABLE') ? true : false;
 | |
| 1211 | +			$neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
 | |
| 1212 | 1212 | |
| 1213 | -			if ( geodir_is_page( 'detail' ) && isset( $post->country_slug ) ) {
 | |
| 1213 | +			if (geodir_is_page('detail') && isset($post->country_slug)) {
 | |
| 1214 | 1214 | $location_terms = array( | 
| 1215 | 1215 | 'gd_country' => $post->country_slug, | 
| 1216 | 1216 | 'gd_region' => $post->region_slug, | 
| 1217 | 1217 | 'gd_city' => $post->city_slug | 
| 1218 | 1218 | ); | 
| 1219 | 1219 | |
| 1220 | -				if ( $neighbourhood_active && ! empty( $location_terms['gd_city'] ) && $gd_ses_neighbourhood = $gd_session->get( 'gd_neighbourhood' ) ) {
 | |
| 1220 | +				if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
 | |
| 1221 | 1221 | $location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood; | 
| 1222 | 1222 | } | 
| 1223 | 1223 | } | 
| 1224 | 1224 | |
| 1225 | - $geodir_show_location_url = get_option( 'geodir_show_location_url' ); | |
| 1225 | +			$geodir_show_location_url = get_option('geodir_show_location_url');
 | |
| 1226 | 1226 | |
| 1227 | 1227 | $hide_url_part = array(); | 
| 1228 | -			if ( $location_manager ) {
 | |
| 1229 | - $hide_country_part = get_option( 'geodir_location_hide_country_part' ); | |
| 1230 | - $hide_region_part = get_option( 'geodir_location_hide_region_part' ); | |
| 1231 | - | |
| 1232 | -				if ( $hide_region_part && $hide_country_part ) {
 | |
| 1233 | - $hide_url_part = array( 'gd_country', 'gd_region' ); | |
| 1234 | -				} else if ( $hide_region_part && ! $hide_country_part ) {
 | |
| 1235 | - $hide_url_part = array( 'gd_region' ); | |
| 1236 | -				} else if ( ! $hide_region_part && $hide_country_part ) {
 | |
| 1237 | - $hide_url_part = array( 'gd_country' ); | |
| 1228 | +			if ($location_manager) {
 | |
| 1229 | +				$hide_country_part = get_option('geodir_location_hide_country_part');
 | |
| 1230 | +				$hide_region_part  = get_option('geodir_location_hide_region_part');
 | |
| 1231 | + | |
| 1232 | +				if ($hide_region_part && $hide_country_part) {
 | |
| 1233 | +					$hide_url_part = array('gd_country', 'gd_region');
 | |
| 1234 | +				} else if ($hide_region_part && !$hide_country_part) {
 | |
| 1235 | +					$hide_url_part = array('gd_region');
 | |
| 1236 | +				} else if (!$hide_region_part && $hide_country_part) {
 | |
| 1237 | +					$hide_url_part = array('gd_country');
 | |
| 1238 | 1238 | } | 
| 1239 | 1239 | } | 
| 1240 | 1240 | |
| 1241 | 1241 | $hide_text_part = array(); | 
| 1242 | -			if ( $geodir_show_location_url == 'country_city' ) {
 | |
| 1243 | - $hide_text_part = array( 'gd_region' ); | |
| 1242 | +			if ($geodir_show_location_url == 'country_city') {
 | |
| 1243 | +				$hide_text_part = array('gd_region');
 | |
| 1244 | 1244 | |
| 1245 | -				if ( isset( $location_terms['gd_region'] ) && ! $location_manager ) {
 | |
| 1246 | - unset( $location_terms['gd_region'] ); | |
| 1245 | +				if (isset($location_terms['gd_region']) && !$location_manager) {
 | |
| 1246 | + unset($location_terms['gd_region']); | |
| 1247 | 1247 | } | 
| 1248 | -			} else if ( $geodir_show_location_url == 'region_city' ) {
 | |
| 1249 | - $hide_text_part = array( 'gd_country' ); | |
| 1248 | +			} else if ($geodir_show_location_url == 'region_city') {
 | |
| 1249 | +				$hide_text_part = array('gd_country');
 | |
| 1250 | 1250 | |
| 1251 | -				if ( isset( $location_terms['gd_country'] ) && ! $location_manager ) {
 | |
| 1252 | - unset( $location_terms['gd_country'] ); | |
| 1251 | +				if (isset($location_terms['gd_country']) && !$location_manager) {
 | |
| 1252 | + unset($location_terms['gd_country']); | |
| 1253 | 1253 | } | 
| 1254 | -			} else if ( $geodir_show_location_url == 'city' ) {
 | |
| 1255 | - $hide_text_part = array( 'gd_country', 'gd_region' ); | |
| 1254 | +			} else if ($geodir_show_location_url == 'city') {
 | |
| 1255 | +				$hide_text_part = array('gd_country', 'gd_region');
 | |
| 1256 | 1256 | |
| 1257 | -				if ( isset( $location_terms['gd_country'] ) && ! $location_manager ) {
 | |
| 1258 | - unset( $location_terms['gd_country'] ); | |
| 1257 | +				if (isset($location_terms['gd_country']) && !$location_manager) {
 | |
| 1258 | + unset($location_terms['gd_country']); | |
| 1259 | 1259 | } | 
| 1260 | -				if ( isset( $location_terms['gd_region'] ) && ! $location_manager ) {
 | |
| 1261 | - unset( $location_terms['gd_region'] ); | |
| 1260 | +				if (isset($location_terms['gd_region']) && !$location_manager) {
 | |
| 1261 | + unset($location_terms['gd_region']); | |
| 1262 | 1262 | } | 
| 1263 | 1263 | } | 
| 1264 | 1264 | |
| 1265 | 1265 | $is_location_last = ''; | 
| 1266 | 1266 | $is_taxonomy_last = ''; | 
| 1267 | 1267 | $breadcrumb .= '<li>'; | 
| 1268 | -			if ( get_query_var( $gd_post_type . 'category' ) ) {
 | |
| 1269 | - $gd_taxonomy = $gd_post_type . 'category'; | |
| 1270 | -			} elseif ( get_query_var( $gd_post_type . '_tags' ) ) {
 | |
| 1271 | - $gd_taxonomy = $gd_post_type . '_tags'; | |
| 1268 | +			if (get_query_var($gd_post_type.'category')) {
 | |
| 1269 | + $gd_taxonomy = $gd_post_type.'category'; | |
| 1270 | +			} elseif (get_query_var($gd_post_type.'_tags')) {
 | |
| 1271 | + $gd_taxonomy = $gd_post_type.'_tags'; | |
| 1272 | 1272 | } | 
| 1273 | 1273 | |
| 1274 | - $breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __( ucfirst( $post_type_info->label ), 'geodirectory' ) . '</a>'; | |
| 1275 | -			if ( ! empty( $gd_taxonomy ) || geodir_is_page( 'detail' ) ) {
 | |
| 1274 | + $breadcrumb .= $separator.'<a href="'.$listing_link.'">'.__(ucfirst($post_type_info->label), 'geodirectory').'</a>'; | |
| 1275 | +			if (!empty($gd_taxonomy) || geodir_is_page('detail')) {
 | |
| 1276 | 1276 | $is_location_last = false; | 
| 1277 | 1277 |  			} else {
 | 
| 1278 | 1278 | $is_location_last = true; | 
| 1279 | 1279 | } | 
| 1280 | 1280 | |
| 1281 | -			if ( ! empty( $gd_taxonomy ) && geodir_is_page( 'listing' ) ) {
 | |
| 1281 | +			if (!empty($gd_taxonomy) && geodir_is_page('listing')) {
 | |
| 1282 | 1282 | $is_taxonomy_last = true; | 
| 1283 | 1283 |  			} else {
 | 
| 1284 | 1284 | $is_taxonomy_last = false; | 
| 1285 | 1285 | } | 
| 1286 | 1286 | |
| 1287 | -			if ( ! empty( $location_terms ) ) {
 | |
| 1288 | - $geodir_get_locations = function_exists( 'get_actual_location_name' ) ? true : false; | |
| 1287 | +			if (!empty($location_terms)) {
 | |
| 1288 | +				$geodir_get_locations = function_exists('get_actual_location_name') ? true : false;
 | |
| 1289 | 1289 | |
| 1290 | -				foreach ( $location_terms as $key => $location_term ) {
 | |
| 1291 | -					if ( $location_term != '' ) {
 | |
| 1292 | -						if ( ! empty( $hide_url_part ) && in_array( $key, $hide_url_part ) ) { // Hide location part from url & breadcrumb.
 | |
| 1290 | +				foreach ($location_terms as $key => $location_term) {
 | |
| 1291 | +					if ($location_term != '') {
 | |
| 1292 | +						if (!empty($hide_url_part) && in_array($key, $hide_url_part)) { // Hide location part from url & breadcrumb.
 | |
| 1293 | 1293 | continue; | 
| 1294 | 1294 | } | 
| 1295 | 1295 | |
| 1296 | - $gd_location_link_text = preg_replace( '/-(\d+)$/', '', $location_term ); | |
| 1297 | - $gd_location_link_text = preg_replace( '/[_-]/', ' ', $gd_location_link_text ); | |
| 1298 | - $gd_location_link_text = ucfirst( $gd_location_link_text ); | |
| 1296 | +						$gd_location_link_text = preg_replace('/-(\d+)$/', '', $location_term);
 | |
| 1297 | +						$gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
 | |
| 1298 | + $gd_location_link_text = ucfirst($gd_location_link_text); | |
| 1299 | 1299 | |
| 1300 | 1300 | $location_term_actual_country = ''; | 
| 1301 | 1301 | $location_term_actual_region = ''; | 
| 1302 | 1302 | $location_term_actual_city = ''; | 
| 1303 | -						if ( $geodir_get_locations ) {
 | |
| 1304 | -							if ( $key == 'gd_country' ) {
 | |
| 1305 | - $location_term_actual_country = get_actual_location_name( 'country', $location_term, true ); | |
| 1306 | -							} else if ( $key == 'gd_region' ) {
 | |
| 1307 | - $location_term_actual_region = get_actual_location_name( 'region', $location_term, true ); | |
| 1308 | -							} else if ( $key == 'gd_city' ) {
 | |
| 1309 | - $location_term_actual_city = get_actual_location_name( 'city', $location_term, true ); | |
| 1303 | +						if ($geodir_get_locations) {
 | |
| 1304 | +							if ($key == 'gd_country') {
 | |
| 1305 | +								$location_term_actual_country = get_actual_location_name('country', $location_term, true);
 | |
| 1306 | +							} else if ($key == 'gd_region') {
 | |
| 1307 | +								$location_term_actual_region = get_actual_location_name('region', $location_term, true);
 | |
| 1308 | +							} else if ($key == 'gd_city') {
 | |
| 1309 | +								$location_term_actual_city = get_actual_location_name('city', $location_term, true);
 | |
| 1310 | 1310 | } | 
| 1311 | 1311 |  						} else {
 | 
| 1312 | 1312 | $location_info = geodir_get_location(); | 
| 1313 | 1313 | |
| 1314 | -							if ( ! empty( $location_info ) && isset( $location_info->location_id ) ) {
 | |
| 1315 | -								if ( $key == 'gd_country' ) {
 | |
| 1316 | - $location_term_actual_country = __( $location_info->country, 'geodirectory' ); | |
| 1317 | -								} else if ( $key == 'gd_region' ) {
 | |
| 1318 | - $location_term_actual_region = __( $location_info->region, 'geodirectory' ); | |
| 1319 | -								} else if ( $key == 'gd_city' ) {
 | |
| 1320 | - $location_term_actual_city = __( $location_info->city, 'geodirectory' ); | |
| 1314 | +							if (!empty($location_info) && isset($location_info->location_id)) {
 | |
| 1315 | +								if ($key == 'gd_country') {
 | |
| 1316 | + $location_term_actual_country = __($location_info->country, 'geodirectory'); | |
| 1317 | +								} else if ($key == 'gd_region') {
 | |
| 1318 | + $location_term_actual_region = __($location_info->region, 'geodirectory'); | |
| 1319 | +								} else if ($key == 'gd_city') {
 | |
| 1320 | + $location_term_actual_city = __($location_info->city, 'geodirectory'); | |
| 1321 | 1321 | } | 
| 1322 | 1322 | } | 
| 1323 | 1323 | } | 
| 1324 | 1324 | |
| 1325 | -						if ( $is_location_last && $key == 'gd_country' && ! ( isset( $location_terms['gd_region'] ) && $location_terms['gd_region'] != '' ) && ! ( isset( $location_terms['gd_city'] ) && $location_terms['gd_city'] != '' ) ) {
 | |
| 1326 | - $breadcrumb .= $location_term_actual_country != '' ? $separator . $location_term_actual_country : $separator . $gd_location_link_text; | |
| 1327 | -						} else if ( $is_location_last && $key == 'gd_region' && ! ( isset( $location_terms['gd_city'] ) && $location_terms['gd_city'] != '' ) ) {
 | |
| 1328 | - $breadcrumb .= $location_term_actual_region != '' ? $separator . $location_term_actual_region : $separator . $gd_location_link_text; | |
| 1329 | -						} else if ( $is_location_last && $key == 'gd_city' && empty( $location_terms['gd_neighbourhood'] ) ) {
 | |
| 1330 | - $breadcrumb .= $location_term_actual_city != '' ? $separator . $location_term_actual_city : $separator . $gd_location_link_text; | |
| 1331 | -						} else if ( $is_location_last && $key == 'gd_neighbourhood' ) {
 | |
| 1332 | - $breadcrumb .= $separator . $gd_location_link_text; | |
| 1325 | +						if ($is_location_last && $key == 'gd_country' && !(isset($location_terms['gd_region']) && $location_terms['gd_region'] != '') && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
 | |
| 1326 | + $breadcrumb .= $location_term_actual_country != '' ? $separator.$location_term_actual_country : $separator.$gd_location_link_text; | |
| 1327 | +						} else if ($is_location_last && $key == 'gd_region' && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
 | |
| 1328 | + $breadcrumb .= $location_term_actual_region != '' ? $separator.$location_term_actual_region : $separator.$gd_location_link_text; | |
| 1329 | +						} else if ($is_location_last && $key == 'gd_city' && empty($location_terms['gd_neighbourhood'])) {
 | |
| 1330 | + $breadcrumb .= $location_term_actual_city != '' ? $separator.$location_term_actual_city : $separator.$gd_location_link_text; | |
| 1331 | +						} else if ($is_location_last && $key == 'gd_neighbourhood') {
 | |
| 1332 | + $breadcrumb .= $separator.$gd_location_link_text; | |
| 1333 | 1333 |  						} else {
 | 
| 1334 | -							if ( get_option( 'permalink_structure' ) != '' ) {
 | |
| 1335 | - $location_link .= $location_term . '/'; | |
| 1334 | +							if (get_option('permalink_structure') != '') {
 | |
| 1335 | + $location_link .= $location_term.'/'; | |
| 1336 | 1336 |  							} else {
 | 
| 1337 | - $location_link .= "&$key=" . $location_term; | |
| 1337 | + $location_link .= "&$key=".$location_term; | |
| 1338 | 1338 | } | 
| 1339 | 1339 | |
| 1340 | -							if ( $key == 'gd_country' && $location_term_actual_country != '' ) {
 | |
| 1340 | +							if ($key == 'gd_country' && $location_term_actual_country != '') {
 | |
| 1341 | 1341 | $gd_location_link_text = $location_term_actual_country; | 
| 1342 | -							} else if ( $key == 'gd_region' && $location_term_actual_region != '' ) {
 | |
| 1342 | +							} else if ($key == 'gd_region' && $location_term_actual_region != '') {
 | |
| 1343 | 1343 | $gd_location_link_text = $location_term_actual_region; | 
| 1344 | -							} else if ( $key == 'gd_city' && $location_term_actual_city != '' ) {
 | |
| 1344 | +							} else if ($key == 'gd_city' && $location_term_actual_city != '') {
 | |
| 1345 | 1345 | $gd_location_link_text = $location_term_actual_city; | 
| 1346 | 1346 | } | 
| 1347 | 1347 | |
| @@ -1351,76 +1351,76 @@ discard block | ||
| 1351 | 1351 | } | 
| 1352 | 1352 | */ | 
| 1353 | 1353 | |
| 1354 | - $breadcrumb .= $separator . '<a href="' . $location_link . '">' . $gd_location_link_text . '</a>'; | |
| 1354 | + $breadcrumb .= $separator.'<a href="'.$location_link.'">'.$gd_location_link_text.'</a>'; | |
| 1355 | 1355 | } | 
| 1356 | 1356 | } | 
| 1357 | 1357 | } | 
| 1358 | 1358 | } | 
| 1359 | 1359 | |
| 1360 | -			if ( ! empty( $gd_taxonomy ) ) {
 | |
| 1360 | +			if (!empty($gd_taxonomy)) {
 | |
| 1361 | 1361 | $term_index = 1; | 
| 1362 | 1362 | |
| 1363 | 1363 |  				//if(get_option('geodir_add_categories_url'))
 | 
| 1364 | 1364 |  				{
 | 
| 1365 | -					if ( get_query_var( $gd_post_type . '_tags' ) ) {
 | |
| 1366 | - $cat_link = $listing_link . 'tags/'; | |
| 1365 | +					if (get_query_var($gd_post_type.'_tags')) {
 | |
| 1366 | + $cat_link = $listing_link.'tags/'; | |
| 1367 | 1367 |  					} else {
 | 
| 1368 | 1368 | $cat_link = $listing_link; | 
| 1369 | 1369 | } | 
| 1370 | 1370 | |
| 1371 | -					foreach ( $location_terms as $key => $location_term ) {
 | |
| 1372 | -						if ( $location_manager && in_array( $key, $hide_url_part ) ) {
 | |
| 1371 | +					foreach ($location_terms as $key => $location_term) {
 | |
| 1372 | +						if ($location_manager && in_array($key, $hide_url_part)) {
 | |
| 1373 | 1373 | continue; | 
| 1374 | 1374 | } | 
| 1375 | 1375 | |
| 1376 | -						if ( $location_term != '' ) {
 | |
| 1377 | -							if ( get_option( 'permalink_structure' ) != '' ) {
 | |
| 1378 | - $cat_link .= $location_term . '/'; | |
| 1376 | +						if ($location_term != '') {
 | |
| 1377 | +							if (get_option('permalink_structure') != '') {
 | |
| 1378 | + $cat_link .= $location_term.'/'; | |
| 1379 | 1379 | } | 
| 1380 | 1380 | } | 
| 1381 | 1381 | } | 
| 1382 | 1382 | |
| 1383 | - $term_array = explode( "/", trim( $wp_query->query[ $gd_taxonomy ], "/" ) ); | |
| 1384 | -					foreach ( $term_array as $term ) {
 | |
| 1385 | - $term_link_text = preg_replace( '/-(\d+)$/', '', $term ); | |
| 1386 | - $term_link_text = preg_replace( '/[_-]/', ' ', $term_link_text ); | |
| 1383 | +					$term_array = explode("/", trim($wp_query->query[$gd_taxonomy], "/"));
 | |
| 1384 | +					foreach ($term_array as $term) {
 | |
| 1385 | +						$term_link_text = preg_replace('/-(\d+)$/', '', $term);
 | |
| 1386 | +						$term_link_text = preg_replace('/[_-]/', ' ', $term_link_text);
 | |
| 1387 | 1387 | |
| 1388 | 1388 | // get term actual name | 
| 1389 | - $term_info = get_term_by( 'slug', $term, $gd_taxonomy, 'ARRAY_A' ); | |
| 1390 | -						if ( ! empty( $term_info ) && isset( $term_info['name'] ) && $term_info['name'] != '' ) {
 | |
| 1391 | - $term_link_text = urldecode( $term_info['name'] ); | |
| 1389 | +						$term_info = get_term_by('slug', $term, $gd_taxonomy, 'ARRAY_A');
 | |
| 1390 | +						if (!empty($term_info) && isset($term_info['name']) && $term_info['name'] != '') {
 | |
| 1391 | + $term_link_text = urldecode($term_info['name']); | |
| 1392 | 1392 |  						} else {
 | 
| 1393 | 1393 | continue; | 
| 1394 | 1394 | //$term_link_text = wp_strip_all_tags(geodir_ucwords(urldecode($term_link_text))); | 
| 1395 | 1395 | } | 
| 1396 | 1396 | |
| 1397 | -						if ( $term_index == count( $term_array ) && $is_taxonomy_last ) {
 | |
| 1398 | - $breadcrumb .= $separator . $term_link_text; | |
| 1397 | +						if ($term_index == count($term_array) && $is_taxonomy_last) {
 | |
| 1398 | + $breadcrumb .= $separator.$term_link_text; | |
| 1399 | 1399 |  						} else {
 | 
| 1400 | - $cat_link .= $term . '/'; | |
| 1401 | - $breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>'; | |
| 1400 | + $cat_link .= $term.'/'; | |
| 1401 | + $breadcrumb .= $separator.'<a href="'.$cat_link.'">'.$term_link_text.'</a>'; | |
| 1402 | 1402 | } | 
| 1403 | - $term_index ++; | |
| 1403 | + $term_index++; | |
| 1404 | 1404 | } | 
| 1405 | 1405 | } | 
| 1406 | 1406 | |
| 1407 | 1407 | |
| 1408 | 1408 | } | 
| 1409 | 1409 | |
| 1410 | -			if ( geodir_is_page( 'detail' ) ) {
 | |
| 1411 | - $breadcrumb .= $separator . get_the_title(); | |
| 1410 | +			if (geodir_is_page('detail')) {
 | |
| 1411 | + $breadcrumb .= $separator.get_the_title(); | |
| 1412 | 1412 | } | 
| 1413 | 1413 | |
| 1414 | 1414 | $breadcrumb .= '</li>'; | 
| 1415 | 1415 | |
| 1416 | 1416 | |
| 1417 | -		} elseif ( geodir_is_page( 'author' ) ) {
 | |
| 1417 | +		} elseif (geodir_is_page('author')) {
 | |
| 1418 | 1418 | $user_id = get_current_user_id(); | 
| 1419 | - $author_link = get_author_posts_url( $user_id ); | |
| 1420 | - $default_author_link = geodir_getlink( $author_link, array( | |
| 1419 | + $author_link = get_author_posts_url($user_id); | |
| 1420 | + $default_author_link = geodir_getlink($author_link, array( | |
| 1421 | 1421 | 'geodir_dashbord' => 'true', | 
| 1422 | 1422 | 'stype' => 'gd_place' | 
| 1423 | - ), false ); | |
| 1423 | + ), false); | |
| 1424 | 1424 | |
| 1425 | 1425 | /** | 
| 1426 | 1426 | * Filter author page link. | 
| @@ -1430,16 +1430,16 @@ discard block | ||
| 1430 | 1430 | * @param string $default_author_link Default author link. | 
| 1431 | 1431 | * @param int $user_id Author ID. | 
| 1432 | 1432 | */ | 
| 1433 | - $default_author_link = apply_filters( 'geodir_dashboard_author_link', $default_author_link, $user_id ); | |
| 1433 | +			$default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_id);
 | |
| 1434 | 1434 | |
| 1435 | 1435 | $breadcrumb .= '<li>'; | 
| 1436 | - $breadcrumb .= $separator . '<a href="' . $default_author_link . '">' . __( 'My Dashboard', 'geodirectory' ) . '</a>'; | |
| 1436 | +			$breadcrumb .= $separator.'<a href="'.$default_author_link.'">'.__('My Dashboard', 'geodirectory').'</a>';
 | |
| 1437 | 1437 | |
| 1438 | -			if ( isset( $_REQUEST['list'] ) ) {
 | |
| 1439 | - $author_link = geodir_getlink( $author_link, array( | |
| 1438 | +			if (isset($_REQUEST['list'])) {
 | |
| 1439 | + $author_link = geodir_getlink($author_link, array( | |
| 1440 | 1440 | 'geodir_dashbord' => 'true', | 
| 1441 | 1441 | 'stype' => $_REQUEST['stype'] | 
| 1442 | - ), false ); | |
| 1442 | + ), false); | |
| 1443 | 1443 | |
| 1444 | 1444 | /** | 
| 1445 | 1445 | * Filter author page link. | 
| @@ -1450,61 +1450,61 @@ discard block | ||
| 1450 | 1450 | * @param int $user_id Author ID. | 
| 1451 | 1451 | * @param string $_REQUEST ['stype'] Post type. | 
| 1452 | 1452 | */ | 
| 1453 | - $author_link = apply_filters( 'geodir_dashboard_author_link', $author_link, $user_id, $_REQUEST['stype'] ); | |
| 1453 | +				$author_link = apply_filters('geodir_dashboard_author_link', $author_link, $user_id, $_REQUEST['stype']);
 | |
| 1454 | 1454 | |
| 1455 | - $breadcrumb .= $separator . '<a href="' . $author_link . '">' . __( ucfirst( $post_type_info->label ), 'geodirectory' ) . '</a>'; | |
| 1456 | - $breadcrumb .= $separator . ucfirst( __( 'My', 'geodirectory' ) . ' ' . $_REQUEST['list'] ); | |
| 1455 | + $breadcrumb .= $separator.'<a href="'.$author_link.'">'.__(ucfirst($post_type_info->label), 'geodirectory').'</a>'; | |
| 1456 | +				$breadcrumb .= $separator.ucfirst(__('My', 'geodirectory').' '.$_REQUEST['list']);
 | |
| 1457 | 1457 |  			} else {
 | 
| 1458 | - $breadcrumb .= $separator . __( ucfirst( $post_type_info->label ), 'geodirectory' ); | |
| 1458 | + $breadcrumb .= $separator.__(ucfirst($post_type_info->label), 'geodirectory'); | |
| 1459 | 1459 | } | 
| 1460 | 1460 | |
| 1461 | 1461 | $breadcrumb .= '</li>'; | 
| 1462 | -		} elseif ( is_category() || is_single() ) {
 | |
| 1462 | +		} elseif (is_category() || is_single()) {
 | |
| 1463 | 1463 | $category = get_the_category(); | 
| 1464 | -			if ( is_category() ) {
 | |
| 1465 | - $breadcrumb .= '<li>' . $separator . $category[0]->cat_name . '</li>'; | |
| 1464 | +			if (is_category()) {
 | |
| 1465 | + $breadcrumb .= '<li>'.$separator.$category[0]->cat_name.'</li>'; | |
| 1466 | 1466 | } | 
| 1467 | -			if ( is_single() ) {
 | |
| 1468 | - $breadcrumb .= '<li>' . $separator . '<a href="' . get_category_link( $category[0]->term_id ) . '">' . $category[0]->cat_name . '</a></li>'; | |
| 1469 | - $breadcrumb .= '<li>' . $separator . get_the_title() . '</li>'; | |
| 1467 | +			if (is_single()) {
 | |
| 1468 | + $breadcrumb .= '<li>'.$separator.'<a href="'.get_category_link($category[0]->term_id).'">'.$category[0]->cat_name.'</a></li>'; | |
| 1469 | + $breadcrumb .= '<li>'.$separator.get_the_title().'</li>'; | |
| 1470 | 1470 | } | 
| 1471 | 1471 | /* End of my version ##################################################### */ | 
| 1472 | -		} else if ( is_page() ) {
 | |
| 1472 | +		} else if (is_page()) {
 | |
| 1473 | 1473 | $page_title = get_the_title(); | 
| 1474 | 1474 | |
| 1475 | -			if ( geodir_is_page( 'location' ) ) {
 | |
| 1475 | +			if (geodir_is_page('location')) {
 | |
| 1476 | 1476 | $location_page_id = geodir_location_page_id(); | 
| 1477 | - $loc_post = get_post( $location_page_id ); | |
| 1477 | + $loc_post = get_post($location_page_id); | |
| 1478 | 1478 | $post_name = $loc_post->post_name; | 
| 1479 | - $slug = ucwords( str_replace( '-', ' ', $post_name ) ); | |
| 1480 | - $page_title = ! empty( $slug ) ? $slug : __( 'Location', 'geodirectory' ); | |
| 1479 | +				$slug             = ucwords(str_replace('-', ' ', $post_name));
 | |
| 1480 | +				$page_title       = !empty($slug) ? $slug : __('Location', 'geodirectory');
 | |
| 1481 | 1481 | } | 
| 1482 | 1482 | |
| 1483 | - $breadcrumb .= '<li>' . $separator; | |
| 1484 | - $breadcrumb .= stripslashes_deep( $page_title ); | |
| 1483 | + $breadcrumb .= '<li>'.$separator; | |
| 1484 | + $breadcrumb .= stripslashes_deep($page_title); | |
| 1485 | 1485 | $breadcrumb .= '</li>'; | 
| 1486 | -		} else if ( is_tag() ) {
 | |
| 1487 | - $breadcrumb .= "<li> " . $separator . single_tag_title( '', false ) . '</li>'; | |
| 1488 | -		} else if ( is_day() ) {
 | |
| 1489 | - $breadcrumb .= "<li> " . $separator . __( " Archive for", 'geodirectory' ) . " "; | |
| 1490 | - the_time( 'F jS, Y' ); | |
| 1486 | +		} else if (is_tag()) {
 | |
| 1487 | +			$breadcrumb .= "<li> ".$separator.single_tag_title('', false).'</li>';
 | |
| 1488 | +		} else if (is_day()) {
 | |
| 1489 | +			$breadcrumb .= "<li> ".$separator.__(" Archive for", 'geodirectory')." ";
 | |
| 1490 | +			the_time('F jS, Y');
 | |
| 1491 | 1491 | $breadcrumb .= '</li>'; | 
| 1492 | -		} else if ( is_month() ) {
 | |
| 1493 | - $breadcrumb .= "<li> " . $separator . __( " Archive for", 'geodirectory' ) . " "; | |
| 1494 | - the_time( 'F, Y' ); | |
| 1492 | +		} else if (is_month()) {
 | |
| 1493 | +			$breadcrumb .= "<li> ".$separator.__(" Archive for", 'geodirectory')." ";
 | |
| 1494 | +			the_time('F, Y');
 | |
| 1495 | 1495 | $breadcrumb .= '</li>'; | 
| 1496 | -		} else if ( is_year() ) {
 | |
| 1497 | - $breadcrumb .= "<li> " . $separator . __( " Archive for", 'geodirectory' ) . " "; | |
| 1498 | - the_time( 'Y' ); | |
| 1496 | +		} else if (is_year()) {
 | |
| 1497 | +			$breadcrumb .= "<li> ".$separator.__(" Archive for", 'geodirectory')." ";
 | |
| 1498 | +			the_time('Y');
 | |
| 1499 | 1499 | $breadcrumb .= '</li>'; | 
| 1500 | -		} else if ( is_author() ) {
 | |
| 1501 | - $breadcrumb .= "<li> " . $separator . __( " Author Archive", 'geodirectory' ); | |
| 1500 | +		} else if (is_author()) {
 | |
| 1501 | +			$breadcrumb .= "<li> ".$separator.__(" Author Archive", 'geodirectory');
 | |
| 1502 | 1502 | $breadcrumb .= '</li>'; | 
| 1503 | -		} else if ( isset( $_GET['paged'] ) && ! empty( $_GET['paged'] ) ) {
 | |
| 1504 | - $breadcrumb .= "<li>" . $separator . __( "Blog Archives", 'geodirectory' ); | |
| 1503 | +		} else if (isset($_GET['paged']) && !empty($_GET['paged'])) {
 | |
| 1504 | +			$breadcrumb .= "<li>".$separator.__("Blog Archives", 'geodirectory');
 | |
| 1505 | 1505 | $breadcrumb .= '</li>'; | 
| 1506 | -		} else if ( is_search() ) {
 | |
| 1507 | - $breadcrumb .= "<li> " . $separator . __( " Search Results", 'geodirectory' ); | |
| 1506 | +		} else if (is_search()) {
 | |
| 1507 | +			$breadcrumb .= "<li> ".$separator.__(" Search Results", 'geodirectory');
 | |
| 1508 | 1508 | $breadcrumb .= '</li>'; | 
| 1509 | 1509 | } | 
| 1510 | 1510 | $breadcrumb .= '</ul></div>'; | 
| @@ -1517,13 +1517,13 @@ discard block | ||
| 1517 | 1517 | * @param string $breadcrumb Breadcrumb HTML. | 
| 1518 | 1518 | * @param string $separator Breadcrumb separator. | 
| 1519 | 1519 | */ | 
| 1520 | - echo $breadcrumb = apply_filters( 'geodir_breadcrumb', $breadcrumb, $separator ); | |
| 1520 | +		echo $breadcrumb = apply_filters('geodir_breadcrumb', $breadcrumb, $separator);
 | |
| 1521 | 1521 | } | 
| 1522 | 1522 | } | 
| 1523 | 1523 | |
| 1524 | 1524 | |
| 1525 | -add_action( "admin_init", "geodir_allow_wpadmin" ); // check user is admin | |
| 1526 | -if ( ! function_exists( 'geodir_allow_wpadmin' ) ) {
 | |
| 1525 | +add_action("admin_init", "geodir_allow_wpadmin"); // check user is admin
 | |
| 1526 | +if (!function_exists('geodir_allow_wpadmin')) {
 | |
| 1527 | 1527 | /** | 
| 1528 | 1528 | * Allow only admins to access wp-admin. | 
| 1529 | 1529 | * | 
| @@ -1535,12 +1535,12 @@ discard block | ||
| 1535 | 1535 | */ | 
| 1536 | 1536 |  	function geodir_allow_wpadmin() {
 | 
| 1537 | 1537 | global $wpdb; | 
| 1538 | - if ( get_option( 'geodir_allow_wpadmin' ) == '0' && is_user_logged_in() && ( ! defined( 'DOING_AJAX' ) ) ) // checking action in request to allow ajax request go through | |
| 1538 | +		if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!defined('DOING_AJAX'))) // checking action in request to allow ajax request go through
 | |
| 1539 | 1539 |  		{
 | 
| 1540 | -			if ( current_user_can( 'administrator' ) ) {
 | |
| 1540 | +			if (current_user_can('administrator')) {
 | |
| 1541 | 1541 |  			} else {
 | 
| 1542 | 1542 | |
| 1543 | - wp_redirect( home_url() ); | |
| 1543 | + wp_redirect(home_url()); | |
| 1544 | 1544 | exit; | 
| 1545 | 1545 | } | 
| 1546 | 1546 | |
| @@ -1559,23 +1559,23 @@ discard block | ||
| 1559 | 1559 | * | 
| 1560 | 1560 | * @return array|WP_Error The uploaded data as array. When failure returns error. | 
| 1561 | 1561 | */ | 
| 1562 | -function fetch_remote_file( $url ) {
 | |
| 1562 | +function fetch_remote_file($url) {
 | |
| 1563 | 1563 | // extract the file name and extension from the url | 
| 1564 | - require_once( ABSPATH . 'wp-includes/pluggable.php' ); | |
| 1565 | - $file_name = basename( $url ); | |
| 1566 | -	if ( strpos( $file_name, '?' ) !== false ) {
 | |
| 1567 | - list( $file_name ) = explode( '?', $file_name ); | |
| 1564 | + require_once(ABSPATH.'wp-includes/pluggable.php'); | |
| 1565 | + $file_name = basename($url); | |
| 1566 | +	if (strpos($file_name, '?') !== false) {
 | |
| 1567 | +		list($file_name) = explode('?', $file_name);
 | |
| 1568 | 1568 | } | 
| 1569 | 1569 | $dummy = false; | 
| 1570 | 1570 | $add_to_cache = false; | 
| 1571 | 1571 | $key = null; | 
| 1572 | -	if ( strpos( $url, '/dummy/' ) !== false ) {
 | |
| 1572 | +	if (strpos($url, '/dummy/') !== false) {
 | |
| 1573 | 1573 | $dummy = true; | 
| 1574 | - $key = "dummy_" . str_replace( '.', '_', $file_name ); | |
| 1575 | - $value = get_transient( 'cached_dummy_images' ); | |
| 1576 | -		if ( $value ) {
 | |
| 1577 | -			if ( isset( $value[ $key ] ) ) {
 | |
| 1578 | - return $value[ $key ]; | |
| 1574 | +		$key   = "dummy_".str_replace('.', '_', $file_name);
 | |
| 1575 | +		$value = get_transient('cached_dummy_images');
 | |
| 1576 | +		if ($value) {
 | |
| 1577 | +			if (isset($value[$key])) {
 | |
| 1578 | + return $value[$key]; | |
| 1579 | 1579 |  			} else {
 | 
| 1580 | 1580 | $add_to_cache = true; | 
| 1581 | 1581 | } | 
| @@ -1586,58 +1586,58 @@ discard block | ||
| 1586 | 1586 | |
| 1587 | 1587 | // get placeholder file in the upload dir with a unique, sanitized filename | 
| 1588 | 1588 | |
| 1589 | - $post_upload_date = isset( $post['upload_date'] ) ? $post['upload_date'] : ''; | |
| 1589 | + $post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : ''; | |
| 1590 | 1590 | |
| 1591 | - $upload = wp_upload_bits( $file_name, 0, '', $post_upload_date ); | |
| 1592 | -	if ( $upload['error'] ) {
 | |
| 1593 | - return new WP_Error( 'upload_dir_error', $upload['error'] ); | |
| 1591 | + $upload = wp_upload_bits($file_name, 0, '', $post_upload_date); | |
| 1592 | +	if ($upload['error']) {
 | |
| 1593 | +		return new WP_Error('upload_dir_error', $upload['error']);
 | |
| 1594 | 1594 | } | 
| 1595 | 1595 | |
| 1596 | 1596 | |
| 1597 | - sleep( 0.3 );// if multiple remote file this can cause the remote server to timeout so we add a slight delay | |
| 1597 | + sleep(0.3); // if multiple remote file this can cause the remote server to timeout so we add a slight delay | |
| 1598 | 1598 | |
| 1599 | 1599 | // fetch the remote url and write it to the placeholder file | 
| 1600 | - $headers = wp_remote_get( $url, array( 'stream' => true, 'filename' => $upload['file'] ) ); | |
| 1600 | +	$headers = wp_remote_get($url, array('stream' => true, 'filename' => $upload['file']));
 | |
| 1601 | 1601 | |
| 1602 | 1602 | $log_message = ''; | 
| 1603 | -	if ( is_wp_error( $headers ) ) {
 | |
| 1604 | - echo 'file: ' . $url; | |
| 1603 | +	if (is_wp_error($headers)) {
 | |
| 1604 | + echo 'file: '.$url; | |
| 1605 | 1605 | |
| 1606 | - return new WP_Error( 'import_file_error', $headers->get_error_message() ); | |
| 1606 | +		return new WP_Error('import_file_error', $headers->get_error_message());
 | |
| 1607 | 1607 | } | 
| 1608 | 1608 | |
| 1609 | - $filesize = filesize( $upload['file'] ); | |
| 1609 | + $filesize = filesize($upload['file']); | |
| 1610 | 1610 | // request failed | 
| 1611 | -	if ( ! $headers ) {
 | |
| 1612 | - $log_message = __( 'Remote server did not respond', 'geodirectory' ); | |
| 1611 | +	if (!$headers) {
 | |
| 1612 | +		$log_message = __('Remote server did not respond', 'geodirectory');
 | |
| 1613 | 1613 | } // make sure the fetch was successful | 
| 1614 | -	elseif ( $headers['response']['code'] != '200' ) {
 | |
| 1615 | - $log_message = sprintf( __( 'Remote server returned error response %1$d %2$s', 'geodirectory' ), esc_html( $headers['response'] ), get_status_header_desc( $headers['response'] ) ); | |
| 1616 | -	} elseif ( isset( $headers['headers']['content-length'] ) && $filesize != $headers['headers']['content-length'] ) {
 | |
| 1617 | - $log_message = __( 'Remote file is incorrect size', 'geodirectory' ); | |
| 1618 | -	} elseif ( 0 == $filesize ) {
 | |
| 1619 | - $log_message = __( 'Zero size file downloaded', 'geodirectory' ); | |
| 1620 | - } | |
| 1621 | - | |
| 1622 | -	if ( $log_message ) {
 | |
| 1623 | - $del = unlink( $upload['file'] ); | |
| 1624 | -		if ( ! $del ) {
 | |
| 1625 | - geodir_error_log( __( 'GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory' ) ); | |
| 1614 | +	elseif ($headers['response']['code'] != '200') {
 | |
| 1615 | +		$log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
 | |
| 1616 | +	} elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
 | |
| 1617 | +		$log_message = __('Remote file is incorrect size', 'geodirectory');
 | |
| 1618 | +	} elseif (0 == $filesize) {
 | |
| 1619 | +		$log_message = __('Zero size file downloaded', 'geodirectory');
 | |
| 1620 | + } | |
| 1621 | + | |
| 1622 | +	if ($log_message) {
 | |
| 1623 | + $del = unlink($upload['file']); | |
| 1624 | +		if (!$del) {
 | |
| 1625 | +			geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));
 | |
| 1626 | 1626 | } | 
| 1627 | 1627 | |
| 1628 | - return new WP_Error( 'import_file_error', $log_message ); | |
| 1628 | +		return new WP_Error('import_file_error', $log_message);
 | |
| 1629 | 1629 | } | 
| 1630 | 1630 | |
| 1631 | -	if ( $dummy && $add_to_cache && is_array( $upload ) ) {
 | |
| 1632 | - $images = get_transient( 'cached_dummy_images' ); | |
| 1633 | -		if ( is_array( $images ) ) {
 | |
| 1634 | - $images[ $key ] = $upload; | |
| 1631 | +	if ($dummy && $add_to_cache && is_array($upload)) {
 | |
| 1632 | +		$images = get_transient('cached_dummy_images');
 | |
| 1633 | +		if (is_array($images)) {
 | |
| 1634 | + $images[$key] = $upload; | |
| 1635 | 1635 |  		} else {
 | 
| 1636 | - $images = array( $key => $upload ); | |
| 1636 | + $images = array($key => $upload); | |
| 1637 | 1637 | } | 
| 1638 | 1638 | |
| 1639 | 1639 | //setting the cache using the WP Transient API | 
| 1640 | - set_transient( 'cached_dummy_images', $images, 60 * 10 ); //10 minutes cache | |
| 1640 | +		set_transient('cached_dummy_images', $images, 60 * 10); //10 minutes cache
 | |
| 1641 | 1641 | } | 
| 1642 | 1642 | |
| 1643 | 1643 | return $upload; | 
| @@ -1651,12 +1651,12 @@ discard block | ||
| 1651 | 1651 | * @return string|void Max upload size. | 
| 1652 | 1652 | */ | 
| 1653 | 1653 |  function geodir_max_upload_size() {
 | 
| 1654 | - $max_filesize = (float) get_option( 'geodir_upload_max_filesize', 2 ); | |
| 1654 | +	$max_filesize = (float) get_option('geodir_upload_max_filesize', 2);
 | |
| 1655 | 1655 | |
| 1656 | -	if ( $max_filesize > 0 && $max_filesize < 1 ) {
 | |
| 1657 | - $max_filesize = (int) ( $max_filesize * 1024 ) . 'kb'; | |
| 1656 | +	if ($max_filesize > 0 && $max_filesize < 1) {
 | |
| 1657 | + $max_filesize = (int) ($max_filesize * 1024).'kb'; | |
| 1658 | 1658 |  	} else {
 | 
| 1659 | - $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb'; | |
| 1659 | + $max_filesize = $max_filesize > 0 ? $max_filesize.'mb' : '2mb'; | |
| 1660 | 1660 | } | 
| 1661 | 1661 | |
| 1662 | 1662 | /** | 
| @@ -1666,7 +1666,7 @@ discard block | ||
| 1666 | 1666 | * | 
| 1667 | 1667 | * @param string $max_filesize Max file upload size. Ex. 10mb, 512kb. | 
| 1668 | 1668 | */ | 
| 1669 | - return apply_filters( 'geodir_default_image_upload_size_limit', $max_filesize ); | |
| 1669 | +	return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
 | |
| 1670 | 1670 | } | 
| 1671 | 1671 | |
| 1672 | 1672 | /** | 
| @@ -1679,8 +1679,8 @@ discard block | ||
| 1679 | 1679 | * @return bool If dummy folder exists returns true, else false. | 
| 1680 | 1680 | */ | 
| 1681 | 1681 |  function geodir_dummy_folder_exists() {
 | 
| 1682 | - $path = geodir_plugin_path() . '/geodirectory-admin/dummy/'; | |
| 1683 | -	if ( ! is_dir( $path ) ) {
 | |
| 1682 | + $path = geodir_plugin_path().'/geodirectory-admin/dummy/'; | |
| 1683 | +	if (!is_dir($path)) {
 | |
| 1684 | 1684 | return false; | 
| 1685 | 1685 |  	} else {
 | 
| 1686 | 1686 | return true; | 
| @@ -1699,17 +1699,17 @@ discard block | ||
| 1699 | 1699 | * | 
| 1700 | 1700 | * @return object Author info. | 
| 1701 | 1701 | */ | 
| 1702 | -function geodir_get_author_info( $aid ) {
 | |
| 1702 | +function geodir_get_author_info($aid) {
 | |
| 1703 | 1703 | global $wpdb; | 
| 1704 | 1704 | /*$infosql = "select * from $wpdb->users where ID=$aid";*/ | 
| 1705 | - $infosql = $wpdb->prepare( "select * from $wpdb->users where ID=%d", array( $aid ) ); | |
| 1706 | - $info = $wpdb->get_results( $infosql ); | |
| 1707 | -	if ( $info ) {
 | |
| 1705 | +	$infosql = $wpdb->prepare("select * from $wpdb->users where ID=%d", array($aid));
 | |
| 1706 | + $info = $wpdb->get_results($infosql); | |
| 1707 | +	if ($info) {
 | |
| 1708 | 1708 | return $info[0]; | 
| 1709 | 1709 | } | 
| 1710 | 1710 | } | 
| 1711 | 1711 | |
| 1712 | -if ( ! function_exists( 'adminEmail' ) ) {
 | |
| 1712 | +if (!function_exists('adminEmail')) {
 | |
| 1713 | 1713 | /** | 
| 1714 | 1714 | * Send emails to client on post submission, renew etc. | 
| 1715 | 1715 | * | 
| @@ -1722,67 +1722,67 @@ discard block | ||
| 1722 | 1722 | * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. | 
| 1723 | 1723 | * @param string $custom_1 Custom data to be sent. | 
| 1724 | 1724 | */ | 
| 1725 | -	function adminEmail( $page_id, $user_id, $message_type, $custom_1 = '' ) {
 | |
| 1725 | +	function adminEmail($page_id, $user_id, $message_type, $custom_1 = '') {
 | |
| 1726 | 1726 | global $wpdb; | 
| 1727 | -		if ( $message_type == 'expiration' ) {
 | |
| 1728 | - $subject = stripslashes( __( get_option( 'renew_email_subject' ), 'geodirectory' ) ); | |
| 1729 | - $client_message = stripslashes( __( get_option( 'renew_email_content' ), 'geodirectory' ) ); | |
| 1730 | -		} elseif ( $message_type == 'post_submited' ) {
 | |
| 1731 | - $subject = __( get_option( 'post_submited_success_email_subject_admin' ), 'geodirectory' ); | |
| 1732 | - $client_message = __( get_option( 'post_submited_success_email_content_admin' ), 'geodirectory' ); | |
| 1733 | -		} elseif ( $message_type == 'renew' ) {
 | |
| 1734 | - $subject = __( get_option( 'post_renew_success_email_subject_admin' ), 'geodirectory' ); | |
| 1735 | - $client_message = __( get_option( 'post_renew_success_email_content_admin' ), 'geodirectory' ); | |
| 1736 | -		} elseif ( $message_type == 'upgrade' ) {
 | |
| 1737 | - $subject = __( get_option( 'post_upgrade_success_email_subject_admin' ), 'geodirectory' ); | |
| 1738 | - $client_message = __( get_option( 'post_upgrade_success_email_content_admin' ), 'geodirectory' ); | |
| 1739 | -		} elseif ( $message_type == 'claim_approved' ) {
 | |
| 1740 | - $subject = __( get_option( 'claim_approved_email_subject' ), 'geodirectory' ); | |
| 1741 | - $client_message = __( get_option( 'claim_approved_email_content' ), 'geodirectory' ); | |
| 1742 | -		} elseif ( $message_type == 'claim_rejected' ) {
 | |
| 1743 | - $subject = __( get_option( 'claim_rejected_email_subject' ), 'geodirectory' ); | |
| 1744 | - $client_message = __( get_option( 'claim_rejected_email_content' ), 'geodirectory' ); | |
| 1745 | -		} elseif ( $message_type == 'claim_requested' ) {
 | |
| 1746 | - $subject = __( get_option( 'claim_email_subject_admin' ), 'geodirectory' ); | |
| 1747 | - $client_message = __( get_option( 'claim_email_content_admin' ), 'geodirectory' ); | |
| 1748 | -		} elseif ( $message_type == 'auto_claim' ) {
 | |
| 1749 | - $subject = __( get_option( 'auto_claim_email_subject' ), 'geodirectory' ); | |
| 1750 | - $client_message = __( get_option( 'auto_claim_email_content' ), 'geodirectory' ); | |
| 1751 | -		} elseif ( $message_type == 'payment_success' ) {
 | |
| 1752 | - $subject = __( get_option( 'post_payment_success_admin_email_subject' ), 'geodirectory' ); | |
| 1753 | - $client_message = __( get_option( 'post_payment_success_admin_email_content' ), 'geodirectory' ); | |
| 1754 | -		} elseif ( $message_type == 'payment_fail' ) {
 | |
| 1755 | - $subject = __( get_option( 'post_payment_fail_admin_email_subject' ), 'geodirectory' ); | |
| 1756 | - $client_message = __( get_option( 'post_payment_fail_admin_email_content' ), 'geodirectory' ); | |
| 1727 | +		if ($message_type == 'expiration') {
 | |
| 1728 | +			$subject        = stripslashes(__(get_option('renew_email_subject'), 'geodirectory'));
 | |
| 1729 | +			$client_message = stripslashes(__(get_option('renew_email_content'), 'geodirectory'));
 | |
| 1730 | +		} elseif ($message_type == 'post_submited') {
 | |
| 1731 | +			$subject        = __(get_option('post_submited_success_email_subject_admin'), 'geodirectory');
 | |
| 1732 | +			$client_message = __(get_option('post_submited_success_email_content_admin'), 'geodirectory');
 | |
| 1733 | +		} elseif ($message_type == 'renew') {
 | |
| 1734 | +			$subject        = __(get_option('post_renew_success_email_subject_admin'), 'geodirectory');
 | |
| 1735 | +			$client_message = __(get_option('post_renew_success_email_content_admin'), 'geodirectory');
 | |
| 1736 | +		} elseif ($message_type == 'upgrade') {
 | |
| 1737 | +			$subject        = __(get_option('post_upgrade_success_email_subject_admin'), 'geodirectory');
 | |
| 1738 | +			$client_message = __(get_option('post_upgrade_success_email_content_admin'), 'geodirectory');
 | |
| 1739 | +		} elseif ($message_type == 'claim_approved') {
 | |
| 1740 | +			$subject        = __(get_option('claim_approved_email_subject'), 'geodirectory');
 | |
| 1741 | +			$client_message = __(get_option('claim_approved_email_content'), 'geodirectory');
 | |
| 1742 | +		} elseif ($message_type == 'claim_rejected') {
 | |
| 1743 | +			$subject        = __(get_option('claim_rejected_email_subject'), 'geodirectory');
 | |
| 1744 | +			$client_message = __(get_option('claim_rejected_email_content'), 'geodirectory');
 | |
| 1745 | +		} elseif ($message_type == 'claim_requested') {
 | |
| 1746 | +			$subject        = __(get_option('claim_email_subject_admin'), 'geodirectory');
 | |
| 1747 | +			$client_message = __(get_option('claim_email_content_admin'), 'geodirectory');
 | |
| 1748 | +		} elseif ($message_type == 'auto_claim') {
 | |
| 1749 | +			$subject        = __(get_option('auto_claim_email_subject'), 'geodirectory');
 | |
| 1750 | +			$client_message = __(get_option('auto_claim_email_content'), 'geodirectory');
 | |
| 1751 | +		} elseif ($message_type == 'payment_success') {
 | |
| 1752 | +			$subject        = __(get_option('post_payment_success_admin_email_subject'), 'geodirectory');
 | |
| 1753 | +			$client_message = __(get_option('post_payment_success_admin_email_content'), 'geodirectory');
 | |
| 1754 | +		} elseif ($message_type == 'payment_fail') {
 | |
| 1755 | +			$subject        = __(get_option('post_payment_fail_admin_email_subject'), 'geodirectory');
 | |
| 1756 | +			$client_message = __(get_option('post_payment_fail_admin_email_content'), 'geodirectory');
 | |
| 1757 | 1757 | } | 
| 1758 | 1758 | $transaction_details = $custom_1; | 
| 1759 | - $fromEmail = get_option( 'site_email' ); | |
| 1759 | +		$fromEmail           = get_option('site_email');
 | |
| 1760 | 1760 | $fromEmailName = get_site_emailName(); | 
| 1761 | 1761 | //$alivedays = get_post_meta($page_id,'alive_days',true); | 
| 1762 | - $pkg_limit = get_property_price_info_listing( $page_id ); | |
| 1762 | + $pkg_limit = get_property_price_info_listing($page_id); | |
| 1763 | 1763 | $alivedays = $pkg_limit['days']; | 
| 1764 | - $productlink = get_permalink( $page_id ); | |
| 1765 | - $post_info = get_post( $page_id ); | |
| 1766 | - $post_date = date( 'dS F,Y', strtotime( $post_info->post_date ) ); | |
| 1767 | - $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>'; | |
| 1764 | + $productlink = get_permalink($page_id); | |
| 1765 | + $post_info = get_post($page_id); | |
| 1766 | +		$post_date            = date('dS F,Y', strtotime($post_info->post_date));
 | |
| 1767 | + $listingLink = '<a href="'.$productlink.'"><b>'.$post_info->post_title.'</b></a>'; | |
| 1768 | 1768 | $loginurl = geodir_login_url(); | 
| 1769 | - $loginurl_link = '<a href="' . $loginurl . '">login</a>'; | |
| 1769 | + $loginurl_link = '<a href="'.$loginurl.'">login</a>'; | |
| 1770 | 1770 | $siteurl = home_url(); | 
| 1771 | - $siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>'; | |
| 1772 | - $user_info = get_userdata( $user_id ); | |
| 1771 | + $siteurl_link = '<a href="'.$siteurl.'">'.$fromEmailName.'</a>'; | |
| 1772 | + $user_info = get_userdata($user_id); | |
| 1773 | 1773 | $user_email = $user_info->user_email; | 
| 1774 | - $display_name = geodir_get_client_name( $user_id ); | |
| 1774 | + $display_name = geodir_get_client_name($user_id); | |
| 1775 | 1775 | $user_login = $user_info->user_login; | 
| 1776 | - $number_of_grace_days = get_option( 'ptthemes_listing_preexpiry_notice_days' ); | |
| 1777 | -		if ( $number_of_grace_days == '' ) {
 | |
| 1776 | +		$number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
 | |
| 1777 | +		if ($number_of_grace_days == '') {
 | |
| 1778 | 1778 | $number_of_grace_days = 1; | 
| 1779 | 1779 | } | 
| 1780 | -		if ( $post_info->post_type == 'event' ) {
 | |
| 1780 | +		if ($post_info->post_type == 'event') {
 | |
| 1781 | 1781 | $post_type = 'event'; | 
| 1782 | 1782 |  		} else {
 | 
| 1783 | 1783 | $post_type = 'listing'; | 
| 1784 | 1784 | } | 
| 1785 | - $renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>'; | |
| 1785 | + $renew_link = '<a href="'.$siteurl.'?ptype=post_'.$post_type.'&renew=1&pid='.$page_id.'">'.RENEW_LINK.'</a>'; | |
| 1786 | 1786 | $search_array = array( | 
| 1787 | 1787 | '[#client_name#]', | 
| 1788 | 1788 | '[#listing_link#]', | 
| @@ -1798,7 +1798,7 @@ discard block | ||
| 1798 | 1798 | '[#site_name#]', | 
| 1799 | 1799 | '[#transaction_details#]' | 
| 1800 | 1800 | ); | 
| 1801 | - $replace_array = array( | |
| 1801 | + $replace_array = array( | |
| 1802 | 1802 | $display_name, | 
| 1803 | 1803 | $listingLink, | 
| 1804 | 1804 | $post_date, | 
| @@ -1813,11 +1813,11 @@ discard block | ||
| 1813 | 1813 | $fromEmailName, | 
| 1814 | 1814 | $transaction_details | 
| 1815 | 1815 | ); | 
| 1816 | - $client_message = str_replace( $search_array, $replace_array, $client_message ); | |
| 1817 | - $subject = str_replace( $search_array, $replace_array, $subject ); | |
| 1818 | - $headers = 'MIME-Version: 1.0' . "\r\n"; | |
| 1819 | - $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; | |
| 1820 | - $headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n"; | |
| 1816 | + $client_message = str_replace($search_array, $replace_array, $client_message); | |
| 1817 | + $subject = str_replace($search_array, $replace_array, $subject); | |
| 1818 | + $headers = 'MIME-Version: 1.0'."\r\n"; | |
| 1819 | + $headers .= 'Content-type: text/html; charset=UTF-8'."\r\n"; | |
| 1820 | + $headers .= 'From: '.$fromEmailName.' <'.$fromEmail.'>'."\r\n"; | |
| 1821 | 1821 | |
| 1822 | 1822 | $to = $fromEmail; | 
| 1823 | 1823 | $message = $client_message; | 
| @@ -1835,7 +1835,7 @@ discard block | ||
| 1835 | 1835 | * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. | 
| 1836 | 1836 | * @param string $custom_1 Custom data to be sent. | 
| 1837 | 1837 | */ | 
| 1838 | - $to = apply_filters( 'geodir_adminEmail_to', $to, $page_id, $user_id, $message_type, $custom_1 ); | |
| 1838 | +		$to = apply_filters('geodir_adminEmail_to', $to, $page_id, $user_id, $message_type, $custom_1);
 | |
| 1839 | 1839 | /** | 
| 1840 | 1840 | * Filter the admin email subject. | 
| 1841 | 1841 | * | 
| @@ -1848,7 +1848,7 @@ discard block | ||
| 1848 | 1848 | * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. | 
| 1849 | 1849 | * @param string $custom_1 Custom data to be sent. | 
| 1850 | 1850 | */ | 
| 1851 | - $subject = apply_filters( 'geodir_adminEmail_subject', $subject, $page_id, $user_id, $message_type, $custom_1 ); | |
| 1851 | +		$subject = apply_filters('geodir_adminEmail_subject', $subject, $page_id, $user_id, $message_type, $custom_1);
 | |
| 1852 | 1852 | /** | 
| 1853 | 1853 | * Filter the admin email message. | 
| 1854 | 1854 | * | 
| @@ -1861,7 +1861,7 @@ discard block | ||
| 1861 | 1861 | * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. | 
| 1862 | 1862 | * @param string $custom_1 Custom data to be sent. | 
| 1863 | 1863 | */ | 
| 1864 | - $message = apply_filters( 'geodir_adminEmail_message', $message, $page_id, $user_id, $message_type, $custom_1 ); | |
| 1864 | +		$message = apply_filters('geodir_adminEmail_message', $message, $page_id, $user_id, $message_type, $custom_1);
 | |
| 1865 | 1865 | /** | 
| 1866 | 1866 | * Filter the admin email headers. | 
| 1867 | 1867 | * | 
| @@ -1874,22 +1874,22 @@ discard block | ||
| 1874 | 1874 | * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. | 
| 1875 | 1875 | * @param string $custom_1 Custom data to be sent. | 
| 1876 | 1876 | */ | 
| 1877 | - $headers = apply_filters( 'geodir_adminEmail_headers', $headers, $page_id, $user_id, $message_type, $custom_1 ); | |
| 1877 | +		$headers = apply_filters('geodir_adminEmail_headers', $headers, $page_id, $user_id, $message_type, $custom_1);
 | |
| 1878 | 1878 | |
| 1879 | 1879 | |
| 1880 | - $sent = wp_mail( $to, $subject, $message, $headers ); | |
| 1881 | -		if ( ! $sent ) {
 | |
| 1882 | -			if ( is_array( $to ) ) {
 | |
| 1883 | - $to = implode( ',', $to ); | |
| 1880 | + $sent = wp_mail($to, $subject, $message, $headers); | |
| 1881 | +		if (!$sent) {
 | |
| 1882 | +			if (is_array($to)) {
 | |
| 1883 | +				$to = implode(',', $to);
 | |
| 1884 | 1884 | } | 
| 1885 | 1885 | $log_message = sprintf( | 
| 1886 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), | |
| 1886 | +				__("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
 | |
| 1887 | 1887 | $message_type, | 
| 1888 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), | |
| 1888 | +				date_i18n('F j Y H:i:s', current_time('timestamp')),
 | |
| 1889 | 1889 | $to, | 
| 1890 | 1890 | $subject | 
| 1891 | 1891 | ); | 
| 1892 | - geodir_error_log( $log_message ); | |
| 1892 | + geodir_error_log($log_message); | |
| 1893 | 1893 | } | 
| 1894 | 1894 | } | 
| 1895 | 1895 | } | 
| @@ -1909,12 +1909,12 @@ discard block | ||
| 1909 | 1909 | * | 
| 1910 | 1910 | * @return array Category IDs. | 
| 1911 | 1911 | */ | 
| 1912 | -function gd_lang_object_ids( $ids_array, $type ) {
 | |
| 1913 | -	if ( function_exists( 'icl_object_id' ) ) {
 | |
| 1912 | +function gd_lang_object_ids($ids_array, $type) {
 | |
| 1913 | +	if (function_exists('icl_object_id')) {
 | |
| 1914 | 1914 | $res = array(); | 
| 1915 | -		foreach ( $ids_array as $id ) {
 | |
| 1916 | - $xlat = icl_object_id( $id, $type, false ); | |
| 1917 | -			if ( ! is_null( $xlat ) ) {
 | |
| 1915 | +		foreach ($ids_array as $id) {
 | |
| 1916 | + $xlat = icl_object_id($id, $type, false); | |
| 1917 | +			if (!is_null($xlat)) {
 | |
| 1918 | 1918 | $res[] = $xlat; | 
| 1919 | 1919 | } | 
| 1920 | 1920 | } | 
| @@ -1938,20 +1938,20 @@ discard block | ||
| 1938 | 1938 | * | 
| 1939 | 1939 | * @return array Modified Body CSS classes. | 
| 1940 | 1940 | */ | 
| 1941 | -function geodir_custom_posts_body_class( $classes ) {
 | |
| 1941 | +function geodir_custom_posts_body_class($classes) {
 | |
| 1942 | 1942 | global $wpdb, $wp; | 
| 1943 | - $post_types = geodir_get_posttypes( 'object' ); | |
| 1944 | -	if ( ! empty( $post_types ) && count( (array) $post_types ) > 1 ) {
 | |
| 1943 | +	$post_types = geodir_get_posttypes('object');
 | |
| 1944 | +	if (!empty($post_types) && count((array) $post_types) > 1) {
 | |
| 1945 | 1945 | $classes[] = 'geodir_custom_posts'; | 
| 1946 | 1946 | } | 
| 1947 | 1947 | |
| 1948 | 1948 | // fix body class for signup page | 
| 1949 | -	if ( geodir_is_page( 'login' ) ) {
 | |
| 1949 | +	if (geodir_is_page('login')) {
 | |
| 1950 | 1950 | $new_classes = array(); | 
| 1951 | 1951 | $new_classes[] = 'signup page-geodir-signup'; | 
| 1952 | -		if ( ! empty( $classes ) ) {
 | |
| 1953 | -			foreach ( $classes as $class ) {
 | |
| 1954 | -				if ( $class && $class != 'home' && $class != 'blog' ) {
 | |
| 1952 | +		if (!empty($classes)) {
 | |
| 1953 | +			foreach ($classes as $class) {
 | |
| 1954 | +				if ($class && $class != 'home' && $class != 'blog') {
 | |
| 1955 | 1955 | $new_classes[] = $class; | 
| 1956 | 1956 | } | 
| 1957 | 1957 | } | 
| @@ -1959,14 +1959,14 @@ discard block | ||
| 1959 | 1959 | $classes = $new_classes; | 
| 1960 | 1960 | } | 
| 1961 | 1961 | |
| 1962 | -	if ( geodir_is_geodir_page() ) {
 | |
| 1962 | +	if (geodir_is_geodir_page()) {
 | |
| 1963 | 1963 | $classes[] = 'geodir-page'; | 
| 1964 | 1964 | } | 
| 1965 | 1965 | |
| 1966 | 1966 | return $classes; | 
| 1967 | 1967 | } | 
| 1968 | 1968 | |
| 1969 | -add_filter( 'body_class', 'geodir_custom_posts_body_class' ); // let's add a class to the body so we can style the new addition to the search | |
| 1969 | +add_filter('body_class', 'geodir_custom_posts_body_class'); // let's add a class to the body so we can style the new addition to the search
 | |
| 1970 | 1970 | |
| 1971 | 1971 | |
| 1972 | 1972 | /** | 
| @@ -1982,7 +1982,7 @@ discard block | ||
| 1982 | 1982 | * | 
| 1983 | 1983 | * @since 1.0.0 | 
| 1984 | 1984 | */ | 
| 1985 | - return apply_filters( 'geodir_map_zoom_level', array( | |
| 1985 | +	return apply_filters('geodir_map_zoom_level', array(
 | |
| 1986 | 1986 | 1, | 
| 1987 | 1987 | 2, | 
| 1988 | 1988 | 3, | 
| @@ -2002,7 +2002,7 @@ discard block | ||
| 2002 | 2002 | 17, | 
| 2003 | 2003 | 18, | 
| 2004 | 2004 | 19 | 
| 2005 | - ) ); | |
| 2005 | + )); | |
| 2006 | 2006 | |
| 2007 | 2007 | } | 
| 2008 | 2008 | |
| @@ -2015,12 +2015,12 @@ discard block | ||
| 2015 | 2015 | * | 
| 2016 | 2016 | * @param string $geodir_option_name Option key. | 
| 2017 | 2017 | */ | 
| 2018 | -function geodir_option_version_backup( $geodir_option_name ) {
 | |
| 2018 | +function geodir_option_version_backup($geodir_option_name) {
 | |
| 2019 | 2019 | $version_date = time(); | 
| 2020 | - $geodir_option = get_option( $geodir_option_name ); | |
| 2020 | + $geodir_option = get_option($geodir_option_name); | |
| 2021 | 2021 | |
| 2022 | -	if ( ! empty( $geodir_option ) ) {
 | |
| 2023 | - add_option( $geodir_option_name . '_' . $version_date, $geodir_option ); | |
| 2022 | +	if (!empty($geodir_option)) {
 | |
| 2023 | + add_option($geodir_option_name.'_'.$version_date, $geodir_option); | |
| 2024 | 2024 | } | 
| 2025 | 2025 | } | 
| 2026 | 2026 | |
| @@ -2034,10 +2034,10 @@ discard block | ||
| 2034 | 2034 | * | 
| 2035 | 2035 | * @return int Page ID. | 
| 2036 | 2036 | */ | 
| 2037 | -function get_page_id_geodir_add_listing_page( $page_id ) {
 | |
| 2038 | -	if ( geodir_wpml_multilingual_status() ) {
 | |
| 2037 | +function get_page_id_geodir_add_listing_page($page_id) {
 | |
| 2038 | +	if (geodir_wpml_multilingual_status()) {
 | |
| 2039 | 2039 | $post_type = 'post_page'; | 
| 2040 | - $page_id = geodir_get_wpml_element_id( $page_id, $post_type ); | |
| 2040 | + $page_id = geodir_get_wpml_element_id($page_id, $post_type); | |
| 2041 | 2041 | } | 
| 2042 | 2042 | |
| 2043 | 2043 | return $page_id; | 
| @@ -2051,7 +2051,7 @@ discard block | ||
| 2051 | 2051 | * @return bool Returns true when sitepress multilingual CMS active. else returns false. | 
| 2052 | 2052 | */ | 
| 2053 | 2053 |  function geodir_wpml_multilingual_status() {
 | 
| 2054 | -	if ( function_exists( 'icl_object_id' ) ) {
 | |
| 2054 | +	if (function_exists('icl_object_id')) {
 | |
| 2055 | 2055 | return true; | 
| 2056 | 2056 | } | 
| 2057 | 2057 | |
| @@ -2069,19 +2069,19 @@ discard block | ||
| 2069 | 2069 | * | 
| 2070 | 2070 | * @return int Element ID when exists. Else the page id. | 
| 2071 | 2071 | */ | 
| 2072 | -function geodir_get_wpml_element_id( $page_id, $post_type ) {
 | |
| 2072 | +function geodir_get_wpml_element_id($page_id, $post_type) {
 | |
| 2073 | 2073 | global $sitepress; | 
| 2074 | -	if ( geodir_wpml_multilingual_status() && ! empty( $sitepress ) && isset( $sitepress->queries ) ) {
 | |
| 2075 | - $trid = $sitepress->get_element_trid( $page_id, $post_type ); | |
| 2074 | +	if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
 | |
| 2075 | + $trid = $sitepress->get_element_trid($page_id, $post_type); | |
| 2076 | 2076 | |
| 2077 | -		if ( $trid > 0 ) {
 | |
| 2078 | - $translations = $sitepress->get_element_translations( $trid, $post_type ); | |
| 2077 | +		if ($trid > 0) {
 | |
| 2078 | + $translations = $sitepress->get_element_translations($trid, $post_type); | |
| 2079 | 2079 | |
| 2080 | 2080 | $lang = $sitepress->get_current_language(); | 
| 2081 | 2081 | $lang = $lang ? $lang : $sitepress->get_default_language(); | 
| 2082 | 2082 | |
| 2083 | -			if ( ! empty( $translations ) && ! empty( $lang ) && isset( $translations[ $lang ] ) && isset( $translations[ $lang ]->element_id ) && ! empty( $translations[ $lang ]->element_id ) ) {
 | |
| 2084 | - $page_id = $translations[ $lang ]->element_id; | |
| 2083 | +			if (!empty($translations) && !empty($lang) && isset($translations[$lang]) && isset($translations[$lang]->element_id) && !empty($translations[$lang]->element_id)) {
 | |
| 2084 | + $page_id = $translations[$lang]->element_id; | |
| 2085 | 2085 | } | 
| 2086 | 2086 | } | 
| 2087 | 2087 | } | 
| @@ -2098,15 +2098,15 @@ discard block | ||
| 2098 | 2098 | */ | 
| 2099 | 2099 |  function geodir_wpml_check_element_id() {
 | 
| 2100 | 2100 | global $sitepress; | 
| 2101 | -	if ( geodir_wpml_multilingual_status() && ! empty( $sitepress ) && isset( $sitepress->queries ) ) {
 | |
| 2101 | +	if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
 | |
| 2102 | 2102 | $el_type = 'post_page'; | 
| 2103 | - $el_id = get_option( 'geodir_add_listing_page' ); | |
| 2103 | +		$el_id        = get_option('geodir_add_listing_page');
 | |
| 2104 | 2104 | $default_lang = $sitepress->get_default_language(); | 
| 2105 | - $el_details = $sitepress->get_element_language_details( $el_id, $el_type ); | |
| 2105 | + $el_details = $sitepress->get_element_language_details($el_id, $el_type); | |
| 2106 | 2106 | |
| 2107 | -		if ( ! ( $el_id > 0 && $default_lang && ! empty( $el_details ) && isset( $el_details->language_code ) && $el_details->language_code == $default_lang ) ) {
 | |
| 2108 | -			if ( ! $el_details->source_language_code ) {
 | |
| 2109 | - $sitepress->set_element_language_details( $el_id, $el_type, '', $default_lang ); | |
| 2107 | +		if (!($el_id > 0 && $default_lang && !empty($el_details) && isset($el_details->language_code) && $el_details->language_code == $default_lang)) {
 | |
| 2108 | +			if (!$el_details->source_language_code) {
 | |
| 2109 | + $sitepress->set_element_language_details($el_id, $el_type, '', $default_lang); | |
| 2110 | 2110 | $sitepress->icl_translations_cache->clear(); | 
| 2111 | 2111 | } | 
| 2112 | 2112 | } | 
| @@ -2125,41 +2125,41 @@ discard block | ||
| 2125 | 2125 | * | 
| 2126 | 2126 | * @return string Orderby SQL. | 
| 2127 | 2127 | */ | 
| 2128 | -function geodir_widget_listings_get_order( $query_args ) {
 | |
| 2128 | +function geodir_widget_listings_get_order($query_args) {
 | |
| 2129 | 2129 | global $wpdb, $plugin_prefix, $gd_query_args_widgets; | 
| 2130 | 2130 | |
| 2131 | 2131 | $query_args = $gd_query_args_widgets; | 
| 2132 | -	if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) {
 | |
| 2133 | - return $wpdb->posts . ".post_date DESC, "; | |
| 2132 | +	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
 | |
| 2133 | + return $wpdb->posts.".post_date DESC, "; | |
| 2134 | 2134 | } | 
| 2135 | 2135 | |
| 2136 | - $post_type = empty( $query_args['post_type'] ) ? 'gd_place' : $query_args['post_type']; | |
| 2137 | - $table = $plugin_prefix . $post_type . '_detail'; | |
| 2136 | + $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; | |
| 2137 | + $table = $plugin_prefix.$post_type.'_detail'; | |
| 2138 | 2138 | |
| 2139 | - $sort_by = ! empty( $query_args['order_by'] ) ? $query_args['order_by'] : ''; | |
| 2139 | + $sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : ''; | |
| 2140 | 2140 | |
| 2141 | -	switch ( $sort_by ) {
 | |
| 2141 | +	switch ($sort_by) {
 | |
| 2142 | 2142 | case 'latest': | 
| 2143 | 2143 | case 'newest': | 
| 2144 | - $orderby = $wpdb->posts . ".post_date DESC, "; | |
| 2144 | + $orderby = $wpdb->posts.".post_date DESC, "; | |
| 2145 | 2145 | break; | 
| 2146 | 2146 | case 'featured': | 
| 2147 | - $orderby = $table . ".is_featured ASC, "; | |
| 2147 | + $orderby = $table.".is_featured ASC, "; | |
| 2148 | 2148 | break; | 
| 2149 | 2149 | case 'az': | 
| 2150 | - $orderby = $wpdb->posts . ".post_title ASC, "; | |
| 2150 | + $orderby = $wpdb->posts.".post_title ASC, "; | |
| 2151 | 2151 | break; | 
| 2152 | 2152 | case 'high_review': | 
| 2153 | - $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, "; | |
| 2153 | + $orderby = $table.".rating_count DESC, ".$table.".overall_rating DESC, "; | |
| 2154 | 2154 | break; | 
| 2155 | 2155 | case 'high_rating': | 
| 2156 | - $orderby = "( " . $table . ".overall_rating ) DESC, "; | |
| 2156 | + $orderby = "( ".$table.".overall_rating ) DESC, "; | |
| 2157 | 2157 | break; | 
| 2158 | 2158 | case 'random': | 
| 2159 | 2159 | $orderby = "RAND(), "; | 
| 2160 | 2160 | break; | 
| 2161 | 2161 | default: | 
| 2162 | - $orderby = $wpdb->posts . ".post_title ASC, "; | |
| 2162 | + $orderby = $wpdb->posts.".post_title ASC, "; | |
| 2163 | 2163 | break; | 
| 2164 | 2164 | } | 
| 2165 | 2165 | |
| @@ -2181,15 +2181,15 @@ discard block | ||
| 2181 | 2181 | * | 
| 2182 | 2182 | * @return mixed Result object. | 
| 2183 | 2183 | */ | 
| 2184 | -function geodir_get_widget_listings( $query_args = array(), $count_only = false ) {
 | |
| 2184 | +function geodir_get_widget_listings($query_args = array(), $count_only = false) {
 | |
| 2185 | 2185 | global $wpdb, $plugin_prefix, $table_prefix; | 
| 2186 | 2186 | $GLOBALS['gd_query_args_widgets'] = $query_args; | 
| 2187 | 2187 | $gd_query_args_widgets = $query_args; | 
| 2188 | 2188 | |
| 2189 | - $post_type = empty( $query_args['post_type'] ) ? 'gd_place' : $query_args['post_type']; | |
| 2190 | - $table = $plugin_prefix . $post_type . '_detail'; | |
| 2189 | + $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; | |
| 2190 | + $table = $plugin_prefix.$post_type.'_detail'; | |
| 2191 | 2191 | |
| 2192 | - $fields = $wpdb->posts . ".*, " . $table . ".*"; | |
| 2192 | + $fields = $wpdb->posts.".*, ".$table.".*"; | |
| 2193 | 2193 | /** | 
| 2194 | 2194 | * Filter widget listing fields string part that is being used for query. | 
| 2195 | 2195 | * | 
| @@ -2199,17 +2199,17 @@ discard block | ||
| 2199 | 2199 | * @param string $table Table name. | 
| 2200 | 2200 | * @param string $post_type Post type. | 
| 2201 | 2201 | */ | 
| 2202 | - $fields = apply_filters( 'geodir_filter_widget_listings_fields', $fields, $table, $post_type ); | |
| 2202 | +	$fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
 | |
| 2203 | 2203 | |
| 2204 | -	$join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
 | |
| 2204 | +	$join = "INNER JOIN ".$table." ON (".$table.".post_id = ".$wpdb->posts.".ID)";
 | |
| 2205 | 2205 | |
| 2206 | 2206 | ########### WPML ########### | 
| 2207 | 2207 | |
| 2208 | -	if ( function_exists( 'icl_object_id' ) ) {
 | |
| 2208 | +	if (function_exists('icl_object_id')) {
 | |
| 2209 | 2209 | global $sitepress; | 
| 2210 | 2210 | $lang_code = ICL_LANGUAGE_CODE; | 
| 2211 | -		if ( $lang_code ) {
 | |
| 2212 | - $join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID"; | |
| 2211 | +		if ($lang_code) {
 | |
| 2212 | + $join .= " JOIN ".$table_prefix."icl_translations icl_t ON icl_t.element_id = ".$table_prefix."posts.ID"; | |
| 2213 | 2213 | } | 
| 2214 | 2214 | } | 
| 2215 | 2215 | |
| @@ -2223,15 +2223,15 @@ discard block | ||
| 2223 | 2223 | * @param string $join Join clause string. | 
| 2224 | 2224 | * @param string $post_type Post type. | 
| 2225 | 2225 | */ | 
| 2226 | - $join = apply_filters( 'geodir_filter_widget_listings_join', $join, $post_type ); | |
| 2226 | +	$join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
 | |
| 2227 | 2227 | |
| 2228 | - $post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : ''; | |
| 2228 | + $post_status = is_super_admin() ? " OR ".$wpdb->posts.".post_status = 'private'" : ''; | |
| 2229 | 2229 | |
| 2230 | - $where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'"; | |
| 2230 | + $where = " AND ( ".$wpdb->posts.".post_status = 'publish' ".$post_status." ) AND ".$wpdb->posts.".post_type = '".$post_type."'"; | |
| 2231 | 2231 | |
| 2232 | 2232 | ########### WPML ########### | 
| 2233 | -	if ( function_exists( 'icl_object_id' ) ) {
 | |
| 2234 | -		if ( $lang_code ) {
 | |
| 2233 | +	if (function_exists('icl_object_id')) {
 | |
| 2234 | +		if ($lang_code) {
 | |
| 2235 | 2235 | $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type = 'post_$post_type' "; | 
| 2236 | 2236 | } | 
| 2237 | 2237 | } | 
| @@ -2244,8 +2244,8 @@ discard block | ||
| 2244 | 2244 | * @param string $where Where clause string. | 
| 2245 | 2245 | * @param string $post_type Post type. | 
| 2246 | 2246 | */ | 
| 2247 | - $where = apply_filters( 'geodir_filter_widget_listings_where', $where, $post_type ); | |
| 2248 | - $where = $where != '' ? " WHERE 1=1 " . $where : ''; | |
| 2247 | +	$where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
 | |
| 2248 | + $where = $where != '' ? " WHERE 1=1 ".$where : ''; | |
| 2249 | 2249 | |
| 2250 | 2250 | $groupby = " GROUP BY $wpdb->posts.ID "; | 
| 2251 | 2251 | /** | 
| @@ -2256,15 +2256,15 @@ discard block | ||
| 2256 | 2256 | * @param string $groupby Group by clause string. | 
| 2257 | 2257 | * @param string $post_type Post type. | 
| 2258 | 2258 | */ | 
| 2259 | - $groupby = apply_filters( 'geodir_filter_widget_listings_groupby', $groupby, $post_type ); | |
| 2259 | +	$groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
 | |
| 2260 | 2260 | |
| 2261 | -	if ( $count_only ) {
 | |
| 2262 | -		$sql  = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
 | |
| 2263 | - " . $join . " | |
| 2261 | +	if ($count_only) {
 | |
| 2262 | +		$sql  = "SELECT COUNT(".$wpdb->posts.".ID) AS total FROM ".$wpdb->posts."
 | |
| 2263 | + " . $join." | |
| 2264 | 2264 | " . $where; | 
| 2265 | - $rows = (int) $wpdb->get_var( $sql ); | |
| 2265 | + $rows = (int) $wpdb->get_var($sql); | |
| 2266 | 2266 |  	} else {
 | 
| 2267 | - $orderby = geodir_widget_listings_get_order( $query_args ); | |
| 2267 | + $orderby = geodir_widget_listings_get_order($query_args); | |
| 2268 | 2268 | /** | 
| 2269 | 2269 | * Filter widget listing orderby clause string part that is being used for query. | 
| 2270 | 2270 | * | 
| @@ -2274,11 +2274,11 @@ discard block | ||
| 2274 | 2274 | * @param string $table Table name. | 
| 2275 | 2275 | * @param string $post_type Post type. | 
| 2276 | 2276 | */ | 
| 2277 | - $orderby = apply_filters( 'geodir_filter_widget_listings_orderby', $orderby, $table, $post_type ); | |
| 2278 | - $orderby .= $wpdb->posts . ".post_title ASC"; | |
| 2279 | - $orderby = $orderby != '' ? " ORDER BY " . $orderby : ''; | |
| 2277 | +		$orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
 | |
| 2278 | + $orderby .= $wpdb->posts.".post_title ASC"; | |
| 2279 | + $orderby = $orderby != '' ? " ORDER BY ".$orderby : ''; | |
| 2280 | 2280 | |
| 2281 | - $limit = ! empty( $query_args['posts_per_page'] ) ? $query_args['posts_per_page'] : 5; | |
| 2281 | + $limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5; | |
| 2282 | 2282 | /** | 
| 2283 | 2283 | * Filter widget listing limit that is being used for query. | 
| 2284 | 2284 | * | 
| @@ -2287,26 +2287,26 @@ discard block | ||
| 2287 | 2287 | * @param int $limit Query results limit. | 
| 2288 | 2288 | * @param string $post_type Post type. | 
| 2289 | 2289 | */ | 
| 2290 | - $limit = apply_filters( 'geodir_filter_widget_listings_limit', $limit, $post_type ); | |
| 2290 | +		$limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
 | |
| 2291 | 2291 | |
| 2292 | - $page = ! empty( $query_args['pageno'] ) ? absint( $query_args['pageno'] ) : 1; | |
| 2293 | -		if ( ! $page ) {
 | |
| 2292 | + $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1; | |
| 2293 | +		if (!$page) {
 | |
| 2294 | 2294 | $page = 1; | 
| 2295 | 2295 | } | 
| 2296 | 2296 | |
| 2297 | - $limit = (int) $limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int) $limit ) . ", " . (int) $limit : ""; | |
| 2297 | + $limit = (int) $limit > 0 ? " LIMIT ".absint(($page - 1) * (int) $limit).", ".(int) $limit : ""; | |
| 2298 | 2298 | |
| 2299 | - $sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . " | |
| 2300 | - " . $join . " | |
| 2301 | - " . $where . " | |
| 2302 | - " . $groupby . " | |
| 2303 | - " . $orderby . " | |
| 2299 | + $sql = "SELECT SQL_CALC_FOUND_ROWS ".$fields." FROM ".$wpdb->posts." | |
| 2300 | + " . $join." | |
| 2301 | + " . $where." | |
| 2302 | + " . $groupby." | |
| 2303 | + " . $orderby." | |
| 2304 | 2304 | " . $limit; | 
| 2305 | - $rows = $wpdb->get_results( $sql ); | |
| 2305 | + $rows = $wpdb->get_results($sql); | |
| 2306 | 2306 | } | 
| 2307 | 2307 | |
| 2308 | - unset( $GLOBALS['gd_query_args_widgets'] ); | |
| 2309 | - unset( $gd_query_args_widgets ); | |
| 2308 | + unset($GLOBALS['gd_query_args_widgets']); | |
| 2309 | + unset($gd_query_args_widgets); | |
| 2310 | 2310 | |
| 2311 | 2311 | return $rows; | 
| 2312 | 2312 | } | 
| @@ -2323,11 +2323,11 @@ discard block | ||
| 2323 | 2323 | * | 
| 2324 | 2324 | * @return string Modified fields SQL. | 
| 2325 | 2325 | */ | 
| 2326 | -function geodir_function_widget_listings_fields( $fields ) {
 | |
| 2326 | +function geodir_function_widget_listings_fields($fields) {
 | |
| 2327 | 2327 | global $wpdb, $plugin_prefix, $gd_query_args_widgets; | 
| 2328 | 2328 | |
| 2329 | 2329 | $query_args = $gd_query_args_widgets; | 
| 2330 | -	if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) {
 | |
| 2330 | +	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
 | |
| 2331 | 2331 | return $fields; | 
| 2332 | 2332 | } | 
| 2333 | 2333 | |
| @@ -2346,24 +2346,24 @@ discard block | ||
| 2346 | 2346 | * | 
| 2347 | 2347 | * @return string Modified join clause SQL. | 
| 2348 | 2348 | */ | 
| 2349 | -function geodir_function_widget_listings_join( $join ) {
 | |
| 2349 | +function geodir_function_widget_listings_join($join) {
 | |
| 2350 | 2350 | global $wpdb, $plugin_prefix, $gd_query_args_widgets; | 
| 2351 | 2351 | |
| 2352 | 2352 | $query_args = $gd_query_args_widgets; | 
| 2353 | -	if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) {
 | |
| 2353 | +	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
 | |
| 2354 | 2354 | return $join; | 
| 2355 | 2355 | } | 
| 2356 | 2356 | |
| 2357 | - $post_type = empty( $query_args['post_type'] ) ? 'gd_place' : $query_args['post_type']; | |
| 2358 | - $table = $plugin_prefix . $post_type . '_detail'; | |
| 2357 | + $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; | |
| 2358 | + $table = $plugin_prefix.$post_type.'_detail'; | |
| 2359 | 2359 | |
| 2360 | -	if ( ! empty( $query_args['with_pics_only'] ) ) {
 | |
| 2361 | - $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )"; | |
| 2360 | +	if (!empty($query_args['with_pics_only'])) {
 | |
| 2361 | + $join .= " LEFT JOIN ".GEODIR_ATTACHMENT_TABLE." ON ( ".GEODIR_ATTACHMENT_TABLE.".post_id=".$table.".post_id AND ".GEODIR_ATTACHMENT_TABLE.".mime_type LIKE '%image%' )"; | |
| 2362 | 2362 | } | 
| 2363 | 2363 | |
| 2364 | -	if ( ! empty( $query_args['tax_query'] ) ) {
 | |
| 2365 | - $tax_queries = get_tax_sql( $query_args['tax_query'], $wpdb->posts, 'ID' ); | |
| 2366 | -		if ( ! empty( $tax_queries['join'] ) && ! empty( $tax_queries['where'] ) ) {
 | |
| 2364 | +	if (!empty($query_args['tax_query'])) {
 | |
| 2365 | + $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID'); | |
| 2366 | +		if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
 | |
| 2367 | 2367 | $join .= $tax_queries['join']; | 
| 2368 | 2368 | } | 
| 2369 | 2369 | } | 
| @@ -2383,49 +2383,49 @@ discard block | ||
| 2383 | 2383 | * | 
| 2384 | 2384 | * @return string Modified where clause SQL. | 
| 2385 | 2385 | */ | 
| 2386 | -function geodir_function_widget_listings_where( $where ) {
 | |
| 2386 | +function geodir_function_widget_listings_where($where) {
 | |
| 2387 | 2387 | global $wpdb, $plugin_prefix, $gd_query_args_widgets; | 
| 2388 | 2388 | |
| 2389 | 2389 | $query_args = $gd_query_args_widgets; | 
| 2390 | -	if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) {
 | |
| 2390 | +	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
 | |
| 2391 | 2391 | return $where; | 
| 2392 | 2392 | } | 
| 2393 | - $post_type = empty( $query_args['post_type'] ) ? 'gd_place' : $query_args['post_type']; | |
| 2394 | - $table = $plugin_prefix . $post_type . '_detail'; | |
| 2393 | + $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; | |
| 2394 | + $table = $plugin_prefix.$post_type.'_detail'; | |
| 2395 | 2395 | |
| 2396 | -	if ( ! empty( $query_args ) ) {
 | |
| 2397 | -		if ( ! empty( $query_args['gd_location'] ) && function_exists( 'geodir_default_location_where' ) ) {
 | |
| 2398 | - $where = geodir_default_location_where( $where, $table ); | |
| 2396 | +	if (!empty($query_args)) {
 | |
| 2397 | +		if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
 | |
| 2398 | + $where = geodir_default_location_where($where, $table); | |
| 2399 | 2399 | } | 
| 2400 | 2400 | |
| 2401 | -		if ( ! empty( $query_args['post_author'] ) ) {
 | |
| 2402 | - $where .= " AND " . $wpdb->posts . ".post_author = " . (int) $query_args['post_author']; | |
| 2401 | +		if (!empty($query_args['post_author'])) {
 | |
| 2402 | + $where .= " AND ".$wpdb->posts.".post_author = ".(int) $query_args['post_author']; | |
| 2403 | 2403 | } | 
| 2404 | 2404 | |
| 2405 | -		if ( ! empty( $query_args['show_featured_only'] ) ) {
 | |
| 2406 | - $where .= " AND " . $table . ".is_featured = '1'"; | |
| 2405 | +		if (!empty($query_args['show_featured_only'])) {
 | |
| 2406 | + $where .= " AND ".$table.".is_featured = '1'"; | |
| 2407 | 2407 | } | 
| 2408 | 2408 | |
| 2409 | -		if ( ! empty( $query_args['show_special_only'] ) ) {
 | |
| 2410 | - $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )"; | |
| 2409 | +		if (!empty($query_args['show_special_only'])) {
 | |
| 2410 | + $where .= " AND ( ".$table.".geodir_special_offers != '' AND ".$table.".geodir_special_offers IS NOT NULL )"; | |
| 2411 | 2411 | } | 
| 2412 | 2412 | |
| 2413 | -		if ( ! empty( $query_args['with_pics_only'] ) ) {
 | |
| 2414 | - $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL "; | |
| 2413 | +		if (!empty($query_args['with_pics_only'])) {
 | |
| 2414 | + $where .= " AND ".GEODIR_ATTACHMENT_TABLE.".ID IS NOT NULL "; | |
| 2415 | 2415 | } | 
| 2416 | 2416 | |
| 2417 | -		if ( ! empty( $query_args['featured_image_only'] ) ) {
 | |
| 2418 | - $where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' "; | |
| 2417 | +		if (!empty($query_args['featured_image_only'])) {
 | |
| 2418 | + $where .= " AND ".$table.".featured_image IS NOT NULL AND ".$table.".featured_image!='' "; | |
| 2419 | 2419 | } | 
| 2420 | 2420 | |
| 2421 | -		if ( ! empty( $query_args['with_videos_only'] ) ) {
 | |
| 2422 | - $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )"; | |
| 2421 | +		if (!empty($query_args['with_videos_only'])) {
 | |
| 2422 | + $where .= " AND ( ".$table.".geodir_video != '' AND ".$table.".geodir_video IS NOT NULL )"; | |
| 2423 | 2423 | } | 
| 2424 | 2424 | |
| 2425 | -		if ( ! empty( $query_args['tax_query'] ) ) {
 | |
| 2426 | - $tax_queries = get_tax_sql( $query_args['tax_query'], $wpdb->posts, 'ID' ); | |
| 2425 | +		if (!empty($query_args['tax_query'])) {
 | |
| 2426 | + $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID'); | |
| 2427 | 2427 | |
| 2428 | -			if ( ! empty( $tax_queries['join'] ) && ! empty( $tax_queries['where'] ) ) {
 | |
| 2428 | +			if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
 | |
| 2429 | 2429 | $where .= $tax_queries['where']; | 
| 2430 | 2430 | } | 
| 2431 | 2431 | } | 
| @@ -2446,11 +2446,11 @@ discard block | ||
| 2446 | 2446 | * | 
| 2447 | 2447 | * @return string Modified orderby clause SQL. | 
| 2448 | 2448 | */ | 
| 2449 | -function geodir_function_widget_listings_orderby( $orderby ) {
 | |
| 2449 | +function geodir_function_widget_listings_orderby($orderby) {
 | |
| 2450 | 2450 | global $wpdb, $plugin_prefix, $gd_query_args_widgets; | 
| 2451 | 2451 | |
| 2452 | 2452 | $query_args = $gd_query_args_widgets; | 
| 2453 | -	if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) {
 | |
| 2453 | +	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
 | |
| 2454 | 2454 | return $orderby; | 
| 2455 | 2455 | } | 
| 2456 | 2456 | |
| @@ -2469,15 +2469,15 @@ discard block | ||
| 2469 | 2469 | * | 
| 2470 | 2470 | * @return int Query limit. | 
| 2471 | 2471 | */ | 
| 2472 | -function geodir_function_widget_listings_limit( $limit ) {
 | |
| 2472 | +function geodir_function_widget_listings_limit($limit) {
 | |
| 2473 | 2473 | global $wpdb, $plugin_prefix, $gd_query_args_widgets; | 
| 2474 | 2474 | |
| 2475 | 2475 | $query_args = $gd_query_args_widgets; | 
| 2476 | -	if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) {
 | |
| 2476 | +	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
 | |
| 2477 | 2477 | return $limit; | 
| 2478 | 2478 | } | 
| 2479 | 2479 | |
| 2480 | -	if ( ! empty( $query_args ) && ! empty( $query_args['posts_per_page'] ) ) {
 | |
| 2480 | +	if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
 | |
| 2481 | 2481 | $limit = (int) $query_args['posts_per_page']; | 
| 2482 | 2482 | } | 
| 2483 | 2483 | |
| @@ -2495,12 +2495,12 @@ discard block | ||
| 2495 | 2495 | * | 
| 2496 | 2496 | * @return int Large size width. | 
| 2497 | 2497 | */ | 
| 2498 | -function geodir_media_image_large_width( $default = 800, $params = '' ) {
 | |
| 2499 | - $large_size_w = get_option( 'large_size_w' ); | |
| 2498 | +function geodir_media_image_large_width($default = 800, $params = '') {
 | |
| 2499 | +	$large_size_w = get_option('large_size_w');
 | |
| 2500 | 2500 | $large_size_w = $large_size_w > 0 ? $large_size_w : $default; | 
| 2501 | - $large_size_w = absint( $large_size_w ); | |
| 2501 | + $large_size_w = absint($large_size_w); | |
| 2502 | 2502 | |
| 2503 | -	if ( ! get_option( 'geodir_use_wp_media_large_size' ) ) {
 | |
| 2503 | +	if (!get_option('geodir_use_wp_media_large_size')) {
 | |
| 2504 | 2504 | $large_size_w = 800; | 
| 2505 | 2505 | } | 
| 2506 | 2506 | |
| @@ -2513,7 +2513,7 @@ discard block | ||
| 2513 | 2513 | * @param int $default Default width. | 
| 2514 | 2514 | * @param string|array $params Image parameters. | 
| 2515 | 2515 | */ | 
| 2516 | - $large_size_w = apply_filters( 'geodir_filter_media_image_large_width', $large_size_w, $default, $params ); | |
| 2516 | +	$large_size_w = apply_filters('geodir_filter_media_image_large_width', $large_size_w, $default, $params);
 | |
| 2517 | 2517 | |
| 2518 | 2518 | return $large_size_w; | 
| 2519 | 2519 | } | 
| @@ -2529,12 +2529,12 @@ discard block | ||
| 2529 | 2529 | * | 
| 2530 | 2530 | * @return int Large size height. | 
| 2531 | 2531 | */ | 
| 2532 | -function geodir_media_image_large_height( $default = 800, $params = '' ) {
 | |
| 2533 | - $large_size_h = get_option( 'large_size_h' ); | |
| 2532 | +function geodir_media_image_large_height($default = 800, $params = '') {
 | |
| 2533 | +	$large_size_h = get_option('large_size_h');
 | |
| 2534 | 2534 | $large_size_h = $large_size_h > 0 ? $large_size_h : $default; | 
| 2535 | - $large_size_h = absint( $large_size_h ); | |
| 2535 | + $large_size_h = absint($large_size_h); | |
| 2536 | 2536 | |
| 2537 | -	if ( ! get_option( 'geodir_use_wp_media_large_size' ) ) {
 | |
| 2537 | +	if (!get_option('geodir_use_wp_media_large_size')) {
 | |
| 2538 | 2538 | $large_size_h = 800; | 
| 2539 | 2539 | } | 
| 2540 | 2540 | |
| @@ -2547,7 +2547,7 @@ discard block | ||
| 2547 | 2547 | * @param int $default Default height. | 
| 2548 | 2548 | * @param string|array $params Image parameters. | 
| 2549 | 2549 | */ | 
| 2550 | - $large_size_h = apply_filters( 'geodir_filter_media_image_large_height', $large_size_h, $default, $params ); | |
| 2550 | +	$large_size_h = apply_filters('geodir_filter_media_image_large_height', $large_size_h, $default, $params);
 | |
| 2551 | 2551 | |
| 2552 | 2552 | return $large_size_h; | 
| 2553 | 2553 | } | 
| @@ -2564,8 +2564,8 @@ discard block | ||
| 2564 | 2564 | * | 
| 2565 | 2565 | * @return string Sanitized name. | 
| 2566 | 2566 | */ | 
| 2567 | -function geodir_sanitize_location_name( $type, $name, $translate = true ) {
 | |
| 2568 | -	if ( $name == '' ) {
 | |
| 2567 | +function geodir_sanitize_location_name($type, $name, $translate = true) {
 | |
| 2568 | +	if ($name == '') {
 | |
| 2569 | 2569 | return null; | 
| 2570 | 2570 | } | 
| 2571 | 2571 | |
| @@ -2574,13 +2574,13 @@ discard block | ||
| 2574 | 2574 | $type = $type == 'gd_city' ? 'city' : $type; | 
| 2575 | 2575 | |
| 2576 | 2576 | $return = $name; | 
| 2577 | -	if ( function_exists( 'get_actual_location_name' ) ) {
 | |
| 2578 | - $return = get_actual_location_name( $type, $name, $translate ); | |
| 2577 | +	if (function_exists('get_actual_location_name')) {
 | |
| 2578 | + $return = get_actual_location_name($type, $name, $translate); | |
| 2579 | 2579 |  	} else {
 | 
| 2580 | - $return = preg_replace( '/-(\d+)$/', '', $return ); | |
| 2581 | - $return = preg_replace( '/[_-]/', ' ', $return ); | |
| 2582 | - $return = geodir_ucwords( $return ); | |
| 2583 | - $return = $translate ? __( $return, 'geodirectory' ) : $return; | |
| 2580 | +		$return = preg_replace('/-(\d+)$/', '', $return);
 | |
| 2581 | +		$return = preg_replace('/[_-]/', ' ', $return);
 | |
| 2582 | + $return = geodir_ucwords($return); | |
| 2583 | + $return = $translate ? __($return, 'geodirectory') : $return; | |
| 2584 | 2584 | } | 
| 2585 | 2585 | |
| 2586 | 2586 | return $return; | 
| @@ -2595,14 +2595,14 @@ discard block | ||
| 2595 | 2595 | * | 
| 2596 | 2596 | * @param int $number Comments number. | 
| 2597 | 2597 | */ | 
| 2598 | -function geodir_comments_number( $number ) {
 | |
| 2598 | +function geodir_comments_number($number) {
 | |
| 2599 | 2599 | |
| 2600 | -	if ( $number > 1 ) {
 | |
| 2601 | - $output = str_replace( '%', number_format_i18n( $number ), __( '% Reviews', 'geodirectory' ) ); | |
| 2602 | -	} elseif ( $number == 0 || $number == '' ) {
 | |
| 2603 | - $output = __( 'No Reviews', 'geodirectory' ); | |
| 2600 | +	if ($number > 1) {
 | |
| 2601 | +		$output = str_replace('%', number_format_i18n($number), __('% Reviews', 'geodirectory'));
 | |
| 2602 | +	} elseif ($number == 0 || $number == '') {
 | |
| 2603 | +		$output = __('No Reviews', 'geodirectory');
 | |
| 2604 | 2604 |  	} else { // must be one
 | 
| 2605 | - $output = __( '1 Review', 'geodirectory' ); | |
| 2605 | +		$output = __('1 Review', 'geodirectory');
 | |
| 2606 | 2606 | } | 
| 2607 | 2607 | echo $output; | 
| 2608 | 2608 | } | 
| @@ -2617,18 +2617,18 @@ discard block | ||
| 2617 | 2617 | */ | 
| 2618 | 2618 |  function is_page_geodir_home() {
 | 
| 2619 | 2619 | global $wpdb; | 
| 2620 | - $cur_url = str_replace( array( "https://", "http://", "www." ), array( '', '', '' ), geodir_curPageURL() ); | |
| 2621 | -	if ( function_exists( 'geodir_location_geo_home_link' ) ) {
 | |
| 2622 | - remove_filter( 'home_url', 'geodir_location_geo_home_link', 100000 ); | |
| 2620 | +	$cur_url = str_replace(array("https://", "http://", "www."), array('', '', ''), geodir_curPageURL());
 | |
| 2621 | +	if (function_exists('geodir_location_geo_home_link')) {
 | |
| 2622 | +		remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
 | |
| 2623 | 2623 | } | 
| 2624 | - $home_url = home_url( '', 'http' ); | |
| 2625 | -	if ( function_exists( 'geodir_location_geo_home_link' ) ) {
 | |
| 2626 | - add_filter( 'home_url', 'geodir_location_geo_home_link', 100000, 2 ); | |
| 2624 | +	$home_url = home_url('', 'http');
 | |
| 2625 | +	if (function_exists('geodir_location_geo_home_link')) {
 | |
| 2626 | +		add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
 | |
| 2627 | 2627 | } | 
| 2628 | - $home_url = str_replace( "www.", "", $home_url ); | |
| 2629 | -	if ( ( strpos( $home_url, $cur_url ) !== false || strpos( $home_url . '/', $cur_url ) !== false ) && ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) && get_option( 'page_on_front' ) == get_option( 'geodir_home_page' ) ) ) {
 | |
| 2628 | +	$home_url = str_replace("www.", "", $home_url);
 | |
| 2629 | +	if ((strpos($home_url, $cur_url) !== false || strpos($home_url.'/', $cur_url) !== false) && ('page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front') == get_option('geodir_home_page'))) {
 | |
| 2630 | 2630 | return true; | 
| 2631 | -	} elseif ( get_query_var( 'page_id' ) == get_option( 'page_on_front' ) && 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) && get_option( 'page_on_front' ) == get_option( 'geodir_home_page' ) ) {
 | |
| 2631 | +	} elseif (get_query_var('page_id') == get_option('page_on_front') && 'page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front') == get_option('geodir_home_page')) {
 | |
| 2632 | 2632 | return true; | 
| 2633 | 2633 |  	} else {
 | 
| 2634 | 2634 | return false; | 
| @@ -2648,18 +2648,18 @@ discard block | ||
| 2648 | 2648 | * | 
| 2649 | 2649 | * @return string The canonical URL. | 
| 2650 | 2650 | */ | 
| 2651 | -function geodir_wpseo_homepage_canonical( $url ) {
 | |
| 2651 | +function geodir_wpseo_homepage_canonical($url) {
 | |
| 2652 | 2652 | global $post; | 
| 2653 | 2653 | |
| 2654 | -	if ( is_page_geodir_home() ) {
 | |
| 2654 | +	if (is_page_geodir_home()) {
 | |
| 2655 | 2655 | return home_url(); | 
| 2656 | 2656 | } | 
| 2657 | 2657 | |
| 2658 | 2658 | return $url; | 
| 2659 | 2659 | } | 
| 2660 | 2660 | |
| 2661 | -add_filter( 'wpseo_canonical', 'geodir_wpseo_homepage_canonical', 10 ); | |
| 2662 | -add_filter( 'aioseop_canonical_url', 'geodir_wpseo_homepage_canonical', 10 ); | |
| 2661 | +add_filter('wpseo_canonical', 'geodir_wpseo_homepage_canonical', 10);
 | |
| 2662 | +add_filter('aioseop_canonical_url', 'geodir_wpseo_homepage_canonical', 10);
 | |
| 2663 | 2663 | |
| 2664 | 2664 | /** | 
| 2665 | 2665 | * Add extra fields to google maps script call. | 
| @@ -2672,20 +2672,20 @@ discard block | ||
| 2672 | 2672 | * | 
| 2673 | 2673 | * @return string Modified extra string. | 
| 2674 | 2674 | */ | 
| 2675 | -function geodir_googlemap_script_extra_details_page( $extra ) {
 | |
| 2675 | +function geodir_googlemap_script_extra_details_page($extra) {
 | |
| 2676 | 2676 | global $post; | 
| 2677 | 2677 | $add_google_places_api = false; | 
| 2678 | -	if ( isset( $post->post_content ) && has_shortcode( $post->post_content, 'gd_add_listing' ) ) {
 | |
| 2678 | +	if (isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
 | |
| 2679 | 2679 | $add_google_places_api = true; | 
| 2680 | 2680 | } | 
| 2681 | -	if ( ! str_replace( 'libraries=places', '', $extra ) && ( geodir_is_page( 'detail' ) || $add_google_places_api ) ) {
 | |
| 2681 | +	if (!str_replace('libraries=places', '', $extra) && (geodir_is_page('detail') || $add_google_places_api)) {
 | |
| 2682 | 2682 | $extra .= "&libraries=places"; | 
| 2683 | 2683 | } | 
| 2684 | 2684 | |
| 2685 | 2685 | return $extra; | 
| 2686 | 2686 | } | 
| 2687 | 2687 | |
| 2688 | -add_filter( 'geodir_googlemap_script_extra', 'geodir_googlemap_script_extra_details_page', 101, 1 ); | |
| 2688 | +add_filter('geodir_googlemap_script_extra', 'geodir_googlemap_script_extra_details_page', 101, 1);
 | |
| 2689 | 2689 | |
| 2690 | 2690 | |
| 2691 | 2691 | /** | 
| @@ -2703,99 +2703,99 @@ discard block | ||
| 2703 | 2703 | * after_widget. | 
| 2704 | 2704 | * @param array|string $instance The settings for the particular instance of the widget. | 
| 2705 | 2705 | */ | 
| 2706 | -function geodir_popular_post_category_output( $args = '', $instance = '' ) {
 | |
| 2706 | +function geodir_popular_post_category_output($args = '', $instance = '') {
 | |
| 2707 | 2707 | // prints the widget | 
| 2708 | 2708 | global $wpdb, $plugin_prefix, $geodir_post_category_str; | 
| 2709 | - extract( $args, EXTR_SKIP ); | |
| 2709 | + extract($args, EXTR_SKIP); | |
| 2710 | 2710 | |
| 2711 | 2711 | echo $before_widget; | 
| 2712 | 2712 | |
| 2713 | 2713 | /** This filter is documented in geodirectory_widgets.php */ | 
| 2714 | - $title = empty( $instance['title'] ) ? __( 'Popular Categories', 'geodirectory' ) : apply_filters( 'widget_title', __( $instance['title'], 'geodirectory' ) ); | |
| 2714 | +	$title = empty($instance['title']) ? __('Popular Categories', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
 | |
| 2715 | 2715 | |
| 2716 | 2716 | $gd_post_type = geodir_get_current_posttype(); | 
| 2717 | 2717 | |
| 2718 | - $category_limit = isset( $instance['category_limit'] ) && $instance['category_limit'] > 0 ? (int) $instance['category_limit'] : 15; | |
| 2719 | -	if ( ! empty( $gd_post_type ) ) {
 | |
| 2718 | + $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int) $instance['category_limit'] : 15; | |
| 2719 | +	if (!empty($gd_post_type)) {
 | |
| 2720 | 2720 | $default_post_type = $gd_post_type; | 
| 2721 | -	} elseif ( isset( $instance['default_post_type'] ) && gdsc_is_post_type_valid( $instance['default_post_type'] ) ) {
 | |
| 2721 | +	} elseif (isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type'])) {
 | |
| 2722 | 2722 | $default_post_type = $instance['default_post_type']; | 
| 2723 | 2723 |  	} else {
 | 
| 2724 | 2724 | $all_gd_post_type = geodir_get_posttypes(); | 
| 2725 | - $default_post_type = ( isset( $all_gd_post_type[0] ) ) ? $all_gd_post_type[0] : ''; | |
| 2725 | + $default_post_type = (isset($all_gd_post_type[0])) ? $all_gd_post_type[0] : ''; | |
| 2726 | 2726 | } | 
| 2727 | - $parent_only = !empty( $instance['parent_only'] ) ? true : false; | |
| 2727 | + $parent_only = !empty($instance['parent_only']) ? true : false; | |
| 2728 | 2728 | |
| 2729 | 2729 | $taxonomy = array(); | 
| 2730 | -	if ( ! empty( $gd_post_type ) ) {
 | |
| 2731 | - $taxonomy[] = $gd_post_type . "category"; | |
| 2730 | +	if (!empty($gd_post_type)) {
 | |
| 2731 | + $taxonomy[] = $gd_post_type."category"; | |
| 2732 | 2732 |  	} else {
 | 
| 2733 | - $taxonomy = geodir_get_taxonomies( $gd_post_type ); | |
| 2733 | + $taxonomy = geodir_get_taxonomies($gd_post_type); | |
| 2734 | 2734 | } | 
| 2735 | 2735 | |
| 2736 | - $term_args = array( 'taxonomy' => $taxonomy ); | |
| 2737 | -	if ( $parent_only ) {
 | |
| 2736 | +	$term_args = array('taxonomy' => $taxonomy);
 | |
| 2737 | +	if ($parent_only) {
 | |
| 2738 | 2738 | $term_args['parent'] = 0; | 
| 2739 | 2739 | } | 
| 2740 | 2740 | |
| 2741 | - $terms = get_terms( $term_args ); | |
| 2741 | + $terms = get_terms($term_args); | |
| 2742 | 2742 | $a_terms = array(); | 
| 2743 | 2743 | $b_terms = array(); | 
| 2744 | 2744 | |
| 2745 | -	foreach ( $terms as $term ) {
 | |
| 2746 | -		if ( $term->count > 0 ) {
 | |
| 2747 | - $a_terms[ $term->taxonomy ][] = $term; | |
| 2745 | +	foreach ($terms as $term) {
 | |
| 2746 | +		if ($term->count > 0) {
 | |
| 2747 | + $a_terms[$term->taxonomy][] = $term; | |
| 2748 | 2748 | } | 
| 2749 | 2749 | } | 
| 2750 | 2750 | |
| 2751 | -	if ( ! empty( $a_terms ) ) {
 | |
| 2752 | -		foreach ( $a_terms as $b_key => $b_val ) {
 | |
| 2753 | - $b_terms[ $b_key ] = geodir_sort_terms( $b_val, 'count' ); | |
| 2751 | +	if (!empty($a_terms)) {
 | |
| 2752 | +		foreach ($a_terms as $b_key => $b_val) {
 | |
| 2753 | + $b_terms[$b_key] = geodir_sort_terms($b_val, 'count'); | |
| 2754 | 2754 | } | 
| 2755 | 2755 | |
| 2756 | - $default_taxonomy = $default_post_type != '' && isset( $b_terms[ $default_post_type . 'category' ] ) ? $default_post_type . 'category' : ''; | |
| 2756 | + $default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type.'category']) ? $default_post_type.'category' : ''; | |
| 2757 | 2757 | |
| 2758 | 2758 | $tax_change_output = ''; | 
| 2759 | -		if ( count( $b_terms ) > 1 ) {
 | |
| 2760 | - $tax_change_output .= "<select data-limit='$category_limit' data-parent='" . (int)$parent_only . "' class='geodir-cat-list-tax' onchange='geodir_get_post_term(this);'>"; | |
| 2761 | -			foreach ( $b_terms as $key => $val ) {
 | |
| 2762 | - $ptype = get_post_type_object( str_replace( "category", "", $key ) ); | |
| 2763 | - $cpt_name = __( $ptype->labels->singular_name, 'geodirectory' ); | |
| 2764 | - $tax_change_output .= "<option value='$key' " . selected( $key, $default_taxonomy, false ) . ">" . sprintf( __( '%s Categories', 'geodirectory' ), $cpt_name ) . "</option>"; | |
| 2759 | +		if (count($b_terms) > 1) {
 | |
| 2760 | + $tax_change_output .= "<select data-limit='$category_limit' data-parent='".(int) $parent_only."' class='geodir-cat-list-tax' onchange='geodir_get_post_term(this);'>"; | |
| 2761 | +			foreach ($b_terms as $key => $val) {
 | |
| 2762 | +				$ptype    = get_post_type_object(str_replace("category", "", $key));
 | |
| 2763 | + $cpt_name = __($ptype->labels->singular_name, 'geodirectory'); | |
| 2764 | +				$tax_change_output .= "<option value='$key' ".selected($key, $default_taxonomy, false).">".sprintf(__('%s Categories', 'geodirectory'), $cpt_name)."</option>";
 | |
| 2765 | 2765 | } | 
| 2766 | 2766 | $tax_change_output .= "</select>"; | 
| 2767 | 2767 | } | 
| 2768 | 2768 | |
| 2769 | -		if ( ! empty( $b_terms ) ) {
 | |
| 2770 | - $terms = $default_taxonomy != '' && isset( $b_terms[ $default_taxonomy ] ) ? $b_terms[ $default_taxonomy ] : reset( $b_terms );// get the first array | |
| 2771 | - global $cat_count;//make global so we can change via function | |
| 2769 | +		if (!empty($b_terms)) {
 | |
| 2770 | + $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms); // get the first array | |
| 2771 | + global $cat_count; //make global so we can change via function | |
| 2772 | 2772 | $cat_count = 0; | 
| 2773 | 2773 | ?> | 
| 2774 | 2774 | <div class="geodir-category-list-in clearfix"> | 
| 2775 | 2775 | <div class="geodir-cat-list clearfix"> | 
| 2776 | 2776 | <?php | 
| 2777 | - echo $before_title . __( $title ) . $after_title; | |
| 2777 | + echo $before_title.__($title).$after_title; | |
| 2778 | 2778 | |
| 2779 | 2779 | echo $tax_change_output; | 
| 2780 | 2780 | |
| 2781 | 2781 | echo '<ul class="geodir-popular-cat-list">'; | 
| 2782 | 2782 | |
| 2783 | - geodir_helper_cat_list_output( $terms, $category_limit ); | |
| 2783 | + geodir_helper_cat_list_output($terms, $category_limit); | |
| 2784 | 2784 | |
| 2785 | 2785 | echo '</ul>'; | 
| 2786 | 2786 | ?> | 
| 2787 | 2787 | </div> | 
| 2788 | 2788 | <?php | 
| 2789 | 2789 | $hide = ''; | 
| 2790 | -				if ( $cat_count < $category_limit ) {
 | |
| 2790 | +				if ($cat_count < $category_limit) {
 | |
| 2791 | 2791 | $hide = 'style="display:none;"'; | 
| 2792 | 2792 | } | 
| 2793 | 2793 | echo "<div class='geodir-cat-list-more' $hide >"; | 
| 2794 | - echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __( 'More Categories', 'geodirectory' ) . '</a>'; | |
| 2795 | - echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __( 'Less Categories', 'geodirectory' ) . '</a>'; | |
| 2794 | +				echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">'.__('More Categories', 'geodirectory').'</a>';
 | |
| 2795 | +				echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">'.__('Less Categories', 'geodirectory').'</a>';
 | |
| 2796 | 2796 | echo "</div>"; | 
| 2797 | 2797 | /* add scripts */ | 
| 2798 | - add_action( 'wp_footer', 'geodir_popular_category_add_scripts', 100 ); | |
| 2798 | +				add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
 | |
| 2799 | 2799 | ?> | 
| 2800 | 2800 | </div> | 
| 2801 | 2801 | <?php | 
| @@ -2814,25 +2814,25 @@ discard block | ||
| 2814 | 2814 | * @param array $terms An array of term objects. | 
| 2815 | 2815 | * @param int $category_limit Number of categories to display by default. | 
| 2816 | 2816 | */ | 
| 2817 | -function geodir_helper_cat_list_output( $terms, $category_limit ) {
 | |
| 2817 | +function geodir_helper_cat_list_output($terms, $category_limit) {
 | |
| 2818 | 2818 | global $geodir_post_category_str, $cat_count; | 
| 2819 | 2819 | $term_icons = geodir_get_term_icon(); | 
| 2820 | 2820 | |
| 2821 | 2821 | $geodir_post_category_str = array(); | 
| 2822 | 2822 | |
| 2823 | 2823 | |
| 2824 | -	foreach ( $terms as $cat ) {
 | |
| 2825 | - $post_type = str_replace( "category", "", $cat->taxonomy ); | |
| 2826 | - $term_icon_url = ! empty( $term_icons ) && isset( $term_icons[ $cat->term_id ] ) ? $term_icons[ $cat->term_id ] : ''; | |
| 2824 | +	foreach ($terms as $cat) {
 | |
| 2825 | +		$post_type     = str_replace("category", "", $cat->taxonomy);
 | |
| 2826 | + $term_icon_url = !empty($term_icons) && isset($term_icons[$cat->term_id]) ? $term_icons[$cat->term_id] : ''; | |
| 2827 | 2827 | |
| 2828 | - $cat_count ++; | |
| 2828 | + $cat_count++; | |
| 2829 | 2829 | |
| 2830 | - $geodir_post_category_str[] = array( 'posttype' => $post_type, 'termid' => $cat->term_id ); | |
| 2830 | +		$geodir_post_category_str[] = array('posttype' => $post_type, 'termid' => $cat->term_id);
 | |
| 2831 | 2831 | |
| 2832 | 2832 | $class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show'; | 
| 2833 | 2833 | $total_post = $cat->count; | 
| 2834 | 2834 | |
| 2835 | - $term_link = get_term_link( $cat, $cat->taxonomy ); | |
| 2835 | + $term_link = get_term_link($cat, $cat->taxonomy); | |
| 2836 | 2836 | /** | 
| 2837 | 2837 | * Filer the category term link. | 
| 2838 | 2838 | * | 
| @@ -2842,11 +2842,11 @@ discard block | ||
| 2842 | 2842 | * @param int $cat ->term_id The term id. | 
| 2843 | 2843 | * @param string $post_type Wordpress post type. | 
| 2844 | 2844 | */ | 
| 2845 | - $term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type ); | |
| 2845 | +		$term_link = apply_filters('geodir_category_term_link', $term_link, $cat->term_id, $post_type);
 | |
| 2846 | 2846 | |
| 2847 | - echo '<li class="' . $class_row . '"><a href="' . $term_link . '">'; | |
| 2848 | - echo '<img alt="' . esc_attr( $cat->name ) . ' icon" style="height:20px;vertical-align:middle;" src="' . $term_icon_url . '"/> <span class="cat-link">'; | |
| 2849 | -		echo $cat->name . '</span> <span class="geodir_term_class geodir_link_span geodir_category_class_' . $post_type . '_' . $cat->term_id . '">(' . $total_post . ')</span> ';
 | |
| 2847 | + echo '<li class="'.$class_row.'"><a href="'.$term_link.'">'; | |
| 2848 | + echo '<img alt="'.esc_attr($cat->name).' icon" style="height:20px;vertical-align:middle;" src="'.$term_icon_url.'"/> <span class="cat-link">'; | |
| 2849 | +		echo $cat->name.'</span> <span class="geodir_term_class geodir_link_span geodir_category_class_'.$post_type.'_'.$cat->term_id.'">('.$total_post.')</span> ';
 | |
| 2850 | 2850 | echo '</a></li>'; | 
| 2851 | 2851 | } | 
| 2852 | 2852 | } | 
| @@ -2861,14 +2861,14 @@ discard block | ||
| 2861 | 2861 | * @param array|string $args Display arguments including before_title, after_title, before_widget, and after_widget. | 
| 2862 | 2862 | * @param array|string $instance The settings for the particular instance of the widget. | 
| 2863 | 2863 | */ | 
| 2864 | -function geodir_listing_slider_widget_output( $args = '', $instance = '' ) {
 | |
| 2864 | +function geodir_listing_slider_widget_output($args = '', $instance = '') {
 | |
| 2865 | 2865 | // prints the widget | 
| 2866 | - extract( $args, EXTR_SKIP ); | |
| 2866 | + extract($args, EXTR_SKIP); | |
| 2867 | 2867 | |
| 2868 | 2868 | echo $before_widget; | 
| 2869 | 2869 | |
| 2870 | 2870 | /** This filter is documented in geodirectory_widgets.php */ | 
| 2871 | - $title = empty( $instance['title'] ) ? '' : apply_filters( 'widget_title', __( $instance['title'], 'geodirectory' ) ); | |
| 2871 | +	$title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
 | |
| 2872 | 2872 | /** | 
| 2873 | 2873 | * Filter the widget post type. | 
| 2874 | 2874 | * | 
| @@ -2876,7 +2876,7 @@ discard block | ||
| 2876 | 2876 | * | 
| 2877 | 2877 | * @param string $instance ['post_type'] Post type of listing. | 
| 2878 | 2878 | */ | 
| 2879 | - $post_type = empty( $instance['post_type'] ) ? 'gd_place' : apply_filters( 'widget_post_type', $instance['post_type'] ); | |
| 2879 | +	$post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
 | |
| 2880 | 2880 | /** | 
| 2881 | 2881 | * Filter the widget's term. | 
| 2882 | 2882 | * | 
| @@ -2884,7 +2884,7 @@ discard block | ||
| 2884 | 2884 | * | 
| 2885 | 2885 | * @param string $instance ['category'] Filter by term. Can be any valid term. | 
| 2886 | 2886 | */ | 
| 2887 | - $category = empty( $instance['category'] ) ? '0' : apply_filters( 'widget_category', $instance['category'] ); | |
| 2887 | +	$category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
 | |
| 2888 | 2888 | /** | 
| 2889 | 2889 | * Filter widget's "add_location_filter" value. | 
| 2890 | 2890 | * | 
| @@ -2892,7 +2892,7 @@ discard block | ||
| 2892 | 2892 | * | 
| 2893 | 2893 | * @param string|bool $instance ['add_location_filter'] Do you want to add location filter? Can be 1 or 0. | 
| 2894 | 2894 | */ | 
| 2895 | - $add_location_filter = empty( $instance['add_location_filter'] ) ? '0' : apply_filters( 'widget_add_location_filter', $instance['add_location_filter'] ); | |
| 2895 | +	$add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']);
 | |
| 2896 | 2896 | /** | 
| 2897 | 2897 | * Filter the widget listings limit. | 
| 2898 | 2898 | * | 
| @@ -2900,7 +2900,7 @@ discard block | ||
| 2900 | 2900 | * | 
| 2901 | 2901 | * @param string $instance ['post_number'] Number of listings to display. | 
| 2902 | 2902 | */ | 
| 2903 | - $post_number = empty( $instance['post_number'] ) ? '5' : apply_filters( 'widget_post_number', $instance['post_number'] ); | |
| 2903 | +	$post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
 | |
| 2904 | 2904 | /** | 
| 2905 | 2905 | * Filter the widget listings limit shown at one time. | 
| 2906 | 2906 | * | 
| @@ -2908,7 +2908,7 @@ discard block | ||
| 2908 | 2908 | * | 
| 2909 | 2909 | * @param string $instance ['max_show'] Number of listings to display on screen. | 
| 2910 | 2910 | */ | 
| 2911 | - $max_show = empty( $instance['max_show'] ) ? '1' : apply_filters( 'widget_max_show', $instance['max_show'] ); | |
| 2911 | +	$max_show = empty($instance['max_show']) ? '1' : apply_filters('widget_max_show', $instance['max_show']);
 | |
| 2912 | 2912 | /** | 
| 2913 | 2913 | * Filter the widget slide width. | 
| 2914 | 2914 | * | 
| @@ -2916,7 +2916,7 @@ discard block | ||
| 2916 | 2916 | * | 
| 2917 | 2917 | * @param string $instance ['slide_width'] Width of the slides shown. | 
| 2918 | 2918 | */ | 
| 2919 | - $slide_width = empty( $instance['slide_width'] ) ? '' : apply_filters( 'widget_slide_width', $instance['slide_width'] ); | |
| 2919 | +	$slide_width = empty($instance['slide_width']) ? '' : apply_filters('widget_slide_width', $instance['slide_width']);
 | |
| 2920 | 2920 | /** | 
| 2921 | 2921 | * Filter widget's "show title" value. | 
| 2922 | 2922 | * | 
| @@ -2924,7 +2924,7 @@ discard block | ||
| 2924 | 2924 | * | 
| 2925 | 2925 | * @param string|bool $instance ['show_title'] Do you want to display title? Can be 1 or 0. | 
| 2926 | 2926 | */ | 
| 2927 | - $show_title = empty( $instance['show_title'] ) ? '' : apply_filters( 'widget_show_title', $instance['show_title'] ); | |
| 2927 | +	$show_title = empty($instance['show_title']) ? '' : apply_filters('widget_show_title', $instance['show_title']);
 | |
| 2928 | 2928 | /** | 
| 2929 | 2929 | * Filter widget's "slideshow" value. | 
| 2930 | 2930 | * | 
| @@ -2932,7 +2932,7 @@ discard block | ||
| 2932 | 2932 | * | 
| 2933 | 2933 | * @param int $instance ['slideshow'] Setup a slideshow for the slider to animate automatically. | 
| 2934 | 2934 | */ | 
| 2935 | - $slideshow = empty( $instance['slideshow'] ) ? 0 : apply_filters( 'widget_slideshow', $instance['slideshow'] ); | |
| 2935 | +	$slideshow = empty($instance['slideshow']) ? 0 : apply_filters('widget_slideshow', $instance['slideshow']);
 | |
| 2936 | 2936 | /** | 
| 2937 | 2937 | * Filter widget's "animationLoop" value. | 
| 2938 | 2938 | * | 
| @@ -2940,7 +2940,7 @@ discard block | ||
| 2940 | 2940 | * | 
| 2941 | 2941 | * @param int $instance ['animationLoop'] Gives the slider a seamless infinite loop. | 
| 2942 | 2942 | */ | 
| 2943 | - $animationLoop = empty( $instance['animationLoop'] ) ? 0 : apply_filters( 'widget_animationLoop', $instance['animationLoop'] ); | |
| 2943 | +	$animationLoop = empty($instance['animationLoop']) ? 0 : apply_filters('widget_animationLoop', $instance['animationLoop']);
 | |
| 2944 | 2944 | /** | 
| 2945 | 2945 | * Filter widget's "directionNav" value. | 
| 2946 | 2946 | * | 
| @@ -2948,7 +2948,7 @@ discard block | ||
| 2948 | 2948 | * | 
| 2949 | 2949 | * @param int $instance ['directionNav'] Enable previous/next arrow navigation?. Can be 1 or 0. | 
| 2950 | 2950 | */ | 
| 2951 | - $directionNav = empty( $instance['directionNav'] ) ? 0 : apply_filters( 'widget_directionNav', $instance['directionNav'] ); | |
| 2951 | +	$directionNav = empty($instance['directionNav']) ? 0 : apply_filters('widget_directionNav', $instance['directionNav']);
 | |
| 2952 | 2952 | /** | 
| 2953 | 2953 | * Filter widget's "slideshowSpeed" value. | 
| 2954 | 2954 | * | 
| @@ -2956,7 +2956,7 @@ discard block | ||
| 2956 | 2956 | * | 
| 2957 | 2957 | * @param int $instance ['slideshowSpeed'] Set the speed of the slideshow cycling, in milliseconds. | 
| 2958 | 2958 | */ | 
| 2959 | - $slideshowSpeed = empty( $instance['slideshowSpeed'] ) ? 5000 : apply_filters( 'widget_slideshowSpeed', $instance['slideshowSpeed'] ); | |
| 2959 | +	$slideshowSpeed = empty($instance['slideshowSpeed']) ? 5000 : apply_filters('widget_slideshowSpeed', $instance['slideshowSpeed']);
 | |
| 2960 | 2960 | /** | 
| 2961 | 2961 | * Filter widget's "animationSpeed" value. | 
| 2962 | 2962 | * | 
| @@ -2964,7 +2964,7 @@ discard block | ||
| 2964 | 2964 | * | 
| 2965 | 2965 | * @param int $instance ['animationSpeed'] Set the speed of animations, in milliseconds. | 
| 2966 | 2966 | */ | 
| 2967 | - $animationSpeed = empty( $instance['animationSpeed'] ) ? 600 : apply_filters( 'widget_animationSpeed', $instance['animationSpeed'] ); | |
| 2967 | +	$animationSpeed = empty($instance['animationSpeed']) ? 600 : apply_filters('widget_animationSpeed', $instance['animationSpeed']);
 | |
| 2968 | 2968 | /** | 
| 2969 | 2969 | * Filter widget's "animation" value. | 
| 2970 | 2970 | * | 
| @@ -2972,7 +2972,7 @@ discard block | ||
| 2972 | 2972 | * | 
| 2973 | 2973 | * @param string $instance ['animation'] Controls the animation type, "fade" or "slide". | 
| 2974 | 2974 | */ | 
| 2975 | - $animation = empty( $instance['animation'] ) ? 'slide' : apply_filters( 'widget_animation', $instance['animation'] ); | |
| 2975 | +	$animation = empty($instance['animation']) ? 'slide' : apply_filters('widget_animation', $instance['animation']);
 | |
| 2976 | 2976 | /** | 
| 2977 | 2977 | * Filter widget's "list_sort" type. | 
| 2978 | 2978 | * | 
| @@ -2980,10 +2980,10 @@ discard block | ||
| 2980 | 2980 | * | 
| 2981 | 2981 | * @param string $instance ['list_sort'] Listing sort by type. | 
| 2982 | 2982 | */ | 
| 2983 | - $list_sort = empty( $instance['list_sort'] ) ? 'latest' : apply_filters( 'widget_list_sort', $instance['list_sort'] ); | |
| 2984 | - $show_featured_only = ! empty( $instance['show_featured_only'] ) ? 1 : null; | |
| 2983 | +	$list_sort          = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
 | |
| 2984 | + $show_featured_only = !empty($instance['show_featured_only']) ? 1 : null; | |
| 2985 | 2985 | |
| 2986 | - wp_enqueue_script( 'geodirectory-jquery-flexslider-js' ); | |
| 2986 | +	wp_enqueue_script('geodirectory-jquery-flexslider-js');
 | |
| 2987 | 2987 | ?> | 
| 2988 | 2988 | <script type="text/javascript"> | 
| 2989 | 2989 |  		jQuery(window).load(function () {
 | 
| @@ -2998,23 +2998,23 @@ discard block | ||
| 2998 | 2998 | itemWidth: 75, | 
| 2999 | 2999 | itemMargin: 5, | 
| 3000 | 3000 | asNavFor: '#geodir_widget_slider', | 
| 3001 | - rtl: <?php echo( is_rtl() ? 'true' : 'false' ); /* fix rtl issue */ ?> | |
| 3001 | + rtl: <?php echo(is_rtl() ? 'true' : 'false'); /* fix rtl issue */ ?> | |
| 3002 | 3002 | }); | 
| 3003 | 3003 | |
| 3004 | 3004 |  			jQuery('#geodir_widget_slider').flexslider({
 | 
| 3005 | - animation: "<?php echo $animation;?>", | |
| 3005 | + animation: "<?php echo $animation; ?>", | |
| 3006 | 3006 | selector: ".geodir-slides > li", | 
| 3007 | 3007 | namespace: "geodir-", | 
| 3008 | 3008 | controlNav: true, | 
| 3009 | - animationLoop: <?php echo $animationLoop;?>, | |
| 3010 | - slideshow: <?php echo $slideshow;?>, | |
| 3011 | - slideshowSpeed: <?php echo $slideshowSpeed;?>, | |
| 3012 | - animationSpeed: <?php echo $animationSpeed;?>, | |
| 3013 | - directionNav: <?php echo $directionNav;?>, | |
| 3014 | - maxItems: <?php echo $max_show;?>, | |
| 3009 | + animationLoop: <?php echo $animationLoop; ?>, | |
| 3010 | + slideshow: <?php echo $slideshow; ?>, | |
| 3011 | + slideshowSpeed: <?php echo $slideshowSpeed; ?>, | |
| 3012 | + animationSpeed: <?php echo $animationSpeed; ?>, | |
| 3013 | + directionNav: <?php echo $directionNav; ?>, | |
| 3014 | + maxItems: <?php echo $max_show; ?>, | |
| 3015 | 3015 | move: 1, | 
| 3016 | -				<?php if ( $slide_width ) {
 | |
| 3017 | - echo "itemWidth: " . $slide_width . ","; | |
| 3016 | +				<?php if ($slide_width) {
 | |
| 3017 | + echo "itemWidth: ".$slide_width.","; | |
| 3018 | 3018 | }?> | 
| 3019 | 3019 | sync: "#geodir_widget_carousel", | 
| 3020 | 3020 |  				start: function (slider) {
 | 
| @@ -3022,7 +3022,7 @@ discard block | ||
| 3022 | 3022 |  					jQuery('#geodir_widget_slider').css({'visibility': 'visible'});
 | 
| 3023 | 3023 |  					jQuery('#geodir_widget_carousel').css({'visibility': 'visible'});
 | 
| 3024 | 3024 | }, | 
| 3025 | - rtl: <?php echo( is_rtl() ? 'true' : 'false' ); /* fix rtl issue */ ?> | |
| 3025 | + rtl: <?php echo(is_rtl() ? 'true' : 'false'); /* fix rtl issue */ ?> | |
| 3026 | 3026 | }); | 
| 3027 | 3027 | }); | 
| 3028 | 3028 | </script> | 
| @@ -3035,62 +3035,62 @@ discard block | ||
| 3035 | 3035 | 'order_by' => $list_sort | 
| 3036 | 3036 | ); | 
| 3037 | 3037 | |
| 3038 | -	if ( $show_featured_only ) {
 | |
| 3038 | +	if ($show_featured_only) {
 | |
| 3039 | 3039 | $query_args['show_featured_only'] = 1; | 
| 3040 | 3040 | } | 
| 3041 | 3041 | |
| 3042 | -	if ( $category != 0 || $category != '' ) {
 | |
| 3043 | - $category_taxonomy = geodir_get_taxonomies( $post_type ); | |
| 3042 | +	if ($category != 0 || $category != '') {
 | |
| 3043 | + $category_taxonomy = geodir_get_taxonomies($post_type); | |
| 3044 | 3044 | $tax_query = array( | 
| 3045 | 3045 | 'taxonomy' => $category_taxonomy[0], | 
| 3046 | 3046 | 'field' => 'id', | 
| 3047 | 3047 | 'terms' => $category | 
| 3048 | 3048 | ); | 
| 3049 | 3049 | |
| 3050 | - $query_args['tax_query'] = array( $tax_query ); | |
| 3050 | + $query_args['tax_query'] = array($tax_query); | |
| 3051 | 3051 | } | 
| 3052 | 3052 | |
| 3053 | 3053 | // we want listings with featured image only | 
| 3054 | 3054 | $query_args['featured_image_only'] = 1; | 
| 3055 | 3055 | |
| 3056 | -	if ( $post_type == 'gd_event' ) {
 | |
| 3056 | +	if ($post_type == 'gd_event') {
 | |
| 3057 | 3057 | $query_args['gedir_event_listing_filter'] = 'upcoming'; | 
| 3058 | 3058 | }// show only upcoming events | 
| 3059 | 3059 | |
| 3060 | - $widget_listings = geodir_get_widget_listings( $query_args ); | |
| 3061 | -	if ( ! empty( $widget_listings ) || ( isset( $with_no_results ) && $with_no_results ) ) {
 | |
| 3062 | -		if ( $title ) {
 | |
| 3063 | - echo $before_title . $title . $after_title; | |
| 3060 | + $widget_listings = geodir_get_widget_listings($query_args); | |
| 3061 | +	if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
 | |
| 3062 | +		if ($title) {
 | |
| 3063 | + echo $before_title.$title.$after_title; | |
| 3064 | 3064 | } | 
| 3065 | 3065 | |
| 3066 | 3066 | global $post; | 
| 3067 | 3067 | |
| 3068 | - $current_post = $post;// keep current post info | |
| 3068 | + $current_post = $post; // keep current post info | |
| 3069 | 3069 | |
| 3070 | 3070 | $widget_main_slides = ''; | 
| 3071 | 3071 | $nav_slides = ''; | 
| 3072 | 3072 | $widget_slides = 0; | 
| 3073 | 3073 | |
| 3074 | -		foreach ( $widget_listings as $widget_listing ) {
 | |
| 3074 | +		foreach ($widget_listings as $widget_listing) {
 | |
| 3075 | 3075 | global $gd_widget_listing_type; | 
| 3076 | 3076 | $post = $widget_listing; | 
| 3077 | - $widget_image = geodir_get_featured_image( $post->ID, 'thumbnail', get_option( 'geodir_listing_no_img' ) ); | |
| 3077 | +			$widget_image = geodir_get_featured_image($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
 | |
| 3078 | 3078 | |
| 3079 | -			if ( ! empty( $widget_image ) ) {
 | |
| 3080 | -				if ( $widget_image->height >= 200 ) {
 | |
| 3079 | +			if (!empty($widget_image)) {
 | |
| 3080 | +				if ($widget_image->height >= 200) {
 | |
| 3081 | 3081 | $widget_spacer_height = 0; | 
| 3082 | 3082 |  				} else {
 | 
| 3083 | - $widget_spacer_height = ( ( 200 - $widget_image->height ) / 2 ); | |
| 3083 | + $widget_spacer_height = ((200 - $widget_image->height) / 2); | |
| 3084 | 3084 | } | 
| 3085 | 3085 | |
| 3086 | - $widget_main_slides .= '<li class="geodir-listing-slider-widget"><img class="geodir-listing-slider-spacer" src="' . geodir_plugin_url() . "/geodirectory-assets/images/spacer.gif" . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:' . $widget_spacer_height . 'px !important;margin:0 auto;" width="100" />'; | |
| 3086 | + $widget_main_slides .= '<li class="geodir-listing-slider-widget"><img class="geodir-listing-slider-spacer" src="'.geodir_plugin_url()."/geodirectory-assets/images/spacer.gif".'" alt="'.$widget_image->title.'" title="'.$widget_image->title.'" style="max-height:'.$widget_spacer_height.'px !important;margin:0 auto;" width="100" />'; | |
| 3087 | 3087 | |
| 3088 | 3088 | $title = ''; | 
| 3089 | -				if ( $show_title ) {
 | |
| 3090 | - $title_html = '<div class="geodir-slider-title"><a href="' . get_permalink( $post->ID ) . '">' . get_the_title( $post->ID ) . '</a></div>'; | |
| 3089 | +				if ($show_title) {
 | |
| 3090 | + $title_html = '<div class="geodir-slider-title"><a href="'.get_permalink($post->ID).'">'.get_the_title($post->ID).'</a></div>'; | |
| 3091 | 3091 | $post_id = $post->ID; | 
| 3092 | - $post_permalink = get_permalink( $post->ID ); | |
| 3093 | - $post_title = get_the_title( $post->ID ); | |
| 3092 | + $post_permalink = get_permalink($post->ID); | |
| 3093 | + $post_title = get_the_title($post->ID); | |
| 3094 | 3094 | /** | 
| 3095 | 3095 | * Filter the listing slider widget title. | 
| 3096 | 3096 | * | 
| @@ -3101,12 +3101,12 @@ discard block | ||
| 3101 | 3101 | * @param string $post_permalink The post permalink url. | 
| 3102 | 3102 | * @param string $post_title The post title text. | 
| 3103 | 3103 | */ | 
| 3104 | - $title = apply_filters( 'geodir_listing_slider_title', $title_html, $post_id, $post_permalink, $post_title ); | |
| 3104 | +					$title = apply_filters('geodir_listing_slider_title', $title_html, $post_id, $post_permalink, $post_title);
 | |
| 3105 | 3105 | } | 
| 3106 | 3106 | |
| 3107 | - $widget_main_slides .= $title . '<img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:200px;margin:0 auto;" /></li>'; | |
| 3108 | - $nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>'; | |
| 3109 | - $widget_slides ++; | |
| 3107 | + $widget_main_slides .= $title.'<img src="'.$widget_image->src.'" alt="'.$widget_image->title.'" title="'.$widget_image->title.'" style="max-height:200px;margin:0 auto;" /></li>'; | |
| 3108 | + $nav_slides .= '<li><img src="'.$widget_image->src.'" alt="'.$widget_image->title.'" title="'.$widget_image->title.'" style="max-height:48px;margin:0 auto;" /></li>'; | |
| 3109 | + $widget_slides++; | |
| 3110 | 3110 | } | 
| 3111 | 3111 | } | 
| 3112 | 3112 | ?> | 
| @@ -3115,7 +3115,7 @@ discard block | ||
| 3115 | 3115 | <div id="geodir_widget_slider" class="geodir_flexslider"> | 
| 3116 | 3116 | <ul class="geodir-slides clearfix"><?php echo $widget_main_slides; ?></ul> | 
| 3117 | 3117 | </div> | 
| 3118 | -			<?php if ( $widget_slides > 1 ) { ?>
 | |
| 3118 | +			<?php if ($widget_slides > 1) { ?>
 | |
| 3119 | 3119 | <div id="geodir_widget_carousel" class="geodir_flexslider"> | 
| 3120 | 3120 | <ul class="geodir-slides clearfix"><?php echo $nav_slides; ?></ul> | 
| 3121 | 3121 | </div> | 
| @@ -3123,7 +3123,7 @@ discard block | ||
| 3123 | 3123 | </div> | 
| 3124 | 3124 | <?php | 
| 3125 | 3125 | $GLOBALS['post'] = $current_post; | 
| 3126 | - setup_postdata( $current_post ); | |
| 3126 | + setup_postdata($current_post); | |
| 3127 | 3127 | } | 
| 3128 | 3128 | echo $after_widget; | 
| 3129 | 3129 | } | 
| @@ -3139,46 +3139,46 @@ discard block | ||
| 3139 | 3139 | * @param array|string $args Display arguments including before_title, after_title, before_widget, and after_widget. | 
| 3140 | 3140 | * @param array|string $instance The settings for the particular instance of the widget. | 
| 3141 | 3141 | */ | 
| 3142 | -function geodir_loginwidget_output( $args = '', $instance = '' ) {
 | |
| 3142 | +function geodir_loginwidget_output($args = '', $instance = '') {
 | |
| 3143 | 3143 | //print_r($args); | 
| 3144 | 3144 | //print_r($instance); | 
| 3145 | 3145 | // prints the widget | 
| 3146 | - extract( $args, EXTR_SKIP ); | |
| 3146 | + extract($args, EXTR_SKIP); | |
| 3147 | 3147 | |
| 3148 | 3148 | /** This filter is documented in geodirectory_widgets.php */ | 
| 3149 | - $title = empty( $instance['title'] ) ? __( 'My Dashboard', 'geodirectory' ) : apply_filters( 'my_dashboard_widget_title', __( $instance['title'], 'geodirectory' ) ); | |
| 3149 | +	$title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('my_dashboard_widget_title', __($instance['title'], 'geodirectory'));
 | |
| 3150 | 3150 | |
| 3151 | 3151 | echo $before_widget; | 
| 3152 | - echo $before_title . $title . $after_title; | |
| 3152 | + echo $before_title.$title.$after_title; | |
| 3153 | 3153 | |
| 3154 | -	if ( is_user_logged_in() ) {
 | |
| 3154 | +	if (is_user_logged_in()) {
 | |
| 3155 | 3155 | global $current_user; | 
| 3156 | 3156 | |
| 3157 | - $author_link = get_author_posts_url( $current_user->data->ID ); | |
| 3158 | - $author_link = geodir_getlink( $author_link, array( 'geodir_dashbord' => 'true' ), false ); | |
| 3157 | + $author_link = get_author_posts_url($current_user->data->ID); | |
| 3158 | +		$author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
 | |
| 3159 | 3159 | |
| 3160 | 3160 | echo '<ul class="geodir-loginbox-list">'; | 
| 3161 | 3161 | ob_start(); | 
| 3162 | 3162 | ?> | 
| 3163 | 3163 | <li><a class="signin" | 
| 3164 | - href="<?php echo wp_logout_url( home_url() ); ?>"><?php _e( 'Logout', 'geodirectory' ); ?></a></li> | |
| 3164 | +		       href="<?php echo wp_logout_url(home_url()); ?>"><?php _e('Logout', 'geodirectory'); ?></a></li>
 | |
| 3165 | 3165 | <?php | 
| 3166 | - $post_types = geodir_get_posttypes( 'object' ); | |
| 3167 | - $show_add_listing_post_types_main_nav = get_option( 'geodir_add_listing_link_user_dashboard' ); | |
| 3168 | - $geodir_allow_posttype_frontend = get_option( 'geodir_allow_posttype_frontend' ); | |
| 3166 | +		$post_types                           = geodir_get_posttypes('object');
 | |
| 3167 | +		$show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_user_dashboard');
 | |
| 3168 | +		$geodir_allow_posttype_frontend       = get_option('geodir_allow_posttype_frontend');
 | |
| 3169 | 3169 | |
| 3170 | -		if ( ! empty( $show_add_listing_post_types_main_nav ) ) {
 | |
| 3170 | +		if (!empty($show_add_listing_post_types_main_nav)) {
 | |
| 3171 | 3171 | $addlisting_links = ''; | 
| 3172 | -			foreach ( $post_types as $key => $postobj ) {
 | |
| 3172 | +			foreach ($post_types as $key => $postobj) {
 | |
| 3173 | 3173 | |
| 3174 | -				if ( in_array( $key, $show_add_listing_post_types_main_nav ) ) {
 | |
| 3174 | +				if (in_array($key, $show_add_listing_post_types_main_nav)) {
 | |
| 3175 | 3175 | |
| 3176 | -					if ( $add_link = geodir_get_addlisting_link( $key ) ) {
 | |
| 3176 | +					if ($add_link = geodir_get_addlisting_link($key)) {
 | |
| 3177 | 3177 | |
| 3178 | 3178 | $name = $postobj->labels->name; | 
| 3179 | 3179 | |
| 3180 | 3180 | $selected = ''; | 
| 3181 | -						if ( geodir_get_current_posttype() == $key && geodir_is_page( 'add-listing' ) ) {
 | |
| 3181 | +						if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing')) {
 | |
| 3182 | 3182 | $selected = 'selected="selected"'; | 
| 3183 | 3183 | } | 
| 3184 | 3184 | |
| @@ -3191,22 +3191,22 @@ discard block | ||
| 3191 | 3191 | * @param string $key Add listing array key. | 
| 3192 | 3192 | * @param int $current_user ->ID Current user ID. | 
| 3193 | 3193 | */ | 
| 3194 | - $add_link = apply_filters( 'geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID ); | |
| 3194 | +						$add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
 | |
| 3195 | 3195 | |
| 3196 | - $addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __( ucfirst( $name ), 'geodirectory' ) . '</option>'; | |
| 3196 | + $addlisting_links .= '<option '.$selected.' value="'.$add_link.'">'.__(ucfirst($name), 'geodirectory').'</option>'; | |
| 3197 | 3197 | |
| 3198 | 3198 | } | 
| 3199 | 3199 | } | 
| 3200 | 3200 | |
| 3201 | 3201 | } | 
| 3202 | 3202 | |
| 3203 | -			if ( $addlisting_links != '' ) { ?>
 | |
| 3203 | +			if ($addlisting_links != '') { ?>
 | |
| 3204 | 3204 | |
| 3205 | 3205 | <li><select id="geodir_add_listing" class="chosen_select" onchange="window.location.href=this.value" | 
| 3206 | 3206 | option-autoredirect="1" name="geodir_add_listing" option-ajaxchosen="false" | 
| 3207 | - data-placeholder="<?php echo esc_attr( __( 'Add Listing', 'geodirectory' ) ); ?>"> | |
| 3207 | +				            data-placeholder="<?php echo esc_attr(__('Add Listing', 'geodirectory')); ?>">
 | |
| 3208 | 3208 | <option value="" disabled="disabled" selected="selected" | 
| 3209 | - style='display:none;'><?php echo esc_attr( __( 'Add Listing', 'geodirectory' ) ); ?></option> | |
| 3209 | +						        style='display:none;'><?php echo esc_attr(__('Add Listing', 'geodirectory')); ?></option>
 | |
| 3210 | 3210 | <?php echo $addlisting_links; ?> | 
| 3211 | 3211 | </select></li> <?php | 
| 3212 | 3212 | |
| @@ -3214,23 +3214,23 @@ discard block | ||
| 3214 | 3214 | |
| 3215 | 3215 | } | 
| 3216 | 3216 | // My Favourites in Dashboard | 
| 3217 | - $show_favorite_link_user_dashboard = get_option( 'geodir_favorite_link_user_dashboard' ); | |
| 3217 | +		$show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard');
 | |
| 3218 | 3218 | $user_favourite = geodir_user_favourite_listing_count(); | 
| 3219 | 3219 | |
| 3220 | -		if ( ! empty( $show_favorite_link_user_dashboard ) && ! empty( $user_favourite ) ) {
 | |
| 3220 | +		if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) {
 | |
| 3221 | 3221 | $favourite_links = ''; | 
| 3222 | 3222 | |
| 3223 | -			foreach ( $post_types as $key => $postobj ) {
 | |
| 3224 | -				if ( in_array( $key, $show_favorite_link_user_dashboard ) && array_key_exists( $key, $user_favourite ) ) {
 | |
| 3223 | +			foreach ($post_types as $key => $postobj) {
 | |
| 3224 | +				if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) {
 | |
| 3225 | 3225 | $name = $postobj->labels->name; | 
| 3226 | - $post_type_link = geodir_getlink( $author_link, array( | |
| 3226 | + $post_type_link = geodir_getlink($author_link, array( | |
| 3227 | 3227 | 'stype' => $key, | 
| 3228 | 3228 | 'list' => 'favourite' | 
| 3229 | - ), false ); | |
| 3229 | + ), false); | |
| 3230 | 3230 | |
| 3231 | 3231 | $selected = ''; | 
| 3232 | 3232 | |
| 3233 | -					if ( isset( $_REQUEST['list'] ) && $_REQUEST['list'] == 'favourite' && isset( $_REQUEST['stype'] ) && $_REQUEST['stype'] == $key && isset( $_REQUEST['geodir_dashbord'] ) ) {
 | |
| 3233 | +					if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) {
 | |
| 3234 | 3234 | $selected = 'selected="selected"'; | 
| 3235 | 3235 | } | 
| 3236 | 3236 | /** | 
| @@ -3242,20 +3242,20 @@ discard block | ||
| 3242 | 3242 | * @param string $key Favorite listing array key. | 
| 3243 | 3243 | * @param int $current_user ->ID Current user ID. | 
| 3244 | 3244 | */ | 
| 3245 | - $post_type_link = apply_filters( 'geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID ); | |
| 3245 | +					$post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
 | |
| 3246 | 3246 | |
| 3247 | - $favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __( ucfirst( $name ), 'geodirectory' ) . '</option>'; | |
| 3247 | + $favourite_links .= '<option '.$selected.' value="'.$post_type_link.'">'.__(ucfirst($name), 'geodirectory').'</option>'; | |
| 3248 | 3248 | } | 
| 3249 | 3249 | } | 
| 3250 | 3250 | |
| 3251 | -			if ( $favourite_links != '' ) {
 | |
| 3251 | +			if ($favourite_links != '') {
 | |
| 3252 | 3252 | ?> | 
| 3253 | 3253 | <li> | 
| 3254 | 3254 | <select id="geodir_my_favourites" class="chosen_select" onchange="window.location.href=this.value" | 
| 3255 | 3255 | option-autoredirect="1" name="geodir_my_favourites" option-ajaxchosen="false" | 
| 3256 | - data-placeholder="<?php echo esc_attr( __( 'My Favorites', 'geodirectory' ) ); ?>"> | |
| 3256 | +					        data-placeholder="<?php echo esc_attr(__('My Favorites', 'geodirectory')); ?>">
 | |
| 3257 | 3257 | <option value="" disabled="disabled" selected="selected" | 
| 3258 | - style='display:none;'><?php echo esc_attr( __( 'My Favorites', 'geodirectory' ) ); ?></option> | |
| 3258 | +						        style='display:none;'><?php echo esc_attr(__('My Favorites', 'geodirectory')); ?></option>
 | |
| 3259 | 3259 | <?php echo $favourite_links; ?> | 
| 3260 | 3260 | </select> | 
| 3261 | 3261 | </li> | 
| @@ -3264,19 +3264,19 @@ discard block | ||
| 3264 | 3264 | } | 
| 3265 | 3265 | |
| 3266 | 3266 | |
| 3267 | - $show_listing_link_user_dashboard = get_option( 'geodir_listing_link_user_dashboard' ); | |
| 3267 | +		$show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard');
 | |
| 3268 | 3268 | $user_listing = geodir_user_post_listing_count(); | 
| 3269 | 3269 | |
| 3270 | -		if ( ! empty( $show_listing_link_user_dashboard ) && ! empty( $user_listing ) ) {
 | |
| 3270 | +		if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) {
 | |
| 3271 | 3271 | $listing_links = ''; | 
| 3272 | 3272 | |
| 3273 | -			foreach ( $post_types as $key => $postobj ) {
 | |
| 3274 | -				if ( in_array( $key, $show_listing_link_user_dashboard ) && array_key_exists( $key, $user_listing ) ) {
 | |
| 3273 | +			foreach ($post_types as $key => $postobj) {
 | |
| 3274 | +				if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) {
 | |
| 3275 | 3275 | $name = $postobj->labels->name; | 
| 3276 | - $listing_link = geodir_getlink( $author_link, array( 'stype' => $key ), false ); | |
| 3276 | +					$listing_link = geodir_getlink($author_link, array('stype' => $key), false);
 | |
| 3277 | 3277 | |
| 3278 | 3278 | $selected = ''; | 
| 3279 | -					if ( ! isset( $_REQUEST['list'] ) && isset( $_REQUEST['geodir_dashbord'] ) && isset( $_REQUEST['stype'] ) && $_REQUEST['stype'] == $key ) {
 | |
| 3279 | +					if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) {
 | |
| 3280 | 3280 | $selected = 'selected="selected"'; | 
| 3281 | 3281 | } | 
| 3282 | 3282 | |
| @@ -3289,20 +3289,20 @@ discard block | ||
| 3289 | 3289 | * @param string $key My listing array key. | 
| 3290 | 3290 | * @param int $current_user ->ID Current user ID. | 
| 3291 | 3291 | */ | 
| 3292 | - $listing_link = apply_filters( 'geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID ); | |
| 3292 | +					$listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
 | |
| 3293 | 3293 | |
| 3294 | - $listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __( ucfirst( $name ), 'geodirectory' ) . '</option>'; | |
| 3294 | + $listing_links .= '<option '.$selected.' value="'.$listing_link.'">'.__(ucfirst($name), 'geodirectory').'</option>'; | |
| 3295 | 3295 | } | 
| 3296 | 3296 | } | 
| 3297 | 3297 | |
| 3298 | -			if ( $listing_links != '' ) {
 | |
| 3298 | +			if ($listing_links != '') {
 | |
| 3299 | 3299 | ?> | 
| 3300 | 3300 | <li> | 
| 3301 | 3301 | <select id="geodir_my_listings" class="chosen_select" onchange="window.location.href=this.value" | 
| 3302 | 3302 | option-autoredirect="1" name="geodir_my_listings" option-ajaxchosen="false" | 
| 3303 | - data-placeholder="<?php echo esc_attr( __( 'My Listings', 'geodirectory' ) ); ?>"> | |
| 3303 | +					        data-placeholder="<?php echo esc_attr(__('My Listings', 'geodirectory')); ?>">
 | |
| 3304 | 3304 | <option value="" disabled="disabled" selected="selected" | 
| 3305 | - style='display:none;'><?php echo esc_attr( __( 'My Listings', 'geodirectory' ) ); ?></option> | |
| 3305 | +						        style='display:none;'><?php echo esc_attr(__('My Listings', 'geodirectory')); ?></option>
 | |
| 3306 | 3306 | <?php echo $listing_links; ?> | 
| 3307 | 3307 | </select> | 
| 3308 | 3308 | </li> | 
| @@ -3318,7 +3318,7 @@ discard block | ||
| 3318 | 3318 | * | 
| 3319 | 3319 | * @param string $dashboard_link Dashboard links HTML. | 
| 3320 | 3320 | */ | 
| 3321 | - echo apply_filters( 'geodir_dashboard_links', $dashboard_link ); | |
| 3321 | +		echo apply_filters('geodir_dashboard_links', $dashboard_link);
 | |
| 3322 | 3322 | echo '</ul>'; | 
| 3323 | 3323 | |
| 3324 | 3324 | /** | 
| @@ -3326,7 +3326,7 @@ discard block | ||
| 3326 | 3326 | * | 
| 3327 | 3327 | * @since 1.6.6 | 
| 3328 | 3328 | */ | 
| 3329 | - do_action( 'geodir_after_loginwidget_form_logged_in' ); | |
| 3329 | +		do_action('geodir_after_loginwidget_form_logged_in');
 | |
| 3330 | 3330 | |
| 3331 | 3331 | |
| 3332 | 3332 |  	} else {
 | 
| @@ -3341,18 +3341,18 @@ discard block | ||
| 3341 | 3341 | <form name="loginform" class="loginform1" | 
| 3342 | 3342 | action="<?php echo geodir_login_url(); ?>" | 
| 3343 | 3343 | method="post"> | 
| 3344 | - <div class="geodir_form_row"><input placeholder="<?php _e( 'Email', 'geodirectory' ); ?>" name="log" | |
| 3344 | +			<div class="geodir_form_row"><input placeholder="<?php _e('Email', 'geodirectory'); ?>" name="log"
 | |
| 3345 | 3345 | type="text" class="textfield user_login1"/> <span | 
| 3346 | 3346 | class="user_loginInfo"></span></div> | 
| 3347 | - <div class="geodir_form_row"><input placeholder="<?php _e( 'Password', 'geodirectory' ); ?>" | |
| 3347 | +			<div class="geodir_form_row"><input placeholder="<?php _e('Password', 'geodirectory'); ?>"
 | |
| 3348 | 3348 | name="pwd" type="password" | 
| 3349 | 3349 | class="textfield user_pass1 input-text"/><span | 
| 3350 | 3350 | class="user_passInfo"></span></div> | 
| 3351 | 3351 | |
| 3352 | - <input type="hidden" name="redirect_to" value="<?php echo htmlspecialchars( geodir_curPageURL() ); ?>"/> | |
| 3352 | + <input type="hidden" name="redirect_to" value="<?php echo htmlspecialchars(geodir_curPageURL()); ?>"/> | |
| 3353 | 3353 | <input type="hidden" name="testcookie" value="1"/> | 
| 3354 | 3354 | |
| 3355 | - <?php do_action( 'login_form' ); ?> | |
| 3355 | +				<?php do_action('login_form'); ?>
 | |
| 3356 | 3356 | |
| 3357 | 3357 | <div class="geodir_form_row clearfix"><input type="submit" name="submit" | 
| 3358 | 3358 | value="<?php echo SIGN_IN_BUTTON; ?>" class="b_signin"/> | 
| @@ -3365,7 +3365,7 @@ discard block | ||
| 3365 | 3365 | * @since 1.0.0 | 
| 3366 | 3366 | */ | 
| 3367 | 3367 | ?> | 
| 3368 | - <a href="<?php echo geodir_login_url( array( 'signup' => true ) ); ?>" | |
| 3368 | +					<a href="<?php echo geodir_login_url(array('signup' => true)); ?>"
 | |
| 3369 | 3369 | class="goedir-newuser-link"><?php echo NEW_USER_TEXT; ?></a> | 
| 3370 | 3370 | |
| 3371 | 3371 | <?php | 
| @@ -3375,7 +3375,7 @@ discard block | ||
| 3375 | 3375 | * @since 1.0.0 | 
| 3376 | 3376 | */ | 
| 3377 | 3377 | ?> | 
| 3378 | - <a href="<?php echo geodir_login_url( array( 'forgot' => true ) ); ?>" | |
| 3378 | +					<a href="<?php echo geodir_login_url(array('forgot' => true)); ?>"
 | |
| 3379 | 3379 | class="goedir-forgot-link"><?php echo FORGOT_PW_TEXT; ?></a></p></div> | 
| 3380 | 3380 | </form> | 
| 3381 | 3381 | <?php | 
| @@ -3384,7 +3384,7 @@ discard block | ||
| 3384 | 3384 | * | 
| 3385 | 3385 | * @since 1.6.6 | 
| 3386 | 3386 | */ | 
| 3387 | - do_action( 'geodir_after_loginwidget_form_logged_out' ); | |
| 3387 | +		do_action('geodir_after_loginwidget_form_logged_out');
 | |
| 3388 | 3388 | } | 
| 3389 | 3389 | |
| 3390 | 3390 | echo $after_widget; | 
| @@ -3406,16 +3406,16 @@ discard block | ||
| 3406 | 3406 | * after_widget. | 
| 3407 | 3407 | * @param array|string $instance The settings for the particular instance of the widget. | 
| 3408 | 3408 | */ | 
| 3409 | -function geodir_popular_postview_output( $args = '', $instance = '' ) {
 | |
| 3409 | +function geodir_popular_postview_output($args = '', $instance = '') {
 | |
| 3410 | 3410 | global $gd_session; | 
| 3411 | 3411 | |
| 3412 | 3412 | // prints the widget | 
| 3413 | - extract( $args, EXTR_SKIP ); | |
| 3413 | + extract($args, EXTR_SKIP); | |
| 3414 | 3414 | |
| 3415 | 3415 | echo $before_widget; | 
| 3416 | 3416 | |
| 3417 | 3417 | /** This filter is documented in geodirectory_widgets.php */ | 
| 3418 | - $title = empty( $instance['title'] ) ? geodir_ucwords( $instance['category_title'] ) : apply_filters( 'widget_title', __( $instance['title'], 'geodirectory' ) ); | |
| 3418 | +	$title = empty($instance['title']) ? geodir_ucwords($instance['category_title']) : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
 | |
| 3419 | 3419 | /** | 
| 3420 | 3420 | * Filter the widget post type. | 
| 3421 | 3421 | * | 
| @@ -3423,7 +3423,7 @@ discard block | ||
| 3423 | 3423 | * | 
| 3424 | 3424 | * @param string $instance ['post_type'] Post type of listing. | 
| 3425 | 3425 | */ | 
| 3426 | - $post_type = empty( $instance['post_type'] ) ? 'gd_place' : apply_filters( 'widget_post_type', $instance['post_type'] ); | |
| 3426 | +	$post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
 | |
| 3427 | 3427 | /** | 
| 3428 | 3428 | * Filter the widget's term. | 
| 3429 | 3429 | * | 
| @@ -3431,7 +3431,7 @@ discard block | ||
| 3431 | 3431 | * | 
| 3432 | 3432 | * @param string $instance ['category'] Filter by term. Can be any valid term. | 
| 3433 | 3433 | */ | 
| 3434 | - $category = empty( $instance['category'] ) ? '0' : apply_filters( 'widget_category', $instance['category'] ); | |
| 3434 | +	$category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
 | |
| 3435 | 3435 | /** | 
| 3436 | 3436 | * Filter the widget listings limit. | 
| 3437 | 3437 | * | 
| @@ -3439,7 +3439,7 @@ discard block | ||
| 3439 | 3439 | * | 
| 3440 | 3440 | * @param string $instance ['post_number'] Number of listings to display. | 
| 3441 | 3441 | */ | 
| 3442 | - $post_number = empty( $instance['post_number'] ) ? '5' : apply_filters( 'widget_post_number', $instance['post_number'] ); | |
| 3442 | +	$post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
 | |
| 3443 | 3443 | /** | 
| 3444 | 3444 | * Filter widget's "layout" type. | 
| 3445 | 3445 | * | 
| @@ -3447,7 +3447,7 @@ discard block | ||
| 3447 | 3447 | * | 
| 3448 | 3448 | * @param string $instance ['layout'] Widget layout type. | 
| 3449 | 3449 | */ | 
| 3450 | - $layout = empty( $instance['layout'] ) ? 'gridview_onehalf' : apply_filters( 'widget_layout', $instance['layout'] ); | |
| 3450 | +	$layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']);
 | |
| 3451 | 3451 | /** | 
| 3452 | 3452 | * Filter widget's "add_location_filter" value. | 
| 3453 | 3453 | * | 
| @@ -3455,7 +3455,7 @@ discard block | ||
| 3455 | 3455 | * | 
| 3456 | 3456 | * @param string|bool $instance ['add_location_filter'] Do you want to add location filter? Can be 1 or 0. | 
| 3457 | 3457 | */ | 
| 3458 | - $add_location_filter = empty( $instance['add_location_filter'] ) ? '0' : apply_filters( 'widget_add_location_filter', $instance['add_location_filter'] ); | |
| 3458 | +	$add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']);
 | |
| 3459 | 3459 | /** | 
| 3460 | 3460 | * Filter widget's listing width. | 
| 3461 | 3461 | * | 
| @@ -3463,7 +3463,7 @@ discard block | ||
| 3463 | 3463 | * | 
| 3464 | 3464 | * @param string $instance ['listing_width'] Listing width. | 
| 3465 | 3465 | */ | 
| 3466 | - $listing_width = empty( $instance['listing_width'] ) ? '' : apply_filters( 'widget_listing_width', $instance['listing_width'] ); | |
| 3466 | +	$listing_width = empty($instance['listing_width']) ? '' : apply_filters('widget_listing_width', $instance['listing_width']);
 | |
| 3467 | 3467 | /** | 
| 3468 | 3468 | * Filter widget's "list_sort" type. | 
| 3469 | 3469 | * | 
| @@ -3471,25 +3471,25 @@ discard block | ||
| 3471 | 3471 | * | 
| 3472 | 3472 | * @param string $instance ['list_sort'] Listing sort by type. | 
| 3473 | 3473 | */ | 
| 3474 | - $list_sort = empty( $instance['list_sort'] ) ? 'latest' : apply_filters( 'widget_list_sort', $instance['list_sort'] ); | |
| 3475 | - $use_viewing_post_type = ! empty( $instance['use_viewing_post_type'] ) ? true : false; | |
| 3474 | +	$list_sort             = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
 | |
| 3475 | + $use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false; | |
| 3476 | 3476 | |
| 3477 | 3477 | // set post type to current viewing post type | 
| 3478 | -	if ( $use_viewing_post_type ) {
 | |
| 3478 | +	if ($use_viewing_post_type) {
 | |
| 3479 | 3479 | $current_post_type = geodir_get_current_posttype(); | 
| 3480 | -		if ( $current_post_type != '' && $current_post_type != $post_type ) {
 | |
| 3480 | +		if ($current_post_type != '' && $current_post_type != $post_type) {
 | |
| 3481 | 3481 | $post_type = $current_post_type; | 
| 3482 | 3482 | $category = array(); // old post type category will not work for current changed post type | 
| 3483 | 3483 | } | 
| 3484 | 3484 | } | 
| 3485 | 3485 | // replace widget title dynamically | 
| 3486 | - $posttype_plural_label = __( get_post_type_plural_label( $post_type ), 'geodirectory' ); | |
| 3487 | - $posttype_singular_label = __( get_post_type_singular_label( $post_type ), 'geodirectory' ); | |
| 3486 | + $posttype_plural_label = __(get_post_type_plural_label($post_type), 'geodirectory'); | |
| 3487 | + $posttype_singular_label = __(get_post_type_singular_label($post_type), 'geodirectory'); | |
| 3488 | 3488 | |
| 3489 | - $title = str_replace( "%posttype_plural_label%", $posttype_plural_label, $title ); | |
| 3490 | - $title = str_replace( "%posttype_singular_label%", $posttype_singular_label, $title ); | |
| 3489 | +	$title = str_replace("%posttype_plural_label%", $posttype_plural_label, $title);
 | |
| 3490 | +	$title = str_replace("%posttype_singular_label%", $posttype_singular_label, $title);
 | |
| 3491 | 3491 | |
| 3492 | -	if ( isset( $instance['character_count'] ) ) {
 | |
| 3492 | +	if (isset($instance['character_count'])) {
 | |
| 3493 | 3493 | /** | 
| 3494 | 3494 | * Filter the widget's excerpt character count. | 
| 3495 | 3495 | * | 
| @@ -3497,37 +3497,37 @@ discard block | ||
| 3497 | 3497 | * | 
| 3498 | 3498 | * @param int $instance ['character_count'] Excerpt character count. | 
| 3499 | 3499 | */ | 
| 3500 | - $character_count = apply_filters( 'widget_list_character_count', $instance['character_count'] ); | |
| 3500 | +		$character_count = apply_filters('widget_list_character_count', $instance['character_count']);
 | |
| 3501 | 3501 |  	} else {
 | 
| 3502 | 3502 | $character_count = ''; | 
| 3503 | 3503 | } | 
| 3504 | 3504 | |
| 3505 | -	if ( empty( $title ) || $title == 'All' ) {
 | |
| 3506 | - $title .= ' ' . __( get_post_type_plural_label( $post_type ), 'geodirectory' ); | |
| 3505 | +	if (empty($title) || $title == 'All') {
 | |
| 3506 | + $title .= ' '.__(get_post_type_plural_label($post_type), 'geodirectory'); | |
| 3507 | 3507 | } | 
| 3508 | 3508 | |
| 3509 | 3509 | $location_url = array(); | 
| 3510 | - $city = get_query_var( 'gd_city' ); | |
| 3511 | -	if ( ! empty( $city ) ) {
 | |
| 3512 | - $country = get_query_var( 'gd_country' ); | |
| 3513 | - $region = get_query_var( 'gd_region' ); | |
| 3510 | +	$city         = get_query_var('gd_city');
 | |
| 3511 | +	if (!empty($city)) {
 | |
| 3512 | +		$country = get_query_var('gd_country');
 | |
| 3513 | +		$region  = get_query_var('gd_region');
 | |
| 3514 | 3514 | |
| 3515 | - $geodir_show_location_url = get_option( 'geodir_show_location_url' ); | |
| 3515 | +		$geodir_show_location_url = get_option('geodir_show_location_url');
 | |
| 3516 | 3516 | |
| 3517 | -		if ( $geodir_show_location_url == 'all' ) {
 | |
| 3518 | -			if ( $country != '' ) {
 | |
| 3517 | +		if ($geodir_show_location_url == 'all') {
 | |
| 3518 | +			if ($country != '') {
 | |
| 3519 | 3519 | $location_url[] = $country; | 
| 3520 | 3520 | } | 
| 3521 | 3521 | |
| 3522 | -			if ( $region != '' ) {
 | |
| 3522 | +			if ($region != '') {
 | |
| 3523 | 3523 | $location_url[] = $region; | 
| 3524 | 3524 | } | 
| 3525 | -		} else if ( $geodir_show_location_url == 'country_city' ) {
 | |
| 3526 | -			if ( $country != '' ) {
 | |
| 3525 | +		} else if ($geodir_show_location_url == 'country_city') {
 | |
| 3526 | +			if ($country != '') {
 | |
| 3527 | 3527 | $location_url[] = $country; | 
| 3528 | 3528 | } | 
| 3529 | -		} else if ( $geodir_show_location_url == 'region_city' ) {
 | |
| 3530 | -			if ( $region != '' ) {
 | |
| 3529 | +		} else if ($geodir_show_location_url == 'region_city') {
 | |
| 3530 | +			if ($region != '') {
 | |
| 3531 | 3531 | $location_url[] = $region; | 
| 3532 | 3532 | } | 
| 3533 | 3533 | } | 
| @@ -3535,37 +3535,37 @@ discard block | ||
| 3535 | 3535 | $location_url[] = $city; | 
| 3536 | 3536 | } | 
| 3537 | 3537 | |
| 3538 | - $location_url = implode( '/', $location_url ); | |
| 3538 | +	$location_url  = implode('/', $location_url);
 | |
| 3539 | 3539 | $skip_location = false; | 
| 3540 | -	if ( ! $add_location_filter && $gd_session->get( 'gd_multi_location' ) ) {
 | |
| 3540 | +	if (!$add_location_filter && $gd_session->get('gd_multi_location')) {
 | |
| 3541 | 3541 | $skip_location = true; | 
| 3542 | - $gd_session->un_set( 'gd_multi_location' ); | |
| 3542 | +		$gd_session->un_set('gd_multi_location');
 | |
| 3543 | 3543 | } | 
| 3544 | 3544 | |
| 3545 | -	if ( get_option( 'permalink_structure' ) ) {
 | |
| 3546 | - $viewall_url = get_post_type_archive_link( $post_type ); | |
| 3545 | +	if (get_option('permalink_structure')) {
 | |
| 3546 | + $viewall_url = get_post_type_archive_link($post_type); | |
| 3547 | 3547 |  	} else {
 | 
| 3548 | - $viewall_url = get_post_type_archive_link( $post_type ); | |
| 3548 | + $viewall_url = get_post_type_archive_link($post_type); | |
| 3549 | 3549 | } | 
| 3550 | 3550 | |
| 3551 | -	if ( ! empty( $category ) && $category[0] != '0' ) {
 | |
| 3551 | +	if (!empty($category) && $category[0] != '0') {
 | |
| 3552 | 3552 | global $geodir_add_location_url; | 
| 3553 | 3553 | |
| 3554 | 3554 | $geodir_add_location_url = '0'; | 
| 3555 | 3555 | |
| 3556 | -		if ( $add_location_filter != '0' ) {
 | |
| 3556 | +		if ($add_location_filter != '0') {
 | |
| 3557 | 3557 | $geodir_add_location_url = '1'; | 
| 3558 | 3558 | } | 
| 3559 | 3559 | |
| 3560 | - $viewall_url = get_term_link( (int) $category[0], $post_type . 'category' ); | |
| 3560 | + $viewall_url = get_term_link((int) $category[0], $post_type.'category'); | |
| 3561 | 3561 | |
| 3562 | 3562 | $geodir_add_location_url = null; | 
| 3563 | 3563 | } | 
| 3564 | -	if ( $skip_location ) {
 | |
| 3565 | - $gd_session->set( 'gd_multi_location', 1 ); | |
| 3564 | +	if ($skip_location) {
 | |
| 3565 | +		$gd_session->set('gd_multi_location', 1);
 | |
| 3566 | 3566 | } | 
| 3567 | 3567 | |
| 3568 | -	if ( is_wp_error( $viewall_url ) ) {
 | |
| 3568 | +	if (is_wp_error($viewall_url)) {
 | |
| 3569 | 3569 | $viewall_url = ''; | 
| 3570 | 3570 | } | 
| 3571 | 3571 | |
| @@ -3577,34 +3577,34 @@ discard block | ||
| 3577 | 3577 | 'order_by' => $list_sort | 
| 3578 | 3578 | ); | 
| 3579 | 3579 | |
| 3580 | -	if ( $character_count ) {
 | |
| 3580 | +	if ($character_count) {
 | |
| 3581 | 3581 | $query_args['excerpt_length'] = $character_count; | 
| 3582 | 3582 | } | 
| 3583 | 3583 | |
| 3584 | -	if ( ! empty( $instance['show_featured_only'] ) ) {
 | |
| 3584 | +	if (!empty($instance['show_featured_only'])) {
 | |
| 3585 | 3585 | $query_args['show_featured_only'] = 1; | 
| 3586 | 3586 | } | 
| 3587 | 3587 | |
| 3588 | -	if ( ! empty( $instance['show_special_only'] ) ) {
 | |
| 3588 | +	if (!empty($instance['show_special_only'])) {
 | |
| 3589 | 3589 | $query_args['show_special_only'] = 1; | 
| 3590 | 3590 | } | 
| 3591 | 3591 | |
| 3592 | -	if ( ! empty( $instance['with_pics_only'] ) ) {
 | |
| 3592 | +	if (!empty($instance['with_pics_only'])) {
 | |
| 3593 | 3593 | $query_args['with_pics_only'] = 0; | 
| 3594 | 3594 | $query_args['featured_image_only'] = 1; | 
| 3595 | 3595 | } | 
| 3596 | 3596 | |
| 3597 | -	if ( ! empty( $instance['with_videos_only'] ) ) {
 | |
| 3597 | +	if (!empty($instance['with_videos_only'])) {
 | |
| 3598 | 3598 | $query_args['with_videos_only'] = 1; | 
| 3599 | 3599 | } | 
| 3600 | - $with_no_results = ! empty( $instance['without_no_results'] ) ? false : true; | |
| 3600 | + $with_no_results = !empty($instance['without_no_results']) ? false : true; | |
| 3601 | 3601 | |
| 3602 | -	if ( ! empty( $category ) && $category[0] != '0' ) {
 | |
| 3603 | - $category_taxonomy = geodir_get_taxonomies( $post_type ); | |
| 3602 | +	if (!empty($category) && $category[0] != '0') {
 | |
| 3603 | + $category_taxonomy = geodir_get_taxonomies($post_type); | |
| 3604 | 3604 | |
| 3605 | 3605 | ######### WPML ######### | 
| 3606 | -		if ( function_exists( 'icl_object_id' ) ) {
 | |
| 3607 | - $category = gd_lang_object_ids( $category, $category_taxonomy[0] ); | |
| 3606 | +		if (function_exists('icl_object_id')) {
 | |
| 3607 | + $category = gd_lang_object_ids($category, $category_taxonomy[0]); | |
| 3608 | 3608 | } | 
| 3609 | 3609 | ######### WPML ######### | 
| 3610 | 3610 | |
| @@ -3614,14 +3614,14 @@ discard block | ||
| 3614 | 3614 | 'terms' => $category | 
| 3615 | 3615 | ); | 
| 3616 | 3616 | |
| 3617 | - $query_args['tax_query'] = array( $tax_query ); | |
| 3617 | + $query_args['tax_query'] = array($tax_query); | |
| 3618 | 3618 | } | 
| 3619 | 3619 | |
| 3620 | 3620 | global $gridview_columns_widget, $geodir_is_widget_listing; | 
| 3621 | 3621 | |
| 3622 | - $widget_listings = geodir_get_widget_listings( $query_args ); | |
| 3622 | + $widget_listings = geodir_get_widget_listings($query_args); | |
| 3623 | 3623 | |
| 3624 | -	if ( ! empty( $widget_listings ) || $with_no_results ) {
 | |
| 3624 | +	if (!empty($widget_listings) || $with_no_results) {
 | |
| 3625 | 3625 | ?> | 
| 3626 | 3626 | <div class="geodir_locations geodir_location_listing"> | 
| 3627 | 3627 | |
| @@ -3631,11 +3631,11 @@ discard block | ||
| 3631 | 3631 | * | 
| 3632 | 3632 | * @since 1.0.0 | 
| 3633 | 3633 | */ | 
| 3634 | - do_action( 'geodir_before_view_all_link_in_widget' ); ?> | |
| 3634 | +			do_action('geodir_before_view_all_link_in_widget'); ?>
 | |
| 3635 | 3635 | <div class="geodir_list_heading clearfix"> | 
| 3636 | - <?php echo $before_title . $title . $after_title; ?> | |
| 3636 | + <?php echo $before_title.$title.$after_title; ?> | |
| 3637 | 3637 | <a href="<?php echo $viewall_url; ?>" | 
| 3638 | - class="geodir-viewall"><?php _e( 'View all', 'geodirectory' ); ?></a> | |
| 3638 | +				   class="geodir-viewall"><?php _e('View all', 'geodirectory'); ?></a>
 | |
| 3639 | 3639 | </div> | 
| 3640 | 3640 | <?php | 
| 3641 | 3641 | /** | 
| @@ -3643,10 +3643,10 @@ discard block | ||
| 3643 | 3643 | * | 
| 3644 | 3644 | * @since 1.0.0 | 
| 3645 | 3645 | */ | 
| 3646 | - do_action( 'geodir_after_view_all_link_in_widget' ); ?> | |
| 3646 | +			do_action('geodir_after_view_all_link_in_widget'); ?>
 | |
| 3647 | 3647 | <?php | 
| 3648 | -			if ( strstr( $layout, 'gridview' ) ) {
 | |
| 3649 | - $listing_view_exp = explode( '_', $layout ); | |
| 3648 | +			if (strstr($layout, 'gridview')) {
 | |
| 3649 | +				$listing_view_exp        = explode('_', $layout);
 | |
| 3650 | 3650 | $gridview_columns_widget = $layout; | 
| 3651 | 3651 | $layout = $listing_view_exp[0]; | 
| 3652 | 3652 |  			} else {
 | 
| @@ -3658,8 +3658,8 @@ discard block | ||
| 3658 | 3658 | * | 
| 3659 | 3659 | * @since 1.0.0 | 
| 3660 | 3660 | */ | 
| 3661 | - $template = apply_filters( "geodir_template_part-widget-listing-listview", geodir_locate_template( 'widget-listing-listview' ) ); | |
| 3662 | -			if ( ! isset( $character_count ) ) {
 | |
| 3661 | +			$template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
 | |
| 3662 | +			if (!isset($character_count)) {
 | |
| 3663 | 3663 | /** | 
| 3664 | 3664 | * Filter the widget's excerpt character count. | 
| 3665 | 3665 | * | 
| @@ -3667,7 +3667,7 @@ discard block | ||
| 3667 | 3667 | * | 
| 3668 | 3668 | * @param int $instance ['character_count'] Excerpt character count. | 
| 3669 | 3669 | */ | 
| 3670 | - $character_count = $character_count == '' ? 50 : apply_filters( 'widget_character_count', $character_count ); | |
| 3670 | +				$character_count = $character_count == '' ? 50 : apply_filters('widget_character_count', $character_count);
 | |
| 3671 | 3671 | } | 
| 3672 | 3672 | |
| 3673 | 3673 | global $post, $map_jason, $map_canvas_arr; | 
| @@ -3682,13 +3682,13 @@ discard block | ||
| 3682 | 3682 | * | 
| 3683 | 3683 | * @since 1.0.0 | 
| 3684 | 3684 | */ | 
| 3685 | - include( $template ); | |
| 3685 | + include($template); | |
| 3686 | 3686 | |
| 3687 | 3687 | $geodir_is_widget_listing = false; | 
| 3688 | 3688 | |
| 3689 | 3689 | $GLOBALS['post'] = $current_post; | 
| 3690 | -			if ( ! empty( $current_post ) ) {
 | |
| 3691 | - setup_postdata( $current_post ); | |
| 3690 | +			if (!empty($current_post)) {
 | |
| 3691 | + setup_postdata($current_post); | |
| 3692 | 3692 | } | 
| 3693 | 3693 | $map_jason = $current_map_jason; | 
| 3694 | 3694 | $map_canvas_arr = $current_map_canvas_arr; | 
| @@ -3719,12 +3719,12 @@ discard block | ||
| 3719 | 3719 | * | 
| 3720 | 3720 | * @return int Reviews count. | 
| 3721 | 3721 | */ | 
| 3722 | -function geodir_count_reviews_by_term_id( $term_id, $taxonomy, $post_type ) {
 | |
| 3722 | +function geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type) {
 | |
| 3723 | 3723 | global $wpdb, $plugin_prefix; | 
| 3724 | 3724 | |
| 3725 | - $detail_table = $plugin_prefix . $post_type . '_detail'; | |
| 3725 | + $detail_table = $plugin_prefix.$post_type.'_detail'; | |
| 3726 | 3726 | |
| 3727 | -	$sql = "SELECT COALESCE(SUM(rating_count),0) FROM " . $detail_table . " WHERE post_status = 'publish' AND rating_count > 0 AND FIND_IN_SET(" . $term_id . ", " . $taxonomy . ")";
 | |
| 3727 | +	$sql = "SELECT COALESCE(SUM(rating_count),0) FROM ".$detail_table." WHERE post_status = 'publish' AND rating_count > 0 AND FIND_IN_SET(".$term_id.", ".$taxonomy.")";
 | |
| 3728 | 3728 | |
| 3729 | 3729 | /** | 
| 3730 | 3730 | * Filter count review sql query. | 
| @@ -3736,9 +3736,9 @@ discard block | ||
| 3736 | 3736 | * @param int $taxonomy The taxonomy Id. | 
| 3737 | 3737 | * @param string $post_type The post type. | 
| 3738 | 3738 | */ | 
| 3739 | - $sql = apply_filters( 'geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type ); | |
| 3739 | +	$sql = apply_filters('geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type);
 | |
| 3740 | 3740 | |
| 3741 | - $count = $wpdb->get_var( $sql ); | |
| 3741 | + $count = $wpdb->get_var($sql); | |
| 3742 | 3742 | |
| 3743 | 3743 | return $count; | 
| 3744 | 3744 | } | 
| @@ -3756,7 +3756,7 @@ discard block | ||
| 3756 | 3756 | * | 
| 3757 | 3757 | * @return array Term array data. | 
| 3758 | 3758 | */ | 
| 3759 | -function geodir_count_reviews_by_terms( $force_update = false, $post_ID = 0 ) {
 | |
| 3759 | +function geodir_count_reviews_by_terms($force_update = false, $post_ID = 0) {
 | |
| 3760 | 3760 | /** | 
| 3761 | 3761 | * Filter review count option data. | 
| 3762 | 3762 | * | 
| @@ -3766,78 +3766,78 @@ discard block | ||
| 3766 | 3766 | * @param bool $force_update Force update option value?. Default.false. | 
| 3767 | 3767 | * @param int $post_ID The post id to update if any. | 
| 3768 | 3768 | */ | 
| 3769 | - $option_data = apply_filters( 'geodir_count_reviews_by_terms_before', '', $force_update, $post_ID ); | |
| 3770 | -	if ( ! empty( $option_data ) ) {
 | |
| 3769 | +	$option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update, $post_ID);
 | |
| 3770 | +	if (!empty($option_data)) {
 | |
| 3771 | 3771 | return $option_data; | 
| 3772 | 3772 | } | 
| 3773 | 3773 | |
| 3774 | - $option_data = get_option( 'geodir_global_review_count' ); | |
| 3774 | +	$option_data = get_option('geodir_global_review_count');
 | |
| 3775 | 3775 | |
| 3776 | -	if ( ! $option_data || $force_update ) {
 | |
| 3777 | -		if ( (int) $post_ID > 0 ) { // Update reviews count for specific post categories only.
 | |
| 3776 | +	if (!$option_data || $force_update) {
 | |
| 3777 | +		if ((int) $post_ID > 0) { // Update reviews count for specific post categories only.
 | |
| 3778 | 3778 | global $gd_session; | 
| 3779 | 3779 | $term_array = (array) $option_data; | 
| 3780 | - $post_type = get_post_type( $post_ID ); | |
| 3781 | - $taxonomy = $post_type . 'category'; | |
| 3782 | - $terms = wp_get_object_terms( $post_ID, $taxonomy, array( 'fields' => 'ids' ) ); | |
| 3783 | - | |
| 3784 | -			if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
 | |
| 3785 | -				foreach ( $terms as $term_id ) {
 | |
| 3786 | - $count = geodir_count_reviews_by_term_id( $term_id, $taxonomy, $post_type ); | |
| 3787 | - $children = get_term_children( $term_id, $taxonomy ); | |
| 3788 | - $term_array[ $term_id ] = $count; | |
| 3780 | + $post_type = get_post_type($post_ID); | |
| 3781 | + $taxonomy = $post_type.'category'; | |
| 3782 | +			$terms      = wp_get_object_terms($post_ID, $taxonomy, array('fields' => 'ids'));
 | |
| 3783 | + | |
| 3784 | +			if (!empty($terms) && !is_wp_error($terms)) {
 | |
| 3785 | +				foreach ($terms as $term_id) {
 | |
| 3786 | + $count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type); | |
| 3787 | + $children = get_term_children($term_id, $taxonomy); | |
| 3788 | + $term_array[$term_id] = $count; | |
| 3789 | 3789 | } | 
| 3790 | 3790 | } | 
| 3791 | 3791 | |
| 3792 | - $session_listing = $gd_session->get( 'listing' ); | |
| 3792 | +			$session_listing = $gd_session->get('listing');
 | |
| 3793 | 3793 | |
| 3794 | 3794 | $terms = array(); | 
| 3795 | -			if ( isset( $_POST['post_category'][ $taxonomy ] ) ) {
 | |
| 3796 | - $terms = (array) $_POST['post_category'][ $taxonomy ]; | |
| 3797 | -			} else if ( ! empty( $session_listing ) && isset( $session_listing['post_category'][ $taxonomy ] ) ) {
 | |
| 3798 | - $terms = (array) $session_listing['post_category'][ $taxonomy ]; | |
| 3795 | +			if (isset($_POST['post_category'][$taxonomy])) {
 | |
| 3796 | + $terms = (array) $_POST['post_category'][$taxonomy]; | |
| 3797 | +			} else if (!empty($session_listing) && isset($session_listing['post_category'][$taxonomy])) {
 | |
| 3798 | + $terms = (array) $session_listing['post_category'][$taxonomy]; | |
| 3799 | 3799 | } | 
| 3800 | 3800 | |
| 3801 | -			if ( ! empty( $terms ) ) {
 | |
| 3802 | -				foreach ( $terms as $term_id ) {
 | |
| 3803 | -					if ( $term_id > 0 ) {
 | |
| 3804 | - $count = geodir_count_reviews_by_term_id( $term_id, $taxonomy, $post_type ); | |
| 3805 | - $children = get_term_children( $term_id, $taxonomy ); | |
| 3806 | - $term_array[ $term_id ] = $count; | |
| 3801 | +			if (!empty($terms)) {
 | |
| 3802 | +				foreach ($terms as $term_id) {
 | |
| 3803 | +					if ($term_id > 0) {
 | |
| 3804 | + $count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type); | |
| 3805 | + $children = get_term_children($term_id, $taxonomy); | |
| 3806 | + $term_array[$term_id] = $count; | |
| 3807 | 3807 | } | 
| 3808 | 3808 | } | 
| 3809 | 3809 | } | 
| 3810 | 3810 |  		} else { // Update reviews count for all post categories.
 | 
| 3811 | 3811 | $term_array = array(); | 
| 3812 | 3812 | $post_types = geodir_get_posttypes(); | 
| 3813 | -			foreach ( $post_types as $post_type ) {
 | |
| 3813 | +			foreach ($post_types as $post_type) {
 | |
| 3814 | 3814 | |
| 3815 | - $taxonomy = geodir_get_taxonomies( $post_type ); | |
| 3815 | + $taxonomy = geodir_get_taxonomies($post_type); | |
| 3816 | 3816 | $taxonomy = $taxonomy[0]; | 
| 3817 | 3817 | |
| 3818 | 3818 | $args = array( | 
| 3819 | 3819 | 'hide_empty' => false | 
| 3820 | 3820 | ); | 
| 3821 | 3821 | |
| 3822 | - $terms = get_terms( $taxonomy, $args ); | |
| 3822 | + $terms = get_terms($taxonomy, $args); | |
| 3823 | 3823 | |
| 3824 | -				foreach ( $terms as $term ) {
 | |
| 3825 | - $count = geodir_count_reviews_by_term_id( $term->term_id, $taxonomy, $post_type ); | |
| 3826 | - $children = get_term_children( $term->term_id, $taxonomy ); | |
| 3824 | +				foreach ($terms as $term) {
 | |
| 3825 | + $count = geodir_count_reviews_by_term_id($term->term_id, $taxonomy, $post_type); | |
| 3826 | + $children = get_term_children($term->term_id, $taxonomy); | |
| 3827 | 3827 |  					/*if ( is_array( $children ) ) {
 | 
| 3828 | 3828 |                          foreach ( $children as $child_id ) {
 | 
| 3829 | 3829 | $child_count = geodir_count_reviews_by_term_id($child_id, $taxonomy, $post_type); | 
| 3830 | 3830 | $count = $count + $child_count; | 
| 3831 | 3831 | } | 
| 3832 | 3832 | }*/ | 
| 3833 | - $term_array[ $term->term_id ] = $count; | |
| 3833 | + $term_array[$term->term_id] = $count; | |
| 3834 | 3834 | } | 
| 3835 | 3835 | } | 
| 3836 | 3836 | } | 
| 3837 | 3837 | |
| 3838 | - update_option( 'geodir_global_review_count', $term_array ); | |
| 3838 | +		update_option('geodir_global_review_count', $term_array);
 | |
| 3839 | 3839 | //clear cache | 
| 3840 | - wp_cache_delete( 'geodir_global_review_count' ); | |
| 3840 | +		wp_cache_delete('geodir_global_review_count');
 | |
| 3841 | 3841 | |
| 3842 | 3842 | return $term_array; | 
| 3843 | 3843 |  	} else {
 | 
| @@ -3853,39 +3853,39 @@ discard block | ||
| 3853 | 3853 | * @package GeoDirectory | 
| 3854 | 3854 | * @return bool | 
| 3855 | 3855 | */ | 
| 3856 | -function geodir_term_review_count_force_update( $new_status, $old_status = '', $post = '' ) {
 | |
| 3857 | -	if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'geodir_import_export' ) {
 | |
| 3856 | +function geodir_term_review_count_force_update($new_status, $old_status = '', $post = '') {
 | |
| 3857 | +	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'geodir_import_export') {
 | |
| 3858 | 3858 | return; // do not run if importing listings | 
| 3859 | 3859 | } | 
| 3860 | 3860 | |
| 3861 | -	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
 | |
| 3861 | +	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
 | |
| 3862 | 3862 | return; | 
| 3863 | 3863 | } | 
| 3864 | 3864 | |
| 3865 | 3865 | $post_ID = 0; | 
| 3866 | -	if ( ! empty( $post ) ) {
 | |
| 3867 | -		if ( isset( $post->post_type ) && strpos( $post->post_type, 'gd_' ) !== 0 ) {
 | |
| 3866 | +	if (!empty($post)) {
 | |
| 3867 | +		if (isset($post->post_type) && strpos($post->post_type, 'gd_') !== 0) {
 | |
| 3868 | 3868 | return; | 
| 3869 | 3869 | } | 
| 3870 | 3870 | |
| 3871 | -		if ( $new_status == 'auto-draft' && $old_status == 'new' ) {
 | |
| 3871 | +		if ($new_status == 'auto-draft' && $old_status == 'new') {
 | |
| 3872 | 3872 | return; | 
| 3873 | 3873 | } | 
| 3874 | 3874 | |
| 3875 | -		if ( ! empty( $post->ID ) ) {
 | |
| 3875 | +		if (!empty($post->ID)) {
 | |
| 3876 | 3876 | $post_ID = $post->ID; | 
| 3877 | 3877 | } | 
| 3878 | 3878 | } | 
| 3879 | 3879 | |
| 3880 | -	if ( $new_status != $old_status ) {
 | |
| 3881 | - geodir_count_reviews_by_terms( true, $post_ID ); | |
| 3880 | +	if ($new_status != $old_status) {
 | |
| 3881 | + geodir_count_reviews_by_terms(true, $post_ID); | |
| 3882 | 3882 | } | 
| 3883 | 3883 | |
| 3884 | 3884 | return true; | 
| 3885 | 3885 | } | 
| 3886 | 3886 | |
| 3887 | -function geodir_term_review_count_force_update_single_post( $post_id ) {
 | |
| 3888 | - geodir_count_reviews_by_terms( true, $post_id ); | |
| 3887 | +function geodir_term_review_count_force_update_single_post($post_id) {
 | |
| 3888 | + geodir_count_reviews_by_terms(true, $post_id); | |
| 3889 | 3889 | } | 
| 3890 | 3890 | |
| 3891 | 3891 | /*-----------------------------------------------------------------------------------*/ | 
| @@ -3902,11 +3902,11 @@ discard block | ||
| 3902 | 3902 | * | 
| 3903 | 3903 | * @return int Post count. | 
| 3904 | 3904 | */ | 
| 3905 | -function geodir_count_posts_by_term( $data, $term ) {
 | |
| 3905 | +function geodir_count_posts_by_term($data, $term) {
 | |
| 3906 | 3906 | |
| 3907 | -	if ( $data ) {
 | |
| 3908 | -		if ( isset( $data[ $term->term_id ] ) ) {
 | |
| 3909 | - return $data[ $term->term_id ]; | |
| 3907 | +	if ($data) {
 | |
| 3908 | +		if (isset($data[$term->term_id])) {
 | |
| 3909 | + return $data[$term->term_id]; | |
| 3910 | 3910 |  		} else {
 | 
| 3911 | 3911 | return 0; | 
| 3912 | 3912 | } | 
| @@ -3923,8 +3923,8 @@ discard block | ||
| 3923 | 3923 | * param array $terms An array of term objects. | 
| 3924 | 3924 | * @return array Sorted terms array. | 
| 3925 | 3925 | */ | 
| 3926 | -function geodir_sort_terms_by_count( $terms ) {
 | |
| 3927 | - usort( $terms, "geodir_sort_by_count_obj" ); | |
| 3926 | +function geodir_sort_terms_by_count($terms) {
 | |
| 3927 | + usort($terms, "geodir_sort_by_count_obj"); | |
| 3928 | 3928 | |
| 3929 | 3929 | return $terms; | 
| 3930 | 3930 | } | 
| @@ -3939,8 +3939,8 @@ discard block | ||
| 3939 | 3939 | * | 
| 3940 | 3940 | * @return array Sorted terms array. | 
| 3941 | 3941 | */ | 
| 3942 | -function geodir_sort_terms_by_review_count( $terms ) {
 | |
| 3943 | - usort( $terms, "geodir_sort_by_review_count_obj" ); | |
| 3942 | +function geodir_sort_terms_by_review_count($terms) {
 | |
| 3943 | + usort($terms, "geodir_sort_by_review_count_obj"); | |
| 3944 | 3944 | |
| 3945 | 3945 | return $terms; | 
| 3946 | 3946 | } | 
| @@ -3956,12 +3956,12 @@ discard block | ||
| 3956 | 3956 | * | 
| 3957 | 3957 | * @return array Sorted terms array. | 
| 3958 | 3958 | */ | 
| 3959 | -function geodir_sort_terms( $terms, $sort = 'count' ) {
 | |
| 3960 | -	if ( $sort == 'count' ) {
 | |
| 3961 | - return geodir_sort_terms_by_count( $terms ); | |
| 3959 | +function geodir_sort_terms($terms, $sort = 'count') {
 | |
| 3960 | +	if ($sort == 'count') {
 | |
| 3961 | + return geodir_sort_terms_by_count($terms); | |
| 3962 | 3962 | } | 
| 3963 | -	if ( $sort == 'review_count' ) {
 | |
| 3964 | - return geodir_sort_terms_by_review_count( $terms ); | |
| 3963 | +	if ($sort == 'review_count') {
 | |
| 3964 | + return geodir_sort_terms_by_review_count($terms); | |
| 3965 | 3965 | } | 
| 3966 | 3966 | } | 
| 3967 | 3967 | |
| @@ -3979,7 +3979,7 @@ discard block | ||
| 3979 | 3979 | * | 
| 3980 | 3980 | * @return bool | 
| 3981 | 3981 | */ | 
| 3982 | -function geodir_sort_by_count( $a, $b ) {
 | |
| 3982 | +function geodir_sort_by_count($a, $b) {
 | |
| 3983 | 3983 | return $a['count'] < $b['count']; | 
| 3984 | 3984 | } | 
| 3985 | 3985 | |
| @@ -3994,7 +3994,7 @@ discard block | ||
| 3994 | 3994 | * | 
| 3995 | 3995 | * @return bool | 
| 3996 | 3996 | */ | 
| 3997 | -function geodir_sort_by_count_obj( $a, $b ) {
 | |
| 3997 | +function geodir_sort_by_count_obj($a, $b) {
 | |
| 3998 | 3998 | return $a->count < $b->count; | 
| 3999 | 3999 | } | 
| 4000 | 4000 | |
| @@ -4009,7 +4009,7 @@ discard block | ||
| 4009 | 4009 | * | 
| 4010 | 4010 | * @return bool | 
| 4011 | 4011 | */ | 
| 4012 | -function geodir_sort_by_review_count_obj( $a, $b ) {
 | |
| 4012 | +function geodir_sort_by_review_count_obj($a, $b) {
 | |
| 4013 | 4013 | return $a->review_count < $b->review_count; | 
| 4014 | 4014 | } | 
| 4015 | 4015 | |
| @@ -4026,35 +4026,35 @@ discard block | ||
| 4026 | 4026 | * @since 1.4.2 | 
| 4027 | 4027 | * @package GeoDirectory | 
| 4028 | 4028 | */ | 
| 4029 | - $locale = apply_filters( 'plugin_locale', get_locale(), 'geodirectory' ); | |
| 4029 | +	$locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
 | |
| 4030 | 4030 | |
| 4031 | - load_textdomain( 'geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo' ); | |
| 4032 | - load_plugin_textdomain( 'geodirectory', false, plugin_basename( dirname( dirname( __FILE__ ) ) ) . '/geodirectory-languages' ); | |
| 4031 | +	load_textdomain('geodirectory', WP_LANG_DIR.'/'.'geodirectory'.'/'.'geodirectory'.'-'.$locale.'.mo');
 | |
| 4032 | +	load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))).'/geodirectory-languages');
 | |
| 4033 | 4033 | |
| 4034 | 4034 | /** | 
| 4035 | 4035 | * Define language constants. | 
| 4036 | 4036 | * | 
| 4037 | 4037 | * @since 1.0.0 | 
| 4038 | 4038 | */ | 
| 4039 | - require_once( geodir_plugin_path() . '/language.php' ); | |
| 4039 | + require_once(geodir_plugin_path().'/language.php'); | |
| 4040 | 4040 | |
| 4041 | - $language_file = geodir_plugin_path() . '/db-language.php'; | |
| 4041 | + $language_file = geodir_plugin_path().'/db-language.php'; | |
| 4042 | 4042 | |
| 4043 | 4043 | // Load language string file if not created yet | 
| 4044 | -	if ( ! file_exists( $language_file ) ) {
 | |
| 4044 | +	if (!file_exists($language_file)) {
 | |
| 4045 | 4045 | geodirectory_load_db_language(); | 
| 4046 | 4046 | } | 
| 4047 | 4047 | |
| 4048 | -	if ( file_exists( $language_file ) ) {
 | |
| 4048 | +	if (file_exists($language_file)) {
 | |
| 4049 | 4049 | /** | 
| 4050 | 4050 | * Language strings from database. | 
| 4051 | 4051 | * | 
| 4052 | 4052 | * @since 1.4.2 | 
| 4053 | 4053 | */ | 
| 4054 | 4054 |  		try {
 | 
| 4055 | - require_once( $language_file ); | |
| 4056 | -		} catch ( Exception $e ) {
 | |
| 4057 | - error_log( 'Language Error: ' . $e->getMessage() ); | |
| 4055 | + require_once($language_file); | |
| 4056 | +		} catch (Exception $e) {
 | |
| 4057 | +			error_log('Language Error: '.$e->getMessage());
 | |
| 4058 | 4058 | } | 
| 4059 | 4059 | } | 
| 4060 | 4060 | } | 
| @@ -4071,19 +4071,19 @@ discard block | ||
| 4071 | 4071 | */ | 
| 4072 | 4072 |  function geodirectory_load_db_language() {
 | 
| 4073 | 4073 | global $wp_filesystem; | 
| 4074 | -	if ( empty( $wp_filesystem ) ) {
 | |
| 4075 | - require_once( ABSPATH . '/wp-admin/includes/file.php' ); | |
| 4074 | +	if (empty($wp_filesystem)) {
 | |
| 4075 | + require_once(ABSPATH.'/wp-admin/includes/file.php'); | |
| 4076 | 4076 | WP_Filesystem(); | 
| 4077 | 4077 | global $wp_filesystem; | 
| 4078 | 4078 | } | 
| 4079 | 4079 | |
| 4080 | - $language_file = geodir_plugin_path() . '/db-language.php'; | |
| 4080 | + $language_file = geodir_plugin_path().'/db-language.php'; | |
| 4081 | 4081 | |
| 4082 | -	if ( is_file( $language_file ) && ! is_writable( $language_file ) ) {
 | |
| 4082 | +	if (is_file($language_file) && !is_writable($language_file)) {
 | |
| 4083 | 4083 | return false; | 
| 4084 | 4084 | } // Not possible to create. | 
| 4085 | 4085 | |
| 4086 | -	if ( ! is_file( $language_file ) && ! is_writable( dirname( $language_file ) ) ) {
 | |
| 4086 | +	if (!is_file($language_file) && !is_writable(dirname($language_file))) {
 | |
| 4087 | 4087 | return false; | 
| 4088 | 4088 | } // Not possible to create. | 
| 4089 | 4089 | |
| @@ -4096,9 +4096,9 @@ discard block | ||
| 4096 | 4096 | * | 
| 4097 | 4097 | * @param array $contents_strings Array of strings. | 
| 4098 | 4098 | */ | 
| 4099 | - $contents_strings = apply_filters( 'geodir_load_db_language', $contents_strings ); | |
| 4099 | +	$contents_strings = apply_filters('geodir_load_db_language', $contents_strings);
 | |
| 4100 | 4100 | |
| 4101 | - $contents_strings = array_unique( $contents_strings ); | |
| 4101 | + $contents_strings = array_unique($contents_strings); | |
| 4102 | 4102 | |
| 4103 | 4103 | $contents_head = array(); | 
| 4104 | 4104 | $contents_head[] = "<?php"; | 
| @@ -4115,20 +4115,20 @@ discard block | ||
| 4115 | 4115 | $contents_foot[] = ""; | 
| 4116 | 4116 | $contents_foot[] = ""; | 
| 4117 | 4117 | |
| 4118 | - $contents = implode( PHP_EOL, $contents_head ); | |
| 4118 | + $contents = implode(PHP_EOL, $contents_head); | |
| 4119 | 4119 | |
| 4120 | -	if ( ! empty( $contents_strings ) ) {
 | |
| 4121 | -		foreach ( $contents_strings as $string ) {
 | |
| 4122 | -			if ( is_scalar( $string ) && $string != '' ) {
 | |
| 4123 | - $string = str_replace( "'", "\'", $string ); | |
| 4124 | -				$contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
 | |
| 4120 | +	if (!empty($contents_strings)) {
 | |
| 4121 | +		foreach ($contents_strings as $string) {
 | |
| 4122 | +			if (is_scalar($string) && $string != '') {
 | |
| 4123 | +				$string = str_replace("'", "\'", $string);
 | |
| 4124 | +				$contents .= PHP_EOL."__('".$string."', 'geodirectory');";
 | |
| 4125 | 4125 | } | 
| 4126 | 4126 | } | 
| 4127 | 4127 | } | 
| 4128 | 4128 | |
| 4129 | - $contents .= implode( PHP_EOL, $contents_foot ); | |
| 4129 | + $contents .= implode(PHP_EOL, $contents_foot); | |
| 4130 | 4130 | |
| 4131 | -	if ( $wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE ) ) {
 | |
| 4131 | +	if ($wp_filesystem->put_contents($language_file, $contents, FS_CHMOD_FILE)) {
 | |
| 4132 | 4132 | return false; | 
| 4133 | 4133 | } // Failure; could not write file. | 
| 4134 | 4134 | |
| @@ -4148,45 +4148,45 @@ discard block | ||
| 4148 | 4148 | * | 
| 4149 | 4149 | * @return array Translation texts. | 
| 4150 | 4150 | */ | 
| 4151 | -function geodir_load_custom_field_translation( $translation_texts = array() ) {
 | |
| 4151 | +function geodir_load_custom_field_translation($translation_texts = array()) {
 | |
| 4152 | 4152 | global $wpdb; | 
| 4153 | 4153 | |
| 4154 | 4154 | // Custom fields table | 
| 4155 | - $sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE; | |
| 4156 | - $rows = $wpdb->get_results( $sql ); | |
| 4155 | + $sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM ".GEODIR_CUSTOM_FIELDS_TABLE; | |
| 4156 | + $rows = $wpdb->get_results($sql); | |
| 4157 | 4157 | |
| 4158 | -	if ( ! empty( $rows ) ) {
 | |
| 4159 | -		foreach ( $rows as $row ) {
 | |
| 4160 | -			if ( ! empty( $row->admin_title ) ) {
 | |
| 4161 | - $translation_texts[] = stripslashes_deep( $row->admin_title ); | |
| 4158 | +	if (!empty($rows)) {
 | |
| 4159 | +		foreach ($rows as $row) {
 | |
| 4160 | +			if (!empty($row->admin_title)) {
 | |
| 4161 | + $translation_texts[] = stripslashes_deep($row->admin_title); | |
| 4162 | 4162 | } | 
| 4163 | 4163 | |
| 4164 | -			if ( ! empty( $row->admin_desc ) ) {
 | |
| 4165 | - $translation_texts[] = stripslashes_deep( $row->admin_desc ); | |
| 4164 | +			if (!empty($row->admin_desc)) {
 | |
| 4165 | + $translation_texts[] = stripslashes_deep($row->admin_desc); | |
| 4166 | 4166 | } | 
| 4167 | 4167 | |
| 4168 | -			if ( ! empty( $row->site_title ) ) {
 | |
| 4169 | - $translation_texts[] = stripslashes_deep( $row->site_title ); | |
| 4168 | +			if (!empty($row->site_title)) {
 | |
| 4169 | + $translation_texts[] = stripslashes_deep($row->site_title); | |
| 4170 | 4170 | } | 
| 4171 | 4171 | |
| 4172 | -			if ( ! empty( $row->clabels ) ) {
 | |
| 4173 | - $translation_texts[] = stripslashes_deep( $row->clabels ); | |
| 4172 | +			if (!empty($row->clabels)) {
 | |
| 4173 | + $translation_texts[] = stripslashes_deep($row->clabels); | |
| 4174 | 4174 | } | 
| 4175 | 4175 | |
| 4176 | -			if ( ! empty( $row->required_msg ) ) {
 | |
| 4177 | - $translation_texts[] = stripslashes_deep( $row->required_msg ); | |
| 4176 | +			if (!empty($row->required_msg)) {
 | |
| 4177 | + $translation_texts[] = stripslashes_deep($row->required_msg); | |
| 4178 | 4178 | } | 
| 4179 | 4179 | |
| 4180 | -			if ( ! empty( $row->default_value ) ) {
 | |
| 4181 | - $translation_texts[] = stripslashes_deep( $row->default_value ); | |
| 4180 | +			if (!empty($row->default_value)) {
 | |
| 4181 | + $translation_texts[] = stripslashes_deep($row->default_value); | |
| 4182 | 4182 | } | 
| 4183 | 4183 | |
| 4184 | -			if ( ! empty( $row->option_values ) ) {
 | |
| 4185 | - $option_values = geodir_string_values_to_options( stripslashes_deep( $row->option_values ) ); | |
| 4184 | +			if (!empty($row->option_values)) {
 | |
| 4185 | + $option_values = geodir_string_values_to_options(stripslashes_deep($row->option_values)); | |
| 4186 | 4186 | |
| 4187 | -				if ( ! empty( $option_values ) ) {
 | |
| 4188 | -					foreach ( $option_values as $option_value ) {
 | |
| 4189 | -						if ( ! empty( $option_value['label'] ) ) {
 | |
| 4187 | +				if (!empty($option_values)) {
 | |
| 4188 | +					foreach ($option_values as $option_value) {
 | |
| 4189 | +						if (!empty($option_value['label'])) {
 | |
| 4190 | 4190 | $translation_texts[] = $option_value['label']; | 
| 4191 | 4191 | } | 
| 4192 | 4192 | } | 
| @@ -4196,48 +4196,48 @@ discard block | ||
| 4196 | 4196 | } | 
| 4197 | 4197 | |
| 4198 | 4198 | // Custom sorting fields table | 
| 4199 | - $sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE; | |
| 4200 | - $rows = $wpdb->get_results( $sql ); | |
| 4199 | + $sql = "SELECT site_title, asc_title, desc_title FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE; | |
| 4200 | + $rows = $wpdb->get_results($sql); | |
| 4201 | 4201 | |
| 4202 | -	if ( ! empty( $rows ) ) {
 | |
| 4203 | -		foreach ( $rows as $row ) {
 | |
| 4204 | -			if ( ! empty( $row->site_title ) ) {
 | |
| 4205 | - $translation_texts[] = stripslashes_deep( $row->site_title ); | |
| 4202 | +	if (!empty($rows)) {
 | |
| 4203 | +		foreach ($rows as $row) {
 | |
| 4204 | +			if (!empty($row->site_title)) {
 | |
| 4205 | + $translation_texts[] = stripslashes_deep($row->site_title); | |
| 4206 | 4206 | } | 
| 4207 | 4207 | |
| 4208 | -			if ( ! empty( $row->asc_title ) ) {
 | |
| 4209 | - $translation_texts[] = stripslashes_deep( $row->asc_title ); | |
| 4208 | +			if (!empty($row->asc_title)) {
 | |
| 4209 | + $translation_texts[] = stripslashes_deep($row->asc_title); | |
| 4210 | 4210 | } | 
| 4211 | 4211 | |
| 4212 | -			if ( ! empty( $row->desc_title ) ) {
 | |
| 4213 | - $translation_texts[] = stripslashes_deep( $row->desc_title ); | |
| 4212 | +			if (!empty($row->desc_title)) {
 | |
| 4213 | + $translation_texts[] = stripslashes_deep($row->desc_title); | |
| 4214 | 4214 | } | 
| 4215 | 4215 | } | 
| 4216 | 4216 | } | 
| 4217 | 4217 | |
| 4218 | 4218 | // Advance search filter fields table | 
| 4219 | -	if ( defined( 'GEODIR_ADVANCE_SEARCH_TABLE' ) ) {
 | |
| 4220 | - $sql = "SELECT field_site_name, front_search_title, field_desc FROM " . GEODIR_ADVANCE_SEARCH_TABLE; | |
| 4221 | - $rows = $wpdb->get_results( $sql ); | |
| 4222 | - | |
| 4223 | -		if ( ! empty( $rows ) ) {
 | |
| 4224 | -			foreach ( $rows as $row ) {
 | |
| 4225 | -				if ( ! empty( $row->field_site_name ) ) {
 | |
| 4226 | - $translation_texts[] = stripslashes_deep( $row->field_site_name ); | |
| 4219 | +	if (defined('GEODIR_ADVANCE_SEARCH_TABLE')) {
 | |
| 4220 | + $sql = "SELECT field_site_name, front_search_title, field_desc FROM ".GEODIR_ADVANCE_SEARCH_TABLE; | |
| 4221 | + $rows = $wpdb->get_results($sql); | |
| 4222 | + | |
| 4223 | +		if (!empty($rows)) {
 | |
| 4224 | +			foreach ($rows as $row) {
 | |
| 4225 | +				if (!empty($row->field_site_name)) {
 | |
| 4226 | + $translation_texts[] = stripslashes_deep($row->field_site_name); | |
| 4227 | 4227 | } | 
| 4228 | 4228 | |
| 4229 | -				if ( ! empty( $row->front_search_title ) ) {
 | |
| 4230 | - $translation_texts[] = stripslashes_deep( $row->front_search_title ); | |
| 4229 | +				if (!empty($row->front_search_title)) {
 | |
| 4230 | + $translation_texts[] = stripslashes_deep($row->front_search_title); | |
| 4231 | 4231 | } | 
| 4232 | 4232 | |
| 4233 | -				if ( ! empty( $row->field_desc ) ) {
 | |
| 4234 | - $translation_texts[] = stripslashes_deep( $row->field_desc ); | |
| 4233 | +				if (!empty($row->field_desc)) {
 | |
| 4234 | + $translation_texts[] = stripslashes_deep($row->field_desc); | |
| 4235 | 4235 | } | 
| 4236 | 4236 | } | 
| 4237 | 4237 | } | 
| 4238 | 4238 | } | 
| 4239 | 4239 | |
| 4240 | - $translation_texts = ! empty( $translation_texts ) ? array_unique( $translation_texts ) : $translation_texts; | |
| 4240 | + $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts; | |
| 4241 | 4241 | |
| 4242 | 4242 | return $translation_texts; | 
| 4243 | 4243 | } | 
| @@ -4259,7 +4259,7 @@ discard block | ||
| 4259 | 4259 | * | 
| 4260 | 4260 | * @param array $geodir_allowed_mime_types and file extensions. | 
| 4261 | 4261 | */ | 
| 4262 | - return apply_filters( 'geodir_allowed_mime_types', array( | |
| 4262 | +	return apply_filters('geodir_allowed_mime_types', array(
 | |
| 4263 | 4263 | 'Image' => array( // Image formats. | 
| 4264 | 4264 | 'jpg' => 'image/jpeg', | 
| 4265 | 4265 | 'jpe' => 'image/jpeg', | 
| @@ -4327,18 +4327,18 @@ discard block | ||
| 4327 | 4327 | * | 
| 4328 | 4328 | * @return string User display name. | 
| 4329 | 4329 | */ | 
| 4330 | -function geodir_get_client_name( $user_id ) {
 | |
| 4330 | +function geodir_get_client_name($user_id) {
 | |
| 4331 | 4331 | $client_name = ''; | 
| 4332 | 4332 | |
| 4333 | - $user_data = get_userdata( $user_id ); | |
| 4333 | + $user_data = get_userdata($user_id); | |
| 4334 | 4334 | |
| 4335 | -	if ( ! empty( $user_data ) ) {
 | |
| 4336 | -		if ( isset( $user_data->display_name ) && trim( $user_data->display_name ) != '' ) {
 | |
| 4337 | - $client_name = trim( $user_data->display_name ); | |
| 4338 | -		} else if ( isset( $user_data->user_nicename ) && trim( $user_data->user_nicename ) != '' ) {
 | |
| 4339 | - $client_name = trim( $user_data->user_nicename ); | |
| 4335 | +	if (!empty($user_data)) {
 | |
| 4336 | +		if (isset($user_data->display_name) && trim($user_data->display_name) != '') {
 | |
| 4337 | + $client_name = trim($user_data->display_name); | |
| 4338 | +		} else if (isset($user_data->user_nicename) && trim($user_data->user_nicename) != '') {
 | |
| 4339 | + $client_name = trim($user_data->user_nicename); | |
| 4340 | 4340 |  		} else {
 | 
| 4341 | - $client_name = trim( $user_data->user_login ); | |
| 4341 | + $client_name = trim($user_data->user_login); | |
| 4342 | 4342 | } | 
| 4343 | 4343 | } | 
| 4344 | 4344 | |
| @@ -4346,19 +4346,19 @@ discard block | ||
| 4346 | 4346 | } | 
| 4347 | 4347 | |
| 4348 | 4348 | |
| 4349 | -add_filter( 'wpseo_replacements', 'geodir_wpseo_replacements', 10, 1 ); | |
| 4349 | +add_filter('wpseo_replacements', 'geodir_wpseo_replacements', 10, 1);
 | |
| 4350 | 4350 | /* | 
| 4351 | 4351 | * Add location variables to wpseo replacements. | 
| 4352 | 4352 | * | 
| 4353 | 4353 | * @since 1.5.4 | 
| 4354 | 4354 | */ | 
| 4355 | -function geodir_wpseo_replacements( $vars ) {
 | |
| 4355 | +function geodir_wpseo_replacements($vars) {
 | |
| 4356 | 4356 | |
| 4357 | 4357 | global $wp; | 
| 4358 | 4358 | $title = ''; | 
| 4359 | 4359 | // location variables | 
| 4360 | 4360 | $gd_post_type = geodir_get_current_posttype(); | 
| 4361 | - $location_array = geodir_get_current_location_terms( 'query_vars', $gd_post_type ); | |
| 4361 | +	$location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
 | |
| 4362 | 4362 | /** | 
| 4363 | 4363 | * Filter the title variables location variables array | 
| 4364 | 4364 | * | 
| @@ -4368,105 +4368,105 @@ discard block | ||
| 4368 | 4368 | * @param array $location_array The array of location variables. | 
| 4369 | 4369 | * @param array $vars The page title variables. | 
| 4370 | 4370 | */ | 
| 4371 | - $location_array = apply_filters( 'geodir_filter_title_variables_location_arr_seo', $location_array, $vars ); | |
| 4371 | +	$location_array  = apply_filters('geodir_filter_title_variables_location_arr_seo', $location_array, $vars);
 | |
| 4372 | 4372 | $location_titles = array(); | 
| 4373 | -	if ( get_query_var( 'gd_country_full' ) ) {
 | |
| 4374 | -		if ( get_query_var( 'gd_country_full' ) ) {
 | |
| 4375 | - $location_array['gd_country'] = get_query_var( 'gd_country_full' ); | |
| 4373 | +	if (get_query_var('gd_country_full')) {
 | |
| 4374 | +		if (get_query_var('gd_country_full')) {
 | |
| 4375 | +			$location_array['gd_country'] = get_query_var('gd_country_full');
 | |
| 4376 | 4376 | } | 
| 4377 | -		if ( get_query_var( 'gd_region_full' ) ) {
 | |
| 4378 | - $location_array['gd_region'] = get_query_var( 'gd_region_full' ); | |
| 4377 | +		if (get_query_var('gd_region_full')) {
 | |
| 4378 | +			$location_array['gd_region'] = get_query_var('gd_region_full');
 | |
| 4379 | 4379 | } | 
| 4380 | -		if ( get_query_var( 'gd_city_full' ) ) {
 | |
| 4381 | - $location_array['gd_city'] = get_query_var( 'gd_city_full' ); | |
| 4380 | +		if (get_query_var('gd_city_full')) {
 | |
| 4381 | +			$location_array['gd_city'] = get_query_var('gd_city_full');
 | |
| 4382 | 4382 | } | 
| 4383 | 4383 | } | 
| 4384 | 4384 | $location_single = ''; | 
| 4385 | - $gd_country = ( isset( $wp->query_vars['gd_country'] ) && $wp->query_vars['gd_country'] != '' ) ? $wp->query_vars['gd_country'] : ''; | |
| 4386 | - $gd_region = ( isset( $wp->query_vars['gd_region'] ) && $wp->query_vars['gd_region'] != '' ) ? $wp->query_vars['gd_region'] : ''; | |
| 4387 | - $gd_city = ( isset( $wp->query_vars['gd_city'] ) && $wp->query_vars['gd_city'] != '' ) ? $wp->query_vars['gd_city'] : ''; | |
| 4385 | + $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; | |
| 4386 | + $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : ''; | |
| 4387 | + $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : ''; | |
| 4388 | 4388 | |
| 4389 | 4389 | $gd_country_actual = $gd_region_actual = $gd_city_actual = ''; | 
| 4390 | 4390 | |
| 4391 | -	if ( function_exists( 'get_actual_location_name' ) ) {
 | |
| 4392 | - $gd_country_actual = $gd_country != '' ? get_actual_location_name( 'country', $gd_country, true ) : $gd_country; | |
| 4393 | - $gd_region_actual = $gd_region != '' ? get_actual_location_name( 'region', $gd_region ) : $gd_region; | |
| 4394 | - $gd_city_actual = $gd_city != '' ? get_actual_location_name( 'city', $gd_city ) : $gd_city; | |
| 4391 | +	if (function_exists('get_actual_location_name')) {
 | |
| 4392 | +		$gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
 | |
| 4393 | +		$gd_region_actual  = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
 | |
| 4394 | +		$gd_city_actual    = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
 | |
| 4395 | 4395 | } | 
| 4396 | 4396 | |
| 4397 | -	if ( $gd_city != '' ) {
 | |
| 4398 | -		if ( $gd_city_actual != '' ) {
 | |
| 4397 | +	if ($gd_city != '') {
 | |
| 4398 | +		if ($gd_city_actual != '') {
 | |
| 4399 | 4399 | $gd_city = $gd_city_actual; | 
| 4400 | 4400 |  		} else {
 | 
| 4401 | - $gd_city = preg_replace( '/-(\d+)$/', '', $gd_city ); | |
| 4402 | - $gd_city = preg_replace( '/[_-]/', ' ', $gd_city ); | |
| 4403 | - $gd_city = __( geodir_ucwords( $gd_city ), 'geodirectory' ); | |
| 4401 | +			$gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
 | |
| 4402 | +			$gd_city = preg_replace('/[_-]/', ' ', $gd_city);
 | |
| 4403 | + $gd_city = __(geodir_ucwords($gd_city), 'geodirectory'); | |
| 4404 | 4404 | } | 
| 4405 | 4405 | $location_single = $gd_city; | 
| 4406 | 4406 | |
| 4407 | -	} else if ( $gd_region != '' ) {
 | |
| 4408 | -		if ( $gd_region_actual != '' ) {
 | |
| 4407 | +	} else if ($gd_region != '') {
 | |
| 4408 | +		if ($gd_region_actual != '') {
 | |
| 4409 | 4409 | $gd_region = $gd_region_actual; | 
| 4410 | 4410 |  		} else {
 | 
| 4411 | - $gd_region = preg_replace( '/-(\d+)$/', '', $gd_region ); | |
| 4412 | - $gd_region = preg_replace( '/[_-]/', ' ', $gd_region ); | |
| 4413 | - $gd_region = __( geodir_ucwords( $gd_region ), 'geodirectory' ); | |
| 4411 | +			$gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
 | |
| 4412 | +			$gd_region = preg_replace('/[_-]/', ' ', $gd_region);
 | |
| 4413 | + $gd_region = __(geodir_ucwords($gd_region), 'geodirectory'); | |
| 4414 | 4414 | } | 
| 4415 | 4415 | |
| 4416 | 4416 | $location_single = $gd_region; | 
| 4417 | -	} else if ( $gd_country != '' ) {
 | |
| 4418 | -		if ( $gd_country_actual != '' ) {
 | |
| 4417 | +	} else if ($gd_country != '') {
 | |
| 4418 | +		if ($gd_country_actual != '') {
 | |
| 4419 | 4419 | $gd_country = $gd_country_actual; | 
| 4420 | 4420 |  		} else {
 | 
| 4421 | - $gd_country = preg_replace( '/-(\d+)$/', '', $gd_country ); | |
| 4422 | - $gd_country = preg_replace( '/[_-]/', ' ', $gd_country ); | |
| 4423 | - $gd_country = __( geodir_ucwords( $gd_country ), 'geodirectory' ); | |
| 4421 | +			$gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
 | |
| 4422 | +			$gd_country = preg_replace('/[_-]/', ' ', $gd_country);
 | |
| 4423 | + $gd_country = __(geodir_ucwords($gd_country), 'geodirectory'); | |
| 4424 | 4424 | } | 
| 4425 | 4425 | |
| 4426 | 4426 | $location_single = $gd_country; | 
| 4427 | 4427 | } | 
| 4428 | 4428 | |
| 4429 | -	if ( ! empty( $location_array ) ) {
 | |
| 4429 | +	if (!empty($location_array)) {
 | |
| 4430 | 4430 | |
| 4431 | - $actual_location_name = function_exists( 'get_actual_location_name' ) ? true : false; | |
| 4432 | - $location_array = array_reverse( $location_array ); | |
| 4431 | +		$actual_location_name = function_exists('get_actual_location_name') ? true : false;
 | |
| 4432 | + $location_array = array_reverse($location_array); | |
| 4433 | 4433 | |
| 4434 | -		foreach ( $location_array as $location_type => $location ) {
 | |
| 4435 | - $gd_location_link_text = preg_replace( '/-(\d+)$/', '', $location ); | |
| 4436 | - $gd_location_link_text = preg_replace( '/[_-]/', ' ', $gd_location_link_text ); | |
| 4434 | +		foreach ($location_array as $location_type => $location) {
 | |
| 4435 | +			$gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
 | |
| 4436 | +			$gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
 | |
| 4437 | 4437 | |
| 4438 | - $location_name = geodir_ucwords( $gd_location_link_text ); | |
| 4439 | - $location_name = __( $location_name, 'geodirectory' ); | |
| 4438 | + $location_name = geodir_ucwords($gd_location_link_text); | |
| 4439 | + $location_name = __($location_name, 'geodirectory'); | |
| 4440 | 4440 | |
| 4441 | -			if ( $actual_location_name ) {
 | |
| 4442 | - $location_type = strpos( $location_type, 'gd_' ) === 0 ? substr( $location_type, 3 ) : $location_type; | |
| 4443 | - $location_name = get_actual_location_name( $location_type, $location, true ); | |
| 4441 | +			if ($actual_location_name) {
 | |
| 4442 | + $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type; | |
| 4443 | + $location_name = get_actual_location_name($location_type, $location, true); | |
| 4444 | 4444 | } | 
| 4445 | 4445 | |
| 4446 | 4446 | $location_titles[] = $location_name; | 
| 4447 | 4447 | } | 
| 4448 | -		if ( ! empty( $location_titles ) ) {
 | |
| 4449 | - $location_titles = array_unique( $location_titles ); | |
| 4448 | +		if (!empty($location_titles)) {
 | |
| 4449 | + $location_titles = array_unique($location_titles); | |
| 4450 | 4450 | } | 
| 4451 | 4451 | } | 
| 4452 | 4452 | |
| 4453 | 4453 | |
| 4454 | -	if ( ! empty( $location_titles ) ) {
 | |
| 4455 | - $vars['%%location%%'] = implode( ", ", $location_titles ); | |
| 4454 | +	if (!empty($location_titles)) {
 | |
| 4455 | +		$vars['%%location%%'] = implode(", ", $location_titles);
 | |
| 4456 | 4456 | } | 
| 4457 | 4457 | |
| 4458 | 4458 | |
| 4459 | -	if ( ! empty( $location_titles ) ) {
 | |
| 4460 | - $vars['%%in_location%%'] = __( 'in ', 'geodirectory' ) . implode( ", ", $location_titles ); | |
| 4459 | +	if (!empty($location_titles)) {
 | |
| 4460 | +		$vars['%%in_location%%'] = __('in ', 'geodirectory').implode(", ", $location_titles);
 | |
| 4461 | 4461 | } | 
| 4462 | 4462 | |
| 4463 | 4463 | |
| 4464 | -	if ( $location_single ) {
 | |
| 4465 | - $vars['%%in_location_single%%'] = __( 'in', 'geodirectory' ) . ' ' . $location_single; | |
| 4464 | +	if ($location_single) {
 | |
| 4465 | +		$vars['%%in_location_single%%'] = __('in', 'geodirectory').' '.$location_single;
 | |
| 4466 | 4466 | } | 
| 4467 | 4467 | |
| 4468 | 4468 | |
| 4469 | -	if ( $location_single ) {
 | |
| 4469 | +	if ($location_single) {
 | |
| 4470 | 4470 | $vars['%%location_single%%'] = $location_single; | 
| 4471 | 4471 | } | 
| 4472 | 4472 | |
| @@ -4479,13 +4479,13 @@ discard block | ||
| 4479 | 4479 | * @param string $vars The title with variables. | 
| 4480 | 4480 | * @param array $location_array The array of location variables. | 
| 4481 | 4481 | */ | 
| 4482 | - return apply_filters( 'geodir_wpseo_replacements_vars', $vars, $location_array ); | |
| 4482 | +	return apply_filters('geodir_wpseo_replacements_vars', $vars, $location_array);
 | |
| 4483 | 4483 | } | 
| 4484 | 4484 | |
| 4485 | 4485 | |
| 4486 | -add_filter( 'geodir_seo_meta_title', 'geodir_filter_title_variables', 10, 3 ); | |
| 4487 | -add_filter( 'geodir_seo_page_title', 'geodir_filter_title_variables', 10, 2 ); | |
| 4488 | -add_filter( 'geodir_seo_meta_description_pre', 'geodir_filter_title_variables', 10, 3 ); | |
| 4486 | +add_filter('geodir_seo_meta_title', 'geodir_filter_title_variables', 10, 3);
 | |
| 4487 | +add_filter('geodir_seo_page_title', 'geodir_filter_title_variables', 10, 2);
 | |
| 4488 | +add_filter('geodir_seo_meta_description_pre', 'geodir_filter_title_variables', 10, 3);
 | |
| 4489 | 4489 | |
| 4490 | 4490 | /** | 
| 4491 | 4491 | * Filter the title variables. | 
| @@ -4527,14 +4527,14 @@ discard block | ||
| 4527 | 4527 | * | 
| 4528 | 4528 | * @return string Title after filtered variables. | 
| 4529 | 4529 | */ | 
| 4530 | -function geodir_filter_title_variables( $title, $gd_page, $sep = '' ) {
 | |
| 4530 | +function geodir_filter_title_variables($title, $gd_page, $sep = '') {
 | |
| 4531 | 4531 | global $wp, $post; | 
| 4532 | 4532 | |
| 4533 | -	if ( ! $gd_page || ! $title ) {
 | |
| 4533 | +	if (!$gd_page || !$title) {
 | |
| 4534 | 4534 | return $title; // if no a GD page then bail. | 
| 4535 | 4535 | } | 
| 4536 | 4536 | |
| 4537 | -	if ( $sep == '' ) {
 | |
| 4537 | +	if ($sep == '') {
 | |
| 4538 | 4538 | /** | 
| 4539 | 4539 | * Filter the page title separator. | 
| 4540 | 4540 | * | 
| @@ -4543,100 +4543,100 @@ discard block | ||
| 4543 | 4543 | * | 
| 4544 | 4544 | * @param string $sep The separator, default: `|`. | 
| 4545 | 4545 | */ | 
| 4546 | - $sep = apply_filters( 'geodir_page_title_separator', '|' ); | |
| 4546 | +		$sep = apply_filters('geodir_page_title_separator', '|');
 | |
| 4547 | 4547 | } | 
| 4548 | 4548 | |
| 4549 | -	if ( strpos( $title, '%%title%%' ) !== false ) {
 | |
| 4550 | - $title = str_replace( "%%title%%", $post->post_title, $title ); | |
| 4549 | +	if (strpos($title, '%%title%%') !== false) {
 | |
| 4550 | +		$title = str_replace("%%title%%", $post->post_title, $title);
 | |
| 4551 | 4551 | } | 
| 4552 | 4552 | |
| 4553 | -	if ( strpos( $title, '%%sitename%%' ) !== false ) {
 | |
| 4554 | - $title = str_replace( "%%sitename%%", get_bloginfo( 'name' ), $title ); | |
| 4553 | +	if (strpos($title, '%%sitename%%') !== false) {
 | |
| 4554 | +		$title = str_replace("%%sitename%%", get_bloginfo('name'), $title);
 | |
| 4555 | 4555 | } | 
| 4556 | 4556 | |
| 4557 | -	if ( strpos( $title, '%%sitedesc%%' ) !== false ) {
 | |
| 4558 | - $title = str_replace( "%%sitedesc%%", get_bloginfo( 'description' ), $title ); | |
| 4557 | +	if (strpos($title, '%%sitedesc%%') !== false) {
 | |
| 4558 | +		$title = str_replace("%%sitedesc%%", get_bloginfo('description'), $title);
 | |
| 4559 | 4559 | } | 
| 4560 | 4560 | |
| 4561 | -	if ( strpos( $title, '%%excerpt%%' ) !== false ) {
 | |
| 4562 | - $title = str_replace( "%%excerpt%%", strip_tags( get_the_excerpt() ), $title ); | |
| 4561 | +	if (strpos($title, '%%excerpt%%') !== false) {
 | |
| 4562 | +		$title = str_replace("%%excerpt%%", strip_tags(get_the_excerpt()), $title);
 | |
| 4563 | 4563 | } | 
| 4564 | 4564 | |
| 4565 | -	if ( $gd_page == 'search' || $gd_page == 'author' ) {
 | |
| 4566 | - $post_type = isset( $_REQUEST['stype'] ) ? sanitize_text_field( $_REQUEST['stype'] ) : ''; | |
| 4567 | -	} else if ( $gd_page == 'add-listing' ) {
 | |
| 4568 | - $post_type = ( isset( $_REQUEST['listing_type'] ) ) ? sanitize_text_field( $_REQUEST['listing_type'] ) : ''; | |
| 4569 | - $post_type = ! $post_type && ! empty( $_REQUEST['pid'] ) ? get_post_type( (int) $_REQUEST['pid'] ) : $post_type; | |
| 4570 | -	} else if ( isset( $post->post_type ) && $post->post_type && in_array( $post->post_type, geodir_get_posttypes() ) ) {
 | |
| 4565 | +	if ($gd_page == 'search' || $gd_page == 'author') {
 | |
| 4566 | + $post_type = isset($_REQUEST['stype']) ? sanitize_text_field($_REQUEST['stype']) : ''; | |
| 4567 | +	} else if ($gd_page == 'add-listing') {
 | |
| 4568 | + $post_type = (isset($_REQUEST['listing_type'])) ? sanitize_text_field($_REQUEST['listing_type']) : ''; | |
| 4569 | + $post_type = !$post_type && !empty($_REQUEST['pid']) ? get_post_type((int) $_REQUEST['pid']) : $post_type; | |
| 4570 | +	} else if (isset($post->post_type) && $post->post_type && in_array($post->post_type, geodir_get_posttypes())) {
 | |
| 4571 | 4571 | $post_type = $post->post_type; | 
| 4572 | 4572 |  	} else {
 | 
| 4573 | - $post_type = get_query_var( 'post_type' ); | |
| 4573 | +		$post_type = get_query_var('post_type');
 | |
| 4574 | 4574 | } | 
| 4575 | 4575 | |
| 4576 | -	if ( strpos( $title, '%%pt_single%%' ) !== false ) {
 | |
| 4576 | +	if (strpos($title, '%%pt_single%%') !== false) {
 | |
| 4577 | 4577 | $singular_name = ''; | 
| 4578 | -		if ( $post_type && $singular_name = get_post_type_singular_label( $post_type ) ) {
 | |
| 4579 | - $singular_name = __( $singular_name, 'geodirectory' ); | |
| 4578 | +		if ($post_type && $singular_name = get_post_type_singular_label($post_type)) {
 | |
| 4579 | + $singular_name = __($singular_name, 'geodirectory'); | |
| 4580 | 4580 | } | 
| 4581 | 4581 | |
| 4582 | - $title = str_replace( "%%pt_single%%", $singular_name, $title ); | |
| 4582 | +		$title = str_replace("%%pt_single%%", $singular_name, $title);
 | |
| 4583 | 4583 | } | 
| 4584 | 4584 | |
| 4585 | -	if ( strpos( $title, '%%pt_plural%%' ) !== false ) {
 | |
| 4585 | +	if (strpos($title, '%%pt_plural%%') !== false) {
 | |
| 4586 | 4586 | $plural_name = ''; | 
| 4587 | -		if ( $post_type && $plural_name = get_post_type_plural_label( $post_type ) ) {
 | |
| 4588 | - $plural_name = __( $plural_name, 'geodirectory' ); | |
| 4587 | +		if ($post_type && $plural_name = get_post_type_plural_label($post_type)) {
 | |
| 4588 | + $plural_name = __($plural_name, 'geodirectory'); | |
| 4589 | 4589 | } | 
| 4590 | 4590 | |
| 4591 | - $title = str_replace( "%%pt_plural%%", $plural_name, $title ); | |
| 4591 | +		$title = str_replace("%%pt_plural%%", $plural_name, $title);
 | |
| 4592 | 4592 | } | 
| 4593 | 4593 | |
| 4594 | -	if ( strpos( $title, '%%category%%' ) !== false ) {
 | |
| 4594 | +	if (strpos($title, '%%category%%') !== false) {
 | |
| 4595 | 4595 | $cat_name = ''; | 
| 4596 | 4596 | |
| 4597 | -		if ( $gd_page == 'detail' ) {
 | |
| 4598 | -			if ( $post->default_category ) {
 | |
| 4599 | - $cat = get_term( $post->default_category, $post->post_type . 'category' ); | |
| 4600 | - $cat_name = ( isset( $cat->name ) ) ? $cat->name : ''; | |
| 4597 | +		if ($gd_page == 'detail') {
 | |
| 4598 | +			if ($post->default_category) {
 | |
| 4599 | + $cat = get_term($post->default_category, $post->post_type.'category'); | |
| 4600 | + $cat_name = (isset($cat->name)) ? $cat->name : ''; | |
| 4601 | 4601 | } | 
| 4602 | -		} else if ( $gd_page == 'listing' ) {
 | |
| 4602 | +		} else if ($gd_page == 'listing') {
 | |
| 4603 | 4603 | $queried_object = get_queried_object(); | 
| 4604 | -			if ( isset( $queried_object->name ) ) {
 | |
| 4604 | +			if (isset($queried_object->name)) {
 | |
| 4605 | 4605 | $cat_name = $queried_object->name; | 
| 4606 | 4606 | } | 
| 4607 | 4607 | } | 
| 4608 | - $title = str_replace( "%%category%%", $cat_name, $title ); | |
| 4608 | +		$title = str_replace("%%category%%", $cat_name, $title);
 | |
| 4609 | 4609 | } | 
| 4610 | 4610 | |
| 4611 | -	if ( strpos( $title, '%%tag%%' ) !== false ) {
 | |
| 4611 | +	if (strpos($title, '%%tag%%') !== false) {
 | |
| 4612 | 4612 | $cat_name = ''; | 
| 4613 | 4613 | |
| 4614 | -		if ( $gd_page == 'detail' ) {
 | |
| 4615 | -			if ( $post->default_category ) {
 | |
| 4616 | - $cat = get_term( $post->default_category, $post->post_type . 'category' ); | |
| 4617 | - $cat_name = ( isset( $cat->name ) ) ? $cat->name : ''; | |
| 4614 | +		if ($gd_page == 'detail') {
 | |
| 4615 | +			if ($post->default_category) {
 | |
| 4616 | + $cat = get_term($post->default_category, $post->post_type.'category'); | |
| 4617 | + $cat_name = (isset($cat->name)) ? $cat->name : ''; | |
| 4618 | 4618 | } | 
| 4619 | -		} else if ( $gd_page == 'listing' ) {
 | |
| 4619 | +		} else if ($gd_page == 'listing') {
 | |
| 4620 | 4620 | $queried_object = get_queried_object(); | 
| 4621 | -			if ( isset( $queried_object->name ) ) {
 | |
| 4621 | +			if (isset($queried_object->name)) {
 | |
| 4622 | 4622 | $cat_name = $queried_object->name; | 
| 4623 | 4623 | } | 
| 4624 | 4624 | } | 
| 4625 | - $title = str_replace( "%%tag%%", $cat_name, $title ); | |
| 4625 | +		$title = str_replace("%%tag%%", $cat_name, $title);
 | |
| 4626 | 4626 | } | 
| 4627 | 4627 | |
| 4628 | -	if ( strpos( $title, '%%id%%' ) !== false ) {
 | |
| 4629 | - $ID = ( isset( $post->ID ) ) ? $post->ID : ''; | |
| 4630 | - $title = str_replace( "%%id%%", $ID, $title ); | |
| 4628 | +	if (strpos($title, '%%id%%') !== false) {
 | |
| 4629 | + $ID = (isset($post->ID)) ? $post->ID : ''; | |
| 4630 | +		$title = str_replace("%%id%%", $ID, $title);
 | |
| 4631 | 4631 | } | 
| 4632 | 4632 | |
| 4633 | -	if ( strpos( $title, '%%sep%%' ) !== false ) {
 | |
| 4634 | - $title = str_replace( "%%sep%%", $sep, $title ); | |
| 4633 | +	if (strpos($title, '%%sep%%') !== false) {
 | |
| 4634 | +		$title = str_replace("%%sep%%", $sep, $title);
 | |
| 4635 | 4635 | } | 
| 4636 | 4636 | |
| 4637 | 4637 | // location variables | 
| 4638 | 4638 | $gd_post_type = geodir_get_current_posttype(); | 
| 4639 | - $location_array = geodir_get_current_location_terms( 'query_vars', $gd_post_type ); | |
| 4639 | +	$location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
 | |
| 4640 | 4640 | /** | 
| 4641 | 4641 | * Filter the title variables location variables array | 
| 4642 | 4642 | * | 
| @@ -4648,166 +4648,166 @@ discard block | ||
| 4648 | 4648 | * @param string $gd_page The page being filtered. | 
| 4649 | 4649 | * @param string $sep The separator, default: `|`. | 
| 4650 | 4650 | */ | 
| 4651 | - $location_array = apply_filters( 'geodir_filter_title_variables_location_arr', $location_array, $title, $gd_page, $sep ); | |
| 4651 | +	$location_array  = apply_filters('geodir_filter_title_variables_location_arr', $location_array, $title, $gd_page, $sep);
 | |
| 4652 | 4652 | $location_titles = array(); | 
| 4653 | -	if ( $gd_page == 'location' && get_query_var( 'gd_country_full' ) ) {
 | |
| 4654 | -		if ( get_query_var( 'gd_country_full' ) ) {
 | |
| 4655 | - $location_array['gd_country'] = get_query_var( 'gd_country_full' ); | |
| 4653 | +	if ($gd_page == 'location' && get_query_var('gd_country_full')) {
 | |
| 4654 | +		if (get_query_var('gd_country_full')) {
 | |
| 4655 | +			$location_array['gd_country'] = get_query_var('gd_country_full');
 | |
| 4656 | 4656 | } | 
| 4657 | -		if ( get_query_var( 'gd_region_full' ) ) {
 | |
| 4658 | - $location_array['gd_region'] = get_query_var( 'gd_region_full' ); | |
| 4657 | +		if (get_query_var('gd_region_full')) {
 | |
| 4658 | +			$location_array['gd_region'] = get_query_var('gd_region_full');
 | |
| 4659 | 4659 | } | 
| 4660 | -		if ( get_query_var( 'gd_city_full' ) ) {
 | |
| 4661 | - $location_array['gd_city'] = get_query_var( 'gd_city_full' ); | |
| 4660 | +		if (get_query_var('gd_city_full')) {
 | |
| 4661 | +			$location_array['gd_city'] = get_query_var('gd_city_full');
 | |
| 4662 | 4662 | } | 
| 4663 | 4663 | } | 
| 4664 | 4664 | $location_single = ''; | 
| 4665 | - $gd_country = ( isset( $wp->query_vars['gd_country'] ) && $wp->query_vars['gd_country'] != '' ) ? $wp->query_vars['gd_country'] : ''; | |
| 4666 | - $gd_region = ( isset( $wp->query_vars['gd_region'] ) && $wp->query_vars['gd_region'] != '' ) ? $wp->query_vars['gd_region'] : ''; | |
| 4667 | - $gd_city = ( isset( $wp->query_vars['gd_city'] ) && $wp->query_vars['gd_city'] != '' ) ? $wp->query_vars['gd_city'] : ''; | |
| 4665 | + $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; | |
| 4666 | + $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : ''; | |
| 4667 | + $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : ''; | |
| 4668 | 4668 | |
| 4669 | 4669 | $gd_country_actual = $gd_region_actual = $gd_city_actual = ''; | 
| 4670 | 4670 | |
| 4671 | -	if ( function_exists( 'get_actual_location_name' ) ) {
 | |
| 4672 | - $gd_country_actual = $gd_country != '' ? get_actual_location_name( 'country', $gd_country, true ) : $gd_country; | |
| 4673 | - $gd_region_actual = $gd_region != '' ? get_actual_location_name( 'region', $gd_region ) : $gd_region; | |
| 4674 | - $gd_city_actual = $gd_city != '' ? get_actual_location_name( 'city', $gd_city ) : $gd_city; | |
| 4671 | +	if (function_exists('get_actual_location_name')) {
 | |
| 4672 | +		$gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
 | |
| 4673 | +		$gd_region_actual  = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
 | |
| 4674 | +		$gd_city_actual    = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
 | |
| 4675 | 4675 | } | 
| 4676 | 4676 | |
| 4677 | -	if ( $gd_city != '' ) {
 | |
| 4678 | -		if ( $gd_city_actual != '' ) {
 | |
| 4677 | +	if ($gd_city != '') {
 | |
| 4678 | +		if ($gd_city_actual != '') {
 | |
| 4679 | 4679 | $gd_city = $gd_city_actual; | 
| 4680 | 4680 |  		} else {
 | 
| 4681 | - $gd_city = preg_replace( '/-(\d+)$/', '', $gd_city ); | |
| 4682 | - $gd_city = preg_replace( '/[_-]/', ' ', $gd_city ); | |
| 4683 | - $gd_city = __( geodir_ucwords( $gd_city ), 'geodirectory' ); | |
| 4681 | +			$gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
 | |
| 4682 | +			$gd_city = preg_replace('/[_-]/', ' ', $gd_city);
 | |
| 4683 | + $gd_city = __(geodir_ucwords($gd_city), 'geodirectory'); | |
| 4684 | 4684 | } | 
| 4685 | 4685 | $location_single = $gd_city; | 
| 4686 | 4686 | |
| 4687 | -	} else if ( $gd_region != '' ) {
 | |
| 4688 | -		if ( $gd_region_actual != '' ) {
 | |
| 4687 | +	} else if ($gd_region != '') {
 | |
| 4688 | +		if ($gd_region_actual != '') {
 | |
| 4689 | 4689 | $gd_region = $gd_region_actual; | 
| 4690 | 4690 |  		} else {
 | 
| 4691 | - $gd_region = preg_replace( '/-(\d+)$/', '', $gd_region ); | |
| 4692 | - $gd_region = preg_replace( '/[_-]/', ' ', $gd_region ); | |
| 4693 | - $gd_region = __( geodir_ucwords( $gd_region ), 'geodirectory' ); | |
| 4691 | +			$gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
 | |
| 4692 | +			$gd_region = preg_replace('/[_-]/', ' ', $gd_region);
 | |
| 4693 | + $gd_region = __(geodir_ucwords($gd_region), 'geodirectory'); | |
| 4694 | 4694 | } | 
| 4695 | 4695 | |
| 4696 | 4696 | $location_single = $gd_region; | 
| 4697 | -	} else if ( $gd_country != '' ) {
 | |
| 4698 | -		if ( $gd_country_actual != '' ) {
 | |
| 4697 | +	} else if ($gd_country != '') {
 | |
| 4698 | +		if ($gd_country_actual != '') {
 | |
| 4699 | 4699 | $gd_country = $gd_country_actual; | 
| 4700 | 4700 |  		} else {
 | 
| 4701 | - $gd_country = preg_replace( '/-(\d+)$/', '', $gd_country ); | |
| 4702 | - $gd_country = preg_replace( '/[_-]/', ' ', $gd_country ); | |
| 4703 | - $gd_country = __( geodir_ucwords( $gd_country ), 'geodirectory' ); | |
| 4701 | +			$gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
 | |
| 4702 | +			$gd_country = preg_replace('/[_-]/', ' ', $gd_country);
 | |
| 4703 | + $gd_country = __(geodir_ucwords($gd_country), 'geodirectory'); | |
| 4704 | 4704 | } | 
| 4705 | 4705 | |
| 4706 | 4706 | $location_single = $gd_country; | 
| 4707 | 4707 | } | 
| 4708 | 4708 | |
| 4709 | -	if ( ! empty( $location_array ) ) {
 | |
| 4709 | +	if (!empty($location_array)) {
 | |
| 4710 | 4710 | |
| 4711 | - $actual_location_name = function_exists( 'get_actual_location_name' ) ? true : false; | |
| 4712 | - $location_array = array_reverse( $location_array ); | |
| 4711 | +		$actual_location_name = function_exists('get_actual_location_name') ? true : false;
 | |
| 4712 | + $location_array = array_reverse($location_array); | |
| 4713 | 4713 | |
| 4714 | -		foreach ( $location_array as $location_type => $location ) {
 | |
| 4715 | - $gd_location_link_text = preg_replace( '/-(\d+)$/', '', $location ); | |
| 4716 | - $gd_location_link_text = preg_replace( '/[_-]/', ' ', $gd_location_link_text ); | |
| 4714 | +		foreach ($location_array as $location_type => $location) {
 | |
| 4715 | +			$gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
 | |
| 4716 | +			$gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
 | |
| 4717 | 4717 | |
| 4718 | - $location_name = geodir_ucwords( $gd_location_link_text ); | |
| 4719 | - $location_name = __( $location_name, 'geodirectory' ); | |
| 4718 | + $location_name = geodir_ucwords($gd_location_link_text); | |
| 4719 | + $location_name = __($location_name, 'geodirectory'); | |
| 4720 | 4720 | |
| 4721 | -			if ( $actual_location_name ) {
 | |
| 4722 | - $location_type = strpos( $location_type, 'gd_' ) === 0 ? substr( $location_type, 3 ) : $location_type; | |
| 4723 | - $location_name = get_actual_location_name( $location_type, $location, true ); | |
| 4721 | +			if ($actual_location_name) {
 | |
| 4722 | + $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type; | |
| 4723 | + $location_name = get_actual_location_name($location_type, $location, true); | |
| 4724 | 4724 | } | 
| 4725 | 4725 | |
| 4726 | 4726 | $location_titles[] = $location_name; | 
| 4727 | 4727 | } | 
| 4728 | -		if ( ! empty( $location_titles ) ) {
 | |
| 4729 | - $location_titles = array_unique( $location_titles ); | |
| 4728 | +		if (!empty($location_titles)) {
 | |
| 4729 | + $location_titles = array_unique($location_titles); | |
| 4730 | 4730 | } | 
| 4731 | 4731 | } | 
| 4732 | 4732 | |
| 4733 | 4733 | |
| 4734 | -	if ( strpos( $title, '%%location%%' ) !== false ) {
 | |
| 4734 | +	if (strpos($title, '%%location%%') !== false) {
 | |
| 4735 | 4735 | $location = ''; | 
| 4736 | -		if ( $location_titles ) {
 | |
| 4737 | - $location = implode( ", ", $location_titles ); | |
| 4736 | +		if ($location_titles) {
 | |
| 4737 | +			$location = implode(", ", $location_titles);
 | |
| 4738 | 4738 | } | 
| 4739 | - $title = str_replace( "%%location%%", $location, $title ); | |
| 4739 | +		$title = str_replace("%%location%%", $location, $title);
 | |
| 4740 | 4740 | } | 
| 4741 | 4741 | |
| 4742 | -	if ( strpos( $title, '%%in_location%%' ) !== false ) {
 | |
| 4742 | +	if (strpos($title, '%%in_location%%') !== false) {
 | |
| 4743 | 4743 | $location = ''; | 
| 4744 | -		if ( $location_titles ) {
 | |
| 4745 | - $location = __( 'in ', 'geodirectory' ) . implode( ", ", $location_titles ); | |
| 4744 | +		if ($location_titles) {
 | |
| 4745 | +			$location = __('in ', 'geodirectory').implode(", ", $location_titles);
 | |
| 4746 | 4746 | } | 
| 4747 | - $title = str_replace( "%%in_location%%", $location, $title ); | |
| 4747 | +		$title = str_replace("%%in_location%%", $location, $title);
 | |
| 4748 | 4748 | } | 
| 4749 | 4749 | |
| 4750 | -	if ( strpos( $title, '%%in_location_single%%' ) !== false ) {
 | |
| 4751 | -		if ( $location_single ) {
 | |
| 4752 | - $location_single = __( 'in', 'geodirectory' ) . ' ' . $location_single; | |
| 4750 | +	if (strpos($title, '%%in_location_single%%') !== false) {
 | |
| 4751 | +		if ($location_single) {
 | |
| 4752 | +			$location_single = __('in', 'geodirectory').' '.$location_single;
 | |
| 4753 | 4753 | } | 
| 4754 | - $title = str_replace( "%%in_location_single%%", $location_single, $title ); | |
| 4754 | +		$title = str_replace("%%in_location_single%%", $location_single, $title);
 | |
| 4755 | 4755 | } | 
| 4756 | 4756 | |
| 4757 | -	if ( strpos( $title, '%%location_single%%' ) !== false ) {
 | |
| 4758 | - $title = str_replace( "%%location_single%%", $location_single, $title ); | |
| 4757 | +	if (strpos($title, '%%location_single%%') !== false) {
 | |
| 4758 | +		$title = str_replace("%%location_single%%", $location_single, $title);
 | |
| 4759 | 4759 | } | 
| 4760 | 4760 | |
| 4761 | 4761 | |
| 4762 | -	if ( strpos( $title, '%%search_term%%' ) !== false ) {
 | |
| 4762 | +	if (strpos($title, '%%search_term%%') !== false) {
 | |
| 4763 | 4763 | $search_term = ''; | 
| 4764 | -		if ( isset( $_REQUEST['s'] ) ) {
 | |
| 4765 | - $search_term = esc_attr( $_REQUEST['s'] ); | |
| 4764 | +		if (isset($_REQUEST['s'])) {
 | |
| 4765 | + $search_term = esc_attr($_REQUEST['s']); | |
| 4766 | 4766 | } | 
| 4767 | - $title = str_replace( "%%search_term%%", $search_term, $title ); | |
| 4767 | +		$title = str_replace("%%search_term%%", $search_term, $title);
 | |
| 4768 | 4768 | } | 
| 4769 | 4769 | |
| 4770 | -	if ( strpos( $title, '%%search_near%%' ) !== false ) {
 | |
| 4770 | +	if (strpos($title, '%%search_near%%') !== false) {
 | |
| 4771 | 4771 | $search_term = ''; | 
| 4772 | -		if ( isset( $_REQUEST['snear'] ) ) {
 | |
| 4773 | - $search_term = esc_attr( $_REQUEST['snear'] ); | |
| 4772 | +		if (isset($_REQUEST['snear'])) {
 | |
| 4773 | + $search_term = esc_attr($_REQUEST['snear']); | |
| 4774 | 4774 | } | 
| 4775 | - $title = str_replace( "%%search_near%%", $search_term, $title ); | |
| 4775 | +		$title = str_replace("%%search_near%%", $search_term, $title);
 | |
| 4776 | 4776 | } | 
| 4777 | 4777 | |
| 4778 | -	if ( strpos( $title, '%%name%%' ) !== false ) {
 | |
| 4779 | -		if ( is_author() ) {
 | |
| 4780 | - $curauth = ( get_query_var( 'author_name' ) ) ? get_user_by( 'slug', get_query_var( 'author_name' ) ) : get_userdata( get_query_var( 'author' ) ); | |
| 4778 | +	if (strpos($title, '%%name%%') !== false) {
 | |
| 4779 | +		if (is_author()) {
 | |
| 4780 | +			$curauth     = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
 | |
| 4781 | 4781 | $author_name = $curauth->display_name; | 
| 4782 | 4782 |  		} else {
 | 
| 4783 | 4783 | $author_name = get_the_author(); | 
| 4784 | 4784 | } | 
| 4785 | -		if ( ! $author_name || $author_name === '' ) {
 | |
| 4785 | +		if (!$author_name || $author_name === '') {
 | |
| 4786 | 4786 | $queried_object = get_queried_object(); | 
| 4787 | 4787 | |
| 4788 | -			if ( isset( $queried_object->data->user_nicename ) ) {
 | |
| 4788 | +			if (isset($queried_object->data->user_nicename)) {
 | |
| 4789 | 4789 | $author_name = $queried_object->data->display_name; | 
| 4790 | 4790 | } | 
| 4791 | 4791 | } | 
| 4792 | - $title = str_replace( "%%name%%", $author_name, $title ); | |
| 4792 | +		$title = str_replace("%%name%%", $author_name, $title);
 | |
| 4793 | 4793 | } | 
| 4794 | 4794 | |
| 4795 | -	if ( strpos( $title, '%%page%%' ) !== false ) {
 | |
| 4796 | - $page = geodir_title_meta_page( $sep ); | |
| 4797 | - $title = str_replace( "%%page%%", $page, $title ); | |
| 4795 | +	if (strpos($title, '%%page%%') !== false) {
 | |
| 4796 | + $page = geodir_title_meta_page($sep); | |
| 4797 | +		$title = str_replace("%%page%%", $page, $title);
 | |
| 4798 | 4798 | } | 
| 4799 | -	if ( strpos( $title, '%%pagenumber%%' ) !== false ) {
 | |
| 4799 | +	if (strpos($title, '%%pagenumber%%') !== false) {
 | |
| 4800 | 4800 | $pagenumber = geodir_title_meta_pagenumber(); | 
| 4801 | - $title = str_replace( "%%pagenumber%%", $pagenumber, $title ); | |
| 4801 | +		$title      = str_replace("%%pagenumber%%", $pagenumber, $title);
 | |
| 4802 | 4802 | } | 
| 4803 | -	if ( strpos( $title, '%%pagetotal%%' ) !== false ) {
 | |
| 4803 | +	if (strpos($title, '%%pagetotal%%') !== false) {
 | |
| 4804 | 4804 | $pagetotal = geodir_title_meta_pagetotal(); | 
| 4805 | - $title = str_replace( "%%pagetotal%%", $pagetotal, $title ); | |
| 4805 | +		$title     = str_replace("%%pagetotal%%", $pagetotal, $title);
 | |
| 4806 | 4806 | } | 
| 4807 | 4807 | |
| 4808 | - $title = wptexturize( $title ); | |
| 4809 | - $title = convert_chars( $title ); | |
| 4810 | - $title = esc_html( $title ); | |
| 4808 | + $title = wptexturize($title); | |
| 4809 | + $title = convert_chars($title); | |
| 4810 | + $title = esc_html($title); | |
| 4811 | 4811 | |
| 4812 | 4812 | /** | 
| 4813 | 4813 | * Filter the title variables after standard ones have been filtered. | 
| @@ -4821,7 +4821,7 @@ discard block | ||
| 4821 | 4821 | * @param string $sep The separator, default: `|`. | 
| 4822 | 4822 | */ | 
| 4823 | 4823 | |
| 4824 | - return apply_filters( 'geodir_filter_title_variables_vars', $title, $location_array, $gd_page, $sep ); | |
| 4824 | +	return apply_filters('geodir_filter_title_variables_vars', $title, $location_array, $gd_page, $sep);
 | |
| 4825 | 4825 | } | 
| 4826 | 4826 | |
| 4827 | 4827 | /** | 
| @@ -4834,82 +4834,82 @@ discard block | ||
| 4834 | 4834 | * | 
| 4835 | 4835 | * @return array Translation texts. | 
| 4836 | 4836 | */ | 
| 4837 | -function geodir_load_cpt_text_translation( $translation_texts = array() ) {
 | |
| 4838 | - $gd_post_types = geodir_get_posttypes( 'array' ); | |
| 4837 | +function geodir_load_cpt_text_translation($translation_texts = array()) {
 | |
| 4838 | +	$gd_post_types = geodir_get_posttypes('array');
 | |
| 4839 | 4839 | |
| 4840 | -	if ( ! empty( $gd_post_types ) ) {
 | |
| 4841 | -		foreach ( $gd_post_types as $post_type => $cpt_info ) {
 | |
| 4842 | - $labels = isset( $cpt_info['labels'] ) ? $cpt_info['labels'] : ''; | |
| 4843 | - $description = isset( $cpt_info['description'] ) ? $cpt_info['description'] : ''; | |
| 4844 | - $seo = isset( $cpt_info['seo'] ) ? $cpt_info['seo'] : ''; | |
| 4840 | +	if (!empty($gd_post_types)) {
 | |
| 4841 | +		foreach ($gd_post_types as $post_type => $cpt_info) {
 | |
| 4842 | + $labels = isset($cpt_info['labels']) ? $cpt_info['labels'] : ''; | |
| 4843 | + $description = isset($cpt_info['description']) ? $cpt_info['description'] : ''; | |
| 4844 | + $seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : ''; | |
| 4845 | 4845 | |
| 4846 | -			if ( ! empty( $labels ) ) {
 | |
| 4847 | -				if ( $labels['name'] != '' && ! in_array( $labels['name'], $translation_texts ) ) {
 | |
| 4846 | +			if (!empty($labels)) {
 | |
| 4847 | +				if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts)) {
 | |
| 4848 | 4848 | $translation_texts[] = $labels['name']; | 
| 4849 | 4849 | } | 
| 4850 | -				if ( $labels['singular_name'] != '' && ! in_array( $labels['singular_name'], $translation_texts ) ) {
 | |
| 4850 | +				if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts)) {
 | |
| 4851 | 4851 | $translation_texts[] = $labels['singular_name']; | 
| 4852 | 4852 | } | 
| 4853 | -				if ( $labels['add_new'] != '' && ! in_array( $labels['add_new'], $translation_texts ) ) {
 | |
| 4853 | +				if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts)) {
 | |
| 4854 | 4854 | $translation_texts[] = $labels['add_new']; | 
| 4855 | 4855 | } | 
| 4856 | -				if ( $labels['add_new_item'] != '' && ! in_array( $labels['add_new_item'], $translation_texts ) ) {
 | |
| 4856 | +				if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts)) {
 | |
| 4857 | 4857 | $translation_texts[] = $labels['add_new_item']; | 
| 4858 | 4858 | } | 
| 4859 | -				if ( $labels['edit_item'] != '' && ! in_array( $labels['edit_item'], $translation_texts ) ) {
 | |
| 4859 | +				if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts)) {
 | |
| 4860 | 4860 | $translation_texts[] = $labels['edit_item']; | 
| 4861 | 4861 | } | 
| 4862 | -				if ( $labels['new_item'] != '' && ! in_array( $labels['new_item'], $translation_texts ) ) {
 | |
| 4862 | +				if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts)) {
 | |
| 4863 | 4863 | $translation_texts[] = $labels['new_item']; | 
| 4864 | 4864 | } | 
| 4865 | -				if ( $labels['view_item'] != '' && ! in_array( $labels['view_item'], $translation_texts ) ) {
 | |
| 4865 | +				if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts)) {
 | |
| 4866 | 4866 | $translation_texts[] = $labels['view_item']; | 
| 4867 | 4867 | } | 
| 4868 | -				if ( $labels['search_items'] != '' && ! in_array( $labels['search_items'], $translation_texts ) ) {
 | |
| 4868 | +				if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts)) {
 | |
| 4869 | 4869 | $translation_texts[] = $labels['search_items']; | 
| 4870 | 4870 | } | 
| 4871 | -				if ( $labels['not_found'] != '' && ! in_array( $labels['not_found'], $translation_texts ) ) {
 | |
| 4871 | +				if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts)) {
 | |
| 4872 | 4872 | $translation_texts[] = $labels['not_found']; | 
| 4873 | 4873 | } | 
| 4874 | -				if ( $labels['not_found_in_trash'] != '' && ! in_array( $labels['not_found_in_trash'], $translation_texts ) ) {
 | |
| 4874 | +				if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts)) {
 | |
| 4875 | 4875 | $translation_texts[] = $labels['not_found_in_trash']; | 
| 4876 | 4876 | } | 
| 4877 | -				if ( isset( $labels['label_post_profile'] ) && $labels['label_post_profile'] != '' && ! in_array( $labels['label_post_profile'], $translation_texts ) ) {
 | |
| 4877 | +				if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts)) {
 | |
| 4878 | 4878 | $translation_texts[] = $labels['label_post_profile']; | 
| 4879 | 4879 | } | 
| 4880 | -				if ( isset( $labels['label_post_info'] ) && $labels['label_post_info'] != '' && ! in_array( $labels['label_post_info'], $translation_texts ) ) {
 | |
| 4880 | +				if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts)) {
 | |
| 4881 | 4881 | $translation_texts[] = $labels['label_post_info']; | 
| 4882 | 4882 | } | 
| 4883 | -				if ( isset( $labels['label_post_images'] ) && $labels['label_post_images'] != '' && ! in_array( $labels['label_post_images'], $translation_texts ) ) {
 | |
| 4883 | +				if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts)) {
 | |
| 4884 | 4884 | $translation_texts[] = $labels['label_post_images']; | 
| 4885 | 4885 | } | 
| 4886 | -				if ( isset( $labels['label_post_map'] ) && $labels['label_post_map'] != '' && ! in_array( $labels['label_post_map'], $translation_texts ) ) {
 | |
| 4886 | +				if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts)) {
 | |
| 4887 | 4887 | $translation_texts[] = $labels['label_post_map']; | 
| 4888 | 4888 | } | 
| 4889 | -				if ( isset( $labels['label_reviews'] ) && $labels['label_reviews'] != '' && ! in_array( $labels['label_reviews'], $translation_texts ) ) {
 | |
| 4889 | +				if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts)) {
 | |
| 4890 | 4890 | $translation_texts[] = $labels['label_reviews']; | 
| 4891 | 4891 | } | 
| 4892 | -				if ( isset( $labels['label_related_listing'] ) && $labels['label_related_listing'] != '' && ! in_array( $labels['label_related_listing'], $translation_texts ) ) {
 | |
| 4892 | +				if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts)) {
 | |
| 4893 | 4893 | $translation_texts[] = $labels['label_related_listing']; | 
| 4894 | 4894 | } | 
| 4895 | 4895 | } | 
| 4896 | 4896 | |
| 4897 | -			if ( $description != '' && ! in_array( $description, $translation_texts ) ) {
 | |
| 4898 | - $translation_texts[] = normalize_whitespace( $description ); | |
| 4897 | +			if ($description != '' && !in_array($description, $translation_texts)) {
 | |
| 4898 | + $translation_texts[] = normalize_whitespace($description); | |
| 4899 | 4899 | } | 
| 4900 | 4900 | |
| 4901 | -			if ( ! empty( $seo ) ) {
 | |
| 4902 | -				if ( isset( $seo['meta_keyword'] ) && $seo['meta_keyword'] != '' && ! in_array( $seo['meta_keyword'], $translation_texts ) ) {
 | |
| 4903 | - $translation_texts[] = normalize_whitespace( $seo['meta_keyword'] ); | |
| 4901 | +			if (!empty($seo)) {
 | |
| 4902 | +				if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts)) {
 | |
| 4903 | + $translation_texts[] = normalize_whitespace($seo['meta_keyword']); | |
| 4904 | 4904 | } | 
| 4905 | 4905 | |
| 4906 | -				if ( isset( $seo['meta_description'] ) && $seo['meta_description'] != '' && ! in_array( $seo['meta_description'], $translation_texts ) ) {
 | |
| 4907 | - $translation_texts[] = normalize_whitespace( $seo['meta_description'] ); | |
| 4906 | +				if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts)) {
 | |
| 4907 | + $translation_texts[] = normalize_whitespace($seo['meta_description']); | |
| 4908 | 4908 | } | 
| 4909 | 4909 | } | 
| 4910 | 4910 | } | 
| 4911 | 4911 | } | 
| 4912 | - $translation_texts = ! empty( $translation_texts ) ? array_unique( $translation_texts ) : $translation_texts; | |
| 4912 | + $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts; | |
| 4913 | 4913 | |
| 4914 | 4914 | return $translation_texts; | 
| 4915 | 4915 | } | 
| @@ -4924,27 +4924,27 @@ discard block | ||
| 4924 | 4924 | * | 
| 4925 | 4925 | * @return array Location terms. | 
| 4926 | 4926 | */ | 
| 4927 | -function geodir_remove_location_terms( $location_terms = array() ) {
 | |
| 4928 | - $location_manager = defined( 'POST_LOCATION_TABLE' ) ? true : false; | |
| 4927 | +function geodir_remove_location_terms($location_terms = array()) {
 | |
| 4928 | +	$location_manager = defined('POST_LOCATION_TABLE') ? true : false;
 | |
| 4929 | 4929 | |
| 4930 | -	if ( ! empty( $location_terms ) && $location_manager ) {
 | |
| 4931 | - $hide_country_part = get_option( 'geodir_location_hide_country_part' ); | |
| 4932 | - $hide_region_part = get_option( 'geodir_location_hide_region_part' ); | |
| 4930 | +	if (!empty($location_terms) && $location_manager) {
 | |
| 4931 | +		$hide_country_part = get_option('geodir_location_hide_country_part');
 | |
| 4932 | +		$hide_region_part  = get_option('geodir_location_hide_region_part');
 | |
| 4933 | 4933 | |
| 4934 | -		if ( $hide_region_part && $hide_country_part ) {
 | |
| 4935 | -			if ( isset( $location_terms['gd_country'] ) ) {
 | |
| 4936 | - unset( $location_terms['gd_country'] ); | |
| 4934 | +		if ($hide_region_part && $hide_country_part) {
 | |
| 4935 | +			if (isset($location_terms['gd_country'])) {
 | |
| 4936 | + unset($location_terms['gd_country']); | |
| 4937 | 4937 | } | 
| 4938 | -			if ( isset( $location_terms['gd_region'] ) ) {
 | |
| 4939 | - unset( $location_terms['gd_region'] ); | |
| 4938 | +			if (isset($location_terms['gd_region'])) {
 | |
| 4939 | + unset($location_terms['gd_region']); | |
| 4940 | 4940 | } | 
| 4941 | -		} else if ( $hide_region_part && ! $hide_country_part ) {
 | |
| 4942 | -			if ( isset( $location_terms['gd_region'] ) ) {
 | |
| 4943 | - unset( $location_terms['gd_region'] ); | |
| 4941 | +		} else if ($hide_region_part && !$hide_country_part) {
 | |
| 4942 | +			if (isset($location_terms['gd_region'])) {
 | |
| 4943 | + unset($location_terms['gd_region']); | |
| 4944 | 4944 | } | 
| 4945 | -		} else if ( ! $hide_region_part && $hide_country_part ) {
 | |
| 4946 | -			if ( isset( $location_terms['gd_country'] ) ) {
 | |
| 4947 | - unset( $location_terms['gd_country'] ); | |
| 4945 | +		} else if (!$hide_region_part && $hide_country_part) {
 | |
| 4946 | +			if (isset($location_terms['gd_country'])) {
 | |
| 4947 | + unset($location_terms['gd_country']); | |
| 4948 | 4948 | } | 
| 4949 | 4949 | } | 
| 4950 | 4950 | } | 
| @@ -4962,33 +4962,33 @@ discard block | ||
| 4962 | 4962 | * @param WP_Post $post Post object. | 
| 4963 | 4963 | * @param bool $update Whether this is an existing listing being updated or not. | 
| 4964 | 4964 | */ | 
| 4965 | -function geodir_on_wp_insert_post( $post_ID, $post, $update ) {
 | |
| 4966 | -	if ( ! $update ) {
 | |
| 4965 | +function geodir_on_wp_insert_post($post_ID, $post, $update) {
 | |
| 4966 | +	if (!$update) {
 | |
| 4967 | 4967 | return; | 
| 4968 | 4968 | } | 
| 4969 | 4969 | |
| 4970 | - $action = isset( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : ''; | |
| 4971 | - $is_admin = is_admin() && ( ! defined( 'DOING_AJAX' ) || ( defined( 'DOING_AJAX' ) && ! DOING_AJAX ) ) ? true : false; | |
| 4970 | + $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : ''; | |
| 4971 | +	$is_admin    = is_admin() && (!defined('DOING_AJAX') || (defined('DOING_AJAX') && !DOING_AJAX)) ? true : false;
 | |
| 4972 | 4972 | $inline_save = $action == 'inline-save' ? true : false; | 
| 4973 | 4973 | |
| 4974 | -	if ( empty( $post->post_type ) || $is_admin || $inline_save || ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) ) {
 | |
| 4974 | +	if (empty($post->post_type) || $is_admin || $inline_save || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
 | |
| 4975 | 4975 | return; | 
| 4976 | 4976 | } | 
| 4977 | 4977 | |
| 4978 | -	if ( $action != '' && in_array( $action, array( 'geodir_import_export' ) ) ) {
 | |
| 4978 | +	if ($action != '' && in_array($action, array('geodir_import_export'))) {
 | |
| 4979 | 4979 | return; | 
| 4980 | 4980 | } | 
| 4981 | 4981 | |
| 4982 | 4982 | $user_id = (int) get_current_user_id(); | 
| 4983 | 4983 | |
| 4984 | -	if ( $user_id > 0 && get_option( 'geodir_notify_post_edited' ) && ! wp_is_post_revision( $post_ID ) && in_array( $post->post_type, geodir_get_posttypes() ) ) {
 | |
| 4985 | - $author_id = ! empty( $post->post_author ) ? $post->post_author : 0; | |
| 4984 | +	if ($user_id > 0 && get_option('geodir_notify_post_edited') && !wp_is_post_revision($post_ID) && in_array($post->post_type, geodir_get_posttypes())) {
 | |
| 4985 | + $author_id = !empty($post->post_author) ? $post->post_author : 0; | |
| 4986 | 4986 | |
| 4987 | -		if ( $user_id == $author_id && ! is_super_admin() ) {
 | |
| 4988 | - $from_email = get_option( 'site_email' ); | |
| 4987 | +		if ($user_id == $author_id && !is_super_admin()) {
 | |
| 4988 | +			$from_email   = get_option('site_email');
 | |
| 4989 | 4989 | $from_name = get_site_emailName(); | 
| 4990 | - $to_email = get_option( 'admin_email' ); | |
| 4991 | - $to_name = get_option( 'name' ); | |
| 4990 | +			$to_email     = get_option('admin_email');
 | |
| 4991 | +			$to_name      = get_option('name');
 | |
| 4992 | 4992 | $message_type = 'listing_edited'; | 
| 4993 | 4993 | |
| 4994 | 4994 | $notify_edited = true; | 
| @@ -5000,9 +5000,9 @@ discard block | ||
| 5000 | 5000 | * @param bool $notify_edited Notify on listing edited by author? | 
| 5001 | 5001 | * @param object $post The current post object. | 
| 5002 | 5002 | */ | 
| 5003 | - $notify_edited = apply_filters( 'geodir_notify_on_listing_edited', $notify_edited, $post ); | |
| 5003 | +			$notify_edited = apply_filters('geodir_notify_on_listing_edited', $notify_edited, $post);
 | |
| 5004 | 5004 | |
| 5005 | - geodir_sendEmail( $from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID ); | |
| 5005 | + geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID); | |
| 5006 | 5006 | } | 
| 5007 | 5007 | } | 
| 5008 | 5008 | } | 
| @@ -5017,14 +5017,14 @@ discard block | ||
| 5017 | 5017 | * | 
| 5018 | 5018 | * @return string|null The current page start & end numbering. | 
| 5019 | 5019 | */ | 
| 5020 | -function geodir_title_meta_page( $sep ) {
 | |
| 5020 | +function geodir_title_meta_page($sep) {
 | |
| 5021 | 5021 | $replacement = null; | 
| 5022 | 5022 | |
| 5023 | - $max = geodir_title_meta_pagenumbering( 'max' ); | |
| 5024 | - $nr = geodir_title_meta_pagenumbering( 'nr' ); | |
| 5023 | +	$max = geodir_title_meta_pagenumbering('max');
 | |
| 5024 | +	$nr  = geodir_title_meta_pagenumbering('nr');
 | |
| 5025 | 5025 | |
| 5026 | -	if ( $max > 1 && $nr > 1 ) {
 | |
| 5027 | - $replacement = sprintf( $sep . ' ' . __( 'Page %1$d of %2$d', 'geodirectory' ), $nr, $max ); | |
| 5026 | +	if ($max > 1 && $nr > 1) {
 | |
| 5027 | +		$replacement = sprintf($sep.' '.__('Page %1$d of %2$d', 'geodirectory'), $nr, $max);
 | |
| 5028 | 5028 | } | 
| 5029 | 5029 | |
| 5030 | 5030 | return $replacement; | 
| @@ -5041,8 +5041,8 @@ discard block | ||
| 5041 | 5041 |  function geodir_title_meta_pagenumber() {
 | 
| 5042 | 5042 | $replacement = null; | 
| 5043 | 5043 | |
| 5044 | - $nr = geodir_title_meta_pagenumbering( 'nr' ); | |
| 5045 | -	if ( isset( $nr ) && $nr > 0 ) {
 | |
| 5044 | +	$nr = geodir_title_meta_pagenumbering('nr');
 | |
| 5045 | +	if (isset($nr) && $nr > 0) {
 | |
| 5046 | 5046 | $replacement = (string) $nr; | 
| 5047 | 5047 | } | 
| 5048 | 5048 | |
| @@ -5060,8 +5060,8 @@ discard block | ||
| 5060 | 5060 |  function geodir_title_meta_pagetotal() {
 | 
| 5061 | 5061 | $replacement = null; | 
| 5062 | 5062 | |
| 5063 | - $max = geodir_title_meta_pagenumbering( 'max' ); | |
| 5064 | -	if ( isset( $max ) && $max > 0 ) {
 | |
| 5063 | +	$max = geodir_title_meta_pagenumbering('max');
 | |
| 5064 | +	if (isset($max) && $max > 0) {
 | |
| 5065 | 5065 | $replacement = (string) $max; | 
| 5066 | 5066 | } | 
| 5067 | 5067 | |
| @@ -5081,36 +5081,36 @@ discard block | ||
| 5081 | 5081 | * | 
| 5082 | 5082 | * @return int|null The current page numbering. | 
| 5083 | 5083 | */ | 
| 5084 | -function geodir_title_meta_pagenumbering( $request = 'nr' ) {
 | |
| 5084 | +function geodir_title_meta_pagenumbering($request = 'nr') {
 | |
| 5085 | 5085 | global $wp_query, $post; | 
| 5086 | 5086 | $max_num_pages = null; | 
| 5087 | 5087 | $page_number = null; | 
| 5088 | 5088 | |
| 5089 | 5089 | $max_num_pages = 1; | 
| 5090 | 5090 | |
| 5091 | -	if ( ! is_singular() ) {
 | |
| 5092 | - $page_number = get_query_var( 'paged' ); | |
| 5093 | -		if ( $page_number === 0 || $page_number === '' ) {
 | |
| 5091 | +	if (!is_singular()) {
 | |
| 5092 | +		$page_number = get_query_var('paged');
 | |
| 5093 | +		if ($page_number === 0 || $page_number === '') {
 | |
| 5094 | 5094 | $page_number = 1; | 
| 5095 | 5095 | } | 
| 5096 | 5096 | |
| 5097 | -		if ( isset( $wp_query->max_num_pages ) && ( $wp_query->max_num_pages != '' && $wp_query->max_num_pages != 0 ) ) {
 | |
| 5097 | +		if (isset($wp_query->max_num_pages) && ($wp_query->max_num_pages != '' && $wp_query->max_num_pages != 0)) {
 | |
| 5098 | 5098 | $max_num_pages = $wp_query->max_num_pages; | 
| 5099 | 5099 | } | 
| 5100 | 5100 |  	} else {
 | 
| 5101 | - $page_number = get_query_var( 'page' ); | |
| 5102 | -		if ( $page_number === 0 || $page_number === '' ) {
 | |
| 5101 | +		$page_number = get_query_var('page');
 | |
| 5102 | +		if ($page_number === 0 || $page_number === '') {
 | |
| 5103 | 5103 | $page_number = 1; | 
| 5104 | 5104 | } | 
| 5105 | 5105 | |
| 5106 | -		if ( isset( $post->post_content ) ) {
 | |
| 5107 | - $max_num_pages = ( substr_count( $post->post_content, '<!--nextpage-->' ) + 1 ); | |
| 5106 | +		if (isset($post->post_content)) {
 | |
| 5107 | + $max_num_pages = (substr_count($post->post_content, '<!--nextpage-->') + 1); | |
| 5108 | 5108 | } | 
| 5109 | 5109 | } | 
| 5110 | 5110 | |
| 5111 | 5111 | $return = null; | 
| 5112 | 5112 | |
| 5113 | -	switch ( $request ) {
 | |
| 5113 | +	switch ($request) {
 | |
| 5114 | 5114 | case 'nr': | 
| 5115 | 5115 | $return = $page_number; | 
| 5116 | 5116 | break; | 
| @@ -5131,14 +5131,14 @@ discard block | ||
| 5131 | 5131 | * | 
| 5132 | 5132 | * @return array Terms. | 
| 5133 | 5133 | */ | 
| 5134 | -function geodir_filter_empty_terms( $terms ) {
 | |
| 5135 | -	if ( empty( $terms ) ) {
 | |
| 5134 | +function geodir_filter_empty_terms($terms) {
 | |
| 5135 | +	if (empty($terms)) {
 | |
| 5136 | 5136 | return $terms; | 
| 5137 | 5137 | } | 
| 5138 | 5138 | |
| 5139 | 5139 | $return = array(); | 
| 5140 | -	foreach ( $terms as $term ) {
 | |
| 5141 | -		if ( isset( $term->count ) && $term->count > 0 ) {
 | |
| 5140 | +	foreach ($terms as $term) {
 | |
| 5141 | +		if (isset($term->count) && $term->count > 0) {
 | |
| 5142 | 5142 | $return[] = $term; | 
| 5143 | 5143 |  		} else {
 | 
| 5144 | 5144 | /** | 
| @@ -5149,7 +5149,7 @@ discard block | ||
| 5149 | 5149 | * @param array $return The array of terms to return. | 
| 5150 | 5150 | * @param object $term The term object. | 
| 5151 | 5151 | */ | 
| 5152 | - $return = apply_filters( 'geodir_filter_empty_terms_filter', $return, $term ); | |
| 5152 | +			$return = apply_filters('geodir_filter_empty_terms_filter', $return, $term);
 | |
| 5153 | 5153 | } | 
| 5154 | 5154 | } | 
| 5155 | 5155 | |
| @@ -5166,12 +5166,12 @@ discard block | ||
| 5166 | 5166 | * | 
| 5167 | 5167 | * @return array | 
| 5168 | 5168 | */ | 
| 5169 | -function geodir_remove_hentry( $class ) {
 | |
| 5170 | -	if ( geodir_is_page( 'detail' ) ) {
 | |
| 5171 | - $class = array_diff( $class, array( 'hentry' ) ); | |
| 5169 | +function geodir_remove_hentry($class) {
 | |
| 5170 | +	if (geodir_is_page('detail')) {
 | |
| 5171 | +		$class = array_diff($class, array('hentry'));
 | |
| 5172 | 5172 | } | 
| 5173 | 5173 | |
| 5174 | 5174 | return $class; | 
| 5175 | 5175 | } | 
| 5176 | 5176 | |
| 5177 | -add_filter( 'post_class', 'geodir_remove_hentry' ); | |
| 5178 | 5177 | \ No newline at end of file | 
| 5178 | +add_filter('post_class', 'geodir_remove_hentry'); | |
| 5179 | 5179 | \ No newline at end of file | 
| @@ -52,31 +52,31 @@ discard block | ||
| 52 | 52 |  				jQuery(listSel).children('li').switchClass('gridview_onehalf gridview_onethird gridview_onefourth', 'gridview_onefifth', 600);
 | 
| 53 | 53 | } | 
| 54 | 54 | |
| 55 | -			jQuery.post("<?php echo geodir_get_ajax_url();?>&gd_listing_view=" + val, function (data) {
 | |
| 55 | +			jQuery.post("<?php echo geodir_get_ajax_url(); ?>&gd_listing_view=" + val, function (data) {
 | |
| 56 | 56 | //alert(data ); | 
| 57 | 57 | }); | 
| 58 | 58 | } | 
| 59 | 59 | </script> | 
| 60 | 60 | <div class="geodir-list-view-select"> | 
| 61 | 61 | <select name="gd_list_view" id="gd_list_view" onchange="geodir_list_view_select(this);"> | 
| 62 | - <?php $listing_view = (int) $gd_session->get( 'gd_listing_view' ); ?> | |
| 63 | - <option value=""><?php _e( 'View:', 'geodirectory' ); ?></option> | |
| 62 | +			<?php $listing_view = (int) $gd_session->get('gd_listing_view'); ?>
 | |
| 63 | +			<option value=""><?php _e('View:', 'geodirectory'); ?></option>
 | |
| 64 | 64 | <option | 
| 65 | - value="1" <?php selected( 1, $listing_view ); ?>><?php _e( 'View: List', 'geodirectory' ); ?></option> | |
| 65 | +				value="1" <?php selected(1, $listing_view); ?>><?php _e('View: List', 'geodirectory'); ?></option>
 | |
| 66 | 66 | <option | 
| 67 | - value="2" <?php selected( 2, $listing_view ); ?>><?php _e( 'View: Grid 2', 'geodirectory' ); ?></option> | |
| 67 | +				value="2" <?php selected(2, $listing_view); ?>><?php _e('View: Grid 2', 'geodirectory'); ?></option>
 | |
| 68 | 68 | <option | 
| 69 | - value="3" <?php selected( 3, $listing_view ); ?>><?php _e( 'View: Grid 3', 'geodirectory' ); ?></option> | |
| 69 | +				value="3" <?php selected(3, $listing_view); ?>><?php _e('View: Grid 3', 'geodirectory'); ?></option>
 | |
| 70 | 70 | <option | 
| 71 | - value="4" <?php selected( 4, $listing_view ); ?>><?php _e( 'View: Grid 4', 'geodirectory' ); ?></option> | |
| 71 | +				value="4" <?php selected(4, $listing_view); ?>><?php _e('View: Grid 4', 'geodirectory'); ?></option>
 | |
| 72 | 72 | <option | 
| 73 | - value="5" <?php selected( 5, $listing_view ); ?>><?php _e( 'View: Grid 5', 'geodirectory' ); ?></option> | |
| 73 | +				value="5" <?php selected(5, $listing_view); ?>><?php _e('View: Grid 5', 'geodirectory'); ?></option>
 | |
| 74 | 74 | </select> | 
| 75 | 75 | </div> | 
| 76 | 76 | <?php | 
| 77 | 77 | } | 
| 78 | 78 | |
| 79 | -add_action( 'geodir_before_listing', 'geodir_list_view_select', 100 ); | |
| 79 | +add_action('geodir_before_listing', 'geodir_list_view_select', 100);
 | |
| 80 | 80 | |
| 81 | 81 | /** | 
| 82 | 82 | * Limit the listing excerpt. | 
| @@ -91,9 +91,9 @@ discard block | ||
| 91 | 91 | * @global object $post The current post object. | 
| 92 | 92 | * @return string The modified excerpt. | 
| 93 | 93 | */ | 
| 94 | -function geodir_max_excerpt( $charlength ) {
 | |
| 94 | +function geodir_max_excerpt($charlength) {
 | |
| 95 | 95 | global $post; | 
| 96 | -	if ( $charlength == '0' ) {
 | |
| 96 | +	if ($charlength == '0') {
 | |
| 97 | 97 | return; | 
| 98 | 98 | } | 
| 99 | 99 | $out = ''; | 
| @@ -101,46 +101,46 @@ discard block | ||
| 101 | 101 | $temp_post = $post; | 
| 102 | 102 | $excerpt = get_the_excerpt(); | 
| 103 | 103 | |
| 104 | - $charlength ++; | |
| 105 | - $excerpt_more = function_exists( 'geodirf_excerpt_more' ) ? geodirf_excerpt_more( '' ) : geodir_excerpt_more( '' ); | |
| 106 | -	if ( mb_strlen( $excerpt ) > $charlength ) {
 | |
| 107 | -		if ( mb_strlen( $excerpt_more ) > 0 && mb_strpos( $excerpt, $excerpt_more ) !== false ) {
 | |
| 108 | - $excut = - ( mb_strlen( $excerpt_more ) ); | |
| 109 | - $subex = mb_substr( $excerpt, 0, $excut ); | |
| 110 | -			if ( $charlength > 0 && mb_strlen( $subex ) > $charlength ) {
 | |
| 111 | - $subex = mb_substr( $subex, 0, $charlength ); | |
| 104 | + $charlength++; | |
| 105 | +	$excerpt_more = function_exists('geodirf_excerpt_more') ? geodirf_excerpt_more('') : geodir_excerpt_more('');
 | |
| 106 | +	if (mb_strlen($excerpt) > $charlength) {
 | |
| 107 | +		if (mb_strlen($excerpt_more) > 0 && mb_strpos($excerpt, $excerpt_more) !== false) {
 | |
| 108 | + $excut = - (mb_strlen($excerpt_more)); | |
| 109 | + $subex = mb_substr($excerpt, 0, $excut); | |
| 110 | +			if ($charlength > 0 && mb_strlen($subex) > $charlength) {
 | |
| 111 | + $subex = mb_substr($subex, 0, $charlength); | |
| 112 | 112 | } | 
| 113 | 113 | $out .= $subex; | 
| 114 | 114 |  		} else {
 | 
| 115 | - $subex = mb_substr( $excerpt, 0, $charlength - 5 ); | |
| 116 | - $exwords = explode( ' ', $subex ); | |
| 117 | - $excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) ); | |
| 118 | -			if ( $excut < 0 ) {
 | |
| 119 | - $out .= mb_substr( $subex, 0, $excut ); | |
| 115 | + $subex = mb_substr($excerpt, 0, $charlength - 5); | |
| 116 | +			$exwords = explode(' ', $subex);
 | |
| 117 | + $excut = - (mb_strlen($exwords[count($exwords) - 1])); | |
| 118 | +			if ($excut < 0) {
 | |
| 119 | + $out .= mb_substr($subex, 0, $excut); | |
| 120 | 120 |  			} else {
 | 
| 121 | 121 | $out .= $subex; | 
| 122 | 122 | } | 
| 123 | 123 | } | 
| 124 | - $out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">'; | |
| 124 | + $out .= ' <a class="excerpt-read-more" href="'.get_permalink().'" title="'.get_the_title().'">'; | |
| 125 | 125 | /** | 
| 126 | 126 | * Filter excerpt read more text. | 
| 127 | 127 | * | 
| 128 | 128 | * @since 1.0.0 | 
| 129 | 129 | */ | 
| 130 | - $out .= apply_filters( 'geodir_max_excerpt_end', __( 'Read more [...]', 'geodirectory' ) ); | |
| 130 | +		$out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
 | |
| 131 | 131 | $out .= '</a>'; | 
| 132 | 132 | |
| 133 | 133 |  	} else {
 | 
| 134 | -		if ( mb_strlen( $excerpt_more ) > 0 && mb_strpos( $excerpt, $excerpt_more ) !== false ) {
 | |
| 135 | - $excut = - ( mb_strlen( $excerpt_more ) ); | |
| 136 | - $out .= mb_substr( $excerpt, 0, $excut ); | |
| 137 | - $out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">'; | |
| 134 | +		if (mb_strlen($excerpt_more) > 0 && mb_strpos($excerpt, $excerpt_more) !== false) {
 | |
| 135 | + $excut = - (mb_strlen($excerpt_more)); | |
| 136 | + $out .= mb_substr($excerpt, 0, $excut); | |
| 137 | + $out .= ' <a class="excerpt-read-more" href="'.get_permalink().'" title="'.get_the_title().'">'; | |
| 138 | 138 | /** | 
| 139 | 139 | * Filter excerpt read more text. | 
| 140 | 140 | * | 
| 141 | 141 | * @since 1.0.0 | 
| 142 | 142 | */ | 
| 143 | - $out .= apply_filters( 'geodir_max_excerpt_end', __( 'Read more [...]', 'geodirectory' ) ); | |
| 143 | +			$out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
 | |
| 144 | 144 | $out .= '</a>'; | 
| 145 | 145 |  		} else {
 | 
| 146 | 146 | $out .= $excerpt; | 
| @@ -163,7 +163,7 @@ discard block | ||
| 163 | 163 | * | 
| 164 | 164 | * @return object Returns filtered package info as an object. | 
| 165 | 165 | */ | 
| 166 | -function geodir_post_package_info( $package_info, $post = '', $post_type = '' ) {
 | |
| 166 | +function geodir_post_package_info($package_info, $post = '', $post_type = '') {
 | |
| 167 | 167 | $package_info['pid'] = 0; | 
| 168 | 168 | $package_info['days'] = 0; | 
| 169 | 169 | $package_info['amount'] = 0; | 
| @@ -192,7 +192,7 @@ discard block | ||
| 192 | 192 | * @param object|string $post The post object. | 
| 193 | 193 | * @param string $post_type The post type. | 
| 194 | 194 | */ | 
| 195 | - return (object) apply_filters( 'geodir_post_package_info', $package_info, $post, $post_type ); | |
| 195 | +	return (object) apply_filters('geodir_post_package_info', $package_info, $post, $post_type);
 | |
| 196 | 196 | |
| 197 | 197 | } | 
| 198 | 198 | |
| @@ -220,11 +220,11 @@ discard block | ||
| 220 | 220 | * | 
| 221 | 221 | * } | 
| 222 | 222 | */ | 
| 223 | -function geodir_send_inquiry( $request ) {
 | |
| 223 | +function geodir_send_inquiry($request) {
 | |
| 224 | 224 | global $wpdb; | 
| 225 | 225 | |
| 226 | 226 | // strip slashes from text | 
| 227 | - $request = ! empty( $request ) ? stripslashes_deep( $request ) : $request; | |
| 227 | + $request = !empty($request) ? stripslashes_deep($request) : $request; | |
| 228 | 228 | |
| 229 | 229 | $yourname = $request['inq_name']; | 
| 230 | 230 | $youremail = $request['inq_email']; | 
| @@ -235,26 +235,26 @@ discard block | ||
| 235 | 235 | $author_id = ''; | 
| 236 | 236 | $post_title = ''; | 
| 237 | 237 | |
| 238 | -	if ( $request['pid'] ) {
 | |
| 238 | +	if ($request['pid']) {
 | |
| 239 | 239 | |
| 240 | 240 | $productinfosql = $wpdb->prepare( | 
| 241 | 241 | "select ID,post_author,post_title from $wpdb->posts where ID =%d", | 
| 242 | - array( $request['pid'] ) | |
| 242 | + array($request['pid']) | |
| 243 | 243 | ); | 
| 244 | - $productinfo = $wpdb->get_row( $productinfosql ); | |
| 244 | + $productinfo = $wpdb->get_row($productinfosql); | |
| 245 | 245 | |
| 246 | 246 | $author_id = $productinfo->post_author; | 
| 247 | 247 | $post_title = $productinfo->post_title; | 
| 248 | 248 | } | 
| 249 | 249 | |
| 250 | - $post_title = '<a href="' . get_permalink( $pid ) . '">' . $post_title . '</a>'; | |
| 250 | + $post_title = '<a href="'.get_permalink($pid).'">'.$post_title.'</a>'; | |
| 251 | 251 | |
| 252 | - $user_info = get_userdata( $author_id ); | |
| 253 | - $to_email = geodir_get_post_meta( $pid, 'geodir_email', true ); | |
| 254 | - $to_name = geodir_get_client_name( $author_id ); | |
| 252 | + $user_info = get_userdata($author_id); | |
| 253 | + $to_email = geodir_get_post_meta($pid, 'geodir_email', true); | |
| 254 | + $to_name = geodir_get_client_name($author_id); | |
| 255 | 255 | |
| 256 | -	if ( $to_email == '' ) {
 | |
| 257 | - $to_email = get_option( 'admin_email' ); | |
| 256 | +	if ($to_email == '') {
 | |
| 257 | +		$to_email = get_option('admin_email');
 | |
| 258 | 258 | } | 
| 259 | 259 | |
| 260 | 260 | /** | 
| @@ -275,10 +275,10 @@ discard block | ||
| 275 | 275 | * } | 
| 276 | 276 | * @param string $type The form type, default: `Enquiry`. | 
| 277 | 277 | */ | 
| 278 | - do_action( 'geodir_after_send_enquiry', $request, 'Enquiry' ); | |
| 278 | +	do_action('geodir_after_send_enquiry', $request, 'Enquiry');
 | |
| 279 | 279 | |
| 280 | 280 | $client_message = $frnd_comments; | 
| 281 | - $client_message .= '<br>' . __( 'From :', 'geodirectory' ) . ' ' . $yourname . '<br>' . __( 'Phone :', 'geodirectory' ) . ' ' . $inq_phone . '<br>' . __( 'Email :', 'geodirectory' ) . ' ' . $youremail . '<br><br>' . __( 'Sent from', 'geodirectory' ) . ' - <b><a href="' . trailingslashit( home_url() ) . '">' . get_option( 'blogname' ) . '</a></b>.'; | |
| 281 | +	$client_message .= '<br>'.__('From :', 'geodirectory').' '.$yourname.'<br>'.__('Phone :', 'geodirectory').' '.$inq_phone.'<br>'.__('Email :', 'geodirectory').' '.$youremail.'<br><br>'.__('Sent from', 'geodirectory').' - <b><a href="'.trailingslashit(home_url()).'">'.get_option('blogname').'</a></b>.';
 | |
| 282 | 282 | /** | 
| 283 | 283 | * Filter client message text. | 
| 284 | 284 | * | 
| @@ -286,7 +286,7 @@ discard block | ||
| 286 | 286 | * | 
| 287 | 287 | * @param string $client_message Client message text. | 
| 288 | 288 | */ | 
| 289 | - $client_message = apply_filters( 'geodir_inquiry_email_msg', $client_message ); | |
| 289 | +	$client_message = apply_filters('geodir_inquiry_email_msg', $client_message);
 | |
| 290 | 290 | |
| 291 | 291 | /** | 
| 292 | 292 | * Called before the send enquiry email is sent. | 
| @@ -305,12 +305,12 @@ discard block | ||
| 305 | 305 | * | 
| 306 | 306 | * } | 
| 307 | 307 | */ | 
| 308 | - do_action( 'geodir_before_send_enquiry_email', $request ); | |
| 309 | -	if ( $to_email ) {
 | |
| 308 | +	do_action('geodir_before_send_enquiry_email', $request);
 | |
| 309 | +	if ($to_email) {
 | |
| 310 | 310 | // strip slashes message | 
| 311 | - $client_message = stripslashes_deep( $client_message ); | |
| 311 | + $client_message = stripslashes_deep($client_message); | |
| 312 | 312 | |
| 313 | - geodir_sendEmail( $youremail, $yourname, $to_email, $to_name, '', $client_message, $extra = '', 'send_enquiry', $request['pid'] );//To client email | |
| 313 | + geodir_sendEmail($youremail, $yourname, $to_email, $to_name, '', $client_message, $extra = '', 'send_enquiry', $request['pid']); //To client email | |
| 314 | 314 | } | 
| 315 | 315 | |
| 316 | 316 | /** | 
| @@ -330,12 +330,12 @@ discard block | ||
| 330 | 330 | * | 
| 331 | 331 | * } | 
| 332 | 332 | */ | 
| 333 | - do_action( 'geodir_after_send_enquiry_email', $request ); | |
| 334 | - $url = get_permalink( $pid ); | |
| 335 | -	if ( strstr( $url, '?' ) ) {
 | |
| 336 | - $url = $url . "&send_inquiry=success"; | |
| 333 | +	do_action('geodir_after_send_enquiry_email', $request);
 | |
| 334 | + $url = get_permalink($pid); | |
| 335 | +	if (strstr($url, '?')) {
 | |
| 336 | + $url = $url."&send_inquiry=success"; | |
| 337 | 337 |  	} else {
 | 
| 338 | - $url = $url . "?send_inquiry=success"; | |
| 338 | + $url = $url."?send_inquiry=success"; | |
| 339 | 339 | } | 
| 340 | 340 | /** | 
| 341 | 341 | * Filter redirect url after the send enquiry email is sent. | 
| @@ -344,8 +344,8 @@ discard block | ||
| 344 | 344 | * | 
| 345 | 345 | * @param string $url Redirect url. | 
| 346 | 346 | */ | 
| 347 | - $url = apply_filters( 'geodir_send_enquiry_after_submit_redirect', $url ); | |
| 348 | - wp_redirect( $url ); | |
| 347 | +	$url = apply_filters('geodir_send_enquiry_after_submit_redirect', $url);
 | |
| 348 | + wp_redirect($url); | |
| 349 | 349 | gd_die(); | 
| 350 | 350 | |
| 351 | 351 | } | 
| @@ -374,11 +374,11 @@ discard block | ||
| 374 | 374 | * } | 
| 375 | 375 | * @global object $wpdb WordPress Database object. | 
| 376 | 376 | */ | 
| 377 | -function geodir_send_friend( $request ) {
 | |
| 377 | +function geodir_send_friend($request) {
 | |
| 378 | 378 | global $wpdb; | 
| 379 | 379 | |
| 380 | 380 | // strip slashes from text | 
| 381 | - $request = ! empty( $request ) ? stripslashes_deep( $request ) : $request; | |
| 381 | + $request = !empty($request) ? stripslashes_deep($request) : $request; | |
| 382 | 382 | |
| 383 | 383 | $yourname = $request['yourname']; | 
| 384 | 384 | $youremail = $request['youremail']; | 
| @@ -387,13 +387,13 @@ discard block | ||
| 387 | 387 | $pid = $request['pid']; | 
| 388 | 388 | $to_email = $request['to_email']; | 
| 389 | 389 | $to_name = $request['to_name']; | 
| 390 | -	if ( $request['pid'] ) {
 | |
| 390 | +	if ($request['pid']) {
 | |
| 391 | 391 | $productinfosql = $wpdb->prepare( | 
| 392 | 392 | "select ID,post_title from $wpdb->posts where ID =%d", | 
| 393 | - array( $request['pid'] ) | |
| 393 | + array($request['pid']) | |
| 394 | 394 | ); | 
| 395 | - $productinfo = $wpdb->get_results( $productinfosql ); | |
| 396 | -		foreach ( $productinfo as $productinfoObj ) {
 | |
| 395 | + $productinfo = $wpdb->get_results($productinfosql); | |
| 396 | +		foreach ($productinfo as $productinfoObj) {
 | |
| 397 | 397 | $post_title = $productinfoObj->post_title; | 
| 398 | 398 | } | 
| 399 | 399 | } | 
| @@ -417,8 +417,8 @@ discard block | ||
| 417 | 417 | * | 
| 418 | 418 | * } | 
| 419 | 419 | */ | 
| 420 | - do_action( 'geodir_before_send_to_friend_email', $request ); | |
| 421 | - geodir_sendEmail( $youremail, $yourname, $to_email, $to_name, $frnd_subject, $frnd_comments, $extra = '', 'send_friend', $request['pid'] );//To client email | |
| 420 | +	do_action('geodir_before_send_to_friend_email', $request);
 | |
| 421 | + geodir_sendEmail($youremail, $yourname, $to_email, $to_name, $frnd_subject, $frnd_comments, $extra = '', 'send_friend', $request['pid']); //To client email | |
| 422 | 422 | |
| 423 | 423 | /** | 
| 424 | 424 | * Called after the send to friend email is sent. | 
| @@ -439,13 +439,13 @@ discard block | ||
| 439 | 439 | * | 
| 440 | 440 | * } | 
| 441 | 441 | */ | 
| 442 | - do_action( 'geodir_after_send_to_friend_email', $request ); | |
| 442 | +	do_action('geodir_after_send_to_friend_email', $request);
 | |
| 443 | 443 | |
| 444 | - $url = get_permalink( $pid ); | |
| 445 | -	if ( strstr( $url, '?' ) ) {
 | |
| 446 | - $url = $url . "&sendtofrnd=success"; | |
| 444 | + $url = get_permalink($pid); | |
| 445 | +	if (strstr($url, '?')) {
 | |
| 446 | + $url = $url."&sendtofrnd=success"; | |
| 447 | 447 |  	} else {
 | 
| 448 | - $url = $url . "?sendtofrnd=success"; | |
| 448 | + $url = $url."?sendtofrnd=success"; | |
| 449 | 449 | } | 
| 450 | 450 | /** | 
| 451 | 451 | * Filter redirect url after the send to friend email is sent. | 
| @@ -454,8 +454,8 @@ discard block | ||
| 454 | 454 | * | 
| 455 | 455 | * @param string $url Redirect url. | 
| 456 | 456 | */ | 
| 457 | - $url = apply_filters( 'geodir_send_to_friend_after_submit_redirect', $url ); | |
| 458 | - wp_redirect( $url ); | |
| 457 | +	$url = apply_filters('geodir_send_to_friend_after_submit_redirect', $url);
 | |
| 458 | + wp_redirect($url); | |
| 459 | 459 | gd_die(); | 
| 460 | 460 | } | 
| 461 | 461 | |
| @@ -469,8 +469,8 @@ discard block | ||
| 469 | 469 | * | 
| 470 | 470 | * @param string $hash_key | 
| 471 | 471 | */ | 
| 472 | -function geodir_before_tab_content( $hash_key ) {
 | |
| 473 | -	switch ( $hash_key ) {
 | |
| 472 | +function geodir_before_tab_content($hash_key) {
 | |
| 473 | +	switch ($hash_key) {
 | |
| 474 | 474 | case 'post_info' : | 
| 475 | 475 | echo '<div class="geodir-company_info field-group">'; | 
| 476 | 476 | break; | 
| @@ -480,7 +480,7 @@ discard block | ||
| 480 | 480 | * | 
| 481 | 481 | * @since 1.0.0 | 
| 482 | 482 | */ | 
| 483 | - echo ' <div id="' . apply_filters( 'geodir_post_gallery_id', 'geodir-post-gallery' ) . '" class="clearfix" >'; | |
| 483 | +			echo ' <div id="'.apply_filters('geodir_post_gallery_id', 'geodir-post-gallery').'" class="clearfix" >';
 | |
| 484 | 484 | break; | 
| 485 | 485 | case 'reviews' : | 
| 486 | 486 | echo '<div id="reviews-wrap" class="clearfix"> '; | 
| @@ -504,8 +504,8 @@ discard block | ||
| 504 | 504 | * | 
| 505 | 505 | * @param string $hash_key | 
| 506 | 506 | */ | 
| 507 | -function geodir_after_tab_content( $hash_key ) {
 | |
| 508 | -	switch ( $hash_key ) {
 | |
| 507 | +function geodir_after_tab_content($hash_key) {
 | |
| 508 | +	switch ($hash_key) {
 | |
| 509 | 509 | case 'post_info' : | 
| 510 | 510 | echo '</div>'; | 
| 511 | 511 | break; | 
| @@ -536,25 +536,25 @@ discard block | ||
| 536 | 536 | * @global object $wpdb WordPress Database object. | 
| 537 | 537 | * @return bool|null|string Returns default sort results, when the post type is valid. Otherwise returns false. | 
| 538 | 538 | */ | 
| 539 | -function geodir_get_posts_default_sort( $post_type ) {
 | |
| 539 | +function geodir_get_posts_default_sort($post_type) {
 | |
| 540 | 540 | |
| 541 | 541 | global $wpdb; | 
| 542 | 542 | |
| 543 | -	if ( $post_type != '' ) {
 | |
| 543 | +	if ($post_type != '') {
 | |
| 544 | 544 | |
| 545 | 545 | $all_postypes = geodir_get_posttypes(); | 
| 546 | 546 | |
| 547 | -		if ( ! in_array( $post_type, $all_postypes ) ) {
 | |
| 547 | +		if (!in_array($post_type, $all_postypes)) {
 | |
| 548 | 548 | return false; | 
| 549 | 549 | } | 
| 550 | 550 | |
| 551 | - $sort_field_info = $wpdb->get_var( $wpdb->prepare( "select default_order from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type= %s and is_active=%d and is_default=%d", array( | |
| 551 | +		$sort_field_info = $wpdb->get_var($wpdb->prepare("select default_order from ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." where	post_type= %s and is_active=%d and is_default=%d", array(
 | |
| 552 | 552 | $post_type, | 
| 553 | 553 | 1, | 
| 554 | 554 | 1 | 
| 555 | - ) ) ); | |
| 555 | + ))); | |
| 556 | 556 | |
| 557 | -		if ( ! empty( $sort_field_info ) ) {
 | |
| 557 | +		if (!empty($sort_field_info)) {
 | |
| 558 | 558 | return $sort_field_info; | 
| 559 | 559 | } | 
| 560 | 560 | |
| @@ -574,20 +574,20 @@ discard block | ||
| 574 | 574 | * @global object $wpdb WordPress Database object. | 
| 575 | 575 | * @return bool|mixed|void Returns sort results, when the post type is valid. Otherwise returns false. | 
| 576 | 576 | */ | 
| 577 | -function geodir_get_sort_options( $post_type ) {
 | |
| 577 | +function geodir_get_sort_options($post_type) {
 | |
| 578 | 578 | global $wpdb; | 
| 579 | 579 | |
| 580 | -	if ( $post_type != '' ) {
 | |
| 580 | +	if ($post_type != '') {
 | |
| 581 | 581 | $all_postypes = geodir_get_posttypes(); | 
| 582 | 582 | |
| 583 | -		if ( ! in_array( $post_type, $all_postypes ) ) {
 | |
| 583 | +		if (!in_array($post_type, $all_postypes)) {
 | |
| 584 | 584 | return false; | 
| 585 | 585 | } | 
| 586 | 586 | |
| 587 | - $sort_field_info = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type=%s AND is_active=%d AND (sort_asc=1 || sort_desc=1 || field_type='random') AND field_type != 'address' ORDER BY sort_order ASC", array( | |
| 587 | +		$sort_field_info = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." WHERE post_type=%s AND is_active=%d AND (sort_asc=1 || sort_desc=1 || field_type='random') AND field_type != 'address' ORDER BY sort_order ASC", array(
 | |
| 588 | 588 | $post_type, | 
| 589 | 589 | 1 | 
| 590 | - ) ) ); | |
| 590 | + ))); | |
| 591 | 591 | |
| 592 | 592 | /** | 
| 593 | 593 | * Filter post sort options. | 
| @@ -597,7 +597,7 @@ discard block | ||
| 597 | 597 | * @param array $sort_field_info Unfiltered sort field array. | 
| 598 | 598 | * @param string $post_type Post type. | 
| 599 | 599 | */ | 
| 600 | - return apply_filters( 'geodir_get_sort_options', $sort_field_info, $post_type ); | |
| 600 | +		return apply_filters('geodir_get_sort_options', $sort_field_info, $post_type);
 | |
| 601 | 601 | } | 
| 602 | 602 | |
| 603 | 603 | } | 
| @@ -618,63 +618,63 @@ discard block | ||
| 618 | 618 | * | 
| 619 | 619 | * @since 1.4.4 | 
| 620 | 620 | */ | 
| 621 | -	if ( is_search() ) {
 | |
| 621 | +	if (is_search()) {
 | |
| 622 | 622 | return; | 
| 623 | 623 | } | 
| 624 | 624 | |
| 625 | 625 | $sort_by = ''; | 
| 626 | 626 | |
| 627 | -	if ( isset( $_REQUEST['sort_by'] ) ) {
 | |
| 627 | +	if (isset($_REQUEST['sort_by'])) {
 | |
| 628 | 628 | $sort_by = $_REQUEST['sort_by']; | 
| 629 | 629 | } | 
| 630 | 630 | |
| 631 | 631 | $gd_post_type = geodir_get_current_posttype(); | 
| 632 | 632 | |
| 633 | - $sort_options = geodir_get_sort_options( $gd_post_type ); | |
| 633 | + $sort_options = geodir_get_sort_options($gd_post_type); | |
| 634 | 634 | |
| 635 | 635 | |
| 636 | 636 | $sort_field_options = ''; | 
| 637 | 637 | |
| 638 | -	if ( ! empty( $sort_options ) ) {
 | |
| 639 | -		foreach ( $sort_options as $sort ) {
 | |
| 640 | - $sort = stripslashes_deep( $sort ); // strip slashes | |
| 638 | +	if (!empty($sort_options)) {
 | |
| 639 | +		foreach ($sort_options as $sort) {
 | |
| 640 | + $sort = stripslashes_deep($sort); // strip slashes | |
| 641 | 641 | |
| 642 | - $label = __( $sort->site_title, 'geodirectory' ); | |
| 642 | + $label = __($sort->site_title, 'geodirectory'); | |
| 643 | 643 | |
| 644 | -			if ( $sort->field_type == 'random' ) {
 | |
| 644 | +			if ($sort->field_type == 'random') {
 | |
| 645 | 645 | $key = $sort->field_type; | 
| 646 | - ( $sort_by == $key || ( $sort->is_default == '1' && ! isset( $_REQUEST['sort_by'] ) ) ) ? $selected = 'selected="selected"' : $selected = ''; | |
| 647 | - $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg( 'sort_by', $key ) ) . '">' . __( $label, 'geodirectory' ) . '</option>'; | |
| 646 | + ($sort_by == $key || ($sort->is_default == '1' && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = ''; | |
| 647 | +				$sort_field_options .= '<option '.$selected.' value="'.esc_url(add_query_arg('sort_by', $key)).'">'.__($label, 'geodirectory').'</option>';
 | |
| 648 | 648 | } | 
| 649 | 649 | |
| 650 | -			if ( $sort->htmlvar_name == 'comment_count' ) {
 | |
| 650 | +			if ($sort->htmlvar_name == 'comment_count') {
 | |
| 651 | 651 | $sort->htmlvar_name = 'rating_count'; | 
| 652 | 652 | } | 
| 653 | 653 | |
| 654 | -			if ( $sort->sort_asc ) {
 | |
| 655 | - $key = $sort->htmlvar_name . '_asc'; | |
| 654 | +			if ($sort->sort_asc) {
 | |
| 655 | + $key = $sort->htmlvar_name.'_asc'; | |
| 656 | 656 | $label = $sort->site_title; | 
| 657 | -				if ( $sort->asc_title ) {
 | |
| 657 | +				if ($sort->asc_title) {
 | |
| 658 | 658 | $label = $sort->asc_title; | 
| 659 | 659 | } | 
| 660 | - ( $sort_by == $key || ( $sort->is_default == '1' && $sort->default_order == $key && ! isset( $_REQUEST['sort_by'] ) ) ) ? $selected = 'selected="selected"' : $selected = ''; | |
| 661 | - $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg( 'sort_by', $key ) ) . '">' . __( $label, 'geodirectory' ) . '</option>'; | |
| 660 | + ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = ''; | |
| 661 | +				$sort_field_options .= '<option '.$selected.' value="'.esc_url(add_query_arg('sort_by', $key)).'">'.__($label, 'geodirectory').'</option>';
 | |
| 662 | 662 | } | 
| 663 | 663 | |
| 664 | -			if ( $sort->sort_desc ) {
 | |
| 665 | - $key = $sort->htmlvar_name . '_desc'; | |
| 664 | +			if ($sort->sort_desc) {
 | |
| 665 | + $key = $sort->htmlvar_name.'_desc'; | |
| 666 | 666 | $label = $sort->site_title; | 
| 667 | -				if ( $sort->desc_title ) {
 | |
| 667 | +				if ($sort->desc_title) {
 | |
| 668 | 668 | $label = $sort->desc_title; | 
| 669 | 669 | } | 
| 670 | - ( $sort_by == $key || ( $sort->is_default == '1' && $sort->default_order == $key && ! isset( $_REQUEST['sort_by'] ) ) ) ? $selected = 'selected="selected"' : $selected = ''; | |
| 671 | - $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg( 'sort_by', $key ) ) . '">' . __( $label, 'geodirectory' ) . '</option>'; | |
| 670 | + ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = ''; | |
| 671 | +				$sort_field_options .= '<option '.$selected.' value="'.esc_url(add_query_arg('sort_by', $key)).'">'.__($label, 'geodirectory').'</option>';
 | |
| 672 | 672 | } | 
| 673 | 673 | |
| 674 | 674 | } | 
| 675 | 675 | } | 
| 676 | 676 | |
| 677 | -	if ( $sort_field_options != '' ) {
 | |
| 677 | +	if ($sort_field_options != '') {
 | |
| 678 | 678 | |
| 679 | 679 | ?> | 
| 680 | 680 | |
| @@ -683,9 +683,9 @@ discard block | ||
| 683 | 683 | <select name="sort_by" id="sort_by" onchange="javascript:window.location=this.value;"> | 
| 684 | 684 | |
| 685 | 685 | <option | 
| 686 | -					value="<?php echo esc_url( add_query_arg( 'sort_by', '' ) ); ?>" <?php if ( $sort_by == '' ) {
 | |
| 686 | +					value="<?php echo esc_url(add_query_arg('sort_by', '')); ?>" <?php if ($sort_by == '') {
 | |
| 687 | 687 | echo 'selected="selected"'; | 
| 688 | - } ?>><?php _e( 'Sort By', 'geodirectory' ); ?></option><?php | |
| 688 | +				} ?>><?php _e('Sort By', 'geodirectory'); ?></option><?php
 | |
| 689 | 689 | |
| 690 | 690 | echo $sort_field_options; ?> | 
| 691 | 691 | |
| @@ -713,9 +713,9 @@ discard block | ||
| 713 | 713 | * | 
| 714 | 714 | * @return string Returns the section title. | 
| 715 | 715 | */ | 
| 716 | -function geodir_advance_customfields_heading( $title, $field_type ) {
 | |
| 716 | +function geodir_advance_customfields_heading($title, $field_type) {
 | |
| 717 | 717 | |
| 718 | -	if ( in_array( $field_type, array( 'multiselect', 'textarea', 'taxonomy' ) ) ) {
 | |
| 718 | +	if (in_array($field_type, array('multiselect', 'textarea', 'taxonomy'))) {
 | |
| 719 | 719 | $title = ''; | 
| 720 | 720 | } | 
| 721 | 721 | |
| @@ -737,19 +737,19 @@ discard block | ||
| 737 | 737 | * @global object $gd_session GeoDirectory Session object. | 
| 738 | 738 | * @return string Returns related posts html. | 
| 739 | 739 | */ | 
| 740 | -function geodir_related_posts_display( $request ) {
 | |
| 741 | -	if ( ! empty( $request ) ) {
 | |
| 742 | - $before_title = ( isset( $request['before_title'] ) && ! empty( $request['before_title'] ) ) ? $request['before_title'] : ''; | |
| 743 | - $after_title = ( isset( $request['after_title'] ) && ! empty( $request['after_title'] ) ) ? $request['after_title'] : ''; | |
| 744 | - | |
| 745 | - $title = ( isset( $request['title'] ) && ! empty( $request['title'] ) ) ? $request['title'] : __( 'Related Listings', 'geodirectory' ); | |
| 746 | - $post_number = ( isset( $request['post_number'] ) && ! empty( $request['post_number'] ) ) ? $request['post_number'] : '5'; | |
| 747 | - $relate_to = ( isset( $request['relate_to'] ) && ! empty( $request['relate_to'] ) ) ? $request['relate_to'] : 'category'; | |
| 748 | - $layout = ( isset( $request['layout'] ) && ! empty( $request['layout'] ) ) ? $request['layout'] : 'gridview_onehalf'; | |
| 749 | - $add_location_filter = ( isset( $request['add_location_filter'] ) && ! empty( $request['add_location_filter'] ) ) ? $request['add_location_filter'] : '0'; | |
| 750 | - $listing_width = ( isset( $request['listing_width'] ) && ! empty( $request['listing_width'] ) ) ? $request['listing_width'] : ''; | |
| 751 | - $list_sort = ( isset( $request['list_sort'] ) && ! empty( $request['list_sort'] ) ) ? $request['list_sort'] : 'latest'; | |
| 752 | - $character_count = ( isset( $request['character_count'] ) && ! empty( $request['character_count'] ) ) ? $request['character_count'] : ''; | |
| 740 | +function geodir_related_posts_display($request) {
 | |
| 741 | +	if (!empty($request)) {
 | |
| 742 | + $before_title = (isset($request['before_title']) && !empty($request['before_title'])) ? $request['before_title'] : ''; | |
| 743 | + $after_title = (isset($request['after_title']) && !empty($request['after_title'])) ? $request['after_title'] : ''; | |
| 744 | + | |
| 745 | +		$title               = (isset($request['title']) && !empty($request['title'])) ? $request['title'] : __('Related Listings', 'geodirectory');
 | |
| 746 | + $post_number = (isset($request['post_number']) && !empty($request['post_number'])) ? $request['post_number'] : '5'; | |
| 747 | + $relate_to = (isset($request['relate_to']) && !empty($request['relate_to'])) ? $request['relate_to'] : 'category'; | |
| 748 | + $layout = (isset($request['layout']) && !empty($request['layout'])) ? $request['layout'] : 'gridview_onehalf'; | |
| 749 | + $add_location_filter = (isset($request['add_location_filter']) && !empty($request['add_location_filter'])) ? $request['add_location_filter'] : '0'; | |
| 750 | + $listing_width = (isset($request['listing_width']) && !empty($request['listing_width'])) ? $request['listing_width'] : ''; | |
| 751 | + $list_sort = (isset($request['list_sort']) && !empty($request['list_sort'])) ? $request['list_sort'] : 'latest'; | |
| 752 | + $character_count = (isset($request['character_count']) && !empty($request['character_count'])) ? $request['character_count'] : ''; | |
| 753 | 753 | |
| 754 | 754 | global $wpdb, $post, $gd_session, $related_nearest, $related_parent_lat, $related_parent_lon; | 
| 755 | 755 | $related_parent_lat = $post->post_latitude; | 
| @@ -757,10 +757,10 @@ discard block | ||
| 757 | 757 | $arr_detail_page_tabs = geodir_detail_page_tabs_list(); | 
| 758 | 758 | |
| 759 | 759 | $related_listing_array = array(); | 
| 760 | -		if ( get_option( 'geodir_add_related_listing_posttypes' ) ) {
 | |
| 761 | - $related_listing_array = get_option( 'geodir_add_related_listing_posttypes' ); | |
| 760 | +		if (get_option('geodir_add_related_listing_posttypes')) {
 | |
| 761 | +			$related_listing_array = get_option('geodir_add_related_listing_posttypes');
 | |
| 762 | 762 | } | 
| 763 | -		if ( in_array( $post->post_type, $related_listing_array ) ) {
 | |
| 763 | +		if (in_array($post->post_type, $related_listing_array)) {
 | |
| 764 | 764 | $arr_detail_page_tabs['related_listing']['is_display'] = true; | 
| 765 | 765 | } | 
| 766 | 766 | |
| @@ -772,90 +772,90 @@ discard block | ||
| 772 | 772 | $tax_field = 'id'; | 
| 773 | 773 | $category = array(); | 
| 774 | 774 | |
| 775 | -		if ( isset( $_REQUEST['backandedit'] ) ) {
 | |
| 776 | - $post = (object) $gd_session->get( 'listing' ); | |
| 775 | +		if (isset($_REQUEST['backandedit'])) {
 | |
| 776 | +			$post      = (object) $gd_session->get('listing');
 | |
| 777 | 777 | $post_type = $post->listing_type; | 
| 778 | -			if ( isset( $_REQUEST['pid'] ) && $_REQUEST['pid'] != '' ) {
 | |
| 778 | +			if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
 | |
| 779 | 779 | $post_id = $_REQUEST['pid']; | 
| 780 | 780 | } | 
| 781 | -		} elseif ( isset( $_REQUEST['pid'] ) && $_REQUEST['pid'] != '' ) {
 | |
| 782 | - $post = geodir_get_post_info( $_REQUEST['pid'] ); | |
| 781 | +		} elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
 | |
| 782 | + $post = geodir_get_post_info($_REQUEST['pid']); | |
| 783 | 783 | $post_type = $post->post_type; | 
| 784 | 784 | $post_id = $_REQUEST['pid']; | 
| 785 | -		} elseif ( isset( $post->post_type ) && $post->post_type != '' ) {
 | |
| 785 | +		} elseif (isset($post->post_type) && $post->post_type != '') {
 | |
| 786 | 786 | $post_type = $post->post_type; | 
| 787 | 787 | $post_id = $post->ID; | 
| 788 | 788 | } | 
| 789 | 789 | |
| 790 | -		if ( $relate_to == 'category' ) {
 | |
| 790 | +		if ($relate_to == 'category') {
 | |
| 791 | 791 | |
| 792 | - $category_taxonomy = $post_type . $relate_to; | |
| 793 | -			if ( isset( $post->{$category_taxonomy} ) && $post->{$category_taxonomy} != '' ) {
 | |
| 794 | -				$category = explode( ',', trim( $post->{$category_taxonomy}, ',' ) );
 | |
| 792 | + $category_taxonomy = $post_type.$relate_to; | |
| 793 | +			if (isset($post->{$category_taxonomy} ) && $post->{$category_taxonomy} != '') {
 | |
| 794 | +				$category = explode(',', trim($post->{$category_taxonomy}, ','));
 | |
| 795 | 795 | } | 
| 796 | 796 | |
| 797 | -		} elseif ( $relate_to == 'tags' ) {
 | |
| 797 | +		} elseif ($relate_to == 'tags') {
 | |
| 798 | 798 | |
| 799 | - $category_taxonomy = $post_type . '_' . $relate_to; | |
| 800 | -			if ( $post->post_tags != '' ) {
 | |
| 801 | - $category = explode( ',', trim( $post->post_tags, ',' ) ); | |
| 799 | + $category_taxonomy = $post_type.'_'.$relate_to; | |
| 800 | +			if ($post->post_tags != '') {
 | |
| 801 | +				$category = explode(',', trim($post->post_tags, ','));
 | |
| 802 | 802 | } | 
| 803 | 803 | $tax_field = 'name'; | 
| 804 | 804 | } | 
| 805 | 805 | |
| 806 | 806 | /* --- return false in invalid request --- */ | 
| 807 | -		if ( empty( $category ) ) {
 | |
| 807 | +		if (empty($category)) {
 | |
| 808 | 808 | return false; | 
| 809 | 809 | } | 
| 810 | 810 | |
| 811 | 811 | $all_postypes = geodir_get_posttypes(); | 
| 812 | 812 | |
| 813 | -		if ( ! in_array( $post_type, $all_postypes ) ) {
 | |
| 813 | +		if (!in_array($post_type, $all_postypes)) {
 | |
| 814 | 814 | return false; | 
| 815 | 815 | } | 
| 816 | 816 | |
| 817 | 817 | /* --- return false in invalid request --- */ | 
| 818 | 818 | |
| 819 | 819 | $location_url = ''; | 
| 820 | -		if ( $add_location_filter != '0' ) {
 | |
| 820 | +		if ($add_location_filter != '0') {
 | |
| 821 | 821 | $location_url = array(); | 
| 822 | - $geodir_show_location_url = get_option( 'geodir_show_location_url' ); | |
| 822 | +			$geodir_show_location_url = get_option('geodir_show_location_url');
 | |
| 823 | 823 | |
| 824 | - $gd_city = get_query_var( 'gd_city' ); | |
| 824 | +			$gd_city = get_query_var('gd_city');
 | |
| 825 | 825 | |
| 826 | -			if ( $gd_city ) {
 | |
| 827 | - $gd_country = get_query_var( 'gd_country' ); | |
| 828 | - $gd_region = get_query_var( 'gd_region' ); | |
| 826 | +			if ($gd_city) {
 | |
| 827 | +				$gd_country = get_query_var('gd_country');
 | |
| 828 | +				$gd_region  = get_query_var('gd_region');
 | |
| 829 | 829 |  			} else {
 | 
| 830 | 830 | $location = geodir_get_default_location(); | 
| 831 | 831 | |
| 832 | - $gd_country = isset( $location->country_slug ) ? $location->country_slug : ''; | |
| 833 | - $gd_region = isset( $location->region_slug ) ? $location->region_slug : ''; | |
| 834 | - $gd_city = isset( $location->city_slug ) ? $location->city_slug : ''; | |
| 832 | + $gd_country = isset($location->country_slug) ? $location->country_slug : ''; | |
| 833 | + $gd_region = isset($location->region_slug) ? $location->region_slug : ''; | |
| 834 | + $gd_city = isset($location->city_slug) ? $location->city_slug : ''; | |
| 835 | 835 | } | 
| 836 | 836 | |
| 837 | -			if ( $geodir_show_location_url == 'all' ) {
 | |
| 837 | +			if ($geodir_show_location_url == 'all') {
 | |
| 838 | 838 | $location_url[] = $gd_country; | 
| 839 | 839 | $location_url[] = $gd_region; | 
| 840 | -			} else if ( $geodir_show_location_url == 'country_city' ) {
 | |
| 840 | +			} else if ($geodir_show_location_url == 'country_city') {
 | |
| 841 | 841 | $location_url[] = $gd_country; | 
| 842 | -			} else if ( $geodir_show_location_url == 'region_city' ) {
 | |
| 842 | +			} else if ($geodir_show_location_url == 'region_city') {
 | |
| 843 | 843 | $location_url[] = $gd_region; | 
| 844 | 844 | } | 
| 845 | 845 | |
| 846 | 846 | $location_url[] = $gd_city; | 
| 847 | 847 | |
| 848 | - $location_url = implode( '/', $location_url ); | |
| 848 | +			$location_url = implode('/', $location_url);
 | |
| 849 | 849 | } | 
| 850 | 850 | |
| 851 | 851 | |
| 852 | -		if ( ! empty( $category ) ) {
 | |
| 852 | +		if (!empty($category)) {
 | |
| 853 | 853 | global $geodir_add_location_url; | 
| 854 | 854 | $geodir_add_location_url = '0'; | 
| 855 | -			if ( $add_location_filter != '0' ) {
 | |
| 855 | +			if ($add_location_filter != '0') {
 | |
| 856 | 856 | $geodir_add_location_url = '1'; | 
| 857 | 857 | } | 
| 858 | - $viewall_url = get_term_link( (int) $category[0], $post_type . $category_taxonomy ); | |
| 858 | + $viewall_url = get_term_link((int) $category[0], $post_type.$category_taxonomy); | |
| 859 | 859 | $geodir_add_location_url = null; | 
| 860 | 860 | } | 
| 861 | 861 | ob_start(); | 
| @@ -865,24 +865,24 @@ discard block | ||
| 865 | 865 | <div class="geodir_locations geodir_location_listing"> | 
| 866 | 866 | |
| 867 | 867 | <?php | 
| 868 | -			if ( isset( $request['is_widget'] ) && $request['is_widget'] == '1' ) {
 | |
| 868 | +			if (isset($request['is_widget']) && $request['is_widget'] == '1') {
 | |
| 869 | 869 | /** geodir_before_title filter Documented in geodirectory_widgets.php */ | 
| 870 | - $before_title = isset( $before_title ) ? $before_title : apply_filters( 'geodir_before_title', '<h3 class="widget-title">' ); | |
| 870 | +				$before_title = isset($before_title) ? $before_title : apply_filters('geodir_before_title', '<h3 class="widget-title">');
 | |
| 871 | 871 | /** geodir_after_title filter Documented in geodirectory_widgets.php */ | 
| 872 | - $after_title = isset( $after_title ) ? $after_title : apply_filters( 'geodir_after_title', '</h3>' ); | |
| 872 | +				$after_title = isset($after_title) ? $after_title : apply_filters('geodir_after_title', '</h3>');
 | |
| 873 | 873 | ?> | 
| 874 | 874 | <div class="location_list_heading clearfix"> | 
| 875 | - <?php echo $before_title . $title . $after_title; ?> | |
| 875 | + <?php echo $before_title.$title.$after_title; ?> | |
| 876 | 876 | </div> | 
| 877 | 877 | <?php | 
| 878 | 878 | } | 
| 879 | 879 | $query_args = array( | 
| 880 | 880 | 'posts_per_page' => $post_number, | 
| 881 | 881 | 'is_geodir_loop' => true, | 
| 882 | - 'gd_location' => ( $add_location_filter ) ? true : false, | |
| 882 | + 'gd_location' => ($add_location_filter) ? true : false, | |
| 883 | 883 | 'post_type' => $post_type, | 
| 884 | 884 | 'order_by' => $list_sort, | 
| 885 | - 'post__not_in' => array( $post_id ), | |
| 885 | + 'post__not_in' => array($post_id), | |
| 886 | 886 | 'excerpt_length' => $character_count, | 
| 887 | 887 | 'related_listings' => $is_display | 
| 888 | 888 | ); | 
| @@ -893,24 +893,24 @@ discard block | ||
| 893 | 893 | 'terms' => $category | 
| 894 | 894 | ); | 
| 895 | 895 | |
| 896 | - $query_args['tax_query'] = array( $tax_query ); | |
| 896 | + $query_args['tax_query'] = array($tax_query); | |
| 897 | 897 | |
| 898 | 898 | global $gridview_columns, $post; | 
| 899 | 899 | |
| 900 | 900 | |
| 901 | - query_posts( $query_args ); | |
| 901 | + query_posts($query_args); | |
| 902 | 902 | |
| 903 | -			if ( strstr( $layout, 'gridview' ) ) {
 | |
| 904 | - $listing_view_exp = explode( '_', $layout ); | |
| 903 | +			if (strstr($layout, 'gridview')) {
 | |
| 904 | +				$listing_view_exp = explode('_', $layout);
 | |
| 905 | 905 | $gridview_columns = $layout; | 
| 906 | 906 | $layout = $listing_view_exp[0]; | 
| 907 | -			} else if ( $layout == 'list' ) {
 | |
| 907 | +			} else if ($layout == 'list') {
 | |
| 908 | 908 | $gridview_columns = ''; | 
| 909 | 909 | } | 
| 910 | 910 | $related_posts = true; | 
| 911 | 911 | |
| 912 | 912 | $related_nearest = false; | 
| 913 | -			if ( $list_sort == 'nearest' ) {
 | |
| 913 | +			if ($list_sort == 'nearest') {
 | |
| 914 | 914 | $related_nearest = true; | 
| 915 | 915 | } | 
| 916 | 916 | |
| @@ -920,14 +920,14 @@ discard block | ||
| 920 | 920 | * | 
| 921 | 921 | * @since 1.0.0 | 
| 922 | 922 | */ | 
| 923 | - $template = apply_filters( "geodir_template_part-related-listing-listview", geodir_locate_template( 'listing-listview' ) ); | |
| 923 | +			$template = apply_filters("geodir_template_part-related-listing-listview", geodir_locate_template('listing-listview'));
 | |
| 924 | 924 | |
| 925 | 925 | /** | 
| 926 | 926 | * Includes related listing listview template. | 
| 927 | 927 | * | 
| 928 | 928 | * @since 1.0.0 | 
| 929 | 929 | */ | 
| 930 | - include( $template ); | |
| 930 | + include($template); | |
| 931 | 931 | |
| 932 | 932 | wp_reset_query(); | 
| 933 | 933 | $post = $origi_post; | 
| @@ -955,12 +955,12 @@ discard block | ||
| 955 | 955 |  function geodir_category_count_script() {
 | 
| 956 | 956 | global $geodir_post_category_str; | 
| 957 | 957 | |
| 958 | -	if ( ! empty( $geodir_post_category_str ) ) {
 | |
| 959 | - $geodir_post_category_str = serialize( $geodir_post_category_str ); | |
| 958 | +	if (!empty($geodir_post_category_str)) {
 | |
| 959 | + $geodir_post_category_str = serialize($geodir_post_category_str); | |
| 960 | 960 | } | 
| 961 | 961 | |
| 962 | - $all_var['post_category_array'] = html_entity_decode( (string) $geodir_post_category_str, ENT_QUOTES, 'UTF-8' ); | |
| 963 | - $script = "var post_category_array = " . json_encode( $all_var ) . ';'; | |
| 962 | + $all_var['post_category_array'] = html_entity_decode((string) $geodir_post_category_str, ENT_QUOTES, 'UTF-8'); | |
| 963 | + $script = "var post_category_array = ".json_encode($all_var).';'; | |
| 964 | 964 | echo '<script>'; | 
| 965 | 965 | echo $script; | 
| 966 | 966 | echo '</script>'; | 
| @@ -975,8 +975,8 @@ discard block | ||
| 975 | 975 | * @return string Returns the default language. | 
| 976 | 976 | */ | 
| 977 | 977 |  function geodir_get_map_default_language() {
 | 
| 978 | - $geodir_default_map_language = get_option( 'geodir_default_map_language' ); | |
| 979 | -	if ( empty( $geodir_default_map_language ) ) {
 | |
| 978 | +	$geodir_default_map_language = get_option('geodir_default_map_language');
 | |
| 979 | +	if (empty($geodir_default_map_language)) {
 | |
| 980 | 980 | $geodir_default_map_language = 'en'; | 
| 981 | 981 | } | 
| 982 | 982 | |
| @@ -987,7 +987,7 @@ discard block | ||
| 987 | 987 | * | 
| 988 | 988 | * @param string $geodir_default_map_language Default map language. | 
| 989 | 989 | */ | 
| 990 | - return apply_filters( 'geodir_default_map_language', $geodir_default_map_language ); | |
| 990 | +	return apply_filters('geodir_default_map_language', $geodir_default_map_language);
 | |
| 991 | 991 | } | 
| 992 | 992 | |
| 993 | 993 | /** | 
| @@ -998,7 +998,7 @@ discard block | ||
| 998 | 998 | * @return string Returns the api key. | 
| 999 | 999 | */ | 
| 1000 | 1000 |  function geodir_get_map_api_key() {
 | 
| 1001 | - $key = get_option( 'geodir_google_api_key' ); | |
| 1001 | +	$key = get_option('geodir_google_api_key');
 | |
| 1002 | 1002 | |
| 1003 | 1003 | /** | 
| 1004 | 1004 | * Filter Google maps api key. | 
| @@ -1007,7 +1007,7 @@ discard block | ||
| 1007 | 1007 | * | 
| 1008 | 1008 | * @param string $key Google maps api key. | 
| 1009 | 1009 | */ | 
| 1010 | - return apply_filters( 'geodir_google_api_key', $key ); | |
| 1010 | +	return apply_filters('geodir_google_api_key', $key);
 | |
| 1011 | 1011 | } | 
| 1012 | 1012 | |
| 1013 | 1013 | |
| @@ -1026,20 +1026,20 @@ discard block | ||
| 1026 | 1026 | global $wp, $post, $wp_query, $wpdb, $geodir_addon_list; | 
| 1027 | 1027 | |
| 1028 | 1028 | $is_geodir_page = geodir_is_geodir_page(); | 
| 1029 | -	if ( ! $is_geodir_page ) {
 | |
| 1029 | +	if (!$is_geodir_page) {
 | |
| 1030 | 1030 | return; | 
| 1031 | 1031 | }// if non GD page, bail | 
| 1032 | 1032 | |
| 1033 | 1033 | $use_gd_meta = true; | 
| 1034 | -	if ( class_exists( 'WPSEO_Frontend' ) || class_exists( 'All_in_One_SEO_Pack' ) ) {
 | |
| 1034 | +	if (class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) {
 | |
| 1035 | 1035 | $use_gd_meta = false; | 
| 1036 | 1036 | |
| 1037 | -		if ( geodir_is_page( 'search' ) ) {
 | |
| 1037 | +		if (geodir_is_page('search')) {
 | |
| 1038 | 1038 | $use_gd_meta = true; | 
| 1039 | 1039 | } | 
| 1040 | 1040 | } | 
| 1041 | 1041 | |
| 1042 | -	if ( ! $use_gd_meta ) {
 | |
| 1042 | +	if (!$use_gd_meta) {
 | |
| 1043 | 1043 | return; | 
| 1044 | 1044 | }// bail if Yoast Wordpress SEO or All_in_One_SEO_Pack active. | 
| 1045 | 1045 | |
| @@ -1047,170 +1047,170 @@ discard block | ||
| 1047 | 1047 | |
| 1048 | 1048 | $all_postypes = geodir_get_posttypes(); | 
| 1049 | 1049 | |
| 1050 | - $geodir_taxonomies = geodir_get_taxonomies( '', true ); | |
| 1050 | +	$geodir_taxonomies = geodir_get_taxonomies('', true);
 | |
| 1051 | 1051 | |
| 1052 | 1052 | $meta_desc = ''; | 
| 1053 | 1053 | $meta_key = ''; | 
| 1054 | -	if ( isset( $current_term->ID ) && $current_term->ID == geodir_location_page_id() ) {
 | |
| 1054 | +	if (isset($current_term->ID) && $current_term->ID == geodir_location_page_id()) {
 | |
| 1055 | 1055 | /** | 
| 1056 | 1056 | * Filter SEO meta location description. | 
| 1057 | 1057 | * | 
| 1058 | 1058 | * @since 1.0.0 | 
| 1059 | 1059 | */ | 
| 1060 | - $meta_desc = apply_filters( 'geodir_seo_meta_location_description', '' ); | |
| 1060 | +		$meta_desc = apply_filters('geodir_seo_meta_location_description', '');
 | |
| 1061 | 1061 | $meta_desc .= ''; | 
| 1062 | 1062 | } | 
| 1063 | -	if ( have_posts() && is_single() OR is_page() ) {
 | |
| 1064 | -		while ( have_posts() ) {
 | |
| 1063 | +	if (have_posts() && is_single() OR is_page()) {
 | |
| 1064 | +		while (have_posts()) {
 | |
| 1065 | 1065 | the_post(); | 
| 1066 | 1066 | |
| 1067 | -			if ( has_excerpt() ) {
 | |
| 1068 | - $out_excerpt = strip_tags( strip_shortcodes( get_the_excerpt() ) ); | |
| 1069 | -				if ( empty( $out_excerpt ) ) {
 | |
| 1070 | - $out_excerpt = strip_tags( do_shortcode( get_the_excerpt() ) ); | |
| 1067 | +			if (has_excerpt()) {
 | |
| 1068 | + $out_excerpt = strip_tags(strip_shortcodes(get_the_excerpt())); | |
| 1069 | +				if (empty($out_excerpt)) {
 | |
| 1070 | + $out_excerpt = strip_tags(do_shortcode(get_the_excerpt())); | |
| 1071 | 1071 | } | 
| 1072 | - $out_excerpt = str_replace( array( "\r\n", "\r", "\n" ), "", $out_excerpt ); | |
| 1072 | +				$out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $out_excerpt);
 | |
| 1073 | 1073 |  			} else {
 | 
| 1074 | - $out_excerpt = str_replace( array( "\r\n", "\r", "\n" ), "", $post->post_content ); | |
| 1075 | - $out_excerpt = strip_tags( strip_shortcodes( $out_excerpt ) ); | |
| 1076 | -				if ( empty( $out_excerpt ) ) {
 | |
| 1077 | - $out_excerpt = strip_tags( do_shortcode( $out_excerpt ) ); // parse short code from content | |
| 1074 | +				$out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $post->post_content);
 | |
| 1075 | + $out_excerpt = strip_tags(strip_shortcodes($out_excerpt)); | |
| 1076 | +				if (empty($out_excerpt)) {
 | |
| 1077 | + $out_excerpt = strip_tags(do_shortcode($out_excerpt)); // parse short code from content | |
| 1078 | 1078 | } | 
| 1079 | - $out_excerpt = trim( wp_trim_words( $out_excerpt, 35, '' ), '.!?,;:-' ); | |
| 1079 | + $out_excerpt = trim(wp_trim_words($out_excerpt, 35, ''), '.!?,;:-'); | |
| 1080 | 1080 | } | 
| 1081 | 1081 | |
| 1082 | 1082 | $meta_desc .= $out_excerpt; | 
| 1083 | 1083 | } | 
| 1084 | -	} elseif ( ( is_category() || is_tag() ) && isset( $current_term->taxonomy ) && in_array( $current_term->taxonomy, $geodir_taxonomies ) ) {
 | |
| 1085 | -		if ( is_category() ) {
 | |
| 1086 | - $meta_desc .= __( "Posts related to Category:", 'geodirectory' ) . " " . ucfirst( single_cat_title( "", false ) ); | |
| 1087 | -		} elseif ( is_tag() ) {
 | |
| 1088 | - $meta_desc .= __( "Posts related to Tag:", 'geodirectory' ) . " " . ucfirst( single_tag_title( "", false ) ); | |
| 1084 | +	} elseif ((is_category() || is_tag()) && isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
 | |
| 1085 | +		if (is_category()) {
 | |
| 1086 | +			$meta_desc .= __("Posts related to Category:", 'geodirectory')." ".ucfirst(single_cat_title("", false));
 | |
| 1087 | +		} elseif (is_tag()) {
 | |
| 1088 | +			$meta_desc .= __("Posts related to Tag:", 'geodirectory')." ".ucfirst(single_tag_title("", false));
 | |
| 1089 | 1089 | } | 
| 1090 | -	} elseif ( isset( $current_term->taxonomy ) && in_array( $current_term->taxonomy, $geodir_taxonomies ) ) {
 | |
| 1091 | - $meta_desc .= isset( $current_term->description ) ? $current_term->description : ''; | |
| 1090 | +	} elseif (isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
 | |
| 1091 | + $meta_desc .= isset($current_term->description) ? $current_term->description : ''; | |
| 1092 | 1092 | } | 
| 1093 | 1093 | |
| 1094 | 1094 | |
| 1095 | 1095 | $geodir_post_type = geodir_get_current_posttype(); | 
| 1096 | - $geodir_post_type_info = get_post_type_object( $geodir_post_type ); | |
| 1097 | - $geodir_is_page_listing = geodir_is_page( 'listing' ) ? true : false; | |
| 1098 | - | |
| 1099 | - $category_taxonomy = geodir_get_taxonomies( $geodir_post_type ); | |
| 1100 | - $tag_taxonomy = geodir_get_taxonomies( $geodir_post_type, true ); | |
| 1101 | - | |
| 1102 | - $geodir_is_category = isset( $category_taxonomy[0] ) && get_query_var( $category_taxonomy[0] ) ? get_query_var( $category_taxonomy[0] ) : false; | |
| 1103 | - $geodir_is_tag = isset( $tag_taxonomy[0] ) && get_query_var( $tag_taxonomy[0] ) ? true : false; | |
| 1104 | - | |
| 1105 | - $geodir_is_search = geodir_is_page( 'search' ) ? true : false; | |
| 1106 | - $geodir_is_location = geodir_is_page( 'location' ) ? true : false; | |
| 1107 | - $geodir_location_manager = isset( $geodir_addon_list['geodir_location_manager'] ) && $geodir_addon_list['geodir_location_manager'] = 'yes' ? true : false; | |
| 1108 | - $godir_location_terms = geodir_get_current_location_terms( 'query_vars' ); | |
| 1109 | - $gd_city = $geodir_location_manager && isset( $godir_location_terms['gd_city'] ) ? $godir_location_terms['gd_city'] : null; | |
| 1110 | - $gd_region = $geodir_location_manager && isset( $godir_location_terms['gd_region'] ) ? $godir_location_terms['gd_region'] : null; | |
| 1111 | - $gd_country = $geodir_location_manager && isset( $godir_location_terms['gd_country'] ) ? $godir_location_terms['gd_country'] : null; | |
| 1112 | - $replace_location = __( 'Everywhere', 'geodirectory' ); | |
| 1096 | + $geodir_post_type_info = get_post_type_object($geodir_post_type); | |
| 1097 | +	$geodir_is_page_listing = geodir_is_page('listing') ? true : false;
 | |
| 1098 | + | |
| 1099 | + $category_taxonomy = geodir_get_taxonomies($geodir_post_type); | |
| 1100 | + $tag_taxonomy = geodir_get_taxonomies($geodir_post_type, true); | |
| 1101 | + | |
| 1102 | + $geodir_is_category = isset($category_taxonomy[0]) && get_query_var($category_taxonomy[0]) ? get_query_var($category_taxonomy[0]) : false; | |
| 1103 | + $geodir_is_tag = isset($tag_taxonomy[0]) && get_query_var($tag_taxonomy[0]) ? true : false; | |
| 1104 | + | |
| 1105 | +	$geodir_is_search        = geodir_is_page('search') ? true : false;
 | |
| 1106 | +	$geodir_is_location      = geodir_is_page('location') ? true : false;
 | |
| 1107 | + $geodir_location_manager = isset($geodir_addon_list['geodir_location_manager']) && $geodir_addon_list['geodir_location_manager'] = 'yes' ? true : false; | |
| 1108 | +	$godir_location_terms    = geodir_get_current_location_terms('query_vars');
 | |
| 1109 | + $gd_city = $geodir_location_manager && isset($godir_location_terms['gd_city']) ? $godir_location_terms['gd_city'] : null; | |
| 1110 | + $gd_region = $geodir_location_manager && isset($godir_location_terms['gd_region']) ? $godir_location_terms['gd_region'] : null; | |
| 1111 | + $gd_country = $geodir_location_manager && isset($godir_location_terms['gd_country']) ? $godir_location_terms['gd_country'] : null; | |
| 1112 | +	$replace_location        = __('Everywhere', 'geodirectory');
 | |
| 1113 | 1113 | $location_id = null; | 
| 1114 | -	if ( $geodir_location_manager ) {
 | |
| 1115 | - $sql = $wpdb->prepare( "SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array( $gd_city ) ); | |
| 1116 | - $location_id = (int) $wpdb->get_var( $sql ); | |
| 1114 | +	if ($geodir_location_manager) {
 | |
| 1115 | +		$sql           = $wpdb->prepare("SELECT location_id FROM ".POST_LOCATION_TABLE." WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array($gd_city));
 | |
| 1116 | + $location_id = (int) $wpdb->get_var($sql); | |
| 1117 | 1117 | $location_type = geodir_what_is_current_location(); | 
| 1118 | -		if ( $location_type == 'city' ) {
 | |
| 1119 | - $replace_location = geodir_get_current_location( array( 'what' => 'city', 'echo' => false ) ); | |
| 1120 | -		} elseif ( $location_type == 'region' ) {
 | |
| 1121 | - $replace_location = geodir_get_current_location( array( 'what' => 'region', 'echo' => false ) ); | |
| 1122 | -		} elseif ( $location_type == 'country' ) {
 | |
| 1123 | - $replace_location = geodir_get_current_location( array( 'what' => 'country', 'echo' => false ) ); | |
| 1124 | - $replace_location = __( $replace_location, 'geodirectory' ); | |
| 1118 | +		if ($location_type == 'city') {
 | |
| 1119 | +			$replace_location = geodir_get_current_location(array('what' => 'city', 'echo' => false));
 | |
| 1120 | +		} elseif ($location_type == 'region') {
 | |
| 1121 | +			$replace_location = geodir_get_current_location(array('what' => 'region', 'echo' => false));
 | |
| 1122 | +		} elseif ($location_type == 'country') {
 | |
| 1123 | +			$replace_location = geodir_get_current_location(array('what' => 'country', 'echo' => false));
 | |
| 1124 | + $replace_location = __($replace_location, 'geodirectory'); | |
| 1125 | 1125 | } | 
| 1126 | - $country = get_query_var( 'gd_country' ); | |
| 1127 | - $region = get_query_var( 'gd_region' ); | |
| 1128 | - $city = get_query_var( 'gd_city' ); | |
| 1126 | +		$country          = get_query_var('gd_country');
 | |
| 1127 | +		$region           = get_query_var('gd_region');
 | |
| 1128 | +		$city             = get_query_var('gd_city');
 | |
| 1129 | 1129 | $current_location = ''; | 
| 1130 | -		if ( $country != '' ) {
 | |
| 1131 | - $current_location = get_actual_location_name( 'country', $country, true ); | |
| 1130 | +		if ($country != '') {
 | |
| 1131 | +			$current_location = get_actual_location_name('country', $country, true);
 | |
| 1132 | 1132 | } | 
| 1133 | -		if ( $region != '' ) {
 | |
| 1134 | - $current_location = get_actual_location_name( 'region', $region ); | |
| 1133 | +		if ($region != '') {
 | |
| 1134 | +			$current_location = get_actual_location_name('region', $region);
 | |
| 1135 | 1135 | } | 
| 1136 | -		if ( $city != '' ) {
 | |
| 1137 | - $current_location = get_actual_location_name( 'city', $city ); | |
| 1136 | +		if ($city != '') {
 | |
| 1137 | +			$current_location = get_actual_location_name('city', $city);
 | |
| 1138 | 1138 | } | 
| 1139 | 1139 | $replace_location = $current_location != '' ? $current_location : $replace_location; | 
| 1140 | 1140 | } | 
| 1141 | 1141 | |
| 1142 | 1142 | $geodir_meta_keys = ''; | 
| 1143 | 1143 | $geodir_meta_desc = ''; | 
| 1144 | -	if ( $is_geodir_page && ! empty( $geodir_post_type_info ) ) {
 | |
| 1145 | -		if ( $geodir_is_page_listing || $geodir_is_search || geodir_is_page( 'add-listing' ) ) {
 | |
| 1146 | - $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; | |
| 1144 | +	if ($is_geodir_page && !empty($geodir_post_type_info)) {
 | |
| 1145 | +		if ($geodir_is_page_listing || $geodir_is_search || geodir_is_page('add-listing')) {
 | |
| 1146 | + $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; | |
| 1147 | 1147 | |
| 1148 | - $geodir_meta_desc = isset( $geodir_post_type_info->description ) ? $geodir_post_type_info->description : $geodir_meta_desc; | |
| 1149 | - $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; | |
| 1148 | + $geodir_meta_desc = isset($geodir_post_type_info->description) ? $geodir_post_type_info->description : $geodir_meta_desc; | |
| 1149 | + $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; | |
| 1150 | 1150 | |
| 1151 | -			if ( $geodir_is_category ) {
 | |
| 1152 | - $category = $geodir_is_category ? get_term_by( 'slug', $geodir_is_category, $category_taxonomy[0] ) : null; | |
| 1153 | -				if ( isset( $category->term_id ) && ! empty( $category->term_id ) ) {
 | |
| 1151 | +			if ($geodir_is_category) {
 | |
| 1152 | +				$category = $geodir_is_category ? get_term_by('slug', $geodir_is_category, $category_taxonomy[0]) : null;
 | |
| 1153 | +				if (isset($category->term_id) && !empty($category->term_id)) {
 | |
| 1154 | 1154 | $category_id = $category->term_id; | 
| 1155 | - $category_desc = trim( $category->description ) != '' ? trim( $category->description ) : get_tax_meta( $category_id, 'ct_cat_top_desc', false, $geodir_post_type ); | |
| 1156 | -					if ( $location_id ) {
 | |
| 1157 | - $option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id; | |
| 1158 | - $cat_loc_option = get_option( $option_name ); | |
| 1159 | - | |
| 1160 | - $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; | |
| 1161 | -						if ( ! $gd_cat_loc_default ) {
 | |
| 1162 | - $option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id . '_' . $location_id; | |
| 1163 | - $option = get_option( $option_name ); | |
| 1164 | - $category_desc = isset( $option['gd_cat_loc_desc'] ) && trim( $option['gd_cat_loc_desc'] ) != '' ? trim( $option['gd_cat_loc_desc'] ) : $category_desc; | |
| 1155 | + $category_desc = trim($category->description) != '' ? trim($category->description) : get_tax_meta($category_id, 'ct_cat_top_desc', false, $geodir_post_type); | |
| 1156 | +					if ($location_id) {
 | |
| 1157 | + $option_name = 'geodir_cat_loc_'.$geodir_post_type.'_'.$category_id; | |
| 1158 | + $cat_loc_option = get_option($option_name); | |
| 1159 | + | |
| 1160 | + $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; | |
| 1161 | +						if (!$gd_cat_loc_default) {
 | |
| 1162 | + $option_name = 'geodir_cat_loc_'.$geodir_post_type.'_'.$category_id.'_'.$location_id; | |
| 1163 | + $option = get_option($option_name); | |
| 1164 | + $category_desc = isset($option['gd_cat_loc_desc']) && trim($option['gd_cat_loc_desc']) != '' ? trim($option['gd_cat_loc_desc']) : $category_desc; | |
| 1165 | 1165 | } | 
| 1166 | 1166 | } | 
| 1167 | - $geodir_meta_desc = __( "Posts related to Category:", 'geodirectory' ) . " " . ucfirst( single_cat_title( "", false ) ) . '. ' . $category_desc; | |
| 1167 | +					$geodir_meta_desc = __("Posts related to Category:", 'geodirectory')." ".ucfirst(single_cat_title("", false)).'. '.$category_desc;
 | |
| 1168 | 1168 | } | 
| 1169 | -			} else if ( $geodir_is_tag ) {
 | |
| 1170 | - $geodir_meta_desc = __( "Posts related to Tag:", 'geodirectory' ) . " " . ucfirst( single_tag_title( "", false ) ) . '. ' . $geodir_meta_desc; | |
| 1169 | +			} else if ($geodir_is_tag) {
 | |
| 1170 | +				$geodir_meta_desc = __("Posts related to Tag:", 'geodirectory')." ".ucfirst(single_tag_title("", false)).'. '.$geodir_meta_desc;
 | |
| 1171 | 1171 | } | 
| 1172 | 1172 | } | 
| 1173 | 1173 | } | 
| 1174 | 1174 | |
| 1175 | 1175 | |
| 1176 | 1176 | $gd_page = ''; | 
| 1177 | -	if ( geodir_is_page( 'home' ) ) {
 | |
| 1177 | +	if (geodir_is_page('home')) {
 | |
| 1178 | 1178 | $gd_page = 'home'; | 
| 1179 | - $meta_desc = ( get_option( 'geodir_meta_desc_homepage' ) ) ? get_option( 'geodir_meta_desc_homepage' ) : $meta_desc; | |
| 1180 | -	} elseif ( geodir_is_page( 'detail' ) ) {
 | |
| 1179 | +		$meta_desc = (get_option('geodir_meta_desc_homepage')) ? get_option('geodir_meta_desc_homepage') : $meta_desc;
 | |
| 1180 | +	} elseif (geodir_is_page('detail')) {
 | |
| 1181 | 1181 | $gd_page = 'detail'; | 
| 1182 | - $meta_desc = ( get_option( 'geodir_meta_desc_detail' ) ) ? get_option( 'geodir_meta_desc_detail' ) : $meta_desc; | |
| 1183 | -	} elseif ( geodir_is_page( 'pt' ) ) {
 | |
| 1182 | +		$meta_desc = (get_option('geodir_meta_desc_detail')) ? get_option('geodir_meta_desc_detail') : $meta_desc;
 | |
| 1183 | +	} elseif (geodir_is_page('pt')) {
 | |
| 1184 | 1184 | $gd_page = 'pt'; | 
| 1185 | - $meta_desc = ( get_option( 'geodir_meta_desc_pt' ) ) ? get_option( 'geodir_meta_desc_pt' ) : $meta_desc; | |
| 1186 | -	} elseif ( geodir_is_page( 'listing' ) ) {
 | |
| 1185 | +		$meta_desc = (get_option('geodir_meta_desc_pt')) ? get_option('geodir_meta_desc_pt') : $meta_desc;
 | |
| 1186 | +	} elseif (geodir_is_page('listing')) {
 | |
| 1187 | 1187 | $gd_page = 'listing'; | 
| 1188 | - $meta_desc = ( get_option( 'geodir_meta_desc_listing' ) ) ? get_option( 'geodir_meta_desc_listing' ) : $meta_desc; | |
| 1189 | -	} elseif ( geodir_is_page( 'location' ) ) {
 | |
| 1188 | +		$meta_desc = (get_option('geodir_meta_desc_listing')) ? get_option('geodir_meta_desc_listing') : $meta_desc;
 | |
| 1189 | +	} elseif (geodir_is_page('location')) {
 | |
| 1190 | 1190 | $gd_page = 'location'; | 
| 1191 | - $meta_desc = ( get_option( 'geodir_meta_desc_location' ) ) ? get_option( 'geodir_meta_desc_location' ) : $meta_desc; | |
| 1192 | - $meta_desc = apply_filters( 'geodir_seo_meta_location_description', $meta_desc ); | |
| 1191 | +		$meta_desc = (get_option('geodir_meta_desc_location')) ? get_option('geodir_meta_desc_location') : $meta_desc;
 | |
| 1192 | +		$meta_desc = apply_filters('geodir_seo_meta_location_description', $meta_desc);
 | |
| 1193 | 1193 | |
| 1194 | -	} elseif ( geodir_is_page( 'search' ) ) {
 | |
| 1194 | +	} elseif (geodir_is_page('search')) {
 | |
| 1195 | 1195 | $gd_page = 'search'; | 
| 1196 | - $meta_desc = ( get_option( 'geodir_meta_desc_search' ) ) ? get_option( 'geodir_meta_desc_search' ) : $meta_desc; | |
| 1197 | -	} elseif ( geodir_is_page( 'add-listing' ) ) {
 | |
| 1196 | +		$meta_desc = (get_option('geodir_meta_desc_search')) ? get_option('geodir_meta_desc_search') : $meta_desc;
 | |
| 1197 | +	} elseif (geodir_is_page('add-listing')) {
 | |
| 1198 | 1198 | $gd_page = 'add-listing'; | 
| 1199 | - $meta_desc = ( get_option( 'geodir_meta_desc_add-listing' ) ) ? get_option( 'geodir_meta_desc_add-listing' ) : $meta_desc; | |
| 1200 | -	} elseif ( geodir_is_page( 'author' ) ) {
 | |
| 1199 | +		$meta_desc = (get_option('geodir_meta_desc_add-listing')) ? get_option('geodir_meta_desc_add-listing') : $meta_desc;
 | |
| 1200 | +	} elseif (geodir_is_page('author')) {
 | |
| 1201 | 1201 | $gd_page = 'author'; | 
| 1202 | - $meta_desc = ( get_option( 'geodir_meta_desc_author' ) ) ? get_option( 'geodir_meta_desc_author' ) : $meta_desc; | |
| 1203 | -	} elseif ( geodir_is_page( 'login' ) ) {
 | |
| 1202 | +		$meta_desc = (get_option('geodir_meta_desc_author')) ? get_option('geodir_meta_desc_author') : $meta_desc;
 | |
| 1203 | +	} elseif (geodir_is_page('login')) {
 | |
| 1204 | 1204 | $gd_page = 'login'; | 
| 1205 | - $meta_desc = ( get_option( 'geodir_meta_desc_login' ) ) ? get_option( 'geodir_meta_desc_login' ) : $meta_desc; | |
| 1206 | -	} elseif ( geodir_is_page( 'listing-success' ) ) {
 | |
| 1205 | +		$meta_desc = (get_option('geodir_meta_desc_login')) ? get_option('geodir_meta_desc_login') : $meta_desc;
 | |
| 1206 | +	} elseif (geodir_is_page('listing-success')) {
 | |
| 1207 | 1207 | $gd_page = 'listing-success'; | 
| 1208 | - $meta_desc = ( get_option( 'geodir_meta_desc_listing-success' ) ) ? get_option( 'geodir_meta_desc_listing-success' ) : $meta_desc; | |
| 1208 | +		$meta_desc = (get_option('geodir_meta_desc_listing-success')) ? get_option('geodir_meta_desc_listing-success') : $meta_desc;
 | |
| 1209 | 1209 | } | 
| 1210 | 1210 | |
| 1211 | 1211 | |
| 1212 | -	if ( $meta_desc ) {
 | |
| 1213 | - $meta_desc = stripslashes_deep( $meta_desc ); | |
| 1212 | +	if ($meta_desc) {
 | |
| 1213 | + $meta_desc = stripslashes_deep($meta_desc); | |
| 1214 | 1214 | /** | 
| 1215 | 1215 | * Filter page description to replace variables. | 
| 1216 | 1216 | * | 
| @@ -1219,7 +1219,7 @@ discard block | ||
| 1219 | 1219 | * @param string $title The page description including variables. | 
| 1220 | 1220 | * @param string $gd_page The GeoDirectory page type if any. | 
| 1221 | 1221 | */ | 
| 1222 | - $meta_desc = apply_filters( 'geodir_seo_meta_description_pre', __( $meta_desc, 'geodirectory' ), $gd_page, '' ); | |
| 1222 | +		$meta_desc = apply_filters('geodir_seo_meta_description_pre', __($meta_desc, 'geodirectory'), $gd_page, '');
 | |
| 1223 | 1223 | |
| 1224 | 1224 | /** | 
| 1225 | 1225 | * Filter SEO meta description. | 
| @@ -1228,49 +1228,49 @@ discard block | ||
| 1228 | 1228 | * | 
| 1229 | 1229 | * @param string $meta_desc Meta description content. | 
| 1230 | 1230 | */ | 
| 1231 | - echo apply_filters( 'geodir_seo_meta_description', '<meta name="description" content="' . $meta_desc . '" />', $meta_desc ); | |
| 1231 | +		echo apply_filters('geodir_seo_meta_description', '<meta name="description" content="'.$meta_desc.'" />', $meta_desc);
 | |
| 1232 | 1232 | } | 
| 1233 | 1233 | |
| 1234 | 1234 | // meta keywords | 
| 1235 | -	if ( isset( $post->post_type ) && in_array( $post->post_type, $all_postypes ) ) {
 | |
| 1236 | - $place_tags = wp_get_post_terms( $post->ID, $post->post_type . '_tags', array( "fields" => "names" ) ); | |
| 1237 | - $place_cats = wp_get_post_terms( $post->ID, $post->post_type . 'category', array( "fields" => "names" ) ); | |
| 1235 | +	if (isset($post->post_type) && in_array($post->post_type, $all_postypes)) {
 | |
| 1236 | +		$place_tags = wp_get_post_terms($post->ID, $post->post_type.'_tags', array("fields" => "names"));
 | |
| 1237 | +		$place_cats = wp_get_post_terms($post->ID, $post->post_type.'category', array("fields" => "names"));
 | |
| 1238 | 1238 | |
| 1239 | - $meta_key .= implode( ", ", array_merge( (array) $place_cats, (array) $place_tags ) ); | |
| 1239 | +		$meta_key .= implode(", ", array_merge((array) $place_cats, (array) $place_tags));
 | |
| 1240 | 1240 |  	} else {
 | 
| 1241 | 1241 | $posttags = get_the_tags(); | 
| 1242 | -		if ( $posttags ) {
 | |
| 1243 | -			foreach ( $posttags as $tag ) {
 | |
| 1244 | - $meta_key .= $tag->name . ' '; | |
| 1242 | +		if ($posttags) {
 | |
| 1243 | +			foreach ($posttags as $tag) {
 | |
| 1244 | + $meta_key .= $tag->name.' '; | |
| 1245 | 1245 | } | 
| 1246 | 1246 |  		} else {
 | 
| 1247 | - $tags = get_tags( array( 'orderby' => 'count', 'order' => 'DESC' ) ); | |
| 1247 | +			$tags = get_tags(array('orderby' => 'count', 'order' => 'DESC'));
 | |
| 1248 | 1248 | $xt = 1; | 
| 1249 | 1249 | |
| 1250 | -			foreach ( $tags as $tag ) {
 | |
| 1251 | -				if ( $xt <= 20 ) {
 | |
| 1252 | - $meta_key .= $tag->name . ", "; | |
| 1250 | +			foreach ($tags as $tag) {
 | |
| 1251 | +				if ($xt <= 20) {
 | |
| 1252 | + $meta_key .= $tag->name.", "; | |
| 1253 | 1253 | } | 
| 1254 | 1254 | |
| 1255 | - $xt ++; | |
| 1255 | + $xt++; | |
| 1256 | 1256 | } | 
| 1257 | 1257 | } | 
| 1258 | 1258 | } | 
| 1259 | 1259 | |
| 1260 | - $meta_key = $meta_key != '' ? rtrim( trim( $meta_key ), "," ) : $meta_key; | |
| 1261 | - $geodir_meta_keys = $geodir_meta_keys != '' ? ( $meta_key != '' ? $meta_key . ', ' . $geodir_meta_keys : $geodir_meta_keys ) : $meta_key; | |
| 1262 | -	if ( $geodir_meta_keys != '' ) {
 | |
| 1263 | - $geodir_meta_keys = strip_tags( $geodir_meta_keys ); | |
| 1264 | - $geodir_meta_keys = esc_html( $geodir_meta_keys ); | |
| 1265 | - $geodir_meta_keys = geodir_strtolower( $geodir_meta_keys ); | |
| 1266 | - $geodir_meta_keys = wp_html_excerpt( $geodir_meta_keys, 1000, '' ); | |
| 1267 | - $geodir_meta_keys = str_replace( '%location%', $replace_location, $geodir_meta_keys ); | |
| 1260 | + $meta_key = $meta_key != '' ? rtrim(trim($meta_key), ",") : $meta_key; | |
| 1261 | + $geodir_meta_keys = $geodir_meta_keys != '' ? ($meta_key != '' ? $meta_key.', '.$geodir_meta_keys : $geodir_meta_keys) : $meta_key; | |
| 1262 | +	if ($geodir_meta_keys != '') {
 | |
| 1263 | + $geodir_meta_keys = strip_tags($geodir_meta_keys); | |
| 1264 | + $geodir_meta_keys = esc_html($geodir_meta_keys); | |
| 1265 | + $geodir_meta_keys = geodir_strtolower($geodir_meta_keys); | |
| 1266 | + $geodir_meta_keys = wp_html_excerpt($geodir_meta_keys, 1000, ''); | |
| 1267 | +		$geodir_meta_keys = str_replace('%location%', $replace_location, $geodir_meta_keys);
 | |
| 1268 | 1268 | |
| 1269 | - $meta_key = rtrim( trim( $geodir_meta_keys ), "," ); | |
| 1269 | + $meta_key = rtrim(trim($geodir_meta_keys), ","); | |
| 1270 | 1270 | } | 
| 1271 | 1271 | |
| 1272 | -	if ( $meta_key ) {
 | |
| 1273 | - $meta_key = stripslashes_deep( $meta_key ); | |
| 1272 | +	if ($meta_key) {
 | |
| 1273 | + $meta_key = stripslashes_deep($meta_key); | |
| 1274 | 1274 | /** | 
| 1275 | 1275 | * Filter SEO meta keywords. | 
| 1276 | 1276 | * | 
| @@ -1278,7 +1278,7 @@ discard block | ||
| 1278 | 1278 | * | 
| 1279 | 1279 | * @param string $meta_desc Meta keywords. | 
| 1280 | 1280 | */ | 
| 1281 | - echo apply_filters( 'geodir_seo_meta_keywords', '<meta name="keywords" content="' . $meta_key . '" />', $meta_key ); | |
| 1281 | +		echo apply_filters('geodir_seo_meta_keywords', '<meta name="keywords" content="'.$meta_key.'" />', $meta_key);
 | |
| 1282 | 1282 | } | 
| 1283 | 1283 | |
| 1284 | 1284 | } | 
| @@ -1298,8 +1298,8 @@ discard block | ||
| 1298 | 1298 | |
| 1299 | 1299 | $geodir_detail_page_tabs_array = geodir_detail_page_tabs_array(); | 
| 1300 | 1300 | |
| 1301 | -	foreach ( $geodir_detail_page_tabs_array as $key => $tabs_obj ) {
 | |
| 1302 | - $geodir_detail_page_tabs_key_value_array[ $key ] = $tabs_obj['heading_text']; | |
| 1301 | +	foreach ($geodir_detail_page_tabs_array as $key => $tabs_obj) {
 | |
| 1302 | + $geodir_detail_page_tabs_key_value_array[$key] = $tabs_obj['heading_text']; | |
| 1303 | 1303 | } | 
| 1304 | 1304 | |
| 1305 | 1305 | return $geodir_detail_page_tabs_key_value_array; | 
| @@ -1321,57 +1321,57 @@ discard block | ||
| 1321 | 1321 | * @since 1.0.0 | 
| 1322 | 1322 | */ | 
| 1323 | 1323 | $arr_tabs['post_profile'] = array( | 
| 1324 | - 'heading_text' => __( 'Profile', 'geodirectory' ), | |
| 1324 | +		'heading_text'  => __('Profile', 'geodirectory'),
 | |
| 1325 | 1325 | 'is_active_tab' => true, | 
| 1326 | - 'is_display' => apply_filters( 'geodir_detail_page_tab_is_display', true, 'post_profile' ), | |
| 1326 | +		'is_display'    => apply_filters('geodir_detail_page_tab_is_display', true, 'post_profile'),
 | |
| 1327 | 1327 | 'tab_content' => '' | 
| 1328 | 1328 | ); | 
| 1329 | - $arr_tabs['post_info'] = array( | |
| 1330 | - 'heading_text' => __( 'More Info', 'geodirectory' ), | |
| 1329 | + $arr_tabs['post_info'] = array( | |
| 1330 | +		'heading_text'  => __('More Info', 'geodirectory'),
 | |
| 1331 | 1331 | 'is_active_tab' => false, | 
| 1332 | - 'is_display' => apply_filters( 'geodir_detail_page_tab_is_display', true, 'post_info' ), | |
| 1332 | +		'is_display'    => apply_filters('geodir_detail_page_tab_is_display', true, 'post_info'),
 | |
| 1333 | 1333 | 'tab_content' => '' | 
| 1334 | 1334 | ); | 
| 1335 | 1335 | |
| 1336 | 1336 | $arr_tabs['post_images'] = array( | 
| 1337 | - 'heading_text' => __( 'Photo', 'geodirectory' ), | |
| 1337 | +		'heading_text'  => __('Photo', 'geodirectory'),
 | |
| 1338 | 1338 | 'is_active_tab' => false, | 
| 1339 | - 'is_display' => apply_filters( 'geodir_detail_page_tab_is_display', true, 'post_images' ), | |
| 1339 | +		'is_display'    => apply_filters('geodir_detail_page_tab_is_display', true, 'post_images'),
 | |
| 1340 | 1340 | 'tab_content' => '' | 
| 1341 | 1341 | ); | 
| 1342 | 1342 | |
| 1343 | 1343 | $arr_tabs['post_video'] = array( | 
| 1344 | - 'heading_text' => __( 'Video', 'geodirectory' ), | |
| 1344 | +		'heading_text'  => __('Video', 'geodirectory'),
 | |
| 1345 | 1345 | 'is_active_tab' => false, | 
| 1346 | - 'is_display' => apply_filters( 'geodir_detail_page_tab_is_display', true, 'post_video' ), | |
| 1346 | +		'is_display'    => apply_filters('geodir_detail_page_tab_is_display', true, 'post_video'),
 | |
| 1347 | 1347 | 'tab_content' => '' | 
| 1348 | 1348 | ); | 
| 1349 | 1349 | |
| 1350 | 1350 | $arr_tabs['special_offers'] = array( | 
| 1351 | - 'heading_text' => __( 'Special Offers', 'geodirectory' ), | |
| 1351 | +		'heading_text'  => __('Special Offers', 'geodirectory'),
 | |
| 1352 | 1352 | 'is_active_tab' => false, | 
| 1353 | - 'is_display' => apply_filters( 'geodir_detail_page_tab_is_display', true, 'special_offers' ), | |
| 1353 | +		'is_display'    => apply_filters('geodir_detail_page_tab_is_display', true, 'special_offers'),
 | |
| 1354 | 1354 | 'tab_content' => '' | 
| 1355 | 1355 | ); | 
| 1356 | 1356 | |
| 1357 | 1357 | $arr_tabs['post_map'] = array( | 
| 1358 | - 'heading_text' => __( 'Map', 'geodirectory' ), | |
| 1358 | +		'heading_text'  => __('Map', 'geodirectory'),
 | |
| 1359 | 1359 | 'is_active_tab' => false, | 
| 1360 | - 'is_display' => apply_filters( 'geodir_detail_page_tab_is_display', true, 'post_map' ), | |
| 1360 | +		'is_display'    => apply_filters('geodir_detail_page_tab_is_display', true, 'post_map'),
 | |
| 1361 | 1361 | 'tab_content' => '' | 
| 1362 | 1362 | ); | 
| 1363 | 1363 | |
| 1364 | 1364 | $arr_tabs['reviews'] = array( | 
| 1365 | - 'heading_text' => __( 'Reviews', 'geodirectory' ), | |
| 1365 | +		'heading_text'  => __('Reviews', 'geodirectory'),
 | |
| 1366 | 1366 | 'is_active_tab' => false, | 
| 1367 | - 'is_display' => apply_filters( 'geodir_detail_page_tab_is_display', true, 'reviews' ), | |
| 1367 | +		'is_display'    => apply_filters('geodir_detail_page_tab_is_display', true, 'reviews'),
 | |
| 1368 | 1368 | 'tab_content' => 'review display' | 
| 1369 | 1369 | ); | 
| 1370 | 1370 | |
| 1371 | 1371 | $arr_tabs['related_listing'] = array( | 
| 1372 | - 'heading_text' => __( 'Related Listing', 'geodirectory' ), | |
| 1372 | +		'heading_text'  => __('Related Listing', 'geodirectory'),
 | |
| 1373 | 1373 | 'is_active_tab' => false, | 
| 1374 | - 'is_display' => apply_filters( 'geodir_detail_page_tab_is_display', true, 'related_listing' ), | |
| 1374 | +		'is_display'    => apply_filters('geodir_detail_page_tab_is_display', true, 'related_listing'),
 | |
| 1375 | 1375 | 'tab_content' => '' | 
| 1376 | 1376 | ); | 
| 1377 | 1377 | |
| @@ -1380,7 +1380,7 @@ discard block | ||
| 1380 | 1380 | * | 
| 1381 | 1381 | * @since 1.0.0 | 
| 1382 | 1382 | */ | 
| 1383 | - return apply_filters( 'geodir_detail_page_tab_list_extend', $arr_tabs ); | |
| 1383 | +	return apply_filters('geodir_detail_page_tab_list_extend', $arr_tabs);
 | |
| 1384 | 1384 | |
| 1385 | 1385 | |
| 1386 | 1386 | } | 
| @@ -1394,13 +1394,13 @@ discard block | ||
| 1394 | 1394 | * @return mixed|array Tabs array. | 
| 1395 | 1395 | */ | 
| 1396 | 1396 |  function geodir_detail_page_tabs_list() {
 | 
| 1397 | - $tabs_excluded = get_option( 'geodir_detail_page_tabs_excluded' ); | |
| 1397 | +	$tabs_excluded = get_option('geodir_detail_page_tabs_excluded');
 | |
| 1398 | 1398 | $tabs_array = geodir_detail_page_tabs_array(); | 
| 1399 | 1399 | |
| 1400 | -	if ( ! empty( $tabs_excluded ) ) {
 | |
| 1401 | -		foreach ( $tabs_excluded as $tab ) {
 | |
| 1402 | -			if ( array_key_exists( $tab, $tabs_array ) ) {
 | |
| 1403 | - unset( $tabs_array[ $tab ] ); | |
| 1400 | +	if (!empty($tabs_excluded)) {
 | |
| 1401 | +		foreach ($tabs_excluded as $tab) {
 | |
| 1402 | +			if (array_key_exists($tab, $tabs_array)) {
 | |
| 1403 | + unset($tabs_array[$tab]); | |
| 1404 | 1404 | } | 
| 1405 | 1405 | } | 
| 1406 | 1406 | } | 
| @@ -1424,58 +1424,58 @@ discard block | ||
| 1424 | 1424 |  function geodir_show_detail_page_tabs() {
 | 
| 1425 | 1425 | global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields, $preview; | 
| 1426 | 1426 | |
| 1427 | - $post_id = ! empty( $post ) && isset( $post->ID ) ? (int) $post->ID : 0; | |
| 1428 | - $request_post_id = ! empty( $_REQUEST['p'] ) ? (int) $_REQUEST['p'] : 0; | |
| 1429 | - $is_backend_preview = ( is_single() && ! empty( $_REQUEST['post_type'] ) && ! empty( $_REQUEST['preview'] ) && ! empty( $_REQUEST['p'] ) ) && is_super_admin() ? true : false; // skip if preview from backend | |
| 1427 | + $post_id = !empty($post) && isset($post->ID) ? (int) $post->ID : 0; | |
| 1428 | + $request_post_id = !empty($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0; | |
| 1429 | + $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend | |
| 1430 | 1430 | |
| 1431 | -	if ( $is_backend_preview && ! $post_id > 0 && $request_post_id > 0 ) {
 | |
| 1432 | - $post = geodir_get_post_info( $request_post_id ); | |
| 1433 | - setup_postdata( $post ); | |
| 1431 | +	if ($is_backend_preview && !$post_id > 0 && $request_post_id > 0) {
 | |
| 1432 | + $post = geodir_get_post_info($request_post_id); | |
| 1433 | + setup_postdata($post); | |
| 1434 | 1434 | } | 
| 1435 | 1435 | |
| 1436 | - $geodir_post_detail_fields = geodir_show_listing_info( 'moreinfo' ); | |
| 1436 | +	$geodir_post_detail_fields = geodir_show_listing_info('moreinfo');
 | |
| 1437 | 1437 | |
| 1438 | 1438 | |
| 1439 | -	if ( geodir_is_page( 'detail' ) ) {
 | |
| 1440 | - $video = geodir_get_video( $post->ID ); | |
| 1441 | - $special_offers = geodir_get_special_offers( $post->ID ); | |
| 1439 | +	if (geodir_is_page('detail')) {
 | |
| 1440 | + $video = geodir_get_video($post->ID); | |
| 1441 | + $special_offers = geodir_get_special_offers($post->ID); | |
| 1442 | 1442 | $related_listing_array = array(); | 
| 1443 | -		if ( get_option( 'geodir_add_related_listing_posttypes' ) ) {
 | |
| 1444 | - $related_listing_array = get_option( 'geodir_add_related_listing_posttypes' ); | |
| 1443 | +		if (get_option('geodir_add_related_listing_posttypes')) {
 | |
| 1444 | +			$related_listing_array = get_option('geodir_add_related_listing_posttypes');
 | |
| 1445 | 1445 | } | 
| 1446 | 1446 | |
| 1447 | 1447 | |
| 1448 | - $excluded_tabs = get_option( 'geodir_detail_page_tabs_excluded' ); | |
| 1449 | -		if ( ! $excluded_tabs ) {
 | |
| 1448 | +		$excluded_tabs = get_option('geodir_detail_page_tabs_excluded');
 | |
| 1449 | +		if (!$excluded_tabs) {
 | |
| 1450 | 1450 | $excluded_tabs = array(); | 
| 1451 | 1451 | } | 
| 1452 | 1452 | |
| 1453 | 1453 | $related_listing = ''; | 
| 1454 | -		if ( in_array( $post->post_type, $related_listing_array ) && ! in_array( 'related_listing', $excluded_tabs ) ) {
 | |
| 1454 | +		if (in_array($post->post_type, $related_listing_array) && !in_array('related_listing', $excluded_tabs)) {
 | |
| 1455 | 1455 | $request = array( | 
| 1456 | - 'post_number' => get_option( 'geodir_related_post_count' ), | |
| 1457 | - 'relate_to' => get_option( 'geodir_related_post_relate_to' ), | |
| 1458 | - 'layout' => get_option( 'geodir_related_post_listing_view' ), | |
| 1459 | - 'add_location_filter' => get_option( 'geodir_related_post_location_filter' ), | |
| 1460 | - 'list_sort' => get_option( 'geodir_related_post_sortby' ), | |
| 1461 | - 'character_count' => get_option( 'geodir_related_post_excerpt' ) | |
| 1456 | +				'post_number'         => get_option('geodir_related_post_count'),
 | |
| 1457 | +				'relate_to'           => get_option('geodir_related_post_relate_to'),
 | |
| 1458 | +				'layout'              => get_option('geodir_related_post_listing_view'),
 | |
| 1459 | +				'add_location_filter' => get_option('geodir_related_post_location_filter'),
 | |
| 1460 | +				'list_sort'           => get_option('geodir_related_post_sortby'),
 | |
| 1461 | +				'character_count'     => get_option('geodir_related_post_excerpt')
 | |
| 1462 | 1462 | ); | 
| 1463 | 1463 | |
| 1464 | -			if ( $post->post_type == 'gd_event' && defined( 'GDEVENTS_VERSION' ) ) {
 | |
| 1465 | - $related_listing = geodir_get_detail_page_related_events( $request ); | |
| 1464 | +			if ($post->post_type == 'gd_event' && defined('GDEVENTS_VERSION')) {
 | |
| 1465 | + $related_listing = geodir_get_detail_page_related_events($request); | |
| 1466 | 1466 |  			} else {
 | 
| 1467 | - $related_listing = geodir_related_posts_display( $request ); | |
| 1467 | + $related_listing = geodir_related_posts_display($request); | |
| 1468 | 1468 | } | 
| 1469 | 1469 | |
| 1470 | 1470 | } | 
| 1471 | 1471 | |
| 1472 | - $post_images = geodir_get_images( $post->ID, 'thumbnail' ); | |
| 1472 | + $post_images = geodir_get_images($post->ID, 'thumbnail'); | |
| 1473 | 1473 | $thumb_image = ''; | 
| 1474 | -		if ( ! empty( $post_images ) ) {
 | |
| 1475 | -			foreach ( $post_images as $image ) {
 | |
| 1476 | - $caption = ( ! empty( $image->caption ) ) ? $image->caption : ''; | |
| 1477 | - $thumb_image .= '<a href="' . $image->src . '" title="' . $caption . '">'; | |
| 1478 | - $thumb_image .= geodir_show_image( $image, 'thumbnail', true, false ); | |
| 1474 | +		if (!empty($post_images)) {
 | |
| 1475 | +			foreach ($post_images as $image) {
 | |
| 1476 | + $caption = (!empty($image->caption)) ? $image->caption : ''; | |
| 1477 | + $thumb_image .= '<a href="'.$image->src.'" title="'.$caption.'">'; | |
| 1478 | + $thumb_image .= geodir_show_image($image, 'thumbnail', true, false); | |
| 1479 | 1479 | $thumb_image .= '</a>'; | 
| 1480 | 1480 | } | 
| 1481 | 1481 | } | 
| @@ -1484,11 +1484,11 @@ discard block | ||
| 1484 | 1484 | $map_args['map_canvas_name'] = 'detail_page_map_canvas'; | 
| 1485 | 1485 | $map_args['width'] = '600'; | 
| 1486 | 1486 | $map_args['height'] = '300'; | 
| 1487 | -		if ( $post->post_mapzoom ) {
 | |
| 1488 | - $map_args['zoom'] = '' . $post->post_mapzoom . ''; | |
| 1487 | +		if ($post->post_mapzoom) {
 | |
| 1488 | + $map_args['zoom'] = ''.$post->post_mapzoom.''; | |
| 1489 | 1489 | } | 
| 1490 | 1490 | $map_args['autozoom'] = false; | 
| 1491 | - $map_args['scrollwheel'] = ( get_option( 'geodir_add_listing_mouse_scroll' ) ) ? 0 : 1; | |
| 1491 | +		$map_args['scrollwheel']              = (get_option('geodir_add_listing_mouse_scroll')) ? 0 : 1;
 | |
| 1492 | 1492 | $map_args['child_collapse'] = '0'; | 
| 1493 | 1493 | $map_args['enable_cat_filters'] = false; | 
| 1494 | 1494 | $map_args['enable_text_search'] = false; | 
| @@ -1497,43 +1497,43 @@ discard block | ||
| 1497 | 1497 | $map_args['enable_jason_on_load'] = true; | 
| 1498 | 1498 | $map_args['enable_map_direction'] = true; | 
| 1499 | 1499 | $map_args['map_class_name'] = 'geodir-map-detail-page'; | 
| 1500 | - $map_args['maptype'] = ( ! empty( $post->post_mapview ) ) ? $post->post_mapview : 'ROADMAP'; | |
| 1501 | -	} else if ( geodir_is_page( 'preview' ) ) {
 | |
| 1502 | - $video = isset( $post->geodir_video ) ? $post->geodir_video : ''; | |
| 1503 | - $special_offers = isset( $post->geodir_special_offers ) ? $post->geodir_special_offers : ''; | |
| 1500 | + $map_args['maptype'] = (!empty($post->post_mapview)) ? $post->post_mapview : 'ROADMAP'; | |
| 1501 | +	} else if (geodir_is_page('preview')) {
 | |
| 1502 | + $video = isset($post->geodir_video) ? $post->geodir_video : ''; | |
| 1503 | + $special_offers = isset($post->geodir_special_offers) ? $post->geodir_special_offers : ''; | |
| 1504 | 1504 | |
| 1505 | -		if ( isset( $post->post_images ) ) {
 | |
| 1506 | - $post->post_images = trim( $post->post_images, "," ); | |
| 1505 | +		if (isset($post->post_images)) {
 | |
| 1506 | + $post->post_images = trim($post->post_images, ","); | |
| 1507 | 1507 | } | 
| 1508 | 1508 | |
| 1509 | -		if ( isset( $post->post_images ) && ! empty( $post->post_images ) ) {
 | |
| 1510 | - $post_images = explode( ",", $post->post_images ); | |
| 1509 | +		if (isset($post->post_images) && !empty($post->post_images)) {
 | |
| 1510 | +			$post_images = explode(",", $post->post_images);
 | |
| 1511 | 1511 | } | 
| 1512 | 1512 | |
| 1513 | 1513 | $thumb_image = ''; | 
| 1514 | -		if ( ! empty( $post_images ) ) {
 | |
| 1515 | -			foreach ( $post_images as $image ) {
 | |
| 1516 | -				if ( $image != '' ) {
 | |
| 1517 | - $thumb_image .= '<a href="' . $image . '">'; | |
| 1518 | - $thumb_image .= geodir_show_image( array( 'src' => $image ), 'thumbnail', true, false ); | |
| 1514 | +		if (!empty($post_images)) {
 | |
| 1515 | +			foreach ($post_images as $image) {
 | |
| 1516 | +				if ($image != '') {
 | |
| 1517 | + $thumb_image .= '<a href="'.$image.'">'; | |
| 1518 | +					$thumb_image .= geodir_show_image(array('src' => $image), 'thumbnail', true, false);
 | |
| 1519 | 1519 | $thumb_image .= '</a>'; | 
| 1520 | 1520 | } | 
| 1521 | 1521 | } | 
| 1522 | 1522 | } | 
| 1523 | 1523 | |
| 1524 | 1524 | global $map_jason; | 
| 1525 | - $marker_json = $post->marker_json != '' ? json_decode( $post->marker_json, true ) : array(); | |
| 1526 | - $marker_icon = ( ! empty( $marker_json ) && ! empty( $marker_json['i'] ) ) ? $marker_json['i'] : ''; | |
| 1527 | - $icon_size = geodir_get_marker_size( $marker_icon ); | |
| 1525 | + $marker_json = $post->marker_json != '' ? json_decode($post->marker_json, true) : array(); | |
| 1526 | + $marker_icon = (!empty($marker_json) && !empty($marker_json['i'])) ? $marker_json['i'] : ''; | |
| 1527 | + $icon_size = geodir_get_marker_size($marker_icon); | |
| 1528 | 1528 | $marker_json['w'] = $icon_size['w']; | 
| 1529 | 1529 | $marker_json['h'] = $icon_size['h']; | 
| 1530 | - $map_jason[] = json_encode( $marker_json ); | |
| 1530 | + $map_jason[] = json_encode($marker_json); | |
| 1531 | 1531 | |
| 1532 | - $address_latitude = isset( $post->post_latitude ) ? $post->post_latitude : ''; | |
| 1533 | - $address_longitude = isset( $post->post_longitude ) ? $post->post_longitude : ''; | |
| 1534 | - $mapview = isset( $post->post_mapview ) ? $post->post_mapview : ''; | |
| 1535 | - $mapzoom = isset( $post->post_mapzoom ) ? $post->post_mapzoom : ''; | |
| 1536 | -		if ( ! $mapzoom ) {
 | |
| 1532 | + $address_latitude = isset($post->post_latitude) ? $post->post_latitude : ''; | |
| 1533 | + $address_longitude = isset($post->post_longitude) ? $post->post_longitude : ''; | |
| 1534 | + $mapview = isset($post->post_mapview) ? $post->post_mapview : ''; | |
| 1535 | + $mapzoom = isset($post->post_mapzoom) ? $post->post_mapzoom : ''; | |
| 1536 | +		if (!$mapzoom) {
 | |
| 1537 | 1537 | $mapzoom = 12; | 
| 1538 | 1538 | } | 
| 1539 | 1539 | |
| @@ -1556,37 +1556,37 @@ discard block | ||
| 1556 | 1556 | $map_args['map_class_name'] = 'geodir-map-preview-page'; | 
| 1557 | 1557 | } | 
| 1558 | 1558 | |
| 1559 | - $arr_detail_page_tabs = geodir_detail_page_tabs_list();// get this sooner so we can get the active tab for the user | |
| 1559 | + $arr_detail_page_tabs = geodir_detail_page_tabs_list(); // get this sooner so we can get the active tab for the user | |
| 1560 | 1560 | |
| 1561 | 1561 | $active_tab = ''; | 
| 1562 | 1562 | $active_tab_name = ''; | 
| 1563 | 1563 | $default_tab = ''; | 
| 1564 | 1564 | $default_tab_name = ''; | 
| 1565 | -	foreach ( $arr_detail_page_tabs as $tab_index => $tabs ) {
 | |
| 1566 | -		if ( isset( $tabs['is_active_tab'] ) && $tabs['is_active_tab'] && ! empty( $tabs['is_display'] ) && isset( $tabs['heading_text'] ) && $tabs['heading_text'] ) {
 | |
| 1565 | +	foreach ($arr_detail_page_tabs as $tab_index => $tabs) {
 | |
| 1566 | +		if (isset($tabs['is_active_tab']) && $tabs['is_active_tab'] && !empty($tabs['is_display']) && isset($tabs['heading_text']) && $tabs['heading_text']) {
 | |
| 1567 | 1567 | $active_tab = $tab_index; | 
| 1568 | - $active_tab_name = __( $tabs['heading_text'], 'geodirectory' ); | |
| 1568 | + $active_tab_name = __($tabs['heading_text'], 'geodirectory'); | |
| 1569 | 1569 | } | 
| 1570 | 1570 | |
| 1571 | -		if ( $default_tab === '' && ! empty( $tabs['is_display'] ) && ! empty( $tabs['heading_text'] ) ) {
 | |
| 1571 | +		if ($default_tab === '' && !empty($tabs['is_display']) && !empty($tabs['heading_text'])) {
 | |
| 1572 | 1572 | $default_tab = $tab_index; | 
| 1573 | - $default_tab_name = __( $tabs['heading_text'], 'geodirectory' ); | |
| 1573 | + $default_tab_name = __($tabs['heading_text'], 'geodirectory'); | |
| 1574 | 1574 | } | 
| 1575 | 1575 | } | 
| 1576 | 1576 | |
| 1577 | -	if ( $active_tab === '' && $default_tab !== '' ) { // Make first tab acs a active tab if not any tab is active.
 | |
| 1578 | -		if ( isset( $arr_detail_page_tabs[ $active_tab ] ) && isset( $arr_detail_page_tabs[ $active_tab ]['is_active_tab'] ) ) {
 | |
| 1579 | - $arr_detail_page_tabs[ $active_tab ]['is_active_tab'] = false; | |
| 1577 | +	if ($active_tab === '' && $default_tab !== '') { // Make first tab acs a active tab if not any tab is active.
 | |
| 1578 | +		if (isset($arr_detail_page_tabs[$active_tab]) && isset($arr_detail_page_tabs[$active_tab]['is_active_tab'])) {
 | |
| 1579 | + $arr_detail_page_tabs[$active_tab]['is_active_tab'] = false; | |
| 1580 | 1580 | } | 
| 1581 | 1581 | |
| 1582 | - $arr_detail_page_tabs[ $default_tab ]['is_active_tab'] = true; | |
| 1582 | + $arr_detail_page_tabs[$default_tab]['is_active_tab'] = true; | |
| 1583 | 1583 | $active_tab = $default_tab; | 
| 1584 | 1584 | $active_tab_name = $default_tab_name; | 
| 1585 | 1585 | } | 
| 1586 | - $tab_list = ( get_option( 'geodir_disable_tabs', false ) ) ? true : false; | |
| 1586 | +	$tab_list = (get_option('geodir_disable_tabs', false)) ? true : false;
 | |
| 1587 | 1587 | ?> | 
| 1588 | 1588 | <div class="geodir-tabs" id="gd-tabs" style="position:relative;"> | 
| 1589 | -		<?php if ( ! $tab_list ){ ?>
 | |
| 1589 | +		<?php if (!$tab_list) { ?>
 | |
| 1590 | 1590 | <div id="geodir-tab-mobile-menu"> | 
| 1591 | 1591 | <i class="fa fa-bars"></i> | 
| 1592 | 1592 | <span class="geodir-mobile-active-tab"><?php echo $active_tab_name; ?></span> | 
| @@ -1601,26 +1601,26 @@ discard block | ||
| 1601 | 1601 | * @since 1.0.0 | 
| 1602 | 1602 | * @see 'geodir_after_tab_list' | 
| 1603 | 1603 | */ | 
| 1604 | - do_action( 'geodir_before_tab_list' ); ?> | |
| 1604 | +			do_action('geodir_before_tab_list'); ?>
 | |
| 1605 | 1605 | <?php | 
| 1606 | 1606 | |
| 1607 | -			foreach ( $arr_detail_page_tabs as $tab_index => $detail_page_tab ) {
 | |
| 1608 | -				if ( $detail_page_tab['is_display'] ) {
 | |
| 1607 | +			foreach ($arr_detail_page_tabs as $tab_index => $detail_page_tab) {
 | |
| 1608 | +				if ($detail_page_tab['is_display']) {
 | |
| 1609 | 1609 | |
| 1610 | -					if ( ! $tab_list ) {
 | |
| 1610 | +					if (!$tab_list) {
 | |
| 1611 | 1611 | ?> | 
| 1612 | 1612 | <dt></dt> <!-- added to comply with validation --> | 
| 1613 | -						<dd <?php if ( $detail_page_tab['is_active_tab'] ){ ?>class="geodir-tab-active"<?php } ?> ><a
 | |
| 1613 | +						<dd <?php if ($detail_page_tab['is_active_tab']) { ?>class="geodir-tab-active"<?php } ?> ><a
 | |
| 1614 | 1614 | data-tab="#<?php echo $tab_index; ?>" | 
| 1615 | - data-status="enable"><?php _e( $detail_page_tab['heading_text'], 'geodirectory' ); ?></a> | |
| 1615 | + data-status="enable"><?php _e($detail_page_tab['heading_text'], 'geodirectory'); ?></a> | |
| 1616 | 1616 | </dd> | 
| 1617 | 1617 | <?php | 
| 1618 | 1618 | } | 
| 1619 | 1619 | ob_start() // start tab content buffering | 
| 1620 | 1620 | ?> | 
| 1621 | 1621 | <li id="<?php echo $tab_index; ?>Tab"> | 
| 1622 | -						<?php if ( $tab_list ) {
 | |
| 1623 | - $tab_title = '<span class="gd-tab-list-title" ><a href="#' . $tab_index . '">' . __( $detail_page_tab['heading_text'], 'geodirectory' ) . '</a></span><hr />'; | |
| 1622 | +						<?php if ($tab_list) {
 | |
| 1623 | + $tab_title = '<span class="gd-tab-list-title" ><a href="#'.$tab_index.'">'.__($detail_page_tab['heading_text'], 'geodirectory').'</a></span><hr />'; | |
| 1624 | 1624 | /** | 
| 1625 | 1625 | * Filter the tab list title html. | 
| 1626 | 1626 | * | 
| @@ -1630,7 +1630,7 @@ discard block | ||
| 1630 | 1630 | * @param string $tab_index The tab index type. | 
| 1631 | 1631 | * @param array $detail_page_tab The array of values including title text. | 
| 1632 | 1632 | */ | 
| 1633 | - echo apply_filters( 'geodir_tab_list_title', $tab_title, $tab_index, $detail_page_tab ); | |
| 1633 | +							echo apply_filters('geodir_tab_list_title', $tab_title, $tab_index, $detail_page_tab);
 | |
| 1634 | 1634 | } ?> | 
| 1635 | 1635 | <div id="<?php echo $tab_index; ?>" class="hash-offset"></div> | 
| 1636 | 1636 | <?php | 
| @@ -1641,7 +1641,7 @@ discard block | ||
| 1641 | 1641 | * | 
| 1642 | 1642 | * @param string $tab_index The tab name ID. | 
| 1643 | 1643 | */ | 
| 1644 | - do_action( 'geodir_before_tab_content', $tab_index ); | |
| 1644 | +						do_action('geodir_before_tab_content', $tab_index);
 | |
| 1645 | 1645 | |
| 1646 | 1646 | /** | 
| 1647 | 1647 | * Called before the details tab content is output per tab. | 
| @@ -1651,21 +1651,21 @@ discard block | ||
| 1651 | 1651 | * @since 1.0.0 | 
| 1652 | 1652 | * @todo do we need this if we have the hook above? 'geodir_before_tab_content' | 
| 1653 | 1653 | */ | 
| 1654 | - do_action( 'geodir_before_' . $tab_index . '_tab_content' ); | |
| 1654 | +						do_action('geodir_before_'.$tab_index.'_tab_content');
 | |
| 1655 | 1655 | /// write a code to generate content of each tab | 
| 1656 | -						switch ( $tab_index ) {
 | |
| 1656 | +						switch ($tab_index) {
 | |
| 1657 | 1657 | case 'post_profile': | 
| 1658 | 1658 | /** | 
| 1659 | 1659 | * Called before the listing description content on the details page tab. | 
| 1660 | 1660 | * | 
| 1661 | 1661 | * @since 1.0.0 | 
| 1662 | 1662 | */ | 
| 1663 | - do_action( 'geodir_before_description_on_listing_detail' ); | |
| 1664 | -								if ( geodir_is_page( 'detail' ) ) {
 | |
| 1663 | +								do_action('geodir_before_description_on_listing_detail');
 | |
| 1664 | +								if (geodir_is_page('detail')) {
 | |
| 1665 | 1665 | the_content(); | 
| 1666 | 1666 |  								} else {
 | 
| 1667 | 1667 | /** This action is documented in geodirectory_template_actions.php */ | 
| 1668 | - echo apply_filters( 'the_content', stripslashes( $post->post_desc ) ); | |
| 1668 | +									echo apply_filters('the_content', stripslashes($post->post_desc));
 | |
| 1669 | 1669 | } | 
| 1670 | 1670 | |
| 1671 | 1671 | /** | 
| @@ -1673,7 +1673,7 @@ discard block | ||
| 1673 | 1673 | * | 
| 1674 | 1674 | * @since 1.0.0 | 
| 1675 | 1675 | */ | 
| 1676 | - do_action( 'geodir_after_description_on_listing_detail' ); | |
| 1676 | +								do_action('geodir_after_description_on_listing_detail');
 | |
| 1677 | 1677 | break; | 
| 1678 | 1678 | case 'post_info': | 
| 1679 | 1679 | echo $geodir_post_detail_fields; | 
| @@ -1683,21 +1683,21 @@ discard block | ||
| 1683 | 1683 | break; | 
| 1684 | 1684 | case 'post_video': | 
| 1685 | 1685 | // some browsers hide $_POST data if used for embeds so we repalce with a placeholder | 
| 1686 | -								if ( $preview ) {
 | |
| 1687 | -									if ( $video ) {
 | |
| 1688 | - echo "<span class='gd-video-embed-preview' ><p class='gd-video-preview-text'><i class=\"fa fa-video-camera\" aria-hidden=\"true\"></i><br />" . __( 'Video Preview Placeholder', 'geodirectory' ) . "</p></span>"; | |
| 1686 | +								if ($preview) {
 | |
| 1687 | +									if ($video) {
 | |
| 1688 | +										echo "<span class='gd-video-embed-preview' ><p class='gd-video-preview-text'><i class=\"fa fa-video-camera\" aria-hidden=\"true\"></i><br />".__('Video Preview Placeholder', 'geodirectory')."</p></span>";
 | |
| 1689 | 1689 | } | 
| 1690 | 1690 |  								} else {
 | 
| 1691 | 1691 | /** This action is documented in geodirectory_template_actions.php */ | 
| 1692 | - echo apply_filters( 'the_content', stripslashes( $video ) );// we apply the_content filter so oembed works also; | |
| 1692 | +									echo apply_filters('the_content', stripslashes($video)); // we apply the_content filter so oembed works also;
 | |
| 1693 | 1693 | } | 
| 1694 | 1694 | break; | 
| 1695 | 1695 | case 'special_offers': | 
| 1696 | - echo apply_filters( 'gd_special_offers_content', wpautop( stripslashes( $special_offers ) ) ); | |
| 1696 | +								echo apply_filters('gd_special_offers_content', wpautop(stripslashes($special_offers)));
 | |
| 1697 | 1697 | |
| 1698 | 1698 | break; | 
| 1699 | 1699 | case 'post_map': | 
| 1700 | - geodir_draw_map( $map_args ); | |
| 1700 | + geodir_draw_map($map_args); | |
| 1701 | 1701 | break; | 
| 1702 | 1702 | case 'reviews': | 
| 1703 | 1703 | comments_template(); | 
| @@ -1706,7 +1706,7 @@ discard block | ||
| 1706 | 1706 | echo $related_listing; | 
| 1707 | 1707 | break; | 
| 1708 | 1708 |  							default: {
 | 
| 1709 | -								if ( ( isset( $post->{$tab_index} ) || ( ! isset( $post->{$tab_index} ) && ( strpos( $tab_index, 'gd_tab_' ) !== false || $tab_index == 'link_business' ) ) ) && ! empty( $detail_page_tab['tab_content'] ) ) {
 | |
| 1709 | +								if ((isset($post->{$tab_index} ) || (!isset($post->{$tab_index} ) && (strpos($tab_index, 'gd_tab_') !== false || $tab_index == 'link_business'))) && !empty($detail_page_tab['tab_content'])) {
 | |
| 1710 | 1710 | echo $detail_page_tab['tab_content']; | 
| 1711 | 1711 | } | 
| 1712 | 1712 | } | 
| @@ -1718,7 +1718,7 @@ discard block | ||
| 1718 | 1718 | * | 
| 1719 | 1719 | * @since 1.0.0 | 
| 1720 | 1720 | */ | 
| 1721 | - do_action( 'geodir_after_tab_content', $tab_index ); | |
| 1721 | +						do_action('geodir_after_tab_content', $tab_index);
 | |
| 1722 | 1722 | |
| 1723 | 1723 | /** | 
| 1724 | 1724 | * Called after the details tab content is output per tab. | 
| @@ -1728,7 +1728,7 @@ discard block | ||
| 1728 | 1728 | * @since 1.0.0 | 
| 1729 | 1729 | * @todo do we need this if we have the hook above? 'geodir_after_tab_content' | 
| 1730 | 1730 | */ | 
| 1731 | - do_action( 'geodir_after_' . $tab_index . '_tab_content' ); | |
| 1731 | +						do_action('geodir_after_'.$tab_index.'_tab_content');
 | |
| 1732 | 1732 | ?> </li> | 
| 1733 | 1733 | <?php | 
| 1734 | 1734 | /** | 
| @@ -1736,7 +1736,7 @@ discard block | ||
| 1736 | 1736 | * | 
| 1737 | 1737 | * @since 1.0.0 | 
| 1738 | 1738 | */ | 
| 1739 | - $arr_detail_page_tabs[ $tab_index ]['tab_content'] = apply_filters( "geodir_modify_" . $detail_page_tab['tab_content'] . "_tab_content", ob_get_clean() ); | |
| 1739 | +					$arr_detail_page_tabs[$tab_index]['tab_content'] = apply_filters("geodir_modify_".$detail_page_tab['tab_content']."_tab_content", ob_get_clean());
 | |
| 1740 | 1740 | } // end of if for is_display | 
| 1741 | 1741 | }// end of foreach | 
| 1742 | 1742 | |
| @@ -1746,14 +1746,14 @@ discard block | ||
| 1746 | 1746 | * @since 1.0.0 | 
| 1747 | 1747 | * @see 'geodir_before_tab_list' | 
| 1748 | 1748 | */ | 
| 1749 | - do_action( 'geodir_after_tab_list' ); | |
| 1749 | +			do_action('geodir_after_tab_list');
 | |
| 1750 | 1750 | ?> | 
| 1751 | -			<?php if ( ! $tab_list ){ ?></dl><?php } ?>
 | |
| 1752 | -		<ul class="geodir-tabs-content entry-content <?php if ( $tab_list ) { ?>geodir-tabs-list<?php } ?>"
 | |
| 1751 | +			<?php if (!$tab_list) { ?></dl><?php } ?>
 | |
| 1752 | +		<ul class="geodir-tabs-content entry-content <?php if ($tab_list) { ?>geodir-tabs-list<?php } ?>"
 | |
| 1753 | 1753 | style="position:relative;"> | 
| 1754 | 1754 | <?php | 
| 1755 | -			foreach ( $arr_detail_page_tabs as $detail_page_tab ) {
 | |
| 1756 | -				if ( $detail_page_tab['is_display'] && ! empty( $detail_page_tab['tab_content'] ) ) {
 | |
| 1755 | +			foreach ($arr_detail_page_tabs as $detail_page_tab) {
 | |
| 1756 | +				if ($detail_page_tab['is_display'] && !empty($detail_page_tab['tab_content'])) {
 | |
| 1757 | 1757 | echo $detail_page_tab['tab_content']; | 
| 1758 | 1758 | }// end of if | 
| 1759 | 1759 | }// end of foreach | 
| @@ -1763,11 +1763,11 @@ discard block | ||
| 1763 | 1763 | * | 
| 1764 | 1764 | * @since 1.0.0 | 
| 1765 | 1765 | */ | 
| 1766 | - do_action( 'geodir_add_tab_content' ); ?> | |
| 1766 | +			do_action('geodir_add_tab_content'); ?>
 | |
| 1767 | 1767 | </ul> | 
| 1768 | 1768 | <!--gd-tabs-content ul end--> | 
| 1769 | 1769 | </div> | 
| 1770 | -	<?php if ( ! $tab_list ) { ?>
 | |
| 1770 | +	<?php if (!$tab_list) { ?>
 | |
| 1771 | 1771 | <script> | 
| 1772 | 1772 |  			if (window.location.hash && window.location.hash.indexOf('&') === -1 && jQuery(window.location.hash + 'Tab').length) {
 | 
| 1773 | 1773 | hashVal = window.location.hash; | 
| @@ -1799,31 +1799,31 @@ discard block | ||
| 1799 | 1799 | * | 
| 1800 | 1800 | * @return mixed Image file. | 
| 1801 | 1801 | */ | 
| 1802 | -function geodir_exif( $file ) {
 | |
| 1803 | -	if ( empty( $file ) || ! is_array( $file ) ) {
 | |
| 1802 | +function geodir_exif($file) {
 | |
| 1803 | +	if (empty($file) || !is_array($file)) {
 | |
| 1804 | 1804 | return $file; | 
| 1805 | 1805 | } | 
| 1806 | 1806 | |
| 1807 | - $file_path = ! empty( $file['tmp_name'] ) ? sanitize_text_field( $file['tmp_name'] ) : ''; | |
| 1808 | -	if ( ! ( $file_path && file_exists( $file_path ) ) ) {
 | |
| 1807 | + $file_path = !empty($file['tmp_name']) ? sanitize_text_field($file['tmp_name']) : ''; | |
| 1808 | +	if (!($file_path && file_exists($file_path))) {
 | |
| 1809 | 1809 | return $file; | 
| 1810 | 1810 | } | 
| 1811 | 1811 | $file['file'] = $file_path; | 
| 1812 | 1812 | |
| 1813 | -	if ( ! file_is_valid_image( $file_path ) ) {
 | |
| 1813 | +	if (!file_is_valid_image($file_path)) {
 | |
| 1814 | 1814 | return $file; // Bail if file is not an image. | 
| 1815 | 1815 | } | 
| 1816 | 1816 | |
| 1817 | -	if ( ! function_exists( 'wp_get_image_editor' ) ) {
 | |
| 1817 | +	if (!function_exists('wp_get_image_editor')) {
 | |
| 1818 | 1818 | return $file; | 
| 1819 | 1819 | } | 
| 1820 | 1820 | |
| 1821 | 1821 | $mime_type = $file['type']; | 
| 1822 | 1822 | $exif = array(); | 
| 1823 | -	if ( $mime_type == 'image/jpeg' && function_exists( 'exif_read_data' ) ) {
 | |
| 1823 | +	if ($mime_type == 'image/jpeg' && function_exists('exif_read_data')) {
 | |
| 1824 | 1824 |  		try {
 | 
| 1825 | - $exif = exif_read_data( $file_path ); | |
| 1826 | -		} catch ( Exception $e ) {
 | |
| 1825 | + $exif = exif_read_data($file_path); | |
| 1826 | +		} catch (Exception $e) {
 | |
| 1827 | 1827 | $exif = array(); | 
| 1828 | 1828 | } | 
| 1829 | 1829 | } | 
| @@ -1832,13 +1832,13 @@ discard block | ||
| 1832 | 1832 | $flip = false; | 
| 1833 | 1833 | $modify = false; | 
| 1834 | 1834 | $orientation = 0; | 
| 1835 | -	if ( ! empty( $exif ) && isset( $exif['Orientation'] ) ) {
 | |
| 1836 | -		switch ( (int) $exif['Orientation'] ) {
 | |
| 1835 | +	if (!empty($exif) && isset($exif['Orientation'])) {
 | |
| 1836 | +		switch ((int) $exif['Orientation']) {
 | |
| 1837 | 1837 | case 1: | 
| 1838 | 1838 | // do nothing | 
| 1839 | 1839 | break; | 
| 1840 | 1840 | case 2: | 
| 1841 | - $flip = array( false, true ); | |
| 1841 | + $flip = array(false, true); | |
| 1842 | 1842 | $modify = true; | 
| 1843 | 1843 | break; | 
| 1844 | 1844 | case 3: | 
| @@ -1847,13 +1847,13 @@ discard block | ||
| 1847 | 1847 | $modify = true; | 
| 1848 | 1848 | break; | 
| 1849 | 1849 | case 4: | 
| 1850 | - $flip = array( true, false ); | |
| 1850 | + $flip = array(true, false); | |
| 1851 | 1851 | $modify = true; | 
| 1852 | 1852 | break; | 
| 1853 | 1853 | case 5: | 
| 1854 | 1854 | $orientation = - 90; | 
| 1855 | 1855 | $rotate = true; | 
| 1856 | - $flip = array( false, true ); | |
| 1856 | + $flip = array(false, true); | |
| 1857 | 1857 | $modify = true; | 
| 1858 | 1858 | break; | 
| 1859 | 1859 | case 6: | 
| @@ -1864,7 +1864,7 @@ discard block | ||
| 1864 | 1864 | case 7: | 
| 1865 | 1865 | $orientation = - 270; | 
| 1866 | 1866 | $rotate = true; | 
| 1867 | - $flip = array( false, true ); | |
| 1867 | + $flip = array(false, true); | |
| 1868 | 1868 | $modify = true; | 
| 1869 | 1869 | break; | 
| 1870 | 1870 | case 8: | 
| @@ -1890,31 +1890,31 @@ discard block | ||
| 1890 | 1890 | * @param int|null $quality Image Compression quality between 1-100% scale. Default null. | 
| 1891 | 1891 | * @param string $quality Image mime type. | 
| 1892 | 1892 | */ | 
| 1893 | - $quality = apply_filters( 'geodir_image_upload_set_quality', $quality, $mime_type ); | |
| 1894 | -	if ( $quality !== null ) {
 | |
| 1893 | +	$quality = apply_filters('geodir_image_upload_set_quality', $quality, $mime_type);
 | |
| 1894 | +	if ($quality !== null) {
 | |
| 1895 | 1895 | $modify = true; | 
| 1896 | 1896 | } | 
| 1897 | 1897 | |
| 1898 | -	if ( ! $modify ) {
 | |
| 1898 | +	if (!$modify) {
 | |
| 1899 | 1899 | return $file; // no change | 
| 1900 | 1900 | } | 
| 1901 | 1901 | |
| 1902 | - $image = wp_get_image_editor( $file_path ); | |
| 1903 | -	if ( ! is_wp_error( $image ) ) {
 | |
| 1904 | -		if ( $rotate ) {
 | |
| 1905 | - $image->rotate( $orientation ); | |
| 1902 | + $image = wp_get_image_editor($file_path); | |
| 1903 | +	if (!is_wp_error($image)) {
 | |
| 1904 | +		if ($rotate) {
 | |
| 1905 | + $image->rotate($orientation); | |
| 1906 | 1906 | } | 
| 1907 | 1907 | |
| 1908 | -		if ( ! empty( $flip ) ) {
 | |
| 1909 | - $image->flip( $flip[0], $flip[1] ); | |
| 1908 | +		if (!empty($flip)) {
 | |
| 1909 | + $image->flip($flip[0], $flip[1]); | |
| 1910 | 1910 | } | 
| 1911 | 1911 | |
| 1912 | -		if ( $quality !== null ) {
 | |
| 1913 | - $image->set_quality( (int) $quality ); | |
| 1912 | +		if ($quality !== null) {
 | |
| 1913 | + $image->set_quality((int) $quality); | |
| 1914 | 1914 | } | 
| 1915 | 1915 | |
| 1916 | - $result = $image->save( $file_path ); | |
| 1917 | -		if ( ! is_wp_error( $result ) ) {
 | |
| 1916 | + $result = $image->save($file_path); | |
| 1917 | +		if (!is_wp_error($result)) {
 | |
| 1918 | 1918 | $file['file'] = $result['path']; | 
| 1919 | 1919 | $file['tmp_name'] = $result['path']; | 
| 1920 | 1920 | } | 
| @@ -1941,7 +1941,7 @@ discard block | ||
| 1941 | 1941 | * | 
| 1942 | 1942 | * @return string Returns the recent reviews html. | 
| 1943 | 1943 | */ | 
| 1944 | -function geodir_get_recent_reviews( $g_size = 60, $no_comments = 10, $comment_lenth = 60, $show_pass_post = false ) {
 | |
| 1944 | +function geodir_get_recent_reviews($g_size = 60, $no_comments = 10, $comment_lenth = 60, $show_pass_post = false) {
 | |
| 1945 | 1945 | global $wpdb, $tablecomments, $tableposts, $rating_table_name, $gd_session; | 
| 1946 | 1946 | $tablecomments = $wpdb->comments; | 
| 1947 | 1947 | $tableposts = $wpdb->posts; | 
| @@ -1951,28 +1951,28 @@ discard block | ||
| 1951 | 1951 | $region_filter = ''; | 
| 1952 | 1952 | $country_filter = ''; | 
| 1953 | 1953 | |
| 1954 | -	if ( $gd_session->get( 'gd_multi_location' ) ) {
 | |
| 1955 | -		if ( $gd_ses_country = $gd_session->get( 'gd_country' ) ) {
 | |
| 1956 | - $country_filter = $wpdb->prepare( " AND r.post_country=%s ", str_replace( "-", " ", $gd_ses_country ) ); | |
| 1954 | +	if ($gd_session->get('gd_multi_location')) {
 | |
| 1955 | +		if ($gd_ses_country = $gd_session->get('gd_country')) {
 | |
| 1956 | +			$country_filter = $wpdb->prepare(" AND r.post_country=%s ", str_replace("-", " ", $gd_ses_country));
 | |
| 1957 | 1957 | } | 
| 1958 | 1958 | |
| 1959 | -		if ( $gd_ses_region = $gd_session->get( 'gd_region' ) ) {
 | |
| 1960 | - $region_filter = $wpdb->prepare( " AND r.post_region=%s ", str_replace( "-", " ", $gd_ses_region ) ); | |
| 1959 | +		if ($gd_ses_region = $gd_session->get('gd_region')) {
 | |
| 1960 | +			$region_filter = $wpdb->prepare(" AND r.post_region=%s ", str_replace("-", " ", $gd_ses_region));
 | |
| 1961 | 1961 | } | 
| 1962 | 1962 | |
| 1963 | -		if ( $gd_ses_city = $gd_session->get( 'gd_city' ) ) {
 | |
| 1964 | - $city_filter = $wpdb->prepare( " AND r.post_city=%s ", str_replace( "-", " ", $gd_ses_city ) ); | |
| 1963 | +		if ($gd_ses_city = $gd_session->get('gd_city')) {
 | |
| 1964 | +			$city_filter = $wpdb->prepare(" AND r.post_city=%s ", str_replace("-", " ", $gd_ses_city));
 | |
| 1965 | 1965 | } | 
| 1966 | 1966 | } | 
| 1967 | 1967 | |
| 1968 | 1968 | $review_table = GEODIR_REVIEW_TABLE; | 
| 1969 | 1969 | $request = "SELECT r.id as ID, r.post_type, r.comment_id as comment_ID, r.post_date as comment_date,r.overall_rating, r.user_id, r.post_id FROM $review_table as r WHERE r.post_status = 1 AND r.status =1 AND r.overall_rating>=1 $country_filter $region_filter $city_filter ORDER BY r.post_date DESC, r.id DESC LIMIT $no_comments"; | 
| 1970 | 1970 | |
| 1971 | - $comments = $wpdb->get_results( $request ); | |
| 1971 | + $comments = $wpdb->get_results($request); | |
| 1972 | 1972 | |
| 1973 | -	foreach ( $comments as $comment ) {
 | |
| 1973 | +	foreach ($comments as $comment) {
 | |
| 1974 | 1974 | // Set the extra comment info needed. | 
| 1975 | - $comment_extra = $wpdb->get_row( "SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID" ); | |
| 1975 | +		$comment_extra = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID");
 | |
| 1976 | 1976 | //echo "SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID"; | 
| 1977 | 1977 | $comment->comment_content = $comment_extra->comment_content; | 
| 1978 | 1978 | $comment->comment_author = $comment_extra->comment_author; | 
| @@ -1980,75 +1980,75 @@ discard block | ||
| 1980 | 1980 | |
| 1981 | 1981 | $comment_id = ''; | 
| 1982 | 1982 | $comment_id = $comment->comment_ID; | 
| 1983 | - $comment_content = strip_tags( $comment->comment_content ); | |
| 1983 | + $comment_content = strip_tags($comment->comment_content); | |
| 1984 | 1984 | |
| 1985 | - $comment_content = preg_replace( '#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_content ); | |
| 1985 | +		$comment_content = preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_content);
 | |
| 1986 | 1986 | |
| 1987 | - $permalink = get_permalink( $comment->ID ) . "#comment-" . $comment->comment_ID; | |
| 1987 | + $permalink = get_permalink($comment->ID)."#comment-".$comment->comment_ID; | |
| 1988 | 1988 | $comment_author_email = $comment->comment_author_email; | 
| 1989 | 1989 | $comment_post_ID = $comment->post_id; | 
| 1990 | 1990 | |
| 1991 | 1991 | $na = true; | 
| 1992 | -		if ( function_exists( 'icl_object_id' ) && icl_object_id( $comment_post_ID, $comment->post_type, true ) ) {
 | |
| 1993 | - $comment_post_ID2 = icl_object_id( $comment_post_ID, $comment->post_type, false ); | |
| 1994 | -			if ( $comment_post_ID == $comment_post_ID2 ) {
 | |
| 1992 | +		if (function_exists('icl_object_id') && icl_object_id($comment_post_ID, $comment->post_type, true)) {
 | |
| 1993 | + $comment_post_ID2 = icl_object_id($comment_post_ID, $comment->post_type, false); | |
| 1994 | +			if ($comment_post_ID == $comment_post_ID2) {
 | |
| 1995 | 1995 |  			} else {
 | 
| 1996 | 1996 | $na = false; | 
| 1997 | 1997 | } | 
| 1998 | 1998 | } | 
| 1999 | 1999 | |
| 2000 | - $post_title = get_the_title( $comment_post_ID ); | |
| 2001 | - $permalink = get_permalink( $comment_post_ID ); | |
| 2002 | - $comment_permalink = $permalink . "#comment-" . $comment->comment_ID; | |
| 2003 | - $read_more = '<a class="comment_excerpt" href="' . $comment_permalink . '">' . __( 'Read more', 'geodirectory' ) . '</a>'; | |
| 2000 | + $post_title = get_the_title($comment_post_ID); | |
| 2001 | + $permalink = get_permalink($comment_post_ID); | |
| 2002 | + $comment_permalink = $permalink."#comment-".$comment->comment_ID; | |
| 2003 | +		$read_more         = '<a class="comment_excerpt" href="'.$comment_permalink.'">'.__('Read more', 'geodirectory').'</a>';
 | |
| 2004 | 2004 | |
| 2005 | - $comment_content_length = strlen( $comment_content ); | |
| 2006 | -		if ( $comment_content_length > $comment_lenth ) {
 | |
| 2007 | - $comment_excerpt = mb_substr( $comment_content, 0, $comment_lenth ) . '... ' . $read_more; | |
| 2005 | + $comment_content_length = strlen($comment_content); | |
| 2006 | +		if ($comment_content_length > $comment_lenth) {
 | |
| 2007 | + $comment_excerpt = mb_substr($comment_content, 0, $comment_lenth).'... '.$read_more; | |
| 2008 | 2008 |  		} else {
 | 
| 2009 | 2009 | $comment_excerpt = $comment_content; | 
| 2010 | 2010 | } | 
| 2011 | 2011 | |
| 2012 | -		if ( $comment->user_id ) {
 | |
| 2013 | - $user_profile_url = get_author_posts_url( $comment->user_id ); | |
| 2012 | +		if ($comment->user_id) {
 | |
| 2013 | + $user_profile_url = get_author_posts_url($comment->user_id); | |
| 2014 | 2014 |  		} else {
 | 
| 2015 | 2015 | $user_profile_url = ''; | 
| 2016 | 2016 | } | 
| 2017 | 2017 | |
| 2018 | -		if ( $comment_id && $na ) {
 | |
| 2018 | +		if ($comment_id && $na) {
 | |
| 2019 | 2019 | $comments_echo .= '<li class="clearfix">'; | 
| 2020 | - $comments_echo .= "<span class=\"li" . $comment_id . " geodir_reviewer_image\">"; | |
| 2021 | -			if ( function_exists( 'get_avatar' ) ) {
 | |
| 2022 | -				if ( ! isset( $comment->comment_type ) ) {
 | |
| 2023 | -					if ( $user_profile_url ) {
 | |
| 2024 | - $comments_echo .= '<a href="' . $user_profile_url . '">'; | |
| 2020 | + $comments_echo .= "<span class=\"li".$comment_id." geodir_reviewer_image\">"; | |
| 2021 | +			if (function_exists('get_avatar')) {
 | |
| 2022 | +				if (!isset($comment->comment_type)) {
 | |
| 2023 | +					if ($user_profile_url) {
 | |
| 2024 | + $comments_echo .= '<a href="'.$user_profile_url.'">'; | |
| 2025 | 2025 | } | 
| 2026 | - $comments_echo .= get_avatar( $comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png' ); | |
| 2027 | -					if ( $user_profile_url ) {
 | |
| 2026 | + $comments_echo .= get_avatar($comment->comment_author_email, $g_size, geodir_plugin_url().'/geodirectory-assets/images/gravatar2.png'); | |
| 2027 | +					if ($user_profile_url) {
 | |
| 2028 | 2028 | $comments_echo .= '</a>'; | 
| 2029 | 2029 | } | 
| 2030 | -				} elseif ( ( isset( $comment->comment_type ) && $comment->comment_type == 'trackback' ) || ( isset( $comment->comment_type ) && $comment->comment_type == 'pingback' ) ) {
 | |
| 2031 | -					if ( $user_profile_url ) {
 | |
| 2032 | - $comments_echo .= '<a href="' . $user_profile_url . '">'; | |
| 2030 | +				} elseif ((isset($comment->comment_type) && $comment->comment_type == 'trackback') || (isset($comment->comment_type) && $comment->comment_type == 'pingback')) {
 | |
| 2031 | +					if ($user_profile_url) {
 | |
| 2032 | + $comments_echo .= '<a href="'.$user_profile_url.'">'; | |
| 2033 | 2033 | } | 
| 2034 | - $comments_echo .= get_avatar( $comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png' ); | |
| 2034 | + $comments_echo .= get_avatar($comment->comment_author_url, $g_size, geodir_plugin_url().'/geodirectory-assets/images/gravatar2.png'); | |
| 2035 | 2035 | } | 
| 2036 | -			} elseif ( function_exists( 'gravatar' ) ) {
 | |
| 2037 | -				if ( $user_profile_url ) {
 | |
| 2038 | - $comments_echo .= '<a href="' . $user_profile_url . '">'; | |
| 2036 | +			} elseif (function_exists('gravatar')) {
 | |
| 2037 | +				if ($user_profile_url) {
 | |
| 2038 | + $comments_echo .= '<a href="'.$user_profile_url.'">'; | |
| 2039 | 2039 | } | 
| 2040 | 2040 | $comments_echo .= "<img src=\""; | 
| 2041 | -				if ( '' == $comment->comment_type ) {
 | |
| 2042 | - $comments_echo .= gravatar( $comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png' ); | |
| 2043 | -					if ( $user_profile_url ) {
 | |
| 2041 | +				if ('' == $comment->comment_type) {
 | |
| 2042 | + $comments_echo .= gravatar($comment->comment_author_email, $g_size, geodir_plugin_url().'/geodirectory-assets/images/gravatar2.png'); | |
| 2043 | +					if ($user_profile_url) {
 | |
| 2044 | 2044 | $comments_echo .= '</a>'; | 
| 2045 | 2045 | } | 
| 2046 | -				} elseif ( ( 'trackback' == $comment->comment_type ) || ( 'pingback' == $comment->comment_type ) ) {
 | |
| 2047 | -					if ( $user_profile_url ) {
 | |
| 2048 | - $comments_echo .= '<a href="' . $user_profile_url . '">'; | |
| 2046 | +				} elseif (('trackback' == $comment->comment_type) || ('pingback' == $comment->comment_type)) {
 | |
| 2047 | +					if ($user_profile_url) {
 | |
| 2048 | + $comments_echo .= '<a href="'.$user_profile_url.'">'; | |
| 2049 | 2049 | } | 
| 2050 | - $comments_echo .= gravatar( $comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png' ); | |
| 2051 | -					if ( $user_profile_url ) {
 | |
| 2050 | + $comments_echo .= gravatar($comment->comment_author_url, $g_size, geodir_plugin_url().'/geodirectory-assets/images/gravatar2.png'); | |
| 2051 | +					if ($user_profile_url) {
 | |
| 2052 | 2052 | $comments_echo .= '</a>'; | 
| 2053 | 2053 | } | 
| 2054 | 2054 | } | 
| @@ -2058,17 +2058,17 @@ discard block | ||
| 2058 | 2058 | $comments_echo .= "</span>\n"; | 
| 2059 | 2059 | |
| 2060 | 2060 | $comments_echo .= '<span class="geodir_reviewer_content">'; | 
| 2061 | -			if ( $comment->user_id ) {
 | |
| 2062 | - $comments_echo .= '<a href="' . get_author_posts_url( $comment->user_id ) . '">'; | |
| 2061 | +			if ($comment->user_id) {
 | |
| 2062 | + $comments_echo .= '<a href="'.get_author_posts_url($comment->user_id).'">'; | |
| 2063 | 2063 | } | 
| 2064 | - $comments_echo .= '<span class="geodir_reviewer_author">' . $comment->comment_author . '</span> '; | |
| 2065 | -			if ( $comment->user_id ) {
 | |
| 2064 | + $comments_echo .= '<span class="geodir_reviewer_author">'.$comment->comment_author.'</span> '; | |
| 2065 | +			if ($comment->user_id) {
 | |
| 2066 | 2066 | $comments_echo .= '</a>'; | 
| 2067 | 2067 | } | 
| 2068 | - $comments_echo .= '<span class="geodir_reviewer_reviewed">' . __( 'reviewed', 'geodirectory' ) . '</span> '; | |
| 2069 | - $comments_echo .= '<a href="' . $permalink . '" class="geodir_reviewer_title">' . $post_title . '</a>'; | |
| 2070 | - $comments_echo .= geodir_get_rating_stars( $comment->overall_rating, $comment_post_ID ); | |
| 2071 | - $comments_echo .= '<p class="geodir_reviewer_text">' . $comment_excerpt . ''; | |
| 2068 | +			$comments_echo .= '<span class="geodir_reviewer_reviewed">'.__('reviewed', 'geodirectory').'</span> ';
 | |
| 2069 | + $comments_echo .= '<a href="'.$permalink.'" class="geodir_reviewer_title">'.$post_title.'</a>'; | |
| 2070 | + $comments_echo .= geodir_get_rating_stars($comment->overall_rating, $comment_post_ID); | |
| 2071 | + $comments_echo .= '<p class="geodir_reviewer_text">'.$comment_excerpt.''; | |
| 2072 | 2072 |  			//echo preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_excerpt);
 | 
| 2073 | 2073 | $comments_echo .= '</p>'; | 
| 2074 | 2074 | |
| @@ -2088,25 +2088,25 @@ discard block | ||
| 2088 | 2088 | * @return array Returns post categories as an array. | 
| 2089 | 2089 | */ | 
| 2090 | 2090 |  function geodir_home_map_cats_key_value_array() {
 | 
| 2091 | - $post_types = geodir_get_posttypes( 'object' ); | |
| 2091 | +	$post_types = geodir_get_posttypes('object');
 | |
| 2092 | 2092 | |
| 2093 | 2093 | $return = array(); | 
| 2094 | -	if ( ! empty( $post_types ) ) {
 | |
| 2095 | -		foreach ( $post_types as $key => $post_type ) {
 | |
| 2096 | - $cpt_name = __( $post_type->labels->singular_name, 'geodirectory' ); | |
| 2097 | - $post_type_name = sprintf( __( '%s Categories', 'geodirectory' ), $cpt_name ); | |
| 2098 | - $taxonomies = geodir_get_taxonomies( $key ); | |
| 2099 | - $cat_taxonomy = ! empty( $taxonomies[0] ) ? $taxonomies[0] : null; | |
| 2100 | - $cat_terms = $cat_taxonomy ? get_terms( $cat_taxonomy ) : null; | |
| 2101 | - | |
| 2102 | -			if ( ! empty( $cat_terms ) ) {
 | |
| 2103 | - $return[ 'optgroup_start-' . $key ] = $post_type_name; | |
| 2104 | - | |
| 2105 | -				foreach ( $cat_terms as $cat_term ) {
 | |
| 2106 | - $return[ $key . '_' . $cat_term->term_id ] = $cat_term->name; | |
| 2094 | +	if (!empty($post_types)) {
 | |
| 2095 | +		foreach ($post_types as $key => $post_type) {
 | |
| 2096 | + $cpt_name = __($post_type->labels->singular_name, 'geodirectory'); | |
| 2097 | +			$post_type_name = sprintf(__('%s Categories', 'geodirectory'), $cpt_name);
 | |
| 2098 | + $taxonomies = geodir_get_taxonomies($key); | |
| 2099 | + $cat_taxonomy = !empty($taxonomies[0]) ? $taxonomies[0] : null; | |
| 2100 | + $cat_terms = $cat_taxonomy ? get_terms($cat_taxonomy) : null; | |
| 2101 | + | |
| 2102 | +			if (!empty($cat_terms)) {
 | |
| 2103 | + $return['optgroup_start-'.$key] = $post_type_name; | |
| 2104 | + | |
| 2105 | +				foreach ($cat_terms as $cat_term) {
 | |
| 2106 | + $return[$key.'_'.$cat_term->term_id] = $cat_term->name; | |
| 2107 | 2107 | } | 
| 2108 | 2108 | |
| 2109 | - $return[ 'optgroup_end-' . $key ] = $post_type_name; | |
| 2109 | + $return['optgroup_end-'.$key] = $post_type_name; | |
| 2110 | 2110 | } | 
| 2111 | 2111 | } | 
| 2112 | 2112 | } | 
| @@ -2122,14 +2122,14 @@ discard block | ||
| 2122 | 2122 | * @package GeoDirectory | 
| 2123 | 2123 | */ | 
| 2124 | 2124 |  function geodir_twitter_tweet_button() {
 | 
| 2125 | -	if ( isset( $_GET['gde'] ) ) {
 | |
| 2126 | - $link = '?url=' . urlencode( geodir_curPageURL() ); | |
| 2125 | +	if (isset($_GET['gde'])) {
 | |
| 2126 | + $link = '?url='.urlencode(geodir_curPageURL()); | |
| 2127 | 2127 |  	} else {
 | 
| 2128 | 2128 | $link = ''; | 
| 2129 | 2129 | } | 
| 2130 | 2130 | ?> | 
| 2131 | 2131 | <a href="http://twitter.com/share<?php echo $link; ?>" | 
| 2132 | - class="twitter-share-button"><?php _e( 'Tweet', 'geodirectory' ); ?></a> | |
| 2132 | +	   class="twitter-share-button"><?php _e('Tweet', 'geodirectory'); ?></a>
 | |
| 2133 | 2133 | <script type="text/javascript" src="//platform.twitter.com/widgets.js"></script> | 
| 2134 | 2134 | <?php | 
| 2135 | 2135 | } | 
| @@ -2146,10 +2146,10 @@ discard block | ||
| 2146 | 2146 |  function geodir_fb_like_button() {
 | 
| 2147 | 2147 | global $post; | 
| 2148 | 2148 | ?> | 
| 2149 | -	<iframe <?php if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false ) ) {
 | |
| 2149 | +	<iframe <?php if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) {
 | |
| 2150 | 2150 | echo 'allowtransparency="true"'; | 
| 2151 | 2151 | } ?> class="facebook" | 
| 2152 | - src="//www.facebook.com/plugins/like.php?href=<?php echo urlencode( get_permalink( $post->ID ) ); ?>&layout=button_count&show_faces=false&width=100&action=like&colorscheme=light" | |
| 2152 | + src="//www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&layout=button_count&show_faces=false&width=100&action=like&colorscheme=light" | |
| 2153 | 2153 | style="border:none; overflow:hidden; width:100px; height:20px"></iframe> | 
| 2154 | 2154 | <?php | 
| 2155 | 2155 | } | 
| @@ -2203,10 +2203,10 @@ discard block | ||
| 2203 | 2203 |  			stWidget.addEntry({
 | 
| 2204 | 2204 | "service": "sharethis", | 
| 2205 | 2205 |  				"element": document.getElementById('st_sharethis'),
 | 
| 2206 | - "url": "<?php echo geodir_curPageURL();?>", | |
| 2207 | - "title": "<?php echo $post->post_title;?>", | |
| 2206 | + "url": "<?php echo geodir_curPageURL(); ?>", | |
| 2207 | + "title": "<?php echo $post->post_title; ?>", | |
| 2208 | 2208 | "type": "chicklet", | 
| 2209 | - "text": "<?php _e( 'Share', 'geodirectory' );?>" | |
| 2209 | +				"text": "<?php _e('Share', 'geodirectory'); ?>"
 | |
| 2210 | 2210 | }); | 
| 2211 | 2211 | </script> | 
| 2212 | 2212 | </div> | 
| @@ -2214,7 +2214,7 @@ discard block | ||
| 2214 | 2214 | } | 
| 2215 | 2215 | |
| 2216 | 2216 |  function geodir_listing_bounce_map_pin_on_hover() {
 | 
| 2217 | -	if ( get_option( 'geodir_listing_hover_bounce_map_pin', true ) ) {
 | |
| 2217 | +	if (get_option('geodir_listing_hover_bounce_map_pin', true)) {
 | |
| 2218 | 2218 | ?> | 
| 2219 | 2219 | <script> | 
| 2220 | 2220 |  			jQuery(function ($) {
 | 
| @@ -2237,44 +2237,44 @@ discard block | ||
| 2237 | 2237 | } | 
| 2238 | 2238 | } | 
| 2239 | 2239 | |
| 2240 | -add_action( 'geodir_after_listing_listview', 'geodir_listing_bounce_map_pin_on_hover', 10 ); | |
| 2240 | +add_action('geodir_after_listing_listview', 'geodir_listing_bounce_map_pin_on_hover', 10);
 | |
| 2241 | 2241 | |
| 2242 | -add_action( 'geodir_after_favorite_html', 'geodir_output_favourite_html_listings', 1, 1 ); | |
| 2243 | -function geodir_output_favourite_html_listings( $post_id ) {
 | |
| 2244 | - geodir_favourite_html( '', $post_id ); | |
| 2242 | +add_action('geodir_after_favorite_html', 'geodir_output_favourite_html_listings', 1, 1);
 | |
| 2243 | +function geodir_output_favourite_html_listings($post_id) {
 | |
| 2244 | +	geodir_favourite_html('', $post_id);
 | |
| 2245 | 2245 | } | 
| 2246 | 2246 | |
| 2247 | -add_action( 'geodir_listing_after_pinpoint', 'geodir_output_pinpoint_html_listings', 1, 2 ); | |
| 2248 | -function geodir_output_pinpoint_html_listings( $post_id, $post ) {
 | |
| 2247 | +add_action('geodir_listing_after_pinpoint', 'geodir_output_pinpoint_html_listings', 1, 2);
 | |
| 2248 | +function geodir_output_pinpoint_html_listings($post_id, $post) {
 | |
| 2249 | 2249 | global $wp_query; | 
| 2250 | 2250 | |
| 2251 | 2251 | $show_pin_point = $wp_query->is_main_query(); | 
| 2252 | 2252 | |
| 2253 | -	if ( ! empty( $show_pin_point ) && is_active_widget( false, "", "geodir_map_v3_listing_map" ) ) {
 | |
| 2254 | - $term_icon_url = get_tax_meta( $post->default_category, 'ct_cat_icon', false, $post->post_type ); | |
| 2255 | - $marker_icon = isset( $term_icon_url['src'] ) ? $term_icon_url['src'] : get_option( 'geodir_default_marker_icon' ); | |
| 2253 | +	if (!empty($show_pin_point) && is_active_widget(false, "", "geodir_map_v3_listing_map")) {
 | |
| 2254 | + $term_icon_url = get_tax_meta($post->default_category, 'ct_cat_icon', false, $post->post_type); | |
| 2255 | +		$marker_icon   = isset($term_icon_url['src']) ? $term_icon_url['src'] : get_option('geodir_default_marker_icon');
 | |
| 2256 | 2256 | ?> | 
| 2257 | 2257 | <span class="geodir-pinpoint" | 
| 2258 | -		      style="background:url('<?php echo $marker_icon; ?>') no-repeat scroll left top transparent;background-size:auto 100%; -webkit-background-size:auto 100%;-moz-background-size:auto 100%;height:9px;width:14px;"><?php echo apply_filters( 'geodir_listing_listview_pinpoint_inner_content', '', 'listing' ); ?></span>
 | |
| 2258 | +		      style="background:url('<?php echo $marker_icon; ?>') no-repeat scroll left top transparent;background-size:auto 100%; -webkit-background-size:auto 100%;-moz-background-size:auto 100%;height:9px;width:14px;"><?php echo apply_filters('geodir_listing_listview_pinpoint_inner_content', '', 'listing'); ?></span>
 | |
| 2259 | 2259 | <a class="geodir-pinpoint-link" href="javascript:void(0)" | 
| 2260 | 2260 |  		   onclick="openMarker('listing_map_canvas' ,'<?php echo $post->ID; ?>')"
 | 
| 2261 | 2261 |  		   onmouseover="animate_marker('listing_map_canvas' ,'<?php echo $post->ID; ?>')"
 | 
| 2262 | -		   onmouseout="stop_marker_animation('listing_map_canvas' ,'<?php echo $post->ID; ?>')"><?php _e( 'Pinpoint', 'geodirectory' ); ?></a>
 | |
| 2262 | +		   onmouseout="stop_marker_animation('listing_map_canvas' ,'<?php echo $post->ID; ?>')"><?php _e('Pinpoint', 'geodirectory'); ?></a>
 | |
| 2263 | 2263 | <?php | 
| 2264 | 2264 | } | 
| 2265 | 2265 | } | 
| 2266 | 2266 | |
| 2267 | 2267 |  function geodir_search_form_submit_button() {
 | 
| 2268 | 2268 | |
| 2269 | - $new_style = get_option( 'geodir_show_search_old_search_from' ) ? false : true; | |
| 2269 | +	$new_style = get_option('geodir_show_search_old_search_from') ? false : true;
 | |
| 2270 | 2270 | |
| 2271 | -	if ( $new_style ) {
 | |
| 2271 | +	if ($new_style) {
 | |
| 2272 | 2272 | $default_search_button_label = '<i class="fa fa-search" aria-hidden="true"></i>'; | 
| 2273 | -	}else{
 | |
| 2273 | +	} else {
 | |
| 2274 | 2274 | $default_search_button_label = 'Search'; | 
| 2275 | 2275 | } | 
| 2276 | -	if ( get_option( 'geodir_search_button_label' ) && get_option( 'geodir_search_button_label' ) != 'Search' ) {
 | |
| 2277 | - $default_search_button_label = __( get_option( 'geodir_search_button_label' ), 'geodirectory' ); | |
| 2276 | +	if (get_option('geodir_search_button_label') && get_option('geodir_search_button_label') != 'Search') {
 | |
| 2277 | +		$default_search_button_label = __(get_option('geodir_search_button_label'), 'geodirectory');
 | |
| 2278 | 2278 | } | 
| 2279 | 2279 | |
| 2280 | 2280 | /** | 
| @@ -2286,47 +2286,47 @@ discard block | ||
| 2286 | 2286 | * | 
| 2287 | 2287 | * @param string $default_search_button_label The current search button text. | 
| 2288 | 2288 | */ | 
| 2289 | - $default_search_button_label = apply_filters( 'geodir_search_default_search_button_text', $default_search_button_label ); | |
| 2289 | +	$default_search_button_label = apply_filters('geodir_search_default_search_button_text', $default_search_button_label);
 | |
| 2290 | 2290 | |
| 2291 | 2291 | $fa_class = ''; | 
| 2292 | -	if ( strpos( $default_search_button_label, '&#' ) !== false ) {
 | |
| 2292 | +	if (strpos($default_search_button_label, '&#') !== false) {
 | |
| 2293 | 2293 | $fa_class = 'fa'; | 
| 2294 | 2294 | } | 
| 2295 | 2295 | |
| 2296 | 2296 | |
| 2297 | -	if ( $new_style ) {
 | |
| 2297 | +	if ($new_style) {
 | |
| 2298 | 2298 | ?> | 
| 2299 | - <button class="geodir_submit_search <?php echo $fa_class; ?>"><?php _e( $default_search_button_label ,'geodirectory'); ?></button> | |
| 2300 | -<?php }else{?>
 | |
| 2301 | - <input type="button" value="<?php esc_attr_e( $default_search_button_label ); ?>" | |
| 2299 | + <button class="geodir_submit_search <?php echo $fa_class; ?>"><?php _e($default_search_button_label, 'geodirectory'); ?></button> | |
| 2300 | +<?php } else {?>
 | |
| 2301 | + <input type="button" value="<?php esc_attr_e($default_search_button_label); ?>" | |
| 2302 | 2302 | class="geodir_submit_search <?php echo $fa_class; ?>"/> | 
| 2303 | 2303 | <?php } | 
| 2304 | 2304 | } | 
| 2305 | 2305 | |
| 2306 | -add_action( 'geodir_before_search_button', 'geodir_search_form_submit_button', 5000 ); | |
| 2306 | +add_action('geodir_before_search_button', 'geodir_search_form_submit_button', 5000);
 | |
| 2307 | 2307 | |
| 2308 | 2308 |  function geodir_search_form_post_type_input() {
 | 
| 2309 | - $post_types = apply_filters( 'geodir_search_form_post_types', geodir_get_posttypes( 'object' ) ); | |
| 2309 | +	$post_types     = apply_filters('geodir_search_form_post_types', geodir_get_posttypes('object'));
 | |
| 2310 | 2310 | $curr_post_type = geodir_get_current_posttype(); | 
| 2311 | -	if ( ! empty( $post_types ) && count( (array) $post_types ) > 1 ) {
 | |
| 2311 | +	if (!empty($post_types) && count((array) $post_types) > 1) {
 | |
| 2312 | 2312 | |
| 2313 | -		foreach ( $post_types as $post_type => $info ){
 | |
| 2313 | +		foreach ($post_types as $post_type => $info) {
 | |
| 2314 | 2314 | global $wpdb; | 
| 2315 | - $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) ); | |
| 2316 | -			if ( ! $has_posts ) {
 | |
| 2315 | +			$has_posts = $wpdb->get_row($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type));
 | |
| 2316 | +			if (!$has_posts) {
 | |
| 2317 | 2317 |  				unset($post_types->{$post_type});
 | 
| 2318 | 2318 | } | 
| 2319 | 2319 | } | 
| 2320 | 2320 | |
| 2321 | -		if ( ! empty( $post_types ) && count( (array) $post_types ) > 1 ) {
 | |
| 2321 | +		if (!empty($post_types) && count((array) $post_types) > 1) {
 | |
| 2322 | 2322 | |
| 2323 | - $new_style = get_option( 'geodir_show_search_old_search_from' ) ? false : true; | |
| 2324 | -			if ( $new_style ) {
 | |
| 2323 | +			$new_style = get_option('geodir_show_search_old_search_from') ? false : true;
 | |
| 2324 | +			if ($new_style) {
 | |
| 2325 | 2325 | echo "<div class='gd-search-input-wrapper gd-search-field-cpt'>"; | 
| 2326 | 2326 | } | 
| 2327 | 2327 | ?> | 
| 2328 | 2328 | <select name="stype" class="search_by_post"> | 
| 2329 | - <?php foreach ( $post_types as $post_type => $info ): | |
| 2329 | + <?php foreach ($post_types as $post_type => $info): | |
| 2330 | 2330 | global $wpdb; | 
| 2331 | 2331 | // $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) ); | 
| 2332 | 2332 |  //					if ( ! $has_posts ) {
 | 
| @@ -2334,58 +2334,58 @@ discard block | ||
| 2334 | 2334 | // } | 
| 2335 | 2335 | ?> | 
| 2336 | 2336 | |
| 2337 | - <option data-label="<?php echo get_post_type_archive_link( $post_type ); ?>" | |
| 2338 | -					        value="<?php echo $post_type; ?>" <?php if ( isset( $_REQUEST['stype'] ) ) {
 | |
| 2339 | -						if ( $post_type == $_REQUEST['stype'] ) {
 | |
| 2337 | + <option data-label="<?php echo get_post_type_archive_link($post_type); ?>" | |
| 2338 | +					        value="<?php echo $post_type; ?>" <?php if (isset($_REQUEST['stype'])) {
 | |
| 2339 | +						if ($post_type == $_REQUEST['stype']) {
 | |
| 2340 | 2340 | echo 'selected="selected"'; | 
| 2341 | 2341 | } | 
| 2342 | -					} elseif ( $curr_post_type == $post_type ) {
 | |
| 2342 | +					} elseif ($curr_post_type == $post_type) {
 | |
| 2343 | 2343 | echo 'selected="selected"'; | 
| 2344 | - } ?>><?php _e( ucfirst( $info->labels->name ), 'geodirectory' ); ?></option> | |
| 2344 | + } ?>><?php _e(ucfirst($info->labels->name), 'geodirectory'); ?></option> | |
| 2345 | 2345 | |
| 2346 | 2346 | <?php endforeach; ?> | 
| 2347 | 2347 | </select> | 
| 2348 | 2348 | <?php | 
| 2349 | -			if ( $new_style ) {
 | |
| 2349 | +			if ($new_style) {
 | |
| 2350 | 2350 | echo "</div>"; | 
| 2351 | 2351 | } | 
| 2352 | -		}else{
 | |
| 2353 | -			if(! empty( $post_types )){
 | |
| 2354 | - echo '<input type="hidden" name="stype" value="' . key( $post_types ) . '" />'; | |
| 2355 | -			}else{
 | |
| 2352 | +		} else {
 | |
| 2353 | +			if (!empty($post_types)) {
 | |
| 2354 | + echo '<input type="hidden" name="stype" value="'.key($post_types).'" />'; | |
| 2355 | +			} else {
 | |
| 2356 | 2356 | echo '<input type="hidden" name="stype" value="gd_place" />'; | 
| 2357 | 2357 | } | 
| 2358 | 2358 | |
| 2359 | 2359 | } | 
| 2360 | 2360 | |
| 2361 | -	}elseif ( ! empty( $post_types ) ) {
 | |
| 2362 | - echo '<input type="hidden" name="stype" value="' . key( $post_types ) . '" />'; | |
| 2361 | +	}elseif (!empty($post_types)) {
 | |
| 2362 | + echo '<input type="hidden" name="stype" value="'.key($post_types).'" />'; | |
| 2363 | 2363 | } | 
| 2364 | 2364 | } | 
| 2365 | 2365 | |
| 2366 | 2366 |  function geodir_search_form_search_input() {
 | 
| 2367 | 2367 | |
| 2368 | 2368 | $default_search_for_text = SEARCH_FOR_TEXT; | 
| 2369 | -	if ( get_option( 'geodir_search_field_default_text' ) ) {
 | |
| 2370 | - $default_search_for_text = __( get_option( 'geodir_search_field_default_text' ), 'geodirectory' ); | |
| 2369 | +	if (get_option('geodir_search_field_default_text')) {
 | |
| 2370 | +		$default_search_for_text = __(get_option('geodir_search_field_default_text'), 'geodirectory');
 | |
| 2371 | 2371 | } | 
| 2372 | 2372 | |
| 2373 | 2373 |  	$new_style = get_option('geodir_show_search_old_search_from') ? false : true;
 | 
| 2374 | -	if($new_style){
 | |
| 2374 | +	if ($new_style) {
 | |
| 2375 | 2375 | echo "<div class='gd-search-input-wrapper gd-search-field-search'>"; | 
| 2376 | 2376 | } | 
| 2377 | 2377 | ?> | 
| 2378 | 2378 | <input class="search_text" name="s" | 
| 2379 | -	       value="<?php if ( isset( $_REQUEST['s'] ) && trim( $_REQUEST['s'] ) != '' ) {
 | |
| 2380 | - echo esc_attr( stripslashes_deep( $_REQUEST['s'] ) ); | |
| 2379 | +	       value="<?php if (isset($_REQUEST['s']) && trim($_REQUEST['s']) != '') {
 | |
| 2380 | + echo esc_attr(stripslashes_deep($_REQUEST['s'])); | |
| 2381 | 2381 |  	       } else {
 | 
| 2382 | 2382 | echo $default_search_for_text; | 
| 2383 | 2383 | } ?>" type="text" | 
| 2384 | -	       onblur="if (this.value.trim() == '') {this.value = '<?php echo esc_sql( $default_search_for_text ); ?>';}"
 | |
| 2385 | -	       onfocus="if (this.value == '<?php echo esc_sql( $default_search_for_text ); ?>') {this.value = '';}"
 | |
| 2384 | +	       onblur="if (this.value.trim() == '') {this.value = '<?php echo esc_sql($default_search_for_text); ?>';}"
 | |
| 2385 | +	       onfocus="if (this.value == '<?php echo esc_sql($default_search_for_text); ?>') {this.value = '';}"
 | |
| 2386 | 2386 | onkeydown="javascript: if(event.keyCode == 13) geodir_click_search(this);"> | 
| 2387 | 2387 | <?php | 
| 2388 | -	if($new_style){
 | |
| 2388 | +	if ($new_style) {
 | |
| 2389 | 2389 | echo "</div>"; | 
| 2390 | 2390 | } | 
| 2391 | 2391 | } | 
| @@ -2393,12 +2393,12 @@ discard block | ||
| 2393 | 2393 |  function geodir_search_form_near_input() {
 | 
| 2394 | 2394 | |
| 2395 | 2395 | $default_near_text = NEAR_TEXT; | 
| 2396 | -	if ( get_option( 'geodir_near_field_default_text' ) ) {
 | |
| 2397 | - $default_near_text = __( get_option( 'geodir_near_field_default_text' ), 'geodirectory' ); | |
| 2396 | +	if (get_option('geodir_near_field_default_text')) {
 | |
| 2397 | +		$default_near_text = __(get_option('geodir_near_field_default_text'), 'geodirectory');
 | |
| 2398 | 2398 | } | 
| 2399 | 2399 | |
| 2400 | -	if ( isset( $_REQUEST['snear'] ) && $_REQUEST['snear'] != '' ) {
 | |
| 2401 | - $near = esc_attr( stripslashes_deep( $_REQUEST['snear'] ) ); | |
| 2400 | +	if (isset($_REQUEST['snear']) && $_REQUEST['snear'] != '') {
 | |
| 2401 | + $near = esc_attr(stripslashes_deep($_REQUEST['snear'])); | |
| 2402 | 2402 |  	} else {
 | 
| 2403 | 2403 | $near = $default_near_text; | 
| 2404 | 2404 | } | 
| @@ -2412,7 +2412,7 @@ discard block | ||
| 2412 | 2412 | * @param string $near The current near value. | 
| 2413 | 2413 | * @param string $default_near_text The default near value. | 
| 2414 | 2414 | */ | 
| 2415 | - $near = apply_filters( 'geodir_search_near_text', $near, $default_near_text ); | |
| 2415 | +	$near = apply_filters('geodir_search_near_text', $near, $default_near_text);
 | |
| 2416 | 2416 | /** | 
| 2417 | 2417 | * Filter the default "Near" text value for the search form. | 
| 2418 | 2418 | * | 
| @@ -2423,7 +2423,7 @@ discard block | ||
| 2423 | 2423 | * @param string $near The current near value. | 
| 2424 | 2424 | * @param string $default_near_text The default near value. | 
| 2425 | 2425 | */ | 
| 2426 | - $default_near_text = apply_filters( 'geodir_search_default_near_text', $default_near_text, $near ); | |
| 2426 | +	$default_near_text = apply_filters('geodir_search_default_near_text', $default_near_text, $near);
 | |
| 2427 | 2427 | /** | 
| 2428 | 2428 | * Filter the class for the near search input. | 
| 2429 | 2429 | * | 
| @@ -2431,24 +2431,24 @@ discard block | ||
| 2431 | 2431 | * | 
| 2432 | 2432 | * @param string $class The class for the HTML near input, default is blank. | 
| 2433 | 2433 | */ | 
| 2434 | - $near_class = apply_filters( 'geodir_search_near_class', '' ); | |
| 2434 | +	$near_class = apply_filters('geodir_search_near_class', '');
 | |
| 2435 | 2435 | |
| 2436 | 2436 |  	$new_style = get_option('geodir_show_search_old_search_from') ? false : true;
 | 
| 2437 | -	if($new_style){
 | |
| 2437 | +	if ($new_style) {
 | |
| 2438 | 2438 | echo "<div class='gd-search-input-wrapper gd-search-field-near'>"; | 
| 2439 | 2439 | |
| 2440 | -		if(defined('GEODIRADVANCESEARCH_TEXTDOMAIN')) {
 | |
| 2440 | +		if (defined('GEODIRADVANCESEARCH_TEXTDOMAIN')) {
 | |
| 2441 | 2441 | echo "<div class='gd-append-near-wrapper'>"; | 
| 2442 | 2442 | } | 
| 2443 | 2443 | } | 
| 2444 | 2444 | ?> | 
| 2445 | 2445 | <input name="snear" class="snear <?php echo $near_class; ?>" type="text" value="<?php echo $near; ?>" | 
| 2446 | -	       onblur="if (this.value.trim() == '') {this.value = ('<?php echo esc_sql( $near ); ?>' != '' ? '<?php echo esc_sql( $near ); ?>' : '<?php echo $default_near_text; ?>');}"
 | |
| 2447 | -	       onfocus="if (this.value == '<?php echo $default_near_text; ?>' || this.value =='<?php echo esc_sql( $near ); ?>') {this.value = '';}"
 | |
| 2446 | +	       onblur="if (this.value.trim() == '') {this.value = ('<?php echo esc_sql($near); ?>' != '' ? '<?php echo esc_sql($near); ?>' : '<?php echo $default_near_text; ?>');}"
 | |
| 2447 | +	       onfocus="if (this.value == '<?php echo $default_near_text; ?>' || this.value =='<?php echo esc_sql($near); ?>') {this.value = '';}"
 | |
| 2448 | 2448 | onkeydown="javascript: if(event.keyCode == 13) geodir_click_search(this);"/> | 
| 2449 | 2449 | <?php | 
| 2450 | -	if($new_style){
 | |
| 2451 | -		if(defined('GEODIRADVANCESEARCH_TEXTDOMAIN')){
 | |
| 2450 | +	if ($new_style) {
 | |
| 2451 | +		if (defined('GEODIRADVANCESEARCH_TEXTDOMAIN')) {
 | |
| 2452 | 2452 | echo '<span class="near-compass gd-search-near-input" data-dropdown=".gd-near-me-dropdown" ><i class="fa fa-compass" aria-hidden="true"></i></span></div>'; | 
| 2453 | 2453 | } | 
| 2454 | 2454 | |
| @@ -2456,9 +2456,9 @@ discard block | ||
| 2456 | 2456 | } | 
| 2457 | 2457 | } | 
| 2458 | 2458 | |
| 2459 | -add_action( 'geodir_search_form_inputs', 'geodir_search_form_post_type_input', 10 ); | |
| 2460 | -add_action( 'geodir_search_form_inputs', 'geodir_search_form_search_input', 20 ); | |
| 2461 | -add_action( 'geodir_search_form_inputs', 'geodir_search_form_near_input', 30 ); | |
| 2459 | +add_action('geodir_search_form_inputs', 'geodir_search_form_post_type_input', 10);
 | |
| 2460 | +add_action('geodir_search_form_inputs', 'geodir_search_form_search_input', 20);
 | |
| 2461 | +add_action('geodir_search_form_inputs', 'geodir_search_form_near_input', 30);
 | |
| 2462 | 2462 | |
| 2463 | 2463 | |
| 2464 | 2464 |  function geodir_search_form() {
 | 
| @@ -2469,5 +2469,5 @@ discard block | ||
| 2469 | 2469 | die(); | 
| 2470 | 2470 | } | 
| 2471 | 2471 | |
| 2472 | -add_action( 'wp_ajax_geodir_search_form', 'geodir_search_form' ); | |
| 2473 | -add_action( 'wp_ajax_nopriv_geodir_search_form', 'geodir_search_form' ); | |
| 2474 | 2472 | \ No newline at end of file | 
| 2473 | +add_action('wp_ajax_geodir_search_form', 'geodir_search_form');
 | |
| 2474 | +add_action('wp_ajax_nopriv_geodir_search_form', 'geodir_search_form'); | |
| 2475 | 2475 | \ No newline at end of file | 
| @@ -2270,7 +2270,7 @@ discard block | ||
| 2270 | 2270 | |
| 2271 | 2271 |  	if ( $new_style ) {
 | 
| 2272 | 2272 | $default_search_button_label = '<i class="fa fa-search" aria-hidden="true"></i>'; | 
| 2273 | -	}else{
 | |
| 2273 | +	} else{
 | |
| 2274 | 2274 | $default_search_button_label = 'Search'; | 
| 2275 | 2275 | } | 
| 2276 | 2276 |  	if ( get_option( 'geodir_search_button_label' ) && get_option( 'geodir_search_button_label' ) != 'Search' ) {
 | 
| @@ -2297,7 +2297,7 @@ discard block | ||
| 2297 | 2297 |  	if ( $new_style ) {
 | 
| 2298 | 2298 | ?> | 
| 2299 | 2299 | <button class="geodir_submit_search <?php echo $fa_class; ?>"><?php _e( $default_search_button_label ,'geodirectory'); ?></button> | 
| 2300 | -<?php }else{?>
 | |
| 2300 | +<?php } else{?>
 | |
| 2301 | 2301 | <input type="button" value="<?php esc_attr_e( $default_search_button_label ); ?>" | 
| 2302 | 2302 | class="geodir_submit_search <?php echo $fa_class; ?>"/> | 
| 2303 | 2303 | <?php } | 
| @@ -2349,16 +2349,16 @@ discard block | ||
| 2349 | 2349 |  			if ( $new_style ) {
 | 
| 2350 | 2350 | echo "</div>"; | 
| 2351 | 2351 | } | 
| 2352 | -		}else{
 | |
| 2352 | +		} else{
 | |
| 2353 | 2353 |  			if(! empty( $post_types )){
 | 
| 2354 | 2354 | echo '<input type="hidden" name="stype" value="' . key( $post_types ) . '" />'; | 
| 2355 | -			}else{
 | |
| 2355 | +			} else{
 | |
| 2356 | 2356 | echo '<input type="hidden" name="stype" value="gd_place" />'; | 
| 2357 | 2357 | } | 
| 2358 | 2358 | |
| 2359 | 2359 | } | 
| 2360 | 2360 | |
| 2361 | -	}elseif ( ! empty( $post_types ) ) {
 | |
| 2361 | +	} elseif ( ! empty( $post_types ) ) {
 | |
| 2362 | 2362 | echo '<input type="hidden" name="stype" value="' . key( $post_types ) . '" />'; | 
| 2363 | 2363 | } | 
| 2364 | 2364 | } | 
| @@ -10,33 +10,33 @@ discard block | ||
| 10 | 10 | |
| 11 | 11 |  add_action('admin_init', 'geodir_admin_init');
 | 
| 12 | 12 |  if (!function_exists('geodir_admin_init')) {
 | 
| 13 | - /** | |
| 14 | - * Adds GD setting pages in admin. | |
| 15 | - * | |
| 16 | - * @since 1.0.0 | |
| 17 | - * @package GeoDirectory | |
| 18 | - * @global string $current_tab The current settings tab name. | |
| 19 | - */ | |
| 20 | - function geodir_admin_init() | |
| 21 | -    {
 | |
| 22 | - | |
| 23 | - if (is_admin()): | |
| 24 | - global $current_tab; | |
| 25 | - geodir_redirect_to_admin_panel_on_installed(); | |
| 26 | - $current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings'; | |
| 27 | - if (!(isset($_REQUEST['action']))) // this will avoid Ajax requests | |
| 28 | - geodir_handle_option_form_submit($current_tab); // located in admin function.php | |
| 29 | - /** | |
| 30 | - * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area. | |
| 31 | - * | |
| 32 | - * @since 1.0.0 | |
| 33 | - */ | |
| 34 | -            do_action('admin_panel_init');
 | |
| 35 | -            add_action('geodir_admin_option_form', 'geodir_get_admin_option_form', 1);
 | |
| 36 | - | |
| 37 | - | |
| 38 | - endif; | |
| 39 | - } | |
| 13 | + /** | |
| 14 | + * Adds GD setting pages in admin. | |
| 15 | + * | |
| 16 | + * @since 1.0.0 | |
| 17 | + * @package GeoDirectory | |
| 18 | + * @global string $current_tab The current settings tab name. | |
| 19 | + */ | |
| 20 | + function geodir_admin_init() | |
| 21 | +	{
 | |
| 22 | + | |
| 23 | + if (is_admin()): | |
| 24 | + global $current_tab; | |
| 25 | + geodir_redirect_to_admin_panel_on_installed(); | |
| 26 | + $current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings'; | |
| 27 | + if (!(isset($_REQUEST['action']))) // this will avoid Ajax requests | |
| 28 | + geodir_handle_option_form_submit($current_tab); // located in admin function.php | |
| 29 | + /** | |
| 30 | + * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area. | |
| 31 | + * | |
| 32 | + * @since 1.0.0 | |
| 33 | + */ | |
| 34 | +			do_action('admin_panel_init');
 | |
| 35 | +			add_action('geodir_admin_option_form', 'geodir_get_admin_option_form', 1);
 | |
| 36 | + | |
| 37 | + | |
| 38 | + endif; | |
| 39 | + } | |
| 40 | 40 | } | 
| 41 | 41 | |
| 42 | 42 | /** | 
| @@ -47,10 +47,10 @@ discard block | ||
| 47 | 47 | */ | 
| 48 | 48 | function geodir_redirect_to_admin_panel_on_installed() | 
| 49 | 49 |  {
 | 
| 50 | -    if (get_option('geodir_installation_redirect', false)) {
 | |
| 51 | -        delete_option('geodir_installation_redirect');
 | |
| 52 | -        wp_redirect(admin_url('admin.php?page=geodirectory&installed=yes'));
 | |
| 53 | - } | |
| 50 | +	if (get_option('geodir_installation_redirect', false)) {
 | |
| 51 | +		delete_option('geodir_installation_redirect');
 | |
| 52 | +		wp_redirect(admin_url('admin.php?page=geodirectory&installed=yes'));
 | |
| 53 | + } | |
| 54 | 54 | } | 
| 55 | 55 | |
| 56 | 56 | /** | 
| @@ -62,7 +62,7 @@ discard block | ||
| 62 | 62 | */ | 
| 63 | 63 | function geodir_get_admin_option_form($current_tab) | 
| 64 | 64 |  {
 | 
| 65 | - geodir_admin_option_form($current_tab);// defined in admin template tags.php | |
| 65 | + geodir_admin_option_form($current_tab);// defined in admin template tags.php | |
| 66 | 66 | } | 
| 67 | 67 | |
| 68 | 68 | |
| @@ -85,19 +85,19 @@ discard block | ||
| 85 | 85 | */ | 
| 86 | 86 | function geodir_conditional_admin_script_load() | 
| 87 | 87 |  {
 | 
| 88 | - global $pagenow; | |
| 88 | + global $pagenow; | |
| 89 | 89 | |
| 90 | 90 | // Get the current post type | 
| 91 | 91 | $post_type = geodir_admin_current_post_type(); | 
| 92 | 92 | $geodir_post_types = geodir_get_posttypes(); | 
| 93 | 93 | |
| 94 | 94 |  	if ((isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') || (($pagenow == 'post.php' || $pagenow == 'post-new.php' || $pagenow == 'edit.php') && $post_type && in_array($post_type, $geodir_post_types)) || ($pagenow == 'edit-tags.php' || $pagenow == 'term.php' || $pagenow == 'edit-comments.php' || $pagenow == 'comment.php')) {
 | 
| 95 | -        add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
 | |
| 96 | -        add_action('admin_enqueue_scripts', 'geodir_admin_styles');
 | |
| 97 | -        add_action('admin_enqueue_scripts', 'geodir_admin_dequeue_scripts', 100);
 | |
| 98 | - } | |
| 95 | +		add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
 | |
| 96 | +		add_action('admin_enqueue_scripts', 'geodir_admin_styles');
 | |
| 97 | +		add_action('admin_enqueue_scripts', 'geodir_admin_dequeue_scripts', 100);
 | |
| 98 | + } | |
| 99 | 99 | |
| 100 | -    add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
 | |
| 100 | +	add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
 | |
| 101 | 101 | |
| 102 | 102 | } | 
| 103 | 103 | |
| @@ -131,12 +131,12 @@ discard block | ||
| 131 | 131 | */ | 
| 132 | 132 | function create_default_admin_main_nav() | 
| 133 | 133 |  {
 | 
| 134 | -    add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
 | |
| 135 | -    add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
 | |
| 136 | -    add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
 | |
| 137 | -    add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
 | |
| 138 | -    add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
 | |
| 139 | -    //add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
 | |
| 134 | +	add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
 | |
| 135 | +	add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
 | |
| 136 | +	add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
 | |
| 137 | +	add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
 | |
| 138 | +	add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
 | |
| 139 | +	//add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
 | |
| 140 | 140 | |
| 141 | 141 | } | 
| 142 | 142 | |
| @@ -149,16 +149,16 @@ discard block | ||
| 149 | 149 | */ | 
| 150 | 150 | function geodir_admin_list_columns() | 
| 151 | 151 |  {
 | 
| 152 | -    if ($post_types = geodir_get_posttypes()) {
 | |
| 152 | +	if ($post_types = geodir_get_posttypes()) {
 | |
| 153 | 153 | |
| 154 | - foreach ($post_types as $post_type): | |
| 155 | -            add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
 | |
| 156 | - //Filter-Payment-Manager to show Package | |
| 157 | -            add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
 | |
| 154 | + foreach ($post_types as $post_type): | |
| 155 | +			add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
 | |
| 156 | + //Filter-Payment-Manager to show Package | |
| 157 | +			add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
 | |
| 158 | 158 | |
| 159 | -            add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
 | |
| 160 | - endforeach; | |
| 161 | - } | |
| 159 | +			add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
 | |
| 160 | + endforeach; | |
| 161 | + } | |
| 162 | 162 | } | 
| 163 | 163 | |
| 164 | 164 | /** | 
| @@ -171,15 +171,15 @@ discard block | ||
| 171 | 171 | */ | 
| 172 | 172 | function geodir_default_admin_main_tabs($tabs) | 
| 173 | 173 |  {
 | 
| 174 | - return $tabs = array( | |
| 175 | -        'general_settings' => array('label' => __('General', 'geodirectory')),
 | |
| 176 | -        'design_settings' => array('label' => __('Design', 'geodirectory')),
 | |
| 177 | -        'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
 | |
| 178 | -        'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
 | |
| 179 | -        'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
 | |
| 180 | -        'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
 | |
| 181 | - | |
| 182 | - ); | |
| 174 | + return $tabs = array( | |
| 175 | +		'general_settings' => array('label' => __('General', 'geodirectory')),
 | |
| 176 | +		'design_settings' => array('label' => __('Design', 'geodirectory')),
 | |
| 177 | +		'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
 | |
| 178 | +		'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
 | |
| 179 | +		'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
 | |
| 180 | +		'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
 | |
| 181 | + | |
| 182 | + ); | |
| 183 | 183 | } | 
| 184 | 184 | |
| 185 | 185 |  add_action('do_meta_boxes', 'geodir_remove_image_box');
 | 
| @@ -192,16 +192,16 @@ discard block | ||
| 192 | 192 | */ | 
| 193 | 193 | function geodir_remove_image_box() | 
| 194 | 194 |  {
 | 
| 195 | - global $post; | |
| 195 | + global $post; | |
| 196 | 196 | |
| 197 | - $geodir_posttypes = geodir_get_posttypes(); | |
| 197 | + $geodir_posttypes = geodir_get_posttypes(); | |
| 198 | 198 | |
| 199 | - if (isset($post) && in_array($post->post_type, $geodir_posttypes)): | |
| 199 | + if (isset($post) && in_array($post->post_type, $geodir_posttypes)): | |
| 200 | 200 | |
| 201 | -        remove_meta_box('postimagediv', $post->post_type, 'side');
 | |
| 202 | -        remove_meta_box('revisionsdiv', $post->post_type, 'normal');
 | |
| 201 | +		remove_meta_box('postimagediv', $post->post_type, 'side');
 | |
| 202 | +		remove_meta_box('revisionsdiv', $post->post_type, 'normal');
 | |
| 203 | 203 | |
| 204 | - endif; | |
| 204 | + endif; | |
| 205 | 205 | |
| 206 | 206 | } | 
| 207 | 207 | |
| @@ -216,26 +216,26 @@ discard block | ||
| 216 | 216 | */ | 
| 217 | 217 | function geodir_meta_box_add() | 
| 218 | 218 |  {
 | 
| 219 | - global $post; | |
| 219 | + global $post; | |
| 220 | 220 | |
| 221 | -    $geodir_post_types = geodir_get_posttypes('array');
 | |
| 222 | - $geodir_posttypes = array_keys($geodir_post_types); | |
| 221 | +	$geodir_post_types = geodir_get_posttypes('array');
 | |
| 222 | + $geodir_posttypes = array_keys($geodir_post_types); | |
| 223 | 223 | |
| 224 | - if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)): | |
| 224 | + if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)): | |
| 225 | 225 | |
| 226 | - $geodir_posttype = $post->post_type; | |
| 227 | - $post_typename = geodir_ucwords($geodir_post_types[$geodir_posttype]['labels']['singular_name']); | |
| 226 | + $geodir_posttype = $post->post_type; | |
| 227 | + $post_typename = geodir_ucwords($geodir_post_types[$geodir_posttype]['labels']['singular_name']); | |
| 228 | 228 | |
| 229 | - // Filter-Payment-Manager | |
| 229 | + // Filter-Payment-Manager | |
| 230 | 230 | |
| 231 | -        add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
 | |
| 231 | +		add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
 | |
| 232 | 232 | |
| 233 | -        add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
 | |
| 233 | +		add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
 | |
| 234 | 234 | |
| 235 | - // no need of this box as all fields moved to main information box | |
| 236 | -        //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
 | |
| 235 | + // no need of this box as all fields moved to main information box | |
| 236 | +		//add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
 | |
| 237 | 237 | |
| 238 | - endif; | |
| 238 | + endif; | |
| 239 | 239 | |
| 240 | 240 | } | 
| 241 | 241 | |
| @@ -259,23 +259,23 @@ discard block | ||
| 259 | 259 | function geodir_hide_post_taxonomy_meta_boxes() | 
| 260 | 260 |  {
 | 
| 261 | 261 | |
| 262 | -    $geodir_post_types = get_option('geodir_post_types');
 | |
| 262 | +	$geodir_post_types = get_option('geodir_post_types');
 | |
| 263 | 263 | |
| 264 | -    if (!empty($geodir_post_types)) {
 | |
| 265 | -        foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
 | |
| 264 | +	if (!empty($geodir_post_types)) {
 | |
| 265 | +		foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
 | |
| 266 | 266 | |
| 267 | - $gd_taxonomy = geodir_get_taxonomies($geodir_post_type); | |
| 267 | + $gd_taxonomy = geodir_get_taxonomies($geodir_post_type); | |
| 268 | 268 | |
| 269 | -            if(!empty($gd_taxonomy)) {
 | |
| 270 | -                foreach ($gd_taxonomy as $tax) {
 | |
| 269 | +			if(!empty($gd_taxonomy)) {
 | |
| 270 | +				foreach ($gd_taxonomy as $tax) {
 | |
| 271 | 271 | |
| 272 | - remove_meta_box($tax . 'div', $geodir_post_type, 'normal'); | |
| 272 | + remove_meta_box($tax . 'div', $geodir_post_type, 'normal'); | |
| 273 | 273 | |
| 274 | - } | |
| 275 | - } | |
| 274 | + } | |
| 275 | + } | |
| 276 | 276 | |
| 277 | - } | |
| 278 | - } | |
| 277 | + } | |
| 278 | + } | |
| 279 | 279 | } | 
| 280 | 280 | |
| 281 | 281 |  add_filter('geodir_add_listing_map_restrict', 'geodir_add_listing_map_restrict');
 | 
| @@ -289,12 +289,12 @@ discard block | ||
| 289 | 289 | */ | 
| 290 | 290 | function geodir_add_listing_map_restrict($map_restirct) | 
| 291 | 291 |  {
 | 
| 292 | -    if (is_admin()) {
 | |
| 293 | -        if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
 | |
| 294 | - $map_restirct = false; | |
| 295 | - } | |
| 296 | - } | |
| 297 | - return $map_restirct; | |
| 292 | +	if (is_admin()) {
 | |
| 293 | +		if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
 | |
| 294 | + $map_restirct = false; | |
| 295 | + } | |
| 296 | + } | |
| 297 | + return $map_restirct; | |
| 298 | 298 | } | 
| 299 | 299 | |
| 300 | 300 | |
| @@ -313,16 +313,16 @@ discard block | ||
| 313 | 313 | function geodir_enable_editor_on_notifications($notification) | 
| 314 | 314 |  {
 | 
| 315 | 315 | |
| 316 | -    if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
 | |
| 316 | +	if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
 | |
| 317 | 317 | |
| 318 | -        foreach ($notification as $key => $value) {
 | |
| 319 | - if ($value['type'] == 'textarea') | |
| 320 | - $notification[$key]['type'] = 'editor'; | |
| 321 | - } | |
| 318 | +		foreach ($notification as $key => $value) {
 | |
| 319 | + if ($value['type'] == 'textarea') | |
| 320 | + $notification[$key]['type'] = 'editor'; | |
| 321 | + } | |
| 322 | 322 | |
| 323 | - } | |
| 323 | + } | |
| 324 | 324 | |
| 325 | - return $notification; | |
| 325 | + return $notification; | |
| 326 | 326 | } | 
| 327 | 327 | |
| 328 | 328 | |
| @@ -339,16 +339,16 @@ discard block | ||
| 339 | 339 | function geodir_enable_editor_on_design_settings($design_setting) | 
| 340 | 340 |  {
 | 
| 341 | 341 | |
| 342 | -    if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
 | |
| 342 | +	if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
 | |
| 343 | 343 | |
| 344 | -        foreach ($design_setting as $key => $value) {
 | |
| 345 | - if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content') | |
| 346 | - $design_setting[$key]['type'] = 'editor'; | |
| 347 | - } | |
| 344 | +		foreach ($design_setting as $key => $value) {
 | |
| 345 | + if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content') | |
| 346 | + $design_setting[$key]['type'] = 'editor'; | |
| 347 | + } | |
| 348 | 348 | |
| 349 | - } | |
| 349 | + } | |
| 350 | 350 | |
| 351 | - return $design_setting; | |
| 351 | + return $design_setting; | |
| 352 | 352 | } | 
| 353 | 353 | |
| 354 | 354 | /* ----------- START MANAGE CUSTOM FIELDS ---------------- */ | 
| @@ -356,15 +356,15 @@ discard block | ||
| 356 | 356 |  add_action('geodir_manage_available_fields_custom', 'geodir_manage_available_fields_custom');
 | 
| 357 | 357 | |
| 358 | 358 |  function geodir_manage_available_fields_predefined($sub_tab){
 | 
| 359 | -    if($sub_tab=='custom_fields'){
 | |
| 360 | -        geodir_custom_available_fields('predefined');
 | |
| 361 | - } | |
| 359 | +	if($sub_tab=='custom_fields'){
 | |
| 360 | +		geodir_custom_available_fields('predefined');
 | |
| 361 | + } | |
| 362 | 362 | } | 
| 363 | 363 | |
| 364 | 364 |  function geodir_manage_available_fields_custom($sub_tab){
 | 
| 365 | -    if($sub_tab=='custom_fields'){
 | |
| 366 | -        geodir_custom_available_fields('custom');
 | |
| 367 | - } | |
| 365 | +	if($sub_tab=='custom_fields'){
 | |
| 366 | +		geodir_custom_available_fields('custom');
 | |
| 367 | + } | |
| 368 | 368 | } | 
| 369 | 369 | |
| 370 | 370 | |
| @@ -383,16 +383,16 @@ discard block | ||
| 383 | 383 | function geodir_manage_available_fields($sub_tab) | 
| 384 | 384 |  {
 | 
| 385 | 385 | |
| 386 | -    switch ($sub_tab) {
 | |
| 387 | - case 'custom_fields': | |
| 388 | - geodir_custom_available_fields(); | |
| 389 | - break; | |
| 386 | +	switch ($sub_tab) {
 | |
| 387 | + case 'custom_fields': | |
| 388 | + geodir_custom_available_fields(); | |
| 389 | + break; | |
| 390 | 390 | |
| 391 | - case 'sorting_options': | |
| 392 | - geodir_sorting_options_available_fields(); | |
| 393 | - break; | |
| 391 | + case 'sorting_options': | |
| 392 | + geodir_sorting_options_available_fields(); | |
| 393 | + break; | |
| 394 | 394 | |
| 395 | - } | |
| 395 | + } | |
| 396 | 396 | } | 
| 397 | 397 | |
| 398 | 398 | |
| @@ -408,16 +408,16 @@ discard block | ||
| 408 | 408 | function geodir_manage_selected_fields($sub_tab) | 
| 409 | 409 |  {
 | 
| 410 | 410 | |
| 411 | -    switch ($sub_tab) {
 | |
| 412 | - case 'custom_fields': | |
| 413 | - geodir_custom_selected_fields(); | |
| 414 | - break; | |
| 411 | +	switch ($sub_tab) {
 | |
| 412 | + case 'custom_fields': | |
| 413 | + geodir_custom_selected_fields(); | |
| 414 | + break; | |
| 415 | 415 | |
| 416 | - case 'sorting_options': | |
| 417 | - geodir_sorting_options_selected_fields(); | |
| 418 | - break; | |
| 416 | + case 'sorting_options': | |
| 417 | + geodir_sorting_options_selected_fields(); | |
| 418 | + break; | |
| 419 | 419 | |
| 420 | - } | |
| 420 | + } | |
| 421 | 421 | } | 
| 422 | 422 | |
| 423 | 423 | /** | 
| @@ -429,52 +429,52 @@ discard block | ||
| 429 | 429 | */ | 
| 430 | 430 | function geodir_sorting_options_available_fields() | 
| 431 | 431 |  {
 | 
| 432 | - global $wpdb; | |
| 433 | - $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; | |
| 434 | - ?> | |
| 432 | + global $wpdb; | |
| 433 | + $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; | |
| 434 | + ?> | |
| 435 | 435 | <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/> | 
| 436 | 436 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> | 
| 437 | 437 | <ul> | 
| 438 | 438 | <?php | 
| 439 | - $sort_options = geodir_get_custom_sort_options($listing_type); | |
| 439 | + $sort_options = geodir_get_custom_sort_options($listing_type); | |
| 440 | 440 | |
| 441 | -        foreach ($sort_options as $key => $val) {
 | |
| 442 | - $val = stripslashes_deep($val); // strip slashes | |
| 443 | - | |
| 444 | - $check_html_variable = $wpdb->get_var( | |
| 445 | - $wpdb->prepare( | |
| 446 | - "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s", | |
| 447 | - array($val['htmlvar_name'], $listing_type, $val['field_type']) | |
| 448 | - ) | |
| 449 | - ); | |
| 441 | +		foreach ($sort_options as $key => $val) {
 | |
| 442 | + $val = stripslashes_deep($val); // strip slashes | |
| 443 | + | |
| 444 | + $check_html_variable = $wpdb->get_var( | |
| 445 | + $wpdb->prepare( | |
| 446 | + "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s", | |
| 447 | + array($val['htmlvar_name'], $listing_type, $val['field_type']) | |
| 448 | + ) | |
| 449 | + ); | |
| 450 | 450 | |
| 451 | - $display = $check_html_variable ? ' style="display:none;"' : ''; | |
| 452 | - ?> | |
| 451 | + $display = $check_html_variable ? ' style="display:none;"' : ''; | |
| 452 | + ?> | |
| 453 | 453 | |
| 454 | 454 | <li class="gd-cf-tooltip-wrap" <?php echo $display;?>> | 
| 455 | 455 | <?php | 
| 456 | -                if(isset($val['description']) && $val['description']){
 | |
| 457 | - echo '<div class="gdcf-tooltip">'.$val['description'].'</div>'; | |
| 458 | - }?> | |
| 456 | +				if(isset($val['description']) && $val['description']){
 | |
| 457 | + echo '<div class="gdcf-tooltip">'.$val['description'].'</div>'; | |
| 458 | + }?> | |
| 459 | 459 | |
| 460 | 460 | <a id="gd-<?php echo $val['field_type'];?>-_-<?php echo $val['htmlvar_name'];?>" data-field-type-key="<?php echo $val['htmlvar_name'];?>" data-field-type="<?php echo $val['field_type'];?>" | 
| 461 | 461 | title="<?php echo $val['site_title'];?>" | 
| 462 | 462 | class="gd-draggable-form-items gd-<?php echo $val['field_type'];?> geodir-sort-<?php echo $val['htmlvar_name'];?>" href="javascript:void(0);"> | 
| 463 | 463 |                      <?php if (isset($val['field_icon']) && strpos($val['field_icon'], 'fa fa-') !== false) {
 | 
| 464 | - echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>'; | |
| 465 | -                    }elseif(isset($val['field_icon']) && $val['field_icon'] ){
 | |
| 466 | -                        echo '<b style="background-image: url("'.$val['field_icon'].'")"></b>';
 | |
| 467 | -                    }else{
 | |
| 468 | - echo '<i class="fa fa-cog" aria-hidden="true"></i>'; | |
| 469 | - }?> | |
| 464 | + echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>'; | |
| 465 | +					}elseif(isset($val['field_icon']) && $val['field_icon'] ){
 | |
| 466 | +						echo '<b style="background-image: url("'.$val['field_icon'].'")"></b>';
 | |
| 467 | +					}else{
 | |
| 468 | + echo '<i class="fa fa-cog" aria-hidden="true"></i>'; | |
| 469 | + }?> | |
| 470 | 470 | <?php echo $val['site_title'];?> | 
| 471 | 471 | </a> | 
| 472 | 472 | </li> | 
| 473 | 473 | |
| 474 | 474 | |
| 475 | 475 | <?php | 
| 476 | - } | |
| 477 | - ?> | |
| 476 | + } | |
| 477 | + ?> | |
| 478 | 478 | </ul> | 
| 479 | 479 | <?php | 
| 480 | 480 | } | 
| @@ -488,28 +488,28 @@ discard block | ||
| 488 | 488 | */ | 
| 489 | 489 | function geodir_sorting_options_selected_fields() | 
| 490 | 490 |  {
 | 
| 491 | - $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; | |
| 492 | - ?> | |
| 491 | + $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; | |
| 492 | + ?> | |
| 493 | 493 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> | 
| 494 | 494 | <ul class="core"> | 
| 495 | 495 | <?php | 
| 496 | - global $wpdb; | |
| 496 | + global $wpdb; | |
| 497 | 497 | |
| 498 | -        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
 | |
| 498 | +		$fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
 | |
| 499 | 499 | |
| 500 | -        if (!empty($fields)) {
 | |
| 501 | -            foreach ($fields as $field) {
 | |
| 502 | - //$result_str = $field->id; | |
| 503 | - $result_str = $field; | |
| 504 | - $field_type = $field->field_type; | |
| 505 | - $field_ins_upd = 'display'; | |
| 500 | +		if (!empty($fields)) {
 | |
| 501 | +			foreach ($fields as $field) {
 | |
| 502 | + //$result_str = $field->id; | |
| 503 | + $result_str = $field; | |
| 504 | + $field_type = $field->field_type; | |
| 505 | + $field_ins_upd = 'display'; | |
| 506 | 506 | |
| 507 | - $default = false; | |
| 507 | + $default = false; | |
| 508 | 508 | |
| 509 | - geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default); | |
| 510 | - } | |
| 511 | - } | |
| 512 | - ?> | |
| 509 | + geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default); | |
| 510 | + } | |
| 511 | + } | |
| 512 | + ?> | |
| 513 | 513 | </ul> | 
| 514 | 514 | <?php | 
| 515 | 515 | } | 
| @@ -522,12 +522,12 @@ discard block | ||
| 522 | 522 | */ | 
| 523 | 523 |  function geodir_custom_fields_custom($post_type=''){
 | 
| 524 | 524 | |
| 525 | - $custom_fields = array(); | |
| 525 | + $custom_fields = array(); | |
| 526 | 526 | |
| 527 | - /** | |
| 528 | - * @see `geodir_custom_fields` | |
| 529 | - */ | |
| 530 | -    return apply_filters('geodir_custom_fields_custom',$custom_fields,$post_type);
 | |
| 527 | + /** | |
| 528 | + * @see `geodir_custom_fields` | |
| 529 | + */ | |
| 530 | +	return apply_filters('geodir_custom_fields_custom',$custom_fields,$post_type);
 | |
| 531 | 531 | } | 
| 532 | 532 | |
| 533 | 533 | |
| @@ -540,140 +540,140 @@ discard block | ||
| 540 | 540 | */ | 
| 541 | 541 |  function geodir_custom_fields($post_type=''){
 | 
| 542 | 542 | |
| 543 | - $custom_fields = array( | |
| 544 | - 'text' => array( | |
| 545 | - 'field_type' => 'text', | |
| 546 | - 'class' => 'gd-text', | |
| 547 | - 'icon' => 'fa fa-minus', | |
| 548 | -            'name'  =>  __('Text', 'geodirectory'),
 | |
| 549 | -            'description' =>  __('Add any sort of text field, text or numbers', 'geodirectory')
 | |
| 550 | - ), | |
| 551 | - 'datepicker' => array( | |
| 552 | - 'field_type' => 'datepicker', | |
| 553 | - 'class' => 'gd-datepicker', | |
| 554 | - 'icon' => 'fa fa-calendar', | |
| 555 | -            'name'  =>  __('Date', 'geodirectory'),
 | |
| 556 | -            'description' =>  __('Adds a date picker.', 'geodirectory')
 | |
| 557 | - ), | |
| 558 | - 'textarea' => array( | |
| 559 | - 'field_type' => 'textarea', | |
| 560 | - 'class' => 'gd-textarea', | |
| 561 | - 'icon' => 'fa fa-bars', | |
| 562 | -            'name'  =>  __('Textarea', 'geodirectory'),
 | |
| 563 | -            'description' =>  __('Adds a textarea', 'geodirectory')
 | |
| 564 | - ), | |
| 565 | - 'time' => array( | |
| 566 | - 'field_type' => 'time', | |
| 567 | - 'class' => 'gd-time', | |
| 568 | - 'icon' => 'fa fa-clock-o', | |
| 569 | -            'name'  =>  __('Time', 'geodirectory'),
 | |
| 570 | -            'description' =>  __('Adds a time picker', 'geodirectory')
 | |
| 571 | - ), | |
| 572 | - 'checkbox' => array( | |
| 573 | - 'field_type' => 'checkbox', | |
| 574 | - 'class' => 'gd-checkbox', | |
| 575 | - 'icon' => 'fa fa-check-square-o', | |
| 576 | -            'name'  =>  __('Checkbox', 'geodirectory'),
 | |
| 577 | -            'description' =>  __('Adds a checkbox', 'geodirectory')
 | |
| 578 | - ), | |
| 579 | - 'phone' => array( | |
| 580 | - 'field_type' => 'phone', | |
| 581 | - 'class' => 'gd-phone', | |
| 582 | - 'icon' => 'fa fa-phone', | |
| 583 | -            'name'  =>  __('Phone', 'geodirectory'),
 | |
| 584 | -            'description' =>  __('Adds a phone input', 'geodirectory')
 | |
| 585 | - ), | |
| 586 | - 'radio' => array( | |
| 587 | - 'field_type' => 'radio', | |
| 588 | - 'class' => 'gd-radio', | |
| 589 | - 'icon' => 'fa fa-dot-circle-o', | |
| 590 | -            'name'  =>  __('Radio', 'geodirectory'),
 | |
| 591 | -            'description' =>  __('Adds a radio input', 'geodirectory')
 | |
| 592 | - ), | |
| 593 | - 'email' => array( | |
| 594 | - 'field_type' => 'email', | |
| 595 | - 'class' => 'gd-email', | |
| 596 | - 'icon' => 'fa fa-envelope-o', | |
| 597 | -            'name'  =>  __('Email', 'geodirectory'),
 | |
| 598 | -            'description' =>  __('Adds a email input', 'geodirectory')
 | |
| 599 | - ), | |
| 600 | - 'select' => array( | |
| 601 | - 'field_type' => 'select', | |
| 602 | - 'class' => 'gd-select', | |
| 603 | - 'icon' => 'fa fa-caret-square-o-down', | |
| 604 | -            'name'  =>  __('Select', 'geodirectory'),
 | |
| 605 | -            'description' =>  __('Adds a select input', 'geodirectory')
 | |
| 606 | - ), | |
| 607 | - 'multiselect' => array( | |
| 608 | - 'field_type' => 'multiselect', | |
| 609 | - 'class' => 'gd-multiselect', | |
| 610 | - 'icon' => 'fa fa-caret-square-o-down', | |
| 611 | -            'name'  =>  __('Multi Select', 'geodirectory'),
 | |
| 612 | -            'description' =>  __('Adds a multiselect input', 'geodirectory')
 | |
| 613 | - ), | |
| 614 | - 'url' => array( | |
| 615 | - 'field_type' => 'url', | |
| 616 | - 'class' => 'gd-url', | |
| 617 | - 'icon' => 'fa fa-link', | |
| 618 | -            'name'  =>  __('URL', 'geodirectory'),
 | |
| 619 | -            'description' =>  __('Adds a url input', 'geodirectory')
 | |
| 620 | - ), | |
| 621 | - 'html' => array( | |
| 622 | - 'field_type' => 'html', | |
| 623 | - 'class' => 'gd-html', | |
| 624 | - 'icon' => 'fa fa-code', | |
| 625 | -            'name'  =>  __('HTML', 'geodirectory'),
 | |
| 626 | -            'description' =>  __('Adds a html input textarea', 'geodirectory')
 | |
| 627 | - ), | |
| 628 | - 'file' => array( | |
| 629 | - 'field_type' => 'file', | |
| 630 | - 'class' => 'gd-file', | |
| 631 | - 'icon' => 'fa fa-file', | |
| 632 | -            'name'  =>  __('File Upload', 'geodirectory'),
 | |
| 633 | -            'description' =>  __('Adds a file input', 'geodirectory')
 | |
| 634 | - ) | |
| 635 | - ); | |
| 636 | - | |
| 637 | - /** | |
| 638 | - * Filter the custom fields array to be able to add or remove items. | |
| 639 | - * | |
| 640 | - * @since 1.6.6 | |
| 641 | - * | |
| 642 | -     * @param array $custom_fields {
 | |
| 643 | - * The custom fields array to be filtered. | |
| 644 | - * | |
| 645 | - * @type string $field_type The type of field, eg: text, datepicker, textarea, time, checkbox, phone, radio, email, select, multiselect, url, html, file. | |
| 646 | - * @type string $class The class for the field in backend. | |
| 647 | - * @type string $icon Can be font-awesome class name or icon image url. | |
| 648 | - * @type string $name The name of the field. | |
| 649 | - * @type string $description A short description about the field. | |
| 650 | -     *     @type array $defaults {
 | |
| 651 | - * Optional. Used to set the default value of the field. | |
| 652 | - * | |
| 653 | - * @type string data_type The SQL data type for the field. VARCHAR, TEXT, TIME, TINYINT, INT, FLOAT, DATE | |
| 654 | - * @type int decimal_point limit if usinf FLOAT data_type | |
| 655 | - * @type string admin_title The admin title for the field. | |
| 656 | - * @type string site_title This will be the title for the field on the frontend. | |
| 657 | - * @type string admin_desc This will be shown below the field on the add listing form. | |
| 658 | - * @type string htmlvar_name This is a unique identifier used in the HTML, it MUST NOT contain spaces or special characters. | |
| 659 | - * @type bool is_active If false the field will not be displayed anywhere. | |
| 660 | - * @type bool for_admin_use If true then only site admin can see and edit this field. | |
| 661 | - * @type string default_value The default value for the input on the add listing page. | |
| 662 | - * @type string show_in The locations to show in. [detail],[moreinfo],[listing],[owntab],[mapbubble] | |
| 663 | - * @type bool is_required If true the field will be required on the add listing page. | |
| 664 | - * @type string option_values The option values for select and multiselect only | |
| 665 | - * @type string validation_pattern HTML5 validation pattern (text input only by default). | |
| 666 | - * @type string validation_msg HTML5 validation message (text input only by default). | |
| 667 | - * @type string required_msg Required warning message. | |
| 668 | - * @type string field_icon Icon url or font awesome class. | |
| 669 | - * @type string css_class Field custom css class for field custom style. | |
| 670 | - * @type bool cat_sort If true the field will appear in the category sort options, if false the field will be hidden, leave blank to show option. | |
| 671 | - * @type bool cat_sort If true the field will appear in the advanced search sort options, if false the field will be hidden, leave blank to show option. (advanced search addon required) | |
| 672 | - * } | |
| 673 | - * } | |
| 674 | - * @param string $post_type The post type requested. | |
| 675 | - */ | |
| 676 | -    return apply_filters('geodir_custom_fields',$custom_fields,$post_type);
 | |
| 543 | + $custom_fields = array( | |
| 544 | + 'text' => array( | |
| 545 | + 'field_type' => 'text', | |
| 546 | + 'class' => 'gd-text', | |
| 547 | + 'icon' => 'fa fa-minus', | |
| 548 | +			'name'  =>  __('Text', 'geodirectory'),
 | |
| 549 | +			'description' =>  __('Add any sort of text field, text or numbers', 'geodirectory')
 | |
| 550 | + ), | |
| 551 | + 'datepicker' => array( | |
| 552 | + 'field_type' => 'datepicker', | |
| 553 | + 'class' => 'gd-datepicker', | |
| 554 | + 'icon' => 'fa fa-calendar', | |
| 555 | +			'name'  =>  __('Date', 'geodirectory'),
 | |
| 556 | +			'description' =>  __('Adds a date picker.', 'geodirectory')
 | |
| 557 | + ), | |
| 558 | + 'textarea' => array( | |
| 559 | + 'field_type' => 'textarea', | |
| 560 | + 'class' => 'gd-textarea', | |
| 561 | + 'icon' => 'fa fa-bars', | |
| 562 | +			'name'  =>  __('Textarea', 'geodirectory'),
 | |
| 563 | +			'description' =>  __('Adds a textarea', 'geodirectory')
 | |
| 564 | + ), | |
| 565 | + 'time' => array( | |
| 566 | + 'field_type' => 'time', | |
| 567 | + 'class' => 'gd-time', | |
| 568 | + 'icon' => 'fa fa-clock-o', | |
| 569 | +			'name'  =>  __('Time', 'geodirectory'),
 | |
| 570 | +			'description' =>  __('Adds a time picker', 'geodirectory')
 | |
| 571 | + ), | |
| 572 | + 'checkbox' => array( | |
| 573 | + 'field_type' => 'checkbox', | |
| 574 | + 'class' => 'gd-checkbox', | |
| 575 | + 'icon' => 'fa fa-check-square-o', | |
| 576 | +			'name'  =>  __('Checkbox', 'geodirectory'),
 | |
| 577 | +			'description' =>  __('Adds a checkbox', 'geodirectory')
 | |
| 578 | + ), | |
| 579 | + 'phone' => array( | |
| 580 | + 'field_type' => 'phone', | |
| 581 | + 'class' => 'gd-phone', | |
| 582 | + 'icon' => 'fa fa-phone', | |
| 583 | +			'name'  =>  __('Phone', 'geodirectory'),
 | |
| 584 | +			'description' =>  __('Adds a phone input', 'geodirectory')
 | |
| 585 | + ), | |
| 586 | + 'radio' => array( | |
| 587 | + 'field_type' => 'radio', | |
| 588 | + 'class' => 'gd-radio', | |
| 589 | + 'icon' => 'fa fa-dot-circle-o', | |
| 590 | +			'name'  =>  __('Radio', 'geodirectory'),
 | |
| 591 | +			'description' =>  __('Adds a radio input', 'geodirectory')
 | |
| 592 | + ), | |
| 593 | + 'email' => array( | |
| 594 | + 'field_type' => 'email', | |
| 595 | + 'class' => 'gd-email', | |
| 596 | + 'icon' => 'fa fa-envelope-o', | |
| 597 | +			'name'  =>  __('Email', 'geodirectory'),
 | |
| 598 | +			'description' =>  __('Adds a email input', 'geodirectory')
 | |
| 599 | + ), | |
| 600 | + 'select' => array( | |
| 601 | + 'field_type' => 'select', | |
| 602 | + 'class' => 'gd-select', | |
| 603 | + 'icon' => 'fa fa-caret-square-o-down', | |
| 604 | +			'name'  =>  __('Select', 'geodirectory'),
 | |
| 605 | +			'description' =>  __('Adds a select input', 'geodirectory')
 | |
| 606 | + ), | |
| 607 | + 'multiselect' => array( | |
| 608 | + 'field_type' => 'multiselect', | |
| 609 | + 'class' => 'gd-multiselect', | |
| 610 | + 'icon' => 'fa fa-caret-square-o-down', | |
| 611 | +			'name'  =>  __('Multi Select', 'geodirectory'),
 | |
| 612 | +			'description' =>  __('Adds a multiselect input', 'geodirectory')
 | |
| 613 | + ), | |
| 614 | + 'url' => array( | |
| 615 | + 'field_type' => 'url', | |
| 616 | + 'class' => 'gd-url', | |
| 617 | + 'icon' => 'fa fa-link', | |
| 618 | +			'name'  =>  __('URL', 'geodirectory'),
 | |
| 619 | +			'description' =>  __('Adds a url input', 'geodirectory')
 | |
| 620 | + ), | |
| 621 | + 'html' => array( | |
| 622 | + 'field_type' => 'html', | |
| 623 | + 'class' => 'gd-html', | |
| 624 | + 'icon' => 'fa fa-code', | |
| 625 | +			'name'  =>  __('HTML', 'geodirectory'),
 | |
| 626 | +			'description' =>  __('Adds a html input textarea', 'geodirectory')
 | |
| 627 | + ), | |
| 628 | + 'file' => array( | |
| 629 | + 'field_type' => 'file', | |
| 630 | + 'class' => 'gd-file', | |
| 631 | + 'icon' => 'fa fa-file', | |
| 632 | +			'name'  =>  __('File Upload', 'geodirectory'),
 | |
| 633 | +			'description' =>  __('Adds a file input', 'geodirectory')
 | |
| 634 | + ) | |
| 635 | + ); | |
| 636 | + | |
| 637 | + /** | |
| 638 | + * Filter the custom fields array to be able to add or remove items. | |
| 639 | + * | |
| 640 | + * @since 1.6.6 | |
| 641 | + * | |
| 642 | +	 * @param array $custom_fields {
 | |
| 643 | + * The custom fields array to be filtered. | |
| 644 | + * | |
| 645 | + * @type string $field_type The type of field, eg: text, datepicker, textarea, time, checkbox, phone, radio, email, select, multiselect, url, html, file. | |
| 646 | + * @type string $class The class for the field in backend. | |
| 647 | + * @type string $icon Can be font-awesome class name or icon image url. | |
| 648 | + * @type string $name The name of the field. | |
| 649 | + * @type string $description A short description about the field. | |
| 650 | +	 *     @type array $defaults {
 | |
| 651 | + * Optional. Used to set the default value of the field. | |
| 652 | + * | |
| 653 | + * @type string data_type The SQL data type for the field. VARCHAR, TEXT, TIME, TINYINT, INT, FLOAT, DATE | |
| 654 | + * @type int decimal_point limit if usinf FLOAT data_type | |
| 655 | + * @type string admin_title The admin title for the field. | |
| 656 | + * @type string site_title This will be the title for the field on the frontend. | |
| 657 | + * @type string admin_desc This will be shown below the field on the add listing form. | |
| 658 | + * @type string htmlvar_name This is a unique identifier used in the HTML, it MUST NOT contain spaces or special characters. | |
| 659 | + * @type bool is_active If false the field will not be displayed anywhere. | |
| 660 | + * @type bool for_admin_use If true then only site admin can see and edit this field. | |
| 661 | + * @type string default_value The default value for the input on the add listing page. | |
| 662 | + * @type string show_in The locations to show in. [detail],[moreinfo],[listing],[owntab],[mapbubble] | |
| 663 | + * @type bool is_required If true the field will be required on the add listing page. | |
| 664 | + * @type string option_values The option values for select and multiselect only | |
| 665 | + * @type string validation_pattern HTML5 validation pattern (text input only by default). | |
| 666 | + * @type string validation_msg HTML5 validation message (text input only by default). | |
| 667 | + * @type string required_msg Required warning message. | |
| 668 | + * @type string field_icon Icon url or font awesome class. | |
| 669 | + * @type string css_class Field custom css class for field custom style. | |
| 670 | + * @type bool cat_sort If true the field will appear in the category sort options, if false the field will be hidden, leave blank to show option. | |
| 671 | + * @type bool cat_sort If true the field will appear in the advanced search sort options, if false the field will be hidden, leave blank to show option. (advanced search addon required) | |
| 672 | + * } | |
| 673 | + * } | |
| 674 | + * @param string $post_type The post type requested. | |
| 675 | + */ | |
| 676 | +	return apply_filters('geodir_custom_fields',$custom_fields,$post_type);
 | |
| 677 | 677 | } | 
| 678 | 678 | |
| 679 | 679 | /** | 
| @@ -686,19 +686,19 @@ discard block | ||
| 686 | 686 | */ | 
| 687 | 687 | function geodir_custom_available_fields($type='') | 
| 688 | 688 |  {
 | 
| 689 | - $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; | |
| 690 | - ?> | |
| 689 | + $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; | |
| 690 | + ?> | |
| 691 | 691 | <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/> | 
| 692 | 692 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>" /> | 
| 693 | 693 | |
| 694 | 694 | <?php | 
| 695 | -        if($type=='predefined'){
 | |
| 696 | - $cfs = geodir_custom_fields_predefined($listing_type); | |
| 697 | -        }elseif($type=='custom'){
 | |
| 698 | - $cfs = geodir_custom_fields_custom($listing_type); | |
| 699 | -        }else{
 | |
| 700 | - $cfs = geodir_custom_fields($listing_type); | |
| 701 | - ?> | |
| 695 | +		if($type=='predefined'){
 | |
| 696 | + $cfs = geodir_custom_fields_predefined($listing_type); | |
| 697 | +		}elseif($type=='custom'){
 | |
| 698 | + $cfs = geodir_custom_fields_custom($listing_type); | |
| 699 | +		}else{
 | |
| 700 | + $cfs = geodir_custom_fields($listing_type); | |
| 701 | + ?> | |
| 702 | 702 | <ul class="full gd-cf-tooltip-wrap"> | 
| 703 | 703 | <li> | 
| 704 | 704 | <div class="gdcf-tooltip"> | 
| @@ -719,18 +719,18 @@ discard block | ||
| 719 | 719 | </ul> | 
| 720 | 720 | |
| 721 | 721 | <?php | 
| 722 | - } | |
| 722 | + } | |
| 723 | 723 | |
| 724 | -    if(!empty($cfs)) {
 | |
| 724 | +	if(!empty($cfs)) {
 | |
| 725 | 725 | |
| 726 | -        foreach ( $cfs as $id => $cf ) {
 | |
| 727 | - ?> | |
| 726 | +		foreach ( $cfs as $id => $cf ) {
 | |
| 727 | + ?> | |
| 728 | 728 | <ul> | 
| 729 | 729 | <li class="gd-cf-tooltip-wrap"> | 
| 730 | 730 | <?php | 
| 731 | -                if ( isset( $cf['description'] ) && $cf['description'] ) {
 | |
| 732 | - echo '<div class="gdcf-tooltip">' . $cf['description'] . '</div>'; | |
| 733 | - } ?> | |
| 731 | +				if ( isset( $cf['description'] ) && $cf['description'] ) {
 | |
| 732 | + echo '<div class="gdcf-tooltip">' . $cf['description'] . '</div>'; | |
| 733 | + } ?> | |
| 734 | 734 | |
| 735 | 735 | <a id="gd-<?php echo $id; ?>" | 
| 736 | 736 | data-field-custom-type="<?php echo $type; ?>" | 
| @@ -740,21 +740,21 @@ discard block | ||
| 740 | 740 | href="javascript:void(0);"> | 
| 741 | 741 | |
| 742 | 742 |                      <?php if ( isset( $cf['icon'] ) && strpos( $cf['icon'], 'fa fa-' ) !== false ) {
 | 
| 743 | - echo '<i class="' . $cf['icon'] . '" aria-hidden="true"></i>'; | |
| 744 | -                    } elseif ( isset( $cf['icon'] ) && $cf['icon'] ) {
 | |
| 745 | -                        echo '<b style="background-image: url("' . $cf['icon'] . '")"></b>';
 | |
| 746 | -                    } else {
 | |
| 747 | - echo '<i class="fa fa-cog" aria-hidden="true"></i>'; | |
| 748 | - } ?> | |
| 743 | + echo '<i class="' . $cf['icon'] . '" aria-hidden="true"></i>'; | |
| 744 | +					} elseif ( isset( $cf['icon'] ) && $cf['icon'] ) {
 | |
| 745 | +						echo '<b style="background-image: url("' . $cf['icon'] . '")"></b>';
 | |
| 746 | +					} else {
 | |
| 747 | + echo '<i class="fa fa-cog" aria-hidden="true"></i>'; | |
| 748 | + } ?> | |
| 749 | 749 | <?php echo $cf['name']; ?> | 
| 750 | 750 | </a> | 
| 751 | 751 | </li> | 
| 752 | 752 | <?php | 
| 753 | - } | |
| 754 | -    }else{
 | |
| 755 | -        _e('There are no custom fields here yet.', 'geodirectory');
 | |
| 756 | - } | |
| 757 | - ?> | |
| 753 | + } | |
| 754 | +	}else{
 | |
| 755 | +		_e('There are no custom fields here yet.', 'geodirectory');
 | |
| 756 | + } | |
| 757 | + ?> | |
| 758 | 758 | |
| 759 | 759 | |
| 760 | 760 | </ul> | 
| @@ -773,26 +773,26 @@ discard block | ||
| 773 | 773 | */ | 
| 774 | 774 | function geodir_custom_selected_fields() | 
| 775 | 775 |  {
 | 
| 776 | - $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; | |
| 777 | - ?> | |
| 776 | + $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; | |
| 777 | + ?> | |
| 778 | 778 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> | 
| 779 | 779 | <ul class="core"> | 
| 780 | 780 | <?php | 
| 781 | - global $wpdb; | |
| 782 | -        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
 | |
| 783 | - | |
| 784 | -        if (!empty($fields)) {
 | |
| 785 | -            foreach ($fields as $field) {
 | |
| 786 | - //$result_str = $field->id; | |
| 787 | - $result_str = $field; | |
| 788 | - $field_type = $field->field_type; | |
| 789 | - $field_type_key = $field->field_type_key; | |
| 790 | - $field_ins_upd = 'display'; | |
| 791 | - | |
| 792 | - geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key); | |
| 793 | - } | |
| 794 | - } | |
| 795 | - ?></ul> | |
| 781 | + global $wpdb; | |
| 782 | +		$fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
 | |
| 783 | + | |
| 784 | +		if (!empty($fields)) {
 | |
| 785 | +			foreach ($fields as $field) {
 | |
| 786 | + //$result_str = $field->id; | |
| 787 | + $result_str = $field; | |
| 788 | + $field_type = $field->field_type; | |
| 789 | + $field_type_key = $field->field_type_key; | |
| 790 | + $field_ins_upd = 'display'; | |
| 791 | + | |
| 792 | + geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key); | |
| 793 | + } | |
| 794 | + } | |
| 795 | + ?></ul> | |
| 796 | 796 | <?php | 
| 797 | 797 | |
| 798 | 798 | } | 
| @@ -811,16 +811,16 @@ discard block | ||
| 811 | 811 | function geodir_custom_fields_panel_head($heading, $sub_tab, $listing_type) | 
| 812 | 812 |  {
 | 
| 813 | 813 | |
| 814 | -    switch ($sub_tab) {
 | |
| 815 | - case 'custom_fields': | |
| 816 | -            $heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 817 | - break; | |
| 814 | +	switch ($sub_tab) {
 | |
| 815 | + case 'custom_fields': | |
| 816 | +			$heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 817 | + break; | |
| 818 | 818 | |
| 819 | - case 'sorting_options': | |
| 820 | -            $heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 821 | - break; | |
| 822 | - } | |
| 823 | - return $heading; | |
| 819 | + case 'sorting_options': | |
| 820 | +			$heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 821 | + break; | |
| 822 | + } | |
| 823 | + return $heading; | |
| 824 | 824 | } | 
| 825 | 825 | |
| 826 | 826 | |
| @@ -838,16 +838,16 @@ discard block | ||
| 838 | 838 | function geodir_cf_panel_available_fields_head($heading, $sub_tab, $listing_type) | 
| 839 | 839 |  {
 | 
| 840 | 840 | |
| 841 | -    switch ($sub_tab) {
 | |
| 842 | - case 'custom_fields': | |
| 843 | -            $heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 844 | - break; | |
| 841 | +	switch ($sub_tab) {
 | |
| 842 | + case 'custom_fields': | |
| 843 | +			$heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 844 | + break; | |
| 845 | 845 | |
| 846 | - case 'sorting_options': | |
| 847 | -            $heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 848 | - break; | |
| 849 | - } | |
| 850 | - return $heading; | |
| 846 | + case 'sorting_options': | |
| 847 | +			$heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 848 | + break; | |
| 849 | + } | |
| 850 | + return $heading; | |
| 851 | 851 | } | 
| 852 | 852 | |
| 853 | 853 | |
| @@ -865,16 +865,16 @@ discard block | ||
| 865 | 865 | function geodir_cf_panel_available_fields_note($note, $sub_tab, $listing_type) | 
| 866 | 866 |  {
 | 
| 867 | 867 | |
| 868 | -    switch ($sub_tab) {
 | |
| 869 | - case 'custom_fields': | |
| 870 | -            $note = sprintf(__('Click on any box below to add a field of that type to the add %s listing form. You can use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type));;
 | |
| 871 | - break; | |
| 868 | +	switch ($sub_tab) {
 | |
| 869 | + case 'custom_fields': | |
| 870 | +			$note = sprintf(__('Click on any box below to add a field of that type to the add %s listing form. You can use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type));;
 | |
| 871 | + break; | |
| 872 | 872 | |
| 873 | - case 'sorting_options': | |
| 874 | -            $note = sprintf(__('Click on any box below to make it appear in the sorting option dropdown on %s listing and search results.<br />To make a field available here, go to custom fields tab and expand any field from selected fields panel and tick the checkbox saying \'Include this field in sort option\'.', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 875 | - break; | |
| 876 | - } | |
| 877 | - return $note; | |
| 873 | + case 'sorting_options': | |
| 874 | +			$note = sprintf(__('Click on any box below to make it appear in the sorting option dropdown on %s listing and search results.<br />To make a field available here, go to custom fields tab and expand any field from selected fields panel and tick the checkbox saying \'Include this field in sort option\'.', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 875 | + break; | |
| 876 | + } | |
| 877 | + return $note; | |
| 878 | 878 | } | 
| 879 | 879 | |
| 880 | 880 | |
| @@ -892,16 +892,16 @@ discard block | ||
| 892 | 892 | function geodir_cf_panel_selected_fields_head($heading, $sub_tab, $listing_type) | 
| 893 | 893 |  {
 | 
| 894 | 894 | |
| 895 | -    switch ($sub_tab) {
 | |
| 896 | - case 'custom_fields': | |
| 897 | -            $heading = sprintf(__('List of fields that will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 898 | - break; | |
| 895 | +	switch ($sub_tab) {
 | |
| 896 | + case 'custom_fields': | |
| 897 | +			$heading = sprintf(__('List of fields that will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 898 | + break; | |
| 899 | 899 | |
| 900 | - case 'sorting_options': | |
| 901 | -            $heading = sprintf(__('List of fields that will appear in %s listing and search results sorting option dropdown box.', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 902 | - break; | |
| 903 | - } | |
| 904 | - return $heading; | |
| 900 | + case 'sorting_options': | |
| 901 | +			$heading = sprintf(__('List of fields that will appear in %s listing and search results sorting option dropdown box.', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 902 | + break; | |
| 903 | + } | |
| 904 | + return $heading; | |
| 905 | 905 | } | 
| 906 | 906 | |
| 907 | 907 | |
| @@ -919,16 +919,16 @@ discard block | ||
| 919 | 919 | function geodir_cf_panel_selected_fields_note($note, $sub_tab, $listing_type) | 
| 920 | 920 |  {
 | 
| 921 | 921 | |
| 922 | -    switch ($sub_tab) {
 | |
| 923 | - case 'custom_fields': | |
| 924 | -            $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order on add %s listing form too.', 'geodirectory'), get_post_type_singular_label($listing_type));;
 | |
| 925 | - break; | |
| 922 | +	switch ($sub_tab) {
 | |
| 923 | + case 'custom_fields': | |
| 924 | +			$note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order on add %s listing form too.', 'geodirectory'), get_post_type_singular_label($listing_type));;
 | |
| 925 | + break; | |
| 926 | 926 | |
| 927 | - case 'sorting_options': | |
| 928 | -            $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order in sorting option dropdown box on %s listing and search results page.', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 929 | - break; | |
| 930 | - } | |
| 931 | - return $note; | |
| 927 | + case 'sorting_options': | |
| 928 | +			$note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order in sorting option dropdown box on %s listing and search results page.', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 929 | + break; | |
| 930 | + } | |
| 931 | + return $note; | |
| 932 | 932 | } | 
| 933 | 933 | |
| 934 | 934 | |
| @@ -944,16 +944,16 @@ discard block | ||
| 944 | 944 | */ | 
| 945 | 945 | function geodir_remove_unnecessary_fields() | 
| 946 | 946 |  {
 | 
| 947 | - global $wpdb, $plugin_prefix; | |
| 947 | + global $wpdb, $plugin_prefix; | |
| 948 | 948 | |
| 949 | -    if (!get_option('geodir_remove_unnecessary_fields')) {
 | |
| 949 | +	if (!get_option('geodir_remove_unnecessary_fields')) {
 | |
| 950 | 950 | |
| 951 | -        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
 | |
| 952 | -            $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
 | |
| 951 | +		if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
 | |
| 952 | +			$wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
 | |
| 953 | 953 | |
| 954 | -        update_option('geodir_remove_unnecessary_fields', '1');
 | |
| 954 | +		update_option('geodir_remove_unnecessary_fields', '1');
 | |
| 955 | 955 | |
| 956 | - } | |
| 956 | + } | |
| 957 | 957 | |
| 958 | 958 | } | 
| 959 | 959 | |
| @@ -971,25 +971,25 @@ discard block | ||
| 971 | 971 | */ | 
| 972 | 972 | function geodir_admin_ajax_handler() | 
| 973 | 973 |  {
 | 
| 974 | -    if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
 | |
| 975 | - $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action']; | |
| 976 | -        switch ($geodir_admin_ajax_action) {
 | |
| 977 | - case 'diagnosis' : | |
| 978 | - if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') | |
| 979 | - $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); | |
| 980 | -                call_user_func('geodir_diagnose_' . $diagnose_this);
 | |
| 981 | - exit(); | |
| 982 | - break; | |
| 983 | - | |
| 984 | - case 'diagnosis-fix' : | |
| 985 | - if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') | |
| 986 | - $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); | |
| 987 | -                call_user_func('geodir_diagnose_' . $diagnose_this);
 | |
| 988 | - exit(); | |
| 989 | - break; | |
| 990 | - } | |
| 991 | - } | |
| 992 | - exit(); | |
| 974 | +	if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
 | |
| 975 | + $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action']; | |
| 976 | +		switch ($geodir_admin_ajax_action) {
 | |
| 977 | + case 'diagnosis' : | |
| 978 | + if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') | |
| 979 | + $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); | |
| 980 | +				call_user_func('geodir_diagnose_' . $diagnose_this);
 | |
| 981 | + exit(); | |
| 982 | + break; | |
| 983 | + | |
| 984 | + case 'diagnosis-fix' : | |
| 985 | + if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') | |
| 986 | + $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); | |
| 987 | +				call_user_func('geodir_diagnose_' . $diagnose_this);
 | |
| 988 | + exit(); | |
| 989 | + break; | |
| 990 | + } | |
| 991 | + } | |
| 992 | + exit(); | |
| 993 | 993 | } | 
| 994 | 994 | |
| 995 | 995 | |
| @@ -1007,127 +1007,127 @@ discard block | ||
| 1007 | 1007 | */ | 
| 1008 | 1008 | function geodir_diagnose_multisite_table($filter_arr, $table, $tabel_name, $fix) | 
| 1009 | 1009 |  {
 | 
| 1010 | - global $wpdb; | |
| 1011 | - //$filter_arr['output_str'] .='###'.$table.'###'; | |
| 1012 | -    if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
 | |
| 1013 | -        $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
 | |
| 1014 | - $filter_arr['is_error_during_diagnose'] = true; | |
| 1015 | - | |
| 1016 | -    } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
 | |
| 1017 | -        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 1018 | - $filter_arr['is_error_during_diagnose'] = true; | |
| 1019 | -        $filter_arr['output_str'] .= "<li>" . __('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory') . "</li>";
 | |
| 1020 | - $filter_arr['is_error_during_diagnose'] = true; | |
| 1021 | - | |
| 1022 | -        if ($fix) {
 | |
| 1023 | -            $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
 | |
| 1024 | -            $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
 | |
| 1025 | - | |
| 1026 | -            if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
 | |
| 1027 | -                //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
 | |
| 1028 | - | |
| 1029 | -                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
 | |
| 1030 | - | |
| 1031 | -                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
 | |
| 1032 | -                    $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
 | |
| 1033 | -                } else {
 | |
| 1034 | -                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
 | |
| 1035 | - } | |
| 1036 | - | |
| 1037 | -            } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
 | |
| 1038 | - | |
| 1039 | -                $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
 | |
| 1040 | -                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
 | |
| 1041 | - | |
| 1042 | -                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 1043 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
 | |
| 1044 | -                } else {
 | |
| 1045 | -                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
 | |
| 1046 | - } | |
| 1047 | - | |
| 1048 | -            } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
 | |
| 1049 | - | |
| 1050 | -                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
 | |
| 1051 | - | |
| 1052 | -                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
 | |
| 1053 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
 | |
| 1054 | -                } else {
 | |
| 1055 | -                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
 | |
| 1056 | - } | |
| 1057 | - | |
| 1058 | - } | |
| 1059 | - | |
| 1060 | - } | |
| 1061 | - | |
| 1062 | - | |
| 1063 | -    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
 | |
| 1064 | -        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 1065 | - $filter_arr['is_error_during_diagnose'] = true; | |
| 1066 | - | |
| 1067 | -        if ($fix) {
 | |
| 1068 | -            if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
 | |
| 1069 | -                if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
 | |
| 1070 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
 | |
| 1071 | -                } else {
 | |
| 1072 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
 | |
| 1073 | - } | |
| 1074 | - | |
| 1075 | -            } elseif ($wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table") == 0) {// if main table is empty but original is not, delete main and rename original
 | |
| 1076 | -                if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
 | |
| 1077 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
 | |
| 1078 | -                } else {
 | |
| 1079 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
 | |
| 1080 | - } | |
| 1081 | -                if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 1082 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
 | |
| 1083 | -                } else {
 | |
| 1084 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
 | |
| 1085 | - } | |
| 1086 | -            } else {// else rename the original table to _ms_bak
 | |
| 1087 | -                if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 1088 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
 | |
| 1089 | -                } else {
 | |
| 1090 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
 | |
| 1091 | - } | |
| 1092 | - } | |
| 1093 | - } | |
| 1094 | - | |
| 1095 | -    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
 | |
| 1096 | -        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 1097 | - $filter_arr['is_error_during_diagnose'] = true; | |
| 1098 | - | |
| 1099 | -        if ($fix) {
 | |
| 1100 | - // if original table exists but new does not, rename | |
| 1101 | -            if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 1102 | -                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
 | |
| 1103 | -            } else {
 | |
| 1104 | -                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
 | |
| 1105 | - } | |
| 1106 | - | |
| 1107 | - } | |
| 1108 | - | |
| 1109 | -    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
 | |
| 1110 | -        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 1111 | - $filter_arr['is_error_during_diagnose'] = true; | |
| 1112 | - | |
| 1113 | -        if ($fix) {
 | |
| 1114 | - // if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run; | |
| 1115 | -            delete_option('geodirlocation_db_version');
 | |
| 1116 | -            delete_option('geodirevents_db_version');
 | |
| 1117 | -            delete_option('geodir_reviewrating_db_version');
 | |
| 1118 | -            delete_option('gdevents_db_version');
 | |
| 1119 | -            delete_option('geodirectory_db_version');
 | |
| 1120 | -            delete_option('geodirclaim_db_version');
 | |
| 1121 | -            delete_option('geodir_custom_posts_db_version');
 | |
| 1122 | -            delete_option('geodir_reviewratings_db_version');
 | |
| 1123 | -            delete_option('geodiradvancesearch_db_version');
 | |
| 1124 | -            $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
 | |
| 1125 | - } | |
| 1126 | - | |
| 1127 | -    } else {
 | |
| 1128 | -        $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 1129 | - } | |
| 1130 | - return $filter_arr; | |
| 1010 | + global $wpdb; | |
| 1011 | + //$filter_arr['output_str'] .='###'.$table.'###'; | |
| 1012 | +	if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
 | |
| 1013 | +		$filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
 | |
| 1014 | + $filter_arr['is_error_during_diagnose'] = true; | |
| 1015 | + | |
| 1016 | +	} elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
 | |
| 1017 | +		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 1018 | + $filter_arr['is_error_during_diagnose'] = true; | |
| 1019 | +		$filter_arr['output_str'] .= "<li>" . __('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory') . "</li>";
 | |
| 1020 | + $filter_arr['is_error_during_diagnose'] = true; | |
| 1021 | + | |
| 1022 | +		if ($fix) {
 | |
| 1023 | +			$ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
 | |
| 1024 | +			$new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
 | |
| 1025 | + | |
| 1026 | +			if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
 | |
| 1027 | +				//$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
 | |
| 1028 | + | |
| 1029 | +				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
 | |
| 1030 | + | |
| 1031 | +				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
 | |
| 1032 | +					$filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
 | |
| 1033 | +				} else {
 | |
| 1034 | +					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
 | |
| 1035 | + } | |
| 1036 | + | |
| 1037 | +			} elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
 | |
| 1038 | + | |
| 1039 | +				$wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
 | |
| 1040 | +				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
 | |
| 1041 | + | |
| 1042 | +				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 1043 | +					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
 | |
| 1044 | +				} else {
 | |
| 1045 | +					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
 | |
| 1046 | + } | |
| 1047 | + | |
| 1048 | +			} elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
 | |
| 1049 | + | |
| 1050 | +				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
 | |
| 1051 | + | |
| 1052 | +				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
 | |
| 1053 | +					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
 | |
| 1054 | +				} else {
 | |
| 1055 | +					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
 | |
| 1056 | + } | |
| 1057 | + | |
| 1058 | + } | |
| 1059 | + | |
| 1060 | + } | |
| 1061 | + | |
| 1062 | + | |
| 1063 | +	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
 | |
| 1064 | +		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 1065 | + $filter_arr['is_error_during_diagnose'] = true; | |
| 1066 | + | |
| 1067 | +		if ($fix) {
 | |
| 1068 | +			if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
 | |
| 1069 | +				if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
 | |
| 1070 | +					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
 | |
| 1071 | +				} else {
 | |
| 1072 | +					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
 | |
| 1073 | + } | |
| 1074 | + | |
| 1075 | +			} elseif ($wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table") == 0) {// if main table is empty but original is not, delete main and rename original
 | |
| 1076 | +				if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
 | |
| 1077 | +					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
 | |
| 1078 | +				} else {
 | |
| 1079 | +					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
 | |
| 1080 | + } | |
| 1081 | +				if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 1082 | +					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
 | |
| 1083 | +				} else {
 | |
| 1084 | +					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
 | |
| 1085 | + } | |
| 1086 | +			} else {// else rename the original table to _ms_bak
 | |
| 1087 | +				if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 1088 | +					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
 | |
| 1089 | +				} else {
 | |
| 1090 | +					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
 | |
| 1091 | + } | |
| 1092 | + } | |
| 1093 | + } | |
| 1094 | + | |
| 1095 | +	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
 | |
| 1096 | +		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 1097 | + $filter_arr['is_error_during_diagnose'] = true; | |
| 1098 | + | |
| 1099 | +		if ($fix) {
 | |
| 1100 | + // if original table exists but new does not, rename | |
| 1101 | +			if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 1102 | +				$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
 | |
| 1103 | +			} else {
 | |
| 1104 | +				$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
 | |
| 1105 | + } | |
| 1106 | + | |
| 1107 | + } | |
| 1108 | + | |
| 1109 | +	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
 | |
| 1110 | +		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 1111 | + $filter_arr['is_error_during_diagnose'] = true; | |
| 1112 | + | |
| 1113 | +		if ($fix) {
 | |
| 1114 | + // if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run; | |
| 1115 | +			delete_option('geodirlocation_db_version');
 | |
| 1116 | +			delete_option('geodirevents_db_version');
 | |
| 1117 | +			delete_option('geodir_reviewrating_db_version');
 | |
| 1118 | +			delete_option('gdevents_db_version');
 | |
| 1119 | +			delete_option('geodirectory_db_version');
 | |
| 1120 | +			delete_option('geodirclaim_db_version');
 | |
| 1121 | +			delete_option('geodir_custom_posts_db_version');
 | |
| 1122 | +			delete_option('geodir_reviewratings_db_version');
 | |
| 1123 | +			delete_option('geodiradvancesearch_db_version');
 | |
| 1124 | +			$filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
 | |
| 1125 | + } | |
| 1126 | + | |
| 1127 | +	} else {
 | |
| 1128 | +		$filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 1129 | + } | |
| 1130 | + return $filter_arr; | |
| 1131 | 1131 | } | 
| 1132 | 1132 | |
| 1133 | 1133 | |
| @@ -1141,53 +1141,53 @@ discard block | ||
| 1141 | 1141 | */ | 
| 1142 | 1142 | function geodir_diagnose_tags_sync() | 
| 1143 | 1143 |  {
 | 
| 1144 | - global $wpdb, $plugin_prefix; | |
| 1145 | - $fix = isset($_POST['fix']) ? true : false; | |
| 1146 | - | |
| 1147 | -    //if($fix){echo 'true';}else{echo 'false';}
 | |
| 1148 | - $is_error_during_diagnose = false; | |
| 1149 | - $output_str = ''; | |
| 1150 | - | |
| 1151 | - | |
| 1152 | - $all_postypes = geodir_get_posttypes(); | |
| 1153 | - | |
| 1154 | -    if (!empty($all_postypes)) {
 | |
| 1155 | -        foreach ($all_postypes as $key) {
 | |
| 1156 | - // update each GD CPT | |
| 1157 | -            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
 | |
| 1158 | - | |
| 1159 | -            if (!empty($posts)) {
 | |
| 1160 | - | |
| 1161 | -                foreach ($posts as $p) {
 | |
| 1162 | - $p->post_type = $key; | |
| 1163 | -                    $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
 | |
| 1164 | -                    if (empty($raw_tags)) {
 | |
| 1165 | - $post_tags = ''; | |
| 1166 | -                    } else {
 | |
| 1167 | -                        $post_tags = implode(",", $raw_tags);
 | |
| 1168 | - } | |
| 1169 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; | |
| 1170 | -                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
 | |
| 1171 | - | |
| 1172 | - } | |
| 1173 | -                $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
 | |
| 1174 | - } | |
| 1175 | - | |
| 1176 | - } | |
| 1177 | - | |
| 1178 | - } | |
| 1179 | - | |
| 1180 | -    if ($is_error_during_diagnose) {
 | |
| 1181 | - $info_div_class = "geodir_problem_info"; | |
| 1182 | -        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
 | |
| 1183 | -    } else {
 | |
| 1184 | - $info_div_class = "geodir_noproblem_info"; | |
| 1185 | - $fix_button_txt = ''; | |
| 1186 | - } | |
| 1187 | - echo "<ul class='$info_div_class'>"; | |
| 1188 | - echo $output_str; | |
| 1189 | - echo $fix_button_txt; | |
| 1190 | - echo "</ul>"; | |
| 1144 | + global $wpdb, $plugin_prefix; | |
| 1145 | + $fix = isset($_POST['fix']) ? true : false; | |
| 1146 | + | |
| 1147 | +	//if($fix){echo 'true';}else{echo 'false';}
 | |
| 1148 | + $is_error_during_diagnose = false; | |
| 1149 | + $output_str = ''; | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + $all_postypes = geodir_get_posttypes(); | |
| 1153 | + | |
| 1154 | +	if (!empty($all_postypes)) {
 | |
| 1155 | +		foreach ($all_postypes as $key) {
 | |
| 1156 | + // update each GD CPT | |
| 1157 | +			$posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
 | |
| 1158 | + | |
| 1159 | +			if (!empty($posts)) {
 | |
| 1160 | + | |
| 1161 | +				foreach ($posts as $p) {
 | |
| 1162 | + $p->post_type = $key; | |
| 1163 | +					$raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
 | |
| 1164 | +					if (empty($raw_tags)) {
 | |
| 1165 | + $post_tags = ''; | |
| 1166 | +					} else {
 | |
| 1167 | +						$post_tags = implode(",", $raw_tags);
 | |
| 1168 | + } | |
| 1169 | + $tablename = $plugin_prefix . $p->post_type . '_detail'; | |
| 1170 | +					$wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
 | |
| 1171 | + | |
| 1172 | + } | |
| 1173 | +				$output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
 | |
| 1174 | + } | |
| 1175 | + | |
| 1176 | + } | |
| 1177 | + | |
| 1178 | + } | |
| 1179 | + | |
| 1180 | +	if ($is_error_during_diagnose) {
 | |
| 1181 | + $info_div_class = "geodir_problem_info"; | |
| 1182 | +		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
 | |
| 1183 | +	} else {
 | |
| 1184 | + $info_div_class = "geodir_noproblem_info"; | |
| 1185 | + $fix_button_txt = ''; | |
| 1186 | + } | |
| 1187 | + echo "<ul class='$info_div_class'>"; | |
| 1188 | + echo $output_str; | |
| 1189 | + echo $fix_button_txt; | |
| 1190 | + echo "</ul>"; | |
| 1191 | 1191 | |
| 1192 | 1192 | } | 
| 1193 | 1193 | |
| @@ -1203,75 +1203,75 @@ discard block | ||
| 1203 | 1203 | */ | 
| 1204 | 1204 | function geodir_diagnose_cats_sync() | 
| 1205 | 1205 |  {
 | 
| 1206 | - global $wpdb, $plugin_prefix; | |
| 1207 | - $fix = isset($_POST['fix']) ? true : false; | |
| 1206 | + global $wpdb, $plugin_prefix; | |
| 1207 | + $fix = isset($_POST['fix']) ? true : false; | |
| 1208 | 1208 | |
| 1209 | -    //if($fix){echo 'true';}else{echo 'false';}
 | |
| 1210 | - $is_error_during_diagnose = false; | |
| 1211 | - $output_str = ''; | |
| 1209 | +	//if($fix){echo 'true';}else{echo 'false';}
 | |
| 1210 | + $is_error_during_diagnose = false; | |
| 1211 | + $output_str = ''; | |
| 1212 | 1212 | |
| 1213 | 1213 | |
| 1214 | - $all_postypes = geodir_get_posttypes(); | |
| 1214 | + $all_postypes = geodir_get_posttypes(); | |
| 1215 | 1215 | |
| 1216 | -    if (!empty($all_postypes)) {
 | |
| 1217 | -        foreach ($all_postypes as $key) {
 | |
| 1218 | - // update each GD CTP | |
| 1219 | -            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
 | |
| 1216 | +	if (!empty($all_postypes)) {
 | |
| 1217 | +		foreach ($all_postypes as $key) {
 | |
| 1218 | + // update each GD CTP | |
| 1219 | +			$posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
 | |
| 1220 | 1220 | |
| 1221 | -            if (!empty($posts)) {
 | |
| 1221 | +			if (!empty($posts)) {
 | |
| 1222 | 1222 | |
| 1223 | -                foreach ($posts as $p) {
 | |
| 1224 | - $p->post_type = $key; | |
| 1225 | -                    $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
 | |
| 1223 | +				foreach ($posts as $p) {
 | |
| 1224 | + $p->post_type = $key; | |
| 1225 | +					$raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
 | |
| 1226 | 1226 | |
| 1227 | -                    if (empty($raw_cats)) {
 | |
| 1228 | - $post_categories = get_post_meta($p->post_id, 'post_categories', true); | |
| 1227 | +					if (empty($raw_cats)) {
 | |
| 1228 | + $post_categories = get_post_meta($p->post_id, 'post_categories', true); | |
| 1229 | 1229 | |
| 1230 | -                        if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
 | |
| 1231 | -                            $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
 | |
| 1232 | -                            foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
 | |
| 1233 | -                                if (is_numeric($cat_part)) {
 | |
| 1234 | - $raw_cats[] = (int)$cat_part; | |
| 1235 | - } | |
| 1236 | - } | |
| 1230 | +						if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
 | |
| 1231 | +							$post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
 | |
| 1232 | +							foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
 | |
| 1233 | +								if (is_numeric($cat_part)) {
 | |
| 1234 | + $raw_cats[] = (int)$cat_part; | |
| 1235 | + } | |
| 1236 | + } | |
| 1237 | 1237 | |
| 1238 | - } | |
| 1238 | + } | |
| 1239 | 1239 | |
| 1240 | -                        if (!empty($raw_cats)) {
 | |
| 1241 | - $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category'); | |
| 1240 | +						if (!empty($raw_cats)) {
 | |
| 1241 | + $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category'); | |
| 1242 | 1242 | |
| 1243 | - } | |
| 1243 | + } | |
| 1244 | 1244 | |
| 1245 | - } | |
| 1245 | + } | |
| 1246 | 1246 | |
| 1247 | 1247 | |
| 1248 | -                    if (empty($raw_cats)) {
 | |
| 1249 | - $post_cats = ''; | |
| 1250 | -                    } else {
 | |
| 1251 | -                        $post_cats = ',' . implode(",", $raw_cats) . ',';
 | |
| 1252 | - } | |
| 1253 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; | |
| 1254 | -                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
 | |
| 1255 | - } | |
| 1248 | +					if (empty($raw_cats)) {
 | |
| 1249 | + $post_cats = ''; | |
| 1250 | +					} else {
 | |
| 1251 | +						$post_cats = ',' . implode(",", $raw_cats) . ',';
 | |
| 1252 | + } | |
| 1253 | + $tablename = $plugin_prefix . $p->post_type . '_detail'; | |
| 1254 | +					$wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
 | |
| 1255 | + } | |
| 1256 | 1256 | |
| 1257 | - } | |
| 1258 | -            $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
 | |
| 1257 | + } | |
| 1258 | +			$output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
 | |
| 1259 | 1259 | |
| 1260 | - } | |
| 1260 | + } | |
| 1261 | 1261 | |
| 1262 | - } | |
| 1262 | + } | |
| 1263 | 1263 | |
| 1264 | -    if ($is_error_during_diagnose) {
 | |
| 1265 | - $info_div_class = "geodir_problem_info"; | |
| 1266 | -        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
 | |
| 1267 | -    } else {
 | |
| 1268 | - $info_div_class = "geodir_noproblem_info"; | |
| 1269 | - $fix_button_txt = ''; | |
| 1270 | - } | |
| 1271 | - echo "<ul class='$info_div_class'>"; | |
| 1272 | - echo $output_str; | |
| 1273 | - echo $fix_button_txt; | |
| 1274 | - echo "</ul>"; | |
| 1264 | +	if ($is_error_during_diagnose) {
 | |
| 1265 | + $info_div_class = "geodir_problem_info"; | |
| 1266 | +		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
 | |
| 1267 | +	} else {
 | |
| 1268 | + $info_div_class = "geodir_noproblem_info"; | |
| 1269 | + $fix_button_txt = ''; | |
| 1270 | + } | |
| 1271 | + echo "<ul class='$info_div_class'>"; | |
| 1272 | + echo $output_str; | |
| 1273 | + echo $fix_button_txt; | |
| 1274 | + echo "</ul>"; | |
| 1275 | 1275 | |
| 1276 | 1276 | } | 
| 1277 | 1277 | |
| @@ -1285,61 +1285,61 @@ discard block | ||
| 1285 | 1285 | */ | 
| 1286 | 1286 | function geodir_diagnose_version_clear() | 
| 1287 | 1287 |  {
 | 
| 1288 | - global $wpdb, $plugin_prefix; | |
| 1289 | - $fix = isset($_POST['fix']) ? true : false; | |
| 1290 | - | |
| 1291 | -    //if($fix){echo 'true';}else{echo 'false';}
 | |
| 1292 | - $is_error_during_diagnose = false; | |
| 1293 | - $output_str = ''; | |
| 1294 | - | |
| 1295 | - | |
| 1296 | -    $gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
 | |
| 1297 | - 'Payment Manager' => 'geodir_payments_db_version', | |
| 1298 | - 'GeoDirectory Framework' => 'gdf_db_version', | |
| 1299 | - 'Advanced Search' => 'geodiradvancesearch_db_version', | |
| 1300 | - 'Review Rating Manager' => 'geodir_reviewratings_db_version', | |
| 1301 | - 'Claim Manager' => 'geodirclaim_db_version', | |
| 1302 | - 'CPT Manager' => 'geodir_custom_posts_db_version', | |
| 1303 | - 'Location Manager' => 'geodirlocation_db_version', | |
| 1304 | - 'Payment Manager' => 'geodir_payments_db_version', | |
| 1305 | - 'Events Manager' => 'geodirevents_db_version', | |
| 1306 | - ); | |
| 1307 | - | |
| 1308 | - /** | |
| 1309 | - * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers. | |
| 1310 | - * | |
| 1311 | - * @since 1.0.0 | |
| 1312 | -     * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
 | |
| 1313 | - */ | |
| 1314 | -    $ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
 | |
| 1315 | - | |
| 1316 | -    if (!empty($ver_arr)) {
 | |
| 1317 | -        foreach ($ver_arr as $key => $val) {
 | |
| 1318 | -            if (delete_option($val)) {
 | |
| 1319 | -                $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
 | |
| 1320 | -            } else {
 | |
| 1321 | -                $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
 | |
| 1322 | - } | |
| 1323 | - | |
| 1324 | - } | |
| 1325 | - | |
| 1326 | -        if ($output_str) {
 | |
| 1327 | -            $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
 | |
| 1328 | - } | |
| 1329 | - | |
| 1330 | - } | |
| 1331 | - | |
| 1332 | -    if ($is_error_during_diagnose) {
 | |
| 1333 | - $info_div_class = "geodir_problem_info"; | |
| 1334 | - $fix_button_txt = ""; | |
| 1335 | -    } else {
 | |
| 1336 | - $info_div_class = "geodir_noproblem_info"; | |
| 1337 | - $fix_button_txt = ''; | |
| 1338 | - } | |
| 1339 | - echo "<ul class='$info_div_class'>"; | |
| 1340 | - echo $output_str; | |
| 1341 | - echo $fix_button_txt; | |
| 1342 | - echo "</ul>"; | |
| 1288 | + global $wpdb, $plugin_prefix; | |
| 1289 | + $fix = isset($_POST['fix']) ? true : false; | |
| 1290 | + | |
| 1291 | +	//if($fix){echo 'true';}else{echo 'false';}
 | |
| 1292 | + $is_error_during_diagnose = false; | |
| 1293 | + $output_str = ''; | |
| 1294 | + | |
| 1295 | + | |
| 1296 | +	$gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
 | |
| 1297 | + 'Payment Manager' => 'geodir_payments_db_version', | |
| 1298 | + 'GeoDirectory Framework' => 'gdf_db_version', | |
| 1299 | + 'Advanced Search' => 'geodiradvancesearch_db_version', | |
| 1300 | + 'Review Rating Manager' => 'geodir_reviewratings_db_version', | |
| 1301 | + 'Claim Manager' => 'geodirclaim_db_version', | |
| 1302 | + 'CPT Manager' => 'geodir_custom_posts_db_version', | |
| 1303 | + 'Location Manager' => 'geodirlocation_db_version', | |
| 1304 | + 'Payment Manager' => 'geodir_payments_db_version', | |
| 1305 | + 'Events Manager' => 'geodirevents_db_version', | |
| 1306 | + ); | |
| 1307 | + | |
| 1308 | + /** | |
| 1309 | + * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers. | |
| 1310 | + * | |
| 1311 | + * @since 1.0.0 | |
| 1312 | +	 * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
 | |
| 1313 | + */ | |
| 1314 | +	$ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
 | |
| 1315 | + | |
| 1316 | +	if (!empty($ver_arr)) {
 | |
| 1317 | +		foreach ($ver_arr as $key => $val) {
 | |
| 1318 | +			if (delete_option($val)) {
 | |
| 1319 | +				$output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
 | |
| 1320 | +			} else {
 | |
| 1321 | +				$output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
 | |
| 1322 | + } | |
| 1323 | + | |
| 1324 | + } | |
| 1325 | + | |
| 1326 | +		if ($output_str) {
 | |
| 1327 | +			$output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
 | |
| 1328 | + } | |
| 1329 | + | |
| 1330 | + } | |
| 1331 | + | |
| 1332 | +	if ($is_error_during_diagnose) {
 | |
| 1333 | + $info_div_class = "geodir_problem_info"; | |
| 1334 | + $fix_button_txt = ""; | |
| 1335 | +	} else {
 | |
| 1336 | + $info_div_class = "geodir_noproblem_info"; | |
| 1337 | + $fix_button_txt = ''; | |
| 1338 | + } | |
| 1339 | + echo "<ul class='$info_div_class'>"; | |
| 1340 | + echo $output_str; | |
| 1341 | + echo $fix_button_txt; | |
| 1342 | + echo "</ul>"; | |
| 1343 | 1343 | |
| 1344 | 1344 | } | 
| 1345 | 1345 | |
| @@ -1353,59 +1353,59 @@ discard block | ||
| 1353 | 1353 | */ | 
| 1354 | 1354 | function geodir_diagnose_ratings() | 
| 1355 | 1355 |  {
 | 
| 1356 | - global $wpdb; | |
| 1357 | - $fix = isset($_POST['fix']) ? true : false; | |
| 1358 | - | |
| 1359 | -    //if($fix){echo 'true';}else{echo 'false';}
 | |
| 1360 | - $is_error_during_diagnose = false; | |
| 1361 | - $output_str = ''; | |
| 1362 | - | |
| 1363 | - // check review locations | |
| 1364 | -    if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) {
 | |
| 1365 | -        $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
 | |
| 1366 | - $is_error_during_diagnose = true; | |
| 1367 | - | |
| 1368 | -        if ($fix) {
 | |
| 1369 | -            if (geodir_fix_review_location()) {
 | |
| 1370 | -                $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
 | |
| 1371 | -            } else {
 | |
| 1372 | -                $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1373 | - } | |
| 1374 | - } | |
| 1375 | - | |
| 1376 | -    } else {
 | |
| 1377 | -        $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
 | |
| 1378 | - } | |
| 1379 | - | |
| 1380 | - // check review content | |
| 1381 | -    if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
 | |
| 1382 | -        $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
 | |
| 1383 | - $is_error_during_diagnose = true; | |
| 1384 | - | |
| 1385 | -        if ($fix) {
 | |
| 1386 | -            if (geodir_fix_review_content()) {
 | |
| 1387 | -                $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
 | |
| 1388 | -            } else {
 | |
| 1389 | -                $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1390 | - } | |
| 1391 | - } | |
| 1392 | - | |
| 1393 | -    } else {
 | |
| 1394 | -        $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
 | |
| 1395 | - } | |
| 1396 | - | |
| 1397 | - | |
| 1398 | -    if ($is_error_during_diagnose) {
 | |
| 1399 | - $info_div_class = "geodir_problem_info"; | |
| 1400 | -        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
 | |
| 1401 | -    } else {
 | |
| 1402 | - $info_div_class = "geodir_noproblem_info"; | |
| 1403 | - $fix_button_txt = ''; | |
| 1404 | - } | |
| 1405 | - echo "<ul class='$info_div_class'>"; | |
| 1406 | - echo $output_str; | |
| 1407 | - echo $fix_button_txt; | |
| 1408 | - echo "</ul>"; | |
| 1356 | + global $wpdb; | |
| 1357 | + $fix = isset($_POST['fix']) ? true : false; | |
| 1358 | + | |
| 1359 | +	//if($fix){echo 'true';}else{echo 'false';}
 | |
| 1360 | + $is_error_during_diagnose = false; | |
| 1361 | + $output_str = ''; | |
| 1362 | + | |
| 1363 | + // check review locations | |
| 1364 | +	if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) {
 | |
| 1365 | +		$output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
 | |
| 1366 | + $is_error_during_diagnose = true; | |
| 1367 | + | |
| 1368 | +		if ($fix) {
 | |
| 1369 | +			if (geodir_fix_review_location()) {
 | |
| 1370 | +				$output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
 | |
| 1371 | +			} else {
 | |
| 1372 | +				$output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1373 | + } | |
| 1374 | + } | |
| 1375 | + | |
| 1376 | +	} else {
 | |
| 1377 | +		$output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
 | |
| 1378 | + } | |
| 1379 | + | |
| 1380 | + // check review content | |
| 1381 | +	if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
 | |
| 1382 | +		$output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
 | |
| 1383 | + $is_error_during_diagnose = true; | |
| 1384 | + | |
| 1385 | +		if ($fix) {
 | |
| 1386 | +			if (geodir_fix_review_content()) {
 | |
| 1387 | +				$output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
 | |
| 1388 | +			} else {
 | |
| 1389 | +				$output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1390 | + } | |
| 1391 | + } | |
| 1392 | + | |
| 1393 | +	} else {
 | |
| 1394 | +		$output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
 | |
| 1395 | + } | |
| 1396 | + | |
| 1397 | + | |
| 1398 | +	if ($is_error_during_diagnose) {
 | |
| 1399 | + $info_div_class = "geodir_problem_info"; | |
| 1400 | +		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
 | |
| 1401 | +	} else {
 | |
| 1402 | + $info_div_class = "geodir_noproblem_info"; | |
| 1403 | + $fix_button_txt = ''; | |
| 1404 | + } | |
| 1405 | + echo "<ul class='$info_div_class'>"; | |
| 1406 | + echo $output_str; | |
| 1407 | + echo $fix_button_txt; | |
| 1408 | + echo "</ul>"; | |
| 1409 | 1409 | |
| 1410 | 1410 | } | 
| 1411 | 1411 | |
| @@ -1419,57 +1419,57 @@ discard block | ||
| 1419 | 1419 | */ | 
| 1420 | 1420 | function geodir_diagnose_multisite_conversion() | 
| 1421 | 1421 |  {
 | 
| 1422 | - global $wpdb; | |
| 1423 | - $fix = isset($_POST['fix']) ? true : false; | |
| 1424 | -    //if($fix){echo 'true';}else{echo 'false';}
 | |
| 1425 | - $is_error_during_diagnose = false; | |
| 1426 | - $output_str = ''; | |
| 1427 | - | |
| 1428 | - $filter_arr = array(); | |
| 1429 | - $filter_arr['output_str'] = $output_str; | |
| 1430 | - $filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose; | |
| 1431 | -    $table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
 | |
| 1432 | -        'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
 | |
| 1433 | -        'geodir_post_icon' => __('Post icon', 'geodirectory'),
 | |
| 1434 | -        'geodir_attachments' => __('Attachments', 'geodirectory'),
 | |
| 1435 | -        'geodir_post_review' => __('Reviews', 'geodirectory'),
 | |
| 1436 | -        'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
 | |
| 1437 | -        'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
 | |
| 1438 | - ); | |
| 1439 | - | |
| 1440 | - // allow other addons to hook in and add their checks | |
| 1441 | - | |
| 1442 | - /** | |
| 1443 | - * Filter the array of tables. | |
| 1444 | - * | |
| 1445 | - * Filter the array of tables to check during the GD>Tools multisite DB conversion tool check, this allows addons to add their DB tables to the checks. | |
| 1446 | - * | |
| 1447 | - * @since 1.0.0 | |
| 1448 | -     * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
 | |
| 1449 | - */ | |
| 1450 | -    $table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
 | |
| 1451 | - | |
| 1452 | -    foreach ($table_arr as $table => $table_name) {
 | |
| 1453 | - // Diagnose table | |
| 1454 | - $filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix); | |
| 1455 | - } | |
| 1456 | - | |
| 1457 | - | |
| 1458 | - $output_str = $filter_arr['output_str']; | |
| 1459 | - $is_error_during_diagnose = $filter_arr['is_error_during_diagnose']; | |
| 1460 | - | |
| 1461 | - | |
| 1462 | -    if ($is_error_during_diagnose) {
 | |
| 1463 | - $info_div_class = "geodir_problem_info"; | |
| 1464 | -        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
 | |
| 1465 | -    } else {
 | |
| 1466 | - $info_div_class = "geodir_noproblem_info"; | |
| 1467 | - $fix_button_txt = ''; | |
| 1468 | - } | |
| 1469 | - echo "<ul class='$info_div_class'>"; | |
| 1470 | - echo $output_str; | |
| 1471 | - echo $fix_button_txt; | |
| 1472 | - echo "</ul>"; | |
| 1422 | + global $wpdb; | |
| 1423 | + $fix = isset($_POST['fix']) ? true : false; | |
| 1424 | +	//if($fix){echo 'true';}else{echo 'false';}
 | |
| 1425 | + $is_error_during_diagnose = false; | |
| 1426 | + $output_str = ''; | |
| 1427 | + | |
| 1428 | + $filter_arr = array(); | |
| 1429 | + $filter_arr['output_str'] = $output_str; | |
| 1430 | + $filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose; | |
| 1431 | +	$table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
 | |
| 1432 | +		'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
 | |
| 1433 | +		'geodir_post_icon' => __('Post icon', 'geodirectory'),
 | |
| 1434 | +		'geodir_attachments' => __('Attachments', 'geodirectory'),
 | |
| 1435 | +		'geodir_post_review' => __('Reviews', 'geodirectory'),
 | |
| 1436 | +		'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
 | |
| 1437 | +		'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
 | |
| 1438 | + ); | |
| 1439 | + | |
| 1440 | + // allow other addons to hook in and add their checks | |
| 1441 | + | |
| 1442 | + /** | |
| 1443 | + * Filter the array of tables. | |
| 1444 | + * | |
| 1445 | + * Filter the array of tables to check during the GD>Tools multisite DB conversion tool check, this allows addons to add their DB tables to the checks. | |
| 1446 | + * | |
| 1447 | + * @since 1.0.0 | |
| 1448 | +	 * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
 | |
| 1449 | + */ | |
| 1450 | +	$table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
 | |
| 1451 | + | |
| 1452 | +	foreach ($table_arr as $table => $table_name) {
 | |
| 1453 | + // Diagnose table | |
| 1454 | + $filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix); | |
| 1455 | + } | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + $output_str = $filter_arr['output_str']; | |
| 1459 | + $is_error_during_diagnose = $filter_arr['is_error_during_diagnose']; | |
| 1460 | + | |
| 1461 | + | |
| 1462 | +	if ($is_error_during_diagnose) {
 | |
| 1463 | + $info_div_class = "geodir_problem_info"; | |
| 1464 | +		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
 | |
| 1465 | +	} else {
 | |
| 1466 | + $info_div_class = "geodir_noproblem_info"; | |
| 1467 | + $fix_button_txt = ''; | |
| 1468 | + } | |
| 1469 | + echo "<ul class='$info_div_class'>"; | |
| 1470 | + echo $output_str; | |
| 1471 | + echo $fix_button_txt; | |
| 1472 | + echo "</ul>"; | |
| 1473 | 1473 | } | 
| 1474 | 1474 | |
| 1475 | 1475 | /** | 
| @@ -1487,39 +1487,39 @@ discard block | ||
| 1487 | 1487 | */ | 
| 1488 | 1488 | function geodir_fix_virtual_page($slug, $page_title, $old_id, $option) | 
| 1489 | 1489 |  {
 | 
| 1490 | - global $wpdb, $current_user; | |
| 1491 | - | |
| 1492 | -    if (!empty($old_id)) {
 | |
| 1493 | - wp_delete_post($old_id, true); | |
| 1494 | - }//delete post if already there | |
| 1495 | -    else {
 | |
| 1496 | - $page_found = $wpdb->get_var( | |
| 1497 | - $wpdb->prepare( | |
| 1498 | - "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", | |
| 1499 | - array($slug) | |
| 1500 | - ) | |
| 1501 | - ); | |
| 1502 | - wp_delete_post($page_found, true); | |
| 1503 | - | |
| 1504 | - } | |
| 1505 | - | |
| 1506 | - $page_data = array( | |
| 1507 | - 'post_status' => 'publish', | |
| 1508 | - 'post_type' => 'page', | |
| 1509 | - 'post_author' => $current_user->ID, | |
| 1510 | - 'post_name' => $slug, | |
| 1511 | - 'post_title' => $page_title, | |
| 1512 | - 'post_content' => '', | |
| 1513 | - 'post_parent' => 0, | |
| 1514 | - 'comment_status' => 'closed' | |
| 1515 | - ); | |
| 1516 | - $page_id = wp_insert_post($page_data); | |
| 1517 | - update_option($option, $page_id); | |
| 1518 | -    if ($page_id) {
 | |
| 1519 | - return true; | |
| 1520 | -    } else {
 | |
| 1521 | - return false; | |
| 1522 | - } | |
| 1490 | + global $wpdb, $current_user; | |
| 1491 | + | |
| 1492 | +	if (!empty($old_id)) {
 | |
| 1493 | + wp_delete_post($old_id, true); | |
| 1494 | + }//delete post if already there | |
| 1495 | +	else {
 | |
| 1496 | + $page_found = $wpdb->get_var( | |
| 1497 | + $wpdb->prepare( | |
| 1498 | + "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", | |
| 1499 | + array($slug) | |
| 1500 | + ) | |
| 1501 | + ); | |
| 1502 | + wp_delete_post($page_found, true); | |
| 1503 | + | |
| 1504 | + } | |
| 1505 | + | |
| 1506 | + $page_data = array( | |
| 1507 | + 'post_status' => 'publish', | |
| 1508 | + 'post_type' => 'page', | |
| 1509 | + 'post_author' => $current_user->ID, | |
| 1510 | + 'post_name' => $slug, | |
| 1511 | + 'post_title' => $page_title, | |
| 1512 | + 'post_content' => '', | |
| 1513 | + 'post_parent' => 0, | |
| 1514 | + 'comment_status' => 'closed' | |
| 1515 | + ); | |
| 1516 | + $page_id = wp_insert_post($page_data); | |
| 1517 | + update_option($option, $page_id); | |
| 1518 | +	if ($page_id) {
 | |
| 1519 | + return true; | |
| 1520 | +	} else {
 | |
| 1521 | + return false; | |
| 1522 | + } | |
| 1523 | 1523 | } | 
| 1524 | 1524 | |
| 1525 | 1525 | /** | 
| @@ -1531,212 +1531,212 @@ discard block | ||
| 1531 | 1531 | */ | 
| 1532 | 1532 | function geodir_diagnose_default_pages() | 
| 1533 | 1533 |  {
 | 
| 1534 | - global $wpdb; | |
| 1535 | - $is_error_during_diagnose = false; | |
| 1536 | - $output_str = ''; | |
| 1537 | - $fix = isset($_POST['fix']) ? true : false; | |
| 1538 | - | |
| 1539 | - ////////////////////////////////// | |
| 1540 | - /* Diagnose GD Home Page Starts */ | |
| 1541 | - ////////////////////////////////// | |
| 1542 | -    $option_value = get_option('geodir_home_page');
 | |
| 1543 | - $page = get_post($option_value); | |
| 1544 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1545 | - | |
| 1546 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1547 | -        $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1548 | -    else {
 | |
| 1549 | - $is_error_during_diagnose = true; | |
| 1550 | -        $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1551 | -        if ($fix) {
 | |
| 1552 | -            if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
 | |
| 1553 | -                $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1554 | -            } else {
 | |
| 1555 | -                $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1556 | - } | |
| 1557 | - } | |
| 1558 | - } | |
| 1559 | - | |
| 1560 | - //////////////////////////////// | |
| 1561 | - /* Diagnose GD Home Page Ends */ | |
| 1562 | - //////////////////////////////// | |
| 1563 | - | |
| 1564 | - ////////////////////////////////// | |
| 1565 | - /* Diagnose Add Listing Page Starts */ | |
| 1566 | - ////////////////////////////////// | |
| 1567 | -    $option_value = get_option('geodir_add_listing_page');
 | |
| 1568 | - $page = get_post($option_value); | |
| 1569 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1570 | - | |
| 1571 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1572 | -        $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1573 | -    else {
 | |
| 1574 | - $is_error_during_diagnose = true; | |
| 1575 | -        $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1576 | -        if ($fix) {
 | |
| 1577 | -            if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
 | |
| 1578 | -                $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1579 | -            } else {
 | |
| 1580 | -                $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1581 | - } | |
| 1582 | - } | |
| 1583 | - } | |
| 1584 | - | |
| 1585 | - //////////////////////////////// | |
| 1586 | - /* Diagnose Add Listing Page Ends */ | |
| 1587 | - //////////////////////////////// | |
| 1588 | - | |
| 1589 | - | |
| 1590 | - ////////////////////////////////// | |
| 1591 | - /* Diagnose Listing Preview Page Starts */ | |
| 1592 | - ////////////////////////////////// | |
| 1593 | -    $option_value = get_option('geodir_preview_page');
 | |
| 1594 | - $page = get_post($option_value); | |
| 1595 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1596 | - | |
| 1597 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1598 | -        $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1599 | -    else {
 | |
| 1600 | - $is_error_during_diagnose = true; | |
| 1601 | -        $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1602 | -        if ($fix) {
 | |
| 1603 | -            if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
 | |
| 1604 | -                $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1605 | -            } else {
 | |
| 1606 | -                $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1607 | - } | |
| 1608 | - } | |
| 1609 | - } | |
| 1610 | - | |
| 1611 | - //////////////////////////////// | |
| 1612 | - /* Diagnose Listing Preview Page Ends */ | |
| 1613 | - //////////////////////////////// | |
| 1614 | - | |
| 1615 | - ////////////////////////////////// | |
| 1616 | - /* Diagnose Listing Success Page Starts */ | |
| 1617 | - ////////////////////////////////// | |
| 1618 | -    $option_value = get_option('geodir_success_page');
 | |
| 1619 | - $page = get_post($option_value); | |
| 1620 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1621 | - | |
| 1622 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1623 | -        $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1624 | -    else {
 | |
| 1625 | - $is_error_during_diagnose = true; | |
| 1626 | -        $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1627 | -        if ($fix) {
 | |
| 1628 | -            if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
 | |
| 1629 | -                $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1630 | -            } else {
 | |
| 1631 | -                $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1632 | - } | |
| 1633 | - } | |
| 1634 | - } | |
| 1635 | - | |
| 1636 | - //////////////////////////////// | |
| 1637 | - /* Diagnose Listing Sucess Page Ends */ | |
| 1638 | - //////////////////////////////// | |
| 1639 | - | |
| 1640 | - ////////////////////////////////// | |
| 1641 | - /* Diagnose Info Page Starts */ | |
| 1642 | - ////////////////////////////////// | |
| 1643 | -    $option_value = get_option('geodir_info_page');
 | |
| 1644 | - $page = get_post($option_value); | |
| 1645 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1646 | - | |
| 1647 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1648 | -        $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1649 | -    else {
 | |
| 1650 | - $is_error_during_diagnose = true; | |
| 1651 | -        $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1652 | -        if ($fix) {
 | |
| 1653 | -            if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
 | |
| 1654 | -                $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1655 | -            } else {
 | |
| 1656 | -                $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1657 | - } | |
| 1658 | - } | |
| 1659 | - } | |
| 1660 | - | |
| 1661 | - //////////////////////////////// | |
| 1662 | - /* Diagnose Info Page Ends */ | |
| 1663 | - //////////////////////////////// | |
| 1664 | - | |
| 1665 | - ////////////////////////////////// | |
| 1666 | - /* Diagnose Login Page Starts */ | |
| 1667 | - ////////////////////////////////// | |
| 1668 | -    $option_value = get_option('geodir_login_page');
 | |
| 1669 | - $page = get_post($option_value); | |
| 1670 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1671 | - | |
| 1672 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1673 | -        $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1674 | -    else {
 | |
| 1675 | - $is_error_during_diagnose = true; | |
| 1676 | -        $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1677 | -        if ($fix) {
 | |
| 1678 | -            if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
 | |
| 1679 | -                $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1680 | -            } else {
 | |
| 1681 | -                $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1682 | - } | |
| 1683 | - } | |
| 1684 | - } | |
| 1685 | - | |
| 1686 | - //////////////////////////////// | |
| 1687 | - /* Diagnose Info Page Ends */ | |
| 1688 | - //////////////////////////////// | |
| 1689 | - | |
| 1690 | - ////////////////////////////////// | |
| 1691 | - /* Diagnose Location Page Starts */ | |
| 1692 | - ////////////////////////////////// | |
| 1693 | -    $option_value = get_option('geodir_location_page');
 | |
| 1694 | - $page = get_post($option_value); | |
| 1695 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1696 | - | |
| 1697 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1698 | -        $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1699 | -    else {
 | |
| 1700 | - $is_error_during_diagnose = true; | |
| 1701 | -        $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1702 | -        if ($fix) {
 | |
| 1703 | -            if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
 | |
| 1704 | -                $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1705 | -            } else {
 | |
| 1706 | -                $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1707 | - } | |
| 1708 | - } | |
| 1709 | - } | |
| 1710 | - | |
| 1711 | - //////////////////////////////// | |
| 1712 | - /* Diagnose Location Page Ends */ | |
| 1713 | - //////////////////////////////// | |
| 1714 | - | |
| 1715 | -    $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
 | |
| 1716 | - /** | |
| 1717 | - * This action is called at the end of the GD Tools page check function. | |
| 1718 | - * | |
| 1719 | - * @since 1.5.2 | |
| 1720 | - */ | |
| 1721 | -    $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
 | |
| 1722 | - | |
| 1723 | - $output_str = $page_chk_arr['output_str']; | |
| 1724 | - $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose']; | |
| 1725 | - | |
| 1726 | -    if ($is_error_during_diagnose) {
 | |
| 1727 | -        if ($fix) {
 | |
| 1728 | - flush_rewrite_rules(); | |
| 1729 | - } | |
| 1730 | - $info_div_class = "geodir_problem_info"; | |
| 1731 | -        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
 | |
| 1732 | -    } else {
 | |
| 1733 | - $info_div_class = "geodir_noproblem_info"; | |
| 1734 | - $fix_button_txt = ''; | |
| 1735 | - } | |
| 1736 | - echo "<ul class='$info_div_class'>"; | |
| 1737 | - echo $output_str; | |
| 1738 | - echo $fix_button_txt; | |
| 1739 | - echo "</ul>"; | |
| 1534 | + global $wpdb; | |
| 1535 | + $is_error_during_diagnose = false; | |
| 1536 | + $output_str = ''; | |
| 1537 | + $fix = isset($_POST['fix']) ? true : false; | |
| 1538 | + | |
| 1539 | + ////////////////////////////////// | |
| 1540 | + /* Diagnose GD Home Page Starts */ | |
| 1541 | + ////////////////////////////////// | |
| 1542 | +	$option_value = get_option('geodir_home_page');
 | |
| 1543 | + $page = get_post($option_value); | |
| 1544 | +	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1545 | + | |
| 1546 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1547 | +		$output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1548 | +	else {
 | |
| 1549 | + $is_error_during_diagnose = true; | |
| 1550 | +		$output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1551 | +		if ($fix) {
 | |
| 1552 | +			if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
 | |
| 1553 | +				$output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1554 | +			} else {
 | |
| 1555 | +				$output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1556 | + } | |
| 1557 | + } | |
| 1558 | + } | |
| 1559 | + | |
| 1560 | + //////////////////////////////// | |
| 1561 | + /* Diagnose GD Home Page Ends */ | |
| 1562 | + //////////////////////////////// | |
| 1563 | + | |
| 1564 | + ////////////////////////////////// | |
| 1565 | + /* Diagnose Add Listing Page Starts */ | |
| 1566 | + ////////////////////////////////// | |
| 1567 | +	$option_value = get_option('geodir_add_listing_page');
 | |
| 1568 | + $page = get_post($option_value); | |
| 1569 | +	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1570 | + | |
| 1571 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1572 | +		$output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1573 | +	else {
 | |
| 1574 | + $is_error_during_diagnose = true; | |
| 1575 | +		$output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1576 | +		if ($fix) {
 | |
| 1577 | +			if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
 | |
| 1578 | +				$output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1579 | +			} else {
 | |
| 1580 | +				$output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1581 | + } | |
| 1582 | + } | |
| 1583 | + } | |
| 1584 | + | |
| 1585 | + //////////////////////////////// | |
| 1586 | + /* Diagnose Add Listing Page Ends */ | |
| 1587 | + //////////////////////////////// | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + ////////////////////////////////// | |
| 1591 | + /* Diagnose Listing Preview Page Starts */ | |
| 1592 | + ////////////////////////////////// | |
| 1593 | +	$option_value = get_option('geodir_preview_page');
 | |
| 1594 | + $page = get_post($option_value); | |
| 1595 | +	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1596 | + | |
| 1597 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1598 | +		$output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1599 | +	else {
 | |
| 1600 | + $is_error_during_diagnose = true; | |
| 1601 | +		$output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1602 | +		if ($fix) {
 | |
| 1603 | +			if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
 | |
| 1604 | +				$output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1605 | +			} else {
 | |
| 1606 | +				$output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1607 | + } | |
| 1608 | + } | |
| 1609 | + } | |
| 1610 | + | |
| 1611 | + //////////////////////////////// | |
| 1612 | + /* Diagnose Listing Preview Page Ends */ | |
| 1613 | + //////////////////////////////// | |
| 1614 | + | |
| 1615 | + ////////////////////////////////// | |
| 1616 | + /* Diagnose Listing Success Page Starts */ | |
| 1617 | + ////////////////////////////////// | |
| 1618 | +	$option_value = get_option('geodir_success_page');
 | |
| 1619 | + $page = get_post($option_value); | |
| 1620 | +	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1621 | + | |
| 1622 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1623 | +		$output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1624 | +	else {
 | |
| 1625 | + $is_error_during_diagnose = true; | |
| 1626 | +		$output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1627 | +		if ($fix) {
 | |
| 1628 | +			if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
 | |
| 1629 | +				$output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1630 | +			} else {
 | |
| 1631 | +				$output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1632 | + } | |
| 1633 | + } | |
| 1634 | + } | |
| 1635 | + | |
| 1636 | + //////////////////////////////// | |
| 1637 | + /* Diagnose Listing Sucess Page Ends */ | |
| 1638 | + //////////////////////////////// | |
| 1639 | + | |
| 1640 | + ////////////////////////////////// | |
| 1641 | + /* Diagnose Info Page Starts */ | |
| 1642 | + ////////////////////////////////// | |
| 1643 | +	$option_value = get_option('geodir_info_page');
 | |
| 1644 | + $page = get_post($option_value); | |
| 1645 | +	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1646 | + | |
| 1647 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1648 | +		$output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1649 | +	else {
 | |
| 1650 | + $is_error_during_diagnose = true; | |
| 1651 | +		$output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1652 | +		if ($fix) {
 | |
| 1653 | +			if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
 | |
| 1654 | +				$output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1655 | +			} else {
 | |
| 1656 | +				$output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1657 | + } | |
| 1658 | + } | |
| 1659 | + } | |
| 1660 | + | |
| 1661 | + //////////////////////////////// | |
| 1662 | + /* Diagnose Info Page Ends */ | |
| 1663 | + //////////////////////////////// | |
| 1664 | + | |
| 1665 | + ////////////////////////////////// | |
| 1666 | + /* Diagnose Login Page Starts */ | |
| 1667 | + ////////////////////////////////// | |
| 1668 | +	$option_value = get_option('geodir_login_page');
 | |
| 1669 | + $page = get_post($option_value); | |
| 1670 | +	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1671 | + | |
| 1672 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1673 | +		$output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1674 | +	else {
 | |
| 1675 | + $is_error_during_diagnose = true; | |
| 1676 | +		$output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1677 | +		if ($fix) {
 | |
| 1678 | +			if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
 | |
| 1679 | +				$output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1680 | +			} else {
 | |
| 1681 | +				$output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1682 | + } | |
| 1683 | + } | |
| 1684 | + } | |
| 1685 | + | |
| 1686 | + //////////////////////////////// | |
| 1687 | + /* Diagnose Info Page Ends */ | |
| 1688 | + //////////////////////////////// | |
| 1689 | + | |
| 1690 | + ////////////////////////////////// | |
| 1691 | + /* Diagnose Location Page Starts */ | |
| 1692 | + ////////////////////////////////// | |
| 1693 | +	$option_value = get_option('geodir_location_page');
 | |
| 1694 | + $page = get_post($option_value); | |
| 1695 | +	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1696 | + | |
| 1697 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1698 | +		$output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1699 | +	else {
 | |
| 1700 | + $is_error_during_diagnose = true; | |
| 1701 | +		$output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1702 | +		if ($fix) {
 | |
| 1703 | +			if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
 | |
| 1704 | +				$output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1705 | +			} else {
 | |
| 1706 | +				$output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1707 | + } | |
| 1708 | + } | |
| 1709 | + } | |
| 1710 | + | |
| 1711 | + //////////////////////////////// | |
| 1712 | + /* Diagnose Location Page Ends */ | |
| 1713 | + //////////////////////////////// | |
| 1714 | + | |
| 1715 | +	$page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
 | |
| 1716 | + /** | |
| 1717 | + * This action is called at the end of the GD Tools page check function. | |
| 1718 | + * | |
| 1719 | + * @since 1.5.2 | |
| 1720 | + */ | |
| 1721 | +	$page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
 | |
| 1722 | + | |
| 1723 | + $output_str = $page_chk_arr['output_str']; | |
| 1724 | + $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose']; | |
| 1725 | + | |
| 1726 | +	if ($is_error_during_diagnose) {
 | |
| 1727 | +		if ($fix) {
 | |
| 1728 | + flush_rewrite_rules(); | |
| 1729 | + } | |
| 1730 | + $info_div_class = "geodir_problem_info"; | |
| 1731 | +		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
 | |
| 1732 | +	} else {
 | |
| 1733 | + $info_div_class = "geodir_noproblem_info"; | |
| 1734 | + $fix_button_txt = ''; | |
| 1735 | + } | |
| 1736 | + echo "<ul class='$info_div_class'>"; | |
| 1737 | + echo $output_str; | |
| 1738 | + echo $fix_button_txt; | |
| 1739 | + echo "</ul>"; | |
| 1740 | 1740 | |
| 1741 | 1741 | } | 
| 1742 | 1742 | |
| @@ -1748,26 +1748,26 @@ discard block | ||
| 1748 | 1748 | * @global object $wpdb WordPress Database object. | 
| 1749 | 1749 | */ | 
| 1750 | 1750 |  function geodir_diagnose_load_db_language() {
 | 
| 1751 | - global $wpdb; | |
| 1751 | + global $wpdb; | |
| 1752 | 1752 | |
| 1753 | 1753 | $is_error_during_diagnose = geodirectory_load_db_language(); | 
| 1754 | 1754 | |
| 1755 | - $output_str = ''; | |
| 1756 | - $fix_button_txt = ''; | |
| 1755 | + $output_str = ''; | |
| 1756 | + $fix_button_txt = ''; | |
| 1757 | 1757 | |
| 1758 | -    if ($is_error_during_diagnose) {
 | |
| 1759 | -        $output_str .= "<li>" . __('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory') . ' ' . geodir_plugin_path() . '/db-language.php' . "</li>";
 | |
| 1758 | +	if ($is_error_during_diagnose) {
 | |
| 1759 | +		$output_str .= "<li>" . __('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory') . ' ' . geodir_plugin_path() . '/db-language.php' . "</li>";
 | |
| 1760 | 1760 | $info_div_class = "geodir_problem_info"; | 
| 1761 | -    } else {
 | |
| 1762 | -        $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
 | |
| 1761 | +	} else {
 | |
| 1762 | +		$output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
 | |
| 1763 | 1763 | $info_div_class = "geodir_noproblem_info"; | 
| 1764 | - $fix_button_txt = ''; | |
| 1765 | - } | |
| 1764 | + $fix_button_txt = ''; | |
| 1765 | + } | |
| 1766 | 1766 | |
| 1767 | 1767 | echo "<ul class='$info_div_class'>"; | 
| 1768 | - echo $output_str; | |
| 1769 | - echo $fix_button_txt; | |
| 1770 | - echo "</ul>"; | |
| 1768 | + echo $output_str; | |
| 1769 | + echo $fix_button_txt; | |
| 1770 | + echo "</ul>"; | |
| 1771 | 1771 | |
| 1772 | 1772 | } | 
| 1773 | 1773 | |
| @@ -1798,23 +1798,23 @@ discard block | ||
| 1798 | 1798 | */ | 
| 1799 | 1799 | function geodir_posts_clauses_request($clauses) | 
| 1800 | 1800 |  {
 | 
| 1801 | - global $wpdb, $wp_query, $plugin_prefix; | |
| 1801 | + global $wpdb, $wp_query, $plugin_prefix; | |
| 1802 | 1802 | |
| 1803 | -    if (is_admin() && !empty($wp_query->query_vars) && !empty($wp_query->query_vars['is_geodir_loop']) && !empty($wp_query->query_vars['orderby']) && $wp_query->query_vars['orderby'] == 'expire' && !empty($wp_query->query_vars['post_type']) && in_array($wp_query->query_vars['post_type'], geodir_get_posttypes()) && !empty($wp_query->query_vars['orderby']) && isset($clauses['join']) && isset($clauses['orderby']) && isset($clauses['fields'])) {
 | |
| 1804 | - $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail'; | |
| 1803 | +	if (is_admin() && !empty($wp_query->query_vars) && !empty($wp_query->query_vars['is_geodir_loop']) && !empty($wp_query->query_vars['orderby']) && $wp_query->query_vars['orderby'] == 'expire' && !empty($wp_query->query_vars['post_type']) && in_array($wp_query->query_vars['post_type'], geodir_get_posttypes()) && !empty($wp_query->query_vars['orderby']) && isset($clauses['join']) && isset($clauses['orderby']) && isset($clauses['fields'])) {
 | |
| 1804 | + $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail'; | |
| 1805 | 1805 | |
| 1806 | - $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)'; | |
| 1807 | - $clauses['join'] = $join; | |
| 1806 | + $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)'; | |
| 1807 | + $clauses['join'] = $join; | |
| 1808 | 1808 | |
| 1809 | - $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : ''; | |
| 1810 | - $fields .= 'IF(UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), 253402300799) AS gd_expire'; | |
| 1811 | - $clauses['fields'] = $fields; | |
| 1809 | + $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : ''; | |
| 1810 | + $fields .= 'IF(UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), 253402300799) AS gd_expire'; | |
| 1811 | + $clauses['fields'] = $fields; | |
| 1812 | 1812 | |
| 1813 | - $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC'; | |
| 1814 | - $orderby = 'gd_expire ' . $order; | |
| 1815 | - $clauses['orderby'] = $orderby; | |
| 1816 | - } | |
| 1817 | - return $clauses; | |
| 1813 | + $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC'; | |
| 1814 | + $orderby = 'gd_expire ' . $order; | |
| 1815 | + $clauses['orderby'] = $orderby; | |
| 1816 | + } | |
| 1817 | + return $clauses; | |
| 1818 | 1818 | } | 
| 1819 | 1819 | |
| 1820 | 1820 | |
| @@ -1835,7 +1835,7 @@ discard block | ||
| 1835 | 1835 | */ | 
| 1836 | 1836 | function gd_theme_switch_compat_check() | 
| 1837 | 1837 |  {
 | 
| 1838 | - gd_set_theme_compat(); | |
| 1838 | + gd_set_theme_compat(); | |
| 1839 | 1839 | } | 
| 1840 | 1840 | |
| 1841 | 1841 | /** | 
| @@ -1848,27 +1848,27 @@ discard block | ||
| 1848 | 1848 | */ | 
| 1849 | 1849 | function geodir_str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") | 
| 1850 | 1850 |  {
 | 
| 1851 | -    if (function_exists('str_getcsv')) {
 | |
| 1852 | - $fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape); | |
| 1853 | -    } else {
 | |
| 1854 | - global $current_user; | |
| 1855 | - $upload_dir = wp_upload_dir(); | |
| 1856 | - | |
| 1857 | - $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv'; | |
| 1858 | - $handle = fopen($file, 'w'); | |
| 1859 | - | |
| 1860 | - fwrite($handle, $input); | |
| 1861 | - fclose($handle); | |
| 1862 | - | |
| 1863 | - $handle = fopen($file, 'rt'); | |
| 1864 | -        if (PHP_VERSION >= '5.3.0') {
 | |
| 1865 | - $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape); | |
| 1866 | -        } else {
 | |
| 1867 | - $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure); | |
| 1868 | - } | |
| 1869 | - fclose($handle); | |
| 1870 | - } | |
| 1871 | - return $fgetcsv; | |
| 1851 | +	if (function_exists('str_getcsv')) {
 | |
| 1852 | + $fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape); | |
| 1853 | +	} else {
 | |
| 1854 | + global $current_user; | |
| 1855 | + $upload_dir = wp_upload_dir(); | |
| 1856 | + | |
| 1857 | + $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv'; | |
| 1858 | + $handle = fopen($file, 'w'); | |
| 1859 | + | |
| 1860 | + fwrite($handle, $input); | |
| 1861 | + fclose($handle); | |
| 1862 | + | |
| 1863 | + $handle = fopen($file, 'rt'); | |
| 1864 | +		if (PHP_VERSION >= '5.3.0') {
 | |
| 1865 | + $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape); | |
| 1866 | +		} else {
 | |
| 1867 | + $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure); | |
| 1868 | + } | |
| 1869 | + fclose($handle); | |
| 1870 | + } | |
| 1871 | + return $fgetcsv; | |
| 1872 | 1872 | } | 
| 1873 | 1873 | |
| 1874 | 1874 |  add_action('wp_ajax_gdImportCsv', 'geodir_ajax_import_csv');
 | 
| @@ -1883,375 +1883,375 @@ discard block | ||
| 1883 | 1883 | */ | 
| 1884 | 1884 | function geodir_ajax_import_csv() | 
| 1885 | 1885 |  {
 | 
| 1886 | - error_reporting(0); // hide error to get clean json response | |
| 1886 | + error_reporting(0); // hide error to get clean json response | |
| 1887 | 1887 | |
| 1888 | - global $wpdb, $plugin_prefix, $current_user; | |
| 1889 | - $uploads = wp_upload_dir(); | |
| 1890 | -    ini_set('auto_detect_line_endings', true);
 | |
| 1888 | + global $wpdb, $plugin_prefix, $current_user; | |
| 1889 | + $uploads = wp_upload_dir(); | |
| 1890 | +	ini_set('auto_detect_line_endings', true);
 | |
| 1891 | 1891 | |
| 1892 | 1892 | $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. | 
| 1893 | 1893 | |
| 1894 | - $task = isset($_POST['task']) ? $_POST['task'] : ''; | |
| 1895 | - $uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL; | |
| 1896 | - $filename = $uploadedFile; | |
| 1897 | - | |
| 1898 | - $uploads = wp_upload_dir(); | |
| 1899 | - $uploads_dir = $uploads['path']; | |
| 1900 | -    $image_name_arr = explode('/', $filename);
 | |
| 1901 | - $filename = end($image_name_arr); | |
| 1902 | - $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; | |
| 1903 | - $return = array(); | |
| 1904 | - $return['file'] = $uploadedFile; | |
| 1905 | -    $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
 | |
| 1906 | - | |
| 1907 | -    if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
 | |
| 1908 | - $wp_filetype = wp_check_filetype_and_ext($target_path, $filename); | |
| 1909 | - | |
| 1910 | -        if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
 | |
| 1911 | - $return['error'] = NULL; | |
| 1912 | - | |
| 1913 | - $return['rows'] = 0; | |
| 1914 | - | |
| 1915 | - | |
| 1916 | - | |
| 1917 | -                if (($handle = fopen($target_path, "r")) !== FALSE) {
 | |
| 1918 | -                    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
 | |
| 1919 | -                        if(is_array($data) && !empty($data)) {
 | |
| 1920 | -                            $file[] = '"' . implode('","', $data) . '"';
 | |
| 1921 | - } | |
| 1922 | - } | |
| 1923 | - fclose($handle); | |
| 1924 | - $file = $file; | |
| 1925 | - } | |
| 1926 | - | |
| 1927 | - | |
| 1928 | - | |
| 1929 | - $return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; | |
| 1930 | - | |
| 1931 | - | |
| 1932 | -            if (!$return['rows'] > 0) {
 | |
| 1933 | -                $return['error'] = __('No data found in csv file.', 'geodirectory');
 | |
| 1934 | - } | |
| 1935 | - } | |
| 1936 | - } | |
| 1937 | -    if ($task == 'prepare' || !empty($return['error'])) {
 | |
| 1938 | - echo json_encode($return); | |
| 1939 | - exit; | |
| 1940 | - } | |
| 1941 | - | |
| 1942 | - $totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL; | |
| 1943 | - $importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1; | |
| 1944 | - $count = $importlimit; | |
| 1945 | - $requested_limit = $importlimit; | |
| 1946 | - $tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0; | |
| 1947 | - | |
| 1948 | -    if ($count < $totRecords) {
 | |
| 1949 | - $count = $tmpCnt + $count; | |
| 1950 | -        if ($count > $totRecords) {
 | |
| 1951 | - $count = $totRecords; | |
| 1952 | - } | |
| 1953 | -    } else {
 | |
| 1954 | - $count = $totRecords; | |
| 1955 | - } | |
| 1956 | - | |
| 1957 | - $total_records = 0; | |
| 1958 | - $rowcount = 0; | |
| 1959 | - $address_invalid = 0; | |
| 1960 | - $blank_address = 0; | |
| 1961 | - $upload_files = 0; | |
| 1962 | - $invalid_post_type = 0; | |
| 1963 | - $invalid_title = 0; | |
| 1964 | - $customKeyarray = array(); | |
| 1965 | - $gd_post_info = array(); | |
| 1966 | - $post_location = array(); | |
| 1967 | - $countpost = 0; | |
| 1968 | - | |
| 1969 | -    if (!empty($file)) {
 | |
| 1970 | - $columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL; | |
| 1971 | - $customKeyarray = $columns; | |
| 1972 | - | |
| 1973 | -        if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
 | |
| 1974 | - $return['error'] = CSV_INVAILD_FILE; | |
| 1975 | - echo json_encode($return); | |
| 1976 | - exit; | |
| 1977 | - } | |
| 1978 | - | |
| 1979 | -        for ($i = 1; $i <= $importlimit; $i++) {
 | |
| 1980 | - $current_index = $tmpCnt + $i; | |
| 1981 | -            if (isset($file[$current_index])) {
 | |
| 1982 | - $total_records++; | |
| 1983 | - | |
| 1984 | - $buffer = geodir_str_getcsv($file[$current_index]); | |
| 1985 | - $post_title = addslashes($buffer[0]); | |
| 1986 | - $current_post_author = $buffer[1]; | |
| 1987 | - $post_desc = addslashes($buffer[2]); | |
| 1988 | - $post_cat = array(); | |
| 1989 | - $catids_arr = array(); | |
| 1990 | - $post_cat = trim($buffer[3]); // comma seperated category name | |
| 1991 | - | |
| 1992 | -                if ($post_cat) {
 | |
| 1993 | -                    $post_cat_arr = explode(',', $post_cat);
 | |
| 1994 | - | |
| 1995 | -                    for ($c = 0; $c < count($post_cat_arr); $c++) {
 | |
| 1996 | - $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c])); | |
| 1997 | - | |
| 1998 | -                        if (!empty($buffer[5])) {
 | |
| 1999 | -                            if (in_array($buffer[5], geodir_get_posttypes())) {
 | |
| 2000 | - | |
| 2001 | - $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5])); | |
| 2002 | - | |
| 2003 | -                                if (get_term_by('name', $catid, $p_taxonomy[0])) {
 | |
| 2004 | -                                    $cat = get_term_by('name', $catid, $p_taxonomy[0]);
 | |
| 2005 | - $catids_arr[] = $cat->slug; | |
| 2006 | -                                } else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
 | |
| 2007 | -                                    $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
 | |
| 2008 | - $catids_arr[] = $cat->slug; | |
| 2009 | -                                } else {
 | |
| 2010 | - $ret = wp_insert_term($catid, $p_taxonomy[0]); | |
| 2011 | -                                    if ($ret && !is_wp_error($ret)) {
 | |
| 2012 | -                                        if (get_term_by('name', $catid, $p_taxonomy[0])) {
 | |
| 2013 | -                                            $cat = get_term_by('name', $catid, $p_taxonomy[0]);
 | |
| 2014 | - $catids_arr[] = $cat->slug; | |
| 2015 | -                                        } elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
 | |
| 2016 | -                                            $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
 | |
| 2017 | - $catids_arr[] = $cat->slug; | |
| 2018 | - } | |
| 2019 | - } | |
| 2020 | - } | |
| 2021 | - } | |
| 2022 | - } | |
| 2023 | - } | |
| 2024 | - } | |
| 2025 | - | |
| 2026 | -                if (!$catids_arr) {
 | |
| 2027 | - $catids_arr[] = 1; | |
| 2028 | - } | |
| 2029 | - | |
| 2030 | - $post_tags = trim($buffer[4]); // comma seperated tags | |
| 2031 | - | |
| 2032 | - $tag_arr = ''; | |
| 2033 | -                if ($post_tags) {
 | |
| 2034 | -                    $tag_arr = explode(',', $post_tags);
 | |
| 2035 | - } | |
| 2036 | - | |
| 2037 | - $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database | |
| 2038 | - | |
| 2039 | - $error = ''; | |
| 2040 | -                if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
 | |
| 2041 | - $invalid_post_type++; | |
| 2042 | - continue; | |
| 2043 | - } | |
| 2044 | - | |
| 2045 | -                if ($post_title != '') {
 | |
| 2046 | - $menu_order = 0; | |
| 2047 | - $image_folder_name = 'uplaod/'; | |
| 2048 | - | |
| 2049 | - $image_names = array(); | |
| 2050 | - | |
| 2051 | -                    for ($c = 5; $c < count($customKeyarray); $c++) {
 | |
| 2052 | - $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]); | |
| 2053 | - | |
| 2054 | -                        if ($customKeyarray[$c] == 'IMAGE') {
 | |
| 2055 | - $buffer[$c] = trim($buffer[$c]); | |
| 2056 | - | |
| 2057 | -                            if (!empty($buffer[$c])) {
 | |
| 2058 | - $image_names[] = $buffer[$c]; | |
| 2059 | - } | |
| 2060 | - } | |
| 2061 | - | |
| 2062 | -                        if ($customKeyarray[$c] == 'alive_days') {
 | |
| 2063 | -                            if ($buffer[$c] != '0' && $buffer[$c] != '') {
 | |
| 2064 | -                                $submitdata = date('Y-m-d');
 | |
| 2065 | - | |
| 2066 | -                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
 | |
| 2067 | -                            } else {
 | |
| 2068 | - $gd_post_info['expire_date'] = 'Never'; | |
| 2069 | - } | |
| 2070 | - } | |
| 2071 | - | |
| 2072 | -                        if ($customKeyarray[$c] == 'post_city') {
 | |
| 2073 | - $post_city = addslashes($buffer[$c]); | |
| 2074 | - } | |
| 2075 | - | |
| 2076 | -                        if ($customKeyarray[$c] == 'post_region') {
 | |
| 2077 | - $post_region = addslashes($buffer[$c]); | |
| 2078 | - } | |
| 2079 | - | |
| 2080 | -                        if ($customKeyarray[$c] == 'post_country') {
 | |
| 2081 | - $post_country = addslashes($buffer[$c]); | |
| 2082 | - } | |
| 2083 | - | |
| 2084 | -                        if ($customKeyarray[$c] == 'post_latitude') {
 | |
| 2085 | - $post_latitude = addslashes($buffer[$c]); | |
| 2086 | - } | |
| 2087 | - | |
| 2088 | -                        if ($customKeyarray[$c] == 'post_longitude') {
 | |
| 2089 | - $post_longitude = addslashes($buffer[$c]); | |
| 2090 | - } | |
| 1894 | + $task = isset($_POST['task']) ? $_POST['task'] : ''; | |
| 1895 | + $uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL; | |
| 1896 | + $filename = $uploadedFile; | |
| 1897 | + | |
| 1898 | + $uploads = wp_upload_dir(); | |
| 1899 | + $uploads_dir = $uploads['path']; | |
| 1900 | +	$image_name_arr = explode('/', $filename);
 | |
| 1901 | + $filename = end($image_name_arr); | |
| 1902 | + $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; | |
| 1903 | + $return = array(); | |
| 1904 | + $return['file'] = $uploadedFile; | |
| 1905 | +	$return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
 | |
| 1906 | + | |
| 1907 | +	if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
 | |
| 1908 | + $wp_filetype = wp_check_filetype_and_ext($target_path, $filename); | |
| 1909 | + | |
| 1910 | +		if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
 | |
| 1911 | + $return['error'] = NULL; | |
| 1912 | + | |
| 1913 | + $return['rows'] = 0; | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | +				if (($handle = fopen($target_path, "r")) !== FALSE) {
 | |
| 1918 | +					while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
 | |
| 1919 | +						if(is_array($data) && !empty($data)) {
 | |
| 1920 | +							$file[] = '"' . implode('","', $data) . '"';
 | |
| 1921 | + } | |
| 1922 | + } | |
| 1923 | + fclose($handle); | |
| 1924 | + $file = $file; | |
| 1925 | + } | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + $return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; | |
| 1930 | + | |
| 1931 | + | |
| 1932 | +			if (!$return['rows'] > 0) {
 | |
| 1933 | +				$return['error'] = __('No data found in csv file.', 'geodirectory');
 | |
| 1934 | + } | |
| 1935 | + } | |
| 1936 | + } | |
| 1937 | +	if ($task == 'prepare' || !empty($return['error'])) {
 | |
| 1938 | + echo json_encode($return); | |
| 1939 | + exit; | |
| 1940 | + } | |
| 1941 | + | |
| 1942 | + $totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL; | |
| 1943 | + $importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1; | |
| 1944 | + $count = $importlimit; | |
| 1945 | + $requested_limit = $importlimit; | |
| 1946 | + $tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0; | |
| 1947 | + | |
| 1948 | +	if ($count < $totRecords) {
 | |
| 1949 | + $count = $tmpCnt + $count; | |
| 1950 | +		if ($count > $totRecords) {
 | |
| 1951 | + $count = $totRecords; | |
| 1952 | + } | |
| 1953 | +	} else {
 | |
| 1954 | + $count = $totRecords; | |
| 1955 | + } | |
| 1956 | + | |
| 1957 | + $total_records = 0; | |
| 1958 | + $rowcount = 0; | |
| 1959 | + $address_invalid = 0; | |
| 1960 | + $blank_address = 0; | |
| 1961 | + $upload_files = 0; | |
| 1962 | + $invalid_post_type = 0; | |
| 1963 | + $invalid_title = 0; | |
| 1964 | + $customKeyarray = array(); | |
| 1965 | + $gd_post_info = array(); | |
| 1966 | + $post_location = array(); | |
| 1967 | + $countpost = 0; | |
| 1968 | + | |
| 1969 | +	if (!empty($file)) {
 | |
| 1970 | + $columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL; | |
| 1971 | + $customKeyarray = $columns; | |
| 1972 | + | |
| 1973 | +		if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
 | |
| 1974 | + $return['error'] = CSV_INVAILD_FILE; | |
| 1975 | + echo json_encode($return); | |
| 1976 | + exit; | |
| 1977 | + } | |
| 1978 | + | |
| 1979 | +		for ($i = 1; $i <= $importlimit; $i++) {
 | |
| 1980 | + $current_index = $tmpCnt + $i; | |
| 1981 | +			if (isset($file[$current_index])) {
 | |
| 1982 | + $total_records++; | |
| 1983 | + | |
| 1984 | + $buffer = geodir_str_getcsv($file[$current_index]); | |
| 1985 | + $post_title = addslashes($buffer[0]); | |
| 1986 | + $current_post_author = $buffer[1]; | |
| 1987 | + $post_desc = addslashes($buffer[2]); | |
| 1988 | + $post_cat = array(); | |
| 1989 | + $catids_arr = array(); | |
| 1990 | + $post_cat = trim($buffer[3]); // comma seperated category name | |
| 1991 | + | |
| 1992 | +				if ($post_cat) {
 | |
| 1993 | +					$post_cat_arr = explode(',', $post_cat);
 | |
| 1994 | + | |
| 1995 | +					for ($c = 0; $c < count($post_cat_arr); $c++) {
 | |
| 1996 | + $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c])); | |
| 1997 | + | |
| 1998 | +						if (!empty($buffer[5])) {
 | |
| 1999 | +							if (in_array($buffer[5], geodir_get_posttypes())) {
 | |
| 2000 | + | |
| 2001 | + $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5])); | |
| 2002 | + | |
| 2003 | +								if (get_term_by('name', $catid, $p_taxonomy[0])) {
 | |
| 2004 | +									$cat = get_term_by('name', $catid, $p_taxonomy[0]);
 | |
| 2005 | + $catids_arr[] = $cat->slug; | |
| 2006 | +								} else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
 | |
| 2007 | +									$cat = get_term_by('slug', $catid, $p_taxonomy[0]);
 | |
| 2008 | + $catids_arr[] = $cat->slug; | |
| 2009 | +								} else {
 | |
| 2010 | + $ret = wp_insert_term($catid, $p_taxonomy[0]); | |
| 2011 | +									if ($ret && !is_wp_error($ret)) {
 | |
| 2012 | +										if (get_term_by('name', $catid, $p_taxonomy[0])) {
 | |
| 2013 | +											$cat = get_term_by('name', $catid, $p_taxonomy[0]);
 | |
| 2014 | + $catids_arr[] = $cat->slug; | |
| 2015 | +										} elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
 | |
| 2016 | +											$cat = get_term_by('slug', $catid, $p_taxonomy[0]);
 | |
| 2017 | + $catids_arr[] = $cat->slug; | |
| 2018 | + } | |
| 2019 | + } | |
| 2020 | + } | |
| 2021 | + } | |
| 2022 | + } | |
| 2023 | + } | |
| 2024 | + } | |
| 2025 | + | |
| 2026 | +				if (!$catids_arr) {
 | |
| 2027 | + $catids_arr[] = 1; | |
| 2028 | + } | |
| 2029 | + | |
| 2030 | + $post_tags = trim($buffer[4]); // comma seperated tags | |
| 2031 | + | |
| 2032 | + $tag_arr = ''; | |
| 2033 | +				if ($post_tags) {
 | |
| 2034 | +					$tag_arr = explode(',', $post_tags);
 | |
| 2035 | + } | |
| 2036 | + | |
| 2037 | + $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database | |
| 2038 | + | |
| 2039 | + $error = ''; | |
| 2040 | +				if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
 | |
| 2041 | + $invalid_post_type++; | |
| 2042 | + continue; | |
| 2043 | + } | |
| 2044 | + | |
| 2045 | +				if ($post_title != '') {
 | |
| 2046 | + $menu_order = 0; | |
| 2047 | + $image_folder_name = 'uplaod/'; | |
| 2048 | + | |
| 2049 | + $image_names = array(); | |
| 2050 | + | |
| 2051 | +					for ($c = 5; $c < count($customKeyarray); $c++) {
 | |
| 2052 | + $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]); | |
| 2053 | + | |
| 2054 | +						if ($customKeyarray[$c] == 'IMAGE') {
 | |
| 2055 | + $buffer[$c] = trim($buffer[$c]); | |
| 2056 | + | |
| 2057 | +							if (!empty($buffer[$c])) {
 | |
| 2058 | + $image_names[] = $buffer[$c]; | |
| 2059 | + } | |
| 2060 | + } | |
| 2061 | + | |
| 2062 | +						if ($customKeyarray[$c] == 'alive_days') {
 | |
| 2063 | +							if ($buffer[$c] != '0' && $buffer[$c] != '') {
 | |
| 2064 | +								$submitdata = date('Y-m-d');
 | |
| 2065 | + | |
| 2066 | +								$gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
 | |
| 2067 | +							} else {
 | |
| 2068 | + $gd_post_info['expire_date'] = 'Never'; | |
| 2069 | + } | |
| 2070 | + } | |
| 2071 | + | |
| 2072 | +						if ($customKeyarray[$c] == 'post_city') {
 | |
| 2073 | + $post_city = addslashes($buffer[$c]); | |
| 2074 | + } | |
| 2075 | + | |
| 2076 | +						if ($customKeyarray[$c] == 'post_region') {
 | |
| 2077 | + $post_region = addslashes($buffer[$c]); | |
| 2078 | + } | |
| 2079 | + | |
| 2080 | +						if ($customKeyarray[$c] == 'post_country') {
 | |
| 2081 | + $post_country = addslashes($buffer[$c]); | |
| 2082 | + } | |
| 2083 | + | |
| 2084 | +						if ($customKeyarray[$c] == 'post_latitude') {
 | |
| 2085 | + $post_latitude = addslashes($buffer[$c]); | |
| 2086 | + } | |
| 2087 | + | |
| 2088 | +						if ($customKeyarray[$c] == 'post_longitude') {
 | |
| 2089 | + $post_longitude = addslashes($buffer[$c]); | |
| 2090 | + } | |
| 2091 | 2091 | |
| 2092 | 2092 | // Post status | 
| 2093 | 2093 |  						if ($customKeyarray[$c] == 'post_status') {
 | 
| 2094 | - $post_status = sanitize_key( $buffer[$c] ); | |
| 2095 | - } | |
| 2096 | - } | |
| 2097 | - | |
| 2098 | - /* ================ before array create ============== */ | |
| 2099 | - $location_result = geodir_get_default_location(); | |
| 2100 | -                    if ((!isset($gd_post_info['post_city']) || $gd_post_info['post_city'] == '') || (!isset($gd_post_info['post_region']) || $gd_post_info['post_region'] == '') || (!isset($gd_post_info['post_country']) || $gd_post_info['post_country'] == '') || (!isset($gd_post_info['post_address']) || $gd_post_info['post_address'] == '') || (!isset($gd_post_info['post_latitude']) || $gd_post_info['post_latitude'] == '') || (!isset($gd_post_info['post_longitude']) || $gd_post_info['post_longitude'] == '')) {
 | |
| 2101 | - $blank_address++; | |
| 2102 | - continue; | |
| 2103 | -                    } else if ($location_result->location_id == 0) {
 | |
| 2104 | -                        if ((geodir_strtolower($gd_post_info['post_city']) != geodir_strtolower($location_result->city)) || (geodir_strtolower($gd_post_info['post_region']) != geodir_strtolower($location_result->region)) || (geodir_strtolower($gd_post_info['post_country']) != geodir_strtolower($location_result->country))) {
 | |
| 2105 | - $address_invalid++; | |
| 2106 | - continue; | |
| 2107 | - } | |
| 2108 | - } | |
| 2094 | + $post_status = sanitize_key( $buffer[$c] ); | |
| 2095 | + } | |
| 2096 | + } | |
| 2097 | + | |
| 2098 | + /* ================ before array create ============== */ | |
| 2099 | + $location_result = geodir_get_default_location(); | |
| 2100 | +					if ((!isset($gd_post_info['post_city']) || $gd_post_info['post_city'] == '') || (!isset($gd_post_info['post_region']) || $gd_post_info['post_region'] == '') || (!isset($gd_post_info['post_country']) || $gd_post_info['post_country'] == '') || (!isset($gd_post_info['post_address']) || $gd_post_info['post_address'] == '') || (!isset($gd_post_info['post_latitude']) || $gd_post_info['post_latitude'] == '') || (!isset($gd_post_info['post_longitude']) || $gd_post_info['post_longitude'] == '')) {
 | |
| 2101 | + $blank_address++; | |
| 2102 | + continue; | |
| 2103 | +					} else if ($location_result->location_id == 0) {
 | |
| 2104 | +						if ((geodir_strtolower($gd_post_info['post_city']) != geodir_strtolower($location_result->city)) || (geodir_strtolower($gd_post_info['post_region']) != geodir_strtolower($location_result->region)) || (geodir_strtolower($gd_post_info['post_country']) != geodir_strtolower($location_result->country))) {
 | |
| 2105 | + $address_invalid++; | |
| 2106 | + continue; | |
| 2107 | + } | |
| 2108 | + } | |
| 2109 | 2109 | |
| 2110 | 2110 | // Default post status | 
| 2111 | 2111 | $default_status = 'publish'; | 
| 2112 | 2112 | $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; | 
| 2113 | 2113 | $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; | 
| 2114 | 2114 | |
| 2115 | - $my_post['post_title'] = $post_title; | |
| 2116 | - $my_post['post_content'] = $post_desc; | |
| 2117 | - $my_post['post_type'] = addslashes($buffer[5]); | |
| 2118 | - $my_post['post_author'] = $current_post_author; | |
| 2119 | - $my_post['post_status'] = $post_status; | |
| 2120 | - $my_post['post_category'] = $catids_arr; | |
| 2121 | - $my_post['post_tags'] = $tag_arr; | |
| 2122 | - | |
| 2123 | - $gd_post_info['post_tags'] = $tag_arr; | |
| 2124 | - $gd_post_info['post_title'] = $post_title; | |
| 2125 | - $gd_post_info['post_status'] = $post_status; | |
| 2126 | - $gd_post_info['submit_time'] = time(); | |
| 2127 | - $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR']; | |
| 2128 | - | |
| 2129 | - $last_postid = wp_insert_post($my_post); | |
| 2130 | - $countpost++; | |
| 2131 | - | |
| 2132 | - // Check if we need to save post location as new location | |
| 2133 | -                    if ($location_result->location_id > 0) {
 | |
| 2134 | -                        if (isset($post_city) && isset($post_region)) {
 | |
| 2135 | - $request_info['post_location'] = array( | |
| 2136 | - 'city' => $post_city, | |
| 2137 | - 'region' => $post_region, | |
| 2138 | - 'country' => $post_country, | |
| 2139 | - 'geo_lat' => $post_latitude, | |
| 2140 | - 'geo_lng' => $post_longitude | |
| 2141 | - ); | |
| 2142 | - | |
| 2143 | - $post_location_info = $request_info['post_location']; | |
| 2144 | - if ($location_id = geodir_add_new_location($post_location_info)) | |
| 2145 | - $post_location_id = $location_id; | |
| 2146 | -                        } else {
 | |
| 2147 | - $post_location_id = 0; | |
| 2148 | - } | |
| 2149 | -                    } else {
 | |
| 2150 | - $post_location_id = 0; | |
| 2151 | - } | |
| 2152 | - | |
| 2153 | - /* ------- get default package info ----- */ | |
| 2154 | - $payment_info = array(); | |
| 2155 | - $package_info = array(); | |
| 2156 | - | |
| 2157 | - $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]); | |
| 2158 | - $package_id = ''; | |
| 2159 | -                    if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
 | |
| 2160 | - $package_id = $gd_post_info['package_id']; | |
| 2161 | - } | |
| 2162 | - | |
| 2163 | -                    if (!empty($package_info)) {
 | |
| 2164 | - $payment_info['package_id'] = $package_info['pid']; | |
| 2165 | - | |
| 2166 | -                        if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
 | |
| 2167 | -                            $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
 | |
| 2168 | -                        } else {
 | |
| 2169 | - $payment_info['expire_date'] = 'Never'; | |
| 2170 | - } | |
| 2171 | - | |
| 2172 | - $gd_post_info = array_merge($gd_post_info, $payment_info); | |
| 2173 | - } | |
| 2174 | - | |
| 2175 | - $gd_post_info['post_location_id'] = $post_location_id; | |
| 2176 | - | |
| 2177 | - $post_type = get_post_type($last_postid); | |
| 2178 | - | |
| 2179 | - $table = $plugin_prefix . $post_type . '_detail'; | |
| 2180 | - | |
| 2181 | - geodir_save_post_info($last_postid, $gd_post_info); | |
| 2182 | - | |
| 2183 | -                    if (!empty($image_names)) {
 | |
| 2184 | - $upload_files++; | |
| 2185 | - $menu_order = 1; | |
| 2186 | - | |
| 2187 | -                        foreach ($image_names as $image_name) {
 | |
| 2188 | -                            $img_name_arr = explode('.', $image_name);
 | |
| 2189 | - | |
| 2190 | - $uploads = wp_upload_dir(); | |
| 2191 | - $sub_dir = $uploads['subdir']; | |
| 2192 | - | |
| 2193 | - $arr_file_type = wp_check_filetype($image_name); | |
| 2194 | - $uploaded_file_type = $arr_file_type['type']; | |
| 2195 | - | |
| 2196 | - $attachment = array(); | |
| 2197 | - $attachment['post_id'] = $last_postid; | |
| 2198 | - $attachment['title'] = $img_name_arr[0]; | |
| 2199 | - $attachment['content'] = ''; | |
| 2200 | - $attachment['file'] = $sub_dir . '/' . $image_name; | |
| 2201 | - $attachment['mime_type'] = $uploaded_file_type; | |
| 2202 | - $attachment['menu_order'] = $menu_order; | |
| 2203 | - $attachment['is_featured'] = 0; | |
| 2204 | - | |
| 2205 | - $attachment_set = ''; | |
| 2206 | - | |
| 2207 | -                            foreach ($attachment as $key => $val) {
 | |
| 2208 | - if ($val != '') | |
| 2209 | - $attachment_set .= $key . " = '" . $val . "', "; | |
| 2210 | - } | |
| 2211 | - $attachment_set = trim($attachment_set, ", "); | |
| 2212 | - | |
| 2213 | -                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
 | |
| 2214 | - | |
| 2215 | -                            if ($menu_order == 1) {
 | |
| 2216 | - $post_type = get_post_type($last_postid); | |
| 2217 | -                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
 | |
| 2218 | - } | |
| 2219 | - $menu_order++; | |
| 2220 | - } | |
| 2221 | - } | |
| 2222 | - | |
| 2223 | - $gd_post_info['package_id'] = $package_id; | |
| 2224 | - | |
| 2225 | - /** This action is documented in geodirectory-functions/post-functions.php */ | |
| 2226 | -                    do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
 | |
| 2227 | - | |
| 2228 | -                    if (!empty($buffer[5])) {
 | |
| 2229 | -                        if (in_array($buffer[5], geodir_get_posttypes())) {
 | |
| 2230 | - $taxonomies = geodir_get_posttype_info(addslashes($buffer[5])); | |
| 2231 | - wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]); | |
| 2232 | - wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]); | |
| 2233 | - | |
| 2234 | - $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : ''; | |
| 2235 | - $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : ''; | |
| 2236 | - geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str); | |
| 2237 | - } | |
| 2238 | - } | |
| 2239 | -                } else {
 | |
| 2240 | - $invalid_title++; | |
| 2241 | - } | |
| 2242 | - } | |
| 2243 | - } | |
| 2244 | - } | |
| 2245 | - $return['rowcount'] = $countpost; | |
| 2246 | - $return['invalidcount'] = $address_invalid; | |
| 2247 | - $return['blank_address'] = $blank_address; | |
| 2248 | - $return['upload_files'] = $upload_files; | |
| 2249 | - $return['invalid_post_type'] = $invalid_post_type; | |
| 2250 | - $return['invalid_title'] = $invalid_title; | |
| 2251 | - $return['total_records'] = $total_records; | |
| 2252 | - | |
| 2253 | - echo json_encode($return); | |
| 2254 | - exit; | |
| 2115 | + $my_post['post_title'] = $post_title; | |
| 2116 | + $my_post['post_content'] = $post_desc; | |
| 2117 | + $my_post['post_type'] = addslashes($buffer[5]); | |
| 2118 | + $my_post['post_author'] = $current_post_author; | |
| 2119 | + $my_post['post_status'] = $post_status; | |
| 2120 | + $my_post['post_category'] = $catids_arr; | |
| 2121 | + $my_post['post_tags'] = $tag_arr; | |
| 2122 | + | |
| 2123 | + $gd_post_info['post_tags'] = $tag_arr; | |
| 2124 | + $gd_post_info['post_title'] = $post_title; | |
| 2125 | + $gd_post_info['post_status'] = $post_status; | |
| 2126 | + $gd_post_info['submit_time'] = time(); | |
| 2127 | + $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR']; | |
| 2128 | + | |
| 2129 | + $last_postid = wp_insert_post($my_post); | |
| 2130 | + $countpost++; | |
| 2131 | + | |
| 2132 | + // Check if we need to save post location as new location | |
| 2133 | +					if ($location_result->location_id > 0) {
 | |
| 2134 | +						if (isset($post_city) && isset($post_region)) {
 | |
| 2135 | + $request_info['post_location'] = array( | |
| 2136 | + 'city' => $post_city, | |
| 2137 | + 'region' => $post_region, | |
| 2138 | + 'country' => $post_country, | |
| 2139 | + 'geo_lat' => $post_latitude, | |
| 2140 | + 'geo_lng' => $post_longitude | |
| 2141 | + ); | |
| 2142 | + | |
| 2143 | + $post_location_info = $request_info['post_location']; | |
| 2144 | + if ($location_id = geodir_add_new_location($post_location_info)) | |
| 2145 | + $post_location_id = $location_id; | |
| 2146 | +						} else {
 | |
| 2147 | + $post_location_id = 0; | |
| 2148 | + } | |
| 2149 | +					} else {
 | |
| 2150 | + $post_location_id = 0; | |
| 2151 | + } | |
| 2152 | + | |
| 2153 | + /* ------- get default package info ----- */ | |
| 2154 | + $payment_info = array(); | |
| 2155 | + $package_info = array(); | |
| 2156 | + | |
| 2157 | + $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]); | |
| 2158 | + $package_id = ''; | |
| 2159 | +					if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
 | |
| 2160 | + $package_id = $gd_post_info['package_id']; | |
| 2161 | + } | |
| 2162 | + | |
| 2163 | +					if (!empty($package_info)) {
 | |
| 2164 | + $payment_info['package_id'] = $package_info['pid']; | |
| 2165 | + | |
| 2166 | +						if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
 | |
| 2167 | +							$payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
 | |
| 2168 | +						} else {
 | |
| 2169 | + $payment_info['expire_date'] = 'Never'; | |
| 2170 | + } | |
| 2171 | + | |
| 2172 | + $gd_post_info = array_merge($gd_post_info, $payment_info); | |
| 2173 | + } | |
| 2174 | + | |
| 2175 | + $gd_post_info['post_location_id'] = $post_location_id; | |
| 2176 | + | |
| 2177 | + $post_type = get_post_type($last_postid); | |
| 2178 | + | |
| 2179 | + $table = $plugin_prefix . $post_type . '_detail'; | |
| 2180 | + | |
| 2181 | + geodir_save_post_info($last_postid, $gd_post_info); | |
| 2182 | + | |
| 2183 | +					if (!empty($image_names)) {
 | |
| 2184 | + $upload_files++; | |
| 2185 | + $menu_order = 1; | |
| 2186 | + | |
| 2187 | +						foreach ($image_names as $image_name) {
 | |
| 2188 | +							$img_name_arr = explode('.', $image_name);
 | |
| 2189 | + | |
| 2190 | + $uploads = wp_upload_dir(); | |
| 2191 | + $sub_dir = $uploads['subdir']; | |
| 2192 | + | |
| 2193 | + $arr_file_type = wp_check_filetype($image_name); | |
| 2194 | + $uploaded_file_type = $arr_file_type['type']; | |
| 2195 | + | |
| 2196 | + $attachment = array(); | |
| 2197 | + $attachment['post_id'] = $last_postid; | |
| 2198 | + $attachment['title'] = $img_name_arr[0]; | |
| 2199 | + $attachment['content'] = ''; | |
| 2200 | + $attachment['file'] = $sub_dir . '/' . $image_name; | |
| 2201 | + $attachment['mime_type'] = $uploaded_file_type; | |
| 2202 | + $attachment['menu_order'] = $menu_order; | |
| 2203 | + $attachment['is_featured'] = 0; | |
| 2204 | + | |
| 2205 | + $attachment_set = ''; | |
| 2206 | + | |
| 2207 | +							foreach ($attachment as $key => $val) {
 | |
| 2208 | + if ($val != '') | |
| 2209 | + $attachment_set .= $key . " = '" . $val . "', "; | |
| 2210 | + } | |
| 2211 | + $attachment_set = trim($attachment_set, ", "); | |
| 2212 | + | |
| 2213 | +							$wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
 | |
| 2214 | + | |
| 2215 | +							if ($menu_order == 1) {
 | |
| 2216 | + $post_type = get_post_type($last_postid); | |
| 2217 | +								$wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
 | |
| 2218 | + } | |
| 2219 | + $menu_order++; | |
| 2220 | + } | |
| 2221 | + } | |
| 2222 | + | |
| 2223 | + $gd_post_info['package_id'] = $package_id; | |
| 2224 | + | |
| 2225 | + /** This action is documented in geodirectory-functions/post-functions.php */ | |
| 2226 | +					do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
 | |
| 2227 | + | |
| 2228 | +					if (!empty($buffer[5])) {
 | |
| 2229 | +						if (in_array($buffer[5], geodir_get_posttypes())) {
 | |
| 2230 | + $taxonomies = geodir_get_posttype_info(addslashes($buffer[5])); | |
| 2231 | + wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]); | |
| 2232 | + wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]); | |
| 2233 | + | |
| 2234 | + $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : ''; | |
| 2235 | + $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : ''; | |
| 2236 | + geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str); | |
| 2237 | + } | |
| 2238 | + } | |
| 2239 | +				} else {
 | |
| 2240 | + $invalid_title++; | |
| 2241 | + } | |
| 2242 | + } | |
| 2243 | + } | |
| 2244 | + } | |
| 2245 | + $return['rowcount'] = $countpost; | |
| 2246 | + $return['invalidcount'] = $address_invalid; | |
| 2247 | + $return['blank_address'] = $blank_address; | |
| 2248 | + $return['upload_files'] = $upload_files; | |
| 2249 | + $return['invalid_post_type'] = $invalid_post_type; | |
| 2250 | + $return['invalid_title'] = $invalid_title; | |
| 2251 | + $return['total_records'] = $total_records; | |
| 2252 | + | |
| 2253 | + echo json_encode($return); | |
| 2254 | + exit; | |
| 2255 | 2255 | } | 
| 2256 | 2256 | |
| 2257 | 2257 | // Add the tab in left sidebar menu fro import & export page. | 
| @@ -2271,9 +2271,9 @@ discard block | ||
| 2271 | 2271 | * @param $post object $post The post object of the post being saved. | 
| 2272 | 2272 | */ | 
| 2273 | 2273 |  function geodir_update_location_prefix($post_id,$post){
 | 
| 2274 | -    if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
 | |
| 2275 | -        update_option('geodir_location_prefix',$post->post_name);
 | |
| 2276 | - } | |
| 2274 | +	if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
 | |
| 2275 | +		update_option('geodir_location_prefix',$post->post_name);
 | |
| 2276 | + } | |
| 2277 | 2277 | |
| 2278 | 2278 | } | 
| 2279 | 2279 | |
| @@ -2284,50 +2284,50 @@ discard block | ||
| 2284 | 2284 |  function geodir_ga_callback(){
 | 
| 2285 | 2285 | |
| 2286 | 2286 |  if(isset($_REQUEST['code']) && $_REQUEST['code']) {
 | 
| 2287 | - $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?"; | |
| 2288 | - $code = "code=".$_REQUEST['code']; | |
| 2289 | - $grant_type = "&grant_type=authorization_code"; | |
| 2290 | -    $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
 | |
| 2291 | -    $client_id = "&client_id=".get_option('geodir_ga_client_id');
 | |
| 2292 | -    $client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
 | |
| 2287 | + $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?"; | |
| 2288 | + $code = "code=".$_REQUEST['code']; | |
| 2289 | + $grant_type = "&grant_type=authorization_code"; | |
| 2290 | +	$redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
 | |
| 2291 | +	$client_id = "&client_id=".get_option('geodir_ga_client_id');
 | |
| 2292 | +	$client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
 | |
| 2293 | 2293 | |
| 2294 | - $auth_url = $oAuthURL . $code . $redirect_uri . $grant_type . $client_id .$client_secret; | |
| 2294 | + $auth_url = $oAuthURL . $code . $redirect_uri . $grant_type . $client_id .$client_secret; | |
| 2295 | 2295 | |
| 2296 | -    $response = wp_remote_post($auth_url, array('timeout' => 15));
 | |
| 2296 | +	$response = wp_remote_post($auth_url, array('timeout' => 15));
 | |
| 2297 | 2297 | |
| 2298 | - //print_r($response); | |
| 2298 | + //print_r($response); | |
| 2299 | 2299 | |
| 2300 | -    $error_msg =  __('Something went wrong','geodirectory');
 | |
| 2301 | -    if(!empty($response['response']['code']) && $response['response']['code']==200){
 | |
| 2300 | +	$error_msg =  __('Something went wrong','geodirectory');
 | |
| 2301 | +	if(!empty($response['response']['code']) && $response['response']['code']==200){
 | |
| 2302 | 2302 | |
| 2303 | - $parts = json_decode($response['body']); | |
| 2304 | - //print_r($parts); | |
| 2305 | -        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
 | |
| 2306 | -        else{
 | |
| 2303 | + $parts = json_decode($response['body']); | |
| 2304 | + //print_r($parts); | |
| 2305 | +		if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
 | |
| 2306 | +		else{
 | |
| 2307 | 2307 | |
| 2308 | -            update_option('gd_ga_access_token', $parts->access_token);
 | |
| 2309 | -            update_option('gd_ga_refresh_token', $parts->refresh_token);
 | |
| 2310 | - ?><script>window.close();</script><?php | |
| 2311 | - } | |
| 2308 | +			update_option('gd_ga_access_token', $parts->access_token);
 | |
| 2309 | +			update_option('gd_ga_refresh_token', $parts->refresh_token);
 | |
| 2310 | + ?><script>window.close();</script><?php | |
| 2311 | + } | |
| 2312 | 2312 | |
| 2313 | 2313 | |
| 2314 | - } | |
| 2315 | -    elseif(!empty($response['response']['code'])) {
 | |
| 2316 | - $parts = json_decode($response['body']); | |
| 2314 | + } | |
| 2315 | +	elseif(!empty($response['response']['code'])) {
 | |
| 2316 | + $parts = json_decode($response['body']); | |
| 2317 | 2317 | |
| 2318 | -        if(isset($parts->error)){
 | |
| 2319 | - echo $parts->error.": ".$parts->error_description;exit; | |
| 2320 | -        }else{
 | |
| 2321 | - echo $error_msg." - #2";exit; | |
| 2322 | - } | |
| 2318 | +		if(isset($parts->error)){
 | |
| 2319 | + echo $parts->error.": ".$parts->error_description;exit; | |
| 2320 | +		}else{
 | |
| 2321 | + echo $error_msg." - #2";exit; | |
| 2322 | + } | |
| 2323 | 2323 | |
| 2324 | -    }else{
 | |
| 2324 | +	}else{
 | |
| 2325 | 2325 | |
| 2326 | - echo $error_msg." - #3";exit; | |
| 2326 | + echo $error_msg." - #3";exit; | |
| 2327 | 2327 | |
| 2328 | - } | |
| 2328 | + } | |
| 2329 | 2329 | } | 
| 2330 | - exit; | |
| 2330 | + exit; | |
| 2331 | 2331 | } | 
| 2332 | 2332 | |
| 2333 | 2333 | add_filter( 'icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4 ); | 
| @@ -62,7 +62,7 @@ discard block | ||
| 62 | 62 | */ | 
| 63 | 63 | function geodir_get_admin_option_form($current_tab) | 
| 64 | 64 |  {
 | 
| 65 | - geodir_admin_option_form($current_tab);// defined in admin template tags.php | |
| 65 | + geodir_admin_option_form($current_tab); // defined in admin template tags.php | |
| 66 | 66 | } | 
| 67 | 67 | |
| 68 | 68 | |
| @@ -70,7 +70,7 @@ discard block | ||
| 70 | 70 |  add_action('geodir_update_options_compatibility_settings', 'geodir_update_options_compatibility_settings');
 | 
| 71 | 71 |  add_action('geodir_update_options_default_location_settings', 'geodir_location_form_submit');
 | 
| 72 | 72 |  add_action('geodir_before_admin_panel', 'geodir_before_admin_panel'); // this function is in admin_functions.php
 | 
| 73 | -add_action('geodir_before_update_options', 'geodir_before_update_options',10,2);
 | |
| 73 | +add_action('geodir_before_update_options', 'geodir_before_update_options', 10, 2);
 | |
| 74 | 74 | |
| 75 | 75 |  //add_action('geodir_before_admin_panel', 'geodir_autoinstall_admin_header');
 | 
| 76 | 76 | |
| @@ -228,9 +228,9 @@ discard block | ||
| 228 | 228 | |
| 229 | 229 | // Filter-Payment-Manager | 
| 230 | 230 | |
| 231 | -        add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
 | |
| 231 | +        add_meta_box('geodir_post_images', $post_typename.' '.__('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
 | |
| 232 | 232 | |
| 233 | -        add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
 | |
| 233 | +        add_meta_box('geodir_post_info', $post_typename.' '.__('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
 | |
| 234 | 234 | |
| 235 | 235 | // no need of this box as all fields moved to main information box | 
| 236 | 236 |          //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
 | 
| @@ -239,7 +239,7 @@ discard block | ||
| 239 | 239 | |
| 240 | 240 | } | 
| 241 | 241 | |
| 242 | -add_action('save_post', 'geodir_post_information_save',10,2);
 | |
| 242 | +add_action('save_post', 'geodir_post_information_save', 10, 2);
 | |
| 243 | 243 | |
| 244 | 244 | |
| 245 | 245 | |
| @@ -266,10 +266,10 @@ discard block | ||
| 266 | 266 | |
| 267 | 267 | $gd_taxonomy = geodir_get_taxonomies($geodir_post_type); | 
| 268 | 268 | |
| 269 | -            if(!empty($gd_taxonomy)) {
 | |
| 269 | +            if (!empty($gd_taxonomy)) {
 | |
| 270 | 270 |                  foreach ($gd_taxonomy as $tax) {
 | 
| 271 | 271 | |
| 272 | - remove_meta_box($tax . 'div', $geodir_post_type, 'normal'); | |
| 272 | + remove_meta_box($tax.'div', $geodir_post_type, 'normal'); | |
| 273 | 273 | |
| 274 | 274 | } | 
| 275 | 275 | } | 
| @@ -355,14 +355,14 @@ discard block | ||
| 355 | 355 |  add_action('geodir_manage_available_fields_predefined', 'geodir_manage_available_fields_predefined');
 | 
| 356 | 356 |  add_action('geodir_manage_available_fields_custom', 'geodir_manage_available_fields_custom');
 | 
| 357 | 357 | |
| 358 | -function geodir_manage_available_fields_predefined($sub_tab){
 | |
| 359 | -    if($sub_tab=='custom_fields'){
 | |
| 358 | +function geodir_manage_available_fields_predefined($sub_tab) {
 | |
| 359 | +    if ($sub_tab == 'custom_fields') {
 | |
| 360 | 360 |          geodir_custom_available_fields('predefined');
 | 
| 361 | 361 | } | 
| 362 | 362 | } | 
| 363 | 363 | |
| 364 | -function geodir_manage_available_fields_custom($sub_tab){
 | |
| 365 | -    if($sub_tab=='custom_fields'){
 | |
| 364 | +function geodir_manage_available_fields_custom($sub_tab) {
 | |
| 365 | +    if ($sub_tab == 'custom_fields') {
 | |
| 366 | 366 |          geodir_custom_available_fields('custom');
 | 
| 367 | 367 | } | 
| 368 | 368 | } | 
| @@ -432,7 +432,7 @@ discard block | ||
| 432 | 432 | global $wpdb; | 
| 433 | 433 | $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; | 
| 434 | 434 | ?> | 
| 435 | - <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/> | |
| 435 | + <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type; ?>"/> | |
| 436 | 436 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> | 
| 437 | 437 | <ul> | 
| 438 | 438 | <?php | 
| @@ -443,7 +443,7 @@ discard block | ||
| 443 | 443 | |
| 444 | 444 | $check_html_variable = $wpdb->get_var( | 
| 445 | 445 | $wpdb->prepare( | 
| 446 | - "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s", | |
| 446 | + "SELECT htmlvar_name FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s", | |
| 447 | 447 | array($val['htmlvar_name'], $listing_type, $val['field_type']) | 
| 448 | 448 | ) | 
| 449 | 449 | ); | 
| @@ -451,23 +451,23 @@ discard block | ||
| 451 | 451 | $display = $check_html_variable ? ' style="display:none;"' : ''; | 
| 452 | 452 | ?> | 
| 453 | 453 | |
| 454 | - <li class="gd-cf-tooltip-wrap" <?php echo $display;?>> | |
| 454 | + <li class="gd-cf-tooltip-wrap" <?php echo $display; ?>> | |
| 455 | 455 | <?php | 
| 456 | -                if(isset($val['description']) && $val['description']){
 | |
| 456 | +                if (isset($val['description']) && $val['description']) {
 | |
| 457 | 457 | echo '<div class="gdcf-tooltip">'.$val['description'].'</div>'; | 
| 458 | 458 | }?> | 
| 459 | 459 | |
| 460 | - <a id="gd-<?php echo $val['field_type'];?>-_-<?php echo $val['htmlvar_name'];?>" data-field-type-key="<?php echo $val['htmlvar_name'];?>" data-field-type="<?php echo $val['field_type'];?>" | |
| 461 | - title="<?php echo $val['site_title'];?>" | |
| 462 | - class="gd-draggable-form-items gd-<?php echo $val['field_type'];?> geodir-sort-<?php echo $val['htmlvar_name'];?>" href="javascript:void(0);"> | |
| 460 | + <a id="gd-<?php echo $val['field_type']; ?>-_-<?php echo $val['htmlvar_name']; ?>" data-field-type-key="<?php echo $val['htmlvar_name']; ?>" data-field-type="<?php echo $val['field_type']; ?>" | |
| 461 | + title="<?php echo $val['site_title']; ?>" | |
| 462 | + class="gd-draggable-form-items gd-<?php echo $val['field_type']; ?> geodir-sort-<?php echo $val['htmlvar_name']; ?>" href="javascript:void(0);"> | |
| 463 | 463 |                      <?php if (isset($val['field_icon']) && strpos($val['field_icon'], 'fa fa-') !== false) {
 | 
| 464 | 464 | echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>'; | 
| 465 | -                    }elseif(isset($val['field_icon']) && $val['field_icon'] ){
 | |
| 465 | +                    }elseif (isset($val['field_icon']) && $val['field_icon']) {
 | |
| 466 | 466 |                          echo '<b style="background-image: url("'.$val['field_icon'].'")"></b>';
 | 
| 467 | -                    }else{
 | |
| 467 | +                    } else {
 | |
| 468 | 468 | echo '<i class="fa fa-cog" aria-hidden="true"></i>'; | 
| 469 | 469 | }?> | 
| 470 | - <?php echo $val['site_title'];?> | |
| 470 | + <?php echo $val['site_title']; ?> | |
| 471 | 471 | </a> | 
| 472 | 472 | </li> | 
| 473 | 473 | |
| @@ -495,7 +495,7 @@ discard block | ||
| 495 | 495 | <?php | 
| 496 | 496 | global $wpdb; | 
| 497 | 497 | |
| 498 | -        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
 | |
| 498 | +        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
 | |
| 499 | 499 | |
| 500 | 500 |          if (!empty($fields)) {
 | 
| 501 | 501 |              foreach ($fields as $field) {
 | 
| @@ -520,14 +520,14 @@ discard block | ||
| 520 | 520 | * @since 1.6.9 | 
| 521 | 521 | * @package GeoDirectory | 
| 522 | 522 | */ | 
| 523 | -function geodir_custom_fields_custom($post_type=''){
 | |
| 523 | +function geodir_custom_fields_custom($post_type = '') {
 | |
| 524 | 524 | |
| 525 | 525 | $custom_fields = array(); | 
| 526 | 526 | |
| 527 | 527 | /** | 
| 528 | 528 | * @see `geodir_custom_fields` | 
| 529 | 529 | */ | 
| 530 | -    return apply_filters('geodir_custom_fields_custom',$custom_fields,$post_type);
 | |
| 530 | +    return apply_filters('geodir_custom_fields_custom', $custom_fields, $post_type);
 | |
| 531 | 531 | } | 
| 532 | 532 | |
| 533 | 533 | |
| @@ -538,7 +538,7 @@ discard block | ||
| 538 | 538 | * @since 1.6.6 | 
| 539 | 539 | * @package GeoDirectory | 
| 540 | 540 | */ | 
| 541 | -function geodir_custom_fields($post_type=''){
 | |
| 541 | +function geodir_custom_fields($post_type = '') {
 | |
| 542 | 542 | |
| 543 | 543 | $custom_fields = array( | 
| 544 | 544 | 'text' => array( | 
| @@ -673,7 +673,7 @@ discard block | ||
| 673 | 673 | * } | 
| 674 | 674 | * @param string $post_type The post type requested. | 
| 675 | 675 | */ | 
| 676 | -    return apply_filters('geodir_custom_fields',$custom_fields,$post_type);
 | |
| 676 | +    return apply_filters('geodir_custom_fields', $custom_fields, $post_type);
 | |
| 677 | 677 | } | 
| 678 | 678 | |
| 679 | 679 | /** | 
| @@ -684,25 +684,25 @@ discard block | ||
| 684 | 684 | * @param string $type The custom field type, predefined, custom or blank for default | 
| 685 | 685 | * @package GeoDirectory | 
| 686 | 686 | */ | 
| 687 | -function geodir_custom_available_fields($type='') | |
| 687 | +function geodir_custom_available_fields($type = '') | |
| 688 | 688 |  {
 | 
| 689 | 689 | $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; | 
| 690 | 690 | ?> | 
| 691 | - <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/> | |
| 691 | + <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type; ?>"/> | |
| 692 | 692 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>" /> | 
| 693 | 693 | |
| 694 | 694 | <?php | 
| 695 | -        if($type=='predefined'){
 | |
| 695 | +        if ($type == 'predefined') {
 | |
| 696 | 696 | $cfs = geodir_custom_fields_predefined($listing_type); | 
| 697 | -        }elseif($type=='custom'){
 | |
| 697 | +        }elseif ($type == 'custom') {
 | |
| 698 | 698 | $cfs = geodir_custom_fields_custom($listing_type); | 
| 699 | -        }else{
 | |
| 699 | +        } else {
 | |
| 700 | 700 | $cfs = geodir_custom_fields($listing_type); | 
| 701 | 701 | ?> | 
| 702 | 702 | <ul class="full gd-cf-tooltip-wrap"> | 
| 703 | 703 | <li> | 
| 704 | 704 | <div class="gdcf-tooltip"> | 
| 705 | -                        <?php _e('This adds a section separator with a title.', 'geodirectory');?>
 | |
| 705 | +                        <?php _e('This adds a section separator with a title.', 'geodirectory'); ?>
 | |
| 706 | 706 | </div> | 
| 707 | 707 | <a id="gt-fieldset" | 
| 708 | 708 | class="gd-draggable-form-items gt-fieldset" | 
| @@ -713,7 +713,7 @@ discard block | ||
| 713 | 713 | |
| 714 | 714 | <i class="fa fa-long-arrow-left " aria-hidden="true"></i> | 
| 715 | 715 | <i class="fa fa-long-arrow-right " aria-hidden="true"></i> | 
| 716 | -                        <?php _e('Fieldset (section separator)', 'geodirectory');?>
 | |
| 716 | +                        <?php _e('Fieldset (section separator)', 'geodirectory'); ?>
 | |
| 717 | 717 | </a> | 
| 718 | 718 | </li> | 
| 719 | 719 | </ul> | 
| @@ -721,15 +721,15 @@ discard block | ||
| 721 | 721 | <?php | 
| 722 | 722 | } | 
| 723 | 723 | |
| 724 | -    if(!empty($cfs)) {
 | |
| 724 | +    if (!empty($cfs)) {
 | |
| 725 | 725 | |
| 726 | -        foreach ( $cfs as $id => $cf ) {
 | |
| 726 | +        foreach ($cfs as $id => $cf) {
 | |
| 727 | 727 | ?> | 
| 728 | 728 | <ul> | 
| 729 | 729 | <li class="gd-cf-tooltip-wrap"> | 
| 730 | 730 | <?php | 
| 731 | -                if ( isset( $cf['description'] ) && $cf['description'] ) {
 | |
| 732 | - echo '<div class="gdcf-tooltip">' . $cf['description'] . '</div>'; | |
| 731 | +                if (isset($cf['description']) && $cf['description']) {
 | |
| 732 | + echo '<div class="gdcf-tooltip">'.$cf['description'].'</div>'; | |
| 733 | 733 | } ?> | 
| 734 | 734 | |
| 735 | 735 | <a id="gd-<?php echo $id; ?>" | 
| @@ -739,10 +739,10 @@ discard block | ||
| 739 | 739 | class="gd-draggable-form-items <?php echo $cf['class']; ?>" | 
| 740 | 740 | href="javascript:void(0);"> | 
| 741 | 741 | |
| 742 | -                    <?php if ( isset( $cf['icon'] ) && strpos( $cf['icon'], 'fa fa-' ) !== false ) {
 | |
| 743 | - echo '<i class="' . $cf['icon'] . '" aria-hidden="true"></i>'; | |
| 744 | -                    } elseif ( isset( $cf['icon'] ) && $cf['icon'] ) {
 | |
| 745 | -                        echo '<b style="background-image: url("' . $cf['icon'] . '")"></b>';
 | |
| 742 | +                    <?php if (isset($cf['icon']) && strpos($cf['icon'], 'fa fa-') !== false) {
 | |
| 743 | + echo '<i class="'.$cf['icon'].'" aria-hidden="true"></i>'; | |
| 744 | +                    } elseif (isset($cf['icon']) && $cf['icon']) {
 | |
| 745 | +                        echo '<b style="background-image: url("'.$cf['icon'].'")"></b>';
 | |
| 746 | 746 |                      } else {
 | 
| 747 | 747 | echo '<i class="fa fa-cog" aria-hidden="true"></i>'; | 
| 748 | 748 | } ?> | 
| @@ -751,7 +751,7 @@ discard block | ||
| 751 | 751 | </li> | 
| 752 | 752 | <?php | 
| 753 | 753 | } | 
| 754 | -    }else{
 | |
| 754 | +    } else {
 | |
| 755 | 755 |          _e('There are no custom fields here yet.', 'geodirectory');
 | 
| 756 | 756 | } | 
| 757 | 757 | ?> | 
| @@ -779,7 +779,7 @@ discard block | ||
| 779 | 779 | <ul class="core"> | 
| 780 | 780 | <?php | 
| 781 | 781 | global $wpdb; | 
| 782 | -        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
 | |
| 782 | +        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".GEODIR_CUSTOM_FIELDS_TABLE." WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
 | |
| 783 | 783 | |
| 784 | 784 |          if (!empty($fields)) {
 | 
| 785 | 785 |              foreach ($fields as $field) {
 | 
| @@ -789,7 +789,7 @@ discard block | ||
| 789 | 789 | $field_type_key = $field->field_type_key; | 
| 790 | 790 | $field_ins_upd = 'display'; | 
| 791 | 791 | |
| 792 | - geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key); | |
| 792 | + geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd, $field_type_key); | |
| 793 | 793 | } | 
| 794 | 794 | } | 
| 795 | 795 | ?></ul> | 
| @@ -867,7 +867,7 @@ discard block | ||
| 867 | 867 | |
| 868 | 868 |      switch ($sub_tab) {
 | 
| 869 | 869 | case 'custom_fields': | 
| 870 | -            $note = sprintf(__('Click on any box below to add a field of that type to the add %s listing form. You can use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type));;
 | |
| 870 | +            $note = sprintf(__('Click on any box below to add a field of that type to the add %s listing form. You can use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type)); ;
 | |
| 871 | 871 | break; | 
| 872 | 872 | |
| 873 | 873 | case 'sorting_options': | 
| @@ -921,7 +921,7 @@ discard block | ||
| 921 | 921 | |
| 922 | 922 |      switch ($sub_tab) {
 | 
| 923 | 923 | case 'custom_fields': | 
| 924 | -            $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order on add %s listing form too.', 'geodirectory'), get_post_type_singular_label($listing_type));;
 | |
| 924 | +            $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order on add %s listing form too.', 'geodirectory'), get_post_type_singular_label($listing_type)); ;
 | |
| 925 | 925 | break; | 
| 926 | 926 | |
| 927 | 927 | case 'sorting_options': | 
| @@ -948,8 +948,8 @@ discard block | ||
| 948 | 948 | |
| 949 | 949 |      if (!get_option('geodir_remove_unnecessary_fields')) {
 | 
| 950 | 950 | |
| 951 | -        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
 | |
| 952 | -            $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
 | |
| 951 | +        if ($wpdb->get_var("SHOW COLUMNS FROM ".$plugin_prefix."gd_place_detail WHERE field = 'categories'"))
 | |
| 952 | +            $wpdb->query("ALTER TABLE `".$plugin_prefix."gd_place_detail` DROP `categories`");
 | |
| 953 | 953 | |
| 954 | 954 |          update_option('geodir_remove_unnecessary_fields', '1');
 | 
| 955 | 955 | |
| @@ -977,14 +977,14 @@ discard block | ||
| 977 | 977 | case 'diagnosis' : | 
| 978 | 978 | if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') | 
| 979 | 979 | $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); | 
| 980 | -                call_user_func('geodir_diagnose_' . $diagnose_this);
 | |
| 980 | +                call_user_func('geodir_diagnose_'.$diagnose_this);
 | |
| 981 | 981 | exit(); | 
| 982 | 982 | break; | 
| 983 | 983 | |
| 984 | 984 | case 'diagnosis-fix' : | 
| 985 | 985 | if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') | 
| 986 | 986 | $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); | 
| 987 | -                call_user_func('geodir_diagnose_' . $diagnose_this);
 | |
| 987 | +                call_user_func('geodir_diagnose_'.$diagnose_this);
 | |
| 988 | 988 | exit(); | 
| 989 | 989 | break; | 
| 990 | 990 | } | 
| @@ -1009,50 +1009,50 @@ discard block | ||
| 1009 | 1009 |  {
 | 
| 1010 | 1010 | global $wpdb; | 
| 1011 | 1011 | //$filter_arr['output_str'] .='###'.$table.'###'; | 
| 1012 | -    if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
 | |
| 1013 | -        $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
 | |
| 1012 | +    if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") > 0) {
 | |
| 1013 | +        $filter_arr['output_str'] .= "<li>".__('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory')."</li>";
 | |
| 1014 | 1014 | $filter_arr['is_error_during_diagnose'] = true; | 
| 1015 | 1015 | |
| 1016 | -    } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
 | |
| 1017 | -        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 1016 | +    } elseif ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") > 0) {
 | |
| 1017 | +        $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name)."</li>";
 | |
| 1018 | 1018 | $filter_arr['is_error_during_diagnose'] = true; | 
| 1019 | -        $filter_arr['output_str'] .= "<li>" . __('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory') . "</li>";
 | |
| 1019 | +        $filter_arr['output_str'] .= "<li>".__('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory')."</li>";
 | |
| 1020 | 1020 | $filter_arr['is_error_during_diagnose'] = true; | 
| 1021 | 1021 | |
| 1022 | 1022 |          if ($fix) {
 | 
| 1023 | -            $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
 | |
| 1024 | -            $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
 | |
| 1023 | +            $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM ".$table."_ms_bak"); // get backup table count
 | |
| 1024 | +            $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM ".$wpdb->prefix."$table"); // get new table count
 | |
| 1025 | 1025 | |
| 1026 | 1026 |              if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
 | 
| 1027 | 1027 |                  //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
 | 
| 1028 | 1028 | |
| 1029 | -                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
 | |
| 1029 | +                $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$table."_ms_bak2"); // rename bak table to new table
 | |
| 1030 | 1030 | |
| 1031 | -                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
 | |
| 1032 | -                    $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
 | |
| 1031 | +                if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") == 0) {
 | |
| 1032 | +                    $filter_arr['output_str'] .= "<li>".__('-->FIXED: Renamed and backed up the tables', 'geodirectory')."</li>";
 | |
| 1033 | 1033 |                  } else {
 | 
| 1034 | -                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
 | |
| 1034 | +                    $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>";
 | |
| 1035 | 1035 | } | 
| 1036 | 1036 | |
| 1037 | 1037 |              } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
 | 
| 1038 | 1038 | |
| 1039 | -                $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
 | |
| 1040 | -                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
 | |
| 1039 | +                $wpdb->query("RENAME TABLE ".$wpdb->prefix."$table TO ".$table."_ms_bak2"); // rename new table to bak2
 | |
| 1040 | +                $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$wpdb->prefix."$table"); // rename bak table to new table
 | |
| 1041 | 1041 | |
| 1042 | -                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 1043 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
 | |
| 1042 | +                if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 1043 | +                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table)."</li>";
 | |
| 1044 | 1044 |                  } else {
 | 
| 1045 | -                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
 | |
| 1045 | +                    $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>";
 | |
| 1046 | 1046 | } | 
| 1047 | 1047 | |
| 1048 | 1048 |              } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
 | 
| 1049 | 1049 | |
| 1050 | -                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
 | |
| 1050 | +                $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$table."_ms_bak2"); // rename ms_bak table to ms_bak2
 | |
| 1051 | 1051 | |
| 1052 | -                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
 | |
| 1053 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
 | |
| 1052 | +                if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") == 0) {
 | |
| 1053 | +                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table)."</li>";
 | |
| 1054 | 1054 |                  } else {
 | 
| 1055 | -                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
 | |
| 1055 | +                    $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>";
 | |
| 1056 | 1056 | } | 
| 1057 | 1057 | |
| 1058 | 1058 | } | 
| @@ -1060,54 +1060,54 @@ discard block | ||
| 1060 | 1060 | } | 
| 1061 | 1061 | |
| 1062 | 1062 | |
| 1063 | -    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
 | |
| 1064 | -        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 1063 | +    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") > 0) {
 | |
| 1064 | +        $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name)."</li>";
 | |
| 1065 | 1065 | $filter_arr['is_error_during_diagnose'] = true; | 
| 1066 | 1066 | |
| 1067 | 1067 |          if ($fix) {
 | 
| 1068 | 1068 |              if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
 | 
| 1069 | 1069 |                  if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
 | 
| 1070 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
 | |
| 1070 | +                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table)."</li>";
 | |
| 1071 | 1071 |                  } else {
 | 
| 1072 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
 | |
| 1072 | +                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table)."</li>";
 | |
| 1073 | 1073 | } | 
| 1074 | 1074 | |
| 1075 | -            } elseif ($wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table") == 0) {// if main table is empty but original is not, delete main and rename original
 | |
| 1076 | -                if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
 | |
| 1077 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
 | |
| 1075 | +            } elseif ($wpdb->get_var("SELECT COUNT(*) FROM ".$wpdb->prefix."$table") == 0) {// if main table is empty but original is not, delete main and rename original
 | |
| 1076 | +                if ($wpdb->query("DROP TABLE IF EXISTS ".$wpdb->prefix."$table")) {
 | |
| 1077 | +                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix.$table)."</li>";
 | |
| 1078 | 1078 |                  } else {
 | 
| 1079 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
 | |
| 1079 | +                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix.$table)."</li>";
 | |
| 1080 | 1080 | } | 
| 1081 | -                if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 1082 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
 | |
| 1081 | +                if ($wpdb->query("RENAME TABLE $table TO ".$wpdb->prefix."$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 1082 | +                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>";
 | |
| 1083 | 1083 |                  } else {
 | 
| 1084 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
 | |
| 1084 | +                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>";
 | |
| 1085 | 1085 | } | 
| 1086 | 1086 |              } else {// else rename the original table to _ms_bak
 | 
| 1087 | -                if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 1088 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
 | |
| 1087 | +                if ($wpdb->query("RENAME TABLE $table TO ".$table."_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 1088 | +                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table."_ms_bak")."</li>";
 | |
| 1089 | 1089 |                  } else {
 | 
| 1090 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
 | |
| 1090 | +                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table."_ms_bak")."</li>";
 | |
| 1091 | 1091 | } | 
| 1092 | 1092 | } | 
| 1093 | 1093 | } | 
| 1094 | 1094 | |
| 1095 | -    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
 | |
| 1096 | -        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 1095 | +    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") == 0) {
 | |
| 1096 | +        $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name)."</li>";
 | |
| 1097 | 1097 | $filter_arr['is_error_during_diagnose'] = true; | 
| 1098 | 1098 | |
| 1099 | 1099 |          if ($fix) {
 | 
| 1100 | 1100 | // if original table exists but new does not, rename | 
| 1101 | -            if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 1102 | -                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
 | |
| 1101 | +            if ($wpdb->query("RENAME TABLE $table TO ".$wpdb->prefix."$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 1102 | +                $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>";
 | |
| 1103 | 1103 |              } else {
 | 
| 1104 | -                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
 | |
| 1104 | +                $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>";
 | |
| 1105 | 1105 | } | 
| 1106 | 1106 | |
| 1107 | 1107 | } | 
| 1108 | 1108 | |
| 1109 | -    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
 | |
| 1110 | -        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 1109 | +    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") == 0) {
 | |
| 1110 | +        $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name)."</li>";
 | |
| 1111 | 1111 | $filter_arr['is_error_during_diagnose'] = true; | 
| 1112 | 1112 | |
| 1113 | 1113 |          if ($fix) {
 | 
| @@ -1121,11 +1121,11 @@ discard block | ||
| 1121 | 1121 |              delete_option('geodir_custom_posts_db_version');
 | 
| 1122 | 1122 |              delete_option('geodir_reviewratings_db_version');
 | 
| 1123 | 1123 |              delete_option('geodiradvancesearch_db_version');
 | 
| 1124 | -            $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
 | |
| 1124 | +            $filter_arr['output_str'] .= "<li>".__('-->TRY: Please refresh page to run table install functions', 'geodirectory')."</li>";
 | |
| 1125 | 1125 | } | 
| 1126 | 1126 | |
| 1127 | 1127 |      } else {
 | 
| 1128 | -        $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 1128 | +        $filter_arr['output_str'] .= "<li>".sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name)."</li>";
 | |
| 1129 | 1129 | } | 
| 1130 | 1130 | return $filter_arr; | 
| 1131 | 1131 | } | 
| @@ -1154,23 +1154,23 @@ discard block | ||
| 1154 | 1154 |      if (!empty($all_postypes)) {
 | 
| 1155 | 1155 |          foreach ($all_postypes as $key) {
 | 
| 1156 | 1156 | // update each GD CPT | 
| 1157 | -            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
 | |
| 1157 | +            $posts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."geodir_".$key."_detail d");
 | |
| 1158 | 1158 | |
| 1159 | 1159 |              if (!empty($posts)) {
 | 
| 1160 | 1160 | |
| 1161 | 1161 |                  foreach ($posts as $p) {
 | 
| 1162 | 1162 | $p->post_type = $key; | 
| 1163 | -                    $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
 | |
| 1163 | +                    $raw_tags = wp_get_object_terms($p->post_id, $p->post_type.'_tags', array('fields' => 'names'));
 | |
| 1164 | 1164 |                      if (empty($raw_tags)) {
 | 
| 1165 | 1165 | $post_tags = ''; | 
| 1166 | 1166 |                      } else {
 | 
| 1167 | 1167 |                          $post_tags = implode(",", $raw_tags);
 | 
| 1168 | 1168 | } | 
| 1169 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; | |
| 1170 | -                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
 | |
| 1169 | + $tablename = $plugin_prefix.$p->post_type.'_detail'; | |
| 1170 | +                    $wpdb->query($wpdb->prepare("UPDATE ".$tablename." SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
 | |
| 1171 | 1171 | |
| 1172 | 1172 | } | 
| 1173 | -                $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
 | |
| 1173 | +                $output_str .= "<li>".$key.__(': Done', 'geodirectory')."</li>";
 | |
| 1174 | 1174 | } | 
| 1175 | 1175 | |
| 1176 | 1176 | } | 
| @@ -1179,7 +1179,7 @@ discard block | ||
| 1179 | 1179 | |
| 1180 | 1180 |      if ($is_error_during_diagnose) {
 | 
| 1181 | 1181 | $info_div_class = "geodir_problem_info"; | 
| 1182 | -        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
 | |
| 1182 | +        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
 | |
| 1183 | 1183 |      } else {
 | 
| 1184 | 1184 | $info_div_class = "geodir_noproblem_info"; | 
| 1185 | 1185 | $fix_button_txt = ''; | 
| @@ -1216,29 +1216,29 @@ discard block | ||
| 1216 | 1216 |      if (!empty($all_postypes)) {
 | 
| 1217 | 1217 |          foreach ($all_postypes as $key) {
 | 
| 1218 | 1218 | // update each GD CTP | 
| 1219 | -            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
 | |
| 1219 | +            $posts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."geodir_".$key."_detail d WHERE d.".$key."category='' ");
 | |
| 1220 | 1220 | |
| 1221 | 1221 |              if (!empty($posts)) {
 | 
| 1222 | 1222 | |
| 1223 | 1223 |                  foreach ($posts as $p) {
 | 
| 1224 | 1224 | $p->post_type = $key; | 
| 1225 | -                    $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
 | |
| 1225 | +                    $raw_cats = wp_get_object_terms($p->post_id, $p->post_type.'category', array('fields' => 'ids'));
 | |
| 1226 | 1226 | |
| 1227 | 1227 |                      if (empty($raw_cats)) {
 | 
| 1228 | 1228 | $post_categories = get_post_meta($p->post_id, 'post_categories', true); | 
| 1229 | 1229 | |
| 1230 | -                        if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
 | |
| 1231 | -                            $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
 | |
| 1232 | -                            foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
 | |
| 1230 | +                        if (!empty($post_categories) && !empty($post_categories[$p->post_type.'category'])) {
 | |
| 1231 | +                            $post_categories[$p->post_type.'category'] = str_replace("d:", "", $post_categories[$p->post_type.'category']);
 | |
| 1232 | +                            foreach (explode(",", $post_categories[$p->post_type.'category']) as $cat_part) {
 | |
| 1233 | 1233 |                                  if (is_numeric($cat_part)) {
 | 
| 1234 | - $raw_cats[] = (int)$cat_part; | |
| 1234 | + $raw_cats[] = (int) $cat_part; | |
| 1235 | 1235 | } | 
| 1236 | 1236 | } | 
| 1237 | 1237 | |
| 1238 | 1238 | } | 
| 1239 | 1239 | |
| 1240 | 1240 |                          if (!empty($raw_cats)) {
 | 
| 1241 | - $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category'); | |
| 1241 | + $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type.'category'); | |
| 1242 | 1242 | |
| 1243 | 1243 | } | 
| 1244 | 1244 | |
| @@ -1248,14 +1248,14 @@ discard block | ||
| 1248 | 1248 |                      if (empty($raw_cats)) {
 | 
| 1249 | 1249 | $post_cats = ''; | 
| 1250 | 1250 |                      } else {
 | 
| 1251 | -                        $post_cats = ',' . implode(",", $raw_cats) . ',';
 | |
| 1251 | +                        $post_cats = ','.implode(",", $raw_cats).',';
 | |
| 1252 | 1252 | } | 
| 1253 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; | |
| 1254 | -                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
 | |
| 1253 | + $tablename = $plugin_prefix.$p->post_type.'_detail'; | |
| 1254 | +                    $wpdb->query($wpdb->prepare("UPDATE ".$tablename." SET ".$p->post_type."category=%s WHERE post_id =%d", $post_cats, $p->post_id));
 | |
| 1255 | 1255 | } | 
| 1256 | 1256 | |
| 1257 | 1257 | } | 
| 1258 | -            $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
 | |
| 1258 | +            $output_str .= "<li>".$key.__(': Done', 'geodirectory')."</li>";
 | |
| 1259 | 1259 | |
| 1260 | 1260 | } | 
| 1261 | 1261 | |
| @@ -1263,7 +1263,7 @@ discard block | ||
| 1263 | 1263 | |
| 1264 | 1264 |      if ($is_error_during_diagnose) {
 | 
| 1265 | 1265 | $info_div_class = "geodir_problem_info"; | 
| 1266 | -        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
 | |
| 1266 | +        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
 | |
| 1267 | 1267 |      } else {
 | 
| 1268 | 1268 | $info_div_class = "geodir_noproblem_info"; | 
| 1269 | 1269 | $fix_button_txt = ''; | 
| @@ -1316,15 +1316,15 @@ discard block | ||
| 1316 | 1316 |      if (!empty($ver_arr)) {
 | 
| 1317 | 1317 |          foreach ($ver_arr as $key => $val) {
 | 
| 1318 | 1318 |              if (delete_option($val)) {
 | 
| 1319 | -                $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
 | |
| 1319 | +                $output_str .= "<li>".$key.__(' Version: Deleted', 'geodirectory')."</li>";
 | |
| 1320 | 1320 |              } else {
 | 
| 1321 | -                $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
 | |
| 1321 | +                $output_str .= "<li>".$key.__(' Version: Not Found', 'geodirectory')."</li>";
 | |
| 1322 | 1322 | } | 
| 1323 | 1323 | |
| 1324 | 1324 | } | 
| 1325 | 1325 | |
| 1326 | 1326 |          if ($output_str) {
 | 
| 1327 | -            $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
 | |
| 1327 | +            $output_str .= "<li><strong>".__(' Upgrade/install scripts will run on next page reload.', 'geodirectory')."</strong></li>";
 | |
| 1328 | 1328 | } | 
| 1329 | 1329 | |
| 1330 | 1330 | } | 
| @@ -1361,43 +1361,43 @@ discard block | ||
| 1361 | 1361 | $output_str = ''; | 
| 1362 | 1362 | |
| 1363 | 1363 | // check review locations | 
| 1364 | -    if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) {
 | |
| 1365 | -        $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
 | |
| 1364 | +    if ($wpdb->get_results("SELECT * FROM ".GEODIR_REVIEW_TABLE." WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) {
 | |
| 1365 | +        $output_str .= "<li>".__('Review locations missing or broken', 'geodirectory')."</li>";
 | |
| 1366 | 1366 | $is_error_during_diagnose = true; | 
| 1367 | 1367 | |
| 1368 | 1368 |          if ($fix) {
 | 
| 1369 | 1369 |              if (geodir_fix_review_location()) {
 | 
| 1370 | -                $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
 | |
| 1370 | +                $output_str .= "<li><strong>".__('-->FIXED: Review locations fixed', 'geodirectory')."</strong></li>";
 | |
| 1371 | 1371 |              } else {
 | 
| 1372 | -                $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1372 | +                $output_str .= "<li><strong>".__('-->FAILED: Review locations fix failed', 'geodirectory')."</strong></li>";
 | |
| 1373 | 1373 | } | 
| 1374 | 1374 | } | 
| 1375 | 1375 | |
| 1376 | 1376 |      } else {
 | 
| 1377 | -        $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
 | |
| 1377 | +        $output_str .= "<li>".__('Review locations ok', 'geodirectory')."</li>";
 | |
| 1378 | 1378 | } | 
| 1379 | 1379 | |
| 1380 | 1380 | // check review content | 
| 1381 | -    if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
 | |
| 1382 | -        $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
 | |
| 1381 | +    if ($wpdb->get_results("SELECT * FROM ".GEODIR_REVIEW_TABLE." WHERE comment_content IS NULL")) {
 | |
| 1382 | +        $output_str .= "<li>".__('Review content missing or broken', 'geodirectory')."</li>";
 | |
| 1383 | 1383 | $is_error_during_diagnose = true; | 
| 1384 | 1384 | |
| 1385 | 1385 |          if ($fix) {
 | 
| 1386 | 1386 |              if (geodir_fix_review_content()) {
 | 
| 1387 | -                $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
 | |
| 1387 | +                $output_str .= "<li><strong>".__('-->FIXED: Review content fixed', 'geodirectory')."</strong></li>";
 | |
| 1388 | 1388 |              } else {
 | 
| 1389 | -                $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1389 | +                $output_str .= "<li><strong>".__('-->FAILED: Review content fix failed', 'geodirectory')."</strong></li>";
 | |
| 1390 | 1390 | } | 
| 1391 | 1391 | } | 
| 1392 | 1392 | |
| 1393 | 1393 |      } else {
 | 
| 1394 | -        $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
 | |
| 1394 | +        $output_str .= "<li>".__('Review content ok', 'geodirectory')."</li>";
 | |
| 1395 | 1395 | } | 
| 1396 | 1396 | |
| 1397 | 1397 | |
| 1398 | 1398 |      if ($is_error_during_diagnose) {
 | 
| 1399 | 1399 | $info_div_class = "geodir_problem_info"; | 
| 1400 | -        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
 | |
| 1400 | +        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
 | |
| 1401 | 1401 |      } else {
 | 
| 1402 | 1402 | $info_div_class = "geodir_noproblem_info"; | 
| 1403 | 1403 | $fix_button_txt = ''; | 
| @@ -1461,7 +1461,7 @@ discard block | ||
| 1461 | 1461 | |
| 1462 | 1462 |      if ($is_error_during_diagnose) {
 | 
| 1463 | 1463 | $info_div_class = "geodir_problem_info"; | 
| 1464 | -        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
 | |
| 1464 | +        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
 | |
| 1465 | 1465 |      } else {
 | 
| 1466 | 1466 | $info_div_class = "geodir_noproblem_info"; | 
| 1467 | 1467 | $fix_button_txt = ''; | 
| @@ -1495,7 +1495,7 @@ discard block | ||
| 1495 | 1495 |      else {
 | 
| 1496 | 1496 | $page_found = $wpdb->get_var( | 
| 1497 | 1497 | $wpdb->prepare( | 
| 1498 | - "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", | |
| 1498 | + "SELECT ID FROM ".$wpdb->posts." WHERE post_name = %s LIMIT 1;", | |
| 1499 | 1499 | array($slug) | 
| 1500 | 1500 | ) | 
| 1501 | 1501 | ); | 
| @@ -1541,18 +1541,18 @@ discard block | ||
| 1541 | 1541 | ////////////////////////////////// | 
| 1542 | 1542 |      $option_value = get_option('geodir_home_page');
 | 
| 1543 | 1543 | $page = get_post($option_value); | 
| 1544 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1544 | +    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
 | |
| 1545 | 1545 | |
| 1546 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1547 | -        $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1546 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') | |
| 1547 | +        $output_str .= "<li>".__('GD Home page exists with proper setting.', 'geodirectory')."</li>";
 | |
| 1548 | 1548 |      else {
 | 
| 1549 | 1549 | $is_error_during_diagnose = true; | 
| 1550 | -        $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1550 | +        $output_str .= "<li><strong>".__('GD Home page is missing.', 'geodirectory')."</strong></li>";
 | |
| 1551 | 1551 |          if ($fix) {
 | 
| 1552 | 1552 |              if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
 | 
| 1553 | -                $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1553 | +                $output_str .= "<li><strong>".__('-->FIXED: GD Home page fixed', 'geodirectory')."</strong></li>";
 | |
| 1554 | 1554 |              } else {
 | 
| 1555 | -                $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1555 | +                $output_str .= "<li><strong>".__('-->FAILED: GD Home page fix failed', 'geodirectory')."</strong></li>";
 | |
| 1556 | 1556 | } | 
| 1557 | 1557 | } | 
| 1558 | 1558 | } | 
| @@ -1566,18 +1566,18 @@ discard block | ||
| 1566 | 1566 | ////////////////////////////////// | 
| 1567 | 1567 |      $option_value = get_option('geodir_add_listing_page');
 | 
| 1568 | 1568 | $page = get_post($option_value); | 
| 1569 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1569 | +    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
 | |
| 1570 | 1570 | |
| 1571 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1572 | -        $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1571 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') | |
| 1572 | +        $output_str .= "<li>".__('Add Listing page exists with proper setting.', 'geodirectory')."</li>";
 | |
| 1573 | 1573 |      else {
 | 
| 1574 | 1574 | $is_error_during_diagnose = true; | 
| 1575 | -        $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1575 | +        $output_str .= "<li><strong>".__('Add Listing page is missing.', 'geodirectory')."</strong></li>";
 | |
| 1576 | 1576 |          if ($fix) {
 | 
| 1577 | 1577 |              if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
 | 
| 1578 | -                $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1578 | +                $output_str .= "<li><strong>".__('-->FIXED: Add Listing page fixed', 'geodirectory')."</strong></li>";
 | |
| 1579 | 1579 |              } else {
 | 
| 1580 | -                $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1580 | +                $output_str .= "<li><strong>".__('-->FAILED: Add Listing page fix failed', 'geodirectory')."</strong></li>";
 | |
| 1581 | 1581 | } | 
| 1582 | 1582 | } | 
| 1583 | 1583 | } | 
| @@ -1592,18 +1592,18 @@ discard block | ||
| 1592 | 1592 | ////////////////////////////////// | 
| 1593 | 1593 |      $option_value = get_option('geodir_preview_page');
 | 
| 1594 | 1594 | $page = get_post($option_value); | 
| 1595 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1595 | +    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
 | |
| 1596 | 1596 | |
| 1597 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1598 | -        $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1597 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') | |
| 1598 | +        $output_str .= "<li>".__('Listing Preview page exists with proper setting.', 'geodirectory')."</li>";
 | |
| 1599 | 1599 |      else {
 | 
| 1600 | 1600 | $is_error_during_diagnose = true; | 
| 1601 | -        $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1601 | +        $output_str .= "<li><strong>".__('Listing Preview page is missing.', 'geodirectory')."</strong></li>";
 | |
| 1602 | 1602 |          if ($fix) {
 | 
| 1603 | 1603 |              if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
 | 
| 1604 | -                $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1604 | +                $output_str .= "<li><strong>".__('-->FIXED: Listing Preview page fixed', 'geodirectory')."</strong></li>";
 | |
| 1605 | 1605 |              } else {
 | 
| 1606 | -                $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1606 | +                $output_str .= "<li><strong>".__('-->FAILED: Listing Preview page fix failed', 'geodirectory')."</strong></li>";
 | |
| 1607 | 1607 | } | 
| 1608 | 1608 | } | 
| 1609 | 1609 | } | 
| @@ -1617,18 +1617,18 @@ discard block | ||
| 1617 | 1617 | ////////////////////////////////// | 
| 1618 | 1618 |      $option_value = get_option('geodir_success_page');
 | 
| 1619 | 1619 | $page = get_post($option_value); | 
| 1620 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1620 | +    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
 | |
| 1621 | 1621 | |
| 1622 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1623 | -        $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1622 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') | |
| 1623 | +        $output_str .= "<li>".__('Listing Success page exists with proper setting.', 'geodirectory')."</li>";
 | |
| 1624 | 1624 |      else {
 | 
| 1625 | 1625 | $is_error_during_diagnose = true; | 
| 1626 | -        $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1626 | +        $output_str .= "<li><strong>".__('Listing Success page is missing.', 'geodirectory')."</strong></li>";
 | |
| 1627 | 1627 |          if ($fix) {
 | 
| 1628 | 1628 |              if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
 | 
| 1629 | -                $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1629 | +                $output_str .= "<li><strong>".__('-->FIXED: Listing Success page fixed', 'geodirectory')."</strong></li>";
 | |
| 1630 | 1630 |              } else {
 | 
| 1631 | -                $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1631 | +                $output_str .= "<li><strong>".__('-->FAILED: Listing Success page fix failed', 'geodirectory')."</strong></li>";
 | |
| 1632 | 1632 | } | 
| 1633 | 1633 | } | 
| 1634 | 1634 | } | 
| @@ -1642,18 +1642,18 @@ discard block | ||
| 1642 | 1642 | ////////////////////////////////// | 
| 1643 | 1643 |      $option_value = get_option('geodir_info_page');
 | 
| 1644 | 1644 | $page = get_post($option_value); | 
| 1645 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1645 | +    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
 | |
| 1646 | 1646 | |
| 1647 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1648 | -        $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1647 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') | |
| 1648 | +        $output_str .= "<li>".__('Info page exists with proper setting.', 'geodirectory')."</li>";
 | |
| 1649 | 1649 |      else {
 | 
| 1650 | 1650 | $is_error_during_diagnose = true; | 
| 1651 | -        $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1651 | +        $output_str .= "<li><strong>".__('Info page is missing.', 'geodirectory')."</strong></li>";
 | |
| 1652 | 1652 |          if ($fix) {
 | 
| 1653 | 1653 |              if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
 | 
| 1654 | -                $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1654 | +                $output_str .= "<li><strong>".__('-->FIXED: Info page fixed', 'geodirectory')."</strong></li>";
 | |
| 1655 | 1655 |              } else {
 | 
| 1656 | -                $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1656 | +                $output_str .= "<li><strong>".__('-->FAILED: Info page fix failed', 'geodirectory')."</strong></li>";
 | |
| 1657 | 1657 | } | 
| 1658 | 1658 | } | 
| 1659 | 1659 | } | 
| @@ -1667,18 +1667,18 @@ discard block | ||
| 1667 | 1667 | ////////////////////////////////// | 
| 1668 | 1668 |      $option_value = get_option('geodir_login_page');
 | 
| 1669 | 1669 | $page = get_post($option_value); | 
| 1670 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1670 | +    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
 | |
| 1671 | 1671 | |
| 1672 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1673 | -        $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1672 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') | |
| 1673 | +        $output_str .= "<li>".__('Login page exists with proper setting.', 'geodirectory')."</li>";
 | |
| 1674 | 1674 |      else {
 | 
| 1675 | 1675 | $is_error_during_diagnose = true; | 
| 1676 | -        $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1676 | +        $output_str .= "<li><strong>".__('Login page is missing.', 'geodirectory')."</strong></li>";
 | |
| 1677 | 1677 |          if ($fix) {
 | 
| 1678 | 1678 |              if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
 | 
| 1679 | -                $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1679 | +                $output_str .= "<li><strong>".__('-->FIXED: Login page fixed', 'geodirectory')."</strong></li>";
 | |
| 1680 | 1680 |              } else {
 | 
| 1681 | -                $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1681 | +                $output_str .= "<li><strong>".__('-->FAILED: Login page fix failed', 'geodirectory')."</strong></li>";
 | |
| 1682 | 1682 | } | 
| 1683 | 1683 | } | 
| 1684 | 1684 | } | 
| @@ -1692,18 +1692,18 @@ discard block | ||
| 1692 | 1692 | ////////////////////////////////// | 
| 1693 | 1693 |      $option_value = get_option('geodir_location_page');
 | 
| 1694 | 1694 | $page = get_post($option_value); | 
| 1695 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1695 | +    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
 | |
| 1696 | 1696 | |
| 1697 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1698 | -        $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1697 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') | |
| 1698 | +        $output_str .= "<li>".__('Location page exists with proper setting.', 'geodirectory')."</li>";
 | |
| 1699 | 1699 |      else {
 | 
| 1700 | 1700 | $is_error_during_diagnose = true; | 
| 1701 | -        $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1701 | +        $output_str .= "<li><strong>".__('Location page is missing.', 'geodirectory')."</strong></li>";
 | |
| 1702 | 1702 |          if ($fix) {
 | 
| 1703 | 1703 |              if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
 | 
| 1704 | -                $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1704 | +                $output_str .= "<li><strong>".__('-->FIXED: Location page fixed', 'geodirectory')."</strong></li>";
 | |
| 1705 | 1705 |              } else {
 | 
| 1706 | -                $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1706 | +                $output_str .= "<li><strong>".__('-->FAILED: Location page fix failed', 'geodirectory')."</strong></li>";
 | |
| 1707 | 1707 | } | 
| 1708 | 1708 | } | 
| 1709 | 1709 | } | 
| @@ -1712,13 +1712,13 @@ discard block | ||
| 1712 | 1712 | /* Diagnose Location Page Ends */ | 
| 1713 | 1713 | //////////////////////////////// | 
| 1714 | 1714 | |
| 1715 | -    $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
 | |
| 1715 | +    $page_chk_arr = array('output_str'=>$output_str, 'is_error_during_diagnose'=>$is_error_during_diagnose);
 | |
| 1716 | 1716 | /** | 
| 1717 | 1717 | * This action is called at the end of the GD Tools page check function. | 
| 1718 | 1718 | * | 
| 1719 | 1719 | * @since 1.5.2 | 
| 1720 | 1720 | */ | 
| 1721 | -    $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
 | |
| 1721 | +    $page_chk_arr = apply_filters('geodir_diagnose_default_pages', $page_chk_arr);
 | |
| 1722 | 1722 | |
| 1723 | 1723 | $output_str = $page_chk_arr['output_str']; | 
| 1724 | 1724 | $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose']; | 
| @@ -1728,7 +1728,7 @@ discard block | ||
| 1728 | 1728 | flush_rewrite_rules(); | 
| 1729 | 1729 | } | 
| 1730 | 1730 | $info_div_class = "geodir_problem_info"; | 
| 1731 | -        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
 | |
| 1731 | +        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
 | |
| 1732 | 1732 |      } else {
 | 
| 1733 | 1733 | $info_div_class = "geodir_noproblem_info"; | 
| 1734 | 1734 | $fix_button_txt = ''; | 
| @@ -1756,10 +1756,10 @@ discard block | ||
| 1756 | 1756 | $fix_button_txt = ''; | 
| 1757 | 1757 | |
| 1758 | 1758 |      if ($is_error_during_diagnose) {
 | 
| 1759 | -        $output_str .= "<li>" . __('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory') . ' ' . geodir_plugin_path() . '/db-language.php' . "</li>";
 | |
| 1759 | +        $output_str .= "<li>".__('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory').' '.geodir_plugin_path().'/db-language.php'."</li>";
 | |
| 1760 | 1760 | $info_div_class = "geodir_problem_info"; | 
| 1761 | 1761 |      } else {
 | 
| 1762 | -        $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
 | |
| 1762 | +        $output_str .= "<li>".__('Load custom fields in to file for translation: ok', 'geodirectory')."</li>";
 | |
| 1763 | 1763 | $info_div_class = "geodir_noproblem_info"; | 
| 1764 | 1764 | $fix_button_txt = ''; | 
| 1765 | 1765 | } | 
| @@ -1801,17 +1801,17 @@ discard block | ||
| 1801 | 1801 | global $wpdb, $wp_query, $plugin_prefix; | 
| 1802 | 1802 | |
| 1803 | 1803 |      if (is_admin() && !empty($wp_query->query_vars) && !empty($wp_query->query_vars['is_geodir_loop']) && !empty($wp_query->query_vars['orderby']) && $wp_query->query_vars['orderby'] == 'expire' && !empty($wp_query->query_vars['post_type']) && in_array($wp_query->query_vars['post_type'], geodir_get_posttypes()) && !empty($wp_query->query_vars['orderby']) && isset($clauses['join']) && isset($clauses['orderby']) && isset($clauses['fields'])) {
 | 
| 1804 | - $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail'; | |
| 1804 | + $table = $plugin_prefix.$wp_query->query_vars['post_type'].'_detail'; | |
| 1805 | 1805 | |
| 1806 | - $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)'; | |
| 1806 | + $join = $clauses['join'].' INNER JOIN '.$table.' AS gd_posts ON (gd_posts.post_id = '.$wpdb->posts.'.ID)'; | |
| 1807 | 1807 | $clauses['join'] = $join; | 
| 1808 | 1808 | |
| 1809 | - $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : ''; | |
| 1809 | + $fields = $clauses['fields'] != '' ? $clauses['fields'].', ' : ''; | |
| 1810 | 1810 | $fields .= 'IF(UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), 253402300799) AS gd_expire'; | 
| 1811 | 1811 | $clauses['fields'] = $fields; | 
| 1812 | 1812 | |
| 1813 | 1813 | $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC'; | 
| 1814 | - $orderby = 'gd_expire ' . $order; | |
| 1814 | + $orderby = 'gd_expire '.$order; | |
| 1815 | 1815 | $clauses['orderby'] = $orderby; | 
| 1816 | 1816 | } | 
| 1817 | 1817 | return $clauses; | 
| @@ -1854,7 +1854,7 @@ discard block | ||
| 1854 | 1854 | global $current_user; | 
| 1855 | 1855 | $upload_dir = wp_upload_dir(); | 
| 1856 | 1856 | |
| 1857 | - $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv'; | |
| 1857 | + $file = $upload_dir['path'].'/temp_'.$current_user->data->ID.'/geodir_tmp.csv'; | |
| 1858 | 1858 | $handle = fopen($file, 'w'); | 
| 1859 | 1859 | |
| 1860 | 1860 | fwrite($handle, $input); | 
| @@ -1899,7 +1899,7 @@ discard block | ||
| 1899 | 1899 | $uploads_dir = $uploads['path']; | 
| 1900 | 1900 |      $image_name_arr = explode('/', $filename);
 | 
| 1901 | 1901 | $filename = end($image_name_arr); | 
| 1902 | - $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; | |
| 1902 | + $target_path = $uploads_dir.'/temp_'.$current_user->data->ID.'/'.$filename; | |
| 1903 | 1903 | $return = array(); | 
| 1904 | 1904 | $return['file'] = $uploadedFile; | 
| 1905 | 1905 |      $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
 | 
| @@ -1916,8 +1916,8 @@ discard block | ||
| 1916 | 1916 | |
| 1917 | 1917 |                  if (($handle = fopen($target_path, "r")) !== FALSE) {
 | 
| 1918 | 1918 |                      while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
 | 
| 1919 | -                        if(is_array($data) && !empty($data)) {
 | |
| 1920 | -                            $file[] = '"' . implode('","', $data) . '"';
 | |
| 1919 | +                        if (is_array($data) && !empty($data)) {
 | |
| 1920 | +                            $file[] = '"'.implode('","', $data).'"';
 | |
| 1921 | 1921 | } | 
| 1922 | 1922 | } | 
| 1923 | 1923 | fclose($handle); | 
| @@ -2034,10 +2034,10 @@ discard block | ||
| 2034 | 2034 |                      $tag_arr = explode(',', $post_tags);
 | 
| 2035 | 2035 | } | 
| 2036 | 2036 | |
| 2037 | - $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database | |
| 2037 | + $table = $plugin_prefix.$buffer[5].'_detail'; // check table in database | |
| 2038 | 2038 | |
| 2039 | 2039 | $error = ''; | 
| 2040 | -                if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
 | |
| 2040 | +                if ($wpdb->get_var("SHOW TABLES LIKE '".$table."'") != $table) {
 | |
| 2041 | 2041 | $invalid_post_type++; | 
| 2042 | 2042 | continue; | 
| 2043 | 2043 | } | 
| @@ -2063,7 +2063,7 @@ discard block | ||
| 2063 | 2063 |                              if ($buffer[$c] != '0' && $buffer[$c] != '') {
 | 
| 2064 | 2064 |                                  $submitdata = date('Y-m-d');
 | 
| 2065 | 2065 | |
| 2066 | -                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
 | |
| 2066 | +                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata."+".addslashes($buffer[$c])." days"));
 | |
| 2067 | 2067 |                              } else {
 | 
| 2068 | 2068 | $gd_post_info['expire_date'] = 'Never'; | 
| 2069 | 2069 | } | 
| @@ -2091,7 +2091,7 @@ discard block | ||
| 2091 | 2091 | |
| 2092 | 2092 | // Post status | 
| 2093 | 2093 |  						if ($customKeyarray[$c] == 'post_status') {
 | 
| 2094 | - $post_status = sanitize_key( $buffer[$c] ); | |
| 2094 | + $post_status = sanitize_key($buffer[$c]); | |
| 2095 | 2095 | } | 
| 2096 | 2096 | } | 
| 2097 | 2097 | |
| @@ -2109,8 +2109,8 @@ discard block | ||
| 2109 | 2109 | |
| 2110 | 2110 | // Default post status | 
| 2111 | 2111 | $default_status = 'publish'; | 
| 2112 | - $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; | |
| 2113 | - $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; | |
| 2112 | + $post_status = !empty($post_status) ? sanitize_key($post_status) : $default_status; | |
| 2113 | + $post_status = !empty($wp_post_statuses) && !isset($wp_post_statuses[$post_status]) ? $default_status : $post_status; | |
| 2114 | 2114 | |
| 2115 | 2115 | $my_post['post_title'] = $post_title; | 
| 2116 | 2116 | $my_post['post_content'] = $post_desc; | 
| @@ -2154,7 +2154,7 @@ discard block | ||
| 2154 | 2154 | $payment_info = array(); | 
| 2155 | 2155 | $package_info = array(); | 
| 2156 | 2156 | |
| 2157 | - $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]); | |
| 2157 | + $package_info = (array) geodir_post_package_info($package_info, '', $buffer[5]); | |
| 2158 | 2158 | $package_id = ''; | 
| 2159 | 2159 |                      if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
 | 
| 2160 | 2160 | $package_id = $gd_post_info['package_id']; | 
| @@ -2164,7 +2164,7 @@ discard block | ||
| 2164 | 2164 | $payment_info['package_id'] = $package_info['pid']; | 
| 2165 | 2165 | |
| 2166 | 2166 |                          if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
 | 
| 2167 | -                            $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
 | |
| 2167 | +                            $payment_info['expire_date'] = date('Y-m-d', strtotime("+".$package_info['alive_days']." days"));
 | |
| 2168 | 2168 |                          } else {
 | 
| 2169 | 2169 | $payment_info['expire_date'] = 'Never'; | 
| 2170 | 2170 | } | 
| @@ -2176,7 +2176,7 @@ discard block | ||
| 2176 | 2176 | |
| 2177 | 2177 | $post_type = get_post_type($last_postid); | 
| 2178 | 2178 | |
| 2179 | - $table = $plugin_prefix . $post_type . '_detail'; | |
| 2179 | + $table = $plugin_prefix.$post_type.'_detail'; | |
| 2180 | 2180 | |
| 2181 | 2181 | geodir_save_post_info($last_postid, $gd_post_info); | 
| 2182 | 2182 | |
| @@ -2197,7 +2197,7 @@ discard block | ||
| 2197 | 2197 | $attachment['post_id'] = $last_postid; | 
| 2198 | 2198 | $attachment['title'] = $img_name_arr[0]; | 
| 2199 | 2199 | $attachment['content'] = ''; | 
| 2200 | - $attachment['file'] = $sub_dir . '/' . $image_name; | |
| 2200 | + $attachment['file'] = $sub_dir.'/'.$image_name; | |
| 2201 | 2201 | $attachment['mime_type'] = $uploaded_file_type; | 
| 2202 | 2202 | $attachment['menu_order'] = $menu_order; | 
| 2203 | 2203 | $attachment['is_featured'] = 0; | 
| @@ -2206,15 +2206,15 @@ discard block | ||
| 2206 | 2206 | |
| 2207 | 2207 |                              foreach ($attachment as $key => $val) {
 | 
| 2208 | 2208 | if ($val != '') | 
| 2209 | - $attachment_set .= $key . " = '" . $val . "', "; | |
| 2209 | + $attachment_set .= $key." = '".$val."', "; | |
| 2210 | 2210 | } | 
| 2211 | 2211 | $attachment_set = trim($attachment_set, ", "); | 
| 2212 | 2212 | |
| 2213 | -                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
 | |
| 2213 | +                            $wpdb->query("INSERT INTO ".GEODIR_ATTACHMENT_TABLE." SET ".$attachment_set);
 | |
| 2214 | 2214 | |
| 2215 | 2215 |                              if ($menu_order == 1) {
 | 
| 2216 | 2216 | $post_type = get_post_type($last_postid); | 
| 2217 | -                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
 | |
| 2217 | +                                $wpdb->query($wpdb->prepare("UPDATE ".$table." SET featured_image = %s where post_id =%d", array($sub_dir.'/'.$image_name, $last_postid)));
 | |
| 2218 | 2218 | } | 
| 2219 | 2219 | $menu_order++; | 
| 2220 | 2220 | } | 
| @@ -2255,11 +2255,11 @@ discard block | ||
| 2255 | 2255 | } | 
| 2256 | 2256 | |
| 2257 | 2257 | // Add the tab in left sidebar menu fro import & export page. | 
| 2258 | -add_filter( 'geodir_settings_tabs_array', 'geodir_import_export_tab', 94 ); | |
| 2258 | +add_filter('geodir_settings_tabs_array', 'geodir_import_export_tab', 94);
 | |
| 2259 | 2259 | |
| 2260 | 2260 | // Handle ajax request for import/export. | 
| 2261 | -add_action( 'wp_ajax_geodir_import_export', 'geodir_ajax_import_export' ); | |
| 2262 | -add_action( 'wp_ajax_nopriv_geodir_import_exportn', 'geodir_ajax_import_export' ); | |
| 2261 | +add_action('wp_ajax_geodir_import_export', 'geodir_ajax_import_export');
 | |
| 2262 | +add_action('wp_ajax_nopriv_geodir_import_exportn', 'geodir_ajax_import_export');
 | |
| 2263 | 2263 | |
| 2264 | 2264 | |
| 2265 | 2265 | /** | 
| @@ -2270,40 +2270,40 @@ discard block | ||
| 2270 | 2270 | * @param $post_id int $post_id The post ID of the post being saved. | 
| 2271 | 2271 | * @param $post object $post The post object of the post being saved. | 
| 2272 | 2272 | */ | 
| 2273 | -function geodir_update_location_prefix($post_id,$post){
 | |
| 2274 | -    if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
 | |
| 2275 | -        update_option('geodir_location_prefix',$post->post_name);
 | |
| 2273 | +function geodir_update_location_prefix($post_id, $post) {
 | |
| 2274 | +    if ($post->post_type == 'page' && $post->post_name && $post_id == get_option('geodir_location_page')) {
 | |
| 2275 | +        update_option('geodir_location_prefix', $post->post_name);
 | |
| 2276 | 2276 | } | 
| 2277 | 2277 | |
| 2278 | 2278 | } | 
| 2279 | 2279 | |
| 2280 | -add_action('save_post', 'geodir_update_location_prefix',10,2);
 | |
| 2280 | +add_action('save_post', 'geodir_update_location_prefix', 10, 2);
 | |
| 2281 | 2281 | |
| 2282 | -add_action( 'wp_ajax_geodir_ga_callback', 'geodir_ga_callback' ); | |
| 2282 | +add_action('wp_ajax_geodir_ga_callback', 'geodir_ga_callback');
 | |
| 2283 | 2283 | |
| 2284 | -function geodir_ga_callback(){
 | |
| 2284 | +function geodir_ga_callback() {
 | |
| 2285 | 2285 | |
| 2286 | -if(isset($_REQUEST['code']) && $_REQUEST['code']) {
 | |
| 2286 | +if (isset($_REQUEST['code']) && $_REQUEST['code']) {
 | |
| 2287 | 2287 | $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?"; | 
| 2288 | 2288 | $code = "code=".$_REQUEST['code']; | 
| 2289 | 2289 | $grant_type = "&grant_type=authorization_code"; | 
| 2290 | -    $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
 | |
| 2290 | +    $redirect_uri = "&redirect_uri=".admin_url('admin-ajax.php')."?action=geodir_ga_callback";
 | |
| 2291 | 2291 |      $client_id = "&client_id=".get_option('geodir_ga_client_id');
 | 
| 2292 | 2292 |      $client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
 | 
| 2293 | 2293 | |
| 2294 | - $auth_url = $oAuthURL . $code . $redirect_uri . $grant_type . $client_id .$client_secret; | |
| 2294 | + $auth_url = $oAuthURL.$code.$redirect_uri.$grant_type.$client_id.$client_secret; | |
| 2295 | 2295 | |
| 2296 | 2296 |      $response = wp_remote_post($auth_url, array('timeout' => 15));
 | 
| 2297 | 2297 | |
| 2298 | 2298 | //print_r($response); | 
| 2299 | 2299 | |
| 2300 | -    $error_msg =  __('Something went wrong','geodirectory');
 | |
| 2301 | -    if(!empty($response['response']['code']) && $response['response']['code']==200){
 | |
| 2300 | +    $error_msg = __('Something went wrong', 'geodirectory');
 | |
| 2301 | +    if (!empty($response['response']['code']) && $response['response']['code'] == 200) {
 | |
| 2302 | 2302 | |
| 2303 | 2303 | $parts = json_decode($response['body']); | 
| 2304 | 2304 | //print_r($parts); | 
| 2305 | -        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
 | |
| 2306 | -        else{
 | |
| 2305 | +        if (!isset($parts->access_token)) {echo $error_msg." - #1"; exit; }
 | |
| 2306 | +        else {
 | |
| 2307 | 2307 | |
| 2308 | 2308 |              update_option('gd_ga_access_token', $parts->access_token);
 | 
| 2309 | 2309 |              update_option('gd_ga_refresh_token', $parts->refresh_token);
 | 
| @@ -2312,25 +2312,25 @@ discard block | ||
| 2312 | 2312 | |
| 2313 | 2313 | |
| 2314 | 2314 | } | 
| 2315 | -    elseif(!empty($response['response']['code'])) {
 | |
| 2315 | +    elseif (!empty($response['response']['code'])) {
 | |
| 2316 | 2316 | $parts = json_decode($response['body']); | 
| 2317 | 2317 | |
| 2318 | -        if(isset($parts->error)){
 | |
| 2319 | - echo $parts->error.": ".$parts->error_description;exit; | |
| 2320 | -        }else{
 | |
| 2321 | - echo $error_msg." - #2";exit; | |
| 2318 | +        if (isset($parts->error)) {
 | |
| 2319 | + echo $parts->error.": ".$parts->error_description; exit; | |
| 2320 | +        } else {
 | |
| 2321 | + echo $error_msg." - #2"; exit; | |
| 2322 | 2322 | } | 
| 2323 | 2323 | |
| 2324 | -    }else{
 | |
| 2324 | +    } else {
 | |
| 2325 | 2325 | |
| 2326 | - echo $error_msg." - #3";exit; | |
| 2326 | + echo $error_msg." - #3"; exit; | |
| 2327 | 2327 | |
| 2328 | 2328 | } | 
| 2329 | 2329 | } | 
| 2330 | 2330 | exit; | 
| 2331 | 2331 | } | 
| 2332 | 2332 | |
| 2333 | -add_filter( 'icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4 ); | |
| 2333 | +add_filter('icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4);
 | |
| 2334 | 2334 | |
| 2335 | 2335 |  if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
 | 
| 2336 | 2336 |  	add_action('geodir_before_admin_panel', 'geodir_wpml_permalink_setting_notice');
 |