@@ -14,13 +14,13 @@ discard block |
||
| 14 | 14 | * @return int|null Return the page ID if present or null if not. |
| 15 | 15 | */ |
| 16 | 16 | function geodir_add_listing_page_id(){ |
| 17 | - $gd_page_id = get_option('geodir_add_listing_page'); |
|
| 17 | + $gd_page_id = get_option('geodir_add_listing_page'); |
|
| 18 | 18 | |
| 19 | - if (function_exists('icl_object_id')) { |
|
| 20 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 21 | - } |
|
| 19 | + if (function_exists('icl_object_id')) { |
|
| 20 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - return $gd_page_id; |
|
| 23 | + return $gd_page_id; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -31,13 +31,13 @@ discard block |
||
| 31 | 31 | * @return int|null Return the page ID if present or null if not. |
| 32 | 32 | */ |
| 33 | 33 | function geodir_preview_page_id(){ |
| 34 | - $gd_page_id = get_option('geodir_preview_page'); |
|
| 34 | + $gd_page_id = get_option('geodir_preview_page'); |
|
| 35 | 35 | |
| 36 | - if (function_exists('icl_object_id')) { |
|
| 37 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 38 | - } |
|
| 36 | + if (function_exists('icl_object_id')) { |
|
| 37 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - return $gd_page_id; |
|
| 40 | + return $gd_page_id; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | * @return int|null Return the page ID if present or null if not. |
| 49 | 49 | */ |
| 50 | 50 | function geodir_success_page_id(){ |
| 51 | - $gd_page_id = get_option('geodir_success_page'); |
|
| 51 | + $gd_page_id = get_option('geodir_success_page'); |
|
| 52 | 52 | |
| 53 | - if (function_exists('icl_object_id')) { |
|
| 54 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 55 | - } |
|
| 53 | + if (function_exists('icl_object_id')) { |
|
| 54 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - return $gd_page_id; |
|
| 57 | + return $gd_page_id; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -65,13 +65,13 @@ discard block |
||
| 65 | 65 | * @return int|null Return the page ID if present or null if not. |
| 66 | 66 | */ |
| 67 | 67 | function geodir_location_page_id(){ |
| 68 | - $gd_page_id = get_option('geodir_location_page'); |
|
| 68 | + $gd_page_id = get_option('geodir_location_page'); |
|
| 69 | 69 | |
| 70 | - if (function_exists('icl_object_id')) { |
|
| 71 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 72 | - } |
|
| 70 | + if (function_exists('icl_object_id')) { |
|
| 71 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - return $gd_page_id; |
|
| 74 | + return $gd_page_id; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -82,13 +82,13 @@ discard block |
||
| 82 | 82 | * @return int|null Return the page ID if present or null if not. |
| 83 | 83 | */ |
| 84 | 84 | function geodir_home_page_id(){ |
| 85 | - $gd_page_id = get_option('geodir_home_page'); |
|
| 85 | + $gd_page_id = get_option('geodir_home_page'); |
|
| 86 | 86 | |
| 87 | - if (function_exists('icl_object_id')) { |
|
| 88 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 89 | - } |
|
| 87 | + if (function_exists('icl_object_id')) { |
|
| 88 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - return $gd_page_id; |
|
| 91 | + return $gd_page_id; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -99,13 +99,13 @@ discard block |
||
| 99 | 99 | * @return int|null Return the page ID if present or null if not. |
| 100 | 100 | */ |
| 101 | 101 | function geodir_info_page_id(){ |
| 102 | - $gd_page_id = get_option('geodir_info_page'); |
|
| 102 | + $gd_page_id = get_option('geodir_info_page'); |
|
| 103 | 103 | |
| 104 | - if (function_exists('icl_object_id')) { |
|
| 105 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 106 | - } |
|
| 104 | + if (function_exists('icl_object_id')) { |
|
| 105 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - return $gd_page_id; |
|
| 108 | + return $gd_page_id; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -116,13 +116,13 @@ discard block |
||
| 116 | 116 | * @return int|null Return the page ID if present or null if not. |
| 117 | 117 | */ |
| 118 | 118 | function geodir_login_page_id(){ |
| 119 | - $gd_page_id = get_option('geodir_login_page'); |
|
| 119 | + $gd_page_id = get_option('geodir_login_page'); |
|
| 120 | 120 | |
| 121 | - if (function_exists('icl_object_id')) { |
|
| 122 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 123 | - } |
|
| 121 | + if (function_exists('icl_object_id')) { |
|
| 122 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - return $gd_page_id; |
|
| 125 | + return $gd_page_id; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | |
@@ -134,15 +134,15 @@ discard block |
||
| 134 | 134 | * @return int|null Return the page ID if present or null if not. |
| 135 | 135 | */ |
| 136 | 136 | function geodir_login_url($args=array()){ |
| 137 | - $gd_page_id = get_option('geodir_login_page'); |
|
| 137 | + $gd_page_id = get_option('geodir_login_page'); |
|
| 138 | 138 | |
| 139 | - if (function_exists('icl_object_id')) { |
|
| 140 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 141 | - } |
|
| 139 | + if (function_exists('icl_object_id')) { |
|
| 140 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - if (function_exists('geodir_location_geo_home_link')) { |
|
| 144 | - remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
|
| 145 | - } |
|
| 143 | + if (function_exists('geodir_location_geo_home_link')) { |
|
| 144 | + remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | 147 | if (defined('ICL_LANGUAGE_CODE')){ |
| 148 | 148 | $home_url = icl_get_home_url(); |
@@ -150,35 +150,35 @@ discard block |
||
| 150 | 150 | $home_url = home_url(); |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - if (function_exists('geodir_location_geo_home_link')) { |
|
| 154 | - add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - if($gd_page_id){ |
|
| 158 | - $post = get_post($gd_page_id); |
|
| 159 | - $slug = $post->post_name; |
|
| 160 | - //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors |
|
| 161 | - $login_url = trailingslashit($home_url)."$slug/"; |
|
| 162 | - }else{ |
|
| 163 | - $login_url = trailingslashit($home_url)."?geodir_signup=true"; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - if($args){ |
|
| 167 | - $login_url = add_query_arg($args,$login_url ); |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * Filter the GeoDirectory login page url. |
|
| 172 | - * |
|
| 173 | - * This filter can be used to change the GeoDirectory page url. |
|
| 174 | - * |
|
| 175 | - * @since 1.5.3 |
|
| 176 | - * @package GeoDirectory |
|
| 177 | - * @param string $login_url The url of the login page. |
|
| 178 | - * @param array $args The array of query args used. |
|
| 179 | - * @param int $gd_page_id The page id of the GD login page. |
|
| 180 | - */ |
|
| 181 | - return apply_filters('geodir_login_url',$login_url,$args,$gd_page_id); |
|
| 153 | + if (function_exists('geodir_location_geo_home_link')) { |
|
| 154 | + add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + if($gd_page_id){ |
|
| 158 | + $post = get_post($gd_page_id); |
|
| 159 | + $slug = $post->post_name; |
|
| 160 | + //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors |
|
| 161 | + $login_url = trailingslashit($home_url)."$slug/"; |
|
| 162 | + }else{ |
|
| 163 | + $login_url = trailingslashit($home_url)."?geodir_signup=true"; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + if($args){ |
|
| 167 | + $login_url = add_query_arg($args,$login_url ); |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * Filter the GeoDirectory login page url. |
|
| 172 | + * |
|
| 173 | + * This filter can be used to change the GeoDirectory page url. |
|
| 174 | + * |
|
| 175 | + * @since 1.5.3 |
|
| 176 | + * @package GeoDirectory |
|
| 177 | + * @param string $login_url The url of the login page. |
|
| 178 | + * @param array $args The array of query args used. |
|
| 179 | + * @param int $gd_page_id The page id of the GD login page. |
|
| 180 | + */ |
|
| 181 | + return apply_filters('geodir_login_url',$login_url,$args,$gd_page_id); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
@@ -190,15 +190,15 @@ discard block |
||
| 190 | 190 | * @return string Info page url. |
| 191 | 191 | */ |
| 192 | 192 | function geodir_info_url($args=array()){ |
| 193 | - $gd_page_id = get_option('geodir_info_page'); |
|
| 193 | + $gd_page_id = get_option('geodir_info_page'); |
|
| 194 | 194 | |
| 195 | - if (function_exists('icl_object_id')) { |
|
| 196 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 197 | - } |
|
| 195 | + if (function_exists('icl_object_id')) { |
|
| 196 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - if (function_exists('geodir_location_geo_home_link')) { |
|
| 200 | - remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
|
| 201 | - } |
|
| 199 | + if (function_exists('geodir_location_geo_home_link')) { |
|
| 200 | + remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | 203 | if (defined('ICL_LANGUAGE_CODE')){ |
| 204 | 204 | $home_url = icl_get_home_url(); |
@@ -206,24 +206,24 @@ discard block |
||
| 206 | 206 | $home_url = home_url(); |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - if (function_exists('geodir_location_geo_home_link')) { |
|
| 210 | - add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
|
| 211 | - } |
|
| 209 | + if (function_exists('geodir_location_geo_home_link')) { |
|
| 210 | + add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | - if($gd_page_id){ |
|
| 214 | - $post = get_post($gd_page_id); |
|
| 215 | - $slug = $post->post_name; |
|
| 216 | - //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors |
|
| 217 | - $info_url = trailingslashit($home_url)."$slug/"; |
|
| 218 | - }else{ |
|
| 219 | - $info_url = trailingslashit($home_url); |
|
| 220 | - } |
|
| 213 | + if($gd_page_id){ |
|
| 214 | + $post = get_post($gd_page_id); |
|
| 215 | + $slug = $post->post_name; |
|
| 216 | + //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors |
|
| 217 | + $info_url = trailingslashit($home_url)."$slug/"; |
|
| 218 | + }else{ |
|
| 219 | + $info_url = trailingslashit($home_url); |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | - if($args){ |
|
| 223 | - $info_url = add_query_arg($args,$info_url ); |
|
| 224 | - } |
|
| 222 | + if($args){ |
|
| 223 | + $info_url = add_query_arg($args,$info_url ); |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - return $info_url; |
|
| 226 | + return $info_url; |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /** |
@@ -239,11 +239,11 @@ discard block |
||
| 239 | 239 | * @return string Returns converted string. |
| 240 | 240 | */ |
| 241 | 241 | function geodir_ucwords($string, $charset='UTF-8') { |
| 242 | - if (function_exists('mb_convert_case')) { |
|
| 243 | - return mb_convert_case($string, MB_CASE_TITLE, $charset); |
|
| 244 | - } else { |
|
| 245 | - return ucwords($string); |
|
| 246 | - } |
|
| 242 | + if (function_exists('mb_convert_case')) { |
|
| 243 | + return mb_convert_case($string, MB_CASE_TITLE, $charset); |
|
| 244 | + } else { |
|
| 245 | + return ucwords($string); |
|
| 246 | + } |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
@@ -259,11 +259,11 @@ discard block |
||
| 259 | 259 | * @return string Returns converted string. |
| 260 | 260 | */ |
| 261 | 261 | function geodir_strtolower($string, $charset='UTF-8') { |
| 262 | - if (function_exists('mb_convert_case')) { |
|
| 263 | - return mb_convert_case($string, MB_CASE_LOWER, $charset); |
|
| 264 | - } else { |
|
| 265 | - return strtolower($string); |
|
| 266 | - } |
|
| 262 | + if (function_exists('mb_convert_case')) { |
|
| 263 | + return mb_convert_case($string, MB_CASE_LOWER, $charset); |
|
| 264 | + } else { |
|
| 265 | + return strtolower($string); |
|
| 266 | + } |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
@@ -279,11 +279,11 @@ discard block |
||
| 279 | 279 | * @return string Returns converted string. |
| 280 | 280 | */ |
| 281 | 281 | function geodir_strtoupper($string, $charset='UTF-8') { |
| 282 | - if (function_exists('mb_convert_case')) { |
|
| 283 | - return mb_convert_case($string, MB_CASE_UPPER, $charset); |
|
| 284 | - } else { |
|
| 285 | - return strtoupper($string); |
|
| 286 | - } |
|
| 282 | + if (function_exists('mb_convert_case')) { |
|
| 283 | + return mb_convert_case($string, MB_CASE_UPPER, $charset); |
|
| 284 | + } else { |
|
| 285 | + return strtoupper($string); |
|
| 286 | + } |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | /** |
@@ -462,11 +462,11 @@ discard block |
||
| 462 | 462 | * @package GeoDirectory |
| 463 | 463 | */ |
| 464 | 464 | function _gd_die_handler() { |
| 465 | - if ( defined( 'GD_TESTING_MODE' ) ) { |
|
| 466 | - return '_gd_die_handler'; |
|
| 467 | - } else { |
|
| 468 | - die(); |
|
| 469 | - } |
|
| 465 | + if ( defined( 'GD_TESTING_MODE' ) ) { |
|
| 466 | + return '_gd_die_handler'; |
|
| 467 | + } else { |
|
| 468 | + die(); |
|
| 469 | + } |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | /** |
@@ -481,9 +481,9 @@ discard block |
||
| 481 | 481 | * @param int $status Optional. Status code. |
| 482 | 482 | */ |
| 483 | 483 | function gd_die( $message = '', $title = '', $status = 400 ) { |
| 484 | - add_filter( 'wp_die_ajax_handler', '_gd_die_handler', 10, 3 ); |
|
| 485 | - add_filter( 'wp_die_handler', '_gd_die_handler', 10, 3 ); |
|
| 486 | - wp_die( $message, $title, array( 'response' => $status )); |
|
| 484 | + add_filter( 'wp_die_ajax_handler', '_gd_die_handler', 10, 3 ); |
|
| 485 | + add_filter( 'wp_die_handler', '_gd_die_handler', 10, 3 ); |
|
| 486 | + wp_die( $message, $title, array( 'response' => $status )); |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | /* |
@@ -652,37 +652,37 @@ discard block |
||
| 652 | 652 | * @return string The formatted date. |
| 653 | 653 | */ |
| 654 | 654 | function geodir_date($date_input, $date_to, $date_from = '') { |
| 655 | - if (empty($date_input) || empty($date_to)) { |
|
| 656 | - return NULL; |
|
| 657 | - } |
|
| 655 | + if (empty($date_input) || empty($date_to)) { |
|
| 656 | + return NULL; |
|
| 657 | + } |
|
| 658 | 658 | |
| 659 | - $date = ''; |
|
| 660 | - if (!empty($date_from)) { |
|
| 661 | - $datetime = date_create_from_format($date_from, $date_input); |
|
| 659 | + $date = ''; |
|
| 660 | + if (!empty($date_from)) { |
|
| 661 | + $datetime = date_create_from_format($date_from, $date_input); |
|
| 662 | 662 | |
| 663 | - if (!empty($datetime)) { |
|
| 664 | - $date = $datetime->format($date_to); |
|
| 665 | - } |
|
| 666 | - } |
|
| 663 | + if (!empty($datetime)) { |
|
| 664 | + $date = $datetime->format($date_to); |
|
| 665 | + } |
|
| 666 | + } |
|
| 667 | 667 | |
| 668 | - if (empty($date)) { |
|
| 669 | - $date = strpos($date_input, '/') !== false ? str_replace('/', '-', $date_input) : $date_input; |
|
| 670 | - $date = date_i18n($date_to, strtotime($date)); |
|
| 671 | - } |
|
| 668 | + if (empty($date)) { |
|
| 669 | + $date = strpos($date_input, '/') !== false ? str_replace('/', '-', $date_input) : $date_input; |
|
| 670 | + $date = date_i18n($date_to, strtotime($date)); |
|
| 671 | + } |
|
| 672 | 672 | |
| 673 | - $date = geodir_maybe_untranslate_date($date); |
|
| 674 | - /** |
|
| 675 | - * Filter the the date format conversion. |
|
| 676 | - * |
|
| 677 | - * @since 1.6.7 |
|
| 678 | - * @package GeoDirectory |
|
| 679 | - * |
|
| 680 | - * @param string $date The date string. |
|
| 681 | - * @param string $date_input The date input. |
|
| 682 | - * @param string $date_to The destination date format. |
|
| 683 | - * @param string $date_from The source date format. |
|
| 684 | - */ |
|
| 685 | - return apply_filters('geodir_date', $date, $date_input, $date_to, $date_from); |
|
| 673 | + $date = geodir_maybe_untranslate_date($date); |
|
| 674 | + /** |
|
| 675 | + * Filter the the date format conversion. |
|
| 676 | + * |
|
| 677 | + * @since 1.6.7 |
|
| 678 | + * @package GeoDirectory |
|
| 679 | + * |
|
| 680 | + * @param string $date The date string. |
|
| 681 | + * @param string $date_input The date input. |
|
| 682 | + * @param string $date_to The destination date format. |
|
| 683 | + * @param string $date_from The source date format. |
|
| 684 | + */ |
|
| 685 | + return apply_filters('geodir_date', $date, $date_input, $date_to, $date_from); |
|
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | /** |
@@ -707,91 +707,91 @@ discard block |
||
| 707 | 707 | * @return string Trimmed string. |
| 708 | 708 | */ |
| 709 | 709 | function geodir_excerpt($text, $length = 100, $options = array()) { |
| 710 | - if (!(int)$length > 0) { |
|
| 711 | - return $text; |
|
| 712 | - } |
|
| 713 | - $default = array( |
|
| 714 | - 'ellipsis' => '', 'exact' => true, 'html' => true, 'trimWidth' => false, |
|
| 710 | + if (!(int)$length > 0) { |
|
| 711 | + return $text; |
|
| 712 | + } |
|
| 713 | + $default = array( |
|
| 714 | + 'ellipsis' => '', 'exact' => true, 'html' => true, 'trimWidth' => false, |
|
| 715 | 715 | ); |
| 716 | - if (!empty($options['html']) && strtolower(mb_internal_encoding()) === 'utf-8') { |
|
| 717 | - $default['ellipsis'] = ""; |
|
| 718 | - } |
|
| 719 | - $options += $default; |
|
| 720 | - |
|
| 721 | - $prefix = ''; |
|
| 722 | - $suffix = $options['ellipsis']; |
|
| 723 | - |
|
| 724 | - if ($options['html']) { |
|
| 725 | - $ellipsisLength = geodir_strlen(strip_tags($options['ellipsis']), $options); |
|
| 726 | - |
|
| 727 | - $truncateLength = 0; |
|
| 728 | - $totalLength = 0; |
|
| 729 | - $openTags = array(); |
|
| 730 | - $truncate = ''; |
|
| 731 | - |
|
| 732 | - preg_match_all('/(<\/?([\w+]+)[^>]*>)?([^<>]*)/', $text, $tags, PREG_SET_ORDER); |
|
| 733 | - foreach ($tags as $tag) { |
|
| 734 | - $contentLength = geodir_strlen($tag[3], $options); |
|
| 735 | - |
|
| 736 | - if ($truncate === '') { |
|
| 737 | - if (!preg_match('/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/i', $tag[2])) { |
|
| 738 | - if (preg_match('/<[\w]+[^>]*>/', $tag[0])) { |
|
| 739 | - array_unshift($openTags, $tag[2]); |
|
| 740 | - } elseif (preg_match('/<\/([\w]+)[^>]*>/', $tag[0], $closeTag)) { |
|
| 741 | - $pos = array_search($closeTag[1], $openTags); |
|
| 742 | - if ($pos !== false) { |
|
| 743 | - array_splice($openTags, $pos, 1); |
|
| 744 | - } |
|
| 745 | - } |
|
| 746 | - } |
|
| 747 | - |
|
| 748 | - $prefix .= $tag[1]; |
|
| 749 | - |
|
| 750 | - if ($totalLength + $contentLength + $ellipsisLength > $length) { |
|
| 751 | - $truncate = $tag[3]; |
|
| 752 | - $truncateLength = $length - $totalLength; |
|
| 753 | - } else { |
|
| 754 | - $prefix .= $tag[3]; |
|
| 755 | - } |
|
| 756 | - } |
|
| 757 | - |
|
| 758 | - $totalLength += $contentLength; |
|
| 759 | - if ($totalLength > $length) { |
|
| 760 | - break; |
|
| 761 | - } |
|
| 762 | - } |
|
| 763 | - |
|
| 764 | - if ($totalLength <= $length) { |
|
| 765 | - return $text; |
|
| 766 | - } |
|
| 767 | - |
|
| 768 | - $text = $truncate; |
|
| 769 | - $length = $truncateLength; |
|
| 770 | - |
|
| 771 | - foreach ($openTags as $tag) { |
|
| 772 | - $suffix .= '</' . $tag . '>'; |
|
| 773 | - } |
|
| 774 | - } else { |
|
| 775 | - if (geodir_strlen($text, $options) <= $length) { |
|
| 776 | - return $text; |
|
| 777 | - } |
|
| 778 | - $ellipsisLength = geodir_strlen($options['ellipsis'], $options); |
|
| 779 | - } |
|
| 780 | - |
|
| 781 | - $result = geodir_substr($text, 0, $length - $ellipsisLength, $options); |
|
| 782 | - |
|
| 783 | - if (!$options['exact']) { |
|
| 784 | - if (geodir_substr($text, $length - $ellipsisLength, 1, $options) !== ' ') { |
|
| 785 | - $result = geodir_remove_last_word($result); |
|
| 786 | - } |
|
| 787 | - |
|
| 788 | - // Do not need to count ellipsis in the cut, if result is empty. |
|
| 789 | - if (!strlen($result)) { |
|
| 790 | - $result = geodir_substr($text, 0, $length, $options); |
|
| 791 | - } |
|
| 792 | - } |
|
| 793 | - |
|
| 794 | - return $prefix . $result . $suffix; |
|
| 716 | + if (!empty($options['html']) && strtolower(mb_internal_encoding()) === 'utf-8') { |
|
| 717 | + $default['ellipsis'] = ""; |
|
| 718 | + } |
|
| 719 | + $options += $default; |
|
| 720 | + |
|
| 721 | + $prefix = ''; |
|
| 722 | + $suffix = $options['ellipsis']; |
|
| 723 | + |
|
| 724 | + if ($options['html']) { |
|
| 725 | + $ellipsisLength = geodir_strlen(strip_tags($options['ellipsis']), $options); |
|
| 726 | + |
|
| 727 | + $truncateLength = 0; |
|
| 728 | + $totalLength = 0; |
|
| 729 | + $openTags = array(); |
|
| 730 | + $truncate = ''; |
|
| 731 | + |
|
| 732 | + preg_match_all('/(<\/?([\w+]+)[^>]*>)?([^<>]*)/', $text, $tags, PREG_SET_ORDER); |
|
| 733 | + foreach ($tags as $tag) { |
|
| 734 | + $contentLength = geodir_strlen($tag[3], $options); |
|
| 735 | + |
|
| 736 | + if ($truncate === '') { |
|
| 737 | + if (!preg_match('/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/i', $tag[2])) { |
|
| 738 | + if (preg_match('/<[\w]+[^>]*>/', $tag[0])) { |
|
| 739 | + array_unshift($openTags, $tag[2]); |
|
| 740 | + } elseif (preg_match('/<\/([\w]+)[^>]*>/', $tag[0], $closeTag)) { |
|
| 741 | + $pos = array_search($closeTag[1], $openTags); |
|
| 742 | + if ($pos !== false) { |
|
| 743 | + array_splice($openTags, $pos, 1); |
|
| 744 | + } |
|
| 745 | + } |
|
| 746 | + } |
|
| 747 | + |
|
| 748 | + $prefix .= $tag[1]; |
|
| 749 | + |
|
| 750 | + if ($totalLength + $contentLength + $ellipsisLength > $length) { |
|
| 751 | + $truncate = $tag[3]; |
|
| 752 | + $truncateLength = $length - $totalLength; |
|
| 753 | + } else { |
|
| 754 | + $prefix .= $tag[3]; |
|
| 755 | + } |
|
| 756 | + } |
|
| 757 | + |
|
| 758 | + $totalLength += $contentLength; |
|
| 759 | + if ($totalLength > $length) { |
|
| 760 | + break; |
|
| 761 | + } |
|
| 762 | + } |
|
| 763 | + |
|
| 764 | + if ($totalLength <= $length) { |
|
| 765 | + return $text; |
|
| 766 | + } |
|
| 767 | + |
|
| 768 | + $text = $truncate; |
|
| 769 | + $length = $truncateLength; |
|
| 770 | + |
|
| 771 | + foreach ($openTags as $tag) { |
|
| 772 | + $suffix .= '</' . $tag . '>'; |
|
| 773 | + } |
|
| 774 | + } else { |
|
| 775 | + if (geodir_strlen($text, $options) <= $length) { |
|
| 776 | + return $text; |
|
| 777 | + } |
|
| 778 | + $ellipsisLength = geodir_strlen($options['ellipsis'], $options); |
|
| 779 | + } |
|
| 780 | + |
|
| 781 | + $result = geodir_substr($text, 0, $length - $ellipsisLength, $options); |
|
| 782 | + |
|
| 783 | + if (!$options['exact']) { |
|
| 784 | + if (geodir_substr($text, $length - $ellipsisLength, 1, $options) !== ' ') { |
|
| 785 | + $result = geodir_remove_last_word($result); |
|
| 786 | + } |
|
| 787 | + |
|
| 788 | + // Do not need to count ellipsis in the cut, if result is empty. |
|
| 789 | + if (!strlen($result)) { |
|
| 790 | + $result = geodir_substr($text, 0, $length, $options); |
|
| 791 | + } |
|
| 792 | + } |
|
| 793 | + |
|
| 794 | + return $prefix . $result . $suffix; |
|
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | /** |
@@ -815,28 +815,28 @@ discard block |
||
| 815 | 815 | * @return int |
| 816 | 816 | */ |
| 817 | 817 | function geodir_strlen($text, array $options) { |
| 818 | - if (empty($options['trimWidth'])) { |
|
| 819 | - $strlen = 'mb_strlen'; |
|
| 820 | - } else { |
|
| 821 | - $strlen = 'mb_strwidth'; |
|
| 822 | - } |
|
| 823 | - |
|
| 824 | - if (empty($options['html'])) { |
|
| 825 | - return $strlen($text); |
|
| 826 | - } |
|
| 827 | - |
|
| 828 | - $pattern = '/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i'; |
|
| 829 | - $replace = preg_replace_callback( |
|
| 830 | - $pattern, |
|
| 831 | - function ($match) use ($strlen) { |
|
| 832 | - $utf8 = html_entity_decode($match[0], ENT_HTML5 | ENT_QUOTES, 'UTF-8'); |
|
| 833 | - |
|
| 834 | - return str_repeat(' ', $strlen($utf8, 'UTF-8')); |
|
| 835 | - }, |
|
| 836 | - $text |
|
| 837 | - ); |
|
| 838 | - |
|
| 839 | - return $strlen($replace); |
|
| 818 | + if (empty($options['trimWidth'])) { |
|
| 819 | + $strlen = 'mb_strlen'; |
|
| 820 | + } else { |
|
| 821 | + $strlen = 'mb_strwidth'; |
|
| 822 | + } |
|
| 823 | + |
|
| 824 | + if (empty($options['html'])) { |
|
| 825 | + return $strlen($text); |
|
| 826 | + } |
|
| 827 | + |
|
| 828 | + $pattern = '/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i'; |
|
| 829 | + $replace = preg_replace_callback( |
|
| 830 | + $pattern, |
|
| 831 | + function ($match) use ($strlen) { |
|
| 832 | + $utf8 = html_entity_decode($match[0], ENT_HTML5 | ENT_QUOTES, 'UTF-8'); |
|
| 833 | + |
|
| 834 | + return str_repeat(' ', $strlen($utf8, 'UTF-8')); |
|
| 835 | + }, |
|
| 836 | + $text |
|
| 837 | + ); |
|
| 838 | + |
|
| 839 | + return $strlen($replace); |
|
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | /** |
@@ -857,80 +857,80 @@ discard block |
||
| 857 | 857 | * @return string |
| 858 | 858 | */ |
| 859 | 859 | function geodir_substr($text, $start, $length, array $options) { |
| 860 | - if (empty($options['trimWidth'])) { |
|
| 861 | - $substr = 'mb_substr'; |
|
| 862 | - } else { |
|
| 863 | - $substr = 'mb_strimwidth'; |
|
| 864 | - } |
|
| 865 | - |
|
| 866 | - $maxPosition = geodir_strlen($text, ['trimWidth' => false] + $options); |
|
| 867 | - if ($start < 0) { |
|
| 868 | - $start += $maxPosition; |
|
| 869 | - if ($start < 0) { |
|
| 870 | - $start = 0; |
|
| 871 | - } |
|
| 872 | - } |
|
| 873 | - if ($start >= $maxPosition) { |
|
| 874 | - return ''; |
|
| 875 | - } |
|
| 876 | - |
|
| 877 | - if ($length === null) { |
|
| 878 | - $length = geodir_strlen($text, $options); |
|
| 879 | - } |
|
| 880 | - |
|
| 881 | - if ($length < 0) { |
|
| 882 | - $text = geodir_substr($text, $start, null, $options); |
|
| 883 | - $start = 0; |
|
| 884 | - $length += geodir_strlen($text, $options); |
|
| 885 | - } |
|
| 886 | - |
|
| 887 | - if ($length <= 0) { |
|
| 888 | - return ''; |
|
| 889 | - } |
|
| 890 | - |
|
| 891 | - if (empty($options['html'])) { |
|
| 892 | - return (string)$substr($text, $start, $length); |
|
| 893 | - } |
|
| 894 | - |
|
| 895 | - $totalOffset = 0; |
|
| 896 | - $totalLength = 0; |
|
| 897 | - $result = ''; |
|
| 898 | - |
|
| 899 | - $pattern = '/(&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};)/i'; |
|
| 900 | - $parts = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
|
| 901 | - foreach ($parts as $part) { |
|
| 902 | - $offset = 0; |
|
| 903 | - |
|
| 904 | - if ($totalOffset < $start) { |
|
| 905 | - $len = geodir_strlen($part, ['trimWidth' => false] + $options); |
|
| 906 | - if ($totalOffset + $len <= $start) { |
|
| 907 | - $totalOffset += $len; |
|
| 908 | - continue; |
|
| 909 | - } |
|
| 910 | - |
|
| 911 | - $offset = $start - $totalOffset; |
|
| 912 | - $totalOffset = $start; |
|
| 913 | - } |
|
| 914 | - |
|
| 915 | - $len = geodir_strlen($part, $options); |
|
| 916 | - if ($offset !== 0 || $totalLength + $len > $length) { |
|
| 917 | - if (strpos($part, '&') === 0 && preg_match($pattern, $part) && $part !== html_entity_decode($part, ENT_HTML5 | ENT_QUOTES, 'UTF-8') ) { |
|
| 918 | - // Entities cannot be passed substr. |
|
| 919 | - continue; |
|
| 920 | - } |
|
| 921 | - |
|
| 922 | - $part = $substr($part, $offset, $length - $totalLength); |
|
| 923 | - $len = geodir_strlen($part, $options); |
|
| 924 | - } |
|
| 925 | - |
|
| 926 | - $result .= $part; |
|
| 927 | - $totalLength += $len; |
|
| 928 | - if ($totalLength >= $length) { |
|
| 929 | - break; |
|
| 930 | - } |
|
| 931 | - } |
|
| 932 | - |
|
| 933 | - return $result; |
|
| 860 | + if (empty($options['trimWidth'])) { |
|
| 861 | + $substr = 'mb_substr'; |
|
| 862 | + } else { |
|
| 863 | + $substr = 'mb_strimwidth'; |
|
| 864 | + } |
|
| 865 | + |
|
| 866 | + $maxPosition = geodir_strlen($text, ['trimWidth' => false] + $options); |
|
| 867 | + if ($start < 0) { |
|
| 868 | + $start += $maxPosition; |
|
| 869 | + if ($start < 0) { |
|
| 870 | + $start = 0; |
|
| 871 | + } |
|
| 872 | + } |
|
| 873 | + if ($start >= $maxPosition) { |
|
| 874 | + return ''; |
|
| 875 | + } |
|
| 876 | + |
|
| 877 | + if ($length === null) { |
|
| 878 | + $length = geodir_strlen($text, $options); |
|
| 879 | + } |
|
| 880 | + |
|
| 881 | + if ($length < 0) { |
|
| 882 | + $text = geodir_substr($text, $start, null, $options); |
|
| 883 | + $start = 0; |
|
| 884 | + $length += geodir_strlen($text, $options); |
|
| 885 | + } |
|
| 886 | + |
|
| 887 | + if ($length <= 0) { |
|
| 888 | + return ''; |
|
| 889 | + } |
|
| 890 | + |
|
| 891 | + if (empty($options['html'])) { |
|
| 892 | + return (string)$substr($text, $start, $length); |
|
| 893 | + } |
|
| 894 | + |
|
| 895 | + $totalOffset = 0; |
|
| 896 | + $totalLength = 0; |
|
| 897 | + $result = ''; |
|
| 898 | + |
|
| 899 | + $pattern = '/(&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};)/i'; |
|
| 900 | + $parts = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
|
| 901 | + foreach ($parts as $part) { |
|
| 902 | + $offset = 0; |
|
| 903 | + |
|
| 904 | + if ($totalOffset < $start) { |
|
| 905 | + $len = geodir_strlen($part, ['trimWidth' => false] + $options); |
|
| 906 | + if ($totalOffset + $len <= $start) { |
|
| 907 | + $totalOffset += $len; |
|
| 908 | + continue; |
|
| 909 | + } |
|
| 910 | + |
|
| 911 | + $offset = $start - $totalOffset; |
|
| 912 | + $totalOffset = $start; |
|
| 913 | + } |
|
| 914 | + |
|
| 915 | + $len = geodir_strlen($part, $options); |
|
| 916 | + if ($offset !== 0 || $totalLength + $len > $length) { |
|
| 917 | + if (strpos($part, '&') === 0 && preg_match($pattern, $part) && $part !== html_entity_decode($part, ENT_HTML5 | ENT_QUOTES, 'UTF-8') ) { |
|
| 918 | + // Entities cannot be passed substr. |
|
| 919 | + continue; |
|
| 920 | + } |
|
| 921 | + |
|
| 922 | + $part = $substr($part, $offset, $length - $totalLength); |
|
| 923 | + $len = geodir_strlen($part, $options); |
|
| 924 | + } |
|
| 925 | + |
|
| 926 | + $result .= $part; |
|
| 927 | + $totalLength += $len; |
|
| 928 | + if ($totalLength >= $length) { |
|
| 929 | + break; |
|
| 930 | + } |
|
| 931 | + } |
|
| 932 | + |
|
| 933 | + return $result; |
|
| 934 | 934 | } |
| 935 | 935 | |
| 936 | 936 | /** |
@@ -943,21 +943,21 @@ discard block |
||
| 943 | 943 | * @return string |
| 944 | 944 | */ |
| 945 | 945 | function geodir_remove_last_word($text) { |
| 946 | - $spacepos = mb_strrpos($text, ' '); |
|
| 946 | + $spacepos = mb_strrpos($text, ' '); |
|
| 947 | 947 | |
| 948 | - if ($spacepos !== false) { |
|
| 949 | - $lastWord = mb_strrpos($text, $spacepos); |
|
| 948 | + if ($spacepos !== false) { |
|
| 949 | + $lastWord = mb_strrpos($text, $spacepos); |
|
| 950 | 950 | |
| 951 | - // Some languages are written without word separation. |
|
| 952 | - // We recognize a string as a word if it does not contain any full-width characters. |
|
| 953 | - if (mb_strwidth($lastWord) === mb_strlen($lastWord)) { |
|
| 954 | - $text = mb_substr($text, 0, $spacepos); |
|
| 955 | - } |
|
| 951 | + // Some languages are written without word separation. |
|
| 952 | + // We recognize a string as a word if it does not contain any full-width characters. |
|
| 953 | + if (mb_strwidth($lastWord) === mb_strlen($lastWord)) { |
|
| 954 | + $text = mb_substr($text, 0, $spacepos); |
|
| 955 | + } |
|
| 956 | 956 | |
| 957 | - return $text; |
|
| 958 | - } |
|
| 957 | + return $text; |
|
| 958 | + } |
|
| 959 | 959 | |
| 960 | - return ''; |
|
| 960 | + return ''; |
|
| 961 | 961 | } |
| 962 | 962 | |
| 963 | 963 | function geodir_tool_restore_cpt_from_taxonomies(){ |
@@ -13,11 +13,11 @@ discard block |
||
| 13 | 13 | * @since 1.4.6 |
| 14 | 14 | * @return int|null Return the page ID if present or null if not. |
| 15 | 15 | */ |
| 16 | -function geodir_add_listing_page_id(){ |
|
| 16 | +function geodir_add_listing_page_id() { |
|
| 17 | 17 | $gd_page_id = get_option('geodir_add_listing_page'); |
| 18 | 18 | |
| 19 | 19 | if (function_exists('icl_object_id')) { |
| 20 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 20 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | return $gd_page_id; |
@@ -30,11 +30,11 @@ discard block |
||
| 30 | 30 | * @since 1.4.6 |
| 31 | 31 | * @return int|null Return the page ID if present or null if not. |
| 32 | 32 | */ |
| 33 | -function geodir_preview_page_id(){ |
|
| 33 | +function geodir_preview_page_id() { |
|
| 34 | 34 | $gd_page_id = get_option('geodir_preview_page'); |
| 35 | 35 | |
| 36 | 36 | if (function_exists('icl_object_id')) { |
| 37 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 37 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | return $gd_page_id; |
@@ -47,11 +47,11 @@ discard block |
||
| 47 | 47 | * @since 1.4.6 |
| 48 | 48 | * @return int|null Return the page ID if present or null if not. |
| 49 | 49 | */ |
| 50 | -function geodir_success_page_id(){ |
|
| 50 | +function geodir_success_page_id() { |
|
| 51 | 51 | $gd_page_id = get_option('geodir_success_page'); |
| 52 | 52 | |
| 53 | 53 | if (function_exists('icl_object_id')) { |
| 54 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 54 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | return $gd_page_id; |
@@ -64,11 +64,11 @@ discard block |
||
| 64 | 64 | * @since 1.4.6 |
| 65 | 65 | * @return int|null Return the page ID if present or null if not. |
| 66 | 66 | */ |
| 67 | -function geodir_location_page_id(){ |
|
| 67 | +function geodir_location_page_id() { |
|
| 68 | 68 | $gd_page_id = get_option('geodir_location_page'); |
| 69 | 69 | |
| 70 | 70 | if (function_exists('icl_object_id')) { |
| 71 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 71 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | return $gd_page_id; |
@@ -81,11 +81,11 @@ discard block |
||
| 81 | 81 | * @since 1.5.4 |
| 82 | 82 | * @return int|null Return the page ID if present or null if not. |
| 83 | 83 | */ |
| 84 | -function geodir_home_page_id(){ |
|
| 84 | +function geodir_home_page_id() { |
|
| 85 | 85 | $gd_page_id = get_option('geodir_home_page'); |
| 86 | 86 | |
| 87 | 87 | if (function_exists('icl_object_id')) { |
| 88 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 88 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | return $gd_page_id; |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | * @since 1.5.3 |
| 99 | 99 | * @return int|null Return the page ID if present or null if not. |
| 100 | 100 | */ |
| 101 | -function geodir_info_page_id(){ |
|
| 101 | +function geodir_info_page_id() { |
|
| 102 | 102 | $gd_page_id = get_option('geodir_info_page'); |
| 103 | 103 | |
| 104 | 104 | if (function_exists('icl_object_id')) { |
| 105 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 105 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | return $gd_page_id; |
@@ -115,11 +115,11 @@ discard block |
||
| 115 | 115 | * @since 1.5.3 |
| 116 | 116 | * @return int|null Return the page ID if present or null if not. |
| 117 | 117 | */ |
| 118 | -function geodir_login_page_id(){ |
|
| 118 | +function geodir_login_page_id() { |
|
| 119 | 119 | $gd_page_id = get_option('geodir_login_page'); |
| 120 | 120 | |
| 121 | 121 | if (function_exists('icl_object_id')) { |
| 122 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 122 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | return $gd_page_id; |
@@ -133,20 +133,20 @@ discard block |
||
| 133 | 133 | * @since 1.5.3 |
| 134 | 134 | * @return int|null Return the page ID if present or null if not. |
| 135 | 135 | */ |
| 136 | -function geodir_login_url($args=array()){ |
|
| 136 | +function geodir_login_url($args = array()) { |
|
| 137 | 137 | $gd_page_id = get_option('geodir_login_page'); |
| 138 | 138 | |
| 139 | 139 | if (function_exists('icl_object_id')) { |
| 140 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 140 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | if (function_exists('geodir_location_geo_home_link')) { |
| 144 | 144 | remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - if (defined('ICL_LANGUAGE_CODE')){ |
|
| 147 | + if (defined('ICL_LANGUAGE_CODE')) { |
|
| 148 | 148 | $home_url = icl_get_home_url(); |
| 149 | - }else{ |
|
| 149 | + } else { |
|
| 150 | 150 | $home_url = home_url(); |
| 151 | 151 | } |
| 152 | 152 | |
@@ -154,17 +154,17 @@ discard block |
||
| 154 | 154 | add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - if($gd_page_id){ |
|
| 157 | + if ($gd_page_id) { |
|
| 158 | 158 | $post = get_post($gd_page_id); |
| 159 | 159 | $slug = $post->post_name; |
| 160 | 160 | //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors |
| 161 | 161 | $login_url = trailingslashit($home_url)."$slug/"; |
| 162 | - }else{ |
|
| 162 | + } else { |
|
| 163 | 163 | $login_url = trailingslashit($home_url)."?geodir_signup=true"; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - if($args){ |
|
| 167 | - $login_url = add_query_arg($args,$login_url ); |
|
| 166 | + if ($args) { |
|
| 167 | + $login_url = add_query_arg($args, $login_url); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | * @param array $args The array of query args used. |
| 179 | 179 | * @param int $gd_page_id The page id of the GD login page. |
| 180 | 180 | */ |
| 181 | - return apply_filters('geodir_login_url',$login_url,$args,$gd_page_id); |
|
| 181 | + return apply_filters('geodir_login_url', $login_url, $args, $gd_page_id); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
@@ -189,20 +189,20 @@ discard block |
||
| 189 | 189 | * @since 1.5.16 Added WPML lang code to url. |
| 190 | 190 | * @return string Info page url. |
| 191 | 191 | */ |
| 192 | -function geodir_info_url($args=array()){ |
|
| 192 | +function geodir_info_url($args = array()) { |
|
| 193 | 193 | $gd_page_id = get_option('geodir_info_page'); |
| 194 | 194 | |
| 195 | 195 | if (function_exists('icl_object_id')) { |
| 196 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 196 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | if (function_exists('geodir_location_geo_home_link')) { |
| 200 | 200 | remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - if (defined('ICL_LANGUAGE_CODE')){ |
|
| 203 | + if (defined('ICL_LANGUAGE_CODE')) { |
|
| 204 | 204 | $home_url = icl_get_home_url(); |
| 205 | - }else{ |
|
| 205 | + } else { |
|
| 206 | 206 | $home_url = home_url(); |
| 207 | 207 | } |
| 208 | 208 | |
@@ -210,17 +210,17 @@ discard block |
||
| 210 | 210 | add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - if($gd_page_id){ |
|
| 213 | + if ($gd_page_id) { |
|
| 214 | 214 | $post = get_post($gd_page_id); |
| 215 | 215 | $slug = $post->post_name; |
| 216 | 216 | //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors |
| 217 | 217 | $info_url = trailingslashit($home_url)."$slug/"; |
| 218 | - }else{ |
|
| 218 | + } else { |
|
| 219 | 219 | $info_url = trailingslashit($home_url); |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - if($args){ |
|
| 223 | - $info_url = add_query_arg($args,$info_url ); |
|
| 222 | + if ($args) { |
|
| 223 | + $info_url = add_query_arg($args, $info_url); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | return $info_url; |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | * @param string $charset Character set to use for conversion. |
| 239 | 239 | * @return string Returns converted string. |
| 240 | 240 | */ |
| 241 | -function geodir_ucwords($string, $charset='UTF-8') { |
|
| 241 | +function geodir_ucwords($string, $charset = 'UTF-8') { |
|
| 242 | 242 | if (function_exists('mb_convert_case')) { |
| 243 | 243 | return mb_convert_case($string, MB_CASE_TITLE, $charset); |
| 244 | 244 | } else { |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | * @param string $charset Character set to use for conversion. |
| 259 | 259 | * @return string Returns converted string. |
| 260 | 260 | */ |
| 261 | -function geodir_strtolower($string, $charset='UTF-8') { |
|
| 261 | +function geodir_strtolower($string, $charset = 'UTF-8') { |
|
| 262 | 262 | if (function_exists('mb_convert_case')) { |
| 263 | 263 | return mb_convert_case($string, MB_CASE_LOWER, $charset); |
| 264 | 264 | } else { |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | * @param string $charset Character set to use for conversion. |
| 279 | 279 | * @return string Returns converted string. |
| 280 | 280 | */ |
| 281 | -function geodir_strtoupper($string, $charset='UTF-8') { |
|
| 281 | +function geodir_strtoupper($string, $charset = 'UTF-8') { |
|
| 282 | 282 | if (function_exists('mb_convert_case')) { |
| 283 | 283 | return mb_convert_case($string, MB_CASE_UPPER, $charset); |
| 284 | 284 | } else { |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | |
| 310 | 310 | $url = trim($parts[0]); |
| 311 | 311 | if ($formatted && $url != '') { |
| 312 | - $url = str_replace( ' ', '%20', $url ); |
|
| 312 | + $url = str_replace(' ', '%20', $url); |
|
| 313 | 313 | $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\[\]\\x80-\\xff]|i', '', $url); |
| 314 | 314 | |
| 315 | 315 | if (0 !== stripos($url, 'mailto:')) { |
@@ -319,8 +319,8 @@ discard block |
||
| 319 | 319 | |
| 320 | 320 | $url = str_replace(';//', '://', $url); |
| 321 | 321 | |
| 322 | - if (strpos($url, ':') === false && ! in_array($url[0], array('/', '#', '?')) && !preg_match('/^[a-z0-9-]+?\.php/i', $url)) { |
|
| 323 | - $url = 'http://' . $url; |
|
| 322 | + if (strpos($url, ':') === false && !in_array($url[0], array('/', '#', '?')) && !preg_match('/^[a-z0-9-]+?\.php/i', $url)) { |
|
| 323 | + $url = 'http://'.$url; |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | $url = wp_kses_normalize_entities($url); |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | * @package GeoDirectory |
| 463 | 463 | */ |
| 464 | 464 | function _gd_die_handler() { |
| 465 | - if ( defined( 'GD_TESTING_MODE' ) ) { |
|
| 465 | + if (defined('GD_TESTING_MODE')) { |
|
| 466 | 466 | return '_gd_die_handler'; |
| 467 | 467 | } else { |
| 468 | 468 | die(); |
@@ -480,10 +480,10 @@ discard block |
||
| 480 | 480 | * @param string $title Optional. Error title. |
| 481 | 481 | * @param int $status Optional. Status code. |
| 482 | 482 | */ |
| 483 | -function gd_die( $message = '', $title = '', $status = 400 ) { |
|
| 484 | - add_filter( 'wp_die_ajax_handler', '_gd_die_handler', 10, 3 ); |
|
| 485 | - add_filter( 'wp_die_handler', '_gd_die_handler', 10, 3 ); |
|
| 486 | - wp_die( $message, $title, array( 'response' => $status )); |
|
| 483 | +function gd_die($message = '', $title = '', $status = 400) { |
|
| 484 | + add_filter('wp_die_ajax_handler', '_gd_die_handler', 10, 3); |
|
| 485 | + add_filter('wp_die_handler', '_gd_die_handler', 10, 3); |
|
| 486 | + wp_die($message, $title, array('response' => $status)); |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | /* |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | * @param string $php_format The PHP date format. |
| 494 | 494 | * @return string The jQuery format date string. |
| 495 | 495 | */ |
| 496 | -function geodir_date_format_php_to_jqueryui( $php_format ) { |
|
| 496 | +function geodir_date_format_php_to_jqueryui($php_format) { |
|
| 497 | 497 | $symbols = array( |
| 498 | 498 | // Day |
| 499 | 499 | 'd' => 'dd', |
@@ -533,27 +533,27 @@ discard block |
||
| 533 | 533 | $jqueryui_format = ""; |
| 534 | 534 | $escaping = false; |
| 535 | 535 | |
| 536 | - for ( $i = 0; $i < strlen( $php_format ); $i++ ) { |
|
| 536 | + for ($i = 0; $i < strlen($php_format); $i++) { |
|
| 537 | 537 | $char = $php_format[$i]; |
| 538 | 538 | |
| 539 | 539 | // PHP date format escaping character |
| 540 | - if ( $char === '\\' ) { |
|
| 540 | + if ($char === '\\') { |
|
| 541 | 541 | $i++; |
| 542 | 542 | |
| 543 | - if ( $escaping ) { |
|
| 543 | + if ($escaping) { |
|
| 544 | 544 | $jqueryui_format .= $php_format[$i]; |
| 545 | 545 | } else { |
| 546 | - $jqueryui_format .= '\'' . $php_format[$i]; |
|
| 546 | + $jqueryui_format .= '\''.$php_format[$i]; |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | $escaping = true; |
| 550 | 550 | } else { |
| 551 | - if ( $escaping ) { |
|
| 551 | + if ($escaping) { |
|
| 552 | 552 | $jqueryui_format .= "'"; |
| 553 | 553 | $escaping = false; |
| 554 | 554 | } |
| 555 | 555 | |
| 556 | - if ( isset( $symbols[$char] ) ) { |
|
| 556 | + if (isset($symbols[$char])) { |
|
| 557 | 557 | $jqueryui_format .= $symbols[$char]; |
| 558 | 558 | } else { |
| 559 | 559 | $jqueryui_format .= $char; |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | * @return string The untranslated date string. |
| 573 | 573 | * @since 1.6.5 |
| 574 | 574 | */ |
| 575 | -function geodir_maybe_untranslate_date($date){ |
|
| 575 | +function geodir_maybe_untranslate_date($date) { |
|
| 576 | 576 | $english_long_months = array( |
| 577 | 577 | 'January', |
| 578 | 578 | 'February', |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | 'December', |
| 589 | 589 | ); |
| 590 | 590 | |
| 591 | - $non_english_long_months = array( |
|
| 591 | + $non_english_long_months = array( |
|
| 592 | 592 | __('January'), |
| 593 | 593 | __('February'), |
| 594 | 594 | __('March'), |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | __('November'), |
| 603 | 603 | __('December'), |
| 604 | 604 | ); |
| 605 | - $date = str_replace($non_english_long_months,$english_long_months,$date); |
|
| 605 | + $date = str_replace($non_english_long_months, $english_long_months, $date); |
|
| 606 | 606 | |
| 607 | 607 | |
| 608 | 608 | $english_short_months = array( |
@@ -621,21 +621,21 @@ discard block |
||
| 621 | 621 | ); |
| 622 | 622 | |
| 623 | 623 | $non_english_short_months = array( |
| 624 | - ' '._x( 'Jan', 'January abbreviation' ).' ', |
|
| 625 | - ' '._x( 'Feb', 'February abbreviation' ).' ', |
|
| 626 | - ' '._x( 'Mar', 'March abbreviation' ).' ', |
|
| 627 | - ' '._x( 'Apr', 'April abbreviation' ).' ', |
|
| 628 | - ' '._x( 'May', 'May abbreviation' ).' ', |
|
| 629 | - ' '._x( 'Jun', 'June abbreviation' ).' ', |
|
| 630 | - ' '._x( 'Jul', 'July abbreviation' ).' ', |
|
| 631 | - ' '._x( 'Aug', 'August abbreviation' ).' ', |
|
| 632 | - ' '._x( 'Sep', 'September abbreviation' ).' ', |
|
| 633 | - ' '._x( 'Oct', 'October abbreviation' ).' ', |
|
| 634 | - ' '._x( 'Nov', 'November abbreviation' ).' ', |
|
| 635 | - ' '._x( 'Dec', 'December abbreviation' ).' ', |
|
| 624 | + ' '._x('Jan', 'January abbreviation').' ', |
|
| 625 | + ' '._x('Feb', 'February abbreviation').' ', |
|
| 626 | + ' '._x('Mar', 'March abbreviation').' ', |
|
| 627 | + ' '._x('Apr', 'April abbreviation').' ', |
|
| 628 | + ' '._x('May', 'May abbreviation').' ', |
|
| 629 | + ' '._x('Jun', 'June abbreviation').' ', |
|
| 630 | + ' '._x('Jul', 'July abbreviation').' ', |
|
| 631 | + ' '._x('Aug', 'August abbreviation').' ', |
|
| 632 | + ' '._x('Sep', 'September abbreviation').' ', |
|
| 633 | + ' '._x('Oct', 'October abbreviation').' ', |
|
| 634 | + ' '._x('Nov', 'November abbreviation').' ', |
|
| 635 | + ' '._x('Dec', 'December abbreviation').' ', |
|
| 636 | 636 | ); |
| 637 | 637 | |
| 638 | - $date = str_replace($non_english_short_months,$english_short_months,$date); |
|
| 638 | + $date = str_replace($non_english_short_months, $english_short_months, $date); |
|
| 639 | 639 | |
| 640 | 640 | |
| 641 | 641 | return $date; |
@@ -707,7 +707,7 @@ discard block |
||
| 707 | 707 | * @return string Trimmed string. |
| 708 | 708 | */ |
| 709 | 709 | function geodir_excerpt($text, $length = 100, $options = array()) { |
| 710 | - if (!(int)$length > 0) { |
|
| 710 | + if (!(int) $length > 0) { |
|
| 711 | 711 | return $text; |
| 712 | 712 | } |
| 713 | 713 | $default = array( |
@@ -769,7 +769,7 @@ discard block |
||
| 769 | 769 | $length = $truncateLength; |
| 770 | 770 | |
| 771 | 771 | foreach ($openTags as $tag) { |
| 772 | - $suffix .= '</' . $tag . '>'; |
|
| 772 | + $suffix .= '</'.$tag.'>'; |
|
| 773 | 773 | } |
| 774 | 774 | } else { |
| 775 | 775 | if (geodir_strlen($text, $options) <= $length) { |
@@ -791,7 +791,7 @@ discard block |
||
| 791 | 791 | } |
| 792 | 792 | } |
| 793 | 793 | |
| 794 | - return $prefix . $result . $suffix; |
|
| 794 | + return $prefix.$result.$suffix; |
|
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | /** |
@@ -828,7 +828,7 @@ discard block |
||
| 828 | 828 | $pattern = '/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i'; |
| 829 | 829 | $replace = preg_replace_callback( |
| 830 | 830 | $pattern, |
| 831 | - function ($match) use ($strlen) { |
|
| 831 | + function($match) use ($strlen) { |
|
| 832 | 832 | $utf8 = html_entity_decode($match[0], ENT_HTML5 | ENT_QUOTES, 'UTF-8'); |
| 833 | 833 | |
| 834 | 834 | return str_repeat(' ', $strlen($utf8, 'UTF-8')); |
@@ -889,7 +889,7 @@ discard block |
||
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | if (empty($options['html'])) { |
| 892 | - return (string)$substr($text, $start, $length); |
|
| 892 | + return (string) $substr($text, $start, $length); |
|
| 893 | 893 | } |
| 894 | 894 | |
| 895 | 895 | $totalOffset = 0; |
@@ -914,7 +914,7 @@ discard block |
||
| 914 | 914 | |
| 915 | 915 | $len = geodir_strlen($part, $options); |
| 916 | 916 | if ($offset !== 0 || $totalLength + $len > $length) { |
| 917 | - if (strpos($part, '&') === 0 && preg_match($pattern, $part) && $part !== html_entity_decode($part, ENT_HTML5 | ENT_QUOTES, 'UTF-8') ) { |
|
| 917 | + if (strpos($part, '&') === 0 && preg_match($pattern, $part) && $part !== html_entity_decode($part, ENT_HTML5 | ENT_QUOTES, 'UTF-8')) { |
|
| 918 | 918 | // Entities cannot be passed substr. |
| 919 | 919 | continue; |
| 920 | 920 | } |
@@ -960,39 +960,39 @@ discard block |
||
| 960 | 960 | return ''; |
| 961 | 961 | } |
| 962 | 962 | |
| 963 | -function geodir_tool_restore_cpt_from_taxonomies(){ |
|
| 963 | +function geodir_tool_restore_cpt_from_taxonomies() { |
|
| 964 | 964 | |
| 965 | 965 | $cpts = get_option('geodir_post_types'); |
| 966 | 966 | |
| 967 | - if(!empty($cpts)){return;} |
|
| 967 | + if (!empty($cpts)) {return; } |
|
| 968 | 968 | |
| 969 | 969 | $taxonomies = get_option('geodir_taxonomies'); |
| 970 | 970 | |
| 971 | - if(empty($taxonomies)){return;} |
|
| 971 | + if (empty($taxonomies)) {return; } |
|
| 972 | 972 | |
| 973 | 973 | $cpts = array(); |
| 974 | 974 | |
| 975 | - foreach($taxonomies as $key => $val){ |
|
| 975 | + foreach ($taxonomies as $key => $val) { |
|
| 976 | 976 | |
| 977 | - if(strpos($val['listing_slug'], '/') === false) { |
|
| 978 | - $cpts[$val['object_type']] = array('cpt'=>$val['object_type'],'slug'=>$val['listing_slug']); |
|
| 977 | + if (strpos($val['listing_slug'], '/') === false) { |
|
| 978 | + $cpts[$val['object_type']] = array('cpt'=>$val['object_type'], 'slug'=>$val['listing_slug']); |
|
| 979 | 979 | } |
| 980 | 980 | |
| 981 | 981 | } |
| 982 | 982 | |
| 983 | - if(empty($cpts)){return;} |
|
| 983 | + if (empty($cpts)) {return; } |
|
| 984 | 984 | |
| 985 | 985 | |
| 986 | 986 | $cpts_restore = $cpts; |
| 987 | 987 | |
| 988 | - foreach($cpts as $cpt){ |
|
| 988 | + foreach ($cpts as $cpt) { |
|
| 989 | 989 | |
| 990 | 990 | |
| 991 | - $is_custom = $cpt['cpt']=='gd_place' ? 0 : 1; |
|
| 991 | + $is_custom = $cpt['cpt'] == 'gd_place' ? 0 : 1; |
|
| 992 | 992 | |
| 993 | - $cpts_restore[$cpt['cpt']] = array ( |
|
| 993 | + $cpts_restore[$cpt['cpt']] = array( |
|
| 994 | 994 | 'labels' => |
| 995 | - array ( |
|
| 995 | + array( |
|
| 996 | 996 | 'name' => $cpt['slug'], |
| 997 | 997 | 'singular_name' => $cpt['slug'], |
| 998 | 998 | 'add_new' => 'Add New', |
@@ -1020,14 +1020,14 @@ discard block |
||
| 1020 | 1020 | 'public' => true, |
| 1021 | 1021 | 'query_var' => true, |
| 1022 | 1022 | 'rewrite' => |
| 1023 | - array ( |
|
| 1023 | + array( |
|
| 1024 | 1024 | 'slug' => $cpt['slug'], |
| 1025 | 1025 | 'with_front' => false, |
| 1026 | 1026 | 'hierarchical' => true, |
| 1027 | 1027 | 'feeds' => true, |
| 1028 | 1028 | ), |
| 1029 | 1029 | 'supports' => |
| 1030 | - array ( |
|
| 1030 | + array( |
|
| 1031 | 1031 | 0 => 'title', |
| 1032 | 1032 | 1 => 'editor', |
| 1033 | 1033 | 2 => 'author', |
@@ -1037,14 +1037,14 @@ discard block |
||
| 1037 | 1037 | 6 => 'comments', |
| 1038 | 1038 | ), |
| 1039 | 1039 | 'taxonomies' => |
| 1040 | - array ( |
|
| 1040 | + array( |
|
| 1041 | 1041 | 0 => $cpt['cpt'].'category', |
| 1042 | 1042 | 1 => $cpt['cpt'].'_tags', |
| 1043 | 1043 | ), |
| 1044 | 1044 | 'is_custom' => $is_custom, |
| 1045 | 1045 | 'listing_order' => '1', |
| 1046 | 1046 | 'seo' => |
| 1047 | - array ( |
|
| 1047 | + array( |
|
| 1048 | 1048 | 'meta_keyword' => '', |
| 1049 | 1049 | 'meta_description' => '', |
| 1050 | 1050 | ), |
@@ -1056,6 +1056,6 @@ discard block |
||
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 1058 | 1058 | |
| 1059 | - update_option('geodir_post_types',$cpts_restore); |
|
| 1059 | + update_option('geodir_post_types', $cpts_restore); |
|
| 1060 | 1060 | |
| 1061 | 1061 | } |