@@ -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 | |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | if (!empty($_SERVER['PHP_SELF']) && !empty($_SERVER['REQUEST_URI'])) {
|
| 209 | 209 | // To build the entire URI we need to prepend the protocol, and the http host |
| 210 | 210 | // to the URI string. |
| 211 | - $pageURL .= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
| 211 | + $pageURL .= $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; |
|
| 212 | 212 | } else {
|
| 213 | 213 | /* |
| 214 | 214 | * Since we do not have REQUEST_URI to work with, we will assume we are |
@@ -217,11 +217,11 @@ discard block |
||
| 217 | 217 | * |
| 218 | 218 | * IIS uses the SCRIPT_NAME variable instead of a REQUEST_URI variable... thanks, MS |
| 219 | 219 | */ |
| 220 | - $pageURL .= $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; |
|
| 220 | + $pageURL .= $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; |
|
| 221 | 221 | |
| 222 | 222 | // If the query string exists append it to the URI string |
| 223 | 223 | if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
|
| 224 | - $pageURL .= '?' . $_SERVER['QUERY_STRING']; |
|
| 224 | + $pageURL .= '?'.$_SERVER['QUERY_STRING']; |
|
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | * |
| 233 | 233 | * @param string $pageURL The URL of the current page. |
| 234 | 234 | */ |
| 235 | - return apply_filters( 'geodir_curPageURL', $pageURL ); |
|
| 235 | + return apply_filters('geodir_curPageURL', $pageURL);
|
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | /** |
@@ -247,12 +247,12 @@ discard block |
||
| 247 | 247 | * |
| 248 | 248 | * @return string Cleaned variable. |
| 249 | 249 | */ |
| 250 | -function geodir_clean( $string ) {
|
|
| 250 | +function geodir_clean($string) {
|
|
| 251 | 251 | |
| 252 | - $string = trim( strip_tags( stripslashes( $string ) ) ); |
|
| 253 | - $string = str_replace( " ", "-", $string ); // Replaces all spaces with hyphens. |
|
| 254 | - $string = preg_replace( '/[^A-Za-z0-9\-\_]/', '', $string ); // Removes special chars. |
|
| 255 | - $string = preg_replace( '/-+/', '-', $string ); // Replaces multiple hyphens with single one. |
|
| 252 | + $string = trim(strip_tags(stripslashes($string))); |
|
| 253 | + $string = str_replace(" ", "-", $string); // Replaces all spaces with hyphens.
|
|
| 254 | + $string = preg_replace('/[^A-Za-z0-9\-\_]/', '', $string); // Removes special chars.
|
|
| 255 | + $string = preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one.
|
|
| 256 | 256 | |
| 257 | 257 | return $string; |
| 258 | 258 | } |
@@ -266,13 +266,13 @@ discard block |
||
| 266 | 266 | */ |
| 267 | 267 | function geodir_get_weekday() {
|
| 268 | 268 | return array( |
| 269 | - __( 'Sunday', 'geodirectory' ), |
|
| 270 | - __( 'Monday', 'geodirectory' ), |
|
| 271 | - __( 'Tuesday', 'geodirectory' ), |
|
| 272 | - __( 'Wednesday', 'geodirectory' ), |
|
| 273 | - __( 'Thursday', 'geodirectory' ), |
|
| 274 | - __( 'Friday', 'geodirectory' ), |
|
| 275 | - __( 'Saturday', 'geodirectory' ) |
|
| 269 | + __('Sunday', 'geodirectory'),
|
|
| 270 | + __('Monday', 'geodirectory'),
|
|
| 271 | + __('Tuesday', 'geodirectory'),
|
|
| 272 | + __('Wednesday', 'geodirectory'),
|
|
| 273 | + __('Thursday', 'geodirectory'),
|
|
| 274 | + __('Friday', 'geodirectory'),
|
|
| 275 | + __('Saturday', 'geodirectory')
|
|
| 276 | 276 | ); |
| 277 | 277 | } |
| 278 | 278 | |
@@ -285,11 +285,11 @@ discard block |
||
| 285 | 285 | */ |
| 286 | 286 | function geodir_get_weeks() {
|
| 287 | 287 | return array( |
| 288 | - __( 'First', 'geodirectory' ), |
|
| 289 | - __( 'Second', 'geodirectory' ), |
|
| 290 | - __( 'Third', 'geodirectory' ), |
|
| 291 | - __( 'Fourth', 'geodirectory' ), |
|
| 292 | - __( 'Last', 'geodirectory' ) |
|
| 288 | + __('First', 'geodirectory'),
|
|
| 289 | + __('Second', 'geodirectory'),
|
|
| 290 | + __('Third', 'geodirectory'),
|
|
| 291 | + __('Fourth', 'geodirectory'),
|
|
| 292 | + __('Last', 'geodirectory')
|
|
| 293 | 293 | ); |
| 294 | 294 | } |
| 295 | 295 | |
@@ -308,112 +308,112 @@ discard block |
||
| 308 | 308 | * |
| 309 | 309 | * @return bool If valid returns true. Otherwise false. |
| 310 | 310 | */ |
| 311 | -function geodir_is_page( $gdpage = '' ) {
|
|
| 311 | +function geodir_is_page($gdpage = '') {
|
|
| 312 | 312 | |
| 313 | 313 | global $wp_query, $post, $wp; |
| 314 | 314 | //if(!is_admin()): |
| 315 | 315 | |
| 316 | - switch ( $gdpage ): |
|
| 316 | + switch ($gdpage): |
|
| 317 | 317 | case 'add-listing': |
| 318 | 318 | |
| 319 | - if ( is_page() && get_query_var( 'page_id' ) == geodir_add_listing_page_id() ) {
|
|
| 319 | + if (is_page() && get_query_var('page_id') == geodir_add_listing_page_id()) {
|
|
| 320 | 320 | return true; |
| 321 | - } elseif ( is_page() && isset( $post->post_content ) && has_shortcode( $post->post_content, 'gd_add_listing' ) ) {
|
|
| 321 | + } elseif (is_page() && isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
|
|
| 322 | 322 | return true; |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | break; |
| 326 | 326 | case 'preview': |
| 327 | - if ( ( is_page() && get_query_var( 'page_id' ) == geodir_preview_page_id() ) && isset( $_REQUEST['listing_type'] ) |
|
| 328 | - && in_array( $_REQUEST['listing_type'], geodir_get_posttypes() ) |
|
| 327 | + if ((is_page() && get_query_var('page_id') == geodir_preview_page_id()) && isset($_REQUEST['listing_type'])
|
|
| 328 | + && in_array($_REQUEST['listing_type'], geodir_get_posttypes()) |
|
| 329 | 329 | ) {
|
| 330 | 330 | return true; |
| 331 | 331 | } |
| 332 | 332 | break; |
| 333 | 333 | case 'listing-success': |
| 334 | - if ( is_page() && get_query_var( 'page_id' ) == geodir_success_page_id() ) {
|
|
| 334 | + if (is_page() && get_query_var('page_id') == geodir_success_page_id()) {
|
|
| 335 | 335 | return true; |
| 336 | 336 | } |
| 337 | 337 | break; |
| 338 | 338 | case 'detail': |
| 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_single() && in_array( $post_type, geodir_get_posttypes() ) ) {
|
|
| 343 | + if (is_single() && in_array($post_type, geodir_get_posttypes())) {
|
|
| 344 | 344 | return true; |
| 345 | 345 | } |
| 346 | 346 | break; |
| 347 | 347 | case 'pt': |
| 348 | - $post_type = get_query_var( 'post_type' ); |
|
| 349 | - if ( is_array( $post_type ) ) {
|
|
| 350 | - $post_type = reset( $post_type ); |
|
| 348 | + $post_type = get_query_var('post_type');
|
|
| 349 | + if (is_array($post_type)) {
|
|
| 350 | + $post_type = reset($post_type); |
|
| 351 | 351 | } |
| 352 | - if ( is_post_type_archive() && in_array( $post_type, geodir_get_posttypes() ) && ! is_tax() ) {
|
|
| 352 | + if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes()) && !is_tax()) {
|
|
| 353 | 353 | return true; |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | break; |
| 357 | 357 | case 'listing': |
| 358 | - if ( is_tax() && geodir_get_taxonomy_posttype() ) {
|
|
| 358 | + if (is_tax() && geodir_get_taxonomy_posttype()) {
|
|
| 359 | 359 | global $current_term, $taxonomy, $term; |
| 360 | 360 | |
| 361 | 361 | return true; |
| 362 | 362 | } |
| 363 | - $post_type = get_query_var( 'post_type' ); |
|
| 364 | - if ( is_array( $post_type ) ) {
|
|
| 365 | - $post_type = reset( $post_type ); |
|
| 363 | + $post_type = get_query_var('post_type');
|
|
| 364 | + if (is_array($post_type)) {
|
|
| 365 | + $post_type = reset($post_type); |
|
| 366 | 366 | } |
| 367 | - if ( is_post_type_archive() && in_array( $post_type, geodir_get_posttypes() ) ) {
|
|
| 367 | + if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes())) {
|
|
| 368 | 368 | return true; |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | break; |
| 372 | 372 | case 'home': |
| 373 | 373 | |
| 374 | - if ( ( is_page() && get_query_var( 'page_id' ) == geodir_home_page_id() ) || is_page_geodir_home() ) {
|
|
| 374 | + if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home()) {
|
|
| 375 | 375 | return true; |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | break; |
| 379 | 379 | case 'location': |
| 380 | - if ( is_page() && get_query_var( 'page_id' ) == geodir_location_page_id() ) {
|
|
| 380 | + if (is_page() && get_query_var('page_id') == geodir_location_page_id()) {
|
|
| 381 | 381 | return true; |
| 382 | 382 | } |
| 383 | 383 | break; |
| 384 | 384 | case 'author': |
| 385 | - if ( is_author() && isset( $_REQUEST['geodir_dashbord'] ) ) {
|
|
| 385 | + if (is_author() && isset($_REQUEST['geodir_dashbord'])) {
|
|
| 386 | 386 | return true; |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - if ( function_exists( 'bp_loggedin_user_id' ) && function_exists( 'bp_displayed_user_id' ) && $my_id = (int) bp_loggedin_user_id() ) {
|
|
| 390 | - if ( ( (bool) bp_is_current_component( 'listings' ) || (bool) bp_is_current_component( 'favorites' ) ) && $my_id > 0 && $my_id == (int) bp_displayed_user_id() ) {
|
|
| 389 | + if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int) bp_loggedin_user_id()) {
|
|
| 390 | + if (((bool) bp_is_current_component('listings') || (bool) bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int) bp_displayed_user_id()) {
|
|
| 391 | 391 | return true; |
| 392 | 392 | } |
| 393 | 393 | } |
| 394 | 394 | break; |
| 395 | 395 | case 'search': |
| 396 | - if ( is_search() && isset( $_REQUEST['geodir_search'] ) ) {
|
|
| 396 | + if (is_search() && isset($_REQUEST['geodir_search'])) {
|
|
| 397 | 397 | return true; |
| 398 | 398 | } |
| 399 | 399 | break; |
| 400 | 400 | case 'info': |
| 401 | - if ( is_page() && get_query_var( 'page_id' ) == geodir_info_page_id() ) {
|
|
| 401 | + if (is_page() && get_query_var('page_id') == geodir_info_page_id()) {
|
|
| 402 | 402 | return true; |
| 403 | 403 | } |
| 404 | 404 | break; |
| 405 | 405 | case 'login': |
| 406 | - if ( is_page() && get_query_var( 'page_id' ) == geodir_login_page_id() ) {
|
|
| 406 | + if (is_page() && get_query_var('page_id') == geodir_login_page_id()) {
|
|
| 407 | 407 | return true; |
| 408 | 408 | } |
| 409 | 409 | break; |
| 410 | 410 | case 'checkout': |
| 411 | - if ( is_page() && function_exists( 'geodir_payment_checkout_page_id' ) && get_query_var( 'page_id' ) == geodir_payment_checkout_page_id() ) {
|
|
| 411 | + if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id()) {
|
|
| 412 | 412 | return true; |
| 413 | 413 | } |
| 414 | 414 | break; |
| 415 | 415 | case 'invoices': |
| 416 | - if ( is_page() && function_exists( 'geodir_payment_invoices_page_id' ) && get_query_var( 'page_id' ) == geodir_payment_invoices_page_id() ) {
|
|
| 416 | + if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id()) {
|
|
| 417 | 417 | return true; |
| 418 | 418 | } |
| 419 | 419 | break; |
@@ -438,25 +438,25 @@ discard block |
||
| 438 | 438 | * |
| 439 | 439 | * @param object $wp WordPress object. |
| 440 | 440 | */ |
| 441 | -function geodir_set_is_geodir_page( $wp ) {
|
|
| 442 | - if ( ! is_admin() ) {
|
|
| 441 | +function geodir_set_is_geodir_page($wp) {
|
|
| 442 | + if (!is_admin()) {
|
|
| 443 | 443 | //$wp->query_vars['gd_is_geodir_page'] = false; |
| 444 | 444 | //print_r() |
| 445 | - if ( empty( $wp->query_vars ) || ! array_diff( array_keys( $wp->query_vars ), array( |
|
| 445 | + if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array( |
|
| 446 | 446 | 'preview', |
| 447 | 447 | 'page', |
| 448 | 448 | 'paged', |
| 449 | 449 | 'cpage' |
| 450 | - ) ) |
|
| 450 | + )) |
|
| 451 | 451 | ) {
|
| 452 | - if ( geodir_is_page( 'home' ) ) {
|
|
| 452 | + if (geodir_is_page('home')) {
|
|
| 453 | 453 | $wp->query_vars['gd_is_geodir_page'] = true; |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | - if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) && isset( $wp->query_vars['page_id'] ) ) {
|
|
| 459 | + if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['page_id'])) {
|
|
| 460 | 460 | if ( |
| 461 | 461 | $wp->query_vars['page_id'] == geodir_add_listing_page_id() |
| 462 | 462 | || $wp->query_vars['page_id'] == geodir_preview_page_id() |
@@ -465,26 +465,26 @@ discard block |
||
| 465 | 465 | || $wp->query_vars['page_id'] == geodir_home_page_id() |
| 466 | 466 | || $wp->query_vars['page_id'] == geodir_info_page_id() |
| 467 | 467 | || $wp->query_vars['page_id'] == geodir_login_page_id() |
| 468 | - || ( function_exists( 'geodir_payment_checkout_page_id' ) && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id() ) |
|
| 469 | - || ( function_exists( 'geodir_payment_invoices_page_id' ) && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id() ) |
|
| 468 | + || (function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
|
|
| 469 | + || (function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
|
|
| 470 | 470 | ) {
|
| 471 | 471 | $wp->query_vars['gd_is_geodir_page'] = true; |
| 472 | 472 | } |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | - if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) && isset( $wp->query_vars['pagename'] ) ) {
|
|
| 476 | - $page = get_page_by_path( $wp->query_vars['pagename'] ); |
|
| 475 | + if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['pagename'])) {
|
|
| 476 | + $page = get_page_by_path($wp->query_vars['pagename']); |
|
| 477 | 477 | |
| 478 | - if ( ! empty( $page ) && ( |
|
| 478 | + if (!empty($page) && ( |
|
| 479 | 479 | $page->ID == geodir_add_listing_page_id() |
| 480 | 480 | || $page->ID == geodir_preview_page_id() |
| 481 | 481 | || $page->ID == geodir_success_page_id() |
| 482 | 482 | || $page->ID == geodir_location_page_id() |
| 483 | - || ( isset( $wp->query_vars['page_id'] ) && $wp->query_vars['page_id'] == geodir_home_page_id() ) |
|
| 484 | - || ( isset( $wp->query_vars['page_id'] ) && $wp->query_vars['page_id'] == geodir_info_page_id() ) |
|
| 485 | - || ( isset( $wp->query_vars['page_id'] ) && $wp->query_vars['page_id'] == geodir_login_page_id() ) |
|
| 486 | - || ( isset( $wp->query_vars['page_id'] ) && function_exists( 'geodir_payment_checkout_page_id' ) && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id() ) |
|
| 487 | - || ( isset( $wp->query_vars['page_id'] ) && function_exists( 'geodir_payment_invoices_page_id' ) && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id() ) |
|
| 483 | + || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_home_page_id()) |
|
| 484 | + || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_info_page_id()) |
|
| 485 | + || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_login_page_id()) |
|
| 486 | + || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
|
|
| 487 | + || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
|
|
| 488 | 488 | ) |
| 489 | 489 | ) {
|
| 490 | 490 | $wp->query_vars['gd_is_geodir_page'] = true; |
@@ -492,20 +492,20 @@ discard block |
||
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | |
| 495 | - if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) && isset( $wp->query_vars['post_type'] ) && $wp->query_vars['post_type'] != '' ) {
|
|
| 495 | + if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
|
|
| 496 | 496 | $requested_post_type = $wp->query_vars['post_type']; |
| 497 | 497 | // check if this post type is geodirectory post types |
| 498 | 498 | $post_type_array = geodir_get_posttypes(); |
| 499 | - if ( in_array( $requested_post_type, $post_type_array ) ) {
|
|
| 499 | + if (in_array($requested_post_type, $post_type_array)) {
|
|
| 500 | 500 | $wp->query_vars['gd_is_geodir_page'] = true; |
| 501 | 501 | } |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | - if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) ) {
|
|
| 505 | - $geodir_taxonomis = geodir_get_taxonomies( '', true ); |
|
| 506 | - if ( ! empty( $geodir_taxonomis ) ) {
|
|
| 507 | - foreach ( $geodir_taxonomis as $taxonomy ) {
|
|
| 508 | - if ( array_key_exists( $taxonomy, $wp->query_vars ) ) {
|
|
| 504 | + if (!isset($wp->query_vars['gd_is_geodir_page'])) {
|
|
| 505 | + $geodir_taxonomis = geodir_get_taxonomies('', true);
|
|
| 506 | + if (!empty($geodir_taxonomis)) {
|
|
| 507 | + foreach ($geodir_taxonomis as $taxonomy) {
|
|
| 508 | + if (array_key_exists($taxonomy, $wp->query_vars)) {
|
|
| 509 | 509 | $wp->query_vars['gd_is_geodir_page'] = true; |
| 510 | 510 | break; |
| 511 | 511 | } |
@@ -514,20 +514,20 @@ discard block |
||
| 514 | 514 | |
| 515 | 515 | } |
| 516 | 516 | |
| 517 | - if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) && isset( $wp->query_vars['author_name'] ) && isset( $_REQUEST['geodir_dashbord'] ) ) {
|
|
| 517 | + if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord'])) {
|
|
| 518 | 518 | $wp->query_vars['gd_is_geodir_page'] = true; |
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | |
| 522 | - if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) && isset( $_REQUEST['geodir_search'] ) ) {
|
|
| 522 | + if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search'])) {
|
|
| 523 | 523 | $wp->query_vars['gd_is_geodir_page'] = true; |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | |
| 527 | 527 | //check if homepage |
| 528 | - if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) |
|
| 529 | - && ! isset( $wp->query_vars['page_id'] ) |
|
| 530 | - && ! isset( $wp->query_vars['pagename'] ) |
|
| 528 | + if (!isset($wp->query_vars['gd_is_geodir_page']) |
|
| 529 | + && !isset($wp->query_vars['page_id']) |
|
| 530 | + && !isset($wp->query_vars['pagename']) |
|
| 531 | 531 | && is_page_geodir_home() |
| 532 | 532 | ) {
|
| 533 | 533 | $wp->query_vars['gd_is_geodir_page'] = true; |
@@ -551,14 +551,14 @@ discard block |
||
| 551 | 551 | */ |
| 552 | 552 | function geodir_is_geodir_page() {
|
| 553 | 553 | global $wp; |
| 554 | - if ( isset( $wp->query_vars['gd_is_geodir_page'] ) && $wp->query_vars['gd_is_geodir_page'] ) {
|
|
| 554 | + if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page']) {
|
|
| 555 | 555 | return true; |
| 556 | 556 | } else {
|
| 557 | 557 | return false; |
| 558 | 558 | } |
| 559 | 559 | } |
| 560 | 560 | |
| 561 | -if ( ! function_exists( 'geodir_get_imagesize' ) ) {
|
|
| 561 | +if (!function_exists('geodir_get_imagesize')) {
|
|
| 562 | 562 | /** |
| 563 | 563 | * Get image size using the size key . |
| 564 | 564 | * |
@@ -569,13 +569,13 @@ discard block |
||
| 569 | 569 | * |
| 570 | 570 | * @return array|mixed|void|WP_Error If valid returns image size. Else returns error. |
| 571 | 571 | */ |
| 572 | - function geodir_get_imagesize( $size = '' ) {
|
|
| 572 | + function geodir_get_imagesize($size = '') {
|
|
| 573 | 573 | |
| 574 | 574 | $imagesizes = array( |
| 575 | - 'list-thumb' => array( 'w' => 283, 'h' => 188 ), |
|
| 576 | - 'thumbnail' => array( 'w' => 125, 'h' => 125 ), |
|
| 577 | - 'widget-thumb' => array( 'w' => 50, 'h' => 50 ), |
|
| 578 | - 'slider-thumb' => array( 'w' => 100, 'h' => 100 ) |
|
| 575 | + 'list-thumb' => array('w' => 283, 'h' => 188),
|
|
| 576 | + 'thumbnail' => array('w' => 125, 'h' => 125),
|
|
| 577 | + 'widget-thumb' => array('w' => 50, 'h' => 50),
|
|
| 578 | + 'slider-thumb' => array('w' => 100, 'h' => 100)
|
|
| 579 | 579 | ); |
| 580 | 580 | |
| 581 | 581 | /** |
@@ -585,9 +585,9 @@ discard block |
||
| 585 | 585 | * |
| 586 | 586 | * @param array $imagesizes Image size array. |
| 587 | 587 | */ |
| 588 | - $imagesizes = apply_filters( 'geodir_imagesizes', $imagesizes ); |
|
| 588 | + $imagesizes = apply_filters('geodir_imagesizes', $imagesizes);
|
|
| 589 | 589 | |
| 590 | - if ( ! empty( $size ) && array_key_exists( $size, $imagesizes ) ) {
|
|
| 590 | + if (!empty($size) && array_key_exists($size, $imagesizes)) {
|
|
| 591 | 591 | /** |
| 592 | 592 | * Filters image size of the passed key. |
| 593 | 593 | * |
@@ -595,11 +595,11 @@ discard block |
||
| 595 | 595 | * |
| 596 | 596 | * @param array $imagesizes [$size] Image size array of the passed key. |
| 597 | 597 | */ |
| 598 | - return apply_filters( 'geodir_get_imagesize_' . $size, $imagesizes[ $size ] ); |
|
| 598 | + return apply_filters('geodir_get_imagesize_'.$size, $imagesizes[$size]);
|
|
| 599 | 599 | |
| 600 | - } elseif ( ! empty( $size ) ) {
|
|
| 600 | + } elseif (!empty($size)) {
|
|
| 601 | 601 | |
| 602 | - return new WP_Error( 'geodir_no_imagesize', __( "Given image size is not valid", 'geodirectory' ) ); |
|
| 602 | + return new WP_Error('geodir_no_imagesize', __("Given image size is not valid", 'geodirectory'));
|
|
| 603 | 603 | |
| 604 | 604 | } |
| 605 | 605 | |
@@ -623,7 +623,7 @@ discard block |
||
| 623 | 623 | */ |
| 624 | 624 | |
| 625 | 625 | |
| 626 | -if ( ! function_exists( 'createRandomString' ) ) {
|
|
| 626 | +if (!function_exists('createRandomString')) {
|
|
| 627 | 627 | /** |
| 628 | 628 | * Creates random string. |
| 629 | 629 | * |
@@ -633,21 +633,21 @@ discard block |
||
| 633 | 633 | */ |
| 634 | 634 | function createRandomString() {
|
| 635 | 635 | $chars = "abcdefghijkmlnopqrstuvwxyz1023456789"; |
| 636 | - srand( (double) microtime() * 1000000 ); |
|
| 636 | + srand((double) microtime() * 1000000); |
|
| 637 | 637 | $i = 0; |
| 638 | 638 | $rstring = ''; |
| 639 | - while ( $i <= 25 ) {
|
|
| 639 | + while ($i <= 25) {
|
|
| 640 | 640 | $num = rand() % 33; |
| 641 | - $tmp = substr( $chars, $num, 1 ); |
|
| 642 | - $rstring = $rstring . $tmp; |
|
| 643 | - $i ++; |
|
| 641 | + $tmp = substr($chars, $num, 1); |
|
| 642 | + $rstring = $rstring.$tmp; |
|
| 643 | + $i++; |
|
| 644 | 644 | } |
| 645 | 645 | |
| 646 | 646 | return $rstring; |
| 647 | 647 | } |
| 648 | 648 | } |
| 649 | 649 | |
| 650 | -if ( ! function_exists( 'geodir_getDistanceRadius' ) ) {
|
|
| 650 | +if (!function_exists('geodir_getDistanceRadius')) {
|
|
| 651 | 651 | /** |
| 652 | 652 | * Calculates the distance radius. |
| 653 | 653 | * |
@@ -658,9 +658,9 @@ discard block |
||
| 658 | 658 | * |
| 659 | 659 | * @return float The mean radius. |
| 660 | 660 | */ |
| 661 | - function geodir_getDistanceRadius( $uom = 'km' ) {
|
|
| 661 | + function geodir_getDistanceRadius($uom = 'km') {
|
|
| 662 | 662 | // Use Haversine formula to calculate the great circle distance between two points identified by longitude and latitude |
| 663 | - switch ( geodir_strtolower( $uom ) ): |
|
| 663 | + switch (geodir_strtolower($uom)): |
|
| 664 | 664 | case 'km' : |
| 665 | 665 | $earthMeanRadius = 6371.009; // km |
| 666 | 666 | break; |
@@ -692,7 +692,7 @@ discard block |
||
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | |
| 695 | -if ( ! function_exists( 'geodir_calculateDistanceFromLatLong' ) ) {
|
|
| 695 | +if (!function_exists('geodir_calculateDistanceFromLatLong')) {
|
|
| 696 | 696 | /** |
| 697 | 697 | * Calculate the great circle distance between two points identified by longitude and latitude. |
| 698 | 698 | * |
@@ -705,17 +705,17 @@ discard block |
||
| 705 | 705 | * |
| 706 | 706 | * @return float The distance. |
| 707 | 707 | */ |
| 708 | - function geodir_calculateDistanceFromLatLong( $point1, $point2, $uom = 'km' ) {
|
|
| 708 | + function geodir_calculateDistanceFromLatLong($point1, $point2, $uom = 'km') {
|
|
| 709 | 709 | // Use Haversine formula to calculate the great circle distance between two points identified by longitude and latitude |
| 710 | 710 | |
| 711 | - $earthMeanRadius = geodir_getDistanceRadius( $uom ); |
|
| 711 | + $earthMeanRadius = geodir_getDistanceRadius($uom); |
|
| 712 | 712 | |
| 713 | - $deltaLatitude = deg2rad( (float) $point2['latitude'] - (float) $point1['latitude'] ); |
|
| 714 | - $deltaLongitude = deg2rad( (float) $point2['longitude'] - (float) $point1['longitude'] ); |
|
| 715 | - $a = sin( $deltaLatitude / 2 ) * sin( $deltaLatitude / 2 ) + |
|
| 716 | - cos( deg2rad( (float) $point1['latitude'] ) ) * cos( deg2rad( (float) $point2['latitude'] ) ) * |
|
| 717 | - sin( $deltaLongitude / 2 ) * sin( $deltaLongitude / 2 ); |
|
| 718 | - $c = 2 * atan2( sqrt( $a ), sqrt( 1 - $a ) ); |
|
| 713 | + $deltaLatitude = deg2rad((float) $point2['latitude'] - (float) $point1['latitude']); |
|
| 714 | + $deltaLongitude = deg2rad((float) $point2['longitude'] - (float) $point1['longitude']); |
|
| 715 | + $a = sin($deltaLatitude / 2) * sin($deltaLatitude / 2) + |
|
| 716 | + cos(deg2rad((float) $point1['latitude'])) * cos(deg2rad((float) $point2['latitude'])) * |
|
| 717 | + sin($deltaLongitude / 2) * sin($deltaLongitude / 2); |
|
| 718 | + $c = 2 * atan2(sqrt($a), sqrt(1 - $a)); |
|
| 719 | 719 | $distance = $earthMeanRadius * $c; |
| 720 | 720 | |
| 721 | 721 | return $distance; |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | } |
| 725 | 725 | |
| 726 | 726 | |
| 727 | -if ( ! function_exists( 'geodir_sendEmail' ) ) {
|
|
| 727 | +if (!function_exists('geodir_sendEmail')) {
|
|
| 728 | 728 | /** |
| 729 | 729 | * The main function that send transactional emails using the args provided. |
| 730 | 730 | * |
@@ -743,95 +743,95 @@ discard block |
||
| 743 | 743 | * @param string $post_id The post ID. |
| 744 | 744 | * @param string $user_id The user ID. |
| 745 | 745 | */ |
| 746 | - function geodir_sendEmail( $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '' ) {
|
|
| 746 | + function geodir_sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '') {
|
|
| 747 | 747 | $login_details = ''; |
| 748 | 748 | |
| 749 | 749 | // strip slashes from subject & message text |
| 750 | - $to_subject = stripslashes_deep( $to_subject ); |
|
| 751 | - $to_message = stripslashes_deep( $to_message ); |
|
| 750 | + $to_subject = stripslashes_deep($to_subject); |
|
| 751 | + $to_message = stripslashes_deep($to_message); |
|
| 752 | 752 | |
| 753 | - if ( $message_type == 'send_friend' ) {
|
|
| 754 | - $subject = get_option( 'geodir_email_friend_subject' ); |
|
| 755 | - $message = get_option( 'geodir_email_friend_content' ); |
|
| 756 | - } elseif ( $message_type == 'send_enquiry' ) {
|
|
| 757 | - $subject = get_option( 'geodir_email_enquiry_subject' ); |
|
| 758 | - $message = get_option( 'geodir_email_enquiry_content' ); |
|
| 753 | + if ($message_type == 'send_friend') {
|
|
| 754 | + $subject = get_option('geodir_email_friend_subject');
|
|
| 755 | + $message = get_option('geodir_email_friend_content');
|
|
| 756 | + } elseif ($message_type == 'send_enquiry') {
|
|
| 757 | + $subject = get_option('geodir_email_enquiry_subject');
|
|
| 758 | + $message = get_option('geodir_email_enquiry_content');
|
|
| 759 | 759 | |
| 760 | 760 | // change to name in some cases |
| 761 | - $post_author = get_post_field( 'post_author', $post_id ); |
|
| 762 | - if(is_super_admin( $post_author )){// if admin probably not the post author so change name
|
|
| 763 | - $toEmailName = __('Business Owner','geodirectory');
|
|
| 764 | - }elseif(defined('GEODIRCLAIM_VERSION') && geodir_get_post_meta($post_id,'claimed')!='1'){// if claim manager installed but listing not claimed
|
|
| 765 | - $toEmailName = __('Business Owner','geodirectory');
|
|
| 761 | + $post_author = get_post_field('post_author', $post_id);
|
|
| 762 | + if (is_super_admin($post_author)) {// if admin probably not the post author so change name
|
|
| 763 | + $toEmailName = __('Business Owner', 'geodirectory');
|
|
| 764 | + }elseif (defined('GEODIRCLAIM_VERSION') && geodir_get_post_meta($post_id, 'claimed') != '1') {// if claim manager installed but listing not claimed
|
|
| 765 | + $toEmailName = __('Business Owner', 'geodirectory');
|
|
| 766 | 766 | } |
| 767 | 767 | |
| 768 | 768 | |
| 769 | - } elseif ( $message_type == 'forgot_password' ) {
|
|
| 770 | - $subject = get_option( 'geodir_forgot_password_subject' ); |
|
| 771 | - $message = get_option( 'geodir_forgot_password_content' ); |
|
| 769 | + } elseif ($message_type == 'forgot_password') {
|
|
| 770 | + $subject = get_option('geodir_forgot_password_subject');
|
|
| 771 | + $message = get_option('geodir_forgot_password_content');
|
|
| 772 | 772 | $login_details = $to_message; |
| 773 | - } elseif ( $message_type == 'registration' ) {
|
|
| 774 | - $subject = get_option( 'geodir_registration_success_email_subject' ); |
|
| 775 | - $message = get_option( 'geodir_registration_success_email_content' ); |
|
| 773 | + } elseif ($message_type == 'registration') {
|
|
| 774 | + $subject = get_option('geodir_registration_success_email_subject');
|
|
| 775 | + $message = get_option('geodir_registration_success_email_content');
|
|
| 776 | 776 | $login_details = $to_message; |
| 777 | - } elseif ( $message_type == 'post_submit' ) {
|
|
| 778 | - $subject = get_option( 'geodir_post_submited_success_email_subject' ); |
|
| 779 | - $message = get_option( 'geodir_post_submited_success_email_content' ); |
|
| 780 | - } elseif ( $message_type == 'listing_published' ) {
|
|
| 781 | - $subject = get_option( 'geodir_post_published_email_subject' ); |
|
| 782 | - $message = get_option( 'geodir_post_published_email_content' ); |
|
| 783 | - } elseif ( $message_type == 'listing_edited' ) {
|
|
| 784 | - $subject = get_option( 'geodir_post_edited_email_subject_admin' ); |
|
| 785 | - $message = get_option( 'geodir_post_edited_email_content_admin' ); |
|
| 777 | + } elseif ($message_type == 'post_submit') {
|
|
| 778 | + $subject = get_option('geodir_post_submited_success_email_subject');
|
|
| 779 | + $message = get_option('geodir_post_submited_success_email_content');
|
|
| 780 | + } elseif ($message_type == 'listing_published') {
|
|
| 781 | + $subject = get_option('geodir_post_published_email_subject');
|
|
| 782 | + $message = get_option('geodir_post_published_email_content');
|
|
| 783 | + } elseif ($message_type == 'listing_edited') {
|
|
| 784 | + $subject = get_option('geodir_post_edited_email_subject_admin');
|
|
| 785 | + $message = get_option('geodir_post_edited_email_content_admin');
|
|
| 786 | 786 | } |
| 787 | 787 | |
| 788 | - if ( ! empty( $subject ) ) {
|
|
| 789 | - $subject = __( stripslashes_deep( $subject ), 'geodirectory' ); |
|
| 788 | + if (!empty($subject)) {
|
|
| 789 | + $subject = __(stripslashes_deep($subject), 'geodirectory'); |
|
| 790 | 790 | } |
| 791 | 791 | |
| 792 | - if ( ! empty( $message ) ) {
|
|
| 793 | - $message = __( stripslashes_deep( $message ), 'geodirectory' ); |
|
| 792 | + if (!empty($message)) {
|
|
| 793 | + $message = __(stripslashes_deep($message), 'geodirectory'); |
|
| 794 | 794 | } |
| 795 | 795 | |
| 796 | - $to_message = nl2br( $to_message ); |
|
| 797 | - $sitefromEmail = get_option( 'site_email' ); |
|
| 796 | + $to_message = nl2br($to_message); |
|
| 797 | + $sitefromEmail = get_option('site_email');
|
|
| 798 | 798 | $sitefromEmailName = get_site_emailName(); |
| 799 | - $productlink = get_permalink( $post_id ); |
|
| 799 | + $productlink = get_permalink($post_id); |
|
| 800 | 800 | |
| 801 | 801 | $user_login = ''; |
| 802 | - if ( $user_id > 0 && $user_info = get_userdata( $user_id ) ) {
|
|
| 802 | + if ($user_id > 0 && $user_info = get_userdata($user_id)) {
|
|
| 803 | 803 | $user_login = $user_info->user_login; |
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | $posted_date = ''; |
| 807 | 807 | $listingLink = ''; |
| 808 | 808 | |
| 809 | - $post_info = get_post( $post_id ); |
|
| 809 | + $post_info = get_post($post_id); |
|
| 810 | 810 | |
| 811 | - if ( $post_info ) {
|
|
| 811 | + if ($post_info) {
|
|
| 812 | 812 | $posted_date = $post_info->post_date; |
| 813 | - $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>'; |
|
| 813 | + $listingLink = '<a href="'.$productlink.'"><b>'.$post_info->post_title.'</b></a>'; |
|
| 814 | 814 | } |
| 815 | 815 | $siteurl = home_url(); |
| 816 | - $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>'; |
|
| 816 | + $siteurl_link = '<a href="'.$siteurl.'">'.$siteurl.'</a>'; |
|
| 817 | 817 | $loginurl = geodir_login_url(); |
| 818 | - $loginurl_link = '<a href="' . $loginurl . '">login</a>'; |
|
| 818 | + $loginurl_link = '<a href="'.$loginurl.'">login</a>'; |
|
| 819 | 819 | |
| 820 | - $post_author_id = ! empty( $post_info ) ? $post_info->post_author : 0; |
|
| 821 | - $post_author_data = $post_author_id ? get_userdata( $post_author_id ) : NULL; |
|
| 822 | - $post_author_name = geodir_get_client_name( $post_author_id ); |
|
| 823 | - $post_author_email = !empty( $post_author_data->user_email ) ? $post_author_data->user_email : ''; |
|
| 824 | - $current_date = date_i18n( 'Y-m-d H:i:s', current_time( 'timestamp' ) ); |
|
| 825 | - |
|
| 826 | - if ( $fromEmail == '' ) {
|
|
| 827 | - $fromEmail = get_option( 'site_email' ); |
|
| 820 | + $post_author_id = !empty($post_info) ? $post_info->post_author : 0; |
|
| 821 | + $post_author_data = $post_author_id ? get_userdata($post_author_id) : NULL; |
|
| 822 | + $post_author_name = geodir_get_client_name($post_author_id); |
|
| 823 | + $post_author_email = !empty($post_author_data->user_email) ? $post_author_data->user_email : ''; |
|
| 824 | + $current_date = date_i18n('Y-m-d H:i:s', current_time('timestamp'));
|
|
| 825 | + |
|
| 826 | + if ($fromEmail == '') {
|
|
| 827 | + $fromEmail = get_option('site_email');
|
|
| 828 | 828 | } |
| 829 | 829 | |
| 830 | - if ( $fromEmailName == '' ) {
|
|
| 831 | - $fromEmailName = get_option( 'site_email_name' ); |
|
| 830 | + if ($fromEmailName == '') {
|
|
| 831 | + $fromEmailName = get_option('site_email_name');
|
|
| 832 | 832 | } |
| 833 | 833 | |
| 834 | - $search_array = array( |
|
| 834 | + $search_array = array( |
|
| 835 | 835 | '[#listing_link#]', |
| 836 | 836 | '[#site_name_url#]', |
| 837 | 837 | '[#post_id#]', |
@@ -873,7 +873,7 @@ discard block |
||
| 873 | 873 | $post_author_email, |
| 874 | 874 | $current_date, |
| 875 | 875 | ); |
| 876 | - $message = str_replace( $search_array, $replace_array, $message ); |
|
| 876 | + $message = str_replace($search_array, $replace_array, $message); |
|
| 877 | 877 | |
| 878 | 878 | $search_array = array( |
| 879 | 879 | '[#listing_link#]', |
@@ -911,12 +911,12 @@ discard block |
||
| 911 | 911 | $post_author_email, |
| 912 | 912 | $current_date |
| 913 | 913 | ); |
| 914 | - $subject = str_replace( $search_array, $replace_array, $subject ); |
|
| 914 | + $subject = str_replace($search_array, $replace_array, $subject); |
|
| 915 | 915 | |
| 916 | - $headers = array(); |
|
| 916 | + $headers = array(); |
|
| 917 | 917 | $headers[] = 'Content-type: text/html; charset=UTF-8'; |
| 918 | - $headers[] = "Reply-To: " . $fromEmail; |
|
| 919 | - $headers[] = 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>'; |
|
| 918 | + $headers[] = "Reply-To: ".$fromEmail; |
|
| 919 | + $headers[] = 'From: '.$sitefromEmailName.' <'.$sitefromEmail.'>'; |
|
| 920 | 920 | |
| 921 | 921 | $to = $toEmail; |
| 922 | 922 | |
@@ -938,7 +938,7 @@ discard block |
||
| 938 | 938 | * @param string $post_id The post ID. |
| 939 | 939 | * @param string $user_id The user ID. |
| 940 | 940 | */ |
| 941 | - $to = apply_filters( 'geodir_sendEmail_to', $to, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id ); |
|
| 941 | + $to = apply_filters('geodir_sendEmail_to', $to, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id);
|
|
| 942 | 942 | /** |
| 943 | 943 | * Filter the client email subject. |
| 944 | 944 | * |
@@ -957,7 +957,7 @@ discard block |
||
| 957 | 957 | * @param string $post_id The post ID. |
| 958 | 958 | * @param string $user_id The user ID. |
| 959 | 959 | */ |
| 960 | - $subject = apply_filters( 'geodir_sendEmail_subject', $subject, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id ); |
|
| 960 | + $subject = apply_filters('geodir_sendEmail_subject', $subject, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id);
|
|
| 961 | 961 | /** |
| 962 | 962 | * Filter the client email message. |
| 963 | 963 | * |
@@ -976,7 +976,7 @@ discard block |
||
| 976 | 976 | * @param string $post_id The post ID. |
| 977 | 977 | * @param string $user_id The user ID. |
| 978 | 978 | */ |
| 979 | - $message = apply_filters( 'geodir_sendEmail_message', $message, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id ); |
|
| 979 | + $message = apply_filters('geodir_sendEmail_message', $message, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id);
|
|
| 980 | 980 | /** |
| 981 | 981 | * Filter the client email headers. |
| 982 | 982 | * |
@@ -995,39 +995,39 @@ discard block |
||
| 995 | 995 | * @param string $post_id The post ID. |
| 996 | 996 | * @param string $user_id The user ID. |
| 997 | 997 | */ |
| 998 | - $headers = apply_filters( 'geodir_sendEmail_headers', $headers, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id ); |
|
| 998 | + $headers = apply_filters('geodir_sendEmail_headers', $headers, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id);
|
|
| 999 | 999 | |
| 1000 | - $sent = wp_mail( $to, $subject, $message, $headers ); |
|
| 1000 | + $sent = wp_mail($to, $subject, $message, $headers); |
|
| 1001 | 1001 | |
| 1002 | - if ( ! $sent ) {
|
|
| 1003 | - if ( is_array( $to ) ) {
|
|
| 1004 | - $to = implode( ',', $to ); |
|
| 1002 | + if (!$sent) {
|
|
| 1003 | + if (is_array($to)) {
|
|
| 1004 | + $to = implode(',', $to);
|
|
| 1005 | 1005 | } |
| 1006 | 1006 | $log_message = sprintf( |
| 1007 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 1007 | + __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
|
|
| 1008 | 1008 | $message_type, |
| 1009 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 1009 | + date_i18n('F j Y H:i:s', current_time('timestamp')),
|
|
| 1010 | 1010 | $to, |
| 1011 | 1011 | $subject |
| 1012 | 1012 | ); |
| 1013 | - geodir_error_log( $log_message ); |
|
| 1013 | + geodir_error_log($log_message); |
|
| 1014 | 1014 | } |
| 1015 | 1015 | |
| 1016 | 1016 | ///////// ADMIN BCC EMIALS |
| 1017 | - $adminEmail = get_bloginfo( 'admin_email' ); |
|
| 1017 | + $adminEmail = get_bloginfo('admin_email');
|
|
| 1018 | 1018 | $to = $adminEmail; |
| 1019 | 1019 | |
| 1020 | 1020 | $admin_bcc = false; |
| 1021 | - if ( $message_type == 'registration' ) {
|
|
| 1022 | - $message_raw = explode( __( "Password:", 'geodirectory' ), $message ); |
|
| 1023 | - $message_raw2 = explode( "</p>", $message_raw[1], 2 ); |
|
| 1024 | - $message = $message_raw[0] . __( 'Password:', 'geodirectory' ) . ' **********</p>' . $message_raw2[1]; |
|
| 1021 | + if ($message_type == 'registration') {
|
|
| 1022 | + $message_raw = explode(__("Password:", 'geodirectory'), $message);
|
|
| 1023 | + $message_raw2 = explode("</p>", $message_raw[1], 2);
|
|
| 1024 | + $message = $message_raw[0].__('Password:', 'geodirectory').' **********</p>'.$message_raw2[1];
|
|
| 1025 | 1025 | } |
| 1026 | - if ( $message_type == 'post_submit' ) {
|
|
| 1027 | - $subject = __( stripslashes_deep( get_option( 'geodir_post_submited_success_email_subject_admin' ) ), 'geodirectory' ); |
|
| 1028 | - $message = __( stripslashes_deep( get_option( 'geodir_post_submited_success_email_content_admin' ) ), 'geodirectory' ); |
|
| 1026 | + if ($message_type == 'post_submit') {
|
|
| 1027 | + $subject = __(stripslashes_deep(get_option('geodir_post_submited_success_email_subject_admin')), 'geodirectory');
|
|
| 1028 | + $message = __(stripslashes_deep(get_option('geodir_post_submited_success_email_content_admin')), 'geodirectory');
|
|
| 1029 | 1029 | |
| 1030 | - $search_array = array( |
|
| 1030 | + $search_array = array( |
|
| 1031 | 1031 | '[#listing_link#]', |
| 1032 | 1032 | '[#site_name_url#]', |
| 1033 | 1033 | '[#post_id#]', |
@@ -1063,7 +1063,7 @@ discard block |
||
| 1063 | 1063 | $user_login, |
| 1064 | 1064 | $post_author_email, |
| 1065 | 1065 | ); |
| 1066 | - $message = str_replace( $search_array, $replace_array, $message ); |
|
| 1066 | + $message = str_replace($search_array, $replace_array, $message); |
|
| 1067 | 1067 | |
| 1068 | 1068 | $search_array = array( |
| 1069 | 1069 | '[#listing_link#]', |
@@ -1095,26 +1095,26 @@ discard block |
||
| 1095 | 1095 | $user_login, |
| 1096 | 1096 | $post_author_email, |
| 1097 | 1097 | ); |
| 1098 | - $subject = str_replace( $search_array, $replace_array, $subject ); |
|
| 1098 | + $subject = str_replace($search_array, $replace_array, $subject); |
|
| 1099 | 1099 | |
| 1100 | 1100 | $subject .= ' - ADMIN BCC COPY'; |
| 1101 | 1101 | $admin_bcc = true; |
| 1102 | 1102 | |
| 1103 | - } elseif ( $message_type == 'registration' && get_option( 'geodir_bcc_new_user' ) ) {
|
|
| 1103 | + } elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
|
|
| 1104 | 1104 | $subject .= ' - ADMIN BCC COPY'; |
| 1105 | 1105 | $admin_bcc = true; |
| 1106 | - } elseif ( $message_type == 'send_friend' && get_option( 'geodir_bcc_friend' ) ) {
|
|
| 1106 | + } elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
|
|
| 1107 | 1107 | $subject .= ' - ADMIN BCC COPY'; |
| 1108 | 1108 | $admin_bcc = true; |
| 1109 | - } elseif ( $message_type == 'send_enquiry' && get_option( 'geodir_bcc_enquiry' ) ) {
|
|
| 1109 | + } elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
|
|
| 1110 | 1110 | $subject .= ' - ADMIN BCC COPY'; |
| 1111 | 1111 | $admin_bcc = true; |
| 1112 | - } elseif ( $message_type == 'listing_published' && get_option( 'geodir_bcc_listing_published' ) ) {
|
|
| 1112 | + } elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
|
|
| 1113 | 1113 | $subject .= ' - ADMIN BCC COPY'; |
| 1114 | 1114 | $admin_bcc = true; |
| 1115 | 1115 | } |
| 1116 | 1116 | |
| 1117 | - if ( $admin_bcc === true ) {
|
|
| 1117 | + if ($admin_bcc === true) {
|
|
| 1118 | 1118 | |
| 1119 | 1119 | /** |
| 1120 | 1120 | * Filter the client email subject. |
@@ -1134,7 +1134,7 @@ discard block |
||
| 1134 | 1134 | * @param string $post_id The post ID. |
| 1135 | 1135 | * @param string $user_id The user ID. |
| 1136 | 1136 | */ |
| 1137 | - $subject = apply_filters( 'geodir_sendEmail_subject_admin_bcc', $subject, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id ); |
|
| 1137 | + $subject = apply_filters('geodir_sendEmail_subject_admin_bcc', $subject, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id);
|
|
| 1138 | 1138 | /** |
| 1139 | 1139 | * Filter the client email message. |
| 1140 | 1140 | * |
@@ -1153,23 +1153,23 @@ discard block |
||
| 1153 | 1153 | * @param string $post_id The post ID. |
| 1154 | 1154 | * @param string $user_id The user ID. |
| 1155 | 1155 | */ |
| 1156 | - $message = apply_filters( 'geodir_sendEmail_message_admin_bcc', $message, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id ); |
|
| 1156 | + $message = apply_filters('geodir_sendEmail_message_admin_bcc', $message, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id);
|
|
| 1157 | 1157 | |
| 1158 | 1158 | |
| 1159 | - $sent = wp_mail( $to, $subject, $message, $headers ); |
|
| 1159 | + $sent = wp_mail($to, $subject, $message, $headers); |
|
| 1160 | 1160 | |
| 1161 | - if ( ! $sent ) {
|
|
| 1162 | - if ( is_array( $to ) ) {
|
|
| 1163 | - $to = implode( ',', $to ); |
|
| 1161 | + if (!$sent) {
|
|
| 1162 | + if (is_array($to)) {
|
|
| 1163 | + $to = implode(',', $to);
|
|
| 1164 | 1164 | } |
| 1165 | 1165 | $log_message = sprintf( |
| 1166 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 1166 | + __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
|
|
| 1167 | 1167 | $message_type, |
| 1168 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 1168 | + date_i18n('F j Y H:i:s', current_time('timestamp')),
|
|
| 1169 | 1169 | $to, |
| 1170 | 1170 | $subject |
| 1171 | 1171 | ); |
| 1172 | - geodir_error_log( $log_message ); |
|
| 1172 | + geodir_error_log($log_message); |
|
| 1173 | 1173 | } |
| 1174 | 1174 | } |
| 1175 | 1175 | |
@@ -1185,49 +1185,49 @@ discard block |
||
| 1185 | 1185 | */ |
| 1186 | 1186 | function geodir_taxonomy_breadcrumb() {
|
| 1187 | 1187 | |
| 1188 | - $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); |
|
| 1188 | + $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
|
|
| 1189 | 1189 | $parent = $term->parent; |
| 1190 | 1190 | |
| 1191 | - while ( $parent ): |
|
| 1191 | + while ($parent): |
|
| 1192 | 1192 | $parents[] = $parent; |
| 1193 | - $new_parent = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ) ); |
|
| 1193 | + $new_parent = get_term_by('id', $parent, get_query_var('taxonomy'));
|
|
| 1194 | 1194 | $parent = $new_parent->parent; |
| 1195 | 1195 | endwhile; |
| 1196 | 1196 | |
| 1197 | - if ( ! empty( $parents ) ): |
|
| 1198 | - $parents = array_reverse( $parents ); |
|
| 1197 | + if (!empty($parents)): |
|
| 1198 | + $parents = array_reverse($parents); |
|
| 1199 | 1199 | |
| 1200 | - foreach ( $parents as $parent ): |
|
| 1201 | - $item = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ) ); |
|
| 1202 | - $url = get_term_link( $item, get_query_var( 'taxonomy' ) ); |
|
| 1203 | - echo '<li> > <a href="' . $url . '">' . $item->name . '</a></li>'; |
|
| 1200 | + foreach ($parents as $parent): |
|
| 1201 | + $item = get_term_by('id', $parent, get_query_var('taxonomy'));
|
|
| 1202 | + $url = get_term_link($item, get_query_var('taxonomy'));
|
|
| 1203 | + echo '<li> > <a href="'.$url.'">'.$item->name.'</a></li>'; |
|
| 1204 | 1204 | endforeach; |
| 1205 | 1205 | |
| 1206 | 1206 | endif; |
| 1207 | 1207 | |
| 1208 | - echo '<li> > ' . $term->name . '</li>'; |
|
| 1208 | + echo '<li> > '.$term->name.'</li>'; |
|
| 1209 | 1209 | } |
| 1210 | 1210 | |
| 1211 | -function geodir_wpml_post_type_archive_link($link, $post_type){
|
|
| 1211 | +function geodir_wpml_post_type_archive_link($link, $post_type) {
|
|
| 1212 | 1212 | if (function_exists('icl_object_id')) {
|
| 1213 | - $post_types = get_option( 'geodir_post_types' ); |
|
| 1214 | - $slug = $post_types[ $post_type ]['rewrite']['slug']; |
|
| 1213 | + $post_types = get_option('geodir_post_types');
|
|
| 1214 | + $slug = $post_types[$post_type]['rewrite']['slug']; |
|
| 1215 | 1215 | |
| 1216 | 1216 | // Alter the CPT slug if WPML is set to do so |
| 1217 | - if ( function_exists( 'icl_object_id' ) ) {
|
|
| 1218 | - if ( gd_wpml_slug_translation_turned_on( $post_type ) && $language_code = gd_wpml_get_lang_from_url( $link) ) {
|
|
| 1217 | + if (function_exists('icl_object_id')) {
|
|
| 1218 | + if (gd_wpml_slug_translation_turned_on($post_type) && $language_code = gd_wpml_get_lang_from_url($link)) {
|
|
| 1219 | 1219 | |
| 1220 | 1220 | $org_slug = $slug; |
| 1221 | - $slug = apply_filters( 'wpml_translate_single_string', |
|
| 1221 | + $slug = apply_filters('wpml_translate_single_string',
|
|
| 1222 | 1222 | $slug, |
| 1223 | 1223 | 'WordPress', |
| 1224 | - 'URL slug: ' . $slug, |
|
| 1225 | - $language_code ); |
|
| 1224 | + 'URL slug: '.$slug, |
|
| 1225 | + $language_code); |
|
| 1226 | 1226 | |
| 1227 | - if ( ! $slug ) {
|
|
| 1227 | + if (!$slug) {
|
|
| 1228 | 1228 | $slug = $org_slug; |
| 1229 | 1229 | } else {
|
| 1230 | - $link = str_replace( $org_slug, $slug, $link ); |
|
| 1230 | + $link = str_replace($org_slug, $slug, $link); |
|
| 1231 | 1231 | } |
| 1232 | 1232 | } |
| 1233 | 1233 | } |
@@ -1235,7 +1235,7 @@ discard block |
||
| 1235 | 1235 | |
| 1236 | 1236 | return $link; |
| 1237 | 1237 | } |
| 1238 | -add_filter( 'post_type_archive_link','geodir_wpml_post_type_archive_link', 1000, 2); |
|
| 1238 | +add_filter('post_type_archive_link', 'geodir_wpml_post_type_archive_link', 1000, 2);
|
|
| 1239 | 1239 | |
| 1240 | 1240 | /** |
| 1241 | 1241 | * Main function that generates breadcrumb for all pages. |
@@ -1256,9 +1256,9 @@ discard block |
||
| 1256 | 1256 | * |
| 1257 | 1257 | * @since 1.0.0 |
| 1258 | 1258 | */ |
| 1259 | - $separator = apply_filters( 'geodir_breadcrumb_separator', ' > ' ); |
|
| 1259 | + $separator = apply_filters('geodir_breadcrumb_separator', ' > ');
|
|
| 1260 | 1260 | |
| 1261 | - if ( ! geodir_is_page( 'home' ) ) {
|
|
| 1261 | + if (!geodir_is_page('home')) {
|
|
| 1262 | 1262 | $breadcrumb = ''; |
| 1263 | 1263 | $url_categoris = ''; |
| 1264 | 1264 | $breadcrumb .= '<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">'; |
@@ -1267,167 +1267,167 @@ discard block |
||
| 1267 | 1267 | * |
| 1268 | 1268 | * @since 1.0.0 |
| 1269 | 1269 | */ |
| 1270 | - $breadcrumb .= '<li>' . apply_filters( 'geodir_breadcrumb_first_link', '<a href="' . home_url() . '">' . __( 'Home', 'geodirectory' ) . '</a>' ) . '</li>'; |
|
| 1270 | + $breadcrumb .= '<li>'.apply_filters('geodir_breadcrumb_first_link', '<a href="'.home_url().'">'.__('Home', 'geodirectory').'</a>').'</li>';
|
|
| 1271 | 1271 | |
| 1272 | 1272 | $gd_post_type = geodir_get_current_posttype(); |
| 1273 | - $post_type_info = get_post_type_object( $gd_post_type ); |
|
| 1273 | + $post_type_info = get_post_type_object($gd_post_type); |
|
| 1274 | 1274 | |
| 1275 | - remove_filter( 'post_type_archive_link', 'geodir_get_posttype_link' ); |
|
| 1275 | + remove_filter('post_type_archive_link', 'geodir_get_posttype_link');
|
|
| 1276 | 1276 | |
| 1277 | - $listing_link = get_post_type_archive_link( $gd_post_type ); |
|
| 1277 | + $listing_link = get_post_type_archive_link($gd_post_type); |
|
| 1278 | 1278 | |
| 1279 | - add_filter( 'post_type_archive_link', 'geodir_get_posttype_link', 10, 2 ); |
|
| 1280 | - $listing_link = rtrim( $listing_link, '/' ); |
|
| 1279 | + add_filter('post_type_archive_link', 'geodir_get_posttype_link', 10, 2);
|
|
| 1280 | + $listing_link = rtrim($listing_link, '/'); |
|
| 1281 | 1281 | $listing_link .= '/'; |
| 1282 | 1282 | |
| 1283 | 1283 | $post_type_for_location_link = $listing_link; |
| 1284 | - $location_terms = geodir_get_current_location_terms( 'query_vars', $gd_post_type ); |
|
| 1284 | + $location_terms = geodir_get_current_location_terms('query_vars', $gd_post_type);
|
|
| 1285 | 1285 | |
| 1286 | 1286 | global $wp, $gd_session; |
| 1287 | 1287 | $location_link = $post_type_for_location_link; |
| 1288 | 1288 | |
| 1289 | - if ( geodir_is_page( 'detail' ) || geodir_is_page( 'listing' ) ) {
|
|
| 1289 | + if (geodir_is_page('detail') || geodir_is_page('listing')) {
|
|
| 1290 | 1290 | global $post; |
| 1291 | - $location_manager = defined( 'POST_LOCATION_TABLE' ) ? true : false; |
|
| 1292 | - $neighbourhood_active = $location_manager && get_option( 'location_neighbourhoods' ) ? true : false; |
|
| 1291 | + $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
|
|
| 1292 | + $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
|
| 1293 | 1293 | |
| 1294 | - if ( geodir_is_page( 'detail' ) && isset( $post->country_slug ) ) {
|
|
| 1294 | + if (geodir_is_page('detail') && isset($post->country_slug)) {
|
|
| 1295 | 1295 | $location_terms = array( |
| 1296 | 1296 | 'gd_country' => $post->country_slug, |
| 1297 | 1297 | 'gd_region' => $post->region_slug, |
| 1298 | 1298 | 'gd_city' => $post->city_slug |
| 1299 | 1299 | ); |
| 1300 | 1300 | |
| 1301 | - if ( $neighbourhood_active && ! empty( $location_terms['gd_city'] ) && $gd_ses_neighbourhood = $gd_session->get( 'gd_neighbourhood' ) ) {
|
|
| 1301 | + if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
|
|
| 1302 | 1302 | $location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood; |
| 1303 | 1303 | } |
| 1304 | 1304 | } |
| 1305 | 1305 | |
| 1306 | - $geodir_show_location_url = get_option( 'geodir_show_location_url' ); |
|
| 1306 | + $geodir_show_location_url = get_option('geodir_show_location_url');
|
|
| 1307 | 1307 | |
| 1308 | 1308 | $hide_url_part = array(); |
| 1309 | - if ( $location_manager ) {
|
|
| 1310 | - $hide_country_part = get_option( 'geodir_location_hide_country_part' ); |
|
| 1311 | - $hide_region_part = get_option( 'geodir_location_hide_region_part' ); |
|
| 1312 | - |
|
| 1313 | - if ( $hide_region_part && $hide_country_part ) {
|
|
| 1314 | - $hide_url_part = array( 'gd_country', 'gd_region' ); |
|
| 1315 | - } else if ( $hide_region_part && ! $hide_country_part ) {
|
|
| 1316 | - $hide_url_part = array( 'gd_region' ); |
|
| 1317 | - } else if ( ! $hide_region_part && $hide_country_part ) {
|
|
| 1318 | - $hide_url_part = array( 'gd_country' ); |
|
| 1309 | + if ($location_manager) {
|
|
| 1310 | + $hide_country_part = get_option('geodir_location_hide_country_part');
|
|
| 1311 | + $hide_region_part = get_option('geodir_location_hide_region_part');
|
|
| 1312 | + |
|
| 1313 | + if ($hide_region_part && $hide_country_part) {
|
|
| 1314 | + $hide_url_part = array('gd_country', 'gd_region');
|
|
| 1315 | + } else if ($hide_region_part && !$hide_country_part) {
|
|
| 1316 | + $hide_url_part = array('gd_region');
|
|
| 1317 | + } else if (!$hide_region_part && $hide_country_part) {
|
|
| 1318 | + $hide_url_part = array('gd_country');
|
|
| 1319 | 1319 | } |
| 1320 | 1320 | } |
| 1321 | 1321 | |
| 1322 | 1322 | $hide_text_part = array(); |
| 1323 | - if ( $geodir_show_location_url == 'country_city' ) {
|
|
| 1324 | - $hide_text_part = array( 'gd_region' ); |
|
| 1323 | + if ($geodir_show_location_url == 'country_city') {
|
|
| 1324 | + $hide_text_part = array('gd_region');
|
|
| 1325 | 1325 | |
| 1326 | - if ( isset( $location_terms['gd_region'] ) && ! $location_manager ) {
|
|
| 1327 | - unset( $location_terms['gd_region'] ); |
|
| 1326 | + if (isset($location_terms['gd_region']) && !$location_manager) {
|
|
| 1327 | + unset($location_terms['gd_region']); |
|
| 1328 | 1328 | } |
| 1329 | - } else if ( $geodir_show_location_url == 'region_city' ) {
|
|
| 1330 | - $hide_text_part = array( 'gd_country' ); |
|
| 1329 | + } else if ($geodir_show_location_url == 'region_city') {
|
|
| 1330 | + $hide_text_part = array('gd_country');
|
|
| 1331 | 1331 | |
| 1332 | - if ( isset( $location_terms['gd_country'] ) && ! $location_manager ) {
|
|
| 1333 | - unset( $location_terms['gd_country'] ); |
|
| 1332 | + if (isset($location_terms['gd_country']) && !$location_manager) {
|
|
| 1333 | + unset($location_terms['gd_country']); |
|
| 1334 | 1334 | } |
| 1335 | - } else if ( $geodir_show_location_url == 'city' ) {
|
|
| 1336 | - $hide_text_part = array( 'gd_country', 'gd_region' ); |
|
| 1335 | + } else if ($geodir_show_location_url == 'city') {
|
|
| 1336 | + $hide_text_part = array('gd_country', 'gd_region');
|
|
| 1337 | 1337 | |
| 1338 | - if ( isset( $location_terms['gd_country'] ) && ! $location_manager ) {
|
|
| 1339 | - unset( $location_terms['gd_country'] ); |
|
| 1338 | + if (isset($location_terms['gd_country']) && !$location_manager) {
|
|
| 1339 | + unset($location_terms['gd_country']); |
|
| 1340 | 1340 | } |
| 1341 | - if ( isset( $location_terms['gd_region'] ) && ! $location_manager ) {
|
|
| 1342 | - unset( $location_terms['gd_region'] ); |
|
| 1341 | + if (isset($location_terms['gd_region']) && !$location_manager) {
|
|
| 1342 | + unset($location_terms['gd_region']); |
|
| 1343 | 1343 | } |
| 1344 | 1344 | } |
| 1345 | 1345 | |
| 1346 | 1346 | $is_location_last = ''; |
| 1347 | 1347 | $is_taxonomy_last = ''; |
| 1348 | 1348 | $breadcrumb .= '<li>'; |
| 1349 | - if ( get_query_var( $gd_post_type . 'category' ) ) {
|
|
| 1350 | - $gd_taxonomy = $gd_post_type . 'category'; |
|
| 1351 | - } elseif ( get_query_var( $gd_post_type . '_tags' ) ) {
|
|
| 1352 | - $gd_taxonomy = $gd_post_type . '_tags'; |
|
| 1349 | + if (get_query_var($gd_post_type.'category')) {
|
|
| 1350 | + $gd_taxonomy = $gd_post_type.'category'; |
|
| 1351 | + } elseif (get_query_var($gd_post_type.'_tags')) {
|
|
| 1352 | + $gd_taxonomy = $gd_post_type.'_tags'; |
|
| 1353 | 1353 | } |
| 1354 | 1354 | |
| 1355 | - $breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __( ucfirst( $post_type_info->label ), 'geodirectory' ) . '</a>'; |
|
| 1356 | - if ( ! empty( $gd_taxonomy ) || geodir_is_page( 'detail' ) ) {
|
|
| 1355 | + $breadcrumb .= $separator.'<a href="'.$listing_link.'">'.__(ucfirst($post_type_info->label), 'geodirectory').'</a>'; |
|
| 1356 | + if (!empty($gd_taxonomy) || geodir_is_page('detail')) {
|
|
| 1357 | 1357 | $is_location_last = false; |
| 1358 | 1358 | } else {
|
| 1359 | 1359 | $is_location_last = true; |
| 1360 | 1360 | } |
| 1361 | 1361 | |
| 1362 | - if ( ! empty( $gd_taxonomy ) && geodir_is_page( 'listing' ) ) {
|
|
| 1362 | + if (!empty($gd_taxonomy) && geodir_is_page('listing')) {
|
|
| 1363 | 1363 | $is_taxonomy_last = true; |
| 1364 | 1364 | } else {
|
| 1365 | 1365 | $is_taxonomy_last = false; |
| 1366 | 1366 | } |
| 1367 | 1367 | |
| 1368 | - if ( ! empty( $location_terms ) ) {
|
|
| 1369 | - $geodir_get_locations = function_exists( 'get_actual_location_name' ) ? true : false; |
|
| 1368 | + if (!empty($location_terms)) {
|
|
| 1369 | + $geodir_get_locations = function_exists('get_actual_location_name') ? true : false;
|
|
| 1370 | 1370 | |
| 1371 | - foreach ( $location_terms as $key => $location_term ) {
|
|
| 1372 | - if ( $location_term != '' ) {
|
|
| 1373 | - if ( ! empty( $hide_url_part ) && in_array( $key, $hide_url_part ) ) { // Hide location part from url & breadcrumb.
|
|
| 1371 | + foreach ($location_terms as $key => $location_term) {
|
|
| 1372 | + if ($location_term != '') {
|
|
| 1373 | + if (!empty($hide_url_part) && in_array($key, $hide_url_part)) { // Hide location part from url & breadcrumb.
|
|
| 1374 | 1374 | continue; |
| 1375 | 1375 | } |
| 1376 | 1376 | |
| 1377 | - $gd_location_link_text = preg_replace( '/-(\d+)$/', '', $location_term ); |
|
| 1378 | - $gd_location_link_text = preg_replace( '/[_-]/', ' ', $gd_location_link_text ); |
|
| 1379 | - $gd_location_link_text = ucfirst( $gd_location_link_text ); |
|
| 1377 | + $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location_term);
|
|
| 1378 | + $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
|
|
| 1379 | + $gd_location_link_text = ucfirst($gd_location_link_text); |
|
| 1380 | 1380 | |
| 1381 | 1381 | $location_term_actual_country = ''; |
| 1382 | 1382 | $location_term_actual_region = ''; |
| 1383 | 1383 | $location_term_actual_city = ''; |
| 1384 | 1384 | $location_term_actual_neighbourhood = ''; |
| 1385 | - if ( $geodir_get_locations ) {
|
|
| 1386 | - if ( $key == 'gd_country' ) {
|
|
| 1387 | - $location_term_actual_country = get_actual_location_name( 'country', $location_term, true ); |
|
| 1388 | - } else if ( $key == 'gd_region' ) {
|
|
| 1389 | - $location_term_actual_region = get_actual_location_name( 'region', $location_term, true ); |
|
| 1390 | - } else if ( $key == 'gd_city' ) {
|
|
| 1391 | - $location_term_actual_city = get_actual_location_name( 'city', $location_term, true ); |
|
| 1392 | - } else if ( $key == 'gd_neighbourhood' ) {
|
|
| 1393 | - $location_term_actual_neighbourhood = get_actual_location_name( 'neighbourhood', $location_term, true ); |
|
| 1385 | + if ($geodir_get_locations) {
|
|
| 1386 | + if ($key == 'gd_country') {
|
|
| 1387 | + $location_term_actual_country = get_actual_location_name('country', $location_term, true);
|
|
| 1388 | + } else if ($key == 'gd_region') {
|
|
| 1389 | + $location_term_actual_region = get_actual_location_name('region', $location_term, true);
|
|
| 1390 | + } else if ($key == 'gd_city') {
|
|
| 1391 | + $location_term_actual_city = get_actual_location_name('city', $location_term, true);
|
|
| 1392 | + } else if ($key == 'gd_neighbourhood') {
|
|
| 1393 | + $location_term_actual_neighbourhood = get_actual_location_name('neighbourhood', $location_term, true);
|
|
| 1394 | 1394 | } |
| 1395 | 1395 | } else {
|
| 1396 | 1396 | $location_info = geodir_get_location(); |
| 1397 | 1397 | |
| 1398 | - if ( ! empty( $location_info ) && isset( $location_info->location_id ) ) {
|
|
| 1399 | - if ( $key == 'gd_country' ) {
|
|
| 1400 | - $location_term_actual_country = __( $location_info->country, 'geodirectory' ); |
|
| 1401 | - } else if ( $key == 'gd_region' ) {
|
|
| 1402 | - $location_term_actual_region = __( $location_info->region, 'geodirectory' ); |
|
| 1403 | - } else if ( $key == 'gd_city' ) {
|
|
| 1404 | - $location_term_actual_city = __( $location_info->city, 'geodirectory' ); |
|
| 1398 | + if (!empty($location_info) && isset($location_info->location_id)) {
|
|
| 1399 | + if ($key == 'gd_country') {
|
|
| 1400 | + $location_term_actual_country = __($location_info->country, 'geodirectory'); |
|
| 1401 | + } else if ($key == 'gd_region') {
|
|
| 1402 | + $location_term_actual_region = __($location_info->region, 'geodirectory'); |
|
| 1403 | + } else if ($key == 'gd_city') {
|
|
| 1404 | + $location_term_actual_city = __($location_info->city, 'geodirectory'); |
|
| 1405 | 1405 | } |
| 1406 | 1406 | } |
| 1407 | 1407 | } |
| 1408 | 1408 | |
| 1409 | - 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'] != '' ) ) {
|
|
| 1410 | - $breadcrumb .= $location_term_actual_country != '' ? $separator . $location_term_actual_country : $separator . $gd_location_link_text; |
|
| 1411 | - } else if ( $is_location_last && $key == 'gd_region' && ! ( isset( $location_terms['gd_city'] ) && $location_terms['gd_city'] != '' ) ) {
|
|
| 1412 | - $breadcrumb .= $location_term_actual_region != '' ? $separator . $location_term_actual_region : $separator . $gd_location_link_text; |
|
| 1413 | - } else if ( $is_location_last && $key == 'gd_city' && empty( $location_terms['gd_neighbourhood'] ) ) {
|
|
| 1414 | - $breadcrumb .= $location_term_actual_city != '' ? $separator . $location_term_actual_city : $separator . $gd_location_link_text; |
|
| 1415 | - } else if ( $is_location_last && $key == 'gd_neighbourhood' ) {
|
|
| 1416 | - $breadcrumb .= $location_term_actual_neighbourhood != '' ? $separator . $location_term_actual_neighbourhood : $separator . $gd_location_link_text; |
|
| 1409 | + 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'] != '')) {
|
|
| 1410 | + $breadcrumb .= $location_term_actual_country != '' ? $separator.$location_term_actual_country : $separator.$gd_location_link_text; |
|
| 1411 | + } else if ($is_location_last && $key == 'gd_region' && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
|
|
| 1412 | + $breadcrumb .= $location_term_actual_region != '' ? $separator.$location_term_actual_region : $separator.$gd_location_link_text; |
|
| 1413 | + } else if ($is_location_last && $key == 'gd_city' && empty($location_terms['gd_neighbourhood'])) {
|
|
| 1414 | + $breadcrumb .= $location_term_actual_city != '' ? $separator.$location_term_actual_city : $separator.$gd_location_link_text; |
|
| 1415 | + } else if ($is_location_last && $key == 'gd_neighbourhood') {
|
|
| 1416 | + $breadcrumb .= $location_term_actual_neighbourhood != '' ? $separator.$location_term_actual_neighbourhood : $separator.$gd_location_link_text; |
|
| 1417 | 1417 | } else {
|
| 1418 | - if ( get_option( 'permalink_structure' ) != '' ) {
|
|
| 1419 | - $location_link .= $location_term . '/'; |
|
| 1418 | + if (get_option('permalink_structure') != '') {
|
|
| 1419 | + $location_link .= $location_term.'/'; |
|
| 1420 | 1420 | } else {
|
| 1421 | - $location_link .= "&$key=" . $location_term; |
|
| 1421 | + $location_link .= "&$key=".$location_term; |
|
| 1422 | 1422 | } |
| 1423 | 1423 | |
| 1424 | - if ( $key == 'gd_country' && $location_term_actual_country != '' ) {
|
|
| 1424 | + if ($key == 'gd_country' && $location_term_actual_country != '') {
|
|
| 1425 | 1425 | $gd_location_link_text = $location_term_actual_country; |
| 1426 | - } else if ( $key == 'gd_region' && $location_term_actual_region != '' ) {
|
|
| 1426 | + } else if ($key == 'gd_region' && $location_term_actual_region != '') {
|
|
| 1427 | 1427 | $gd_location_link_text = $location_term_actual_region; |
| 1428 | - } else if ( $key == 'gd_city' && $location_term_actual_city != '' ) {
|
|
| 1428 | + } else if ($key == 'gd_city' && $location_term_actual_city != '') {
|
|
| 1429 | 1429 | $gd_location_link_text = $location_term_actual_city; |
| 1430 | - } else if ( $key == 'gd_neighbourhood' && $location_term_actual_neighbourhood != '' ) {
|
|
| 1430 | + } else if ($key == 'gd_neighbourhood' && $location_term_actual_neighbourhood != '') {
|
|
| 1431 | 1431 | $gd_location_link_text = $location_term_actual_neighbourhood; |
| 1432 | 1432 | } |
| 1433 | 1433 | |
@@ -1437,76 +1437,76 @@ discard block |
||
| 1437 | 1437 | } |
| 1438 | 1438 | */ |
| 1439 | 1439 | |
| 1440 | - $breadcrumb .= $separator . '<a href="' . $location_link . '">' . $gd_location_link_text . '</a>'; |
|
| 1440 | + $breadcrumb .= $separator.'<a href="'.$location_link.'">'.$gd_location_link_text.'</a>'; |
|
| 1441 | 1441 | } |
| 1442 | 1442 | } |
| 1443 | 1443 | } |
| 1444 | 1444 | } |
| 1445 | 1445 | |
| 1446 | - if ( ! empty( $gd_taxonomy ) ) {
|
|
| 1446 | + if (!empty($gd_taxonomy)) {
|
|
| 1447 | 1447 | $term_index = 1; |
| 1448 | 1448 | |
| 1449 | 1449 | //if(get_option('geodir_add_categories_url'))
|
| 1450 | 1450 | {
|
| 1451 | - if ( get_query_var( $gd_post_type . '_tags' ) ) {
|
|
| 1452 | - $cat_link = $listing_link . 'tags/'; |
|
| 1451 | + if (get_query_var($gd_post_type.'_tags')) {
|
|
| 1452 | + $cat_link = $listing_link.'tags/'; |
|
| 1453 | 1453 | } else {
|
| 1454 | 1454 | $cat_link = $listing_link; |
| 1455 | 1455 | } |
| 1456 | 1456 | |
| 1457 | - foreach ( $location_terms as $key => $location_term ) {
|
|
| 1458 | - if ( $location_manager && in_array( $key, $hide_url_part ) ) {
|
|
| 1457 | + foreach ($location_terms as $key => $location_term) {
|
|
| 1458 | + if ($location_manager && in_array($key, $hide_url_part)) {
|
|
| 1459 | 1459 | continue; |
| 1460 | 1460 | } |
| 1461 | 1461 | |
| 1462 | - if ( $location_term != '' ) {
|
|
| 1463 | - if ( get_option( 'permalink_structure' ) != '' ) {
|
|
| 1464 | - $cat_link .= $location_term . '/'; |
|
| 1462 | + if ($location_term != '') {
|
|
| 1463 | + if (get_option('permalink_structure') != '') {
|
|
| 1464 | + $cat_link .= $location_term.'/'; |
|
| 1465 | 1465 | } |
| 1466 | 1466 | } |
| 1467 | 1467 | } |
| 1468 | 1468 | |
| 1469 | - $term_array = explode( "/", trim( $wp_query->query[ $gd_taxonomy ], "/" ) ); |
|
| 1470 | - foreach ( $term_array as $term ) {
|
|
| 1471 | - $term_link_text = preg_replace( '/-(\d+)$/', '', $term ); |
|
| 1472 | - $term_link_text = preg_replace( '/[_-]/', ' ', $term_link_text ); |
|
| 1469 | + $term_array = explode("/", trim($wp_query->query[$gd_taxonomy], "/"));
|
|
| 1470 | + foreach ($term_array as $term) {
|
|
| 1471 | + $term_link_text = preg_replace('/-(\d+)$/', '', $term);
|
|
| 1472 | + $term_link_text = preg_replace('/[_-]/', ' ', $term_link_text);
|
|
| 1473 | 1473 | |
| 1474 | 1474 | // get term actual name |
| 1475 | - $term_info = get_term_by( 'slug', $term, $gd_taxonomy, 'ARRAY_A' ); |
|
| 1476 | - if ( ! empty( $term_info ) && isset( $term_info['name'] ) && $term_info['name'] != '' ) {
|
|
| 1477 | - $term_link_text = urldecode( $term_info['name'] ); |
|
| 1475 | + $term_info = get_term_by('slug', $term, $gd_taxonomy, 'ARRAY_A');
|
|
| 1476 | + if (!empty($term_info) && isset($term_info['name']) && $term_info['name'] != '') {
|
|
| 1477 | + $term_link_text = urldecode($term_info['name']); |
|
| 1478 | 1478 | } else {
|
| 1479 | 1479 | continue; |
| 1480 | 1480 | //$term_link_text = wp_strip_all_tags(geodir_ucwords(urldecode($term_link_text))); |
| 1481 | 1481 | } |
| 1482 | 1482 | |
| 1483 | - if ( $term_index == count( $term_array ) && $is_taxonomy_last ) {
|
|
| 1484 | - $breadcrumb .= $separator . $term_link_text; |
|
| 1483 | + if ($term_index == count($term_array) && $is_taxonomy_last) {
|
|
| 1484 | + $breadcrumb .= $separator.$term_link_text; |
|
| 1485 | 1485 | } else {
|
| 1486 | - $cat_link .= $term . '/'; |
|
| 1487 | - $breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>'; |
|
| 1486 | + $cat_link .= $term.'/'; |
|
| 1487 | + $breadcrumb .= $separator.'<a href="'.$cat_link.'">'.$term_link_text.'</a>'; |
|
| 1488 | 1488 | } |
| 1489 | - $term_index ++; |
|
| 1489 | + $term_index++; |
|
| 1490 | 1490 | } |
| 1491 | 1491 | } |
| 1492 | 1492 | |
| 1493 | 1493 | |
| 1494 | 1494 | } |
| 1495 | 1495 | |
| 1496 | - if ( geodir_is_page( 'detail' ) ) {
|
|
| 1497 | - $breadcrumb .= $separator . get_the_title(); |
|
| 1496 | + if (geodir_is_page('detail')) {
|
|
| 1497 | + $breadcrumb .= $separator.get_the_title(); |
|
| 1498 | 1498 | } |
| 1499 | 1499 | |
| 1500 | 1500 | $breadcrumb .= '</li>'; |
| 1501 | 1501 | |
| 1502 | 1502 | |
| 1503 | - } elseif ( geodir_is_page( 'author' ) ) {
|
|
| 1503 | + } elseif (geodir_is_page('author')) {
|
|
| 1504 | 1504 | $user_id = get_current_user_id(); |
| 1505 | - $author_link = get_author_posts_url( $user_id ); |
|
| 1506 | - $default_author_link = geodir_getlink( $author_link, array( |
|
| 1505 | + $author_link = get_author_posts_url($user_id); |
|
| 1506 | + $default_author_link = geodir_getlink($author_link, array( |
|
| 1507 | 1507 | 'geodir_dashbord' => 'true', |
| 1508 | 1508 | 'stype' => 'gd_place' |
| 1509 | - ), false ); |
|
| 1509 | + ), false); |
|
| 1510 | 1510 | |
| 1511 | 1511 | /** |
| 1512 | 1512 | * Filter author page link. |
@@ -1516,16 +1516,16 @@ discard block |
||
| 1516 | 1516 | * @param string $default_author_link Default author link. |
| 1517 | 1517 | * @param int $user_id Author ID. |
| 1518 | 1518 | */ |
| 1519 | - $default_author_link = apply_filters( 'geodir_dashboard_author_link', $default_author_link, $user_id ); |
|
| 1519 | + $default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_id);
|
|
| 1520 | 1520 | |
| 1521 | 1521 | $breadcrumb .= '<li>'; |
| 1522 | - $breadcrumb .= $separator . '<a href="' . $default_author_link . '">' . __( 'My Dashboard', 'geodirectory' ) . '</a>'; |
|
| 1522 | + $breadcrumb .= $separator.'<a href="'.$default_author_link.'">'.__('My Dashboard', 'geodirectory').'</a>';
|
|
| 1523 | 1523 | |
| 1524 | - if ( isset( $_REQUEST['list'] ) ) {
|
|
| 1525 | - $author_link = geodir_getlink( $author_link, array( |
|
| 1524 | + if (isset($_REQUEST['list'])) {
|
|
| 1525 | + $author_link = geodir_getlink($author_link, array( |
|
| 1526 | 1526 | 'geodir_dashbord' => 'true', |
| 1527 | 1527 | 'stype' => $_REQUEST['stype'] |
| 1528 | - ), false ); |
|
| 1528 | + ), false); |
|
| 1529 | 1529 | |
| 1530 | 1530 | /** |
| 1531 | 1531 | * Filter author page link. |
@@ -1536,61 +1536,61 @@ discard block |
||
| 1536 | 1536 | * @param int $user_id Author ID. |
| 1537 | 1537 | * @param string $_REQUEST ['stype'] Post type. |
| 1538 | 1538 | */ |
| 1539 | - $author_link = apply_filters( 'geodir_dashboard_author_link', $author_link, $user_id, $_REQUEST['stype'] ); |
|
| 1539 | + $author_link = apply_filters('geodir_dashboard_author_link', $author_link, $user_id, $_REQUEST['stype']);
|
|
| 1540 | 1540 | |
| 1541 | - $breadcrumb .= $separator . '<a href="' . $author_link . '">' . __( ucfirst( $post_type_info->label ), 'geodirectory' ) . '</a>'; |
|
| 1542 | - $breadcrumb .= $separator . ucfirst( __( 'My', 'geodirectory' ) . ' ' . $_REQUEST['list'] ); |
|
| 1541 | + $breadcrumb .= $separator.'<a href="'.$author_link.'">'.__(ucfirst($post_type_info->label), 'geodirectory').'</a>'; |
|
| 1542 | + $breadcrumb .= $separator.ucfirst(__('My', 'geodirectory').' '.$_REQUEST['list']);
|
|
| 1543 | 1543 | } else {
|
| 1544 | - $breadcrumb .= $separator . __( ucfirst( $post_type_info->label ), 'geodirectory' ); |
|
| 1544 | + $breadcrumb .= $separator.__(ucfirst($post_type_info->label), 'geodirectory'); |
|
| 1545 | 1545 | } |
| 1546 | 1546 | |
| 1547 | 1547 | $breadcrumb .= '</li>'; |
| 1548 | - } elseif ( is_category() || is_single() ) {
|
|
| 1548 | + } elseif (is_category() || is_single()) {
|
|
| 1549 | 1549 | $category = get_the_category(); |
| 1550 | - if ( is_category() ) {
|
|
| 1551 | - $breadcrumb .= '<li>' . $separator . $category[0]->cat_name . '</li>'; |
|
| 1550 | + if (is_category()) {
|
|
| 1551 | + $breadcrumb .= '<li>'.$separator.$category[0]->cat_name.'</li>'; |
|
| 1552 | 1552 | } |
| 1553 | - if ( is_single() ) {
|
|
| 1554 | - $breadcrumb .= '<li>' . $separator . '<a href="' . get_category_link( $category[0]->term_id ) . '">' . $category[0]->cat_name . '</a></li>'; |
|
| 1555 | - $breadcrumb .= '<li>' . $separator . get_the_title() . '</li>'; |
|
| 1553 | + if (is_single()) {
|
|
| 1554 | + $breadcrumb .= '<li>'.$separator.'<a href="'.get_category_link($category[0]->term_id).'">'.$category[0]->cat_name.'</a></li>'; |
|
| 1555 | + $breadcrumb .= '<li>'.$separator.get_the_title().'</li>'; |
|
| 1556 | 1556 | } |
| 1557 | 1557 | /* End of my version ##################################################### */ |
| 1558 | - } else if ( is_page() ) {
|
|
| 1558 | + } else if (is_page()) {
|
|
| 1559 | 1559 | $page_title = get_the_title(); |
| 1560 | 1560 | |
| 1561 | - if ( geodir_is_page( 'location' ) ) {
|
|
| 1561 | + if (geodir_is_page('location')) {
|
|
| 1562 | 1562 | $location_page_id = geodir_location_page_id(); |
| 1563 | - $loc_post = get_post( $location_page_id ); |
|
| 1563 | + $loc_post = get_post($location_page_id); |
|
| 1564 | 1564 | $post_name = $loc_post->post_name; |
| 1565 | - $slug = ucwords( str_replace( '-', ' ', $post_name ) ); |
|
| 1566 | - $page_title = ! empty( $slug ) ? $slug : __( 'Location', 'geodirectory' ); |
|
| 1565 | + $slug = ucwords(str_replace('-', ' ', $post_name));
|
|
| 1566 | + $page_title = !empty($slug) ? $slug : __('Location', 'geodirectory');
|
|
| 1567 | 1567 | } |
| 1568 | 1568 | |
| 1569 | - $breadcrumb .= '<li>' . $separator; |
|
| 1570 | - $breadcrumb .= stripslashes_deep( $page_title ); |
|
| 1569 | + $breadcrumb .= '<li>'.$separator; |
|
| 1570 | + $breadcrumb .= stripslashes_deep($page_title); |
|
| 1571 | 1571 | $breadcrumb .= '</li>'; |
| 1572 | - } else if ( is_tag() ) {
|
|
| 1573 | - $breadcrumb .= "<li> " . $separator . single_tag_title( '', false ) . '</li>'; |
|
| 1574 | - } else if ( is_day() ) {
|
|
| 1575 | - $breadcrumb .= "<li> " . $separator . __( " Archive for", 'geodirectory' ) . " "; |
|
| 1576 | - the_time( 'F jS, Y' ); |
|
| 1572 | + } else if (is_tag()) {
|
|
| 1573 | + $breadcrumb .= "<li> ".$separator.single_tag_title('', false).'</li>';
|
|
| 1574 | + } else if (is_day()) {
|
|
| 1575 | + $breadcrumb .= "<li> ".$separator.__(" Archive for", 'geodirectory')." ";
|
|
| 1576 | + the_time('F jS, Y');
|
|
| 1577 | 1577 | $breadcrumb .= '</li>'; |
| 1578 | - } else if ( is_month() ) {
|
|
| 1579 | - $breadcrumb .= "<li> " . $separator . __( " Archive for", 'geodirectory' ) . " "; |
|
| 1580 | - the_time( 'F, Y' ); |
|
| 1578 | + } else if (is_month()) {
|
|
| 1579 | + $breadcrumb .= "<li> ".$separator.__(" Archive for", 'geodirectory')." ";
|
|
| 1580 | + the_time('F, Y');
|
|
| 1581 | 1581 | $breadcrumb .= '</li>'; |
| 1582 | - } else if ( is_year() ) {
|
|
| 1583 | - $breadcrumb .= "<li> " . $separator . __( " Archive for", 'geodirectory' ) . " "; |
|
| 1584 | - the_time( 'Y' ); |
|
| 1582 | + } else if (is_year()) {
|
|
| 1583 | + $breadcrumb .= "<li> ".$separator.__(" Archive for", 'geodirectory')." ";
|
|
| 1584 | + the_time('Y');
|
|
| 1585 | 1585 | $breadcrumb .= '</li>'; |
| 1586 | - } else if ( is_author() ) {
|
|
| 1587 | - $breadcrumb .= "<li> " . $separator . __( " Author Archive", 'geodirectory' ); |
|
| 1586 | + } else if (is_author()) {
|
|
| 1587 | + $breadcrumb .= "<li> ".$separator.__(" Author Archive", 'geodirectory');
|
|
| 1588 | 1588 | $breadcrumb .= '</li>'; |
| 1589 | - } else if ( isset( $_GET['paged'] ) && ! empty( $_GET['paged'] ) ) {
|
|
| 1590 | - $breadcrumb .= "<li>" . $separator . __( "Blog Archives", 'geodirectory' ); |
|
| 1589 | + } else if (isset($_GET['paged']) && !empty($_GET['paged'])) {
|
|
| 1590 | + $breadcrumb .= "<li>".$separator.__("Blog Archives", 'geodirectory');
|
|
| 1591 | 1591 | $breadcrumb .= '</li>'; |
| 1592 | - } else if ( is_search() ) {
|
|
| 1593 | - $breadcrumb .= "<li> " . $separator . __( " Search Results", 'geodirectory' ); |
|
| 1592 | + } else if (is_search()) {
|
|
| 1593 | + $breadcrumb .= "<li> ".$separator.__(" Search Results", 'geodirectory');
|
|
| 1594 | 1594 | $breadcrumb .= '</li>'; |
| 1595 | 1595 | } |
| 1596 | 1596 | $breadcrumb .= '</ul></div>'; |
@@ -1603,13 +1603,13 @@ discard block |
||
| 1603 | 1603 | * @param string $breadcrumb Breadcrumb HTML. |
| 1604 | 1604 | * @param string $separator Breadcrumb separator. |
| 1605 | 1605 | */ |
| 1606 | - echo $breadcrumb = apply_filters( 'geodir_breadcrumb', $breadcrumb, $separator ); |
|
| 1606 | + echo $breadcrumb = apply_filters('geodir_breadcrumb', $breadcrumb, $separator);
|
|
| 1607 | 1607 | } |
| 1608 | 1608 | } |
| 1609 | 1609 | |
| 1610 | 1610 | |
| 1611 | -add_action( "admin_init", "geodir_allow_wpadmin" ); // check user is admin |
|
| 1612 | -if ( ! function_exists( 'geodir_allow_wpadmin' ) ) {
|
|
| 1611 | +add_action("admin_init", "geodir_allow_wpadmin"); // check user is admin
|
|
| 1612 | +if (!function_exists('geodir_allow_wpadmin')) {
|
|
| 1613 | 1613 | /** |
| 1614 | 1614 | * Allow only admins to access wp-admin. |
| 1615 | 1615 | * |
@@ -1621,12 +1621,12 @@ discard block |
||
| 1621 | 1621 | */ |
| 1622 | 1622 | function geodir_allow_wpadmin() {
|
| 1623 | 1623 | global $wpdb; |
| 1624 | - if ( get_option( 'geodir_allow_wpadmin' ) == '0' && is_user_logged_in() && ( ! defined( 'DOING_AJAX' ) ) ) // checking action in request to allow ajax request go through |
|
| 1624 | + if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!defined('DOING_AJAX'))) // checking action in request to allow ajax request go through
|
|
| 1625 | 1625 | {
|
| 1626 | - if ( current_user_can( 'administrator' ) ) {
|
|
| 1626 | + if (current_user_can('administrator')) {
|
|
| 1627 | 1627 | } else {
|
| 1628 | 1628 | |
| 1629 | - wp_redirect( home_url() ); |
|
| 1629 | + wp_redirect(home_url()); |
|
| 1630 | 1630 | exit; |
| 1631 | 1631 | } |
| 1632 | 1632 | |
@@ -1645,23 +1645,23 @@ discard block |
||
| 1645 | 1645 | * |
| 1646 | 1646 | * @return array|WP_Error The uploaded data as array. When failure returns error. |
| 1647 | 1647 | */ |
| 1648 | -function fetch_remote_file( $url ) {
|
|
| 1648 | +function fetch_remote_file($url) {
|
|
| 1649 | 1649 | // extract the file name and extension from the url |
| 1650 | - require_once( ABSPATH . 'wp-includes/pluggable.php' ); |
|
| 1651 | - $file_name = basename( $url ); |
|
| 1652 | - if ( strpos( $file_name, '?' ) !== false ) {
|
|
| 1653 | - list( $file_name ) = explode( '?', $file_name ); |
|
| 1650 | + require_once(ABSPATH.'wp-includes/pluggable.php'); |
|
| 1651 | + $file_name = basename($url); |
|
| 1652 | + if (strpos($file_name, '?') !== false) {
|
|
| 1653 | + list($file_name) = explode('?', $file_name);
|
|
| 1654 | 1654 | } |
| 1655 | 1655 | $dummy = false; |
| 1656 | 1656 | $add_to_cache = false; |
| 1657 | 1657 | $key = null; |
| 1658 | - if ( strpos( $url, '/dummy/' ) !== false ) {
|
|
| 1658 | + if (strpos($url, '/dummy/') !== false) {
|
|
| 1659 | 1659 | $dummy = true; |
| 1660 | - $key = "dummy_" . str_replace( '.', '_', $file_name ); |
|
| 1661 | - $value = get_transient( 'cached_dummy_images' ); |
|
| 1662 | - if ( $value ) {
|
|
| 1663 | - if ( isset( $value[ $key ] ) ) {
|
|
| 1664 | - return $value[ $key ]; |
|
| 1660 | + $key = "dummy_".str_replace('.', '_', $file_name);
|
|
| 1661 | + $value = get_transient('cached_dummy_images');
|
|
| 1662 | + if ($value) {
|
|
| 1663 | + if (isset($value[$key])) {
|
|
| 1664 | + return $value[$key]; |
|
| 1665 | 1665 | } else {
|
| 1666 | 1666 | $add_to_cache = true; |
| 1667 | 1667 | } |
@@ -1672,58 +1672,58 @@ discard block |
||
| 1672 | 1672 | |
| 1673 | 1673 | // get placeholder file in the upload dir with a unique, sanitized filename |
| 1674 | 1674 | |
| 1675 | - $post_upload_date = isset( $post['upload_date'] ) ? $post['upload_date'] : ''; |
|
| 1675 | + $post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : ''; |
|
| 1676 | 1676 | |
| 1677 | - $upload = wp_upload_bits( $file_name, 0, '', $post_upload_date ); |
|
| 1678 | - if ( $upload['error'] ) {
|
|
| 1679 | - return new WP_Error( 'upload_dir_error', $upload['error'] ); |
|
| 1677 | + $upload = wp_upload_bits($file_name, 0, '', $post_upload_date); |
|
| 1678 | + if ($upload['error']) {
|
|
| 1679 | + return new WP_Error('upload_dir_error', $upload['error']);
|
|
| 1680 | 1680 | } |
| 1681 | 1681 | |
| 1682 | 1682 | |
| 1683 | - sleep( 0.3 );// if multiple remote file this can cause the remote server to timeout so we add a slight delay |
|
| 1683 | + sleep(0.3); // if multiple remote file this can cause the remote server to timeout so we add a slight delay |
|
| 1684 | 1684 | |
| 1685 | 1685 | // fetch the remote url and write it to the placeholder file |
| 1686 | - $headers = wp_remote_get( $url, array( 'stream' => true, 'filename' => $upload['file'] ) ); |
|
| 1686 | + $headers = wp_remote_get($url, array('stream' => true, 'filename' => $upload['file']));
|
|
| 1687 | 1687 | |
| 1688 | 1688 | $log_message = ''; |
| 1689 | - if ( is_wp_error( $headers ) ) {
|
|
| 1690 | - echo 'file: ' . $url; |
|
| 1689 | + if (is_wp_error($headers)) {
|
|
| 1690 | + echo 'file: '.$url; |
|
| 1691 | 1691 | |
| 1692 | - return new WP_Error( 'import_file_error', $headers->get_error_message() ); |
|
| 1692 | + return new WP_Error('import_file_error', $headers->get_error_message());
|
|
| 1693 | 1693 | } |
| 1694 | 1694 | |
| 1695 | - $filesize = filesize( $upload['file'] ); |
|
| 1695 | + $filesize = filesize($upload['file']); |
|
| 1696 | 1696 | // request failed |
| 1697 | - if ( ! $headers ) {
|
|
| 1698 | - $log_message = __( 'Remote server did not respond', 'geodirectory' ); |
|
| 1697 | + if (!$headers) {
|
|
| 1698 | + $log_message = __('Remote server did not respond', 'geodirectory');
|
|
| 1699 | 1699 | } // make sure the fetch was successful |
| 1700 | - elseif ( $headers['response']['code'] != '200' ) {
|
|
| 1701 | - $log_message = sprintf( __( 'Remote server returned error response %1$d %2$s', 'geodirectory' ), esc_html( $headers['response'] ), get_status_header_desc( $headers['response'] ) ); |
|
| 1702 | - } elseif ( isset( $headers['headers']['content-length'] ) && $filesize != $headers['headers']['content-length'] ) {
|
|
| 1703 | - $log_message = __( 'Remote file is incorrect size', 'geodirectory' ); |
|
| 1704 | - } elseif ( 0 == $filesize ) {
|
|
| 1705 | - $log_message = __( 'Zero size file downloaded', 'geodirectory' ); |
|
| 1706 | - } |
|
| 1707 | - |
|
| 1708 | - if ( $log_message ) {
|
|
| 1709 | - $del = unlink( $upload['file'] ); |
|
| 1710 | - if ( ! $del ) {
|
|
| 1711 | - geodir_error_log( __( 'GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory' ) ); |
|
| 1700 | + elseif ($headers['response']['code'] != '200') {
|
|
| 1701 | + $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
|
|
| 1702 | + } elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
|
|
| 1703 | + $log_message = __('Remote file is incorrect size', 'geodirectory');
|
|
| 1704 | + } elseif (0 == $filesize) {
|
|
| 1705 | + $log_message = __('Zero size file downloaded', 'geodirectory');
|
|
| 1706 | + } |
|
| 1707 | + |
|
| 1708 | + if ($log_message) {
|
|
| 1709 | + $del = unlink($upload['file']); |
|
| 1710 | + if (!$del) {
|
|
| 1711 | + geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));
|
|
| 1712 | 1712 | } |
| 1713 | 1713 | |
| 1714 | - return new WP_Error( 'import_file_error', $log_message ); |
|
| 1714 | + return new WP_Error('import_file_error', $log_message);
|
|
| 1715 | 1715 | } |
| 1716 | 1716 | |
| 1717 | - if ( $dummy && $add_to_cache && is_array( $upload ) ) {
|
|
| 1718 | - $images = get_transient( 'cached_dummy_images' ); |
|
| 1719 | - if ( is_array( $images ) ) {
|
|
| 1720 | - $images[ $key ] = $upload; |
|
| 1717 | + if ($dummy && $add_to_cache && is_array($upload)) {
|
|
| 1718 | + $images = get_transient('cached_dummy_images');
|
|
| 1719 | + if (is_array($images)) {
|
|
| 1720 | + $images[$key] = $upload; |
|
| 1721 | 1721 | } else {
|
| 1722 | - $images = array( $key => $upload ); |
|
| 1722 | + $images = array($key => $upload); |
|
| 1723 | 1723 | } |
| 1724 | 1724 | |
| 1725 | 1725 | //setting the cache using the WP Transient API |
| 1726 | - set_transient( 'cached_dummy_images', $images, 60 * 10 ); //10 minutes cache |
|
| 1726 | + set_transient('cached_dummy_images', $images, 60 * 10); //10 minutes cache
|
|
| 1727 | 1727 | } |
| 1728 | 1728 | |
| 1729 | 1729 | return $upload; |
@@ -1737,12 +1737,12 @@ discard block |
||
| 1737 | 1737 | * @return string|void Max upload size. |
| 1738 | 1738 | */ |
| 1739 | 1739 | function geodir_max_upload_size() {
|
| 1740 | - $max_filesize = (float) get_option( 'geodir_upload_max_filesize', 2 ); |
|
| 1740 | + $max_filesize = (float) get_option('geodir_upload_max_filesize', 2);
|
|
| 1741 | 1741 | |
| 1742 | - if ( $max_filesize > 0 && $max_filesize < 1 ) {
|
|
| 1743 | - $max_filesize = (int) ( $max_filesize * 1024 ) . 'kb'; |
|
| 1742 | + if ($max_filesize > 0 && $max_filesize < 1) {
|
|
| 1743 | + $max_filesize = (int) ($max_filesize * 1024).'kb'; |
|
| 1744 | 1744 | } else {
|
| 1745 | - $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb'; |
|
| 1745 | + $max_filesize = $max_filesize > 0 ? $max_filesize.'mb' : '2mb'; |
|
| 1746 | 1746 | } |
| 1747 | 1747 | |
| 1748 | 1748 | /** |
@@ -1752,7 +1752,7 @@ discard block |
||
| 1752 | 1752 | * |
| 1753 | 1753 | * @param string $max_filesize Max file upload size. Ex. 10mb, 512kb. |
| 1754 | 1754 | */ |
| 1755 | - return apply_filters( 'geodir_default_image_upload_size_limit', $max_filesize ); |
|
| 1755 | + return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
|
|
| 1756 | 1756 | } |
| 1757 | 1757 | |
| 1758 | 1758 | /** |
@@ -1765,8 +1765,8 @@ discard block |
||
| 1765 | 1765 | * @return bool If dummy folder exists returns true, else false. |
| 1766 | 1766 | */ |
| 1767 | 1767 | function geodir_dummy_folder_exists() {
|
| 1768 | - $path = geodir_plugin_path() . '/geodirectory-admin/dummy/'; |
|
| 1769 | - if ( ! is_dir( $path ) ) {
|
|
| 1768 | + $path = geodir_plugin_path().'/geodirectory-admin/dummy/'; |
|
| 1769 | + if (!is_dir($path)) {
|
|
| 1770 | 1770 | return false; |
| 1771 | 1771 | } else {
|
| 1772 | 1772 | return true; |
@@ -1785,17 +1785,17 @@ discard block |
||
| 1785 | 1785 | * |
| 1786 | 1786 | * @return object Author info. |
| 1787 | 1787 | */ |
| 1788 | -function geodir_get_author_info( $aid ) {
|
|
| 1788 | +function geodir_get_author_info($aid) {
|
|
| 1789 | 1789 | global $wpdb; |
| 1790 | 1790 | /*$infosql = "select * from $wpdb->users where ID=$aid";*/ |
| 1791 | - $infosql = $wpdb->prepare( "select * from $wpdb->users where ID=%d", array( $aid ) ); |
|
| 1792 | - $info = $wpdb->get_results( $infosql ); |
|
| 1793 | - if ( $info ) {
|
|
| 1791 | + $infosql = $wpdb->prepare("select * from $wpdb->users where ID=%d", array($aid));
|
|
| 1792 | + $info = $wpdb->get_results($infosql); |
|
| 1793 | + if ($info) {
|
|
| 1794 | 1794 | return $info[0]; |
| 1795 | 1795 | } |
| 1796 | 1796 | } |
| 1797 | 1797 | |
| 1798 | -if ( ! function_exists( 'adminEmail' ) ) {
|
|
| 1798 | +if (!function_exists('adminEmail')) {
|
|
| 1799 | 1799 | /** |
| 1800 | 1800 | * Send emails to client on post submission, renew etc. |
| 1801 | 1801 | * |
@@ -1808,67 +1808,67 @@ discard block |
||
| 1808 | 1808 | * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. |
| 1809 | 1809 | * @param string $custom_1 Custom data to be sent. |
| 1810 | 1810 | */ |
| 1811 | - function adminEmail( $page_id, $user_id, $message_type, $custom_1 = '' ) {
|
|
| 1811 | + function adminEmail($page_id, $user_id, $message_type, $custom_1 = '') {
|
|
| 1812 | 1812 | global $wpdb; |
| 1813 | - if ( $message_type == 'expiration' ) {
|
|
| 1814 | - $subject = stripslashes( __( get_option( 'renew_email_subject' ), 'geodirectory' ) ); |
|
| 1815 | - $client_message = stripslashes( __( get_option( 'renew_email_content' ), 'geodirectory' ) ); |
|
| 1816 | - } elseif ( $message_type == 'post_submited' ) {
|
|
| 1817 | - $subject = __( get_option( 'post_submited_success_email_subject_admin' ), 'geodirectory' ); |
|
| 1818 | - $client_message = __( get_option( 'post_submited_success_email_content_admin' ), 'geodirectory' ); |
|
| 1819 | - } elseif ( $message_type == 'renew' ) {
|
|
| 1820 | - $subject = __( get_option( 'post_renew_success_email_subject_admin' ), 'geodirectory' ); |
|
| 1821 | - $client_message = __( get_option( 'post_renew_success_email_content_admin' ), 'geodirectory' ); |
|
| 1822 | - } elseif ( $message_type == 'upgrade' ) {
|
|
| 1823 | - $subject = __( get_option( 'post_upgrade_success_email_subject_admin' ), 'geodirectory' ); |
|
| 1824 | - $client_message = __( get_option( 'post_upgrade_success_email_content_admin' ), 'geodirectory' ); |
|
| 1825 | - } elseif ( $message_type == 'claim_approved' ) {
|
|
| 1826 | - $subject = __( get_option( 'claim_approved_email_subject' ), 'geodirectory' ); |
|
| 1827 | - $client_message = __( get_option( 'claim_approved_email_content' ), 'geodirectory' ); |
|
| 1828 | - } elseif ( $message_type == 'claim_rejected' ) {
|
|
| 1829 | - $subject = __( get_option( 'claim_rejected_email_subject' ), 'geodirectory' ); |
|
| 1830 | - $client_message = __( get_option( 'claim_rejected_email_content' ), 'geodirectory' ); |
|
| 1831 | - } elseif ( $message_type == 'claim_requested' ) {
|
|
| 1832 | - $subject = __( get_option( 'claim_email_subject_admin' ), 'geodirectory' ); |
|
| 1833 | - $client_message = __( get_option( 'claim_email_content_admin' ), 'geodirectory' ); |
|
| 1834 | - } elseif ( $message_type == 'auto_claim' ) {
|
|
| 1835 | - $subject = __( get_option( 'auto_claim_email_subject' ), 'geodirectory' ); |
|
| 1836 | - $client_message = __( get_option( 'auto_claim_email_content' ), 'geodirectory' ); |
|
| 1837 | - } elseif ( $message_type == 'payment_success' ) {
|
|
| 1838 | - $subject = __( get_option( 'post_payment_success_admin_email_subject' ), 'geodirectory' ); |
|
| 1839 | - $client_message = __( get_option( 'post_payment_success_admin_email_content' ), 'geodirectory' ); |
|
| 1840 | - } elseif ( $message_type == 'payment_fail' ) {
|
|
| 1841 | - $subject = __( get_option( 'post_payment_fail_admin_email_subject' ), 'geodirectory' ); |
|
| 1842 | - $client_message = __( get_option( 'post_payment_fail_admin_email_content' ), 'geodirectory' ); |
|
| 1813 | + if ($message_type == 'expiration') {
|
|
| 1814 | + $subject = stripslashes(__(get_option('renew_email_subject'), 'geodirectory'));
|
|
| 1815 | + $client_message = stripslashes(__(get_option('renew_email_content'), 'geodirectory'));
|
|
| 1816 | + } elseif ($message_type == 'post_submited') {
|
|
| 1817 | + $subject = __(get_option('post_submited_success_email_subject_admin'), 'geodirectory');
|
|
| 1818 | + $client_message = __(get_option('post_submited_success_email_content_admin'), 'geodirectory');
|
|
| 1819 | + } elseif ($message_type == 'renew') {
|
|
| 1820 | + $subject = __(get_option('post_renew_success_email_subject_admin'), 'geodirectory');
|
|
| 1821 | + $client_message = __(get_option('post_renew_success_email_content_admin'), 'geodirectory');
|
|
| 1822 | + } elseif ($message_type == 'upgrade') {
|
|
| 1823 | + $subject = __(get_option('post_upgrade_success_email_subject_admin'), 'geodirectory');
|
|
| 1824 | + $client_message = __(get_option('post_upgrade_success_email_content_admin'), 'geodirectory');
|
|
| 1825 | + } elseif ($message_type == 'claim_approved') {
|
|
| 1826 | + $subject = __(get_option('claim_approved_email_subject'), 'geodirectory');
|
|
| 1827 | + $client_message = __(get_option('claim_approved_email_content'), 'geodirectory');
|
|
| 1828 | + } elseif ($message_type == 'claim_rejected') {
|
|
| 1829 | + $subject = __(get_option('claim_rejected_email_subject'), 'geodirectory');
|
|
| 1830 | + $client_message = __(get_option('claim_rejected_email_content'), 'geodirectory');
|
|
| 1831 | + } elseif ($message_type == 'claim_requested') {
|
|
| 1832 | + $subject = __(get_option('claim_email_subject_admin'), 'geodirectory');
|
|
| 1833 | + $client_message = __(get_option('claim_email_content_admin'), 'geodirectory');
|
|
| 1834 | + } elseif ($message_type == 'auto_claim') {
|
|
| 1835 | + $subject = __(get_option('auto_claim_email_subject'), 'geodirectory');
|
|
| 1836 | + $client_message = __(get_option('auto_claim_email_content'), 'geodirectory');
|
|
| 1837 | + } elseif ($message_type == 'payment_success') {
|
|
| 1838 | + $subject = __(get_option('post_payment_success_admin_email_subject'), 'geodirectory');
|
|
| 1839 | + $client_message = __(get_option('post_payment_success_admin_email_content'), 'geodirectory');
|
|
| 1840 | + } elseif ($message_type == 'payment_fail') {
|
|
| 1841 | + $subject = __(get_option('post_payment_fail_admin_email_subject'), 'geodirectory');
|
|
| 1842 | + $client_message = __(get_option('post_payment_fail_admin_email_content'), 'geodirectory');
|
|
| 1843 | 1843 | } |
| 1844 | 1844 | $transaction_details = $custom_1; |
| 1845 | - $fromEmail = get_option( 'site_email' ); |
|
| 1845 | + $fromEmail = get_option('site_email');
|
|
| 1846 | 1846 | $fromEmailName = get_site_emailName(); |
| 1847 | 1847 | //$alivedays = get_post_meta($page_id,'alive_days',true); |
| 1848 | - $pkg_limit = get_property_price_info_listing( $page_id ); |
|
| 1848 | + $pkg_limit = get_property_price_info_listing($page_id); |
|
| 1849 | 1849 | $alivedays = $pkg_limit['days']; |
| 1850 | - $productlink = get_permalink( $page_id ); |
|
| 1851 | - $post_info = get_post( $page_id ); |
|
| 1852 | - $post_date = date( 'dS F,Y', strtotime( $post_info->post_date ) ); |
|
| 1853 | - $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>'; |
|
| 1850 | + $productlink = get_permalink($page_id); |
|
| 1851 | + $post_info = get_post($page_id); |
|
| 1852 | + $post_date = date('dS F,Y', strtotime($post_info->post_date));
|
|
| 1853 | + $listingLink = '<a href="'.$productlink.'"><b>'.$post_info->post_title.'</b></a>'; |
|
| 1854 | 1854 | $loginurl = geodir_login_url(); |
| 1855 | - $loginurl_link = '<a href="' . $loginurl . '">login</a>'; |
|
| 1855 | + $loginurl_link = '<a href="'.$loginurl.'">login</a>'; |
|
| 1856 | 1856 | $siteurl = home_url(); |
| 1857 | - $siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>'; |
|
| 1858 | - $user_info = get_userdata( $user_id ); |
|
| 1857 | + $siteurl_link = '<a href="'.$siteurl.'">'.$fromEmailName.'</a>'; |
|
| 1858 | + $user_info = get_userdata($user_id); |
|
| 1859 | 1859 | $user_email = $user_info->user_email; |
| 1860 | - $display_name = geodir_get_client_name( $user_id ); |
|
| 1860 | + $display_name = geodir_get_client_name($user_id); |
|
| 1861 | 1861 | $user_login = $user_info->user_login; |
| 1862 | - $number_of_grace_days = get_option( 'ptthemes_listing_preexpiry_notice_days' ); |
|
| 1863 | - if ( $number_of_grace_days == '' ) {
|
|
| 1862 | + $number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
|
|
| 1863 | + if ($number_of_grace_days == '') {
|
|
| 1864 | 1864 | $number_of_grace_days = 1; |
| 1865 | 1865 | } |
| 1866 | - if ( $post_info->post_type == 'event' ) {
|
|
| 1866 | + if ($post_info->post_type == 'event') {
|
|
| 1867 | 1867 | $post_type = 'event'; |
| 1868 | 1868 | } else {
|
| 1869 | 1869 | $post_type = 'listing'; |
| 1870 | 1870 | } |
| 1871 | - $renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>'; |
|
| 1871 | + $renew_link = '<a href="'.$siteurl.'?ptype=post_'.$post_type.'&renew=1&pid='.$page_id.'">'.RENEW_LINK.'</a>'; |
|
| 1872 | 1872 | $search_array = array( |
| 1873 | 1873 | '[#client_name#]', |
| 1874 | 1874 | '[#listing_link#]', |
@@ -1884,7 +1884,7 @@ discard block |
||
| 1884 | 1884 | '[#site_name#]', |
| 1885 | 1885 | '[#transaction_details#]' |
| 1886 | 1886 | ); |
| 1887 | - $replace_array = array( |
|
| 1887 | + $replace_array = array( |
|
| 1888 | 1888 | $display_name, |
| 1889 | 1889 | $listingLink, |
| 1890 | 1890 | $post_date, |
@@ -1899,13 +1899,13 @@ discard block |
||
| 1899 | 1899 | $fromEmailName, |
| 1900 | 1900 | $transaction_details |
| 1901 | 1901 | ); |
| 1902 | - $client_message = str_replace( $search_array, $replace_array, $client_message ); |
|
| 1903 | - $subject = str_replace( $search_array, $replace_array, $subject ); |
|
| 1902 | + $client_message = str_replace($search_array, $replace_array, $client_message); |
|
| 1903 | + $subject = str_replace($search_array, $replace_array, $subject); |
|
| 1904 | 1904 | |
| 1905 | 1905 | |
| 1906 | - $headers = array(); |
|
| 1906 | + $headers = array(); |
|
| 1907 | 1907 | $headers[] = 'Content-type: text/html; charset=UTF-8'; |
| 1908 | - $headers[] = 'From: ' . $fromEmailName . ' <' . $fromEmail . '>'; |
|
| 1908 | + $headers[] = 'From: '.$fromEmailName.' <'.$fromEmail.'>'; |
|
| 1909 | 1909 | |
| 1910 | 1910 | $to = $fromEmail; |
| 1911 | 1911 | $message = $client_message; |
@@ -1923,7 +1923,7 @@ discard block |
||
| 1923 | 1923 | * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. |
| 1924 | 1924 | * @param string $custom_1 Custom data to be sent. |
| 1925 | 1925 | */ |
| 1926 | - $to = apply_filters( 'geodir_adminEmail_to', $to, $page_id, $user_id, $message_type, $custom_1 ); |
|
| 1926 | + $to = apply_filters('geodir_adminEmail_to', $to, $page_id, $user_id, $message_type, $custom_1);
|
|
| 1927 | 1927 | /** |
| 1928 | 1928 | * Filter the admin email subject. |
| 1929 | 1929 | * |
@@ -1936,7 +1936,7 @@ discard block |
||
| 1936 | 1936 | * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. |
| 1937 | 1937 | * @param string $custom_1 Custom data to be sent. |
| 1938 | 1938 | */ |
| 1939 | - $subject = apply_filters( 'geodir_adminEmail_subject', $subject, $page_id, $user_id, $message_type, $custom_1 ); |
|
| 1939 | + $subject = apply_filters('geodir_adminEmail_subject', $subject, $page_id, $user_id, $message_type, $custom_1);
|
|
| 1940 | 1940 | /** |
| 1941 | 1941 | * Filter the admin email message. |
| 1942 | 1942 | * |
@@ -1949,7 +1949,7 @@ discard block |
||
| 1949 | 1949 | * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. |
| 1950 | 1950 | * @param string $custom_1 Custom data to be sent. |
| 1951 | 1951 | */ |
| 1952 | - $message = apply_filters( 'geodir_adminEmail_message', $message, $page_id, $user_id, $message_type, $custom_1 ); |
|
| 1952 | + $message = apply_filters('geodir_adminEmail_message', $message, $page_id, $user_id, $message_type, $custom_1);
|
|
| 1953 | 1953 | /** |
| 1954 | 1954 | * Filter the admin email headers. |
| 1955 | 1955 | * |
@@ -1962,22 +1962,22 @@ discard block |
||
| 1962 | 1962 | * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. |
| 1963 | 1963 | * @param string $custom_1 Custom data to be sent. |
| 1964 | 1964 | */ |
| 1965 | - $headers = apply_filters( 'geodir_adminEmail_headers', $headers, $page_id, $user_id, $message_type, $custom_1 ); |
|
| 1965 | + $headers = apply_filters('geodir_adminEmail_headers', $headers, $page_id, $user_id, $message_type, $custom_1);
|
|
| 1966 | 1966 | |
| 1967 | 1967 | |
| 1968 | - $sent = wp_mail( $to, $subject, $message, $headers ); |
|
| 1969 | - if ( ! $sent ) {
|
|
| 1970 | - if ( is_array( $to ) ) {
|
|
| 1971 | - $to = implode( ',', $to ); |
|
| 1968 | + $sent = wp_mail($to, $subject, $message, $headers); |
|
| 1969 | + if (!$sent) {
|
|
| 1970 | + if (is_array($to)) {
|
|
| 1971 | + $to = implode(',', $to);
|
|
| 1972 | 1972 | } |
| 1973 | 1973 | $log_message = sprintf( |
| 1974 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 1974 | + __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
|
|
| 1975 | 1975 | $message_type, |
| 1976 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 1976 | + date_i18n('F j Y H:i:s', current_time('timestamp')),
|
|
| 1977 | 1977 | $to, |
| 1978 | 1978 | $subject |
| 1979 | 1979 | ); |
| 1980 | - geodir_error_log( $log_message ); |
|
| 1980 | + geodir_error_log($log_message); |
|
| 1981 | 1981 | } |
| 1982 | 1982 | } |
| 1983 | 1983 | } |
@@ -1997,12 +1997,12 @@ discard block |
||
| 1997 | 1997 | * |
| 1998 | 1998 | * @return array Category IDs. |
| 1999 | 1999 | */ |
| 2000 | -function gd_lang_object_ids( $ids_array, $type ) {
|
|
| 2001 | - if ( function_exists( 'icl_object_id' ) ) {
|
|
| 2000 | +function gd_lang_object_ids($ids_array, $type) {
|
|
| 2001 | + if (function_exists('icl_object_id')) {
|
|
| 2002 | 2002 | $res = array(); |
| 2003 | - foreach ( $ids_array as $id ) {
|
|
| 2004 | - $xlat = icl_object_id( $id, $type, false ); |
|
| 2005 | - if ( ! is_null( $xlat ) ) {
|
|
| 2003 | + foreach ($ids_array as $id) {
|
|
| 2004 | + $xlat = icl_object_id($id, $type, false); |
|
| 2005 | + if (!is_null($xlat)) {
|
|
| 2006 | 2006 | $res[] = $xlat; |
| 2007 | 2007 | } |
| 2008 | 2008 | } |
@@ -2026,20 +2026,20 @@ discard block |
||
| 2026 | 2026 | * |
| 2027 | 2027 | * @return array Modified Body CSS classes. |
| 2028 | 2028 | */ |
| 2029 | -function geodir_custom_posts_body_class( $classes ) {
|
|
| 2029 | +function geodir_custom_posts_body_class($classes) {
|
|
| 2030 | 2030 | global $wpdb, $wp; |
| 2031 | - $post_types = geodir_get_posttypes( 'object' ); |
|
| 2032 | - if ( ! empty( $post_types ) && count( (array) $post_types ) > 1 ) {
|
|
| 2031 | + $post_types = geodir_get_posttypes('object');
|
|
| 2032 | + if (!empty($post_types) && count((array) $post_types) > 1) {
|
|
| 2033 | 2033 | $classes[] = 'geodir_custom_posts'; |
| 2034 | 2034 | } |
| 2035 | 2035 | |
| 2036 | 2036 | // fix body class for signup page |
| 2037 | - if ( geodir_is_page( 'login' ) ) {
|
|
| 2037 | + if (geodir_is_page('login')) {
|
|
| 2038 | 2038 | $new_classes = array(); |
| 2039 | 2039 | $new_classes[] = 'signup page-geodir-signup'; |
| 2040 | - if ( ! empty( $classes ) ) {
|
|
| 2041 | - foreach ( $classes as $class ) {
|
|
| 2042 | - if ( $class && $class != 'home' && $class != 'blog' ) {
|
|
| 2040 | + if (!empty($classes)) {
|
|
| 2041 | + foreach ($classes as $class) {
|
|
| 2042 | + if ($class && $class != 'home' && $class != 'blog') {
|
|
| 2043 | 2043 | $new_classes[] = $class; |
| 2044 | 2044 | } |
| 2045 | 2045 | } |
@@ -2047,14 +2047,14 @@ discard block |
||
| 2047 | 2047 | $classes = $new_classes; |
| 2048 | 2048 | } |
| 2049 | 2049 | |
| 2050 | - if ( geodir_is_geodir_page() ) {
|
|
| 2050 | + if (geodir_is_geodir_page()) {
|
|
| 2051 | 2051 | $classes[] = 'geodir-page'; |
| 2052 | 2052 | } |
| 2053 | 2053 | |
| 2054 | 2054 | return $classes; |
| 2055 | 2055 | } |
| 2056 | 2056 | |
| 2057 | -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 |
|
| 2057 | +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
|
|
| 2058 | 2058 | |
| 2059 | 2059 | |
| 2060 | 2060 | /** |
@@ -2070,7 +2070,7 @@ discard block |
||
| 2070 | 2070 | * |
| 2071 | 2071 | * @since 1.0.0 |
| 2072 | 2072 | */ |
| 2073 | - return apply_filters( 'geodir_map_zoom_level', array( |
|
| 2073 | + return apply_filters('geodir_map_zoom_level', array(
|
|
| 2074 | 2074 | 1, |
| 2075 | 2075 | 2, |
| 2076 | 2076 | 3, |
@@ -2090,7 +2090,7 @@ discard block |
||
| 2090 | 2090 | 17, |
| 2091 | 2091 | 18, |
| 2092 | 2092 | 19 |
| 2093 | - ) ); |
|
| 2093 | + )); |
|
| 2094 | 2094 | |
| 2095 | 2095 | } |
| 2096 | 2096 | |
@@ -2103,12 +2103,12 @@ discard block |
||
| 2103 | 2103 | * |
| 2104 | 2104 | * @param string $geodir_option_name Option key. |
| 2105 | 2105 | */ |
| 2106 | -function geodir_option_version_backup( $geodir_option_name ) {
|
|
| 2106 | +function geodir_option_version_backup($geodir_option_name) {
|
|
| 2107 | 2107 | $version_date = time(); |
| 2108 | - $geodir_option = get_option( $geodir_option_name ); |
|
| 2108 | + $geodir_option = get_option($geodir_option_name); |
|
| 2109 | 2109 | |
| 2110 | - if ( ! empty( $geodir_option ) ) {
|
|
| 2111 | - add_option( $geodir_option_name . '_' . $version_date, $geodir_option ); |
|
| 2110 | + if (!empty($geodir_option)) {
|
|
| 2111 | + add_option($geodir_option_name.'_'.$version_date, $geodir_option); |
|
| 2112 | 2112 | } |
| 2113 | 2113 | } |
| 2114 | 2114 | |
@@ -2122,10 +2122,10 @@ discard block |
||
| 2122 | 2122 | * |
| 2123 | 2123 | * @return int Page ID. |
| 2124 | 2124 | */ |
| 2125 | -function get_page_id_geodir_add_listing_page( $page_id ) {
|
|
| 2126 | - if ( geodir_wpml_multilingual_status() ) {
|
|
| 2125 | +function get_page_id_geodir_add_listing_page($page_id) {
|
|
| 2126 | + if (geodir_wpml_multilingual_status()) {
|
|
| 2127 | 2127 | $post_type = 'post_page'; |
| 2128 | - $page_id = geodir_get_wpml_element_id( $page_id, $post_type ); |
|
| 2128 | + $page_id = geodir_get_wpml_element_id($page_id, $post_type); |
|
| 2129 | 2129 | } |
| 2130 | 2130 | |
| 2131 | 2131 | return $page_id; |
@@ -2139,7 +2139,7 @@ discard block |
||
| 2139 | 2139 | * @return bool Returns true when sitepress multilingual CMS active. else returns false. |
| 2140 | 2140 | */ |
| 2141 | 2141 | function geodir_wpml_multilingual_status() {
|
| 2142 | - if ( function_exists( 'icl_object_id' ) ) {
|
|
| 2142 | + if (function_exists('icl_object_id')) {
|
|
| 2143 | 2143 | return true; |
| 2144 | 2144 | } |
| 2145 | 2145 | |
@@ -2157,19 +2157,19 @@ discard block |
||
| 2157 | 2157 | * |
| 2158 | 2158 | * @return int Element ID when exists. Else the page id. |
| 2159 | 2159 | */ |
| 2160 | -function geodir_get_wpml_element_id( $page_id, $post_type ) {
|
|
| 2160 | +function geodir_get_wpml_element_id($page_id, $post_type) {
|
|
| 2161 | 2161 | global $sitepress; |
| 2162 | - if ( geodir_wpml_multilingual_status() && ! empty( $sitepress ) && isset( $sitepress->queries ) ) {
|
|
| 2163 | - $trid = $sitepress->get_element_trid( $page_id, $post_type ); |
|
| 2162 | + if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
|
|
| 2163 | + $trid = $sitepress->get_element_trid($page_id, $post_type); |
|
| 2164 | 2164 | |
| 2165 | - if ( $trid > 0 ) {
|
|
| 2166 | - $translations = $sitepress->get_element_translations( $trid, $post_type ); |
|
| 2165 | + if ($trid > 0) {
|
|
| 2166 | + $translations = $sitepress->get_element_translations($trid, $post_type); |
|
| 2167 | 2167 | |
| 2168 | 2168 | $lang = $sitepress->get_current_language(); |
| 2169 | 2169 | $lang = $lang ? $lang : $sitepress->get_default_language(); |
| 2170 | 2170 | |
| 2171 | - if ( ! empty( $translations ) && ! empty( $lang ) && isset( $translations[ $lang ] ) && isset( $translations[ $lang ]->element_id ) && ! empty( $translations[ $lang ]->element_id ) ) {
|
|
| 2172 | - $page_id = $translations[ $lang ]->element_id; |
|
| 2171 | + if (!empty($translations) && !empty($lang) && isset($translations[$lang]) && isset($translations[$lang]->element_id) && !empty($translations[$lang]->element_id)) {
|
|
| 2172 | + $page_id = $translations[$lang]->element_id; |
|
| 2173 | 2173 | } |
| 2174 | 2174 | } |
| 2175 | 2175 | } |
@@ -2186,15 +2186,15 @@ discard block |
||
| 2186 | 2186 | */ |
| 2187 | 2187 | function geodir_wpml_check_element_id() {
|
| 2188 | 2188 | global $sitepress; |
| 2189 | - if ( geodir_wpml_multilingual_status() && ! empty( $sitepress ) && isset( $sitepress->queries ) ) {
|
|
| 2189 | + if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
|
|
| 2190 | 2190 | $el_type = 'post_page'; |
| 2191 | - $el_id = get_option( 'geodir_add_listing_page' ); |
|
| 2191 | + $el_id = get_option('geodir_add_listing_page');
|
|
| 2192 | 2192 | $default_lang = $sitepress->get_default_language(); |
| 2193 | - $el_details = $sitepress->get_element_language_details( $el_id, $el_type ); |
|
| 2193 | + $el_details = $sitepress->get_element_language_details($el_id, $el_type); |
|
| 2194 | 2194 | |
| 2195 | - if ( ! ( $el_id > 0 && $default_lang && ! empty( $el_details ) && isset( $el_details->language_code ) && $el_details->language_code == $default_lang ) ) {
|
|
| 2196 | - if ( ! $el_details->source_language_code ) {
|
|
| 2197 | - $sitepress->set_element_language_details( $el_id, $el_type, '', $default_lang ); |
|
| 2195 | + if (!($el_id > 0 && $default_lang && !empty($el_details) && isset($el_details->language_code) && $el_details->language_code == $default_lang)) {
|
|
| 2196 | + if (!$el_details->source_language_code) {
|
|
| 2197 | + $sitepress->set_element_language_details($el_id, $el_type, '', $default_lang); |
|
| 2198 | 2198 | $sitepress->icl_translations_cache->clear(); |
| 2199 | 2199 | } |
| 2200 | 2200 | } |
@@ -2213,41 +2213,41 @@ discard block |
||
| 2213 | 2213 | * |
| 2214 | 2214 | * @return string Orderby SQL. |
| 2215 | 2215 | */ |
| 2216 | -function geodir_widget_listings_get_order( $query_args ) {
|
|
| 2216 | +function geodir_widget_listings_get_order($query_args) {
|
|
| 2217 | 2217 | global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
| 2218 | 2218 | |
| 2219 | 2219 | $query_args = $gd_query_args_widgets; |
| 2220 | - if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) {
|
|
| 2221 | - return $wpdb->posts . ".post_date DESC, "; |
|
| 2220 | + if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 2221 | + return $wpdb->posts.".post_date DESC, "; |
|
| 2222 | 2222 | } |
| 2223 | 2223 | |
| 2224 | - $post_type = empty( $query_args['post_type'] ) ? 'gd_place' : $query_args['post_type']; |
|
| 2225 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2224 | + $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
|
| 2225 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 2226 | 2226 | |
| 2227 | - $sort_by = ! empty( $query_args['order_by'] ) ? $query_args['order_by'] : ''; |
|
| 2227 | + $sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : ''; |
|
| 2228 | 2228 | |
| 2229 | - switch ( $sort_by ) {
|
|
| 2229 | + switch ($sort_by) {
|
|
| 2230 | 2230 | case 'latest': |
| 2231 | 2231 | case 'newest': |
| 2232 | - $orderby = $wpdb->posts . ".post_date DESC, "; |
|
| 2232 | + $orderby = $wpdb->posts.".post_date DESC, "; |
|
| 2233 | 2233 | break; |
| 2234 | 2234 | case 'featured': |
| 2235 | - $orderby = $table . ".is_featured ASC, ". $wpdb->posts . ".post_date DESC, "; |
|
| 2235 | + $orderby = $table.".is_featured ASC, ".$wpdb->posts.".post_date DESC, "; |
|
| 2236 | 2236 | break; |
| 2237 | 2237 | case 'az': |
| 2238 | - $orderby = $wpdb->posts . ".post_title ASC, "; |
|
| 2238 | + $orderby = $wpdb->posts.".post_title ASC, "; |
|
| 2239 | 2239 | break; |
| 2240 | 2240 | case 'high_review': |
| 2241 | - $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, "; |
|
| 2241 | + $orderby = $table.".rating_count DESC, ".$table.".overall_rating DESC, "; |
|
| 2242 | 2242 | break; |
| 2243 | 2243 | case 'high_rating': |
| 2244 | - $orderby = "( " . $table . ".overall_rating ) DESC, "; |
|
| 2244 | + $orderby = "( ".$table.".overall_rating ) DESC, "; |
|
| 2245 | 2245 | break; |
| 2246 | 2246 | case 'random': |
| 2247 | 2247 | $orderby = "RAND(), "; |
| 2248 | 2248 | break; |
| 2249 | 2249 | default: |
| 2250 | - $orderby = $wpdb->posts . ".post_title ASC, "; |
|
| 2250 | + $orderby = $wpdb->posts.".post_title ASC, "; |
|
| 2251 | 2251 | break; |
| 2252 | 2252 | } |
| 2253 | 2253 | |
@@ -2270,15 +2270,15 @@ discard block |
||
| 2270 | 2270 | * |
| 2271 | 2271 | * @return mixed Result object. |
| 2272 | 2272 | */ |
| 2273 | -function geodir_get_widget_listings( $query_args = array(), $count_only = false ) {
|
|
| 2273 | +function geodir_get_widget_listings($query_args = array(), $count_only = false) {
|
|
| 2274 | 2274 | global $wpdb, $plugin_prefix, $table_prefix; |
| 2275 | 2275 | $GLOBALS['gd_query_args_widgets'] = $query_args; |
| 2276 | 2276 | $gd_query_args_widgets = $query_args; |
| 2277 | 2277 | |
| 2278 | - $post_type = empty( $query_args['post_type'] ) ? 'gd_place' : $query_args['post_type']; |
|
| 2279 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2278 | + $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
|
| 2279 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 2280 | 2280 | |
| 2281 | - $fields = $wpdb->posts . ".*, " . $table . ".*"; |
|
| 2281 | + $fields = $wpdb->posts.".*, ".$table.".*"; |
|
| 2282 | 2282 | /** |
| 2283 | 2283 | * Filter widget listing fields string part that is being used for query. |
| 2284 | 2284 | * |
@@ -2288,17 +2288,17 @@ discard block |
||
| 2288 | 2288 | * @param string $table Table name. |
| 2289 | 2289 | * @param string $post_type Post type. |
| 2290 | 2290 | */ |
| 2291 | - $fields = apply_filters( 'geodir_filter_widget_listings_fields', $fields, $table, $post_type ); |
|
| 2291 | + $fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
|
|
| 2292 | 2292 | |
| 2293 | - $join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
|
|
| 2293 | + $join = "INNER JOIN ".$table." ON (".$table.".post_id = ".$wpdb->posts.".ID)";
|
|
| 2294 | 2294 | |
| 2295 | 2295 | ########### WPML ########### |
| 2296 | 2296 | |
| 2297 | - if ( function_exists( 'icl_object_id' ) ) {
|
|
| 2297 | + if (function_exists('icl_object_id')) {
|
|
| 2298 | 2298 | global $sitepress; |
| 2299 | 2299 | $lang_code = ICL_LANGUAGE_CODE; |
| 2300 | - if ( $lang_code ) {
|
|
| 2301 | - $join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID"; |
|
| 2300 | + if ($lang_code) {
|
|
| 2301 | + $join .= " JOIN ".$table_prefix."icl_translations icl_t ON icl_t.element_id = ".$table_prefix."posts.ID"; |
|
| 2302 | 2302 | } |
| 2303 | 2303 | } |
| 2304 | 2304 | |
@@ -2312,15 +2312,15 @@ discard block |
||
| 2312 | 2312 | * @param string $join Join clause string. |
| 2313 | 2313 | * @param string $post_type Post type. |
| 2314 | 2314 | */ |
| 2315 | - $join = apply_filters( 'geodir_filter_widget_listings_join', $join, $post_type ); |
|
| 2315 | + $join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
|
|
| 2316 | 2316 | |
| 2317 | - $post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : ''; |
|
| 2317 | + $post_status = is_super_admin() ? " OR ".$wpdb->posts.".post_status = 'private'" : ''; |
|
| 2318 | 2318 | |
| 2319 | - $where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'"; |
|
| 2319 | + $where = " AND ( ".$wpdb->posts.".post_status = 'publish' ".$post_status." ) AND ".$wpdb->posts.".post_type = '".$post_type."'"; |
|
| 2320 | 2320 | |
| 2321 | 2321 | ########### WPML ########### |
| 2322 | - if ( function_exists( 'icl_object_id' ) ) {
|
|
| 2323 | - if ( $lang_code ) {
|
|
| 2322 | + if (function_exists('icl_object_id')) {
|
|
| 2323 | + if ($lang_code) {
|
|
| 2324 | 2324 | $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type = 'post_$post_type' "; |
| 2325 | 2325 | } |
| 2326 | 2326 | } |
@@ -2333,8 +2333,8 @@ discard block |
||
| 2333 | 2333 | * @param string $where Where clause string. |
| 2334 | 2334 | * @param string $post_type Post type. |
| 2335 | 2335 | */ |
| 2336 | - $where = apply_filters( 'geodir_filter_widget_listings_where', $where, $post_type ); |
|
| 2337 | - $where = $where != '' ? " WHERE 1=1 " . $where : ''; |
|
| 2336 | + $where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
|
|
| 2337 | + $where = $where != '' ? " WHERE 1=1 ".$where : ''; |
|
| 2338 | 2338 | |
| 2339 | 2339 | $groupby = " GROUP BY $wpdb->posts.ID "; //@todo is this needed? faster withotu |
| 2340 | 2340 | /** |
@@ -2345,15 +2345,15 @@ discard block |
||
| 2345 | 2345 | * @param string $groupby Group by clause string. |
| 2346 | 2346 | * @param string $post_type Post type. |
| 2347 | 2347 | */ |
| 2348 | - $groupby = apply_filters( 'geodir_filter_widget_listings_groupby', $groupby, $post_type ); |
|
| 2348 | + $groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
|
|
| 2349 | 2349 | |
| 2350 | - if ( $count_only ) {
|
|
| 2351 | - $sql = "SELECT COUNT(DISTINCT " . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . " |
|
| 2352 | - " . $join . " |
|
| 2350 | + if ($count_only) {
|
|
| 2351 | + $sql = "SELECT COUNT(DISTINCT ".$wpdb->posts.".ID) AS total FROM ".$wpdb->posts." |
|
| 2352 | + " . $join." |
|
| 2353 | 2353 | " . $where; |
| 2354 | - $rows = (int) $wpdb->get_var( $sql ); |
|
| 2354 | + $rows = (int) $wpdb->get_var($sql); |
|
| 2355 | 2355 | } else {
|
| 2356 | - $orderby = geodir_widget_listings_get_order( $query_args ); |
|
| 2356 | + $orderby = geodir_widget_listings_get_order($query_args); |
|
| 2357 | 2357 | /** |
| 2358 | 2358 | * Filter widget listing orderby clause string part that is being used for query. |
| 2359 | 2359 | * |
@@ -2363,11 +2363,11 @@ discard block |
||
| 2363 | 2363 | * @param string $table Table name. |
| 2364 | 2364 | * @param string $post_type Post type. |
| 2365 | 2365 | */ |
| 2366 | - $orderby = apply_filters( 'geodir_filter_widget_listings_orderby', $orderby, $table, $post_type ); |
|
| 2367 | - $orderby .= $wpdb->posts . ".post_title ASC"; |
|
| 2368 | - $orderby = $orderby != '' ? " ORDER BY " . $orderby : ''; |
|
| 2366 | + $orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
|
|
| 2367 | + $orderby .= $wpdb->posts.".post_title ASC"; |
|
| 2368 | + $orderby = $orderby != '' ? " ORDER BY ".$orderby : ''; |
|
| 2369 | 2369 | |
| 2370 | - $limit = ! empty( $query_args['posts_per_page'] ) ? $query_args['posts_per_page'] : 5; |
|
| 2370 | + $limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5; |
|
| 2371 | 2371 | /** |
| 2372 | 2372 | * Filter widget listing limit that is being used for query. |
| 2373 | 2373 | * |
@@ -2376,27 +2376,27 @@ discard block |
||
| 2376 | 2376 | * @param int $limit Query results limit. |
| 2377 | 2377 | * @param string $post_type Post type. |
| 2378 | 2378 | */ |
| 2379 | - $limit = apply_filters( 'geodir_filter_widget_listings_limit', $limit, $post_type ); |
|
| 2379 | + $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
|
|
| 2380 | 2380 | |
| 2381 | - $page = ! empty( $query_args['pageno'] ) ? absint( $query_args['pageno'] ) : 1; |
|
| 2382 | - if ( ! $page ) {
|
|
| 2381 | + $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1; |
|
| 2382 | + if (!$page) {
|
|
| 2383 | 2383 | $page = 1; |
| 2384 | 2384 | } |
| 2385 | 2385 | |
| 2386 | - $limit = (int) $limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int) $limit ) . ", " . (int) $limit : ""; |
|
| 2386 | + $limit = (int) $limit > 0 ? " LIMIT ".absint(($page - 1) * (int) $limit).", ".(int) $limit : ""; |
|
| 2387 | 2387 | |
| 2388 | 2388 | //@todo removed SQL_CALC_FOUND_ROWS from below as don't think it is needed and query is faster without |
| 2389 | - $sql = "SELECT " . $fields . " FROM " . $wpdb->posts . " |
|
| 2390 | - " . $join . " |
|
| 2391 | - " . $where . " |
|
| 2392 | - " . $groupby . " |
|
| 2393 | - " . $orderby . " |
|
| 2389 | + $sql = "SELECT ".$fields." FROM ".$wpdb->posts." |
|
| 2390 | + " . $join." |
|
| 2391 | + " . $where." |
|
| 2392 | + " . $groupby." |
|
| 2393 | + " . $orderby." |
|
| 2394 | 2394 | " . $limit; |
| 2395 | - $rows = $wpdb->get_results( $sql ); |
|
| 2395 | + $rows = $wpdb->get_results($sql); |
|
| 2396 | 2396 | } |
| 2397 | 2397 | |
| 2398 | - unset( $GLOBALS['gd_query_args_widgets'] ); |
|
| 2399 | - unset( $gd_query_args_widgets ); |
|
| 2398 | + unset($GLOBALS['gd_query_args_widgets']); |
|
| 2399 | + unset($gd_query_args_widgets); |
|
| 2400 | 2400 | |
| 2401 | 2401 | return $rows; |
| 2402 | 2402 | } |
@@ -2413,11 +2413,11 @@ discard block |
||
| 2413 | 2413 | * |
| 2414 | 2414 | * @return string Modified fields SQL. |
| 2415 | 2415 | */ |
| 2416 | -function geodir_function_widget_listings_fields( $fields ) {
|
|
| 2416 | +function geodir_function_widget_listings_fields($fields) {
|
|
| 2417 | 2417 | global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
| 2418 | 2418 | |
| 2419 | 2419 | $query_args = $gd_query_args_widgets; |
| 2420 | - if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) {
|
|
| 2420 | + if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 2421 | 2421 | return $fields; |
| 2422 | 2422 | } |
| 2423 | 2423 | |
@@ -2436,24 +2436,24 @@ discard block |
||
| 2436 | 2436 | * |
| 2437 | 2437 | * @return string Modified join clause SQL. |
| 2438 | 2438 | */ |
| 2439 | -function geodir_function_widget_listings_join( $join ) {
|
|
| 2439 | +function geodir_function_widget_listings_join($join) {
|
|
| 2440 | 2440 | global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
| 2441 | 2441 | |
| 2442 | 2442 | $query_args = $gd_query_args_widgets; |
| 2443 | - if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) {
|
|
| 2443 | + if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 2444 | 2444 | return $join; |
| 2445 | 2445 | } |
| 2446 | 2446 | |
| 2447 | - $post_type = empty( $query_args['post_type'] ) ? 'gd_place' : $query_args['post_type']; |
|
| 2448 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2447 | + $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
|
| 2448 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 2449 | 2449 | |
| 2450 | - if ( ! empty( $query_args['with_pics_only'] ) ) {
|
|
| 2451 | - $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )"; |
|
| 2450 | + if (!empty($query_args['with_pics_only'])) {
|
|
| 2451 | + $join .= " LEFT JOIN ".GEODIR_ATTACHMENT_TABLE." ON ( ".GEODIR_ATTACHMENT_TABLE.".post_id=".$table.".post_id AND ".GEODIR_ATTACHMENT_TABLE.".mime_type LIKE '%image%' )"; |
|
| 2452 | 2452 | } |
| 2453 | 2453 | |
| 2454 | - if ( ! empty( $query_args['tax_query'] ) ) {
|
|
| 2455 | - $tax_queries = get_tax_sql( $query_args['tax_query'], $wpdb->posts, 'ID' ); |
|
| 2456 | - if ( ! empty( $tax_queries['join'] ) && ! empty( $tax_queries['where'] ) ) {
|
|
| 2454 | + if (!empty($query_args['tax_query'])) {
|
|
| 2455 | + $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID'); |
|
| 2456 | + if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
|
|
| 2457 | 2457 | $join .= $tax_queries['join']; |
| 2458 | 2458 | } |
| 2459 | 2459 | } |
@@ -2473,49 +2473,49 @@ discard block |
||
| 2473 | 2473 | * |
| 2474 | 2474 | * @return string Modified where clause SQL. |
| 2475 | 2475 | */ |
| 2476 | -function geodir_function_widget_listings_where( $where ) {
|
|
| 2476 | +function geodir_function_widget_listings_where($where) {
|
|
| 2477 | 2477 | global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
| 2478 | 2478 | |
| 2479 | 2479 | $query_args = $gd_query_args_widgets; |
| 2480 | - if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) {
|
|
| 2480 | + if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 2481 | 2481 | return $where; |
| 2482 | 2482 | } |
| 2483 | - $post_type = empty( $query_args['post_type'] ) ? 'gd_place' : $query_args['post_type']; |
|
| 2484 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2483 | + $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
|
| 2484 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 2485 | 2485 | |
| 2486 | - if ( ! empty( $query_args ) ) {
|
|
| 2487 | - if ( ! empty( $query_args['gd_location'] ) && function_exists( 'geodir_default_location_where' ) ) {
|
|
| 2488 | - $where = geodir_default_location_where( $where, $table ); |
|
| 2486 | + if (!empty($query_args)) {
|
|
| 2487 | + if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
|
|
| 2488 | + $where = geodir_default_location_where($where, $table); |
|
| 2489 | 2489 | } |
| 2490 | 2490 | |
| 2491 | - if ( ! empty( $query_args['post_author'] ) ) {
|
|
| 2492 | - $where .= " AND " . $wpdb->posts . ".post_author = " . (int) $query_args['post_author']; |
|
| 2491 | + if (!empty($query_args['post_author'])) {
|
|
| 2492 | + $where .= " AND ".$wpdb->posts.".post_author = ".(int) $query_args['post_author']; |
|
| 2493 | 2493 | } |
| 2494 | 2494 | |
| 2495 | - if ( ! empty( $query_args['show_featured_only'] ) ) {
|
|
| 2496 | - $where .= " AND " . $table . ".is_featured = '1'"; |
|
| 2495 | + if (!empty($query_args['show_featured_only'])) {
|
|
| 2496 | + $where .= " AND ".$table.".is_featured = '1'"; |
|
| 2497 | 2497 | } |
| 2498 | 2498 | |
| 2499 | - if ( ! empty( $query_args['show_special_only'] ) ) {
|
|
| 2500 | - $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )"; |
|
| 2499 | + if (!empty($query_args['show_special_only'])) {
|
|
| 2500 | + $where .= " AND ( ".$table.".geodir_special_offers != '' AND ".$table.".geodir_special_offers IS NOT NULL )"; |
|
| 2501 | 2501 | } |
| 2502 | 2502 | |
| 2503 | - if ( ! empty( $query_args['with_pics_only'] ) ) {
|
|
| 2504 | - $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL "; |
|
| 2503 | + if (!empty($query_args['with_pics_only'])) {
|
|
| 2504 | + $where .= " AND ".GEODIR_ATTACHMENT_TABLE.".ID IS NOT NULL "; |
|
| 2505 | 2505 | } |
| 2506 | 2506 | |
| 2507 | - if ( ! empty( $query_args['featured_image_only'] ) ) {
|
|
| 2508 | - $where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' "; |
|
| 2507 | + if (!empty($query_args['featured_image_only'])) {
|
|
| 2508 | + $where .= " AND ".$table.".featured_image IS NOT NULL AND ".$table.".featured_image!='' "; |
|
| 2509 | 2509 | } |
| 2510 | 2510 | |
| 2511 | - if ( ! empty( $query_args['with_videos_only'] ) ) {
|
|
| 2512 | - $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )"; |
|
| 2511 | + if (!empty($query_args['with_videos_only'])) {
|
|
| 2512 | + $where .= " AND ( ".$table.".geodir_video != '' AND ".$table.".geodir_video IS NOT NULL )"; |
|
| 2513 | 2513 | } |
| 2514 | 2514 | |
| 2515 | - if ( ! empty( $query_args['tax_query'] ) ) {
|
|
| 2516 | - $tax_queries = get_tax_sql( $query_args['tax_query'], $wpdb->posts, 'ID' ); |
|
| 2515 | + if (!empty($query_args['tax_query'])) {
|
|
| 2516 | + $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID'); |
|
| 2517 | 2517 | |
| 2518 | - if ( ! empty( $tax_queries['join'] ) && ! empty( $tax_queries['where'] ) ) {
|
|
| 2518 | + if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
|
|
| 2519 | 2519 | $where .= $tax_queries['where']; |
| 2520 | 2520 | } |
| 2521 | 2521 | } |
@@ -2536,11 +2536,11 @@ discard block |
||
| 2536 | 2536 | * |
| 2537 | 2537 | * @return string Modified orderby clause SQL. |
| 2538 | 2538 | */ |
| 2539 | -function geodir_function_widget_listings_orderby( $orderby ) {
|
|
| 2539 | +function geodir_function_widget_listings_orderby($orderby) {
|
|
| 2540 | 2540 | global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
| 2541 | 2541 | |
| 2542 | 2542 | $query_args = $gd_query_args_widgets; |
| 2543 | - if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) {
|
|
| 2543 | + if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 2544 | 2544 | return $orderby; |
| 2545 | 2545 | } |
| 2546 | 2546 | |
@@ -2559,15 +2559,15 @@ discard block |
||
| 2559 | 2559 | * |
| 2560 | 2560 | * @return int Query limit. |
| 2561 | 2561 | */ |
| 2562 | -function geodir_function_widget_listings_limit( $limit ) {
|
|
| 2562 | +function geodir_function_widget_listings_limit($limit) {
|
|
| 2563 | 2563 | global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
| 2564 | 2564 | |
| 2565 | 2565 | $query_args = $gd_query_args_widgets; |
| 2566 | - if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) {
|
|
| 2566 | + if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 2567 | 2567 | return $limit; |
| 2568 | 2568 | } |
| 2569 | 2569 | |
| 2570 | - if ( ! empty( $query_args ) && ! empty( $query_args['posts_per_page'] ) ) {
|
|
| 2570 | + if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
|
|
| 2571 | 2571 | $limit = (int) $query_args['posts_per_page']; |
| 2572 | 2572 | } |
| 2573 | 2573 | |
@@ -2585,12 +2585,12 @@ discard block |
||
| 2585 | 2585 | * |
| 2586 | 2586 | * @return int Large size width. |
| 2587 | 2587 | */ |
| 2588 | -function geodir_media_image_large_width( $default = 800, $params = '' ) {
|
|
| 2589 | - $large_size_w = get_option( 'large_size_w' ); |
|
| 2588 | +function geodir_media_image_large_width($default = 800, $params = '') {
|
|
| 2589 | + $large_size_w = get_option('large_size_w');
|
|
| 2590 | 2590 | $large_size_w = $large_size_w > 0 ? $large_size_w : $default; |
| 2591 | - $large_size_w = absint( $large_size_w ); |
|
| 2591 | + $large_size_w = absint($large_size_w); |
|
| 2592 | 2592 | |
| 2593 | - if ( ! get_option( 'geodir_use_wp_media_large_size' ) ) {
|
|
| 2593 | + if (!get_option('geodir_use_wp_media_large_size')) {
|
|
| 2594 | 2594 | $large_size_w = 800; |
| 2595 | 2595 | } |
| 2596 | 2596 | |
@@ -2603,7 +2603,7 @@ discard block |
||
| 2603 | 2603 | * @param int $default Default width. |
| 2604 | 2604 | * @param string|array $params Image parameters. |
| 2605 | 2605 | */ |
| 2606 | - $large_size_w = apply_filters( 'geodir_filter_media_image_large_width', $large_size_w, $default, $params ); |
|
| 2606 | + $large_size_w = apply_filters('geodir_filter_media_image_large_width', $large_size_w, $default, $params);
|
|
| 2607 | 2607 | |
| 2608 | 2608 | return $large_size_w; |
| 2609 | 2609 | } |
@@ -2619,12 +2619,12 @@ discard block |
||
| 2619 | 2619 | * |
| 2620 | 2620 | * @return int Large size height. |
| 2621 | 2621 | */ |
| 2622 | -function geodir_media_image_large_height( $default = 800, $params = '' ) {
|
|
| 2623 | - $large_size_h = get_option( 'large_size_h' ); |
|
| 2622 | +function geodir_media_image_large_height($default = 800, $params = '') {
|
|
| 2623 | + $large_size_h = get_option('large_size_h');
|
|
| 2624 | 2624 | $large_size_h = $large_size_h > 0 ? $large_size_h : $default; |
| 2625 | - $large_size_h = absint( $large_size_h ); |
|
| 2625 | + $large_size_h = absint($large_size_h); |
|
| 2626 | 2626 | |
| 2627 | - if ( ! get_option( 'geodir_use_wp_media_large_size' ) ) {
|
|
| 2627 | + if (!get_option('geodir_use_wp_media_large_size')) {
|
|
| 2628 | 2628 | $large_size_h = 800; |
| 2629 | 2629 | } |
| 2630 | 2630 | |
@@ -2637,7 +2637,7 @@ discard block |
||
| 2637 | 2637 | * @param int $default Default height. |
| 2638 | 2638 | * @param string|array $params Image parameters. |
| 2639 | 2639 | */ |
| 2640 | - $large_size_h = apply_filters( 'geodir_filter_media_image_large_height', $large_size_h, $default, $params ); |
|
| 2640 | + $large_size_h = apply_filters('geodir_filter_media_image_large_height', $large_size_h, $default, $params);
|
|
| 2641 | 2641 | |
| 2642 | 2642 | return $large_size_h; |
| 2643 | 2643 | } |
@@ -2654,8 +2654,8 @@ discard block |
||
| 2654 | 2654 | * |
| 2655 | 2655 | * @return string Sanitized name. |
| 2656 | 2656 | */ |
| 2657 | -function geodir_sanitize_location_name( $type, $name, $translate = true ) {
|
|
| 2658 | - if ( $name == '' ) {
|
|
| 2657 | +function geodir_sanitize_location_name($type, $name, $translate = true) {
|
|
| 2658 | + if ($name == '') {
|
|
| 2659 | 2659 | return null; |
| 2660 | 2660 | } |
| 2661 | 2661 | |
@@ -2664,13 +2664,13 @@ discard block |
||
| 2664 | 2664 | $type = $type == 'gd_city' ? 'city' : $type; |
| 2665 | 2665 | |
| 2666 | 2666 | $return = $name; |
| 2667 | - if ( function_exists( 'get_actual_location_name' ) ) {
|
|
| 2668 | - $return = get_actual_location_name( $type, $name, $translate ); |
|
| 2667 | + if (function_exists('get_actual_location_name')) {
|
|
| 2668 | + $return = get_actual_location_name($type, $name, $translate); |
|
| 2669 | 2669 | } else {
|
| 2670 | - $return = preg_replace( '/-(\d+)$/', '', $return ); |
|
| 2671 | - $return = preg_replace( '/[_-]/', ' ', $return ); |
|
| 2672 | - $return = geodir_ucwords( $return ); |
|
| 2673 | - $return = $translate ? __( $return, 'geodirectory' ) : $return; |
|
| 2670 | + $return = preg_replace('/-(\d+)$/', '', $return);
|
|
| 2671 | + $return = preg_replace('/[_-]/', ' ', $return);
|
|
| 2672 | + $return = geodir_ucwords($return); |
|
| 2673 | + $return = $translate ? __($return, 'geodirectory') : $return; |
|
| 2674 | 2674 | } |
| 2675 | 2675 | |
| 2676 | 2676 | return $return; |
@@ -2688,26 +2688,26 @@ discard block |
||
| 2688 | 2688 | * |
| 2689 | 2689 | * @param int $number Comments number. |
| 2690 | 2690 | */ |
| 2691 | -function geodir_comments_number( $number ) {
|
|
| 2691 | +function geodir_comments_number($number) {
|
|
| 2692 | 2692 | global $post; |
| 2693 | 2693 | |
| 2694 | - if ( !empty( $post->post_type ) && geodir_cpt_has_rating_disabled( $post->post_type ) ) {
|
|
| 2694 | + if (!empty($post->post_type) && geodir_cpt_has_rating_disabled($post->post_type)) {
|
|
| 2695 | 2695 | $number = get_comments_number(); |
| 2696 | 2696 | |
| 2697 | - if ( $number > 1 ) {
|
|
| 2698 | - $output = str_replace( '%', number_format_i18n( $number ), __( '% Comments', 'geodirectory' ) ); |
|
| 2699 | - } elseif ( $number == 0 || $number == '' ) {
|
|
| 2700 | - $output = __( 'No Comments', 'geodirectory' ); |
|
| 2697 | + if ($number > 1) {
|
|
| 2698 | + $output = str_replace('%', number_format_i18n($number), __('% Comments', 'geodirectory'));
|
|
| 2699 | + } elseif ($number == 0 || $number == '') {
|
|
| 2700 | + $output = __('No Comments', 'geodirectory');
|
|
| 2701 | 2701 | } else { // must be one
|
| 2702 | - $output = __( '1 Comment', 'geodirectory' ); |
|
| 2702 | + $output = __('1 Comment', 'geodirectory');
|
|
| 2703 | 2703 | } |
| 2704 | 2704 | } else {
|
| 2705 | - if ( $number > 1 ) {
|
|
| 2706 | - $output = str_replace( '%', number_format_i18n( $number ), __( '% Reviews', 'geodirectory' ) ); |
|
| 2707 | - } elseif ( $number == 0 || $number == '' ) {
|
|
| 2708 | - $output = __( 'No Reviews', 'geodirectory' ); |
|
| 2705 | + if ($number > 1) {
|
|
| 2706 | + $output = str_replace('%', number_format_i18n($number), __('% Reviews', 'geodirectory'));
|
|
| 2707 | + } elseif ($number == 0 || $number == '') {
|
|
| 2708 | + $output = __('No Reviews', 'geodirectory');
|
|
| 2709 | 2709 | } else { // must be one
|
| 2710 | - $output = __( '1 Review', 'geodirectory' ); |
|
| 2710 | + $output = __('1 Review', 'geodirectory');
|
|
| 2711 | 2711 | } |
| 2712 | 2712 | } |
| 2713 | 2713 | |
@@ -2724,18 +2724,18 @@ discard block |
||
| 2724 | 2724 | */ |
| 2725 | 2725 | function is_page_geodir_home() {
|
| 2726 | 2726 | global $wpdb; |
| 2727 | - $cur_url = str_replace( array( "https://", "http://", "www." ), array( '', '', '' ), geodir_curPageURL() ); |
|
| 2728 | - if ( function_exists( 'geodir_location_geo_home_link' ) ) {
|
|
| 2729 | - remove_filter( 'home_url', 'geodir_location_geo_home_link', 100000 ); |
|
| 2727 | + $cur_url = str_replace(array("https://", "http://", "www."), array('', '', ''), geodir_curPageURL());
|
|
| 2728 | + if (function_exists('geodir_location_geo_home_link')) {
|
|
| 2729 | + remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
|
|
| 2730 | 2730 | } |
| 2731 | - $home_url = home_url( '', 'http' ); |
|
| 2732 | - if ( function_exists( 'geodir_location_geo_home_link' ) ) {
|
|
| 2733 | - add_filter( 'home_url', 'geodir_location_geo_home_link', 100000, 2 ); |
|
| 2731 | + $home_url = home_url('', 'http');
|
|
| 2732 | + if (function_exists('geodir_location_geo_home_link')) {
|
|
| 2733 | + add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
|
|
| 2734 | 2734 | } |
| 2735 | - $home_url = str_replace( "www.", "", $home_url ); |
|
| 2736 | - 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' ) ) ) {
|
|
| 2735 | + $home_url = str_replace("www.", "", $home_url);
|
|
| 2736 | + 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'))) {
|
|
| 2737 | 2737 | return true; |
| 2738 | - } 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' ) ) {
|
|
| 2738 | + } 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')) {
|
|
| 2739 | 2739 | return true; |
| 2740 | 2740 | } else {
|
| 2741 | 2741 | return false; |
@@ -2755,18 +2755,18 @@ discard block |
||
| 2755 | 2755 | * |
| 2756 | 2756 | * @return string The canonical URL. |
| 2757 | 2757 | */ |
| 2758 | -function geodir_wpseo_homepage_canonical( $url ) {
|
|
| 2758 | +function geodir_wpseo_homepage_canonical($url) {
|
|
| 2759 | 2759 | global $post; |
| 2760 | 2760 | |
| 2761 | - if ( is_page_geodir_home() ) {
|
|
| 2761 | + if (is_page_geodir_home()) {
|
|
| 2762 | 2762 | return home_url(); |
| 2763 | 2763 | } |
| 2764 | 2764 | |
| 2765 | 2765 | return $url; |
| 2766 | 2766 | } |
| 2767 | 2767 | |
| 2768 | -add_filter( 'wpseo_canonical', 'geodir_wpseo_homepage_canonical', 10 ); |
|
| 2769 | -add_filter( 'aioseop_canonical_url', 'geodir_wpseo_homepage_canonical', 10 ); |
|
| 2768 | +add_filter('wpseo_canonical', 'geodir_wpseo_homepage_canonical', 10);
|
|
| 2769 | +add_filter('aioseop_canonical_url', 'geodir_wpseo_homepage_canonical', 10);
|
|
| 2770 | 2770 | |
| 2771 | 2771 | /** |
| 2772 | 2772 | * Add extra fields to google maps script call. |
@@ -2779,20 +2779,20 @@ discard block |
||
| 2779 | 2779 | * |
| 2780 | 2780 | * @return string Modified extra string. |
| 2781 | 2781 | */ |
| 2782 | -function geodir_googlemap_script_extra_details_page( $extra ) {
|
|
| 2782 | +function geodir_googlemap_script_extra_details_page($extra) {
|
|
| 2783 | 2783 | global $post; |
| 2784 | 2784 | $add_google_places_api = false; |
| 2785 | - if ( isset( $post->post_content ) && has_shortcode( $post->post_content, 'gd_add_listing' ) ) {
|
|
| 2785 | + if (isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
|
|
| 2786 | 2786 | $add_google_places_api = true; |
| 2787 | 2787 | } |
| 2788 | - if ( ! str_replace( 'libraries=places', '', $extra ) && ( geodir_is_page( 'detail' ) || $add_google_places_api ) ) {
|
|
| 2788 | + if (!str_replace('libraries=places', '', $extra) && (geodir_is_page('detail') || $add_google_places_api)) {
|
|
| 2789 | 2789 | $extra .= "&libraries=places"; |
| 2790 | 2790 | } |
| 2791 | 2791 | |
| 2792 | 2792 | return $extra; |
| 2793 | 2793 | } |
| 2794 | 2794 | |
| 2795 | -add_filter( 'geodir_googlemap_script_extra', 'geodir_googlemap_script_extra_details_page', 101, 1 ); |
|
| 2795 | +add_filter('geodir_googlemap_script_extra', 'geodir_googlemap_script_extra_details_page', 101, 1);
|
|
| 2796 | 2796 | |
| 2797 | 2797 | |
| 2798 | 2798 | /** |
@@ -2810,104 +2810,104 @@ discard block |
||
| 2810 | 2810 | * after_widget. |
| 2811 | 2811 | * @param array|string $instance The settings for the particular instance of the widget. |
| 2812 | 2812 | */ |
| 2813 | -function geodir_popular_post_category_output( $args = '', $instance = '' ) {
|
|
| 2813 | +function geodir_popular_post_category_output($args = '', $instance = '') {
|
|
| 2814 | 2814 | // prints the widget |
| 2815 | 2815 | global $wpdb, $plugin_prefix, $geodir_post_category_str; |
| 2816 | - extract( $args, EXTR_SKIP ); |
|
| 2816 | + extract($args, EXTR_SKIP); |
|
| 2817 | 2817 | |
| 2818 | 2818 | echo $before_widget; |
| 2819 | 2819 | |
| 2820 | 2820 | /** This filter is documented in geodirectory_widgets.php */ |
| 2821 | - $title = empty( $instance['title'] ) ? __( 'Popular Categories', 'geodirectory' ) : apply_filters( 'widget_title', __( $instance['title'], 'geodirectory' ) ); |
|
| 2821 | + $title = empty($instance['title']) ? __('Popular Categories', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
|
|
| 2822 | 2822 | |
| 2823 | 2823 | $gd_post_type = geodir_get_current_posttype(); |
| 2824 | 2824 | |
| 2825 | - $category_limit = isset( $instance['category_limit'] ) && $instance['category_limit'] > 0 ? (int) $instance['category_limit'] : 15; |
|
| 2825 | + $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int) $instance['category_limit'] : 15; |
|
| 2826 | 2826 | if (!isset($category_restrict)) {
|
| 2827 | 2827 | $category_restrict = false; |
| 2828 | 2828 | } |
| 2829 | - if ( ! empty( $gd_post_type ) ) {
|
|
| 2829 | + if (!empty($gd_post_type)) {
|
|
| 2830 | 2830 | $default_post_type = $gd_post_type; |
| 2831 | - } elseif ( isset( $instance['default_post_type'] ) && gdsc_is_post_type_valid( $instance['default_post_type'] ) ) {
|
|
| 2831 | + } elseif (isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type'])) {
|
|
| 2832 | 2832 | $default_post_type = $instance['default_post_type']; |
| 2833 | 2833 | } else {
|
| 2834 | 2834 | $all_gd_post_type = geodir_get_posttypes(); |
| 2835 | - $default_post_type = ( isset( $all_gd_post_type[0] ) ) ? $all_gd_post_type[0] : ''; |
|
| 2835 | + $default_post_type = (isset($all_gd_post_type[0])) ? $all_gd_post_type[0] : ''; |
|
| 2836 | 2836 | } |
| 2837 | - $parent_only = !empty( $instance['parent_only'] ) ? true : false; |
|
| 2837 | + $parent_only = !empty($instance['parent_only']) ? true : false; |
|
| 2838 | 2838 | |
| 2839 | 2839 | $taxonomy = array(); |
| 2840 | - if ( ! empty( $gd_post_type ) ) {
|
|
| 2841 | - $taxonomy[] = $gd_post_type . "category"; |
|
| 2840 | + if (!empty($gd_post_type)) {
|
|
| 2841 | + $taxonomy[] = $gd_post_type."category"; |
|
| 2842 | 2842 | } else {
|
| 2843 | - $taxonomy = geodir_get_taxonomies( $gd_post_type ); |
|
| 2843 | + $taxonomy = geodir_get_taxonomies($gd_post_type); |
|
| 2844 | 2844 | } |
| 2845 | 2845 | |
| 2846 | 2846 | $taxonomy = apply_filters('geodir_pp_category_taxonomy', $taxonomy);
|
| 2847 | 2847 | |
| 2848 | - $term_args = array( 'taxonomy' => $taxonomy ); |
|
| 2849 | - if ( $parent_only ) {
|
|
| 2848 | + $term_args = array('taxonomy' => $taxonomy);
|
|
| 2849 | + if ($parent_only) {
|
|
| 2850 | 2850 | $term_args['parent'] = 0; |
| 2851 | 2851 | } |
| 2852 | 2852 | |
| 2853 | - $terms = get_terms( $term_args ); |
|
| 2853 | + $terms = get_terms($term_args); |
|
| 2854 | 2854 | $a_terms = array(); |
| 2855 | 2855 | $b_terms = array(); |
| 2856 | 2856 | |
| 2857 | - foreach ( $terms as $term ) {
|
|
| 2858 | - if ( $term->count > 0 ) {
|
|
| 2859 | - $a_terms[ $term->taxonomy ][] = $term; |
|
| 2857 | + foreach ($terms as $term) {
|
|
| 2858 | + if ($term->count > 0) {
|
|
| 2859 | + $a_terms[$term->taxonomy][] = $term; |
|
| 2860 | 2860 | } |
| 2861 | 2861 | } |
| 2862 | 2862 | |
| 2863 | - if ( ! empty( $a_terms ) ) {
|
|
| 2864 | - foreach ( $a_terms as $b_key => $b_val ) {
|
|
| 2865 | - $b_terms[ $b_key ] = geodir_sort_terms( $b_val, 'count' ); |
|
| 2863 | + if (!empty($a_terms)) {
|
|
| 2864 | + foreach ($a_terms as $b_key => $b_val) {
|
|
| 2865 | + $b_terms[$b_key] = geodir_sort_terms($b_val, 'count'); |
|
| 2866 | 2866 | } |
| 2867 | 2867 | |
| 2868 | - $default_taxonomy = $default_post_type != '' && isset( $b_terms[ $default_post_type . 'category' ] ) ? $default_post_type . 'category' : ''; |
|
| 2868 | + $default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type.'category']) ? $default_post_type.'category' : ''; |
|
| 2869 | 2869 | |
| 2870 | 2870 | $tax_change_output = ''; |
| 2871 | - if ( count( $b_terms ) > 1 ) {
|
|
| 2872 | - $tax_change_output .= "<select data-limit='$category_limit' data-parent='" . (int)$parent_only . "' class='geodir-cat-list-tax' onchange='geodir_get_post_term(this);'>"; |
|
| 2873 | - foreach ( $b_terms as $key => $val ) {
|
|
| 2874 | - $ptype = get_post_type_object( str_replace( "category", "", $key ) ); |
|
| 2875 | - $cpt_name = __( $ptype->labels->singular_name, 'geodirectory' ); |
|
| 2876 | - $tax_change_output .= "<option value='$key' " . selected( $key, $default_taxonomy, false ) . ">" . sprintf( __( '%s Categories', 'geodirectory' ), $cpt_name ) . "</option>"; |
|
| 2871 | + if (count($b_terms) > 1) {
|
|
| 2872 | + $tax_change_output .= "<select data-limit='$category_limit' data-parent='".(int) $parent_only."' class='geodir-cat-list-tax' onchange='geodir_get_post_term(this);'>"; |
|
| 2873 | + foreach ($b_terms as $key => $val) {
|
|
| 2874 | + $ptype = get_post_type_object(str_replace("category", "", $key));
|
|
| 2875 | + $cpt_name = __($ptype->labels->singular_name, 'geodirectory'); |
|
| 2876 | + $tax_change_output .= "<option value='$key' ".selected($key, $default_taxonomy, false).">".sprintf(__('%s Categories', 'geodirectory'), $cpt_name)."</option>";
|
|
| 2877 | 2877 | } |
| 2878 | 2878 | $tax_change_output .= "</select>"; |
| 2879 | 2879 | } |
| 2880 | 2880 | |
| 2881 | - if ( ! empty( $b_terms ) ) {
|
|
| 2882 | - $terms = $default_taxonomy != '' && isset( $b_terms[ $default_taxonomy ] ) ? $b_terms[ $default_taxonomy ] : reset( $b_terms );// get the first array |
|
| 2883 | - global $cat_count;//make global so we can change via function |
|
| 2881 | + if (!empty($b_terms)) {
|
|
| 2882 | + $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms); // get the first array |
|
| 2883 | + global $cat_count; //make global so we can change via function |
|
| 2884 | 2884 | $cat_count = 0; |
| 2885 | 2885 | ?> |
| 2886 | 2886 | <div class="geodir-category-list-in clearfix"> |
| 2887 | 2887 | <div class="geodir-cat-list clearfix"> |
| 2888 | 2888 | <?php |
| 2889 | - echo $before_title . __( $title ) . $after_title; |
|
| 2889 | + echo $before_title.__($title).$after_title; |
|
| 2890 | 2890 | |
| 2891 | 2891 | echo $tax_change_output; |
| 2892 | 2892 | |
| 2893 | 2893 | echo '<ul class="geodir-popular-cat-list">'; |
| 2894 | 2894 | |
| 2895 | - geodir_helper_cat_list_output( $terms, $category_limit, $category_restrict); |
|
| 2895 | + geodir_helper_cat_list_output($terms, $category_limit, $category_restrict); |
|
| 2896 | 2896 | |
| 2897 | 2897 | echo '</ul>'; |
| 2898 | 2898 | ?> |
| 2899 | 2899 | </div> |
| 2900 | 2900 | <?php |
| 2901 | 2901 | $hide = ''; |
| 2902 | - if ( $cat_count < $category_limit ) {
|
|
| 2902 | + if ($cat_count < $category_limit) {
|
|
| 2903 | 2903 | $hide = 'style="display:none;"'; |
| 2904 | 2904 | } |
| 2905 | 2905 | echo "<div class='geodir-cat-list-more' $hide >"; |
| 2906 | - echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __( 'More Categories', 'geodirectory' ) . '</a>'; |
|
| 2907 | - echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __( 'Less Categories', 'geodirectory' ) . '</a>'; |
|
| 2906 | + echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">'.__('More Categories', 'geodirectory').'</a>';
|
|
| 2907 | + echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">'.__('Less Categories', 'geodirectory').'</a>';
|
|
| 2908 | 2908 | echo "</div>"; |
| 2909 | 2909 | /* add scripts */ |
| 2910 | - add_action( 'wp_footer', 'geodir_popular_category_add_scripts', 100 ); |
|
| 2910 | + add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
|
|
| 2911 | 2911 | ?> |
| 2912 | 2912 | </div> |
| 2913 | 2913 | <?php |
@@ -2927,28 +2927,28 @@ discard block |
||
| 2927 | 2927 | * @param int $category_limit Number of categories to display by default. |
| 2928 | 2928 | * @param bool $category_restrict If the cat limit shoudl be hidden or not shown. |
| 2929 | 2929 | */ |
| 2930 | -function geodir_helper_cat_list_output( $terms, $category_limit , $category_restrict=false) {
|
|
| 2930 | +function geodir_helper_cat_list_output($terms, $category_limit, $category_restrict = false) {
|
|
| 2931 | 2931 | global $geodir_post_category_str, $cat_count; |
| 2932 | 2932 | $term_icons = geodir_get_term_icon(); |
| 2933 | 2933 | |
| 2934 | 2934 | $geodir_post_category_str = array(); |
| 2935 | 2935 | |
| 2936 | 2936 | |
| 2937 | - foreach ( $terms as $cat ) {
|
|
| 2938 | - $post_type = str_replace( "category", "", $cat->taxonomy ); |
|
| 2939 | - $term_icon_url = ! empty( $term_icons ) && isset( $term_icons[ $cat->term_id ] ) ? $term_icons[ $cat->term_id ] : ''; |
|
| 2937 | + foreach ($terms as $cat) {
|
|
| 2938 | + $post_type = str_replace("category", "", $cat->taxonomy);
|
|
| 2939 | + $term_icon_url = !empty($term_icons) && isset($term_icons[$cat->term_id]) ? $term_icons[$cat->term_id] : ''; |
|
| 2940 | 2940 | |
| 2941 | - $cat_count ++; |
|
| 2941 | + $cat_count++; |
|
| 2942 | 2942 | |
| 2943 | - $geodir_post_category_str[] = array( 'posttype' => $post_type, 'termid' => $cat->term_id ); |
|
| 2943 | + $geodir_post_category_str[] = array('posttype' => $post_type, 'termid' => $cat->term_id);
|
|
| 2944 | 2944 | |
| 2945 | - $class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show'; |
|
| 2946 | - if($category_restrict && $cat_count > $category_limit ){
|
|
| 2945 | + $class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show'; |
|
| 2946 | + if ($category_restrict && $cat_count > $category_limit) {
|
|
| 2947 | 2947 | continue; |
| 2948 | 2948 | } |
| 2949 | 2949 | $total_post = $cat->count; |
| 2950 | 2950 | |
| 2951 | - $term_link = get_term_link( $cat, $cat->taxonomy ); |
|
| 2951 | + $term_link = get_term_link($cat, $cat->taxonomy); |
|
| 2952 | 2952 | /** |
| 2953 | 2953 | * Filer the category term link. |
| 2954 | 2954 | * |
@@ -2958,11 +2958,11 @@ discard block |
||
| 2958 | 2958 | * @param int $cat ->term_id The term id. |
| 2959 | 2959 | * @param string $post_type Wordpress post type. |
| 2960 | 2960 | */ |
| 2961 | - $term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type ); |
|
| 2961 | + $term_link = apply_filters('geodir_category_term_link', $term_link, $cat->term_id, $post_type);
|
|
| 2962 | 2962 | |
| 2963 | - echo '<li class="' . $class_row . '"><a href="' . $term_link . '">'; |
|
| 2964 | - echo '<img alt="' . esc_attr( $cat->name ) . ' icon" style="height:20px;vertical-align:middle;" src="' . $term_icon_url . '"/> <span class="cat-link">'; |
|
| 2965 | - echo $cat->name . '</span> <span class="geodir_term_class geodir_link_span geodir_category_class_' . $post_type . '_' . $cat->term_id . '">(' . $total_post . ')</span> ';
|
|
| 2963 | + echo '<li class="'.$class_row.'"><a href="'.$term_link.'">'; |
|
| 2964 | + echo '<img alt="'.esc_attr($cat->name).' icon" style="height:20px;vertical-align:middle;" src="'.$term_icon_url.'"/> <span class="cat-link">'; |
|
| 2965 | + echo $cat->name.'</span> <span class="geodir_term_class geodir_link_span geodir_category_class_'.$post_type.'_'.$cat->term_id.'">('.$total_post.')</span> ';
|
|
| 2966 | 2966 | echo '</a></li>'; |
| 2967 | 2967 | } |
| 2968 | 2968 | } |
@@ -2977,14 +2977,14 @@ discard block |
||
| 2977 | 2977 | * @param array|string $args Display arguments including before_title, after_title, before_widget, and after_widget. |
| 2978 | 2978 | * @param array|string $instance The settings for the particular instance of the widget. |
| 2979 | 2979 | */ |
| 2980 | -function geodir_listing_slider_widget_output( $args = '', $instance = '' ) {
|
|
| 2980 | +function geodir_listing_slider_widget_output($args = '', $instance = '') {
|
|
| 2981 | 2981 | // prints the widget |
| 2982 | - extract( $args, EXTR_SKIP ); |
|
| 2982 | + extract($args, EXTR_SKIP); |
|
| 2983 | 2983 | |
| 2984 | 2984 | echo $before_widget; |
| 2985 | 2985 | |
| 2986 | 2986 | /** This filter is documented in geodirectory_widgets.php */ |
| 2987 | - $title = empty( $instance['title'] ) ? '' : apply_filters( 'widget_title', __( $instance['title'], 'geodirectory' ) ); |
|
| 2987 | + $title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
|
|
| 2988 | 2988 | /** |
| 2989 | 2989 | * Filter the widget post type. |
| 2990 | 2990 | * |
@@ -2992,7 +2992,7 @@ discard block |
||
| 2992 | 2992 | * |
| 2993 | 2993 | * @param string $instance ['post_type'] Post type of listing. |
| 2994 | 2994 | */ |
| 2995 | - $post_type = empty( $instance['post_type'] ) ? 'gd_place' : apply_filters( 'widget_post_type', $instance['post_type'] ); |
|
| 2995 | + $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
|
|
| 2996 | 2996 | /** |
| 2997 | 2997 | * Filter the widget's term. |
| 2998 | 2998 | * |
@@ -3000,7 +3000,7 @@ discard block |
||
| 3000 | 3000 | * |
| 3001 | 3001 | * @param string $instance ['category'] Filter by term. Can be any valid term. |
| 3002 | 3002 | */ |
| 3003 | - $category = empty( $instance['category'] ) ? '0' : apply_filters( 'widget_category', $instance['category'] ); |
|
| 3003 | + $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
|
|
| 3004 | 3004 | /** |
| 3005 | 3005 | * Filter widget's "add_location_filter" value. |
| 3006 | 3006 | * |
@@ -3008,7 +3008,7 @@ discard block |
||
| 3008 | 3008 | * |
| 3009 | 3009 | * @param string|bool $instance ['add_location_filter'] Do you want to add location filter? Can be 1 or 0. |
| 3010 | 3010 | */ |
| 3011 | - $add_location_filter = empty( $instance['add_location_filter'] ) ? '0' : apply_filters( 'widget_add_location_filter', $instance['add_location_filter'] ); |
|
| 3011 | + $add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']);
|
|
| 3012 | 3012 | /** |
| 3013 | 3013 | * Filter the widget listings limit. |
| 3014 | 3014 | * |
@@ -3016,7 +3016,7 @@ discard block |
||
| 3016 | 3016 | * |
| 3017 | 3017 | * @param string $instance ['post_number'] Number of listings to display. |
| 3018 | 3018 | */ |
| 3019 | - $post_number = empty( $instance['post_number'] ) ? '5' : apply_filters( 'widget_post_number', $instance['post_number'] ); |
|
| 3019 | + $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
|
|
| 3020 | 3020 | /** |
| 3021 | 3021 | * Filter the widget listings limit shown at one time. |
| 3022 | 3022 | * |
@@ -3024,7 +3024,7 @@ discard block |
||
| 3024 | 3024 | * |
| 3025 | 3025 | * @param string $instance ['max_show'] Number of listings to display on screen. |
| 3026 | 3026 | */ |
| 3027 | - $max_show = empty( $instance['max_show'] ) ? '1' : apply_filters( 'widget_max_show', $instance['max_show'] ); |
|
| 3027 | + $max_show = empty($instance['max_show']) ? '1' : apply_filters('widget_max_show', $instance['max_show']);
|
|
| 3028 | 3028 | /** |
| 3029 | 3029 | * Filter the widget slide width. |
| 3030 | 3030 | * |
@@ -3032,7 +3032,7 @@ discard block |
||
| 3032 | 3032 | * |
| 3033 | 3033 | * @param string $instance ['slide_width'] Width of the slides shown. |
| 3034 | 3034 | */ |
| 3035 | - $slide_width = empty( $instance['slide_width'] ) ? '' : apply_filters( 'widget_slide_width', $instance['slide_width'] ); |
|
| 3035 | + $slide_width = empty($instance['slide_width']) ? '' : apply_filters('widget_slide_width', $instance['slide_width']);
|
|
| 3036 | 3036 | /** |
| 3037 | 3037 | * Filter widget's "show title" value. |
| 3038 | 3038 | * |
@@ -3040,7 +3040,7 @@ discard block |
||
| 3040 | 3040 | * |
| 3041 | 3041 | * @param string|bool $instance ['show_title'] Do you want to display title? Can be 1 or 0. |
| 3042 | 3042 | */ |
| 3043 | - $show_title = empty( $instance['show_title'] ) ? '' : apply_filters( 'widget_show_title', $instance['show_title'] ); |
|
| 3043 | + $show_title = empty($instance['show_title']) ? '' : apply_filters('widget_show_title', $instance['show_title']);
|
|
| 3044 | 3044 | /** |
| 3045 | 3045 | * Filter widget's "slideshow" value. |
| 3046 | 3046 | * |
@@ -3048,7 +3048,7 @@ discard block |
||
| 3048 | 3048 | * |
| 3049 | 3049 | * @param int $instance ['slideshow'] Setup a slideshow for the slider to animate automatically. |
| 3050 | 3050 | */ |
| 3051 | - $slideshow = empty( $instance['slideshow'] ) ? 0 : apply_filters( 'widget_slideshow', $instance['slideshow'] ); |
|
| 3051 | + $slideshow = empty($instance['slideshow']) ? 0 : apply_filters('widget_slideshow', $instance['slideshow']);
|
|
| 3052 | 3052 | /** |
| 3053 | 3053 | * Filter widget's "animationLoop" value. |
| 3054 | 3054 | * |
@@ -3056,7 +3056,7 @@ discard block |
||
| 3056 | 3056 | * |
| 3057 | 3057 | * @param int $instance ['animationLoop'] Gives the slider a seamless infinite loop. |
| 3058 | 3058 | */ |
| 3059 | - $animationLoop = empty( $instance['animationLoop'] ) ? 0 : apply_filters( 'widget_animationLoop', $instance['animationLoop'] ); |
|
| 3059 | + $animationLoop = empty($instance['animationLoop']) ? 0 : apply_filters('widget_animationLoop', $instance['animationLoop']);
|
|
| 3060 | 3060 | /** |
| 3061 | 3061 | * Filter widget's "directionNav" value. |
| 3062 | 3062 | * |
@@ -3064,7 +3064,7 @@ discard block |
||
| 3064 | 3064 | * |
| 3065 | 3065 | * @param int $instance ['directionNav'] Enable previous/next arrow navigation?. Can be 1 or 0. |
| 3066 | 3066 | */ |
| 3067 | - $directionNav = empty( $instance['directionNav'] ) ? 0 : apply_filters( 'widget_directionNav', $instance['directionNav'] ); |
|
| 3067 | + $directionNav = empty($instance['directionNav']) ? 0 : apply_filters('widget_directionNav', $instance['directionNav']);
|
|
| 3068 | 3068 | /** |
| 3069 | 3069 | * Filter widget's "slideshowSpeed" value. |
| 3070 | 3070 | * |
@@ -3072,7 +3072,7 @@ discard block |
||
| 3072 | 3072 | * |
| 3073 | 3073 | * @param int $instance ['slideshowSpeed'] Set the speed of the slideshow cycling, in milliseconds. |
| 3074 | 3074 | */ |
| 3075 | - $slideshowSpeed = empty( $instance['slideshowSpeed'] ) ? 5000 : apply_filters( 'widget_slideshowSpeed', $instance['slideshowSpeed'] ); |
|
| 3075 | + $slideshowSpeed = empty($instance['slideshowSpeed']) ? 5000 : apply_filters('widget_slideshowSpeed', $instance['slideshowSpeed']);
|
|
| 3076 | 3076 | /** |
| 3077 | 3077 | * Filter widget's "animationSpeed" value. |
| 3078 | 3078 | * |
@@ -3080,7 +3080,7 @@ discard block |
||
| 3080 | 3080 | * |
| 3081 | 3081 | * @param int $instance ['animationSpeed'] Set the speed of animations, in milliseconds. |
| 3082 | 3082 | */ |
| 3083 | - $animationSpeed = empty( $instance['animationSpeed'] ) ? 600 : apply_filters( 'widget_animationSpeed', $instance['animationSpeed'] ); |
|
| 3083 | + $animationSpeed = empty($instance['animationSpeed']) ? 600 : apply_filters('widget_animationSpeed', $instance['animationSpeed']);
|
|
| 3084 | 3084 | /** |
| 3085 | 3085 | * Filter widget's "animation" value. |
| 3086 | 3086 | * |
@@ -3088,7 +3088,7 @@ discard block |
||
| 3088 | 3088 | * |
| 3089 | 3089 | * @param string $instance ['animation'] Controls the animation type, "fade" or "slide". |
| 3090 | 3090 | */ |
| 3091 | - $animation = empty( $instance['animation'] ) ? 'slide' : apply_filters( 'widget_animation', $instance['animation'] ); |
|
| 3091 | + $animation = empty($instance['animation']) ? 'slide' : apply_filters('widget_animation', $instance['animation']);
|
|
| 3092 | 3092 | /** |
| 3093 | 3093 | * Filter widget's "list_sort" type. |
| 3094 | 3094 | * |
@@ -3096,10 +3096,10 @@ discard block |
||
| 3096 | 3096 | * |
| 3097 | 3097 | * @param string $instance ['list_sort'] Listing sort by type. |
| 3098 | 3098 | */ |
| 3099 | - $list_sort = empty( $instance['list_sort'] ) ? 'latest' : apply_filters( 'widget_list_sort', $instance['list_sort'] ); |
|
| 3100 | - $show_featured_only = ! empty( $instance['show_featured_only'] ) ? 1 : null; |
|
| 3099 | + $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
|
|
| 3100 | + $show_featured_only = !empty($instance['show_featured_only']) ? 1 : null; |
|
| 3101 | 3101 | |
| 3102 | - wp_enqueue_script( 'geodirectory-jquery-flexslider-js' ); |
|
| 3102 | + wp_enqueue_script('geodirectory-jquery-flexslider-js');
|
|
| 3103 | 3103 | ?> |
| 3104 | 3104 | <script type="text/javascript"> |
| 3105 | 3105 | jQuery(window).load(function () {
|
@@ -3117,23 +3117,23 @@ discard block |
||
| 3117 | 3117 | itemWidth: 75, |
| 3118 | 3118 | itemMargin: 5, |
| 3119 | 3119 | asNavFor: '#geodir_widget_slider', |
| 3120 | - rtl: <?php echo( is_rtl() ? 'true' : 'false' ); /* fix rtl issue */ ?> |
|
| 3120 | + rtl: <?php echo(is_rtl() ? 'true' : 'false'); /* fix rtl issue */ ?> |
|
| 3121 | 3121 | }); |
| 3122 | 3122 | |
| 3123 | 3123 | jQuery('#geodir_widget_slider').flexslider({
|
| 3124 | - animation: "<?php echo $animation;?>", |
|
| 3124 | + animation: "<?php echo $animation; ?>", |
|
| 3125 | 3125 | selector: ".geodir-slides > li", |
| 3126 | 3126 | namespace: "geodir-", |
| 3127 | 3127 | controlNav: true, |
| 3128 | - animationLoop: <?php echo $animationLoop;?>, |
|
| 3129 | - slideshow: <?php echo $slideshow;?>, |
|
| 3130 | - slideshowSpeed: <?php echo $slideshowSpeed;?>, |
|
| 3131 | - animationSpeed: <?php echo $animationSpeed;?>, |
|
| 3132 | - directionNav: <?php echo $directionNav;?>, |
|
| 3133 | - maxItems: <?php echo $max_show;?>, |
|
| 3128 | + animationLoop: <?php echo $animationLoop; ?>, |
|
| 3129 | + slideshow: <?php echo $slideshow; ?>, |
|
| 3130 | + slideshowSpeed: <?php echo $slideshowSpeed; ?>, |
|
| 3131 | + animationSpeed: <?php echo $animationSpeed; ?>, |
|
| 3132 | + directionNav: <?php echo $directionNav; ?>, |
|
| 3133 | + maxItems: <?php echo $max_show; ?>, |
|
| 3134 | 3134 | move: 1, |
| 3135 | - <?php if ( $slide_width ) {
|
|
| 3136 | - echo "itemWidth: " . $slide_width . ","; |
|
| 3135 | + <?php if ($slide_width) {
|
|
| 3136 | + echo "itemWidth: ".$slide_width.","; |
|
| 3137 | 3137 | }?> |
| 3138 | 3138 | sync: "#geodir_widget_carousel", |
| 3139 | 3139 | start: function (slider) {
|
@@ -3145,7 +3145,7 @@ discard block |
||
| 3145 | 3145 | jQuery('#geodir_widget_slider').css({'visibility': 'visible'});
|
| 3146 | 3146 | jQuery('#geodir_widget_carousel').css({'visibility': 'visible'});
|
| 3147 | 3147 | }, |
| 3148 | - rtl: <?php echo( is_rtl() ? 'true' : 'false' ); /* fix rtl issue */ ?> |
|
| 3148 | + rtl: <?php echo(is_rtl() ? 'true' : 'false'); /* fix rtl issue */ ?> |
|
| 3149 | 3149 | }); |
| 3150 | 3150 | }); |
| 3151 | 3151 | </script> |
@@ -3158,62 +3158,62 @@ discard block |
||
| 3158 | 3158 | 'order_by' => $list_sort |
| 3159 | 3159 | ); |
| 3160 | 3160 | |
| 3161 | - if ( $show_featured_only ) {
|
|
| 3161 | + if ($show_featured_only) {
|
|
| 3162 | 3162 | $query_args['show_featured_only'] = 1; |
| 3163 | 3163 | } |
| 3164 | 3164 | |
| 3165 | - if ( $category != 0 || $category != '' ) {
|
|
| 3166 | - $category_taxonomy = geodir_get_taxonomies( $post_type ); |
|
| 3165 | + if ($category != 0 || $category != '') {
|
|
| 3166 | + $category_taxonomy = geodir_get_taxonomies($post_type); |
|
| 3167 | 3167 | $tax_query = array( |
| 3168 | 3168 | 'taxonomy' => $category_taxonomy[0], |
| 3169 | 3169 | 'field' => 'id', |
| 3170 | 3170 | 'terms' => $category |
| 3171 | 3171 | ); |
| 3172 | 3172 | |
| 3173 | - $query_args['tax_query'] = array( $tax_query ); |
|
| 3173 | + $query_args['tax_query'] = array($tax_query); |
|
| 3174 | 3174 | } |
| 3175 | 3175 | |
| 3176 | 3176 | // we want listings with featured image only |
| 3177 | 3177 | $query_args['featured_image_only'] = 1; |
| 3178 | 3178 | |
| 3179 | - if ( $post_type == 'gd_event' ) {
|
|
| 3179 | + if ($post_type == 'gd_event') {
|
|
| 3180 | 3180 | $query_args['gedir_event_listing_filter'] = 'upcoming'; |
| 3181 | 3181 | }// show only upcoming events |
| 3182 | 3182 | |
| 3183 | - $widget_listings = geodir_get_widget_listings( $query_args ); |
|
| 3184 | - if ( ! empty( $widget_listings ) || ( isset( $with_no_results ) && $with_no_results ) ) {
|
|
| 3185 | - if ( $title ) {
|
|
| 3186 | - echo $before_title . $title . $after_title; |
|
| 3183 | + $widget_listings = geodir_get_widget_listings($query_args); |
|
| 3184 | + if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
|
|
| 3185 | + if ($title) {
|
|
| 3186 | + echo $before_title.$title.$after_title; |
|
| 3187 | 3187 | } |
| 3188 | 3188 | |
| 3189 | 3189 | global $post; |
| 3190 | 3190 | |
| 3191 | - $current_post = $post;// keep current post info |
|
| 3191 | + $current_post = $post; // keep current post info |
|
| 3192 | 3192 | |
| 3193 | 3193 | $widget_main_slides = ''; |
| 3194 | 3194 | $nav_slides = ''; |
| 3195 | 3195 | $widget_slides = 0; |
| 3196 | 3196 | |
| 3197 | - foreach ( $widget_listings as $widget_listing ) {
|
|
| 3197 | + foreach ($widget_listings as $widget_listing) {
|
|
| 3198 | 3198 | global $gd_widget_listing_type; |
| 3199 | 3199 | $post = $widget_listing; |
| 3200 | - $widget_image = geodir_get_featured_image( $post->ID, 'thumbnail', get_option( 'geodir_listing_no_img' ) ); |
|
| 3200 | + $widget_image = geodir_get_featured_image($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
|
|
| 3201 | 3201 | |
| 3202 | - if ( ! empty( $widget_image ) ) {
|
|
| 3203 | - if ( $widget_image->height >= 200 ) {
|
|
| 3202 | + if (!empty($widget_image)) {
|
|
| 3203 | + if ($widget_image->height >= 200) {
|
|
| 3204 | 3204 | $widget_spacer_height = 0; |
| 3205 | 3205 | } else {
|
| 3206 | - $widget_spacer_height = ( ( 200 - $widget_image->height ) / 2 ); |
|
| 3206 | + $widget_spacer_height = ((200 - $widget_image->height) / 2); |
|
| 3207 | 3207 | } |
| 3208 | 3208 | |
| 3209 | - $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" />'; |
|
| 3209 | + $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" />'; |
|
| 3210 | 3210 | |
| 3211 | 3211 | $title = ''; |
| 3212 | - if ( $show_title ) {
|
|
| 3213 | - $title_html = '<div class="geodir-slider-title"><a href="' . get_permalink( $post->ID ) . '">' . get_the_title( $post->ID ) . '</a></div>'; |
|
| 3212 | + if ($show_title) {
|
|
| 3213 | + $title_html = '<div class="geodir-slider-title"><a href="'.get_permalink($post->ID).'">'.get_the_title($post->ID).'</a></div>'; |
|
| 3214 | 3214 | $post_id = $post->ID; |
| 3215 | - $post_permalink = get_permalink( $post->ID ); |
|
| 3216 | - $post_title = get_the_title( $post->ID ); |
|
| 3215 | + $post_permalink = get_permalink($post->ID); |
|
| 3216 | + $post_title = get_the_title($post->ID); |
|
| 3217 | 3217 | /** |
| 3218 | 3218 | * Filter the listing slider widget title. |
| 3219 | 3219 | * |
@@ -3224,12 +3224,12 @@ discard block |
||
| 3224 | 3224 | * @param string $post_permalink The post permalink url. |
| 3225 | 3225 | * @param string $post_title The post title text. |
| 3226 | 3226 | */ |
| 3227 | - $title = apply_filters( 'geodir_listing_slider_title', $title_html, $post_id, $post_permalink, $post_title ); |
|
| 3227 | + $title = apply_filters('geodir_listing_slider_title', $title_html, $post_id, $post_permalink, $post_title);
|
|
| 3228 | 3228 | } |
| 3229 | 3229 | |
| 3230 | - $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>'; |
|
| 3231 | - $nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>'; |
|
| 3232 | - $widget_slides ++; |
|
| 3230 | + $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>'; |
|
| 3231 | + $nav_slides .= '<li><img src="'.$widget_image->src.'" alt="'.$widget_image->title.'" title="'.$widget_image->title.'" style="max-height:48px;margin:0 auto;" /></li>'; |
|
| 3232 | + $widget_slides++; |
|
| 3233 | 3233 | } |
| 3234 | 3234 | } |
| 3235 | 3235 | ?> |
@@ -3238,7 +3238,7 @@ discard block |
||
| 3238 | 3238 | <div id="geodir_widget_slider" class="geodir_flexslider"> |
| 3239 | 3239 | <ul class="geodir-slides clearfix"><?php echo $widget_main_slides; ?></ul> |
| 3240 | 3240 | </div> |
| 3241 | - <?php if ( $widget_slides > 1 ) { ?>
|
|
| 3241 | + <?php if ($widget_slides > 1) { ?>
|
|
| 3242 | 3242 | <div id="geodir_widget_carousel" class="geodir_flexslider"> |
| 3243 | 3243 | <ul class="geodir-slides clearfix"><?php echo $nav_slides; ?></ul> |
| 3244 | 3244 | </div> |
@@ -3246,7 +3246,7 @@ discard block |
||
| 3246 | 3246 | </div> |
| 3247 | 3247 | <?php |
| 3248 | 3248 | $GLOBALS['post'] = $current_post; |
| 3249 | - setup_postdata( $current_post ); |
|
| 3249 | + setup_postdata($current_post); |
|
| 3250 | 3250 | } |
| 3251 | 3251 | echo $after_widget; |
| 3252 | 3252 | } |
@@ -3262,46 +3262,46 @@ discard block |
||
| 3262 | 3262 | * @param array|string $args Display arguments including before_title, after_title, before_widget, and after_widget. |
| 3263 | 3263 | * @param array|string $instance The settings for the particular instance of the widget. |
| 3264 | 3264 | */ |
| 3265 | -function geodir_loginwidget_output( $args = '', $instance = '' ) {
|
|
| 3265 | +function geodir_loginwidget_output($args = '', $instance = '') {
|
|
| 3266 | 3266 | //print_r($args); |
| 3267 | 3267 | //print_r($instance); |
| 3268 | 3268 | // prints the widget |
| 3269 | - extract( $args, EXTR_SKIP ); |
|
| 3269 | + extract($args, EXTR_SKIP); |
|
| 3270 | 3270 | |
| 3271 | 3271 | /** This filter is documented in geodirectory_widgets.php */ |
| 3272 | - $title = empty( $instance['title'] ) ? __( 'My Dashboard', 'geodirectory' ) : apply_filters( 'my_dashboard_widget_title', __( $instance['title'], 'geodirectory' ) ); |
|
| 3272 | + $title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('my_dashboard_widget_title', __($instance['title'], 'geodirectory'));
|
|
| 3273 | 3273 | |
| 3274 | 3274 | echo $before_widget; |
| 3275 | - echo $before_title . $title . $after_title; |
|
| 3275 | + echo $before_title.$title.$after_title; |
|
| 3276 | 3276 | |
| 3277 | - if ( is_user_logged_in() ) {
|
|
| 3277 | + if (is_user_logged_in()) {
|
|
| 3278 | 3278 | global $current_user; |
| 3279 | 3279 | |
| 3280 | - $author_link = get_author_posts_url( $current_user->data->ID ); |
|
| 3281 | - $author_link = geodir_getlink( $author_link, array( 'geodir_dashbord' => 'true' ), false ); |
|
| 3280 | + $author_link = get_author_posts_url($current_user->data->ID); |
|
| 3281 | + $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
|
|
| 3282 | 3282 | |
| 3283 | 3283 | echo '<ul class="geodir-loginbox-list">'; |
| 3284 | 3284 | ob_start(); |
| 3285 | 3285 | ?> |
| 3286 | 3286 | <li><a class="signin" |
| 3287 | - href="<?php echo wp_logout_url( home_url() ); ?>"><?php _e( 'Logout', 'geodirectory' ); ?></a></li> |
|
| 3287 | + href="<?php echo wp_logout_url(home_url()); ?>"><?php _e('Logout', 'geodirectory'); ?></a></li>
|
|
| 3288 | 3288 | <?php |
| 3289 | - $post_types = geodir_get_posttypes( 'object' ); |
|
| 3290 | - $show_add_listing_post_types_main_nav = get_option( 'geodir_add_listing_link_user_dashboard' ); |
|
| 3291 | - $geodir_allow_posttype_frontend = get_option( 'geodir_allow_posttype_frontend' ); |
|
| 3289 | + $post_types = geodir_get_posttypes('object');
|
|
| 3290 | + $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_user_dashboard');
|
|
| 3291 | + $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
|
|
| 3292 | 3292 | |
| 3293 | - if ( ! empty( $show_add_listing_post_types_main_nav ) ) {
|
|
| 3293 | + if (!empty($show_add_listing_post_types_main_nav)) {
|
|
| 3294 | 3294 | $addlisting_links = ''; |
| 3295 | - foreach ( $post_types as $key => $postobj ) {
|
|
| 3295 | + foreach ($post_types as $key => $postobj) {
|
|
| 3296 | 3296 | |
| 3297 | - if ( in_array( $key, $show_add_listing_post_types_main_nav ) ) {
|
|
| 3297 | + if (in_array($key, $show_add_listing_post_types_main_nav)) {
|
|
| 3298 | 3298 | |
| 3299 | - if ( $add_link = geodir_get_addlisting_link( $key ) ) {
|
|
| 3299 | + if ($add_link = geodir_get_addlisting_link($key)) {
|
|
| 3300 | 3300 | |
| 3301 | 3301 | $name = $postobj->labels->name; |
| 3302 | 3302 | |
| 3303 | 3303 | $selected = ''; |
| 3304 | - if ( geodir_get_current_posttype() == $key && geodir_is_page( 'add-listing' ) ) {
|
|
| 3304 | + if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing')) {
|
|
| 3305 | 3305 | $selected = 'selected="selected"'; |
| 3306 | 3306 | } |
| 3307 | 3307 | |
@@ -3314,22 +3314,22 @@ discard block |
||
| 3314 | 3314 | * @param string $key Add listing array key. |
| 3315 | 3315 | * @param int $current_user ->ID Current user ID. |
| 3316 | 3316 | */ |
| 3317 | - $add_link = apply_filters( 'geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID ); |
|
| 3317 | + $add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
|
|
| 3318 | 3318 | |
| 3319 | - $addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __( ucfirst( $name ), 'geodirectory' ) . '</option>'; |
|
| 3319 | + $addlisting_links .= '<option '.$selected.' value="'.$add_link.'">'.__(ucfirst($name), 'geodirectory').'</option>'; |
|
| 3320 | 3320 | |
| 3321 | 3321 | } |
| 3322 | 3322 | } |
| 3323 | 3323 | |
| 3324 | 3324 | } |
| 3325 | 3325 | |
| 3326 | - if ( $addlisting_links != '' ) { ?>
|
|
| 3326 | + if ($addlisting_links != '') { ?>
|
|
| 3327 | 3327 | |
| 3328 | 3328 | <li><select id="geodir_add_listing" class="chosen_select" onchange="window.location.href=this.value" |
| 3329 | 3329 | option-autoredirect="1" name="geodir_add_listing" option-ajaxchosen="false" |
| 3330 | - data-placeholder="<?php echo esc_attr( __( 'Add Listing', 'geodirectory' ) ); ?>"> |
|
| 3330 | + data-placeholder="<?php echo esc_attr(__('Add Listing', 'geodirectory')); ?>">
|
|
| 3331 | 3331 | <option value="" disabled="disabled" selected="selected" |
| 3332 | - style='display:none;'><?php echo esc_attr( __( 'Add Listing', 'geodirectory' ) ); ?></option> |
|
| 3332 | + style='display:none;'><?php echo esc_attr(__('Add Listing', 'geodirectory')); ?></option>
|
|
| 3333 | 3333 | <?php echo $addlisting_links; ?> |
| 3334 | 3334 | </select></li> <?php |
| 3335 | 3335 | |
@@ -3337,23 +3337,23 @@ discard block |
||
| 3337 | 3337 | |
| 3338 | 3338 | } |
| 3339 | 3339 | // My Favourites in Dashboard |
| 3340 | - $show_favorite_link_user_dashboard = get_option( 'geodir_favorite_link_user_dashboard' ); |
|
| 3340 | + $show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard');
|
|
| 3341 | 3341 | $user_favourite = geodir_user_favourite_listing_count(); |
| 3342 | 3342 | |
| 3343 | - if ( ! empty( $show_favorite_link_user_dashboard ) && ! empty( $user_favourite ) ) {
|
|
| 3343 | + if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) {
|
|
| 3344 | 3344 | $favourite_links = ''; |
| 3345 | 3345 | |
| 3346 | - foreach ( $post_types as $key => $postobj ) {
|
|
| 3347 | - if ( in_array( $key, $show_favorite_link_user_dashboard ) && array_key_exists( $key, $user_favourite ) ) {
|
|
| 3346 | + foreach ($post_types as $key => $postobj) {
|
|
| 3347 | + if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) {
|
|
| 3348 | 3348 | $name = $postobj->labels->name; |
| 3349 | - $post_type_link = geodir_getlink( $author_link, array( |
|
| 3349 | + $post_type_link = geodir_getlink($author_link, array( |
|
| 3350 | 3350 | 'stype' => $key, |
| 3351 | 3351 | 'list' => 'favourite' |
| 3352 | - ), false ); |
|
| 3352 | + ), false); |
|
| 3353 | 3353 | |
| 3354 | 3354 | $selected = ''; |
| 3355 | 3355 | |
| 3356 | - if ( isset( $_REQUEST['list'] ) && $_REQUEST['list'] == 'favourite' && isset( $_REQUEST['stype'] ) && $_REQUEST['stype'] == $key && isset( $_REQUEST['geodir_dashbord'] ) ) {
|
|
| 3356 | + if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) {
|
|
| 3357 | 3357 | $selected = 'selected="selected"'; |
| 3358 | 3358 | } |
| 3359 | 3359 | /** |
@@ -3365,20 +3365,20 @@ discard block |
||
| 3365 | 3365 | * @param string $key Favorite listing array key. |
| 3366 | 3366 | * @param int $current_user ->ID Current user ID. |
| 3367 | 3367 | */ |
| 3368 | - $post_type_link = apply_filters( 'geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID ); |
|
| 3368 | + $post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
|
|
| 3369 | 3369 | |
| 3370 | - $favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __( ucfirst( $name ), 'geodirectory' ) . '</option>'; |
|
| 3370 | + $favourite_links .= '<option '.$selected.' value="'.$post_type_link.'">'.__(ucfirst($name), 'geodirectory').'</option>'; |
|
| 3371 | 3371 | } |
| 3372 | 3372 | } |
| 3373 | 3373 | |
| 3374 | - if ( $favourite_links != '' ) {
|
|
| 3374 | + if ($favourite_links != '') {
|
|
| 3375 | 3375 | ?> |
| 3376 | 3376 | <li> |
| 3377 | 3377 | <select id="geodir_my_favourites" class="chosen_select" onchange="window.location.href=this.value" |
| 3378 | 3378 | option-autoredirect="1" name="geodir_my_favourites" option-ajaxchosen="false" |
| 3379 | - data-placeholder="<?php echo esc_attr( __( 'My Favorites', 'geodirectory' ) ); ?>"> |
|
| 3379 | + data-placeholder="<?php echo esc_attr(__('My Favorites', 'geodirectory')); ?>">
|
|
| 3380 | 3380 | <option value="" disabled="disabled" selected="selected" |
| 3381 | - style='display:none;'><?php echo esc_attr( __( 'My Favorites', 'geodirectory' ) ); ?></option> |
|
| 3381 | + style='display:none;'><?php echo esc_attr(__('My Favorites', 'geodirectory')); ?></option>
|
|
| 3382 | 3382 | <?php echo $favourite_links; ?> |
| 3383 | 3383 | </select> |
| 3384 | 3384 | </li> |
@@ -3387,19 +3387,19 @@ discard block |
||
| 3387 | 3387 | } |
| 3388 | 3388 | |
| 3389 | 3389 | |
| 3390 | - $show_listing_link_user_dashboard = get_option( 'geodir_listing_link_user_dashboard' ); |
|
| 3390 | + $show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard');
|
|
| 3391 | 3391 | $user_listing = geodir_user_post_listing_count(); |
| 3392 | 3392 | |
| 3393 | - if ( ! empty( $show_listing_link_user_dashboard ) && ! empty( $user_listing ) ) {
|
|
| 3393 | + if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) {
|
|
| 3394 | 3394 | $listing_links = ''; |
| 3395 | 3395 | |
| 3396 | - foreach ( $post_types as $key => $postobj ) {
|
|
| 3397 | - if ( in_array( $key, $show_listing_link_user_dashboard ) && array_key_exists( $key, $user_listing ) ) {
|
|
| 3396 | + foreach ($post_types as $key => $postobj) {
|
|
| 3397 | + if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) {
|
|
| 3398 | 3398 | $name = $postobj->labels->name; |
| 3399 | - $listing_link = geodir_getlink( $author_link, array( 'stype' => $key ), false ); |
|
| 3399 | + $listing_link = geodir_getlink($author_link, array('stype' => $key), false);
|
|
| 3400 | 3400 | |
| 3401 | 3401 | $selected = ''; |
| 3402 | - if ( ! isset( $_REQUEST['list'] ) && isset( $_REQUEST['geodir_dashbord'] ) && isset( $_REQUEST['stype'] ) && $_REQUEST['stype'] == $key ) {
|
|
| 3402 | + if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) {
|
|
| 3403 | 3403 | $selected = 'selected="selected"'; |
| 3404 | 3404 | } |
| 3405 | 3405 | |
@@ -3412,20 +3412,20 @@ discard block |
||
| 3412 | 3412 | * @param string $key My listing array key. |
| 3413 | 3413 | * @param int $current_user ->ID Current user ID. |
| 3414 | 3414 | */ |
| 3415 | - $listing_link = apply_filters( 'geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID ); |
|
| 3415 | + $listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
|
|
| 3416 | 3416 | |
| 3417 | - $listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __( ucfirst( $name ), 'geodirectory' ) . '</option>'; |
|
| 3417 | + $listing_links .= '<option '.$selected.' value="'.$listing_link.'">'.__(ucfirst($name), 'geodirectory').'</option>'; |
|
| 3418 | 3418 | } |
| 3419 | 3419 | } |
| 3420 | 3420 | |
| 3421 | - if ( $listing_links != '' ) {
|
|
| 3421 | + if ($listing_links != '') {
|
|
| 3422 | 3422 | ?> |
| 3423 | 3423 | <li> |
| 3424 | 3424 | <select id="geodir_my_listings" class="chosen_select" onchange="window.location.href=this.value" |
| 3425 | 3425 | option-autoredirect="1" name="geodir_my_listings" option-ajaxchosen="false" |
| 3426 | - data-placeholder="<?php echo esc_attr( __( 'My Listings', 'geodirectory' ) ); ?>"> |
|
| 3426 | + data-placeholder="<?php echo esc_attr(__('My Listings', 'geodirectory')); ?>">
|
|
| 3427 | 3427 | <option value="" disabled="disabled" selected="selected" |
| 3428 | - style='display:none;'><?php echo esc_attr( __( 'My Listings', 'geodirectory' ) ); ?></option> |
|
| 3428 | + style='display:none;'><?php echo esc_attr(__('My Listings', 'geodirectory')); ?></option>
|
|
| 3429 | 3429 | <?php echo $listing_links; ?> |
| 3430 | 3430 | </select> |
| 3431 | 3431 | </li> |
@@ -3441,7 +3441,7 @@ discard block |
||
| 3441 | 3441 | * |
| 3442 | 3442 | * @param string $dashboard_link Dashboard links HTML. |
| 3443 | 3443 | */ |
| 3444 | - echo apply_filters( 'geodir_dashboard_links', $dashboard_link ); |
|
| 3444 | + echo apply_filters('geodir_dashboard_links', $dashboard_link);
|
|
| 3445 | 3445 | echo '</ul>'; |
| 3446 | 3446 | |
| 3447 | 3447 | /** |
@@ -3449,7 +3449,7 @@ discard block |
||
| 3449 | 3449 | * |
| 3450 | 3450 | * @since 1.6.6 |
| 3451 | 3451 | */ |
| 3452 | - do_action( 'geodir_after_loginwidget_form_logged_in' ); |
|
| 3452 | + do_action('geodir_after_loginwidget_form_logged_in');
|
|
| 3453 | 3453 | |
| 3454 | 3454 | |
| 3455 | 3455 | } else {
|
@@ -3464,18 +3464,18 @@ discard block |
||
| 3464 | 3464 | <form name="loginform" class="loginform1" |
| 3465 | 3465 | action="<?php echo geodir_login_url(); ?>" |
| 3466 | 3466 | method="post"> |
| 3467 | - <div class="geodir_form_row"><input placeholder="<?php _e( 'Email', 'geodirectory' ); ?>" name="log" |
|
| 3467 | + <div class="geodir_form_row"><input placeholder="<?php _e('Email', 'geodirectory'); ?>" name="log"
|
|
| 3468 | 3468 | type="text" class="textfield user_login1"/> <span |
| 3469 | 3469 | class="user_loginInfo"></span></div> |
| 3470 | - <div class="geodir_form_row"><input placeholder="<?php _e( 'Password', 'geodirectory' ); ?>" |
|
| 3470 | + <div class="geodir_form_row"><input placeholder="<?php _e('Password', 'geodirectory'); ?>"
|
|
| 3471 | 3471 | name="pwd" type="password" |
| 3472 | 3472 | class="textfield user_pass1 input-text"/><span |
| 3473 | 3473 | class="user_passInfo"></span></div> |
| 3474 | 3474 | |
| 3475 | - <input type="hidden" name="redirect_to" value="<?php echo htmlspecialchars( geodir_curPageURL() ); ?>"/> |
|
| 3475 | + <input type="hidden" name="redirect_to" value="<?php echo htmlspecialchars(geodir_curPageURL()); ?>"/> |
|
| 3476 | 3476 | <input type="hidden" name="testcookie" value="1"/> |
| 3477 | 3477 | |
| 3478 | - <?php do_action( 'login_form' ); ?> |
|
| 3478 | + <?php do_action('login_form'); ?>
|
|
| 3479 | 3479 | |
| 3480 | 3480 | <div class="geodir_form_row clearfix"><input type="submit" name="submit" |
| 3481 | 3481 | value="<?php echo SIGN_IN_BUTTON; ?>" class="b_signin"/> |
@@ -3488,7 +3488,7 @@ discard block |
||
| 3488 | 3488 | * @since 1.0.0 |
| 3489 | 3489 | */ |
| 3490 | 3490 | ?> |
| 3491 | - <a href="<?php echo geodir_login_url( array( 'signup' => true ) ); ?>" |
|
| 3491 | + <a href="<?php echo geodir_login_url(array('signup' => true)); ?>"
|
|
| 3492 | 3492 | class="goedir-newuser-link"><?php echo NEW_USER_TEXT; ?></a> |
| 3493 | 3493 | |
| 3494 | 3494 | <?php |
@@ -3498,7 +3498,7 @@ discard block |
||
| 3498 | 3498 | * @since 1.0.0 |
| 3499 | 3499 | */ |
| 3500 | 3500 | ?> |
| 3501 | - <a href="<?php echo geodir_login_url( array( 'forgot' => true ) ); ?>" |
|
| 3501 | + <a href="<?php echo geodir_login_url(array('forgot' => true)); ?>"
|
|
| 3502 | 3502 | class="goedir-forgot-link"><?php echo FORGOT_PW_TEXT; ?></a></p></div> |
| 3503 | 3503 | </form> |
| 3504 | 3504 | <?php |
@@ -3507,7 +3507,7 @@ discard block |
||
| 3507 | 3507 | * |
| 3508 | 3508 | * @since 1.6.6 |
| 3509 | 3509 | */ |
| 3510 | - do_action( 'geodir_after_loginwidget_form_logged_out' ); |
|
| 3510 | + do_action('geodir_after_loginwidget_form_logged_out');
|
|
| 3511 | 3511 | } |
| 3512 | 3512 | |
| 3513 | 3513 | echo $after_widget; |
@@ -3529,16 +3529,16 @@ discard block |
||
| 3529 | 3529 | * after_widget. |
| 3530 | 3530 | * @param array|string $instance The settings for the particular instance of the widget. |
| 3531 | 3531 | */ |
| 3532 | -function geodir_popular_postview_output( $args = '', $instance = '' ) {
|
|
| 3532 | +function geodir_popular_postview_output($args = '', $instance = '') {
|
|
| 3533 | 3533 | global $gd_session; |
| 3534 | 3534 | |
| 3535 | 3535 | // prints the widget |
| 3536 | - extract( $args, EXTR_SKIP ); |
|
| 3536 | + extract($args, EXTR_SKIP); |
|
| 3537 | 3537 | |
| 3538 | 3538 | echo $before_widget; |
| 3539 | 3539 | |
| 3540 | 3540 | /** This filter is documented in geodirectory_widgets.php */ |
| 3541 | - $title = empty( $instance['title'] ) ? geodir_ucwords( $instance['category_title'] ) : apply_filters( 'widget_title', __( $instance['title'], 'geodirectory' ) ); |
|
| 3541 | + $title = empty($instance['title']) ? geodir_ucwords($instance['category_title']) : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
|
|
| 3542 | 3542 | /** |
| 3543 | 3543 | * Filter the widget post type. |
| 3544 | 3544 | * |
@@ -3546,7 +3546,7 @@ discard block |
||
| 3546 | 3546 | * |
| 3547 | 3547 | * @param string $instance ['post_type'] Post type of listing. |
| 3548 | 3548 | */ |
| 3549 | - $post_type = empty( $instance['post_type'] ) ? 'gd_place' : apply_filters( 'widget_post_type', $instance['post_type'] ); |
|
| 3549 | + $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
|
|
| 3550 | 3550 | /** |
| 3551 | 3551 | * Filter the widget's term. |
| 3552 | 3552 | * |
@@ -3554,7 +3554,7 @@ discard block |
||
| 3554 | 3554 | * |
| 3555 | 3555 | * @param string $instance ['category'] Filter by term. Can be any valid term. |
| 3556 | 3556 | */ |
| 3557 | - $category = empty( $instance['category'] ) ? '0' : apply_filters( 'widget_category', $instance['category'] ); |
|
| 3557 | + $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
|
|
| 3558 | 3558 | /** |
| 3559 | 3559 | * Filter the widget listings limit. |
| 3560 | 3560 | * |
@@ -3562,7 +3562,7 @@ discard block |
||
| 3562 | 3562 | * |
| 3563 | 3563 | * @param string $instance ['post_number'] Number of listings to display. |
| 3564 | 3564 | */ |
| 3565 | - $post_number = empty( $instance['post_number'] ) ? '5' : apply_filters( 'widget_post_number', $instance['post_number'] ); |
|
| 3565 | + $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
|
|
| 3566 | 3566 | /** |
| 3567 | 3567 | * Filter widget's "layout" type. |
| 3568 | 3568 | * |
@@ -3570,7 +3570,7 @@ discard block |
||
| 3570 | 3570 | * |
| 3571 | 3571 | * @param string $instance ['layout'] Widget layout type. |
| 3572 | 3572 | */ |
| 3573 | - $layout = empty( $instance['layout'] ) ? 'gridview_onehalf' : apply_filters( 'widget_layout', $instance['layout'] ); |
|
| 3573 | + $layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']);
|
|
| 3574 | 3574 | /** |
| 3575 | 3575 | * Filter widget's "add_location_filter" value. |
| 3576 | 3576 | * |
@@ -3578,7 +3578,7 @@ discard block |
||
| 3578 | 3578 | * |
| 3579 | 3579 | * @param string|bool $instance ['add_location_filter'] Do you want to add location filter? Can be 1 or 0. |
| 3580 | 3580 | */ |
| 3581 | - $add_location_filter = empty( $instance['add_location_filter'] ) ? '0' : apply_filters( 'widget_add_location_filter', $instance['add_location_filter'] ); |
|
| 3581 | + $add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']);
|
|
| 3582 | 3582 | /** |
| 3583 | 3583 | * Filter widget's listing width. |
| 3584 | 3584 | * |
@@ -3586,7 +3586,7 @@ discard block |
||
| 3586 | 3586 | * |
| 3587 | 3587 | * @param string $instance ['listing_width'] Listing width. |
| 3588 | 3588 | */ |
| 3589 | - $listing_width = empty( $instance['listing_width'] ) ? '' : apply_filters( 'widget_listing_width', $instance['listing_width'] ); |
|
| 3589 | + $listing_width = empty($instance['listing_width']) ? '' : apply_filters('widget_listing_width', $instance['listing_width']);
|
|
| 3590 | 3590 | /** |
| 3591 | 3591 | * Filter widget's "list_sort" type. |
| 3592 | 3592 | * |
@@ -3594,25 +3594,25 @@ discard block |
||
| 3594 | 3594 | * |
| 3595 | 3595 | * @param string $instance ['list_sort'] Listing sort by type. |
| 3596 | 3596 | */ |
| 3597 | - $list_sort = empty( $instance['list_sort'] ) ? 'latest' : apply_filters( 'widget_list_sort', $instance['list_sort'] ); |
|
| 3598 | - $use_viewing_post_type = ! empty( $instance['use_viewing_post_type'] ) ? true : false; |
|
| 3597 | + $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
|
|
| 3598 | + $use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false; |
|
| 3599 | 3599 | |
| 3600 | 3600 | // set post type to current viewing post type |
| 3601 | - if ( $use_viewing_post_type ) {
|
|
| 3601 | + if ($use_viewing_post_type) {
|
|
| 3602 | 3602 | $current_post_type = geodir_get_current_posttype(); |
| 3603 | - if ( $current_post_type != '' && $current_post_type != $post_type ) {
|
|
| 3603 | + if ($current_post_type != '' && $current_post_type != $post_type) {
|
|
| 3604 | 3604 | $post_type = $current_post_type; |
| 3605 | 3605 | $category = array(); // old post type category will not work for current changed post type |
| 3606 | 3606 | } |
| 3607 | 3607 | } |
| 3608 | 3608 | // replace widget title dynamically |
| 3609 | - $posttype_plural_label = __( get_post_type_plural_label( $post_type ), 'geodirectory' ); |
|
| 3610 | - $posttype_singular_label = __( get_post_type_singular_label( $post_type ), 'geodirectory' ); |
|
| 3609 | + $posttype_plural_label = __(get_post_type_plural_label($post_type), 'geodirectory'); |
|
| 3610 | + $posttype_singular_label = __(get_post_type_singular_label($post_type), 'geodirectory'); |
|
| 3611 | 3611 | |
| 3612 | - $title = str_replace( "%posttype_plural_label%", $posttype_plural_label, $title ); |
|
| 3613 | - $title = str_replace( "%posttype_singular_label%", $posttype_singular_label, $title ); |
|
| 3612 | + $title = str_replace("%posttype_plural_label%", $posttype_plural_label, $title);
|
|
| 3613 | + $title = str_replace("%posttype_singular_label%", $posttype_singular_label, $title);
|
|
| 3614 | 3614 | |
| 3615 | - if ( isset( $instance['character_count'] ) ) {
|
|
| 3615 | + if (isset($instance['character_count'])) {
|
|
| 3616 | 3616 | /** |
| 3617 | 3617 | * Filter the widget's excerpt character count. |
| 3618 | 3618 | * |
@@ -3620,37 +3620,37 @@ discard block |
||
| 3620 | 3620 | * |
| 3621 | 3621 | * @param int $instance ['character_count'] Excerpt character count. |
| 3622 | 3622 | */ |
| 3623 | - $character_count = apply_filters( 'widget_list_character_count', $instance['character_count'] ); |
|
| 3623 | + $character_count = apply_filters('widget_list_character_count', $instance['character_count']);
|
|
| 3624 | 3624 | } else {
|
| 3625 | 3625 | $character_count = ''; |
| 3626 | 3626 | } |
| 3627 | 3627 | |
| 3628 | - if ( empty( $title ) || $title == 'All' ) {
|
|
| 3629 | - $title .= ' ' . __( get_post_type_plural_label( $post_type ), 'geodirectory' ); |
|
| 3628 | + if (empty($title) || $title == 'All') {
|
|
| 3629 | + $title .= ' '.__(get_post_type_plural_label($post_type), 'geodirectory'); |
|
| 3630 | 3630 | } |
| 3631 | 3631 | |
| 3632 | 3632 | $location_url = array(); |
| 3633 | - $city = get_query_var( 'gd_city' ); |
|
| 3634 | - if ( ! empty( $city ) ) {
|
|
| 3635 | - $country = get_query_var( 'gd_country' ); |
|
| 3636 | - $region = get_query_var( 'gd_region' ); |
|
| 3633 | + $city = get_query_var('gd_city');
|
|
| 3634 | + if (!empty($city)) {
|
|
| 3635 | + $country = get_query_var('gd_country');
|
|
| 3636 | + $region = get_query_var('gd_region');
|
|
| 3637 | 3637 | |
| 3638 | - $geodir_show_location_url = get_option( 'geodir_show_location_url' ); |
|
| 3638 | + $geodir_show_location_url = get_option('geodir_show_location_url');
|
|
| 3639 | 3639 | |
| 3640 | - if ( $geodir_show_location_url == 'all' ) {
|
|
| 3641 | - if ( $country != '' ) {
|
|
| 3640 | + if ($geodir_show_location_url == 'all') {
|
|
| 3641 | + if ($country != '') {
|
|
| 3642 | 3642 | $location_url[] = $country; |
| 3643 | 3643 | } |
| 3644 | 3644 | |
| 3645 | - if ( $region != '' ) {
|
|
| 3645 | + if ($region != '') {
|
|
| 3646 | 3646 | $location_url[] = $region; |
| 3647 | 3647 | } |
| 3648 | - } else if ( $geodir_show_location_url == 'country_city' ) {
|
|
| 3649 | - if ( $country != '' ) {
|
|
| 3648 | + } else if ($geodir_show_location_url == 'country_city') {
|
|
| 3649 | + if ($country != '') {
|
|
| 3650 | 3650 | $location_url[] = $country; |
| 3651 | 3651 | } |
| 3652 | - } else if ( $geodir_show_location_url == 'region_city' ) {
|
|
| 3653 | - if ( $region != '' ) {
|
|
| 3652 | + } else if ($geodir_show_location_url == 'region_city') {
|
|
| 3653 | + if ($region != '') {
|
|
| 3654 | 3654 | $location_url[] = $region; |
| 3655 | 3655 | } |
| 3656 | 3656 | } |
@@ -3658,37 +3658,37 @@ discard block |
||
| 3658 | 3658 | $location_url[] = $city; |
| 3659 | 3659 | } |
| 3660 | 3660 | |
| 3661 | - $location_url = implode( '/', $location_url ); |
|
| 3661 | + $location_url = implode('/', $location_url);
|
|
| 3662 | 3662 | $skip_location = false; |
| 3663 | - if ( ! $add_location_filter && $gd_session->get( 'gd_multi_location' ) ) {
|
|
| 3663 | + if (!$add_location_filter && $gd_session->get('gd_multi_location')) {
|
|
| 3664 | 3664 | $skip_location = true; |
| 3665 | - $gd_session->un_set( 'gd_multi_location' ); |
|
| 3665 | + $gd_session->un_set('gd_multi_location');
|
|
| 3666 | 3666 | } |
| 3667 | 3667 | |
| 3668 | - if ( get_option( 'permalink_structure' ) ) {
|
|
| 3669 | - $viewall_url = get_post_type_archive_link( $post_type ); |
|
| 3668 | + if (get_option('permalink_structure')) {
|
|
| 3669 | + $viewall_url = get_post_type_archive_link($post_type); |
|
| 3670 | 3670 | } else {
|
| 3671 | - $viewall_url = get_post_type_archive_link( $post_type ); |
|
| 3671 | + $viewall_url = get_post_type_archive_link($post_type); |
|
| 3672 | 3672 | } |
| 3673 | 3673 | |
| 3674 | - if ( ! empty( $category ) && $category[0] != '0' ) {
|
|
| 3674 | + if (!empty($category) && $category[0] != '0') {
|
|
| 3675 | 3675 | global $geodir_add_location_url; |
| 3676 | 3676 | |
| 3677 | 3677 | $geodir_add_location_url = '0'; |
| 3678 | 3678 | |
| 3679 | - if ( $add_location_filter != '0' ) {
|
|
| 3679 | + if ($add_location_filter != '0') {
|
|
| 3680 | 3680 | $geodir_add_location_url = '1'; |
| 3681 | 3681 | } |
| 3682 | 3682 | |
| 3683 | - $viewall_url = get_term_link( (int) $category[0], $post_type . 'category' ); |
|
| 3683 | + $viewall_url = get_term_link((int) $category[0], $post_type.'category'); |
|
| 3684 | 3684 | |
| 3685 | 3685 | $geodir_add_location_url = null; |
| 3686 | 3686 | } |
| 3687 | - if ( $skip_location ) {
|
|
| 3688 | - $gd_session->set( 'gd_multi_location', 1 ); |
|
| 3687 | + if ($skip_location) {
|
|
| 3688 | + $gd_session->set('gd_multi_location', 1);
|
|
| 3689 | 3689 | } |
| 3690 | 3690 | |
| 3691 | - if ( is_wp_error( $viewall_url ) ) {
|
|
| 3691 | + if (is_wp_error($viewall_url)) {
|
|
| 3692 | 3692 | $viewall_url = ''; |
| 3693 | 3693 | } |
| 3694 | 3694 | |
@@ -3700,34 +3700,34 @@ discard block |
||
| 3700 | 3700 | 'order_by' => $list_sort |
| 3701 | 3701 | ); |
| 3702 | 3702 | |
| 3703 | - if ( $character_count ) {
|
|
| 3703 | + if ($character_count) {
|
|
| 3704 | 3704 | $query_args['excerpt_length'] = $character_count; |
| 3705 | 3705 | } |
| 3706 | 3706 | |
| 3707 | - if ( ! empty( $instance['show_featured_only'] ) ) {
|
|
| 3707 | + if (!empty($instance['show_featured_only'])) {
|
|
| 3708 | 3708 | $query_args['show_featured_only'] = 1; |
| 3709 | 3709 | } |
| 3710 | 3710 | |
| 3711 | - if ( ! empty( $instance['show_special_only'] ) ) {
|
|
| 3711 | + if (!empty($instance['show_special_only'])) {
|
|
| 3712 | 3712 | $query_args['show_special_only'] = 1; |
| 3713 | 3713 | } |
| 3714 | 3714 | |
| 3715 | - if ( ! empty( $instance['with_pics_only'] ) ) {
|
|
| 3715 | + if (!empty($instance['with_pics_only'])) {
|
|
| 3716 | 3716 | $query_args['with_pics_only'] = 0; |
| 3717 | 3717 | $query_args['featured_image_only'] = 1; |
| 3718 | 3718 | } |
| 3719 | 3719 | |
| 3720 | - if ( ! empty( $instance['with_videos_only'] ) ) {
|
|
| 3720 | + if (!empty($instance['with_videos_only'])) {
|
|
| 3721 | 3721 | $query_args['with_videos_only'] = 1; |
| 3722 | 3722 | } |
| 3723 | - $with_no_results = ! empty( $instance['without_no_results'] ) ? false : true; |
|
| 3723 | + $with_no_results = !empty($instance['without_no_results']) ? false : true; |
|
| 3724 | 3724 | |
| 3725 | - if ( ! empty( $category ) && $category[0] != '0' ) {
|
|
| 3726 | - $category_taxonomy = geodir_get_taxonomies( $post_type ); |
|
| 3725 | + if (!empty($category) && $category[0] != '0') {
|
|
| 3726 | + $category_taxonomy = geodir_get_taxonomies($post_type); |
|
| 3727 | 3727 | |
| 3728 | 3728 | ######### WPML ######### |
| 3729 | - if ( function_exists( 'icl_object_id' ) ) {
|
|
| 3730 | - $category = gd_lang_object_ids( $category, $category_taxonomy[0] ); |
|
| 3729 | + if (function_exists('icl_object_id')) {
|
|
| 3730 | + $category = gd_lang_object_ids($category, $category_taxonomy[0]); |
|
| 3731 | 3731 | } |
| 3732 | 3732 | ######### WPML ######### |
| 3733 | 3733 | |
@@ -3737,14 +3737,14 @@ discard block |
||
| 3737 | 3737 | 'terms' => $category |
| 3738 | 3738 | ); |
| 3739 | 3739 | |
| 3740 | - $query_args['tax_query'] = array( $tax_query ); |
|
| 3740 | + $query_args['tax_query'] = array($tax_query); |
|
| 3741 | 3741 | } |
| 3742 | 3742 | |
| 3743 | 3743 | global $gridview_columns_widget, $geodir_is_widget_listing; |
| 3744 | 3744 | |
| 3745 | - $widget_listings = geodir_get_widget_listings( $query_args ); |
|
| 3745 | + $widget_listings = geodir_get_widget_listings($query_args); |
|
| 3746 | 3746 | |
| 3747 | - if ( ! empty( $widget_listings ) || $with_no_results ) {
|
|
| 3747 | + if (!empty($widget_listings) || $with_no_results) {
|
|
| 3748 | 3748 | ?> |
| 3749 | 3749 | <div class="geodir_locations geodir_location_listing"> |
| 3750 | 3750 | |
@@ -3754,11 +3754,11 @@ discard block |
||
| 3754 | 3754 | * |
| 3755 | 3755 | * @since 1.0.0 |
| 3756 | 3756 | */ |
| 3757 | - do_action( 'geodir_before_view_all_link_in_widget' ); ?> |
|
| 3757 | + do_action('geodir_before_view_all_link_in_widget'); ?>
|
|
| 3758 | 3758 | <div class="geodir_list_heading clearfix"> |
| 3759 | - <?php echo $before_title . $title . $after_title; ?> |
|
| 3759 | + <?php echo $before_title.$title.$after_title; ?> |
|
| 3760 | 3760 | <a href="<?php echo $viewall_url; ?>" |
| 3761 | - class="geodir-viewall"><?php _e( 'View all', 'geodirectory' ); ?></a> |
|
| 3761 | + class="geodir-viewall"><?php _e('View all', 'geodirectory'); ?></a>
|
|
| 3762 | 3762 | </div> |
| 3763 | 3763 | <?php |
| 3764 | 3764 | /** |
@@ -3766,10 +3766,10 @@ discard block |
||
| 3766 | 3766 | * |
| 3767 | 3767 | * @since 1.0.0 |
| 3768 | 3768 | */ |
| 3769 | - do_action( 'geodir_after_view_all_link_in_widget' ); ?> |
|
| 3769 | + do_action('geodir_after_view_all_link_in_widget'); ?>
|
|
| 3770 | 3770 | <?php |
| 3771 | - if ( strstr( $layout, 'gridview' ) ) {
|
|
| 3772 | - $listing_view_exp = explode( '_', $layout ); |
|
| 3771 | + if (strstr($layout, 'gridview')) {
|
|
| 3772 | + $listing_view_exp = explode('_', $layout);
|
|
| 3773 | 3773 | $gridview_columns_widget = $layout; |
| 3774 | 3774 | $layout = $listing_view_exp[0]; |
| 3775 | 3775 | } else {
|
@@ -3781,8 +3781,8 @@ discard block |
||
| 3781 | 3781 | * |
| 3782 | 3782 | * @since 1.0.0 |
| 3783 | 3783 | */ |
| 3784 | - $template = apply_filters( "geodir_template_part-widget-listing-listview", geodir_locate_template( 'widget-listing-listview' ) ); |
|
| 3785 | - if ( ! isset( $character_count ) ) {
|
|
| 3784 | + $template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
|
|
| 3785 | + if (!isset($character_count)) {
|
|
| 3786 | 3786 | /** |
| 3787 | 3787 | * Filter the widget's excerpt character count. |
| 3788 | 3788 | * |
@@ -3790,7 +3790,7 @@ discard block |
||
| 3790 | 3790 | * |
| 3791 | 3791 | * @param int $instance ['character_count'] Excerpt character count. |
| 3792 | 3792 | */ |
| 3793 | - $character_count = $character_count == '' ? 50 : apply_filters( 'widget_character_count', $character_count ); |
|
| 3793 | + $character_count = $character_count == '' ? 50 : apply_filters('widget_character_count', $character_count);
|
|
| 3794 | 3794 | } |
| 3795 | 3795 | |
| 3796 | 3796 | global $post, $map_jason, $map_canvas_arr; |
@@ -3805,13 +3805,13 @@ discard block |
||
| 3805 | 3805 | * |
| 3806 | 3806 | * @since 1.0.0 |
| 3807 | 3807 | */ |
| 3808 | - include( $template ); |
|
| 3808 | + include($template); |
|
| 3809 | 3809 | |
| 3810 | 3810 | $geodir_is_widget_listing = false; |
| 3811 | 3811 | |
| 3812 | 3812 | $GLOBALS['post'] = $current_post; |
| 3813 | - if ( ! empty( $current_post ) ) {
|
|
| 3814 | - setup_postdata( $current_post ); |
|
| 3813 | + if (!empty($current_post)) {
|
|
| 3814 | + setup_postdata($current_post); |
|
| 3815 | 3815 | } |
| 3816 | 3816 | $map_jason = $current_map_jason; |
| 3817 | 3817 | $map_canvas_arr = $current_map_canvas_arr; |
@@ -3842,12 +3842,12 @@ discard block |
||
| 3842 | 3842 | * |
| 3843 | 3843 | * @return int Reviews count. |
| 3844 | 3844 | */ |
| 3845 | -function geodir_count_reviews_by_term_id( $term_id, $taxonomy, $post_type ) {
|
|
| 3845 | +function geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type) {
|
|
| 3846 | 3846 | global $wpdb, $plugin_prefix; |
| 3847 | 3847 | |
| 3848 | - $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 3848 | + $detail_table = $plugin_prefix.$post_type.'_detail'; |
|
| 3849 | 3849 | |
| 3850 | - $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 . ")";
|
|
| 3850 | + $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.")";
|
|
| 3851 | 3851 | |
| 3852 | 3852 | /** |
| 3853 | 3853 | * Filter count review sql query. |
@@ -3859,9 +3859,9 @@ discard block |
||
| 3859 | 3859 | * @param int $taxonomy The taxonomy Id. |
| 3860 | 3860 | * @param string $post_type The post type. |
| 3861 | 3861 | */ |
| 3862 | - $sql = apply_filters( 'geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type ); |
|
| 3862 | + $sql = apply_filters('geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type);
|
|
| 3863 | 3863 | |
| 3864 | - $count = $wpdb->get_var( $sql ); |
|
| 3864 | + $count = $wpdb->get_var($sql); |
|
| 3865 | 3865 | |
| 3866 | 3866 | return $count; |
| 3867 | 3867 | } |
@@ -3879,7 +3879,7 @@ discard block |
||
| 3879 | 3879 | * |
| 3880 | 3880 | * @return array Term array data. |
| 3881 | 3881 | */ |
| 3882 | -function geodir_count_reviews_by_terms( $force_update = false, $post_ID = 0 ) {
|
|
| 3882 | +function geodir_count_reviews_by_terms($force_update = false, $post_ID = 0) {
|
|
| 3883 | 3883 | /** |
| 3884 | 3884 | * Filter review count option data. |
| 3885 | 3885 | * |
@@ -3889,78 +3889,78 @@ discard block |
||
| 3889 | 3889 | * @param bool $force_update Force update option value?. Default.false. |
| 3890 | 3890 | * @param int $post_ID The post id to update if any. |
| 3891 | 3891 | */ |
| 3892 | - $option_data = apply_filters( 'geodir_count_reviews_by_terms_before', '', $force_update, $post_ID ); |
|
| 3893 | - if ( ! empty( $option_data ) ) {
|
|
| 3892 | + $option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update, $post_ID);
|
|
| 3893 | + if (!empty($option_data)) {
|
|
| 3894 | 3894 | return $option_data; |
| 3895 | 3895 | } |
| 3896 | 3896 | |
| 3897 | - $option_data = get_option( 'geodir_global_review_count' ); |
|
| 3897 | + $option_data = get_option('geodir_global_review_count');
|
|
| 3898 | 3898 | |
| 3899 | - if ( ! $option_data || $force_update ) {
|
|
| 3900 | - if ( (int) $post_ID > 0 ) { // Update reviews count for specific post categories only.
|
|
| 3899 | + if (!$option_data || $force_update) {
|
|
| 3900 | + if ((int) $post_ID > 0) { // Update reviews count for specific post categories only.
|
|
| 3901 | 3901 | global $gd_session; |
| 3902 | 3902 | $term_array = (array) $option_data; |
| 3903 | - $post_type = get_post_type( $post_ID ); |
|
| 3904 | - $taxonomy = $post_type . 'category'; |
|
| 3905 | - $terms = wp_get_object_terms( $post_ID, $taxonomy, array( 'fields' => 'ids' ) ); |
|
| 3906 | - |
|
| 3907 | - if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
|
|
| 3908 | - foreach ( $terms as $term_id ) {
|
|
| 3909 | - $count = geodir_count_reviews_by_term_id( $term_id, $taxonomy, $post_type ); |
|
| 3910 | - $children = get_term_children( $term_id, $taxonomy ); |
|
| 3911 | - $term_array[ $term_id ] = $count; |
|
| 3903 | + $post_type = get_post_type($post_ID); |
|
| 3904 | + $taxonomy = $post_type.'category'; |
|
| 3905 | + $terms = wp_get_object_terms($post_ID, $taxonomy, array('fields' => 'ids'));
|
|
| 3906 | + |
|
| 3907 | + if (!empty($terms) && !is_wp_error($terms)) {
|
|
| 3908 | + foreach ($terms as $term_id) {
|
|
| 3909 | + $count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type); |
|
| 3910 | + $children = get_term_children($term_id, $taxonomy); |
|
| 3911 | + $term_array[$term_id] = $count; |
|
| 3912 | 3912 | } |
| 3913 | 3913 | } |
| 3914 | 3914 | |
| 3915 | - $session_listing = $gd_session->get( 'listing' ); |
|
| 3915 | + $session_listing = $gd_session->get('listing');
|
|
| 3916 | 3916 | |
| 3917 | 3917 | $terms = array(); |
| 3918 | - if ( isset( $_POST['post_category'][ $taxonomy ] ) ) {
|
|
| 3919 | - $terms = (array) $_POST['post_category'][ $taxonomy ]; |
|
| 3920 | - } else if ( ! empty( $session_listing ) && isset( $session_listing['post_category'][ $taxonomy ] ) ) {
|
|
| 3921 | - $terms = (array) $session_listing['post_category'][ $taxonomy ]; |
|
| 3918 | + if (isset($_POST['post_category'][$taxonomy])) {
|
|
| 3919 | + $terms = (array) $_POST['post_category'][$taxonomy]; |
|
| 3920 | + } else if (!empty($session_listing) && isset($session_listing['post_category'][$taxonomy])) {
|
|
| 3921 | + $terms = (array) $session_listing['post_category'][$taxonomy]; |
|
| 3922 | 3922 | } |
| 3923 | 3923 | |
| 3924 | - if ( ! empty( $terms ) ) {
|
|
| 3925 | - foreach ( $terms as $term_id ) {
|
|
| 3926 | - if ( $term_id > 0 ) {
|
|
| 3927 | - $count = geodir_count_reviews_by_term_id( $term_id, $taxonomy, $post_type ); |
|
| 3928 | - $children = get_term_children( $term_id, $taxonomy ); |
|
| 3929 | - $term_array[ $term_id ] = $count; |
|
| 3924 | + if (!empty($terms)) {
|
|
| 3925 | + foreach ($terms as $term_id) {
|
|
| 3926 | + if ($term_id > 0) {
|
|
| 3927 | + $count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type); |
|
| 3928 | + $children = get_term_children($term_id, $taxonomy); |
|
| 3929 | + $term_array[$term_id] = $count; |
|
| 3930 | 3930 | } |
| 3931 | 3931 | } |
| 3932 | 3932 | } |
| 3933 | 3933 | } else { // Update reviews count for all post categories.
|
| 3934 | 3934 | $term_array = array(); |
| 3935 | 3935 | $post_types = geodir_get_posttypes(); |
| 3936 | - foreach ( $post_types as $post_type ) {
|
|
| 3936 | + foreach ($post_types as $post_type) {
|
|
| 3937 | 3937 | |
| 3938 | - $taxonomy = geodir_get_taxonomies( $post_type ); |
|
| 3938 | + $taxonomy = geodir_get_taxonomies($post_type); |
|
| 3939 | 3939 | $taxonomy = $taxonomy[0]; |
| 3940 | 3940 | |
| 3941 | 3941 | $args = array( |
| 3942 | 3942 | 'hide_empty' => false |
| 3943 | 3943 | ); |
| 3944 | 3944 | |
| 3945 | - $terms = get_terms( $taxonomy, $args ); |
|
| 3945 | + $terms = get_terms($taxonomy, $args); |
|
| 3946 | 3946 | |
| 3947 | - foreach ( $terms as $term ) {
|
|
| 3948 | - $count = geodir_count_reviews_by_term_id( $term->term_id, $taxonomy, $post_type ); |
|
| 3949 | - $children = get_term_children( $term->term_id, $taxonomy ); |
|
| 3947 | + foreach ($terms as $term) {
|
|
| 3948 | + $count = geodir_count_reviews_by_term_id($term->term_id, $taxonomy, $post_type); |
|
| 3949 | + $children = get_term_children($term->term_id, $taxonomy); |
|
| 3950 | 3950 | /*if ( is_array( $children ) ) {
|
| 3951 | 3951 | foreach ( $children as $child_id ) {
|
| 3952 | 3952 | $child_count = geodir_count_reviews_by_term_id($child_id, $taxonomy, $post_type); |
| 3953 | 3953 | $count = $count + $child_count; |
| 3954 | 3954 | } |
| 3955 | 3955 | }*/ |
| 3956 | - $term_array[ $term->term_id ] = $count; |
|
| 3956 | + $term_array[$term->term_id] = $count; |
|
| 3957 | 3957 | } |
| 3958 | 3958 | } |
| 3959 | 3959 | } |
| 3960 | 3960 | |
| 3961 | - update_option( 'geodir_global_review_count', $term_array ); |
|
| 3961 | + update_option('geodir_global_review_count', $term_array);
|
|
| 3962 | 3962 | //clear cache |
| 3963 | - wp_cache_delete( 'geodir_global_review_count' ); |
|
| 3963 | + wp_cache_delete('geodir_global_review_count');
|
|
| 3964 | 3964 | |
| 3965 | 3965 | return $term_array; |
| 3966 | 3966 | } else {
|
@@ -3976,39 +3976,39 @@ discard block |
||
| 3976 | 3976 | * @package GeoDirectory |
| 3977 | 3977 | * @return bool |
| 3978 | 3978 | */ |
| 3979 | -function geodir_term_review_count_force_update( $new_status, $old_status = '', $post = '' ) {
|
|
| 3980 | - if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'geodir_import_export' ) {
|
|
| 3979 | +function geodir_term_review_count_force_update($new_status, $old_status = '', $post = '') {
|
|
| 3980 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'geodir_import_export') {
|
|
| 3981 | 3981 | return; // do not run if importing listings |
| 3982 | 3982 | } |
| 3983 | 3983 | |
| 3984 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
|
| 3984 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
|
|
| 3985 | 3985 | return; |
| 3986 | 3986 | } |
| 3987 | 3987 | |
| 3988 | 3988 | $post_ID = 0; |
| 3989 | - if ( ! empty( $post ) ) {
|
|
| 3990 | - if ( isset( $post->post_type ) && strpos( $post->post_type, 'gd_' ) !== 0 ) {
|
|
| 3989 | + if (!empty($post)) {
|
|
| 3990 | + if (isset($post->post_type) && strpos($post->post_type, 'gd_') !== 0) {
|
|
| 3991 | 3991 | return; |
| 3992 | 3992 | } |
| 3993 | 3993 | |
| 3994 | - if ( $new_status == 'auto-draft' && $old_status == 'new' ) {
|
|
| 3994 | + if ($new_status == 'auto-draft' && $old_status == 'new') {
|
|
| 3995 | 3995 | return; |
| 3996 | 3996 | } |
| 3997 | 3997 | |
| 3998 | - if ( ! empty( $post->ID ) ) {
|
|
| 3998 | + if (!empty($post->ID)) {
|
|
| 3999 | 3999 | $post_ID = $post->ID; |
| 4000 | 4000 | } |
| 4001 | 4001 | } |
| 4002 | 4002 | |
| 4003 | - if ( $new_status != $old_status ) {
|
|
| 4004 | - geodir_count_reviews_by_terms( true, $post_ID ); |
|
| 4003 | + if ($new_status != $old_status) {
|
|
| 4004 | + geodir_count_reviews_by_terms(true, $post_ID); |
|
| 4005 | 4005 | } |
| 4006 | 4006 | |
| 4007 | 4007 | return true; |
| 4008 | 4008 | } |
| 4009 | 4009 | |
| 4010 | -function geodir_term_review_count_force_update_single_post( $post_id ) {
|
|
| 4011 | - geodir_count_reviews_by_terms( true, $post_id ); |
|
| 4010 | +function geodir_term_review_count_force_update_single_post($post_id) {
|
|
| 4011 | + geodir_count_reviews_by_terms(true, $post_id); |
|
| 4012 | 4012 | } |
| 4013 | 4013 | |
| 4014 | 4014 | /*-----------------------------------------------------------------------------------*/ |
@@ -4025,11 +4025,11 @@ discard block |
||
| 4025 | 4025 | * |
| 4026 | 4026 | * @return int Post count. |
| 4027 | 4027 | */ |
| 4028 | -function geodir_count_posts_by_term( $data, $term ) {
|
|
| 4028 | +function geodir_count_posts_by_term($data, $term) {
|
|
| 4029 | 4029 | |
| 4030 | - if ( $data ) {
|
|
| 4031 | - if ( isset( $data[ $term->term_id ] ) ) {
|
|
| 4032 | - return $data[ $term->term_id ]; |
|
| 4030 | + if ($data) {
|
|
| 4031 | + if (isset($data[$term->term_id])) {
|
|
| 4032 | + return $data[$term->term_id]; |
|
| 4033 | 4033 | } else {
|
| 4034 | 4034 | return 0; |
| 4035 | 4035 | } |
@@ -4046,8 +4046,8 @@ discard block |
||
| 4046 | 4046 | * param array $terms An array of term objects. |
| 4047 | 4047 | * @return array Sorted terms array. |
| 4048 | 4048 | */ |
| 4049 | -function geodir_sort_terms_by_count( $terms ) {
|
|
| 4050 | - usort( $terms, "geodir_sort_by_count_obj" ); |
|
| 4049 | +function geodir_sort_terms_by_count($terms) {
|
|
| 4050 | + usort($terms, "geodir_sort_by_count_obj"); |
|
| 4051 | 4051 | |
| 4052 | 4052 | return $terms; |
| 4053 | 4053 | } |
@@ -4062,8 +4062,8 @@ discard block |
||
| 4062 | 4062 | * |
| 4063 | 4063 | * @return array Sorted terms array. |
| 4064 | 4064 | */ |
| 4065 | -function geodir_sort_terms_by_review_count( $terms ) {
|
|
| 4066 | - usort( $terms, "geodir_sort_by_review_count_obj" ); |
|
| 4065 | +function geodir_sort_terms_by_review_count($terms) {
|
|
| 4066 | + usort($terms, "geodir_sort_by_review_count_obj"); |
|
| 4067 | 4067 | |
| 4068 | 4068 | return $terms; |
| 4069 | 4069 | } |
@@ -4079,12 +4079,12 @@ discard block |
||
| 4079 | 4079 | * |
| 4080 | 4080 | * @return array Sorted terms array. |
| 4081 | 4081 | */ |
| 4082 | -function geodir_sort_terms( $terms, $sort = 'count' ) {
|
|
| 4083 | - if ( $sort == 'count' ) {
|
|
| 4084 | - return geodir_sort_terms_by_count( $terms ); |
|
| 4082 | +function geodir_sort_terms($terms, $sort = 'count') {
|
|
| 4083 | + if ($sort == 'count') {
|
|
| 4084 | + return geodir_sort_terms_by_count($terms); |
|
| 4085 | 4085 | } |
| 4086 | - if ( $sort == 'review_count' ) {
|
|
| 4087 | - return geodir_sort_terms_by_review_count( $terms ); |
|
| 4086 | + if ($sort == 'review_count') {
|
|
| 4087 | + return geodir_sort_terms_by_review_count($terms); |
|
| 4088 | 4088 | } |
| 4089 | 4089 | } |
| 4090 | 4090 | |
@@ -4102,7 +4102,7 @@ discard block |
||
| 4102 | 4102 | * |
| 4103 | 4103 | * @return bool |
| 4104 | 4104 | */ |
| 4105 | -function geodir_sort_by_count( $a, $b ) {
|
|
| 4105 | +function geodir_sort_by_count($a, $b) {
|
|
| 4106 | 4106 | return $a['count'] < $b['count']; |
| 4107 | 4107 | } |
| 4108 | 4108 | |
@@ -4117,7 +4117,7 @@ discard block |
||
| 4117 | 4117 | * |
| 4118 | 4118 | * @return bool |
| 4119 | 4119 | */ |
| 4120 | -function geodir_sort_by_count_obj( $a, $b ) {
|
|
| 4120 | +function geodir_sort_by_count_obj($a, $b) {
|
|
| 4121 | 4121 | return $a->count < $b->count; |
| 4122 | 4122 | } |
| 4123 | 4123 | |
@@ -4132,7 +4132,7 @@ discard block |
||
| 4132 | 4132 | * |
| 4133 | 4133 | * @return bool |
| 4134 | 4134 | */ |
| 4135 | -function geodir_sort_by_review_count_obj( $a, $b ) {
|
|
| 4135 | +function geodir_sort_by_review_count_obj($a, $b) {
|
|
| 4136 | 4136 | return $a->review_count < $b->review_count; |
| 4137 | 4137 | } |
| 4138 | 4138 | |
@@ -4149,35 +4149,35 @@ discard block |
||
| 4149 | 4149 | * @since 1.4.2 |
| 4150 | 4150 | * @package GeoDirectory |
| 4151 | 4151 | */ |
| 4152 | - $locale = apply_filters( 'plugin_locale', get_locale(), 'geodirectory' ); |
|
| 4152 | + $locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
|
|
| 4153 | 4153 | |
| 4154 | - load_textdomain( 'geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo' ); |
|
| 4155 | - load_plugin_textdomain( 'geodirectory', false, plugin_basename( dirname( dirname( __FILE__ ) ) ) . '/geodirectory-languages' ); |
|
| 4154 | + load_textdomain('geodirectory', WP_LANG_DIR.'/'.'geodirectory'.'/'.'geodirectory'.'-'.$locale.'.mo');
|
|
| 4155 | + load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))).'/geodirectory-languages');
|
|
| 4156 | 4156 | |
| 4157 | 4157 | /** |
| 4158 | 4158 | * Define language constants. |
| 4159 | 4159 | * |
| 4160 | 4160 | * @since 1.0.0 |
| 4161 | 4161 | */ |
| 4162 | - require_once( geodir_plugin_path() . '/language.php' ); |
|
| 4162 | + require_once(geodir_plugin_path().'/language.php'); |
|
| 4163 | 4163 | |
| 4164 | - $language_file = geodir_plugin_path() . '/db-language.php'; |
|
| 4164 | + $language_file = geodir_plugin_path().'/db-language.php'; |
|
| 4165 | 4165 | |
| 4166 | 4166 | // Load language string file if not created yet |
| 4167 | - if ( ! file_exists( $language_file ) ) {
|
|
| 4167 | + if (!file_exists($language_file)) {
|
|
| 4168 | 4168 | geodirectory_load_db_language(); |
| 4169 | 4169 | } |
| 4170 | 4170 | |
| 4171 | - if ( file_exists( $language_file ) ) {
|
|
| 4171 | + if (file_exists($language_file)) {
|
|
| 4172 | 4172 | /** |
| 4173 | 4173 | * Language strings from database. |
| 4174 | 4174 | * |
| 4175 | 4175 | * @since 1.4.2 |
| 4176 | 4176 | */ |
| 4177 | 4177 | try {
|
| 4178 | - require_once( $language_file ); |
|
| 4179 | - } catch ( Exception $e ) {
|
|
| 4180 | - error_log( 'Language Error: ' . $e->getMessage() ); |
|
| 4178 | + require_once($language_file); |
|
| 4179 | + } catch (Exception $e) {
|
|
| 4180 | + error_log('Language Error: '.$e->getMessage());
|
|
| 4181 | 4181 | } |
| 4182 | 4182 | } |
| 4183 | 4183 | } |
@@ -4194,19 +4194,19 @@ discard block |
||
| 4194 | 4194 | */ |
| 4195 | 4195 | function geodirectory_load_db_language() {
|
| 4196 | 4196 | global $wp_filesystem; |
| 4197 | - if ( empty( $wp_filesystem ) ) {
|
|
| 4198 | - require_once( ABSPATH . '/wp-admin/includes/file.php' ); |
|
| 4197 | + if (empty($wp_filesystem)) {
|
|
| 4198 | + require_once(ABSPATH.'/wp-admin/includes/file.php'); |
|
| 4199 | 4199 | WP_Filesystem(); |
| 4200 | 4200 | global $wp_filesystem; |
| 4201 | 4201 | } |
| 4202 | 4202 | |
| 4203 | - $language_file = geodir_plugin_path() . '/db-language.php'; |
|
| 4203 | + $language_file = geodir_plugin_path().'/db-language.php'; |
|
| 4204 | 4204 | |
| 4205 | - if ( is_file( $language_file ) && ! is_writable( $language_file ) ) {
|
|
| 4205 | + if (is_file($language_file) && !is_writable($language_file)) {
|
|
| 4206 | 4206 | return false; |
| 4207 | 4207 | } // Not possible to create. |
| 4208 | 4208 | |
| 4209 | - if ( ! is_file( $language_file ) && ! is_writable( dirname( $language_file ) ) ) {
|
|
| 4209 | + if (!is_file($language_file) && !is_writable(dirname($language_file))) {
|
|
| 4210 | 4210 | return false; |
| 4211 | 4211 | } // Not possible to create. |
| 4212 | 4212 | |
@@ -4220,9 +4220,9 @@ discard block |
||
| 4220 | 4220 | * |
| 4221 | 4221 | * @param array $contents_strings Array of strings. |
| 4222 | 4222 | */ |
| 4223 | - $contents_strings = apply_filters( 'geodir_load_db_language', $contents_strings ); |
|
| 4223 | + $contents_strings = apply_filters('geodir_load_db_language', $contents_strings);
|
|
| 4224 | 4224 | |
| 4225 | - $contents_strings = array_unique( $contents_strings ); |
|
| 4225 | + $contents_strings = array_unique($contents_strings); |
|
| 4226 | 4226 | |
| 4227 | 4227 | $contents_head = array(); |
| 4228 | 4228 | $contents_head[] = "<?php"; |
@@ -4239,21 +4239,21 @@ discard block |
||
| 4239 | 4239 | $contents_foot[] = ""; |
| 4240 | 4240 | $contents_foot[] = ""; |
| 4241 | 4241 | |
| 4242 | - $contents = implode( PHP_EOL, $contents_head ); |
|
| 4242 | + $contents = implode(PHP_EOL, $contents_head); |
|
| 4243 | 4243 | |
| 4244 | - if ( ! empty( $contents_strings ) ) {
|
|
| 4245 | - foreach ( $contents_strings as $string ) {
|
|
| 4246 | - if ( is_scalar( $string ) && $string != '' ) {
|
|
| 4247 | - $string = str_replace( "'", "\'", $string ); |
|
| 4248 | - geodir_wpml_register_string( $string ); |
|
| 4249 | - $contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
|
|
| 4244 | + if (!empty($contents_strings)) {
|
|
| 4245 | + foreach ($contents_strings as $string) {
|
|
| 4246 | + if (is_scalar($string) && $string != '') {
|
|
| 4247 | + $string = str_replace("'", "\'", $string);
|
|
| 4248 | + geodir_wpml_register_string($string); |
|
| 4249 | + $contents .= PHP_EOL."__('".$string."', 'geodirectory');";
|
|
| 4250 | 4250 | } |
| 4251 | 4251 | } |
| 4252 | 4252 | } |
| 4253 | 4253 | |
| 4254 | - $contents .= implode( PHP_EOL, $contents_foot ); |
|
| 4254 | + $contents .= implode(PHP_EOL, $contents_foot); |
|
| 4255 | 4255 | |
| 4256 | - if ( $wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE ) ) {
|
|
| 4256 | + if ($wp_filesystem->put_contents($language_file, $contents, FS_CHMOD_FILE)) {
|
|
| 4257 | 4257 | return false; |
| 4258 | 4258 | } // Failure; could not write file. |
| 4259 | 4259 | |
@@ -4274,49 +4274,49 @@ discard block |
||
| 4274 | 4274 | * |
| 4275 | 4275 | * @return array Translation texts. |
| 4276 | 4276 | */ |
| 4277 | -function geodir_load_custom_field_translation( $translation_texts = array() ) {
|
|
| 4277 | +function geodir_load_custom_field_translation($translation_texts = array()) {
|
|
| 4278 | 4278 | global $wpdb; |
| 4279 | 4279 | |
| 4280 | 4280 | // Custom fields table |
| 4281 | - $sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values, validation_msg FROM " . GEODIR_CUSTOM_FIELDS_TABLE; |
|
| 4282 | - $rows = $wpdb->get_results( $sql ); |
|
| 4281 | + $sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values, validation_msg FROM ".GEODIR_CUSTOM_FIELDS_TABLE; |
|
| 4282 | + $rows = $wpdb->get_results($sql); |
|
| 4283 | 4283 | |
| 4284 | - if ( ! empty( $rows ) ) {
|
|
| 4285 | - foreach ( $rows as $row ) {
|
|
| 4286 | - if ( ! empty( $row->admin_title ) ) {
|
|
| 4287 | - $translation_texts[] = stripslashes_deep( $row->admin_title ); |
|
| 4284 | + if (!empty($rows)) {
|
|
| 4285 | + foreach ($rows as $row) {
|
|
| 4286 | + if (!empty($row->admin_title)) {
|
|
| 4287 | + $translation_texts[] = stripslashes_deep($row->admin_title); |
|
| 4288 | 4288 | } |
| 4289 | 4289 | |
| 4290 | - if ( ! empty( $row->admin_desc ) ) {
|
|
| 4291 | - $translation_texts[] = stripslashes_deep( $row->admin_desc ); |
|
| 4290 | + if (!empty($row->admin_desc)) {
|
|
| 4291 | + $translation_texts[] = stripslashes_deep($row->admin_desc); |
|
| 4292 | 4292 | } |
| 4293 | 4293 | |
| 4294 | - if ( ! empty( $row->site_title ) ) {
|
|
| 4295 | - $translation_texts[] = stripslashes_deep( $row->site_title ); |
|
| 4294 | + if (!empty($row->site_title)) {
|
|
| 4295 | + $translation_texts[] = stripslashes_deep($row->site_title); |
|
| 4296 | 4296 | } |
| 4297 | 4297 | |
| 4298 | - if ( ! empty( $row->clabels ) ) {
|
|
| 4299 | - $translation_texts[] = stripslashes_deep( $row->clabels ); |
|
| 4298 | + if (!empty($row->clabels)) {
|
|
| 4299 | + $translation_texts[] = stripslashes_deep($row->clabels); |
|
| 4300 | 4300 | } |
| 4301 | 4301 | |
| 4302 | - if ( ! empty( $row->required_msg ) ) {
|
|
| 4303 | - $translation_texts[] = stripslashes_deep( $row->required_msg ); |
|
| 4302 | + if (!empty($row->required_msg)) {
|
|
| 4303 | + $translation_texts[] = stripslashes_deep($row->required_msg); |
|
| 4304 | 4304 | } |
| 4305 | 4305 | |
| 4306 | - if ( ! empty( $row->validation_msg ) ) {
|
|
| 4307 | - $translation_texts[] = stripslashes_deep( $row->validation_msg ); |
|
| 4306 | + if (!empty($row->validation_msg)) {
|
|
| 4307 | + $translation_texts[] = stripslashes_deep($row->validation_msg); |
|
| 4308 | 4308 | } |
| 4309 | 4309 | |
| 4310 | - if ( ! empty( $row->default_value ) ) {
|
|
| 4311 | - $translation_texts[] = stripslashes_deep( $row->default_value ); |
|
| 4310 | + if (!empty($row->default_value)) {
|
|
| 4311 | + $translation_texts[] = stripslashes_deep($row->default_value); |
|
| 4312 | 4312 | } |
| 4313 | 4313 | |
| 4314 | - if ( ! empty( $row->option_values ) ) {
|
|
| 4315 | - $option_values = geodir_string_values_to_options( stripslashes_deep( $row->option_values ) ); |
|
| 4314 | + if (!empty($row->option_values)) {
|
|
| 4315 | + $option_values = geodir_string_values_to_options(stripslashes_deep($row->option_values)); |
|
| 4316 | 4316 | |
| 4317 | - if ( ! empty( $option_values ) ) {
|
|
| 4318 | - foreach ( $option_values as $option_value ) {
|
|
| 4319 | - if ( ! empty( $option_value['label'] ) ) {
|
|
| 4317 | + if (!empty($option_values)) {
|
|
| 4318 | + foreach ($option_values as $option_value) {
|
|
| 4319 | + if (!empty($option_value['label'])) {
|
|
| 4320 | 4320 | $translation_texts[] = $option_value['label']; |
| 4321 | 4321 | } |
| 4322 | 4322 | } |
@@ -4326,56 +4326,56 @@ discard block |
||
| 4326 | 4326 | } |
| 4327 | 4327 | |
| 4328 | 4328 | // Custom sorting fields table |
| 4329 | - $sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE; |
|
| 4330 | - $rows = $wpdb->get_results( $sql ); |
|
| 4329 | + $sql = "SELECT site_title, asc_title, desc_title FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE; |
|
| 4330 | + $rows = $wpdb->get_results($sql); |
|
| 4331 | 4331 | |
| 4332 | - if ( ! empty( $rows ) ) {
|
|
| 4333 | - foreach ( $rows as $row ) {
|
|
| 4334 | - if ( ! empty( $row->site_title ) ) {
|
|
| 4335 | - $translation_texts[] = stripslashes_deep( $row->site_title ); |
|
| 4332 | + if (!empty($rows)) {
|
|
| 4333 | + foreach ($rows as $row) {
|
|
| 4334 | + if (!empty($row->site_title)) {
|
|
| 4335 | + $translation_texts[] = stripslashes_deep($row->site_title); |
|
| 4336 | 4336 | } |
| 4337 | 4337 | |
| 4338 | - if ( ! empty( $row->asc_title ) ) {
|
|
| 4339 | - $translation_texts[] = stripslashes_deep( $row->asc_title ); |
|
| 4338 | + if (!empty($row->asc_title)) {
|
|
| 4339 | + $translation_texts[] = stripslashes_deep($row->asc_title); |
|
| 4340 | 4340 | } |
| 4341 | 4341 | |
| 4342 | - if ( ! empty( $row->desc_title ) ) {
|
|
| 4343 | - $translation_texts[] = stripslashes_deep( $row->desc_title ); |
|
| 4342 | + if (!empty($row->desc_title)) {
|
|
| 4343 | + $translation_texts[] = stripslashes_deep($row->desc_title); |
|
| 4344 | 4344 | } |
| 4345 | 4345 | } |
| 4346 | 4346 | } |
| 4347 | 4347 | |
| 4348 | 4348 | // Advance search filter fields table |
| 4349 | - if ( defined( 'GEODIR_ADVANCE_SEARCH_TABLE' ) ) {
|
|
| 4350 | - $sql = "SELECT field_site_name, front_search_title, first_search_text, last_search_text, field_desc FROM " . GEODIR_ADVANCE_SEARCH_TABLE; |
|
| 4351 | - $rows = $wpdb->get_results( $sql ); |
|
| 4352 | - |
|
| 4353 | - if ( ! empty( $rows ) ) {
|
|
| 4354 | - foreach ( $rows as $row ) {
|
|
| 4355 | - if ( ! empty( $row->field_site_name ) ) {
|
|
| 4356 | - $translation_texts[] = stripslashes_deep( $row->field_site_name ); |
|
| 4349 | + if (defined('GEODIR_ADVANCE_SEARCH_TABLE')) {
|
|
| 4350 | + $sql = "SELECT field_site_name, front_search_title, first_search_text, last_search_text, field_desc FROM ".GEODIR_ADVANCE_SEARCH_TABLE; |
|
| 4351 | + $rows = $wpdb->get_results($sql); |
|
| 4352 | + |
|
| 4353 | + if (!empty($rows)) {
|
|
| 4354 | + foreach ($rows as $row) {
|
|
| 4355 | + if (!empty($row->field_site_name)) {
|
|
| 4356 | + $translation_texts[] = stripslashes_deep($row->field_site_name); |
|
| 4357 | 4357 | } |
| 4358 | 4358 | |
| 4359 | - if ( ! empty( $row->front_search_title ) ) {
|
|
| 4360 | - $translation_texts[] = stripslashes_deep( $row->front_search_title ); |
|
| 4359 | + if (!empty($row->front_search_title)) {
|
|
| 4360 | + $translation_texts[] = stripslashes_deep($row->front_search_title); |
|
| 4361 | 4361 | } |
| 4362 | 4362 | |
| 4363 | - if ( ! empty( $row->first_search_text ) ) {
|
|
| 4364 | - $translation_texts[] = stripslashes_deep( $row->first_search_text ); |
|
| 4363 | + if (!empty($row->first_search_text)) {
|
|
| 4364 | + $translation_texts[] = stripslashes_deep($row->first_search_text); |
|
| 4365 | 4365 | } |
| 4366 | 4366 | |
| 4367 | - if ( ! empty( $row->last_search_text ) ) {
|
|
| 4368 | - $translation_texts[] = stripslashes_deep( $row->last_search_text ); |
|
| 4367 | + if (!empty($row->last_search_text)) {
|
|
| 4368 | + $translation_texts[] = stripslashes_deep($row->last_search_text); |
|
| 4369 | 4369 | } |
| 4370 | 4370 | |
| 4371 | - if ( ! empty( $row->field_desc ) ) {
|
|
| 4372 | - $translation_texts[] = stripslashes_deep( $row->field_desc ); |
|
| 4371 | + if (!empty($row->field_desc)) {
|
|
| 4372 | + $translation_texts[] = stripslashes_deep($row->field_desc); |
|
| 4373 | 4373 | } |
| 4374 | 4374 | } |
| 4375 | 4375 | } |
| 4376 | 4376 | } |
| 4377 | 4377 | |
| 4378 | - $translation_texts = ! empty( $translation_texts ) ? array_unique( $translation_texts ) : $translation_texts; |
|
| 4378 | + $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts; |
|
| 4379 | 4379 | |
| 4380 | 4380 | return $translation_texts; |
| 4381 | 4381 | } |
@@ -4397,7 +4397,7 @@ discard block |
||
| 4397 | 4397 | * |
| 4398 | 4398 | * @param array $geodir_allowed_mime_types and file extensions. |
| 4399 | 4399 | */ |
| 4400 | - return apply_filters( 'geodir_allowed_mime_types', array( |
|
| 4400 | + return apply_filters('geodir_allowed_mime_types', array(
|
|
| 4401 | 4401 | 'Image' => array( // Image formats. |
| 4402 | 4402 | 'jpg' => 'image/jpeg', |
| 4403 | 4403 | 'jpe' => 'image/jpeg', |
@@ -4465,18 +4465,18 @@ discard block |
||
| 4465 | 4465 | * |
| 4466 | 4466 | * @return string User display name. |
| 4467 | 4467 | */ |
| 4468 | -function geodir_get_client_name( $user_id ) {
|
|
| 4468 | +function geodir_get_client_name($user_id) {
|
|
| 4469 | 4469 | $client_name = ''; |
| 4470 | 4470 | |
| 4471 | - $user_data = get_userdata( $user_id ); |
|
| 4471 | + $user_data = get_userdata($user_id); |
|
| 4472 | 4472 | |
| 4473 | - if ( ! empty( $user_data ) ) {
|
|
| 4474 | - if ( isset( $user_data->display_name ) && trim( $user_data->display_name ) != '' ) {
|
|
| 4475 | - $client_name = trim( $user_data->display_name ); |
|
| 4476 | - } else if ( isset( $user_data->user_nicename ) && trim( $user_data->user_nicename ) != '' ) {
|
|
| 4477 | - $client_name = trim( $user_data->user_nicename ); |
|
| 4473 | + if (!empty($user_data)) {
|
|
| 4474 | + if (isset($user_data->display_name) && trim($user_data->display_name) != '') {
|
|
| 4475 | + $client_name = trim($user_data->display_name); |
|
| 4476 | + } else if (isset($user_data->user_nicename) && trim($user_data->user_nicename) != '') {
|
|
| 4477 | + $client_name = trim($user_data->user_nicename); |
|
| 4478 | 4478 | } else {
|
| 4479 | - $client_name = trim( $user_data->user_login ); |
|
| 4479 | + $client_name = trim($user_data->user_login); |
|
| 4480 | 4480 | } |
| 4481 | 4481 | } |
| 4482 | 4482 | |
@@ -4484,19 +4484,19 @@ discard block |
||
| 4484 | 4484 | } |
| 4485 | 4485 | |
| 4486 | 4486 | |
| 4487 | -add_filter( 'wpseo_replacements', 'geodir_wpseo_replacements', 10, 1 ); |
|
| 4487 | +add_filter('wpseo_replacements', 'geodir_wpseo_replacements', 10, 1);
|
|
| 4488 | 4488 | /* |
| 4489 | 4489 | * Add location variables to wpseo replacements. |
| 4490 | 4490 | * |
| 4491 | 4491 | * @since 1.5.4 |
| 4492 | 4492 | */ |
| 4493 | -function geodir_wpseo_replacements( $vars ) {
|
|
| 4493 | +function geodir_wpseo_replacements($vars) {
|
|
| 4494 | 4494 | |
| 4495 | 4495 | global $wp; |
| 4496 | 4496 | $title = ''; |
| 4497 | 4497 | // location variables |
| 4498 | 4498 | $gd_post_type = geodir_get_current_posttype(); |
| 4499 | - $location_array = geodir_get_current_location_terms( 'query_vars', $gd_post_type ); |
|
| 4499 | + $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
|
|
| 4500 | 4500 | /** |
| 4501 | 4501 | * Filter the title variables location variables array |
| 4502 | 4502 | * |
@@ -4506,20 +4506,20 @@ discard block |
||
| 4506 | 4506 | * @param array $location_array The array of location variables. |
| 4507 | 4507 | * @param array $vars The page title variables. |
| 4508 | 4508 | */ |
| 4509 | - $location_array = apply_filters( 'geodir_filter_title_variables_location_arr_seo', $location_array, $vars ); |
|
| 4509 | + $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo', $location_array, $vars);
|
|
| 4510 | 4510 | $location_titles = array(); |
| 4511 | - if ( get_query_var( 'gd_country_full' ) ) {
|
|
| 4512 | - if ( get_query_var( 'gd_country_full' ) ) {
|
|
| 4513 | - $location_array['gd_country'] = get_query_var( 'gd_country_full' ); |
|
| 4511 | + if (get_query_var('gd_country_full')) {
|
|
| 4512 | + if (get_query_var('gd_country_full')) {
|
|
| 4513 | + $location_array['gd_country'] = get_query_var('gd_country_full');
|
|
| 4514 | 4514 | } |
| 4515 | - if ( get_query_var( 'gd_region_full' ) ) {
|
|
| 4516 | - $location_array['gd_region'] = get_query_var( 'gd_region_full' ); |
|
| 4515 | + if (get_query_var('gd_region_full')) {
|
|
| 4516 | + $location_array['gd_region'] = get_query_var('gd_region_full');
|
|
| 4517 | 4517 | } |
| 4518 | - if ( get_query_var( 'gd_city_full' ) ) {
|
|
| 4519 | - $location_array['gd_city'] = get_query_var( 'gd_city_full' ); |
|
| 4518 | + if (get_query_var('gd_city_full')) {
|
|
| 4519 | + $location_array['gd_city'] = get_query_var('gd_city_full');
|
|
| 4520 | 4520 | } |
| 4521 | - if ( get_query_var( 'gd_neighbourhood_full' ) ) {
|
|
| 4522 | - $location_array['gd_neighbourhood'] = get_query_var( 'gd_neighbourhood_full' ); |
|
| 4521 | + if (get_query_var('gd_neighbourhood_full')) {
|
|
| 4522 | + $location_array['gd_neighbourhood'] = get_query_var('gd_neighbourhood_full');
|
|
| 4523 | 4523 | } |
| 4524 | 4524 | } |
| 4525 | 4525 | |
@@ -4534,7 +4534,7 @@ discard block |
||
| 4534 | 4534 | * @param string $gd_page The page being filtered. |
| 4535 | 4535 | * @param string $sep The separator, default: `|`. |
| 4536 | 4536 | */ |
| 4537 | - $title = apply_filters( 'geodir_replace_location_variables_seo', $title, $location_array, '', '' ); |
|
| 4537 | + $title = apply_filters('geodir_replace_location_variables_seo', $title, $location_array, '', '');
|
|
| 4538 | 4538 | |
| 4539 | 4539 | /** |
| 4540 | 4540 | * Filter the title variables after standard ones have been filtered for wpseo. |
@@ -4545,13 +4545,13 @@ discard block |
||
| 4545 | 4545 | * @param string $vars The title with variables. |
| 4546 | 4546 | * @param array $location_array The array of location variables. |
| 4547 | 4547 | */ |
| 4548 | - return apply_filters( 'geodir_wpseo_replacements_vars', $vars, $location_array ); |
|
| 4548 | + return apply_filters('geodir_wpseo_replacements_vars', $vars, $location_array);
|
|
| 4549 | 4549 | } |
| 4550 | 4550 | |
| 4551 | 4551 | |
| 4552 | -add_filter( 'geodir_seo_meta_title', 'geodir_filter_title_variables', 10, 3 ); |
|
| 4553 | -add_filter( 'geodir_seo_page_title', 'geodir_filter_title_variables', 10, 2 ); |
|
| 4554 | -add_filter( 'geodir_seo_meta_description_pre', 'geodir_filter_title_variables', 10, 3 ); |
|
| 4552 | +add_filter('geodir_seo_meta_title', 'geodir_filter_title_variables', 10, 3);
|
|
| 4553 | +add_filter('geodir_seo_page_title', 'geodir_filter_title_variables', 10, 2);
|
|
| 4554 | +add_filter('geodir_seo_meta_description_pre', 'geodir_filter_title_variables', 10, 3);
|
|
| 4555 | 4555 | |
| 4556 | 4556 | /** |
| 4557 | 4557 | * Filter the title variables. |
@@ -4593,14 +4593,14 @@ discard block |
||
| 4593 | 4593 | * |
| 4594 | 4594 | * @return string Title after filtered variables. |
| 4595 | 4595 | */ |
| 4596 | -function geodir_filter_title_variables( $title, $gd_page, $sep = '' ) {
|
|
| 4596 | +function geodir_filter_title_variables($title, $gd_page, $sep = '') {
|
|
| 4597 | 4597 | global $wp, $post; |
| 4598 | 4598 | |
| 4599 | - if ( ! $gd_page || ! $title ) {
|
|
| 4599 | + if (!$gd_page || !$title) {
|
|
| 4600 | 4600 | return $title; // if no a GD page then bail. |
| 4601 | 4601 | } |
| 4602 | 4602 | |
| 4603 | - if ( $sep == '' ) {
|
|
| 4603 | + if ($sep == '') {
|
|
| 4604 | 4604 | /** |
| 4605 | 4605 | * Filter the page title separator. |
| 4606 | 4606 | * |
@@ -4609,100 +4609,100 @@ discard block |
||
| 4609 | 4609 | * |
| 4610 | 4610 | * @param string $sep The separator, default: `|`. |
| 4611 | 4611 | */ |
| 4612 | - $sep = apply_filters( 'geodir_page_title_separator', '|' ); |
|
| 4612 | + $sep = apply_filters('geodir_page_title_separator', '|');
|
|
| 4613 | 4613 | } |
| 4614 | 4614 | |
| 4615 | - if ( strpos( $title, '%%title%%' ) !== false ) {
|
|
| 4616 | - $title = str_replace( "%%title%%", $post->post_title, $title ); |
|
| 4615 | + if (strpos($title, '%%title%%') !== false) {
|
|
| 4616 | + $title = str_replace("%%title%%", $post->post_title, $title);
|
|
| 4617 | 4617 | } |
| 4618 | 4618 | |
| 4619 | - if ( strpos( $title, '%%sitename%%' ) !== false ) {
|
|
| 4620 | - $title = str_replace( "%%sitename%%", get_bloginfo( 'name' ), $title ); |
|
| 4619 | + if (strpos($title, '%%sitename%%') !== false) {
|
|
| 4620 | + $title = str_replace("%%sitename%%", get_bloginfo('name'), $title);
|
|
| 4621 | 4621 | } |
| 4622 | 4622 | |
| 4623 | - if ( strpos( $title, '%%sitedesc%%' ) !== false ) {
|
|
| 4624 | - $title = str_replace( "%%sitedesc%%", get_bloginfo( 'description' ), $title ); |
|
| 4623 | + if (strpos($title, '%%sitedesc%%') !== false) {
|
|
| 4624 | + $title = str_replace("%%sitedesc%%", get_bloginfo('description'), $title);
|
|
| 4625 | 4625 | } |
| 4626 | 4626 | |
| 4627 | - if ( strpos( $title, '%%excerpt%%' ) !== false ) {
|
|
| 4628 | - $title = str_replace( "%%excerpt%%", strip_tags( get_the_excerpt() ), $title ); |
|
| 4627 | + if (strpos($title, '%%excerpt%%') !== false) {
|
|
| 4628 | + $title = str_replace("%%excerpt%%", strip_tags(get_the_excerpt()), $title);
|
|
| 4629 | 4629 | } |
| 4630 | 4630 | |
| 4631 | - if ( $gd_page == 'search' || $gd_page == 'author' ) {
|
|
| 4632 | - $post_type = isset( $_REQUEST['stype'] ) ? sanitize_text_field( $_REQUEST['stype'] ) : ''; |
|
| 4633 | - } else if ( $gd_page == 'add-listing' ) {
|
|
| 4634 | - $post_type = ( isset( $_REQUEST['listing_type'] ) ) ? sanitize_text_field( $_REQUEST['listing_type'] ) : ''; |
|
| 4635 | - $post_type = ! $post_type && ! empty( $_REQUEST['pid'] ) ? get_post_type( (int) $_REQUEST['pid'] ) : $post_type; |
|
| 4636 | - } else if ( isset( $post->post_type ) && $post->post_type && in_array( $post->post_type, geodir_get_posttypes() ) ) {
|
|
| 4631 | + if ($gd_page == 'search' || $gd_page == 'author') {
|
|
| 4632 | + $post_type = isset($_REQUEST['stype']) ? sanitize_text_field($_REQUEST['stype']) : ''; |
|
| 4633 | + } else if ($gd_page == 'add-listing') {
|
|
| 4634 | + $post_type = (isset($_REQUEST['listing_type'])) ? sanitize_text_field($_REQUEST['listing_type']) : ''; |
|
| 4635 | + $post_type = !$post_type && !empty($_REQUEST['pid']) ? get_post_type((int) $_REQUEST['pid']) : $post_type; |
|
| 4636 | + } else if (isset($post->post_type) && $post->post_type && in_array($post->post_type, geodir_get_posttypes())) {
|
|
| 4637 | 4637 | $post_type = $post->post_type; |
| 4638 | 4638 | } else {
|
| 4639 | - $post_type = get_query_var( 'post_type' ); |
|
| 4639 | + $post_type = get_query_var('post_type');
|
|
| 4640 | 4640 | } |
| 4641 | 4641 | |
| 4642 | - if ( strpos( $title, '%%pt_single%%' ) !== false ) {
|
|
| 4642 | + if (strpos($title, '%%pt_single%%') !== false) {
|
|
| 4643 | 4643 | $singular_name = ''; |
| 4644 | - if ( $post_type && $singular_name = get_post_type_singular_label( $post_type ) ) {
|
|
| 4645 | - $singular_name = __( $singular_name, 'geodirectory' ); |
|
| 4644 | + if ($post_type && $singular_name = get_post_type_singular_label($post_type)) {
|
|
| 4645 | + $singular_name = __($singular_name, 'geodirectory'); |
|
| 4646 | 4646 | } |
| 4647 | 4647 | |
| 4648 | - $title = str_replace( "%%pt_single%%", $singular_name, $title ); |
|
| 4648 | + $title = str_replace("%%pt_single%%", $singular_name, $title);
|
|
| 4649 | 4649 | } |
| 4650 | 4650 | |
| 4651 | - if ( strpos( $title, '%%pt_plural%%' ) !== false ) {
|
|
| 4651 | + if (strpos($title, '%%pt_plural%%') !== false) {
|
|
| 4652 | 4652 | $plural_name = ''; |
| 4653 | - if ( $post_type && $plural_name = get_post_type_plural_label( $post_type ) ) {
|
|
| 4654 | - $plural_name = __( $plural_name, 'geodirectory' ); |
|
| 4653 | + if ($post_type && $plural_name = get_post_type_plural_label($post_type)) {
|
|
| 4654 | + $plural_name = __($plural_name, 'geodirectory'); |
|
| 4655 | 4655 | } |
| 4656 | 4656 | |
| 4657 | - $title = str_replace( "%%pt_plural%%", $plural_name, $title ); |
|
| 4657 | + $title = str_replace("%%pt_plural%%", $plural_name, $title);
|
|
| 4658 | 4658 | } |
| 4659 | 4659 | |
| 4660 | - if ( strpos( $title, '%%category%%' ) !== false ) {
|
|
| 4660 | + if (strpos($title, '%%category%%') !== false) {
|
|
| 4661 | 4661 | $cat_name = ''; |
| 4662 | 4662 | |
| 4663 | - if ( $gd_page == 'detail' ) {
|
|
| 4664 | - if ( $post->default_category ) {
|
|
| 4665 | - $cat = get_term( $post->default_category, $post->post_type . 'category' ); |
|
| 4666 | - $cat_name = ( isset( $cat->name ) ) ? $cat->name : ''; |
|
| 4663 | + if ($gd_page == 'detail') {
|
|
| 4664 | + if ($post->default_category) {
|
|
| 4665 | + $cat = get_term($post->default_category, $post->post_type.'category'); |
|
| 4666 | + $cat_name = (isset($cat->name)) ? $cat->name : ''; |
|
| 4667 | 4667 | } |
| 4668 | - } else if ( $gd_page == 'listing' ) {
|
|
| 4668 | + } else if ($gd_page == 'listing') {
|
|
| 4669 | 4669 | $queried_object = get_queried_object(); |
| 4670 | - if ( isset( $queried_object->name ) ) {
|
|
| 4670 | + if (isset($queried_object->name)) {
|
|
| 4671 | 4671 | $cat_name = $queried_object->name; |
| 4672 | 4672 | } |
| 4673 | 4673 | } |
| 4674 | - $title = str_replace( "%%category%%", $cat_name, $title ); |
|
| 4674 | + $title = str_replace("%%category%%", $cat_name, $title);
|
|
| 4675 | 4675 | } |
| 4676 | 4676 | |
| 4677 | - if ( strpos( $title, '%%tag%%' ) !== false ) {
|
|
| 4677 | + if (strpos($title, '%%tag%%') !== false) {
|
|
| 4678 | 4678 | $cat_name = ''; |
| 4679 | 4679 | |
| 4680 | - if ( $gd_page == 'detail' ) {
|
|
| 4681 | - if ( $post->default_category ) {
|
|
| 4682 | - $cat = get_term( $post->default_category, $post->post_type . 'category' ); |
|
| 4683 | - $cat_name = ( isset( $cat->name ) ) ? $cat->name : ''; |
|
| 4680 | + if ($gd_page == 'detail') {
|
|
| 4681 | + if ($post->default_category) {
|
|
| 4682 | + $cat = get_term($post->default_category, $post->post_type.'category'); |
|
| 4683 | + $cat_name = (isset($cat->name)) ? $cat->name : ''; |
|
| 4684 | 4684 | } |
| 4685 | - } else if ( $gd_page == 'listing' ) {
|
|
| 4685 | + } else if ($gd_page == 'listing') {
|
|
| 4686 | 4686 | $queried_object = get_queried_object(); |
| 4687 | - if ( isset( $queried_object->name ) ) {
|
|
| 4687 | + if (isset($queried_object->name)) {
|
|
| 4688 | 4688 | $cat_name = $queried_object->name; |
| 4689 | 4689 | } |
| 4690 | 4690 | } |
| 4691 | - $title = str_replace( "%%tag%%", $cat_name, $title ); |
|
| 4691 | + $title = str_replace("%%tag%%", $cat_name, $title);
|
|
| 4692 | 4692 | } |
| 4693 | 4693 | |
| 4694 | - if ( strpos( $title, '%%id%%' ) !== false ) {
|
|
| 4695 | - $ID = ( isset( $post->ID ) ) ? $post->ID : ''; |
|
| 4696 | - $title = str_replace( "%%id%%", $ID, $title ); |
|
| 4694 | + if (strpos($title, '%%id%%') !== false) {
|
|
| 4695 | + $ID = (isset($post->ID)) ? $post->ID : ''; |
|
| 4696 | + $title = str_replace("%%id%%", $ID, $title);
|
|
| 4697 | 4697 | } |
| 4698 | 4698 | |
| 4699 | - if ( strpos( $title, '%%sep%%' ) !== false ) {
|
|
| 4700 | - $title = str_replace( "%%sep%%", $sep, $title ); |
|
| 4699 | + if (strpos($title, '%%sep%%') !== false) {
|
|
| 4700 | + $title = str_replace("%%sep%%", $sep, $title);
|
|
| 4701 | 4701 | } |
| 4702 | 4702 | |
| 4703 | 4703 | // location variables |
| 4704 | 4704 | $gd_post_type = geodir_get_current_posttype(); |
| 4705 | - $location_array = geodir_get_current_location_terms( 'query_vars', $gd_post_type ); |
|
| 4705 | + $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
|
|
| 4706 | 4706 | |
| 4707 | 4707 | /** |
| 4708 | 4708 | * Filter the title variables location variables array |
@@ -4715,20 +4715,20 @@ discard block |
||
| 4715 | 4715 | * @param string $gd_page The page being filtered. |
| 4716 | 4716 | * @param string $sep The separator, default: `|`. |
| 4717 | 4717 | */ |
| 4718 | - $location_array = apply_filters( 'geodir_filter_title_variables_location_arr', $location_array, $title, $gd_page, $sep ); |
|
| 4718 | + $location_array = apply_filters('geodir_filter_title_variables_location_arr', $location_array, $title, $gd_page, $sep);
|
|
| 4719 | 4719 | |
| 4720 | - if ( $gd_page == 'location' && get_query_var( 'gd_country_full' ) ) {
|
|
| 4721 | - if ( get_query_var( 'gd_country_full' ) ) {
|
|
| 4722 | - $location_array['gd_country'] = get_query_var( 'gd_country_full' ); |
|
| 4720 | + if ($gd_page == 'location' && get_query_var('gd_country_full')) {
|
|
| 4721 | + if (get_query_var('gd_country_full')) {
|
|
| 4722 | + $location_array['gd_country'] = get_query_var('gd_country_full');
|
|
| 4723 | 4723 | } |
| 4724 | - if ( get_query_var( 'gd_region_full' ) ) {
|
|
| 4725 | - $location_array['gd_region'] = get_query_var( 'gd_region_full' ); |
|
| 4724 | + if (get_query_var('gd_region_full')) {
|
|
| 4725 | + $location_array['gd_region'] = get_query_var('gd_region_full');
|
|
| 4726 | 4726 | } |
| 4727 | - if ( get_query_var( 'gd_city_full' ) ) {
|
|
| 4728 | - $location_array['gd_city'] = get_query_var( 'gd_city_full' ); |
|
| 4727 | + if (get_query_var('gd_city_full')) {
|
|
| 4728 | + $location_array['gd_city'] = get_query_var('gd_city_full');
|
|
| 4729 | 4729 | } |
| 4730 | - if ( get_query_var( 'gd_neighbourhood_full' ) ) {
|
|
| 4731 | - $location_array['gd_neighbourhood'] = get_query_var( 'gd_neighbourhood_full' ); |
|
| 4730 | + if (get_query_var('gd_neighbourhood_full')) {
|
|
| 4731 | + $location_array['gd_neighbourhood'] = get_query_var('gd_neighbourhood_full');
|
|
| 4732 | 4732 | } |
| 4733 | 4733 | } |
| 4734 | 4734 | |
@@ -4743,57 +4743,57 @@ discard block |
||
| 4743 | 4743 | * @param string $gd_page The page being filtered. |
| 4744 | 4744 | * @param string $sep The separator, default: `|`. |
| 4745 | 4745 | */ |
| 4746 | - $title = apply_filters( 'geodir_replace_location_variables', $title, $location_array, $gd_page, $sep ); |
|
| 4746 | + $title = apply_filters('geodir_replace_location_variables', $title, $location_array, $gd_page, $sep);
|
|
| 4747 | 4747 | |
| 4748 | - if ( strpos( $title, '%%search_term%%' ) !== false ) {
|
|
| 4748 | + if (strpos($title, '%%search_term%%') !== false) {
|
|
| 4749 | 4749 | $search_term = ''; |
| 4750 | - if ( isset( $_REQUEST['s'] ) ) {
|
|
| 4751 | - $search_term = esc_attr( $_REQUEST['s'] ); |
|
| 4750 | + if (isset($_REQUEST['s'])) {
|
|
| 4751 | + $search_term = esc_attr($_REQUEST['s']); |
|
| 4752 | 4752 | } |
| 4753 | - $title = str_replace( "%%search_term%%", $search_term, $title ); |
|
| 4753 | + $title = str_replace("%%search_term%%", $search_term, $title);
|
|
| 4754 | 4754 | } |
| 4755 | 4755 | |
| 4756 | - if ( strpos( $title, '%%search_near%%' ) !== false ) {
|
|
| 4756 | + if (strpos($title, '%%search_near%%') !== false) {
|
|
| 4757 | 4757 | $search_term = ''; |
| 4758 | - if ( isset( $_REQUEST['snear'] ) ) {
|
|
| 4759 | - $search_term = esc_attr( $_REQUEST['snear'] ); |
|
| 4758 | + if (isset($_REQUEST['snear'])) {
|
|
| 4759 | + $search_term = esc_attr($_REQUEST['snear']); |
|
| 4760 | 4760 | } |
| 4761 | - $title = str_replace( "%%search_near%%", $search_term, $title ); |
|
| 4761 | + $title = str_replace("%%search_near%%", $search_term, $title);
|
|
| 4762 | 4762 | } |
| 4763 | 4763 | |
| 4764 | - if ( strpos( $title, '%%name%%' ) !== false ) {
|
|
| 4765 | - if ( is_author() ) {
|
|
| 4766 | - $curauth = ( get_query_var( 'author_name' ) ) ? get_user_by( 'slug', get_query_var( 'author_name' ) ) : get_userdata( get_query_var( 'author' ) ); |
|
| 4764 | + if (strpos($title, '%%name%%') !== false) {
|
|
| 4765 | + if (is_author()) {
|
|
| 4766 | + $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
|
|
| 4767 | 4767 | $author_name = $curauth->display_name; |
| 4768 | 4768 | } else {
|
| 4769 | 4769 | $author_name = get_the_author(); |
| 4770 | 4770 | } |
| 4771 | - if ( ! $author_name || $author_name === '' ) {
|
|
| 4771 | + if (!$author_name || $author_name === '') {
|
|
| 4772 | 4772 | $queried_object = get_queried_object(); |
| 4773 | 4773 | |
| 4774 | - if ( isset( $queried_object->data->user_nicename ) ) {
|
|
| 4774 | + if (isset($queried_object->data->user_nicename)) {
|
|
| 4775 | 4775 | $author_name = $queried_object->data->display_name; |
| 4776 | 4776 | } |
| 4777 | 4777 | } |
| 4778 | - $title = str_replace( "%%name%%", $author_name, $title ); |
|
| 4778 | + $title = str_replace("%%name%%", $author_name, $title);
|
|
| 4779 | 4779 | } |
| 4780 | 4780 | |
| 4781 | - if ( strpos( $title, '%%page%%' ) !== false ) {
|
|
| 4782 | - $page = geodir_title_meta_page( $sep ); |
|
| 4783 | - $title = str_replace( "%%page%%", $page, $title ); |
|
| 4781 | + if (strpos($title, '%%page%%') !== false) {
|
|
| 4782 | + $page = geodir_title_meta_page($sep); |
|
| 4783 | + $title = str_replace("%%page%%", $page, $title);
|
|
| 4784 | 4784 | } |
| 4785 | - if ( strpos( $title, '%%pagenumber%%' ) !== false ) {
|
|
| 4785 | + if (strpos($title, '%%pagenumber%%') !== false) {
|
|
| 4786 | 4786 | $pagenumber = geodir_title_meta_pagenumber(); |
| 4787 | - $title = str_replace( "%%pagenumber%%", $pagenumber, $title ); |
|
| 4787 | + $title = str_replace("%%pagenumber%%", $pagenumber, $title);
|
|
| 4788 | 4788 | } |
| 4789 | - if ( strpos( $title, '%%pagetotal%%' ) !== false ) {
|
|
| 4789 | + if (strpos($title, '%%pagetotal%%') !== false) {
|
|
| 4790 | 4790 | $pagetotal = geodir_title_meta_pagetotal(); |
| 4791 | - $title = str_replace( "%%pagetotal%%", $pagetotal, $title ); |
|
| 4791 | + $title = str_replace("%%pagetotal%%", $pagetotal, $title);
|
|
| 4792 | 4792 | } |
| 4793 | 4793 | |
| 4794 | - $title = wptexturize( $title ); |
|
| 4795 | - $title = convert_chars( $title ); |
|
| 4796 | - $title = esc_html( $title ); |
|
| 4794 | + $title = wptexturize($title); |
|
| 4795 | + $title = convert_chars($title); |
|
| 4796 | + $title = esc_html($title); |
|
| 4797 | 4797 | |
| 4798 | 4798 | /** |
| 4799 | 4799 | * Filter the title variables after standard ones have been filtered. |
@@ -4807,7 +4807,7 @@ discard block |
||
| 4807 | 4807 | * @param string $sep The separator, default: `|`. |
| 4808 | 4808 | */ |
| 4809 | 4809 | |
| 4810 | - return apply_filters( 'geodir_filter_title_variables_vars', $title, $location_array, $gd_page, $sep ); |
|
| 4810 | + return apply_filters('geodir_filter_title_variables_vars', $title, $location_array, $gd_page, $sep);
|
|
| 4811 | 4811 | } |
| 4812 | 4812 | |
| 4813 | 4813 | /** |
@@ -4820,82 +4820,82 @@ discard block |
||
| 4820 | 4820 | * |
| 4821 | 4821 | * @return array Translation texts. |
| 4822 | 4822 | */ |
| 4823 | -function geodir_load_cpt_text_translation( $translation_texts = array() ) {
|
|
| 4824 | - $gd_post_types = geodir_get_posttypes( 'array' ); |
|
| 4823 | +function geodir_load_cpt_text_translation($translation_texts = array()) {
|
|
| 4824 | + $gd_post_types = geodir_get_posttypes('array');
|
|
| 4825 | 4825 | |
| 4826 | - if ( ! empty( $gd_post_types ) ) {
|
|
| 4827 | - foreach ( $gd_post_types as $post_type => $cpt_info ) {
|
|
| 4828 | - $labels = isset( $cpt_info['labels'] ) ? $cpt_info['labels'] : ''; |
|
| 4829 | - $description = isset( $cpt_info['description'] ) ? $cpt_info['description'] : ''; |
|
| 4830 | - $seo = isset( $cpt_info['seo'] ) ? $cpt_info['seo'] : ''; |
|
| 4826 | + if (!empty($gd_post_types)) {
|
|
| 4827 | + foreach ($gd_post_types as $post_type => $cpt_info) {
|
|
| 4828 | + $labels = isset($cpt_info['labels']) ? $cpt_info['labels'] : ''; |
|
| 4829 | + $description = isset($cpt_info['description']) ? $cpt_info['description'] : ''; |
|
| 4830 | + $seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : ''; |
|
| 4831 | 4831 | |
| 4832 | - if ( ! empty( $labels ) ) {
|
|
| 4833 | - if ( $labels['name'] != '' && ! in_array( $labels['name'], $translation_texts ) ) {
|
|
| 4832 | + if (!empty($labels)) {
|
|
| 4833 | + if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts)) {
|
|
| 4834 | 4834 | $translation_texts[] = $labels['name']; |
| 4835 | 4835 | } |
| 4836 | - if ( $labels['singular_name'] != '' && ! in_array( $labels['singular_name'], $translation_texts ) ) {
|
|
| 4836 | + if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts)) {
|
|
| 4837 | 4837 | $translation_texts[] = $labels['singular_name']; |
| 4838 | 4838 | } |
| 4839 | - if ( $labels['add_new'] != '' && ! in_array( $labels['add_new'], $translation_texts ) ) {
|
|
| 4839 | + if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts)) {
|
|
| 4840 | 4840 | $translation_texts[] = $labels['add_new']; |
| 4841 | 4841 | } |
| 4842 | - if ( $labels['add_new_item'] != '' && ! in_array( $labels['add_new_item'], $translation_texts ) ) {
|
|
| 4842 | + if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts)) {
|
|
| 4843 | 4843 | $translation_texts[] = $labels['add_new_item']; |
| 4844 | 4844 | } |
| 4845 | - if ( $labels['edit_item'] != '' && ! in_array( $labels['edit_item'], $translation_texts ) ) {
|
|
| 4845 | + if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts)) {
|
|
| 4846 | 4846 | $translation_texts[] = $labels['edit_item']; |
| 4847 | 4847 | } |
| 4848 | - if ( $labels['new_item'] != '' && ! in_array( $labels['new_item'], $translation_texts ) ) {
|
|
| 4848 | + if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts)) {
|
|
| 4849 | 4849 | $translation_texts[] = $labels['new_item']; |
| 4850 | 4850 | } |
| 4851 | - if ( $labels['view_item'] != '' && ! in_array( $labels['view_item'], $translation_texts ) ) {
|
|
| 4851 | + if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts)) {
|
|
| 4852 | 4852 | $translation_texts[] = $labels['view_item']; |
| 4853 | 4853 | } |
| 4854 | - if ( $labels['search_items'] != '' && ! in_array( $labels['search_items'], $translation_texts ) ) {
|
|
| 4854 | + if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts)) {
|
|
| 4855 | 4855 | $translation_texts[] = $labels['search_items']; |
| 4856 | 4856 | } |
| 4857 | - if ( $labels['not_found'] != '' && ! in_array( $labels['not_found'], $translation_texts ) ) {
|
|
| 4857 | + if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts)) {
|
|
| 4858 | 4858 | $translation_texts[] = $labels['not_found']; |
| 4859 | 4859 | } |
| 4860 | - if ( $labels['not_found_in_trash'] != '' && ! in_array( $labels['not_found_in_trash'], $translation_texts ) ) {
|
|
| 4860 | + if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts)) {
|
|
| 4861 | 4861 | $translation_texts[] = $labels['not_found_in_trash']; |
| 4862 | 4862 | } |
| 4863 | - if ( isset( $labels['label_post_profile'] ) && $labels['label_post_profile'] != '' && ! in_array( $labels['label_post_profile'], $translation_texts ) ) {
|
|
| 4863 | + if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts)) {
|
|
| 4864 | 4864 | $translation_texts[] = $labels['label_post_profile']; |
| 4865 | 4865 | } |
| 4866 | - if ( isset( $labels['label_post_info'] ) && $labels['label_post_info'] != '' && ! in_array( $labels['label_post_info'], $translation_texts ) ) {
|
|
| 4866 | + if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts)) {
|
|
| 4867 | 4867 | $translation_texts[] = $labels['label_post_info']; |
| 4868 | 4868 | } |
| 4869 | - if ( isset( $labels['label_post_images'] ) && $labels['label_post_images'] != '' && ! in_array( $labels['label_post_images'], $translation_texts ) ) {
|
|
| 4869 | + if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts)) {
|
|
| 4870 | 4870 | $translation_texts[] = $labels['label_post_images']; |
| 4871 | 4871 | } |
| 4872 | - if ( isset( $labels['label_post_map'] ) && $labels['label_post_map'] != '' && ! in_array( $labels['label_post_map'], $translation_texts ) ) {
|
|
| 4872 | + if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts)) {
|
|
| 4873 | 4873 | $translation_texts[] = $labels['label_post_map']; |
| 4874 | 4874 | } |
| 4875 | - if ( isset( $labels['label_reviews'] ) && $labels['label_reviews'] != '' && ! in_array( $labels['label_reviews'], $translation_texts ) ) {
|
|
| 4875 | + if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts)) {
|
|
| 4876 | 4876 | $translation_texts[] = $labels['label_reviews']; |
| 4877 | 4877 | } |
| 4878 | - if ( isset( $labels['label_related_listing'] ) && $labels['label_related_listing'] != '' && ! in_array( $labels['label_related_listing'], $translation_texts ) ) {
|
|
| 4878 | + if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts)) {
|
|
| 4879 | 4879 | $translation_texts[] = $labels['label_related_listing']; |
| 4880 | 4880 | } |
| 4881 | 4881 | } |
| 4882 | 4882 | |
| 4883 | - if ( $description != '' && ! in_array( $description, $translation_texts ) ) {
|
|
| 4884 | - $translation_texts[] = normalize_whitespace( $description ); |
|
| 4883 | + if ($description != '' && !in_array($description, $translation_texts)) {
|
|
| 4884 | + $translation_texts[] = normalize_whitespace($description); |
|
| 4885 | 4885 | } |
| 4886 | 4886 | |
| 4887 | - if ( ! empty( $seo ) ) {
|
|
| 4888 | - if ( isset( $seo['meta_keyword'] ) && $seo['meta_keyword'] != '' && ! in_array( $seo['meta_keyword'], $translation_texts ) ) {
|
|
| 4889 | - $translation_texts[] = normalize_whitespace( $seo['meta_keyword'] ); |
|
| 4887 | + if (!empty($seo)) {
|
|
| 4888 | + if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts)) {
|
|
| 4889 | + $translation_texts[] = normalize_whitespace($seo['meta_keyword']); |
|
| 4890 | 4890 | } |
| 4891 | 4891 | |
| 4892 | - if ( isset( $seo['meta_description'] ) && $seo['meta_description'] != '' && ! in_array( $seo['meta_description'], $translation_texts ) ) {
|
|
| 4893 | - $translation_texts[] = normalize_whitespace( $seo['meta_description'] ); |
|
| 4892 | + if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts)) {
|
|
| 4893 | + $translation_texts[] = normalize_whitespace($seo['meta_description']); |
|
| 4894 | 4894 | } |
| 4895 | 4895 | } |
| 4896 | 4896 | } |
| 4897 | 4897 | } |
| 4898 | - $translation_texts = ! empty( $translation_texts ) ? array_unique( $translation_texts ) : $translation_texts; |
|
| 4898 | + $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts; |
|
| 4899 | 4899 | |
| 4900 | 4900 | return $translation_texts; |
| 4901 | 4901 | } |
@@ -4910,27 +4910,27 @@ discard block |
||
| 4910 | 4910 | * |
| 4911 | 4911 | * @return array Location terms. |
| 4912 | 4912 | */ |
| 4913 | -function geodir_remove_location_terms( $location_terms = array() ) {
|
|
| 4914 | - $location_manager = defined( 'POST_LOCATION_TABLE' ) ? true : false; |
|
| 4913 | +function geodir_remove_location_terms($location_terms = array()) {
|
|
| 4914 | + $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
|
|
| 4915 | 4915 | |
| 4916 | - if ( ! empty( $location_terms ) && $location_manager ) {
|
|
| 4917 | - $hide_country_part = get_option( 'geodir_location_hide_country_part' ); |
|
| 4918 | - $hide_region_part = get_option( 'geodir_location_hide_region_part' ); |
|
| 4916 | + if (!empty($location_terms) && $location_manager) {
|
|
| 4917 | + $hide_country_part = get_option('geodir_location_hide_country_part');
|
|
| 4918 | + $hide_region_part = get_option('geodir_location_hide_region_part');
|
|
| 4919 | 4919 | |
| 4920 | - if ( $hide_region_part && $hide_country_part ) {
|
|
| 4921 | - if ( isset( $location_terms['gd_country'] ) ) {
|
|
| 4922 | - unset( $location_terms['gd_country'] ); |
|
| 4920 | + if ($hide_region_part && $hide_country_part) {
|
|
| 4921 | + if (isset($location_terms['gd_country'])) {
|
|
| 4922 | + unset($location_terms['gd_country']); |
|
| 4923 | 4923 | } |
| 4924 | - if ( isset( $location_terms['gd_region'] ) ) {
|
|
| 4925 | - unset( $location_terms['gd_region'] ); |
|
| 4924 | + if (isset($location_terms['gd_region'])) {
|
|
| 4925 | + unset($location_terms['gd_region']); |
|
| 4926 | 4926 | } |
| 4927 | - } else if ( $hide_region_part && ! $hide_country_part ) {
|
|
| 4928 | - if ( isset( $location_terms['gd_region'] ) ) {
|
|
| 4929 | - unset( $location_terms['gd_region'] ); |
|
| 4927 | + } else if ($hide_region_part && !$hide_country_part) {
|
|
| 4928 | + if (isset($location_terms['gd_region'])) {
|
|
| 4929 | + unset($location_terms['gd_region']); |
|
| 4930 | 4930 | } |
| 4931 | - } else if ( ! $hide_region_part && $hide_country_part ) {
|
|
| 4932 | - if ( isset( $location_terms['gd_country'] ) ) {
|
|
| 4933 | - unset( $location_terms['gd_country'] ); |
|
| 4931 | + } else if (!$hide_region_part && $hide_country_part) {
|
|
| 4932 | + if (isset($location_terms['gd_country'])) {
|
|
| 4933 | + unset($location_terms['gd_country']); |
|
| 4934 | 4934 | } |
| 4935 | 4935 | } |
| 4936 | 4936 | } |
@@ -4948,33 +4948,33 @@ discard block |
||
| 4948 | 4948 | * @param WP_Post $post Post object. |
| 4949 | 4949 | * @param bool $update Whether this is an existing listing being updated or not. |
| 4950 | 4950 | */ |
| 4951 | -function geodir_on_wp_insert_post( $post_ID, $post, $update ) {
|
|
| 4952 | - if ( ! $update ) {
|
|
| 4951 | +function geodir_on_wp_insert_post($post_ID, $post, $update) {
|
|
| 4952 | + if (!$update) {
|
|
| 4953 | 4953 | return; |
| 4954 | 4954 | } |
| 4955 | 4955 | |
| 4956 | - $action = isset( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : ''; |
|
| 4957 | - $is_admin = is_admin() && ( ! defined( 'DOING_AJAX' ) || ( defined( 'DOING_AJAX' ) && ! DOING_AJAX ) ) ? true : false; |
|
| 4956 | + $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : ''; |
|
| 4957 | + $is_admin = is_admin() && (!defined('DOING_AJAX') || (defined('DOING_AJAX') && !DOING_AJAX)) ? true : false;
|
|
| 4958 | 4958 | $inline_save = $action == 'inline-save' ? true : false; |
| 4959 | 4959 | |
| 4960 | - if ( empty( $post->post_type ) || $is_admin || $inline_save || ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) ) {
|
|
| 4960 | + if (empty($post->post_type) || $is_admin || $inline_save || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
|
|
| 4961 | 4961 | return; |
| 4962 | 4962 | } |
| 4963 | 4963 | |
| 4964 | - if ( $action != '' && in_array( $action, array( 'geodir_import_export' ) ) ) {
|
|
| 4964 | + if ($action != '' && in_array($action, array('geodir_import_export'))) {
|
|
| 4965 | 4965 | return; |
| 4966 | 4966 | } |
| 4967 | 4967 | |
| 4968 | 4968 | $user_id = (int) get_current_user_id(); |
| 4969 | 4969 | |
| 4970 | - if ( $user_id > 0 && get_option( 'geodir_notify_post_edited' ) && ! wp_is_post_revision( $post_ID ) && in_array( $post->post_type, geodir_get_posttypes() ) ) {
|
|
| 4971 | - $author_id = ! empty( $post->post_author ) ? $post->post_author : 0; |
|
| 4970 | + if ($user_id > 0 && get_option('geodir_notify_post_edited') && !wp_is_post_revision($post_ID) && in_array($post->post_type, geodir_get_posttypes())) {
|
|
| 4971 | + $author_id = !empty($post->post_author) ? $post->post_author : 0; |
|
| 4972 | 4972 | |
| 4973 | - if ( $user_id == $author_id && ! is_super_admin() ) {
|
|
| 4974 | - $from_email = get_option( 'site_email' ); |
|
| 4973 | + if ($user_id == $author_id && !is_super_admin()) {
|
|
| 4974 | + $from_email = get_option('site_email');
|
|
| 4975 | 4975 | $from_name = get_site_emailName(); |
| 4976 | - $to_email = get_option( 'admin_email' ); |
|
| 4977 | - $to_name = get_option( 'name' ); |
|
| 4976 | + $to_email = get_option('admin_email');
|
|
| 4977 | + $to_name = get_option('name');
|
|
| 4978 | 4978 | $message_type = 'listing_edited'; |
| 4979 | 4979 | |
| 4980 | 4980 | $notify_edited = true; |
@@ -4986,9 +4986,9 @@ discard block |
||
| 4986 | 4986 | * @param bool $notify_edited Notify on listing edited by author? |
| 4987 | 4987 | * @param object $post The current post object. |
| 4988 | 4988 | */ |
| 4989 | - $notify_edited = apply_filters( 'geodir_notify_on_listing_edited', $notify_edited, $post ); |
|
| 4989 | + $notify_edited = apply_filters('geodir_notify_on_listing_edited', $notify_edited, $post);
|
|
| 4990 | 4990 | |
| 4991 | - geodir_sendEmail( $from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID ); |
|
| 4991 | + geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID); |
|
| 4992 | 4992 | } |
| 4993 | 4993 | } |
| 4994 | 4994 | } |
@@ -5003,14 +5003,14 @@ discard block |
||
| 5003 | 5003 | * |
| 5004 | 5004 | * @return string|null The current page start & end numbering. |
| 5005 | 5005 | */ |
| 5006 | -function geodir_title_meta_page( $sep ) {
|
|
| 5006 | +function geodir_title_meta_page($sep) {
|
|
| 5007 | 5007 | $replacement = null; |
| 5008 | 5008 | |
| 5009 | - $max = geodir_title_meta_pagenumbering( 'max' ); |
|
| 5010 | - $nr = geodir_title_meta_pagenumbering( 'nr' ); |
|
| 5009 | + $max = geodir_title_meta_pagenumbering('max');
|
|
| 5010 | + $nr = geodir_title_meta_pagenumbering('nr');
|
|
| 5011 | 5011 | |
| 5012 | - if ( $max > 1 && $nr > 1 ) {
|
|
| 5013 | - $replacement = sprintf( $sep . ' ' . __( 'Page %1$d of %2$d', 'geodirectory' ), $nr, $max ); |
|
| 5012 | + if ($max > 1 && $nr > 1) {
|
|
| 5013 | + $replacement = sprintf($sep.' '.__('Page %1$d of %2$d', 'geodirectory'), $nr, $max);
|
|
| 5014 | 5014 | } |
| 5015 | 5015 | |
| 5016 | 5016 | return $replacement; |
@@ -5027,8 +5027,8 @@ discard block |
||
| 5027 | 5027 | function geodir_title_meta_pagenumber() {
|
| 5028 | 5028 | $replacement = null; |
| 5029 | 5029 | |
| 5030 | - $nr = geodir_title_meta_pagenumbering( 'nr' ); |
|
| 5031 | - if ( isset( $nr ) && $nr > 0 ) {
|
|
| 5030 | + $nr = geodir_title_meta_pagenumbering('nr');
|
|
| 5031 | + if (isset($nr) && $nr > 0) {
|
|
| 5032 | 5032 | $replacement = (string) $nr; |
| 5033 | 5033 | } |
| 5034 | 5034 | |
@@ -5046,8 +5046,8 @@ discard block |
||
| 5046 | 5046 | function geodir_title_meta_pagetotal() {
|
| 5047 | 5047 | $replacement = null; |
| 5048 | 5048 | |
| 5049 | - $max = geodir_title_meta_pagenumbering( 'max' ); |
|
| 5050 | - if ( isset( $max ) && $max > 0 ) {
|
|
| 5049 | + $max = geodir_title_meta_pagenumbering('max');
|
|
| 5050 | + if (isset($max) && $max > 0) {
|
|
| 5051 | 5051 | $replacement = (string) $max; |
| 5052 | 5052 | } |
| 5053 | 5053 | |
@@ -5067,36 +5067,36 @@ discard block |
||
| 5067 | 5067 | * |
| 5068 | 5068 | * @return int|null The current page numbering. |
| 5069 | 5069 | */ |
| 5070 | -function geodir_title_meta_pagenumbering( $request = 'nr' ) {
|
|
| 5070 | +function geodir_title_meta_pagenumbering($request = 'nr') {
|
|
| 5071 | 5071 | global $wp_query, $post; |
| 5072 | 5072 | $max_num_pages = null; |
| 5073 | 5073 | $page_number = null; |
| 5074 | 5074 | |
| 5075 | 5075 | $max_num_pages = 1; |
| 5076 | 5076 | |
| 5077 | - if ( ! is_singular() ) {
|
|
| 5078 | - $page_number = get_query_var( 'paged' ); |
|
| 5079 | - if ( $page_number === 0 || $page_number === '' ) {
|
|
| 5077 | + if (!is_singular()) {
|
|
| 5078 | + $page_number = get_query_var('paged');
|
|
| 5079 | + if ($page_number === 0 || $page_number === '') {
|
|
| 5080 | 5080 | $page_number = 1; |
| 5081 | 5081 | } |
| 5082 | 5082 | |
| 5083 | - if ( isset( $wp_query->max_num_pages ) && ( $wp_query->max_num_pages != '' && $wp_query->max_num_pages != 0 ) ) {
|
|
| 5083 | + if (isset($wp_query->max_num_pages) && ($wp_query->max_num_pages != '' && $wp_query->max_num_pages != 0)) {
|
|
| 5084 | 5084 | $max_num_pages = $wp_query->max_num_pages; |
| 5085 | 5085 | } |
| 5086 | 5086 | } else {
|
| 5087 | - $page_number = get_query_var( 'page' ); |
|
| 5088 | - if ( $page_number === 0 || $page_number === '' ) {
|
|
| 5087 | + $page_number = get_query_var('page');
|
|
| 5088 | + if ($page_number === 0 || $page_number === '') {
|
|
| 5089 | 5089 | $page_number = 1; |
| 5090 | 5090 | } |
| 5091 | 5091 | |
| 5092 | - if ( isset( $post->post_content ) ) {
|
|
| 5093 | - $max_num_pages = ( substr_count( $post->post_content, '<!--nextpage-->' ) + 1 ); |
|
| 5092 | + if (isset($post->post_content)) {
|
|
| 5093 | + $max_num_pages = (substr_count($post->post_content, '<!--nextpage-->') + 1); |
|
| 5094 | 5094 | } |
| 5095 | 5095 | } |
| 5096 | 5096 | |
| 5097 | 5097 | $return = null; |
| 5098 | 5098 | |
| 5099 | - switch ( $request ) {
|
|
| 5099 | + switch ($request) {
|
|
| 5100 | 5100 | case 'nr': |
| 5101 | 5101 | $return = $page_number; |
| 5102 | 5102 | break; |
@@ -5117,14 +5117,14 @@ discard block |
||
| 5117 | 5117 | * |
| 5118 | 5118 | * @return array Terms. |
| 5119 | 5119 | */ |
| 5120 | -function geodir_filter_empty_terms( $terms ) {
|
|
| 5121 | - if ( empty( $terms ) ) {
|
|
| 5120 | +function geodir_filter_empty_terms($terms) {
|
|
| 5121 | + if (empty($terms)) {
|
|
| 5122 | 5122 | return $terms; |
| 5123 | 5123 | } |
| 5124 | 5124 | |
| 5125 | 5125 | $return = array(); |
| 5126 | - foreach ( $terms as $term ) {
|
|
| 5127 | - if ( isset( $term->count ) && $term->count > 0 ) {
|
|
| 5126 | + foreach ($terms as $term) {
|
|
| 5127 | + if (isset($term->count) && $term->count > 0) {
|
|
| 5128 | 5128 | $return[] = $term; |
| 5129 | 5129 | } else {
|
| 5130 | 5130 | /** |
@@ -5135,7 +5135,7 @@ discard block |
||
| 5135 | 5135 | * @param array $return The array of terms to return. |
| 5136 | 5136 | * @param object $term The term object. |
| 5137 | 5137 | */ |
| 5138 | - $return = apply_filters( 'geodir_filter_empty_terms_filter', $return, $term ); |
|
| 5138 | + $return = apply_filters('geodir_filter_empty_terms_filter', $return, $term);
|
|
| 5139 | 5139 | } |
| 5140 | 5140 | } |
| 5141 | 5141 | |
@@ -5152,15 +5152,15 @@ discard block |
||
| 5152 | 5152 | * |
| 5153 | 5153 | * @return array |
| 5154 | 5154 | */ |
| 5155 | -function geodir_remove_hentry( $class ) {
|
|
| 5156 | - if ( geodir_is_page( 'detail' ) ) {
|
|
| 5157 | - $class = array_diff( $class, array( 'hentry' ) ); |
|
| 5155 | +function geodir_remove_hentry($class) {
|
|
| 5156 | + if (geodir_is_page('detail')) {
|
|
| 5157 | + $class = array_diff($class, array('hentry'));
|
|
| 5158 | 5158 | } |
| 5159 | 5159 | |
| 5160 | 5160 | return $class; |
| 5161 | 5161 | } |
| 5162 | 5162 | |
| 5163 | -add_filter( 'post_class', 'geodir_remove_hentry' ); |
|
| 5163 | +add_filter('post_class', 'geodir_remove_hentry');
|
|
| 5164 | 5164 | |
| 5165 | 5165 | /** |
| 5166 | 5166 | * Registers a individual text string for WPML translation. |
@@ -5172,8 +5172,8 @@ discard block |
||
| 5172 | 5172 | * @param string $domain The plugin domain. Default geodirectory. |
| 5173 | 5173 | * @param string $name The name of the string which helps to know what's being translated. |
| 5174 | 5174 | */ |
| 5175 | -function geodir_wpml_register_string( $string, $domain = 'geodirectory', $name = '' ) {
|
|
| 5176 | - do_action( 'wpml_register_single_string', $domain, $name, $string ); |
|
| 5175 | +function geodir_wpml_register_string($string, $domain = 'geodirectory', $name = '') {
|
|
| 5176 | + do_action('wpml_register_single_string', $domain, $name, $string);
|
|
| 5177 | 5177 | } |
| 5178 | 5178 | |
| 5179 | 5179 | /** |
@@ -5188,6 +5188,6 @@ discard block |
||
| 5188 | 5188 | * @param string $language_code Return the translation in this language. Default is NULL which returns the current language. |
| 5189 | 5189 | * @return string The translated string. |
| 5190 | 5190 | */ |
| 5191 | -function geodir_wpml_translate_string( $string, $domain = 'geodirectory', $name = '', $language_code = NULL ) {
|
|
| 5192 | - return apply_filters( 'wpml_translate_single_string', $string, $domain, $name, $language_code ); |
|
| 5191 | +function geodir_wpml_translate_string($string, $domain = 'geodirectory', $name = '', $language_code = NULL) {
|
|
| 5192 | + return apply_filters('wpml_translate_single_string', $string, $domain, $name, $language_code);
|
|
| 5193 | 5193 | } |
| 5194 | 5194 | \ No newline at end of file |
@@ -31,13 +31,13 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | function geodir_comment_meta_row_action($a) |
| 33 | 33 | {
|
| 34 | - global $comment; |
|
| 34 | + global $comment; |
|
| 35 | 35 | |
| 36 | - $rating = geodir_get_commentoverall($comment->comment_ID); |
|
| 37 | - if ($rating != 0) {
|
|
| 38 | - echo geodir_get_rating_stars($rating, $comment->comment_ID); |
|
| 39 | - } |
|
| 40 | - return $a; |
|
| 36 | + $rating = geodir_get_commentoverall($comment->comment_ID); |
|
| 37 | + if ($rating != 0) {
|
|
| 38 | + echo geodir_get_rating_stars($rating, $comment->comment_ID); |
|
| 39 | + } |
|
| 40 | + return $a; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | add_action('add_meta_boxes_comment', 'geodir_comment_add_meta_box');
|
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | function geodir_comment_add_meta_box($comment) |
| 54 | 54 | {
|
| 55 | - add_meta_box('gd-comment-rating', __('Comment Rating', 'geodirectory'), 'geodir_comment_rating_meta', 'comment', 'normal', 'high');
|
|
| 55 | + add_meta_box('gd-comment-rating', __('Comment Rating', 'geodirectory'), 'geodir_comment_rating_meta', 'comment', 'normal', 'high');
|
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * @param object $comment The comment object. |
| 67 | 67 | */ |
| 68 | 68 | function geodir_comment_rating_meta($comment) {
|
| 69 | - $post_type = get_post_type($comment->comment_post_ID); |
|
| 69 | + $post_type = get_post_type($comment->comment_post_ID); |
|
| 70 | 70 | if (in_array($post_type, (array)geodir_get_posttypes()) && (int)$comment->comment_parent == 0 && !(!empty($post_type) && geodir_cpt_has_rating_disabled($post_type))) {
|
| 71 | 71 | $rating = geodir_get_commentoverall($comment->comment_ID); |
| 72 | 72 | |
@@ -106,24 +106,24 @@ discard block |
||
| 106 | 106 | * @global object $post The post object. |
| 107 | 107 | */ |
| 108 | 108 | function geodir_comment_rating_fields() {
|
| 109 | - global $post; |
|
| 109 | + global $post; |
|
| 110 | 110 | |
| 111 | - $post_types = geodir_get_posttypes(); |
|
| 111 | + $post_types = geodir_get_posttypes(); |
|
| 112 | 112 | |
| 113 | - if (!empty($post->post_type) && in_array($post->post_type, $post_types) && !(!empty($post->post_type) && geodir_cpt_has_rating_disabled($post->post_type))) {
|
|
| 114 | - $star_texts = array(); |
|
| 115 | - $star_texts[] = __('Terrible', 'geodirectory');
|
|
| 116 | - $star_texts[] = __('Poor', 'geodirectory');
|
|
| 117 | - $star_texts[] = __('Average', 'geodirectory');
|
|
| 118 | - $star_texts[] = __('Very Good', 'geodirectory');
|
|
| 119 | - $star_texts[] = __('Excellent', 'geodirectory');
|
|
| 113 | + if (!empty($post->post_type) && in_array($post->post_type, $post_types) && !(!empty($post->post_type) && geodir_cpt_has_rating_disabled($post->post_type))) {
|
|
| 114 | + $star_texts = array(); |
|
| 115 | + $star_texts[] = __('Terrible', 'geodirectory');
|
|
| 116 | + $star_texts[] = __('Poor', 'geodirectory');
|
|
| 117 | + $star_texts[] = __('Average', 'geodirectory');
|
|
| 118 | + $star_texts[] = __('Very Good', 'geodirectory');
|
|
| 119 | + $star_texts[] = __('Excellent', 'geodirectory');
|
|
| 120 | 120 | |
| 121 | - $gd_rating_html = apply_filters('gd_rating_form_html', '<div class="gd_rating" data-average="0" data-id="5"></div>', $star_texts);
|
|
| 122 | - echo $gd_rating_html; |
|
| 123 | - ?> |
|
| 121 | + $gd_rating_html = apply_filters('gd_rating_form_html', '<div class="gd_rating" data-average="0" data-id="5"></div>', $star_texts);
|
|
| 122 | + echo $gd_rating_html; |
|
| 123 | + ?> |
|
| 124 | 124 | <input type="hidden" id="geodir_overallrating" name="geodir_overallrating" value="0"/> |
| 125 | 125 | <?php |
| 126 | - } |
|
| 126 | + } |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | add_filter('comment_reply_link', 'geodir_comment_replaylink');
|
@@ -138,9 +138,9 @@ discard block |
||
| 138 | 138 | function geodir_comment_replaylink($link) |
| 139 | 139 | {
|
| 140 | 140 | |
| 141 | - $link = '<div class="gd_comment_replaylink">' . $link . '</div>'; |
|
| 141 | + $link = '<div class="gd_comment_replaylink">' . $link . '</div>'; |
|
| 142 | 142 | |
| 143 | - return $link; |
|
| 143 | + return $link; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | add_filter('cancel_comment_reply_link', 'geodir_cancle_replaylink');
|
@@ -155,9 +155,9 @@ discard block |
||
| 155 | 155 | function geodir_cancle_replaylink($link) |
| 156 | 156 | {
|
| 157 | 157 | |
| 158 | - $link = '<span class="gd-cancel-replaylink">' . $link . '</span>'; |
|
| 158 | + $link = '<span class="gd-cancel-replaylink">' . $link . '</span>'; |
|
| 159 | 159 | |
| 160 | - return $link; |
|
| 160 | + return $link; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | add_action('comment_post', 'geodir_save_rating');
|
@@ -173,32 +173,32 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | function geodir_save_rating($comment = 0) |
| 175 | 175 | {
|
| 176 | - global $wpdb, $user_ID, $plugin_prefix; |
|
| 176 | + global $wpdb, $user_ID, $plugin_prefix; |
|
| 177 | 177 | |
| 178 | - $comment_info = get_comment($comment); |
|
| 178 | + $comment_info = get_comment($comment); |
|
| 179 | 179 | |
| 180 | - $post_id = $comment_info->comment_post_ID; |
|
| 181 | - $status = $comment_info->comment_approved; |
|
| 182 | - $rating_ip = getenv("REMOTE_ADDR");
|
|
| 180 | + $post_id = $comment_info->comment_post_ID; |
|
| 181 | + $status = $comment_info->comment_approved; |
|
| 182 | + $rating_ip = getenv("REMOTE_ADDR");
|
|
| 183 | 183 | |
| 184 | - $post = geodir_get_post_info($post_id); |
|
| 185 | - if (empty($post)) {
|
|
| 186 | - return; |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - if ($post->post_status == 'publish') {
|
|
| 190 | - $post_status = '1'; |
|
| 191 | - } else {
|
|
| 192 | - $post_status = '0'; |
|
| 193 | - } |
|
| 184 | + $post = geodir_get_post_info($post_id); |
|
| 185 | + if (empty($post)) {
|
|
| 186 | + return; |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + if ($post->post_status == 'publish') {
|
|
| 190 | + $post_status = '1'; |
|
| 191 | + } else {
|
|
| 192 | + $post_status = '0'; |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | - if (isset($_REQUEST['geodir_overallrating'])) {
|
|
| 196 | - $overall_rating = $_REQUEST['geodir_overallrating']; |
|
| 195 | + if (isset($_REQUEST['geodir_overallrating'])) {
|
|
| 196 | + $overall_rating = $_REQUEST['geodir_overallrating']; |
|
| 197 | 197 | |
| 198 | 198 | if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
|
| 199 | - $overall_rating = $overall_rating > 0 ? $overall_rating : '0'; |
|
| 199 | + $overall_rating = $overall_rating > 0 ? $overall_rating : '0'; |
|
| 200 | 200 | |
| 201 | - $sqlqry = $wpdb->prepare("INSERT INTO " . GEODIR_REVIEW_TABLE . " SET
|
|
| 201 | + $sqlqry = $wpdb->prepare("INSERT INTO " . GEODIR_REVIEW_TABLE . " SET
|
|
| 202 | 202 | post_id = %d, |
| 203 | 203 | post_type = %s, |
| 204 | 204 | post_title = %s, |
@@ -216,35 +216,35 @@ discard block |
||
| 216 | 216 | post_latitude = %s, |
| 217 | 217 | comment_content = %s |
| 218 | 218 | ", |
| 219 | - array($post_id, $post->post_type, $post->post_title, $user_ID, $comment, $rating_ip, $overall_rating, $status, $post_status, date_i18n('Y-m-d H:i:s', current_time('timestamp')), $post->post_city, $post->post_region, $post->post_country, $post->post_latitude, $post->post_longitude, $comment_info->comment_content)
|
|
| 220 | - ); |
|
| 221 | - |
|
| 222 | - $wpdb->query($sqlqry); |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * Called after saving the comment. |
|
| 226 | - * |
|
| 227 | - * @since 1.0.0 |
|
| 228 | - * @package GeoDirectory |
|
| 229 | - * @param array $_REQUEST {
|
|
| 230 | - * Attributes of the $_REQUEST variable. |
|
| 231 | - * |
|
| 232 | - * @type string $geodir_overallrating Overall rating. |
|
| 233 | - * @type string $comment Comment text. |
|
| 234 | - * @type string $submit Submit button text. |
|
| 235 | - * @type string $comment_post_ID Comment post ID. |
|
| 236 | - * @type string $comment_parent Comment Parent ID. |
|
| 237 | - * @type string $_wp_unfiltered_html_comment Unfiltered html comment string. |
|
| 238 | - * |
|
| 239 | - * } |
|
| 240 | - */ |
|
| 241 | - do_action('geodir_after_save_comment', $_REQUEST, 'Comment Your Post');
|
|
| 242 | - |
|
| 243 | - if ($status) {
|
|
| 244 | - geodir_update_postrating($post_id); |
|
| 245 | - } |
|
| 246 | - } |
|
| 247 | - } |
|
| 219 | + array($post_id, $post->post_type, $post->post_title, $user_ID, $comment, $rating_ip, $overall_rating, $status, $post_status, date_i18n('Y-m-d H:i:s', current_time('timestamp')), $post->post_city, $post->post_region, $post->post_country, $post->post_latitude, $post->post_longitude, $comment_info->comment_content)
|
|
| 220 | + ); |
|
| 221 | + |
|
| 222 | + $wpdb->query($sqlqry); |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * Called after saving the comment. |
|
| 226 | + * |
|
| 227 | + * @since 1.0.0 |
|
| 228 | + * @package GeoDirectory |
|
| 229 | + * @param array $_REQUEST {
|
|
| 230 | + * Attributes of the $_REQUEST variable. |
|
| 231 | + * |
|
| 232 | + * @type string $geodir_overallrating Overall rating. |
|
| 233 | + * @type string $comment Comment text. |
|
| 234 | + * @type string $submit Submit button text. |
|
| 235 | + * @type string $comment_post_ID Comment post ID. |
|
| 236 | + * @type string $comment_parent Comment Parent ID. |
|
| 237 | + * @type string $_wp_unfiltered_html_comment Unfiltered html comment string. |
|
| 238 | + * |
|
| 239 | + * } |
|
| 240 | + */ |
|
| 241 | + do_action('geodir_after_save_comment', $_REQUEST, 'Comment Your Post');
|
|
| 242 | + |
|
| 243 | + if ($status) {
|
|
| 244 | + geodir_update_postrating($post_id); |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | + } |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | |
@@ -262,51 +262,51 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | function geodir_update_rating_status_change($comment_id, $status) |
| 264 | 264 | {
|
| 265 | - if ($status == 'delete') {
|
|
| 266 | - return; |
|
| 267 | - } |
|
| 268 | - global $wpdb, $plugin_prefix, $user_ID; |
|
| 265 | + if ($status == 'delete') {
|
|
| 266 | + return; |
|
| 267 | + } |
|
| 268 | + global $wpdb, $plugin_prefix, $user_ID; |
|
| 269 | 269 | |
| 270 | - $comment_info = get_comment($comment_id); |
|
| 270 | + $comment_info = get_comment($comment_id); |
|
| 271 | 271 | |
| 272 | - $post_id = isset($comment_info->comment_post_ID) ? $comment_info->comment_post_ID : ''; |
|
| 272 | + $post_id = isset($comment_info->comment_post_ID) ? $comment_info->comment_post_ID : ''; |
|
| 273 | 273 | |
| 274 | - if (!empty($comment_info)) |
|
| 275 | - $status = $comment_info->comment_approved; |
|
| 274 | + if (!empty($comment_info)) |
|
| 275 | + $status = $comment_info->comment_approved; |
|
| 276 | 276 | |
| 277 | - if ($status == 'approve' || $status == 1) {
|
|
| 278 | - $status = 1; |
|
| 279 | - } else {
|
|
| 280 | - $status = 0; |
|
| 281 | - } |
|
| 277 | + if ($status == 'approve' || $status == 1) {
|
|
| 278 | + $status = 1; |
|
| 279 | + } else {
|
|
| 280 | + $status = 0; |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | - $comment_info_ID = isset($comment_info->comment_ID) ? $comment_info->comment_ID : ''; |
|
| 284 | - $old_rating = geodir_get_commentoverall($comment_info_ID); |
|
| 283 | + $comment_info_ID = isset($comment_info->comment_ID) ? $comment_info->comment_ID : ''; |
|
| 284 | + $old_rating = geodir_get_commentoverall($comment_info_ID); |
|
| 285 | 285 | |
| 286 | - $post_type = get_post_type($post_id); |
|
| 286 | + $post_type = get_post_type($post_id); |
|
| 287 | 287 | |
| 288 | - $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 288 | + $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 289 | 289 | |
| 290 | - if ($comment_id) {
|
|
| 290 | + if ($comment_id) {
|
|
| 291 | 291 | |
| 292 | - $overall_rating = $old_rating; |
|
| 292 | + $overall_rating = $old_rating; |
|
| 293 | 293 | |
| 294 | - if (isset($old_rating)) {
|
|
| 294 | + if (isset($old_rating)) {
|
|
| 295 | 295 | |
| 296 | - $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
|
|
| 296 | + $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
|
|
| 297 | 297 | overall_rating = %f, |
| 298 | 298 | status = %s, |
| 299 | 299 | comment_content = %s |
| 300 | 300 | WHERE comment_id = %d ", array($overall_rating, $status, $comment_info->comment_content, $comment_id)); |
| 301 | 301 | |
| 302 | - $wpdb->query($sqlqry); |
|
| 302 | + $wpdb->query($sqlqry); |
|
| 303 | 303 | |
| 304 | - //update rating |
|
| 305 | - geodir_update_postrating($post_id, $post_type); |
|
| 304 | + //update rating |
|
| 305 | + geodir_update_postrating($post_id, $post_type); |
|
| 306 | 306 | |
| 307 | - } |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | - } |
|
| 309 | + } |
|
| 310 | 310 | |
| 311 | 311 | } |
| 312 | 312 | |
@@ -325,41 +325,41 @@ discard block |
||
| 325 | 325 | function geodir_update_rating($comment_id = 0) |
| 326 | 326 | {
|
| 327 | 327 | |
| 328 | - global $wpdb, $plugin_prefix, $user_ID; |
|
| 328 | + global $wpdb, $plugin_prefix, $user_ID; |
|
| 329 | 329 | |
| 330 | - $comment_info = get_comment($comment_id); |
|
| 330 | + $comment_info = get_comment($comment_id); |
|
| 331 | 331 | |
| 332 | - $post_id = $comment_info->comment_post_ID; |
|
| 333 | - $status = $comment_info->comment_approved; |
|
| 334 | - $old_rating = geodir_get_commentoverall($comment_info->comment_ID); |
|
| 332 | + $post_id = $comment_info->comment_post_ID; |
|
| 333 | + $status = $comment_info->comment_approved; |
|
| 334 | + $old_rating = geodir_get_commentoverall($comment_info->comment_ID); |
|
| 335 | 335 | |
| 336 | - $post_type = get_post_type($post_id); |
|
| 336 | + $post_type = get_post_type($post_id); |
|
| 337 | 337 | |
| 338 | - $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 338 | + $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 339 | 339 | |
| 340 | - if (isset($_REQUEST['geodir_overallrating'])) {
|
|
| 340 | + if (isset($_REQUEST['geodir_overallrating'])) {
|
|
| 341 | 341 | |
| 342 | - $overall_rating = $_REQUEST['geodir_overallrating']; |
|
| 342 | + $overall_rating = $_REQUEST['geodir_overallrating']; |
|
| 343 | 343 | |
| 344 | - if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
|
|
| 345 | - $overall_rating = $overall_rating > 0 ? $overall_rating : '0'; |
|
| 344 | + if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
|
|
| 345 | + $overall_rating = $overall_rating > 0 ? $overall_rating : '0'; |
|
| 346 | 346 | |
| 347 | - if (isset($old_rating)) {
|
|
| 347 | + if (isset($old_rating)) {
|
|
| 348 | 348 | |
| 349 | - $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
|
|
| 349 | + $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
|
|
| 350 | 350 | overall_rating = %f, |
| 351 | 351 | status = %s, |
| 352 | 352 | comment_content = %s |
| 353 | 353 | WHERE comment_id = %d ", array($overall_rating, $status, $comment_info->comment_content, $comment_id)); |
| 354 | 354 | |
| 355 | - $wpdb->query($sqlqry); |
|
| 355 | + $wpdb->query($sqlqry); |
|
| 356 | 356 | |
| 357 | - //update rating |
|
| 358 | - geodir_update_postrating($post_id, $post_type); |
|
| 357 | + //update rating |
|
| 358 | + geodir_update_postrating($post_id, $post_type); |
|
| 359 | 359 | |
| 360 | - } |
|
| 361 | - } |
|
| 362 | - } |
|
| 360 | + } |
|
| 361 | + } |
|
| 362 | + } |
|
| 363 | 363 | |
| 364 | 364 | |
| 365 | 365 | } |
@@ -375,19 +375,19 @@ discard block |
||
| 375 | 375 | */ |
| 376 | 376 | function geodir_comment_delete_comment($comment_id) |
| 377 | 377 | {
|
| 378 | - global $wpdb; |
|
| 378 | + global $wpdb; |
|
| 379 | 379 | |
| 380 | - $review_info = geodir_get_review($comment_id); |
|
| 381 | - if ($review_info) {
|
|
| 382 | - geodir_update_postrating($review_info->post_id); |
|
| 383 | - } |
|
| 380 | + $review_info = geodir_get_review($comment_id); |
|
| 381 | + if ($review_info) {
|
|
| 382 | + geodir_update_postrating($review_info->post_id); |
|
| 383 | + } |
|
| 384 | 384 | |
| 385 | - $wpdb->query( |
|
| 386 | - $wpdb->prepare( |
|
| 387 | - "DELETE FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d", |
|
| 388 | - array($comment_id) |
|
| 389 | - ) |
|
| 390 | - ); |
|
| 385 | + $wpdb->query( |
|
| 386 | + $wpdb->prepare( |
|
| 387 | + "DELETE FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d", |
|
| 388 | + array($comment_id) |
|
| 389 | + ) |
|
| 390 | + ); |
|
| 391 | 391 | |
| 392 | 392 | } |
| 393 | 393 | |
@@ -403,21 +403,21 @@ discard block |
||
| 403 | 403 | * @return string The comment content. |
| 404 | 404 | */ |
| 405 | 405 | function geodir_wrap_comment_text($content, $comment = '') {
|
| 406 | - if (!empty($comment->comment_post_ID) && geodir_cpt_has_rating_disabled((int)$comment->comment_post_ID)) {
|
|
| 407 | - if (!is_admin()) {
|
|
| 408 | - return '<div class="description">' . $content . '</div>'; |
|
| 409 | - } else {
|
|
| 410 | - return $content; |
|
| 411 | - } |
|
| 412 | - } else {
|
|
| 413 | - $rating = 0; |
|
| 414 | - if (!empty($comment)) |
|
| 415 | - $rating = geodir_get_commentoverall($comment->comment_ID); |
|
| 416 | - if ($rating != 0 && !is_admin()) {
|
|
| 417 | - return '<div><div class="gd-rating-text">' . __('Overall Rating', 'geodirectory') . ': <div class="rating">' . $rating . '</div></div>' . geodir_get_rating_stars($rating, $comment->comment_ID) . '</div><div class="description">' . $content . '</div>';
|
|
| 418 | - } else |
|
| 419 | - return $content; |
|
| 420 | - } |
|
| 406 | + if (!empty($comment->comment_post_ID) && geodir_cpt_has_rating_disabled((int)$comment->comment_post_ID)) {
|
|
| 407 | + if (!is_admin()) {
|
|
| 408 | + return '<div class="description">' . $content . '</div>'; |
|
| 409 | + } else {
|
|
| 410 | + return $content; |
|
| 411 | + } |
|
| 412 | + } else {
|
|
| 413 | + $rating = 0; |
|
| 414 | + if (!empty($comment)) |
|
| 415 | + $rating = geodir_get_commentoverall($comment->comment_ID); |
|
| 416 | + if ($rating != 0 && !is_admin()) {
|
|
| 417 | + return '<div><div class="gd-rating-text">' . __('Overall Rating', 'geodirectory') . ': <div class="rating">' . $rating . '</div></div>' . geodir_get_rating_stars($rating, $comment->comment_ID) . '</div><div class="description">' . $content . '</div>';
|
|
| 418 | + } else |
|
| 419 | + return $content; |
|
| 420 | + } |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | |
@@ -434,41 +434,41 @@ discard block |
||
| 434 | 434 | */ |
| 435 | 435 | function geodir_update_postrating($post_id = 0, $post_type = '', $delete = false) |
| 436 | 436 | {
|
| 437 | - global $wpdb, $plugin_prefix, $comment; |
|
| 438 | - if (!$post_type) {
|
|
| 439 | - $post_type = get_post_type($post_id); |
|
| 440 | - } |
|
| 441 | - $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 442 | - $post_newrating = geodir_get_post_rating($post_id, 1); |
|
| 443 | - $post_newrating_count = geodir_get_review_count_total($post_id); |
|
| 437 | + global $wpdb, $plugin_prefix, $comment; |
|
| 438 | + if (!$post_type) {
|
|
| 439 | + $post_type = get_post_type($post_id); |
|
| 440 | + } |
|
| 441 | + $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 442 | + $post_newrating = geodir_get_post_rating($post_id, 1); |
|
| 443 | + $post_newrating_count = geodir_get_review_count_total($post_id); |
|
| 444 | 444 | |
| 445 | 445 | |
| 446 | - //$post_newrating = ( (float)$post_oldrating - (float)$old_rating ) + (float)$overall_rating ; |
|
| 446 | + //$post_newrating = ( (float)$post_oldrating - (float)$old_rating ) + (float)$overall_rating ; |
|
| 447 | 447 | |
| 448 | - if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
|
|
| 448 | + if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
|
|
| 449 | 449 | |
| 450 | - $wpdb->query( |
|
| 451 | - $wpdb->prepare( |
|
| 452 | - "UPDATE " . $detail_table . " SET |
|
| 450 | + $wpdb->query( |
|
| 451 | + $wpdb->prepare( |
|
| 452 | + "UPDATE " . $detail_table . " SET |
|
| 453 | 453 | overall_rating = %f, |
| 454 | 454 | rating_count = %f |
| 455 | 455 | where post_id = %d", |
| 456 | - array($post_newrating, $post_newrating_count, $post_id) |
|
| 457 | - ) |
|
| 458 | - ); |
|
| 459 | - |
|
| 460 | - update_post_meta($post_id, 'overall_rating', $post_newrating); |
|
| 461 | - update_post_meta($post_id, 'rating_count', $post_newrating_count); |
|
| 462 | - } |
|
| 463 | - /** |
|
| 464 | - * Called after Updating post overall rating and rating count. |
|
| 465 | - * |
|
| 466 | - * @since 1.0.0 |
|
| 467 | - * @since 1.4.3 Added `$post_id` param. |
|
| 468 | - * @package GeoDirectory |
|
| 469 | - * @param int $post_id The post ID. |
|
| 470 | - */ |
|
| 471 | - do_action('geodir_update_postrating',$post_id);
|
|
| 456 | + array($post_newrating, $post_newrating_count, $post_id) |
|
| 457 | + ) |
|
| 458 | + ); |
|
| 459 | + |
|
| 460 | + update_post_meta($post_id, 'overall_rating', $post_newrating); |
|
| 461 | + update_post_meta($post_id, 'rating_count', $post_newrating_count); |
|
| 462 | + } |
|
| 463 | + /** |
|
| 464 | + * Called after Updating post overall rating and rating count. |
|
| 465 | + * |
|
| 466 | + * @since 1.0.0 |
|
| 467 | + * @since 1.4.3 Added `$post_id` param. |
|
| 468 | + * @package GeoDirectory |
|
| 469 | + * @param int $post_id The post ID. |
|
| 470 | + */ |
|
| 471 | + do_action('geodir_update_postrating',$post_id);
|
|
| 472 | 472 | |
| 473 | 473 | } |
| 474 | 474 | |
@@ -486,29 +486,29 @@ discard block |
||
| 486 | 486 | */ |
| 487 | 487 | function geodir_get_postoverall($post_id = 0) |
| 488 | 488 | {
|
| 489 | - global $wpdb, $plugin_prefix; |
|
| 489 | + global $wpdb, $plugin_prefix; |
|
| 490 | 490 | |
| 491 | - $post_type = get_post_type($post_id); |
|
| 492 | - $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 491 | + $post_type = get_post_type($post_id); |
|
| 492 | + $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 493 | 493 | |
| 494 | - if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
|
|
| 494 | + if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
|
|
| 495 | 495 | |
| 496 | - $post_ratings = $wpdb->get_var( |
|
| 497 | - $wpdb->prepare( |
|
| 498 | - "SELECT overall_rating FROM " . $detail_table . " WHERE post_id = %d", |
|
| 499 | - array($post_id) |
|
| 500 | - ) |
|
| 501 | - ); |
|
| 496 | + $post_ratings = $wpdb->get_var( |
|
| 497 | + $wpdb->prepare( |
|
| 498 | + "SELECT overall_rating FROM " . $detail_table . " WHERE post_id = %d", |
|
| 499 | + array($post_id) |
|
| 500 | + ) |
|
| 501 | + ); |
|
| 502 | 502 | |
| 503 | 503 | |
| 504 | - } else {
|
|
| 505 | - $post_ratings = get_post_meta($post_id, 'overall_rating'); |
|
| 506 | - } |
|
| 504 | + } else {
|
|
| 505 | + $post_ratings = get_post_meta($post_id, 'overall_rating'); |
|
| 506 | + } |
|
| 507 | 507 | |
| 508 | - if ($post_ratings) |
|
| 509 | - return $post_ratings; |
|
| 510 | - else |
|
| 511 | - return false; |
|
| 508 | + if ($post_ratings) |
|
| 509 | + return $post_ratings; |
|
| 510 | + else |
|
| 511 | + return false; |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | |
@@ -525,19 +525,19 @@ discard block |
||
| 525 | 525 | */ |
| 526 | 526 | function geodir_get_review($comment_id = 0) |
| 527 | 527 | {
|
| 528 | - global $wpdb; |
|
| 529 | - |
|
| 530 | - $reatings = $wpdb->get_row( |
|
| 531 | - $wpdb->prepare( |
|
| 532 | - "SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d", |
|
| 533 | - array($comment_id) |
|
| 534 | - ) |
|
| 535 | - ); |
|
| 536 | - |
|
| 537 | - if (!empty($reatings)) |
|
| 538 | - return $reatings; |
|
| 539 | - else |
|
| 540 | - return false; |
|
| 528 | + global $wpdb; |
|
| 529 | + |
|
| 530 | + $reatings = $wpdb->get_row( |
|
| 531 | + $wpdb->prepare( |
|
| 532 | + "SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d", |
|
| 533 | + array($comment_id) |
|
| 534 | + ) |
|
| 535 | + ); |
|
| 536 | + |
|
| 537 | + if (!empty($reatings)) |
|
| 538 | + return $reatings; |
|
| 539 | + else |
|
| 540 | + return false; |
|
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | /** |
@@ -553,19 +553,19 @@ discard block |
||
| 553 | 553 | */ |
| 554 | 554 | function geodir_get_review_total($post_id = 0) |
| 555 | 555 | {
|
| 556 | - global $wpdb; |
|
| 557 | - |
|
| 558 | - $results = $wpdb->get_var( |
|
| 559 | - $wpdb->prepare( |
|
| 560 | - "SELECT SUM(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
| 561 | - array($post_id) |
|
| 562 | - ) |
|
| 563 | - ); |
|
| 564 | - |
|
| 565 | - if (!empty($results)) |
|
| 566 | - return $results; |
|
| 567 | - else |
|
| 568 | - return false; |
|
| 556 | + global $wpdb; |
|
| 557 | + |
|
| 558 | + $results = $wpdb->get_var( |
|
| 559 | + $wpdb->prepare( |
|
| 560 | + "SELECT SUM(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
| 561 | + array($post_id) |
|
| 562 | + ) |
|
| 563 | + ); |
|
| 564 | + |
|
| 565 | + if (!empty($results)) |
|
| 566 | + return $results; |
|
| 567 | + else |
|
| 568 | + return false; |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | /** |
@@ -581,18 +581,18 @@ discard block |
||
| 581 | 581 | */ |
| 582 | 582 | function geodir_get_review_count_by_user_id($user_id = 0) |
| 583 | 583 | {
|
| 584 | - global $wpdb; |
|
| 585 | - $results = $wpdb->get_var( |
|
| 586 | - $wpdb->prepare( |
|
| 587 | - "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE user_id = %d AND status=1 AND overall_rating>0", |
|
| 588 | - array($user_id) |
|
| 589 | - ) |
|
| 590 | - ); |
|
| 591 | - |
|
| 592 | - if (!empty($results)) |
|
| 593 | - return $results; |
|
| 594 | - else |
|
| 595 | - return false; |
|
| 584 | + global $wpdb; |
|
| 585 | + $results = $wpdb->get_var( |
|
| 586 | + $wpdb->prepare( |
|
| 587 | + "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE user_id = %d AND status=1 AND overall_rating>0", |
|
| 588 | + array($user_id) |
|
| 589 | + ) |
|
| 590 | + ); |
|
| 591 | + |
|
| 592 | + if (!empty($results)) |
|
| 593 | + return $results; |
|
| 594 | + else |
|
| 595 | + return false; |
|
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | /** |
@@ -610,27 +610,27 @@ discard block |
||
| 610 | 610 | */ |
| 611 | 611 | function geodir_get_post_rating($post_id = 0, $force_query = 0) |
| 612 | 612 | {
|
| 613 | - global $wpdb, $post; |
|
| 614 | - |
|
| 615 | - if (isset($post->ID) && $post->ID == $post_id && !$force_query) {
|
|
| 616 | - if (isset($post->rating_count) && $post->rating_count > 0 && isset($post->overall_rating) && $post->overall_rating > 0) {
|
|
| 617 | - return $post->overall_rating; |
|
| 618 | - } else {
|
|
| 619 | - return 0; |
|
| 620 | - } |
|
| 621 | - } |
|
| 622 | - |
|
| 623 | - $results = $wpdb->get_var( |
|
| 624 | - $wpdb->prepare( |
|
| 625 | - "SELECT COALESCE(avg(overall_rating),0) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
| 626 | - array($post_id) |
|
| 627 | - ) |
|
| 628 | - ); |
|
| 629 | - |
|
| 630 | - if (!empty($results)) |
|
| 631 | - return $results; |
|
| 632 | - else |
|
| 633 | - return false; |
|
| 613 | + global $wpdb, $post; |
|
| 614 | + |
|
| 615 | + if (isset($post->ID) && $post->ID == $post_id && !$force_query) {
|
|
| 616 | + if (isset($post->rating_count) && $post->rating_count > 0 && isset($post->overall_rating) && $post->overall_rating > 0) {
|
|
| 617 | + return $post->overall_rating; |
|
| 618 | + } else {
|
|
| 619 | + return 0; |
|
| 620 | + } |
|
| 621 | + } |
|
| 622 | + |
|
| 623 | + $results = $wpdb->get_var( |
|
| 624 | + $wpdb->prepare( |
|
| 625 | + "SELECT COALESCE(avg(overall_rating),0) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
| 626 | + array($post_id) |
|
| 627 | + ) |
|
| 628 | + ); |
|
| 629 | + |
|
| 630 | + if (!empty($results)) |
|
| 631 | + return $results; |
|
| 632 | + else |
|
| 633 | + return false; |
|
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | /** |
@@ -646,19 +646,19 @@ discard block |
||
| 646 | 646 | */ |
| 647 | 647 | function geodir_get_review_count_total($post_id = 0) |
| 648 | 648 | {
|
| 649 | - global $wpdb; |
|
| 650 | - |
|
| 651 | - $results = $wpdb->get_var( |
|
| 652 | - $wpdb->prepare( |
|
| 653 | - "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
| 654 | - array($post_id) |
|
| 655 | - ) |
|
| 656 | - ); |
|
| 657 | - |
|
| 658 | - if (!empty($results)) |
|
| 659 | - return $results; |
|
| 660 | - else |
|
| 661 | - return false; |
|
| 649 | + global $wpdb; |
|
| 650 | + |
|
| 651 | + $results = $wpdb->get_var( |
|
| 652 | + $wpdb->prepare( |
|
| 653 | + "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
| 654 | + array($post_id) |
|
| 655 | + ) |
|
| 656 | + ); |
|
| 657 | + |
|
| 658 | + if (!empty($results)) |
|
| 659 | + return $results; |
|
| 660 | + else |
|
| 661 | + return false; |
|
| 662 | 662 | } |
| 663 | 663 | |
| 664 | 664 | /** |
@@ -675,20 +675,20 @@ discard block |
||
| 675 | 675 | */ |
| 676 | 676 | function geodir_get_comments_number($post_id = 0) |
| 677 | 677 | {
|
| 678 | - global $wpdb; |
|
| 678 | + global $wpdb; |
|
| 679 | 679 | |
| 680 | - $results = $wpdb->get_var( |
|
| 681 | - $wpdb->prepare( |
|
| 682 | - "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
| 683 | - array($post_id) |
|
| 684 | - ) |
|
| 685 | - ); |
|
| 680 | + $results = $wpdb->get_var( |
|
| 681 | + $wpdb->prepare( |
|
| 682 | + "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
| 683 | + array($post_id) |
|
| 684 | + ) |
|
| 685 | + ); |
|
| 686 | 686 | |
| 687 | 687 | |
| 688 | - if (!empty($results)) |
|
| 689 | - return $results; |
|
| 690 | - else |
|
| 691 | - return false; |
|
| 688 | + if (!empty($results)) |
|
| 689 | + return $results; |
|
| 690 | + else |
|
| 691 | + return false; |
|
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | /** |
@@ -704,19 +704,19 @@ discard block |
||
| 704 | 704 | */ |
| 705 | 705 | function geodir_get_commentoverall($comment_id = 0) |
| 706 | 706 | {
|
| 707 | - global $wpdb; |
|
| 708 | - |
|
| 709 | - $reatings = $wpdb->get_var( |
|
| 710 | - $wpdb->prepare( |
|
| 711 | - "SELECT overall_rating FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d", |
|
| 712 | - array($comment_id) |
|
| 713 | - ) |
|
| 714 | - ); |
|
| 715 | - |
|
| 716 | - if ($reatings) |
|
| 717 | - return $reatings; |
|
| 718 | - else |
|
| 719 | - return false; |
|
| 707 | + global $wpdb; |
|
| 708 | + |
|
| 709 | + $reatings = $wpdb->get_var( |
|
| 710 | + $wpdb->prepare( |
|
| 711 | + "SELECT overall_rating FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d", |
|
| 712 | + array($comment_id) |
|
| 713 | + ) |
|
| 714 | + ); |
|
| 715 | + |
|
| 716 | + if ($reatings) |
|
| 717 | + return $reatings; |
|
| 718 | + else |
|
| 719 | + return false; |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | /** |
@@ -730,7 +730,7 @@ discard block |
||
| 730 | 730 | */ |
| 731 | 731 | function geodir_get_commentoverall_number($post_id = 0) |
| 732 | 732 | {
|
| 733 | - return geodir_get_post_rating($post_id); |
|
| 733 | + return geodir_get_post_rating($post_id); |
|
| 734 | 734 | } |
| 735 | 735 | |
| 736 | 736 | |
@@ -748,102 +748,102 @@ discard block |
||
| 748 | 748 | */ |
| 749 | 749 | function geodir_comment_template($comment_template) |
| 750 | 750 | {
|
| 751 | - global $post; |
|
| 751 | + global $post; |
|
| 752 | 752 | |
| 753 | - $post_types = geodir_get_posttypes(); |
|
| 753 | + $post_types = geodir_get_posttypes(); |
|
| 754 | 754 | |
| 755 | - if (!(is_singular() && (have_comments() || (isset($post->comment_status) && 'open' == $post->comment_status)))) {
|
|
| 756 | - return; |
|
| 757 | - } |
|
| 758 | - if (in_array($post->post_type, $post_types)) { // assuming there is a post type called business
|
|
| 759 | - if (geodir_cpt_has_rating_disabled($post->post_type)) {
|
|
| 760 | - return $comment_template; |
|
| 761 | - } |
|
| 755 | + if (!(is_singular() && (have_comments() || (isset($post->comment_status) && 'open' == $post->comment_status)))) {
|
|
| 756 | + return; |
|
| 757 | + } |
|
| 758 | + if (in_array($post->post_type, $post_types)) { // assuming there is a post type called business
|
|
| 759 | + if (geodir_cpt_has_rating_disabled($post->post_type)) {
|
|
| 760 | + return $comment_template; |
|
| 761 | + } |
|
| 762 | 762 | |
| 763 | - $template = locate_template(array("geodirectory/reviews.php")); // Use theme template if available
|
|
| 764 | - if (!$template) {
|
|
| 765 | - $template = dirname(__FILE__) . '/reviews.php'; |
|
| 766 | - } |
|
| 767 | - return $template; |
|
| 768 | - } |
|
| 763 | + $template = locate_template(array("geodirectory/reviews.php")); // Use theme template if available
|
|
| 764 | + if (!$template) {
|
|
| 765 | + $template = dirname(__FILE__) . '/reviews.php'; |
|
| 766 | + } |
|
| 767 | + return $template; |
|
| 768 | + } |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | add_filter("comments_template", "geodir_comment_template");
|
| 772 | 772 | |
| 773 | 773 | |
| 774 | 774 | if (!function_exists('geodir_comment')) {
|
| 775 | - /** |
|
| 776 | - * Comment HTML markup. |
|
| 777 | - * |
|
| 778 | - * @since 1.0.0 |
|
| 779 | - * @package GeoDirectory |
|
| 780 | - * @global object $post The current post object. |
|
| 781 | - * @param object $comment The comment object. |
|
| 782 | - * @param string|array $args {
|
|
| 783 | - * Optional. Formatting options. |
|
| 784 | - * |
|
| 785 | - * @type object $walker Instance of a Walker class to list comments. Default null. |
|
| 786 | - * @type int $max_depth The maximum comments depth. Default empty. |
|
| 787 | - * @type string $style The style of list ordering. Default 'ul'. Accepts 'ul', 'ol'. |
|
| 788 | - * @type string $callback Callback function to use. Default null. |
|
| 789 | - * @type string $end-callback Callback function to use at the end. Default null. |
|
| 790 | - * @type string $type Type of comments to list. |
|
| 791 | - * Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'. |
|
| 792 | - * @type int $page Page ID to list comments for. Default empty. |
|
| 793 | - * @type int $per_page Number of comments to list per page. Default empty. |
|
| 794 | - * @type int $avatar_size Height and width dimensions of the avatar size. Default 32. |
|
| 795 | - * @type string $reverse_top_level Ordering of the listed comments. Default null. Accepts 'desc', 'asc'. |
|
| 796 | - * @type bool $reverse_children Whether to reverse child comments in the list. Default null. |
|
| 797 | - * @type string $format How to format the comments list. |
|
| 798 | - * Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'. |
|
| 799 | - * @type bool $short_ping Whether to output short pings. Default false. |
|
| 800 | - * @type bool $echo Whether to echo the output or return it. Default true. |
|
| 801 | - * } |
|
| 802 | - * @param int $depth Depth of comment. |
|
| 803 | - */ |
|
| 804 | - function geodir_comment($comment, $args, $depth) |
|
| 805 | - {
|
|
| 806 | - $GLOBALS['comment'] = $comment; |
|
| 807 | - switch ($comment->comment_type) : |
|
| 808 | - case 'pingback' : |
|
| 809 | - case 'trackback' : |
|
| 810 | - // Display trackbacks differently than normal comments. |
|
| 811 | - ?> |
|
| 775 | + /** |
|
| 776 | + * Comment HTML markup. |
|
| 777 | + * |
|
| 778 | + * @since 1.0.0 |
|
| 779 | + * @package GeoDirectory |
|
| 780 | + * @global object $post The current post object. |
|
| 781 | + * @param object $comment The comment object. |
|
| 782 | + * @param string|array $args {
|
|
| 783 | + * Optional. Formatting options. |
|
| 784 | + * |
|
| 785 | + * @type object $walker Instance of a Walker class to list comments. Default null. |
|
| 786 | + * @type int $max_depth The maximum comments depth. Default empty. |
|
| 787 | + * @type string $style The style of list ordering. Default 'ul'. Accepts 'ul', 'ol'. |
|
| 788 | + * @type string $callback Callback function to use. Default null. |
|
| 789 | + * @type string $end-callback Callback function to use at the end. Default null. |
|
| 790 | + * @type string $type Type of comments to list. |
|
| 791 | + * Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'. |
|
| 792 | + * @type int $page Page ID to list comments for. Default empty. |
|
| 793 | + * @type int $per_page Number of comments to list per page. Default empty. |
|
| 794 | + * @type int $avatar_size Height and width dimensions of the avatar size. Default 32. |
|
| 795 | + * @type string $reverse_top_level Ordering of the listed comments. Default null. Accepts 'desc', 'asc'. |
|
| 796 | + * @type bool $reverse_children Whether to reverse child comments in the list. Default null. |
|
| 797 | + * @type string $format How to format the comments list. |
|
| 798 | + * Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'. |
|
| 799 | + * @type bool $short_ping Whether to output short pings. Default false. |
|
| 800 | + * @type bool $echo Whether to echo the output or return it. Default true. |
|
| 801 | + * } |
|
| 802 | + * @param int $depth Depth of comment. |
|
| 803 | + */ |
|
| 804 | + function geodir_comment($comment, $args, $depth) |
|
| 805 | + {
|
|
| 806 | + $GLOBALS['comment'] = $comment; |
|
| 807 | + switch ($comment->comment_type) : |
|
| 808 | + case 'pingback' : |
|
| 809 | + case 'trackback' : |
|
| 810 | + // Display trackbacks differently than normal comments. |
|
| 811 | + ?> |
|
| 812 | 812 | <li <?php comment_class('geodir-comment'); ?> id="comment-<?php comment_ID(); ?>">
|
| 813 | 813 | <p><?php _e('Pingback:', 'geodirectory'); ?> <?php comment_author_link(); ?> <?php edit_comment_link(__('(Edit)', 'geodirectory'), '<span class="edit-link">', '</span>'); ?></p>
|
| 814 | 814 | <?php |
| 815 | - break; |
|
| 816 | - default : |
|
| 817 | - // Proceed with normal comments. |
|
| 818 | - global $post; |
|
| 819 | - ?> |
|
| 815 | + break; |
|
| 816 | + default : |
|
| 817 | + // Proceed with normal comments. |
|
| 818 | + global $post; |
|
| 819 | + ?> |
|
| 820 | 820 | <li <?php comment_class('geodir-comment'); ?> id="li-comment-<?php comment_ID(); ?>">
|
| 821 | 821 | <article id="comment-<?php comment_ID(); ?>" class="comment"> |
| 822 | 822 | <header class="comment-meta comment-author vcard"> |
| 823 | 823 | <?php |
| 824 | - /** |
|
| 825 | - * Filter to modify comment avatar size |
|
| 826 | - * |
|
| 827 | - * You can use this filter to change comment avatar size. |
|
| 828 | - * |
|
| 829 | - * @since 1.0.0 |
|
| 830 | - * @package GeoDirectory |
|
| 831 | - */ |
|
| 832 | - $avatar_size = apply_filters('geodir_comment_avatar_size', 44);
|
|
| 833 | - echo get_avatar($comment, $avatar_size); |
|
| 834 | - printf('<cite><b class="reviewer">%1$s</b> %2$s</cite>',
|
|
| 835 | - get_comment_author_link(), |
|
| 836 | - // If current post author is also comment author, make it known visually. |
|
| 837 | - ($comment->user_id === $post->post_author) ? '<span>' . __('Post author', 'geodirectory') . '</span>' : ''
|
|
| 838 | - ); |
|
| 839 | - echo "<span class='item'><small><span class='fn'>$post->post_title</span></small></span>"; |
|
| 840 | - printf('<a href="%1$s"><time datetime="%2$s" class="dtreviewed">%3$s<span class="value-title" title="%2$s"></span></time></a>',
|
|
| 841 | - esc_url(get_comment_link($comment->comment_ID)), |
|
| 842 | - get_comment_time('c'),
|
|
| 843 | - /* translators: 1: date, 2: time */ |
|
| 844 | - sprintf(__('%1$s at %2$s', 'geodirectory'), get_comment_date(), get_comment_time())
|
|
| 845 | - ); |
|
| 846 | - ?> |
|
| 824 | + /** |
|
| 825 | + * Filter to modify comment avatar size |
|
| 826 | + * |
|
| 827 | + * You can use this filter to change comment avatar size. |
|
| 828 | + * |
|
| 829 | + * @since 1.0.0 |
|
| 830 | + * @package GeoDirectory |
|
| 831 | + */ |
|
| 832 | + $avatar_size = apply_filters('geodir_comment_avatar_size', 44);
|
|
| 833 | + echo get_avatar($comment, $avatar_size); |
|
| 834 | + printf('<cite><b class="reviewer">%1$s</b> %2$s</cite>',
|
|
| 835 | + get_comment_author_link(), |
|
| 836 | + // If current post author is also comment author, make it known visually. |
|
| 837 | + ($comment->user_id === $post->post_author) ? '<span>' . __('Post author', 'geodirectory') . '</span>' : ''
|
|
| 838 | + ); |
|
| 839 | + echo "<span class='item'><small><span class='fn'>$post->post_title</span></small></span>"; |
|
| 840 | + printf('<a href="%1$s"><time datetime="%2$s" class="dtreviewed">%3$s<span class="value-title" title="%2$s"></span></time></a>',
|
|
| 841 | + esc_url(get_comment_link($comment->comment_ID)), |
|
| 842 | + get_comment_time('c'),
|
|
| 843 | + /* translators: 1: date, 2: time */ |
|
| 844 | + sprintf(__('%1$s at %2$s', 'geodirectory'), get_comment_date(), get_comment_time())
|
|
| 845 | + ); |
|
| 846 | + ?> |
|
| 847 | 847 | </header> |
| 848 | 848 | <!-- .comment-meta --> |
| 849 | 849 | |
@@ -867,47 +867,47 @@ discard block |
||
| 867 | 867 | </article> |
| 868 | 868 | <!-- #comment-## --> |
| 869 | 869 | <?php |
| 870 | - break; |
|
| 871 | - endswitch; // end comment_type check |
|
| 872 | - } |
|
| 870 | + break; |
|
| 871 | + endswitch; // end comment_type check |
|
| 872 | + } |
|
| 873 | 873 | } |
| 874 | 874 | |
| 875 | 875 | |
| 876 | 876 | add_filter('get_comments_number', 'geodir_fix_comment_count', 10, 2);
|
| 877 | 877 | if (!function_exists('geodir_fix_comment_count')) {
|
| 878 | - /** |
|
| 879 | - * Fix comment count by not listing replies as reviews |
|
| 880 | - * |
|
| 881 | - * @since 1.0.0 |
|
| 882 | - * @package GeoDirectory |
|
| 883 | - * @global object $post The current post object. |
|
| 884 | - * @param int $count The comment count. |
|
| 885 | - * @param int $post_id The post ID. |
|
| 886 | - * @todo $post is unreachable since the function return the count before that variable. |
|
| 887 | - * @return bool|null|string The comment count. |
|
| 888 | - */ |
|
| 889 | - function geodir_fix_comment_count($count, $post_id) |
|
| 890 | - {
|
|
| 891 | - if (!is_admin() || strpos($_SERVER['REQUEST_URI'], 'admin-ajax.php')) {
|
|
| 892 | - global $post; |
|
| 893 | - $post_types = geodir_get_posttypes(); |
|
| 894 | - |
|
| 895 | - if (in_array(get_post_type($post_id), $post_types) && !geodir_cpt_has_rating_disabled((int)$post_id)) {
|
|
| 896 | - $review_count = geodir_get_review_count_total($post_id); |
|
| 897 | - return $review_count; |
|
| 898 | - |
|
| 899 | - if ($post && isset($post->rating_count)) {
|
|
| 900 | - return $post->rating_count; |
|
| 901 | - } else {
|
|
| 902 | - return geodir_get_comments_number($post_id); |
|
| 903 | - } |
|
| 904 | - } else {
|
|
| 905 | - return $count; |
|
| 906 | - } |
|
| 907 | - } else {
|
|
| 908 | - return $count; |
|
| 909 | - } |
|
| 910 | - } |
|
| 878 | + /** |
|
| 879 | + * Fix comment count by not listing replies as reviews |
|
| 880 | + * |
|
| 881 | + * @since 1.0.0 |
|
| 882 | + * @package GeoDirectory |
|
| 883 | + * @global object $post The current post object. |
|
| 884 | + * @param int $count The comment count. |
|
| 885 | + * @param int $post_id The post ID. |
|
| 886 | + * @todo $post is unreachable since the function return the count before that variable. |
|
| 887 | + * @return bool|null|string The comment count. |
|
| 888 | + */ |
|
| 889 | + function geodir_fix_comment_count($count, $post_id) |
|
| 890 | + {
|
|
| 891 | + if (!is_admin() || strpos($_SERVER['REQUEST_URI'], 'admin-ajax.php')) {
|
|
| 892 | + global $post; |
|
| 893 | + $post_types = geodir_get_posttypes(); |
|
| 894 | + |
|
| 895 | + if (in_array(get_post_type($post_id), $post_types) && !geodir_cpt_has_rating_disabled((int)$post_id)) {
|
|
| 896 | + $review_count = geodir_get_review_count_total($post_id); |
|
| 897 | + return $review_count; |
|
| 898 | + |
|
| 899 | + if ($post && isset($post->rating_count)) {
|
|
| 900 | + return $post->rating_count; |
|
| 901 | + } else {
|
|
| 902 | + return geodir_get_comments_number($post_id); |
|
| 903 | + } |
|
| 904 | + } else {
|
|
| 905 | + return $count; |
|
| 906 | + } |
|
| 907 | + } else {
|
|
| 908 | + return $count; |
|
| 909 | + } |
|
| 910 | + } |
|
| 911 | 911 | } |
| 912 | 912 | |
| 913 | 913 | /** |
@@ -925,14 +925,14 @@ discard block |
||
| 925 | 925 | */ |
| 926 | 926 | function geodir_get_rating_stars($rating, $post_id, $small = false) |
| 927 | 927 | {
|
| 928 | - if (!empty($post_id) && geodir_cpt_has_rating_disabled((int)$post_id)) {
|
|
| 929 | - return NULL; |
|
| 930 | - } |
|
| 931 | - $a_rating = $rating / 5 * 100; |
|
| 932 | - |
|
| 933 | - if ($small) {
|
|
| 934 | - $r_html = '<div class="rating"><div class="gd_rating_map" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingColor" ></div><div class="geodir_RatingAverage_small" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star_small"></div></div></div>'; |
|
| 935 | - } else {
|
|
| 928 | + if (!empty($post_id) && geodir_cpt_has_rating_disabled((int)$post_id)) {
|
|
| 929 | + return NULL; |
|
| 930 | + } |
|
| 931 | + $a_rating = $rating / 5 * 100; |
|
| 932 | + |
|
| 933 | + if ($small) {
|
|
| 934 | + $r_html = '<div class="rating"><div class="gd_rating_map" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingColor" ></div><div class="geodir_RatingAverage_small" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star_small"></div></div></div>'; |
|
| 935 | + } else {
|
|
| 936 | 936 | if (function_exists('geodir_reviewrating_draw_overall_rating')) {
|
| 937 | 937 | // Show rating stars from review rating manager |
| 938 | 938 | $r_html = geodir_reviewrating_draw_overall_rating($rating); |
@@ -949,8 +949,8 @@ discard block |
||
| 949 | 949 | } |
| 950 | 950 | $r_html = '<div class="geodir-rating" style="' . $attach_style . '"><div class="gd_rating_show" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingAverage" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star">' . $rating_img . $rating_img . $rating_img . $rating_img . $rating_img . '</div></div></div>'; |
| 951 | 951 | } |
| 952 | - } |
|
| 953 | - return apply_filters('geodir_get_rating_stars_html', $r_html, $rating, 5);
|
|
| 952 | + } |
|
| 953 | + return apply_filters('geodir_get_rating_stars_html', $r_html, $rating, 5);
|
|
| 954 | 954 | } |
| 955 | 955 | |
| 956 | 956 | /** |
@@ -964,23 +964,23 @@ discard block |
||
| 964 | 964 | function geodir_is_reviews_show($pageview = '') |
| 965 | 965 | {
|
| 966 | 966 | |
| 967 | - $active_tabs = get_option('geodir_detail_page_tabs_excluded');
|
|
| 968 | - |
|
| 969 | - $is_display = true; |
|
| 970 | - if (!empty($active_tabs) && in_array('reviews', $active_tabs))
|
|
| 971 | - $is_display = false; |
|
| 972 | - |
|
| 973 | - /** |
|
| 974 | - * Filter to change display value. |
|
| 975 | - * |
|
| 976 | - * You can use this filter to change the is_display value. |
|
| 977 | - * |
|
| 978 | - * @since 1.0.0 |
|
| 979 | - * @package GeoDirectory |
|
| 980 | - * @param bool $is_display Display ratings when set to true. |
|
| 981 | - * @param string $pageview The view template. Ex: listview, gridview etc. |
|
| 982 | - */ |
|
| 983 | - return apply_filters('geodir_is_reviews_show', $is_display, $pageview);
|
|
| 967 | + $active_tabs = get_option('geodir_detail_page_tabs_excluded');
|
|
| 968 | + |
|
| 969 | + $is_display = true; |
|
| 970 | + if (!empty($active_tabs) && in_array('reviews', $active_tabs))
|
|
| 971 | + $is_display = false; |
|
| 972 | + |
|
| 973 | + /** |
|
| 974 | + * Filter to change display value. |
|
| 975 | + * |
|
| 976 | + * You can use this filter to change the is_display value. |
|
| 977 | + * |
|
| 978 | + * @since 1.0.0 |
|
| 979 | + * @package GeoDirectory |
|
| 980 | + * @param bool $is_display Display ratings when set to true. |
|
| 981 | + * @param string $pageview The view template. Ex: listview, gridview etc. |
|
| 982 | + */ |
|
| 983 | + return apply_filters('geodir_is_reviews_show', $is_display, $pageview);
|
|
| 984 | 984 | } |
| 985 | 985 | |
| 986 | 986 | |
@@ -988,9 +988,9 @@ discard block |
||
| 988 | 988 | * If Disqus plugin is active, do some fixes to show on blogs but no on GD post types |
| 989 | 989 | */ |
| 990 | 990 | if(function_exists('dsq_can_replace')) {
|
| 991 | - remove_filter('comments_template', 'dsq_comments_template');
|
|
| 992 | - add_filter('comments_template', 'dsq_comments_template', 100);
|
|
| 993 | - add_filter('pre_option_disqus_active', 'geodir_option_disqus_active',10,1);
|
|
| 991 | + remove_filter('comments_template', 'dsq_comments_template');
|
|
| 992 | + add_filter('comments_template', 'dsq_comments_template', 100);
|
|
| 993 | + add_filter('pre_option_disqus_active', 'geodir_option_disqus_active',10,1);
|
|
| 994 | 994 | } |
| 995 | 995 | |
| 996 | 996 | |
@@ -1004,14 +1004,14 @@ discard block |
||
| 1004 | 1004 | * @return string `1` if active `0` if disabled. |
| 1005 | 1005 | */ |
| 1006 | 1006 | function geodir_option_disqus_active($disqus_active){
|
| 1007 | - global $post; |
|
| 1008 | - $all_postypes = geodir_get_posttypes(); |
|
| 1007 | + global $post; |
|
| 1008 | + $all_postypes = geodir_get_posttypes(); |
|
| 1009 | 1009 | |
| 1010 | - if(isset($post->post_type) && is_array($all_postypes) && in_array($post->post_type,$all_postypes)){
|
|
| 1011 | - $disqus_active = '0'; |
|
| 1012 | - } |
|
| 1010 | + if(isset($post->post_type) && is_array($all_postypes) && in_array($post->post_type,$all_postypes)){
|
|
| 1011 | + $disqus_active = '0'; |
|
| 1012 | + } |
|
| 1013 | 1013 | |
| 1014 | - return $disqus_active; |
|
| 1014 | + return $disqus_active; |
|
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | 1017 | /** |
@@ -1025,16 +1025,16 @@ discard block |
||
| 1025 | 1025 | * @return array Modified tabs array. |
| 1026 | 1026 | */ |
| 1027 | 1027 | function geodir_detail_reviews_tab_title($tabs_arr) {
|
| 1028 | - if (defined('GEODIR_CP_VERSION')) {
|
|
| 1029 | - return $tabs_arr; |
|
| 1030 | - } |
|
| 1028 | + if (defined('GEODIR_CP_VERSION')) {
|
|
| 1029 | + return $tabs_arr; |
|
| 1030 | + } |
|
| 1031 | 1031 | |
| 1032 | - $post_type = geodir_get_current_posttype(); |
|
| 1032 | + $post_type = geodir_get_current_posttype(); |
|
| 1033 | 1033 | |
| 1034 | - if (!empty($tabs_arr) && !empty($tabs_arr['reviews']) && isset($tabs_arr['reviews']['heading_text']) && $post_type != '' && geodir_cpt_has_rating_disabled($post_type)) {
|
|
| 1035 | - $tabs_arr['reviews']['heading_text'] = __('Comments', 'geodirectory');
|
|
| 1036 | - } |
|
| 1034 | + if (!empty($tabs_arr) && !empty($tabs_arr['reviews']) && isset($tabs_arr['reviews']['heading_text']) && $post_type != '' && geodir_cpt_has_rating_disabled($post_type)) {
|
|
| 1035 | + $tabs_arr['reviews']['heading_text'] = __('Comments', 'geodirectory');
|
|
| 1036 | + } |
|
| 1037 | 1037 | |
| 1038 | - return $tabs_arr; |
|
| 1038 | + return $tabs_arr; |
|
| 1039 | 1039 | } |
| 1040 | 1040 | add_filter('geodir_detail_page_tab_list_extend', 'geodir_detail_reviews_tab_title', 1000, 1); |
| 1041 | 1041 | \ No newline at end of file |
@@ -67,10 +67,10 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | function geodir_comment_rating_meta($comment) {
|
| 69 | 69 | $post_type = get_post_type($comment->comment_post_ID); |
| 70 | - if (in_array($post_type, (array)geodir_get_posttypes()) && (int)$comment->comment_parent == 0 && !(!empty($post_type) && geodir_cpt_has_rating_disabled($post_type))) {
|
|
| 70 | + if (in_array($post_type, (array) geodir_get_posttypes()) && (int) $comment->comment_parent == 0 && !(!empty($post_type) && geodir_cpt_has_rating_disabled($post_type))) {
|
|
| 71 | 71 | $rating = geodir_get_commentoverall($comment->comment_ID); |
| 72 | 72 | |
| 73 | - if ((int)get_option('geodir_reviewrating_enable_font_awesome') == 1) {
|
|
| 73 | + if ((int) get_option('geodir_reviewrating_enable_font_awesome') == 1) {
|
|
| 74 | 74 | $star_texts = array(); |
| 75 | 75 | $star_texts[] = __('Terrible', 'geodirectory');
|
| 76 | 76 | $star_texts[] = __('Poor', 'geodirectory');
|
@@ -81,13 +81,13 @@ discard block |
||
| 81 | 81 | echo geodir_font_awesome_rating_form_html('', $star_texts, $rating);
|
| 82 | 82 | } else {
|
| 83 | 83 | if ($rating) {
|
| 84 | - echo '<div class="gd_rating" data-average="' . $rating . '" data-id="5">'; |
|
| 84 | + echo '<div class="gd_rating" data-average="'.$rating.'" data-id="5">'; |
|
| 85 | 85 | |
| 86 | 86 | } else {
|
| 87 | 87 | echo '<div class="gd_rating" data-average="0" data-id="5"></div>'; |
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | - echo '<input type="hidden" id="geodir_overallrating" name="geodir_overallrating" value="' . $rating . '" />'; |
|
| 90 | + echo '<input type="hidden" id="geodir_overallrating" name="geodir_overallrating" value="'.$rating.'" />'; |
|
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | function geodir_comment_replaylink($link) |
| 139 | 139 | {
|
| 140 | 140 | |
| 141 | - $link = '<div class="gd_comment_replaylink">' . $link . '</div>'; |
|
| 141 | + $link = '<div class="gd_comment_replaylink">'.$link.'</div>'; |
|
| 142 | 142 | |
| 143 | 143 | return $link; |
| 144 | 144 | } |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | function geodir_cancle_replaylink($link) |
| 156 | 156 | {
|
| 157 | 157 | |
| 158 | - $link = '<span class="gd-cancel-replaylink">' . $link . '</span>'; |
|
| 158 | + $link = '<span class="gd-cancel-replaylink">'.$link.'</span>'; |
|
| 159 | 159 | |
| 160 | 160 | return $link; |
| 161 | 161 | } |
@@ -195,10 +195,10 @@ discard block |
||
| 195 | 195 | if (isset($_REQUEST['geodir_overallrating'])) {
|
| 196 | 196 | $overall_rating = $_REQUEST['geodir_overallrating']; |
| 197 | 197 | |
| 198 | - if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
|
|
| 198 | + if (isset($comment_info->comment_parent) && (int) $comment_info->comment_parent == 0) {
|
|
| 199 | 199 | $overall_rating = $overall_rating > 0 ? $overall_rating : '0'; |
| 200 | 200 | |
| 201 | - $sqlqry = $wpdb->prepare("INSERT INTO " . GEODIR_REVIEW_TABLE . " SET
|
|
| 201 | + $sqlqry = $wpdb->prepare("INSERT INTO ".GEODIR_REVIEW_TABLE." SET
|
|
| 202 | 202 | post_id = %d, |
| 203 | 203 | post_type = %s, |
| 204 | 204 | post_title = %s, |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | |
| 286 | 286 | $post_type = get_post_type($post_id); |
| 287 | 287 | |
| 288 | - $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 288 | + $detail_table = $plugin_prefix.$post_type.'_detail'; |
|
| 289 | 289 | |
| 290 | 290 | if ($comment_id) {
|
| 291 | 291 | |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | |
| 294 | 294 | if (isset($old_rating)) {
|
| 295 | 295 | |
| 296 | - $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
|
|
| 296 | + $sqlqry = $wpdb->prepare("UPDATE ".GEODIR_REVIEW_TABLE." SET
|
|
| 297 | 297 | overall_rating = %f, |
| 298 | 298 | status = %s, |
| 299 | 299 | comment_content = %s |
@@ -335,18 +335,18 @@ discard block |
||
| 335 | 335 | |
| 336 | 336 | $post_type = get_post_type($post_id); |
| 337 | 337 | |
| 338 | - $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 338 | + $detail_table = $plugin_prefix.$post_type.'_detail'; |
|
| 339 | 339 | |
| 340 | 340 | if (isset($_REQUEST['geodir_overallrating'])) {
|
| 341 | 341 | |
| 342 | 342 | $overall_rating = $_REQUEST['geodir_overallrating']; |
| 343 | 343 | |
| 344 | - if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
|
|
| 344 | + if (isset($comment_info->comment_parent) && (int) $comment_info->comment_parent == 0) {
|
|
| 345 | 345 | $overall_rating = $overall_rating > 0 ? $overall_rating : '0'; |
| 346 | 346 | |
| 347 | 347 | if (isset($old_rating)) {
|
| 348 | 348 | |
| 349 | - $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
|
|
| 349 | + $sqlqry = $wpdb->prepare("UPDATE ".GEODIR_REVIEW_TABLE." SET
|
|
| 350 | 350 | overall_rating = %f, |
| 351 | 351 | status = %s, |
| 352 | 352 | comment_content = %s |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | |
| 385 | 385 | $wpdb->query( |
| 386 | 386 | $wpdb->prepare( |
| 387 | - "DELETE FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d", |
|
| 387 | + "DELETE FROM ".GEODIR_REVIEW_TABLE." WHERE comment_id=%d", |
|
| 388 | 388 | array($comment_id) |
| 389 | 389 | ) |
| 390 | 390 | ); |
@@ -403,9 +403,9 @@ discard block |
||
| 403 | 403 | * @return string The comment content. |
| 404 | 404 | */ |
| 405 | 405 | function geodir_wrap_comment_text($content, $comment = '') {
|
| 406 | - if (!empty($comment->comment_post_ID) && geodir_cpt_has_rating_disabled((int)$comment->comment_post_ID)) {
|
|
| 406 | + if (!empty($comment->comment_post_ID) && geodir_cpt_has_rating_disabled((int) $comment->comment_post_ID)) {
|
|
| 407 | 407 | if (!is_admin()) {
|
| 408 | - return '<div class="description">' . $content . '</div>'; |
|
| 408 | + return '<div class="description">'.$content.'</div>'; |
|
| 409 | 409 | } else {
|
| 410 | 410 | return $content; |
| 411 | 411 | } |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | if (!empty($comment)) |
| 415 | 415 | $rating = geodir_get_commentoverall($comment->comment_ID); |
| 416 | 416 | if ($rating != 0 && !is_admin()) {
|
| 417 | - return '<div><div class="gd-rating-text">' . __('Overall Rating', 'geodirectory') . ': <div class="rating">' . $rating . '</div></div>' . geodir_get_rating_stars($rating, $comment->comment_ID) . '</div><div class="description">' . $content . '</div>';
|
|
| 417 | + return '<div><div class="gd-rating-text">'.__('Overall Rating', 'geodirectory').': <div class="rating">'.$rating.'</div></div>'.geodir_get_rating_stars($rating, $comment->comment_ID).'</div><div class="description">'.$content.'</div>';
|
|
| 418 | 418 | } else |
| 419 | 419 | return $content; |
| 420 | 420 | } |
@@ -438,18 +438,18 @@ discard block |
||
| 438 | 438 | if (!$post_type) {
|
| 439 | 439 | $post_type = get_post_type($post_id); |
| 440 | 440 | } |
| 441 | - $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 441 | + $detail_table = $plugin_prefix.$post_type.'_detail'; |
|
| 442 | 442 | $post_newrating = geodir_get_post_rating($post_id, 1); |
| 443 | 443 | $post_newrating_count = geodir_get_review_count_total($post_id); |
| 444 | 444 | |
| 445 | 445 | |
| 446 | 446 | //$post_newrating = ( (float)$post_oldrating - (float)$old_rating ) + (float)$overall_rating ; |
| 447 | 447 | |
| 448 | - if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
|
|
| 448 | + if ($wpdb->get_var("SHOW TABLES LIKE '".$detail_table."'") == $detail_table) {
|
|
| 449 | 449 | |
| 450 | 450 | $wpdb->query( |
| 451 | 451 | $wpdb->prepare( |
| 452 | - "UPDATE " . $detail_table . " SET |
|
| 452 | + "UPDATE ".$detail_table." SET |
|
| 453 | 453 | overall_rating = %f, |
| 454 | 454 | rating_count = %f |
| 455 | 455 | where post_id = %d", |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | * @package GeoDirectory |
| 469 | 469 | * @param int $post_id The post ID. |
| 470 | 470 | */ |
| 471 | - do_action('geodir_update_postrating',$post_id);
|
|
| 471 | + do_action('geodir_update_postrating', $post_id);
|
|
| 472 | 472 | |
| 473 | 473 | } |
| 474 | 474 | |
@@ -489,13 +489,13 @@ discard block |
||
| 489 | 489 | global $wpdb, $plugin_prefix; |
| 490 | 490 | |
| 491 | 491 | $post_type = get_post_type($post_id); |
| 492 | - $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 492 | + $detail_table = $plugin_prefix.$post_type.'_detail'; |
|
| 493 | 493 | |
| 494 | - if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
|
|
| 494 | + if ($wpdb->get_var("SHOW TABLES LIKE '".$detail_table."'") == $detail_table) {
|
|
| 495 | 495 | |
| 496 | 496 | $post_ratings = $wpdb->get_var( |
| 497 | 497 | $wpdb->prepare( |
| 498 | - "SELECT overall_rating FROM " . $detail_table . " WHERE post_id = %d", |
|
| 498 | + "SELECT overall_rating FROM ".$detail_table." WHERE post_id = %d", |
|
| 499 | 499 | array($post_id) |
| 500 | 500 | ) |
| 501 | 501 | ); |
@@ -529,7 +529,7 @@ discard block |
||
| 529 | 529 | |
| 530 | 530 | $reatings = $wpdb->get_row( |
| 531 | 531 | $wpdb->prepare( |
| 532 | - "SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d", |
|
| 532 | + "SELECT * FROM ".GEODIR_REVIEW_TABLE." WHERE comment_id = %d", |
|
| 533 | 533 | array($comment_id) |
| 534 | 534 | ) |
| 535 | 535 | ); |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | |
| 558 | 558 | $results = $wpdb->get_var( |
| 559 | 559 | $wpdb->prepare( |
| 560 | - "SELECT SUM(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
| 560 | + "SELECT SUM(overall_rating) FROM ".GEODIR_REVIEW_TABLE." WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
| 561 | 561 | array($post_id) |
| 562 | 562 | ) |
| 563 | 563 | ); |
@@ -584,7 +584,7 @@ discard block |
||
| 584 | 584 | global $wpdb; |
| 585 | 585 | $results = $wpdb->get_var( |
| 586 | 586 | $wpdb->prepare( |
| 587 | - "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE user_id = %d AND status=1 AND overall_rating>0", |
|
| 587 | + "SELECT COUNT(overall_rating) FROM ".GEODIR_REVIEW_TABLE." WHERE user_id = %d AND status=1 AND overall_rating>0", |
|
| 588 | 588 | array($user_id) |
| 589 | 589 | ) |
| 590 | 590 | ); |
@@ -622,7 +622,7 @@ discard block |
||
| 622 | 622 | |
| 623 | 623 | $results = $wpdb->get_var( |
| 624 | 624 | $wpdb->prepare( |
| 625 | - "SELECT COALESCE(avg(overall_rating),0) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
| 625 | + "SELECT COALESCE(avg(overall_rating),0) FROM ".GEODIR_REVIEW_TABLE." WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
| 626 | 626 | array($post_id) |
| 627 | 627 | ) |
| 628 | 628 | ); |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | |
| 651 | 651 | $results = $wpdb->get_var( |
| 652 | 652 | $wpdb->prepare( |
| 653 | - "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
| 653 | + "SELECT COUNT(overall_rating) FROM ".GEODIR_REVIEW_TABLE." WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
| 654 | 654 | array($post_id) |
| 655 | 655 | ) |
| 656 | 656 | ); |
@@ -679,7 +679,7 @@ discard block |
||
| 679 | 679 | |
| 680 | 680 | $results = $wpdb->get_var( |
| 681 | 681 | $wpdb->prepare( |
| 682 | - "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
| 682 | + "SELECT COUNT(overall_rating) FROM ".GEODIR_REVIEW_TABLE." WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
| 683 | 683 | array($post_id) |
| 684 | 684 | ) |
| 685 | 685 | ); |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | |
| 709 | 709 | $reatings = $wpdb->get_var( |
| 710 | 710 | $wpdb->prepare( |
| 711 | - "SELECT overall_rating FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d", |
|
| 711 | + "SELECT overall_rating FROM ".GEODIR_REVIEW_TABLE." WHERE comment_id = %d", |
|
| 712 | 712 | array($comment_id) |
| 713 | 713 | ) |
| 714 | 714 | ); |
@@ -762,7 +762,7 @@ discard block |
||
| 762 | 762 | |
| 763 | 763 | $template = locate_template(array("geodirectory/reviews.php")); // Use theme template if available
|
| 764 | 764 | if (!$template) {
|
| 765 | - $template = dirname(__FILE__) . '/reviews.php'; |
|
| 765 | + $template = dirname(__FILE__).'/reviews.php'; |
|
| 766 | 766 | } |
| 767 | 767 | return $template; |
| 768 | 768 | } |
@@ -834,7 +834,7 @@ discard block |
||
| 834 | 834 | printf('<cite><b class="reviewer">%1$s</b> %2$s</cite>',
|
| 835 | 835 | get_comment_author_link(), |
| 836 | 836 | // If current post author is also comment author, make it known visually. |
| 837 | - ($comment->user_id === $post->post_author) ? '<span>' . __('Post author', 'geodirectory') . '</span>' : ''
|
|
| 837 | + ($comment->user_id === $post->post_author) ? '<span>'.__('Post author', 'geodirectory').'</span>' : ''
|
|
| 838 | 838 | ); |
| 839 | 839 | echo "<span class='item'><small><span class='fn'>$post->post_title</span></small></span>"; |
| 840 | 840 | printf('<a href="%1$s"><time datetime="%2$s" class="dtreviewed">%3$s<span class="value-title" title="%2$s"></span></time></a>',
|
@@ -892,7 +892,7 @@ discard block |
||
| 892 | 892 | global $post; |
| 893 | 893 | $post_types = geodir_get_posttypes(); |
| 894 | 894 | |
| 895 | - if (in_array(get_post_type($post_id), $post_types) && !geodir_cpt_has_rating_disabled((int)$post_id)) {
|
|
| 895 | + if (in_array(get_post_type($post_id), $post_types) && !geodir_cpt_has_rating_disabled((int) $post_id)) {
|
|
| 896 | 896 | $review_count = geodir_get_review_count_total($post_id); |
| 897 | 897 | return $review_count; |
| 898 | 898 | |
@@ -925,29 +925,29 @@ discard block |
||
| 925 | 925 | */ |
| 926 | 926 | function geodir_get_rating_stars($rating, $post_id, $small = false) |
| 927 | 927 | {
|
| 928 | - if (!empty($post_id) && geodir_cpt_has_rating_disabled((int)$post_id)) {
|
|
| 928 | + if (!empty($post_id) && geodir_cpt_has_rating_disabled((int) $post_id)) {
|
|
| 929 | 929 | return NULL; |
| 930 | 930 | } |
| 931 | 931 | $a_rating = $rating / 5 * 100; |
| 932 | 932 | |
| 933 | 933 | if ($small) {
|
| 934 | - $r_html = '<div class="rating"><div class="gd_rating_map" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingColor" ></div><div class="geodir_RatingAverage_small" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star_small"></div></div></div>'; |
|
| 934 | + $r_html = '<div class="rating"><div class="gd_rating_map" data-average="'.$rating.'" data-id="'.$post_id.'"><div class="geodir_RatingColor" ></div><div class="geodir_RatingAverage_small" style="width: '.$a_rating.'%;"></div><div class="geodir_Star_small"></div></div></div>'; |
|
| 935 | 935 | } else {
|
| 936 | 936 | if (function_exists('geodir_reviewrating_draw_overall_rating')) {
|
| 937 | 937 | // Show rating stars from review rating manager |
| 938 | 938 | $r_html = geodir_reviewrating_draw_overall_rating($rating); |
| 939 | 939 | } else {
|
| 940 | - $rating_img = '<img alt="rating icon" src="' . get_option('geodir_default_rating_star_icon') . '" />';
|
|
| 940 | + $rating_img = '<img alt="rating icon" src="'.get_option('geodir_default_rating_star_icon').'" />';
|
|
| 941 | 941 | |
| 942 | 942 | /* fix rating star for safari */ |
| 943 | 943 | $star_width = 23 * 5; |
| 944 | 944 | |
| 945 | 945 | if ($star_width > 0) {
|
| 946 | - $attach_style = 'max-width:' . $star_width . 'px'; |
|
| 946 | + $attach_style = 'max-width:'.$star_width.'px'; |
|
| 947 | 947 | } else {
|
| 948 | 948 | $attach_style = ''; |
| 949 | 949 | } |
| 950 | - $r_html = '<div class="geodir-rating" style="' . $attach_style . '"><div class="gd_rating_show" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingAverage" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star">' . $rating_img . $rating_img . $rating_img . $rating_img . $rating_img . '</div></div></div>'; |
|
| 950 | + $r_html = '<div class="geodir-rating" style="'.$attach_style.'"><div class="gd_rating_show" data-average="'.$rating.'" data-id="'.$post_id.'"><div class="geodir_RatingAverage" style="width: '.$a_rating.'%;"></div><div class="geodir_Star">'.$rating_img.$rating_img.$rating_img.$rating_img.$rating_img.'</div></div></div>'; |
|
| 951 | 951 | } |
| 952 | 952 | } |
| 953 | 953 | return apply_filters('geodir_get_rating_stars_html', $r_html, $rating, 5);
|
@@ -987,10 +987,10 @@ discard block |
||
| 987 | 987 | /* |
| 988 | 988 | * If Disqus plugin is active, do some fixes to show on blogs but no on GD post types |
| 989 | 989 | */ |
| 990 | -if(function_exists('dsq_can_replace')) {
|
|
| 990 | +if (function_exists('dsq_can_replace')) {
|
|
| 991 | 991 | remove_filter('comments_template', 'dsq_comments_template');
|
| 992 | 992 | add_filter('comments_template', 'dsq_comments_template', 100);
|
| 993 | - add_filter('pre_option_disqus_active', 'geodir_option_disqus_active',10,1);
|
|
| 993 | + add_filter('pre_option_disqus_active', 'geodir_option_disqus_active', 10, 1);
|
|
| 994 | 994 | } |
| 995 | 995 | |
| 996 | 996 | |
@@ -1003,11 +1003,11 @@ discard block |
||
| 1003 | 1003 | * @param string $disqus_active Hook called before DB call for option so this is empty. |
| 1004 | 1004 | * @return string `1` if active `0` if disabled. |
| 1005 | 1005 | */ |
| 1006 | -function geodir_option_disqus_active($disqus_active){
|
|
| 1006 | +function geodir_option_disqus_active($disqus_active) {
|
|
| 1007 | 1007 | global $post; |
| 1008 | 1008 | $all_postypes = geodir_get_posttypes(); |
| 1009 | 1009 | |
| 1010 | - if(isset($post->post_type) && is_array($all_postypes) && in_array($post->post_type,$all_postypes)){
|
|
| 1010 | + if (isset($post->post_type) && is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
|
|
| 1011 | 1011 | $disqus_active = '0'; |
| 1012 | 1012 | } |
| 1013 | 1013 | |
@@ -16,10 +16,10 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | function geodir_session_start() |
| 18 | 18 | {
|
| 19 | - if (!session_id()) session_start(); |
|
| 20 | - global $geodir_add_location_url; |
|
| 19 | + if (!session_id()) session_start(); |
|
| 20 | + global $geodir_add_location_url; |
|
| 21 | 21 | |
| 22 | - $geodir_add_location_url = NULL; |
|
| 22 | + $geodir_add_location_url = NULL; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -33,18 +33,18 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | function geodir_modified_query($query) |
| 35 | 35 | {
|
| 36 | - if ($query->is_main_query() && ( |
|
| 37 | - (geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
|
|
| 38 | - || geodir_is_page('listing')
|
|
| 39 | - || geodir_is_page('author')
|
|
| 40 | - || geodir_is_page('search')
|
|
| 41 | - || geodir_is_page('detail'))
|
|
| 42 | - ) {
|
|
| 43 | - |
|
| 44 | - $query->set('is_geodir_loop', true);
|
|
| 45 | - } |
|
| 36 | + if ($query->is_main_query() && ( |
|
| 37 | + (geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
|
|
| 38 | + || geodir_is_page('listing')
|
|
| 39 | + || geodir_is_page('author')
|
|
| 40 | + || geodir_is_page('search')
|
|
| 41 | + || geodir_is_page('detail'))
|
|
| 42 | + ) {
|
|
| 43 | + |
|
| 44 | + $query->set('is_geodir_loop', true);
|
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - return $query; |
|
| 47 | + return $query; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -67,81 +67,81 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | function set_listing_request($query ) |
| 69 | 69 | {
|
| 70 | - global $wp_query, $wpdb, $geodir_post_type, $table, $dist, $mylat, $mylon, $s, $snear, $s, $s_A, $s_SA; |
|
| 70 | + global $wp_query, $wpdb, $geodir_post_type, $table, $dist, $mylat, $mylon, $s, $snear, $s, $s_A, $s_SA; |
|
| 71 | 71 | |
| 72 | 72 | |
| 73 | - // fix woocommerce shop products filtered by language for GD + WPML + Woocommerce |
|
| 74 | - if (!geodir_is_geodir_page()) {
|
|
| 75 | - return; |
|
| 76 | - } |
|
| 73 | + // fix woocommerce shop products filtered by language for GD + WPML + Woocommerce |
|
| 74 | + if (!geodir_is_geodir_page()) {
|
|
| 75 | + return; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /* remove all pre filters */ |
|
| 79 | - remove_all_filters('query');
|
|
| 80 | - remove_all_filters('posts_search');
|
|
| 81 | - remove_all_filters('posts_fields');
|
|
| 82 | - remove_all_filters('posts_join');
|
|
| 83 | - remove_all_filters('posts_orderby');
|
|
| 84 | - remove_all_filters('posts_where');
|
|
| 78 | + /* remove all pre filters */ |
|
| 79 | + remove_all_filters('query');
|
|
| 80 | + remove_all_filters('posts_search');
|
|
| 81 | + remove_all_filters('posts_fields');
|
|
| 82 | + remove_all_filters('posts_join');
|
|
| 83 | + remove_all_filters('posts_orderby');
|
|
| 84 | + remove_all_filters('posts_where');
|
|
| 85 | 85 | |
| 86 | 86 | |
| 87 | - if ((is_search() && isset($_REQUEST['geodir_search']) && $_REQUEST['geodir_search'] != '')): |
|
| 87 | + if ((is_search() && isset($_REQUEST['geodir_search']) && $_REQUEST['geodir_search'] != '')): |
|
| 88 | 88 | |
| 89 | - if (isset($_REQUEST['scat']) && $_REQUEST['scat'] == 'all') $_REQUEST['scat'] = ''; |
|
| 90 | - //if(isset($_REQUEST['s']) && $_REQUEST['s'] == '+') $_REQUEST['s'] = ''; |
|
| 89 | + if (isset($_REQUEST['scat']) && $_REQUEST['scat'] == 'all') $_REQUEST['scat'] = ''; |
|
| 90 | + //if(isset($_REQUEST['s']) && $_REQUEST['s'] == '+') $_REQUEST['s'] = ''; |
|
| 91 | 91 | |
| 92 | - if (isset($_REQUEST['sdist'])) {
|
|
| 93 | - ($_REQUEST['sdist'] != '0' && $_REQUEST['sdist'] != '') ? $dist = esc_attr($_REQUEST['sdist']) : $dist = 25000; |
|
| 94 | - } elseif (get_option('geodir_search_dist') != '') {
|
|
| 95 | - $dist = get_option('geodir_search_dist');
|
|
| 92 | + if (isset($_REQUEST['sdist'])) {
|
|
| 93 | + ($_REQUEST['sdist'] != '0' && $_REQUEST['sdist'] != '') ? $dist = esc_attr($_REQUEST['sdist']) : $dist = 25000; |
|
| 94 | + } elseif (get_option('geodir_search_dist') != '') {
|
|
| 95 | + $dist = get_option('geodir_search_dist');
|
|
| 96 | 96 | |
| 97 | - } else {
|
|
| 98 | - $dist = 25000; |
|
| 99 | - } // Distance |
|
| 97 | + } else {
|
|
| 98 | + $dist = 25000; |
|
| 99 | + } // Distance |
|
| 100 | 100 | |
| 101 | - if (isset($_REQUEST['sgeo_lat'])) {
|
|
| 102 | - $mylat = (float)esc_attr($_REQUEST['sgeo_lat']); |
|
| 103 | - } else {
|
|
| 104 | - $mylat = (float)geodir_get_current_city_lat(); |
|
| 105 | - } // Latatude |
|
| 101 | + if (isset($_REQUEST['sgeo_lat'])) {
|
|
| 102 | + $mylat = (float)esc_attr($_REQUEST['sgeo_lat']); |
|
| 103 | + } else {
|
|
| 104 | + $mylat = (float)geodir_get_current_city_lat(); |
|
| 105 | + } // Latatude |
|
| 106 | 106 | |
| 107 | - if (isset($_REQUEST['sgeo_lon'])) {
|
|
| 108 | - $mylon = (float)esc_attr($_REQUEST['sgeo_lon']); |
|
| 109 | - } else {
|
|
| 110 | - $mylon = (float)geodir_get_current_city_lng(); |
|
| 111 | - } // Distance |
|
| 107 | + if (isset($_REQUEST['sgeo_lon'])) {
|
|
| 108 | + $mylon = (float)esc_attr($_REQUEST['sgeo_lon']); |
|
| 109 | + } else {
|
|
| 110 | + $mylon = (float)geodir_get_current_city_lng(); |
|
| 111 | + } // Distance |
|
| 112 | 112 | |
| 113 | - if (isset($_REQUEST['snear'])) {
|
|
| 114 | - $snear = trim(esc_attr($_REQUEST['snear'])); |
|
| 115 | - } |
|
| 113 | + if (isset($_REQUEST['snear'])) {
|
|
| 114 | + $snear = trim(esc_attr($_REQUEST['snear'])); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - if (isset($_REQUEST['s'])) {
|
|
| 118 | - $s = trim(esc_attr(wp_strip_all_tags($_REQUEST['s']))); |
|
| 119 | - } |
|
| 117 | + if (isset($_REQUEST['s'])) {
|
|
| 118 | + $s = trim(esc_attr(wp_strip_all_tags($_REQUEST['s']))); |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - if ($snear == 'NEAR ME') {
|
|
| 122 | - $ip = $_SERVER['REMOTE_ADDR']; |
|
| 123 | - $addr_details = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $ip));
|
|
| 124 | - $mylat = stripslashes(ucfirst($addr_details[geoplugin_latitude])); |
|
| 125 | - $mylon = stripslashes(ucfirst($addr_details[geoplugin_longitude])); |
|
| 126 | - } |
|
| 121 | + if ($snear == 'NEAR ME') {
|
|
| 122 | + $ip = $_SERVER['REMOTE_ADDR']; |
|
| 123 | + $addr_details = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $ip));
|
|
| 124 | + $mylat = stripslashes(ucfirst($addr_details[geoplugin_latitude])); |
|
| 125 | + $mylon = stripslashes(ucfirst($addr_details[geoplugin_longitude])); |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | 128 | |
| 129 | - if (strstr($s, ',')) {
|
|
| 130 | - $s_AA = str_replace(" ", "", $s);
|
|
| 131 | - $s_A = explode(",", $s_AA);
|
|
| 132 | - $s_A = implode('","', $s_A);
|
|
| 133 | - $s_A = '"' . $s_A . '"'; |
|
| 134 | - } else {
|
|
| 135 | - $s_A = '"' . $s . '"'; |
|
| 136 | - } |
|
| 129 | + if (strstr($s, ',')) {
|
|
| 130 | + $s_AA = str_replace(" ", "", $s);
|
|
| 131 | + $s_A = explode(",", $s_AA);
|
|
| 132 | + $s_A = implode('","', $s_A);
|
|
| 133 | + $s_A = '"' . $s_A . '"'; |
|
| 134 | + } else {
|
|
| 135 | + $s_A = '"' . $s . '"'; |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - if (strstr($s, ' ')) {
|
|
| 139 | - $s_SA = explode(" ", $s);
|
|
| 140 | - } else {
|
|
| 141 | - $s_SA = ''; |
|
| 142 | - } |
|
| 138 | + if (strstr($s, ' ')) {
|
|
| 139 | + $s_SA = explode(" ", $s);
|
|
| 140 | + } else {
|
|
| 141 | + $s_SA = ''; |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - endif; |
|
| 144 | + endif; |
|
| 145 | 145 | |
| 146 | 146 | |
| 147 | 147 | |
@@ -162,56 +162,56 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | function geodir_listing_loop_filter($query) |
| 164 | 164 | {
|
| 165 | - global $wp_query, $geodir_post_type, $table, $plugin_prefix, $table, $term; |
|
| 165 | + global $wp_query, $geodir_post_type, $table, $plugin_prefix, $table, $term; |
|
| 166 | 166 | |
| 167 | - // fix wp_reset_query for popular post view widget |
|
| 168 | - if (!geodir_is_geodir_page()) {
|
|
| 169 | - return; |
|
| 170 | - } |
|
| 167 | + // fix wp_reset_query for popular post view widget |
|
| 168 | + if (!geodir_is_geodir_page()) {
|
|
| 169 | + return; |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | - $geodir_post_type = geodir_get_current_posttype(); |
|
| 173 | - |
|
| 174 | - if (isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries) {
|
|
| 175 | - $taxonomies = wp_list_pluck($wp_query->tax_query->queries, 'taxonomy'); |
|
| 176 | - |
|
| 177 | - if (isset($wp_query->query[$taxonomies[0]])) {
|
|
| 178 | - $request_term = explode("/", $wp_query->query[$taxonomies[0]]);
|
|
| 179 | - $request_term = end($request_term); |
|
| 180 | - if (!term_exists($request_term)) {
|
|
| 181 | - $args = array('number' => '1',);
|
|
| 182 | - $terms_arr = get_terms($taxonomies[0], $args); |
|
| 183 | - foreach ($terms_arr as $location_term) {
|
|
| 184 | - $term_arr = $location_term; |
|
| 185 | - $term_arr->name = geodir_ucwords(str_replace('-', ' ', $request_term));
|
|
| 186 | - } |
|
| 187 | - $wp_query->queried_object_id = 1; |
|
| 188 | - $wp_query->queried_object = $term_arr; |
|
| 189 | - //print_r($wp_query) ; |
|
| 190 | - } |
|
| 191 | - } |
|
| 172 | + $geodir_post_type = geodir_get_current_posttype(); |
|
| 173 | + |
|
| 174 | + if (isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries) {
|
|
| 175 | + $taxonomies = wp_list_pluck($wp_query->tax_query->queries, 'taxonomy'); |
|
| 176 | + |
|
| 177 | + if (isset($wp_query->query[$taxonomies[0]])) {
|
|
| 178 | + $request_term = explode("/", $wp_query->query[$taxonomies[0]]);
|
|
| 179 | + $request_term = end($request_term); |
|
| 180 | + if (!term_exists($request_term)) {
|
|
| 181 | + $args = array('number' => '1',);
|
|
| 182 | + $terms_arr = get_terms($taxonomies[0], $args); |
|
| 183 | + foreach ($terms_arr as $location_term) {
|
|
| 184 | + $term_arr = $location_term; |
|
| 185 | + $term_arr->name = geodir_ucwords(str_replace('-', ' ', $request_term));
|
|
| 186 | + } |
|
| 187 | + $wp_query->queried_object_id = 1; |
|
| 188 | + $wp_query->queried_object = $term_arr; |
|
| 189 | + //print_r($wp_query) ; |
|
| 190 | + } |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - } |
|
| 194 | - if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']) {
|
|
| 195 | - |
|
| 196 | - $table = $plugin_prefix . $geodir_post_type . '_detail'; |
|
| 197 | - |
|
| 198 | - add_filter('posts_fields', 'geodir_posts_fields', 1);
|
|
| 199 | - add_filter('posts_join', 'geodir_posts_join', 1);
|
|
| 200 | - geodir_post_where(); |
|
| 201 | - if (!is_admin()) |
|
| 202 | - add_filter('posts_orderby', 'geodir_posts_orderby', 1);
|
|
| 203 | - |
|
| 204 | - // advanced filter for popular post view widget |
|
| 205 | - global $wp_query; |
|
| 206 | - if (!is_admin()) {
|
|
| 207 | - if (!empty($wp_query->query['with_pics_only'])) {
|
|
| 208 | - add_filter('posts_join', 'geodir_filter_widget_join', 1000);
|
|
| 209 | - } |
|
| 210 | - add_filter('posts_where', 'geodir_filter_widget_where', 1000);
|
|
| 211 | - } |
|
| 193 | + } |
|
| 194 | + if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']) {
|
|
| 212 | 195 | |
| 213 | - } |
|
| 214 | - return $query; |
|
| 196 | + $table = $plugin_prefix . $geodir_post_type . '_detail'; |
|
| 197 | + |
|
| 198 | + add_filter('posts_fields', 'geodir_posts_fields', 1);
|
|
| 199 | + add_filter('posts_join', 'geodir_posts_join', 1);
|
|
| 200 | + geodir_post_where(); |
|
| 201 | + if (!is_admin()) |
|
| 202 | + add_filter('posts_orderby', 'geodir_posts_orderby', 1);
|
|
| 203 | + |
|
| 204 | + // advanced filter for popular post view widget |
|
| 205 | + global $wp_query; |
|
| 206 | + if (!is_admin()) {
|
|
| 207 | + if (!empty($wp_query->query['with_pics_only'])) {
|
|
| 208 | + add_filter('posts_join', 'geodir_filter_widget_join', 1000);
|
|
| 209 | + } |
|
| 210 | + add_filter('posts_where', 'geodir_filter_widget_where', 1000);
|
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + } |
|
| 214 | + return $query; |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | |
@@ -230,67 +230,67 @@ discard block |
||
| 230 | 230 | * @return string Modified fields query string. |
| 231 | 231 | */ |
| 232 | 232 | function geodir_posts_fields($fields) {
|
| 233 | - global $wp_query, $wpdb, $geodir_post_type, $table, $plugin_prefix, $dist, $mylat, $mylon, $snear, $gd_session; |
|
| 233 | + global $wp_query, $wpdb, $geodir_post_type, $table, $plugin_prefix, $dist, $mylat, $mylon, $snear, $gd_session; |
|
| 234 | 234 | |
| 235 | - // Filter-Location-Manager to add location table. |
|
| 236 | - $fields .= ", " . $table . ".* "; |
|
| 235 | + // Filter-Location-Manager to add location table. |
|
| 236 | + $fields .= ", " . $table . ".* "; |
|
| 237 | 237 | |
| 238 | 238 | if ($snear != '' || $gd_session->get('all_near_me')) {
|
| 239 | - $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
|
|
| 239 | + $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
|
|
| 240 | 240 | |
| 241 | 241 | if ($gd_session->get('all_near_me')) {
|
| 242 | - $mylat = $gd_session->get('user_lat');
|
|
| 243 | - $mylon = $gd_session->get('user_lon');
|
|
| 244 | - } |
|
| 245 | - |
|
| 246 | - $fields .= " , (" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) )))as distance ";
|
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - global $s; |
|
| 250 | - if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
|
|
| 251 | - $keywords = explode(" ", $s);
|
|
| 252 | - |
|
| 253 | - if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
|
|
| 254 | - foreach($keywords as $kkey=>$kword){
|
|
| 255 | - if(mb_strlen($kword, 'UTF-8')<=$klimit){
|
|
| 256 | - unset($keywords[$kkey]); |
|
| 257 | - } |
|
| 258 | - } |
|
| 259 | - } |
|
| 242 | + $mylat = $gd_session->get('user_lat');
|
|
| 243 | + $mylon = $gd_session->get('user_lon');
|
|
| 244 | + } |
|
| 260 | 245 | |
| 246 | + $fields .= " , (" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) )))as distance ";
|
|
| 247 | + } |
|
| 261 | 248 | |
| 262 | - if (count($keywords) > 1) {
|
|
| 263 | - $parts = array( |
|
| 264 | - 'AND' => 'gd_alltitlematch_part', |
|
| 265 | - 'OR' => 'gd_titlematch_part' |
|
| 266 | - ); |
|
| 267 | - $gd_titlematch_part = ""; |
|
| 268 | - foreach ($parts as $key => $part) {
|
|
| 269 | - $gd_titlematch_part .= " CASE WHEN "; |
|
| 270 | - $count = 0; |
|
| 271 | - foreach ($keywords as $keyword) {
|
|
| 272 | - $keyword = trim($keyword); |
|
| 273 | - $keyword = wp_specialchars_decode($keyword ,ENT_QUOTES); |
|
| 249 | + global $s; |
|
| 250 | + if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
|
|
| 251 | + $keywords = explode(" ", $s);
|
|
| 252 | + |
|
| 253 | + if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
|
|
| 254 | + foreach($keywords as $kkey=>$kword){
|
|
| 255 | + if(mb_strlen($kword, 'UTF-8')<=$klimit){
|
|
| 256 | + unset($keywords[$kkey]); |
|
| 257 | + } |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + |
|
| 262 | + if (count($keywords) > 1) {
|
|
| 263 | + $parts = array( |
|
| 264 | + 'AND' => 'gd_alltitlematch_part', |
|
| 265 | + 'OR' => 'gd_titlematch_part' |
|
| 266 | + ); |
|
| 267 | + $gd_titlematch_part = ""; |
|
| 268 | + foreach ($parts as $key => $part) {
|
|
| 269 | + $gd_titlematch_part .= " CASE WHEN "; |
|
| 270 | + $count = 0; |
|
| 271 | + foreach ($keywords as $keyword) {
|
|
| 272 | + $keyword = trim($keyword); |
|
| 273 | + $keyword = wp_specialchars_decode($keyword ,ENT_QUOTES); |
|
| 274 | 274 | $count++; |
| 275 | - if ($count < count($keywords)) {
|
|
| 276 | - // $gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' " . $key . " "; |
|
| 275 | + if ($count < count($keywords)) {
|
|
| 276 | + // $gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' " . $key . " "; |
|
| 277 | 277 | $gd_titlematch_part .= "( " . $wpdb->posts . ".post_title LIKE '" . $keyword . "' OR " . $wpdb->posts . ".post_title LIKE '" . $keyword . "%%' OR " . $wpdb->posts . ".post_title LIKE '%% " . $keyword . "%%' ) " . $key . " "; |
| 278 | - } else {
|
|
| 279 | - //$gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' "; |
|
| 278 | + } else {
|
|
| 279 | + //$gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' "; |
|
| 280 | 280 | $gd_titlematch_part .= "( " . $wpdb->posts . ".post_title LIKE '" . $keyword . "' OR " . $wpdb->posts . ".post_title LIKE '" . $keyword . "%%' OR " . $wpdb->posts . ".post_title LIKE '%% " . $keyword . "%%' ) "; |
| 281 | - } |
|
| 282 | - } |
|
| 283 | - $gd_titlematch_part .= "THEN 1 ELSE 0 END AS " . $part . ","; |
|
| 284 | - } |
|
| 285 | - } else {
|
|
| 286 | - $gd_titlematch_part = ""; |
|
| 287 | - } |
|
| 288 | - $s = stripslashes_deep( $s ); |
|
| 289 | - $s = wp_specialchars_decode($s,ENT_QUOTES); |
|
| 281 | + } |
|
| 282 | + } |
|
| 283 | + $gd_titlematch_part .= "THEN 1 ELSE 0 END AS " . $part . ","; |
|
| 284 | + } |
|
| 285 | + } else {
|
|
| 286 | + $gd_titlematch_part = ""; |
|
| 287 | + } |
|
| 288 | + $s = stripslashes_deep( $s ); |
|
| 289 | + $s = wp_specialchars_decode($s,ENT_QUOTES); |
|
| 290 | 290 | $fields .= $wpdb->prepare(", CASE WHEN " . $table . ".is_featured='1' THEN 1 ELSE 0 END AS gd_featured, CASE WHEN " . $wpdb->posts . ".post_title LIKE %s THEN 1 ELSE 0 END AS gd_exacttitle," . $gd_titlematch_part . " CASE WHEN ( " . $wpdb->posts . ".post_title LIKE %s OR " . $wpdb->posts . ".post_title LIKE %s OR " . $wpdb->posts . ".post_title LIKE %s ) THEN 1 ELSE 0 END AS gd_titlematch, CASE WHEN ( " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s ) THEN 1 ELSE 0 END AS gd_content", array($s, $s, $s . '%', '% ' . $s . '%', $s, $s . ' %', '% ' . $s . ' %', '% ' . $s));
|
| 291 | - } |
|
| 291 | + } |
|
| 292 | 292 | |
| 293 | - return $fields; |
|
| 293 | + return $fields; |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | |
@@ -307,26 +307,26 @@ discard block |
||
| 307 | 307 | */ |
| 308 | 308 | function geodir_posts_join($join) |
| 309 | 309 | {
|
| 310 | - global $wpdb, $geodir_post_type, $table, $table_prefix, $plugin_prefix; |
|
| 310 | + global $wpdb, $geodir_post_type, $table, $table_prefix, $plugin_prefix; |
|
| 311 | 311 | |
| 312 | - ########### WPML ########### |
|
| 312 | + ########### WPML ########### |
|
| 313 | 313 | |
| 314 | - if (function_exists('icl_object_id')) {
|
|
| 315 | - global $sitepress; |
|
| 316 | - $lang_code = ICL_LANGUAGE_CODE; |
|
| 317 | - $default_lang_code = $sitepress->get_default_language(); |
|
| 318 | - if ($lang_code) {
|
|
| 319 | - $join .= "JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID"; |
|
| 320 | - } |
|
| 314 | + if (function_exists('icl_object_id')) {
|
|
| 315 | + global $sitepress; |
|
| 316 | + $lang_code = ICL_LANGUAGE_CODE; |
|
| 317 | + $default_lang_code = $sitepress->get_default_language(); |
|
| 318 | + if ($lang_code) {
|
|
| 319 | + $join .= "JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID"; |
|
| 320 | + } |
|
| 321 | 321 | |
| 322 | - } |
|
| 323 | - ########### WPML ########### |
|
| 322 | + } |
|
| 323 | + ########### WPML ########### |
|
| 324 | 324 | |
| 325 | - $join .= " INNER JOIN " . $table . " ON (" . $table . ".post_id = $wpdb->posts.ID) ";
|
|
| 326 | - //===old code start |
|
| 327 | - //$join .= " INNER JOIN ".POST_LOCATION_TABLE." ON (".$table.".post_location_id = ".POST_LOCATION_TABLE.".location_id) " ;//===old code end
|
|
| 325 | + $join .= " INNER JOIN " . $table . " ON (" . $table . ".post_id = $wpdb->posts.ID) ";
|
|
| 326 | + //===old code start |
|
| 327 | + //$join .= " INNER JOIN ".POST_LOCATION_TABLE." ON (".$table.".post_location_id = ".POST_LOCATION_TABLE.".location_id) " ;//===old code end
|
|
| 328 | 328 | |
| 329 | - return $join; |
|
| 329 | + return $join; |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | |
@@ -344,15 +344,15 @@ discard block |
||
| 344 | 344 | */ |
| 345 | 345 | function geodir_posts_orderby($orderby) |
| 346 | 346 | {
|
| 347 | - global $wpdb, $wp_query, $geodir_post_type, $table, $plugin_prefix, $snear, $default_sort; |
|
| 347 | + global $wpdb, $wp_query, $geodir_post_type, $table, $plugin_prefix, $snear, $default_sort; |
|
| 348 | 348 | |
| 349 | - $sort_by = ''; |
|
| 350 | - $orderby = ' '; |
|
| 349 | + $sort_by = ''; |
|
| 350 | + $orderby = ' '; |
|
| 351 | 351 | |
| 352 | - if (get_query_var('order_by'))
|
|
| 353 | - $sort_by = get_query_var('order_by');
|
|
| 352 | + if (get_query_var('order_by'))
|
|
| 353 | + $sort_by = get_query_var('order_by');
|
|
| 354 | 354 | |
| 355 | - /*if(isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries){
|
|
| 355 | + /*if(isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries){
|
|
| 356 | 356 | $current_term = $wp_query->get_queried_object(); |
| 357 | 357 | } |
| 358 | 358 | |
@@ -366,133 +366,133 @@ discard block |
||
| 366 | 366 | }*/ |
| 367 | 367 | |
| 368 | 368 | |
| 369 | - if ($snear != '') {
|
|
| 370 | - $orderby .= " distance,"; |
|
| 371 | - } |
|
| 369 | + if ($snear != '') {
|
|
| 370 | + $orderby .= " distance,"; |
|
| 371 | + } |
|
| 372 | 372 | |
| 373 | - if (isset($_REQUEST['sort_by']) && $_REQUEST['sort_by'] != '' && is_main_query()) |
|
| 374 | - $sort_by = esc_attr($_REQUEST['sort_by']); |
|
| 373 | + if (isset($_REQUEST['sort_by']) && $_REQUEST['sort_by'] != '' && is_main_query()) |
|
| 374 | + $sort_by = esc_attr($_REQUEST['sort_by']); |
|
| 375 | 375 | |
| 376 | 376 | |
| 377 | - if ($sort_by == '') {
|
|
| 378 | - $default_sort = geodir_get_posts_default_sort($geodir_post_type); |
|
| 379 | - if (!empty($default_sort)) |
|
| 380 | - $sort_by = $default_sort; |
|
| 381 | - } |
|
| 377 | + if ($sort_by == '') {
|
|
| 378 | + $default_sort = geodir_get_posts_default_sort($geodir_post_type); |
|
| 379 | + if (!empty($default_sort)) |
|
| 380 | + $sort_by = $default_sort; |
|
| 381 | + } |
|
| 382 | 382 | |
| 383 | - /* |
|
| 383 | + /* |
|
| 384 | 384 | if search by term & no location then order always "relevance" |
| 385 | 385 | if search by location then order always "nearest" |
| 386 | 386 | */ |
| 387 | - if (is_main_query() && geodir_is_page('search')) {
|
|
| 388 | - $search_term = get_query_var('s');
|
|
| 387 | + if (is_main_query() && geodir_is_page('search')) {
|
|
| 388 | + $search_term = get_query_var('s');
|
|
| 389 | 389 | |
| 390 | - if (trim($search_term) != '' && !isset($_REQUEST['sort_by'])) {
|
|
| 391 | - $sort_by = 'az'; |
|
| 392 | - } |
|
| 390 | + if (trim($search_term) != '' && !isset($_REQUEST['sort_by'])) {
|
|
| 391 | + $sort_by = 'az'; |
|
| 392 | + } |
|
| 393 | 393 | |
| 394 | - if ($snear != '' && $sort_by!='farthest') {
|
|
| 395 | - $sort_by = 'nearest'; |
|
| 396 | - } |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - switch ($sort_by): |
|
| 400 | - case 'newest': |
|
| 401 | - $orderby = "$wpdb->posts.post_date desc, "; |
|
| 402 | - break; |
|
| 403 | - case 'oldest': |
|
| 404 | - $orderby = "$wpdb->posts.post_date asc, "; |
|
| 405 | - break; |
|
| 406 | - case 'low_review': |
|
| 407 | - case 'rating_count_asc': |
|
| 408 | - $orderby = $table . ".rating_count ASC, " . $table . ".overall_rating ASC, "; |
|
| 409 | - break; |
|
| 410 | - case 'high_review': |
|
| 411 | - case 'rating_count_desc': |
|
| 412 | - $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, "; |
|
| 413 | - break; |
|
| 414 | - case 'low_rating': |
|
| 415 | - $orderby = "( " . $table . ".overall_rating ) ASC, " . $table . ".rating_count ASC, "; |
|
| 416 | - break; |
|
| 417 | - case 'high_rating': |
|
| 418 | - $orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, "; |
|
| 419 | - break; |
|
| 420 | - case 'featured': |
|
| 421 | - $orderby = $table . ".is_featured asc, "; |
|
| 422 | - break; |
|
| 423 | - case 'nearest': |
|
| 424 | - $orderby = " distance asc, "; |
|
| 425 | - break; |
|
| 426 | - case 'farthest': |
|
| 427 | - $orderby = " distance desc, "; |
|
| 428 | - break; |
|
| 429 | - case 'random': |
|
| 430 | - $orderby = " rand(), "; |
|
| 431 | - break; |
|
| 432 | - case 'az': |
|
| 433 | - $orderby = "$wpdb->posts.post_title asc, "; |
|
| 434 | - break; |
|
| 435 | - // sort by rating |
|
| 436 | - case 'overall_rating_desc': |
|
| 437 | - $orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, "; |
|
| 438 | - break; |
|
| 439 | - case 'overall_rating_asc': |
|
| 440 | - $orderby = " " . $table . ".overall_rating ASC, " . $table . ".rating_count ASC, "; |
|
| 441 | - break; |
|
| 442 | - default: |
|
| 443 | - |
|
| 444 | - break; |
|
| 445 | - endswitch; |
|
| 446 | - |
|
| 447 | - if ($sort_by != '' && geodir_cpt_has_rating_disabled($geodir_post_type)) {
|
|
| 448 | - if (in_array($sort_by, array('high_review', 'rating_count_desc', 'high_rating', 'overall_rating_desc'))) {
|
|
| 449 | - $orderby = "$wpdb->posts.comment_count DESC, "; |
|
| 450 | - $sort_by = 'comment_count_desc'; |
|
| 451 | - } else if (in_array($sort_by, array('low_review', 'rating_count_asc', 'low_rating', 'overall_rating_asc'))) {
|
|
| 452 | - $orderby = "$wpdb->posts.comment_count ASC, "; |
|
| 453 | - $sort_by = 'comment_count_asc'; |
|
| 454 | - } |
|
| 455 | - } |
|
| 394 | + if ($snear != '' && $sort_by!='farthest') {
|
|
| 395 | + $sort_by = 'nearest'; |
|
| 396 | + } |
|
| 397 | + } |
|
| 456 | 398 | |
| 457 | - global $s; |
|
| 399 | + switch ($sort_by): |
|
| 400 | + case 'newest': |
|
| 401 | + $orderby = "$wpdb->posts.post_date desc, "; |
|
| 402 | + break; |
|
| 403 | + case 'oldest': |
|
| 404 | + $orderby = "$wpdb->posts.post_date asc, "; |
|
| 405 | + break; |
|
| 406 | + case 'low_review': |
|
| 407 | + case 'rating_count_asc': |
|
| 408 | + $orderby = $table . ".rating_count ASC, " . $table . ".overall_rating ASC, "; |
|
| 409 | + break; |
|
| 410 | + case 'high_review': |
|
| 411 | + case 'rating_count_desc': |
|
| 412 | + $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, "; |
|
| 413 | + break; |
|
| 414 | + case 'low_rating': |
|
| 415 | + $orderby = "( " . $table . ".overall_rating ) ASC, " . $table . ".rating_count ASC, "; |
|
| 416 | + break; |
|
| 417 | + case 'high_rating': |
|
| 418 | + $orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, "; |
|
| 419 | + break; |
|
| 420 | + case 'featured': |
|
| 421 | + $orderby = $table . ".is_featured asc, "; |
|
| 422 | + break; |
|
| 423 | + case 'nearest': |
|
| 424 | + $orderby = " distance asc, "; |
|
| 425 | + break; |
|
| 426 | + case 'farthest': |
|
| 427 | + $orderby = " distance desc, "; |
|
| 428 | + break; |
|
| 429 | + case 'random': |
|
| 430 | + $orderby = " rand(), "; |
|
| 431 | + break; |
|
| 432 | + case 'az': |
|
| 433 | + $orderby = "$wpdb->posts.post_title asc, "; |
|
| 434 | + break; |
|
| 435 | + // sort by rating |
|
| 436 | + case 'overall_rating_desc': |
|
| 437 | + $orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, "; |
|
| 438 | + break; |
|
| 439 | + case 'overall_rating_asc': |
|
| 440 | + $orderby = " " . $table . ".overall_rating ASC, " . $table . ".rating_count ASC, "; |
|
| 441 | + break; |
|
| 442 | + default: |
|
| 443 | + |
|
| 444 | + break; |
|
| 445 | + endswitch; |
|
| 446 | + |
|
| 447 | + if ($sort_by != '' && geodir_cpt_has_rating_disabled($geodir_post_type)) {
|
|
| 448 | + if (in_array($sort_by, array('high_review', 'rating_count_desc', 'high_rating', 'overall_rating_desc'))) {
|
|
| 449 | + $orderby = "$wpdb->posts.comment_count DESC, "; |
|
| 450 | + $sort_by = 'comment_count_desc'; |
|
| 451 | + } else if (in_array($sort_by, array('low_review', 'rating_count_asc', 'low_rating', 'overall_rating_asc'))) {
|
|
| 452 | + $orderby = "$wpdb->posts.comment_count ASC, "; |
|
| 453 | + $sort_by = 'comment_count_asc'; |
|
| 454 | + } |
|
| 455 | + } |
|
| 458 | 456 | |
| 459 | - if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
|
|
| 460 | - $keywords = explode(" ", $s);
|
|
| 461 | - if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
|
|
| 462 | - foreach($keywords as $kkey=>$kword){
|
|
| 463 | - if(mb_strlen($kword, 'UTF-8')<=$klimit){
|
|
| 464 | - unset($keywords[$kkey]); |
|
| 465 | - } |
|
| 466 | - } |
|
| 467 | - } |
|
| 468 | - if ($sort_by == 'nearest' || $sort_by == 'farthest') {
|
|
| 469 | - if (count($keywords) > 1) {
|
|
| 470 | - $orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, "; |
|
| 471 | - } else {
|
|
| 472 | - $orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, "; |
|
| 473 | - } |
|
| 474 | - } else {
|
|
| 475 | - if (count($keywords) > 1) {
|
|
| 476 | - $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, " . $orderby; |
|
| 477 | - } else {
|
|
| 478 | - $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, " . $orderby; |
|
| 479 | - } |
|
| 480 | - } |
|
| 481 | - } |
|
| 457 | + global $s; |
|
| 458 | + |
|
| 459 | + if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
|
|
| 460 | + $keywords = explode(" ", $s);
|
|
| 461 | + if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
|
|
| 462 | + foreach($keywords as $kkey=>$kword){
|
|
| 463 | + if(mb_strlen($kword, 'UTF-8')<=$klimit){
|
|
| 464 | + unset($keywords[$kkey]); |
|
| 465 | + } |
|
| 466 | + } |
|
| 467 | + } |
|
| 468 | + if ($sort_by == 'nearest' || $sort_by == 'farthest') {
|
|
| 469 | + if (count($keywords) > 1) {
|
|
| 470 | + $orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, "; |
|
| 471 | + } else {
|
|
| 472 | + $orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, "; |
|
| 473 | + } |
|
| 474 | + } else {
|
|
| 475 | + if (count($keywords) > 1) {
|
|
| 476 | + $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, " . $orderby; |
|
| 477 | + } else {
|
|
| 478 | + $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, " . $orderby; |
|
| 479 | + } |
|
| 480 | + } |
|
| 481 | + } |
|
| 482 | 482 | |
| 483 | - /** |
|
| 484 | - * Filter order by SQL. |
|
| 485 | - * |
|
| 486 | - * @since 1.0.0 |
|
| 487 | - * @param string $orderby The orderby query string. |
|
| 488 | - * @param string $sort_by Sortby query string. |
|
| 489 | - * @param string $table Listing table name. |
|
| 490 | - */ |
|
| 491 | - $orderby = apply_filters('geodir_posts_order_by_sort', $orderby, $sort_by, $table);
|
|
| 483 | + /** |
|
| 484 | + * Filter order by SQL. |
|
| 485 | + * |
|
| 486 | + * @since 1.0.0 |
|
| 487 | + * @param string $orderby The orderby query string. |
|
| 488 | + * @param string $sort_by Sortby query string. |
|
| 489 | + * @param string $table Listing table name. |
|
| 490 | + */ |
|
| 491 | + $orderby = apply_filters('geodir_posts_order_by_sort', $orderby, $sort_by, $table);
|
|
| 492 | 492 | |
| 493 | - $orderby .= $table . ".is_featured asc, $wpdb->posts.post_date desc, $wpdb->posts.post_title "; |
|
| 493 | + $orderby .= $table . ".is_featured asc, $wpdb->posts.post_date desc, $wpdb->posts.post_title "; |
|
| 494 | 494 | |
| 495 | - return $orderby; |
|
| 495 | + return $orderby; |
|
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | |
@@ -510,53 +510,53 @@ discard block |
||
| 510 | 510 | function geodir_posts_order_by_custom_sort($orderby, $sort_by, $table) |
| 511 | 511 | {
|
| 512 | 512 | |
| 513 | - global $wpdb; |
|
| 513 | + global $wpdb; |
|
| 514 | 514 | |
| 515 | - if ($sort_by != '' && (!is_search() || ( isset($_REQUEST['s']) && isset($_REQUEST['snear']) && $_REQUEST['snear']=='' && ( $_REQUEST['s']=='' || $_REQUEST['s']==' ') ) )) {
|
|
| 515 | + if ($sort_by != '' && (!is_search() || ( isset($_REQUEST['s']) && isset($_REQUEST['snear']) && $_REQUEST['snear']=='' && ( $_REQUEST['s']=='' || $_REQUEST['s']==' ') ) )) {
|
|
| 516 | 516 | |
| 517 | - $sort_array = explode('_', $sort_by);
|
|
| 517 | + $sort_array = explode('_', $sort_by);
|
|
| 518 | 518 | |
| 519 | - $sort_by_count = count($sort_array); |
|
| 519 | + $sort_by_count = count($sort_array); |
|
| 520 | 520 | |
| 521 | - $order = $sort_array[$sort_by_count - 1]; |
|
| 521 | + $order = $sort_array[$sort_by_count - 1]; |
|
| 522 | 522 | |
| 523 | - if ($sort_by_count > 1 && ($order == 'asc' || $order == 'desc')) {
|
|
| 523 | + if ($sort_by_count > 1 && ($order == 'asc' || $order == 'desc')) {
|
|
| 524 | 524 | |
| 525 | - $sort_by = str_replace('_' . $order, '', $sort_by);
|
|
| 525 | + $sort_by = str_replace('_' . $order, '', $sort_by);
|
|
| 526 | 526 | |
| 527 | - switch ($sort_by): |
|
| 527 | + switch ($sort_by): |
|
| 528 | 528 | |
| 529 | - case 'post_date': |
|
| 530 | - case 'comment_count': |
|
| 529 | + case 'post_date': |
|
| 530 | + case 'comment_count': |
|
| 531 | 531 | |
| 532 | - $orderby = "$wpdb->posts." . $sort_by . " " . $order . ", ".$table . ".overall_rating " . $order . ", "; |
|
| 533 | - break; |
|
| 532 | + $orderby = "$wpdb->posts." . $sort_by . " " . $order . ", ".$table . ".overall_rating " . $order . ", "; |
|
| 533 | + break; |
|
| 534 | 534 | |
| 535 | - case 'distance': |
|
| 536 | - $orderby = $sort_by . " " . $order . ", "; |
|
| 537 | - break; |
|
| 535 | + case 'distance': |
|
| 536 | + $orderby = $sort_by . " " . $order . ", "; |
|
| 537 | + break; |
|
| 538 | 538 | |
| 539 | 539 | |
| 540 | - // sort by rating |
|
| 541 | - case 'overall_rating': |
|
| 542 | - $orderby = " " . $table . "." . $sort_by . " " . $order . ", " . $table . ".rating_count " . $order . ", "; |
|
| 540 | + // sort by rating |
|
| 541 | + case 'overall_rating': |
|
| 542 | + $orderby = " " . $table . "." . $sort_by . " " . $order . ", " . $table . ".rating_count " . $order . ", "; |
|
| 543 | 543 | |
| 544 | - break; |
|
| 544 | + break; |
|
| 545 | 545 | |
| 546 | 546 | |
| 547 | - default: |
|
| 548 | - if (geodir_column_exist($table, $sort_by)) {
|
|
| 547 | + default: |
|
| 548 | + if (geodir_column_exist($table, $sort_by)) {
|
|
| 549 | 549 | $orderby = $table . "." . $sort_by . " " . $order . ", "; |
| 550 | 550 | } |
| 551 | - break; |
|
| 551 | + break; |
|
| 552 | 552 | |
| 553 | - endswitch; |
|
| 553 | + endswitch; |
|
| 554 | 554 | |
| 555 | - } |
|
| 555 | + } |
|
| 556 | 556 | |
| 557 | - } |
|
| 557 | + } |
|
| 558 | 558 | |
| 559 | - return $orderby; |
|
| 559 | + return $orderby; |
|
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | /** |
@@ -571,34 +571,34 @@ discard block |
||
| 571 | 571 | {
|
| 572 | 572 | |
| 573 | 573 | |
| 574 | - global $wpdb, $geodir_post_type, $table, $s, $snear; |
|
| 574 | + global $wpdb, $geodir_post_type, $table, $s, $snear; |
|
| 575 | 575 | |
| 576 | - if (!is_admin()) {
|
|
| 576 | + if (!is_admin()) {
|
|
| 577 | 577 | |
| 578 | - if (geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 579 | - add_filter('posts_where', 'geodir_edit_listing_where', 1);
|
|
| 578 | + if (geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 579 | + add_filter('posts_where', 'geodir_edit_listing_where', 1);
|
|
| 580 | 580 | |
| 581 | - } elseif ((is_search() && $_REQUEST['geodir_search'])) {
|
|
| 581 | + } elseif ((is_search() && $_REQUEST['geodir_search'])) {
|
|
| 582 | 582 | |
| 583 | - add_filter('posts_where', 'searching_filter_where', 1);
|
|
| 583 | + add_filter('posts_where', 'searching_filter_where', 1);
|
|
| 584 | 584 | |
| 585 | - if ($snear != '') |
|
| 586 | - add_filter('posts_where', 'searching_filter_where', 1);
|
|
| 585 | + if ($snear != '') |
|
| 586 | + add_filter('posts_where', 'searching_filter_where', 1);
|
|
| 587 | 587 | |
| 588 | - add_filter('posts_orderby', 'geodir_posts_orderby', 1);
|
|
| 588 | + add_filter('posts_orderby', 'geodir_posts_orderby', 1);
|
|
| 589 | 589 | |
| 590 | - } elseif (geodir_is_page('author')) {
|
|
| 590 | + } elseif (geodir_is_page('author')) {
|
|
| 591 | 591 | |
| 592 | - add_filter('posts_where', 'author_filter_where', 1);
|
|
| 592 | + add_filter('posts_where', 'author_filter_where', 1);
|
|
| 593 | 593 | |
| 594 | - } |
|
| 594 | + } |
|
| 595 | 595 | |
| 596 | - //if (!geodir_is_page('detail'))
|
|
| 597 | - add_filter('posts_where', 'geodir_default_where', 1);/**/
|
|
| 596 | + //if (!geodir_is_page('detail'))
|
|
| 597 | + add_filter('posts_where', 'geodir_default_where', 1);/**/
|
|
| 598 | 598 | |
| 599 | - //add_filter( 'user_has_cap', 'geodir_preview_post_cap', 10, 3 );// let subscribers edit their own posts |
|
| 599 | + //add_filter( 'user_has_cap', 'geodir_preview_post_cap', 10, 3 );// let subscribers edit their own posts |
|
| 600 | 600 | |
| 601 | - } |
|
| 601 | + } |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | /** |
@@ -613,13 +613,13 @@ discard block |
||
| 613 | 613 | */ |
| 614 | 614 | function geodir_preview_post_cap($allcaps, $caps, $args) |
| 615 | 615 | {
|
| 616 | - $user_id = get_current_user_id(); |
|
| 617 | - if ($user_id && isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != '' && isset($_REQUEST['p']) && $_REQUEST['p'] != '' && $args[0] == 'edit_post' && $_REQUEST['p'] == $args[2]) {
|
|
| 616 | + $user_id = get_current_user_id(); |
|
| 617 | + if ($user_id && isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != '' && isset($_REQUEST['p']) && $_REQUEST['p'] != '' && $args[0] == 'edit_post' && $_REQUEST['p'] == $args[2]) {
|
|
| 618 | 618 | |
| 619 | - $allcaps['edit_posts'] = true; |
|
| 620 | - } |
|
| 621 | - //print_r($allcaps); |
|
| 622 | - return $allcaps; |
|
| 619 | + $allcaps['edit_posts'] = true; |
|
| 620 | + } |
|
| 621 | + //print_r($allcaps); |
|
| 622 | + return $allcaps; |
|
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | |
@@ -634,9 +634,9 @@ discard block |
||
| 634 | 634 | */ |
| 635 | 635 | function geodir_edit_listing_where($where) |
| 636 | 636 | {
|
| 637 | - global $wpdb; |
|
| 638 | - $where = $wpdb->prepare(" AND $wpdb->posts.ID = %d ", $_REQUEST['pid']);
|
|
| 639 | - return $where; |
|
| 637 | + global $wpdb; |
|
| 638 | + $where = $wpdb->prepare(" AND $wpdb->posts.ID = %d ", $_REQUEST['pid']);
|
|
| 639 | + return $where; |
|
| 640 | 640 | } |
| 641 | 641 | |
| 642 | 642 | |
@@ -653,29 +653,29 @@ discard block |
||
| 653 | 653 | */ |
| 654 | 654 | function geodir_default_where($where) |
| 655 | 655 | {
|
| 656 | - global $wp_query, $wpdb; |
|
| 657 | - |
|
| 658 | - //print_r($wp_query); |
|
| 659 | - ########### WPML ########### |
|
| 660 | - |
|
| 661 | - if (function_exists('icl_object_id')) {
|
|
| 662 | - global $sitepress, $table_prefix; |
|
| 663 | - $lang_code = ICL_LANGUAGE_CODE; |
|
| 664 | - $default_lang_code = $sitepress->get_default_language(); |
|
| 665 | - $q_post_type = isset($wp_query->query['post_type']) ? $wp_query->query['post_type'] : ''; |
|
| 666 | - //echo '##########'.$q_post_type; |
|
| 667 | - if ($lang_code && $q_post_type) {
|
|
| 668 | - $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type IN('post_" . $q_post_type . "') ";
|
|
| 669 | - //$where .= " AND icl_t.language_code = '$lang_code' "; |
|
| 670 | - } |
|
| 656 | + global $wp_query, $wpdb; |
|
| 671 | 657 | |
| 672 | - } |
|
| 673 | - ########### WPML ########### |
|
| 658 | + //print_r($wp_query); |
|
| 659 | + ########### WPML ########### |
|
| 660 | + |
|
| 661 | + if (function_exists('icl_object_id')) {
|
|
| 662 | + global $sitepress, $table_prefix; |
|
| 663 | + $lang_code = ICL_LANGUAGE_CODE; |
|
| 664 | + $default_lang_code = $sitepress->get_default_language(); |
|
| 665 | + $q_post_type = isset($wp_query->query['post_type']) ? $wp_query->query['post_type'] : ''; |
|
| 666 | + //echo '##########'.$q_post_type; |
|
| 667 | + if ($lang_code && $q_post_type) {
|
|
| 668 | + $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type IN('post_" . $q_post_type . "') ";
|
|
| 669 | + //$where .= " AND icl_t.language_code = '$lang_code' "; |
|
| 670 | + } |
|
| 671 | + |
|
| 672 | + } |
|
| 673 | + ########### WPML ########### |
|
| 674 | 674 | |
| 675 | 675 | |
| 676 | - return $where = str_replace("0 = 1", "1=1", $where);
|
|
| 676 | + return $where = str_replace("0 = 1", "1=1", $where);
|
|
| 677 | 677 | |
| 678 | - /* ====== old code start === |
|
| 678 | + /* ====== old code start === |
|
| 679 | 679 | $where = str_replace("0 = 1", "1=1", $where);
|
| 680 | 680 | $country = get_query_var('gd_country');
|
| 681 | 681 | $region = get_query_var('gd_region');
|
@@ -716,108 +716,108 @@ discard block |
||
| 716 | 716 | * @return string Modified where query string. |
| 717 | 717 | */ |
| 718 | 718 | function searching_filter_where($where) {
|
| 719 | - global $wpdb, $geodir_post_type, $table, $plugin_prefix, $dist, $mylat, $mylon, $s, $snear, $s_A, $s_SA, $search_term, $gd_session; |
|
| 719 | + global $wpdb, $geodir_post_type, $table, $plugin_prefix, $dist, $mylat, $mylon, $s, $snear, $s_A, $s_SA, $search_term, $gd_session; |
|
| 720 | 720 | |
| 721 | - $search_term = 'OR'; |
|
| 722 | - $search_term = 'AND'; |
|
| 723 | - $geodir_custom_search = ''; |
|
| 724 | - $category_search_range = ''; |
|
| 721 | + $search_term = 'OR'; |
|
| 722 | + $search_term = 'AND'; |
|
| 723 | + $geodir_custom_search = ''; |
|
| 724 | + $category_search_range = ''; |
|
| 725 | 725 | |
| 726 | - if (is_single() && get_query_var('post_type')) {
|
|
| 726 | + if (is_single() && get_query_var('post_type')) {
|
|
| 727 | 727 | return $where; |
| 728 | 728 | } |
| 729 | 729 | |
| 730 | - if (is_tax()) {
|
|
| 730 | + if (is_tax()) {
|
|
| 731 | 731 | return $where; |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | $s = trim($s); |
| 735 | - $s = wp_specialchars_decode($s ,ENT_QUOTES); |
|
| 736 | - $s_A = wp_specialchars_decode($s_A ,ENT_QUOTES); |
|
| 737 | - |
|
| 738 | - $where = ''; |
|
| 739 | - $better_search_terms = ''; |
|
| 740 | - if (isset($_REQUEST['stype'])) |
|
| 741 | - $post_types = esc_attr(wp_strip_all_tags($_REQUEST['stype'])); |
|
| 742 | - else |
|
| 743 | - $post_types = 'gd_place'; |
|
| 744 | - |
|
| 745 | - if ($s != '') {
|
|
| 746 | - $keywords = explode(" ", $s);
|
|
| 747 | - if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
|
|
| 748 | - foreach($keywords as $kkey=>$kword){
|
|
| 749 | - if(mb_strlen($kword, 'UTF-8')<=$klimit){
|
|
| 750 | - unset($keywords[$kkey]); |
|
| 751 | - } |
|
| 752 | - } |
|
| 753 | - } |
|
| 735 | + $s = wp_specialchars_decode($s ,ENT_QUOTES); |
|
| 736 | + $s_A = wp_specialchars_decode($s_A ,ENT_QUOTES); |
|
| 754 | 737 | |
| 755 | - if (!empty($keywords)) {
|
|
| 756 | - foreach ($keywords as $keyword) {
|
|
| 757 | - $keyword = trim($keyword); |
|
| 758 | - $keyword = wp_specialchars_decode($keyword ,ENT_QUOTES); |
|
| 759 | - if ($keyword != '') {
|
|
| 760 | - /** |
|
| 761 | - * Filter the search query keywords SQL. |
|
| 762 | - * |
|
| 763 | - * @since 1.5.9 |
|
| 764 | - * @package GeoDirectory |
|
| 765 | - * @param string $better_search_terms The query values, default: `' OR ( ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '" OR ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '%" OR ' . $wpdb->posts . '.post_title LIKE "% ' . $keyword . '%" )'`. |
|
| 766 | - * @param array $keywords The array of keywords for the query. |
|
| 767 | - * @param string $keyword The single keyword being searched. |
|
| 768 | - */ |
|
| 738 | + $where = ''; |
|
| 739 | + $better_search_terms = ''; |
|
| 740 | + if (isset($_REQUEST['stype'])) |
|
| 741 | + $post_types = esc_attr(wp_strip_all_tags($_REQUEST['stype'])); |
|
| 742 | + else |
|
| 743 | + $post_types = 'gd_place'; |
|
| 744 | + |
|
| 745 | + if ($s != '') {
|
|
| 746 | + $keywords = explode(" ", $s);
|
|
| 747 | + if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
|
|
| 748 | + foreach($keywords as $kkey=>$kword){
|
|
| 749 | + if(mb_strlen($kword, 'UTF-8')<=$klimit){
|
|
| 750 | + unset($keywords[$kkey]); |
|
| 751 | + } |
|
| 752 | + } |
|
| 753 | + } |
|
| 754 | + |
|
| 755 | + if (!empty($keywords)) {
|
|
| 756 | + foreach ($keywords as $keyword) {
|
|
| 757 | + $keyword = trim($keyword); |
|
| 758 | + $keyword = wp_specialchars_decode($keyword ,ENT_QUOTES); |
|
| 759 | + if ($keyword != '') {
|
|
| 760 | + /** |
|
| 761 | + * Filter the search query keywords SQL. |
|
| 762 | + * |
|
| 763 | + * @since 1.5.9 |
|
| 764 | + * @package GeoDirectory |
|
| 765 | + * @param string $better_search_terms The query values, default: `' OR ( ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '" OR ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '%" OR ' . $wpdb->posts . '.post_title LIKE "% ' . $keyword . '%" )'`. |
|
| 766 | + * @param array $keywords The array of keywords for the query. |
|
| 767 | + * @param string $keyword The single keyword being searched. |
|
| 768 | + */ |
|
| 769 | 769 | $better_search_terms .= apply_filters("geodir_search_better_search_terms",' OR ( ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '" OR ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '%" OR ' . $wpdb->posts . '.post_title LIKE "% ' . $keyword . '%" )',$keywords,$keyword);
|
| 770 | - } |
|
| 771 | - } |
|
| 772 | - } |
|
| 773 | - } |
|
| 770 | + } |
|
| 771 | + } |
|
| 772 | + } |
|
| 773 | + } |
|
| 774 | 774 | |
| 775 | - /* get taxonomy */ |
|
| 776 | - $taxonomies = geodir_get_taxonomies($post_types, true); |
|
| 777 | - if($taxonomies) {
|
|
| 778 | - $taxonomies = implode("','", $taxonomies);
|
|
| 779 | - $taxonomies = "'" . $taxonomies . "'"; |
|
| 780 | - }else{$taxonomies='';}
|
|
| 775 | + /* get taxonomy */ |
|
| 776 | + $taxonomies = geodir_get_taxonomies($post_types, true); |
|
| 777 | + if($taxonomies) {
|
|
| 778 | + $taxonomies = implode("','", $taxonomies);
|
|
| 779 | + $taxonomies = "'" . $taxonomies . "'"; |
|
| 780 | + }else{$taxonomies='';}
|
|
| 781 | 781 | |
| 782 | - $content_where = $terms_where = ''; |
|
| 782 | + $content_where = $terms_where = ''; |
|
| 783 | 783 | if ($s != '') {
|
| 784 | - /** |
|
| 785 | - * Filter the search query content where values. |
|
| 786 | - * |
|
| 787 | - * @since 1.5.0 |
|
| 788 | - * @package GeoDirectory |
|
| 789 | - * @param string $content_where The query values, default: `" OR ($wpdb->posts.post_content LIKE \"$s\" OR $wpdb->posts.post_content LIKE \"$s%\" OR $wpdb->posts.post_content LIKE \"% $s%\" OR $wpdb->posts.post_content LIKE \"%>$s%\" OR $wpdb->posts.post_content LIKE \"%\n$s%\") ") "`. |
|
| 790 | - */ |
|
| 784 | + /** |
|
| 785 | + * Filter the search query content where values. |
|
| 786 | + * |
|
| 787 | + * @since 1.5.0 |
|
| 788 | + * @package GeoDirectory |
|
| 789 | + * @param string $content_where The query values, default: `" OR ($wpdb->posts.post_content LIKE \"$s\" OR $wpdb->posts.post_content LIKE \"$s%\" OR $wpdb->posts.post_content LIKE \"% $s%\" OR $wpdb->posts.post_content LIKE \"%>$s%\" OR $wpdb->posts.post_content LIKE \"%\n$s%\") ") "`. |
|
| 790 | + */ |
|
| 791 | 791 | $content_where = apply_filters("geodir_search_content_where"," OR ($wpdb->posts.post_content LIKE \"$s\" OR $wpdb->posts.post_content LIKE \"$s%\" OR $wpdb->posts.post_content LIKE \"% $s%\" OR $wpdb->posts.post_content LIKE \"%>$s%\" OR $wpdb->posts.post_content LIKE \"%\n$s%\") ");
|
| 792 | - /** |
|
| 793 | - * Filter the search query term values. |
|
| 794 | - * |
|
| 795 | - * @since 1.5.0 |
|
| 796 | - * @package GeoDirectory |
|
| 797 | - * @param string $terms_where The separator, default: `" AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) "`. |
|
| 798 | - */ |
|
| 799 | - $terms_where = apply_filters("geodir_search_terms_where"," AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) ");
|
|
| 792 | + /** |
|
| 793 | + * Filter the search query term values. |
|
| 794 | + * |
|
| 795 | + * @since 1.5.0 |
|
| 796 | + * @package GeoDirectory |
|
| 797 | + * @param string $terms_where The separator, default: `" AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) "`. |
|
| 798 | + */ |
|
| 799 | + $terms_where = apply_filters("geodir_search_terms_where"," AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) ");
|
|
| 800 | 800 | } |
| 801 | 801 | |
| 802 | - if ($snear != '') {
|
|
| 802 | + if ($snear != '') {
|
|
| 803 | 803 | |
| 804 | 804 | |
| 805 | - if (is_numeric($gd_session->get('near_me_range')) && !isset($_REQUEST['sdist'])) {
|
|
| 806 | - $dist = $gd_session->get('near_me_range');
|
|
| 807 | - } |
|
| 808 | - $lon1 = $mylon - $dist / abs(cos(deg2rad($mylat)) * 69); |
|
| 809 | - $lon2 = $mylon + $dist / abs(cos(deg2rad($mylat)) * 69); |
|
| 810 | - $lat1 = $mylat - ($dist / 69); |
|
| 811 | - $lat2 = $mylat + ($dist / 69); |
|
| 805 | + if (is_numeric($gd_session->get('near_me_range')) && !isset($_REQUEST['sdist'])) {
|
|
| 806 | + $dist = $gd_session->get('near_me_range');
|
|
| 807 | + } |
|
| 808 | + $lon1 = $mylon - $dist / abs(cos(deg2rad($mylat)) * 69); |
|
| 809 | + $lon2 = $mylon + $dist / abs(cos(deg2rad($mylat)) * 69); |
|
| 810 | + $lat1 = $mylat - ($dist / 69); |
|
| 811 | + $lat2 = $mylat + ($dist / 69); |
|
| 812 | 812 | |
| 813 | - $rlon1 = is_numeric(min($lon1, $lon2)) ? min($lon1, $lon2) : ''; |
|
| 814 | - $rlon2 = is_numeric(max($lon1, $lon2)) ? max($lon1, $lon2) : ''; |
|
| 815 | - $rlat1 = is_numeric(min($lat1, $lat2)) ? min($lat1, $lat2) : ''; |
|
| 816 | - $rlat2 = is_numeric(max($lat1, $lat2)) ? max($lat1, $lat2) : ''; |
|
| 813 | + $rlon1 = is_numeric(min($lon1, $lon2)) ? min($lon1, $lon2) : ''; |
|
| 814 | + $rlon2 = is_numeric(max($lon1, $lon2)) ? max($lon1, $lon2) : ''; |
|
| 815 | + $rlat1 = is_numeric(min($lat1, $lat2)) ? min($lat1, $lat2) : ''; |
|
| 816 | + $rlat2 = is_numeric(max($lat1, $lat2)) ? max($lat1, $lat2) : ''; |
|
| 817 | 817 | |
| 818 | 818 | |
| 819 | 819 | |
| 820 | - $where .= " AND ( ( $wpdb->posts.post_title LIKE \"$s\" $better_search_terms) |
|
| 820 | + $where .= " AND ( ( $wpdb->posts.post_title LIKE \"$s\" $better_search_terms) |
|
| 821 | 821 | $content_where |
| 822 | 822 | OR ($wpdb->posts.ID IN( |
| 823 | 823 | SELECT $wpdb->term_relationships.object_id as post_id |
@@ -834,13 +834,13 @@ discard block |
||
| 834 | 834 | AND ( " . $table . ".post_latitude between $rlat1 and $rlat2 ) |
| 835 | 835 | AND ( " . $table . ".post_longitude between $rlon1 and $rlon2 ) "; |
| 836 | 836 | |
| 837 | - if (isset($_REQUEST['sdist']) && $_REQUEST['sdist'] != 'all') {
|
|
| 838 | - $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
|
|
| 839 | - $where .= " AND CONVERT((" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) ))),DECIMAL(64,4)) <= " . $dist;
|
|
| 840 | - } |
|
| 837 | + if (isset($_REQUEST['sdist']) && $_REQUEST['sdist'] != 'all') {
|
|
| 838 | + $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
|
|
| 839 | + $where .= " AND CONVERT((" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) ))),DECIMAL(64,4)) <= " . $dist;
|
|
| 840 | + } |
|
| 841 | 841 | |
| 842 | - } else {
|
|
| 843 | - $where .= " AND ( ( $wpdb->posts.post_title LIKE \"$s\" $better_search_terms) |
|
| 842 | + } else {
|
|
| 843 | + $where .= " AND ( ( $wpdb->posts.post_title LIKE \"$s\" $better_search_terms) |
|
| 844 | 844 | $content_where |
| 845 | 845 | OR ( $wpdb->posts.ID IN( |
| 846 | 846 | SELECT $wpdb->term_relationships.object_id as post_id |
@@ -854,19 +854,19 @@ discard block |
||
| 854 | 854 | ) |
| 855 | 855 | AND $wpdb->posts.post_type in ('$post_types')
|
| 856 | 856 | AND ($wpdb->posts.post_status = 'publish') "; |
| 857 | - } |
|
| 857 | + } |
|
| 858 | 858 | |
| 859 | 859 | ########### WPML ########### |
| 860 | - if ( function_exists( 'icl_object_id' ) ) {
|
|
| 860 | + if ( function_exists( 'icl_object_id' ) ) {
|
|
| 861 | 861 | $lang_code = ICL_LANGUAGE_CODE; |
| 862 | 862 | |
| 863 | 863 | if ($lang_code && $post_types) {
|
| 864 | - $where .= " AND icl_t.language_code = '".$lang_code."' AND icl_t.element_type IN('post_" . $post_types . "') ";
|
|
| 865 | - } |
|
| 866 | - } |
|
| 867 | - ########### WPML ########### |
|
| 864 | + $where .= " AND icl_t.language_code = '".$lang_code."' AND icl_t.element_type IN('post_" . $post_types . "') ";
|
|
| 865 | + } |
|
| 866 | + } |
|
| 867 | + ########### WPML ########### |
|
| 868 | 868 | |
| 869 | - return $where; |
|
| 869 | + return $where; |
|
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | |
@@ -881,45 +881,45 @@ discard block |
||
| 881 | 881 | * @return string Modified where query string. |
| 882 | 882 | */ |
| 883 | 883 | function author_filter_where($where) {
|
| 884 | - global $wpdb, $geodir_post_type, $table, $curr; |
|
| 884 | + global $wpdb, $geodir_post_type, $table, $curr; |
|
| 885 | 885 | |
| 886 | - $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
|
|
| 887 | - $user_id = !empty($curauth->ID) ? (int)$curauth->ID : 0; |
|
| 886 | + $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
|
|
| 887 | + $user_id = !empty($curauth->ID) ? (int)$curauth->ID : 0; |
|
| 888 | 888 | |
| 889 | - if (isset($_REQUEST['stype'])) {
|
|
| 890 | - $where = $wpdb->prepare(" AND $wpdb->posts.post_type IN (%s) ",$_REQUEST['stype']);
|
|
| 891 | - } else {
|
|
| 892 | - $where = " AND $wpdb->posts.post_type IN ('gd_place') ";
|
|
| 893 | - } |
|
| 889 | + if (isset($_REQUEST['stype'])) {
|
|
| 890 | + $where = $wpdb->prepare(" AND $wpdb->posts.post_type IN (%s) ",$_REQUEST['stype']);
|
|
| 891 | + } else {
|
|
| 892 | + $where = " AND $wpdb->posts.post_type IN ('gd_place') ";
|
|
| 893 | + } |
|
| 894 | 894 | |
| 895 | - if ($user_id > 0) {
|
|
| 896 | - if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
|
|
| 897 | - $user_fav_posts = get_user_meta($user_id, 'gd_user_favourite_post', true); |
|
| 898 | - $user_fav_posts = !empty($user_fav_posts) && is_array($user_fav_posts) ? implode("','", $user_fav_posts) : '-1';
|
|
| 899 | - $where .= " AND $wpdb->posts.ID IN ('$user_fav_posts')";
|
|
| 900 | - } else |
|
| 901 | - $where .= " AND $wpdb->posts.post_author = $user_id"; |
|
| 902 | - |
|
| 903 | - if ($user_id == (int)get_current_user_id()) {
|
|
| 904 | - $where .= " AND $wpdb->posts.post_status IN ('publish','draft','pending') ";
|
|
| 905 | - } else {
|
|
| 906 | - $where .= " AND $wpdb->posts.post_status = 'publish' "; |
|
| 907 | - } |
|
| 908 | - } else {
|
|
| 909 | - $where .= " AND $wpdb->posts.post_author = '-1' AND $wpdb->posts.post_status = 'publish' "; |
|
| 910 | - } |
|
| 895 | + if ($user_id > 0) {
|
|
| 896 | + if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
|
|
| 897 | + $user_fav_posts = get_user_meta($user_id, 'gd_user_favourite_post', true); |
|
| 898 | + $user_fav_posts = !empty($user_fav_posts) && is_array($user_fav_posts) ? implode("','", $user_fav_posts) : '-1';
|
|
| 899 | + $where .= " AND $wpdb->posts.ID IN ('$user_fav_posts')";
|
|
| 900 | + } else |
|
| 901 | + $where .= " AND $wpdb->posts.post_author = $user_id"; |
|
| 902 | + |
|
| 903 | + if ($user_id == (int)get_current_user_id()) {
|
|
| 904 | + $where .= " AND $wpdb->posts.post_status IN ('publish','draft','pending') ";
|
|
| 905 | + } else {
|
|
| 906 | + $where .= " AND $wpdb->posts.post_status = 'publish' "; |
|
| 907 | + } |
|
| 908 | + } else {
|
|
| 909 | + $where .= " AND $wpdb->posts.post_author = '-1' AND $wpdb->posts.post_status = 'publish' "; |
|
| 910 | + } |
|
| 911 | 911 | |
| 912 | - ########### WPML ########### |
|
| 913 | - if (function_exists('icl_object_id')) {
|
|
| 914 | - $lang_code = ICL_LANGUAGE_CODE; |
|
| 915 | - if ($lang_code) {
|
|
| 916 | - $where .= " AND icl_t.language_code='" . $lang_code . "' "; |
|
| 917 | - } |
|
| 912 | + ########### WPML ########### |
|
| 913 | + if (function_exists('icl_object_id')) {
|
|
| 914 | + $lang_code = ICL_LANGUAGE_CODE; |
|
| 915 | + if ($lang_code) {
|
|
| 916 | + $where .= " AND icl_t.language_code='" . $lang_code . "' "; |
|
| 917 | + } |
|
| 918 | 918 | |
| 919 | - } |
|
| 920 | - ########### WPML ########### |
|
| 919 | + } |
|
| 920 | + ########### WPML ########### |
|
| 921 | 921 | |
| 922 | - return $where; |
|
| 922 | + return $where; |
|
| 923 | 923 | } |
| 924 | 924 | |
| 925 | 925 | /** |
@@ -934,11 +934,11 @@ discard block |
||
| 934 | 934 | */ |
| 935 | 935 | function geodir_filter_widget_join($join) |
| 936 | 936 | {
|
| 937 | - global $wp_query, $table; |
|
| 938 | - if (!empty($wp_query->query['with_pics_only'])) {
|
|
| 939 | - $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )"; |
|
| 940 | - } |
|
| 941 | - return $join; |
|
| 937 | + global $wp_query, $table; |
|
| 938 | + if (!empty($wp_query->query['with_pics_only'])) {
|
|
| 939 | + $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )"; |
|
| 940 | + } |
|
| 941 | + return $join; |
|
| 942 | 942 | } |
| 943 | 943 | |
| 944 | 944 | /** |
@@ -953,42 +953,42 @@ discard block |
||
| 953 | 953 | */ |
| 954 | 954 | function geodir_filter_widget_where($where) |
| 955 | 955 | {
|
| 956 | - global $wp_query, $table; |
|
| 957 | - if (!empty($wp_query->query['show_featured_only'])) {
|
|
| 958 | - $where .= " AND " . $table . ".is_featured = '1'"; |
|
| 959 | - } |
|
| 960 | - if (!empty($wp_query->query['show_special_only'])) {
|
|
| 961 | - $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )"; |
|
| 962 | - } |
|
| 963 | - if (!empty($wp_query->query['with_pics_only'])) {
|
|
| 964 | - $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL GROUP BY " . $table . ".post_id"; |
|
| 965 | - } |
|
| 966 | - if (!empty($wp_query->query['with_videos_only'])) {
|
|
| 967 | - $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )"; |
|
| 968 | - } |
|
| 969 | - return $where; |
|
| 956 | + global $wp_query, $table; |
|
| 957 | + if (!empty($wp_query->query['show_featured_only'])) {
|
|
| 958 | + $where .= " AND " . $table . ".is_featured = '1'"; |
|
| 959 | + } |
|
| 960 | + if (!empty($wp_query->query['show_special_only'])) {
|
|
| 961 | + $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )"; |
|
| 962 | + } |
|
| 963 | + if (!empty($wp_query->query['with_pics_only'])) {
|
|
| 964 | + $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL GROUP BY " . $table . ".post_id"; |
|
| 965 | + } |
|
| 966 | + if (!empty($wp_query->query['with_videos_only'])) {
|
|
| 967 | + $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )"; |
|
| 968 | + } |
|
| 969 | + return $where; |
|
| 970 | 970 | } |
| 971 | 971 | |
| 972 | 972 | |
| 973 | 973 | function geodir_related_posts_fields($fields) {
|
| 974 | - global $wp_query, $wpdb, $table, $post; |
|
| 974 | + global $wp_query, $wpdb, $table, $post; |
|
| 975 | 975 | |
| 976 | - $fields .= ", " . $table . ".* "; |
|
| 976 | + $fields .= ", " . $table . ".* "; |
|
| 977 | 977 | |
| 978 | - $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
|
|
| 978 | + $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
|
|
| 979 | 979 | |
| 980 | - $mylat = $post->post_latitude; |
|
| 981 | - $mylon = $post->post_longitude; |
|
| 980 | + $mylat = $post->post_latitude; |
|
| 981 | + $mylon = $post->post_longitude; |
|
| 982 | 982 | |
| 983 | - $fields .= " , (" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) )))as distance ";
|
|
| 984 | - return $fields; |
|
| 983 | + $fields .= " , (" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) )))as distance ";
|
|
| 984 | + return $fields; |
|
| 985 | 985 | } |
| 986 | 986 | function geodir_related_posts_fields_filter($query) {
|
| 987 | - if ( isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop'] |
|
| 988 | - && isset($query->query_vars['order_by']) && $query->query_vars['order_by'] == 'nearest' |
|
| 989 | - && isset($query->query_vars['related_listings']) && $query->query_vars['related_listings'] |
|
| 990 | - ) {
|
|
| 991 | - add_filter('posts_fields', 'geodir_related_posts_fields', 1);
|
|
| 992 | - } |
|
| 987 | + if ( isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop'] |
|
| 988 | + && isset($query->query_vars['order_by']) && $query->query_vars['order_by'] == 'nearest' |
|
| 989 | + && isset($query->query_vars['related_listings']) && $query->query_vars['related_listings'] |
|
| 990 | + ) {
|
|
| 991 | + add_filter('posts_fields', 'geodir_related_posts_fields', 1);
|
|
| 992 | + } |
|
| 993 | 993 | } |
| 994 | 994 | add_action('pre_get_posts', 'geodir_related_posts_fields_filter', 1); |
| 995 | 995 | \ No newline at end of file |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @global string $s_A Extra parameters. |
| 66 | 66 | * @global string $s_SA Extra parameters. |
| 67 | 67 | */ |
| 68 | -function set_listing_request($query ) |
|
| 68 | +function set_listing_request($query) |
|
| 69 | 69 | {
|
| 70 | 70 | global $wp_query, $wpdb, $geodir_post_type, $table, $dist, $mylat, $mylon, $s, $snear, $s, $s_A, $s_SA; |
| 71 | 71 | |
@@ -99,15 +99,15 @@ discard block |
||
| 99 | 99 | } // Distance |
| 100 | 100 | |
| 101 | 101 | if (isset($_REQUEST['sgeo_lat'])) {
|
| 102 | - $mylat = (float)esc_attr($_REQUEST['sgeo_lat']); |
|
| 102 | + $mylat = (float) esc_attr($_REQUEST['sgeo_lat']); |
|
| 103 | 103 | } else {
|
| 104 | - $mylat = (float)geodir_get_current_city_lat(); |
|
| 104 | + $mylat = (float) geodir_get_current_city_lat(); |
|
| 105 | 105 | } // Latatude |
| 106 | 106 | |
| 107 | 107 | if (isset($_REQUEST['sgeo_lon'])) {
|
| 108 | - $mylon = (float)esc_attr($_REQUEST['sgeo_lon']); |
|
| 108 | + $mylon = (float) esc_attr($_REQUEST['sgeo_lon']); |
|
| 109 | 109 | } else {
|
| 110 | - $mylon = (float)geodir_get_current_city_lng(); |
|
| 110 | + $mylon = (float) geodir_get_current_city_lng(); |
|
| 111 | 111 | } // Distance |
| 112 | 112 | |
| 113 | 113 | if (isset($_REQUEST['snear'])) {
|
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | if ($snear == 'NEAR ME') {
|
| 122 | 122 | $ip = $_SERVER['REMOTE_ADDR']; |
| 123 | - $addr_details = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $ip));
|
|
| 123 | + $addr_details = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$ip));
|
|
| 124 | 124 | $mylat = stripslashes(ucfirst($addr_details[geoplugin_latitude])); |
| 125 | 125 | $mylon = stripslashes(ucfirst($addr_details[geoplugin_longitude])); |
| 126 | 126 | } |
@@ -130,9 +130,9 @@ discard block |
||
| 130 | 130 | $s_AA = str_replace(" ", "", $s);
|
| 131 | 131 | $s_A = explode(",", $s_AA);
|
| 132 | 132 | $s_A = implode('","', $s_A);
|
| 133 | - $s_A = '"' . $s_A . '"'; |
|
| 133 | + $s_A = '"'.$s_A.'"'; |
|
| 134 | 134 | } else {
|
| 135 | - $s_A = '"' . $s . '"'; |
|
| 135 | + $s_A = '"'.$s.'"'; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | if (strstr($s, ' ')) {
|
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | } |
| 194 | 194 | if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']) {
|
| 195 | 195 | |
| 196 | - $table = $plugin_prefix . $geodir_post_type . '_detail'; |
|
| 196 | + $table = $plugin_prefix.$geodir_post_type.'_detail'; |
|
| 197 | 197 | |
| 198 | 198 | add_filter('posts_fields', 'geodir_posts_fields', 1);
|
| 199 | 199 | add_filter('posts_join', 'geodir_posts_join', 1);
|
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | global $wp_query, $wpdb, $geodir_post_type, $table, $plugin_prefix, $dist, $mylat, $mylon, $snear, $gd_session; |
| 234 | 234 | |
| 235 | 235 | // Filter-Location-Manager to add location table. |
| 236 | - $fields .= ", " . $table . ".* "; |
|
| 236 | + $fields .= ", ".$table.".* "; |
|
| 237 | 237 | |
| 238 | 238 | if ($snear != '' || $gd_session->get('all_near_me')) {
|
| 239 | 239 | $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
|
@@ -243,16 +243,16 @@ discard block |
||
| 243 | 243 | $mylon = $gd_session->get('user_lon');
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - $fields .= " , (" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) )))as distance ";
|
|
| 246 | + $fields .= " , (".$DistanceRadius." * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(".$table.".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(".$table.".post_latitude) * pi()/180) *POWER(SIN(($mylon - ".$table.".post_longitude) * pi()/180 / 2), 2) )))as distance ";
|
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | global $s; |
| 250 | 250 | if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
|
| 251 | 251 | $keywords = explode(" ", $s);
|
| 252 | 252 | |
| 253 | - if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
|
|
| 254 | - foreach($keywords as $kkey=>$kword){
|
|
| 255 | - if(mb_strlen($kword, 'UTF-8')<=$klimit){
|
|
| 253 | + if (is_array($keywords) && $klimit = get_option('geodir_search_word_limit')) {
|
|
| 254 | + foreach ($keywords as $kkey=>$kword) {
|
|
| 255 | + if (mb_strlen($kword, 'UTF-8') <= $klimit) {
|
|
| 256 | 256 | unset($keywords[$kkey]); |
| 257 | 257 | } |
| 258 | 258 | } |
@@ -270,24 +270,24 @@ discard block |
||
| 270 | 270 | $count = 0; |
| 271 | 271 | foreach ($keywords as $keyword) {
|
| 272 | 272 | $keyword = trim($keyword); |
| 273 | - $keyword = wp_specialchars_decode($keyword ,ENT_QUOTES); |
|
| 273 | + $keyword = wp_specialchars_decode($keyword, ENT_QUOTES); |
|
| 274 | 274 | $count++; |
| 275 | 275 | if ($count < count($keywords)) {
|
| 276 | 276 | // $gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' " . $key . " "; |
| 277 | - $gd_titlematch_part .= "( " . $wpdb->posts . ".post_title LIKE '" . $keyword . "' OR " . $wpdb->posts . ".post_title LIKE '" . $keyword . "%%' OR " . $wpdb->posts . ".post_title LIKE '%% " . $keyword . "%%' ) " . $key . " "; |
|
| 277 | + $gd_titlematch_part .= "( ".$wpdb->posts.".post_title LIKE '".$keyword."' OR ".$wpdb->posts.".post_title LIKE '".$keyword."%%' OR ".$wpdb->posts.".post_title LIKE '%% ".$keyword."%%' ) ".$key." "; |
|
| 278 | 278 | } else {
|
| 279 | 279 | //$gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' "; |
| 280 | - $gd_titlematch_part .= "( " . $wpdb->posts . ".post_title LIKE '" . $keyword . "' OR " . $wpdb->posts . ".post_title LIKE '" . $keyword . "%%' OR " . $wpdb->posts . ".post_title LIKE '%% " . $keyword . "%%' ) "; |
|
| 280 | + $gd_titlematch_part .= "( ".$wpdb->posts.".post_title LIKE '".$keyword."' OR ".$wpdb->posts.".post_title LIKE '".$keyword."%%' OR ".$wpdb->posts.".post_title LIKE '%% ".$keyword."%%' ) "; |
|
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | - $gd_titlematch_part .= "THEN 1 ELSE 0 END AS " . $part . ","; |
|
| 283 | + $gd_titlematch_part .= "THEN 1 ELSE 0 END AS ".$part.","; |
|
| 284 | 284 | } |
| 285 | 285 | } else {
|
| 286 | 286 | $gd_titlematch_part = ""; |
| 287 | 287 | } |
| 288 | - $s = stripslashes_deep( $s ); |
|
| 289 | - $s = wp_specialchars_decode($s,ENT_QUOTES); |
|
| 290 | - $fields .= $wpdb->prepare(", CASE WHEN " . $table . ".is_featured='1' THEN 1 ELSE 0 END AS gd_featured, CASE WHEN " . $wpdb->posts . ".post_title LIKE %s THEN 1 ELSE 0 END AS gd_exacttitle," . $gd_titlematch_part . " CASE WHEN ( " . $wpdb->posts . ".post_title LIKE %s OR " . $wpdb->posts . ".post_title LIKE %s OR " . $wpdb->posts . ".post_title LIKE %s ) THEN 1 ELSE 0 END AS gd_titlematch, CASE WHEN ( " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s ) THEN 1 ELSE 0 END AS gd_content", array($s, $s, $s . '%', '% ' . $s . '%', $s, $s . ' %', '% ' . $s . ' %', '% ' . $s));
|
|
| 288 | + $s = stripslashes_deep($s); |
|
| 289 | + $s = wp_specialchars_decode($s, ENT_QUOTES); |
|
| 290 | + $fields .= $wpdb->prepare(", CASE WHEN ".$table.".is_featured='1' THEN 1 ELSE 0 END AS gd_featured, CASE WHEN ".$wpdb->posts.".post_title LIKE %s THEN 1 ELSE 0 END AS gd_exacttitle,".$gd_titlematch_part." CASE WHEN ( ".$wpdb->posts.".post_title LIKE %s OR ".$wpdb->posts.".post_title LIKE %s OR ".$wpdb->posts.".post_title LIKE %s ) THEN 1 ELSE 0 END AS gd_titlematch, CASE WHEN ( ".$wpdb->posts.".post_content LIKE %s OR ".$wpdb->posts.".post_content LIKE %s OR ".$wpdb->posts.".post_content LIKE %s OR ".$wpdb->posts.".post_content LIKE %s ) THEN 1 ELSE 0 END AS gd_content", array($s, $s, $s.'%', '% '.$s.'%', $s, $s.' %', '% '.$s.' %', '% '.$s));
|
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | return $fields; |
@@ -316,13 +316,13 @@ discard block |
||
| 316 | 316 | $lang_code = ICL_LANGUAGE_CODE; |
| 317 | 317 | $default_lang_code = $sitepress->get_default_language(); |
| 318 | 318 | if ($lang_code) {
|
| 319 | - $join .= "JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID"; |
|
| 319 | + $join .= "JOIN ".$table_prefix."icl_translations icl_t ON icl_t.element_id = ".$table_prefix."posts.ID"; |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | } |
| 323 | 323 | ########### WPML ########### |
| 324 | 324 | |
| 325 | - $join .= " INNER JOIN " . $table . " ON (" . $table . ".post_id = $wpdb->posts.ID) ";
|
|
| 325 | + $join .= " INNER JOIN ".$table." ON (".$table.".post_id = $wpdb->posts.ID) ";
|
|
| 326 | 326 | //===old code start |
| 327 | 327 | //$join .= " INNER JOIN ".POST_LOCATION_TABLE." ON (".$table.".post_location_id = ".POST_LOCATION_TABLE.".location_id) " ;//===old code end
|
| 328 | 328 | |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | $sort_by = 'az'; |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | - if ($snear != '' && $sort_by!='farthest') {
|
|
| 394 | + if ($snear != '' && $sort_by != 'farthest') {
|
|
| 395 | 395 | $sort_by = 'nearest'; |
| 396 | 396 | } |
| 397 | 397 | } |
@@ -405,20 +405,20 @@ discard block |
||
| 405 | 405 | break; |
| 406 | 406 | case 'low_review': |
| 407 | 407 | case 'rating_count_asc': |
| 408 | - $orderby = $table . ".rating_count ASC, " . $table . ".overall_rating ASC, "; |
|
| 408 | + $orderby = $table.".rating_count ASC, ".$table.".overall_rating ASC, "; |
|
| 409 | 409 | break; |
| 410 | 410 | case 'high_review': |
| 411 | 411 | case 'rating_count_desc': |
| 412 | - $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, "; |
|
| 412 | + $orderby = $table.".rating_count DESC, ".$table.".overall_rating DESC, "; |
|
| 413 | 413 | break; |
| 414 | 414 | case 'low_rating': |
| 415 | - $orderby = "( " . $table . ".overall_rating ) ASC, " . $table . ".rating_count ASC, "; |
|
| 415 | + $orderby = "( ".$table.".overall_rating ) ASC, ".$table.".rating_count ASC, "; |
|
| 416 | 416 | break; |
| 417 | 417 | case 'high_rating': |
| 418 | - $orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, "; |
|
| 418 | + $orderby = " ".$table.".overall_rating DESC, ".$table.".rating_count DESC, "; |
|
| 419 | 419 | break; |
| 420 | 420 | case 'featured': |
| 421 | - $orderby = $table . ".is_featured asc, "; |
|
| 421 | + $orderby = $table.".is_featured asc, "; |
|
| 422 | 422 | break; |
| 423 | 423 | case 'nearest': |
| 424 | 424 | $orderby = " distance asc, "; |
@@ -434,10 +434,10 @@ discard block |
||
| 434 | 434 | break; |
| 435 | 435 | // sort by rating |
| 436 | 436 | case 'overall_rating_desc': |
| 437 | - $orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, "; |
|
| 437 | + $orderby = " ".$table.".overall_rating DESC, ".$table.".rating_count DESC, "; |
|
| 438 | 438 | break; |
| 439 | 439 | case 'overall_rating_asc': |
| 440 | - $orderby = " " . $table . ".overall_rating ASC, " . $table . ".rating_count ASC, "; |
|
| 440 | + $orderby = " ".$table.".overall_rating ASC, ".$table.".rating_count ASC, "; |
|
| 441 | 441 | break; |
| 442 | 442 | default: |
| 443 | 443 | |
@@ -458,24 +458,24 @@ discard block |
||
| 458 | 458 | |
| 459 | 459 | if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
|
| 460 | 460 | $keywords = explode(" ", $s);
|
| 461 | - if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
|
|
| 462 | - foreach($keywords as $kkey=>$kword){
|
|
| 463 | - if(mb_strlen($kword, 'UTF-8')<=$klimit){
|
|
| 461 | + if (is_array($keywords) && $klimit = get_option('geodir_search_word_limit')) {
|
|
| 462 | + foreach ($keywords as $kkey=>$kword) {
|
|
| 463 | + if (mb_strlen($kword, 'UTF-8') <= $klimit) {
|
|
| 464 | 464 | unset($keywords[$kkey]); |
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | } |
| 468 | 468 | if ($sort_by == 'nearest' || $sort_by == 'farthest') {
|
| 469 | 469 | if (count($keywords) > 1) {
|
| 470 | - $orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, "; |
|
| 470 | + $orderby = $orderby." ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, "; |
|
| 471 | 471 | } else {
|
| 472 | - $orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, "; |
|
| 472 | + $orderby = $orderby." ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, "; |
|
| 473 | 473 | } |
| 474 | 474 | } else {
|
| 475 | 475 | if (count($keywords) > 1) {
|
| 476 | - $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, " . $orderby; |
|
| 476 | + $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, ".$orderby; |
|
| 477 | 477 | } else {
|
| 478 | - $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, " . $orderby; |
|
| 478 | + $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, ".$orderby; |
|
| 479 | 479 | } |
| 480 | 480 | } |
| 481 | 481 | } |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | */ |
| 491 | 491 | $orderby = apply_filters('geodir_posts_order_by_sort', $orderby, $sort_by, $table);
|
| 492 | 492 | |
| 493 | - $orderby .= $table . ".is_featured asc, $wpdb->posts.post_date desc, $wpdb->posts.post_title "; |
|
| 493 | + $orderby .= $table.".is_featured asc, $wpdb->posts.post_date desc, $wpdb->posts.post_title "; |
|
| 494 | 494 | |
| 495 | 495 | return $orderby; |
| 496 | 496 | } |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | |
| 513 | 513 | global $wpdb; |
| 514 | 514 | |
| 515 | - if ($sort_by != '' && (!is_search() || ( isset($_REQUEST['s']) && isset($_REQUEST['snear']) && $_REQUEST['snear']=='' && ( $_REQUEST['s']=='' || $_REQUEST['s']==' ') ) )) {
|
|
| 515 | + if ($sort_by != '' && (!is_search() || (isset($_REQUEST['s']) && isset($_REQUEST['snear']) && $_REQUEST['snear'] == '' && ($_REQUEST['s'] == '' || $_REQUEST['s'] == ' ')))) {
|
|
| 516 | 516 | |
| 517 | 517 | $sort_array = explode('_', $sort_by);
|
| 518 | 518 | |
@@ -522,31 +522,31 @@ discard block |
||
| 522 | 522 | |
| 523 | 523 | if ($sort_by_count > 1 && ($order == 'asc' || $order == 'desc')) {
|
| 524 | 524 | |
| 525 | - $sort_by = str_replace('_' . $order, '', $sort_by);
|
|
| 525 | + $sort_by = str_replace('_'.$order, '', $sort_by);
|
|
| 526 | 526 | |
| 527 | 527 | switch ($sort_by): |
| 528 | 528 | |
| 529 | 529 | case 'post_date': |
| 530 | 530 | case 'comment_count': |
| 531 | 531 | |
| 532 | - $orderby = "$wpdb->posts." . $sort_by . " " . $order . ", ".$table . ".overall_rating " . $order . ", "; |
|
| 532 | + $orderby = "$wpdb->posts.".$sort_by." ".$order.", ".$table.".overall_rating ".$order.", "; |
|
| 533 | 533 | break; |
| 534 | 534 | |
| 535 | 535 | case 'distance': |
| 536 | - $orderby = $sort_by . " " . $order . ", "; |
|
| 536 | + $orderby = $sort_by." ".$order.", "; |
|
| 537 | 537 | break; |
| 538 | 538 | |
| 539 | 539 | |
| 540 | 540 | // sort by rating |
| 541 | 541 | case 'overall_rating': |
| 542 | - $orderby = " " . $table . "." . $sort_by . " " . $order . ", " . $table . ".rating_count " . $order . ", "; |
|
| 542 | + $orderby = " ".$table.".".$sort_by." ".$order.", ".$table.".rating_count ".$order.", "; |
|
| 543 | 543 | |
| 544 | 544 | break; |
| 545 | 545 | |
| 546 | 546 | |
| 547 | 547 | default: |
| 548 | 548 | if (geodir_column_exist($table, $sort_by)) {
|
| 549 | - $orderby = $table . "." . $sort_by . " " . $order . ", "; |
|
| 549 | + $orderby = $table.".".$sort_by." ".$order.", "; |
|
| 550 | 550 | } |
| 551 | 551 | break; |
| 552 | 552 | |
@@ -594,7 +594,7 @@ discard block |
||
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | //if (!geodir_is_page('detail'))
|
| 597 | - add_filter('posts_where', 'geodir_default_where', 1);/**/
|
|
| 597 | + add_filter('posts_where', 'geodir_default_where', 1); /**/
|
|
| 598 | 598 | |
| 599 | 599 | //add_filter( 'user_has_cap', 'geodir_preview_post_cap', 10, 3 );// let subscribers edit their own posts |
| 600 | 600 | |
@@ -665,7 +665,7 @@ discard block |
||
| 665 | 665 | $q_post_type = isset($wp_query->query['post_type']) ? $wp_query->query['post_type'] : ''; |
| 666 | 666 | //echo '##########'.$q_post_type; |
| 667 | 667 | if ($lang_code && $q_post_type) {
|
| 668 | - $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type IN('post_" . $q_post_type . "') ";
|
|
| 668 | + $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type IN('post_".$q_post_type."') ";
|
|
| 669 | 669 | //$where .= " AND icl_t.language_code = '$lang_code' "; |
| 670 | 670 | } |
| 671 | 671 | |
@@ -732,8 +732,8 @@ discard block |
||
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | $s = trim($s); |
| 735 | - $s = wp_specialchars_decode($s ,ENT_QUOTES); |
|
| 736 | - $s_A = wp_specialchars_decode($s_A ,ENT_QUOTES); |
|
| 735 | + $s = wp_specialchars_decode($s, ENT_QUOTES); |
|
| 736 | + $s_A = wp_specialchars_decode($s_A, ENT_QUOTES); |
|
| 737 | 737 | |
| 738 | 738 | $where = ''; |
| 739 | 739 | $better_search_terms = ''; |
@@ -744,9 +744,9 @@ discard block |
||
| 744 | 744 | |
| 745 | 745 | if ($s != '') {
|
| 746 | 746 | $keywords = explode(" ", $s);
|
| 747 | - if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
|
|
| 748 | - foreach($keywords as $kkey=>$kword){
|
|
| 749 | - if(mb_strlen($kword, 'UTF-8')<=$klimit){
|
|
| 747 | + if (is_array($keywords) && $klimit = get_option('geodir_search_word_limit')) {
|
|
| 748 | + foreach ($keywords as $kkey=>$kword) {
|
|
| 749 | + if (mb_strlen($kword, 'UTF-8') <= $klimit) {
|
|
| 750 | 750 | unset($keywords[$kkey]); |
| 751 | 751 | } |
| 752 | 752 | } |
@@ -755,7 +755,7 @@ discard block |
||
| 755 | 755 | if (!empty($keywords)) {
|
| 756 | 756 | foreach ($keywords as $keyword) {
|
| 757 | 757 | $keyword = trim($keyword); |
| 758 | - $keyword = wp_specialchars_decode($keyword ,ENT_QUOTES); |
|
| 758 | + $keyword = wp_specialchars_decode($keyword, ENT_QUOTES); |
|
| 759 | 759 | if ($keyword != '') {
|
| 760 | 760 | /** |
| 761 | 761 | * Filter the search query keywords SQL. |
@@ -766,7 +766,7 @@ discard block |
||
| 766 | 766 | * @param array $keywords The array of keywords for the query. |
| 767 | 767 | * @param string $keyword The single keyword being searched. |
| 768 | 768 | */ |
| 769 | - $better_search_terms .= apply_filters("geodir_search_better_search_terms",' OR ( ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '" OR ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '%" OR ' . $wpdb->posts . '.post_title LIKE "% ' . $keyword . '%" )',$keywords,$keyword);
|
|
| 769 | + $better_search_terms .= apply_filters("geodir_search_better_search_terms", ' OR ( '.$wpdb->posts.'.post_title LIKE "'.$keyword.'" OR '.$wpdb->posts.'.post_title LIKE "'.$keyword.'%" OR '.$wpdb->posts.'.post_title LIKE "% '.$keyword.'%" )', $keywords, $keyword);
|
|
| 770 | 770 | } |
| 771 | 771 | } |
| 772 | 772 | } |
@@ -774,10 +774,10 @@ discard block |
||
| 774 | 774 | |
| 775 | 775 | /* get taxonomy */ |
| 776 | 776 | $taxonomies = geodir_get_taxonomies($post_types, true); |
| 777 | - if($taxonomies) {
|
|
| 777 | + if ($taxonomies) {
|
|
| 778 | 778 | $taxonomies = implode("','", $taxonomies);
|
| 779 | - $taxonomies = "'" . $taxonomies . "'"; |
|
| 780 | - }else{$taxonomies='';}
|
|
| 779 | + $taxonomies = "'".$taxonomies."'"; |
|
| 780 | + } else {$taxonomies = ''; }
|
|
| 781 | 781 | |
| 782 | 782 | $content_where = $terms_where = ''; |
| 783 | 783 | if ($s != '') {
|
@@ -788,7 +788,7 @@ discard block |
||
| 788 | 788 | * @package GeoDirectory |
| 789 | 789 | * @param string $content_where The query values, default: `" OR ($wpdb->posts.post_content LIKE \"$s\" OR $wpdb->posts.post_content LIKE \"$s%\" OR $wpdb->posts.post_content LIKE \"% $s%\" OR $wpdb->posts.post_content LIKE \"%>$s%\" OR $wpdb->posts.post_content LIKE \"%\n$s%\") ") "`. |
| 790 | 790 | */ |
| 791 | - $content_where = apply_filters("geodir_search_content_where"," OR ($wpdb->posts.post_content LIKE \"$s\" OR $wpdb->posts.post_content LIKE \"$s%\" OR $wpdb->posts.post_content LIKE \"% $s%\" OR $wpdb->posts.post_content LIKE \"%>$s%\" OR $wpdb->posts.post_content LIKE \"%\n$s%\") ");
|
|
| 791 | + $content_where = apply_filters("geodir_search_content_where", " OR ($wpdb->posts.post_content LIKE \"$s\" OR $wpdb->posts.post_content LIKE \"$s%\" OR $wpdb->posts.post_content LIKE \"% $s%\" OR $wpdb->posts.post_content LIKE \"%>$s%\" OR $wpdb->posts.post_content LIKE \"%\n$s%\") ");
|
|
| 792 | 792 | /** |
| 793 | 793 | * Filter the search query term values. |
| 794 | 794 | * |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | * @package GeoDirectory |
| 797 | 797 | * @param string $terms_where The separator, default: `" AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) "`. |
| 798 | 798 | */ |
| 799 | - $terms_where = apply_filters("geodir_search_terms_where"," AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) ");
|
|
| 799 | + $terms_where = apply_filters("geodir_search_terms_where", " AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) ");
|
|
| 800 | 800 | } |
| 801 | 801 | |
| 802 | 802 | if ($snear != '') {
|
@@ -831,12 +831,12 @@ discard block |
||
| 831 | 831 | ) |
| 832 | 832 | AND $wpdb->posts.post_type in ('{$post_types}')
|
| 833 | 833 | AND ($wpdb->posts.post_status = 'publish') |
| 834 | - AND ( " . $table . ".post_latitude between $rlat1 and $rlat2 ) |
|
| 835 | - AND ( " . $table . ".post_longitude between $rlon1 and $rlon2 ) "; |
|
| 834 | + AND ( ".$table.".post_latitude between $rlat1 and $rlat2 ) |
|
| 835 | + AND ( ".$table.".post_longitude between $rlon1 and $rlon2 ) "; |
|
| 836 | 836 | |
| 837 | 837 | if (isset($_REQUEST['sdist']) && $_REQUEST['sdist'] != 'all') {
|
| 838 | 838 | $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
|
| 839 | - $where .= " AND CONVERT((" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) ))),DECIMAL(64,4)) <= " . $dist;
|
|
| 839 | + $where .= " AND CONVERT((".$DistanceRadius." * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(".$table.".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(".$table.".post_latitude) * pi()/180) *POWER(SIN(($mylon - ".$table.".post_longitude) * pi()/180 / 2), 2) ))),DECIMAL(64,4)) <= ".$dist;
|
|
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | } else {
|
@@ -857,11 +857,11 @@ discard block |
||
| 857 | 857 | } |
| 858 | 858 | |
| 859 | 859 | ########### WPML ########### |
| 860 | - if ( function_exists( 'icl_object_id' ) ) {
|
|
| 860 | + if (function_exists('icl_object_id')) {
|
|
| 861 | 861 | $lang_code = ICL_LANGUAGE_CODE; |
| 862 | 862 | |
| 863 | 863 | if ($lang_code && $post_types) {
|
| 864 | - $where .= " AND icl_t.language_code = '".$lang_code."' AND icl_t.element_type IN('post_" . $post_types . "') ";
|
|
| 864 | + $where .= " AND icl_t.language_code = '".$lang_code."' AND icl_t.element_type IN('post_".$post_types."') ";
|
|
| 865 | 865 | } |
| 866 | 866 | } |
| 867 | 867 | ########### WPML ########### |
@@ -884,10 +884,10 @@ discard block |
||
| 884 | 884 | global $wpdb, $geodir_post_type, $table, $curr; |
| 885 | 885 | |
| 886 | 886 | $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
|
| 887 | - $user_id = !empty($curauth->ID) ? (int)$curauth->ID : 0; |
|
| 887 | + $user_id = !empty($curauth->ID) ? (int) $curauth->ID : 0; |
|
| 888 | 888 | |
| 889 | 889 | if (isset($_REQUEST['stype'])) {
|
| 890 | - $where = $wpdb->prepare(" AND $wpdb->posts.post_type IN (%s) ",$_REQUEST['stype']);
|
|
| 890 | + $where = $wpdb->prepare(" AND $wpdb->posts.post_type IN (%s) ", $_REQUEST['stype']);
|
|
| 891 | 891 | } else {
|
| 892 | 892 | $where = " AND $wpdb->posts.post_type IN ('gd_place') ";
|
| 893 | 893 | } |
@@ -900,7 +900,7 @@ discard block |
||
| 900 | 900 | } else |
| 901 | 901 | $where .= " AND $wpdb->posts.post_author = $user_id"; |
| 902 | 902 | |
| 903 | - if ($user_id == (int)get_current_user_id()) {
|
|
| 903 | + if ($user_id == (int) get_current_user_id()) {
|
|
| 904 | 904 | $where .= " AND $wpdb->posts.post_status IN ('publish','draft','pending') ";
|
| 905 | 905 | } else {
|
| 906 | 906 | $where .= " AND $wpdb->posts.post_status = 'publish' "; |
@@ -913,7 +913,7 @@ discard block |
||
| 913 | 913 | if (function_exists('icl_object_id')) {
|
| 914 | 914 | $lang_code = ICL_LANGUAGE_CODE; |
| 915 | 915 | if ($lang_code) {
|
| 916 | - $where .= " AND icl_t.language_code='" . $lang_code . "' "; |
|
| 916 | + $where .= " AND icl_t.language_code='".$lang_code."' "; |
|
| 917 | 917 | } |
| 918 | 918 | |
| 919 | 919 | } |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | {
|
| 937 | 937 | global $wp_query, $table; |
| 938 | 938 | if (!empty($wp_query->query['with_pics_only'])) {
|
| 939 | - $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )"; |
|
| 939 | + $join .= " LEFT JOIN ".GEODIR_ATTACHMENT_TABLE." ON ( ".GEODIR_ATTACHMENT_TABLE.".post_id=".$table.".post_id AND ".GEODIR_ATTACHMENT_TABLE.".mime_type LIKE '%image%' )"; |
|
| 940 | 940 | } |
| 941 | 941 | return $join; |
| 942 | 942 | } |
@@ -955,16 +955,16 @@ discard block |
||
| 955 | 955 | {
|
| 956 | 956 | global $wp_query, $table; |
| 957 | 957 | if (!empty($wp_query->query['show_featured_only'])) {
|
| 958 | - $where .= " AND " . $table . ".is_featured = '1'"; |
|
| 958 | + $where .= " AND ".$table.".is_featured = '1'"; |
|
| 959 | 959 | } |
| 960 | 960 | if (!empty($wp_query->query['show_special_only'])) {
|
| 961 | - $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )"; |
|
| 961 | + $where .= " AND ( ".$table.".geodir_special_offers != '' AND ".$table.".geodir_special_offers IS NOT NULL )"; |
|
| 962 | 962 | } |
| 963 | 963 | if (!empty($wp_query->query['with_pics_only'])) {
|
| 964 | - $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL GROUP BY " . $table . ".post_id"; |
|
| 964 | + $where .= " AND ".GEODIR_ATTACHMENT_TABLE.".ID IS NOT NULL GROUP BY ".$table.".post_id"; |
|
| 965 | 965 | } |
| 966 | 966 | if (!empty($wp_query->query['with_videos_only'])) {
|
| 967 | - $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )"; |
|
| 967 | + $where .= " AND ( ".$table.".geodir_video != '' AND ".$table.".geodir_video IS NOT NULL )"; |
|
| 968 | 968 | } |
| 969 | 969 | return $where; |
| 970 | 970 | } |
@@ -973,18 +973,18 @@ discard block |
||
| 973 | 973 | function geodir_related_posts_fields($fields) {
|
| 974 | 974 | global $wp_query, $wpdb, $table, $post; |
| 975 | 975 | |
| 976 | - $fields .= ", " . $table . ".* "; |
|
| 976 | + $fields .= ", ".$table.".* "; |
|
| 977 | 977 | |
| 978 | 978 | $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
|
| 979 | 979 | |
| 980 | 980 | $mylat = $post->post_latitude; |
| 981 | 981 | $mylon = $post->post_longitude; |
| 982 | 982 | |
| 983 | - $fields .= " , (" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) )))as distance ";
|
|
| 983 | + $fields .= " , (".$DistanceRadius." * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(".$table.".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(".$table.".post_latitude) * pi()/180) *POWER(SIN(($mylon - ".$table.".post_longitude) * pi()/180 / 2), 2) )))as distance ";
|
|
| 984 | 984 | return $fields; |
| 985 | 985 | } |
| 986 | 986 | function geodir_related_posts_fields_filter($query) {
|
| 987 | - if ( isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop'] |
|
| 987 | + if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop'] |
|
| 988 | 988 | && isset($query->query_vars['order_by']) && $query->query_vars['order_by'] == 'nearest' |
| 989 | 989 | && isset($query->query_vars['related_listings']) && $query->query_vars['related_listings'] |
| 990 | 990 | ) {
|