| @@ -2054,6 +2054,11 @@ discard block | ||
| 2054 | 2054 | } | 
| 2055 | 2055 | |
| 2056 | 2056 | //update meta | 
| 2057 | + | |
| 2058 | + /** | |
| 2059 | + * @param string $term_id | |
| 2060 | + * @param string $key | |
| 2061 | + */ | |
| 2057 | 2062 | public function update_tax_meta($term_id, $key, $value, $post_type = '') | 
| 2058 | 2063 |          { | 
| 2059 | 2064 | |
| @@ -2095,6 +2100,12 @@ discard block | ||
| 2095 | 2100 | |
| 2096 | 2101 | //get term meta field | 
| 2097 | 2102 |  if (!function_exists('get_tax_meta')) { | 
| 2103 | + | |
| 2104 | + /** | |
| 2105 | + * @param string $key | |
| 2106 | + * | |
| 2107 | + * @return string | |
| 2108 | + */ | |
| 2098 | 2109 | function get_tax_meta($term_id, $key, $multi = false, $post_type = '') | 
| 2099 | 2110 |      { | 
| 2100 | 2111 | |
| @@ -2139,6 +2150,10 @@ discard block | ||
| 2139 | 2150 | |
| 2140 | 2151 | //update meta | 
| 2141 | 2152 |  if (!function_exists('update_tax_meta')) { | 
| 2153 | + | |
| 2154 | + /** | |
| 2155 | + * @param string $key | |
| 2156 | + */ | |
| 2142 | 2157 | function update_tax_meta($term_id, $key, $value, $post_type = '') | 
| 2143 | 2158 |      { | 
| 2144 | 2159 | |
| @@ -102,8 +102,9 @@ discard block | ||
| 102 | 102 |          { | 
| 103 | 103 | |
| 104 | 104 | // If we are not in admin area exit. | 
| 105 | - if (!is_admin()) | |
| 106 | - return; | |
| 105 | +            if (!is_admin()) { | |
| 106 | + return; | |
| 107 | + } | |
| 107 | 108 | |
| 108 | 109 | // Assign meta box values to local variables and add it's missed values. | 
| 109 | 110 | $this->_meta_box = $meta_box; | 
| @@ -111,15 +112,15 @@ discard block | ||
| 111 | 112 | $this->_fields = &$this->_meta_box['fields']; | 
| 112 | 113 | $this->_Local_images = (isset($meta_box['local_images'])) ? true : false; | 
| 113 | 114 | $this->add_missed_values(); | 
| 114 | - if (isset($meta_box['use_with_theme'])) | |
| 115 | -                if ($meta_box['use_with_theme'] === true) { | |
| 115 | +            if (isset($meta_box['use_with_theme'])) { | |
| 116 | +                            if ($meta_box['use_with_theme'] === true) { | |
| 116 | 117 | $this->SelfPath = get_stylesheet_directory_uri() . '/library/cat-meta'; | 
| 118 | + } | |
| 117 | 119 |                  } elseif ($meta_box['use_with_theme'] === false) { | 
| 118 | 120 |                      $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__))); | 
| 119 | 121 |                  } else { | 
| 120 | 122 | $this->SelfPath = $meta_box['use_with_theme']; | 
| 121 | - } | |
| 122 | -            else { | |
| 123 | +                } else { | |
| 123 | 124 |                  $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__))); | 
| 124 | 125 | } | 
| 125 | 126 | |
| @@ -190,8 +191,9 @@ discard block | ||
| 190 | 191 |          { | 
| 191 | 192 | |
| 192 | 193 | // Check if the field is an image or file. If not, return. | 
| 193 | -            if (!$this->has_field('image') && !$this->has_field('file')) | |
| 194 | - return; | |
| 194 | +            if (!$this->has_field('image') && !$this->has_field('file')) { | |
| 195 | + return; | |
| 196 | + } | |
| 195 | 197 | |
| 196 | 198 | |
| 197 | 199 |              add_action('wp_enqueue_scripts', array(&$this, 'enqueue_tax_meta_scripts'), 100); | 
| @@ -235,8 +237,9 @@ discard block | ||
| 235 | 237 |          { | 
| 236 | 238 | |
| 237 | 239 | // If post variables are empty, return. | 
| 238 | - if (!isset($_POST['at-insert']) || empty($_POST['attachments'])) | |
| 239 | - return; | |
| 240 | +            if (!isset($_POST['at-insert']) || empty($_POST['attachments'])) { | |
| 241 | + return; | |
| 242 | + } | |
| 240 | 243 | |
| 241 | 244 | // Security Check | 
| 242 | 245 |              check_admin_referer('media-form'); | 
| @@ -256,8 +259,9 @@ discard block | ||
| 256 | 259 | $attachment = stripslashes_deep($attachment); | 
| 257 | 260 | |
| 258 | 261 | // If not selected or url is empty, continue in loop. | 
| 259 | - if (empty($attachment['selected']) || empty($attachment['url'])) | |
| 260 | - continue; | |
| 262 | +                if (empty($attachment['selected']) || empty($attachment['url'])) { | |
| 263 | + continue; | |
| 264 | + } | |
| 261 | 265 | |
| 262 | 266 |                  $li = "<li id='item_{$attachment_id}'>"; | 
| 263 | 267 |                  $li .= "<img src='{$attachment['url']}' alt='image_{$attachment_id}' />"; | 
| @@ -308,13 +312,15 @@ discard block | ||
| 308 | 312 | |
| 309 | 313 | |
| 310 | 314 | // If data is not set, die. | 
| 311 | - if (!isset($_POST['data'])) | |
| 312 | - die(); | |
| 315 | +            if (!isset($_POST['data'])) { | |
| 316 | + die(); | |
| 317 | + } | |
| 313 | 318 | |
| 314 | 319 |              list($nonce, $term_id, $key, $attach_id) = explode('|', $_POST['data']); | 
| 315 | 320 | |
| 316 | - if (!wp_verify_nonce($nonce, 'at_ajax_delete')) | |
| 317 | -                die('1'); | |
| 321 | +            if (!wp_verify_nonce($nonce, 'at_ajax_delete')) { | |
| 322 | +                            die('1'); | |
| 323 | + } | |
| 318 | 324 | |
| 319 | 325 | $this->delete_tax_meta($term_id, $key, $attach_id); | 
| 320 | 326 | |
| @@ -336,8 +342,9 @@ discard block | ||
| 336 | 342 | $ok = false; | 
| 337 | 343 |              if (strpos($field_id, '[') === false) { | 
| 338 | 344 |                  check_admin_referer("at-delete-mupload_" . urldecode($field_id)); | 
| 339 | - if ($term_id > 0) | |
| 340 | - $this->delete_tax_meta($term_id, $field_id); | |
| 345 | +                if ($term_id > 0) { | |
| 346 | + $this->delete_tax_meta($term_id, $field_id); | |
| 347 | + } | |
| 341 | 348 | //$ok = wp_delete_attachment( $attachment_id ); | 
| 342 | 349 | $ok = 1; | 
| 343 | 350 |              } else { | 
| @@ -349,8 +356,9 @@ discard block | ||
| 349 | 356 | $saved = $this->get_tax_meta($term_id, $f[0], true); | 
| 350 | 357 |                  if (isset($saved[$f[1]][$f[2]])) { | 
| 351 | 358 | unset($saved[$f[1]][$f[2]]); | 
| 352 | - if ($term_id > 0) | |
| 353 | - update_post_meta($term_id, $f[0], $saved); | |
| 359 | +                    if ($term_id > 0) { | |
| 360 | + update_post_meta($term_id, $f[0], $saved); | |
| 361 | + } | |
| 354 | 362 | //$ok = wp_delete_attachment( $attachment_id ); | 
| 355 | 363 | $ok = 1; | 
| 356 | 364 | } | 
| @@ -375,13 +383,15 @@ discard block | ||
| 375 | 383 | public function reorder_images() | 
| 376 | 384 |          { | 
| 377 | 385 | |
| 378 | - if (!isset($_POST['data'])) | |
| 379 | - die(); | |
| 386 | +            if (!isset($_POST['data'])) { | |
| 387 | + die(); | |
| 388 | + } | |
| 380 | 389 | |
| 381 | 390 |              list($order, $term_id, $key, $nonce) = explode('|', $_POST['data']); | 
| 382 | 391 | |
| 383 | - if (!wp_verify_nonce($nonce, 'at_ajax_reorder')) | |
| 384 | -                die('1'); | |
| 392 | +            if (!wp_verify_nonce($nonce, 'at_ajax_reorder')) { | |
| 393 | +                            die('1'); | |
| 394 | + } | |
| 385 | 395 | |
| 386 | 396 | parse_str($order, $items); | 
| 387 | 397 | $items = $items['item']; | 
| @@ -513,8 +523,9 @@ discard block | ||
| 513 | 523 |              foreach ($this->_fields as $field) { | 
| 514 | 524 | $meta = $this->get_tax_meta($term_id, $field['id'], !$field['multiple']); | 
| 515 | 525 | $meta = ($meta !== '') ? $meta : $field['std']; | 
| 516 | -                if ('image' != $field['type'] && $field['type'] != 'repeater') | |
| 517 | -                    $meta = is_array($meta) ? array_map('esc_attr', $meta) : esc_attr($meta); | |
| 526 | +                if ('image' != $field['type'] && $field['type'] != 'repeater') { | |
| 527 | +                                    $meta = is_array($meta) ? array_map('esc_attr', $meta) : esc_attr($meta); | |
| 528 | + } | |
| 518 | 529 | |
| 519 | 530 |                  if ($field['validate_func']) { | 
| 520 | 531 | echo '<tr class="form-field form-required ' . $field['style'] . '">'; | 
| @@ -560,8 +571,9 @@ discard block | ||
| 560 | 571 | $id = $field['id'] . '[' . $c . '][' . $f['id'] . ']'; | 
| 561 | 572 | $m = $me[$f['id']]; | 
| 562 | 573 | $m = ($m !== '') ? $m : $f['std']; | 
| 563 | -                        if ('image' != $f['type'] && $f['type'] != 'repeater') | |
| 564 | -                            $m = is_array($m) ? array_map('esc_attr', $m) : esc_attr($m); | |
| 574 | +                        if ('image' != $f['type'] && $f['type'] != 'repeater') { | |
| 575 | +                                                    $m = is_array($m) ? array_map('esc_attr', $m) : esc_attr($m); | |
| 576 | + } | |
| 565 | 577 | //set new id for field in array format | 
| 566 | 578 | $f['id'] = $id; | 
| 567 | 579 |                          if (!$field['inline']) { | 
| @@ -802,8 +814,9 @@ discard block | ||
| 802 | 814 | public function show_field_select($field, $meta) | 
| 803 | 815 |          { | 
| 804 | 816 | |
| 805 | - if (!is_array($meta)) | |
| 806 | - $meta = (array)$meta; | |
| 817 | +            if (!is_array($meta)) { | |
| 818 | + $meta = (array)$meta; | |
| 819 | + } | |
| 807 | 820 | |
| 808 | 821 | $this->show_field_begin($field, $meta); | 
| 809 | 822 |              echo "<select class='at-select' name='{$field['id']}" . ($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'") . ">"; | 
| @@ -826,8 +839,9 @@ discard block | ||
| 826 | 839 | public function show_field_radio($field, $meta) | 
| 827 | 840 |          { | 
| 828 | 841 | |
| 829 | - if (!is_array($meta)) | |
| 830 | - $meta = (array)$meta; | |
| 842 | +            if (!is_array($meta)) { | |
| 843 | + $meta = (array)$meta; | |
| 844 | + } | |
| 831 | 845 | |
| 832 | 846 | $this->show_field_begin($field, $meta); | 
| 833 | 847 |              foreach ($field['options'] as $key => $value) { | 
| @@ -889,8 +903,9 @@ discard block | ||
| 889 | 903 | |
| 890 | 904 | global $post; | 
| 891 | 905 | |
| 892 | - if (!is_array($meta)) | |
| 893 | - $meta = (array)$meta; | |
| 906 | +            if (!is_array($meta)) { | |
| 907 | + $meta = (array)$meta; | |
| 908 | + } | |
| 894 | 909 | |
| 895 | 910 | $this->show_field_begin($field, $meta); | 
| 896 | 911 |              echo "{$field['desc']}<br />"; | 
| @@ -934,8 +949,9 @@ discard block | ||
| 934 | 949 | $this->show_field_begin($field, $meta); | 
| 935 | 950 |              $html = wp_nonce_field("at-delete-mupload_{$field['id']}", "nonce-delete-mupload_" . $field['id'], false, false); | 
| 936 | 951 |              if (is_array($meta)) { | 
| 937 | - if (isset($meta[0]) && is_array($meta[0])) | |
| 938 | - $meta = $meta[0]; | |
| 952 | +                if (isset($meta[0]) && is_array($meta[0])) { | |
| 953 | + $meta = $meta[0]; | |
| 954 | + } | |
| 939 | 955 | } | 
| 940 | 956 | |
| 941 | 957 | $uploads = wp_upload_dir(); | 
| @@ -947,8 +963,9 @@ discard block | ||
| 947 | 963 | //print_r($uploads); | 
| 948 | 964 | //print_r($file_info); | 
| 949 | 965 | |
| 950 | - if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') | |
| 951 | - $sub_dir = $file_info['dirname']; | |
| 966 | +                if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') { | |
| 967 | + $sub_dir = $file_info['dirname']; | |
| 968 | + } | |
| 952 | 969 | |
| 953 | 970 | $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs | 
| 954 | 971 | $uploads_baseurl = $uploads['baseurl']; | 
| @@ -988,8 +1005,9 @@ discard block | ||
| 988 | 1005 | public function show_field_color($field, $meta) | 
| 989 | 1006 |          { | 
| 990 | 1007 | |
| 991 | - if (empty($meta)) | |
| 992 | - $meta = '#'; | |
| 1008 | +            if (empty($meta)) { | |
| 1009 | + $meta = '#'; | |
| 1010 | + } | |
| 993 | 1011 | |
| 994 | 1012 | $this->show_field_begin($field, $meta); | 
| 995 | 1013 | |
| @@ -1012,8 +1030,9 @@ discard block | ||
| 1012 | 1030 | public function show_field_checkbox_list($field, $meta) | 
| 1013 | 1031 |          { | 
| 1014 | 1032 | |
| 1015 | - if (!is_array($meta)) | |
| 1016 | - $meta = (array)$meta; | |
| 1033 | +            if (!is_array($meta)) { | |
| 1034 | + $meta = (array)$meta; | |
| 1035 | + } | |
| 1017 | 1036 | |
| 1018 | 1037 | $this->show_field_begin($field, $meta); | 
| 1019 | 1038 | |
| @@ -1073,7 +1092,9 @@ discard block | ||
| 1073 | 1092 |          { | 
| 1074 | 1093 | global $post; | 
| 1075 | 1094 | |
| 1076 | - if (!is_array($meta)) $meta = (array)$meta; | |
| 1095 | +            if (!is_array($meta)) { | |
| 1096 | + $meta = (array)$meta; | |
| 1097 | + } | |
| 1077 | 1098 | $this->show_field_begin($field, $meta); | 
| 1078 | 1099 | $options = $field['options']; | 
| 1079 | 1100 | $posts = get_posts($options['args']); | 
| @@ -1111,7 +1132,9 @@ discard block | ||
| 1111 | 1132 |          { | 
| 1112 | 1133 | global $post; | 
| 1113 | 1134 | |
| 1114 | - if (!is_array($meta)) $meta = (array)$meta; | |
| 1135 | +            if (!is_array($meta)) { | |
| 1136 | + $meta = (array)$meta; | |
| 1137 | + } | |
| 1115 | 1138 | $this->show_field_begin($field, $meta); | 
| 1116 | 1139 | $options = $field['options']; | 
| 1117 | 1140 | $terms = get_terms($options['taxonomy'], $options['args']); | 
| @@ -1145,17 +1168,20 @@ discard block | ||
| 1145 | 1168 |          { | 
| 1146 | 1169 | |
| 1147 | 1170 | $taxnow = ''; | 
| 1148 | - if (isset($_POST['taxonomy'])) | |
| 1149 | - $taxnow = $_POST['taxonomy']; | |
| 1171 | +            if (isset($_POST['taxonomy'])) { | |
| 1172 | + $taxnow = $_POST['taxonomy']; | |
| 1173 | + } | |
| 1150 | 1174 | |
| 1151 | 1175 | if (!isset($term_id) // Check Revision | 
| 1152 | 1176 | || (!in_array($taxnow, $this->_meta_box['pages'])) // Check if current taxonomy type is supported. | 
| 1153 | 1177 | || (!check_admin_referer(basename(__FILE__), 'tax_meta_class_nonce')) // Check nonce - Security | 
| 1154 | 1178 |                  || (!current_user_can('manage_categories')) | 
| 1155 | - ) // Check permission | |
| 1179 | +            ) { | |
| 1180 | + // Check permission | |
| 1156 | 1181 |              { | 
| 1157 | 1182 | return $term_id; | 
| 1158 | 1183 | } | 
| 1184 | + } | |
| 1159 | 1185 | |
| 1160 | 1186 | |
| 1161 | 1187 |              foreach ($this->_fields as $field) { | 
| @@ -1249,8 +1275,9 @@ discard block | ||
| 1249 | 1275 |          { | 
| 1250 | 1276 | $name = $field['id']; | 
| 1251 | 1277 | $this->delete_tax_meta($term_id, $name); | 
| 1252 | - if ($new === '' || $new === array()) | |
| 1253 | - return; | |
| 1278 | +            if ($new === '' || $new === array()) { | |
| 1279 | + return; | |
| 1280 | + } | |
| 1254 | 1281 | |
| 1255 | 1282 | $this->update_tax_meta($term_id, $name, $new); | 
| 1256 | 1283 | } | 
| @@ -1270,8 +1297,9 @@ discard block | ||
| 1270 | 1297 | $name = $field['id']; | 
| 1271 | 1298 | |
| 1272 | 1299 | $this->delete_tax_meta($term_id, $name); | 
| 1273 | - if ($new === '' || $new === array() || $new['id'] == '' || $new['src'] == '') | |
| 1274 | - return; | |
| 1300 | +            if ($new === '' || $new === array() || $new['id'] == '' || $new['src'] == '') { | |
| 1301 | + return; | |
| 1302 | + } | |
| 1275 | 1303 | |
| 1276 | 1304 | $this->update_tax_meta($term_id, $name, $new); | 
| 1277 | 1305 | } | 
| @@ -1318,8 +1346,9 @@ discard block | ||
| 1318 | 1346 | break; | 
| 1319 | 1347 | } | 
| 1320 | 1348 | } | 
| 1321 | - if (!$this->is_array_empty($n)) | |
| 1322 | - $temp[] = $n; | |
| 1349 | +                    if (!$this->is_array_empty($n)) { | |
| 1350 | + $temp[] = $n; | |
| 1351 | + } | |
| 1323 | 1352 | } | 
| 1324 | 1353 |                  if (isset($temp) && count($temp) > 0 && !$this->is_array_empty($temp)) { | 
| 1325 | 1354 | $this->update_tax_meta($term_id, $field['id'], $temp); | 
| @@ -1347,14 +1376,16 @@ discard block | ||
| 1347 | 1376 |          { | 
| 1348 | 1377 | |
| 1349 | 1378 | $name = $field['id']; | 
| 1350 | - if (empty($_FILES[$name])) | |
| 1351 | - return; | |
| 1379 | +            if (empty($_FILES[$name])) { | |
| 1380 | + return; | |
| 1381 | + } | |
| 1352 | 1382 | $this->fix_file_array($_FILES[$name]); | 
| 1353 | 1383 |              foreach ($_FILES[$name] as $position => $fileitem) { | 
| 1354 | 1384 | |
| 1355 | 1385 |                  $file = wp_handle_upload($fileitem, array('test_form' => false)); | 
| 1356 | - if (empty($file['file'])) | |
| 1357 | - continue; | |
| 1386 | +                if (empty($file['file'])) { | |
| 1387 | + continue; | |
| 1388 | + } | |
| 1358 | 1389 | $filename = $file['file']; | 
| 1359 | 1390 | |
| 1360 | 1391 | $attachment = array( | 
| @@ -1392,14 +1423,16 @@ discard block | ||
| 1392 | 1423 |          { | 
| 1393 | 1424 | |
| 1394 | 1425 | $name = $field['id']; | 
| 1395 | - if (empty($_FILES[$name])) | |
| 1396 | - return; | |
| 1426 | +            if (empty($_FILES[$name])) { | |
| 1427 | + return; | |
| 1428 | + } | |
| 1397 | 1429 | $this->fix_file_array($_FILES[$name]); | 
| 1398 | 1430 |              foreach ($_FILES[$name] as $position => $fileitem) { | 
| 1399 | 1431 | |
| 1400 | 1432 |                  $file = wp_handle_upload($fileitem, array('test_form' => false)); | 
| 1401 | - if (empty($file['file'])) | |
| 1402 | - continue; | |
| 1433 | +                if (empty($file['file'])) { | |
| 1434 | + continue; | |
| 1435 | + } | |
| 1403 | 1436 | $filename = $file['file']; | 
| 1404 | 1437 | |
| 1405 | 1438 | $attachment = array( | 
| @@ -1454,8 +1487,9 @@ discard block | ||
| 1454 | 1487 |          { | 
| 1455 | 1488 |              if(is_array($this->_fields)) { | 
| 1456 | 1489 |                  foreach ($this->_fields as $field) { | 
| 1457 | - if ($type == $field['type']) | |
| 1458 | - return true; | |
| 1490 | +                    if ($type == $field['type']) { | |
| 1491 | + return true; | |
| 1492 | + } | |
| 1459 | 1493 | } | 
| 1460 | 1494 | } | 
| 1461 | 1495 | return false; | 
| @@ -1993,18 +2027,21 @@ discard block | ||
| 1993 | 2027 | */ | 
| 1994 | 2028 | public function is_array_empty($array) | 
| 1995 | 2029 |          { | 
| 1996 | - if (!is_array($array)) | |
| 1997 | - return true; | |
| 2030 | +            if (!is_array($array)) { | |
| 2031 | + return true; | |
| 2032 | + } | |
| 1998 | 2033 | |
| 1999 | 2034 |              foreach ($array as $a) { | 
| 2000 | 2035 |                  if (is_array($a)) { | 
| 2001 | 2036 |                      foreach ($a as $sub_a) { | 
| 2002 | - if (!empty($sub_a) && $sub_a != '') | |
| 2003 | - return false; | |
| 2037 | +                        if (!empty($sub_a) && $sub_a != '') { | |
| 2038 | + return false; | |
| 2039 | + } | |
| 2004 | 2040 | } | 
| 2005 | 2041 |                  } else { | 
| 2006 | - if (!empty($a) && $a != '') | |
| 2007 | - return false; | |
| 2042 | +                    if (!empty($a) && $a != '') { | |
| 2043 | + return false; | |
| 2044 | + } | |
| 2008 | 2045 | } | 
| 2009 | 2046 | } | 
| 2010 | 2047 | return true; | 
| @@ -28,260 +28,260 @@ discard block | ||
| 28 | 28 | |
| 29 | 29 |  if (!class_exists('Tax_Meta_Class')) : | 
| 30 | 30 | |
| 31 | - /** | |
| 32 | - * All Types Meta Box class. | |
| 33 | - * | |
| 34 | - * @package All Types Meta Box | |
| 35 | - * @since 1.0 | |
| 36 | - * | |
| 37 | - * @todo Nothing. | |
| 38 | - */ | |
| 39 | - | |
| 40 | - | |
| 41 | - class Tax_Meta_Class | |
| 42 | -    { | |
| 43 | - | |
| 44 | - /** | |
| 45 | - * Holds meta box object | |
| 46 | - * | |
| 47 | - * @var object | |
| 48 | - * @access protected | |
| 49 | - */ | |
| 50 | - protected $_meta_box; | |
| 51 | - | |
| 52 | - /** | |
| 53 | - * Holds meta box fields. | |
| 54 | - * | |
| 55 | - * @var array | |
| 56 | - * @access protected | |
| 57 | - */ | |
| 58 | - protected $_prefix; | |
| 59 | - | |
| 60 | - /** | |
| 61 | - * Holds Prefix for meta box fields. | |
| 62 | - * | |
| 63 | - * @var array | |
| 64 | - * @access protected | |
| 65 | - */ | |
| 66 | - protected $_fields; | |
| 67 | - | |
| 68 | - /** | |
| 69 | - * Use local images. | |
| 70 | - * | |
| 71 | - * @var bool | |
| 72 | - * @access protected | |
| 73 | - */ | |
| 74 | - protected $_Local_images; | |
| 75 | - | |
| 76 | - /** | |
| 77 | - * What form is this? edit or new term. | |
| 78 | - * | |
| 79 | - * @var string | |
| 80 | - * @access protected | |
| 81 | - * $since 1.0 | |
| 82 | - */ | |
| 83 | - protected $_form_type; | |
| 84 | - /** | |
| 85 | - * SelfPath to allow themes as well as plugins. | |
| 86 | - * | |
| 87 | - * @var string | |
| 88 | - * @access protected | |
| 89 | - * $since 1.0 | |
| 90 | - */ | |
| 91 | - protected $SelfPath; | |
| 92 | - | |
| 93 | - /** | |
| 94 | - * Constructor | |
| 95 | - * | |
| 96 | - * @since 1.0 | |
| 97 | - * @access public | |
| 98 | - * | |
| 99 | - * @param array $meta_box | |
| 100 | - */ | |
| 101 | - public function __construct($meta_box) | |
| 102 | -        { | |
| 103 | - | |
| 104 | - // If we are not in admin area exit. | |
| 105 | - if (!is_admin()) | |
| 106 | - return; | |
| 107 | - | |
| 108 | - // Assign meta box values to local variables and add it's missed values. | |
| 109 | - $this->_meta_box = $meta_box; | |
| 110 | - $this->_prefix = (isset($meta_box['prefix'])) ? $meta_box['prefix'] : ''; | |
| 111 | - $this->_fields = &$this->_meta_box['fields']; | |
| 112 | - $this->_Local_images = (isset($meta_box['local_images'])) ? true : false; | |
| 113 | - $this->add_missed_values(); | |
| 114 | - if (isset($meta_box['use_with_theme'])) | |
| 115 | -                if ($meta_box['use_with_theme'] === true) { | |
| 116 | - $this->SelfPath = get_stylesheet_directory_uri() . '/library/cat-meta'; | |
| 117 | -                } elseif ($meta_box['use_with_theme'] === false) { | |
| 118 | -                    $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__))); | |
| 119 | -                } else { | |
| 120 | - $this->SelfPath = $meta_box['use_with_theme']; | |
| 121 | - } | |
| 122 | -            else { | |
| 123 | -                $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__))); | |
| 124 | - } | |
| 125 | - | |
| 126 | - | |
| 127 | - // Add Actions | |
| 128 | -            add_action('admin_init', array(&$this, 'add')); | |
| 129 | - | |
| 130 | - // Check for special fields and add needed actions for them. | |
| 131 | - $this->check_field_upload(); | |
| 132 | - $this->check_field_color(); | |
| 133 | - $this->check_field_date(); | |
| 134 | - $this->check_field_time(); | |
| 135 | - | |
| 136 | - // Load common js, css files | |
| 137 | - // Must enqueue for all pages as we need js for the media upload, too. | |
| 138 | -            add_action('admin_print_styles', array(&$this, 'load_scripts_styles')); | |
| 139 | - | |
| 140 | - } | |
| 141 | - | |
| 142 | - /** | |
| 143 | - * Load all Javascript and CSS | |
| 144 | - * | |
| 145 | - * @since 1.0 | |
| 146 | - * @access public | |
| 147 | - */ | |
| 148 | - public function load_scripts_styles() | |
| 149 | -        { | |
| 150 | - | |
| 151 | - // Get Plugin Path | |
| 152 | - $plugin_path = $this->SelfPath; | |
| 153 | - //only load styles and js when needed | |
| 154 | - /* | |
| 31 | + /** | |
| 32 | + * All Types Meta Box class. | |
| 33 | + * | |
| 34 | + * @package All Types Meta Box | |
| 35 | + * @since 1.0 | |
| 36 | + * | |
| 37 | + * @todo Nothing. | |
| 38 | + */ | |
| 39 | + | |
| 40 | + | |
| 41 | + class Tax_Meta_Class | |
| 42 | +	{ | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * Holds meta box object | |
| 46 | + * | |
| 47 | + * @var object | |
| 48 | + * @access protected | |
| 49 | + */ | |
| 50 | + protected $_meta_box; | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * Holds meta box fields. | |
| 54 | + * | |
| 55 | + * @var array | |
| 56 | + * @access protected | |
| 57 | + */ | |
| 58 | + protected $_prefix; | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * Holds Prefix for meta box fields. | |
| 62 | + * | |
| 63 | + * @var array | |
| 64 | + * @access protected | |
| 65 | + */ | |
| 66 | + protected $_fields; | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * Use local images. | |
| 70 | + * | |
| 71 | + * @var bool | |
| 72 | + * @access protected | |
| 73 | + */ | |
| 74 | + protected $_Local_images; | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * What form is this? edit or new term. | |
| 78 | + * | |
| 79 | + * @var string | |
| 80 | + * @access protected | |
| 81 | + * $since 1.0 | |
| 82 | + */ | |
| 83 | + protected $_form_type; | |
| 84 | + /** | |
| 85 | + * SelfPath to allow themes as well as plugins. | |
| 86 | + * | |
| 87 | + * @var string | |
| 88 | + * @access protected | |
| 89 | + * $since 1.0 | |
| 90 | + */ | |
| 91 | + protected $SelfPath; | |
| 92 | + | |
| 93 | + /** | |
| 94 | + * Constructor | |
| 95 | + * | |
| 96 | + * @since 1.0 | |
| 97 | + * @access public | |
| 98 | + * | |
| 99 | + * @param array $meta_box | |
| 100 | + */ | |
| 101 | + public function __construct($meta_box) | |
| 102 | +		{ | |
| 103 | + | |
| 104 | + // If we are not in admin area exit. | |
| 105 | + if (!is_admin()) | |
| 106 | + return; | |
| 107 | + | |
| 108 | + // Assign meta box values to local variables and add it's missed values. | |
| 109 | + $this->_meta_box = $meta_box; | |
| 110 | + $this->_prefix = (isset($meta_box['prefix'])) ? $meta_box['prefix'] : ''; | |
| 111 | + $this->_fields = &$this->_meta_box['fields']; | |
| 112 | + $this->_Local_images = (isset($meta_box['local_images'])) ? true : false; | |
| 113 | + $this->add_missed_values(); | |
| 114 | + if (isset($meta_box['use_with_theme'])) | |
| 115 | +				if ($meta_box['use_with_theme'] === true) { | |
| 116 | + $this->SelfPath = get_stylesheet_directory_uri() . '/library/cat-meta'; | |
| 117 | +				} elseif ($meta_box['use_with_theme'] === false) { | |
| 118 | +					$this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__))); | |
| 119 | +				} else { | |
| 120 | + $this->SelfPath = $meta_box['use_with_theme']; | |
| 121 | + } | |
| 122 | +			else { | |
| 123 | +				$this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__))); | |
| 124 | + } | |
| 125 | + | |
| 126 | + | |
| 127 | + // Add Actions | |
| 128 | +			add_action('admin_init', array(&$this, 'add')); | |
| 129 | + | |
| 130 | + // Check for special fields and add needed actions for them. | |
| 131 | + $this->check_field_upload(); | |
| 132 | + $this->check_field_color(); | |
| 133 | + $this->check_field_date(); | |
| 134 | + $this->check_field_time(); | |
| 135 | + | |
| 136 | + // Load common js, css files | |
| 137 | + // Must enqueue for all pages as we need js for the media upload, too. | |
| 138 | +			add_action('admin_print_styles', array(&$this, 'load_scripts_styles')); | |
| 139 | + | |
| 140 | + } | |
| 141 | + | |
| 142 | + /** | |
| 143 | + * Load all Javascript and CSS | |
| 144 | + * | |
| 145 | + * @since 1.0 | |
| 146 | + * @access public | |
| 147 | + */ | |
| 148 | + public function load_scripts_styles() | |
| 149 | +		{ | |
| 150 | + | |
| 151 | + // Get Plugin Path | |
| 152 | + $plugin_path = $this->SelfPath; | |
| 153 | + //only load styles and js when needed | |
| 154 | + /* | |
| 155 | 155 | * since 1.0 | 
| 156 | 156 | */ | 
| 157 | - $taxnow = isset($_REQUEST['taxonomy']) ? $_REQUEST['taxonomy'] : ''; | |
| 158 | - | |
| 159 | -            if (!empty($this->_meta_box['pages'])) { | |
| 160 | -                if (in_array($taxnow, $this->_meta_box['pages'])) { | |
| 161 | - // Enqueue Meta Box Style | |
| 162 | - //wp_enqueue_style( 'tax-meta-clss', $plugin_path . '/css/Tax-meta-class.css' ); | |
| 163 | - // Enqueue Meta Box Scripts | |
| 164 | - //wp_enqueue_script( 'tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array( 'jquery' ), null, true ); | |
| 165 | - | |
| 166 | - } | |
| 167 | - } | |
| 168 | - | |
| 169 | - } | |
| 170 | - | |
| 171 | - /** | |
| 172 | - * Check the Field Upload, Add needed Actions | |
| 173 | - * | |
| 174 | - * @since 1.0 | |
| 175 | - * @access public | |
| 176 | - */ | |
| 177 | - public function enqueue_tax_meta_scripts() | |
| 178 | -        { | |
| 179 | - // Make upload feature work event when custom post type doesn't support 'editor' | |
| 180 | -            wp_enqueue_script('media-upload'); | |
| 181 | -            wp_enqueue_script('thickbox'); | |
| 182 | - add_thickbox(); | |
| 183 | -            wp_enqueue_script('jquery-ui-core'); | |
| 184 | -            wp_enqueue_script('jquery-ui-sortable'); | |
| 185 | - | |
| 186 | - | |
| 187 | - } | |
| 188 | - | |
| 189 | - public function check_field_upload() | |
| 190 | -        { | |
| 191 | - | |
| 192 | - // Check if the field is an image or file. If not, return. | |
| 193 | -            if (!$this->has_field('image') && !$this->has_field('file')) | |
| 194 | - return; | |
| 195 | - | |
| 196 | - | |
| 197 | -            add_action('wp_enqueue_scripts', array(&$this, 'enqueue_tax_meta_scripts'), 100); | |
| 198 | - | |
| 199 | - // Add data encoding type for file uploading. | |
| 200 | -            add_action('post_edit_form_tag', array(&$this, 'add_enctype')); | |
| 201 | - | |
| 202 | - | |
| 203 | - // Add filters for media upload. | |
| 204 | -            add_filter('media_upload_gallery', array(&$this, 'insert_images')); | |
| 205 | -            add_filter('media_upload_library', array(&$this, 'insert_images')); | |
| 206 | -            add_filter('media_upload_image', array(&$this, 'insert_images')); | |
| 207 | - | |
| 208 | - // Delete all attachments when delete custom post type. | |
| 209 | -            add_action('wp_ajax_at_delete_file', array(&$this, 'delete_file')); | |
| 210 | -            add_action('wp_ajax_at_reorder_images', array(&$this, 'reorder_images')); | |
| 211 | - // Delete file via Ajax | |
| 212 | -            add_action('wp_ajax_at_delete_mupload', array($this, 'wp_ajax_delete_image')); | |
| 213 | - } | |
| 214 | - | |
| 215 | - /** | |
| 216 | - * Add data encoding type for file uploading | |
| 217 | - * | |
| 218 | - * @since 1.0 | |
| 219 | - * @access public | |
| 220 | - */ | |
| 221 | - public function add_enctype() | |
| 222 | -        { | |
| 223 | - echo ' enctype="multipart/form-data"'; | |
| 224 | - } | |
| 225 | - | |
| 226 | - /** | |
| 227 | - * Process images added to meta field. | |
| 228 | - * | |
| 229 | - * Modified from Faster Image Insert plugin. | |
| 230 | - * | |
| 231 | - * @return void | |
| 232 | - * @author Cory Crowley | |
| 233 | - */ | |
| 234 | - public function insert_images() | |
| 235 | -        { | |
| 236 | - | |
| 237 | - // If post variables are empty, return. | |
| 238 | - if (!isset($_POST['at-insert']) || empty($_POST['attachments'])) | |
| 239 | - return; | |
| 240 | - | |
| 241 | - // Security Check | |
| 242 | -            check_admin_referer('media-form'); | |
| 243 | - | |
| 244 | - // Create Security Nonce | |
| 245 | -            $nonce = wp_create_nonce('at_ajax_delete'); | |
| 246 | - | |
| 247 | - // Get Post Id and Field Id | |
| 248 | - $term_id = $_POST['post_id']; | |
| 249 | - $id = $_POST['field_id']; | |
| 250 | - | |
| 251 | - // Modify the insertion string | |
| 252 | - $html = ''; | |
| 253 | -            foreach ($_POST['attachments'] as $attachment_id => $attachment) { | |
| 254 | - | |
| 255 | - // Strip Slashes | |
| 256 | - $attachment = stripslashes_deep($attachment); | |
| 257 | - | |
| 258 | - // If not selected or url is empty, continue in loop. | |
| 259 | - if (empty($attachment['selected']) || empty($attachment['url'])) | |
| 260 | - continue; | |
| 261 | - | |
| 262 | -                $li = "<li id='item_{$attachment_id}'>"; | |
| 263 | -                $li .= "<img src='{$attachment['url']}' alt='image_{$attachment_id}' />"; | |
| 264 | -                //$li 	.= "<a title='" . __( 'Delete this image' ) . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'>" . __( 'Delete' ) . "</a>"; | |
| 265 | -                $li .= "<a title='" . __('Remove this image', 'geodirectory') . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'><img src='" . $this->SelfPath . "/images/delete-16.png' alt='" . __('Remove', 'geodirectory') . "' /></a>"; | |
| 266 | -                $li .= "<input type='hidden' name='{$id}[]' value='{$attachment_id}' />"; | |
| 267 | - $li .= "</li>"; | |
| 268 | - $html .= $li; | |
| 269 | - | |
| 270 | - } // End For Each | |
| 271 | - | |
| 272 | - return media_send_to_editor($html); | |
| 273 | - | |
| 274 | - } | |
| 275 | - | |
| 276 | - /** | |
| 277 | - * Delete attachments associated with the post. | |
| 278 | - * | |
| 279 | - * @since 1.0 | |
| 280 | - * @access public | |
| 281 | - * | |
| 282 | - * @param int|string $term_id The term ID. | |
| 283 | - */ | |
| 284 | -        /*public function delete_attachments( $term_id ) { | |
| 157 | + $taxnow = isset($_REQUEST['taxonomy']) ? $_REQUEST['taxonomy'] : ''; | |
| 158 | + | |
| 159 | +			if (!empty($this->_meta_box['pages'])) { | |
| 160 | +				if (in_array($taxnow, $this->_meta_box['pages'])) { | |
| 161 | + // Enqueue Meta Box Style | |
| 162 | + //wp_enqueue_style( 'tax-meta-clss', $plugin_path . '/css/Tax-meta-class.css' ); | |
| 163 | + // Enqueue Meta Box Scripts | |
| 164 | + //wp_enqueue_script( 'tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array( 'jquery' ), null, true ); | |
| 165 | + | |
| 166 | + } | |
| 167 | + } | |
| 168 | + | |
| 169 | + } | |
| 170 | + | |
| 171 | + /** | |
| 172 | + * Check the Field Upload, Add needed Actions | |
| 173 | + * | |
| 174 | + * @since 1.0 | |
| 175 | + * @access public | |
| 176 | + */ | |
| 177 | + public function enqueue_tax_meta_scripts() | |
| 178 | +		{ | |
| 179 | + // Make upload feature work event when custom post type doesn't support 'editor' | |
| 180 | +			wp_enqueue_script('media-upload'); | |
| 181 | +			wp_enqueue_script('thickbox'); | |
| 182 | + add_thickbox(); | |
| 183 | +			wp_enqueue_script('jquery-ui-core'); | |
| 184 | +			wp_enqueue_script('jquery-ui-sortable'); | |
| 185 | + | |
| 186 | + | |
| 187 | + } | |
| 188 | + | |
| 189 | + public function check_field_upload() | |
| 190 | +		{ | |
| 191 | + | |
| 192 | + // Check if the field is an image or file. If not, return. | |
| 193 | +			if (!$this->has_field('image') && !$this->has_field('file')) | |
| 194 | + return; | |
| 195 | + | |
| 196 | + | |
| 197 | +			add_action('wp_enqueue_scripts', array(&$this, 'enqueue_tax_meta_scripts'), 100); | |
| 198 | + | |
| 199 | + // Add data encoding type for file uploading. | |
| 200 | +			add_action('post_edit_form_tag', array(&$this, 'add_enctype')); | |
| 201 | + | |
| 202 | + | |
| 203 | + // Add filters for media upload. | |
| 204 | +			add_filter('media_upload_gallery', array(&$this, 'insert_images')); | |
| 205 | +			add_filter('media_upload_library', array(&$this, 'insert_images')); | |
| 206 | +			add_filter('media_upload_image', array(&$this, 'insert_images')); | |
| 207 | + | |
| 208 | + // Delete all attachments when delete custom post type. | |
| 209 | +			add_action('wp_ajax_at_delete_file', array(&$this, 'delete_file')); | |
| 210 | +			add_action('wp_ajax_at_reorder_images', array(&$this, 'reorder_images')); | |
| 211 | + // Delete file via Ajax | |
| 212 | +			add_action('wp_ajax_at_delete_mupload', array($this, 'wp_ajax_delete_image')); | |
| 213 | + } | |
| 214 | + | |
| 215 | + /** | |
| 216 | + * Add data encoding type for file uploading | |
| 217 | + * | |
| 218 | + * @since 1.0 | |
| 219 | + * @access public | |
| 220 | + */ | |
| 221 | + public function add_enctype() | |
| 222 | +		{ | |
| 223 | + echo ' enctype="multipart/form-data"'; | |
| 224 | + } | |
| 225 | + | |
| 226 | + /** | |
| 227 | + * Process images added to meta field. | |
| 228 | + * | |
| 229 | + * Modified from Faster Image Insert plugin. | |
| 230 | + * | |
| 231 | + * @return void | |
| 232 | + * @author Cory Crowley | |
| 233 | + */ | |
| 234 | + public function insert_images() | |
| 235 | +		{ | |
| 236 | + | |
| 237 | + // If post variables are empty, return. | |
| 238 | + if (!isset($_POST['at-insert']) || empty($_POST['attachments'])) | |
| 239 | + return; | |
| 240 | + | |
| 241 | + // Security Check | |
| 242 | +			check_admin_referer('media-form'); | |
| 243 | + | |
| 244 | + // Create Security Nonce | |
| 245 | +			$nonce = wp_create_nonce('at_ajax_delete'); | |
| 246 | + | |
| 247 | + // Get Post Id and Field Id | |
| 248 | + $term_id = $_POST['post_id']; | |
| 249 | + $id = $_POST['field_id']; | |
| 250 | + | |
| 251 | + // Modify the insertion string | |
| 252 | + $html = ''; | |
| 253 | +			foreach ($_POST['attachments'] as $attachment_id => $attachment) { | |
| 254 | + | |
| 255 | + // Strip Slashes | |
| 256 | + $attachment = stripslashes_deep($attachment); | |
| 257 | + | |
| 258 | + // If not selected or url is empty, continue in loop. | |
| 259 | + if (empty($attachment['selected']) || empty($attachment['url'])) | |
| 260 | + continue; | |
| 261 | + | |
| 262 | +				$li = "<li id='item_{$attachment_id}'>"; | |
| 263 | +				$li .= "<img src='{$attachment['url']}' alt='image_{$attachment_id}' />"; | |
| 264 | +				//$li 	.= "<a title='" . __( 'Delete this image' ) . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'>" . __( 'Delete' ) . "</a>"; | |
| 265 | +				$li .= "<a title='" . __('Remove this image', 'geodirectory') . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'><img src='" . $this->SelfPath . "/images/delete-16.png' alt='" . __('Remove', 'geodirectory') . "' /></a>"; | |
| 266 | +				$li .= "<input type='hidden' name='{$id}[]' value='{$attachment_id}' />"; | |
| 267 | + $li .= "</li>"; | |
| 268 | + $html .= $li; | |
| 269 | + | |
| 270 | + } // End For Each | |
| 271 | + | |
| 272 | + return media_send_to_editor($html); | |
| 273 | + | |
| 274 | + } | |
| 275 | + | |
| 276 | + /** | |
| 277 | + * Delete attachments associated with the post. | |
| 278 | + * | |
| 279 | + * @since 1.0 | |
| 280 | + * @access public | |
| 281 | + * | |
| 282 | + * @param int|string $term_id The term ID. | |
| 283 | + */ | |
| 284 | +		/*public function delete_attachments( $term_id ) { | |
| 285 | 285 | |
| 286 | 286 | // Get Attachments | 
| 287 | 287 | $attachments = get_posts( array( 'numberposts' => -1, 'post_type' => 'attachment', 'post_parent' => $term_id ) ); | 
| @@ -295,349 +295,349 @@ discard block | ||
| 295 | 295 | |
| 296 | 296 | }*/ | 
| 297 | 297 | |
| 298 | - /** | |
| 299 | - * Ajax callback for deleting files. | |
| 300 | - * | |
| 301 | - * Modified from a function used by "Verve Meta Boxes" plugin ( http://goo.gl/aw64H ) | |
| 302 | - * | |
| 303 | - * @since 1.0 | |
| 304 | - * @access public | |
| 305 | - */ | |
| 306 | - public function delete_file() | |
| 307 | -        { | |
| 308 | - | |
| 309 | - | |
| 310 | - // If data is not set, die. | |
| 311 | - if (!isset($_POST['data'])) | |
| 312 | - die(); | |
| 313 | - | |
| 314 | -            list($nonce, $term_id, $key, $attach_id) = explode('|', $_POST['data']); | |
| 315 | - | |
| 316 | - if (!wp_verify_nonce($nonce, 'at_ajax_delete')) | |
| 317 | -                die('1'); | |
| 318 | - | |
| 319 | - $this->delete_tax_meta($term_id, $key, $attach_id); | |
| 320 | - | |
| 321 | -            die('0'); | |
| 322 | - | |
| 323 | - } | |
| 324 | - | |
| 325 | - /** | |
| 326 | - * Ajax callback for deleting files. | |
| 327 | - * Modified from a function used by "Verve Meta Boxes" plugin (http://goo.gl/LzYSq) | |
| 328 | - * @since 1.0 | |
| 329 | - * @access public | |
| 330 | - */ | |
| 331 | - public function wp_ajax_delete_image() | |
| 332 | -        { | |
| 333 | - $term_id = isset($_GET['post_id']) ? intval($_GET['post_id']) : 0; | |
| 334 | - $field_id = isset($_GET['field_id']) ? $_GET['field_id'] : 0; | |
| 335 | - $attachment_id = isset($_GET['attachment_id']) ? intval($_GET['attachment_id']) : 0; | |
| 336 | - $ok = false; | |
| 337 | -            if (strpos($field_id, '[') === false) { | |
| 338 | -                check_admin_referer("at-delete-mupload_" . urldecode($field_id)); | |
| 339 | - if ($term_id > 0) | |
| 340 | - $this->delete_tax_meta($term_id, $field_id); | |
| 341 | - //$ok = wp_delete_attachment( $attachment_id ); | |
| 342 | - $ok = 1; | |
| 343 | -            } else { | |
| 344 | -                $f = explode('[', urldecode($field_id)); | |
| 345 | - $f_fiexed = array(); | |
| 346 | -                foreach ($f as $k => $v) { | |
| 347 | -                    $f[$k] = str_replace(']', '', $v); | |
| 348 | - } | |
| 349 | - $saved = $this->get_tax_meta($term_id, $f[0], true); | |
| 350 | -                if (isset($saved[$f[1]][$f[2]])) { | |
| 351 | - unset($saved[$f[1]][$f[2]]); | |
| 352 | - if ($term_id > 0) | |
| 353 | - update_post_meta($term_id, $f[0], $saved); | |
| 354 | - //$ok = wp_delete_attachment( $attachment_id ); | |
| 355 | - $ok = 1; | |
| 356 | - } | |
| 357 | - } | |
| 358 | - | |
| 359 | - | |
| 360 | -            if ($ok) { | |
| 361 | -                echo json_encode(array('status' => 'success')); | |
| 362 | - die(); | |
| 363 | -            } else { | |
| 364 | -                echo json_encode(array('message' => __('Cannot delete file. Something\'s wrong.', 'geodirectory'))); | |
| 365 | - die(); | |
| 366 | - } | |
| 367 | - } | |
| 368 | - | |
| 369 | - /** | |
| 370 | - * Ajax callback for reordering Images. | |
| 371 | - * | |
| 372 | - * @since 1.0 | |
| 373 | - * @access public | |
| 374 | - */ | |
| 375 | - public function reorder_images() | |
| 376 | -        { | |
| 377 | - | |
| 378 | - if (!isset($_POST['data'])) | |
| 379 | - die(); | |
| 380 | - | |
| 381 | -            list($order, $term_id, $key, $nonce) = explode('|', $_POST['data']); | |
| 382 | - | |
| 383 | - if (!wp_verify_nonce($nonce, 'at_ajax_reorder')) | |
| 384 | -                die('1'); | |
| 385 | - | |
| 386 | - parse_str($order, $items); | |
| 387 | - $items = $items['item']; | |
| 388 | - $order = 1; | |
| 389 | -            foreach ($items as $item) { | |
| 390 | -                wp_update_post(array('ID' => $item, 'post_parent' => $term_id, 'menu_order' => $order)); | |
| 391 | - $order++; | |
| 392 | - } | |
| 393 | - | |
| 394 | -            die('0'); | |
| 395 | - | |
| 396 | - } | |
| 397 | - | |
| 398 | - /** | |
| 399 | - * Check Field Color | |
| 400 | - * | |
| 401 | - * @since 1.0 | |
| 402 | - * @access public | |
| 403 | - */ | |
| 404 | - public function check_field_color() | |
| 405 | -        { | |
| 406 | - | |
| 407 | -            if ($this->has_field('color') && $this->is_edit_page()) { | |
| 408 | - // Enqueu built-in script and style for color picker. | |
| 409 | -                wp_enqueue_style('farbtastic'); | |
| 410 | -                wp_enqueue_script('farbtastic'); | |
| 411 | - } | |
| 412 | - | |
| 413 | - } | |
| 414 | - | |
| 415 | - /** | |
| 416 | - * Check Field Date | |
| 417 | - * | |
| 418 | - * @since 1.0 | |
| 419 | - * @access public | |
| 420 | - */ | |
| 421 | - public function check_field_date() | |
| 422 | -        { | |
| 423 | - | |
| 424 | -            if ($this->has_field('date') && $this->is_edit_page()) { | |
| 425 | - // Enqueu JQuery UI, use proper version. | |
| 426 | -                wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css'); | |
| 427 | -                wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery')); | |
| 428 | - } | |
| 429 | - | |
| 430 | - } | |
| 431 | - | |
| 432 | - /** | |
| 433 | - * Check Field Time | |
| 434 | - * | |
| 435 | - * @since 1.0 | |
| 436 | - * @access public | |
| 437 | - */ | |
| 438 | - public function check_field_time() | |
| 439 | -        { | |
| 440 | - | |
| 441 | -            if ($this->has_field('time') && $this->is_edit_page()) { | |
| 442 | - | |
| 443 | - // Enqueu JQuery UI, use proper version. | |
| 444 | -                wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css', array(), false, true); | |
| 445 | -                wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery'), false, true); | |
| 446 | -                wp_enqueue_script('at-timepicker', 'https://github.com/trentrichardson/jQuery-Timepicker-Addon/raw/master/jquery-ui-timepicker-addon.js', array('tmc-jquery-ui'), false, true); | |
| 447 | - | |
| 448 | - } | |
| 449 | - | |
| 450 | - } | |
| 451 | - | |
| 452 | - /** | |
| 453 | - * Add Meta Box for multiple post types. | |
| 454 | - * | |
| 455 | - * @since 1.0 | |
| 456 | - * @access public | |
| 457 | - */ | |
| 458 | - public function add() | |
| 459 | -        { | |
| 460 | - | |
| 461 | - // Loop through array | |
| 462 | -            if (!empty($this->_meta_box['pages'])) { | |
| 463 | -                foreach ($this->_meta_box['pages'] as $page) { | |
| 464 | - //add fields to edit form | |
| 465 | - add_action($page . '_edit_form_fields', array(&$this, 'show_edit_form')); | |
| 466 | - //add fields to add new form | |
| 467 | - add_action($page . '_add_form_fields', array(&$this, 'show_new_form')); | |
| 468 | - // this saves the edit fields | |
| 469 | -                    add_action('edited_' . $page, array(&$this, 'save'), 10, 2); | |
| 470 | - // this saves the add fields | |
| 471 | -                    add_action('created_' . $page, array(&$this, 'save'), 10, 2); | |
| 472 | - } | |
| 473 | - } | |
| 474 | - | |
| 475 | - } | |
| 476 | - | |
| 477 | - /** | |
| 478 | - * Callback function to show fields on add new taxonomy term form. | |
| 479 | - * | |
| 480 | - * @since 1.0 | |
| 481 | - * @access public | |
| 482 | - */ | |
| 483 | - public function show_new_form($term_id) | |
| 484 | -        { | |
| 485 | - $this->_form_type = 'new'; | |
| 486 | - $this->show($term_id); | |
| 487 | - } | |
| 488 | - | |
| 489 | - /** | |
| 490 | - * Callback function to show fields on term edit form. | |
| 491 | - * | |
| 492 | - * @since 1.0 | |
| 493 | - * @access public | |
| 494 | - */ | |
| 495 | - public function show_edit_form($term_id) | |
| 496 | -        { | |
| 497 | - $this->_form_type = 'edit'; | |
| 498 | - $this->show($term_id); | |
| 499 | - } | |
| 500 | - | |
| 501 | - | |
| 502 | - /** | |
| 503 | - * Callback function to show fields in meta box. | |
| 504 | - * | |
| 505 | - * @since 1.0 | |
| 506 | - * @access public | |
| 507 | - */ | |
| 508 | - public function show($term_id) | |
| 509 | -        { | |
| 510 | - | |
| 511 | - wp_nonce_field(basename(__FILE__), 'tax_meta_class_nonce'); | |
| 512 | - | |
| 513 | -            foreach ($this->_fields as $field) { | |
| 514 | - $meta = $this->get_tax_meta($term_id, $field['id'], !$field['multiple']); | |
| 515 | - $meta = ($meta !== '') ? $meta : $field['std']; | |
| 516 | -                if ('image' != $field['type'] && $field['type'] != 'repeater') | |
| 517 | -                    $meta = is_array($meta) ? array_map('esc_attr', $meta) : esc_attr($meta); | |
| 518 | - | |
| 519 | -                if ($field['validate_func']) { | |
| 520 | - echo '<tr class="form-field form-required ' . $field['style'] . '">'; | |
| 521 | -                } else { | |
| 522 | - echo '<tr class="form-field ' . $field['style'] . '">'; | |
| 523 | - } | |
| 524 | - | |
| 525 | - // Call Separated methods for displaying each type of field. | |
| 526 | - call_user_func(array(&$this, 'show_field_' . $field['type']), $field, $meta); | |
| 527 | - echo '</tr>'; | |
| 528 | - } | |
| 529 | - echo '</table>'; | |
| 530 | - } | |
| 531 | - | |
| 532 | - /** | |
| 533 | - * Show Repeater Fields. | |
| 534 | - * | |
| 535 | - * @param string $field | |
| 536 | - * @param string $meta | |
| 537 | - * @since 1.0 | |
| 538 | - * @access public | |
| 539 | - */ | |
| 540 | - public function show_field_repeater($field, $meta) | |
| 541 | -        { | |
| 542 | - // Get Plugin Path | |
| 543 | - $plugin_path = $this->SelfPath; | |
| 544 | - $this->show_field_begin($field, $meta); | |
| 545 | -            echo "<div class='at-repeat' id='{$field['id']}'>"; | |
| 546 | - | |
| 547 | - $c = 0; | |
| 548 | - | |
| 549 | -            if (count($meta) > 0 && is_array($meta)) { | |
| 550 | -                foreach ($meta as $me) { | |
| 551 | - //for labling toggles | |
| 552 | - $mmm = $me[$field['fields'][0]['id']]; | |
| 553 | - echo '<div class="at-repater-block">' . $mmm . '<br/><table class="repeater-table" style="display: none;">'; | |
| 554 | -                    if ($field['inline']) { | |
| 555 | - echo '<tr class="at-inline" VALIGN="top">'; | |
| 556 | - } | |
| 557 | -                    foreach ($field['fields'] as $f) { | |
| 558 | - //reset var $id for repeater | |
| 559 | - $id = ''; | |
| 560 | - $id = $field['id'] . '[' . $c . '][' . $f['id'] . ']'; | |
| 561 | - $m = $me[$f['id']]; | |
| 562 | - $m = ($m !== '') ? $m : $f['std']; | |
| 563 | -                        if ('image' != $f['type'] && $f['type'] != 'repeater') | |
| 564 | -                            $m = is_array($m) ? array_map('esc_attr', $m) : esc_attr($m); | |
| 565 | - //set new id for field in array format | |
| 566 | - $f['id'] = $id; | |
| 567 | -                        if (!$field['inline']) { | |
| 568 | - echo '<tr>'; | |
| 569 | - } | |
| 570 | - call_user_func(array(&$this, 'show_field_' . $f['type']), $f, $m); | |
| 571 | -                        if (!$field['inline']) { | |
| 572 | - echo '</tr>'; | |
| 573 | - } | |
| 574 | - } | |
| 575 | -                    if ($field['inline']) { | |
| 576 | - echo '</tr>'; | |
| 577 | - } | |
| 578 | - echo '</table> | |
| 298 | + /** | |
| 299 | + * Ajax callback for deleting files. | |
| 300 | + * | |
| 301 | + * Modified from a function used by "Verve Meta Boxes" plugin ( http://goo.gl/aw64H ) | |
| 302 | + * | |
| 303 | + * @since 1.0 | |
| 304 | + * @access public | |
| 305 | + */ | |
| 306 | + public function delete_file() | |
| 307 | +		{ | |
| 308 | + | |
| 309 | + | |
| 310 | + // If data is not set, die. | |
| 311 | + if (!isset($_POST['data'])) | |
| 312 | + die(); | |
| 313 | + | |
| 314 | +			list($nonce, $term_id, $key, $attach_id) = explode('|', $_POST['data']); | |
| 315 | + | |
| 316 | + if (!wp_verify_nonce($nonce, 'at_ajax_delete')) | |
| 317 | +				die('1'); | |
| 318 | + | |
| 319 | + $this->delete_tax_meta($term_id, $key, $attach_id); | |
| 320 | + | |
| 321 | +			die('0'); | |
| 322 | + | |
| 323 | + } | |
| 324 | + | |
| 325 | + /** | |
| 326 | + * Ajax callback for deleting files. | |
| 327 | + * Modified from a function used by "Verve Meta Boxes" plugin (http://goo.gl/LzYSq) | |
| 328 | + * @since 1.0 | |
| 329 | + * @access public | |
| 330 | + */ | |
| 331 | + public function wp_ajax_delete_image() | |
| 332 | +		{ | |
| 333 | + $term_id = isset($_GET['post_id']) ? intval($_GET['post_id']) : 0; | |
| 334 | + $field_id = isset($_GET['field_id']) ? $_GET['field_id'] : 0; | |
| 335 | + $attachment_id = isset($_GET['attachment_id']) ? intval($_GET['attachment_id']) : 0; | |
| 336 | + $ok = false; | |
| 337 | +			if (strpos($field_id, '[') === false) { | |
| 338 | +				check_admin_referer("at-delete-mupload_" . urldecode($field_id)); | |
| 339 | + if ($term_id > 0) | |
| 340 | + $this->delete_tax_meta($term_id, $field_id); | |
| 341 | + //$ok = wp_delete_attachment( $attachment_id ); | |
| 342 | + $ok = 1; | |
| 343 | +			} else { | |
| 344 | +				$f = explode('[', urldecode($field_id)); | |
| 345 | + $f_fiexed = array(); | |
| 346 | +				foreach ($f as $k => $v) { | |
| 347 | +					$f[$k] = str_replace(']', '', $v); | |
| 348 | + } | |
| 349 | + $saved = $this->get_tax_meta($term_id, $f[0], true); | |
| 350 | +				if (isset($saved[$f[1]][$f[2]])) { | |
| 351 | + unset($saved[$f[1]][$f[2]]); | |
| 352 | + if ($term_id > 0) | |
| 353 | + update_post_meta($term_id, $f[0], $saved); | |
| 354 | + //$ok = wp_delete_attachment( $attachment_id ); | |
| 355 | + $ok = 1; | |
| 356 | + } | |
| 357 | + } | |
| 358 | + | |
| 359 | + | |
| 360 | +			if ($ok) { | |
| 361 | +				echo json_encode(array('status' => 'success')); | |
| 362 | + die(); | |
| 363 | +			} else { | |
| 364 | +				echo json_encode(array('message' => __('Cannot delete file. Something\'s wrong.', 'geodirectory'))); | |
| 365 | + die(); | |
| 366 | + } | |
| 367 | + } | |
| 368 | + | |
| 369 | + /** | |
| 370 | + * Ajax callback for reordering Images. | |
| 371 | + * | |
| 372 | + * @since 1.0 | |
| 373 | + * @access public | |
| 374 | + */ | |
| 375 | + public function reorder_images() | |
| 376 | +		{ | |
| 377 | + | |
| 378 | + if (!isset($_POST['data'])) | |
| 379 | + die(); | |
| 380 | + | |
| 381 | +			list($order, $term_id, $key, $nonce) = explode('|', $_POST['data']); | |
| 382 | + | |
| 383 | + if (!wp_verify_nonce($nonce, 'at_ajax_reorder')) | |
| 384 | +				die('1'); | |
| 385 | + | |
| 386 | + parse_str($order, $items); | |
| 387 | + $items = $items['item']; | |
| 388 | + $order = 1; | |
| 389 | +			foreach ($items as $item) { | |
| 390 | +				wp_update_post(array('ID' => $item, 'post_parent' => $term_id, 'menu_order' => $order)); | |
| 391 | + $order++; | |
| 392 | + } | |
| 393 | + | |
| 394 | +			die('0'); | |
| 395 | + | |
| 396 | + } | |
| 397 | + | |
| 398 | + /** | |
| 399 | + * Check Field Color | |
| 400 | + * | |
| 401 | + * @since 1.0 | |
| 402 | + * @access public | |
| 403 | + */ | |
| 404 | + public function check_field_color() | |
| 405 | +		{ | |
| 406 | + | |
| 407 | +			if ($this->has_field('color') && $this->is_edit_page()) { | |
| 408 | + // Enqueu built-in script and style for color picker. | |
| 409 | +				wp_enqueue_style('farbtastic'); | |
| 410 | +				wp_enqueue_script('farbtastic'); | |
| 411 | + } | |
| 412 | + | |
| 413 | + } | |
| 414 | + | |
| 415 | + /** | |
| 416 | + * Check Field Date | |
| 417 | + * | |
| 418 | + * @since 1.0 | |
| 419 | + * @access public | |
| 420 | + */ | |
| 421 | + public function check_field_date() | |
| 422 | +		{ | |
| 423 | + | |
| 424 | +			if ($this->has_field('date') && $this->is_edit_page()) { | |
| 425 | + // Enqueu JQuery UI, use proper version. | |
| 426 | +				wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css'); | |
| 427 | +				wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery')); | |
| 428 | + } | |
| 429 | + | |
| 430 | + } | |
| 431 | + | |
| 432 | + /** | |
| 433 | + * Check Field Time | |
| 434 | + * | |
| 435 | + * @since 1.0 | |
| 436 | + * @access public | |
| 437 | + */ | |
| 438 | + public function check_field_time() | |
| 439 | +		{ | |
| 440 | + | |
| 441 | +			if ($this->has_field('time') && $this->is_edit_page()) { | |
| 442 | + | |
| 443 | + // Enqueu JQuery UI, use proper version. | |
| 444 | +				wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css', array(), false, true); | |
| 445 | +				wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery'), false, true); | |
| 446 | +				wp_enqueue_script('at-timepicker', 'https://github.com/trentrichardson/jQuery-Timepicker-Addon/raw/master/jquery-ui-timepicker-addon.js', array('tmc-jquery-ui'), false, true); | |
| 447 | + | |
| 448 | + } | |
| 449 | + | |
| 450 | + } | |
| 451 | + | |
| 452 | + /** | |
| 453 | + * Add Meta Box for multiple post types. | |
| 454 | + * | |
| 455 | + * @since 1.0 | |
| 456 | + * @access public | |
| 457 | + */ | |
| 458 | + public function add() | |
| 459 | +		{ | |
| 460 | + | |
| 461 | + // Loop through array | |
| 462 | +			if (!empty($this->_meta_box['pages'])) { | |
| 463 | +				foreach ($this->_meta_box['pages'] as $page) { | |
| 464 | + //add fields to edit form | |
| 465 | + add_action($page . '_edit_form_fields', array(&$this, 'show_edit_form')); | |
| 466 | + //add fields to add new form | |
| 467 | + add_action($page . '_add_form_fields', array(&$this, 'show_new_form')); | |
| 468 | + // this saves the edit fields | |
| 469 | +					add_action('edited_' . $page, array(&$this, 'save'), 10, 2); | |
| 470 | + // this saves the add fields | |
| 471 | +					add_action('created_' . $page, array(&$this, 'save'), 10, 2); | |
| 472 | + } | |
| 473 | + } | |
| 474 | + | |
| 475 | + } | |
| 476 | + | |
| 477 | + /** | |
| 478 | + * Callback function to show fields on add new taxonomy term form. | |
| 479 | + * | |
| 480 | + * @since 1.0 | |
| 481 | + * @access public | |
| 482 | + */ | |
| 483 | + public function show_new_form($term_id) | |
| 484 | +		{ | |
| 485 | + $this->_form_type = 'new'; | |
| 486 | + $this->show($term_id); | |
| 487 | + } | |
| 488 | + | |
| 489 | + /** | |
| 490 | + * Callback function to show fields on term edit form. | |
| 491 | + * | |
| 492 | + * @since 1.0 | |
| 493 | + * @access public | |
| 494 | + */ | |
| 495 | + public function show_edit_form($term_id) | |
| 496 | +		{ | |
| 497 | + $this->_form_type = 'edit'; | |
| 498 | + $this->show($term_id); | |
| 499 | + } | |
| 500 | + | |
| 501 | + | |
| 502 | + /** | |
| 503 | + * Callback function to show fields in meta box. | |
| 504 | + * | |
| 505 | + * @since 1.0 | |
| 506 | + * @access public | |
| 507 | + */ | |
| 508 | + public function show($term_id) | |
| 509 | +		{ | |
| 510 | + | |
| 511 | + wp_nonce_field(basename(__FILE__), 'tax_meta_class_nonce'); | |
| 512 | + | |
| 513 | +			foreach ($this->_fields as $field) { | |
| 514 | + $meta = $this->get_tax_meta($term_id, $field['id'], !$field['multiple']); | |
| 515 | + $meta = ($meta !== '') ? $meta : $field['std']; | |
| 516 | +				if ('image' != $field['type'] && $field['type'] != 'repeater') | |
| 517 | +					$meta = is_array($meta) ? array_map('esc_attr', $meta) : esc_attr($meta); | |
| 518 | + | |
| 519 | +				if ($field['validate_func']) { | |
| 520 | + echo '<tr class="form-field form-required ' . $field['style'] . '">'; | |
| 521 | +				} else { | |
| 522 | + echo '<tr class="form-field ' . $field['style'] . '">'; | |
| 523 | + } | |
| 524 | + | |
| 525 | + // Call Separated methods for displaying each type of field. | |
| 526 | + call_user_func(array(&$this, 'show_field_' . $field['type']), $field, $meta); | |
| 527 | + echo '</tr>'; | |
| 528 | + } | |
| 529 | + echo '</table>'; | |
| 530 | + } | |
| 531 | + | |
| 532 | + /** | |
| 533 | + * Show Repeater Fields. | |
| 534 | + * | |
| 535 | + * @param string $field | |
| 536 | + * @param string $meta | |
| 537 | + * @since 1.0 | |
| 538 | + * @access public | |
| 539 | + */ | |
| 540 | + public function show_field_repeater($field, $meta) | |
| 541 | +		{ | |
| 542 | + // Get Plugin Path | |
| 543 | + $plugin_path = $this->SelfPath; | |
| 544 | + $this->show_field_begin($field, $meta); | |
| 545 | +			echo "<div class='at-repeat' id='{$field['id']}'>"; | |
| 546 | + | |
| 547 | + $c = 0; | |
| 548 | + | |
| 549 | +			if (count($meta) > 0 && is_array($meta)) { | |
| 550 | +				foreach ($meta as $me) { | |
| 551 | + //for labling toggles | |
| 552 | + $mmm = $me[$field['fields'][0]['id']]; | |
| 553 | + echo '<div class="at-repater-block">' . $mmm . '<br/><table class="repeater-table" style="display: none;">'; | |
| 554 | +					if ($field['inline']) { | |
| 555 | + echo '<tr class="at-inline" VALIGN="top">'; | |
| 556 | + } | |
| 557 | +					foreach ($field['fields'] as $f) { | |
| 558 | + //reset var $id for repeater | |
| 559 | + $id = ''; | |
| 560 | + $id = $field['id'] . '[' . $c . '][' . $f['id'] . ']'; | |
| 561 | + $m = $me[$f['id']]; | |
| 562 | + $m = ($m !== '') ? $m : $f['std']; | |
| 563 | +						if ('image' != $f['type'] && $f['type'] != 'repeater') | |
| 564 | +							$m = is_array($m) ? array_map('esc_attr', $m) : esc_attr($m); | |
| 565 | + //set new id for field in array format | |
| 566 | + $f['id'] = $id; | |
| 567 | +						if (!$field['inline']) { | |
| 568 | + echo '<tr>'; | |
| 569 | + } | |
| 570 | + call_user_func(array(&$this, 'show_field_' . $f['type']), $f, $m); | |
| 571 | +						if (!$field['inline']) { | |
| 572 | + echo '</tr>'; | |
| 573 | + } | |
| 574 | + } | |
| 575 | +					if ($field['inline']) { | |
| 576 | + echo '</tr>'; | |
| 577 | + } | |
| 578 | + echo '</table> | |
| 579 | 579 | <span class="at-re-toggle"><img src="'; | 
| 580 | -                    if ($this->_Local_images) { | |
| 581 | - echo $plugin_path . '/images/edit.png'; | |
| 582 | -                    } else { | |
| 583 | - echo 'http://i.imgur.com/ka0E2.png'; | |
| 584 | - } | |
| 585 | - echo '" alt="Edit" title="Edit"/></span> | |
| 580 | +					if ($this->_Local_images) { | |
| 581 | + echo $plugin_path . '/images/edit.png'; | |
| 582 | +					} else { | |
| 583 | + echo 'http://i.imgur.com/ka0E2.png'; | |
| 584 | + } | |
| 585 | + echo '" alt="Edit" title="Edit"/></span> | |
| 586 | 586 | <img src="'; | 
| 587 | -                    if ($this->_Local_images) { | |
| 588 | - echo $plugin_path . '/images/remove.png'; | |
| 589 | -                    } else { | |
| 590 | - echo 'http://i.imgur.com/g8Duj.png'; | |
| 591 | - } | |
| 592 | -                    echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>'; | |
| 593 | - $c = $c + 1; | |
| 594 | - | |
| 595 | - } | |
| 596 | - $this->show_field_end($field, $meta); | |
| 597 | - } | |
| 598 | - | |
| 599 | - echo '<img src="'; | |
| 600 | -            if ($this->_Local_images) { | |
| 601 | - echo $plugin_path . '/images/add.png'; | |
| 602 | -            } else { | |
| 603 | - echo 'http://i.imgur.com/w5Tuc.png'; | |
| 604 | - } | |
| 605 | -            echo '" alt="' . __('Add', 'geodirectory') . '" title="' . __('Add', 'geodirectory') . '" id="add-' . $field['id'] . '"><br/></div>'; | |
| 606 | - | |
| 607 | - //create all fields once more for js function and catch with object buffer | |
| 608 | - ob_start(); | |
| 609 | - echo '<div class="at-repater-block"><table class="repeater-table">'; | |
| 610 | -            if ($field['inline']) { | |
| 611 | - echo '<tr class="at-inline" VALIGN="top">'; | |
| 612 | - } | |
| 613 | -            foreach ($field['fields'] as $f) { | |
| 614 | - //reset var $id for repeater | |
| 615 | - $id = ''; | |
| 616 | - $id = $field['id'] . '[CurrentCounter][' . $f['id'] . ']'; | |
| 617 | - $f['id'] = $id; | |
| 618 | -                if (!$field['inline']) { | |
| 619 | - echo '<tr>'; | |
| 620 | - } | |
| 621 | - call_user_func(array(&$this, 'show_field_' . $f['type']), $f, ''); | |
| 622 | -                if (!$field['inline']) { | |
| 623 | - echo '</tr>'; | |
| 624 | - } | |
| 625 | - } | |
| 626 | -            if ($field['inline']) { | |
| 627 | - echo '</tr>'; | |
| 628 | - } | |
| 629 | - echo '</table><img src="'; | |
| 630 | -            if ($this->_Local_images) { | |
| 631 | - echo $plugin_path . '/images/remove.png'; | |
| 632 | -            } else { | |
| 633 | - echo 'http://i.imgur.com/g8Duj.png'; | |
| 634 | - } | |
| 635 | -            echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>'; | |
| 636 | - $counter = 'countadd_' . $field['id']; | |
| 637 | - $js_code = ob_get_clean(); | |
| 638 | -            $js_code = str_replace("'", "\"", $js_code); | |
| 639 | -            $js_code = str_replace("CurrentCounter", "' + " . $counter . " + '", $js_code); | |
| 640 | - echo '<script> | |
| 587 | +					if ($this->_Local_images) { | |
| 588 | + echo $plugin_path . '/images/remove.png'; | |
| 589 | +					} else { | |
| 590 | + echo 'http://i.imgur.com/g8Duj.png'; | |
| 591 | + } | |
| 592 | +					echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>'; | |
| 593 | + $c = $c + 1; | |
| 594 | + | |
| 595 | + } | |
| 596 | + $this->show_field_end($field, $meta); | |
| 597 | + } | |
| 598 | + | |
| 599 | + echo '<img src="'; | |
| 600 | +			if ($this->_Local_images) { | |
| 601 | + echo $plugin_path . '/images/add.png'; | |
| 602 | +			} else { | |
| 603 | + echo 'http://i.imgur.com/w5Tuc.png'; | |
| 604 | + } | |
| 605 | +			echo '" alt="' . __('Add', 'geodirectory') . '" title="' . __('Add', 'geodirectory') . '" id="add-' . $field['id'] . '"><br/></div>'; | |
| 606 | + | |
| 607 | + //create all fields once more for js function and catch with object buffer | |
| 608 | + ob_start(); | |
| 609 | + echo '<div class="at-repater-block"><table class="repeater-table">'; | |
| 610 | +			if ($field['inline']) { | |
| 611 | + echo '<tr class="at-inline" VALIGN="top">'; | |
| 612 | + } | |
| 613 | +			foreach ($field['fields'] as $f) { | |
| 614 | + //reset var $id for repeater | |
| 615 | + $id = ''; | |
| 616 | + $id = $field['id'] . '[CurrentCounter][' . $f['id'] . ']'; | |
| 617 | + $f['id'] = $id; | |
| 618 | +				if (!$field['inline']) { | |
| 619 | + echo '<tr>'; | |
| 620 | + } | |
| 621 | + call_user_func(array(&$this, 'show_field_' . $f['type']), $f, ''); | |
| 622 | +				if (!$field['inline']) { | |
| 623 | + echo '</tr>'; | |
| 624 | + } | |
| 625 | + } | |
| 626 | +			if ($field['inline']) { | |
| 627 | + echo '</tr>'; | |
| 628 | + } | |
| 629 | + echo '</table><img src="'; | |
| 630 | +			if ($this->_Local_images) { | |
| 631 | + echo $plugin_path . '/images/remove.png'; | |
| 632 | +			} else { | |
| 633 | + echo 'http://i.imgur.com/g8Duj.png'; | |
| 634 | + } | |
| 635 | +			echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>'; | |
| 636 | + $counter = 'countadd_' . $field['id']; | |
| 637 | + $js_code = ob_get_clean(); | |
| 638 | +			$js_code = str_replace("'", "\"", $js_code); | |
| 639 | +			$js_code = str_replace("CurrentCounter", "' + " . $counter . " + '", $js_code); | |
| 640 | + echo '<script> | |
| 641 | 641 |  				jQuery(document).ready(function() { | 
| 642 | 642 | var ' . $counter . ' = ' . $c . '; | 
| 643 | 643 |  					jQuery("#add-' . $field['id'] . '").live(\'click\', function() { | 
| @@ -650,7 +650,7 @@ discard block | ||
| 650 | 650 | }); | 
| 651 | 651 | }); | 
| 652 | 652 | </script>'; | 
| 653 | - echo '<br/><style> | |
| 653 | + echo '<br/><style> | |
| 654 | 654 |  .at-inline{line-height: 1 !important;} | 
| 655 | 655 |  .at-inline .at-field{border: 0px !important;} | 
| 656 | 656 |  .at-inline .at-label{margin: 0 0 1px !important;} | 
| @@ -658,532 +658,532 @@ discard block | ||
| 658 | 658 |  .at-inline .at-textarea{width: 100px; height: 75px;} | 
| 659 | 659 |  .at-repater-block{background-color: #FFFFFF;border: 1px solid;margin: 2px;} | 
| 660 | 660 | </style>'; | 
| 661 | - $this->show_field_end($field, $meta); | |
| 662 | - } | |
| 663 | - | |
| 664 | - /** | |
| 665 | - * Begin Field. | |
| 666 | - * | |
| 667 | - * @param string $field | |
| 668 | - * @param string $meta | |
| 669 | - * @since 1.0 | |
| 670 | - * @access public | |
| 671 | - */ | |
| 672 | - public function show_field_begin($field, $meta) | |
| 673 | -        { | |
| 674 | -            if (isset($field['group'])) { | |
| 675 | -                if ($field['group'] == "start") { | |
| 676 | - echo "<td class='at-field'>"; | |
| 677 | - } | |
| 678 | -            } else { | |
| 679 | -                if ($this->_form_type == 'edit') { | |
| 680 | - echo '<th valign="top" scope="row">'; | |
| 681 | -                } else { | |
| 682 | -                    if ($field['validate_func']) { | |
| 683 | - echo '<td><div class="form-field form-required">'; | |
| 684 | -                    } else { | |
| 685 | - echo '<td><div class="form-field">'; | |
| 686 | - } | |
| 687 | - } | |
| 688 | - } | |
| 689 | -            if ($field['name'] != '' || $field['name'] != FALSE) { | |
| 690 | - //echo "<div class='at-label'>"; | |
| 691 | -                echo "<label for='{$field['id']}'>{$field['name']}</label>"; | |
| 692 | - //echo "</div>"; | |
| 693 | - } | |
| 694 | -            if ($this->_form_type == 'edit') { | |
| 695 | - echo '</th><td>'; | |
| 696 | - } | |
| 697 | - } | |
| 698 | - | |
| 699 | - /** | |
| 700 | - * End Field. | |
| 701 | - * | |
| 702 | - * @param string $field | |
| 703 | - * @param string $meta | |
| 704 | - * @since 1.0 | |
| 705 | - * @access public | |
| 706 | - */ | |
| 707 | - public function show_field_end($field, $meta = NULL, $group = false) | |
| 708 | -        { | |
| 709 | -            if (isset($field['group'])) { | |
| 710 | -                if ($group == 'end') { | |
| 711 | -                    if ($field['desc'] != '') { | |
| 712 | -                        echo "<p class='desc-field'>{$field['desc']}</p></td>"; | |
| 713 | -                    } else { | |
| 714 | - echo "</td>"; | |
| 715 | - } | |
| 716 | -                } else { | |
| 717 | -                    if ($field['desc'] != '') { | |
| 718 | -                        echo "<p class='desc-field'>{$field['desc']}</p><br/>"; | |
| 719 | -                    } else { | |
| 720 | - echo '<br/>'; | |
| 721 | - } | |
| 722 | - } | |
| 723 | -            } else { | |
| 724 | -                if ($field['desc'] != '') { | |
| 725 | -                    echo "<p class='desc-field'>{$field['desc']}</p>"; | |
| 726 | - } | |
| 727 | -                if ($this->_form_type == 'edit') { | |
| 728 | - echo '</td>'; | |
| 729 | -                } else { | |
| 730 | - echo '</td></div>'; | |
| 731 | - } | |
| 732 | - } | |
| 733 | - } | |
| 734 | - | |
| 735 | - /** | |
| 736 | - * Show Field Text. | |
| 737 | - * | |
| 738 | - * @param string $field | |
| 739 | - * @param string $meta | |
| 740 | - * @since 1.0 | |
| 741 | - * @access public | |
| 742 | - */ | |
| 743 | - public function show_field_text($field, $meta) | |
| 744 | -        { | |
| 745 | - $this->show_field_begin($field, $meta); | |
| 746 | -            echo "<input type='text' class='at-text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='30' />"; | |
| 747 | - $this->show_field_end($field, $meta); | |
| 748 | - } | |
| 749 | - | |
| 750 | - /** | |
| 751 | - * Show Field hidden. | |
| 752 | - * | |
| 753 | - * @param string $field | |
| 754 | - * @param string|mixed $meta | |
| 755 | - * @since 0.1.3 | |
| 756 | - * @access public | |
| 757 | - */ | |
| 758 | - public function show_field_hidden($field, $meta) | |
| 759 | -        { | |
| 760 | - //$this->show_field_begin( $field, $meta ); | |
| 761 | -            echo "<input type='hidden' class='at-text' name='{$field['id']}' id='{$field['id']}' value='{$meta}'/>"; | |
| 762 | - //$this->show_field_end( $field, $meta ); | |
| 763 | - } | |
| 764 | - | |
| 765 | - /** | |
| 766 | - * Show Field Paragraph. | |
| 767 | - * | |
| 768 | - * @param string $field | |
| 769 | - * @since 0.1.3 | |
| 770 | - * @access public | |
| 771 | - */ | |
| 772 | - public function show_field_paragraph($field) | |
| 773 | -        { | |
| 774 | - //$this->show_field_begin( $field, $meta ); | |
| 775 | - echo '<p>' . $field['value'] . '</p>'; | |
| 776 | - //$this->show_field_end( $field, $meta ); | |
| 777 | - } | |
| 778 | - | |
| 779 | - /** | |
| 780 | - * Show Field Textarea. | |
| 781 | - * | |
| 782 | - * @param string $field | |
| 783 | - * @param string $meta | |
| 784 | - * @since 1.0 | |
| 785 | - * @access public | |
| 786 | - */ | |
| 787 | - public function show_field_textarea($field, $meta) | |
| 788 | -        { | |
| 789 | - $this->show_field_begin($field, $meta); | |
| 790 | -            echo "<textarea class='at-textarea large-text' name='{$field['id']}' id='{$field['id']}' cols='60' rows='10'>{$meta}</textarea>"; | |
| 791 | - $this->show_field_end($field, $meta); | |
| 792 | - } | |
| 793 | - | |
| 794 | - /** | |
| 795 | - * Show Field Select. | |
| 796 | - * | |
| 797 | - * @param string $field | |
| 798 | - * @param string $meta | |
| 799 | - * @since 1.0 | |
| 800 | - * @access public | |
| 801 | - */ | |
| 802 | - public function show_field_select($field, $meta) | |
| 803 | -        { | |
| 804 | - | |
| 805 | - if (!is_array($meta)) | |
| 806 | - $meta = (array)$meta; | |
| 807 | - | |
| 808 | - $this->show_field_begin($field, $meta); | |
| 809 | -            echo "<select class='at-select' name='{$field['id']}" . ($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'") . ">"; | |
| 810 | -            foreach ($field['options'] as $key => $value) { | |
| 811 | -                echo "<option value='{$key}'" . selected(in_array($key, $meta), true, false) . ">{$value}</option>"; | |
| 812 | - } | |
| 813 | - echo "</select>"; | |
| 814 | - $this->show_field_end($field, $meta); | |
| 815 | - | |
| 816 | - } | |
| 817 | - | |
| 818 | - /** | |
| 819 | - * Show Radio Field. | |
| 820 | - * | |
| 821 | - * @param string $field | |
| 822 | - * @param string $meta | |
| 823 | - * @since 1.0 | |
| 824 | - * @access public | |
| 825 | - */ | |
| 826 | - public function show_field_radio($field, $meta) | |
| 827 | -        { | |
| 828 | - | |
| 829 | - if (!is_array($meta)) | |
| 830 | - $meta = (array)$meta; | |
| 831 | - | |
| 832 | - $this->show_field_begin($field, $meta); | |
| 833 | -            foreach ($field['options'] as $key => $value) { | |
| 834 | -                echo "<input type='radio' class='at-radio' name='{$field['id']}' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> <span class='at-radio-label'>{$value}</span>"; | |
| 835 | - } | |
| 836 | - $this->show_field_end($field, $meta); | |
| 837 | - } | |
| 838 | - | |
| 839 | - /** | |
| 840 | - * Show Checkbox Field. | |
| 841 | - * | |
| 842 | - * @param string $field | |
| 843 | - * @param string $meta | |
| 844 | - * @since 1.0 | |
| 845 | - * @access public | |
| 846 | - */ | |
| 847 | - public function show_field_checkbox($field, $meta) | |
| 848 | -        { | |
| 849 | - | |
| 850 | - $this->show_field_begin($field, $meta); | |
| 851 | -            echo "<input type='checkbox' class='rw-checkbox' name='{$field['id']}' id='{$field['id']}'" . checked(!empty($meta), true, false) . " /> {$field['desc']}"; | |
| 852 | - $this->show_field_end($field, $meta); | |
| 853 | - } | |
| 854 | - | |
| 855 | - /** | |
| 856 | - * Show Wysiwig Field. | |
| 857 | - * | |
| 858 | - * @param string $field | |
| 859 | - * @param string $meta | |
| 860 | - * @since 1.0 | |
| 861 | - * @access public | |
| 862 | - */ | |
| 863 | - public function show_field_wysiwyg($field, $meta) | |
| 864 | -        { | |
| 865 | - $this->show_field_begin($field, $meta); | |
| 866 | - // Add TinyMCE script for WP version < 3.3 | |
| 867 | - global $wp_version; | |
| 868 | - | |
| 869 | -            if (version_compare($wp_version, '3.2.1') < 1) { | |
| 870 | -                echo "<textarea class='at-wysiwyg theEditor large-text' name='{$field['id']}' id='{$field['id']}' cols='60' rows='10'>{$meta}</textarea>"; | |
| 871 | -            } else { | |
| 872 | - // Use new wp_editor() since WP 3.3 | |
| 873 | -                wp_editor(stripslashes(html_entity_decode($meta)), $field['id'], array('editor_class' => 'at-wysiwyg')); | |
| 874 | - } | |
| 875 | - $this->show_field_end($field, $meta); | |
| 876 | - } | |
| 877 | - | |
| 878 | - /** | |
| 879 | - * Show File Field. | |
| 880 | - * | |
| 881 | - * @global object $post The current post object. | |
| 882 | - * @param string $field | |
| 883 | - * @param string $meta | |
| 884 | - * @since 1.0 | |
| 885 | - * @access public | |
| 886 | - */ | |
| 887 | - public function show_field_file($field, $meta) | |
| 888 | -        { | |
| 889 | - | |
| 890 | - global $post; | |
| 891 | - | |
| 892 | - if (!is_array($meta)) | |
| 893 | - $meta = (array)$meta; | |
| 894 | - | |
| 895 | - $this->show_field_begin($field, $meta); | |
| 896 | -            echo "{$field['desc']}<br />"; | |
| 897 | - | |
| 898 | -            if (!empty($meta)) { | |
| 899 | -                $nonce = wp_create_nonce('at_ajax_delete'); | |
| 900 | -                echo '<div style="margin-bottom: 10px"><strong>' . __('Uploaded files', 'geodirectory') . '</strong></div>'; | |
| 901 | - echo '<ol class="at-upload">'; | |
| 902 | -                foreach ($meta as $att) { | |
| 903 | - // if (wp_attachment_is_image($att)) continue; // what's image uploader for? | |
| 904 | -                    echo "<li>" . wp_get_attachment_link($att, '', false, false, ' ') . " (<a class='at-delete-file' href='#' rel='{$nonce}|{$post->ID}|{$field['id']}|{$att}'>" . __('Remove', 'geodirectory') . "</a>)</li>"; | |
| 905 | - } | |
| 906 | - echo '</ol>'; | |
| 907 | - } | |
| 908 | - | |
| 909 | - // show form upload | |
| 910 | - | |
| 911 | - echo "<div class='at-file-upload-label'>"; | |
| 912 | -            echo "<strong>" . __('Upload new files', 'geodirectory') . "</strong>"; | |
| 913 | - echo "</div>"; | |
| 914 | - echo "<div class='new-files'>"; | |
| 915 | - echo "<div class='file-input'>"; | |
| 916 | -            echo "<input type='file' name='{$field['id']}[]' />"; | |
| 917 | - echo "</div><!-- End .file-input -->"; | |
| 918 | -            echo "<a class='at-add-file button' href='#'>" . __('Add more files', 'geodirectory') . "</a>"; | |
| 919 | - echo "</div><!-- End .new-files -->"; | |
| 920 | - echo "</td>"; | |
| 921 | - $this->show_field_end($field, $meta); | |
| 922 | - } | |
| 923 | - | |
| 924 | - /** | |
| 925 | - * Show Image Field. | |
| 926 | - * | |
| 927 | - * @param array $field | |
| 928 | - * @param array $meta | |
| 929 | - * @since 1.0 | |
| 930 | - * @access public | |
| 931 | - */ | |
| 932 | - public function show_field_image($field, $meta) | |
| 933 | -        { | |
| 934 | - $this->show_field_begin($field, $meta); | |
| 935 | -            $html = wp_nonce_field("at-delete-mupload_{$field['id']}", "nonce-delete-mupload_" . $field['id'], false, false); | |
| 936 | -            if (is_array($meta)) { | |
| 937 | - if (isset($meta[0]) && is_array($meta[0])) | |
| 938 | - $meta = $meta[0]; | |
| 939 | - } | |
| 940 | - | |
| 941 | - $uploads = wp_upload_dir(); | |
| 942 | -            if (is_array($meta) && isset($meta['src']) && $meta['src'] != '') { | |
| 943 | - | |
| 944 | - $file_info = pathinfo($meta['src']); | |
| 945 | - | |
| 946 | - //print_r($meta); | |
| 947 | - //print_r($uploads); | |
| 948 | - //print_r($file_info); | |
| 949 | - | |
| 950 | - if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') | |
| 951 | - $sub_dir = $file_info['dirname']; | |
| 952 | - | |
| 953 | - $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs | |
| 954 | - $uploads_baseurl = $uploads['baseurl']; | |
| 955 | - $uploads_path = $uploads['path']; | |
| 956 | - | |
| 957 | - $file_name = $file_info['basename']; | |
| 958 | - | |
| 959 | - $sub_dir = str_replace($uploads_baseurl, '', $sub_dir); | |
| 960 | - | |
| 961 | - $uploads_url = $uploads_baseurl . $sub_dir; | |
| 962 | - | |
| 963 | - $meta['src'] = $uploads_url . '/' . $file_name; | |
| 964 | - | |
| 965 | - | |
| 966 | - $html .= "<span class='mupload_img_holder'><img src='" . $meta['src'] . "' style='max-height: 150px;max-width: 150px;' /></span>"; | |
| 967 | - $html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='" . $meta['id'] . "' />"; | |
| 968 | - $html .= "<input type='hidden' class='" . $field['id'] . "[src]' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='" . $meta['src'] . "' />"; | |
| 969 | -                $html .= "<input class='at-delete_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Remove Image', 'geodirectory') . "' />"; | |
| 970 | -            } else { | |
| 971 | - $html .= "<span class='mupload_img_holder'></span>"; | |
| 972 | - $html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='' />"; | |
| 973 | - $html .= "<input class='" . $field['id'] . "[src]' style='position:absolute;left:-500px;width:50px;' type='text' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='' />"; | |
| 974 | -                $html .= "<input class='at-upload_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Upload Image', 'geodirectory') . "' />"; | |
| 975 | - } | |
| 976 | - echo $html; | |
| 977 | - $this->show_field_end($field, $meta); | |
| 978 | - } | |
| 979 | - | |
| 980 | - /** | |
| 981 | - * Show Color Field. | |
| 982 | - * | |
| 983 | - * @param string $field | |
| 984 | - * @param string $meta | |
| 985 | - * @since 1.0 | |
| 986 | - * @access public | |
| 987 | - */ | |
| 988 | - public function show_field_color($field, $meta) | |
| 989 | -        { | |
| 990 | - | |
| 991 | - if (empty($meta)) | |
| 992 | - $meta = '#'; | |
| 993 | - | |
| 994 | - $this->show_field_begin($field, $meta); | |
| 995 | - | |
| 996 | -            echo "<input class='at-color' type='text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='8' />"; | |
| 997 | -            //	echo "<a href='#' class='at-color-select button' rel='{$field['id']}'>" . __( 'Select a color' ) . "</a>"; | |
| 998 | -            echo "<input type='button' class='at-color-select button' rel='{$field['id']}' value='" . __('Select a color', 'geodirectory') . "'/>"; | |
| 999 | -            echo "<div style='display:none' class='at-color-picker' rel='{$field['id']}'></div>"; | |
| 1000 | - $this->show_field_end($field, $meta); | |
| 1001 | - | |
| 1002 | - } | |
| 1003 | - | |
| 1004 | - /** | |
| 1005 | - * Show Checkbox List Field | |
| 1006 | - * | |
| 1007 | - * @param string $field | |
| 1008 | - * @param string $meta | |
| 1009 | - * @since 1.0 | |
| 1010 | - * @access public | |
| 1011 | - */ | |
| 1012 | - public function show_field_checkbox_list($field, $meta) | |
| 1013 | -        { | |
| 1014 | - | |
| 1015 | - if (!is_array($meta)) | |
| 1016 | - $meta = (array)$meta; | |
| 1017 | - | |
| 1018 | - $this->show_field_begin($field, $meta); | |
| 1019 | - | |
| 1020 | - $html = array(); | |
| 1021 | - | |
| 1022 | -            foreach ($field['options'] as $key => $value) { | |
| 1023 | -                $html[] = "<input type='checkbox' class='at-checkbox_list' name='{$field['id']}[]' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> {$value}"; | |
| 1024 | - } | |
| 1025 | - | |
| 1026 | -            echo implode('<br />', $html); | |
| 1027 | - | |
| 1028 | - $this->show_field_end($field, $meta); | |
| 1029 | - | |
| 1030 | - } | |
| 1031 | - | |
| 1032 | - /** | |
| 1033 | - * Show Date Field. | |
| 1034 | - * | |
| 1035 | - * @param string $field | |
| 1036 | - * @param string $meta | |
| 1037 | - * @since 1.0 | |
| 1038 | - * @access public | |
| 1039 | - */ | |
| 1040 | - public function show_field_date($field, $meta) | |
| 1041 | -        { | |
| 1042 | - $this->show_field_begin($field, $meta); | |
| 1043 | -            echo "<input type='text' class='at-date' name='{$field['id']}' id='{$field['id']}' rel='{$field['format']}' value='{$meta}' size='30' />"; | |
| 1044 | - $this->show_field_end($field, $meta); | |
| 1045 | - } | |
| 1046 | - | |
| 1047 | - /** | |
| 1048 | - * Show time field. | |
| 1049 | - * | |
| 1050 | - * @param string $field | |
| 1051 | - * @param string $meta | |
| 1052 | - * @since 1.0 | |
| 1053 | - * @access public | |
| 1054 | - */ | |
| 1055 | - public function show_field_time($field, $meta) | |
| 1056 | -        { | |
| 1057 | - $this->show_field_begin($field, $meta); | |
| 1058 | -            echo "<input type='text' class='at-time' name='{$field['id']}' id='{$field['id']}' rel='{$field['format']}' value='{$meta}' size='30' />"; | |
| 1059 | - $this->show_field_end($field, $meta); | |
| 1060 | - } | |
| 1061 | - | |
| 1062 | - /** | |
| 1063 | - * Show Posts field. | |
| 1064 | - * used creating a posts/pages/custom types checkboxlist or a select dropdown | |
| 1065 | - * | |
| 1066 | - * @global object $post The current post object. | |
| 1067 | - * @param string $field | |
| 1068 | - * @param string $meta | |
| 1069 | - * @since 1.0 | |
| 1070 | - * @access public | |
| 1071 | - */ | |
| 1072 | - public function show_field_posts($field, $meta) | |
| 1073 | -        { | |
| 1074 | - global $post; | |
| 1075 | - | |
| 1076 | - if (!is_array($meta)) $meta = (array)$meta; | |
| 1077 | - $this->show_field_begin($field, $meta); | |
| 1078 | - $options = $field['options']; | |
| 1079 | - $posts = get_posts($options['args']); | |
| 1080 | - | |
| 1081 | - // checkbox_list | |
| 1082 | -            if ('checkbox_list' == $options['type']) { | |
| 1083 | -                foreach ($posts as $p) { | |
| 1084 | -                    echo "<input type='checkbox' name='{$field['id']}[]' value='$p->ID'" . checked(in_array($p->ID, $meta), true, false) . " /> $p->post_title<br/>"; | |
| 1085 | - } | |
| 1086 | - } // select | |
| 1087 | -            else { | |
| 1088 | -                echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">"; | |
| 1089 | -                foreach ($posts as $p) { | |
| 1090 | - echo "<option value='$p->ID'" . selected(in_array($p->ID, $meta), true, false) . ">$p->post_title</option>"; | |
| 1091 | - } | |
| 1092 | - echo "</select>"; | |
| 1093 | - } | |
| 1094 | - | |
| 1095 | - $this->show_field_end($field, $meta); | |
| 1096 | - } | |
| 1097 | - | |
| 1098 | - /** | |
| 1099 | - * Show Taxonomy field. | |
| 1100 | - * used creating a category/tags/custom taxonomy checkboxlist or a select dropdown | |
| 1101 | - * | |
| 1102 | - * @global object $post The current post object. | |
| 1103 | - * @param string $field | |
| 1104 | - * @param string $meta | |
| 1105 | - * @since 1.0 | |
| 1106 | - * @access public | |
| 1107 | - * | |
| 1108 | - * @uses get_terms() | |
| 1109 | - */ | |
| 1110 | - public function show_field_taxonomy($field, $meta) | |
| 1111 | -        { | |
| 1112 | - global $post; | |
| 1113 | - | |
| 1114 | - if (!is_array($meta)) $meta = (array)$meta; | |
| 1115 | - $this->show_field_begin($field, $meta); | |
| 1116 | - $options = $field['options']; | |
| 1117 | - $terms = get_terms($options['taxonomy'], $options['args']); | |
| 1118 | - | |
| 1119 | - // checkbox_list | |
| 1120 | -            if ('checkbox_list' == $options['type']) { | |
| 1121 | -                foreach ($terms as $term) { | |
| 1122 | -                    echo "<input type='checkbox' name='{$field['id']}[]' value='$term->slug'" . checked(in_array($term->slug, $meta), true, false) . " /> $term->name<br/>"; | |
| 1123 | - } | |
| 1124 | - } // select | |
| 1125 | -            else { | |
| 1126 | -                echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">"; | |
| 1127 | -                foreach ($terms as $term) { | |
| 1128 | - echo "<option value='$term->slug'" . selected(in_array($term->slug, $meta), true, false) . ">$term->name</option>"; | |
| 1129 | - } | |
| 1130 | - echo "</select>"; | |
| 1131 | - } | |
| 1132 | - | |
| 1133 | - $this->show_field_end($field, $meta); | |
| 1134 | - } | |
| 1135 | - | |
| 1136 | - /** | |
| 1137 | - * Save Data from Metabox | |
| 1138 | - * | |
| 1139 | - * @param string $term_id The term ID. | |
| 1140 | - * @since 1.0 | |
| 1141 | - * @access public | |
| 1142 | - * @return string | |
| 1143 | - */ | |
| 1144 | - public function save($term_id) | |
| 1145 | -        { | |
| 1146 | - | |
| 1147 | - $taxnow = ''; | |
| 1148 | - if (isset($_POST['taxonomy'])) | |
| 1149 | - $taxnow = $_POST['taxonomy']; | |
| 1150 | - | |
| 1151 | - if (!isset($term_id) // Check Revision | |
| 1152 | - || (!in_array($taxnow, $this->_meta_box['pages'])) // Check if current taxonomy type is supported. | |
| 1153 | - || (!check_admin_referer(basename(__FILE__), 'tax_meta_class_nonce')) // Check nonce - Security | |
| 1154 | -                || (!current_user_can('manage_categories')) | |
| 1155 | - ) // Check permission | |
| 1156 | -            { | |
| 1157 | - return $term_id; | |
| 1158 | - } | |
| 1159 | - | |
| 1160 | - | |
| 1161 | -            foreach ($this->_fields as $field) { | |
| 1162 | - | |
| 1163 | - $name = $field['id']; | |
| 1164 | - $type = $field['type']; | |
| 1165 | - $old = $this->get_tax_meta($term_id, $name, !$field['multiple']); | |
| 1166 | - $new = (isset($_POST[$name])) ? $_POST[$name] : (($field['multiple']) ? array() : ''); | |
| 1167 | - | |
| 1168 | - // Validate meta value | |
| 1169 | -                if (class_exists('Tax_Meta_Validate') && method_exists('Tax_Meta_Validate', $field['validate_func'])) { | |
| 1170 | -                    $new = call_user_func(array('Tax_Meta_Validate', $field['validate_func']), $new); | |
| 1171 | - } | |
| 1172 | - | |
| 1173 | - | |
| 1174 | -                if ($name == 'ct_cat_icon') { | |
| 1175 | - | |
| 1176 | - $upload_dir = wp_upload_dir(); | |
| 1177 | - | |
| 1178 | -                    $image_name_arr = explode('/', $new['src']); | |
| 1179 | - //$old_filename = end($image_name_arr); | |
| 1180 | -                    //$img_name_arr = explode('.',$old_filename); | |
| 1181 | - | |
| 1182 | - //$old_filename = $upload_dir['path'].'/'.$old_filename; | |
| 1183 | - | |
| 1184 | - $new_filename = $upload_dir['path'] . '/' . 'cat_icon_' . $term_id . '.png'; | |
| 1185 | - | |
| 1186 | - /*rename($old_filename, $new_filename); | |
| 661 | + $this->show_field_end($field, $meta); | |
| 662 | + } | |
| 663 | + | |
| 664 | + /** | |
| 665 | + * Begin Field. | |
| 666 | + * | |
| 667 | + * @param string $field | |
| 668 | + * @param string $meta | |
| 669 | + * @since 1.0 | |
| 670 | + * @access public | |
| 671 | + */ | |
| 672 | + public function show_field_begin($field, $meta) | |
| 673 | +		{ | |
| 674 | +			if (isset($field['group'])) { | |
| 675 | +				if ($field['group'] == "start") { | |
| 676 | + echo "<td class='at-field'>"; | |
| 677 | + } | |
| 678 | +			} else { | |
| 679 | +				if ($this->_form_type == 'edit') { | |
| 680 | + echo '<th valign="top" scope="row">'; | |
| 681 | +				} else { | |
| 682 | +					if ($field['validate_func']) { | |
| 683 | + echo '<td><div class="form-field form-required">'; | |
| 684 | +					} else { | |
| 685 | + echo '<td><div class="form-field">'; | |
| 686 | + } | |
| 687 | + } | |
| 688 | + } | |
| 689 | +			if ($field['name'] != '' || $field['name'] != FALSE) { | |
| 690 | + //echo "<div class='at-label'>"; | |
| 691 | +				echo "<label for='{$field['id']}'>{$field['name']}</label>"; | |
| 692 | + //echo "</div>"; | |
| 693 | + } | |
| 694 | +			if ($this->_form_type == 'edit') { | |
| 695 | + echo '</th><td>'; | |
| 696 | + } | |
| 697 | + } | |
| 698 | + | |
| 699 | + /** | |
| 700 | + * End Field. | |
| 701 | + * | |
| 702 | + * @param string $field | |
| 703 | + * @param string $meta | |
| 704 | + * @since 1.0 | |
| 705 | + * @access public | |
| 706 | + */ | |
| 707 | + public function show_field_end($field, $meta = NULL, $group = false) | |
| 708 | +		{ | |
| 709 | +			if (isset($field['group'])) { | |
| 710 | +				if ($group == 'end') { | |
| 711 | +					if ($field['desc'] != '') { | |
| 712 | +						echo "<p class='desc-field'>{$field['desc']}</p></td>"; | |
| 713 | +					} else { | |
| 714 | + echo "</td>"; | |
| 715 | + } | |
| 716 | +				} else { | |
| 717 | +					if ($field['desc'] != '') { | |
| 718 | +						echo "<p class='desc-field'>{$field['desc']}</p><br/>"; | |
| 719 | +					} else { | |
| 720 | + echo '<br/>'; | |
| 721 | + } | |
| 722 | + } | |
| 723 | +			} else { | |
| 724 | +				if ($field['desc'] != '') { | |
| 725 | +					echo "<p class='desc-field'>{$field['desc']}</p>"; | |
| 726 | + } | |
| 727 | +				if ($this->_form_type == 'edit') { | |
| 728 | + echo '</td>'; | |
| 729 | +				} else { | |
| 730 | + echo '</td></div>'; | |
| 731 | + } | |
| 732 | + } | |
| 733 | + } | |
| 734 | + | |
| 735 | + /** | |
| 736 | + * Show Field Text. | |
| 737 | + * | |
| 738 | + * @param string $field | |
| 739 | + * @param string $meta | |
| 740 | + * @since 1.0 | |
| 741 | + * @access public | |
| 742 | + */ | |
| 743 | + public function show_field_text($field, $meta) | |
| 744 | +		{ | |
| 745 | + $this->show_field_begin($field, $meta); | |
| 746 | +			echo "<input type='text' class='at-text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='30' />"; | |
| 747 | + $this->show_field_end($field, $meta); | |
| 748 | + } | |
| 749 | + | |
| 750 | + /** | |
| 751 | + * Show Field hidden. | |
| 752 | + * | |
| 753 | + * @param string $field | |
| 754 | + * @param string|mixed $meta | |
| 755 | + * @since 0.1.3 | |
| 756 | + * @access public | |
| 757 | + */ | |
| 758 | + public function show_field_hidden($field, $meta) | |
| 759 | +		{ | |
| 760 | + //$this->show_field_begin( $field, $meta ); | |
| 761 | +			echo "<input type='hidden' class='at-text' name='{$field['id']}' id='{$field['id']}' value='{$meta}'/>"; | |
| 762 | + //$this->show_field_end( $field, $meta ); | |
| 763 | + } | |
| 764 | + | |
| 765 | + /** | |
| 766 | + * Show Field Paragraph. | |
| 767 | + * | |
| 768 | + * @param string $field | |
| 769 | + * @since 0.1.3 | |
| 770 | + * @access public | |
| 771 | + */ | |
| 772 | + public function show_field_paragraph($field) | |
| 773 | +		{ | |
| 774 | + //$this->show_field_begin( $field, $meta ); | |
| 775 | + echo '<p>' . $field['value'] . '</p>'; | |
| 776 | + //$this->show_field_end( $field, $meta ); | |
| 777 | + } | |
| 778 | + | |
| 779 | + /** | |
| 780 | + * Show Field Textarea. | |
| 781 | + * | |
| 782 | + * @param string $field | |
| 783 | + * @param string $meta | |
| 784 | + * @since 1.0 | |
| 785 | + * @access public | |
| 786 | + */ | |
| 787 | + public function show_field_textarea($field, $meta) | |
| 788 | +		{ | |
| 789 | + $this->show_field_begin($field, $meta); | |
| 790 | +			echo "<textarea class='at-textarea large-text' name='{$field['id']}' id='{$field['id']}' cols='60' rows='10'>{$meta}</textarea>"; | |
| 791 | + $this->show_field_end($field, $meta); | |
| 792 | + } | |
| 793 | + | |
| 794 | + /** | |
| 795 | + * Show Field Select. | |
| 796 | + * | |
| 797 | + * @param string $field | |
| 798 | + * @param string $meta | |
| 799 | + * @since 1.0 | |
| 800 | + * @access public | |
| 801 | + */ | |
| 802 | + public function show_field_select($field, $meta) | |
| 803 | +		{ | |
| 804 | + | |
| 805 | + if (!is_array($meta)) | |
| 806 | + $meta = (array)$meta; | |
| 807 | + | |
| 808 | + $this->show_field_begin($field, $meta); | |
| 809 | +			echo "<select class='at-select' name='{$field['id']}" . ($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'") . ">"; | |
| 810 | +			foreach ($field['options'] as $key => $value) { | |
| 811 | +				echo "<option value='{$key}'" . selected(in_array($key, $meta), true, false) . ">{$value}</option>"; | |
| 812 | + } | |
| 813 | + echo "</select>"; | |
| 814 | + $this->show_field_end($field, $meta); | |
| 815 | + | |
| 816 | + } | |
| 817 | + | |
| 818 | + /** | |
| 819 | + * Show Radio Field. | |
| 820 | + * | |
| 821 | + * @param string $field | |
| 822 | + * @param string $meta | |
| 823 | + * @since 1.0 | |
| 824 | + * @access public | |
| 825 | + */ | |
| 826 | + public function show_field_radio($field, $meta) | |
| 827 | +		{ | |
| 828 | + | |
| 829 | + if (!is_array($meta)) | |
| 830 | + $meta = (array)$meta; | |
| 831 | + | |
| 832 | + $this->show_field_begin($field, $meta); | |
| 833 | +			foreach ($field['options'] as $key => $value) { | |
| 834 | +				echo "<input type='radio' class='at-radio' name='{$field['id']}' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> <span class='at-radio-label'>{$value}</span>"; | |
| 835 | + } | |
| 836 | + $this->show_field_end($field, $meta); | |
| 837 | + } | |
| 838 | + | |
| 839 | + /** | |
| 840 | + * Show Checkbox Field. | |
| 841 | + * | |
| 842 | + * @param string $field | |
| 843 | + * @param string $meta | |
| 844 | + * @since 1.0 | |
| 845 | + * @access public | |
| 846 | + */ | |
| 847 | + public function show_field_checkbox($field, $meta) | |
| 848 | +		{ | |
| 849 | + | |
| 850 | + $this->show_field_begin($field, $meta); | |
| 851 | +			echo "<input type='checkbox' class='rw-checkbox' name='{$field['id']}' id='{$field['id']}'" . checked(!empty($meta), true, false) . " /> {$field['desc']}"; | |
| 852 | + $this->show_field_end($field, $meta); | |
| 853 | + } | |
| 854 | + | |
| 855 | + /** | |
| 856 | + * Show Wysiwig Field. | |
| 857 | + * | |
| 858 | + * @param string $field | |
| 859 | + * @param string $meta | |
| 860 | + * @since 1.0 | |
| 861 | + * @access public | |
| 862 | + */ | |
| 863 | + public function show_field_wysiwyg($field, $meta) | |
| 864 | +		{ | |
| 865 | + $this->show_field_begin($field, $meta); | |
| 866 | + // Add TinyMCE script for WP version < 3.3 | |
| 867 | + global $wp_version; | |
| 868 | + | |
| 869 | +			if (version_compare($wp_version, '3.2.1') < 1) { | |
| 870 | +				echo "<textarea class='at-wysiwyg theEditor large-text' name='{$field['id']}' id='{$field['id']}' cols='60' rows='10'>{$meta}</textarea>"; | |
| 871 | +			} else { | |
| 872 | + // Use new wp_editor() since WP 3.3 | |
| 873 | +				wp_editor(stripslashes(html_entity_decode($meta)), $field['id'], array('editor_class' => 'at-wysiwyg')); | |
| 874 | + } | |
| 875 | + $this->show_field_end($field, $meta); | |
| 876 | + } | |
| 877 | + | |
| 878 | + /** | |
| 879 | + * Show File Field. | |
| 880 | + * | |
| 881 | + * @global object $post The current post object. | |
| 882 | + * @param string $field | |
| 883 | + * @param string $meta | |
| 884 | + * @since 1.0 | |
| 885 | + * @access public | |
| 886 | + */ | |
| 887 | + public function show_field_file($field, $meta) | |
| 888 | +		{ | |
| 889 | + | |
| 890 | + global $post; | |
| 891 | + | |
| 892 | + if (!is_array($meta)) | |
| 893 | + $meta = (array)$meta; | |
| 894 | + | |
| 895 | + $this->show_field_begin($field, $meta); | |
| 896 | +			echo "{$field['desc']}<br />"; | |
| 897 | + | |
| 898 | +			if (!empty($meta)) { | |
| 899 | +				$nonce = wp_create_nonce('at_ajax_delete'); | |
| 900 | +				echo '<div style="margin-bottom: 10px"><strong>' . __('Uploaded files', 'geodirectory') . '</strong></div>'; | |
| 901 | + echo '<ol class="at-upload">'; | |
| 902 | +				foreach ($meta as $att) { | |
| 903 | + // if (wp_attachment_is_image($att)) continue; // what's image uploader for? | |
| 904 | +					echo "<li>" . wp_get_attachment_link($att, '', false, false, ' ') . " (<a class='at-delete-file' href='#' rel='{$nonce}|{$post->ID}|{$field['id']}|{$att}'>" . __('Remove', 'geodirectory') . "</a>)</li>"; | |
| 905 | + } | |
| 906 | + echo '</ol>'; | |
| 907 | + } | |
| 908 | + | |
| 909 | + // show form upload | |
| 910 | + | |
| 911 | + echo "<div class='at-file-upload-label'>"; | |
| 912 | +			echo "<strong>" . __('Upload new files', 'geodirectory') . "</strong>"; | |
| 913 | + echo "</div>"; | |
| 914 | + echo "<div class='new-files'>"; | |
| 915 | + echo "<div class='file-input'>"; | |
| 916 | +			echo "<input type='file' name='{$field['id']}[]' />"; | |
| 917 | + echo "</div><!-- End .file-input -->"; | |
| 918 | +			echo "<a class='at-add-file button' href='#'>" . __('Add more files', 'geodirectory') . "</a>"; | |
| 919 | + echo "</div><!-- End .new-files -->"; | |
| 920 | + echo "</td>"; | |
| 921 | + $this->show_field_end($field, $meta); | |
| 922 | + } | |
| 923 | + | |
| 924 | + /** | |
| 925 | + * Show Image Field. | |
| 926 | + * | |
| 927 | + * @param array $field | |
| 928 | + * @param array $meta | |
| 929 | + * @since 1.0 | |
| 930 | + * @access public | |
| 931 | + */ | |
| 932 | + public function show_field_image($field, $meta) | |
| 933 | +		{ | |
| 934 | + $this->show_field_begin($field, $meta); | |
| 935 | +			$html = wp_nonce_field("at-delete-mupload_{$field['id']}", "nonce-delete-mupload_" . $field['id'], false, false); | |
| 936 | +			if (is_array($meta)) { | |
| 937 | + if (isset($meta[0]) && is_array($meta[0])) | |
| 938 | + $meta = $meta[0]; | |
| 939 | + } | |
| 940 | + | |
| 941 | + $uploads = wp_upload_dir(); | |
| 942 | +			if (is_array($meta) && isset($meta['src']) && $meta['src'] != '') { | |
| 943 | + | |
| 944 | + $file_info = pathinfo($meta['src']); | |
| 945 | + | |
| 946 | + //print_r($meta); | |
| 947 | + //print_r($uploads); | |
| 948 | + //print_r($file_info); | |
| 949 | + | |
| 950 | + if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') | |
| 951 | + $sub_dir = $file_info['dirname']; | |
| 952 | + | |
| 953 | + $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs | |
| 954 | + $uploads_baseurl = $uploads['baseurl']; | |
| 955 | + $uploads_path = $uploads['path']; | |
| 956 | + | |
| 957 | + $file_name = $file_info['basename']; | |
| 958 | + | |
| 959 | + $sub_dir = str_replace($uploads_baseurl, '', $sub_dir); | |
| 960 | + | |
| 961 | + $uploads_url = $uploads_baseurl . $sub_dir; | |
| 962 | + | |
| 963 | + $meta['src'] = $uploads_url . '/' . $file_name; | |
| 964 | + | |
| 965 | + | |
| 966 | + $html .= "<span class='mupload_img_holder'><img src='" . $meta['src'] . "' style='max-height: 150px;max-width: 150px;' /></span>"; | |
| 967 | + $html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='" . $meta['id'] . "' />"; | |
| 968 | + $html .= "<input type='hidden' class='" . $field['id'] . "[src]' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='" . $meta['src'] . "' />"; | |
| 969 | +				$html .= "<input class='at-delete_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Remove Image', 'geodirectory') . "' />"; | |
| 970 | +			} else { | |
| 971 | + $html .= "<span class='mupload_img_holder'></span>"; | |
| 972 | + $html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='' />"; | |
| 973 | + $html .= "<input class='" . $field['id'] . "[src]' style='position:absolute;left:-500px;width:50px;' type='text' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='' />"; | |
| 974 | +				$html .= "<input class='at-upload_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Upload Image', 'geodirectory') . "' />"; | |
| 975 | + } | |
| 976 | + echo $html; | |
| 977 | + $this->show_field_end($field, $meta); | |
| 978 | + } | |
| 979 | + | |
| 980 | + /** | |
| 981 | + * Show Color Field. | |
| 982 | + * | |
| 983 | + * @param string $field | |
| 984 | + * @param string $meta | |
| 985 | + * @since 1.0 | |
| 986 | + * @access public | |
| 987 | + */ | |
| 988 | + public function show_field_color($field, $meta) | |
| 989 | +		{ | |
| 990 | + | |
| 991 | + if (empty($meta)) | |
| 992 | + $meta = '#'; | |
| 993 | + | |
| 994 | + $this->show_field_begin($field, $meta); | |
| 995 | + | |
| 996 | +			echo "<input class='at-color' type='text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='8' />"; | |
| 997 | +			//	echo "<a href='#' class='at-color-select button' rel='{$field['id']}'>" . __( 'Select a color' ) . "</a>"; | |
| 998 | +			echo "<input type='button' class='at-color-select button' rel='{$field['id']}' value='" . __('Select a color', 'geodirectory') . "'/>"; | |
| 999 | +			echo "<div style='display:none' class='at-color-picker' rel='{$field['id']}'></div>"; | |
| 1000 | + $this->show_field_end($field, $meta); | |
| 1001 | + | |
| 1002 | + } | |
| 1003 | + | |
| 1004 | + /** | |
| 1005 | + * Show Checkbox List Field | |
| 1006 | + * | |
| 1007 | + * @param string $field | |
| 1008 | + * @param string $meta | |
| 1009 | + * @since 1.0 | |
| 1010 | + * @access public | |
| 1011 | + */ | |
| 1012 | + public function show_field_checkbox_list($field, $meta) | |
| 1013 | +		{ | |
| 1014 | + | |
| 1015 | + if (!is_array($meta)) | |
| 1016 | + $meta = (array)$meta; | |
| 1017 | + | |
| 1018 | + $this->show_field_begin($field, $meta); | |
| 1019 | + | |
| 1020 | + $html = array(); | |
| 1021 | + | |
| 1022 | +			foreach ($field['options'] as $key => $value) { | |
| 1023 | +				$html[] = "<input type='checkbox' class='at-checkbox_list' name='{$field['id']}[]' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> {$value}"; | |
| 1024 | + } | |
| 1025 | + | |
| 1026 | +			echo implode('<br />', $html); | |
| 1027 | + | |
| 1028 | + $this->show_field_end($field, $meta); | |
| 1029 | + | |
| 1030 | + } | |
| 1031 | + | |
| 1032 | + /** | |
| 1033 | + * Show Date Field. | |
| 1034 | + * | |
| 1035 | + * @param string $field | |
| 1036 | + * @param string $meta | |
| 1037 | + * @since 1.0 | |
| 1038 | + * @access public | |
| 1039 | + */ | |
| 1040 | + public function show_field_date($field, $meta) | |
| 1041 | +		{ | |
| 1042 | + $this->show_field_begin($field, $meta); | |
| 1043 | +			echo "<input type='text' class='at-date' name='{$field['id']}' id='{$field['id']}' rel='{$field['format']}' value='{$meta}' size='30' />"; | |
| 1044 | + $this->show_field_end($field, $meta); | |
| 1045 | + } | |
| 1046 | + | |
| 1047 | + /** | |
| 1048 | + * Show time field. | |
| 1049 | + * | |
| 1050 | + * @param string $field | |
| 1051 | + * @param string $meta | |
| 1052 | + * @since 1.0 | |
| 1053 | + * @access public | |
| 1054 | + */ | |
| 1055 | + public function show_field_time($field, $meta) | |
| 1056 | +		{ | |
| 1057 | + $this->show_field_begin($field, $meta); | |
| 1058 | +			echo "<input type='text' class='at-time' name='{$field['id']}' id='{$field['id']}' rel='{$field['format']}' value='{$meta}' size='30' />"; | |
| 1059 | + $this->show_field_end($field, $meta); | |
| 1060 | + } | |
| 1061 | + | |
| 1062 | + /** | |
| 1063 | + * Show Posts field. | |
| 1064 | + * used creating a posts/pages/custom types checkboxlist or a select dropdown | |
| 1065 | + * | |
| 1066 | + * @global object $post The current post object. | |
| 1067 | + * @param string $field | |
| 1068 | + * @param string $meta | |
| 1069 | + * @since 1.0 | |
| 1070 | + * @access public | |
| 1071 | + */ | |
| 1072 | + public function show_field_posts($field, $meta) | |
| 1073 | +		{ | |
| 1074 | + global $post; | |
| 1075 | + | |
| 1076 | + if (!is_array($meta)) $meta = (array)$meta; | |
| 1077 | + $this->show_field_begin($field, $meta); | |
| 1078 | + $options = $field['options']; | |
| 1079 | + $posts = get_posts($options['args']); | |
| 1080 | + | |
| 1081 | + // checkbox_list | |
| 1082 | +			if ('checkbox_list' == $options['type']) { | |
| 1083 | +				foreach ($posts as $p) { | |
| 1084 | +					echo "<input type='checkbox' name='{$field['id']}[]' value='$p->ID'" . checked(in_array($p->ID, $meta), true, false) . " /> $p->post_title<br/>"; | |
| 1085 | + } | |
| 1086 | + } // select | |
| 1087 | +			else { | |
| 1088 | +				echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">"; | |
| 1089 | +				foreach ($posts as $p) { | |
| 1090 | + echo "<option value='$p->ID'" . selected(in_array($p->ID, $meta), true, false) . ">$p->post_title</option>"; | |
| 1091 | + } | |
| 1092 | + echo "</select>"; | |
| 1093 | + } | |
| 1094 | + | |
| 1095 | + $this->show_field_end($field, $meta); | |
| 1096 | + } | |
| 1097 | + | |
| 1098 | + /** | |
| 1099 | + * Show Taxonomy field. | |
| 1100 | + * used creating a category/tags/custom taxonomy checkboxlist or a select dropdown | |
| 1101 | + * | |
| 1102 | + * @global object $post The current post object. | |
| 1103 | + * @param string $field | |
| 1104 | + * @param string $meta | |
| 1105 | + * @since 1.0 | |
| 1106 | + * @access public | |
| 1107 | + * | |
| 1108 | + * @uses get_terms() | |
| 1109 | + */ | |
| 1110 | + public function show_field_taxonomy($field, $meta) | |
| 1111 | +		{ | |
| 1112 | + global $post; | |
| 1113 | + | |
| 1114 | + if (!is_array($meta)) $meta = (array)$meta; | |
| 1115 | + $this->show_field_begin($field, $meta); | |
| 1116 | + $options = $field['options']; | |
| 1117 | + $terms = get_terms($options['taxonomy'], $options['args']); | |
| 1118 | + | |
| 1119 | + // checkbox_list | |
| 1120 | +			if ('checkbox_list' == $options['type']) { | |
| 1121 | +				foreach ($terms as $term) { | |
| 1122 | +					echo "<input type='checkbox' name='{$field['id']}[]' value='$term->slug'" . checked(in_array($term->slug, $meta), true, false) . " /> $term->name<br/>"; | |
| 1123 | + } | |
| 1124 | + } // select | |
| 1125 | +			else { | |
| 1126 | +				echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">"; | |
| 1127 | +				foreach ($terms as $term) { | |
| 1128 | + echo "<option value='$term->slug'" . selected(in_array($term->slug, $meta), true, false) . ">$term->name</option>"; | |
| 1129 | + } | |
| 1130 | + echo "</select>"; | |
| 1131 | + } | |
| 1132 | + | |
| 1133 | + $this->show_field_end($field, $meta); | |
| 1134 | + } | |
| 1135 | + | |
| 1136 | + /** | |
| 1137 | + * Save Data from Metabox | |
| 1138 | + * | |
| 1139 | + * @param string $term_id The term ID. | |
| 1140 | + * @since 1.0 | |
| 1141 | + * @access public | |
| 1142 | + * @return string | |
| 1143 | + */ | |
| 1144 | + public function save($term_id) | |
| 1145 | +		{ | |
| 1146 | + | |
| 1147 | + $taxnow = ''; | |
| 1148 | + if (isset($_POST['taxonomy'])) | |
| 1149 | + $taxnow = $_POST['taxonomy']; | |
| 1150 | + | |
| 1151 | + if (!isset($term_id) // Check Revision | |
| 1152 | + || (!in_array($taxnow, $this->_meta_box['pages'])) // Check if current taxonomy type is supported. | |
| 1153 | + || (!check_admin_referer(basename(__FILE__), 'tax_meta_class_nonce')) // Check nonce - Security | |
| 1154 | +				|| (!current_user_can('manage_categories')) | |
| 1155 | + ) // Check permission | |
| 1156 | +			{ | |
| 1157 | + return $term_id; | |
| 1158 | + } | |
| 1159 | + | |
| 1160 | + | |
| 1161 | +			foreach ($this->_fields as $field) { | |
| 1162 | + | |
| 1163 | + $name = $field['id']; | |
| 1164 | + $type = $field['type']; | |
| 1165 | + $old = $this->get_tax_meta($term_id, $name, !$field['multiple']); | |
| 1166 | + $new = (isset($_POST[$name])) ? $_POST[$name] : (($field['multiple']) ? array() : ''); | |
| 1167 | + | |
| 1168 | + // Validate meta value | |
| 1169 | +				if (class_exists('Tax_Meta_Validate') && method_exists('Tax_Meta_Validate', $field['validate_func'])) { | |
| 1170 | +					$new = call_user_func(array('Tax_Meta_Validate', $field['validate_func']), $new); | |
| 1171 | + } | |
| 1172 | + | |
| 1173 | + | |
| 1174 | +				if ($name == 'ct_cat_icon') { | |
| 1175 | + | |
| 1176 | + $upload_dir = wp_upload_dir(); | |
| 1177 | + | |
| 1178 | +					$image_name_arr = explode('/', $new['src']); | |
| 1179 | + //$old_filename = end($image_name_arr); | |
| 1180 | +					//$img_name_arr = explode('.',$old_filename); | |
| 1181 | + | |
| 1182 | + //$old_filename = $upload_dir['path'].'/'.$old_filename; | |
| 1183 | + | |
| 1184 | + $new_filename = $upload_dir['path'] . '/' . 'cat_icon_' . $term_id . '.png'; | |
| 1185 | + | |
| 1186 | + /*rename($old_filename, $new_filename); | |
| 1187 | 1187 | |
| 1188 | 1188 | //subdir | 
| 1189 | 1189 | $new['src'] = $upload_dir['url'].'/'.'cat_icon_'.$term_id.'.png'; | 
| @@ -1191,7 +1191,7 @@ discard block | ||
| 1191 | 1191 | update_attached_file( $new['id'], $new['src'] );*/ | 
| 1192 | 1192 | |
| 1193 | 1193 | |
| 1194 | - /* | |
| 1194 | + /* | |
| 1195 | 1195 | |
| 1196 | 1196 | $new['src'] = $upload_dir['url'].'/'.'cat_icon_'.$term_id.'.png'; | 
| 1197 | 1197 | |
| @@ -1216,67 +1216,67 @@ discard block | ||
| 1216 | 1216 | $attach_id = wp_insert_attachment( $attachment, $filename);*/ | 
| 1217 | 1217 | |
| 1218 | 1218 | |
| 1219 | - } | |
| 1220 | - | |
| 1221 | - | |
| 1222 | - //skip on Paragraph field | |
| 1223 | -                if ($type != "paragraph") { | |
| 1224 | - | |
| 1225 | - // Call defined method to save meta value, if there's no methods, call common one. | |
| 1226 | - $save_func = 'save_field_' . $type; | |
| 1227 | -                    if (method_exists($this, $save_func)) { | |
| 1228 | - call_user_func(array(&$this, 'save_field_' . $type), $term_id, $field, $old, $new); | |
| 1229 | -                    } else { | |
| 1230 | - $this->save_field($term_id, $field, $old, $new); | |
| 1231 | - } | |
| 1232 | - } | |
| 1233 | - | |
| 1234 | - } // End foreach | |
| 1235 | - | |
| 1236 | - } | |
| 1237 | - | |
| 1238 | - /** | |
| 1239 | - * Common function for saving fields. | |
| 1240 | - * | |
| 1241 | - * @param string $term_id The term ID. | |
| 1242 | - * @param string $field | |
| 1243 | - * @param string $old | |
| 1244 | - * @param string|mixed $new | |
| 1245 | - * @since 1.0 | |
| 1246 | - * @access public | |
| 1247 | - */ | |
| 1248 | - public function save_field($term_id, $field, $old, $new) | |
| 1249 | -        { | |
| 1250 | - $name = $field['id']; | |
| 1251 | - $this->delete_tax_meta($term_id, $name); | |
| 1252 | - if ($new === '' || $new === array()) | |
| 1253 | - return; | |
| 1254 | - | |
| 1255 | - $this->update_tax_meta($term_id, $name, $new); | |
| 1256 | - } | |
| 1257 | - | |
| 1258 | - /** | |
| 1259 | - * function for saving image field. | |
| 1260 | - * | |
| 1261 | - * @param string $term_id The term ID. | |
| 1262 | - * @param string $field | |
| 1263 | - * @param string $old | |
| 1264 | - * @param string|mixed $new | |
| 1265 | - * @since 1.0 | |
| 1266 | - * @access public | |
| 1267 | - */ | |
| 1268 | - public function save_field_image($term_id, $field, $old, $new) | |
| 1269 | -        { | |
| 1270 | - $name = $field['id']; | |
| 1271 | - | |
| 1272 | - $this->delete_tax_meta($term_id, $name); | |
| 1273 | - if ($new === '' || $new === array() || $new['id'] == '' || $new['src'] == '') | |
| 1274 | - return; | |
| 1275 | - | |
| 1276 | - $this->update_tax_meta($term_id, $name, $new); | |
| 1277 | - } | |
| 1278 | - | |
| 1279 | - /* | |
| 1219 | + } | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + //skip on Paragraph field | |
| 1223 | +				if ($type != "paragraph") { | |
| 1224 | + | |
| 1225 | + // Call defined method to save meta value, if there's no methods, call common one. | |
| 1226 | + $save_func = 'save_field_' . $type; | |
| 1227 | +					if (method_exists($this, $save_func)) { | |
| 1228 | + call_user_func(array(&$this, 'save_field_' . $type), $term_id, $field, $old, $new); | |
| 1229 | +					} else { | |
| 1230 | + $this->save_field($term_id, $field, $old, $new); | |
| 1231 | + } | |
| 1232 | + } | |
| 1233 | + | |
| 1234 | + } // End foreach | |
| 1235 | + | |
| 1236 | + } | |
| 1237 | + | |
| 1238 | + /** | |
| 1239 | + * Common function for saving fields. | |
| 1240 | + * | |
| 1241 | + * @param string $term_id The term ID. | |
| 1242 | + * @param string $field | |
| 1243 | + * @param string $old | |
| 1244 | + * @param string|mixed $new | |
| 1245 | + * @since 1.0 | |
| 1246 | + * @access public | |
| 1247 | + */ | |
| 1248 | + public function save_field($term_id, $field, $old, $new) | |
| 1249 | +		{ | |
| 1250 | + $name = $field['id']; | |
| 1251 | + $this->delete_tax_meta($term_id, $name); | |
| 1252 | + if ($new === '' || $new === array()) | |
| 1253 | + return; | |
| 1254 | + | |
| 1255 | + $this->update_tax_meta($term_id, $name, $new); | |
| 1256 | + } | |
| 1257 | + | |
| 1258 | + /** | |
| 1259 | + * function for saving image field. | |
| 1260 | + * | |
| 1261 | + * @param string $term_id The term ID. | |
| 1262 | + * @param string $field | |
| 1263 | + * @param string $old | |
| 1264 | + * @param string|mixed $new | |
| 1265 | + * @since 1.0 | |
| 1266 | + * @access public | |
| 1267 | + */ | |
| 1268 | + public function save_field_image($term_id, $field, $old, $new) | |
| 1269 | +		{ | |
| 1270 | + $name = $field['id']; | |
| 1271 | + | |
| 1272 | + $this->delete_tax_meta($term_id, $name); | |
| 1273 | + if ($new === '' || $new === array() || $new['id'] == '' || $new['src'] == '') | |
| 1274 | + return; | |
| 1275 | + | |
| 1276 | + $this->update_tax_meta($term_id, $name, $new); | |
| 1277 | + } | |
| 1278 | + | |
| 1279 | + /* | |
| 1280 | 1280 | * Save Wysiwyg Field. | 
| 1281 | 1281 | * | 
| 1282 | 1282 | * @param string $term_id The term ID. | 
| @@ -1286,806 +1286,806 @@ discard block | ||
| 1286 | 1286 | * @since 1.0 | 
| 1287 | 1287 | * @access public | 
| 1288 | 1288 | */ | 
| 1289 | - public function save_field_wysiwyg($term_id, $field, $old, $new) | |
| 1290 | -        { | |
| 1291 | - $this->save_field($term_id, $field, $old, $new); | |
| 1292 | - } | |
| 1293 | - | |
| 1294 | - /** | |
| 1295 | - * Save repeater Fields. | |
| 1296 | - * | |
| 1297 | - * @param string $term_id The term ID. | |
| 1298 | - * @param string $field | |
| 1299 | - * @param string|mixed $old | |
| 1300 | - * @param string|mixed $new | |
| 1301 | - * @since 1.0 | |
| 1302 | - * @access public | |
| 1303 | - */ | |
| 1304 | - public function save_field_repeater($term_id, $field, $old, $new) | |
| 1305 | -        { | |
| 1306 | -            if (is_array($new) && count($new) > 0) { | |
| 1307 | -                foreach ($new as $n) { | |
| 1308 | -                    foreach ($field['fields'] as $f) { | |
| 1309 | - $type = $f['type']; | |
| 1310 | -                        switch ($type) { | |
| 1311 | - case 'wysiwyg': | |
| 1312 | - $n[$f['id']] = wpautop($n[$f['id']]); | |
| 1313 | - break; | |
| 1314 | - case 'file': | |
| 1315 | - $n[$f['id']] = $this->save_field_file_repeater($term_id, $f, '', $n[$f['id']]); | |
| 1316 | - break; | |
| 1317 | - default: | |
| 1318 | - break; | |
| 1319 | - } | |
| 1320 | - } | |
| 1321 | - if (!$this->is_array_empty($n)) | |
| 1322 | - $temp[] = $n; | |
| 1323 | - } | |
| 1324 | -                if (isset($temp) && count($temp) > 0 && !$this->is_array_empty($temp)) { | |
| 1325 | - $this->update_tax_meta($term_id, $field['id'], $temp); | |
| 1326 | -                } else { | |
| 1327 | - // remove old meta if exists | |
| 1328 | - delete_post_meta($term_id, $field['id']); | |
| 1329 | - } | |
| 1330 | -            } else { | |
| 1331 | - // remove old meta if exists | |
| 1332 | - delete_post_meta($term_id, $field['id']); | |
| 1333 | - } | |
| 1334 | - } | |
| 1335 | - | |
| 1336 | - /** | |
| 1337 | - * Save File Field. | |
| 1338 | - * | |
| 1339 | - * @param string $term_id The term ID. | |
| 1340 | - * @param string $field | |
| 1341 | - * @param string $old | |
| 1342 | - * @param string $new | |
| 1343 | - * @since 1.0 | |
| 1344 | - * @access public | |
| 1345 | - */ | |
| 1346 | - public function save_field_file($term_id, $field, $old, $new) | |
| 1347 | -        { | |
| 1348 | - | |
| 1349 | - $name = $field['id']; | |
| 1350 | - if (empty($_FILES[$name])) | |
| 1351 | - return; | |
| 1352 | - $this->fix_file_array($_FILES[$name]); | |
| 1353 | -            foreach ($_FILES[$name] as $position => $fileitem) { | |
| 1354 | - | |
| 1355 | -                $file = wp_handle_upload($fileitem, array('test_form' => false)); | |
| 1356 | - if (empty($file['file'])) | |
| 1357 | - continue; | |
| 1358 | - $filename = $file['file']; | |
| 1359 | - | |
| 1360 | - $attachment = array( | |
| 1361 | - 'post_mime_type' => $file['type'], | |
| 1362 | - 'guid' => $file['url'], | |
| 1363 | - 'post_parent' => $term_id, | |
| 1364 | -                    'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)), | |
| 1365 | - 'post_content' => '' | |
| 1366 | - ); | |
| 1367 | - | |
| 1368 | - $id = wp_insert_attachment($attachment, $filename, $term_id); | |
| 1369 | - | |
| 1370 | -                if (!is_wp_error($id)) { | |
| 1371 | - | |
| 1372 | - wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); | |
| 1373 | - add_post_meta($term_id, $name, $id, false); // save file's url in meta fields | |
| 1374 | - | |
| 1375 | - } // End if | |
| 1376 | - | |
| 1377 | - } // End foreach | |
| 1378 | - | |
| 1379 | - } | |
| 1380 | - | |
| 1381 | - /** | |
| 1382 | - * Save repeater File Field. | |
| 1383 | - * @param string $term_id The term ID. | |
| 1384 | - * @param string $field | |
| 1385 | - * @param string $old | |
| 1386 | - * @param string $new | |
| 1387 | - * @since 1.0 | |
| 1388 | - * @access public | |
| 1389 | - * @return int|void | |
| 1390 | - */ | |
| 1391 | - public function save_field_file_repeater($term_id, $field, $old, $new) | |
| 1392 | -        { | |
| 1393 | - | |
| 1394 | - $name = $field['id']; | |
| 1395 | - if (empty($_FILES[$name])) | |
| 1396 | - return; | |
| 1397 | - $this->fix_file_array($_FILES[$name]); | |
| 1398 | -            foreach ($_FILES[$name] as $position => $fileitem) { | |
| 1399 | - | |
| 1400 | -                $file = wp_handle_upload($fileitem, array('test_form' => false)); | |
| 1401 | - if (empty($file['file'])) | |
| 1402 | - continue; | |
| 1403 | - $filename = $file['file']; | |
| 1404 | - | |
| 1405 | - $attachment = array( | |
| 1406 | - 'post_mime_type' => $file['type'], | |
| 1407 | - 'guid' => $file['url'], | |
| 1408 | - 'post_parent' => $term_id, | |
| 1409 | -                    'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)), | |
| 1410 | - 'post_content' => '' | |
| 1411 | - ); | |
| 1412 | - | |
| 1413 | - $id = wp_insert_attachment($attachment, $filename); | |
| 1414 | - | |
| 1415 | -                if (!is_wp_error($id)) { | |
| 1416 | - | |
| 1417 | - wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); | |
| 1418 | - return $id; // return file's url in meta fields | |
| 1419 | - } // End if | |
| 1420 | - } // End foreach | |
| 1421 | - } | |
| 1422 | - | |
| 1423 | - /** | |
| 1424 | - * Add missed values for meta box. | |
| 1425 | - * | |
| 1426 | - * @since 1.0 | |
| 1427 | - * @access public | |
| 1428 | - */ | |
| 1429 | - public function add_missed_values() | |
| 1430 | -        { | |
| 1431 | - | |
| 1432 | - // Default values for meta box | |
| 1433 | -            $this->_meta_box = array_merge(array('context' => 'normal', 'priority' => 'high', 'pages' => array('post')), (array)$this->_meta_box); | |
| 1434 | - | |
| 1435 | -            if(is_array($this->_fields)) { | |
| 1436 | - // Default values for fields | |
| 1437 | -                foreach ($this->_fields as &$field) { | |
| 1438 | -                    $multiple = in_array($field['type'], array('checkbox_list', 'file', 'image')); | |
| 1439 | - $std = $multiple ? array() : ''; | |
| 1440 | -                    $format = 'date' == $field['type'] ? 'yy-mm-dd' : ('time' == $field['type'] ? 'hh:mm' : ''); | |
| 1441 | -                    $field = array_merge(array('multiple' => $multiple, 'std' => $std, 'desc' => '', 'format' => $format, 'validate_func' => ''), $field); | |
| 1442 | - } // End foreach | |
| 1443 | - } | |
| 1444 | - } | |
| 1445 | - | |
| 1446 | - /** | |
| 1447 | - * Check if field with $type exists. | |
| 1448 | - * | |
| 1449 | - * @param string $type | |
| 1450 | - * @since 1.0 | |
| 1451 | - * @access public | |
| 1452 | - */ | |
| 1453 | - public function has_field($type) | |
| 1454 | -        { | |
| 1455 | -            if(is_array($this->_fields)) { | |
| 1456 | -                foreach ($this->_fields as $field) { | |
| 1457 | - if ($type == $field['type']) | |
| 1458 | - return true; | |
| 1459 | - } | |
| 1460 | - } | |
| 1461 | - return false; | |
| 1462 | - } | |
| 1463 | - | |
| 1464 | - /** | |
| 1465 | - * Check if current page is edit page. | |
| 1466 | - * | |
| 1467 | - * @since 1.0 | |
| 1468 | - * @access public | |
| 1469 | - */ | |
| 1470 | - public function is_edit_page() | |
| 1471 | -        { | |
| 1472 | - global $pagenow; | |
| 1473 | - return ($pagenow == 'edit-tags.php' || $pagenow == 'term.php'); | |
| 1474 | - } | |
| 1475 | - | |
| 1476 | - /** | |
| 1477 | - * Fixes the odd indexing of multiple file uploads. | |
| 1478 | - * | |
| 1479 | - * Goes from the format: | |
| 1480 | - * $_FILES['field']['key']['index'] | |
| 1481 | - * to | |
| 1482 | - * The More standard and appropriate: | |
| 1483 | - * $_FILES['field']['index']['key'] | |
| 1484 | - * | |
| 1485 | - * @param string $files | |
| 1486 | - * @since 1.0 | |
| 1487 | - * @access public | |
| 1488 | - */ | |
| 1489 | - public function fix_file_array(&$files) | |
| 1490 | -        { | |
| 1491 | - | |
| 1492 | - $output = array(); | |
| 1493 | - | |
| 1494 | -            foreach ($files as $key => $list) { | |
| 1495 | -                foreach ($list as $index => $value) { | |
| 1496 | - $output[$index][$key] = $value; | |
| 1497 | - } | |
| 1498 | - } | |
| 1499 | - | |
| 1500 | - return $files = $output; | |
| 1501 | - | |
| 1502 | - } | |
| 1503 | - | |
| 1504 | - /** | |
| 1505 | - * Get proper JQuery UI version. | |
| 1506 | - * | |
| 1507 | - * Used in order to not conflict with WP Admin Scripts. | |
| 1508 | - * | |
| 1509 | - * @since 1.0 | |
| 1510 | - * @access public | |
| 1511 | - */ | |
| 1512 | - public function get_jqueryui_ver() | |
| 1513 | -        { | |
| 1514 | - | |
| 1515 | - global $wp_version; | |
| 1516 | - | |
| 1517 | -            if (version_compare($wp_version, '3.1', '>=')) { | |
| 1518 | - return '1.8.10'; | |
| 1519 | - } | |
| 1520 | - | |
| 1521 | - return '1.7.3'; | |
| 1522 | - | |
| 1523 | - } | |
| 1524 | - | |
| 1525 | - /** | |
| 1526 | - * Add Field to meta box (generic function) | |
| 1527 | - * @author Ohad Raz | |
| 1528 | - * @since 1.0 | |
| 1529 | - * @access public | |
| 1530 | - * @param $id string field id, i.e. the meta key | |
| 1531 | - * @param $args mixed|array | |
| 1532 | - */ | |
| 1533 | - public function addField($id, $args) | |
| 1534 | -        { | |
| 1535 | -            $new_field = array('id' => $id, 'std' => '', 'desc' => '', 'style' => ''); | |
| 1536 | - $new_field = array_merge($new_field, $args); | |
| 1537 | - $this->_fields[] = $new_field; | |
| 1538 | - } | |
| 1539 | - | |
| 1540 | - | |
| 1541 | - /** | |
| 1542 | - * Add Text Field to meta box | |
| 1543 | - * @author Ohad Raz | |
| 1544 | - * @since 1.0 | |
| 1545 | - * @access public | |
| 1546 | - * @param $id string field id, i.e. the meta key | |
| 1547 | - * @param $args mixed|array | |
| 1548 | - * 'name' => // field name/label string optional | |
| 1549 | - * 'desc' => // field description, string optional | |
| 1550 | - * 'std' => // default value, string optional | |
| 1551 | - * 'style' => // custom style for field, string optional | |
| 1552 | - * 'validate_func' => // validate function, string optional | |
| 1553 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1554 | - */ | |
| 1555 | - public function addText($id, $args, $repeater = false) | |
| 1556 | -        { | |
| 1557 | -            $new_field = array('type' => 'text', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Text Field', 'geodirectory')); | |
| 1558 | - $new_field = array_merge($new_field, $args); | |
| 1559 | -            if (false === $repeater) { | |
| 1560 | - $this->_fields[] = $new_field; | |
| 1561 | -            } else { | |
| 1562 | - return $new_field; | |
| 1563 | - } | |
| 1564 | - } | |
| 1565 | - | |
| 1566 | - /** | |
| 1567 | - * Add Hidden Field to meta box | |
| 1568 | - * @author Ohad Raz | |
| 1569 | - * @since 0.1.3 | |
| 1570 | - * @access public | |
| 1571 | - * @param $id string field id, i.e. the meta key | |
| 1572 | - * @param $args mixed|array | |
| 1573 | - * 'name' => // field name/label string optional | |
| 1574 | - * 'desc' => // field description, string optional | |
| 1575 | - * 'std' => // default value, string optional | |
| 1576 | - * 'style' => // custom style for field, string optional | |
| 1577 | - * 'validate_func' => // validate function, string optional | |
| 1578 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1579 | - */ | |
| 1580 | - public function addHidden($id, $args, $repeater = false) | |
| 1581 | -        { | |
| 1582 | -            $new_field = array('type' => 'hidden', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Text Field', 'geodirectory')); | |
| 1583 | - $new_field = array_merge($new_field, $args); | |
| 1584 | -            if (false === $repeater) { | |
| 1585 | - $this->_fields[] = $new_field; | |
| 1586 | -            } else { | |
| 1587 | - return $new_field; | |
| 1588 | - } | |
| 1589 | - } | |
| 1590 | - | |
| 1591 | - /** | |
| 1592 | - * Add Paragraph to meta box | |
| 1593 | - * @author Ohad Raz | |
| 1594 | - * @since 0.1.3 | |
| 1595 | - * @access public | |
| 1596 | - * @param $id string field id, i.e. the meta key | |
| 1597 | - * @param $value paragraph html | |
| 1598 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1599 | - */ | |
| 1600 | - public function addParagraph($id, $args, $repeater = false) | |
| 1601 | -        { | |
| 1602 | -            $new_field = array('type' => 'paragraph', 'id' => $id, 'value' => '', 'style' => ''); | |
| 1603 | - $new_field = array_merge($new_field, $args); | |
| 1604 | -            if (false === $repeater) { | |
| 1605 | - $this->_fields[] = $new_field; | |
| 1606 | -            } else { | |
| 1607 | - return $new_field; | |
| 1608 | - } | |
| 1609 | - } | |
| 1610 | - | |
| 1611 | - /** | |
| 1612 | - * Add Checkbox Field to meta box | |
| 1613 | - * @author Ohad Raz | |
| 1614 | - * @since 1.0 | |
| 1615 | - * @access public | |
| 1616 | - * @param $id string field id, i.e. the meta key | |
| 1617 | - * @param $args mixed|array | |
| 1618 | - * 'name' => // field name/label string optional | |
| 1619 | - * 'desc' => // field description, string optional | |
| 1620 | - * 'std' => // default value, string optional | |
| 1621 | - * 'validate_func' => // validate function, string optional | |
| 1622 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1623 | - */ | |
| 1624 | - public function addCheckbox($id, $args, $repeater = false) | |
| 1625 | -        { | |
| 1626 | -            $new_field = array('type' => 'checkbox', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Checkbox Field', 'geodirectory')); | |
| 1627 | - $new_field = array_merge($new_field, $args); | |
| 1628 | -            if (false === $repeater) { | |
| 1629 | - $this->_fields[] = $new_field; | |
| 1630 | -            } else { | |
| 1631 | - return $new_field; | |
| 1632 | - } | |
| 1633 | - } | |
| 1634 | - | |
| 1635 | - /** | |
| 1636 | - * Add CheckboxList Field to meta box | |
| 1637 | - * @author Ohad Raz | |
| 1638 | - * @since 1.0 | |
| 1639 | - * @access public | |
| 1640 | - * @param $id string field id, i.e. the meta key | |
| 1641 | - * @param $options (array) array of key => value pairs for select options | |
| 1642 | - * @param $args mixed|array | |
| 1643 | - * 'name' => // field name/label string optional | |
| 1644 | - * 'desc' => // field description, string optional | |
| 1645 | - * 'std' => // default value, string optional | |
| 1646 | - * 'validate_func' => // validate function, string optional | |
| 1647 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1648 | - * | |
| 1649 | - * @return : remember to call: $checkbox_list = $this->get_tax_meta(get_the_ID(), 'meta_name', false); | |
| 1650 | - * which means the last param as false to get the values in an array | |
| 1651 | - */ | |
| 1652 | - public function addCheckboxList($id, $options, $args, $repeater = false) | |
| 1653 | -        { | |
| 1654 | -            $new_field = array('type' => 'checkbox_list', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Checkbox List Field', 'geodirectory')); | |
| 1655 | - $new_field = array_merge($new_field, $args); | |
| 1656 | -            if (false === $repeater) { | |
| 1657 | - $this->_fields[] = $new_field; | |
| 1658 | -            } else { | |
| 1659 | - return $new_field; | |
| 1660 | - } | |
| 1661 | - } | |
| 1662 | - | |
| 1663 | - /** | |
| 1664 | - * Add Textarea Field to meta box | |
| 1665 | - * @author Ohad Raz | |
| 1666 | - * @since 1.0 | |
| 1667 | - * @access public | |
| 1668 | - * @param $id string field id, i.e. the meta key | |
| 1669 | - * @param $args mixed|array | |
| 1670 | - * 'name' => // field name/label string optional | |
| 1671 | - * 'desc' => // field description, string optional | |
| 1672 | - * 'std' => // default value, string optional | |
| 1673 | - * 'style' => // custom style for field, string optional | |
| 1674 | - * 'validate_func' => // validate function, string optional | |
| 1675 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1676 | - */ | |
| 1677 | - public function addTextarea($id, $args, $repeater = false) | |
| 1678 | -        { | |
| 1679 | -            $new_field = array('type' => 'textarea', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Textarea Field', 'geodirectory')); | |
| 1680 | - $new_field = array_merge($new_field, $args); | |
| 1681 | -            if (false === $repeater) { | |
| 1682 | - $this->_fields[] = $new_field; | |
| 1683 | -            } else { | |
| 1684 | - return $new_field; | |
| 1685 | - } | |
| 1686 | - } | |
| 1687 | - | |
| 1688 | - /** | |
| 1689 | - * Add Select Field to meta box | |
| 1690 | - * @author Ohad Raz | |
| 1691 | - * @since 1.0 | |
| 1692 | - * @access public | |
| 1693 | - * @param $id string field id, i.e. the meta key | |
| 1694 | - * @param $options (array) array of key => value pairs for select options | |
| 1695 | - * @param $args mixed|array | |
| 1696 | - * 'name' => // field name/label string optional | |
| 1697 | - * 'desc' => // field description, string optional | |
| 1698 | - * 'std' => // default value, (array) optional | |
| 1699 | - * 'multiple' => // select multiple values, optional. Default is false. | |
| 1700 | - * 'validate_func' => // validate function, string optional | |
| 1701 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1702 | - */ | |
| 1703 | - public function addSelect($id, $options, $args, $repeater = false) | |
| 1704 | -        { | |
| 1705 | -            $new_field = array('type' => 'select', 'id' => $id, 'std' => array(), 'desc' => '', 'style' => '', 'name' => __('Select Field', 'geodirectory'), 'multiple' => false, 'options' => $options); | |
| 1706 | - $new_field = array_merge($new_field, $args); | |
| 1707 | -            if (false === $repeater) { | |
| 1708 | - $this->_fields[] = $new_field; | |
| 1709 | -            } else { | |
| 1710 | - return $new_field; | |
| 1711 | - } | |
| 1712 | - } | |
| 1713 | - | |
| 1714 | - | |
| 1715 | - /** | |
| 1716 | - * Add Radio Field to meta box | |
| 1717 | - * @author Ohad Raz | |
| 1718 | - * @since 1.0 | |
| 1719 | - * @access public | |
| 1720 | - * @param $id string field id, i.e. the meta key | |
| 1721 | - * @param $options (array) array of key => value pairs for radio options | |
| 1722 | - * @param $args mixed|array | |
| 1723 | - * 'name' => // field name/label string optional | |
| 1724 | - * 'desc' => // field description, string optional | |
| 1725 | - * 'std' => // default value, string optional | |
| 1726 | - * 'validate_func' => // validate function, string optional | |
| 1727 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1728 | - */ | |
| 1729 | - public function addRadio($id, $options, $args, $repeater = false) | |
| 1730 | -        { | |
| 1731 | -            $new_field = array('type' => 'radio', 'id' => $id, 'std' => array(), 'desc' => '', 'style' => '', 'name' => __('Radio Field', 'geodirectory'), 'options' => $options); | |
| 1732 | - $new_field = array_merge($new_field, $args); | |
| 1733 | -            if (false === $repeater) { | |
| 1734 | - $this->_fields[] = $new_field; | |
| 1735 | -            } else { | |
| 1736 | - return $new_field; | |
| 1737 | - } | |
| 1738 | - } | |
| 1739 | - | |
| 1740 | - /** | |
| 1741 | - * Add Date Field to meta box | |
| 1742 | - * @author Ohad Raz | |
| 1743 | - * @since 1.0 | |
| 1744 | - * @access public | |
| 1745 | - * @param $id string field id, i.e. the meta key | |
| 1746 | - * @param $args mixed|array | |
| 1747 | - * 'name' => // field name/label string optional | |
| 1748 | - * 'desc' => // field description, string optional | |
| 1749 | - * 'std' => // default value, string optional | |
| 1750 | - * 'validate_func' => // validate function, string optional | |
| 1751 | - * 'format' => // date format, default yy-mm-dd. Optional. Default "'d MM, yy'" See more formats here: http://goo.gl/Wcwxn | |
| 1752 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1753 | - */ | |
| 1754 | - public function addDate($id, $args, $repeater = false) | |
| 1755 | -        { | |
| 1756 | -            $new_field = array('type' => 'date', 'id' => $id, 'std' => '', 'desc' => '', 'format' => 'yy-mm-dd', 'name' => __('Date Field', 'geodirectory')); | |
| 1757 | - $new_field = array_merge($new_field, $args); | |
| 1758 | -            if (false === $repeater) { | |
| 1759 | - $this->_fields[] = $new_field; | |
| 1760 | -            } else { | |
| 1761 | - return $new_field; | |
| 1762 | - } | |
| 1763 | - } | |
| 1764 | - | |
| 1765 | - /** | |
| 1766 | - * Add Time Field to meta box | |
| 1767 | - * @author Ohad Raz | |
| 1768 | - * @since 1.0 | |
| 1769 | - * @access public | |
| 1770 | - * @param $id string- field id, i.e. the meta key | |
| 1771 | - * @param $args mixed|array | |
| 1772 | - * 'name' => // field name/label string optional | |
| 1773 | - * 'desc' => // field description, string optional | |
| 1774 | - * 'std' => // default value, string optional | |
| 1775 | - * 'validate_func' => // validate function, string optional | |
| 1776 | - * 'format' => // time format, default hh:mm. Optional. See more formats here: http://goo.gl/83woX | |
| 1777 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1778 | - */ | |
| 1779 | - public function addTime($id, $args, $repeater = false) | |
| 1780 | -        { | |
| 1781 | -            $new_field = array('type' => 'time', 'id' => $id, 'std' => '', 'desc' => '', 'format' => 'hh:mm', 'name' => __('Time Field', 'geodirectory')); | |
| 1782 | - $new_field = array_merge($new_field, $args); | |
| 1783 | -            if (false === $repeater) { | |
| 1784 | - $this->_fields[] = $new_field; | |
| 1785 | -            } else { | |
| 1786 | - return $new_field; | |
| 1787 | - } | |
| 1788 | - } | |
| 1789 | - | |
| 1790 | - /** | |
| 1791 | - * Add Color Field to meta box | |
| 1792 | - * @author Ohad Raz | |
| 1793 | - * @since 1.0 | |
| 1794 | - * @access public | |
| 1795 | - * @param $id string field id, i.e. the meta key | |
| 1796 | - * @param $args mixed|array | |
| 1797 | - * 'name' => // field name/label string optional | |
| 1798 | - * 'desc' => // field description, string optional | |
| 1799 | - * 'std' => // default value, string optional | |
| 1800 | - * 'validate_func' => // validate function, string optional | |
| 1801 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1802 | - */ | |
| 1803 | - public function addColor($id, $args, $repeater = false) | |
| 1804 | -        { | |
| 1805 | -            $new_field = array('type' => 'color', 'id' => $id, 'std' => '', 'desc' => '', 'name' => __('ColorPicker Field', 'geodirectory')); | |
| 1806 | - $new_field = array_merge($new_field, $args); | |
| 1807 | -            if (false === $repeater) { | |
| 1808 | - $this->_fields[] = $new_field; | |
| 1809 | -            } else { | |
| 1810 | - return $new_field; | |
| 1811 | - } | |
| 1812 | - } | |
| 1813 | - | |
| 1814 | - /** | |
| 1815 | - * Add Image Field to meta box | |
| 1816 | - * @author Ohad Raz | |
| 1817 | - * @since 1.0 | |
| 1818 | - * @access public | |
| 1819 | - * @param $id string field id, i.e. the meta key | |
| 1820 | - * @param $args mixed|array | |
| 1821 | - * 'name' => // field name/label string optional | |
| 1822 | - * 'desc' => // field description, string optional | |
| 1823 | - * 'validate_func' => // validate function, string optional | |
| 1824 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1825 | - */ | |
| 1826 | - public function addImage($id, $args, $repeater = false) | |
| 1827 | -        { | |
| 1828 | -            $new_field = array('type' => 'image', 'id' => $id, 'desc' => '', 'style' => '', 'name' => __('Image Field', 'geodirectory')); | |
| 1829 | - $new_field = array_merge($new_field, $args); | |
| 1830 | - | |
| 1831 | -            if (false === $repeater) { | |
| 1832 | - $this->_fields[] = $new_field; | |
| 1833 | -            } else { | |
| 1834 | - return $new_field; | |
| 1835 | - } | |
| 1836 | - } | |
| 1837 | - | |
| 1838 | - /** | |
| 1839 | - * Add File Field to meta box | |
| 1840 | - * @author Ohad Raz | |
| 1841 | - * @since 1.0 | |
| 1842 | - * @access public | |
| 1843 | - * @param $id string field id, i.e. the meta key | |
| 1844 | - * @param $args mixed|array | |
| 1845 | - * 'name' => // field name/label string optional | |
| 1846 | - * 'desc' => // field description, string optional | |
| 1847 | - * 'validate_func' => // validate function, string optional | |
| 1848 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1849 | - */ | |
| 1850 | - public function addFile($id, $args, $repeater = false) | |
| 1851 | -        { | |
| 1852 | -            $new_field = array('type' => 'file', 'id' => $id, 'desc' => '', 'style' => '', 'name' => __('File Field', 'geodirectory')); | |
| 1853 | - $new_field = array_merge($new_field, $args); | |
| 1854 | -            if (false === $repeater) { | |
| 1855 | - $this->_fields[] = $new_field; | |
| 1856 | -            } else { | |
| 1857 | - return $new_field; | |
| 1858 | - } | |
| 1859 | - } | |
| 1860 | - | |
| 1861 | - /** | |
| 1862 | - * Add WYSIWYG Field to meta box | |
| 1863 | - * @author Ohad Raz | |
| 1864 | - * @since 1.0 | |
| 1865 | - * @access public | |
| 1866 | - * @param $id string field id, i.e. the meta key | |
| 1867 | - * @param $args mixed|array | |
| 1868 | - * 'name' => // field name/label string optional | |
| 1869 | - * 'desc' => // field description, string optional | |
| 1870 | - * 'std' => // default value, string optional | |
| 1871 | - * 'style' => // custom style for field, string optional Default 'width: 300px; height: 400px' | |
| 1872 | - * 'validate_func' => // validate function, string optional | |
| 1873 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1874 | - */ | |
| 1875 | - public function addWysiwyg($id, $args, $repeater = false) | |
| 1876 | -        { | |
| 1877 | -            $new_field = array('type' => 'wysiwyg', 'id' => $id, 'std' => '', 'desc' => '', 'style' => 'width: 300px; height: 400px', 'name' => __('WYSIWYG Editor Field', 'geodirectory')); | |
| 1878 | - $new_field = array_merge($new_field, $args); | |
| 1879 | -            if (false === $repeater) { | |
| 1880 | - $this->_fields[] = $new_field; | |
| 1881 | -            } else { | |
| 1882 | - return $new_field; | |
| 1883 | - } | |
| 1884 | - } | |
| 1885 | - | |
| 1886 | - /** | |
| 1887 | - * Add Taxonomy Field to meta box | |
| 1888 | - * @author Ohad Raz | |
| 1889 | - * @since 1.0 | |
| 1890 | - * @access public | |
| 1891 | - * @param $id string field id, i.e. the meta key | |
| 1892 | - * @param $options mixed|array options of taxonomy field | |
| 1893 | - * 'taxonomy' => // taxonomy name can be category,post_tag or any custom taxonomy default is category | |
| 1894 | - * 'type' => // how to show taxonomy? 'select' (default) or 'checkbox_list' | |
| 1895 | -         * 'args' =>  // arguments to query taxonomy, see http://goo.gl/uAANN default ('hide_empty' => false) | |
| 1896 | - * @param $args mixed|array | |
| 1897 | - * 'name' => // field name/label string optional | |
| 1898 | - * 'desc' => // field description, string optional | |
| 1899 | - * 'std' => // default value, string optional | |
| 1900 | - * 'validate_func' => // validate function, string optional | |
| 1901 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1902 | - */ | |
| 1903 | - public function addTaxonomy($id, $options, $args, $repeater = false) | |
| 1904 | -        { | |
| 1905 | -            $q = array('hide_empty' => 0); | |
| 1906 | - $tax = 'category'; | |
| 1907 | - $type = 'select'; | |
| 1908 | - $temp = array($tax, $type, $q); | |
| 1909 | - $options = array_merge($temp, $options); | |
| 1910 | -            $new_field = array('type' => 'taxonomy', 'id' => $id, 'desc' => '', 'name' => __('Taxonomy Field', 'geodirectory'), 'options' => $options); | |
| 1911 | - $new_field = array_merge($new_field, $args); | |
| 1912 | -            if (false === $repeater) { | |
| 1913 | - $this->_fields[] = $new_field; | |
| 1914 | -            } else { | |
| 1915 | - return $new_field; | |
| 1916 | - } | |
| 1917 | - } | |
| 1918 | - | |
| 1919 | - /** | |
| 1920 | - * Add posts Field to meta box | |
| 1921 | - * @author Ohad Raz | |
| 1922 | - * @since 1.0 | |
| 1923 | - * @access public | |
| 1924 | - * @param $id string field id, i.e. the meta key | |
| 1925 | - * @param $options mixed|array options of taxonomy field | |
| 1926 | - * 'post_type' => // post type name, 'post' (default) 'page' or any custom post type | |
| 1927 | - * 'type' => // how to show posts? 'select' (default) or 'checkbox_list' | |
| 1928 | -         * 'args' =>  // arguments to query posts, see http://goo.gl/is0yK default ('posts_per_page' => -1) | |
| 1929 | - * @param $args mixed|array | |
| 1930 | - * 'name' => // field name/label string optional | |
| 1931 | - * 'desc' => // field description, string optional | |
| 1932 | - * 'std' => // default value, string optional | |
| 1933 | - * 'validate_func' => // validate function, string optional | |
| 1934 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1935 | - */ | |
| 1936 | - public function addPosts($id, $options, $args, $repeater = false) | |
| 1937 | -        { | |
| 1938 | -            $q = array('posts_per_page' => -1); | |
| 1939 | -            $temp = array('post_type' => 'post', 'type' => 'select', 'args' => $q); | |
| 1940 | - $options = array_merge($temp, $options); | |
| 1941 | -            $new_field = array('type' => 'posts', 'id' => $id, 'desc' => '', 'name' => __('Posts Field', 'geodirectory'), 'options' => $options); | |
| 1942 | - $new_field = array_merge($new_field, $args); | |
| 1943 | -            if (false === $repeater) { | |
| 1944 | - $this->_fields[] = $new_field; | |
| 1945 | -            } else { | |
| 1946 | - return $new_field; | |
| 1947 | - } | |
| 1948 | - } | |
| 1949 | - | |
| 1950 | - /** | |
| 1951 | - * Add repeater Field Block to meta box | |
| 1952 | - * @author Ohad Raz | |
| 1953 | - * @since 1.0 | |
| 1954 | - * @access public | |
| 1955 | - * @param $id string field id, i.e. the meta key | |
| 1956 | - * @param $args mixed|array | |
| 1957 | - * 'name' => // field name/label string optional | |
| 1958 | - * 'desc' => // field description, string optional | |
| 1959 | - * 'std' => // default value, string optional | |
| 1960 | - * 'style' => // custom style for field, string optional | |
| 1961 | - * 'validate_func' => // validate function, string optional | |
| 1962 | - * 'fields' => //fields to repeater | |
| 1963 | - */ | |
| 1964 | - public function addRepeaterBlock($id, $args) | |
| 1965 | -        { | |
| 1966 | -            $new_field = array('type' => 'repeater', 'id' => $id, 'name' => __('Reapeater Field', 'geodirectory'), 'fields' => array(), 'inline' => false); | |
| 1967 | - $new_field = array_merge($new_field, $args); | |
| 1968 | - $this->_fields[] = $new_field; | |
| 1969 | - } | |
| 1970 | - | |
| 1971 | - | |
| 1972 | - /** | |
| 1973 | - * Finish Declaration of Meta Box | |
| 1974 | - * @author Ohad Raz | |
| 1975 | - * @since 1.0 | |
| 1976 | - * @access public | |
| 1977 | - */ | |
| 1978 | - public function Finish() | |
| 1979 | -        { | |
| 1980 | - $this->add_missed_values(); | |
| 1981 | - $this->check_field_upload(); | |
| 1982 | - $this->check_field_color(); | |
| 1983 | - $this->check_field_date(); | |
| 1984 | - $this->check_field_time(); | |
| 1985 | - } | |
| 1986 | - | |
| 1987 | - /** | |
| 1988 | - * Helper function to check for empty arrays | |
| 1989 | - * @author Ohad Raz | |
| 1990 | - * @since 1.0 | |
| 1991 | - * @access public | |
| 1992 | - * @param $args mixed|array | |
| 1993 | - */ | |
| 1994 | - public function is_array_empty($array) | |
| 1995 | -        { | |
| 1996 | - if (!is_array($array)) | |
| 1997 | - return true; | |
| 1998 | - | |
| 1999 | -            foreach ($array as $a) { | |
| 2000 | -                if (is_array($a)) { | |
| 2001 | -                    foreach ($a as $sub_a) { | |
| 2002 | - if (!empty($sub_a) && $sub_a != '') | |
| 2003 | - return false; | |
| 2004 | - } | |
| 2005 | -                } else { | |
| 2006 | - if (!empty($a) && $a != '') | |
| 2007 | - return false; | |
| 2008 | - } | |
| 2009 | - } | |
| 2010 | - return true; | |
| 2011 | - } | |
| 2012 | - | |
| 2013 | - | |
| 2014 | - //get term meta field | |
| 2015 | - public function get_tax_meta($term_id, $key, $multi = false, $post_type = '') | |
| 2016 | -        { | |
| 2017 | - | |
| 2018 | -            if (empty($post_type) && isset($_REQUEST['taxonomy'])) { | |
| 2019 | - $taxObject = get_taxonomy($_REQUEST['taxonomy']); | |
| 2020 | - $post_type = $taxObject->object_type[0]; | |
| 2021 | - } | |
| 2022 | - | |
| 2023 | -            if($post_type=='post'){$post_type='';} | |
| 2024 | -            if($post_type){$post_type = $post_type.'_';} | |
| 2025 | - | |
| 2026 | - $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id; | |
| 2027 | - | |
| 2028 | -            $m = get_option('tax_meta_' . $post_type  . $t_id); | |
| 2029 | -            if (isset($m[$key])) { | |
| 2030 | - return $m[$key]; | |
| 2031 | -            } else { | |
| 2032 | - return ''; | |
| 2033 | - } | |
| 2034 | - } | |
| 2035 | - | |
| 2036 | - //delete meta | |
| 2037 | - public function delete_tax_meta($term_id, $key, $post_type = '') | |
| 2038 | -        { | |
| 2039 | - | |
| 2040 | -            if (empty($post_type) && isset($_REQUEST['taxonomy'])) { | |
| 2041 | - $taxObject = get_taxonomy($_REQUEST['taxonomy']); | |
| 2042 | - $post_type = $taxObject->object_type[0]; | |
| 2043 | - } | |
| 2044 | - | |
| 2045 | -            if($post_type=='post'){$post_type='';} | |
| 2046 | -            if($post_type){$post_type = $post_type.'_';} | |
| 2047 | - | |
| 2048 | -            $m = get_option('tax_meta_' . $post_type  . $term_id); | |
| 2049 | - | |
| 2050 | -            if (isset($m[$key])) { | |
| 2051 | - unset($m[$key]); | |
| 2052 | - } | |
| 2053 | -            update_option('tax_meta_' . $post_type  . $term_id, $m); | |
| 2054 | - } | |
| 2055 | - | |
| 2056 | - //update meta | |
| 2057 | - public function update_tax_meta($term_id, $key, $value, $post_type = '') | |
| 2058 | -        { | |
| 2059 | - | |
| 2060 | -            if (empty($post_type) && isset($_REQUEST['taxonomy'])) { | |
| 2061 | - $taxObject = get_taxonomy($_REQUEST['taxonomy']); | |
| 2062 | - $post_type = $taxObject->object_type[0]; | |
| 2063 | - } | |
| 2064 | - | |
| 2065 | -            if($post_type=='post'){$post_type='';} | |
| 2066 | -            if($post_type){$post_type = $post_type.'_';} | |
| 2067 | - | |
| 2068 | -            $m = get_option('tax_meta_' . $post_type  . $term_id); | |
| 2069 | - | |
| 2070 | - $m[$key] = $value; | |
| 2071 | -            update_option('tax_meta_' . $post_type  . $term_id, $m); | |
| 2072 | - | |
| 2073 | - /** | |
| 2074 | - * Called after the tax meta is updated. | |
| 2075 | - * | |
| 2076 | - * Used to update things after a GD category is saved. | |
| 2077 | - * | |
| 2078 | - * @since 1.0.0 | |
| 2079 | - * @param bool $false False. | |
| 2080 | - * @param bool $true True. | |
| 2081 | - * @param int $term_id The term id being updated. | |
| 2082 | - * @param string $post_type The post type of the cat being updated. | |
| 2083 | - */ | |
| 2084 | -            do_action('gd_tax_meta_updated', false, true, $term_id, $post_type); | |
| 2085 | - } | |
| 2086 | - | |
| 2087 | - | |
| 2088 | - } // End Class | |
| 1289 | + public function save_field_wysiwyg($term_id, $field, $old, $new) | |
| 1290 | +		{ | |
| 1291 | + $this->save_field($term_id, $field, $old, $new); | |
| 1292 | + } | |
| 1293 | + | |
| 1294 | + /** | |
| 1295 | + * Save repeater Fields. | |
| 1296 | + * | |
| 1297 | + * @param string $term_id The term ID. | |
| 1298 | + * @param string $field | |
| 1299 | + * @param string|mixed $old | |
| 1300 | + * @param string|mixed $new | |
| 1301 | + * @since 1.0 | |
| 1302 | + * @access public | |
| 1303 | + */ | |
| 1304 | + public function save_field_repeater($term_id, $field, $old, $new) | |
| 1305 | +		{ | |
| 1306 | +			if (is_array($new) && count($new) > 0) { | |
| 1307 | +				foreach ($new as $n) { | |
| 1308 | +					foreach ($field['fields'] as $f) { | |
| 1309 | + $type = $f['type']; | |
| 1310 | +						switch ($type) { | |
| 1311 | + case 'wysiwyg': | |
| 1312 | + $n[$f['id']] = wpautop($n[$f['id']]); | |
| 1313 | + break; | |
| 1314 | + case 'file': | |
| 1315 | + $n[$f['id']] = $this->save_field_file_repeater($term_id, $f, '', $n[$f['id']]); | |
| 1316 | + break; | |
| 1317 | + default: | |
| 1318 | + break; | |
| 1319 | + } | |
| 1320 | + } | |
| 1321 | + if (!$this->is_array_empty($n)) | |
| 1322 | + $temp[] = $n; | |
| 1323 | + } | |
| 1324 | +				if (isset($temp) && count($temp) > 0 && !$this->is_array_empty($temp)) { | |
| 1325 | + $this->update_tax_meta($term_id, $field['id'], $temp); | |
| 1326 | +				} else { | |
| 1327 | + // remove old meta if exists | |
| 1328 | + delete_post_meta($term_id, $field['id']); | |
| 1329 | + } | |
| 1330 | +			} else { | |
| 1331 | + // remove old meta if exists | |
| 1332 | + delete_post_meta($term_id, $field['id']); | |
| 1333 | + } | |
| 1334 | + } | |
| 1335 | + | |
| 1336 | + /** | |
| 1337 | + * Save File Field. | |
| 1338 | + * | |
| 1339 | + * @param string $term_id The term ID. | |
| 1340 | + * @param string $field | |
| 1341 | + * @param string $old | |
| 1342 | + * @param string $new | |
| 1343 | + * @since 1.0 | |
| 1344 | + * @access public | |
| 1345 | + */ | |
| 1346 | + public function save_field_file($term_id, $field, $old, $new) | |
| 1347 | +		{ | |
| 1348 | + | |
| 1349 | + $name = $field['id']; | |
| 1350 | + if (empty($_FILES[$name])) | |
| 1351 | + return; | |
| 1352 | + $this->fix_file_array($_FILES[$name]); | |
| 1353 | +			foreach ($_FILES[$name] as $position => $fileitem) { | |
| 1354 | + | |
| 1355 | +				$file = wp_handle_upload($fileitem, array('test_form' => false)); | |
| 1356 | + if (empty($file['file'])) | |
| 1357 | + continue; | |
| 1358 | + $filename = $file['file']; | |
| 1359 | + | |
| 1360 | + $attachment = array( | |
| 1361 | + 'post_mime_type' => $file['type'], | |
| 1362 | + 'guid' => $file['url'], | |
| 1363 | + 'post_parent' => $term_id, | |
| 1364 | +					'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)), | |
| 1365 | + 'post_content' => '' | |
| 1366 | + ); | |
| 1367 | + | |
| 1368 | + $id = wp_insert_attachment($attachment, $filename, $term_id); | |
| 1369 | + | |
| 1370 | +				if (!is_wp_error($id)) { | |
| 1371 | + | |
| 1372 | + wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); | |
| 1373 | + add_post_meta($term_id, $name, $id, false); // save file's url in meta fields | |
| 1374 | + | |
| 1375 | + } // End if | |
| 1376 | + | |
| 1377 | + } // End foreach | |
| 1378 | + | |
| 1379 | + } | |
| 1380 | + | |
| 1381 | + /** | |
| 1382 | + * Save repeater File Field. | |
| 1383 | + * @param string $term_id The term ID. | |
| 1384 | + * @param string $field | |
| 1385 | + * @param string $old | |
| 1386 | + * @param string $new | |
| 1387 | + * @since 1.0 | |
| 1388 | + * @access public | |
| 1389 | + * @return int|void | |
| 1390 | + */ | |
| 1391 | + public function save_field_file_repeater($term_id, $field, $old, $new) | |
| 1392 | +		{ | |
| 1393 | + | |
| 1394 | + $name = $field['id']; | |
| 1395 | + if (empty($_FILES[$name])) | |
| 1396 | + return; | |
| 1397 | + $this->fix_file_array($_FILES[$name]); | |
| 1398 | +			foreach ($_FILES[$name] as $position => $fileitem) { | |
| 1399 | + | |
| 1400 | +				$file = wp_handle_upload($fileitem, array('test_form' => false)); | |
| 1401 | + if (empty($file['file'])) | |
| 1402 | + continue; | |
| 1403 | + $filename = $file['file']; | |
| 1404 | + | |
| 1405 | + $attachment = array( | |
| 1406 | + 'post_mime_type' => $file['type'], | |
| 1407 | + 'guid' => $file['url'], | |
| 1408 | + 'post_parent' => $term_id, | |
| 1409 | +					'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)), | |
| 1410 | + 'post_content' => '' | |
| 1411 | + ); | |
| 1412 | + | |
| 1413 | + $id = wp_insert_attachment($attachment, $filename); | |
| 1414 | + | |
| 1415 | +				if (!is_wp_error($id)) { | |
| 1416 | + | |
| 1417 | + wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); | |
| 1418 | + return $id; // return file's url in meta fields | |
| 1419 | + } // End if | |
| 1420 | + } // End foreach | |
| 1421 | + } | |
| 1422 | + | |
| 1423 | + /** | |
| 1424 | + * Add missed values for meta box. | |
| 1425 | + * | |
| 1426 | + * @since 1.0 | |
| 1427 | + * @access public | |
| 1428 | + */ | |
| 1429 | + public function add_missed_values() | |
| 1430 | +		{ | |
| 1431 | + | |
| 1432 | + // Default values for meta box | |
| 1433 | +			$this->_meta_box = array_merge(array('context' => 'normal', 'priority' => 'high', 'pages' => array('post')), (array)$this->_meta_box); | |
| 1434 | + | |
| 1435 | +			if(is_array($this->_fields)) { | |
| 1436 | + // Default values for fields | |
| 1437 | +				foreach ($this->_fields as &$field) { | |
| 1438 | +					$multiple = in_array($field['type'], array('checkbox_list', 'file', 'image')); | |
| 1439 | + $std = $multiple ? array() : ''; | |
| 1440 | +					$format = 'date' == $field['type'] ? 'yy-mm-dd' : ('time' == $field['type'] ? 'hh:mm' : ''); | |
| 1441 | +					$field = array_merge(array('multiple' => $multiple, 'std' => $std, 'desc' => '', 'format' => $format, 'validate_func' => ''), $field); | |
| 1442 | + } // End foreach | |
| 1443 | + } | |
| 1444 | + } | |
| 1445 | + | |
| 1446 | + /** | |
| 1447 | + * Check if field with $type exists. | |
| 1448 | + * | |
| 1449 | + * @param string $type | |
| 1450 | + * @since 1.0 | |
| 1451 | + * @access public | |
| 1452 | + */ | |
| 1453 | + public function has_field($type) | |
| 1454 | +		{ | |
| 1455 | +			if(is_array($this->_fields)) { | |
| 1456 | +				foreach ($this->_fields as $field) { | |
| 1457 | + if ($type == $field['type']) | |
| 1458 | + return true; | |
| 1459 | + } | |
| 1460 | + } | |
| 1461 | + return false; | |
| 1462 | + } | |
| 1463 | + | |
| 1464 | + /** | |
| 1465 | + * Check if current page is edit page. | |
| 1466 | + * | |
| 1467 | + * @since 1.0 | |
| 1468 | + * @access public | |
| 1469 | + */ | |
| 1470 | + public function is_edit_page() | |
| 1471 | +		{ | |
| 1472 | + global $pagenow; | |
| 1473 | + return ($pagenow == 'edit-tags.php' || $pagenow == 'term.php'); | |
| 1474 | + } | |
| 1475 | + | |
| 1476 | + /** | |
| 1477 | + * Fixes the odd indexing of multiple file uploads. | |
| 1478 | + * | |
| 1479 | + * Goes from the format: | |
| 1480 | + * $_FILES['field']['key']['index'] | |
| 1481 | + * to | |
| 1482 | + * The More standard and appropriate: | |
| 1483 | + * $_FILES['field']['index']['key'] | |
| 1484 | + * | |
| 1485 | + * @param string $files | |
| 1486 | + * @since 1.0 | |
| 1487 | + * @access public | |
| 1488 | + */ | |
| 1489 | + public function fix_file_array(&$files) | |
| 1490 | +		{ | |
| 1491 | + | |
| 1492 | + $output = array(); | |
| 1493 | + | |
| 1494 | +			foreach ($files as $key => $list) { | |
| 1495 | +				foreach ($list as $index => $value) { | |
| 1496 | + $output[$index][$key] = $value; | |
| 1497 | + } | |
| 1498 | + } | |
| 1499 | + | |
| 1500 | + return $files = $output; | |
| 1501 | + | |
| 1502 | + } | |
| 1503 | + | |
| 1504 | + /** | |
| 1505 | + * Get proper JQuery UI version. | |
| 1506 | + * | |
| 1507 | + * Used in order to not conflict with WP Admin Scripts. | |
| 1508 | + * | |
| 1509 | + * @since 1.0 | |
| 1510 | + * @access public | |
| 1511 | + */ | |
| 1512 | + public function get_jqueryui_ver() | |
| 1513 | +		{ | |
| 1514 | + | |
| 1515 | + global $wp_version; | |
| 1516 | + | |
| 1517 | +			if (version_compare($wp_version, '3.1', '>=')) { | |
| 1518 | + return '1.8.10'; | |
| 1519 | + } | |
| 1520 | + | |
| 1521 | + return '1.7.3'; | |
| 1522 | + | |
| 1523 | + } | |
| 1524 | + | |
| 1525 | + /** | |
| 1526 | + * Add Field to meta box (generic function) | |
| 1527 | + * @author Ohad Raz | |
| 1528 | + * @since 1.0 | |
| 1529 | + * @access public | |
| 1530 | + * @param $id string field id, i.e. the meta key | |
| 1531 | + * @param $args mixed|array | |
| 1532 | + */ | |
| 1533 | + public function addField($id, $args) | |
| 1534 | +		{ | |
| 1535 | +			$new_field = array('id' => $id, 'std' => '', 'desc' => '', 'style' => ''); | |
| 1536 | + $new_field = array_merge($new_field, $args); | |
| 1537 | + $this->_fields[] = $new_field; | |
| 1538 | + } | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + /** | |
| 1542 | + * Add Text Field to meta box | |
| 1543 | + * @author Ohad Raz | |
| 1544 | + * @since 1.0 | |
| 1545 | + * @access public | |
| 1546 | + * @param $id string field id, i.e. the meta key | |
| 1547 | + * @param $args mixed|array | |
| 1548 | + * 'name' => // field name/label string optional | |
| 1549 | + * 'desc' => // field description, string optional | |
| 1550 | + * 'std' => // default value, string optional | |
| 1551 | + * 'style' => // custom style for field, string optional | |
| 1552 | + * 'validate_func' => // validate function, string optional | |
| 1553 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1554 | + */ | |
| 1555 | + public function addText($id, $args, $repeater = false) | |
| 1556 | +		{ | |
| 1557 | +			$new_field = array('type' => 'text', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Text Field', 'geodirectory')); | |
| 1558 | + $new_field = array_merge($new_field, $args); | |
| 1559 | +			if (false === $repeater) { | |
| 1560 | + $this->_fields[] = $new_field; | |
| 1561 | +			} else { | |
| 1562 | + return $new_field; | |
| 1563 | + } | |
| 1564 | + } | |
| 1565 | + | |
| 1566 | + /** | |
| 1567 | + * Add Hidden Field to meta box | |
| 1568 | + * @author Ohad Raz | |
| 1569 | + * @since 0.1.3 | |
| 1570 | + * @access public | |
| 1571 | + * @param $id string field id, i.e. the meta key | |
| 1572 | + * @param $args mixed|array | |
| 1573 | + * 'name' => // field name/label string optional | |
| 1574 | + * 'desc' => // field description, string optional | |
| 1575 | + * 'std' => // default value, string optional | |
| 1576 | + * 'style' => // custom style for field, string optional | |
| 1577 | + * 'validate_func' => // validate function, string optional | |
| 1578 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1579 | + */ | |
| 1580 | + public function addHidden($id, $args, $repeater = false) | |
| 1581 | +		{ | |
| 1582 | +			$new_field = array('type' => 'hidden', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Text Field', 'geodirectory')); | |
| 1583 | + $new_field = array_merge($new_field, $args); | |
| 1584 | +			if (false === $repeater) { | |
| 1585 | + $this->_fields[] = $new_field; | |
| 1586 | +			} else { | |
| 1587 | + return $new_field; | |
| 1588 | + } | |
| 1589 | + } | |
| 1590 | + | |
| 1591 | + /** | |
| 1592 | + * Add Paragraph to meta box | |
| 1593 | + * @author Ohad Raz | |
| 1594 | + * @since 0.1.3 | |
| 1595 | + * @access public | |
| 1596 | + * @param $id string field id, i.e. the meta key | |
| 1597 | + * @param $value paragraph html | |
| 1598 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1599 | + */ | |
| 1600 | + public function addParagraph($id, $args, $repeater = false) | |
| 1601 | +		{ | |
| 1602 | +			$new_field = array('type' => 'paragraph', 'id' => $id, 'value' => '', 'style' => ''); | |
| 1603 | + $new_field = array_merge($new_field, $args); | |
| 1604 | +			if (false === $repeater) { | |
| 1605 | + $this->_fields[] = $new_field; | |
| 1606 | +			} else { | |
| 1607 | + return $new_field; | |
| 1608 | + } | |
| 1609 | + } | |
| 1610 | + | |
| 1611 | + /** | |
| 1612 | + * Add Checkbox Field to meta box | |
| 1613 | + * @author Ohad Raz | |
| 1614 | + * @since 1.0 | |
| 1615 | + * @access public | |
| 1616 | + * @param $id string field id, i.e. the meta key | |
| 1617 | + * @param $args mixed|array | |
| 1618 | + * 'name' => // field name/label string optional | |
| 1619 | + * 'desc' => // field description, string optional | |
| 1620 | + * 'std' => // default value, string optional | |
| 1621 | + * 'validate_func' => // validate function, string optional | |
| 1622 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1623 | + */ | |
| 1624 | + public function addCheckbox($id, $args, $repeater = false) | |
| 1625 | +		{ | |
| 1626 | +			$new_field = array('type' => 'checkbox', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Checkbox Field', 'geodirectory')); | |
| 1627 | + $new_field = array_merge($new_field, $args); | |
| 1628 | +			if (false === $repeater) { | |
| 1629 | + $this->_fields[] = $new_field; | |
| 1630 | +			} else { | |
| 1631 | + return $new_field; | |
| 1632 | + } | |
| 1633 | + } | |
| 1634 | + | |
| 1635 | + /** | |
| 1636 | + * Add CheckboxList Field to meta box | |
| 1637 | + * @author Ohad Raz | |
| 1638 | + * @since 1.0 | |
| 1639 | + * @access public | |
| 1640 | + * @param $id string field id, i.e. the meta key | |
| 1641 | + * @param $options (array) array of key => value pairs for select options | |
| 1642 | + * @param $args mixed|array | |
| 1643 | + * 'name' => // field name/label string optional | |
| 1644 | + * 'desc' => // field description, string optional | |
| 1645 | + * 'std' => // default value, string optional | |
| 1646 | + * 'validate_func' => // validate function, string optional | |
| 1647 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1648 | + * | |
| 1649 | + * @return : remember to call: $checkbox_list = $this->get_tax_meta(get_the_ID(), 'meta_name', false); | |
| 1650 | + * which means the last param as false to get the values in an array | |
| 1651 | + */ | |
| 1652 | + public function addCheckboxList($id, $options, $args, $repeater = false) | |
| 1653 | +		{ | |
| 1654 | +			$new_field = array('type' => 'checkbox_list', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Checkbox List Field', 'geodirectory')); | |
| 1655 | + $new_field = array_merge($new_field, $args); | |
| 1656 | +			if (false === $repeater) { | |
| 1657 | + $this->_fields[] = $new_field; | |
| 1658 | +			} else { | |
| 1659 | + return $new_field; | |
| 1660 | + } | |
| 1661 | + } | |
| 1662 | + | |
| 1663 | + /** | |
| 1664 | + * Add Textarea Field to meta box | |
| 1665 | + * @author Ohad Raz | |
| 1666 | + * @since 1.0 | |
| 1667 | + * @access public | |
| 1668 | + * @param $id string field id, i.e. the meta key | |
| 1669 | + * @param $args mixed|array | |
| 1670 | + * 'name' => // field name/label string optional | |
| 1671 | + * 'desc' => // field description, string optional | |
| 1672 | + * 'std' => // default value, string optional | |
| 1673 | + * 'style' => // custom style for field, string optional | |
| 1674 | + * 'validate_func' => // validate function, string optional | |
| 1675 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1676 | + */ | |
| 1677 | + public function addTextarea($id, $args, $repeater = false) | |
| 1678 | +		{ | |
| 1679 | +			$new_field = array('type' => 'textarea', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Textarea Field', 'geodirectory')); | |
| 1680 | + $new_field = array_merge($new_field, $args); | |
| 1681 | +			if (false === $repeater) { | |
| 1682 | + $this->_fields[] = $new_field; | |
| 1683 | +			} else { | |
| 1684 | + return $new_field; | |
| 1685 | + } | |
| 1686 | + } | |
| 1687 | + | |
| 1688 | + /** | |
| 1689 | + * Add Select Field to meta box | |
| 1690 | + * @author Ohad Raz | |
| 1691 | + * @since 1.0 | |
| 1692 | + * @access public | |
| 1693 | + * @param $id string field id, i.e. the meta key | |
| 1694 | + * @param $options (array) array of key => value pairs for select options | |
| 1695 | + * @param $args mixed|array | |
| 1696 | + * 'name' => // field name/label string optional | |
| 1697 | + * 'desc' => // field description, string optional | |
| 1698 | + * 'std' => // default value, (array) optional | |
| 1699 | + * 'multiple' => // select multiple values, optional. Default is false. | |
| 1700 | + * 'validate_func' => // validate function, string optional | |
| 1701 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1702 | + */ | |
| 1703 | + public function addSelect($id, $options, $args, $repeater = false) | |
| 1704 | +		{ | |
| 1705 | +			$new_field = array('type' => 'select', 'id' => $id, 'std' => array(), 'desc' => '', 'style' => '', 'name' => __('Select Field', 'geodirectory'), 'multiple' => false, 'options' => $options); | |
| 1706 | + $new_field = array_merge($new_field, $args); | |
| 1707 | +			if (false === $repeater) { | |
| 1708 | + $this->_fields[] = $new_field; | |
| 1709 | +			} else { | |
| 1710 | + return $new_field; | |
| 1711 | + } | |
| 1712 | + } | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + /** | |
| 1716 | + * Add Radio Field to meta box | |
| 1717 | + * @author Ohad Raz | |
| 1718 | + * @since 1.0 | |
| 1719 | + * @access public | |
| 1720 | + * @param $id string field id, i.e. the meta key | |
| 1721 | + * @param $options (array) array of key => value pairs for radio options | |
| 1722 | + * @param $args mixed|array | |
| 1723 | + * 'name' => // field name/label string optional | |
| 1724 | + * 'desc' => // field description, string optional | |
| 1725 | + * 'std' => // default value, string optional | |
| 1726 | + * 'validate_func' => // validate function, string optional | |
| 1727 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1728 | + */ | |
| 1729 | + public function addRadio($id, $options, $args, $repeater = false) | |
| 1730 | +		{ | |
| 1731 | +			$new_field = array('type' => 'radio', 'id' => $id, 'std' => array(), 'desc' => '', 'style' => '', 'name' => __('Radio Field', 'geodirectory'), 'options' => $options); | |
| 1732 | + $new_field = array_merge($new_field, $args); | |
| 1733 | +			if (false === $repeater) { | |
| 1734 | + $this->_fields[] = $new_field; | |
| 1735 | +			} else { | |
| 1736 | + return $new_field; | |
| 1737 | + } | |
| 1738 | + } | |
| 1739 | + | |
| 1740 | + /** | |
| 1741 | + * Add Date Field to meta box | |
| 1742 | + * @author Ohad Raz | |
| 1743 | + * @since 1.0 | |
| 1744 | + * @access public | |
| 1745 | + * @param $id string field id, i.e. the meta key | |
| 1746 | + * @param $args mixed|array | |
| 1747 | + * 'name' => // field name/label string optional | |
| 1748 | + * 'desc' => // field description, string optional | |
| 1749 | + * 'std' => // default value, string optional | |
| 1750 | + * 'validate_func' => // validate function, string optional | |
| 1751 | + * 'format' => // date format, default yy-mm-dd. Optional. Default "'d MM, yy'" See more formats here: http://goo.gl/Wcwxn | |
| 1752 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1753 | + */ | |
| 1754 | + public function addDate($id, $args, $repeater = false) | |
| 1755 | +		{ | |
| 1756 | +			$new_field = array('type' => 'date', 'id' => $id, 'std' => '', 'desc' => '', 'format' => 'yy-mm-dd', 'name' => __('Date Field', 'geodirectory')); | |
| 1757 | + $new_field = array_merge($new_field, $args); | |
| 1758 | +			if (false === $repeater) { | |
| 1759 | + $this->_fields[] = $new_field; | |
| 1760 | +			} else { | |
| 1761 | + return $new_field; | |
| 1762 | + } | |
| 1763 | + } | |
| 1764 | + | |
| 1765 | + /** | |
| 1766 | + * Add Time Field to meta box | |
| 1767 | + * @author Ohad Raz | |
| 1768 | + * @since 1.0 | |
| 1769 | + * @access public | |
| 1770 | + * @param $id string- field id, i.e. the meta key | |
| 1771 | + * @param $args mixed|array | |
| 1772 | + * 'name' => // field name/label string optional | |
| 1773 | + * 'desc' => // field description, string optional | |
| 1774 | + * 'std' => // default value, string optional | |
| 1775 | + * 'validate_func' => // validate function, string optional | |
| 1776 | + * 'format' => // time format, default hh:mm. Optional. See more formats here: http://goo.gl/83woX | |
| 1777 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1778 | + */ | |
| 1779 | + public function addTime($id, $args, $repeater = false) | |
| 1780 | +		{ | |
| 1781 | +			$new_field = array('type' => 'time', 'id' => $id, 'std' => '', 'desc' => '', 'format' => 'hh:mm', 'name' => __('Time Field', 'geodirectory')); | |
| 1782 | + $new_field = array_merge($new_field, $args); | |
| 1783 | +			if (false === $repeater) { | |
| 1784 | + $this->_fields[] = $new_field; | |
| 1785 | +			} else { | |
| 1786 | + return $new_field; | |
| 1787 | + } | |
| 1788 | + } | |
| 1789 | + | |
| 1790 | + /** | |
| 1791 | + * Add Color Field to meta box | |
| 1792 | + * @author Ohad Raz | |
| 1793 | + * @since 1.0 | |
| 1794 | + * @access public | |
| 1795 | + * @param $id string field id, i.e. the meta key | |
| 1796 | + * @param $args mixed|array | |
| 1797 | + * 'name' => // field name/label string optional | |
| 1798 | + * 'desc' => // field description, string optional | |
| 1799 | + * 'std' => // default value, string optional | |
| 1800 | + * 'validate_func' => // validate function, string optional | |
| 1801 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1802 | + */ | |
| 1803 | + public function addColor($id, $args, $repeater = false) | |
| 1804 | +		{ | |
| 1805 | +			$new_field = array('type' => 'color', 'id' => $id, 'std' => '', 'desc' => '', 'name' => __('ColorPicker Field', 'geodirectory')); | |
| 1806 | + $new_field = array_merge($new_field, $args); | |
| 1807 | +			if (false === $repeater) { | |
| 1808 | + $this->_fields[] = $new_field; | |
| 1809 | +			} else { | |
| 1810 | + return $new_field; | |
| 1811 | + } | |
| 1812 | + } | |
| 1813 | + | |
| 1814 | + /** | |
| 1815 | + * Add Image Field to meta box | |
| 1816 | + * @author Ohad Raz | |
| 1817 | + * @since 1.0 | |
| 1818 | + * @access public | |
| 1819 | + * @param $id string field id, i.e. the meta key | |
| 1820 | + * @param $args mixed|array | |
| 1821 | + * 'name' => // field name/label string optional | |
| 1822 | + * 'desc' => // field description, string optional | |
| 1823 | + * 'validate_func' => // validate function, string optional | |
| 1824 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1825 | + */ | |
| 1826 | + public function addImage($id, $args, $repeater = false) | |
| 1827 | +		{ | |
| 1828 | +			$new_field = array('type' => 'image', 'id' => $id, 'desc' => '', 'style' => '', 'name' => __('Image Field', 'geodirectory')); | |
| 1829 | + $new_field = array_merge($new_field, $args); | |
| 1830 | + | |
| 1831 | +			if (false === $repeater) { | |
| 1832 | + $this->_fields[] = $new_field; | |
| 1833 | +			} else { | |
| 1834 | + return $new_field; | |
| 1835 | + } | |
| 1836 | + } | |
| 1837 | + | |
| 1838 | + /** | |
| 1839 | + * Add File Field to meta box | |
| 1840 | + * @author Ohad Raz | |
| 1841 | + * @since 1.0 | |
| 1842 | + * @access public | |
| 1843 | + * @param $id string field id, i.e. the meta key | |
| 1844 | + * @param $args mixed|array | |
| 1845 | + * 'name' => // field name/label string optional | |
| 1846 | + * 'desc' => // field description, string optional | |
| 1847 | + * 'validate_func' => // validate function, string optional | |
| 1848 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1849 | + */ | |
| 1850 | + public function addFile($id, $args, $repeater = false) | |
| 1851 | +		{ | |
| 1852 | +			$new_field = array('type' => 'file', 'id' => $id, 'desc' => '', 'style' => '', 'name' => __('File Field', 'geodirectory')); | |
| 1853 | + $new_field = array_merge($new_field, $args); | |
| 1854 | +			if (false === $repeater) { | |
| 1855 | + $this->_fields[] = $new_field; | |
| 1856 | +			} else { | |
| 1857 | + return $new_field; | |
| 1858 | + } | |
| 1859 | + } | |
| 1860 | + | |
| 1861 | + /** | |
| 1862 | + * Add WYSIWYG Field to meta box | |
| 1863 | + * @author Ohad Raz | |
| 1864 | + * @since 1.0 | |
| 1865 | + * @access public | |
| 1866 | + * @param $id string field id, i.e. the meta key | |
| 1867 | + * @param $args mixed|array | |
| 1868 | + * 'name' => // field name/label string optional | |
| 1869 | + * 'desc' => // field description, string optional | |
| 1870 | + * 'std' => // default value, string optional | |
| 1871 | + * 'style' => // custom style for field, string optional Default 'width: 300px; height: 400px' | |
| 1872 | + * 'validate_func' => // validate function, string optional | |
| 1873 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1874 | + */ | |
| 1875 | + public function addWysiwyg($id, $args, $repeater = false) | |
| 1876 | +		{ | |
| 1877 | +			$new_field = array('type' => 'wysiwyg', 'id' => $id, 'std' => '', 'desc' => '', 'style' => 'width: 300px; height: 400px', 'name' => __('WYSIWYG Editor Field', 'geodirectory')); | |
| 1878 | + $new_field = array_merge($new_field, $args); | |
| 1879 | +			if (false === $repeater) { | |
| 1880 | + $this->_fields[] = $new_field; | |
| 1881 | +			} else { | |
| 1882 | + return $new_field; | |
| 1883 | + } | |
| 1884 | + } | |
| 1885 | + | |
| 1886 | + /** | |
| 1887 | + * Add Taxonomy Field to meta box | |
| 1888 | + * @author Ohad Raz | |
| 1889 | + * @since 1.0 | |
| 1890 | + * @access public | |
| 1891 | + * @param $id string field id, i.e. the meta key | |
| 1892 | + * @param $options mixed|array options of taxonomy field | |
| 1893 | + * 'taxonomy' => // taxonomy name can be category,post_tag or any custom taxonomy default is category | |
| 1894 | + * 'type' => // how to show taxonomy? 'select' (default) or 'checkbox_list' | |
| 1895 | +		 * 'args' =>  // arguments to query taxonomy, see http://goo.gl/uAANN default ('hide_empty' => false) | |
| 1896 | + * @param $args mixed|array | |
| 1897 | + * 'name' => // field name/label string optional | |
| 1898 | + * 'desc' => // field description, string optional | |
| 1899 | + * 'std' => // default value, string optional | |
| 1900 | + * 'validate_func' => // validate function, string optional | |
| 1901 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1902 | + */ | |
| 1903 | + public function addTaxonomy($id, $options, $args, $repeater = false) | |
| 1904 | +		{ | |
| 1905 | +			$q = array('hide_empty' => 0); | |
| 1906 | + $tax = 'category'; | |
| 1907 | + $type = 'select'; | |
| 1908 | + $temp = array($tax, $type, $q); | |
| 1909 | + $options = array_merge($temp, $options); | |
| 1910 | +			$new_field = array('type' => 'taxonomy', 'id' => $id, 'desc' => '', 'name' => __('Taxonomy Field', 'geodirectory'), 'options' => $options); | |
| 1911 | + $new_field = array_merge($new_field, $args); | |
| 1912 | +			if (false === $repeater) { | |
| 1913 | + $this->_fields[] = $new_field; | |
| 1914 | +			} else { | |
| 1915 | + return $new_field; | |
| 1916 | + } | |
| 1917 | + } | |
| 1918 | + | |
| 1919 | + /** | |
| 1920 | + * Add posts Field to meta box | |
| 1921 | + * @author Ohad Raz | |
| 1922 | + * @since 1.0 | |
| 1923 | + * @access public | |
| 1924 | + * @param $id string field id, i.e. the meta key | |
| 1925 | + * @param $options mixed|array options of taxonomy field | |
| 1926 | + * 'post_type' => // post type name, 'post' (default) 'page' or any custom post type | |
| 1927 | + * 'type' => // how to show posts? 'select' (default) or 'checkbox_list' | |
| 1928 | +		 * 'args' =>  // arguments to query posts, see http://goo.gl/is0yK default ('posts_per_page' => -1) | |
| 1929 | + * @param $args mixed|array | |
| 1930 | + * 'name' => // field name/label string optional | |
| 1931 | + * 'desc' => // field description, string optional | |
| 1932 | + * 'std' => // default value, string optional | |
| 1933 | + * 'validate_func' => // validate function, string optional | |
| 1934 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1935 | + */ | |
| 1936 | + public function addPosts($id, $options, $args, $repeater = false) | |
| 1937 | +		{ | |
| 1938 | +			$q = array('posts_per_page' => -1); | |
| 1939 | +			$temp = array('post_type' => 'post', 'type' => 'select', 'args' => $q); | |
| 1940 | + $options = array_merge($temp, $options); | |
| 1941 | +			$new_field = array('type' => 'posts', 'id' => $id, 'desc' => '', 'name' => __('Posts Field', 'geodirectory'), 'options' => $options); | |
| 1942 | + $new_field = array_merge($new_field, $args); | |
| 1943 | +			if (false === $repeater) { | |
| 1944 | + $this->_fields[] = $new_field; | |
| 1945 | +			} else { | |
| 1946 | + return $new_field; | |
| 1947 | + } | |
| 1948 | + } | |
| 1949 | + | |
| 1950 | + /** | |
| 1951 | + * Add repeater Field Block to meta box | |
| 1952 | + * @author Ohad Raz | |
| 1953 | + * @since 1.0 | |
| 1954 | + * @access public | |
| 1955 | + * @param $id string field id, i.e. the meta key | |
| 1956 | + * @param $args mixed|array | |
| 1957 | + * 'name' => // field name/label string optional | |
| 1958 | + * 'desc' => // field description, string optional | |
| 1959 | + * 'std' => // default value, string optional | |
| 1960 | + * 'style' => // custom style for field, string optional | |
| 1961 | + * 'validate_func' => // validate function, string optional | |
| 1962 | + * 'fields' => //fields to repeater | |
| 1963 | + */ | |
| 1964 | + public function addRepeaterBlock($id, $args) | |
| 1965 | +		{ | |
| 1966 | +			$new_field = array('type' => 'repeater', 'id' => $id, 'name' => __('Reapeater Field', 'geodirectory'), 'fields' => array(), 'inline' => false); | |
| 1967 | + $new_field = array_merge($new_field, $args); | |
| 1968 | + $this->_fields[] = $new_field; | |
| 1969 | + } | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + /** | |
| 1973 | + * Finish Declaration of Meta Box | |
| 1974 | + * @author Ohad Raz | |
| 1975 | + * @since 1.0 | |
| 1976 | + * @access public | |
| 1977 | + */ | |
| 1978 | + public function Finish() | |
| 1979 | +		{ | |
| 1980 | + $this->add_missed_values(); | |
| 1981 | + $this->check_field_upload(); | |
| 1982 | + $this->check_field_color(); | |
| 1983 | + $this->check_field_date(); | |
| 1984 | + $this->check_field_time(); | |
| 1985 | + } | |
| 1986 | + | |
| 1987 | + /** | |
| 1988 | + * Helper function to check for empty arrays | |
| 1989 | + * @author Ohad Raz | |
| 1990 | + * @since 1.0 | |
| 1991 | + * @access public | |
| 1992 | + * @param $args mixed|array | |
| 1993 | + */ | |
| 1994 | + public function is_array_empty($array) | |
| 1995 | +		{ | |
| 1996 | + if (!is_array($array)) | |
| 1997 | + return true; | |
| 1998 | + | |
| 1999 | +			foreach ($array as $a) { | |
| 2000 | +				if (is_array($a)) { | |
| 2001 | +					foreach ($a as $sub_a) { | |
| 2002 | + if (!empty($sub_a) && $sub_a != '') | |
| 2003 | + return false; | |
| 2004 | + } | |
| 2005 | +				} else { | |
| 2006 | + if (!empty($a) && $a != '') | |
| 2007 | + return false; | |
| 2008 | + } | |
| 2009 | + } | |
| 2010 | + return true; | |
| 2011 | + } | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + //get term meta field | |
| 2015 | + public function get_tax_meta($term_id, $key, $multi = false, $post_type = '') | |
| 2016 | +		{ | |
| 2017 | + | |
| 2018 | +			if (empty($post_type) && isset($_REQUEST['taxonomy'])) { | |
| 2019 | + $taxObject = get_taxonomy($_REQUEST['taxonomy']); | |
| 2020 | + $post_type = $taxObject->object_type[0]; | |
| 2021 | + } | |
| 2022 | + | |
| 2023 | +			if($post_type=='post'){$post_type='';} | |
| 2024 | +			if($post_type){$post_type = $post_type.'_';} | |
| 2025 | + | |
| 2026 | + $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id; | |
| 2027 | + | |
| 2028 | +			$m = get_option('tax_meta_' . $post_type  . $t_id); | |
| 2029 | +			if (isset($m[$key])) { | |
| 2030 | + return $m[$key]; | |
| 2031 | +			} else { | |
| 2032 | + return ''; | |
| 2033 | + } | |
| 2034 | + } | |
| 2035 | + | |
| 2036 | + //delete meta | |
| 2037 | + public function delete_tax_meta($term_id, $key, $post_type = '') | |
| 2038 | +		{ | |
| 2039 | + | |
| 2040 | +			if (empty($post_type) && isset($_REQUEST['taxonomy'])) { | |
| 2041 | + $taxObject = get_taxonomy($_REQUEST['taxonomy']); | |
| 2042 | + $post_type = $taxObject->object_type[0]; | |
| 2043 | + } | |
| 2044 | + | |
| 2045 | +			if($post_type=='post'){$post_type='';} | |
| 2046 | +			if($post_type){$post_type = $post_type.'_';} | |
| 2047 | + | |
| 2048 | +			$m = get_option('tax_meta_' . $post_type  . $term_id); | |
| 2049 | + | |
| 2050 | +			if (isset($m[$key])) { | |
| 2051 | + unset($m[$key]); | |
| 2052 | + } | |
| 2053 | +			update_option('tax_meta_' . $post_type  . $term_id, $m); | |
| 2054 | + } | |
| 2055 | + | |
| 2056 | + //update meta | |
| 2057 | + public function update_tax_meta($term_id, $key, $value, $post_type = '') | |
| 2058 | +		{ | |
| 2059 | + | |
| 2060 | +			if (empty($post_type) && isset($_REQUEST['taxonomy'])) { | |
| 2061 | + $taxObject = get_taxonomy($_REQUEST['taxonomy']); | |
| 2062 | + $post_type = $taxObject->object_type[0]; | |
| 2063 | + } | |
| 2064 | + | |
| 2065 | +			if($post_type=='post'){$post_type='';} | |
| 2066 | +			if($post_type){$post_type = $post_type.'_';} | |
| 2067 | + | |
| 2068 | +			$m = get_option('tax_meta_' . $post_type  . $term_id); | |
| 2069 | + | |
| 2070 | + $m[$key] = $value; | |
| 2071 | +			update_option('tax_meta_' . $post_type  . $term_id, $m); | |
| 2072 | + | |
| 2073 | + /** | |
| 2074 | + * Called after the tax meta is updated. | |
| 2075 | + * | |
| 2076 | + * Used to update things after a GD category is saved. | |
| 2077 | + * | |
| 2078 | + * @since 1.0.0 | |
| 2079 | + * @param bool $false False. | |
| 2080 | + * @param bool $true True. | |
| 2081 | + * @param int $term_id The term id being updated. | |
| 2082 | + * @param string $post_type The post type of the cat being updated. | |
| 2083 | + */ | |
| 2084 | +			do_action('gd_tax_meta_updated', false, true, $term_id, $post_type); | |
| 2085 | + } | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + } // End Class | |
| 2089 | 2089 | |
| 2090 | 2090 | endif; // End Check Class Exists | 
| 2091 | 2091 | |
| @@ -2095,67 +2095,67 @@ discard block | ||
| 2095 | 2095 | |
| 2096 | 2096 | //get term meta field | 
| 2097 | 2097 |  if (!function_exists('get_tax_meta')) { | 
| 2098 | - function get_tax_meta($term_id, $key, $multi = false, $post_type = '') | |
| 2099 | -    { | |
| 2100 | - | |
| 2101 | -        if (empty($post_type) && isset($_REQUEST['taxonomy'])) { | |
| 2102 | - $taxObject = get_taxonomy($_REQUEST['taxonomy']); | |
| 2103 | - $post_type = $taxObject->object_type[0]; | |
| 2104 | - } | |
| 2105 | - | |
| 2106 | -        if($post_type=='post'){$post_type='';} | |
| 2107 | -        if($post_type){$post_type = $post_type.'_';} | |
| 2108 | - | |
| 2109 | - $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id; | |
| 2110 | - | |
| 2111 | -        $m = get_option('tax_meta_' . $post_type  . $t_id); | |
| 2112 | -        if (isset($m[$key])) { | |
| 2113 | - return $m[$key]; | |
| 2114 | -        } else { | |
| 2115 | - return ''; | |
| 2116 | - } | |
| 2117 | - } | |
| 2098 | + function get_tax_meta($term_id, $key, $multi = false, $post_type = '') | |
| 2099 | +	{ | |
| 2100 | + | |
| 2101 | +		if (empty($post_type) && isset($_REQUEST['taxonomy'])) { | |
| 2102 | + $taxObject = get_taxonomy($_REQUEST['taxonomy']); | |
| 2103 | + $post_type = $taxObject->object_type[0]; | |
| 2104 | + } | |
| 2105 | + | |
| 2106 | +		if($post_type=='post'){$post_type='';} | |
| 2107 | +		if($post_type){$post_type = $post_type.'_';} | |
| 2108 | + | |
| 2109 | + $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id; | |
| 2110 | + | |
| 2111 | +		$m = get_option('tax_meta_' . $post_type  . $t_id); | |
| 2112 | +		if (isset($m[$key])) { | |
| 2113 | + return $m[$key]; | |
| 2114 | +		} else { | |
| 2115 | + return ''; | |
| 2116 | + } | |
| 2117 | + } | |
| 2118 | 2118 | } | 
| 2119 | 2119 | |
| 2120 | 2120 | //delete meta | 
| 2121 | 2121 |  if (!function_exists('delete_tax_meta')) { | 
| 2122 | - function delete_tax_meta($term_id, $key) | |
| 2123 | -    { | |
| 2122 | + function delete_tax_meta($term_id, $key) | |
| 2123 | +	{ | |
| 2124 | 2124 | |
| 2125 | - $taxObject = get_taxonomy($_REQUEST['taxonomy']); | |
| 2126 | - $post_type = $taxObject->object_type[0]; | |
| 2125 | + $taxObject = get_taxonomy($_REQUEST['taxonomy']); | |
| 2126 | + $post_type = $taxObject->object_type[0]; | |
| 2127 | 2127 | |
| 2128 | -        if($post_type=='post'){$post_type='';} | |
| 2129 | -        if($post_type){$post_type = $post_type.'_';} | |
| 2128 | +		if($post_type=='post'){$post_type='';} | |
| 2129 | +		if($post_type){$post_type = $post_type.'_';} | |
| 2130 | 2130 | |
| 2131 | -        $m = get_option('tax_meta_' . $post_type . $term_id); | |
| 2131 | +		$m = get_option('tax_meta_' . $post_type . $term_id); | |
| 2132 | 2132 | |
| 2133 | -        if (isset($m[$key])) { | |
| 2134 | - unset($m[$key]); | |
| 2135 | - } | |
| 2136 | -        update_option('tax_meta_' . $post_type  . $term_id, $m); | |
| 2137 | - } | |
| 2133 | +		if (isset($m[$key])) { | |
| 2134 | + unset($m[$key]); | |
| 2135 | + } | |
| 2136 | +		update_option('tax_meta_' . $post_type  . $term_id, $m); | |
| 2137 | + } | |
| 2138 | 2138 | } | 
| 2139 | 2139 | |
| 2140 | 2140 | //update meta | 
| 2141 | 2141 |  if (!function_exists('update_tax_meta')) { | 
| 2142 | - function update_tax_meta($term_id, $key, $value, $post_type = '') | |
| 2143 | -    { | |
| 2142 | + function update_tax_meta($term_id, $key, $value, $post_type = '') | |
| 2143 | +	{ | |
| 2144 | 2144 | |
| 2145 | -        if (empty($post_type) && isset($_REQUEST['taxonomy'])) { | |
| 2146 | - $taxObject = get_taxonomy($_REQUEST['taxonomy']); | |
| 2147 | - $post_type = $taxObject->object_type[0]; | |
| 2148 | - } | |
| 2145 | +		if (empty($post_type) && isset($_REQUEST['taxonomy'])) { | |
| 2146 | + $taxObject = get_taxonomy($_REQUEST['taxonomy']); | |
| 2147 | + $post_type = $taxObject->object_type[0]; | |
| 2148 | + } | |
| 2149 | 2149 | |
| 2150 | -        if($post_type=='post'){$post_type='';} | |
| 2151 | -        if($post_type){$post_type = $post_type.'_';} | |
| 2150 | +		if($post_type=='post'){$post_type='';} | |
| 2151 | +		if($post_type){$post_type = $post_type.'_';} | |
| 2152 | 2152 | |
| 2153 | -        $m = get_option('tax_meta_' . $post_type  . $term_id); | |
| 2153 | +		$m = get_option('tax_meta_' . $post_type  . $term_id); | |
| 2154 | 2154 | |
| 2155 | - $m[$key] = $value; | |
| 2156 | -        update_option('tax_meta_' . $post_type . $term_id, $m); | |
| 2155 | + $m[$key] = $value; | |
| 2156 | +		update_option('tax_meta_' . $post_type . $term_id, $m); | |
| 2157 | 2157 | |
| 2158 | - /** This action is documented in geodirectory-functions/cat-meta-functions/Tax-meta-class.php */ | |
| 2159 | -        do_action('gd_tax_meta_updated', false, true, $term_id, $post_type); | |
| 2160 | - } | |
| 2158 | + /** This action is documented in geodirectory-functions/cat-meta-functions/Tax-meta-class.php */ | |
| 2159 | +		do_action('gd_tax_meta_updated', false, true, $term_id, $post_type); | |
| 2160 | + } | |
| 2161 | 2161 | } | 
| 2162 | 2162 | \ No newline at end of file | 
| @@ -113,7 +113,7 @@ discard block | ||
| 113 | 113 | $this->add_missed_values(); | 
| 114 | 114 | if (isset($meta_box['use_with_theme'])) | 
| 115 | 115 |                  if ($meta_box['use_with_theme'] === true) { | 
| 116 | - $this->SelfPath = get_stylesheet_directory_uri() . '/library/cat-meta'; | |
| 116 | + $this->SelfPath = get_stylesheet_directory_uri().'/library/cat-meta'; | |
| 117 | 117 |                  } elseif ($meta_box['use_with_theme'] === false) { | 
| 118 | 118 |                      $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__))); | 
| 119 | 119 |                  } else { | 
| @@ -262,7 +262,7 @@ discard block | ||
| 262 | 262 |                  $li = "<li id='item_{$attachment_id}'>"; | 
| 263 | 263 |                  $li .= "<img src='{$attachment['url']}' alt='image_{$attachment_id}' />"; | 
| 264 | 264 |                  //$li 	.= "<a title='" . __( 'Delete this image' ) . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'>" . __( 'Delete' ) . "</a>"; | 
| 265 | -                $li .= "<a title='" . __('Remove this image', 'geodirectory') . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'><img src='" . $this->SelfPath . "/images/delete-16.png' alt='" . __('Remove', 'geodirectory') . "' /></a>"; | |
| 265 | +                $li .= "<a title='".__('Remove this image', 'geodirectory')."' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'><img src='".$this->SelfPath."/images/delete-16.png' alt='".__('Remove', 'geodirectory')."' /></a>"; | |
| 266 | 266 |                  $li .= "<input type='hidden' name='{$id}[]' value='{$attachment_id}' />"; | 
| 267 | 267 | $li .= "</li>"; | 
| 268 | 268 | $html .= $li; | 
| @@ -335,7 +335,7 @@ discard block | ||
| 335 | 335 | $attachment_id = isset($_GET['attachment_id']) ? intval($_GET['attachment_id']) : 0; | 
| 336 | 336 | $ok = false; | 
| 337 | 337 |              if (strpos($field_id, '[') === false) { | 
| 338 | -                check_admin_referer("at-delete-mupload_" . urldecode($field_id)); | |
| 338 | +                check_admin_referer("at-delete-mupload_".urldecode($field_id)); | |
| 339 | 339 | if ($term_id > 0) | 
| 340 | 340 | $this->delete_tax_meta($term_id, $field_id); | 
| 341 | 341 | //$ok = wp_delete_attachment( $attachment_id ); | 
| @@ -423,8 +423,8 @@ discard block | ||
| 423 | 423 | |
| 424 | 424 |              if ($this->has_field('date') && $this->is_edit_page()) { | 
| 425 | 425 | // Enqueu JQuery UI, use proper version. | 
| 426 | -                wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css'); | |
| 427 | -                wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery')); | |
| 426 | +                wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/'.$this->get_jqueryui_ver().'/themes/base/jquery-ui.css'); | |
| 427 | +                wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/'.$this->get_jqueryui_ver().'/jquery-ui.min.js', array('jquery')); | |
| 428 | 428 | } | 
| 429 | 429 | |
| 430 | 430 | } | 
| @@ -441,8 +441,8 @@ discard block | ||
| 441 | 441 |              if ($this->has_field('time') && $this->is_edit_page()) { | 
| 442 | 442 | |
| 443 | 443 | // Enqueu JQuery UI, use proper version. | 
| 444 | -                wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css', array(), false, true); | |
| 445 | -                wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery'), false, true); | |
| 444 | +                wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/'.$this->get_jqueryui_ver().'/themes/base/jquery-ui.css', array(), false, true); | |
| 445 | +                wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/'.$this->get_jqueryui_ver().'/jquery-ui.min.js', array('jquery'), false, true); | |
| 446 | 446 |                  wp_enqueue_script('at-timepicker', 'https://github.com/trentrichardson/jQuery-Timepicker-Addon/raw/master/jquery-ui-timepicker-addon.js', array('tmc-jquery-ui'), false, true); | 
| 447 | 447 | |
| 448 | 448 | } | 
| @@ -462,13 +462,13 @@ discard block | ||
| 462 | 462 |              if (!empty($this->_meta_box['pages'])) { | 
| 463 | 463 |                  foreach ($this->_meta_box['pages'] as $page) { | 
| 464 | 464 | //add fields to edit form | 
| 465 | - add_action($page . '_edit_form_fields', array(&$this, 'show_edit_form')); | |
| 465 | + add_action($page.'_edit_form_fields', array(&$this, 'show_edit_form')); | |
| 466 | 466 | //add fields to add new form | 
| 467 | - add_action($page . '_add_form_fields', array(&$this, 'show_new_form')); | |
| 467 | + add_action($page.'_add_form_fields', array(&$this, 'show_new_form')); | |
| 468 | 468 | // this saves the edit fields | 
| 469 | -                    add_action('edited_' . $page, array(&$this, 'save'), 10, 2); | |
| 469 | +                    add_action('edited_'.$page, array(&$this, 'save'), 10, 2); | |
| 470 | 470 | // this saves the add fields | 
| 471 | -                    add_action('created_' . $page, array(&$this, 'save'), 10, 2); | |
| 471 | +                    add_action('created_'.$page, array(&$this, 'save'), 10, 2); | |
| 472 | 472 | } | 
| 473 | 473 | } | 
| 474 | 474 | |
| @@ -517,13 +517,13 @@ discard block | ||
| 517 | 517 |                      $meta = is_array($meta) ? array_map('esc_attr', $meta) : esc_attr($meta); | 
| 518 | 518 | |
| 519 | 519 |                  if ($field['validate_func']) { | 
| 520 | - echo '<tr class="form-field form-required ' . $field['style'] . '">'; | |
| 520 | + echo '<tr class="form-field form-required '.$field['style'].'">'; | |
| 521 | 521 |                  } else { | 
| 522 | - echo '<tr class="form-field ' . $field['style'] . '">'; | |
| 522 | + echo '<tr class="form-field '.$field['style'].'">'; | |
| 523 | 523 | } | 
| 524 | 524 | |
| 525 | 525 | // Call Separated methods for displaying each type of field. | 
| 526 | - call_user_func(array(&$this, 'show_field_' . $field['type']), $field, $meta); | |
| 526 | + call_user_func(array(&$this, 'show_field_'.$field['type']), $field, $meta); | |
| 527 | 527 | echo '</tr>'; | 
| 528 | 528 | } | 
| 529 | 529 | echo '</table>'; | 
| @@ -550,14 +550,14 @@ discard block | ||
| 550 | 550 |                  foreach ($meta as $me) { | 
| 551 | 551 | //for labling toggles | 
| 552 | 552 | $mmm = $me[$field['fields'][0]['id']]; | 
| 553 | - echo '<div class="at-repater-block">' . $mmm . '<br/><table class="repeater-table" style="display: none;">'; | |
| 553 | + echo '<div class="at-repater-block">'.$mmm.'<br/><table class="repeater-table" style="display: none;">'; | |
| 554 | 554 |                      if ($field['inline']) { | 
| 555 | 555 | echo '<tr class="at-inline" VALIGN="top">'; | 
| 556 | 556 | } | 
| 557 | 557 |                      foreach ($field['fields'] as $f) { | 
| 558 | 558 | //reset var $id for repeater | 
| 559 | 559 | $id = ''; | 
| 560 | - $id = $field['id'] . '[' . $c . '][' . $f['id'] . ']'; | |
| 560 | + $id = $field['id'].'['.$c.']['.$f['id'].']'; | |
| 561 | 561 | $m = $me[$f['id']]; | 
| 562 | 562 | $m = ($m !== '') ? $m : $f['std']; | 
| 563 | 563 |                          if ('image' != $f['type'] && $f['type'] != 'repeater') | 
| @@ -567,7 +567,7 @@ discard block | ||
| 567 | 567 |                          if (!$field['inline']) { | 
| 568 | 568 | echo '<tr>'; | 
| 569 | 569 | } | 
| 570 | - call_user_func(array(&$this, 'show_field_' . $f['type']), $f, $m); | |
| 570 | + call_user_func(array(&$this, 'show_field_'.$f['type']), $f, $m); | |
| 571 | 571 |                          if (!$field['inline']) { | 
| 572 | 572 | echo '</tr>'; | 
| 573 | 573 | } | 
| @@ -578,18 +578,18 @@ discard block | ||
| 578 | 578 | echo '</table> | 
| 579 | 579 | <span class="at-re-toggle"><img src="'; | 
| 580 | 580 |                      if ($this->_Local_images) { | 
| 581 | - echo $plugin_path . '/images/edit.png'; | |
| 581 | + echo $plugin_path.'/images/edit.png'; | |
| 582 | 582 |                      } else { | 
| 583 | 583 | echo 'http://i.imgur.com/ka0E2.png'; | 
| 584 | 584 | } | 
| 585 | 585 | echo '" alt="Edit" title="Edit"/></span> | 
| 586 | 586 | <img src="'; | 
| 587 | 587 |                      if ($this->_Local_images) { | 
| 588 | - echo $plugin_path . '/images/remove.png'; | |
| 588 | + echo $plugin_path.'/images/remove.png'; | |
| 589 | 589 |                      } else { | 
| 590 | 590 | echo 'http://i.imgur.com/g8Duj.png'; | 
| 591 | 591 | } | 
| 592 | -                    echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>'; | |
| 592 | +                    echo '" alt="'.__('Remove', 'geodirectory').'" title="'.__('Remove', 'geodirectory').'" id="remove-'.$field['id'].'"></div>'; | |
| 593 | 593 | $c = $c + 1; | 
| 594 | 594 | |
| 595 | 595 | } | 
| @@ -598,11 +598,11 @@ discard block | ||
| 598 | 598 | |
| 599 | 599 | echo '<img src="'; | 
| 600 | 600 |              if ($this->_Local_images) { | 
| 601 | - echo $plugin_path . '/images/add.png'; | |
| 601 | + echo $plugin_path.'/images/add.png'; | |
| 602 | 602 |              } else { | 
| 603 | 603 | echo 'http://i.imgur.com/w5Tuc.png'; | 
| 604 | 604 | } | 
| 605 | -            echo '" alt="' . __('Add', 'geodirectory') . '" title="' . __('Add', 'geodirectory') . '" id="add-' . $field['id'] . '"><br/></div>'; | |
| 605 | +            echo '" alt="'.__('Add', 'geodirectory').'" title="'.__('Add', 'geodirectory').'" id="add-'.$field['id'].'"><br/></div>'; | |
| 606 | 606 | |
| 607 | 607 | //create all fields once more for js function and catch with object buffer | 
| 608 | 608 | ob_start(); | 
| @@ -613,12 +613,12 @@ discard block | ||
| 613 | 613 |              foreach ($field['fields'] as $f) { | 
| 614 | 614 | //reset var $id for repeater | 
| 615 | 615 | $id = ''; | 
| 616 | - $id = $field['id'] . '[CurrentCounter][' . $f['id'] . ']'; | |
| 616 | + $id = $field['id'].'[CurrentCounter]['.$f['id'].']'; | |
| 617 | 617 | $f['id'] = $id; | 
| 618 | 618 |                  if (!$field['inline']) { | 
| 619 | 619 | echo '<tr>'; | 
| 620 | 620 | } | 
| 621 | - call_user_func(array(&$this, 'show_field_' . $f['type']), $f, ''); | |
| 621 | + call_user_func(array(&$this, 'show_field_'.$f['type']), $f, ''); | |
| 622 | 622 |                  if (!$field['inline']) { | 
| 623 | 623 | echo '</tr>'; | 
| 624 | 624 | } | 
| @@ -628,24 +628,24 @@ discard block | ||
| 628 | 628 | } | 
| 629 | 629 | echo '</table><img src="'; | 
| 630 | 630 |              if ($this->_Local_images) { | 
| 631 | - echo $plugin_path . '/images/remove.png'; | |
| 631 | + echo $plugin_path.'/images/remove.png'; | |
| 632 | 632 |              } else { | 
| 633 | 633 | echo 'http://i.imgur.com/g8Duj.png'; | 
| 634 | 634 | } | 
| 635 | -            echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>'; | |
| 636 | - $counter = 'countadd_' . $field['id']; | |
| 635 | +            echo '" alt="'.__('Remove', 'geodirectory').'" title="'.__('Remove', 'geodirectory').'" id="remove-'.$field['id'].'"></div>'; | |
| 636 | + $counter = 'countadd_'.$field['id']; | |
| 637 | 637 | $js_code = ob_get_clean(); | 
| 638 | 638 |              $js_code = str_replace("'", "\"", $js_code); | 
| 639 | -            $js_code = str_replace("CurrentCounter", "' + " . $counter . " + '", $js_code); | |
| 639 | +            $js_code = str_replace("CurrentCounter", "' + ".$counter." + '", $js_code); | |
| 640 | 640 | echo '<script> | 
| 641 | 641 |  				jQuery(document).ready(function() { | 
| 642 | - var ' . $counter . ' = ' . $c . '; | |
| 643 | -					jQuery("#add-' . $field['id'] . '").live(\'click\', function() { | |
| 644 | - ' . $counter . ' = ' . $counter . ' + 1; | |
| 645 | - jQuery(this).before(\'' . $js_code . '\'); | |
| 642 | + var ' . $counter.' = '.$c.'; | |
| 643 | +					jQuery("#add-' . $field['id'].'").live(\'click\', function() { | |
| 644 | + ' . $counter.' = '.$counter.' + 1; | |
| 645 | + jQuery(this).before(\'' . $js_code.'\'); | |
| 646 | 646 | update_repeater_fields(); | 
| 647 | 647 | }); | 
| 648 | -        			jQuery("#remove-' . $field['id'] . '").live(\'click\', function() { | |
| 648 | +        			jQuery("#remove-' . $field['id'].'").live(\'click\', function() { | |
| 649 | 649 | jQuery(this).parent().remove(); | 
| 650 | 650 | }); | 
| 651 | 651 | }); | 
| @@ -772,7 +772,7 @@ discard block | ||
| 772 | 772 | public function show_field_paragraph($field) | 
| 773 | 773 |          { | 
| 774 | 774 | //$this->show_field_begin( $field, $meta ); | 
| 775 | - echo '<p>' . $field['value'] . '</p>'; | |
| 775 | + echo '<p>'.$field['value'].'</p>'; | |
| 776 | 776 | //$this->show_field_end( $field, $meta ); | 
| 777 | 777 | } | 
| 778 | 778 | |
| @@ -803,12 +803,12 @@ discard block | ||
| 803 | 803 |          { | 
| 804 | 804 | |
| 805 | 805 | if (!is_array($meta)) | 
| 806 | - $meta = (array)$meta; | |
| 806 | + $meta = (array) $meta; | |
| 807 | 807 | |
| 808 | 808 | $this->show_field_begin($field, $meta); | 
| 809 | -            echo "<select class='at-select' name='{$field['id']}" . ($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'") . ">"; | |
| 809 | +            echo "<select class='at-select' name='{$field['id']}".($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'").">"; | |
| 810 | 810 |              foreach ($field['options'] as $key => $value) { | 
| 811 | -                echo "<option value='{$key}'" . selected(in_array($key, $meta), true, false) . ">{$value}</option>"; | |
| 811 | +                echo "<option value='{$key}'".selected(in_array($key, $meta), true, false).">{$value}</option>"; | |
| 812 | 812 | } | 
| 813 | 813 | echo "</select>"; | 
| 814 | 814 | $this->show_field_end($field, $meta); | 
| @@ -827,11 +827,11 @@ discard block | ||
| 827 | 827 |          { | 
| 828 | 828 | |
| 829 | 829 | if (!is_array($meta)) | 
| 830 | - $meta = (array)$meta; | |
| 830 | + $meta = (array) $meta; | |
| 831 | 831 | |
| 832 | 832 | $this->show_field_begin($field, $meta); | 
| 833 | 833 |              foreach ($field['options'] as $key => $value) { | 
| 834 | -                echo "<input type='radio' class='at-radio' name='{$field['id']}' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> <span class='at-radio-label'>{$value}</span>"; | |
| 834 | +                echo "<input type='radio' class='at-radio' name='{$field['id']}' value='{$key}'".checked(in_array($key, $meta), true, false)." /> <span class='at-radio-label'>{$value}</span>"; | |
| 835 | 835 | } | 
| 836 | 836 | $this->show_field_end($field, $meta); | 
| 837 | 837 | } | 
| @@ -848,7 +848,7 @@ discard block | ||
| 848 | 848 |          { | 
| 849 | 849 | |
| 850 | 850 | $this->show_field_begin($field, $meta); | 
| 851 | -            echo "<input type='checkbox' class='rw-checkbox' name='{$field['id']}' id='{$field['id']}'" . checked(!empty($meta), true, false) . " /> {$field['desc']}"; | |
| 851 | +            echo "<input type='checkbox' class='rw-checkbox' name='{$field['id']}' id='{$field['id']}'".checked(!empty($meta), true, false)." /> {$field['desc']}"; | |
| 852 | 852 | $this->show_field_end($field, $meta); | 
| 853 | 853 | } | 
| 854 | 854 | |
| @@ -890,18 +890,18 @@ discard block | ||
| 890 | 890 | global $post; | 
| 891 | 891 | |
| 892 | 892 | if (!is_array($meta)) | 
| 893 | - $meta = (array)$meta; | |
| 893 | + $meta = (array) $meta; | |
| 894 | 894 | |
| 895 | 895 | $this->show_field_begin($field, $meta); | 
| 896 | 896 |              echo "{$field['desc']}<br />"; | 
| 897 | 897 | |
| 898 | 898 |              if (!empty($meta)) { | 
| 899 | 899 |                  $nonce = wp_create_nonce('at_ajax_delete'); | 
| 900 | -                echo '<div style="margin-bottom: 10px"><strong>' . __('Uploaded files', 'geodirectory') . '</strong></div>'; | |
| 900 | +                echo '<div style="margin-bottom: 10px"><strong>'.__('Uploaded files', 'geodirectory').'</strong></div>'; | |
| 901 | 901 | echo '<ol class="at-upload">'; | 
| 902 | 902 |                  foreach ($meta as $att) { | 
| 903 | 903 | // if (wp_attachment_is_image($att)) continue; // what's image uploader for? | 
| 904 | -                    echo "<li>" . wp_get_attachment_link($att, '', false, false, ' ') . " (<a class='at-delete-file' href='#' rel='{$nonce}|{$post->ID}|{$field['id']}|{$att}'>" . __('Remove', 'geodirectory') . "</a>)</li>"; | |
| 904 | +                    echo "<li>".wp_get_attachment_link($att, '', false, false, ' ')." (<a class='at-delete-file' href='#' rel='{$nonce}|{$post->ID}|{$field['id']}|{$att}'>".__('Remove', 'geodirectory')."</a>)</li>"; | |
| 905 | 905 | } | 
| 906 | 906 | echo '</ol>'; | 
| 907 | 907 | } | 
| @@ -909,13 +909,13 @@ discard block | ||
| 909 | 909 | // show form upload | 
| 910 | 910 | |
| 911 | 911 | echo "<div class='at-file-upload-label'>"; | 
| 912 | -            echo "<strong>" . __('Upload new files', 'geodirectory') . "</strong>"; | |
| 912 | +            echo "<strong>".__('Upload new files', 'geodirectory')."</strong>"; | |
| 913 | 913 | echo "</div>"; | 
| 914 | 914 | echo "<div class='new-files'>"; | 
| 915 | 915 | echo "<div class='file-input'>"; | 
| 916 | 916 |              echo "<input type='file' name='{$field['id']}[]' />"; | 
| 917 | 917 | echo "</div><!-- End .file-input -->"; | 
| 918 | -            echo "<a class='at-add-file button' href='#'>" . __('Add more files', 'geodirectory') . "</a>"; | |
| 918 | +            echo "<a class='at-add-file button' href='#'>".__('Add more files', 'geodirectory')."</a>"; | |
| 919 | 919 | echo "</div><!-- End .new-files -->"; | 
| 920 | 920 | echo "</td>"; | 
| 921 | 921 | $this->show_field_end($field, $meta); | 
| @@ -932,7 +932,7 @@ discard block | ||
| 932 | 932 | public function show_field_image($field, $meta) | 
| 933 | 933 |          { | 
| 934 | 934 | $this->show_field_begin($field, $meta); | 
| 935 | -            $html = wp_nonce_field("at-delete-mupload_{$field['id']}", "nonce-delete-mupload_" . $field['id'], false, false); | |
| 935 | +            $html = wp_nonce_field("at-delete-mupload_{$field['id']}", "nonce-delete-mupload_".$field['id'], false, false); | |
| 936 | 936 |              if (is_array($meta)) { | 
| 937 | 937 | if (isset($meta[0]) && is_array($meta[0])) | 
| 938 | 938 | $meta = $meta[0]; | 
| @@ -958,20 +958,20 @@ discard block | ||
| 958 | 958 | |
| 959 | 959 | $sub_dir = str_replace($uploads_baseurl, '', $sub_dir); | 
| 960 | 960 | |
| 961 | - $uploads_url = $uploads_baseurl . $sub_dir; | |
| 961 | + $uploads_url = $uploads_baseurl.$sub_dir; | |
| 962 | 962 | |
| 963 | - $meta['src'] = $uploads_url . '/' . $file_name; | |
| 963 | + $meta['src'] = $uploads_url.'/'.$file_name; | |
| 964 | 964 | |
| 965 | 965 | |
| 966 | - $html .= "<span class='mupload_img_holder'><img src='" . $meta['src'] . "' style='max-height: 150px;max-width: 150px;' /></span>"; | |
| 967 | - $html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='" . $meta['id'] . "' />"; | |
| 968 | - $html .= "<input type='hidden' class='" . $field['id'] . "[src]' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='" . $meta['src'] . "' />"; | |
| 969 | -                $html .= "<input class='at-delete_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Remove Image', 'geodirectory') . "' />"; | |
| 966 | + $html .= "<span class='mupload_img_holder'><img src='".$meta['src']."' style='max-height: 150px;max-width: 150px;' /></span>"; | |
| 967 | + $html .= "<input type='hidden' name='".$field['id']."[id]' id='".$field['id']."[id]' value='".$meta['id']."' />"; | |
| 968 | + $html .= "<input type='hidden' class='".$field['id']."[src]' name='".$field['id']."[src]' id='".$field['id']."[src]' value='".$meta['src']."' />"; | |
| 969 | +                $html .= "<input class='at-delete_image_button' type='button' rel='".$field['id']."' value='".__('Remove Image', 'geodirectory')."' />"; | |
| 970 | 970 |              } else { | 
| 971 | 971 | $html .= "<span class='mupload_img_holder'></span>"; | 
| 972 | - $html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='' />"; | |
| 973 | - $html .= "<input class='" . $field['id'] . "[src]' style='position:absolute;left:-500px;width:50px;' type='text' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='' />"; | |
| 974 | -                $html .= "<input class='at-upload_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Upload Image', 'geodirectory') . "' />"; | |
| 972 | + $html .= "<input type='hidden' name='".$field['id']."[id]' id='".$field['id']."[id]' value='' />"; | |
| 973 | + $html .= "<input class='".$field['id']."[src]' style='position:absolute;left:-500px;width:50px;' type='text' name='".$field['id']."[src]' id='".$field['id']."[src]' value='' />"; | |
| 974 | +                $html .= "<input class='at-upload_image_button' type='button' rel='".$field['id']."' value='".__('Upload Image', 'geodirectory')."' />"; | |
| 975 | 975 | } | 
| 976 | 976 | echo $html; | 
| 977 | 977 | $this->show_field_end($field, $meta); | 
| @@ -995,7 +995,7 @@ discard block | ||
| 995 | 995 | |
| 996 | 996 |              echo "<input class='at-color' type='text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='8' />"; | 
| 997 | 997 |              //	echo "<a href='#' class='at-color-select button' rel='{$field['id']}'>" . __( 'Select a color' ) . "</a>"; | 
| 998 | -            echo "<input type='button' class='at-color-select button' rel='{$field['id']}' value='" . __('Select a color', 'geodirectory') . "'/>"; | |
| 998 | +            echo "<input type='button' class='at-color-select button' rel='{$field['id']}' value='".__('Select a color', 'geodirectory')."'/>"; | |
| 999 | 999 |              echo "<div style='display:none' class='at-color-picker' rel='{$field['id']}'></div>"; | 
| 1000 | 1000 | $this->show_field_end($field, $meta); | 
| 1001 | 1001 | |
| @@ -1013,14 +1013,14 @@ discard block | ||
| 1013 | 1013 |          { | 
| 1014 | 1014 | |
| 1015 | 1015 | if (!is_array($meta)) | 
| 1016 | - $meta = (array)$meta; | |
| 1016 | + $meta = (array) $meta; | |
| 1017 | 1017 | |
| 1018 | 1018 | $this->show_field_begin($field, $meta); | 
| 1019 | 1019 | |
| 1020 | 1020 | $html = array(); | 
| 1021 | 1021 | |
| 1022 | 1022 |              foreach ($field['options'] as $key => $value) { | 
| 1023 | -                $html[] = "<input type='checkbox' class='at-checkbox_list' name='{$field['id']}[]' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> {$value}"; | |
| 1023 | +                $html[] = "<input type='checkbox' class='at-checkbox_list' name='{$field['id']}[]' value='{$key}'".checked(in_array($key, $meta), true, false)." /> {$value}"; | |
| 1024 | 1024 | } | 
| 1025 | 1025 | |
| 1026 | 1026 |              echo implode('<br />', $html); | 
| @@ -1073,7 +1073,7 @@ discard block | ||
| 1073 | 1073 |          { | 
| 1074 | 1074 | global $post; | 
| 1075 | 1075 | |
| 1076 | - if (!is_array($meta)) $meta = (array)$meta; | |
| 1076 | + if (!is_array($meta)) $meta = (array) $meta; | |
| 1077 | 1077 | $this->show_field_begin($field, $meta); | 
| 1078 | 1078 | $options = $field['options']; | 
| 1079 | 1079 | $posts = get_posts($options['args']); | 
| @@ -1081,13 +1081,13 @@ discard block | ||
| 1081 | 1081 | // checkbox_list | 
| 1082 | 1082 |              if ('checkbox_list' == $options['type']) { | 
| 1083 | 1083 |                  foreach ($posts as $p) { | 
| 1084 | -                    echo "<input type='checkbox' name='{$field['id']}[]' value='$p->ID'" . checked(in_array($p->ID, $meta), true, false) . " /> $p->post_title<br/>"; | |
| 1084 | +                    echo "<input type='checkbox' name='{$field['id']}[]' value='$p->ID'".checked(in_array($p->ID, $meta), true, false)." /> $p->post_title<br/>"; | |
| 1085 | 1085 | } | 
| 1086 | 1086 | } // select | 
| 1087 | 1087 |              else { | 
| 1088 | -                echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">"; | |
| 1088 | +                echo "<select name='{$field['id']}".($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'").">"; | |
| 1089 | 1089 |                  foreach ($posts as $p) { | 
| 1090 | - echo "<option value='$p->ID'" . selected(in_array($p->ID, $meta), true, false) . ">$p->post_title</option>"; | |
| 1090 | + echo "<option value='$p->ID'".selected(in_array($p->ID, $meta), true, false).">$p->post_title</option>"; | |
| 1091 | 1091 | } | 
| 1092 | 1092 | echo "</select>"; | 
| 1093 | 1093 | } | 
| @@ -1111,7 +1111,7 @@ discard block | ||
| 1111 | 1111 |          { | 
| 1112 | 1112 | global $post; | 
| 1113 | 1113 | |
| 1114 | - if (!is_array($meta)) $meta = (array)$meta; | |
| 1114 | + if (!is_array($meta)) $meta = (array) $meta; | |
| 1115 | 1115 | $this->show_field_begin($field, $meta); | 
| 1116 | 1116 | $options = $field['options']; | 
| 1117 | 1117 | $terms = get_terms($options['taxonomy'], $options['args']); | 
| @@ -1119,13 +1119,13 @@ discard block | ||
| 1119 | 1119 | // checkbox_list | 
| 1120 | 1120 |              if ('checkbox_list' == $options['type']) { | 
| 1121 | 1121 |                  foreach ($terms as $term) { | 
| 1122 | -                    echo "<input type='checkbox' name='{$field['id']}[]' value='$term->slug'" . checked(in_array($term->slug, $meta), true, false) . " /> $term->name<br/>"; | |
| 1122 | +                    echo "<input type='checkbox' name='{$field['id']}[]' value='$term->slug'".checked(in_array($term->slug, $meta), true, false)." /> $term->name<br/>"; | |
| 1123 | 1123 | } | 
| 1124 | 1124 | } // select | 
| 1125 | 1125 |              else { | 
| 1126 | -                echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">"; | |
| 1126 | +                echo "<select name='{$field['id']}".($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'").">"; | |
| 1127 | 1127 |                  foreach ($terms as $term) { | 
| 1128 | - echo "<option value='$term->slug'" . selected(in_array($term->slug, $meta), true, false) . ">$term->name</option>"; | |
| 1128 | + echo "<option value='$term->slug'".selected(in_array($term->slug, $meta), true, false).">$term->name</option>"; | |
| 1129 | 1129 | } | 
| 1130 | 1130 | echo "</select>"; | 
| 1131 | 1131 | } | 
| @@ -1181,7 +1181,7 @@ discard block | ||
| 1181 | 1181 | |
| 1182 | 1182 | //$old_filename = $upload_dir['path'].'/'.$old_filename; | 
| 1183 | 1183 | |
| 1184 | - $new_filename = $upload_dir['path'] . '/' . 'cat_icon_' . $term_id . '.png'; | |
| 1184 | + $new_filename = $upload_dir['path'].'/'.'cat_icon_'.$term_id.'.png'; | |
| 1185 | 1185 | |
| 1186 | 1186 | /*rename($old_filename, $new_filename); | 
| 1187 | 1187 | |
| @@ -1223,9 +1223,9 @@ discard block | ||
| 1223 | 1223 |                  if ($type != "paragraph") { | 
| 1224 | 1224 | |
| 1225 | 1225 | // Call defined method to save meta value, if there's no methods, call common one. | 
| 1226 | - $save_func = 'save_field_' . $type; | |
| 1226 | + $save_func = 'save_field_'.$type; | |
| 1227 | 1227 |                      if (method_exists($this, $save_func)) { | 
| 1228 | - call_user_func(array(&$this, 'save_field_' . $type), $term_id, $field, $old, $new); | |
| 1228 | + call_user_func(array(&$this, 'save_field_'.$type), $term_id, $field, $old, $new); | |
| 1229 | 1229 |                      } else { | 
| 1230 | 1230 | $this->save_field($term_id, $field, $old, $new); | 
| 1231 | 1231 | } | 
| @@ -1370,7 +1370,7 @@ discard block | ||
| 1370 | 1370 |                  if (!is_wp_error($id)) { | 
| 1371 | 1371 | |
| 1372 | 1372 | wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); | 
| 1373 | - add_post_meta($term_id, $name, $id, false); // save file's url in meta fields | |
| 1373 | + add_post_meta($term_id, $name, $id, false); // save file's url in meta fields | |
| 1374 | 1374 | |
| 1375 | 1375 | } // End if | 
| 1376 | 1376 | |
| @@ -1415,7 +1415,7 @@ discard block | ||
| 1415 | 1415 |                  if (!is_wp_error($id)) { | 
| 1416 | 1416 | |
| 1417 | 1417 | wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); | 
| 1418 | - return $id; // return file's url in meta fields | |
| 1418 | + return $id; // return file's url in meta fields | |
| 1419 | 1419 | } // End if | 
| 1420 | 1420 | } // End foreach | 
| 1421 | 1421 | } | 
| @@ -1430,9 +1430,9 @@ discard block | ||
| 1430 | 1430 |          { | 
| 1431 | 1431 | |
| 1432 | 1432 | // Default values for meta box | 
| 1433 | -            $this->_meta_box = array_merge(array('context' => 'normal', 'priority' => 'high', 'pages' => array('post')), (array)$this->_meta_box); | |
| 1433 | +            $this->_meta_box = array_merge(array('context' => 'normal', 'priority' => 'high', 'pages' => array('post')), (array) $this->_meta_box); | |
| 1434 | 1434 | |
| 1435 | -            if(is_array($this->_fields)) { | |
| 1435 | +            if (is_array($this->_fields)) { | |
| 1436 | 1436 | // Default values for fields | 
| 1437 | 1437 |                  foreach ($this->_fields as &$field) { | 
| 1438 | 1438 |                      $multiple = in_array($field['type'], array('checkbox_list', 'file', 'image')); | 
| @@ -1452,7 +1452,7 @@ discard block | ||
| 1452 | 1452 | */ | 
| 1453 | 1453 | public function has_field($type) | 
| 1454 | 1454 |          { | 
| 1455 | -            if(is_array($this->_fields)) { | |
| 1455 | +            if (is_array($this->_fields)) { | |
| 1456 | 1456 |                  foreach ($this->_fields as $field) { | 
| 1457 | 1457 | if ($type == $field['type']) | 
| 1458 | 1458 | return true; | 
| @@ -2020,12 +2020,12 @@ discard block | ||
| 2020 | 2020 | $post_type = $taxObject->object_type[0]; | 
| 2021 | 2021 | } | 
| 2022 | 2022 | |
| 2023 | -            if($post_type=='post'){$post_type='';} | |
| 2024 | -            if($post_type){$post_type = $post_type.'_';} | |
| 2023 | +            if ($post_type == 'post') {$post_type = ''; } | |
| 2024 | +            if ($post_type) {$post_type = $post_type.'_'; } | |
| 2025 | 2025 | |
| 2026 | 2026 | $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id; | 
| 2027 | 2027 | |
| 2028 | -            $m = get_option('tax_meta_' . $post_type  . $t_id); | |
| 2028 | +            $m = get_option('tax_meta_'.$post_type.$t_id); | |
| 2029 | 2029 |              if (isset($m[$key])) { | 
| 2030 | 2030 | return $m[$key]; | 
| 2031 | 2031 |              } else { | 
| @@ -2042,15 +2042,15 @@ discard block | ||
| 2042 | 2042 | $post_type = $taxObject->object_type[0]; | 
| 2043 | 2043 | } | 
| 2044 | 2044 | |
| 2045 | -            if($post_type=='post'){$post_type='';} | |
| 2046 | -            if($post_type){$post_type = $post_type.'_';} | |
| 2045 | +            if ($post_type == 'post') {$post_type = ''; } | |
| 2046 | +            if ($post_type) {$post_type = $post_type.'_'; } | |
| 2047 | 2047 | |
| 2048 | -            $m = get_option('tax_meta_' . $post_type  . $term_id); | |
| 2048 | +            $m = get_option('tax_meta_'.$post_type.$term_id); | |
| 2049 | 2049 | |
| 2050 | 2050 |              if (isset($m[$key])) { | 
| 2051 | 2051 | unset($m[$key]); | 
| 2052 | 2052 | } | 
| 2053 | -            update_option('tax_meta_' . $post_type  . $term_id, $m); | |
| 2053 | +            update_option('tax_meta_'.$post_type.$term_id, $m); | |
| 2054 | 2054 | } | 
| 2055 | 2055 | |
| 2056 | 2056 | //update meta | 
| @@ -2062,13 +2062,13 @@ discard block | ||
| 2062 | 2062 | $post_type = $taxObject->object_type[0]; | 
| 2063 | 2063 | } | 
| 2064 | 2064 | |
| 2065 | -            if($post_type=='post'){$post_type='';} | |
| 2066 | -            if($post_type){$post_type = $post_type.'_';} | |
| 2065 | +            if ($post_type == 'post') {$post_type = ''; } | |
| 2066 | +            if ($post_type) {$post_type = $post_type.'_'; } | |
| 2067 | 2067 | |
| 2068 | -            $m = get_option('tax_meta_' . $post_type  . $term_id); | |
| 2068 | +            $m = get_option('tax_meta_'.$post_type.$term_id); | |
| 2069 | 2069 | |
| 2070 | 2070 | $m[$key] = $value; | 
| 2071 | -            update_option('tax_meta_' . $post_type  . $term_id, $m); | |
| 2071 | +            update_option('tax_meta_'.$post_type.$term_id, $m); | |
| 2072 | 2072 | |
| 2073 | 2073 | /** | 
| 2074 | 2074 | * Called after the tax meta is updated. | 
| @@ -2103,12 +2103,12 @@ discard block | ||
| 2103 | 2103 | $post_type = $taxObject->object_type[0]; | 
| 2104 | 2104 | } | 
| 2105 | 2105 | |
| 2106 | -        if($post_type=='post'){$post_type='';} | |
| 2107 | -        if($post_type){$post_type = $post_type.'_';} | |
| 2106 | +        if ($post_type == 'post') {$post_type = ''; } | |
| 2107 | +        if ($post_type) {$post_type = $post_type.'_'; } | |
| 2108 | 2108 | |
| 2109 | 2109 | $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id; | 
| 2110 | 2110 | |
| 2111 | -        $m = get_option('tax_meta_' . $post_type  . $t_id); | |
| 2111 | +        $m = get_option('tax_meta_'.$post_type.$t_id); | |
| 2112 | 2112 |          if (isset($m[$key])) { | 
| 2113 | 2113 | return $m[$key]; | 
| 2114 | 2114 |          } else { | 
| @@ -2125,15 +2125,15 @@ discard block | ||
| 2125 | 2125 | $taxObject = get_taxonomy($_REQUEST['taxonomy']); | 
| 2126 | 2126 | $post_type = $taxObject->object_type[0]; | 
| 2127 | 2127 | |
| 2128 | -        if($post_type=='post'){$post_type='';} | |
| 2129 | -        if($post_type){$post_type = $post_type.'_';} | |
| 2128 | +        if ($post_type == 'post') {$post_type = ''; } | |
| 2129 | +        if ($post_type) {$post_type = $post_type.'_'; } | |
| 2130 | 2130 | |
| 2131 | -        $m = get_option('tax_meta_' . $post_type . $term_id); | |
| 2131 | +        $m = get_option('tax_meta_'.$post_type.$term_id); | |
| 2132 | 2132 | |
| 2133 | 2133 |          if (isset($m[$key])) { | 
| 2134 | 2134 | unset($m[$key]); | 
| 2135 | 2135 | } | 
| 2136 | -        update_option('tax_meta_' . $post_type  . $term_id, $m); | |
| 2136 | +        update_option('tax_meta_'.$post_type.$term_id, $m); | |
| 2137 | 2137 | } | 
| 2138 | 2138 | } | 
| 2139 | 2139 | |
| @@ -2147,13 +2147,13 @@ discard block | ||
| 2147 | 2147 | $post_type = $taxObject->object_type[0]; | 
| 2148 | 2148 | } | 
| 2149 | 2149 | |
| 2150 | -        if($post_type=='post'){$post_type='';} | |
| 2151 | -        if($post_type){$post_type = $post_type.'_';} | |
| 2150 | +        if ($post_type == 'post') {$post_type = ''; } | |
| 2151 | +        if ($post_type) {$post_type = $post_type.'_'; } | |
| 2152 | 2152 | |
| 2153 | -        $m = get_option('tax_meta_' . $post_type  . $term_id); | |
| 2153 | +        $m = get_option('tax_meta_'.$post_type.$term_id); | |
| 2154 | 2154 | |
| 2155 | 2155 | $m[$key] = $value; | 
| 2156 | -        update_option('tax_meta_' . $post_type . $term_id, $m); | |
| 2156 | +        update_option('tax_meta_'.$post_type.$term_id, $m); | |
| 2157 | 2157 | |
| 2158 | 2158 | /** This action is documented in geodirectory-functions/cat-meta-functions/Tax-meta-class.php */ | 
| 2159 | 2159 |          do_action('gd_tax_meta_updated', false, true, $term_id, $post_type); | 
| @@ -179,7 +179,7 @@ | ||
| 179 | 179 | * @since 1.0.0 | 
| 180 | 180 | * @package GeoDirectory | 
| 181 | 181 | * @param array $classes Class array. | 
| 182 | - * @return array Modified class array. | |
| 182 | + * @return string[] Modified class array. | |
| 183 | 183 | */ | 
| 184 | 184 | function gd_compat_body_class($classes) | 
| 185 | 185 |  { | 
| @@ -51,7 +51,7 @@ discard block | ||
| 51 | 51 |  { | 
| 52 | 52 |      if (geodir_is_geodir_page()) { | 
| 53 | 53 | gd_avada_current_page_title_bar(); | 
| 54 | -    }else{ | |
| 54 | +    } else{ | |
| 55 | 55 | avada_current_page_title_bar( $c_pageID ); | 
| 56 | 56 | } | 
| 57 | 57 | |
| @@ -96,8 +96,7 @@ discard block | ||
| 96 | 96 | |
| 97 | 97 | |
| 98 | 98 |      if (geodir_is_page('detail') || geodir_is_page('preview')) { | 
| 99 | -        if ( $title = get_post_meta( get_the_ID(), 'pyre_page_title_custom_text', true ) ) {} | |
| 100 | -        else { | |
| 99 | +        if ( $title = get_post_meta( get_the_ID(), 'pyre_page_title_custom_text', true ) ) {} else { | |
| 101 | 100 | $title = get_the_title(); | 
| 102 | 101 | } | 
| 103 | 102 | avada_page_title_bar($title, $subtitle, $secondary_content); | 
| @@ -18,10 +18,10 @@ discard block | ||
| 18 | 18 | */ | 
| 19 | 19 | function gd_strip_breadcrumb_wrappers($breadcrumb) | 
| 20 | 20 |  { | 
| 21 | -    $breadcrumb = str_replace(array("<li>","</li>"), "", $breadcrumb); | |
| 22 | -    $breadcrumb = str_replace('<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">', '<ul class="fusion-breadcrumbs"><li>', $breadcrumb); | |
| 23 | -    $breadcrumb = str_replace('</ul></div>', '</li></ul>', $breadcrumb); | |
| 24 | - return $breadcrumb; | |
| 21 | +	$breadcrumb = str_replace(array("<li>","</li>"), "", $breadcrumb); | |
| 22 | +	$breadcrumb = str_replace('<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">', '<ul class="fusion-breadcrumbs"><li>', $breadcrumb); | |
| 23 | +	$breadcrumb = str_replace('</ul></div>', '</li></ul>', $breadcrumb); | |
| 24 | + return $breadcrumb; | |
| 25 | 25 | } | 
| 26 | 26 | |
| 27 | 27 |  add_filter('geodir_breadcrumb_separator', 'gd_change_breadcrumb_separator'); | 
| @@ -35,8 +35,8 @@ discard block | ||
| 35 | 35 | */ | 
| 36 | 36 | function gd_change_breadcrumb_separator($separator) | 
| 37 | 37 |  { | 
| 38 | - $separator = ' / '; | |
| 39 | - return $separator; | |
| 38 | + $separator = ' / '; | |
| 39 | + return $separator; | |
| 40 | 40 | } | 
| 41 | 41 | |
| 42 | 42 |  add_action('avada_override_current_page_title_bar','gd_avada_current_page_title_bar_change'); | 
| @@ -49,11 +49,11 @@ discard block | ||
| 49 | 49 | */ | 
| 50 | 50 | function gd_avada_current_page_title_bar_change($c_pageID) | 
| 51 | 51 |  { | 
| 52 | -    if (geodir_is_geodir_page()) { | |
| 53 | - gd_avada_current_page_title_bar(); | |
| 54 | -    }else{ | |
| 55 | - avada_current_page_title_bar( $c_pageID ); | |
| 56 | - } | |
| 52 | +	if (geodir_is_geodir_page()) { | |
| 53 | + gd_avada_current_page_title_bar(); | |
| 54 | +	}else{ | |
| 55 | + avada_current_page_title_bar( $c_pageID ); | |
| 56 | + } | |
| 57 | 57 | |
| 58 | 58 | } | 
| 59 | 59 | |
| @@ -65,50 +65,50 @@ discard block | ||
| 65 | 65 | */ | 
| 66 | 66 | function gd_avada_current_page_title_bar() | 
| 67 | 67 |  { | 
| 68 | - ob_start(); | |
| 69 | - geodir_breadcrumb(); | |
| 70 | - $secondary_content = ob_get_contents(); | |
| 71 | - ob_get_clean(); | |
| 72 | - | |
| 73 | - $title = ''; | |
| 74 | - $subtitle = ''; | |
| 75 | - | |
| 76 | -    if (geodir_is_page('listing')) { | |
| 77 | - ob_start(); // Start buffering; | |
| 78 | - geodir_action_listings_title(); | |
| 79 | - $title = ob_get_clean(); | |
| 80 | - avada_page_title_bar($title, $subtitle, $secondary_content); | |
| 81 | - } | |
| 82 | - | |
| 83 | -    if (geodir_is_page('add-listing')) { | |
| 84 | - ob_start(); // Start buffering; | |
| 85 | - geodir_action_add_listing_page_title(); | |
| 86 | - $title = ob_get_clean(); | |
| 87 | - avada_page_title_bar($title, $subtitle, $secondary_content); | |
| 88 | - } | |
| 89 | - | |
| 90 | -    if (geodir_is_page('author')) { | |
| 91 | - ob_start(); // Start buffering; | |
| 92 | - geodir_action_author_page_title(); | |
| 93 | - $title = ob_get_clean(); | |
| 94 | - avada_page_title_bar($title, $subtitle, $secondary_content); | |
| 95 | - } | |
| 96 | - | |
| 97 | - | |
| 98 | -    if (geodir_is_page('detail') || geodir_is_page('preview')) { | |
| 99 | -        if ( $title = get_post_meta( get_the_ID(), 'pyre_page_title_custom_text', true ) ) {} | |
| 100 | -        else { | |
| 101 | - $title = get_the_title(); | |
| 102 | - } | |
| 103 | - avada_page_title_bar($title, $subtitle, $secondary_content); | |
| 104 | - } | |
| 105 | - | |
| 106 | -    if (geodir_is_page('search')) { | |
| 107 | - ob_start(); // Start buffering; | |
| 108 | - geodir_action_search_page_title(); | |
| 109 | - $title = ob_get_clean(); | |
| 110 | - avada_page_title_bar($title, $subtitle, $secondary_content); | |
| 111 | - } | |
| 68 | + ob_start(); | |
| 69 | + geodir_breadcrumb(); | |
| 70 | + $secondary_content = ob_get_contents(); | |
| 71 | + ob_get_clean(); | |
| 72 | + | |
| 73 | + $title = ''; | |
| 74 | + $subtitle = ''; | |
| 75 | + | |
| 76 | +	if (geodir_is_page('listing')) { | |
| 77 | + ob_start(); // Start buffering; | |
| 78 | + geodir_action_listings_title(); | |
| 79 | + $title = ob_get_clean(); | |
| 80 | + avada_page_title_bar($title, $subtitle, $secondary_content); | |
| 81 | + } | |
| 82 | + | |
| 83 | +	if (geodir_is_page('add-listing')) { | |
| 84 | + ob_start(); // Start buffering; | |
| 85 | + geodir_action_add_listing_page_title(); | |
| 86 | + $title = ob_get_clean(); | |
| 87 | + avada_page_title_bar($title, $subtitle, $secondary_content); | |
| 88 | + } | |
| 89 | + | |
| 90 | +	if (geodir_is_page('author')) { | |
| 91 | + ob_start(); // Start buffering; | |
| 92 | + geodir_action_author_page_title(); | |
| 93 | + $title = ob_get_clean(); | |
| 94 | + avada_page_title_bar($title, $subtitle, $secondary_content); | |
| 95 | + } | |
| 96 | + | |
| 97 | + | |
| 98 | +	if (geodir_is_page('detail') || geodir_is_page('preview')) { | |
| 99 | +		if ( $title = get_post_meta( get_the_ID(), 'pyre_page_title_custom_text', true ) ) {} | |
| 100 | +		else { | |
| 101 | + $title = get_the_title(); | |
| 102 | + } | |
| 103 | + avada_page_title_bar($title, $subtitle, $secondary_content); | |
| 104 | + } | |
| 105 | + | |
| 106 | +	if (geodir_is_page('search')) { | |
| 107 | + ob_start(); // Start buffering; | |
| 108 | + geodir_action_search_page_title(); | |
| 109 | + $title = ob_get_clean(); | |
| 110 | + avada_page_title_bar($title, $subtitle, $secondary_content); | |
| 111 | + } | |
| 112 | 112 | } | 
| 113 | 113 | |
| 114 | 114 | /** | 
| @@ -119,34 +119,34 @@ discard block | ||
| 119 | 119 | */ | 
| 120 | 120 | function gd_compat_php_avada() | 
| 121 | 121 |  { | 
| 122 | - // change widget wrappers | |
| 123 | - //add_filter( 'geodir_before_widget', 'geodir_before_widget_compat',10,1 ); | |
| 124 | - //add_filter( 'geodir_after_widget', 'geodir_after_widget_compat',10,1 ); | |
| 125 | - | |
| 126 | - // REMOVE BREADCRUMB | |
| 127 | -    remove_action('geodir_detail_before_main_content', 'geodir_breadcrumb', 20); | |
| 128 | -    remove_action('geodir_listings_before_main_content', 'geodir_breadcrumb', 20); | |
| 129 | -    remove_action('geodir_author_before_main_content', 'geodir_breadcrumb', 20); | |
| 130 | -    remove_action('geodir_search_before_main_content', 'geodir_breadcrumb', 20); | |
| 131 | -    remove_action('geodir_home_before_main_content', 'geodir_breadcrumb', 20); | |
| 132 | -    remove_action('geodir_location_before_main_content', 'geodir_breadcrumb', 20); | |
| 133 | - | |
| 134 | - // REMOVE PAGE TITLES | |
| 135 | -    remove_action('geodir_listings_page_title', 'geodir_action_listings_title', 10); | |
| 136 | -    remove_action('geodir_add_listing_page_title', 'geodir_action_add_listing_page_title', 10); | |
| 137 | -    remove_action('geodir_details_main_content', 'geodir_action_page_title', 20); | |
| 138 | -    remove_action('geodir_search_page_title', 'geodir_action_search_page_title', 10); | |
| 139 | -    remove_action('geodir_author_page_title', 'geodir_action_author_page_title', 10); | |
| 140 | - | |
| 141 | - // make top section wide | |
| 142 | -    remove_action('geodir_home_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10); | |
| 143 | -    remove_action('geodir_location_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10); | |
| 144 | -    remove_action('geodir_author_before_main_content', 'geodir_action_geodir_sidebar_author_top', 10); | |
| 145 | -    remove_action('geodir_search_before_main_content', 'geodir_action_geodir_sidebar_search_top', 10); | |
| 146 | -    remove_action('geodir_detail_before_main_content', 'geodir_action_geodir_sidebar_detail_top', 10); | |
| 147 | -    remove_action('geodir_listings_before_main_content', 'geodir_action_geodir_sidebar_listings_top', 10); | |
| 148 | - | |
| 149 | - //gd_compat_add_top_section_back(); | |
| 122 | + // change widget wrappers | |
| 123 | + //add_filter( 'geodir_before_widget', 'geodir_before_widget_compat',10,1 ); | |
| 124 | + //add_filter( 'geodir_after_widget', 'geodir_after_widget_compat',10,1 ); | |
| 125 | + | |
| 126 | + // REMOVE BREADCRUMB | |
| 127 | +	remove_action('geodir_detail_before_main_content', 'geodir_breadcrumb', 20); | |
| 128 | +	remove_action('geodir_listings_before_main_content', 'geodir_breadcrumb', 20); | |
| 129 | +	remove_action('geodir_author_before_main_content', 'geodir_breadcrumb', 20); | |
| 130 | +	remove_action('geodir_search_before_main_content', 'geodir_breadcrumb', 20); | |
| 131 | +	remove_action('geodir_home_before_main_content', 'geodir_breadcrumb', 20); | |
| 132 | +	remove_action('geodir_location_before_main_content', 'geodir_breadcrumb', 20); | |
| 133 | + | |
| 134 | + // REMOVE PAGE TITLES | |
| 135 | +	remove_action('geodir_listings_page_title', 'geodir_action_listings_title', 10); | |
| 136 | +	remove_action('geodir_add_listing_page_title', 'geodir_action_add_listing_page_title', 10); | |
| 137 | +	remove_action('geodir_details_main_content', 'geodir_action_page_title', 20); | |
| 138 | +	remove_action('geodir_search_page_title', 'geodir_action_search_page_title', 10); | |
| 139 | +	remove_action('geodir_author_page_title', 'geodir_action_author_page_title', 10); | |
| 140 | + | |
| 141 | + // make top section wide | |
| 142 | +	remove_action('geodir_home_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10); | |
| 143 | +	remove_action('geodir_location_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10); | |
| 144 | +	remove_action('geodir_author_before_main_content', 'geodir_action_geodir_sidebar_author_top', 10); | |
| 145 | +	remove_action('geodir_search_before_main_content', 'geodir_action_geodir_sidebar_search_top', 10); | |
| 146 | +	remove_action('geodir_detail_before_main_content', 'geodir_action_geodir_sidebar_detail_top', 10); | |
| 147 | +	remove_action('geodir_listings_before_main_content', 'geodir_action_geodir_sidebar_listings_top', 10); | |
| 148 | + | |
| 149 | + //gd_compat_add_top_section_back(); | |
| 150 | 150 | |
| 151 | 151 | } | 
| 152 | 152 | |
| @@ -158,17 +158,17 @@ discard block | ||
| 158 | 158 | * @package GeoDirectory | 
| 159 | 159 | */ | 
| 160 | 160 |  function gd_compat_add_top_section_back() { | 
| 161 | -    if (geodir_is_page('home') || geodir_is_page('location')) { | |
| 162 | - geodir_action_geodir_sidebar_home_top(); | |
| 163 | -    } elseif (geodir_is_page('listing')) { | |
| 164 | - geodir_action_geodir_sidebar_listings_top(); | |
| 165 | -    } elseif (geodir_is_page('detail')) { | |
| 166 | - geodir_action_geodir_sidebar_detail_top(); | |
| 167 | -    } elseif (geodir_is_page('search')) { | |
| 168 | - geodir_action_geodir_sidebar_search_top(); | |
| 169 | -    } elseif (geodir_is_page('author')) { | |
| 170 | - geodir_action_geodir_sidebar_author_top(); | |
| 171 | - } | |
| 161 | +	if (geodir_is_page('home') || geodir_is_page('location')) { | |
| 162 | + geodir_action_geodir_sidebar_home_top(); | |
| 163 | +	} elseif (geodir_is_page('listing')) { | |
| 164 | + geodir_action_geodir_sidebar_listings_top(); | |
| 165 | +	} elseif (geodir_is_page('detail')) { | |
| 166 | + geodir_action_geodir_sidebar_detail_top(); | |
| 167 | +	} elseif (geodir_is_page('search')) { | |
| 168 | + geodir_action_geodir_sidebar_search_top(); | |
| 169 | +	} elseif (geodir_is_page('author')) { | |
| 170 | + geodir_action_geodir_sidebar_author_top(); | |
| 171 | + } | |
| 172 | 172 | } | 
| 173 | 173 | |
| 174 | 174 |  add_filter('body_class', 'gd_compat_body_class'); | 
| @@ -182,12 +182,12 @@ discard block | ||
| 182 | 182 | */ | 
| 183 | 183 | function gd_compat_body_class($classes) | 
| 184 | 184 |  { | 
| 185 | -    if (geodir_is_geodir_page()) { | |
| 186 | - $classes[] = 'wpgeo-avada'; | |
| 187 | -    } else { | |
| 188 | - $classes[] = ''; | |
| 189 | - } | |
| 190 | - return $classes; | |
| 185 | +	if (geodir_is_geodir_page()) { | |
| 186 | + $classes[] = 'wpgeo-avada'; | |
| 187 | +	} else { | |
| 188 | + $classes[] = ''; | |
| 189 | + } | |
| 190 | + return $classes; | |
| 191 | 191 | } | 
| 192 | 192 | |
| 193 | 193 | |
| @@ -201,7 +201,7 @@ discard block | ||
| 201 | 201 | */ | 
| 202 | 202 | function geodir_before_widget_compat($var) | 
| 203 | 203 |  { | 
| 204 | - return '<div id="%1$s" class="geodir-widget %2$s">'; | |
| 204 | + return '<div id="%1$s" class="geodir-widget %2$s">'; | |
| 205 | 205 | } | 
| 206 | 206 | |
| 207 | 207 | /** | 
| @@ -214,7 +214,7 @@ discard block | ||
| 214 | 214 | */ | 
| 215 | 215 | function geodir_after_widget_compat($var) | 
| 216 | 216 |  { | 
| 217 | - return '</div>'; | |
| 217 | + return '</div>'; | |
| 218 | 218 | } | 
| 219 | 219 | |
| 220 | 220 |  add_filter('geodir_search_form_class', 'geodir_search_form_class_avada'); | 
| @@ -228,8 +228,8 @@ discard block | ||
| 228 | 228 | */ | 
| 229 | 229 | function geodir_search_form_class_avada($class) | 
| 230 | 230 |  { | 
| 231 | - $class .= ' search'; | |
| 232 | - return $class; | |
| 231 | + $class .= ' search'; | |
| 232 | + return $class; | |
| 233 | 233 | } | 
| 234 | 234 | |
| 235 | 235 | |
| @@ -238,11 +238,11 @@ discard block | ||
| 238 | 238 | |
| 239 | 239 | // Avada sets the search page to use wither post or page, we need it to be 'any' | 
| 240 | 240 |  function gd_avada_search_filter( $query ) { | 
| 241 | -    if ( geodir_is_page('search') && is_search() && $query->is_search) { | |
| 242 | -        $query->set('post_type', 'any'); | |
| 243 | - } | |
| 244 | - return $query; | |
| 241 | +	if ( geodir_is_page('search') && is_search() && $query->is_search) { | |
| 242 | +		$query->set('post_type', 'any'); | |
| 243 | + } | |
| 244 | + return $query; | |
| 245 | 245 | } | 
| 246 | 246 |  if ( ! is_admin() ) { | 
| 247 | - add_filter( 'pre_get_posts', 'gd_avada_search_filter',11 ); | |
| 247 | + add_filter( 'pre_get_posts', 'gd_avada_search_filter',11 ); | |
| 248 | 248 | } | 
| 249 | 249 | \ No newline at end of file | 
| @@ -18,7 +18,7 @@ discard block | ||
| 18 | 18 | */ | 
| 19 | 19 | function gd_strip_breadcrumb_wrappers($breadcrumb) | 
| 20 | 20 |  { | 
| 21 | -    $breadcrumb = str_replace(array("<li>","</li>"), "", $breadcrumb); | |
| 21 | +    $breadcrumb = str_replace(array("<li>", "</li>"), "", $breadcrumb); | |
| 22 | 22 |      $breadcrumb = str_replace('<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">', '<ul class="fusion-breadcrumbs"><li>', $breadcrumb); | 
| 23 | 23 |      $breadcrumb = str_replace('</ul></div>', '</li></ul>', $breadcrumb); | 
| 24 | 24 | return $breadcrumb; | 
| @@ -39,7 +39,7 @@ discard block | ||
| 39 | 39 | return $separator; | 
| 40 | 40 | } | 
| 41 | 41 | |
| 42 | -add_action('avada_override_current_page_title_bar','gd_avada_current_page_title_bar_change'); | |
| 42 | +add_action('avada_override_current_page_title_bar', 'gd_avada_current_page_title_bar_change'); | |
| 43 | 43 | /** | 
| 44 | 44 | * new title bar functions for gd pages. | 
| 45 | 45 | * | 
| @@ -51,8 +51,8 @@ discard block | ||
| 51 | 51 |  { | 
| 52 | 52 |      if (geodir_is_geodir_page()) { | 
| 53 | 53 | gd_avada_current_page_title_bar(); | 
| 54 | -    }else{ | |
| 55 | - avada_current_page_title_bar( $c_pageID ); | |
| 54 | +    } else { | |
| 55 | + avada_current_page_title_bar($c_pageID); | |
| 56 | 56 | } | 
| 57 | 57 | |
| 58 | 58 | } | 
| @@ -96,7 +96,7 @@ discard block | ||
| 96 | 96 | |
| 97 | 97 | |
| 98 | 98 |      if (geodir_is_page('detail') || geodir_is_page('preview')) { | 
| 99 | -        if ( $title = get_post_meta( get_the_ID(), 'pyre_page_title_custom_text', true ) ) {} | |
| 99 | +        if ($title = get_post_meta(get_the_ID(), 'pyre_page_title_custom_text', true)) {} | |
| 100 | 100 |          else { | 
| 101 | 101 | $title = get_the_title(); | 
| 102 | 102 | } | 
| @@ -237,12 +237,12 @@ discard block | ||
| 237 | 237 | gd_compat_php_avada(); | 
| 238 | 238 | |
| 239 | 239 | // Avada sets the search page to use wither post or page, we need it to be 'any' | 
| 240 | -function gd_avada_search_filter( $query ) { | |
| 241 | -    if ( geodir_is_page('search') && is_search() && $query->is_search) { | |
| 240 | +function gd_avada_search_filter($query) { | |
| 241 | +    if (geodir_is_page('search') && is_search() && $query->is_search) { | |
| 242 | 242 |          $query->set('post_type', 'any'); | 
| 243 | 243 | } | 
| 244 | 244 | return $query; | 
| 245 | 245 | } | 
| 246 | -if ( ! is_admin() ) { | |
| 247 | - add_filter( 'pre_get_posts', 'gd_avada_search_filter',11 ); | |
| 246 | +if (!is_admin()) { | |
| 247 | +    add_filter('pre_get_posts', 'gd_avada_search_filter', 11); | |
| 248 | 248 | } | 
| 249 | 249 | \ No newline at end of file | 
| @@ -133,7 +133,7 @@ | ||
| 133 | 133 | * @since 1.0.0 | 
| 134 | 134 | * @package GeoDirectory | 
| 135 | 135 | * @param array $classes Class array. | 
| 136 | - * @return array Modified class array. | |
| 136 | + * @return string[] Modified class array. | |
| 137 | 137 | */ | 
| 138 | 138 | function wpgeo_enfold_body_class($classes) | 
| 139 | 139 |  { | 
| @@ -17,84 +17,84 @@ discard block | ||
| 17 | 17 | function enfold_action_calls() | 
| 18 | 18 |  { | 
| 19 | 19 | |
| 20 | - /* ACTIONS | |
| 20 | + /* ACTIONS | |
| 21 | 21 | ****************************************************************************************/ | 
| 22 | 22 | |
| 23 | - // Add body class for styling purposes | |
| 24 | -    add_filter('body_class', 'wpgeo_enfold_body_class'); | |
| 23 | + // Add body class for styling purposes | |
| 24 | +	add_filter('body_class', 'wpgeo_enfold_body_class'); | |
| 25 | 25 | |
| 26 | - // Pages using the page-builder shouldn't redirect on successful payment | |
| 27 | -    if (isset($_REQUEST['pay_action'])) { | |
| 28 | -        add_action('init', 'geodir_allow_payment_urls_enfold', 15); | |
| 29 | - } | |
| 26 | + // Pages using the page-builder shouldn't redirect on successful payment | |
| 27 | +	if (isset($_REQUEST['pay_action'])) { | |
| 28 | +		add_action('init', 'geodir_allow_payment_urls_enfold', 15); | |
| 29 | + } | |
| 30 | 30 | |
| 31 | - // LOCATION MANAGER MENU ACTIONS - set the location menu item before the Enfold search | |
| 32 | -    if (function_exists('geodir_location_menu_items')) { | |
| 33 | -        remove_filter('wp_nav_menu_items', 'geodir_location_menu_items', 110); | |
| 34 | -        add_filter('wp_nav_menu_items', 'geodir_location_menu_items', 8, 2); | |
| 35 | - } | |
| 36 | - // GEODIR MENU ACTIONS - set the GeoDir menu items before the Enfold search | |
| 37 | -    remove_filter('wp_nav_menu_items', 'geodir_menu_items', 100); | |
| 38 | -    add_filter('wp_nav_menu_items', 'geodir_menu_items', 7, 2); | |
| 31 | + // LOCATION MANAGER MENU ACTIONS - set the location menu item before the Enfold search | |
| 32 | +	if (function_exists('geodir_location_menu_items')) { | |
| 33 | +		remove_filter('wp_nav_menu_items', 'geodir_location_menu_items', 110); | |
| 34 | +		add_filter('wp_nav_menu_items', 'geodir_location_menu_items', 8, 2); | |
| 35 | + } | |
| 36 | + // GEODIR MENU ACTIONS - set the GeoDir menu items before the Enfold search | |
| 37 | +	remove_filter('wp_nav_menu_items', 'geodir_menu_items', 100); | |
| 38 | +	add_filter('wp_nav_menu_items', 'geodir_menu_items', 7, 2); | |
| 39 | 39 | |
| 40 | - // HOME TOP SIDEBAR | |
| 41 | -    remove_action('geodir_home_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10); | |
| 42 | -    remove_action('geodir_location_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10); | |
| 43 | - //add_action( 'ava_after_main_container', 'enfold_home_sidebar' ); | |
| 40 | + // HOME TOP SIDEBAR | |
| 41 | +	remove_action('geodir_home_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10); | |
| 42 | +	remove_action('geodir_location_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10); | |
| 43 | + //add_action( 'ava_after_main_container', 'enfold_home_sidebar' ); | |
| 44 | 44 | |
| 45 | 45 | |
| 46 | - // WRAPPER OPEN ACTIONS | |
| 47 | -    remove_action('geodir_wrapper_open', 'geodir_action_wrapper_open', 10); | |
| 48 | -    add_action('geodir_wrapper_open', 'enfold_action_wrapper_open', 9); | |
| 49 | -    add_action('geodir_wrapper_open', 'enfold_detail_title', 8, 2); // ADD GEODIR TITLE | |
| 46 | + // WRAPPER OPEN ACTIONS | |
| 47 | +	remove_action('geodir_wrapper_open', 'geodir_action_wrapper_open', 10); | |
| 48 | +	add_action('geodir_wrapper_open', 'enfold_action_wrapper_open', 9); | |
| 49 | +	add_action('geodir_wrapper_open', 'enfold_detail_title', 8, 2); // ADD GEODIR TITLE | |
| 50 | 50 | |
| 51 | 51 | |
| 52 | - // WRAPPER CONTENT OPEN ACTIONS | |
| 53 | -    remove_action('geodir_wrapper_content_open', 'geodir_action_wrapper_content_open', 10); | |
| 54 | -    add_action('geodir_wrapper_content_open', 'enfold_action_wrapper_content_open', 9, 3); | |
| 52 | + // WRAPPER CONTENT OPEN ACTIONS | |
| 53 | +	remove_action('geodir_wrapper_content_open', 'geodir_action_wrapper_content_open', 10); | |
| 54 | +	add_action('geodir_wrapper_content_open', 'enfold_action_wrapper_content_open', 9, 3); | |
| 55 | 55 | |
| 56 | 56 | |
| 57 | - // SIDEBAR RIGHT OPEN ACTIONS | |
| 58 | -    remove_action('geodir_sidebar_right_open', 'geodir_action_sidebar_right_open', 10); | |
| 59 | -    add_action('geodir_sidebar_right_open', 'enfold_action_sidebar_right_open', 10, 4); | |
| 57 | + // SIDEBAR RIGHT OPEN ACTIONS | |
| 58 | +	remove_action('geodir_sidebar_right_open', 'geodir_action_sidebar_right_open', 10); | |
| 59 | +	add_action('geodir_sidebar_right_open', 'enfold_action_sidebar_right_open', 10, 4); | |
| 60 | 60 | |
| 61 | - // SIDEBAR LEFT OPEN ACTIONS | |
| 62 | -    remove_action('geodir_sidebar_left_open', 'geodir_action_sidebar_left_open', 10); | |
| 63 | -    add_action('geodir_sidebar_left_open', 'enfold_action_sidebar_left_open', 10, 4); | |
| 61 | + // SIDEBAR LEFT OPEN ACTIONS | |
| 62 | +	remove_action('geodir_sidebar_left_open', 'geodir_action_sidebar_left_open', 10); | |
| 63 | +	add_action('geodir_sidebar_left_open', 'enfold_action_sidebar_left_open', 10, 4); | |
| 64 | 64 | |
| 65 | 65 | |
| 66 | - // HOME PAGE BREADCRUMBS | |
| 67 | -    remove_action('geodir_home_before_main_content', 'geodir_breadcrumb', 20); | |
| 68 | -    remove_action('geodir_location_before_main_content', 'geodir_breadcrumb', 20); | |
| 66 | + // HOME PAGE BREADCRUMBS | |
| 67 | +	remove_action('geodir_home_before_main_content', 'geodir_breadcrumb', 20); | |
| 68 | +	remove_action('geodir_location_before_main_content', 'geodir_breadcrumb', 20); | |
| 69 | 69 | |
| 70 | - // LISTINGS PAGE BREADCRUMBS & TITLES | |
| 71 | -    remove_action('geodir_listings_before_main_content', 'geodir_breadcrumb', 20); | |
| 72 | -    remove_action('geodir_listings_page_title', 'geodir_action_listings_title', 10); | |
| 70 | + // LISTINGS PAGE BREADCRUMBS & TITLES | |
| 71 | +	remove_action('geodir_listings_before_main_content', 'geodir_breadcrumb', 20); | |
| 72 | +	remove_action('geodir_listings_page_title', 'geodir_action_listings_title', 10); | |
| 73 | 73 | |
| 74 | - // DETAILS PAGE BREADCRUMBS & TITLES | |
| 75 | -    remove_action('geodir_detail_before_main_content', 'geodir_breadcrumb', 20); | |
| 76 | -    remove_action('geodir_details_main_content', 'geodir_action_page_title', 20); | |
| 74 | + // DETAILS PAGE BREADCRUMBS & TITLES | |
| 75 | +	remove_action('geodir_detail_before_main_content', 'geodir_breadcrumb', 20); | |
| 76 | +	remove_action('geodir_details_main_content', 'geodir_action_page_title', 20); | |
| 77 | 77 | |
| 78 | - // SEARCH PAGE BREADCRUMBS & TITLES | |
| 79 | -    remove_action('geodir_search_before_main_content', 'geodir_breadcrumb', 20); | |
| 80 | -    remove_action('geodir_search_page_title', 'geodir_action_search_page_title', 10); | |
| 78 | + // SEARCH PAGE BREADCRUMBS & TITLES | |
| 79 | +	remove_action('geodir_search_before_main_content', 'geodir_breadcrumb', 20); | |
| 80 | +	remove_action('geodir_search_page_title', 'geodir_action_search_page_title', 10); | |
| 81 | 81 | |
| 82 | - // AUTHOR PAGE BREADCRUMBS & TITLES | |
| 83 | -    remove_action('geodir_author_before_main_content', 'geodir_breadcrumb', 20); | |
| 84 | -    remove_action('geodir_author_page_title', 'geodir_action_author_page_title', 10); | |
| 82 | + // AUTHOR PAGE BREADCRUMBS & TITLES | |
| 83 | +	remove_action('geodir_author_before_main_content', 'geodir_breadcrumb', 20); | |
| 84 | +	remove_action('geodir_author_page_title', 'geodir_action_author_page_title', 10); | |
| 85 | 85 | |
| 86 | - // DISABLE ENFOLD MAPS CALL | |
| 87 | -    add_filter('avf_load_google_map_api', 'gd_enfold_remove_maps_api', 10, 1); | |
| 86 | + // DISABLE ENFOLD MAPS CALL | |
| 87 | +	add_filter('avf_load_google_map_api', 'gd_enfold_remove_maps_api', 10, 1); | |
| 88 | 88 | |
| 89 | - // make top section wide | |
| 90 | -    remove_action('geodir_home_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10); | |
| 91 | -    remove_action('geodir_location_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10); | |
| 92 | -    remove_action('geodir_author_before_main_content', 'geodir_action_geodir_sidebar_author_top', 10); | |
| 93 | -    remove_action('geodir_search_before_main_content', 'geodir_action_geodir_sidebar_search_top', 10); | |
| 94 | -    remove_action('geodir_detail_before_main_content', 'geodir_action_geodir_sidebar_detail_top', 10); | |
| 95 | -    remove_action('geodir_listings_before_main_content', 'geodir_action_geodir_sidebar_listings_top', 10); | |
| 89 | + // make top section wide | |
| 90 | +	remove_action('geodir_home_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10); | |
| 91 | +	remove_action('geodir_location_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10); | |
| 92 | +	remove_action('geodir_author_before_main_content', 'geodir_action_geodir_sidebar_author_top', 10); | |
| 93 | +	remove_action('geodir_search_before_main_content', 'geodir_action_geodir_sidebar_search_top', 10); | |
| 94 | +	remove_action('geodir_detail_before_main_content', 'geodir_action_geodir_sidebar_detail_top', 10); | |
| 95 | +	remove_action('geodir_listings_before_main_content', 'geodir_action_geodir_sidebar_listings_top', 10); | |
| 96 | 96 | |
| 97 | -    add_action('geodir_wrapper_open', 'gd_enfold_compat_add_top_section_back', 5); | |
| 97 | +	add_action('geodir_wrapper_open', 'gd_enfold_compat_add_top_section_back', 5); | |
| 98 | 98 | |
| 99 | 99 | } // Close enfold_action_calls | 
| 100 | 100 | |
| @@ -108,17 +108,17 @@ discard block | ||
| 108 | 108 | function gd_enfold_compat_add_top_section_back() | 
| 109 | 109 |  { | 
| 110 | 110 | |
| 111 | -    if (is_page_geodir_home() || geodir_is_page('location')) { | |
| 112 | -        add_action('geodir_wrapper_open', 'geodir_action_geodir_sidebar_home_top', 8); | |
| 113 | -    } elseif (geodir_is_page('listing')) { | |
| 114 | -        add_action('geodir_wrapper_open', 'geodir_action_geodir_sidebar_listings_top', 8); | |
| 115 | -    } elseif (geodir_is_page('detail')) { | |
| 116 | -        add_action('geodir_wrapper_open', 'geodir_action_geodir_sidebar_detail_top', 8); | |
| 117 | -    } elseif (geodir_is_page('search')) { | |
| 118 | -        add_action('geodir_wrapper_open', 'geodir_action_geodir_sidebar_search_top', 8); | |
| 119 | -    } elseif (geodir_is_page('author')) { | |
| 120 | -        add_action('geodir_wrapper_open', 'geodir_action_geodir_sidebar_author_top', 8); | |
| 121 | - } | |
| 111 | +	if (is_page_geodir_home() || geodir_is_page('location')) { | |
| 112 | +		add_action('geodir_wrapper_open', 'geodir_action_geodir_sidebar_home_top', 8); | |
| 113 | +	} elseif (geodir_is_page('listing')) { | |
| 114 | +		add_action('geodir_wrapper_open', 'geodir_action_geodir_sidebar_listings_top', 8); | |
| 115 | +	} elseif (geodir_is_page('detail')) { | |
| 116 | +		add_action('geodir_wrapper_open', 'geodir_action_geodir_sidebar_detail_top', 8); | |
| 117 | +	} elseif (geodir_is_page('search')) { | |
| 118 | +		add_action('geodir_wrapper_open', 'geodir_action_geodir_sidebar_search_top', 8); | |
| 119 | +	} elseif (geodir_is_page('author')) { | |
| 120 | +		add_action('geodir_wrapper_open', 'geodir_action_geodir_sidebar_author_top', 8); | |
| 121 | + } | |
| 122 | 122 | |
| 123 | 123 | |
| 124 | 124 | } | 
| @@ -137,8 +137,8 @@ discard block | ||
| 137 | 137 | */ | 
| 138 | 138 | function wpgeo_enfold_body_class($classes) | 
| 139 | 139 |  { | 
| 140 | - $classes[] = 'wpgeo-enfold'; | |
| 141 | - return $classes; | |
| 140 | + $classes[] = 'wpgeo-enfold'; | |
| 141 | + return $classes; | |
| 142 | 142 | } | 
| 143 | 143 | |
| 144 | 144 | /** | 
| @@ -149,8 +149,8 @@ discard block | ||
| 149 | 149 | */ | 
| 150 | 150 | function geodir_allow_payment_urls_enfold() | 
| 151 | 151 |  { | 
| 152 | - global $builder; | |
| 153 | -    remove_action('template_redirect', array($builder, 'template_redirect'), 1000); | |
| 152 | + global $builder; | |
| 153 | +	remove_action('template_redirect', array($builder, 'template_redirect'), 1000); | |
| 154 | 154 | } | 
| 155 | 155 | |
| 156 | 156 | |
| @@ -162,8 +162,8 @@ discard block | ||
| 162 | 162 | */ | 
| 163 | 163 | function enfold_action_wrapper_open() | 
| 164 | 164 |  { | 
| 165 | -    echo "<div class='container_wrap container_wrap_first main_color " . avia_layout_class('main', false) . "'>"; | |
| 166 | - echo "<div class='container template-blog '>"; | |
| 165 | +	echo "<div class='container_wrap container_wrap_first main_color " . avia_layout_class('main', false) . "'>"; | |
| 166 | + echo "<div class='container template-blog '>"; | |
| 167 | 167 | } | 
| 168 | 168 | |
| 169 | 169 | /** | 
| @@ -177,38 +177,38 @@ discard block | ||
| 177 | 177 | */ | 
| 178 | 178 | function enfold_detail_title($page, $class) | 
| 179 | 179 |  { | 
| 180 | - //echo '###'.$page; | |
| 181 | - global $wp; | |
| 182 | -    if (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id() && !geodir_is_page('login')) { | |
| 183 | -        add_action('avia_breadcrumbs_trail', 'enfold_detail_breadcrum', 8, 2); | |
| 184 | - echo avia_title(); | |
| 185 | -    } elseif ($page == 'details-page') { | |
| 186 | -        add_action('avia_breadcrumbs_trail', 'enfold_detail_breadcrum', 8, 2); | |
| 187 | - echo avia_title(); | |
| 188 | -    } elseif ($page == 'listings-page' || $page == 'search-page') { | |
| 189 | -        add_action('avia_breadcrumbs_trail', 'enfold_detail_breadcrum', 8, 2); | |
| 190 | - ob_start(); // Start buffering; | |
| 191 | - geodir_action_listings_title(); | |
| 192 | - $gd_title = ob_get_clean(); | |
| 193 | -        $title_p = explode('">', $gd_title); | |
| 194 | -        $title = str_replace('</h1></header>', "", $title_p[2]); | |
| 195 | - //print_r($title_p); | |
| 196 | -        echo avia_title(array('title' => $title)); | |
| 197 | -    } elseif ($page == 'author-page') { | |
| 198 | -        add_action('avia_breadcrumbs_trail', 'enfold_detail_breadcrum', 8, 2); | |
| 199 | - ob_start(); // Start buffering; | |
| 200 | - geodir_action_author_page_title(); | |
| 201 | - $gd_title = ob_get_clean(); | |
| 202 | -        $gd_title = str_replace('<h1>', "", $gd_title); | |
| 203 | -        $gd_title = str_replace('</h1>', "", $gd_title); | |
| 204 | -        echo avia_title(array('title' => $gd_title)); | |
| 205 | -    } elseif ($page == 'add-listing-page') { | |
| 206 | -        add_action('avia_breadcrumbs_trail', 'enfold_detail_breadcrum', 8, 2); | |
| 207 | - echo avia_title(); | |
| 208 | -    } elseif ($page == 'add-listing-page') { | |
| 209 | -        add_action('avia_breadcrumbs_trail', 'enfold_detail_breadcrum', 8, 2); | |
| 210 | - echo avia_title(); | |
| 211 | - } | |
| 180 | + //echo '###'.$page; | |
| 181 | + global $wp; | |
| 182 | +	if (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id() && !geodir_is_page('login')) { | |
| 183 | +		add_action('avia_breadcrumbs_trail', 'enfold_detail_breadcrum', 8, 2); | |
| 184 | + echo avia_title(); | |
| 185 | +	} elseif ($page == 'details-page') { | |
| 186 | +		add_action('avia_breadcrumbs_trail', 'enfold_detail_breadcrum', 8, 2); | |
| 187 | + echo avia_title(); | |
| 188 | +	} elseif ($page == 'listings-page' || $page == 'search-page') { | |
| 189 | +		add_action('avia_breadcrumbs_trail', 'enfold_detail_breadcrum', 8, 2); | |
| 190 | + ob_start(); // Start buffering; | |
| 191 | + geodir_action_listings_title(); | |
| 192 | + $gd_title = ob_get_clean(); | |
| 193 | +		$title_p = explode('">', $gd_title); | |
| 194 | +		$title = str_replace('</h1></header>', "", $title_p[2]); | |
| 195 | + //print_r($title_p); | |
| 196 | +		echo avia_title(array('title' => $title)); | |
| 197 | +	} elseif ($page == 'author-page') { | |
| 198 | +		add_action('avia_breadcrumbs_trail', 'enfold_detail_breadcrum', 8, 2); | |
| 199 | + ob_start(); // Start buffering; | |
| 200 | + geodir_action_author_page_title(); | |
| 201 | + $gd_title = ob_get_clean(); | |
| 202 | +		$gd_title = str_replace('<h1>', "", $gd_title); | |
| 203 | +		$gd_title = str_replace('</h1>', "", $gd_title); | |
| 204 | +		echo avia_title(array('title' => $gd_title)); | |
| 205 | +	} elseif ($page == 'add-listing-page') { | |
| 206 | +		add_action('avia_breadcrumbs_trail', 'enfold_detail_breadcrum', 8, 2); | |
| 207 | + echo avia_title(); | |
| 208 | +	} elseif ($page == 'add-listing-page') { | |
| 209 | +		add_action('avia_breadcrumbs_trail', 'enfold_detail_breadcrum', 8, 2); | |
| 210 | + echo avia_title(); | |
| 211 | + } | |
| 212 | 212 | |
| 213 | 213 | } | 
| 214 | 214 | |
| @@ -223,22 +223,22 @@ discard block | ||
| 223 | 223 | */ | 
| 224 | 224 | function enfold_detail_breadcrum($trail, $args) | 
| 225 | 225 |  { | 
| 226 | - ob_start(); // Start buffering; | |
| 227 | - geodir_breadcrumb(); | |
| 228 | - $gd_crums = ob_get_clean(); | |
| 229 | -    if ($gd_crums) { | |
| 230 | -        $gd_crums = str_replace('<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs"><li>', "", $gd_crums); | |
| 231 | -        $gd_crums = str_replace('</li></ul></div>', "", $gd_crums); | |
| 232 | -        $gd_crums = str_replace(' > ', " > ", $gd_crums); | |
| 233 | -        $gd_crums = str_replace('</li><li>', "", $gd_crums); | |
| 234 | -        $gd_crums = explode(" > ", $gd_crums); | |
| 235 | - $trail_end = array_pop($gd_crums); | |
| 236 | - $gd_crums['trail_end'] = $trail_end; | |
| 237 | - //print_r($gd_crums); | |
| 238 | - //print_r($trail); | |
| 239 | - $trail = $gd_crums; | |
| 240 | - } | |
| 241 | - return $trail; | |
| 226 | + ob_start(); // Start buffering; | |
| 227 | + geodir_breadcrumb(); | |
| 228 | + $gd_crums = ob_get_clean(); | |
| 229 | +	if ($gd_crums) { | |
| 230 | +		$gd_crums = str_replace('<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs"><li>', "", $gd_crums); | |
| 231 | +		$gd_crums = str_replace('</li></ul></div>', "", $gd_crums); | |
| 232 | +		$gd_crums = str_replace(' > ', " > ", $gd_crums); | |
| 233 | +		$gd_crums = str_replace('</li><li>', "", $gd_crums); | |
| 234 | +		$gd_crums = explode(" > ", $gd_crums); | |
| 235 | + $trail_end = array_pop($gd_crums); | |
| 236 | + $gd_crums['trail_end'] = $trail_end; | |
| 237 | + //print_r($gd_crums); | |
| 238 | + //print_r($trail); | |
| 239 | + $trail = $gd_crums; | |
| 240 | + } | |
| 241 | + return $trail; | |
| 242 | 242 | } | 
| 243 | 243 | |
| 244 | 244 | |
| @@ -253,12 +253,12 @@ discard block | ||
| 253 | 253 | */ | 
| 254 | 254 | function enfold_action_wrapper_content_open($type = '', $id = '', $class = '') | 
| 255 | 255 |  { | 
| 256 | -    if (geodir_is_page('login')) { | |
| 257 | -        echo "<main class='template-page content twelve alpha units " . $class . "' " . avia_markup_helper(array('context' => 'content', 'post_type' => 'page', 'echo' => false)) . ">"; | |
| 258 | -    } else { | |
| 259 | -        echo "<main class='template-page content " . avia_layout_class('content', false) . " units " . $class . "' " . avia_markup_helper(array('context' => 'content', 'post_type' => 'page', 'echo' => false)) . ">"; | |
| 260 | - } | |
| 261 | - echo '<div class="entry-content-wrapper">'; | |
| 256 | +	if (geodir_is_page('login')) { | |
| 257 | +		echo "<main class='template-page content twelve alpha units " . $class . "' " . avia_markup_helper(array('context' => 'content', 'post_type' => 'page', 'echo' => false)) . ">"; | |
| 258 | +	} else { | |
| 259 | +		echo "<main class='template-page content " . avia_layout_class('content', false) . " units " . $class . "' " . avia_markup_helper(array('context' => 'content', 'post_type' => 'page', 'echo' => false)) . ">"; | |
| 260 | + } | |
| 261 | + echo '<div class="entry-content-wrapper">'; | |
| 262 | 262 | } | 
| 263 | 263 | |
| 264 | 264 | |
| @@ -274,9 +274,9 @@ discard block | ||
| 274 | 274 | */ | 
| 275 | 275 | function enfold_action_sidebar_right_open($type = '', $id = '', $class = '', $itemtype = '') | 
| 276 | 276 |  { | 
| 277 | -    $sidebar_smartphone = avia_get_option('smartphones_sidebar') == 'smartphones_sidebar' ? 'smartphones_sidebar_active' : ""; | |
| 278 | -    echo "<aside class='sidebar sidebar_right " . $sidebar_smartphone . " " . avia_layout_class('sidebar', false) . " units' " . avia_markup_helper(array('context' => 'sidebar', 'echo' => false)) . ">"; | |
| 279 | - echo "<div class='inner_sidebar extralight-border'>"; | |
| 277 | +	$sidebar_smartphone = avia_get_option('smartphones_sidebar') == 'smartphones_sidebar' ? 'smartphones_sidebar_active' : ""; | |
| 278 | +	echo "<aside class='sidebar sidebar_right " . $sidebar_smartphone . " " . avia_layout_class('sidebar', false) . " units' " . avia_markup_helper(array('context' => 'sidebar', 'echo' => false)) . ">"; | |
| 279 | + echo "<div class='inner_sidebar extralight-border'>"; | |
| 280 | 280 | } | 
| 281 | 281 | |
| 282 | 282 | /** | 
| @@ -291,9 +291,9 @@ discard block | ||
| 291 | 291 | */ | 
| 292 | 292 | function enfold_action_sidebar_left_open($type = '', $id = '', $class = '', $itemtype = '') | 
| 293 | 293 |  { | 
| 294 | -    $sidebar_smartphone = avia_get_option('smartphones_sidebar') == 'smartphones_sidebar' ? 'smartphones_sidebar_active' : ""; | |
| 295 | -    echo "<aside class='sidebar sidebar_left " . $sidebar_smartphone . " " . avia_layout_class('sidebar', false) . " units' " . avia_markup_helper(array('context' => 'sidebar', 'echo' => false)) . ">"; | |
| 296 | - echo "<div class='inner_sidebar extralight-border'>"; | |
| 294 | +	$sidebar_smartphone = avia_get_option('smartphones_sidebar') == 'smartphones_sidebar' ? 'smartphones_sidebar_active' : ""; | |
| 295 | +	echo "<aside class='sidebar sidebar_left " . $sidebar_smartphone . " " . avia_layout_class('sidebar', false) . " units' " . avia_markup_helper(array('context' => 'sidebar', 'echo' => false)) . ">"; | |
| 296 | + echo "<div class='inner_sidebar extralight-border'>"; | |
| 297 | 297 | } | 
| 298 | 298 | |
| 299 | 299 | |
| @@ -307,7 +307,7 @@ discard block | ||
| 307 | 307 | */ | 
| 308 | 308 | function gd_enfold_remove_maps_api($call) | 
| 309 | 309 |  { | 
| 310 | - return false; | |
| 310 | + return false; | |
| 311 | 311 | } | 
| 312 | 312 | |
| 313 | 313 | |
| @@ -162,7 +162,7 @@ discard block | ||
| 162 | 162 | */ | 
| 163 | 163 | function enfold_action_wrapper_open() | 
| 164 | 164 |  { | 
| 165 | -    echo "<div class='container_wrap container_wrap_first main_color " . avia_layout_class('main', false) . "'>"; | |
| 165 | +    echo "<div class='container_wrap container_wrap_first main_color ".avia_layout_class('main', false)."'>"; | |
| 166 | 166 | echo "<div class='container template-blog '>"; | 
| 167 | 167 | } | 
| 168 | 168 | |
| @@ -254,9 +254,9 @@ discard block | ||
| 254 | 254 | function enfold_action_wrapper_content_open($type = '', $id = '', $class = '') | 
| 255 | 255 |  { | 
| 256 | 256 |      if (geodir_is_page('login')) { | 
| 257 | -        echo "<main class='template-page content twelve alpha units " . $class . "' " . avia_markup_helper(array('context' => 'content', 'post_type' => 'page', 'echo' => false)) . ">"; | |
| 257 | +        echo "<main class='template-page content twelve alpha units ".$class."' ".avia_markup_helper(array('context' => 'content', 'post_type' => 'page', 'echo' => false)).">"; | |
| 258 | 258 |      } else { | 
| 259 | -        echo "<main class='template-page content " . avia_layout_class('content', false) . " units " . $class . "' " . avia_markup_helper(array('context' => 'content', 'post_type' => 'page', 'echo' => false)) . ">"; | |
| 259 | +        echo "<main class='template-page content ".avia_layout_class('content', false)." units ".$class."' ".avia_markup_helper(array('context' => 'content', 'post_type' => 'page', 'echo' => false)).">"; | |
| 260 | 260 | } | 
| 261 | 261 | echo '<div class="entry-content-wrapper">'; | 
| 262 | 262 | } | 
| @@ -275,7 +275,7 @@ discard block | ||
| 275 | 275 | function enfold_action_sidebar_right_open($type = '', $id = '', $class = '', $itemtype = '') | 
| 276 | 276 |  { | 
| 277 | 277 |      $sidebar_smartphone = avia_get_option('smartphones_sidebar') == 'smartphones_sidebar' ? 'smartphones_sidebar_active' : ""; | 
| 278 | -    echo "<aside class='sidebar sidebar_right " . $sidebar_smartphone . " " . avia_layout_class('sidebar', false) . " units' " . avia_markup_helper(array('context' => 'sidebar', 'echo' => false)) . ">"; | |
| 278 | +    echo "<aside class='sidebar sidebar_right ".$sidebar_smartphone." ".avia_layout_class('sidebar', false)." units' ".avia_markup_helper(array('context' => 'sidebar', 'echo' => false)).">"; | |
| 279 | 279 | echo "<div class='inner_sidebar extralight-border'>"; | 
| 280 | 280 | } | 
| 281 | 281 | |
| @@ -292,7 +292,7 @@ discard block | ||
| 292 | 292 | function enfold_action_sidebar_left_open($type = '', $id = '', $class = '', $itemtype = '') | 
| 293 | 293 |  { | 
| 294 | 294 |      $sidebar_smartphone = avia_get_option('smartphones_sidebar') == 'smartphones_sidebar' ? 'smartphones_sidebar_active' : ""; | 
| 295 | -    echo "<aside class='sidebar sidebar_left " . $sidebar_smartphone . " " . avia_layout_class('sidebar', false) . " units' " . avia_markup_helper(array('context' => 'sidebar', 'echo' => false)) . ">"; | |
| 295 | +    echo "<aside class='sidebar sidebar_left ".$sidebar_smartphone." ".avia_layout_class('sidebar', false)." units' ".avia_markup_helper(array('context' => 'sidebar', 'echo' => false)).">"; | |
| 296 | 296 | echo "<div class='inner_sidebar extralight-border'>"; | 
| 297 | 297 | } | 
| 298 | 298 | |
| @@ -113,7 +113,7 @@ | ||
| 113 | 113 | * @since 1.0.0 | 
| 114 | 114 | * @package GeoDirectory | 
| 115 | 115 | * @param array $classes Class array. | 
| 116 | - * @return array Modified class array. | |
| 116 | + * @return string[] Modified class array. | |
| 117 | 117 | */ | 
| 118 | 118 | function geodir_x_body_class($classes) | 
| 119 | 119 |  { | 
| @@ -19,60 +19,60 @@ discard block | ||
| 19 | 19 | function geodir_x_action_calls() | 
| 20 | 20 |  { | 
| 21 | 21 | |
| 22 | - /* ACTIONS | |
| 22 | + /* ACTIONS | |
| 23 | 23 | ****************************************************************************************/ | 
| 24 | 24 | |
| 25 | - // Add body class for styling purposes | |
| 26 | -    add_filter('body_class', 'geodir_x_body_class'); | |
| 25 | + // Add body class for styling purposes | |
| 26 | +	add_filter('body_class', 'geodir_x_body_class'); | |
| 27 | 27 | |
| 28 | - // HOME TOP SIDEBAR | |
| 29 | - //remove_action( 'geodir_location_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10 ); | |
| 30 | - //remove_action( 'geodir_home_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10 ); | |
| 31 | - //add_action( 'geodir_wrapper_open', 'geodir_x_home_sidebar', 5 ); | |
| 32 | -    add_action('geodir_before_search_form', 'geodir_x_search_container_open'); | |
| 33 | -    add_action('geodir_after_search_form', 'geodir_x_search_container_close'); | |
| 28 | + // HOME TOP SIDEBAR | |
| 29 | + //remove_action( 'geodir_location_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10 ); | |
| 30 | + //remove_action( 'geodir_home_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10 ); | |
| 31 | + //add_action( 'geodir_wrapper_open', 'geodir_x_home_sidebar', 5 ); | |
| 32 | +	add_action('geodir_before_search_form', 'geodir_x_search_container_open'); | |
| 33 | +	add_action('geodir_after_search_form', 'geodir_x_search_container_close'); | |
| 34 | 34 | |
| 35 | - // WRAPPER OPEN ACTIONS | |
| 36 | -    remove_action('geodir_wrapper_open', 'geodir_action_wrapper_open', 10); | |
| 37 | -    add_action('geodir_wrapper_open', 'geodir_x_action_wrapper_open', 9); | |
| 35 | + // WRAPPER OPEN ACTIONS | |
| 36 | +	remove_action('geodir_wrapper_open', 'geodir_action_wrapper_open', 10); | |
| 37 | +	add_action('geodir_wrapper_open', 'geodir_x_action_wrapper_open', 9); | |
| 38 | 38 | |
| 39 | - // WRAPPER CLOSE ACTIONS | |
| 40 | -    remove_action('geodir_wrapper_close', 'geodir_action_wrapper_close', 10); | |
| 41 | -    add_action('geodir_wrapper_close', 'geodir_x_action_wrapper_close', 11); | |
| 39 | + // WRAPPER CLOSE ACTIONS | |
| 40 | +	remove_action('geodir_wrapper_close', 'geodir_action_wrapper_close', 10); | |
| 41 | +	add_action('geodir_wrapper_close', 'geodir_x_action_wrapper_close', 11); | |
| 42 | 42 | |
| 43 | - // WRAPPER CONTENT OPEN ACTIONS | |
| 44 | -    remove_action('geodir_wrapper_content_open', 'geodir_action_wrapper_content_open', 10); | |
| 45 | -    add_action('geodir_wrapper_content_open', 'geodir_x_action_wrapper_content_open', 9, 3); | |
| 43 | + // WRAPPER CONTENT OPEN ACTIONS | |
| 44 | +	remove_action('geodir_wrapper_content_open', 'geodir_action_wrapper_content_open', 10); | |
| 45 | +	add_action('geodir_wrapper_content_open', 'geodir_x_action_wrapper_content_open', 9, 3); | |
| 46 | 46 | |
| 47 | - // WRAPPER CONTENT CLOSE ACTIONS | |
| 48 | -    remove_action('geodir_wrapper_content_close', 'geodir_action_wrapper_content_close', 10); | |
| 49 | -    add_action('geodir_wrapper_content_close', 'geodir_x_action_wrapper_content_close', 11); | |
| 47 | + // WRAPPER CONTENT CLOSE ACTIONS | |
| 48 | +	remove_action('geodir_wrapper_content_close', 'geodir_action_wrapper_content_close', 10); | |
| 49 | +	add_action('geodir_wrapper_content_close', 'geodir_x_action_wrapper_content_close', 11); | |
| 50 | 50 | |
| 51 | - // SIDEBAR RIGHT OPEN ACTIONS | |
| 52 | -    remove_action('geodir_sidebar_right_open', 'geodir_action_sidebar_right_open', 10); | |
| 53 | -    add_action('geodir_sidebar_right_open', 'geodir_x_action_sidebar_right_open', 10, 4); | |
| 51 | + // SIDEBAR RIGHT OPEN ACTIONS | |
| 52 | +	remove_action('geodir_sidebar_right_open', 'geodir_action_sidebar_right_open', 10); | |
| 53 | +	add_action('geodir_sidebar_right_open', 'geodir_x_action_sidebar_right_open', 10, 4); | |
| 54 | 54 | |
| 55 | - // SIDEBAR RIGHT CLOSE ACTIONS | |
| 56 | -    remove_action('geodir_sidebar_right_close', 'geodir_action_sidebar_right_close', 10); | |
| 57 | -    add_action('geodir_sidebar_right_close', 'geodir_x_action_sidebar_right_close', 10, 1); | |
| 55 | + // SIDEBAR RIGHT CLOSE ACTIONS | |
| 56 | +	remove_action('geodir_sidebar_right_close', 'geodir_action_sidebar_right_close', 10); | |
| 57 | +	add_action('geodir_sidebar_right_close', 'geodir_x_action_sidebar_right_close', 10, 1); | |
| 58 | 58 | |
| 59 | - // REMOVE BREADCRUMBS | |
| 60 | -    remove_action('geodir_listings_before_main_content', 'geodir_breadcrumb', 20); | |
| 61 | -    remove_action('geodir_detail_before_main_content', 'geodir_breadcrumb', 20); | |
| 62 | -    remove_action('geodir_search_before_main_content', 'geodir_breadcrumb', 20); | |
| 63 | -    remove_action('geodir_author_before_main_content', 'geodir_breadcrumb', 20); | |
| 64 | -    remove_action('geodir_home_before_main_content', 'geodir_breadcrumb', 20); | |
| 65 | -    remove_action('geodir_location_before_main_content', 'geodir_breadcrumb', 20); | |
| 59 | + // REMOVE BREADCRUMBS | |
| 60 | +	remove_action('geodir_listings_before_main_content', 'geodir_breadcrumb', 20); | |
| 61 | +	remove_action('geodir_detail_before_main_content', 'geodir_breadcrumb', 20); | |
| 62 | +	remove_action('geodir_search_before_main_content', 'geodir_breadcrumb', 20); | |
| 63 | +	remove_action('geodir_author_before_main_content', 'geodir_breadcrumb', 20); | |
| 64 | +	remove_action('geodir_home_before_main_content', 'geodir_breadcrumb', 20); | |
| 65 | +	remove_action('geodir_location_before_main_content', 'geodir_breadcrumb', 20); | |
| 66 | 66 | |
| 67 | - // make top section wide | |
| 68 | -    remove_action('geodir_home_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10); | |
| 69 | -    remove_action('geodir_location_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10); | |
| 70 | -    remove_action('geodir_author_before_main_content', 'geodir_action_geodir_sidebar_author_top', 10); | |
| 71 | -    remove_action('geodir_search_before_main_content', 'geodir_action_geodir_sidebar_search_top', 10); | |
| 72 | -    remove_action('geodir_detail_before_main_content', 'geodir_action_geodir_sidebar_detail_top', 10); | |
| 73 | -    remove_action('geodir_listings_before_main_content', 'geodir_action_geodir_sidebar_listings_top', 10); | |
| 67 | + // make top section wide | |
| 68 | +	remove_action('geodir_home_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10); | |
| 69 | +	remove_action('geodir_location_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10); | |
| 70 | +	remove_action('geodir_author_before_main_content', 'geodir_action_geodir_sidebar_author_top', 10); | |
| 71 | +	remove_action('geodir_search_before_main_content', 'geodir_action_geodir_sidebar_search_top', 10); | |
| 72 | +	remove_action('geodir_detail_before_main_content', 'geodir_action_geodir_sidebar_detail_top', 10); | |
| 73 | +	remove_action('geodir_listings_before_main_content', 'geodir_action_geodir_sidebar_listings_top', 10); | |
| 74 | 74 | |
| 75 | -    add_action('geodir_wrapper_open', 'gd_X_compat_add_top_section_back', 5); | |
| 75 | +	add_action('geodir_wrapper_open', 'gd_X_compat_add_top_section_back', 5); | |
| 76 | 76 | |
| 77 | 77 | |
| 78 | 78 | } // Close geodir_x_action_calls | 
| @@ -89,17 +89,17 @@ discard block | ||
| 89 | 89 | function gd_X_compat_add_top_section_back() | 
| 90 | 90 |  { | 
| 91 | 91 | |
| 92 | -    if (is_page_geodir_home() || geodir_is_page('location')) { | |
| 93 | - geodir_action_geodir_sidebar_home_top(); | |
| 94 | -    } elseif (geodir_is_page('listing')) { | |
| 95 | - geodir_action_geodir_sidebar_listings_top(); | |
| 96 | -    } elseif (geodir_is_page('detail')) { | |
| 97 | - geodir_action_geodir_sidebar_detail_top(); | |
| 98 | -    } elseif (geodir_is_page('search')) { | |
| 99 | - geodir_action_geodir_sidebar_search_top(); | |
| 100 | -    } elseif (geodir_is_page('author')) { | |
| 101 | - geodir_action_geodir_sidebar_author_top(); | |
| 102 | - } | |
| 92 | +	if (is_page_geodir_home() || geodir_is_page('location')) { | |
| 93 | + geodir_action_geodir_sidebar_home_top(); | |
| 94 | +	} elseif (geodir_is_page('listing')) { | |
| 95 | + geodir_action_geodir_sidebar_listings_top(); | |
| 96 | +	} elseif (geodir_is_page('detail')) { | |
| 97 | + geodir_action_geodir_sidebar_detail_top(); | |
| 98 | +	} elseif (geodir_is_page('search')) { | |
| 99 | + geodir_action_geodir_sidebar_search_top(); | |
| 100 | +	} elseif (geodir_is_page('author')) { | |
| 101 | + geodir_action_geodir_sidebar_author_top(); | |
| 102 | + } | |
| 103 | 103 | |
| 104 | 104 | |
| 105 | 105 | } | 
| @@ -117,8 +117,8 @@ discard block | ||
| 117 | 117 | */ | 
| 118 | 118 | function geodir_x_body_class($classes) | 
| 119 | 119 |  { | 
| 120 | - $classes[] = 'geodir-x'; | |
| 121 | - return $classes; | |
| 120 | + $classes[] = 'geodir-x'; | |
| 121 | + return $classes; | |
| 122 | 122 | } | 
| 123 | 123 | |
| 124 | 124 | /** | 
| @@ -130,14 +130,14 @@ discard block | ||
| 130 | 130 | */ | 
| 131 | 131 | function geodir_x_home_sidebar() | 
| 132 | 132 |  { | 
| 133 | -    //if ( geodir_is_geodir_page() ) { | |
| 134 | - global $wp; | |
| 135 | -    if ($wp->query_vars['page_id'] == geodir_location_page_id() || is_home() && !geodir_is_page('login')) { | |
| 136 | - echo '<div class="x-main full">'; | |
| 137 | -        dynamic_sidebar('geodir_home_top'); | |
| 138 | - echo '</div>'; | |
| 139 | - } | |
| 140 | - //} | |
| 133 | +	//if ( geodir_is_geodir_page() ) { | |
| 134 | + global $wp; | |
| 135 | +	if ($wp->query_vars['page_id'] == geodir_location_page_id() || is_home() && !geodir_is_page('login')) { | |
| 136 | + echo '<div class="x-main full">'; | |
| 137 | +		dynamic_sidebar('geodir_home_top'); | |
| 138 | + echo '</div>'; | |
| 139 | + } | |
| 140 | + //} | |
| 141 | 141 | } | 
| 142 | 142 | |
| 143 | 143 | /** | 
| @@ -148,7 +148,7 @@ discard block | ||
| 148 | 148 | */ | 
| 149 | 149 | function geodir_x_search_container_open() | 
| 150 | 150 |  { | 
| 151 | - echo '<div class="x-container-fluid x-container max">'; | |
| 151 | + echo '<div class="x-container-fluid x-container max">'; | |
| 152 | 152 | } | 
| 153 | 153 | |
| 154 | 154 | /** | 
| @@ -159,7 +159,7 @@ discard block | ||
| 159 | 159 | */ | 
| 160 | 160 | function geodir_x_search_container_close() | 
| 161 | 161 |  { | 
| 162 | - echo '</div>'; | |
| 162 | + echo '</div>'; | |
| 163 | 163 | } | 
| 164 | 164 | |
| 165 | 165 | /** | 
| @@ -170,16 +170,16 @@ discard block | ||
| 170 | 170 | */ | 
| 171 | 171 | function geodir_x_action_wrapper_open() | 
| 172 | 172 |  { | 
| 173 | - global $stack; | |
| 174 | -    if ($stack == 'integrity') { | |
| 175 | - echo '<div class="x-container-fluid x-container max width offset">'; | |
| 176 | -    } elseif ($stack == 'renew') { | |
| 177 | - echo '<div class="x-container-fluid x-container max width offset cf">'; | |
| 178 | -    } elseif ($stack == 'icon') { | |
| 179 | - echo '<div class="x-main full" role="main">'; | |
| 180 | -    } elseif ($stack == 'ethos') { | |
| 181 | - echo '<div class="x-container-fluid x-container max width main"><div class="offset cf">'; | |
| 182 | - } | |
| 173 | + global $stack; | |
| 174 | +	if ($stack == 'integrity') { | |
| 175 | + echo '<div class="x-container-fluid x-container max width offset">'; | |
| 176 | +	} elseif ($stack == 'renew') { | |
| 177 | + echo '<div class="x-container-fluid x-container max width offset cf">'; | |
| 178 | +	} elseif ($stack == 'icon') { | |
| 179 | + echo '<div class="x-main full" role="main">'; | |
| 180 | +	} elseif ($stack == 'ethos') { | |
| 181 | + echo '<div class="x-container-fluid x-container max width main"><div class="offset cf">'; | |
| 182 | + } | |
| 183 | 183 | } | 
| 184 | 184 | |
| 185 | 185 | /** | 
| @@ -190,12 +190,12 @@ discard block | ||
| 190 | 190 | */ | 
| 191 | 191 | function geodir_x_action_wrapper_close() | 
| 192 | 192 |  { | 
| 193 | - global $stack; | |
| 194 | -    if ($stack == 'ethos') { | |
| 195 | - echo '</div></div>'; | |
| 196 | -    } else { | |
| 197 | - echo '</div>'; | |
| 198 | - } | |
| 193 | + global $stack; | |
| 194 | +	if ($stack == 'ethos') { | |
| 195 | + echo '</div></div>'; | |
| 196 | +	} else { | |
| 197 | + echo '</div>'; | |
| 198 | + } | |
| 199 | 199 | } | 
| 200 | 200 | |
| 201 | 201 | /** | 
| @@ -209,7 +209,7 @@ discard block | ||
| 209 | 209 | */ | 
| 210 | 210 | function geodir_x_action_wrapper_content_open($type = '', $id = '', $class = '') | 
| 211 | 211 |  { | 
| 212 | - echo '<div class="x-main left ' . $class . '" role="main">'; | |
| 212 | + echo '<div class="x-main left ' . $class . '" role="main">'; | |
| 213 | 213 | } | 
| 214 | 214 | |
| 215 | 215 | /** | 
| @@ -220,7 +220,7 @@ discard block | ||
| 220 | 220 | */ | 
| 221 | 221 | function geodir_x_action_wrapper_content_close() | 
| 222 | 222 |  { | 
| 223 | - echo '</div>'; | |
| 223 | + echo '</div>'; | |
| 224 | 224 | } | 
| 225 | 225 | |
| 226 | 226 | /** | 
| @@ -235,7 +235,7 @@ discard block | ||
| 235 | 235 | */ | 
| 236 | 236 | function geodir_x_action_sidebar_right_open($type = '', $id = '', $class = '', $itemtype = '') | 
| 237 | 237 |  { | 
| 238 | - echo '<aside class="x-sidebar right" role="complementary" itemscope itemtype="' . $itemtype . '">'; | |
| 238 | + echo '<aside class="x-sidebar right" role="complementary" itemscope itemtype="' . $itemtype . '">'; | |
| 239 | 239 | } | 
| 240 | 240 | |
| 241 | 241 | /** | 
| @@ -247,7 +247,7 @@ discard block | ||
| 247 | 247 | */ | 
| 248 | 248 | function geodir_x_action_sidebar_right_close($type = '') | 
| 249 | 249 |  { | 
| 250 | - echo '</aside>'; | |
| 250 | + echo '</aside>'; | |
| 251 | 251 | } | 
| 252 | 252 | |
| 253 | 253 |  add_filter('geodir_breadcrumb', 'geodir_x_breadcrumb'); | 
| @@ -261,12 +261,12 @@ discard block | ||
| 261 | 261 | */ | 
| 262 | 262 | function geodir_x_breadcrumb($breadcrumb) | 
| 263 | 263 |  { | 
| 264 | -    $breadcrumb = str_replace('<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">', '', $breadcrumb); | |
| 265 | -    $breadcrumb = str_replace('<li>', '', $breadcrumb); | |
| 266 | -    $breadcrumb = str_replace('</li>', '', $breadcrumb); | |
| 267 | -    $breadcrumb = str_replace('Home', '<span class="home"><i class="x-icon-home"></i></span>', $breadcrumb); | |
| 268 | -    $breadcrumb = str_replace('</ul></div>', '', $breadcrumb); | |
| 269 | - return $breadcrumb; | |
| 264 | +	$breadcrumb = str_replace('<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">', '', $breadcrumb); | |
| 265 | +	$breadcrumb = str_replace('<li>', '', $breadcrumb); | |
| 266 | +	$breadcrumb = str_replace('</li>', '', $breadcrumb); | |
| 267 | +	$breadcrumb = str_replace('Home', '<span class="home"><i class="x-icon-home"></i></span>', $breadcrumb); | |
| 268 | +	$breadcrumb = str_replace('</ul></div>', '', $breadcrumb); | |
| 269 | + return $breadcrumb; | |
| 270 | 270 | } | 
| 271 | 271 | |
| 272 | 272 |  add_filter('geodir_breadcrumb_separator', 'geodir_x_breadcrumb_separator'); | 
| @@ -280,125 +280,125 @@ discard block | ||
| 280 | 280 | */ | 
| 281 | 281 | function geodir_x_breadcrumb_separator($separator) | 
| 282 | 282 |  { | 
| 283 | -    $separator = str_replace(' > ', ' <span class="delimiter"><i class="x-icon-angle-right"></i></span> ', $separator); | |
| 284 | - return $separator; | |
| 283 | +	$separator = str_replace(' > ', ' <span class="delimiter"><i class="x-icon-angle-right"></i></span> ', $separator); | |
| 284 | + return $separator; | |
| 285 | 285 | } | 
| 286 | 286 | |
| 287 | 287 |  if (!function_exists('x_breadcrumbs')) : | 
| 288 | - /** | |
| 289 | - * breadcrumbs. | |
| 290 | - * | |
| 291 | - * @since 1.0.0 | |
| 292 | - * @package GeoDirectory | |
| 293 | - */ | |
| 294 | - function x_breadcrumbs() | |
| 295 | -    { | |
| 296 | - | |
| 297 | -        if (x_get_option('x_breadcrumb_display', '1')) { | |
| 298 | - | |
| 299 | - // | |
| 300 | - // 1. Delimiter between crumbs. | |
| 301 | - // 2. Output text for the "Home" link. | |
| 302 | - // 3. Link to the home page. | |
| 303 | - // 4. Tag before the current crumb. | |
| 304 | - // 5. Tag after the current crumb. | |
| 305 | - // 6. Get page title. | |
| 306 | - // 7. Get blog title. | |
| 307 | - // 8. Get shop title. | |
| 308 | - // | |
| 309 | - | |
| 310 | - GLOBAL $post,$wp; | |
| 311 | - | |
| 312 | -            if (geodir_is_page('detail') || geodir_is_page('listing') || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id())) { | |
| 313 | - geodir_breadcrumb(); | |
| 314 | -            } else { | |
| 315 | - | |
| 316 | - $stack = x_get_stack(); | |
| 317 | - $delimiter = ' <span class="delimiter"><i class="x-icon-angle-right"></i></span> '; // 1 | |
| 318 | - $home_text = '<span class="home"><i class="x-icon-home"></i></span>'; // 2 | |
| 319 | - $home_link = home_url(); // 3 | |
| 320 | - $current_before = '<span class="current">'; // 4 | |
| 321 | - $current_after = '</span>'; // 5 | |
| 322 | - $page_title = get_the_title(); // 6 | |
| 323 | -                $blog_title = get_the_title(get_option('page_for_posts', true));                 // 7 | |
| 324 | -                $shop_title = get_theme_mod('x_' . $stack . '_shop_title');                        // 8 | |
| 325 | - | |
| 326 | -                if (function_exists('woocommerce_get_page_id')) { | |
| 327 | - $shop_url = x_get_shop_link(); | |
| 328 | - $shop_link = '<a href="' . $shop_url . '">' . $shop_title . '</a>'; | |
| 329 | - } | |
| 330 | - | |
| 331 | -                if (is_front_page()) { | |
| 332 | - echo '<div class="x-breadcrumbs">' . $current_before . $home_text . $current_after . '</div>'; | |
| 333 | -                } elseif (is_home()) { | |
| 334 | - echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter . $current_before . $blog_title . $current_after . '</div>'; | |
| 335 | -                } else { | |
| 336 | - echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter; | |
| 337 | -                    if (is_category()) { | |
| 338 | -                        $the_cat = get_category(get_query_var('cat'), false); | |
| 339 | - if ($the_cat->parent != 0) echo get_category_parents($the_cat->parent, TRUE, $delimiter); | |
| 340 | -                        echo $current_before . single_cat_title('', false) . $current_after; | |
| 341 | -                    } elseif (x_is_product_category()) { | |
| 342 | -                        echo $shop_link . $delimiter . $current_before . single_cat_title('', false) . $current_after; | |
| 343 | -                    } elseif (x_is_product_tag()) { | |
| 344 | -                        echo $shop_link . $delimiter . $current_before . single_tag_title('', false) . $current_after; | |
| 345 | -                    } elseif (is_search()) { | |
| 346 | -                        echo $current_before . __('Search Results for ', '__x__') . '“' . get_search_query() . '”' . $current_after; | |
| 347 | -                    } elseif (is_singular('post')) { | |
| 348 | -                        if (get_option('page_for_posts') == is_front_page()) { | |
| 349 | - echo $current_before . $page_title . $current_after; | |
| 350 | -                        } else { | |
| 351 | -                            echo '<a href="' . get_permalink(get_option('page_for_posts')) . '" title="' . esc_attr(__('See All Posts', '__x__')) . '">' . $blog_title . '</a>' . $delimiter . $current_before . $page_title . $current_after; | |
| 352 | - } | |
| 353 | -                    } elseif (x_is_portfolio()) { | |
| 354 | - echo $current_before . get_the_title() . $current_after; | |
| 355 | -                    } elseif (x_is_portfolio_item()) { | |
| 356 | - $link = x_get_parent_portfolio_link(); | |
| 357 | - $title = x_get_parent_portfolio_title(); | |
| 358 | -                        echo '<a href="' . $link . '" title="' . esc_attr(__('See All Posts', '__x__')) . '">' . $title . '</a>' . $delimiter . $current_before . $page_title . $current_after; | |
| 359 | -                    } elseif (x_is_product()) { | |
| 360 | - echo $shop_link . $delimiter . $current_before . $page_title . $current_after; | |
| 361 | -                    } elseif (is_page() && !$post->post_parent) { | |
| 362 | - echo $current_before . $page_title . $current_after; | |
| 363 | -                    } elseif (is_page() && $post->post_parent) { | |
| 364 | - $parent_id = $post->post_parent; | |
| 365 | - $breadcrumbs = array(); | |
| 366 | -                        while ($parent_id) { | |
| 367 | - $page = get_page($parent_id); | |
| 368 | - $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>'; | |
| 369 | - $parent_id = $page->post_parent; | |
| 370 | - } | |
| 371 | - $breadcrumbs = array_reverse($breadcrumbs); | |
| 372 | -                        for ($i = 0; $i < count($breadcrumbs); $i++) { | |
| 373 | - echo $breadcrumbs[$i]; | |
| 374 | - if ($i != count($breadcrumbs) - 1) echo $delimiter; | |
| 375 | - } | |
| 376 | - echo $delimiter . $current_before . $page_title . $current_after; | |
| 377 | -                    } elseif (is_tag()) { | |
| 378 | -                        echo $current_before . single_tag_title('', false) . $current_after; | |
| 379 | -                    } elseif (is_author()) { | |
| 380 | - GLOBAL $author; | |
| 381 | - $userdata = get_userdata($author); | |
| 382 | -                        echo $current_before . __('Posts by ', '__x__') . '“' . $userdata->display_name . $current_after . '”'; | |
| 383 | -                    } elseif (is_404()) { | |
| 384 | -                        echo $current_before . __('404 (Page Not Found)', '__x__') . $current_after; | |
| 385 | -                    } elseif (is_archive()) { | |
| 386 | -                        if (x_is_shop()) { | |
| 387 | - echo $current_before . $shop_title . $current_after; | |
| 388 | -                        } else { | |
| 389 | -                            echo $current_before . __('Archives ', '__x__') . $current_after; | |
| 390 | - } | |
| 391 | - } | |
| 392 | -                    if (get_query_var('paged')) { | |
| 393 | -                        echo ' <span class="current" style="white-space: nowrap;">(' . __('Page', '__x__') . ' ' . get_query_var('paged') . ')</span>'; | |
| 394 | - } | |
| 395 | - echo '</div>'; | |
| 396 | - } | |
| 397 | - | |
| 398 | - } | |
| 399 | - | |
| 400 | - } | |
| 401 | - } // ends my geodir check | |
| 288 | + /** | |
| 289 | + * breadcrumbs. | |
| 290 | + * | |
| 291 | + * @since 1.0.0 | |
| 292 | + * @package GeoDirectory | |
| 293 | + */ | |
| 294 | + function x_breadcrumbs() | |
| 295 | +	{ | |
| 296 | + | |
| 297 | +		if (x_get_option('x_breadcrumb_display', '1')) { | |
| 298 | + | |
| 299 | + // | |
| 300 | + // 1. Delimiter between crumbs. | |
| 301 | + // 2. Output text for the "Home" link. | |
| 302 | + // 3. Link to the home page. | |
| 303 | + // 4. Tag before the current crumb. | |
| 304 | + // 5. Tag after the current crumb. | |
| 305 | + // 6. Get page title. | |
| 306 | + // 7. Get blog title. | |
| 307 | + // 8. Get shop title. | |
| 308 | + // | |
| 309 | + | |
| 310 | + GLOBAL $post,$wp; | |
| 311 | + | |
| 312 | +			if (geodir_is_page('detail') || geodir_is_page('listing') || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id())) { | |
| 313 | + geodir_breadcrumb(); | |
| 314 | +			} else { | |
| 315 | + | |
| 316 | + $stack = x_get_stack(); | |
| 317 | + $delimiter = ' <span class="delimiter"><i class="x-icon-angle-right"></i></span> '; // 1 | |
| 318 | + $home_text = '<span class="home"><i class="x-icon-home"></i></span>'; // 2 | |
| 319 | + $home_link = home_url(); // 3 | |
| 320 | + $current_before = '<span class="current">'; // 4 | |
| 321 | + $current_after = '</span>'; // 5 | |
| 322 | + $page_title = get_the_title(); // 6 | |
| 323 | +				$blog_title = get_the_title(get_option('page_for_posts', true));                 // 7 | |
| 324 | +				$shop_title = get_theme_mod('x_' . $stack . '_shop_title');                        // 8 | |
| 325 | + | |
| 326 | +				if (function_exists('woocommerce_get_page_id')) { | |
| 327 | + $shop_url = x_get_shop_link(); | |
| 328 | + $shop_link = '<a href="' . $shop_url . '">' . $shop_title . '</a>'; | |
| 329 | + } | |
| 330 | + | |
| 331 | +				if (is_front_page()) { | |
| 332 | + echo '<div class="x-breadcrumbs">' . $current_before . $home_text . $current_after . '</div>'; | |
| 333 | +				} elseif (is_home()) { | |
| 334 | + echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter . $current_before . $blog_title . $current_after . '</div>'; | |
| 335 | +				} else { | |
| 336 | + echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter; | |
| 337 | +					if (is_category()) { | |
| 338 | +						$the_cat = get_category(get_query_var('cat'), false); | |
| 339 | + if ($the_cat->parent != 0) echo get_category_parents($the_cat->parent, TRUE, $delimiter); | |
| 340 | +						echo $current_before . single_cat_title('', false) . $current_after; | |
| 341 | +					} elseif (x_is_product_category()) { | |
| 342 | +						echo $shop_link . $delimiter . $current_before . single_cat_title('', false) . $current_after; | |
| 343 | +					} elseif (x_is_product_tag()) { | |
| 344 | +						echo $shop_link . $delimiter . $current_before . single_tag_title('', false) . $current_after; | |
| 345 | +					} elseif (is_search()) { | |
| 346 | +						echo $current_before . __('Search Results for ', '__x__') . '“' . get_search_query() . '”' . $current_after; | |
| 347 | +					} elseif (is_singular('post')) { | |
| 348 | +						if (get_option('page_for_posts') == is_front_page()) { | |
| 349 | + echo $current_before . $page_title . $current_after; | |
| 350 | +						} else { | |
| 351 | +							echo '<a href="' . get_permalink(get_option('page_for_posts')) . '" title="' . esc_attr(__('See All Posts', '__x__')) . '">' . $blog_title . '</a>' . $delimiter . $current_before . $page_title . $current_after; | |
| 352 | + } | |
| 353 | +					} elseif (x_is_portfolio()) { | |
| 354 | + echo $current_before . get_the_title() . $current_after; | |
| 355 | +					} elseif (x_is_portfolio_item()) { | |
| 356 | + $link = x_get_parent_portfolio_link(); | |
| 357 | + $title = x_get_parent_portfolio_title(); | |
| 358 | +						echo '<a href="' . $link . '" title="' . esc_attr(__('See All Posts', '__x__')) . '">' . $title . '</a>' . $delimiter . $current_before . $page_title . $current_after; | |
| 359 | +					} elseif (x_is_product()) { | |
| 360 | + echo $shop_link . $delimiter . $current_before . $page_title . $current_after; | |
| 361 | +					} elseif (is_page() && !$post->post_parent) { | |
| 362 | + echo $current_before . $page_title . $current_after; | |
| 363 | +					} elseif (is_page() && $post->post_parent) { | |
| 364 | + $parent_id = $post->post_parent; | |
| 365 | + $breadcrumbs = array(); | |
| 366 | +						while ($parent_id) { | |
| 367 | + $page = get_page($parent_id); | |
| 368 | + $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>'; | |
| 369 | + $parent_id = $page->post_parent; | |
| 370 | + } | |
| 371 | + $breadcrumbs = array_reverse($breadcrumbs); | |
| 372 | +						for ($i = 0; $i < count($breadcrumbs); $i++) { | |
| 373 | + echo $breadcrumbs[$i]; | |
| 374 | + if ($i != count($breadcrumbs) - 1) echo $delimiter; | |
| 375 | + } | |
| 376 | + echo $delimiter . $current_before . $page_title . $current_after; | |
| 377 | +					} elseif (is_tag()) { | |
| 378 | +						echo $current_before . single_tag_title('', false) . $current_after; | |
| 379 | +					} elseif (is_author()) { | |
| 380 | + GLOBAL $author; | |
| 381 | + $userdata = get_userdata($author); | |
| 382 | +						echo $current_before . __('Posts by ', '__x__') . '“' . $userdata->display_name . $current_after . '”'; | |
| 383 | +					} elseif (is_404()) { | |
| 384 | +						echo $current_before . __('404 (Page Not Found)', '__x__') . $current_after; | |
| 385 | +					} elseif (is_archive()) { | |
| 386 | +						if (x_is_shop()) { | |
| 387 | + echo $current_before . $shop_title . $current_after; | |
| 388 | +						} else { | |
| 389 | +							echo $current_before . __('Archives ', '__x__') . $current_after; | |
| 390 | + } | |
| 391 | + } | |
| 392 | +					if (get_query_var('paged')) { | |
| 393 | +						echo ' <span class="current" style="white-space: nowrap;">(' . __('Page', '__x__') . ' ' . get_query_var('paged') . ')</span>'; | |
| 394 | + } | |
| 395 | + echo '</div>'; | |
| 396 | + } | |
| 397 | + | |
| 398 | + } | |
| 399 | + | |
| 400 | + } | |
| 401 | + } // ends my geodir check | |
| 402 | 402 | endif; | 
| 403 | 403 | |
| 404 | 404 | |
| @@ -413,8 +413,8 @@ discard block | ||
| 413 | 413 | */ | 
| 414 | 414 | function geodir_x_location_switcher_menu_li_class($class) | 
| 415 | 415 |  { | 
| 416 | - $class .= " menu-item-has-children "; | |
| 417 | - return $class; | |
| 416 | + $class .= " menu-item-has-children "; | |
| 417 | + return $class; | |
| 418 | 418 | } | 
| 419 | 419 | |
| 420 | 420 |  add_filter('geodir_sub_menu_li_class', 'geodir_x_sub_menu_li_class', 10, 1); | 
| @@ -428,6 +428,6 @@ discard block | ||
| 428 | 428 | */ | 
| 429 | 429 | function geodir_x_sub_menu_li_class($class) | 
| 430 | 430 |  { | 
| 431 | - $class .= " menu-item-has-children "; | |
| 432 | - return $class; | |
| 431 | + $class .= " menu-item-has-children "; | |
| 432 | + return $class; | |
| 433 | 433 | } | 
| 434 | 434 | \ No newline at end of file | 
| @@ -336,7 +336,9 @@ discard block | ||
| 336 | 336 | echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter; | 
| 337 | 337 |                      if (is_category()) { | 
| 338 | 338 |                          $the_cat = get_category(get_query_var('cat'), false); | 
| 339 | - if ($the_cat->parent != 0) echo get_category_parents($the_cat->parent, TRUE, $delimiter); | |
| 339 | +                        if ($the_cat->parent != 0) { | |
| 340 | + echo get_category_parents($the_cat->parent, TRUE, $delimiter); | |
| 341 | + } | |
| 340 | 342 |                          echo $current_before . single_cat_title('', false) . $current_after; | 
| 341 | 343 |                      } elseif (x_is_product_category()) { | 
| 342 | 344 |                          echo $shop_link . $delimiter . $current_before . single_cat_title('', false) . $current_after; | 
| @@ -371,7 +373,9 @@ discard block | ||
| 371 | 373 | $breadcrumbs = array_reverse($breadcrumbs); | 
| 372 | 374 |                          for ($i = 0; $i < count($breadcrumbs); $i++) { | 
| 373 | 375 | echo $breadcrumbs[$i]; | 
| 374 | - if ($i != count($breadcrumbs) - 1) echo $delimiter; | |
| 376 | +                            if ($i != count($breadcrumbs) - 1) { | |
| 377 | + echo $delimiter; | |
| 378 | + } | |
| 375 | 379 | } | 
| 376 | 380 | echo $delimiter . $current_before . $page_title . $current_after; | 
| 377 | 381 |                      } elseif (is_tag()) { | 
| @@ -209,7 +209,7 @@ discard block | ||
| 209 | 209 | */ | 
| 210 | 210 | function geodir_x_action_wrapper_content_open($type = '', $id = '', $class = '') | 
| 211 | 211 |  { | 
| 212 | - echo '<div class="x-main left ' . $class . '" role="main">'; | |
| 212 | + echo '<div class="x-main left '.$class.'" role="main">'; | |
| 213 | 213 | } | 
| 214 | 214 | |
| 215 | 215 | /** | 
| @@ -235,7 +235,7 @@ discard block | ||
| 235 | 235 | */ | 
| 236 | 236 | function geodir_x_action_sidebar_right_open($type = '', $id = '', $class = '', $itemtype = '') | 
| 237 | 237 |  { | 
| 238 | - echo '<aside class="x-sidebar right" role="complementary" itemscope itemtype="' . $itemtype . '">'; | |
| 238 | + echo '<aside class="x-sidebar right" role="complementary" itemscope itemtype="'.$itemtype.'">'; | |
| 239 | 239 | } | 
| 240 | 240 | |
| 241 | 241 | /** | 
| @@ -307,7 +307,7 @@ discard block | ||
| 307 | 307 | // 8. Get shop title. | 
| 308 | 308 | // | 
| 309 | 309 | |
| 310 | - GLOBAL $post,$wp; | |
| 310 | + GLOBAL $post, $wp; | |
| 311 | 311 | |
| 312 | 312 |              if (geodir_is_page('detail') || geodir_is_page('listing') || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id())) { | 
| 313 | 313 | geodir_breadcrumb(); | 
| @@ -315,57 +315,57 @@ discard block | ||
| 315 | 315 | |
| 316 | 316 | $stack = x_get_stack(); | 
| 317 | 317 | $delimiter = ' <span class="delimiter"><i class="x-icon-angle-right"></i></span> '; // 1 | 
| 318 | - $home_text = '<span class="home"><i class="x-icon-home"></i></span>'; // 2 | |
| 319 | - $home_link = home_url(); // 3 | |
| 320 | - $current_before = '<span class="current">'; // 4 | |
| 321 | - $current_after = '</span>'; // 5 | |
| 322 | - $page_title = get_the_title(); // 6 | |
| 323 | -                $blog_title = get_the_title(get_option('page_for_posts', true));                 // 7 | |
| 324 | -                $shop_title = get_theme_mod('x_' . $stack . '_shop_title');                        // 8 | |
| 318 | + $home_text = '<span class="home"><i class="x-icon-home"></i></span>'; // 2 | |
| 319 | + $home_link = home_url(); // 3 | |
| 320 | + $current_before = '<span class="current">'; // 4 | |
| 321 | + $current_after = '</span>'; // 5 | |
| 322 | + $page_title = get_the_title(); // 6 | |
| 323 | +                $blog_title = get_the_title(get_option('page_for_posts', true)); // 7 | |
| 324 | +                $shop_title = get_theme_mod('x_'.$stack.'_shop_title'); // 8 | |
| 325 | 325 | |
| 326 | 326 |                  if (function_exists('woocommerce_get_page_id')) { | 
| 327 | 327 | $shop_url = x_get_shop_link(); | 
| 328 | - $shop_link = '<a href="' . $shop_url . '">' . $shop_title . '</a>'; | |
| 328 | + $shop_link = '<a href="'.$shop_url.'">'.$shop_title.'</a>'; | |
| 329 | 329 | } | 
| 330 | 330 | |
| 331 | 331 |                  if (is_front_page()) { | 
| 332 | - echo '<div class="x-breadcrumbs">' . $current_before . $home_text . $current_after . '</div>'; | |
| 332 | + echo '<div class="x-breadcrumbs">'.$current_before.$home_text.$current_after.'</div>'; | |
| 333 | 333 |                  } elseif (is_home()) { | 
| 334 | - echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter . $current_before . $blog_title . $current_after . '</div>'; | |
| 334 | + echo '<div class="x-breadcrumbs"><a href="'.$home_link.'">'.$home_text.'</a>'.$delimiter.$current_before.$blog_title.$current_after.'</div>'; | |
| 335 | 335 |                  } else { | 
| 336 | - echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter; | |
| 336 | + echo '<div class="x-breadcrumbs"><a href="'.$home_link.'">'.$home_text.'</a>'.$delimiter; | |
| 337 | 337 |                      if (is_category()) { | 
| 338 | 338 |                          $the_cat = get_category(get_query_var('cat'), false); | 
| 339 | 339 | if ($the_cat->parent != 0) echo get_category_parents($the_cat->parent, TRUE, $delimiter); | 
| 340 | -                        echo $current_before . single_cat_title('', false) . $current_after; | |
| 340 | +                        echo $current_before.single_cat_title('', false).$current_after; | |
| 341 | 341 |                      } elseif (x_is_product_category()) { | 
| 342 | -                        echo $shop_link . $delimiter . $current_before . single_cat_title('', false) . $current_after; | |
| 342 | +                        echo $shop_link.$delimiter.$current_before.single_cat_title('', false).$current_after; | |
| 343 | 343 |                      } elseif (x_is_product_tag()) { | 
| 344 | -                        echo $shop_link . $delimiter . $current_before . single_tag_title('', false) . $current_after; | |
| 344 | +                        echo $shop_link.$delimiter.$current_before.single_tag_title('', false).$current_after; | |
| 345 | 345 |                      } elseif (is_search()) { | 
| 346 | -                        echo $current_before . __('Search Results for ', '__x__') . '“' . get_search_query() . '”' . $current_after; | |
| 346 | +                        echo $current_before.__('Search Results for ', '__x__').'“'.get_search_query().'”'.$current_after; | |
| 347 | 347 |                      } elseif (is_singular('post')) { | 
| 348 | 348 |                          if (get_option('page_for_posts') == is_front_page()) { | 
| 349 | - echo $current_before . $page_title . $current_after; | |
| 349 | + echo $current_before.$page_title.$current_after; | |
| 350 | 350 |                          } else { | 
| 351 | -                            echo '<a href="' . get_permalink(get_option('page_for_posts')) . '" title="' . esc_attr(__('See All Posts', '__x__')) . '">' . $blog_title . '</a>' . $delimiter . $current_before . $page_title . $current_after; | |
| 351 | +                            echo '<a href="'.get_permalink(get_option('page_for_posts')).'" title="'.esc_attr(__('See All Posts', '__x__')).'">'.$blog_title.'</a>'.$delimiter.$current_before.$page_title.$current_after; | |
| 352 | 352 | } | 
| 353 | 353 |                      } elseif (x_is_portfolio()) { | 
| 354 | - echo $current_before . get_the_title() . $current_after; | |
| 354 | + echo $current_before.get_the_title().$current_after; | |
| 355 | 355 |                      } elseif (x_is_portfolio_item()) { | 
| 356 | 356 | $link = x_get_parent_portfolio_link(); | 
| 357 | 357 | $title = x_get_parent_portfolio_title(); | 
| 358 | -                        echo '<a href="' . $link . '" title="' . esc_attr(__('See All Posts', '__x__')) . '">' . $title . '</a>' . $delimiter . $current_before . $page_title . $current_after; | |
| 358 | +                        echo '<a href="'.$link.'" title="'.esc_attr(__('See All Posts', '__x__')).'">'.$title.'</a>'.$delimiter.$current_before.$page_title.$current_after; | |
| 359 | 359 |                      } elseif (x_is_product()) { | 
| 360 | - echo $shop_link . $delimiter . $current_before . $page_title . $current_after; | |
| 360 | + echo $shop_link.$delimiter.$current_before.$page_title.$current_after; | |
| 361 | 361 |                      } elseif (is_page() && !$post->post_parent) { | 
| 362 | - echo $current_before . $page_title . $current_after; | |
| 362 | + echo $current_before.$page_title.$current_after; | |
| 363 | 363 |                      } elseif (is_page() && $post->post_parent) { | 
| 364 | 364 | $parent_id = $post->post_parent; | 
| 365 | 365 | $breadcrumbs = array(); | 
| 366 | 366 |                          while ($parent_id) { | 
| 367 | 367 | $page = get_page($parent_id); | 
| 368 | - $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>'; | |
| 368 | + $breadcrumbs[] = '<a href="'.get_permalink($page->ID).'">'.get_the_title($page->ID).'</a>'; | |
| 369 | 369 | $parent_id = $page->post_parent; | 
| 370 | 370 | } | 
| 371 | 371 | $breadcrumbs = array_reverse($breadcrumbs); | 
| @@ -373,24 +373,24 @@ discard block | ||
| 373 | 373 | echo $breadcrumbs[$i]; | 
| 374 | 374 | if ($i != count($breadcrumbs) - 1) echo $delimiter; | 
| 375 | 375 | } | 
| 376 | - echo $delimiter . $current_before . $page_title . $current_after; | |
| 376 | + echo $delimiter.$current_before.$page_title.$current_after; | |
| 377 | 377 |                      } elseif (is_tag()) { | 
| 378 | -                        echo $current_before . single_tag_title('', false) . $current_after; | |
| 378 | +                        echo $current_before.single_tag_title('', false).$current_after; | |
| 379 | 379 |                      } elseif (is_author()) { | 
| 380 | 380 | GLOBAL $author; | 
| 381 | 381 | $userdata = get_userdata($author); | 
| 382 | -                        echo $current_before . __('Posts by ', '__x__') . '“' . $userdata->display_name . $current_after . '”'; | |
| 382 | +                        echo $current_before.__('Posts by ', '__x__').'“'.$userdata->display_name.$current_after.'”'; | |
| 383 | 383 |                      } elseif (is_404()) { | 
| 384 | -                        echo $current_before . __('404 (Page Not Found)', '__x__') . $current_after; | |
| 384 | +                        echo $current_before.__('404 (Page Not Found)', '__x__').$current_after; | |
| 385 | 385 |                      } elseif (is_archive()) { | 
| 386 | 386 |                          if (x_is_shop()) { | 
| 387 | - echo $current_before . $shop_title . $current_after; | |
| 387 | + echo $current_before.$shop_title.$current_after; | |
| 388 | 388 |                          } else { | 
| 389 | -                            echo $current_before . __('Archives ', '__x__') . $current_after; | |
| 389 | +                            echo $current_before.__('Archives ', '__x__').$current_after; | |
| 390 | 390 | } | 
| 391 | 391 | } | 
| 392 | 392 |                      if (get_query_var('paged')) { | 
| 393 | -                        echo ' <span class="current" style="white-space: nowrap;">(' . __('Page', '__x__') . ' ' . get_query_var('paged') . ')</span>'; | |
| 393 | +                        echo ' <span class="current" style="white-space: nowrap;">('.__('Page', '__x__').' '.get_query_var('paged').')</span>'; | |
| 394 | 394 | } | 
| 395 | 395 | echo '</div>'; | 
| 396 | 396 | } | 
| @@ -325,7 +325,7 @@ discard block | ||
| 325 | 325 | * @global wpdb $wpdb WordPress database abstraction object. | 
| 326 | 326 | * @deprecated 1.5.0 No longer required. | 
| 327 | 327 | * @param string $rules mod_rewrite Rewrite rules formatted for .htaccess. | 
| 328 | - * @return array Rewrite rules. | |
| 328 | + * @return string Rewrite rules. | |
| 329 | 329 | */ | 
| 330 | 330 | function geodir_htaccess_contents($rules) | 
| 331 | 331 |  {
 | 
| @@ -350,7 +350,7 @@ discard block | ||
| 350 | 350 | * @since 1.0.0 | 
| 351 | 351 | * | 
| 352 | 352 | * @param array $public_query_vars The array of query variables. | 
| 353 | - * @return array Query variables. | |
| 353 | + * @return string[] Query variables. | |
| 354 | 354 | */ | 
| 355 | 355 | function geodir_add_location_var($public_query_vars) | 
| 356 | 356 |  {
 | 
| @@ -366,7 +366,7 @@ discard block | ||
| 366 | 366 | * @since 1.0.0 | 
| 367 | 367 | * | 
| 368 | 368 | * @param array $public_query_vars The array of query variables. | 
| 369 | - * @return array Query variables. | |
| 369 | + * @return string[] Query variables. | |
| 370 | 370 | */ | 
| 371 | 371 | function geodir_add_geodir_page_var($public_query_vars) | 
| 372 | 372 |  {
 | 
| @@ -793,7 +793,6 @@ discard block | ||
| 793 | 793 | * | 
| 794 | 794 | * @since 1.0.0 | 
| 795 | 795 | * | 
| 796 | - * @param object $wp The WordPress object. | |
| 797 | 796 | */ | 
| 798 | 797 | function geodir_custom_post_status() | 
| 799 | 798 |  {
 | 
| @@ -106,24 +106,30 @@ discard block | ||
| 106 | 106 | $listing_slug = htmlentities(trim($_REQUEST['geodir_listing_prefix'])); | 
| 107 | 107 | |
| 108 | 108 |          if ($post_type == 'gd_place') {
 | 
| 109 | -            if (array_key_exists('has_archive', $args))
 | |
| 110 | - $args['has_archive'] = $listing_slug; | |
| 109 | +            if (array_key_exists('has_archive', $args)) { | |
| 110 | + $args['has_archive'] = $listing_slug; | |
| 111 | + } | |
| 111 | 112 | |
| 112 | 113 |              if (array_key_exists('rewrite', $args)) {
 | 
| 113 | -                if (array_key_exists('slug', $args['rewrite']))
 | |
| 114 | - $args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%'; | |
| 114 | +                if (array_key_exists('slug', $args['rewrite'])) { | |
| 115 | + $args['rewrite']['slug'] = $listing_slug; | |
| 116 | + } | |
| 117 | + // . '/%gd_taxonomy%'; | |
| 115 | 118 | } | 
| 116 | 119 | |
| 117 | 120 |              $geodir_post_types = get_option('geodir_post_types');
 | 
| 118 | 121 | |
| 119 | 122 |              if (array_key_exists($post_type, $geodir_post_types)) {
 | 
| 120 | 123 | |
| 121 | -                if (array_key_exists('has_archive', $geodir_post_types[$post_type]))
 | |
| 122 | - $geodir_post_types[$post_type]['has_archive'] = $listing_slug; | |
| 124 | +                if (array_key_exists('has_archive', $geodir_post_types[$post_type])) { | |
| 125 | + $geodir_post_types[$post_type]['has_archive'] = $listing_slug; | |
| 126 | + } | |
| 123 | 127 | |
| 124 | -                if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
 | |
| 125 | -                    if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
 | |
| 126 | - $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%'; | |
| 128 | +                if (array_key_exists('rewrite', $geodir_post_types[$post_type])) { | |
| 129 | +                                    if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
 | |
| 130 | + $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug; | |
| 131 | + } | |
| 132 | + // . '/%gd_taxonomy%'; | |
| 127 | 133 | |
| 128 | 134 |                  update_option('geodir_post_types', $geodir_post_types);
 | 
| 129 | 135 | |
| @@ -138,10 +144,11 @@ discard block | ||
| 138 | 144 |              if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
 | 
| 139 | 145 | $geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug; | 
| 140 | 146 | |
| 141 | -                if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
 | |
| 142 | -                    if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
 | |
| 147 | +                if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category'])) { | |
| 148 | +                                    if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
 | |
| 143 | 149 |                          if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
 | 
| 144 | - $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug; | |
| 150 | + $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug; | |
| 151 | + } | |
| 145 | 152 | |
| 146 | 153 |                  update_option('geodir_taxonomies', $geodir_taxonomies);
 | 
| 147 | 154 | |
| @@ -152,10 +159,11 @@ discard block | ||
| 152 | 159 |              if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
 | 
| 153 | 160 | $geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags'; | 
| 154 | 161 | |
| 155 | -                if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
 | |
| 156 | -                    if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
 | |
| 162 | +                if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags'])) { | |
| 163 | +                                    if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
 | |
| 157 | 164 |                          if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
 | 
| 158 | - $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags'; | |
| 165 | + $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags'; | |
| 166 | + } | |
| 159 | 167 | |
| 160 | 168 |                  update_option('geodir_taxonomies', $geodir_taxonomies_tag);
 | 
| 161 | 169 | |
| @@ -221,8 +229,9 @@ discard block | ||
| 221 | 229 | global $wpdb; | 
| 222 | 230 |          $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
 | 
| 223 | 231 | } | 
| 224 | - if (!isset($location_prefix)) | |
| 225 | - $location_prefix = 'location'; | |
| 232 | +    if (!isset($location_prefix)) { | |
| 233 | + $location_prefix = 'location'; | |
| 234 | + } | |
| 226 | 235 | |
| 227 | 236 |  	$location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
 | 
| 228 | 237 |  	if ($location_manager) {
 | 
| @@ -441,14 +450,17 @@ discard block | ||
| 441 | 450 | $gd_country = ''; | 
| 442 | 451 | $gd_region = ''; | 
| 443 | 452 | $gd_city = ''; | 
| 444 | - if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') | |
| 445 | - $gd_country = urldecode($wp->query_vars['gd_country']); | |
| 453 | +        if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') { | |
| 454 | + $gd_country = urldecode($wp->query_vars['gd_country']); | |
| 455 | + } | |
| 446 | 456 | |
| 447 | - if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') | |
| 448 | - $gd_region = urldecode($wp->query_vars['gd_region']); | |
| 457 | +        if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') { | |
| 458 | + $gd_region = urldecode($wp->query_vars['gd_region']); | |
| 459 | + } | |
| 449 | 460 | |
| 450 | - if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') | |
| 451 | - $gd_city = urldecode($wp->query_vars['gd_city']); | |
| 461 | +        if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') { | |
| 462 | + $gd_city = urldecode($wp->query_vars['gd_city']); | |
| 463 | + } | |
| 452 | 464 | |
| 453 | 465 |          if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) {
 | 
| 454 | 466 | $default_location = geodir_get_default_location(); | 
| @@ -456,17 +468,19 @@ discard block | ||
| 456 | 468 |              if (get_option('geodir_add_location_url')) {
 | 
| 457 | 469 |                  if ($geodir_show_location_url != 'all') {
 | 
| 458 | 470 |                      if ($gd_region == '') {
 | 
| 459 | -                        if ($gd_ses_region = $gd_session->get('gd_region'))
 | |
| 460 | - $gd_region = $gd_ses_region; | |
| 461 | - else | |
| 462 | - $gd_region = $default_location->region_slug; | |
| 471 | +                        if ($gd_ses_region = $gd_session->get('gd_region')) { | |
| 472 | + $gd_region = $gd_ses_region; | |
| 473 | +                        } else { | |
| 474 | + $gd_region = $default_location->region_slug; | |
| 475 | + } | |
| 463 | 476 | } | 
| 464 | 477 | |
| 465 | 478 |                      if ($gd_city == '') {
 | 
| 466 | -                        if ($gd_ses_city = $gd_session->get('gd_city'))
 | |
| 467 | - $gd_city = $gd_ses_city; | |
| 468 | - else | |
| 469 | - $gd_city = $default_location->city_slug; | |
| 479 | +                        if ($gd_ses_city = $gd_session->get('gd_city')) { | |
| 480 | + $gd_city = $gd_ses_city; | |
| 481 | +                        } else { | |
| 482 | + $gd_city = $default_location->city_slug; | |
| 483 | + } | |
| 470 | 484 | |
| 471 | 485 |                          $base_location_link = geodir_get_location_link('base');
 | 
| 472 | 486 | wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city); | 
| @@ -585,8 +599,9 @@ discard block | ||
| 585 | 599 | |
| 586 | 600 | |
| 587 | 601 |  				$geodir_term = str_replace('/' . $geodir_last_term, '', $geodir_term, $post_title_replace_count);
 | 
| 588 | - if (!$post_title_replace_count) | |
| 589 | - $geodir_term = str_replace($geodir_last_term, '', $geodir_term, $post_title_replace_count); | |
| 602 | +				if (!$post_title_replace_count) { | |
| 603 | + $geodir_term = str_replace($geodir_last_term, '', $geodir_term, $post_title_replace_count); | |
| 604 | + } | |
| 590 | 605 |  				$geodir_terms = explode('/', $geodir_term);
 | 
| 591 | 606 | $geodir_last_term = end($geodir_terms); | 
| 592 | 607 | |
| @@ -622,8 +637,9 @@ discard block | ||
| 622 | 637 | if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && | 
| 623 | 638 | geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && | 
| 624 | 639 | geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city) | 
| 625 | - ) | |
| 626 | - $is_geodir_location_found = true; | |
| 640 | +                    ) { | |
| 641 | + $is_geodir_location_found = true; | |
| 642 | + } | |
| 627 | 643 | |
| 628 | 644 | // if location has not been found for country , region and city then search for country and region only | 
| 629 | 645 | |
| @@ -631,8 +647,9 @@ discard block | ||
| 631 | 647 | $gd_city = ''; | 
| 632 | 648 | if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && | 
| 633 | 649 | geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) | 
| 634 | - ) | |
| 635 | - $is_geodir_location_found = true; | |
| 650 | +                        ) { | |
| 651 | + $is_geodir_location_found = true; | |
| 652 | + } | |
| 636 | 653 | |
| 637 | 654 | } | 
| 638 | 655 | |
| @@ -640,8 +657,9 @@ discard block | ||
| 640 | 657 |                      if (!$is_geodir_location_found) {
 | 
| 641 | 658 | $gd_city = ''; | 
| 642 | 659 | $gd_region = ''; | 
| 643 | - if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) | |
| 644 | - $is_geodir_location_found = true; | |
| 660 | +                        if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) { | |
| 661 | + $is_geodir_location_found = true; | |
| 662 | + } | |
| 645 | 663 | } | 
| 646 | 664 |                  } else if ($geodir_show_location_url == 'country_city') {
 | 
| 647 | 665 |                      if (count($geodir_terms) >= 2) {
 | 
| @@ -651,17 +669,19 @@ discard block | ||
| 651 | 669 | $gd_country = urldecode($geodir_terms[0]); | 
| 652 | 670 | } | 
| 653 | 671 | |
| 654 | - if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) | |
| 655 | - $is_geodir_location_found = true; | |
| 672 | +                    if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) { | |
| 673 | + $is_geodir_location_found = true; | |
| 674 | + } | |
| 656 | 675 | |
| 657 | 676 | // if location has not been found for country and city then search for country only | 
| 658 | 677 |                      if (!$is_geodir_location_found) {
 | 
| 659 | 678 | $gd_city = ''; | 
| 660 | 679 | |
| 661 | - if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) | |
| 662 | - $is_geodir_location_found = true; | |
| 680 | +						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) { | |
| 681 | + $is_geodir_location_found = true; | |
| 682 | + } | |
| 663 | 683 | } | 
| 664 | -                }  else if ($geodir_show_location_url == 'region_city') {
 | |
| 684 | +                } else if ($geodir_show_location_url == 'region_city') {
 | |
| 665 | 685 |                      if (count($geodir_terms) >= 2) {
 | 
| 666 | 686 | $gd_region = urldecode($geodir_terms[0]); | 
| 667 | 687 | $gd_city = urldecode($geodir_terms[1]); | 
| @@ -669,15 +689,17 @@ discard block | ||
| 669 | 689 | $gd_region = urldecode($geodir_terms[0]); | 
| 670 | 690 | } | 
| 671 | 691 | |
| 672 | - if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) | |
| 673 | - $is_geodir_location_found = true; | |
| 692 | +                    if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) { | |
| 693 | + $is_geodir_location_found = true; | |
| 694 | + } | |
| 674 | 695 | |
| 675 | 696 | // if location has not been found for region and city then search for region only | 
| 676 | 697 |                      if (!$is_geodir_location_found) {
 | 
| 677 | 698 | $gd_city = ''; | 
| 678 | 699 | |
| 679 | - if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)) | |
| 680 | - $is_geodir_location_found = true; | |
| 700 | +						if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)) { | |
| 701 | + $is_geodir_location_found = true; | |
| 702 | + } | |
| 681 | 703 | } | 
| 682 | 704 |                  } else {
 | 
| 683 | 705 | $gd_city = $geodir_terms[0]; | 
| @@ -719,14 +741,17 @@ discard block | ||
| 719 | 741 | |
| 720 | 742 | $wp->query_vars[$geodir_taxonomy] = $geodir_term; | 
| 721 | 743 | // eliminate location related terms from taxonomy term | 
| 722 | - if ($gd_country != '') | |
| 723 | -                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
 | |
| 744 | +            if ($gd_country != '') { | |
| 745 | +                            $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1); | |
| 746 | + } | |
| 724 | 747 | |
| 725 | - if ($gd_region != '') | |
| 726 | -                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
 | |
| 748 | +            if ($gd_region != '') { | |
| 749 | +                            $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1); | |
| 750 | + } | |
| 727 | 751 | |
| 728 | - if ($gd_city != '') | |
| 729 | -                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
 | |
| 752 | +            if ($gd_city != '') { | |
| 753 | +                            $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1); | |
| 754 | + } | |
| 730 | 755 | |
| 731 | 756 | |
| 732 | 757 |              $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
 | 
| @@ -762,27 +787,34 @@ discard block | ||
| 762 | 787 |      if (get_option('geodir_add_location_url')) {        
 | 
| 763 | 788 |  		if ($geodir_show_location_url == 'all') {
 | 
| 764 | 789 |  		} else if ($geodir_show_location_url == 'country_city') {
 | 
| 765 | - if (isset($wp->query_vars['gd_region'])) | |
| 766 | - $wp->query_vars['gd_region'] = ''; | |
| 790 | +			 if (isset($wp->query_vars['gd_region'])) { | |
| 791 | + $wp->query_vars['gd_region'] = ''; | |
| 792 | + } | |
| 767 | 793 |  		} else if ($geodir_show_location_url == 'region_city') {
 | 
| 768 | - if (isset($wp->query_vars['gd_country'])) | |
| 769 | - $wp->query_vars['gd_country'] = ''; | |
| 794 | +			if (isset($wp->query_vars['gd_country'])) { | |
| 795 | + $wp->query_vars['gd_country'] = ''; | |
| 796 | + } | |
| 770 | 797 |  		} else {
 | 
| 771 | - if (isset($wp->query_vars['gd_country'])) | |
| 772 | - $wp->query_vars['gd_country'] = ''; | |
| 798 | +			if (isset($wp->query_vars['gd_country'])) { | |
| 799 | + $wp->query_vars['gd_country'] = ''; | |
| 800 | + } | |
| 773 | 801 | |
| 774 | - if (isset($wp->query_vars['gd_region'])) | |
| 775 | - $wp->query_vars['gd_region'] = ''; | |
| 802 | +            if (isset($wp->query_vars['gd_region'])) { | |
| 803 | + $wp->query_vars['gd_region'] = ''; | |
| 804 | + } | |
| 776 | 805 | } | 
| 777 | 806 |      } else {
 | 
| 778 | - if (isset($wp->query_vars['gd_country'])) | |
| 779 | - $wp->query_vars['gd_country'] = ''; | |
| 807 | +        if (isset($wp->query_vars['gd_country'])) { | |
| 808 | + $wp->query_vars['gd_country'] = ''; | |
| 809 | + } | |
| 780 | 810 | |
| 781 | - if (isset($wp->query_vars['gd_region'])) | |
| 782 | - $wp->query_vars['gd_region'] = ''; | |
| 811 | +        if (isset($wp->query_vars['gd_region'])) { | |
| 812 | + $wp->query_vars['gd_region'] = ''; | |
| 813 | + } | |
| 783 | 814 | |
| 784 | - if (isset($wp->query_vars['gd_city'])) | |
| 785 | - $wp->query_vars['gd_city'] = ''; | |
| 815 | +        if (isset($wp->query_vars['gd_city'])) { | |
| 816 | + $wp->query_vars['gd_city'] = ''; | |
| 817 | + } | |
| 786 | 818 | } | 
| 787 | 819 | } | 
| 788 | 820 | |
| @@ -894,8 +926,9 @@ discard block | ||
| 894 | 926 | function geodir_exclude_page_where($where) | 
| 895 | 927 |  {
 | 
| 896 | 928 | global $wpdb; | 
| 897 | - if (is_admin()) | |
| 898 | - $where .= " AND $wpdb->posts.post_status != 'virtual'"; | |
| 929 | +    if (is_admin()) { | |
| 930 | + $where .= " AND $wpdb->posts.post_status != 'virtual'"; | |
| 931 | + } | |
| 899 | 932 | |
| 900 | 933 | return $where; | 
| 901 | 934 | } | 
| @@ -70,7 +70,7 @@ discard block | ||
| 70 | 70 | |
| 71 | 71 |              if (!empty($args['labels'])) {
 | 
| 72 | 72 |                  foreach ($args['labels'] as $key => $val) {
 | 
| 73 | - $args['labels'][$key] = __($val, 'geodirectory');// allow translation | |
| 73 | + $args['labels'][$key] = __($val, 'geodirectory'); // allow translation | |
| 74 | 74 | } | 
| 75 | 75 | } | 
| 76 | 76 | |
| @@ -111,7 +111,7 @@ discard block | ||
| 111 | 111 | |
| 112 | 112 |              if (array_key_exists('rewrite', $args)) {
 | 
| 113 | 113 |                  if (array_key_exists('slug', $args['rewrite']))
 | 
| 114 | - $args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%'; | |
| 114 | + $args['rewrite']['slug'] = $listing_slug; // . '/%gd_taxonomy%'; | |
| 115 | 115 | } | 
| 116 | 116 | |
| 117 | 117 |              $geodir_post_types = get_option('geodir_post_types');
 | 
| @@ -123,7 +123,7 @@ discard block | ||
| 123 | 123 | |
| 124 | 124 |                  if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
 | 
| 125 | 125 |                      if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
 | 
| 126 | - $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%'; | |
| 126 | + $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug; // . '/%gd_taxonomy%'; | |
| 127 | 127 | |
| 128 | 128 |                  update_option('geodir_post_types', $geodir_post_types);
 | 
| 129 | 129 | |
| @@ -135,13 +135,13 @@ discard block | ||
| 135 | 135 | |
| 136 | 136 |              $geodir_taxonomies = get_option('geodir_taxonomies');
 | 
| 137 | 137 | |
| 138 | -            if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
 | |
| 139 | - $geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug; | |
| 138 | +            if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type.'category'])) {
 | |
| 139 | + $geodir_taxonomies[$post_type.'category']['listing_slug'] = $listing_slug; | |
| 140 | 140 | |
| 141 | -                if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
 | |
| 142 | -                    if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
 | |
| 143 | -                        if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
 | |
| 144 | - $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug; | |
| 141 | +                if (array_key_exists('args', $geodir_taxonomies[$post_type.'category']))
 | |
| 142 | +                    if (array_key_exists('rewrite', $geodir_taxonomies[$post_type.'category']['args']))
 | |
| 143 | +                        if (array_key_exists('slug', $geodir_taxonomies[$post_type.'category']['args']['rewrite']))
 | |
| 144 | + $geodir_taxonomies[$post_type.'category']['args']['rewrite']['slug'] = $listing_slug; | |
| 145 | 145 | |
| 146 | 146 |                  update_option('geodir_taxonomies', $geodir_taxonomies);
 | 
| 147 | 147 | |
| @@ -149,13 +149,13 @@ discard block | ||
| 149 | 149 | |
| 150 | 150 | /* --- update taxonomies (tags) --- */ | 
| 151 | 151 |              $geodir_taxonomies_tag = get_option('geodir_taxonomies');
 | 
| 152 | -            if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
 | |
| 153 | - $geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags'; | |
| 152 | +            if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type.'_tags'])) {
 | |
| 153 | + $geodir_taxonomies_tag[$post_type.'_tags']['listing_slug'] = $listing_slug.'/tags'; | |
| 154 | 154 | |
| 155 | -                if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
 | |
| 156 | -                    if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
 | |
| 157 | -                        if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
 | |
| 158 | - $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags'; | |
| 155 | +                if (array_key_exists('args', $geodir_taxonomies_tag[$post_type.'_tags']))
 | |
| 156 | +                    if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type.'_tags']['args']))
 | |
| 157 | +                        if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type.'_tags']['args']['rewrite']))
 | |
| 158 | + $geodir_taxonomies_tag[$post_type.'_tags']['args']['rewrite']['slug'] = $listing_slug.'/tags'; | |
| 159 | 159 | |
| 160 | 160 |                  update_option('geodir_taxonomies', $geodir_taxonomies_tag);
 | 
| 161 | 161 | |
| @@ -205,11 +205,11 @@ discard block | ||
| 205 | 205 | $listing_slug = $args['listing_slug']; | 
| 206 | 206 | |
| 207 | 207 |              if (strpos($taxonomy, 'tags')) {
 | 
| 208 | -                $newrules[$listing_slug . '/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&paged=$matches[2]';
 | |
| 209 | - $newrules[$listing_slug . '/(.+?)/?$'] = 'index.php?' . $taxonomy . '=$matches[1]'; | |
| 208 | +                $newrules[$listing_slug.'/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?'.$taxonomy.'=$matches[1]&paged=$matches[2]';
 | |
| 209 | + $newrules[$listing_slug.'/(.+?)/?$'] = 'index.php?'.$taxonomy.'=$matches[1]'; | |
| 210 | 210 |              } else {
 | 
| 211 | 211 | // use this loop to add paging for details page comments paging | 
| 212 | -                $newrules[str_replace("/tags","",$listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
 | |
| 212 | +                $newrules[str_replace("/tags", "", $listing_slug).'/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?'.$taxonomy.'=$matches[1]&cpage=$matches[2]';
 | |
| 213 | 213 | } | 
| 214 | 214 | endforeach; | 
| 215 | 215 | endif; | 
| @@ -217,7 +217,7 @@ discard block | ||
| 217 | 217 | // create rules for location listing | 
| 218 | 218 |      $location_page = get_option('geodir_location_page');
 | 
| 219 | 219 | |
| 220 | -    if($location_page) {
 | |
| 220 | +    if ($location_page) {
 | |
| 221 | 221 | global $wpdb; | 
| 222 | 222 |          $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
 | 
| 223 | 223 | } | 
| @@ -247,30 +247,30 @@ discard block | ||
| 247 | 247 | |
| 248 | 248 |  		if ($matches2) {
 | 
| 249 | 249 |  			if ($neighbourhood_active) {
 | 
| 250 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]&gd_neighbourhood=$matches[3]'; | |
| 250 | + $newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&'.$matches1.'=$matches[1]&'.$matches2.'=$matches[2]&gd_neighbourhood=$matches[3]'; | |
| 251 | 251 | } | 
| 252 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]'; | |
| 252 | + $newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&'.$matches1.'=$matches[1]&'.$matches2.'=$matches[2]'; | |
| 253 | 253 |  		} else {
 | 
| 254 | 254 |  			if ($neighbourhood_active) {
 | 
| 255 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]&gd_neighbourhood=$matches[2]'; | |
| 255 | + $newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&'.$matches1.'=$matches[1]&gd_neighbourhood=$matches[2]'; | |
| 256 | 256 | } | 
| 257 | 257 | } | 
| 258 | 258 | |
| 259 | - $newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]'; | |
| 259 | + $newrules[$location_prefix.'/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&'.$matches1.'=$matches[1]'; | |
| 260 | 260 |  	} else { // country/region/city
 | 
| 261 | 261 |  		if ($neighbourhood_active) {
 | 
| 262 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]&gd_neighbourhood=$matches[4]'; | |
| 262 | + $newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]&gd_neighbourhood=$matches[4]'; | |
| 263 | 263 | } | 
| 264 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]'; | |
| 265 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]&gd_region=$matches[2]'; | |
| 266 | - $newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]'; | |
| 264 | + $newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]'; | |
| 265 | + $newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&gd_country=$matches[1]&gd_region=$matches[2]'; | |
| 266 | + $newrules[$location_prefix.'/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&gd_country=$matches[1]'; | |
| 267 | 267 | } | 
| 268 | 268 | |
| 269 | 269 |      if ($location_page && function_exists('icl_object_id')) {
 | 
| 270 | -        foreach(icl_get_languages('skip_missing=N') as $lang){
 | |
| 270 | +        foreach (icl_get_languages('skip_missing=N') as $lang) {
 | |
| 271 | 271 | $alt_page_id = ''; | 
| 272 | - $alt_page_id = icl_object_id($location_page, 'page', false,$lang['language_code']); | |
| 273 | -            if($alt_page_id){
 | |
| 272 | + $alt_page_id = icl_object_id($location_page, 'page', false, $lang['language_code']); | |
| 273 | +            if ($alt_page_id) {
 | |
| 274 | 274 |                  $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $alt_page_id));
 | 
| 275 | 275 | |
| 276 | 276 |  				if ($location_manager && ($hide_country_part || $hide_region_part)) {
 | 
| @@ -289,29 +289,29 @@ discard block | ||
| 289 | 289 | |
| 290 | 290 |  					if ($matches2) {
 | 
| 291 | 291 |  						if ($neighbourhood_active) {
 | 
| 292 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]&gd_neighbourhood=$matches[3]'; | |
| 292 | + $newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&'.$matches1.'=$matches[1]&'.$matches2.'=$matches[2]&gd_neighbourhood=$matches[3]'; | |
| 293 | 293 | } | 
| 294 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]'; | |
| 294 | + $newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&'.$matches1.'=$matches[1]&'.$matches2.'=$matches[2]'; | |
| 295 | 295 |  					} else {
 | 
| 296 | 296 |  						if ($neighbourhood_active) {
 | 
| 297 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]&gd_neighbourhood=$matches[2]'; | |
| 297 | + $newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&'.$matches1.'=$matches[1]&gd_neighbourhood=$matches[2]'; | |
| 298 | 298 | } | 
| 299 | 299 | } | 
| 300 | 300 | |
| 301 | - $newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]'; | |
| 301 | + $newrules[$location_prefix.'/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&'.$matches1.'=$matches[1]'; | |
| 302 | 302 |  				} else { // country/region/city
 | 
| 303 | 303 |  					if ($neighbourhood_active) {
 | 
| 304 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]&gd_neighbourhood=$matches[4]'; | |
| 304 | + $newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]&gd_neighbourhood=$matches[4]'; | |
| 305 | 305 | } | 
| 306 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]'; | |
| 307 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]'; | |
| 308 | - $newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]'; | |
| 306 | + $newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]'; | |
| 307 | + $newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&gd_country=$matches[1]&gd_region=$matches[2]'; | |
| 308 | + $newrules[$location_prefix.'/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&gd_country=$matches[1]'; | |
| 309 | 309 | } | 
| 310 | 310 | } | 
| 311 | 311 | } | 
| 312 | 312 | } | 
| 313 | 313 | |
| 314 | - $newrules[$location_prefix . '/?$'] = 'index.php?page_id=' . $location_page; | |
| 314 | + $newrules[$location_prefix.'/?$'] = 'index.php?page_id='.$location_page; | |
| 315 | 315 | |
| 316 | 316 | $rules = array_merge($newrules, $rules); | 
| 317 | 317 | return $rules; | 
| @@ -340,7 +340,7 @@ discard block | ||
| 340 | 340 | #Redirect 301 /location/ /$location_prefix/ | 
| 341 | 341 | # END GeoDirectory Rules\n\n | 
| 342 | 342 | EOD; | 
| 343 | - return $my_content . $rules; | |
| 343 | + return $my_content.$rules; | |
| 344 | 344 | } | 
| 345 | 345 |  //add_filter('mod_rewrite_rules', 'geodir_htaccess_contents');
 | 
| 346 | 346 | |
| @@ -416,12 +416,12 @@ discard block | ||
| 416 | 416 | global $wpdb; | 
| 417 | 417 | |
| 418 | 418 |          $page_for_posts = get_option('page_for_posts');
 | 
| 419 | -        $real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s",$wp->query_vars['pagename']));
 | |
| 419 | +        $real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s", $wp->query_vars['pagename']));
 | |
| 420 | 420 | |
| 421 | 421 |          if (function_exists('icl_object_id')) {
 | 
| 422 | 422 | $real_page_id = icl_object_id($real_page_id, 'page', true, ICL_LANGUAGE_CODE); | 
| 423 | 423 | } | 
| 424 | -        if ($real_page_id && $real_page_id!=$page_for_posts) {
 | |
| 424 | +        if ($real_page_id && $real_page_id != $page_for_posts) {
 | |
| 425 | 425 | $wp->query_vars['page_id'] = $real_page_id; | 
| 426 | 426 | } | 
| 427 | 427 | } | 
| @@ -469,7 +469,7 @@ discard block | ||
| 469 | 469 | $gd_city = $default_location->city_slug; | 
| 470 | 470 | |
| 471 | 471 |                          $base_location_link = geodir_get_location_link('base');
 | 
| 472 | - wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city); | |
| 472 | + wp_redirect($base_location_link.'/'.$gd_country.'/'.$gd_region.'/'.$gd_city); | |
| 473 | 473 | exit(); | 
| 474 | 474 | } | 
| 475 | 475 | } | 
| @@ -530,7 +530,7 @@ discard block | ||
| 530 | 530 | $geodir_set_location_session = true; | 
| 531 | 531 |          $geodir_taxonomis = geodir_get_taxonomies('', true);
 | 
| 532 | 532 | |
| 533 | -        if(!empty($geodir_taxonomis)){
 | |
| 533 | +        if (!empty($geodir_taxonomis)) {
 | |
| 534 | 534 |              foreach ($geodir_taxonomis as $taxonomy) {
 | 
| 535 | 535 |                  if (array_key_exists($taxonomy, $wp->query_vars)) {
 | 
| 536 | 536 | $is_geodir_taxonomy = true; | 
| @@ -587,7 +587,7 @@ discard block | ||
| 587 | 587 | } | 
| 588 | 588 | |
| 589 | 589 | |
| 590 | -				$geodir_term = str_replace('/' . $geodir_last_term, '', $geodir_term, $post_title_replace_count);
 | |
| 590 | +				$geodir_term = str_replace('/'.$geodir_last_term, '', $geodir_term, $post_title_replace_count);
 | |
| 591 | 591 | if (!$post_title_replace_count) | 
| 592 | 592 | $geodir_term = str_replace($geodir_last_term, '', $geodir_term, $post_title_replace_count); | 
| 593 | 593 |  				$geodir_terms = explode('/', $geodir_term);
 | 
| @@ -664,7 +664,7 @@ discard block | ||
| 664 | 664 | if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) | 
| 665 | 665 | $is_geodir_location_found = true; | 
| 666 | 666 | } | 
| 667 | -                }  else if ($geodir_show_location_url == 'region_city') {
 | |
| 667 | +                } else if ($geodir_show_location_url == 'region_city') {
 | |
| 668 | 668 |                      if (count($geodir_terms) >= 2) {
 | 
| 669 | 669 | $gd_region = urldecode($geodir_terms[0]); | 
| 670 | 670 | $gd_city = urldecode($geodir_terms[1]); | 
| @@ -723,13 +723,13 @@ discard block | ||
| 723 | 723 | $wp->query_vars[$geodir_taxonomy] = $geodir_term; | 
| 724 | 724 | // eliminate location related terms from taxonomy term | 
| 725 | 725 | if ($gd_country != '') | 
| 726 | -                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
 | |
| 726 | +                $wp->query_vars[$geodir_taxonomy] = preg_replace('/'.urlencode($gd_country).'/', '', $wp->query_vars[$geodir_taxonomy], 1);
 | |
| 727 | 727 | |
| 728 | 728 | if ($gd_region != '') | 
| 729 | -                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
 | |
| 729 | +                $wp->query_vars[$geodir_taxonomy] = preg_replace('/'.urlencode($gd_region).'/', '', $wp->query_vars[$geodir_taxonomy], 1);
 | |
| 730 | 730 | |
| 731 | 731 | if ($gd_city != '') | 
| 732 | -                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
 | |
| 732 | +                $wp->query_vars[$geodir_taxonomy] = preg_replace('/'.urlencode($gd_city).'/', '', $wp->query_vars[$geodir_taxonomy], 1);
 | |
| 733 | 733 | |
| 734 | 734 | |
| 735 | 735 |              $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
 | 
| @@ -914,16 +914,16 @@ discard block | ||
| 914 | 914 | * @param string $option Option name. | 
| 915 | 915 | * @return mixed The taxonomy option value. | 
| 916 | 916 | */ | 
| 917 | -function geodir_wpseo_taxonomy_meta( $value, $option = '' ) {
 | |
| 917 | +function geodir_wpseo_taxonomy_meta($value, $option = '') {
 | |
| 918 | 918 | global $wp_query; | 
| 919 | 919 | |
| 920 | -    if ( !empty( $value ) && ( is_category() || is_tax() ) ) {
 | |
| 920 | +    if (!empty($value) && (is_category() || is_tax())) {
 | |
| 921 | 921 | $term = $wp_query->get_queried_object(); | 
| 922 | 922 | |
| 923 | -        if ( !empty( $term->term_id ) && !empty( $term->taxonomy ) && isset( $value[$term->taxonomy][$term->term_id] ) && in_array( str_replace( 'category', '', $term->taxonomy ), geodir_get_posttypes() ) ) {
 | |
| 924 | - $image = geodir_get_default_catimage( $term->term_id, str_replace( 'category', '', $term->taxonomy ) ); | |
| 923 | +        if (!empty($term->term_id) && !empty($term->taxonomy) && isset($value[$term->taxonomy][$term->term_id]) && in_array(str_replace('category', '', $term->taxonomy), geodir_get_posttypes())) {
 | |
| 924 | +            $image = geodir_get_default_catimage($term->term_id, str_replace('category', '', $term->taxonomy));
 | |
| 925 | 925 | |
| 926 | -            if ( !empty( $image['src'] ) ) {
 | |
| 926 | +            if (!empty($image['src'])) {
 | |
| 927 | 927 | $value[$term->taxonomy][$term->term_id]['wpseo_twitter-image'] = $image['src']; | 
| 928 | 928 | $value[$term->taxonomy][$term->term_id]['wpseo_opengraph-image'] = $image['src']; | 
| 929 | 929 | } | 
| @@ -931,4 +931,4 @@ discard block | ||
| 931 | 931 | } | 
| 932 | 932 | return $value; | 
| 933 | 933 | } | 
| 934 | -add_filter( 'option_wpseo_taxonomy_meta', 'geodir_wpseo_taxonomy_meta', 10, 2 ); | |
| 934 | +add_filter('option_wpseo_taxonomy_meta', 'geodir_wpseo_taxonomy_meta', 10, 2);
 | |
| @@ -13,29 +13,29 @@ discard block | ||
| 13 | 13 | */ | 
| 14 | 14 | function geodir_register_taxonomies() | 
| 15 | 15 |  {
 | 
| 16 | - $taxonomies = array(); | |
| 17 | -    $taxonomies = get_option('geodir_taxonomies');
 | |
| 18 | - // If custom taxonomies are present, register them | |
| 19 | -    if (is_array($taxonomies)) {
 | |
| 20 | - // Sort taxonomies | |
| 21 | - ksort($taxonomies); | |
| 22 | - | |
| 23 | - // Register taxonomies | |
| 24 | -        foreach ($taxonomies as $taxonomy => $args) {
 | |
| 25 | - // Allow taxonomy names to be translated | |
| 26 | -            if (!empty($args['args']['labels'])) {
 | |
| 27 | -                foreach ($args['args']['labels'] as $key => $tax_label) {
 | |
| 28 | - $args['args']['labels'][$key] = __($tax_label, 'geodirectory'); | |
| 29 | - } | |
| 30 | - } | |
| 31 | - | |
| 32 | - $tax = register_taxonomy($taxonomy, $args['object_type'], $args['args']); | |
| 33 | - | |
| 34 | -            if (taxonomy_exists($taxonomy)) {
 | |
| 35 | - $tax = register_taxonomy_for_object_type($taxonomy, $args['object_type']); | |
| 36 | - } | |
| 37 | - } | |
| 38 | - } | |
| 16 | + $taxonomies = array(); | |
| 17 | +	$taxonomies = get_option('geodir_taxonomies');
 | |
| 18 | + // If custom taxonomies are present, register them | |
| 19 | +	if (is_array($taxonomies)) {
 | |
| 20 | + // Sort taxonomies | |
| 21 | + ksort($taxonomies); | |
| 22 | + | |
| 23 | + // Register taxonomies | |
| 24 | +		foreach ($taxonomies as $taxonomy => $args) {
 | |
| 25 | + // Allow taxonomy names to be translated | |
| 26 | +			if (!empty($args['args']['labels'])) {
 | |
| 27 | +				foreach ($args['args']['labels'] as $key => $tax_label) {
 | |
| 28 | + $args['args']['labels'][$key] = __($tax_label, 'geodirectory'); | |
| 29 | + } | |
| 30 | + } | |
| 31 | + | |
| 32 | + $tax = register_taxonomy($taxonomy, $args['object_type'], $args['args']); | |
| 33 | + | |
| 34 | +			if (taxonomy_exists($taxonomy)) {
 | |
| 35 | + $tax = register_taxonomy_for_object_type($taxonomy, $args['object_type']); | |
| 36 | + } | |
| 37 | + } | |
| 38 | + } | |
| 39 | 39 | } | 
| 40 | 40 | |
| 41 | 41 | |
| @@ -53,40 +53,40 @@ discard block | ||
| 53 | 53 | */ | 
| 54 | 54 | function geodir_register_post_types() | 
| 55 | 55 |  {
 | 
| 56 | - global $wp_post_types; | |
| 56 | + global $wp_post_types; | |
| 57 | 57 | |
| 58 | - $post_types = array(); | |
| 59 | -    $post_types = get_option('geodir_post_types');
 | |
| 58 | + $post_types = array(); | |
| 59 | +	$post_types = get_option('geodir_post_types');
 | |
| 60 | 60 | |
| 61 | - // Register each post type if array of data is returned | |
| 62 | - if (is_array($post_types)): | |
| 61 | + // Register each post type if array of data is returned | |
| 62 | + if (is_array($post_types)): | |
| 63 | 63 | |
| 64 | - foreach ($post_types as $post_type => $args): | |
| 64 | + foreach ($post_types as $post_type => $args): | |
| 65 | 65 | |
| 66 | -            if (!empty($args['rewrite']['slug'])) {
 | |
| 67 | - $args['rewrite']['slug'] = _x($args['rewrite']['slug'], 'URL slug', 'geodirectory'); | |
| 68 | - } | |
| 69 | - $args = stripslashes_deep($args); | |
| 66 | +			if (!empty($args['rewrite']['slug'])) {
 | |
| 67 | + $args['rewrite']['slug'] = _x($args['rewrite']['slug'], 'URL slug', 'geodirectory'); | |
| 68 | + } | |
| 69 | + $args = stripslashes_deep($args); | |
| 70 | 70 | |
| 71 | -            if (!empty($args['labels'])) {
 | |
| 72 | -                foreach ($args['labels'] as $key => $val) {
 | |
| 73 | - $args['labels'][$key] = __($val, 'geodirectory');// allow translation | |
| 74 | - } | |
| 75 | - } | |
| 71 | +			if (!empty($args['labels'])) {
 | |
| 72 | +				foreach ($args['labels'] as $key => $val) {
 | |
| 73 | + $args['labels'][$key] = __($val, 'geodirectory');// allow translation | |
| 74 | + } | |
| 75 | + } | |
| 76 | 76 | |
| 77 | - /** | |
| 78 | - * Filter post type args. | |
| 79 | - * | |
| 80 | - * @since 1.0.0 | |
| 81 | - * @param string $args Post type args. | |
| 82 | - * @param string $post_type The post type. | |
| 83 | - */ | |
| 84 | -            $args = apply_filters('geodir_post_type_args', $args, $post_type);
 | |
| 77 | + /** | |
| 78 | + * Filter post type args. | |
| 79 | + * | |
| 80 | + * @since 1.0.0 | |
| 81 | + * @param string $args Post type args. | |
| 82 | + * @param string $post_type The post type. | |
| 83 | + */ | |
| 84 | +			$args = apply_filters('geodir_post_type_args', $args, $post_type);
 | |
| 85 | 85 | |
| 86 | - $post_type = register_post_type($post_type, $args); | |
| 86 | + $post_type = register_post_type($post_type, $args); | |
| 87 | 87 | |
| 88 | - endforeach; | |
| 89 | - endif; | |
| 88 | + endforeach; | |
| 89 | + endif; | |
| 90 | 90 | } | 
| 91 | 91 | |
| 92 | 92 | /** | 
| @@ -100,72 +100,72 @@ discard block | ||
| 100 | 100 | */ | 
| 101 | 101 | function geodir_post_type_args_modify($args, $post_type) | 
| 102 | 102 |  {
 | 
| 103 | -    $geodir_location_prefix = isset($_REQUEST['geodir_location_prefix']) ? trim($_REQUEST['geodir_location_prefix']) : get_option('geodir_location_prefix');
 | |
| 103 | +	$geodir_location_prefix = isset($_REQUEST['geodir_location_prefix']) ? trim($_REQUEST['geodir_location_prefix']) : get_option('geodir_location_prefix');
 | |
| 104 | 104 |  	if (isset($_REQUEST['geodir_listing_prefix']) && $_REQUEST['geodir_listing_prefix'] != '' && geodir_strtolower($_REQUEST['geodir_listing_prefix']) != geodir_strtolower($geodir_location_prefix)) {
 | 
| 105 | 105 | |
| 106 | - $listing_slug = htmlentities(trim($_REQUEST['geodir_listing_prefix'])); | |
| 106 | + $listing_slug = htmlentities(trim($_REQUEST['geodir_listing_prefix'])); | |
| 107 | 107 | |
| 108 | -        if ($post_type == 'gd_place') {
 | |
| 109 | -            if (array_key_exists('has_archive', $args))
 | |
| 110 | - $args['has_archive'] = $listing_slug; | |
| 108 | +		if ($post_type == 'gd_place') {
 | |
| 109 | +			if (array_key_exists('has_archive', $args))
 | |
| 110 | + $args['has_archive'] = $listing_slug; | |
| 111 | 111 | |
| 112 | -            if (array_key_exists('rewrite', $args)) {
 | |
| 113 | -                if (array_key_exists('slug', $args['rewrite']))
 | |
| 114 | - $args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%'; | |
| 115 | - } | |
| 112 | +			if (array_key_exists('rewrite', $args)) {
 | |
| 113 | +				if (array_key_exists('slug', $args['rewrite']))
 | |
| 114 | + $args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%'; | |
| 115 | + } | |
| 116 | 116 | |
| 117 | -            $geodir_post_types = get_option('geodir_post_types');
 | |
| 117 | +			$geodir_post_types = get_option('geodir_post_types');
 | |
| 118 | 118 | |
| 119 | -            if (array_key_exists($post_type, $geodir_post_types)) {
 | |
| 119 | +			if (array_key_exists($post_type, $geodir_post_types)) {
 | |
| 120 | 120 | |
| 121 | -                if (array_key_exists('has_archive', $geodir_post_types[$post_type]))
 | |
| 122 | - $geodir_post_types[$post_type]['has_archive'] = $listing_slug; | |
| 121 | +				if (array_key_exists('has_archive', $geodir_post_types[$post_type]))
 | |
| 122 | + $geodir_post_types[$post_type]['has_archive'] = $listing_slug; | |
| 123 | 123 | |
| 124 | -                if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
 | |
| 125 | -                    if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
 | |
| 126 | - $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%'; | |
| 124 | +				if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
 | |
| 125 | +					if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
 | |
| 126 | + $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%'; | |
| 127 | 127 | |
| 128 | -                update_option('geodir_post_types', $geodir_post_types);
 | |
| 128 | +				update_option('geodir_post_types', $geodir_post_types);
 | |
| 129 | 129 | |
| 130 | - } | |
| 130 | + } | |
| 131 | 131 | |
| 132 | -            $geodir_post_types = get_option('geodir_post_types');
 | |
| 132 | +			$geodir_post_types = get_option('geodir_post_types');
 | |
| 133 | 133 | |
| 134 | - /* --- update taxonomies (category) --- */ | |
| 134 | + /* --- update taxonomies (category) --- */ | |
| 135 | 135 | |
| 136 | -            $geodir_taxonomies = get_option('geodir_taxonomies');
 | |
| 136 | +			$geodir_taxonomies = get_option('geodir_taxonomies');
 | |
| 137 | 137 | |
| 138 | -            if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
 | |
| 139 | - $geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug; | |
| 138 | +			if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
 | |
| 139 | + $geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug; | |
| 140 | 140 | |
| 141 | -                if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
 | |
| 142 | -                    if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
 | |
| 143 | -                        if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
 | |
| 144 | - $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug; | |
| 141 | +				if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
 | |
| 142 | +					if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
 | |
| 143 | +						if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
 | |
| 144 | + $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug; | |
| 145 | 145 | |
| 146 | -                update_option('geodir_taxonomies', $geodir_taxonomies);
 | |
| 146 | +				update_option('geodir_taxonomies', $geodir_taxonomies);
 | |
| 147 | 147 | |
| 148 | - } | |
| 148 | + } | |
| 149 | 149 | |
| 150 | - /* --- update taxonomies (tags) --- */ | |
| 151 | -            $geodir_taxonomies_tag = get_option('geodir_taxonomies');
 | |
| 152 | -            if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
 | |
| 153 | - $geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags'; | |
| 150 | + /* --- update taxonomies (tags) --- */ | |
| 151 | +			$geodir_taxonomies_tag = get_option('geodir_taxonomies');
 | |
| 152 | +			if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
 | |
| 153 | + $geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags'; | |
| 154 | 154 | |
| 155 | -                if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
 | |
| 156 | -                    if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
 | |
| 157 | -                        if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
 | |
| 158 | - $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags'; | |
| 155 | +				if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
 | |
| 156 | +					if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
 | |
| 157 | +						if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
 | |
| 158 | + $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags'; | |
| 159 | 159 | |
| 160 | -                update_option('geodir_taxonomies', $geodir_taxonomies_tag);
 | |
| 160 | +				update_option('geodir_taxonomies', $geodir_taxonomies_tag);
 | |
| 161 | 161 | |
| 162 | - } | |
| 162 | + } | |
| 163 | 163 | |
| 164 | - } | |
| 164 | + } | |
| 165 | 165 | |
| 166 | - } | |
| 166 | + } | |
| 167 | 167 | |
| 168 | - return $args; | |
| 168 | + return $args; | |
| 169 | 169 | } | 
| 170 | 170 | |
| 171 | 171 | /** | 
| @@ -178,8 +178,8 @@ discard block | ||
| 178 | 178 | */ | 
| 179 | 179 | function geodir_flush_rewrite_rules() | 
| 180 | 180 |  {
 | 
| 181 | - global $wp_rewrite; | |
| 182 | - $wp_rewrite->flush_rules(false); | |
| 181 | + global $wp_rewrite; | |
| 182 | + $wp_rewrite->flush_rules(false); | |
| 183 | 183 | } | 
| 184 | 184 | |
| 185 | 185 | /** | 
| @@ -194,35 +194,35 @@ discard block | ||
| 194 | 194 | * @return array Rewrite rules. | 
| 195 | 195 | */ | 
| 196 | 196 |  function geodir_listing_rewrite_rules($rules) {
 | 
| 197 | - $newrules = array(); | |
| 198 | -    $taxonomies = get_option('geodir_taxonomies');
 | |
| 199 | -    $detail_url_seprator = get_option('geodir_detailurl_separator');
 | |
| 197 | + $newrules = array(); | |
| 198 | +	$taxonomies = get_option('geodir_taxonomies');
 | |
| 199 | +	$detail_url_seprator = get_option('geodir_detailurl_separator');
 | |
| 200 | 200 | |
| 201 | 201 | // create rules for post listing | 
| 202 | - if (is_array($taxonomies)): | |
| 203 | - foreach ($taxonomies as $taxonomy => $args): | |
| 204 | - $post_type = $args['object_type']; | |
| 205 | - $listing_slug = $args['listing_slug']; | |
| 206 | - | |
| 207 | -            if (strpos($taxonomy, 'tags')) {
 | |
| 208 | -                $newrules[$listing_slug . '/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&paged=$matches[2]';
 | |
| 209 | - $newrules[$listing_slug . '/(.+?)/?$'] = 'index.php?' . $taxonomy . '=$matches[1]'; | |
| 210 | -            } else {
 | |
| 211 | - // use this loop to add paging for details page comments paging | |
| 212 | -                $newrules[str_replace("/tags","",$listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
 | |
| 213 | - } | |
| 214 | - endforeach; | |
| 215 | - endif; | |
| 216 | - | |
| 217 | - // create rules for location listing | |
| 218 | -    $location_page = get_option('geodir_location_page');
 | |
| 202 | + if (is_array($taxonomies)): | |
| 203 | + foreach ($taxonomies as $taxonomy => $args): | |
| 204 | + $post_type = $args['object_type']; | |
| 205 | + $listing_slug = $args['listing_slug']; | |
| 206 | + | |
| 207 | +			if (strpos($taxonomy, 'tags')) {
 | |
| 208 | +				$newrules[$listing_slug . '/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&paged=$matches[2]';
 | |
| 209 | + $newrules[$listing_slug . '/(.+?)/?$'] = 'index.php?' . $taxonomy . '=$matches[1]'; | |
| 210 | +			} else {
 | |
| 211 | + // use this loop to add paging for details page comments paging | |
| 212 | +				$newrules[str_replace("/tags","",$listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
 | |
| 213 | + } | |
| 214 | + endforeach; | |
| 215 | + endif; | |
| 216 | + | |
| 217 | + // create rules for location listing | |
| 218 | +	$location_page = get_option('geodir_location_page');
 | |
| 219 | 219 | |
| 220 | -    if($location_page) {
 | |
| 221 | - global $wpdb; | |
| 222 | -        $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
 | |
| 223 | - } | |
| 224 | - if (!isset($location_prefix)) | |
| 225 | - $location_prefix = 'location'; | |
| 220 | +	if($location_page) {
 | |
| 221 | + global $wpdb; | |
| 222 | +		$location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
 | |
| 223 | + } | |
| 224 | + if (!isset($location_prefix)) | |
| 225 | + $location_prefix = 'location'; | |
| 226 | 226 | |
| 227 | 227 |  	$location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
 | 
| 228 | 228 |  	if ($location_manager) {
 | 
| @@ -266,12 +266,12 @@ discard block | ||
| 266 | 266 | $newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]'; | 
| 267 | 267 | } | 
| 268 | 268 | |
| 269 | -    if ($location_page && function_exists('icl_object_id')) {
 | |
| 270 | -        foreach(icl_get_languages('skip_missing=N') as $lang){
 | |
| 271 | - $alt_page_id = ''; | |
| 272 | - $alt_page_id = icl_object_id($location_page, 'page', false,$lang['language_code']); | |
| 273 | -            if($alt_page_id){
 | |
| 274 | -                $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $alt_page_id));
 | |
| 269 | +	if ($location_page && function_exists('icl_object_id')) {
 | |
| 270 | +		foreach(icl_get_languages('skip_missing=N') as $lang){
 | |
| 271 | + $alt_page_id = ''; | |
| 272 | + $alt_page_id = icl_object_id($location_page, 'page', false,$lang['language_code']); | |
| 273 | +			if($alt_page_id){
 | |
| 274 | +				$location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $alt_page_id));
 | |
| 275 | 275 | |
| 276 | 276 |  				if ($location_manager && ($hide_country_part || $hide_region_part)) {
 | 
| 277 | 277 | $matches2 = ''; | 
| @@ -307,14 +307,14 @@ discard block | ||
| 307 | 307 | $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]'; | 
| 308 | 308 | $newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]'; | 
| 309 | 309 | } | 
| 310 | - } | |
| 311 | - } | |
| 312 | - } | |
| 310 | + } | |
| 311 | + } | |
| 312 | + } | |
| 313 | 313 | |
| 314 | - $newrules[$location_prefix . '/?$'] = 'index.php?page_id=' . $location_page; | |
| 314 | + $newrules[$location_prefix . '/?$'] = 'index.php?page_id=' . $location_page; | |
| 315 | 315 | |
| 316 | - $rules = array_merge($newrules, $rules); | |
| 317 | - return $rules; | |
| 316 | + $rules = array_merge($newrules, $rules); | |
| 317 | + return $rules; | |
| 318 | 318 | } | 
| 319 | 319 | |
| 320 | 320 | /** | 
| @@ -329,18 +329,18 @@ discard block | ||
| 329 | 329 | */ | 
| 330 | 330 | function geodir_htaccess_contents($rules) | 
| 331 | 331 |  {
 | 
| 332 | - global $wpdb; | |
| 333 | -    $location_prefix = get_option('geodir_location_prefix');
 | |
| 334 | - // if location page slug changed then add redirect | |
| 335 | -    if ($location_prefix == 'location') {
 | |
| 336 | - return $rules; | |
| 337 | - } | |
| 338 | - $my_content = <<<EOD | |
| 332 | + global $wpdb; | |
| 333 | +	$location_prefix = get_option('geodir_location_prefix');
 | |
| 334 | + // if location page slug changed then add redirect | |
| 335 | +	if ($location_prefix == 'location') {
 | |
| 336 | + return $rules; | |
| 337 | + } | |
| 338 | + $my_content = <<<EOD | |
| 339 | 339 | \n# BEGIN GeoDirectory Rules | 
| 340 | 340 | #Redirect 301 /location/ /$location_prefix/ | 
| 341 | 341 | # END GeoDirectory Rules\n\n | 
| 342 | 342 | EOD; | 
| 343 | - return $my_content . $rules; | |
| 343 | + return $my_content . $rules; | |
| 344 | 344 | } | 
| 345 | 345 |  //add_filter('mod_rewrite_rules', 'geodir_htaccess_contents');
 | 
| 346 | 346 | |
| @@ -354,10 +354,10 @@ discard block | ||
| 354 | 354 | */ | 
| 355 | 355 | function geodir_add_location_var($public_query_vars) | 
| 356 | 356 |  {
 | 
| 357 | - $public_query_vars[] = 'gd_country'; | |
| 358 | - $public_query_vars[] = 'gd_region'; | |
| 359 | - $public_query_vars[] = 'gd_city'; | |
| 360 | - return $public_query_vars; | |
| 357 | + $public_query_vars[] = 'gd_country'; | |
| 358 | + $public_query_vars[] = 'gd_region'; | |
| 359 | + $public_query_vars[] = 'gd_city'; | |
| 360 | + return $public_query_vars; | |
| 361 | 361 | } | 
| 362 | 362 | |
| 363 | 363 | /** | 
| @@ -370,8 +370,8 @@ discard block | ||
| 370 | 370 | */ | 
| 371 | 371 | function geodir_add_geodir_page_var($public_query_vars) | 
| 372 | 372 |  {
 | 
| 373 | - $public_query_vars[] = 'gd_is_geodir_page'; | |
| 374 | - return $public_query_vars; | |
| 373 | + $public_query_vars[] = 'gd_is_geodir_page'; | |
| 374 | + return $public_query_vars; | |
| 375 | 375 | } | 
| 376 | 376 | |
| 377 | 377 | /** | 
| @@ -383,20 +383,20 @@ discard block | ||
| 383 | 383 | */ | 
| 384 | 384 | function geodir_add_page_id_in_query_var() | 
| 385 | 385 |  {
 | 
| 386 | - global $wp_query; | |
| 386 | + global $wp_query; | |
| 387 | 387 | |
| 388 | - $page_id = $wp_query->get_queried_object_id(); | |
| 388 | + $page_id = $wp_query->get_queried_object_id(); | |
| 389 | 389 | |
| 390 | -    if (!get_query_var('page_id') && !is_archive()) {
 | |
| 391 | - // fix for WP tags conflict with enfold theme | |
| 392 | - $theme_name = geodir_strtolower(wp_get_theme()); | |
| 393 | -        if (!geodir_is_geodir_page() && strpos($theme_name, 'enfold') !== false) {
 | |
| 394 | - return $wp_query; | |
| 395 | - } | |
| 396 | -        $wp_query->set('page_id', $page_id);
 | |
| 397 | - } | |
| 390 | +	if (!get_query_var('page_id') && !is_archive()) {
 | |
| 391 | + // fix for WP tags conflict with enfold theme | |
| 392 | + $theme_name = geodir_strtolower(wp_get_theme()); | |
| 393 | +		if (!geodir_is_geodir_page() && strpos($theme_name, 'enfold') !== false) {
 | |
| 394 | + return $wp_query; | |
| 395 | + } | |
| 396 | +		$wp_query->set('page_id', $page_id);
 | |
| 397 | + } | |
| 398 | 398 | |
| 399 | - return $wp_query; | |
| 399 | + return $wp_query; | |
| 400 | 400 | } | 
| 401 | 401 | |
| 402 | 402 | /** | 
| @@ -411,23 +411,23 @@ discard block | ||
| 411 | 411 |  function geodir_set_location_var_in_session_in_core($wp) {
 | 
| 412 | 412 | global $gd_session; | 
| 413 | 413 | |
| 414 | - // Fix for WPML removing page_id query var: | |
| 415 | -    if (isset($wp->query_vars['page']) && !isset($wp->query_vars['page_id']) && isset($wp->query_vars['pagename']) && !is_home()) {
 | |
| 416 | - global $wpdb; | |
| 414 | + // Fix for WPML removing page_id query var: | |
| 415 | +	if (isset($wp->query_vars['page']) && !isset($wp->query_vars['page_id']) && isset($wp->query_vars['pagename']) && !is_home()) {
 | |
| 416 | + global $wpdb; | |
| 417 | 417 | |
| 418 | -        $page_for_posts = get_option('page_for_posts');
 | |
| 419 | -        $real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s",$wp->query_vars['pagename']));
 | |
| 418 | +		$page_for_posts = get_option('page_for_posts');
 | |
| 419 | +		$real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s",$wp->query_vars['pagename']));
 | |
| 420 | 420 | |
| 421 | -        if (function_exists('icl_object_id')) {
 | |
| 422 | - $real_page_id = icl_object_id($real_page_id, 'page', true, ICL_LANGUAGE_CODE); | |
| 423 | - } | |
| 424 | -        if ($real_page_id && $real_page_id!=$page_for_posts) {
 | |
| 425 | - $wp->query_vars['page_id'] = $real_page_id; | |
| 426 | - } | |
| 427 | - } | |
| 421 | +		if (function_exists('icl_object_id')) {
 | |
| 422 | + $real_page_id = icl_object_id($real_page_id, 'page', true, ICL_LANGUAGE_CODE); | |
| 423 | + } | |
| 424 | +		if ($real_page_id && $real_page_id!=$page_for_posts) {
 | |
| 425 | + $wp->query_vars['page_id'] = $real_page_id; | |
| 426 | + } | |
| 427 | + } | |
| 428 | 428 | // Query Vars will have page_id parameter | 
| 429 | 429 | // check if query var has page_id and that page id is location page | 
| 430 | - geodir_set_is_geodir_page($wp); | |
| 430 | + geodir_set_is_geodir_page($wp); | |
| 431 | 431 | // if is GD homepage set the page ID | 
| 432 | 432 |  	if (geodir_is_page('home')) {
 | 
| 433 | 433 |  		$wp->query_vars['page_id'] = get_option('page_on_front');
 | 
| @@ -436,118 +436,118 @@ discard block | ||
| 436 | 436 | // The location url format (all or country_city or region_city or city). | 
| 437 | 437 |  	$geodir_show_location_url = get_option('geodir_show_location_url');
 | 
| 438 | 438 | |
| 439 | -    if (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id()) {
 | |
| 440 | - $gd_country = ''; | |
| 441 | - $gd_region = ''; | |
| 442 | - $gd_city = ''; | |
| 443 | - if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') | |
| 444 | - $gd_country = urldecode($wp->query_vars['gd_country']); | |
| 445 | - | |
| 446 | - if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') | |
| 447 | - $gd_region = urldecode($wp->query_vars['gd_region']); | |
| 448 | - | |
| 449 | - if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') | |
| 450 | - $gd_city = urldecode($wp->query_vars['gd_city']); | |
| 451 | - | |
| 452 | -        if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) {
 | |
| 453 | - $default_location = geodir_get_default_location(); | |
| 454 | - | |
| 455 | -            if (get_option('geodir_add_location_url')) {
 | |
| 456 | -                if ($geodir_show_location_url != 'all') {
 | |
| 457 | -                    if ($gd_region == '') {
 | |
| 458 | -                        if ($gd_ses_region = $gd_session->get('gd_region'))
 | |
| 459 | - $gd_region = $gd_ses_region; | |
| 460 | - else | |
| 461 | - $gd_region = $default_location->region_slug; | |
| 462 | - } | |
| 463 | - | |
| 464 | -                    if ($gd_city == '') {
 | |
| 465 | -                        if ($gd_ses_city = $gd_session->get('gd_city'))
 | |
| 466 | - $gd_city = $gd_ses_city; | |
| 467 | - else | |
| 468 | - $gd_city = $default_location->city_slug; | |
| 469 | - | |
| 470 | -                        $base_location_link = geodir_get_location_link('base');
 | |
| 471 | - wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city); | |
| 472 | - exit(); | |
| 473 | - } | |
| 474 | - } | |
| 475 | - } | |
| 476 | - | |
| 477 | - $args = array( | |
| 478 | - 'what' => 'city', | |
| 479 | - 'city_val' => $gd_city, | |
| 480 | - 'region_val' => $gd_region, | |
| 481 | - 'country_val' => $gd_country, | |
| 482 | - 'country_column_name' => 'country_slug', | |
| 483 | - 'region_column_name' => 'region_slug', | |
| 484 | - 'city_column_name' => 'city_slug', | |
| 485 | - 'location_link_part' => false, | |
| 486 | - 'compare_operator' => '' | |
| 487 | - ); | |
| 488 | - | |
| 489 | -            $location_array = function_exists('geodir_get_location_array') ? geodir_get_location_array($args) : array();
 | |
| 490 | -            if (!empty($location_array)) {
 | |
| 491 | -                $gd_session->set('gd_multi_location', 1);
 | |
| 492 | -                $gd_session->set('gd_country', $gd_country);
 | |
| 493 | -                $gd_session->set('gd_region', $gd_region);
 | |
| 494 | -                $gd_session->set('gd_city', $gd_city);
 | |
| 439 | +	if (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id()) {
 | |
| 440 | + $gd_country = ''; | |
| 441 | + $gd_region = ''; | |
| 442 | + $gd_city = ''; | |
| 443 | + if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') | |
| 444 | + $gd_country = urldecode($wp->query_vars['gd_country']); | |
| 445 | + | |
| 446 | + if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') | |
| 447 | + $gd_region = urldecode($wp->query_vars['gd_region']); | |
| 448 | + | |
| 449 | + if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') | |
| 450 | + $gd_city = urldecode($wp->query_vars['gd_city']); | |
| 451 | + | |
| 452 | +		if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) {
 | |
| 453 | + $default_location = geodir_get_default_location(); | |
| 454 | + | |
| 455 | +			if (get_option('geodir_add_location_url')) {
 | |
| 456 | +				if ($geodir_show_location_url != 'all') {
 | |
| 457 | +					if ($gd_region == '') {
 | |
| 458 | +						if ($gd_ses_region = $gd_session->get('gd_region'))
 | |
| 459 | + $gd_region = $gd_ses_region; | |
| 460 | + else | |
| 461 | + $gd_region = $default_location->region_slug; | |
| 462 | + } | |
| 463 | + | |
| 464 | +					if ($gd_city == '') {
 | |
| 465 | +						if ($gd_ses_city = $gd_session->get('gd_city'))
 | |
| 466 | + $gd_city = $gd_ses_city; | |
| 467 | + else | |
| 468 | + $gd_city = $default_location->city_slug; | |
| 469 | + | |
| 470 | +						$base_location_link = geodir_get_location_link('base');
 | |
| 471 | + wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city); | |
| 472 | + exit(); | |
| 473 | + } | |
| 474 | + } | |
| 475 | + } | |
| 476 | + | |
| 477 | + $args = array( | |
| 478 | + 'what' => 'city', | |
| 479 | + 'city_val' => $gd_city, | |
| 480 | + 'region_val' => $gd_region, | |
| 481 | + 'country_val' => $gd_country, | |
| 482 | + 'country_column_name' => 'country_slug', | |
| 483 | + 'region_column_name' => 'region_slug', | |
| 484 | + 'city_column_name' => 'city_slug', | |
| 485 | + 'location_link_part' => false, | |
| 486 | + 'compare_operator' => '' | |
| 487 | + ); | |
| 488 | + | |
| 489 | +			$location_array = function_exists('geodir_get_location_array') ? geodir_get_location_array($args) : array();
 | |
| 490 | +			if (!empty($location_array)) {
 | |
| 491 | +				$gd_session->set('gd_multi_location', 1);
 | |
| 492 | +				$gd_session->set('gd_country', $gd_country);
 | |
| 493 | +				$gd_session->set('gd_region', $gd_region);
 | |
| 494 | +				$gd_session->set('gd_city', $gd_city);
 | |
| 495 | 495 | |
| 496 | 496 | $wp->query_vars['gd_country'] = $gd_country; | 
| 497 | - $wp->query_vars['gd_region'] = $gd_region; | |
| 498 | - $wp->query_vars['gd_city'] = $gd_city; | |
| 499 | -            } else {
 | |
| 500 | -                $gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
 | |
| 501 | - } | |
| 502 | -        } else {
 | |
| 503 | -            $gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
 | |
| 504 | - } | |
| 505 | - | |
| 506 | -    } else if (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
 | |
| 507 | -        if (!is_admin()) {
 | |
| 508 | - $requested_post_type = $wp->query_vars['post_type']; | |
| 509 | - // check if this post type is geodirectory post types | |
| 510 | - $post_type_array = geodir_get_posttypes(); | |
| 497 | + $wp->query_vars['gd_region'] = $gd_region; | |
| 498 | + $wp->query_vars['gd_city'] = $gd_city; | |
| 499 | +			} else {
 | |
| 500 | +				$gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
 | |
| 501 | + } | |
| 502 | +		} else {
 | |
| 503 | +			$gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
 | |
| 504 | + } | |
| 505 | + | |
| 506 | +	} else if (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
 | |
| 507 | +		if (!is_admin()) {
 | |
| 508 | + $requested_post_type = $wp->query_vars['post_type']; | |
| 509 | + // check if this post type is geodirectory post types | |
| 510 | + $post_type_array = geodir_get_posttypes(); | |
| 511 | 511 | |
| 512 | 512 |  			if (in_array($requested_post_type, $post_type_array)) {
 | 
| 513 | - // now u can apply geodirectory related manipulation. | |
| 514 | - } | |
| 515 | - } | |
| 516 | -    } else {
 | |
| 517 | - // check if a geodirectory taxonomy is set | |
| 518 | - $gd_country = ''; | |
| 519 | - $gd_region = ''; | |
| 520 | - $gd_city = ''; | |
| 513 | + // now u can apply geodirectory related manipulation. | |
| 514 | + } | |
| 515 | + } | |
| 516 | +	} else {
 | |
| 517 | + // check if a geodirectory taxonomy is set | |
| 518 | + $gd_country = ''; | |
| 519 | + $gd_region = ''; | |
| 520 | + $gd_city = ''; | |
| 521 | 521 | |
| 522 | 522 | $is_geodir_taxonomy = false; | 
| 523 | - $is_geodir_taxonomy_term = false; // the last term is real geodirectory taxonomy term or not | |
| 524 | - $is_geodir_location_found = false; | |
| 523 | + $is_geodir_taxonomy_term = false; // the last term is real geodirectory taxonomy term or not | |
| 524 | + $is_geodir_location_found = false; | |
| 525 | 525 | |
| 526 | 526 | $geodir_taxonomy = ''; | 
| 527 | - $geodir_post_type = ''; | |
| 528 | - $geodir_term = ''; | |
| 529 | - $geodir_set_location_session = true; | |
| 530 | -        $geodir_taxonomis = geodir_get_taxonomies('', true);
 | |
| 531 | - | |
| 532 | -        if(!empty($geodir_taxonomis)){
 | |
| 533 | -            foreach ($geodir_taxonomis as $taxonomy) {
 | |
| 534 | -                if (array_key_exists($taxonomy, $wp->query_vars)) {
 | |
| 535 | - $is_geodir_taxonomy = true; | |
| 536 | - $geodir_taxonomy = $taxonomy; | |
| 537 | -                    $geodir_post_type = str_replace('category', '', $taxonomy);
 | |
| 538 | -                    $geodir_post_type = str_replace('_tags', '', $geodir_post_type);
 | |
| 539 | - $geodir_term = $wp->query_vars[$geodir_taxonomy]; | |
| 540 | - break; | |
| 541 | - } | |
| 542 | - } | |
| 543 | - } | |
| 544 | - | |
| 545 | - // now get an array of all terms seperated by '/' | |
| 546 | -        $geodir_terms = explode('/', $geodir_term);
 | |
| 547 | - $geodir_last_term = end($geodir_terms); | |
| 548 | - | |
| 549 | -        if ($is_geodir_taxonomy) { // do all these only when it is a geodirectory taxonomy
 | |
| 550 | - $wp->query_vars['post_type'] = $geodir_post_type; | |
| 527 | + $geodir_post_type = ''; | |
| 528 | + $geodir_term = ''; | |
| 529 | + $geodir_set_location_session = true; | |
| 530 | +		$geodir_taxonomis = geodir_get_taxonomies('', true);
 | |
| 531 | + | |
| 532 | +		if(!empty($geodir_taxonomis)){
 | |
| 533 | +			foreach ($geodir_taxonomis as $taxonomy) {
 | |
| 534 | +				if (array_key_exists($taxonomy, $wp->query_vars)) {
 | |
| 535 | + $is_geodir_taxonomy = true; | |
| 536 | + $geodir_taxonomy = $taxonomy; | |
| 537 | +					$geodir_post_type = str_replace('category', '', $taxonomy);
 | |
| 538 | +					$geodir_post_type = str_replace('_tags', '', $geodir_post_type);
 | |
| 539 | + $geodir_term = $wp->query_vars[$geodir_taxonomy]; | |
| 540 | + break; | |
| 541 | + } | |
| 542 | + } | |
| 543 | + } | |
| 544 | + | |
| 545 | + // now get an array of all terms seperated by '/' | |
| 546 | +		$geodir_terms = explode('/', $geodir_term);
 | |
| 547 | + $geodir_last_term = end($geodir_terms); | |
| 548 | + | |
| 549 | +		if ($is_geodir_taxonomy) { // do all these only when it is a geodirectory taxonomy
 | |
| 550 | + $wp->query_vars['post_type'] = $geodir_post_type; | |
| 551 | 551 | |
| 552 | 552 | // now check if last term is a post of geodirectory post types | 
| 553 | 553 | $geodir_post = get_posts(array( | 
| @@ -596,196 +596,196 @@ discard block | ||
| 596 | 596 | //return ; | 
| 597 | 597 | } | 
| 598 | 598 | |
| 599 | - $geodir_location_terms = ''; | |
| 600 | - // if last term is not a post then check if last term is a term of the specific texonomy or not | |
| 601 | -            if (geodir_term_exists($geodir_last_term, $geodir_taxonomy)) {
 | |
| 602 | - $is_geodir_taxonomy_term = true; | |
| 599 | + $geodir_location_terms = ''; | |
| 600 | + // if last term is not a post then check if last term is a term of the specific texonomy or not | |
| 601 | +			if (geodir_term_exists($geodir_last_term, $geodir_taxonomy)) {
 | |
| 602 | + $is_geodir_taxonomy_term = true; | |
| 603 | 603 | |
| 604 | - $geodir_set_location_session = false; | |
| 605 | - } | |
| 604 | + $geodir_set_location_session = false; | |
| 605 | + } | |
| 606 | 606 | |
| 607 | 607 | |
| 608 | - // now check if there is location parts in the url or not | |
| 609 | -            if (get_option('geodir_add_location_url')) {				
 | |
| 608 | + // now check if there is location parts in the url or not | |
| 609 | +			if (get_option('geodir_add_location_url')) {				
 | |
| 610 | 610 | $default_location = geodir_get_default_location(); | 
| 611 | 611 | |
| 612 | 612 |  				if ($geodir_show_location_url == 'all') {
 | 
| 613 | -                    if (count($geodir_terms) >= 3) {
 | |
| 614 | - $gd_country = urldecode($geodir_terms[0]); | |
| 615 | - $gd_region = urldecode($geodir_terms[1]); | |
| 616 | - $gd_city = urldecode($geodir_terms[2]); | |
| 617 | -                    } else if (count($geodir_terms) >= 2) {
 | |
| 618 | - $gd_country = urldecode($geodir_terms[0]); | |
| 619 | - $gd_region = urldecode($geodir_terms[1]); | |
| 620 | -                    } else if (count($geodir_terms) >= 1) {
 | |
| 621 | - $gd_country = urldecode($geodir_terms[0]); | |
| 622 | - } | |
| 623 | - | |
| 624 | - if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && | |
| 625 | - geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && | |
| 626 | - geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city) | |
| 627 | - ) | |
| 628 | - $is_geodir_location_found = true; | |
| 629 | - | |
| 630 | - // if location has not been found for country , region and city then search for country and region only | |
| 631 | - | |
| 632 | -                    if (!$is_geodir_location_found) {
 | |
| 633 | - $gd_city = ''; | |
| 634 | - if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && | |
| 635 | - geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) | |
| 636 | - ) | |
| 637 | - $is_geodir_location_found = true; | |
| 638 | - | |
| 639 | - } | |
| 640 | - | |
| 641 | - // if location has not been found for country , region then search for country only | |
| 642 | -                    if (!$is_geodir_location_found) {
 | |
| 643 | - $gd_city = ''; | |
| 644 | - $gd_region = ''; | |
| 645 | - if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) | |
| 646 | - $is_geodir_location_found = true; | |
| 647 | - } | |
| 648 | -                } else if ($geodir_show_location_url == 'country_city') {
 | |
| 649 | -                    if (count($geodir_terms) >= 2) {
 | |
| 650 | - $gd_country = urldecode($geodir_terms[0]); | |
| 651 | - $gd_city = urldecode($geodir_terms[1]); | |
| 652 | -                    } else if (count($geodir_terms) >= 1) {
 | |
| 653 | - $gd_country = urldecode($geodir_terms[0]); | |
| 654 | - } | |
| 655 | - | |
| 656 | - if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) | |
| 657 | - $is_geodir_location_found = true; | |
| 658 | - | |
| 659 | - // if location has not been found for country and city then search for country only | |
| 660 | -                    if (!$is_geodir_location_found) {
 | |
| 661 | - $gd_city = ''; | |
| 613 | +					if (count($geodir_terms) >= 3) {
 | |
| 614 | + $gd_country = urldecode($geodir_terms[0]); | |
| 615 | + $gd_region = urldecode($geodir_terms[1]); | |
| 616 | + $gd_city = urldecode($geodir_terms[2]); | |
| 617 | +					} else if (count($geodir_terms) >= 2) {
 | |
| 618 | + $gd_country = urldecode($geodir_terms[0]); | |
| 619 | + $gd_region = urldecode($geodir_terms[1]); | |
| 620 | +					} else if (count($geodir_terms) >= 1) {
 | |
| 621 | + $gd_country = urldecode($geodir_terms[0]); | |
| 622 | + } | |
| 623 | + | |
| 624 | + if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && | |
| 625 | + geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && | |
| 626 | + geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city) | |
| 627 | + ) | |
| 628 | + $is_geodir_location_found = true; | |
| 629 | + | |
| 630 | + // if location has not been found for country , region and city then search for country and region only | |
| 631 | + | |
| 632 | +					if (!$is_geodir_location_found) {
 | |
| 633 | + $gd_city = ''; | |
| 634 | + if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && | |
| 635 | + geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) | |
| 636 | + ) | |
| 637 | + $is_geodir_location_found = true; | |
| 638 | + | |
| 639 | + } | |
| 640 | + | |
| 641 | + // if location has not been found for country , region then search for country only | |
| 642 | +					if (!$is_geodir_location_found) {
 | |
| 643 | + $gd_city = ''; | |
| 644 | + $gd_region = ''; | |
| 645 | + if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) | |
| 646 | + $is_geodir_location_found = true; | |
| 647 | + } | |
| 648 | +				} else if ($geodir_show_location_url == 'country_city') {
 | |
| 649 | +					if (count($geodir_terms) >= 2) {
 | |
| 650 | + $gd_country = urldecode($geodir_terms[0]); | |
| 651 | + $gd_city = urldecode($geodir_terms[1]); | |
| 652 | +					} else if (count($geodir_terms) >= 1) {
 | |
| 653 | + $gd_country = urldecode($geodir_terms[0]); | |
| 654 | + } | |
| 655 | + | |
| 656 | + if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) | |
| 657 | + $is_geodir_location_found = true; | |
| 658 | + | |
| 659 | + // if location has not been found for country and city then search for country only | |
| 660 | +					if (!$is_geodir_location_found) {
 | |
| 661 | + $gd_city = ''; | |
| 662 | 662 | |
| 663 | 663 | if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) | 
| 664 | - $is_geodir_location_found = true; | |
| 665 | - } | |
| 666 | -                }  else if ($geodir_show_location_url == 'region_city') {
 | |
| 667 | -                    if (count($geodir_terms) >= 2) {
 | |
| 668 | - $gd_region = urldecode($geodir_terms[0]); | |
| 669 | - $gd_city = urldecode($geodir_terms[1]); | |
| 670 | -                    } else if (count($geodir_terms) >= 1) {
 | |
| 671 | - $gd_region = urldecode($geodir_terms[0]); | |
| 672 | - } | |
| 673 | - | |
| 674 | - if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) | |
| 675 | - $is_geodir_location_found = true; | |
| 676 | - | |
| 677 | - // if location has not been found for region and city then search for region only | |
| 678 | -                    if (!$is_geodir_location_found) {
 | |
| 679 | - $gd_city = ''; | |
| 664 | + $is_geodir_location_found = true; | |
| 665 | + } | |
| 666 | +				}  else if ($geodir_show_location_url == 'region_city') {
 | |
| 667 | +					if (count($geodir_terms) >= 2) {
 | |
| 668 | + $gd_region = urldecode($geodir_terms[0]); | |
| 669 | + $gd_city = urldecode($geodir_terms[1]); | |
| 670 | +					} else if (count($geodir_terms) >= 1) {
 | |
| 671 | + $gd_region = urldecode($geodir_terms[0]); | |
| 672 | + } | |
| 673 | + | |
| 674 | + if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) | |
| 675 | + $is_geodir_location_found = true; | |
| 676 | + | |
| 677 | + // if location has not been found for region and city then search for region only | |
| 678 | +					if (!$is_geodir_location_found) {
 | |
| 679 | + $gd_city = ''; | |
| 680 | 680 | |
| 681 | 681 | if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)) | 
| 682 | - $is_geodir_location_found = true; | |
| 683 | - } | |
| 684 | -                } else {
 | |
| 685 | - $gd_city = $geodir_terms[0]; | |
| 686 | - | |
| 687 | -                    if (geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) {
 | |
| 688 | - $is_geodir_location_found = true; | |
| 689 | - $gd_region = $default_location->region_slug; | |
| 690 | - $gd_country = $default_location->country_slug; | |
| 691 | - } | |
| 692 | - } | |
| 693 | - // if location still not found then clear location related session variables | |
| 694 | -                if ($is_geodir_location_found && $geodir_set_location_session) {
 | |
| 695 | -                    $gd_session->set('gd_multi_location', 1);
 | |
| 696 | -                    $gd_session->set('gd_country', $gd_country);
 | |
| 697 | -                    $gd_session->set('gd_region', $gd_region);
 | |
| 698 | -                    $gd_session->set('gd_city', $gd_city);
 | |
| 699 | - } | |
| 700 | - | |
| 701 | -                if ($geodir_show_location_url == 'all') {
 | |
| 682 | + $is_geodir_location_found = true; | |
| 683 | + } | |
| 684 | +				} else {
 | |
| 685 | + $gd_city = $geodir_terms[0]; | |
| 686 | + | |
| 687 | +					if (geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) {
 | |
| 688 | + $is_geodir_location_found = true; | |
| 689 | + $gd_region = $default_location->region_slug; | |
| 690 | + $gd_country = $default_location->country_slug; | |
| 691 | + } | |
| 692 | + } | |
| 693 | + // if location still not found then clear location related session variables | |
| 694 | +				if ($is_geodir_location_found && $geodir_set_location_session) {
 | |
| 695 | +					$gd_session->set('gd_multi_location', 1);
 | |
| 696 | +					$gd_session->set('gd_country', $gd_country);
 | |
| 697 | +					$gd_session->set('gd_region', $gd_region);
 | |
| 698 | +					$gd_session->set('gd_city', $gd_city);
 | |
| 699 | + } | |
| 700 | + | |
| 701 | +				if ($geodir_show_location_url == 'all') {
 | |
| 702 | 702 |  				} else if ($geodir_show_location_url == 'country_city') {
 | 
| 703 | 703 | $gd_region = ''; | 
| 704 | 704 |  				} else if ($geodir_show_location_url == 'region_city') {
 | 
| 705 | 705 | $gd_country = ''; | 
| 706 | 706 |  				} else {
 | 
| 707 | 707 | $gd_country = ''; | 
| 708 | - $gd_region = ''; | |
| 708 | + $gd_region = ''; | |
| 709 | + } | |
| 710 | + | |
| 711 | +				if ($is_geodir_location_found) {
 | |
| 712 | + $wp->query_vars['gd_country'] = $gd_country; | |
| 713 | + $wp->query_vars['gd_region'] = $gd_region; | |
| 714 | + $wp->query_vars['gd_city'] = $gd_city; | |
| 715 | +				} else {
 | |
| 716 | + $gd_country = ''; | |
| 717 | + $gd_region = ''; | |
| 718 | + $gd_city = ''; | |
| 709 | 719 | } | 
| 720 | + } | |
| 721 | + | |
| 722 | + $wp->query_vars[$geodir_taxonomy] = $geodir_term; | |
| 723 | + // eliminate location related terms from taxonomy term | |
| 724 | + if ($gd_country != '') | |
| 725 | +				$wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
 | |
| 726 | + | |
| 727 | + if ($gd_region != '') | |
| 728 | +				$wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
 | |
| 710 | 729 | |
| 711 | -                if ($is_geodir_location_found) {
 | |
| 712 | - $wp->query_vars['gd_country'] = $gd_country; | |
| 713 | - $wp->query_vars['gd_region'] = $gd_region; | |
| 714 | - $wp->query_vars['gd_city'] = $gd_city; | |
| 715 | -                } else {
 | |
| 716 | - $gd_country = ''; | |
| 717 | - $gd_region = ''; | |
| 718 | - $gd_city = ''; | |
| 719 | - } | |
| 720 | - } | |
| 721 | - | |
| 722 | - $wp->query_vars[$geodir_taxonomy] = $geodir_term; | |
| 723 | - // eliminate location related terms from taxonomy term | |
| 724 | - if ($gd_country != '') | |
| 725 | -                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
 | |
| 726 | - | |
| 727 | - if ($gd_region != '') | |
| 728 | -                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
 | |
| 729 | - | |
| 730 | - if ($gd_city != '') | |
| 731 | -                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
 | |
| 732 | - | |
| 733 | - | |
| 734 | -            $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
 | |
| 735 | -            $wp->query_vars[$geodir_taxonomy] = str_replace('//', '', $wp->query_vars[$geodir_taxonomy]);
 | |
| 736 | - | |
| 737 | - $wp->query_vars[$geodir_taxonomy] = trim($wp->query_vars[$geodir_taxonomy], '/'); | |
| 738 | - | |
| 739 | -            if ($wp->query_vars[$geodir_taxonomy] == '') {
 | |
| 740 | - unset($wp->query_vars[$geodir_taxonomy]); | |
| 741 | -            } else {
 | |
| 742 | -                if (!$is_geodir_taxonomy_term) {
 | |
| 743 | -                    foreach ($wp->query_vars as $key => $vars) {
 | |
| 744 | - unset($wp->query_vars[$key]); | |
| 745 | - } | |
| 746 | - $wp->query_vars['error'] = '404'; | |
| 747 | - } | |
| 748 | - } | |
| 749 | - } | |
| 750 | - } | |
| 730 | + if ($gd_city != '') | |
| 731 | +				$wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
 | |
| 732 | + | |
| 733 | + | |
| 734 | +			$wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
 | |
| 735 | +			$wp->query_vars[$geodir_taxonomy] = str_replace('//', '', $wp->query_vars[$geodir_taxonomy]);
 | |
| 736 | + | |
| 737 | + $wp->query_vars[$geodir_taxonomy] = trim($wp->query_vars[$geodir_taxonomy], '/'); | |
| 738 | + | |
| 739 | +			if ($wp->query_vars[$geodir_taxonomy] == '') {
 | |
| 740 | + unset($wp->query_vars[$geodir_taxonomy]); | |
| 741 | +			} else {
 | |
| 742 | +				if (!$is_geodir_taxonomy_term) {
 | |
| 743 | +					foreach ($wp->query_vars as $key => $vars) {
 | |
| 744 | + unset($wp->query_vars[$key]); | |
| 745 | + } | |
| 746 | + $wp->query_vars['error'] = '404'; | |
| 747 | + } | |
| 748 | + } | |
| 749 | + } | |
| 750 | + } | |
| 751 | 751 | |
| 752 | 752 | // Unset location session if gd page and location not set. | 
| 753 | 753 |  	if (isset($wp->query_vars['gd_is_geodir_page']) && !isset($wp->query_vars['gd_country'])) {
 | 
| 754 | 754 |  		$gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
 | 
| 755 | 755 | } | 
| 756 | 756 | |
| 757 | -    if ($gd_session->get('gd_multi_location') == 1) {
 | |
| 758 | -        $wp->query_vars['gd_country'] = $gd_session->get('gd_country');
 | |
| 759 | -        $wp->query_vars['gd_region'] = $gd_session->get('gd_region');
 | |
| 760 | -        $wp->query_vars['gd_city'] = $gd_session->get('gd_city');
 | |
| 761 | - } | |
| 757 | +	if ($gd_session->get('gd_multi_location') == 1) {
 | |
| 758 | +		$wp->query_vars['gd_country'] = $gd_session->get('gd_country');
 | |
| 759 | +		$wp->query_vars['gd_region'] = $gd_session->get('gd_region');
 | |
| 760 | +		$wp->query_vars['gd_city'] = $gd_session->get('gd_city');
 | |
| 761 | + } | |
| 762 | 762 | |
| 763 | - // now check if there is location parts in the url or not | |
| 764 | -    if (get_option('geodir_add_location_url')) {        
 | |
| 763 | + // now check if there is location parts in the url or not | |
| 764 | +	if (get_option('geodir_add_location_url')) {        
 | |
| 765 | 765 |  		if ($geodir_show_location_url == 'all') {
 | 
| 766 | 766 |  		} else if ($geodir_show_location_url == 'country_city') {
 | 
| 767 | 767 | if (isset($wp->query_vars['gd_region'])) | 
| 768 | - $wp->query_vars['gd_region'] = ''; | |
| 768 | + $wp->query_vars['gd_region'] = ''; | |
| 769 | 769 |  		} else if ($geodir_show_location_url == 'region_city') {
 | 
| 770 | 770 | if (isset($wp->query_vars['gd_country'])) | 
| 771 | - $wp->query_vars['gd_country'] = ''; | |
| 771 | + $wp->query_vars['gd_country'] = ''; | |
| 772 | 772 |  		} else {
 | 
| 773 | 773 | if (isset($wp->query_vars['gd_country'])) | 
| 774 | - $wp->query_vars['gd_country'] = ''; | |
| 774 | + $wp->query_vars['gd_country'] = ''; | |
| 775 | 775 | |
| 776 | - if (isset($wp->query_vars['gd_region'])) | |
| 777 | - $wp->query_vars['gd_region'] = ''; | |
| 776 | + if (isset($wp->query_vars['gd_region'])) | |
| 777 | + $wp->query_vars['gd_region'] = ''; | |
| 778 | 778 | } | 
| 779 | -    } else {
 | |
| 780 | - if (isset($wp->query_vars['gd_country'])) | |
| 781 | - $wp->query_vars['gd_country'] = ''; | |
| 779 | +	} else {
 | |
| 780 | + if (isset($wp->query_vars['gd_country'])) | |
| 781 | + $wp->query_vars['gd_country'] = ''; | |
| 782 | 782 | |
| 783 | - if (isset($wp->query_vars['gd_region'])) | |
| 784 | - $wp->query_vars['gd_region'] = ''; | |
| 783 | + if (isset($wp->query_vars['gd_region'])) | |
| 784 | + $wp->query_vars['gd_region'] = ''; | |
| 785 | 785 | |
| 786 | - if (isset($wp->query_vars['gd_city'])) | |
| 787 | - $wp->query_vars['gd_city'] = ''; | |
| 788 | - } | |
| 786 | + if (isset($wp->query_vars['gd_city'])) | |
| 787 | + $wp->query_vars['gd_city'] = ''; | |
| 788 | + } | |
| 789 | 789 | } | 
| 790 | 790 | |
| 791 | 791 | /** | 
| @@ -799,24 +799,24 @@ discard block | ||
| 799 | 799 | */ | 
| 800 | 800 | function geodir_custom_post_status() | 
| 801 | 801 |  {
 | 
| 802 | - // Virtual Page Status | |
| 803 | -    register_post_status('virtual', array(
 | |
| 804 | -        'label' => _x('Virtual', 'page', 'geodirectory'),
 | |
| 805 | - 'public' => true, | |
| 806 | - 'exclude_from_search' => true, | |
| 807 | - 'show_in_admin_all_list' => true, | |
| 808 | - 'show_in_admin_status_list' => true, | |
| 809 | -        'label_count' => _n_noop('Virtual <span class="count">(%s)</span>', 'Virtual <span class="count">(%s)</span>', 'geodirectory'),
 | |
| 810 | - )); | |
| 811 | - | |
| 812 | - /** | |
| 813 | - * Called after we register the custom post status 'Virtual'. | |
| 814 | - * | |
| 815 | - * Can be use to add more post statuses. | |
| 816 | - * | |
| 817 | - * @since 1.0.0 | |
| 818 | - */ | |
| 819 | -    do_action('geodir_custom_post_status');
 | |
| 802 | + // Virtual Page Status | |
| 803 | +	register_post_status('virtual', array(
 | |
| 804 | +		'label' => _x('Virtual', 'page', 'geodirectory'),
 | |
| 805 | + 'public' => true, | |
| 806 | + 'exclude_from_search' => true, | |
| 807 | + 'show_in_admin_all_list' => true, | |
| 808 | + 'show_in_admin_status_list' => true, | |
| 809 | +		'label_count' => _n_noop('Virtual <span class="count">(%s)</span>', 'Virtual <span class="count">(%s)</span>', 'geodirectory'),
 | |
| 810 | + )); | |
| 811 | + | |
| 812 | + /** | |
| 813 | + * Called after we register the custom post status 'Virtual'. | |
| 814 | + * | |
| 815 | + * Can be use to add more post statuses. | |
| 816 | + * | |
| 817 | + * @since 1.0.0 | |
| 818 | + */ | |
| 819 | +	do_action('geodir_custom_post_status');
 | |
| 820 | 820 | } | 
| 821 | 821 | |
| 822 | 822 | /** | 
| @@ -831,7 +831,7 @@ discard block | ||
| 831 | 831 | */ | 
| 832 | 832 | function geodir_get_term_link($termlink, $term, $taxonomy) | 
| 833 | 833 |  {
 | 
| 834 | - return geodir_term_link($termlink, $term, $taxonomy); // taxonomy_functions.php | |
| 834 | + return geodir_term_link($termlink, $term, $taxonomy); // taxonomy_functions.php | |
| 835 | 835 | } | 
| 836 | 836 | |
| 837 | 837 | /** | 
| @@ -845,7 +845,7 @@ discard block | ||
| 845 | 845 | */ | 
| 846 | 846 | function geodir_get_posttype_link($link, $post_type) | 
| 847 | 847 |  {
 | 
| 848 | - return geodir_posttype_link($link, $post_type); // taxonomy_functions.php | |
| 848 | + return geodir_posttype_link($link, $post_type); // taxonomy_functions.php | |
| 849 | 849 | } | 
| 850 | 850 | |
| 851 | 851 | /** | 
| @@ -860,13 +860,13 @@ discard block | ||
| 860 | 860 | */ | 
| 861 | 861 | function exclude_from_wp_list_pages($exclude_array) | 
| 862 | 862 |  {
 | 
| 863 | - $pages_ids = array(); | |
| 864 | -    $pages_array = get_posts(array('post_type' => 'page', 'post_status' => 'virtual'));
 | |
| 865 | -    foreach ($pages_array as $page) {
 | |
| 866 | - $pages_ids[] = $page->ID; | |
| 867 | - } | |
| 868 | - $exclude_array = $exclude_array + $pages_ids; | |
| 869 | - return $exclude_array; | |
| 863 | + $pages_ids = array(); | |
| 864 | +	$pages_array = get_posts(array('post_type' => 'page', 'post_status' => 'virtual'));
 | |
| 865 | +	foreach ($pages_array as $page) {
 | |
| 866 | + $pages_ids[] = $page->ID; | |
| 867 | + } | |
| 868 | + $exclude_array = $exclude_array + $pages_ids; | |
| 869 | + return $exclude_array; | |
| 870 | 870 | } | 
| 871 | 871 | |
| 872 | 872 | /** | 
| @@ -879,8 +879,8 @@ discard block | ||
| 879 | 879 | */ | 
| 880 | 880 | function geodir_exclude_page($query) | 
| 881 | 881 |  {
 | 
| 882 | -    add_filter('posts_where', 'geodir_exclude_page_where', 100);
 | |
| 883 | - return $query; | |
| 882 | +	add_filter('posts_where', 'geodir_exclude_page_where', 100);
 | |
| 883 | + return $query; | |
| 884 | 884 | } | 
| 885 | 885 | |
| 886 | 886 | /** | 
| @@ -895,11 +895,11 @@ discard block | ||
| 895 | 895 | */ | 
| 896 | 896 | function geodir_exclude_page_where($where) | 
| 897 | 897 |  {
 | 
| 898 | - global $wpdb; | |
| 899 | - if (is_admin()) | |
| 900 | - $where .= " AND $wpdb->posts.post_status != 'virtual'"; | |
| 898 | + global $wpdb; | |
| 899 | + if (is_admin()) | |
| 900 | + $where .= " AND $wpdb->posts.post_status != 'virtual'"; | |
| 901 | 901 | |
| 902 | - return $where; | |
| 902 | + return $where; | |
| 903 | 903 | } | 
| 904 | 904 | |
| 905 | 905 | /** | 
| @@ -914,20 +914,20 @@ discard block | ||
| 914 | 914 | * @return mixed The taxonomy option value. | 
| 915 | 915 | */ | 
| 916 | 916 |  function geodir_wpseo_taxonomy_meta( $value, $option = '' ) {
 | 
| 917 | - global $wp_query; | |
| 917 | + global $wp_query; | |
| 918 | 918 | |
| 919 | -    if ( !empty( $value ) && ( is_category() || is_tax() ) ) {
 | |
| 920 | - $term = $wp_query->get_queried_object(); | |
| 919 | +	if ( !empty( $value ) && ( is_category() || is_tax() ) ) {
 | |
| 920 | + $term = $wp_query->get_queried_object(); | |
| 921 | 921 | |
| 922 | -        if ( !empty( $term->term_id ) && !empty( $term->taxonomy ) && isset( $value[$term->taxonomy][$term->term_id] ) && in_array( str_replace( 'category', '', $term->taxonomy ), geodir_get_posttypes() ) ) {
 | |
| 923 | - $image = geodir_get_default_catimage( $term->term_id, str_replace( 'category', '', $term->taxonomy ) ); | |
| 922 | +		if ( !empty( $term->term_id ) && !empty( $term->taxonomy ) && isset( $value[$term->taxonomy][$term->term_id] ) && in_array( str_replace( 'category', '', $term->taxonomy ), geodir_get_posttypes() ) ) {
 | |
| 923 | + $image = geodir_get_default_catimage( $term->term_id, str_replace( 'category', '', $term->taxonomy ) ); | |
| 924 | 924 | |
| 925 | -            if ( !empty( $image['src'] ) ) {
 | |
| 926 | - $value[$term->taxonomy][$term->term_id]['wpseo_twitter-image'] = $image['src']; | |
| 927 | - $value[$term->taxonomy][$term->term_id]['wpseo_opengraph-image'] = $image['src']; | |
| 928 | - } | |
| 929 | - } | |
| 930 | - } | |
| 931 | - return $value; | |
| 925 | +			if ( !empty( $image['src'] ) ) {
 | |
| 926 | + $value[$term->taxonomy][$term->term_id]['wpseo_twitter-image'] = $image['src']; | |
| 927 | + $value[$term->taxonomy][$term->term_id]['wpseo_opengraph-image'] = $image['src']; | |
| 928 | + } | |
| 929 | + } | |
| 930 | + } | |
| 931 | + return $value; | |
| 932 | 932 | } | 
| 933 | 933 | add_filter( 'option_wpseo_taxonomy_meta', 'geodir_wpseo_taxonomy_meta', 10, 2 ); | 
| @@ -151,8 +151,7 @@ discard block | ||
| 151 | 151 | * @since 1.5.7 | 
| 152 | 152 | * | 
| 153 | 153 | * @param string|array $key Session key. | 
| 154 | - * @param integer $value Session variable. | |
| 155 | - * @return string Session variable. | |
| 154 | + * @return boolean Session variable. | |
| 156 | 155 | */ | 
| 157 | 156 |  	public function un_set( $key ) { | 
| 158 | 157 |  		if ( empty( $key ) ) { | 
| @@ -188,8 +187,7 @@ discard block | ||
| 188 | 187 | * @since 1.5.7 | 
| 189 | 188 | * | 
| 190 | 189 | * @param string $key Session key. | 
| 191 | - * @param integer $value Session variable. | |
| 192 | - * @return string Session variable. | |
| 190 | + * @return boolean Session variable. | |
| 193 | 191 | */ | 
| 194 | 192 |  	public function is_set( $key ) { | 
| 195 | 193 | $key = sanitize_key( $key ); | 
| @@ -1,6 +1,8 @@ | ||
| 1 | 1 | <?php | 
| 2 | 2 | // Exit if accessed directly. | 
| 3 | -if (!defined( 'ABSPATH' ) ) exit; | |
| 3 | +if (!defined( 'ABSPATH' ) ) { | |
| 4 | + exit; | |
| 5 | +} | |
| 4 | 6 | |
| 5 | 7 | /** | 
| 6 | 8 | * Geodir_Session Class. | 
| @@ -1,6 +1,6 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | // Exit if accessed directly. | 
| 3 | -if (!defined( 'ABSPATH' ) ) exit; | |
| 3 | +if (!defined('ABSPATH')) exit; | |
| 4 | 4 | |
| 5 | 5 | /** | 
| 6 | 6 | * Geodir_Session Class. | 
| @@ -46,36 +46,36 @@ discard block | ||
| 46 | 46 |  	public function __construct() { | 
| 47 | 47 | $this->use_php_sessions = $this->use_php_sessions(); | 
| 48 | 48 | |
| 49 | -		if ( $this->use_php_sessions ) { | |
| 50 | -			if ( is_multisite() ) { | |
| 51 | - $this->prefix = '_' . get_current_blog_id(); | |
| 49 | +		if ($this->use_php_sessions) { | |
| 50 | +			if (is_multisite()) { | |
| 51 | + $this->prefix = '_'.get_current_blog_id(); | |
| 52 | 52 | } | 
| 53 | 53 | |
| 54 | 54 | // Use PHP SESSION (must be enabled via the GEODIR_USE_PHP_SESSIONS constant) | 
| 55 | - add_action( 'init', array( $this, 'maybe_start_session' ), -2 ); | |
| 55 | +			add_action('init', array($this, 'maybe_start_session'), -2); | |
| 56 | 56 |  		} else { | 
| 57 | 57 | // Use WP_Session (default) | 
| 58 | -			if ( !defined( 'WP_SESSION_COOKIE' ) ) { | |
| 59 | - define( 'WP_SESSION_COOKIE', 'geodir_wp_session' ); | |
| 58 | +			if (!defined('WP_SESSION_COOKIE')) { | |
| 59 | +				define('WP_SESSION_COOKIE', 'geodir_wp_session'); | |
| 60 | 60 | } | 
| 61 | 61 | |
| 62 | -			if ( !class_exists( 'Recursive_ArrayAccess' ) ) { | |
| 63 | - require_once GEODIRECTORY_PLUGIN_DIR . 'geodirectory-functions/wp-session/class-recursive-arrayaccess.php'; | |
| 62 | +			if (!class_exists('Recursive_ArrayAccess')) { | |
| 63 | + require_once GEODIRECTORY_PLUGIN_DIR.'geodirectory-functions/wp-session/class-recursive-arrayaccess.php'; | |
| 64 | 64 | } | 
| 65 | 65 | |
| 66 | -			if ( !class_exists( 'WP_Session' ) ) { | |
| 67 | - require_once GEODIRECTORY_PLUGIN_DIR . 'geodirectory-functions/wp-session/class-wp-session.php'; | |
| 68 | - require_once GEODIRECTORY_PLUGIN_DIR . 'geodirectory-functions/wp-session/wp-session.php'; | |
| 66 | +			if (!class_exists('WP_Session')) { | |
| 67 | + require_once GEODIRECTORY_PLUGIN_DIR.'geodirectory-functions/wp-session/class-wp-session.php'; | |
| 68 | + require_once GEODIRECTORY_PLUGIN_DIR.'geodirectory-functions/wp-session/wp-session.php'; | |
| 69 | 69 | } | 
| 70 | 70 | |
| 71 | - add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 ); | |
| 72 | - add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 ); | |
| 71 | +			add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999); | |
| 72 | +			add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999); | |
| 73 | 73 | } | 
| 74 | 74 | |
| 75 | -		if ( empty( $this->session ) && ! $this->use_php_sessions ) { | |
| 76 | - add_action( 'plugins_loaded', array( $this, 'init' ), -1 ); | |
| 75 | +		if (empty($this->session) && !$this->use_php_sessions) { | |
| 76 | +			add_action('plugins_loaded', array($this, 'init'), -1); | |
| 77 | 77 |  		} else { | 
| 78 | - add_action( 'init', array( $this, 'init' ), -1 ); | |
| 78 | +			add_action('init', array($this, 'init'), -1); | |
| 79 | 79 | } | 
| 80 | 80 | } | 
| 81 | 81 | |
| @@ -87,8 +87,8 @@ discard block | ||
| 87 | 87 | * @return void | 
| 88 | 88 | */ | 
| 89 | 89 |  	public function init() { | 
| 90 | -		if ( $this->use_php_sessions ) { | |
| 91 | - $this->session = isset( $_SESSION['gd' . $this->prefix ] ) && is_array( $_SESSION['gd' . $this->prefix ] ) ? $_SESSION['gd' . $this->prefix ] : array(); | |
| 90 | +		if ($this->use_php_sessions) { | |
| 91 | + $this->session = isset($_SESSION['gd'.$this->prefix]) && is_array($_SESSION['gd'.$this->prefix]) ? $_SESSION['gd'.$this->prefix] : array(); | |
| 92 | 92 |  		} else { | 
| 93 | 93 | $this->session = WP_Session::get_instance(); | 
| 94 | 94 | } | 
| @@ -115,9 +115,9 @@ discard block | ||
| 115 | 115 | * @param string $key Session key | 
| 116 | 116 | * @return string Session variable | 
| 117 | 117 | */ | 
| 118 | -	public function get( $key ) { | |
| 119 | - $key = sanitize_key( $key ); | |
| 120 | - return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : false; | |
| 118 | +	public function get($key) { | |
| 119 | + $key = sanitize_key($key); | |
| 120 | + return isset($this->session[$key]) ? maybe_unserialize($this->session[$key]) : false; | |
| 121 | 121 | } | 
| 122 | 122 | |
| 123 | 123 | /** | 
| @@ -129,20 +129,20 @@ discard block | ||
| 129 | 129 | * @param integer $value Session variable | 
| 130 | 130 | * @return string Session variable | 
| 131 | 131 | */ | 
| 132 | -	public function set( $key, $value ) { | |
| 133 | - $key = sanitize_key( $key ); | |
| 132 | +	public function set($key, $value) { | |
| 133 | + $key = sanitize_key($key); | |
| 134 | 134 | |
| 135 | -		if ( is_array( $value ) ) { | |
| 136 | - $this->session[ $key ] = maybe_serialize( $value ); | |
| 135 | +		if (is_array($value)) { | |
| 136 | + $this->session[$key] = maybe_serialize($value); | |
| 137 | 137 |  		} else { | 
| 138 | - $this->session[ $key ] = $value; | |
| 138 | + $this->session[$key] = $value; | |
| 139 | 139 | } | 
| 140 | 140 | |
| 141 | -		if ( $this->use_php_sessions ) { | |
| 142 | - $_SESSION['gd' . $this->prefix ] = $this->session; | |
| 141 | +		if ($this->use_php_sessions) { | |
| 142 | + $_SESSION['gd'.$this->prefix] = $this->session; | |
| 143 | 143 | } | 
| 144 | 144 | |
| 145 | - return $this->session[ $key ]; | |
| 145 | + return $this->session[$key]; | |
| 146 | 146 | } | 
| 147 | 147 | |
| 148 | 148 | /** | 
| @@ -154,29 +154,29 @@ discard block | ||
| 154 | 154 | * @param integer $value Session variable. | 
| 155 | 155 | * @return string Session variable. | 
| 156 | 156 | */ | 
| 157 | -	public function un_set( $key ) { | |
| 158 | -		if ( empty( $key ) ) { | |
| 157 | +	public function un_set($key) { | |
| 158 | +		if (empty($key)) { | |
| 159 | 159 | return false; | 
| 160 | 160 | } | 
| 161 | 161 | |
| 162 | -		if ( is_array( $key ) ) { | |
| 162 | +		if (is_array($key)) { | |
| 163 | 163 |  			foreach ($key as $index) { | 
| 164 | - $index = sanitize_key( $index ); | |
| 164 | + $index = sanitize_key($index); | |
| 165 | 165 | |
| 166 | -				if ( $index && isset( $this->session[ $index ] ) ) { | |
| 167 | - unset( $this->session[ $index ] ); | |
| 166 | +				if ($index && isset($this->session[$index])) { | |
| 167 | + unset($this->session[$index]); | |
| 168 | 168 | } | 
| 169 | 169 | } | 
| 170 | 170 |  		} else { | 
| 171 | - $key = sanitize_key( $key ); | |
| 171 | + $key = sanitize_key($key); | |
| 172 | 172 | |
| 173 | -			if ( isset( $this->session[ $key ] ) ) { | |
| 174 | - unset( $this->session[ $key ] ); | |
| 173 | +			if (isset($this->session[$key])) { | |
| 174 | + unset($this->session[$key]); | |
| 175 | 175 | } | 
| 176 | 176 | } | 
| 177 | 177 | |
| 178 | -		if ( $this->use_php_sessions ) { | |
| 179 | - $_SESSION['gd' . $this->prefix ] = $this->session; | |
| 178 | +		if ($this->use_php_sessions) { | |
| 179 | + $_SESSION['gd'.$this->prefix] = $this->session; | |
| 180 | 180 | } | 
| 181 | 181 | |
| 182 | 182 | return true; | 
| @@ -191,14 +191,14 @@ discard block | ||
| 191 | 191 | * @param integer $value Session variable. | 
| 192 | 192 | * @return string Session variable. | 
| 193 | 193 | */ | 
| 194 | -	public function is_set( $key ) { | |
| 195 | - $key = sanitize_key( $key ); | |
| 194 | +	public function is_set($key) { | |
| 195 | + $key = sanitize_key($key); | |
| 196 | 196 | |
| 197 | -		if ( empty( $key ) ) { | |
| 197 | +		if (empty($key)) { | |
| 198 | 198 | return false; | 
| 199 | 199 | } | 
| 200 | 200 | |
| 201 | -		if ( isset( $this->session[ $key ] ) ) { | |
| 201 | +		if (isset($this->session[$key])) { | |
| 202 | 202 | return true; | 
| 203 | 203 | } | 
| 204 | 204 | |
| @@ -213,8 +213,8 @@ discard block | ||
| 213 | 213 | * @param int $exp Default expiration (1 hour) | 
| 214 | 214 | * @return int | 
| 215 | 215 | */ | 
| 216 | -	public function set_expiration_variant_time( $exp ) { | |
| 217 | - return ( 30 * 60 * 23 ); | |
| 216 | +	public function set_expiration_variant_time($exp) { | |
| 217 | + return (30 * 60 * 23); | |
| 218 | 218 | } | 
| 219 | 219 | |
| 220 | 220 | /** | 
| @@ -225,8 +225,8 @@ discard block | ||
| 225 | 225 | * @param int $exp Default expiration (1 hour) | 
| 226 | 226 | * @return int | 
| 227 | 227 | */ | 
| 228 | -	public function set_expiration_time( $exp ) { | |
| 229 | - return ( 30 * 60 * 24 ); | |
| 228 | +	public function set_expiration_time($exp) { | |
| 229 | + return (30 * 60 * 24); | |
| 230 | 230 | } | 
| 231 | 231 | |
| 232 | 232 | /** | 
| @@ -244,18 +244,18 @@ discard block | ||
| 244 | 244 | $ret = false; | 
| 245 | 245 | |
| 246 | 246 | // If the database variable is already set, no need to run autodetection | 
| 247 | - $geodir_use_php_sessions = (bool)get_option( 'geodir_use_php_sessions' ); | |
| 247 | +		$geodir_use_php_sessions = (bool) get_option('geodir_use_php_sessions'); | |
| 248 | 248 | |
| 249 | -		if (!$geodir_use_php_sessions ) { | |
| 249 | +		if (!$geodir_use_php_sessions) { | |
| 250 | 250 | // Attempt to detect if the server supports PHP sessions | 
| 251 | -			if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) { | |
| 252 | - $this->set( 'geodir_use_php_sessions', 1 ); | |
| 251 | +			if (function_exists('session_start') && !ini_get('safe_mode')) { | |
| 252 | +				$this->set('geodir_use_php_sessions', 1); | |
| 253 | 253 | |
| 254 | -				if ( $this->get( 'geodir_use_php_sessions' ) ) { | |
| 254 | +				if ($this->get('geodir_use_php_sessions')) { | |
| 255 | 255 | $ret = true; | 
| 256 | 256 | |
| 257 | 257 | // Set the database option | 
| 258 | - update_option( 'geodir_use_php_sessions', true ); | |
| 258 | +					update_option('geodir_use_php_sessions', true); | |
| 259 | 259 | } | 
| 260 | 260 | } | 
| 261 | 261 |  		} else { | 
| @@ -263,20 +263,20 @@ discard block | ||
| 263 | 263 | } | 
| 264 | 264 | |
| 265 | 265 | // Enable or disable PHP Sessions based on the GEODIR_USE_PHP_SESSIONS constant | 
| 266 | -		if ( defined( 'GEODIR_USE_PHP_SESSIONS' ) && GEODIR_USE_PHP_SESSIONS ) { | |
| 266 | +		if (defined('GEODIR_USE_PHP_SESSIONS') && GEODIR_USE_PHP_SESSIONS) { | |
| 267 | 267 | $ret = true; | 
| 268 | -		} else if ( defined( 'GEODIR_USE_PHP_SESSIONS' ) && ! GEODIR_USE_PHP_SESSIONS ) { | |
| 268 | +		} else if (defined('GEODIR_USE_PHP_SESSIONS') && !GEODIR_USE_PHP_SESSIONS) { | |
| 269 | 269 | $ret = false; | 
| 270 | 270 | } | 
| 271 | 271 | |
| 272 | - return (bool) apply_filters( 'geodir_use_php_sessions', $ret ); | |
| 272 | +		return (bool) apply_filters('geodir_use_php_sessions', $ret); | |
| 273 | 273 | } | 
| 274 | 274 | |
| 275 | 275 | /** | 
| 276 | 276 | * Starts a new session if one hasn't started yet. | 
| 277 | 277 | */ | 
| 278 | 278 |  	public function maybe_start_session() { | 
| 279 | -		if ( !session_id() && !headers_sent() ) { | |
| 279 | +		if (!session_id() && !headers_sent()) { | |
| 280 | 280 | session_start(); | 
| 281 | 281 | } | 
| 282 | 282 | } | 
| @@ -290,11 +290,11 @@ discard block | ||
| 290 | 290 |  	public function use_cart_cookie() { | 
| 291 | 291 | $ret = true; | 
| 292 | 292 | |
| 293 | -		if ( defined( 'GEODIR_USE_CART_COOKIE' ) && ! GEODIR_USE_CART_COOKIE ) { | |
| 293 | +		if (defined('GEODIR_USE_CART_COOKIE') && !GEODIR_USE_CART_COOKIE) { | |
| 294 | 294 | $ret = false; | 
| 295 | 295 | } | 
| 296 | 296 | |
| 297 | - return (bool) apply_filters( 'geodir_use_cart_cookie', $ret ); | |
| 297 | +		return (bool) apply_filters('geodir_use_cart_cookie', $ret); | |
| 298 | 298 | } | 
| 299 | 299 | } | 
| 300 | 300 | |
| @@ -46,7 +46,6 @@ discard block | ||
| 46 | 46 | * @since 1.0.0 | 
| 47 | 47 | * @since 1.5.2 Added TERRAIN map type. | 
| 48 | 48 | * | 
| 49 | - * @param string $value Input value to validate measurement. | |
| 50 | 49 | * @return string The measurement valud in valid format. | 
| 51 | 50 | */ | 
| 52 | 51 | function gdsc_validate_map_args($params) | 
| @@ -95,7 +94,7 @@ discard block | ||
| 95 | 94 | * @param mixed $in The variable to check | 
| 96 | 95 | * @param bool $strict If set to false, consider everything that is not false to be true. | 
| 97 | 96 | * | 
| 98 | - * @return bool The boolean equivalent or null | |
| 97 | + * @return null|boolean The boolean equivalent or null | |
| 99 | 98 | */ | 
| 100 | 99 | function gdsc_to_bool_val($in, $strict = false) | 
| 101 | 100 |  { | 
| @@ -9,7 +9,7 @@ discard block | ||
| 9 | 9 | |
| 10 | 10 | // If this file is called directly, abort. | 
| 11 | 11 |  if (!defined('WPINC')) { | 
| 12 | - die; | |
| 12 | + die; | |
| 13 | 13 | } | 
| 14 | 14 | |
| 15 | 15 | /** | 
| @@ -22,22 +22,22 @@ discard block | ||
| 22 | 22 | */ | 
| 23 | 23 | function gdsc_validate_measurements($value) | 
| 24 | 24 |  { | 
| 25 | -    if ((strlen($value) - 1) == strpos(trim($value), '%')) { | |
| 26 | - // $value is entered as a percent, so it can't be less than 0 or more than 100 | |
| 27 | -        $value = preg_replace('/\D/', '', $value); | |
| 28 | -        if (100 < $value) { | |
| 29 | - $value = 100; | |
| 30 | - } | |
| 31 | - // Re-add the percent symbol | |
| 32 | - $value = $value . '%'; | |
| 33 | -    } elseif ((strlen($value) - 2) == strpos(trim($value), 'px')) { | |
| 34 | - // Get the absint & re-add the 'px' | |
| 35 | -        $value = preg_replace('/\D/', '', $value) . 'px'; | |
| 36 | -    } else { | |
| 37 | -        $value = preg_replace('/\D/', '', $value); | |
| 38 | - } | |
| 25 | +	if ((strlen($value) - 1) == strpos(trim($value), '%')) { | |
| 26 | + // $value is entered as a percent, so it can't be less than 0 or more than 100 | |
| 27 | +		$value = preg_replace('/\D/', '', $value); | |
| 28 | +		if (100 < $value) { | |
| 29 | + $value = 100; | |
| 30 | + } | |
| 31 | + // Re-add the percent symbol | |
| 32 | + $value = $value . '%'; | |
| 33 | +	} elseif ((strlen($value) - 2) == strpos(trim($value), 'px')) { | |
| 34 | + // Get the absint & re-add the 'px' | |
| 35 | +		$value = preg_replace('/\D/', '', $value) . 'px'; | |
| 36 | +	} else { | |
| 37 | +		$value = preg_replace('/\D/', '', $value); | |
| 38 | + } | |
| 39 | 39 | |
| 40 | - return $value; | |
| 40 | + return $value; | |
| 41 | 41 | } | 
| 42 | 42 | |
| 43 | 43 | /** | 
| @@ -52,35 +52,35 @@ discard block | ||
| 52 | 52 | function gdsc_validate_map_args($params) | 
| 53 | 53 |  { | 
| 54 | 54 | |
| 55 | - $params['width'] = gdsc_validate_measurements($params['width']); | |
| 56 | - $params['height'] = gdsc_validate_measurements($params['height']); | |
| 55 | + $params['width'] = gdsc_validate_measurements($params['width']); | |
| 56 | + $params['height'] = gdsc_validate_measurements($params['height']); | |
| 57 | 57 | |
| 58 | - // Only accept our 4 maptypes. Otherwise, revert to the default. | |
| 59 | -    if (!(in_array(geodir_strtoupper($params['maptype']), array('HYBRID', 'SATELLITE', 'ROADMAP', 'TERRAIN')))) { | |
| 60 | - $params['maptype'] = 'ROADMAP'; | |
| 61 | -    } else { | |
| 62 | - $params['maptype'] = geodir_strtoupper($params['maptype']); | |
| 63 | - } | |
| 58 | + // Only accept our 4 maptypes. Otherwise, revert to the default. | |
| 59 | +	if (!(in_array(geodir_strtoupper($params['maptype']), array('HYBRID', 'SATELLITE', 'ROADMAP', 'TERRAIN')))) { | |
| 60 | + $params['maptype'] = 'ROADMAP'; | |
| 61 | +	} else { | |
| 62 | + $params['maptype'] = geodir_strtoupper($params['maptype']); | |
| 63 | + } | |
| 64 | 64 | |
| 65 | - // Zoom accepts a value between 1 and 19 | |
| 66 | - $params['zoom'] = absint($params['zoom']); | |
| 67 | -    if (19 < $params['zoom']) { | |
| 68 | - $params['zoom'] = '19'; | |
| 69 | - } | |
| 70 | -    if (0 == $params['zoom']) { | |
| 71 | - $params['zoom'] = '1'; | |
| 72 | - } | |
| 65 | + // Zoom accepts a value between 1 and 19 | |
| 66 | + $params['zoom'] = absint($params['zoom']); | |
| 67 | +	if (19 < $params['zoom']) { | |
| 68 | + $params['zoom'] = '19'; | |
| 69 | + } | |
| 70 | +	if (0 == $params['zoom']) { | |
| 71 | + $params['zoom'] = '1'; | |
| 72 | + } | |
| 73 | 73 | |
| 74 | - // Child_collapse must be boolean | |
| 75 | - $params['child_collapse'] = gdsc_to_bool_val($params['child_collapse']); | |
| 74 | + // Child_collapse must be boolean | |
| 75 | + $params['child_collapse'] = gdsc_to_bool_val($params['child_collapse']); | |
| 76 | 76 | |
| 77 | - // Scrollwheel must be boolean | |
| 78 | - $params['scrollwheel'] = gdsc_to_bool_val($params['scrollwheel']); | |
| 77 | + // Scrollwheel must be boolean | |
| 78 | + $params['scrollwheel'] = gdsc_to_bool_val($params['scrollwheel']); | |
| 79 | 79 | |
| 80 | - // Scrollwheel must be boolean | |
| 81 | - $params['autozoom'] = gdsc_to_bool_val($params['autozoom']); | |
| 80 | + // Scrollwheel must be boolean | |
| 81 | + $params['autozoom'] = gdsc_to_bool_val($params['autozoom']); | |
| 82 | 82 | |
| 83 | - return $params; | |
| 83 | + return $params; | |
| 84 | 84 | } | 
| 85 | 85 | |
| 86 | 86 | /** | 
| @@ -99,52 +99,52 @@ discard block | ||
| 99 | 99 | */ | 
| 100 | 100 | function gdsc_to_bool_val($in, $strict = false) | 
| 101 | 101 |  { | 
| 102 | - $out = null; | |
| 103 | - | |
| 104 | - // if not strict, we only have to check if something is false | |
| 105 | - if (in_array($in, array( | |
| 106 | - 'false', | |
| 107 | - 'False', | |
| 108 | - 'FALSE', | |
| 109 | - 'no', | |
| 110 | - 'No', | |
| 111 | - 'n', | |
| 112 | - 'N', | |
| 113 | - '0', | |
| 114 | - 'off', | |
| 115 | - 'Off', | |
| 116 | - 'OFF', | |
| 117 | - false, | |
| 118 | - 0, | |
| 119 | - null | |
| 120 | -    ), true)) { | |
| 121 | - $out = false; | |
| 122 | -    } else if ($strict) { | |
| 123 | - // if strict, check the equivalent true values | |
| 124 | - if (in_array($in, array( | |
| 125 | - 'true', | |
| 126 | - 'True', | |
| 127 | - 'TRUE', | |
| 128 | - 'yes', | |
| 129 | - 'Yes', | |
| 130 | - 'y', | |
| 131 | - 'Y', | |
| 132 | - '1', | |
| 133 | - 'on', | |
| 134 | - 'On', | |
| 135 | - 'ON', | |
| 136 | - true, | |
| 137 | - 1 | |
| 138 | -        ), true)) { | |
| 139 | - $out = true; | |
| 140 | - } | |
| 141 | -    } else { | |
| 142 | - // not strict? let the regular php bool check figure it out (will | |
| 143 | - // largely default to true) | |
| 144 | - $out = ($in ? true : false); | |
| 145 | - } | |
| 102 | + $out = null; | |
| 103 | + | |
| 104 | + // if not strict, we only have to check if something is false | |
| 105 | + if (in_array($in, array( | |
| 106 | + 'false', | |
| 107 | + 'False', | |
| 108 | + 'FALSE', | |
| 109 | + 'no', | |
| 110 | + 'No', | |
| 111 | + 'n', | |
| 112 | + 'N', | |
| 113 | + '0', | |
| 114 | + 'off', | |
| 115 | + 'Off', | |
| 116 | + 'OFF', | |
| 117 | + false, | |
| 118 | + 0, | |
| 119 | + null | |
| 120 | +	), true)) { | |
| 121 | + $out = false; | |
| 122 | +	} else if ($strict) { | |
| 123 | + // if strict, check the equivalent true values | |
| 124 | + if (in_array($in, array( | |
| 125 | + 'true', | |
| 126 | + 'True', | |
| 127 | + 'TRUE', | |
| 128 | + 'yes', | |
| 129 | + 'Yes', | |
| 130 | + 'y', | |
| 131 | + 'Y', | |
| 132 | + '1', | |
| 133 | + 'on', | |
| 134 | + 'On', | |
| 135 | + 'ON', | |
| 136 | + true, | |
| 137 | + 1 | |
| 138 | +		), true)) { | |
| 139 | + $out = true; | |
| 140 | + } | |
| 141 | +	} else { | |
| 142 | + // not strict? let the regular php bool check figure it out (will | |
| 143 | + // largely default to true) | |
| 144 | + $out = ($in ? true : false); | |
| 145 | + } | |
| 146 | 146 | |
| 147 | - return $out; | |
| 147 | + return $out; | |
| 148 | 148 | } | 
| 149 | 149 | |
| 150 | 150 | /** | 
| @@ -157,16 +157,16 @@ discard block | ||
| 157 | 157 | */ | 
| 158 | 158 | function gdsc_is_post_type_valid($incoming_post_type) | 
| 159 | 159 |  { | 
| 160 | - $post_types = geodir_get_posttypes(); | |
| 161 | -    $post_types = array_map('geodir_strtolower', $post_types); | |
| 162 | - $post_type_found = false; | |
| 163 | -    foreach ($post_types as $type) { | |
| 164 | -        if (geodir_strtolower($incoming_post_type) == geodir_strtolower($type)) { | |
| 165 | - $post_type_found = true; | |
| 166 | - } | |
| 167 | - } | |
| 160 | + $post_types = geodir_get_posttypes(); | |
| 161 | +	$post_types = array_map('geodir_strtolower', $post_types); | |
| 162 | + $post_type_found = false; | |
| 163 | +	foreach ($post_types as $type) { | |
| 164 | +		if (geodir_strtolower($incoming_post_type) == geodir_strtolower($type)) { | |
| 165 | + $post_type_found = true; | |
| 166 | + } | |
| 167 | + } | |
| 168 | 168 | |
| 169 | - return $post_type_found; | |
| 169 | + return $post_type_found; | |
| 170 | 170 | } | 
| 171 | 171 | |
| 172 | 172 | /** | 
| @@ -186,52 +186,52 @@ discard block | ||
| 186 | 186 | */ | 
| 187 | 187 | function gdsc_listing_loop_filter($query) | 
| 188 | 188 |  { | 
| 189 | - global $wp_query, $geodir_post_type, $table, $plugin_prefix, $term; | |
| 190 | - | |
| 191 | - $geodir_post_type = geodir_get_current_posttype(); | |
| 192 | - | |
| 193 | -    if (isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries) { | |
| 194 | - $taxonomies = wp_list_pluck($wp_query->tax_query->queries, 'taxonomy'); | |
| 195 | - | |
| 196 | -        if (isset($wp_query->query[$taxonomies[0]])) { | |
| 197 | -            $request_term = explode("/", $wp_query->query[$taxonomies[0]]); | |
| 198 | - $request_term = end($request_term); | |
| 199 | -            if (!term_exists($request_term)) { | |
| 200 | -                $args = array('number' => '1',); | |
| 201 | - $terms_arr = get_terms($taxonomies[0], $args); | |
| 202 | -                foreach ($terms_arr as $location_term) { | |
| 203 | - $term_arr = $location_term; | |
| 204 | -                    $term_arr->name = geodir_ucwords(str_replace('-', ' ', $request_term)); | |
| 205 | - } | |
| 206 | - $wp_query->queried_object_id = 1; | |
| 207 | - $wp_query->queried_object = $term_arr; | |
| 208 | - } | |
| 209 | - } | |
| 189 | + global $wp_query, $geodir_post_type, $table, $plugin_prefix, $term; | |
| 190 | + | |
| 191 | + $geodir_post_type = geodir_get_current_posttype(); | |
| 192 | + | |
| 193 | +	if (isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries) { | |
| 194 | + $taxonomies = wp_list_pluck($wp_query->tax_query->queries, 'taxonomy'); | |
| 195 | + | |
| 196 | +		if (isset($wp_query->query[$taxonomies[0]])) { | |
| 197 | +			$request_term = explode("/", $wp_query->query[$taxonomies[0]]); | |
| 198 | + $request_term = end($request_term); | |
| 199 | +			if (!term_exists($request_term)) { | |
| 200 | +				$args = array('number' => '1',); | |
| 201 | + $terms_arr = get_terms($taxonomies[0], $args); | |
| 202 | +				foreach ($terms_arr as $location_term) { | |
| 203 | + $term_arr = $location_term; | |
| 204 | +					$term_arr->name = geodir_ucwords(str_replace('-', ' ', $request_term)); | |
| 205 | + } | |
| 206 | + $wp_query->queried_object_id = 1; | |
| 207 | + $wp_query->queried_object = $term_arr; | |
| 208 | + } | |
| 209 | + } | |
| 210 | 210 | |
| 211 | - } | |
| 212 | -    if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']) { | |
| 211 | + } | |
| 212 | +	if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']) { | |
| 213 | 213 | |
| 214 | - $table = $plugin_prefix . $geodir_post_type . '_detail'; | |
| 214 | + $table = $plugin_prefix . $geodir_post_type . '_detail'; | |
| 215 | 215 | |
| 216 | -        add_filter('posts_fields', 'geodir_posts_fields', 1); | |
| 217 | -        add_filter('posts_join', 'geodir_posts_join', 1); | |
| 218 | - geodir_post_where(); | |
| 219 | -        if (!is_admin()) { | |
| 220 | -            add_filter('posts_orderby', 'geodir_posts_orderby', 1); | |
| 221 | - } | |
| 216 | +		add_filter('posts_fields', 'geodir_posts_fields', 1); | |
| 217 | +		add_filter('posts_join', 'geodir_posts_join', 1); | |
| 218 | + geodir_post_where(); | |
| 219 | +		if (!is_admin()) { | |
| 220 | +			add_filter('posts_orderby', 'geodir_posts_orderby', 1); | |
| 221 | + } | |
| 222 | 222 | |
| 223 | - // advanced filter for popular post view widget | |
| 224 | - global $wp_query; | |
| 225 | -        if (!is_admin()) { | |
| 226 | -            if (!empty($wp_query->query['with_pics_only'])) { | |
| 227 | -                add_filter('posts_join', 'geodir_filter_widget_join', 1000); | |
| 228 | - } | |
| 229 | -            add_filter('posts_where', 'geodir_filter_widget_where', 1000); | |
| 230 | - } | |
| 223 | + // advanced filter for popular post view widget | |
| 224 | + global $wp_query; | |
| 225 | +		if (!is_admin()) { | |
| 226 | +			if (!empty($wp_query->query['with_pics_only'])) { | |
| 227 | +				add_filter('posts_join', 'geodir_filter_widget_join', 1000); | |
| 228 | + } | |
| 229 | +			add_filter('posts_where', 'geodir_filter_widget_where', 1000); | |
| 230 | + } | |
| 231 | 231 | |
| 232 | - } | |
| 232 | + } | |
| 233 | 233 | |
| 234 | - return $query; | |
| 234 | + return $query; | |
| 235 | 235 | } | 
| 236 | 236 | |
| 237 | 237 | /** | 
| @@ -245,40 +245,40 @@ discard block | ||
| 245 | 245 | */ | 
| 246 | 246 | function gdsc_manage_category_choice($post_type, $category) | 
| 247 | 247 |  { | 
| 248 | -    if (0 == $category || '' == $category) { | |
| 249 | - return ''; | |
| 250 | - } | |
| 248 | +	if (0 == $category || '' == $category) { | |
| 249 | + return ''; | |
| 250 | + } | |
| 251 | 251 | |
| 252 | -    if (!(gdsc_is_post_type_valid($post_type))) { | |
| 253 | - return ''; | |
| 254 | - } | |
| 252 | +	if (!(gdsc_is_post_type_valid($post_type))) { | |
| 253 | + return ''; | |
| 254 | + } | |
| 255 | 255 | |
| 256 | - $taxonomies = geodir_get_taxonomies($post_type); | |
| 256 | + $taxonomies = geodir_get_taxonomies($post_type); | |
| 257 | 257 | |
| 258 | -    $categories = get_terms(array('taxonomy' => $taxonomies[0])); | |
| 258 | +	$categories = get_terms(array('taxonomy' => $taxonomies[0])); | |
| 259 | 259 | |
| 260 | - $cat_id = 0; | |
| 260 | + $cat_id = 0; | |
| 261 | 261 | |
| 262 | -    foreach ($categories as $cat) { | |
| 263 | -        if (is_numeric($category)) { | |
| 264 | -            if (absint($category) == $cat->term_id) { | |
| 265 | - $cat_id = $cat->term_id; | |
| 266 | - break; | |
| 267 | - } | |
| 268 | -        } else { | |
| 269 | -            if ($category == $cat->slug) { | |
| 270 | - $cat_id = $cat->term_id; | |
| 271 | - break; | |
| 272 | - } | |
| 262 | +	foreach ($categories as $cat) { | |
| 263 | +		if (is_numeric($category)) { | |
| 264 | +			if (absint($category) == $cat->term_id) { | |
| 265 | + $cat_id = $cat->term_id; | |
| 266 | + break; | |
| 267 | + } | |
| 268 | +		} else { | |
| 269 | +			if ($category == $cat->slug) { | |
| 270 | + $cat_id = $cat->term_id; | |
| 271 | + break; | |
| 272 | + } | |
| 273 | 273 | |
| 274 | -            if ($category == $cat->name) { | |
| 275 | - $cat_id = $cat->term_id; | |
| 276 | - break; | |
| 277 | - } | |
| 278 | - } | |
| 279 | - } | |
| 274 | +			if ($category == $cat->name) { | |
| 275 | + $cat_id = $cat->term_id; | |
| 276 | + break; | |
| 277 | + } | |
| 278 | + } | |
| 279 | + } | |
| 280 | 280 | |
| 281 | - return $cat_id; | |
| 281 | + return $cat_id; | |
| 282 | 282 | } | 
| 283 | 283 | |
| 284 | 284 | // @todo: Extract this | 
| @@ -288,11 +288,11 @@ discard block | ||
| 288 | 288 | * Adds the script in the page footer for the home page google map. | 
| 289 | 289 | * | 
| 290 | 290 | * @since 1.0.0 | 
| 291 | - * @return string Print the script in page footer. | |
| 291 | + * @return string Print the script in page footer. | |
| 292 | 292 | */ | 
| 293 | 293 | function geodir_home_map_add_script() | 
| 294 | -    { | |
| 295 | - ?> | |
| 294 | +	{ | |
| 295 | + ?> | |
| 296 | 296 | <script type="text/javascript"> | 
| 297 | 297 |              jQuery(document).ready(function () { | 
| 298 | 298 | geoDirMapSlide(); | 
| @@ -365,7 +365,7 @@ discard block | ||
| 365 | 365 | } | 
| 366 | 366 | </script> | 
| 367 | 367 | <?php | 
| 368 | - } | |
| 368 | + } | |
| 369 | 369 | } | 
| 370 | 370 | |
| 371 | 371 | /** | 
| @@ -376,7 +376,7 @@ discard block | ||
| 376 | 376 | */ | 
| 377 | 377 | function geodir_popular_category_add_scripts() | 
| 378 | 378 |  { | 
| 379 | - ?> | |
| 379 | + ?> | |
| 380 | 380 | <script type="text/javascript"> | 
| 381 | 381 |          jQuery(function ($) { | 
| 382 | 382 |              $('.geodir-showcat').click(function () { | 
| @@ -406,56 +406,56 @@ discard block | ||
| 406 | 406 | */ | 
| 407 | 407 | function gdsc_validate_layout_choice($layout_choice) | 
| 408 | 408 |  { | 
| 409 | -    switch (geodir_strtolower($layout_choice)) { | |
| 410 | - case 'list'; | |
| 411 | - case 'one'; | |
| 412 | - case 'one_column'; | |
| 413 | - case 'onecolumn'; | |
| 414 | - case '1'; | |
| 415 | - $layout_choice = 'list'; | |
| 416 | - break; | |
| 417 | - case 'gridview_onehalf'; | |
| 418 | - case 'two'; | |
| 419 | - case 'two_column'; | |
| 420 | - case 'two_columns'; | |
| 421 | - case 'twocolumn'; | |
| 422 | - case 'twocolumns'; | |
| 423 | - case '2'; | |
| 424 | - $layout_choice = 'gridview_onehalf'; | |
| 425 | - break; | |
| 426 | - case 'gridview_onethird'; | |
| 427 | - case 'three'; | |
| 428 | - case 'three_column'; | |
| 429 | - case 'three_columns'; | |
| 430 | - case 'threecolumn'; | |
| 431 | - case 'threecolumns'; | |
| 432 | - case '3'; | |
| 433 | - $layout_choice = 'gridview_onethird'; | |
| 434 | - break; | |
| 435 | - case 'gridview_onefourth'; | |
| 436 | - case 'four'; | |
| 437 | - case 'four_column'; | |
| 438 | - case 'four_columns'; | |
| 439 | - case 'fourcolumn'; | |
| 440 | - case 'fourcolumns'; | |
| 441 | - case '4'; | |
| 442 | - $layout_choice = 'gridview_onefourth'; | |
| 443 | - break; | |
| 444 | - case 'gridview_onefifth'; | |
| 445 | - case 'five'; | |
| 446 | - case 'five_column'; | |
| 447 | - case 'five_columns'; | |
| 448 | - case 'fivecolumn'; | |
| 449 | - case 'fivecolumns'; | |
| 450 | - case '5'; | |
| 451 | - $layout_choice = 'gridview_onefifth'; | |
| 452 | - break; | |
| 453 | - default: | |
| 454 | - $layout_choice = 'gridview_onehalf'; | |
| 455 | - break; | |
| 456 | - } | |
| 409 | +	switch (geodir_strtolower($layout_choice)) { | |
| 410 | + case 'list'; | |
| 411 | + case 'one'; | |
| 412 | + case 'one_column'; | |
| 413 | + case 'onecolumn'; | |
| 414 | + case '1'; | |
| 415 | + $layout_choice = 'list'; | |
| 416 | + break; | |
| 417 | + case 'gridview_onehalf'; | |
| 418 | + case 'two'; | |
| 419 | + case 'two_column'; | |
| 420 | + case 'two_columns'; | |
| 421 | + case 'twocolumn'; | |
| 422 | + case 'twocolumns'; | |
| 423 | + case '2'; | |
| 424 | + $layout_choice = 'gridview_onehalf'; | |
| 425 | + break; | |
| 426 | + case 'gridview_onethird'; | |
| 427 | + case 'three'; | |
| 428 | + case 'three_column'; | |
| 429 | + case 'three_columns'; | |
| 430 | + case 'threecolumn'; | |
| 431 | + case 'threecolumns'; | |
| 432 | + case '3'; | |
| 433 | + $layout_choice = 'gridview_onethird'; | |
| 434 | + break; | |
| 435 | + case 'gridview_onefourth'; | |
| 436 | + case 'four'; | |
| 437 | + case 'four_column'; | |
| 438 | + case 'four_columns'; | |
| 439 | + case 'fourcolumn'; | |
| 440 | + case 'fourcolumns'; | |
| 441 | + case '4'; | |
| 442 | + $layout_choice = 'gridview_onefourth'; | |
| 443 | + break; | |
| 444 | + case 'gridview_onefifth'; | |
| 445 | + case 'five'; | |
| 446 | + case 'five_column'; | |
| 447 | + case 'five_columns'; | |
| 448 | + case 'fivecolumn'; | |
| 449 | + case 'fivecolumns'; | |
| 450 | + case '5'; | |
| 451 | + $layout_choice = 'gridview_onefifth'; | |
| 452 | + break; | |
| 453 | + default: | |
| 454 | + $layout_choice = 'gridview_onehalf'; | |
| 455 | + break; | |
| 456 | + } | |
| 457 | 457 | |
| 458 | - return $layout_choice; | |
| 458 | + return $layout_choice; | |
| 459 | 459 | } | 
| 460 | 460 | |
| 461 | 461 | /** | 
| @@ -468,20 +468,20 @@ discard block | ||
| 468 | 468 | */ | 
| 469 | 469 | function gdsc_validate_sort_choice($sort_choice) | 
| 470 | 470 |  { | 
| 471 | - $sorts = array( | |
| 472 | - 'az', | |
| 473 | - 'latest', | |
| 474 | - 'featured', | |
| 475 | - 'high_review', | |
| 476 | - 'high_rating', | |
| 477 | - 'random', | |
| 478 | - ); | |
| 479 | - | |
| 480 | -    if (!(in_array($sort_choice, $sorts))) { | |
| 481 | - $sort_choice = 'latest'; | |
| 482 | - } | |
| 471 | + $sorts = array( | |
| 472 | + 'az', | |
| 473 | + 'latest', | |
| 474 | + 'featured', | |
| 475 | + 'high_review', | |
| 476 | + 'high_rating', | |
| 477 | + 'random', | |
| 478 | + ); | |
| 479 | + | |
| 480 | +	if (!(in_array($sort_choice, $sorts))) { | |
| 481 | + $sort_choice = 'latest'; | |
| 482 | + } | |
| 483 | 483 | |
| 484 | - return $sort_choice; | |
| 484 | + return $sort_choice; | |
| 485 | 485 | } | 
| 486 | 486 | |
| 487 | 487 | /** | 
| @@ -494,22 +494,22 @@ discard block | ||
| 494 | 494 | */ | 
| 495 | 495 | function gdsc_validate_listing_width($width_choice) | 
| 496 | 496 |  { | 
| 497 | -    if (!(empty($width_choice))) { | |
| 498 | - $width_choice = absint($width_choice); | |
| 499 | -    } else { | |
| 500 | - return ''; | |
| 501 | - } | |
| 497 | +	if (!(empty($width_choice))) { | |
| 498 | + $width_choice = absint($width_choice); | |
| 499 | +	} else { | |
| 500 | + return ''; | |
| 501 | + } | |
| 502 | 502 | |
| 503 | -    if (100 < $width_choice) { | |
| 504 | - $width_choice = 100; | |
| 505 | - } | |
| 503 | +	if (100 < $width_choice) { | |
| 504 | + $width_choice = 100; | |
| 505 | + } | |
| 506 | 506 | |
| 507 | - // If listing_width is too narrow, it won't work, arbitrarily set to 10% here | |
| 508 | -    if (10 > $width_choice) { | |
| 509 | - $width_choice = 10; | |
| 510 | - } | |
| 507 | + // If listing_width is too narrow, it won't work, arbitrarily set to 10% here | |
| 508 | +	if (10 > $width_choice) { | |
| 509 | + $width_choice = 10; | |
| 510 | + } | |
| 511 | 511 | |
| 512 | - return $width_choice; | |
| 512 | + return $width_choice; | |
| 513 | 513 | } | 
| 514 | 514 | |
| 515 | 515 | /** | 
| @@ -522,18 +522,18 @@ discard block | ||
| 522 | 522 | */ | 
| 523 | 523 | function gdsc_validate_list_filter_choice($filter_choice) | 
| 524 | 524 |  { | 
| 525 | - $filters = array( | |
| 526 | - 'all', | |
| 527 | - 'today', | |
| 528 | - 'upcoming', | |
| 529 | - 'past', | |
| 530 | - ); | |
| 531 | - | |
| 532 | -    if (!(in_array($filter_choice, $filters))) { | |
| 533 | - $filter_choice = 'all'; | |
| 534 | - } | |
| 525 | + $filters = array( | |
| 526 | + 'all', | |
| 527 | + 'today', | |
| 528 | + 'upcoming', | |
| 529 | + 'past', | |
| 530 | + ); | |
| 531 | + | |
| 532 | +	if (!(in_array($filter_choice, $filters))) { | |
| 533 | + $filter_choice = 'all'; | |
| 534 | + } | |
| 535 | 535 | |
| 536 | - return $filter_choice; | |
| 536 | + return $filter_choice; | |
| 537 | 537 | } | 
| 538 | 538 | |
| 539 | 539 | /** | 
| @@ -554,7 +554,7 @@ discard block | ||
| 554 | 554 | * @return string Listings HTML content. | 
| 555 | 555 | */ | 
| 556 | 556 |  function geodir_sc_gd_listings_output($args = array()) { | 
| 557 | - $title = !empty($args['title']) ? __($args['title'], 'geodirectory') : ''; | |
| 557 | + $title = !empty($args['title']) ? __($args['title'], 'geodirectory') : ''; | |
| 558 | 558 | $post_type = !empty($args['post_type']) ? $args['post_type'] : 'gd_place'; | 
| 559 | 559 | $category = !empty($args['category']) ? $args['category'] : '0'; | 
| 560 | 560 | $post_number = !empty($args['post_number']) ? $args['post_number'] : 10; | 
| @@ -564,17 +564,17 @@ discard block | ||
| 564 | 564 | $layout = !empty($args['layout']) ? $args['layout'] : 'gridview_onehalf'; | 
| 565 | 565 | $with_pagination = !empty($args['with_pagination']) ? true : false; | 
| 566 | 566 | $event_type = !empty($args['event_type']) ? $args['event_type'] : ''; | 
| 567 | - $shortcode_content = !empty($args['shortcode_content']) ? trim($args['shortcode_content']) : ''; | |
| 568 | - $tags = !empty($args['tags']) ? $args['tags'] : array(); | |
| 569 | - /** | |
| 570 | - * Filter the content text displayed when no listings found. | |
| 571 | - * | |
| 572 | - * @since 1.6.0 | |
| 573 | - * | |
| 574 | - * @param string $shortcode_content The shortcode content text. | |
| 575 | - * @param array $args Array of arguements to filter listings. | |
| 576 | - */ | |
| 577 | -    $shortcode_content = apply_filters('geodir_sc_gd_listings_not_found_content', $shortcode_content, $args); | |
| 567 | + $shortcode_content = !empty($args['shortcode_content']) ? trim($args['shortcode_content']) : ''; | |
| 568 | + $tags = !empty($args['tags']) ? $args['tags'] : array(); | |
| 569 | + /** | |
| 570 | + * Filter the content text displayed when no listings found. | |
| 571 | + * | |
| 572 | + * @since 1.6.0 | |
| 573 | + * | |
| 574 | + * @param string $shortcode_content The shortcode content text. | |
| 575 | + * @param array $args Array of arguements to filter listings. | |
| 576 | + */ | |
| 577 | +	$shortcode_content = apply_filters('geodir_sc_gd_listings_not_found_content', $shortcode_content, $args); | |
| 578 | 578 | |
| 579 | 579 | $top_pagination = $with_pagination && !empty($args['top_pagination']) ? true : false; | 
| 580 | 580 | $bottom_pagination = $with_pagination && !empty($args['bottom_pagination']) ? true : false; | 
| @@ -586,87 +586,87 @@ discard block | ||
| 586 | 586 | $pageno = $geodir_ajax && !empty($args['pageno']) ? $args['pageno'] : 1; | 
| 587 | 587 | |
| 588 | 588 | $query_args = array( | 
| 589 | - 'posts_per_page' => $post_number, | |
| 590 | - 'is_geodir_loop' => true, | |
| 591 | - 'gd_location' => $add_location_filter, | |
| 592 | - 'post_type' => $post_type, | |
| 593 | - 'order_by' => $list_sort, | |
| 589 | + 'posts_per_page' => $post_number, | |
| 590 | + 'is_geodir_loop' => true, | |
| 591 | + 'gd_location' => $add_location_filter, | |
| 592 | + 'post_type' => $post_type, | |
| 593 | + 'order_by' => $list_sort, | |
| 594 | 594 | 'pageno' => $pageno | 
| 595 | - ); | |
| 595 | + ); | |
| 596 | 596 | |
| 597 | -    if ($character_count >= 0) { | |
| 598 | - $query_args['excerpt_length'] = $character_count; | |
| 599 | - } | |
| 597 | +	if ($character_count >= 0) { | |
| 598 | + $query_args['excerpt_length'] = $character_count; | |
| 599 | + } | |
| 600 | 600 | |
| 601 | -    if (!empty($args['post_author'])) { | |
| 602 | - $query_args['post_author'] = $args['post_author']; | |
| 603 | - } | |
| 601 | +	if (!empty($args['post_author'])) { | |
| 602 | + $query_args['post_author'] = $args['post_author']; | |
| 603 | + } | |
| 604 | 604 | |
| 605 | -    if (!empty($args['show_featured_only'])) { | |
| 606 | - $query_args['show_featured_only'] = 1; | |
| 607 | - } | |
| 605 | +	if (!empty($args['show_featured_only'])) { | |
| 606 | + $query_args['show_featured_only'] = 1; | |
| 607 | + } | |
| 608 | 608 | |
| 609 | -    if (!empty($args['show_special_only'])) { | |
| 610 | - $query_args['show_special_only'] = 1; | |
| 611 | - } | |
| 609 | +	if (!empty($args['show_special_only'])) { | |
| 610 | + $query_args['show_special_only'] = 1; | |
| 611 | + } | |
| 612 | 612 | |
| 613 | -    if (!empty($args['with_pics_only'])) { | |
| 614 | - $query_args['with_pics_only'] = 0; | |
| 615 | - $query_args['featured_image_only'] = 1; | |
| 616 | - } | |
| 613 | +	if (!empty($args['with_pics_only'])) { | |
| 614 | + $query_args['with_pics_only'] = 0; | |
| 615 | + $query_args['featured_image_only'] = 1; | |
| 616 | + } | |
| 617 | 617 | |
| 618 | -    if (!empty($args['with_videos_only'])) { | |
| 619 | - $query_args['with_videos_only'] = 1; | |
| 620 | - } | |
| 621 | - $with_no_results = !empty($args['without_no_results']) ? false : true; | |
| 618 | +	if (!empty($args['with_videos_only'])) { | |
| 619 | + $query_args['with_videos_only'] = 1; | |
| 620 | + } | |
| 621 | + $with_no_results = !empty($args['without_no_results']) ? false : true; | |
| 622 | 622 | |
| 623 | -    if (!empty($category) && isset($category[0]) && $category[0] != '0') { | |
| 624 | - $category_taxonomy = geodir_get_taxonomies($post_type); | |
| 623 | +	if (!empty($category) && isset($category[0]) && $category[0] != '0') { | |
| 624 | + $category_taxonomy = geodir_get_taxonomies($post_type); | |
| 625 | 625 | |
| 626 | - ######### WPML ######### | |
| 627 | -        if (function_exists('icl_object_id')) { | |
| 628 | - $category = gd_lang_object_ids($category, $category_taxonomy[0]); | |
| 629 | - } | |
| 630 | - ######### WPML ######### | |
| 626 | + ######### WPML ######### | |
| 627 | +		if (function_exists('icl_object_id')) { | |
| 628 | + $category = gd_lang_object_ids($category, $category_taxonomy[0]); | |
| 629 | + } | |
| 630 | + ######### WPML ######### | |
| 631 | 631 | |
| 632 | - $tax_query = array( | |
| 633 | - 'taxonomy' => $category_taxonomy[0], | |
| 634 | - 'field' => 'id', | |
| 635 | - 'terms' => $category | |
| 636 | - ); | |
| 632 | + $tax_query = array( | |
| 633 | + 'taxonomy' => $category_taxonomy[0], | |
| 634 | + 'field' => 'id', | |
| 635 | + 'terms' => $category | |
| 636 | + ); | |
| 637 | 637 | |
| 638 | - $query_args['tax_query'] = array($tax_query); | |
| 639 | - } | |
| 638 | + $query_args['tax_query'] = array($tax_query); | |
| 639 | + } | |
| 640 | 640 | |
| 641 | -    if (!empty($tags)) { | |
| 642 | - // Clean tags | |
| 643 | -        if (!is_array($tags)) { | |
| 644 | -            $comma = _x(',', 'tag delimiter'); | |
| 645 | -            if ( ',' !== $comma ) { | |
| 646 | - $tags = str_replace($comma, ',', $tags); | |
| 647 | - } | |
| 648 | -            $tags = explode(',', trim($tags, " \n\t\r\0\x0B,")); | |
| 649 | -            $tags = array_map('trim', $tags); | |
| 650 | - } | |
| 641 | +	if (!empty($tags)) { | |
| 642 | + // Clean tags | |
| 643 | +		if (!is_array($tags)) { | |
| 644 | +			$comma = _x(',', 'tag delimiter'); | |
| 645 | +			if ( ',' !== $comma ) { | |
| 646 | + $tags = str_replace($comma, ',', $tags); | |
| 647 | + } | |
| 648 | +			$tags = explode(',', trim($tags, " \n\t\r\0\x0B,")); | |
| 649 | +			$tags = array_map('trim', $tags); | |
| 650 | + } | |
| 651 | 651 | |
| 652 | -        if (!empty($tags)) { | |
| 653 | - $tag_query = array( | |
| 654 | - 'taxonomy' => $post_type . '_tags', | |
| 655 | - 'field' => 'name', | |
| 656 | - 'terms' => $tags | |
| 657 | - ); | |
| 658 | - | |
| 659 | -            if (!empty($query_args['tax_query'])) { | |
| 660 | - $query_args['tax_query'][] = $tag_query; | |
| 661 | -            } else { | |
| 662 | - $query_args['tax_query'] = array($tag_query); | |
| 663 | - } | |
| 664 | - } | |
| 665 | - } | |
| 652 | +		if (!empty($tags)) { | |
| 653 | + $tag_query = array( | |
| 654 | + 'taxonomy' => $post_type . '_tags', | |
| 655 | + 'field' => 'name', | |
| 656 | + 'terms' => $tags | |
| 657 | + ); | |
| 658 | + | |
| 659 | +			if (!empty($query_args['tax_query'])) { | |
| 660 | + $query_args['tax_query'][] = $tag_query; | |
| 661 | +			} else { | |
| 662 | + $query_args['tax_query'] = array($tag_query); | |
| 663 | + } | |
| 664 | + } | |
| 665 | + } | |
| 666 | 666 | |
| 667 | - global $gridview_columns_widget, $geodir_is_widget_listing; | |
| 667 | + global $gridview_columns_widget, $geodir_is_widget_listing; | |
| 668 | 668 | |
| 669 | -    if ($post_type == 'gd_event' && function_exists('geodir_event_get_widget_events')) { | |
| 669 | +	if ($post_type == 'gd_event' && function_exists('geodir_event_get_widget_events')) { | |
| 670 | 670 | global $geodir_event_widget_listview; | 
| 671 | 671 | $geodir_event_widget_listview = true; | 
| 672 | 672 | |
| @@ -681,16 +681,16 @@ discard block | ||
| 681 | 681 | $widget_listings = $total_posts > 0 ? geodir_get_widget_listings($query_args) : array(); | 
| 682 | 682 | } | 
| 683 | 683 | $current_gridview_columns_widget = $gridview_columns_widget; | 
| 684 | - $identifier = ' gd-wgt-pagi-' . mt_rand(); | |
| 685 | - ob_start(); | |
| 684 | + $identifier = ' gd-wgt-pagi-' . mt_rand(); | |
| 685 | + ob_start(); | |
| 686 | 686 |  	if (!empty($widget_listings) || $with_no_results) { | 
| 687 | 687 |  		if (!$geodir_ajax) { | 
| 688 | - /** | |
| 689 | - * Called before the shortcode [gd_listings] content is output. | |
| 690 | - * | |
| 691 | - * @since 1.0.0 | |
| 692 | - */ | |
| 693 | -        do_action('geodir_before_sc_gd_listings'); | |
| 688 | + /** | |
| 689 | + * Called before the shortcode [gd_listings] content is output. | |
| 690 | + * | |
| 691 | + * @since 1.0.0 | |
| 692 | + */ | |
| 693 | +		do_action('geodir_before_sc_gd_listings'); | |
| 694 | 694 | ?> | 
| 695 | 695 | <div class="geodir_locations geodir_location_listing geodir-sc-gd-listings <?php echo $identifier;?>"> | 
| 696 | 696 |              <?php if ($title != '') { ?> | 
| @@ -701,63 +701,63 @@ discard block | ||
| 701 | 701 | <div class="gd-sc-loader"> | 
| 702 | 702 | <div class="gd-sc-content"> | 
| 703 | 703 | <?php } | 
| 704 | -            if (!(empty($widget_listings) && !empty($shortcode_content))) { | |
| 705 | -                if (strstr($layout, 'gridview')) { | |
| 706 | -                    $listing_view_exp = explode('_', $layout); | |
| 707 | - $gridview_columns_widget = $layout; | |
| 708 | - $layout = $listing_view_exp[0]; | |
| 709 | -                } else { | |
| 710 | - $gridview_columns_widget = ''; | |
| 711 | - } | |
| 712 | - | |
| 713 | - /** | |
| 714 | - * Filter the widget listing listview template. | |
| 715 | - * | |
| 716 | - * @since 1.0.0 | |
| 717 | - * | |
| 718 | - * @param string The template file to display listing. | |
| 719 | - */ | |
| 720 | -                $template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview')); | |
| 704 | +			if (!(empty($widget_listings) && !empty($shortcode_content))) { | |
| 705 | +				if (strstr($layout, 'gridview')) { | |
| 706 | +					$listing_view_exp = explode('_', $layout); | |
| 707 | + $gridview_columns_widget = $layout; | |
| 708 | + $layout = $listing_view_exp[0]; | |
| 709 | +				} else { | |
| 710 | + $gridview_columns_widget = ''; | |
| 711 | + } | |
| 712 | + | |
| 713 | + /** | |
| 714 | + * Filter the widget listing listview template. | |
| 715 | + * | |
| 716 | + * @since 1.0.0 | |
| 717 | + * | |
| 718 | + * @param string The template file to display listing. | |
| 719 | + */ | |
| 720 | +				$template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview')); | |
| 721 | 721 | |
| 722 | - global $post, $map_jason, $map_canvas_arr, $gd_session; | |
| 723 | - | |
| 724 | - $current_post = $post; | |
| 725 | - $current_map_jason = $map_jason; | |
| 726 | - $current_map_canvas_arr = $map_canvas_arr; | |
| 727 | - $geodir_is_widget_listing = true; | |
| 728 | -                $gd_session->un_set('gd_listing_view'); | |
| 729 | - | |
| 730 | -                if ($with_pagination && $top_pagination) {				 | |
| 731 | - echo geodir_sc_listings_pagination($total_posts, $post_number, $pageno); | |
| 732 | - } | |
| 733 | - | |
| 734 | - /** | |
| 735 | - * Includes listing listview template. | |
| 736 | - * | |
| 737 | - * @since 1.0.0 | |
| 738 | - */ | |
| 739 | - include($template); | |
| 722 | + global $post, $map_jason, $map_canvas_arr, $gd_session; | |
| 723 | + | |
| 724 | + $current_post = $post; | |
| 725 | + $current_map_jason = $map_jason; | |
| 726 | + $current_map_canvas_arr = $map_canvas_arr; | |
| 727 | + $geodir_is_widget_listing = true; | |
| 728 | +				$gd_session->un_set('gd_listing_view'); | |
| 729 | + | |
| 730 | +				if ($with_pagination && $top_pagination) {				 | |
| 731 | + echo geodir_sc_listings_pagination($total_posts, $post_number, $pageno); | |
| 732 | + } | |
| 733 | + | |
| 734 | + /** | |
| 735 | + * Includes listing listview template. | |
| 736 | + * | |
| 737 | + * @since 1.0.0 | |
| 738 | + */ | |
| 739 | + include($template); | |
| 740 | 740 | |
| 741 | -                if ($with_pagination && $bottom_pagination) {				 | |
| 742 | - echo geodir_sc_listings_pagination($total_posts, $post_number, $pageno); | |
| 743 | - } | |
| 744 | - | |
| 745 | - $geodir_is_widget_listing = false; | |
| 746 | - | |
| 747 | - $GLOBALS['post'] = $current_post; | |
| 748 | -                if (!empty($current_post)) { | |
| 749 | - setup_postdata($current_post); | |
| 750 | - } | |
| 751 | - $map_jason = $current_map_jason; | |
| 752 | - $map_canvas_arr = $current_map_canvas_arr; | |
| 753 | - global $gridview_columns_widget; | |
| 754 | - $gridview_columns_widget = $current_gridview_columns_widget; | |
| 755 | -            } else { | |
| 756 | - echo $shortcode_content; | |
| 757 | - } | |
| 741 | +				if ($with_pagination && $bottom_pagination) {				 | |
| 742 | + echo geodir_sc_listings_pagination($total_posts, $post_number, $pageno); | |
| 743 | + } | |
| 744 | + | |
| 745 | + $geodir_is_widget_listing = false; | |
| 746 | + | |
| 747 | + $GLOBALS['post'] = $current_post; | |
| 748 | +				if (!empty($current_post)) { | |
| 749 | + setup_postdata($current_post); | |
| 750 | + } | |
| 751 | + $map_jason = $current_map_jason; | |
| 752 | + $map_canvas_arr = $current_map_canvas_arr; | |
| 753 | + global $gridview_columns_widget; | |
| 754 | + $gridview_columns_widget = $current_gridview_columns_widget; | |
| 755 | +			} else { | |
| 756 | + echo $shortcode_content; | |
| 757 | + } | |
| 758 | 758 | ?> | 
| 759 | 759 | <?php | 
| 760 | -            if (!$geodir_ajax) {  | |
| 760 | +			if (!$geodir_ajax) {  | |
| 761 | 761 | ?> | 
| 762 | 762 | </div><p class="geodir-sclisting-loading" style="display:none;"><i class="fa fa-cog fa-spin"></i></p></div> | 
| 763 | 763 | <script type="text/javascript"> | 
| @@ -795,10 +795,10 @@ discard block | ||
| 795 | 795 | loading.hide(); | 
| 796 | 796 | jQuery(items).html(response); | 
| 797 | 797 | <?php | 
| 798 | - /** | |
| 799 | - * if lazyload images enabled then refresh them once ajax page changed. | |
| 800 | - */ | |
| 801 | -              if (get_option('geodir_lazy_load', 1)) { ?> | |
| 798 | + /** | |
| 799 | + * if lazyload images enabled then refresh them once ajax page changed. | |
| 800 | + */ | |
| 801 | +			  if (get_option('geodir_lazy_load', 1)) { ?> | |
| 802 | 802 | geodir_init_lazy_load(); | 
| 803 | 803 | <?php } ?> | 
| 804 | 804 | } | 
| @@ -808,11 +808,11 @@ discard block | ||
| 808 | 808 | </div> | 
| 809 | 809 | <?php } ?> | 
| 810 | 810 | <?php | 
| 811 | - } | |
| 811 | + } | |
| 812 | 812 | $output = ob_get_contents(); | 
| 813 | - ob_end_clean(); | |
| 813 | + ob_end_clean(); | |
| 814 | 814 | |
| 815 | - return trim($output); | |
| 815 | + return trim($output); | |
| 816 | 816 | } | 
| 817 | 817 | |
| 818 | 818 | /** | 
| @@ -839,15 +839,15 @@ discard block | ||
| 839 | 839 | * @return string Listings pagination HTML content. | 
| 840 | 840 | */ | 
| 841 | 841 |  function geodir_sc_listings_pagination($total_posts, $posts_per_page, $pageno, $before = '', $after = '', $prelabel = '', $nxtlabel = '', $pages_to_show = 5, $always_show = false) { | 
| 842 | -    if (empty($prelabel)) { | |
| 843 | - $prelabel = '<strong>«</strong>'; | |
| 844 | - } | |
| 842 | +	if (empty($prelabel)) { | |
| 843 | + $prelabel = '<strong>«</strong>'; | |
| 844 | + } | |
| 845 | 845 | |
| 846 | -    if (empty($nxtlabel)) { | |
| 847 | - $nxtlabel = '<strong>»</strong>'; | |
| 848 | - } | |
| 846 | +	if (empty($nxtlabel)) { | |
| 847 | + $nxtlabel = '<strong>»</strong>'; | |
| 848 | + } | |
| 849 | 849 | |
| 850 | - $half_pages_to_show = round($pages_to_show / 2); | |
| 850 | + $half_pages_to_show = round($pages_to_show / 2); | |
| 851 | 851 | |
| 852 | 852 | $numposts = $total_posts; | 
| 853 | 853 | |
| @@ -880,7 +880,7 @@ discard block | ||
| 880 | 880 | } | 
| 881 | 881 | |
| 882 | 882 |  		if (($pageno - 1) > 0) { | 
| 883 | - echo '<a class="gd-page-sc-prev gd-wgt-page" data-page="' . (int)($pageno - 1) . '" href="javascript:void(0);">' . $prelabel . '</a> '; | |
| 883 | + echo '<a class="gd-page-sc-prev gd-wgt-page" data-page="' . (int)($pageno - 1) . '" href="javascript:void(0);">' . $prelabel . '</a> '; | |
| 884 | 884 | } | 
| 885 | 885 | |
| 886 | 886 |  		for ($i = $pageno - $half_pages_to_show; $i <= $pageno + $half_pages_to_show; $i++) { | 
| @@ -903,9 +903,9 @@ discard block | ||
| 903 | 903 | echo "</div> $after </div>"; | 
| 904 | 904 | } | 
| 905 | 905 | $output = ob_get_contents(); | 
| 906 | - ob_end_clean(); | |
| 906 | + ob_end_clean(); | |
| 907 | 907 | |
| 908 | - return trim($output); | |
| 908 | + return trim($output); | |
| 909 | 909 | } | 
| 910 | 910 | |
| 911 | 911 | /** | 
| @@ -916,10 +916,10 @@ discard block | ||
| 916 | 916 | * @return string Listings HTML content. | 
| 917 | 917 | */ | 
| 918 | 918 |  function geodir_sclistings_callback() { | 
| 919 | -    check_ajax_referer('geodir-sclistings-nonce', 'geodir_sclistings_nonce'); | |
| 920 | - //set variables | |
| 921 | - $scatts = isset($_POST['scatts']) ? $_POST['scatts'] : NULL; | |
| 922 | - $pageno = isset($_POST['pageno']) ? absint($_POST['pageno']) : 1; | |
| 919 | +	check_ajax_referer('geodir-sclistings-nonce', 'geodir_sclistings_nonce'); | |
| 920 | + //set variables | |
| 921 | + $scatts = isset($_POST['scatts']) ? $_POST['scatts'] : NULL; | |
| 922 | + $pageno = isset($_POST['pageno']) ? absint($_POST['pageno']) : 1; | |
| 923 | 923 | |
| 924 | 924 | $shortcode_atts = !empty($scatts) ? (array)json_decode(stripslashes_deep($scatts)) : NULL; | 
| 925 | 925 | |
| @@ -931,7 +931,7 @@ discard block | ||
| 931 | 931 |  	} else { | 
| 932 | 932 | echo 0; | 
| 933 | 933 | } | 
| 934 | - wp_die(); | |
| 934 | + wp_die(); | |
| 935 | 935 | } | 
| 936 | 936 |  add_action('wp_ajax_geodir_sclistings', 'geodir_sclistings_callback'); | 
| 937 | 937 |  add_action('wp_ajax_nopriv_geodir_sclistings', 'geodir_sclistings_callback'); | 
| 938 | 938 | \ No newline at end of file | 
| @@ -29,10 +29,10 @@ discard block | ||
| 29 | 29 | $value = 100; | 
| 30 | 30 | } | 
| 31 | 31 | // Re-add the percent symbol | 
| 32 | - $value = $value . '%'; | |
| 32 | + $value = $value.'%'; | |
| 33 | 33 |      } elseif ((strlen($value) - 2) == strpos(trim($value), 'px')) { | 
| 34 | 34 | // Get the absint & re-add the 'px' | 
| 35 | -        $value = preg_replace('/\D/', '', $value) . 'px'; | |
| 35 | +        $value = preg_replace('/\D/', '', $value).'px'; | |
| 36 | 36 |      } else { | 
| 37 | 37 |          $value = preg_replace('/\D/', '', $value); | 
| 38 | 38 | } | 
| @@ -211,7 +211,7 @@ discard block | ||
| 211 | 211 | } | 
| 212 | 212 |      if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']) { | 
| 213 | 213 | |
| 214 | - $table = $plugin_prefix . $geodir_post_type . '_detail'; | |
| 214 | + $table = $plugin_prefix.$geodir_post_type.'_detail'; | |
| 215 | 215 | |
| 216 | 216 |          add_filter('posts_fields', 'geodir_posts_fields', 1); | 
| 217 | 217 |          add_filter('posts_join', 'geodir_posts_join', 1); | 
| @@ -560,10 +560,10 @@ discard block | ||
| 560 | 560 | $post_number = !empty($args['post_number']) ? $args['post_number'] : 10; | 
| 561 | 561 | $add_location_filter = !empty($args['add_location_filter']) ? true : false; | 
| 562 | 562 | $list_sort = !empty($args['list_sort']) ? $args['list_sort'] : 'latest'; | 
| 563 | - $character_count = isset($args['character_count']) ? $args['character_count'] : ''; | |
| 564 | - $layout = !empty($args['layout']) ? $args['layout'] : 'gridview_onehalf'; | |
| 565 | - $with_pagination = !empty($args['with_pagination']) ? true : false; | |
| 566 | - $event_type = !empty($args['event_type']) ? $args['event_type'] : ''; | |
| 563 | + $character_count = isset($args['character_count']) ? $args['character_count'] : ''; | |
| 564 | + $layout = !empty($args['layout']) ? $args['layout'] : 'gridview_onehalf'; | |
| 565 | + $with_pagination = !empty($args['with_pagination']) ? true : false; | |
| 566 | + $event_type = !empty($args['event_type']) ? $args['event_type'] : ''; | |
| 567 | 567 | $shortcode_content = !empty($args['shortcode_content']) ? trim($args['shortcode_content']) : ''; | 
| 568 | 568 | $tags = !empty($args['tags']) ? $args['tags'] : array(); | 
| 569 | 569 | /** | 
| @@ -577,13 +577,13 @@ discard block | ||
| 577 | 577 |      $shortcode_content = apply_filters('geodir_sc_gd_listings_not_found_content', $shortcode_content, $args); | 
| 578 | 578 | |
| 579 | 579 | $top_pagination = $with_pagination && !empty($args['top_pagination']) ? true : false; | 
| 580 | - $bottom_pagination = $with_pagination && !empty($args['bottom_pagination']) ? true : false; | |
| 580 | + $bottom_pagination = $with_pagination && !empty($args['bottom_pagination']) ? true : false; | |
| 581 | 581 | |
| 582 | 582 | $shortcode_atts = !empty($args['shortcode_atts']) ? $args['shortcode_atts'] : array(); | 
| 583 | 583 | |
| 584 | 584 | // ajax mode | 
| 585 | - $geodir_ajax = !empty($args['geodir_ajax']) ? true : false; | |
| 586 | - $pageno = $geodir_ajax && !empty($args['pageno']) ? $args['pageno'] : 1; | |
| 585 | + $geodir_ajax = !empty($args['geodir_ajax']) ? true : false; | |
| 586 | + $pageno = $geodir_ajax && !empty($args['pageno']) ? $args['pageno'] : 1; | |
| 587 | 587 | |
| 588 | 588 | $query_args = array( | 
| 589 | 589 | 'posts_per_page' => $post_number, | 
| @@ -642,7 +642,7 @@ discard block | ||
| 642 | 642 | // Clean tags | 
| 643 | 643 |          if (!is_array($tags)) { | 
| 644 | 644 |              $comma = _x(',', 'tag delimiter'); | 
| 645 | -            if ( ',' !== $comma ) { | |
| 645 | +            if (',' !== $comma) { | |
| 646 | 646 | $tags = str_replace($comma, ',', $tags); | 
| 647 | 647 | } | 
| 648 | 648 |              $tags = explode(',', trim($tags, " \n\t\r\0\x0B,")); | 
| @@ -651,7 +651,7 @@ discard block | ||
| 651 | 651 | |
| 652 | 652 |          if (!empty($tags)) { | 
| 653 | 653 | $tag_query = array( | 
| 654 | - 'taxonomy' => $post_type . '_tags', | |
| 654 | + 'taxonomy' => $post_type.'_tags', | |
| 655 | 655 | 'field' => 'name', | 
| 656 | 656 | 'terms' => $tags | 
| 657 | 657 | ); | 
| @@ -681,7 +681,7 @@ discard block | ||
| 681 | 681 | $widget_listings = $total_posts > 0 ? geodir_get_widget_listings($query_args) : array(); | 
| 682 | 682 | } | 
| 683 | 683 | $current_gridview_columns_widget = $gridview_columns_widget; | 
| 684 | - $identifier = ' gd-wgt-pagi-' . mt_rand(); | |
| 684 | + $identifier = ' gd-wgt-pagi-'.mt_rand(); | |
| 685 | 685 | ob_start(); | 
| 686 | 686 |  	if (!empty($widget_listings) || $with_no_results) { | 
| 687 | 687 |  		if (!$geodir_ajax) { | 
| @@ -692,7 +692,7 @@ discard block | ||
| 692 | 692 | */ | 
| 693 | 693 |          do_action('geodir_before_sc_gd_listings'); | 
| 694 | 694 | ?> | 
| 695 | - <div class="geodir_locations geodir_location_listing geodir-sc-gd-listings <?php echo $identifier;?>"> | |
| 695 | + <div class="geodir_locations geodir_location_listing geodir-sc-gd-listings <?php echo $identifier; ?>"> | |
| 696 | 696 |              <?php if ($title != '') { ?> | 
| 697 | 697 | <div class="geodir_list_heading clearfix"> | 
| 698 | 698 | <?php echo $title; ?> | 
| @@ -761,8 +761,8 @@ discard block | ||
| 761 | 761 | ?> | 
| 762 | 762 | </div><p class="geodir-sclisting-loading" style="display:none;"><i class="fa fa-cog fa-spin"></i></p></div> | 
| 763 | 763 | <script type="text/javascript"> | 
| 764 | -jQuery(document).on('click', '.<?php echo trim($identifier);?> .gd-wgt-page', function(e) { | |
| 765 | - var container = jQuery( '.<?php echo trim($identifier);?>'); | |
| 764 | +jQuery(document).on('click', '.<?php echo trim($identifier); ?> .gd-wgt-page', function(e) { | |
| 765 | + var container = jQuery( '.<?php echo trim($identifier); ?>'); | |
| 766 | 766 | var obj = this; | 
| 767 | 767 |      var pid = parseInt(jQuery(this).data('page')); | 
| 768 | 768 |      var items = jQuery(obj).closest('.gd-sc-content'); | 
| @@ -772,7 +772,7 @@ discard block | ||
| 772 | 772 | return false; | 
| 773 | 773 | } | 
| 774 | 774 | |
| 775 | - var scatts = "<?php echo addslashes(json_encode($shortcode_atts));?>"; | |
| 775 | + var scatts = "<?php echo addslashes(json_encode($shortcode_atts)); ?>"; | |
| 776 | 776 | |
| 777 | 777 |      var data = { | 
| 778 | 778 | 'action': 'geodir_sclistings', | 
| @@ -861,16 +861,16 @@ discard block | ||
| 861 | 861 |  	if ($max_page > 1 || $always_show) { | 
| 862 | 862 | // Extra pagination info | 
| 863 | 863 |  		$geodir_pagination_more_info = get_option('geodir_pagination_advance_info'); | 
| 864 | - $start_no = ( $pageno - 1 ) * $posts_per_page + 1; | |
| 864 | + $start_no = ($pageno - 1) * $posts_per_page + 1; | |
| 865 | 865 | $end_no = min($pageno * $posts_per_page, $numposts); | 
| 866 | 866 | |
| 867 | 867 |  		if ($geodir_pagination_more_info != '') { | 
| 868 | -			$pagination_info = '<div class="gd-pagination-details gd-pagination-details-' . $geodir_pagination_more_info . '">' . wp_sprintf(__('Showing listings %d-%d of %d', 'geodirectory'), $start_no, $end_no, $numposts) . '</div>'; | |
| 868 | +			$pagination_info = '<div class="gd-pagination-details gd-pagination-details-'.$geodir_pagination_more_info.'">'.wp_sprintf(__('Showing listings %d-%d of %d', 'geodirectory'), $start_no, $end_no, $numposts).'</div>'; | |
| 869 | 869 | |
| 870 | 870 |  			if ($geodir_pagination_more_info == 'before') { | 
| 871 | - $before = $before . $pagination_info; | |
| 871 | + $before = $before.$pagination_info; | |
| 872 | 872 |  			} else if ($geodir_pagination_more_info == 'after') { | 
| 873 | - $after = $pagination_info . $after; | |
| 873 | + $after = $pagination_info.$after; | |
| 874 | 874 | } | 
| 875 | 875 | } | 
| 876 | 876 | |
| @@ -880,7 +880,7 @@ discard block | ||
| 880 | 880 | } | 
| 881 | 881 | |
| 882 | 882 |  		if (($pageno - 1) > 0) { | 
| 883 | - echo '<a class="gd-page-sc-prev gd-wgt-page" data-page="' . (int)($pageno - 1) . '" href="javascript:void(0);">' . $prelabel . '</a> '; | |
| 883 | + echo '<a class="gd-page-sc-prev gd-wgt-page" data-page="'.(int) ($pageno - 1).'" href="javascript:void(0);">'.$prelabel.'</a> '; | |
| 884 | 884 | } | 
| 885 | 885 | |
| 886 | 886 |  		for ($i = $pageno - $half_pages_to_show; $i <= $pageno + $half_pages_to_show; $i++) { | 
| @@ -888,17 +888,17 @@ discard block | ||
| 888 | 888 |  				if ($i == $pageno) { | 
| 889 | 889 | echo "<strong class='on' class='gd-page-sc-act'>$i</strong>"; | 
| 890 | 890 |  				} else { | 
| 891 | - echo ' <a class="gd-page-sc-no gd-wgt-page" data-page="' . (int)$i . '" href="javascript:void(0);">' . $i . '</a> '; | |
| 891 | + echo ' <a class="gd-page-sc-no gd-wgt-page" data-page="'.(int) $i.'" href="javascript:void(0);">'.$i.'</a> '; | |
| 892 | 892 | } | 
| 893 | 893 | } | 
| 894 | 894 | } | 
| 895 | 895 | |
| 896 | 896 |  		if (($pageno + 1) <= $max_page) { | 
| 897 | - echo ' <a class="gd-page-sc-nxt gd-wgt-page" data-page="' . (int)($pageno + 1) . '" href="javascript:void(0);">' . $nxtlabel . '</a>'; | |
| 897 | + echo ' <a class="gd-page-sc-nxt gd-wgt-page" data-page="'.(int) ($pageno + 1).'" href="javascript:void(0);">'.$nxtlabel.'</a>'; | |
| 898 | 898 | } | 
| 899 | 899 | |
| 900 | 900 |  		if ($pageno < $max_page) { | 
| 901 | - echo ' <a class="gd-page-sc-lst gd-wgt-page" data-page="' . (int)$max_page . '" href="javascript:void(0);">»</a>'; | |
| 901 | + echo ' <a class="gd-page-sc-lst gd-wgt-page" data-page="'.(int) $max_page.'" href="javascript:void(0);">»</a>'; | |
| 902 | 902 | } | 
| 903 | 903 | echo "</div> $after </div>"; | 
| 904 | 904 | } | 
| @@ -921,7 +921,7 @@ discard block | ||
| 921 | 921 | $scatts = isset($_POST['scatts']) ? $_POST['scatts'] : NULL; | 
| 922 | 922 | $pageno = isset($_POST['pageno']) ? absint($_POST['pageno']) : 1; | 
| 923 | 923 | |
| 924 | - $shortcode_atts = !empty($scatts) ? (array)json_decode(stripslashes_deep($scatts)) : NULL; | |
| 924 | + $shortcode_atts = !empty($scatts) ? (array) json_decode(stripslashes_deep($scatts)) : NULL; | |
| 925 | 925 | |
| 926 | 926 |  	if (!empty($shortcode_atts) && is_array($shortcode_atts)) { | 
| 927 | 927 | $shortcode_atts['pageno'] = $pageno; | 
| @@ -13,7 +13,7 @@ discard block | ||
| 13 | 13 | * @package GeoDirectory | 
| 14 | 14 | * @global object $current_user Current user object. | 
| 15 | 15 | * @param bool $redirect Optional. Do you want to redirect to signup page, if user not logged in? Default: false. | 
| 16 | - * @return bool | |
| 16 | + * @return null|boolean | |
| 17 | 17 | */ | 
| 18 | 18 | function geodir_is_login($redirect = false) | 
| 19 | 19 |  {
 | 
| @@ -69,7 +69,7 @@ discard block | ||
| 69 | 69 | * | 
| 70 | 70 | * @since 1.0.0 | 
| 71 | 71 | * @package GeoDirectory | 
| 72 | - * @return string|mixed|void The email ID. | |
| 72 | + * @return string The email ID. | |
| 73 | 73 | */ | 
| 74 | 74 | function geodir_get_site_email_id() | 
| 75 | 75 |  {
 | 
| @@ -17,18 +17,18 @@ discard block | ||
| 17 | 17 | */ | 
| 18 | 18 | function geodir_is_login($redirect = false) | 
| 19 | 19 |  {
 | 
| 20 | - global $current_user; | |
| 21 | -    if (!$current_user->ID) {
 | |
| 22 | -        if ($redirect) {
 | |
| 23 | - ?> | |
| 20 | + global $current_user; | |
| 21 | +	if (!$current_user->ID) {
 | |
| 22 | +		if ($redirect) {
 | |
| 23 | + ?> | |
| 24 | 24 | <script type="text/javascript"> | 
| 25 | 25 | window.location.href = '<?php echo geodir_login_url();?>'; | 
| 26 | 26 | </script> | 
| 27 | 27 | <?php | 
| 28 | - } else | |
| 29 | - return false; | |
| 30 | - } else | |
| 31 | - return true; | |
| 28 | + } else | |
| 29 | + return false; | |
| 30 | + } else | |
| 31 | + return true; | |
| 32 | 32 | } | 
| 33 | 33 | |
| 34 | 34 | /** | 
| @@ -42,25 +42,25 @@ discard block | ||
| 42 | 42 |  {
 | 
| 43 | 43 | |
| 44 | 44 | // Redirect to https login if forced to use SSL | 
| 45 | -    if (force_ssl_admin() && !is_ssl()) {
 | |
| 46 | -        if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
 | |
| 47 | -            wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
 | |
| 48 | - exit(); | |
| 49 | -        } else {
 | |
| 50 | -            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
 | |
| 51 | - exit(); | |
| 52 | - } | |
| 53 | - } | |
| 54 | - | |
| 55 | - /** | |
| 56 | - * Filter the login message. | |
| 57 | - * | |
| 58 | - * @since 1.0.0 | |
| 59 | - * | |
| 60 | - * @param string $message Login message. | |
| 61 | - */ | |
| 62 | -    $message = apply_filters('login_message', $message);
 | |
| 63 | - if (!empty($message)) echo $message . "\n"; | |
| 45 | +	if (force_ssl_admin() && !is_ssl()) {
 | |
| 46 | +		if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
 | |
| 47 | +			wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
 | |
| 48 | + exit(); | |
| 49 | +		} else {
 | |
| 50 | +			wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
 | |
| 51 | + exit(); | |
| 52 | + } | |
| 53 | + } | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * Filter the login message. | |
| 57 | + * | |
| 58 | + * @since 1.0.0 | |
| 59 | + * | |
| 60 | + * @param string $message Login message. | |
| 61 | + */ | |
| 62 | +	$message = apply_filters('login_message', $message);
 | |
| 63 | + if (!empty($message)) echo $message . "\n"; | |
| 64 | 64 | |
| 65 | 65 | } | 
| 66 | 66 | |
| @@ -73,59 +73,59 @@ discard block | ||
| 73 | 73 | */ | 
| 74 | 74 | function geodir_get_site_email_id() | 
| 75 | 75 |  {
 | 
| 76 | -    if (get_option('site_email')) {
 | |
| 76 | +	if (get_option('site_email')) {
 | |
| 77 | 77 | |
| 78 | -        return get_option('site_email');
 | |
| 78 | +		return get_option('site_email');
 | |
| 79 | 79 | |
| 80 | -    } else {
 | |
| 80 | +	} else {
 | |
| 81 | 81 | |
| 82 | -        return get_option('admin_email');
 | |
| 82 | +		return get_option('admin_email');
 | |
| 83 | 83 | |
| 84 | - } | |
| 84 | + } | |
| 85 | 85 | |
| 86 | 86 | } | 
| 87 | 87 | |
| 88 | 88 | |
| 89 | 89 |  if (!function_exists('get_site_emailName')) {
 | 
| 90 | - /** | |
| 91 | - * Get site name for sending emails. | |
| 92 | - * | |
| 93 | - * @since 1.0.0 | |
| 94 | - * @package GeoDirectory | |
| 95 | - * @return string Site name. | |
| 96 | - */ | |
| 97 | - function get_site_emailName() | |
| 90 | + /** | |
| 91 | + * Get site name for sending emails. | |
| 92 | + * | |
| 93 | + * @since 1.0.0 | |
| 94 | + * @package GeoDirectory | |
| 95 | + * @return string Site name. | |
| 96 | + */ | |
| 97 | + function get_site_emailName() | |
| 98 | 98 | |
| 99 | -    {
 | |
| 99 | +	{
 | |
| 100 | 100 | |
| 101 | -        if (get_option('site_email_name')) {
 | |
| 101 | +		if (get_option('site_email_name')) {
 | |
| 102 | 102 | |
| 103 | -            return stripslashes(get_option('site_email_name'));
 | |
| 103 | +			return stripslashes(get_option('site_email_name'));
 | |
| 104 | 104 | |
| 105 | -        } else {
 | |
| 105 | +		} else {
 | |
| 106 | 106 | |
| 107 | -            return stripslashes(get_option('blogname'));
 | |
| 107 | +			return stripslashes(get_option('blogname'));
 | |
| 108 | 108 | |
| 109 | - } | |
| 109 | + } | |
| 110 | 110 | |
| 111 | - } | |
| 111 | + } | |
| 112 | 112 | } | 
| 113 | 113 | |
| 114 | 114 |  if (!function_exists('is_allow_user_register')) {
 | 
| 115 | - /** | |
| 116 | - * Checks whether the site allowing user registration or not. | |
| 117 | - * | |
| 118 | - * @since 1.0.0 | |
| 119 | - * @package GeoDirectory | |
| 120 | - * @return bool|string | |
| 121 | - */ | |
| 122 | - function is_allow_user_register() | |
| 115 | + /** | |
| 116 | + * Checks whether the site allowing user registration or not. | |
| 117 | + * | |
| 118 | + * @since 1.0.0 | |
| 119 | + * @package GeoDirectory | |
| 120 | + * @return bool|string | |
| 121 | + */ | |
| 122 | + function is_allow_user_register() | |
| 123 | 123 | |
| 124 | -    {
 | |
| 124 | +	{
 | |
| 125 | 125 | |
| 126 | -        return get_option('users_can_register');
 | |
| 126 | +		return get_option('users_can_register');
 | |
| 127 | 127 | |
| 128 | - } | |
| 128 | + } | |
| 129 | 129 | } | 
| 130 | 130 | |
| 131 | 131 | /** | 
| @@ -138,107 +138,107 @@ discard block | ||
| 138 | 138 | */ | 
| 139 | 139 | function geodir_retrieve_password() | 
| 140 | 140 |  {
 | 
| 141 | - global $wpdb; | |
| 142 | - | |
| 143 | - $errors = new WP_Error(); | |
| 144 | - if (empty($_POST['user_login']) && empty($_POST['user_email'])) | |
| 145 | -        $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.', 'geodirectory'));
 | |
| 146 | - | |
| 147 | -    if (strpos($_POST['user_login'], '@')) {
 | |
| 148 | - //$user_data = get_user_by_email(trim($_POST['user_login'])); | |
| 149 | -        $user_data = get_user_by('email', trim($_POST['user_login']));
 | |
| 150 | - if (empty($user_data)) | |
| 151 | -            $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.', 'geodirectory'));
 | |
| 152 | -    } else {
 | |
| 153 | - $login = trim($_POST['user_login']); | |
| 154 | -        $user_data = get_user_by('email', $login);
 | |
| 155 | - } | |
| 156 | - | |
| 157 | - /** | |
| 158 | - * Called in the geodir_retrieve_password() function before any errors are set or any emails are sent. | |
| 159 | - * | |
| 160 | - * @since 1.0.0 | |
| 161 | - */ | |
| 162 | -    do_action('lostpassword_post');
 | |
| 163 | - | |
| 164 | - if ($errors->get_error_code()) | |
| 165 | - return $errors; | |
| 166 | - | |
| 167 | -    if (!$user_data) {
 | |
| 168 | -        $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.', 'geodirectory'));
 | |
| 169 | - return $errors; | |
| 170 | - } | |
| 171 | - | |
| 172 | - // redefining user_login ensures we return the right case in the email | |
| 173 | - $user_login = $user_data->user_login; | |
| 174 | - $user_email = $user_data->user_email; | |
| 175 | - | |
| 176 | - /** | |
| 177 | - * Called in the geodir_retrieve_password() function before any emails are sent. | |
| 178 | - * | |
| 179 | - * @since 1.0.0 | |
| 180 | - * @param string $user_login The users username. | |
| 181 | - */ | |
| 182 | -    do_action('retrieve_password', $user_login);
 | |
| 183 | - | |
| 184 | - //////////////////////////////////// | |
| 185 | - $user_email = isset($_POST['user_email']) ? $_POST['user_email'] : ''; | |
| 186 | - $user_login = $_POST['user_login']; | |
| 187 | - | |
| 188 | - $user = $wpdb->get_row( | |
| 189 | - $wpdb->prepare( | |
| 190 | - "SELECT * FROM $wpdb->users WHERE user_login like %s or user_email like %s", | |
| 191 | - array($user_login, $user_login) | |
| 192 | - ) | |
| 193 | - ); | |
| 194 | - | |
| 195 | - if (empty($user)) | |
| 196 | -        return new WP_Error('invalid_key', __('Invalid key', 'geodirectory'));
 | |
| 197 | - | |
| 198 | - $new_pass = wp_generate_password(12, false); | |
| 199 | - | |
| 200 | - /** | |
| 201 | - * Called in the geodir_retrieve_password() function before any emails are sent. | |
| 202 | - * | |
| 203 | - * @since 1.0.0 | |
| 204 | - * @param object $user The user object. | |
| 205 | - * @param string $new_pass The new pass being sent to the user. | |
| 206 | - */ | |
| 207 | -    do_action('password_reset', $user, $new_pass);
 | |
| 208 | - | |
| 209 | - wp_set_password($new_pass, $user->ID); | |
| 210 | - update_user_meta($user->ID, 'default_password_nag', true); //Set up the Password change nag. | |
| 211 | -    $message = '<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p>';
 | |
| 212 | -    $message .= '<p>' . sprintf(__('Username: %s', 'geodirectory'), $user->user_login) . "</p>";
 | |
| 213 | -    $message .= '<p>' . sprintf(__('Password: %s', 'geodirectory'), $new_pass) . "</p>";
 | |
| 214 | - //$message .= '<p>You can login to : <a href="'.home_url().'/?ptype=login' . "\">Login</a> or the URL is : ".home_url()."/?ptype=login</p>"; | |
| 215 | -    //$message .= '<p>Thank You,<br> '.get_option('blogname').'</p>';
 | |
| 216 | - $user_email = $user_data->user_email; | |
| 217 | - $user_name = geodir_get_client_name($user->ID); | |
| 218 | - $fromEmail = geodir_get_site_email_id(); | |
| 219 | - $fromEmailName = get_site_emailName(); | |
| 220 | -    $title = sprintf(__('[%s] Your new password', 'geodirectory'), get_option('blogname'));
 | |
| 221 | - /** | |
| 222 | - * Filter the password reset email subject part. | |
| 223 | - * | |
| 224 | - * @since 1.0.0 | |
| 225 | - * | |
| 226 | - * @param string $title Password reset email subject. | |
| 227 | - */ | |
| 228 | -    $title = apply_filters('password_reset_title', $title);
 | |
| 229 | - /** | |
| 230 | - * Filter the password reset email message part. | |
| 231 | - * | |
| 232 | - * @since 1.0.0 | |
| 233 | - * | |
| 234 | - * @param string $message Password reset email message. | |
| 235 | - * @param string $new_pass The new password string. | |
| 236 | - */ | |
| 237 | -    $message = apply_filters('password_reset_message', $message, $new_pass);
 | |
| 238 | - //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$user_name,$title,$message,$extra='');///forgot password email | |
| 239 | - geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $user_name, $title, $message, $extra = '', 'forgot_password', $post_id = '', $user->ID);///forgot password email | |
| 240 | - | |
| 241 | - return true; | |
| 141 | + global $wpdb; | |
| 142 | + | |
| 143 | + $errors = new WP_Error(); | |
| 144 | + if (empty($_POST['user_login']) && empty($_POST['user_email'])) | |
| 145 | +		$errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.', 'geodirectory'));
 | |
| 146 | + | |
| 147 | +	if (strpos($_POST['user_login'], '@')) {
 | |
| 148 | + //$user_data = get_user_by_email(trim($_POST['user_login'])); | |
| 149 | +		$user_data = get_user_by('email', trim($_POST['user_login']));
 | |
| 150 | + if (empty($user_data)) | |
| 151 | +			$errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.', 'geodirectory'));
 | |
| 152 | +	} else {
 | |
| 153 | + $login = trim($_POST['user_login']); | |
| 154 | +		$user_data = get_user_by('email', $login);
 | |
| 155 | + } | |
| 156 | + | |
| 157 | + /** | |
| 158 | + * Called in the geodir_retrieve_password() function before any errors are set or any emails are sent. | |
| 159 | + * | |
| 160 | + * @since 1.0.0 | |
| 161 | + */ | |
| 162 | +	do_action('lostpassword_post');
 | |
| 163 | + | |
| 164 | + if ($errors->get_error_code()) | |
| 165 | + return $errors; | |
| 166 | + | |
| 167 | +	if (!$user_data) {
 | |
| 168 | +		$errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.', 'geodirectory'));
 | |
| 169 | + return $errors; | |
| 170 | + } | |
| 171 | + | |
| 172 | + // redefining user_login ensures we return the right case in the email | |
| 173 | + $user_login = $user_data->user_login; | |
| 174 | + $user_email = $user_data->user_email; | |
| 175 | + | |
| 176 | + /** | |
| 177 | + * Called in the geodir_retrieve_password() function before any emails are sent. | |
| 178 | + * | |
| 179 | + * @since 1.0.0 | |
| 180 | + * @param string $user_login The users username. | |
| 181 | + */ | |
| 182 | +	do_action('retrieve_password', $user_login);
 | |
| 183 | + | |
| 184 | + //////////////////////////////////// | |
| 185 | + $user_email = isset($_POST['user_email']) ? $_POST['user_email'] : ''; | |
| 186 | + $user_login = $_POST['user_login']; | |
| 187 | + | |
| 188 | + $user = $wpdb->get_row( | |
| 189 | + $wpdb->prepare( | |
| 190 | + "SELECT * FROM $wpdb->users WHERE user_login like %s or user_email like %s", | |
| 191 | + array($user_login, $user_login) | |
| 192 | + ) | |
| 193 | + ); | |
| 194 | + | |
| 195 | + if (empty($user)) | |
| 196 | +		return new WP_Error('invalid_key', __('Invalid key', 'geodirectory'));
 | |
| 197 | + | |
| 198 | + $new_pass = wp_generate_password(12, false); | |
| 199 | + | |
| 200 | + /** | |
| 201 | + * Called in the geodir_retrieve_password() function before any emails are sent. | |
| 202 | + * | |
| 203 | + * @since 1.0.0 | |
| 204 | + * @param object $user The user object. | |
| 205 | + * @param string $new_pass The new pass being sent to the user. | |
| 206 | + */ | |
| 207 | +	do_action('password_reset', $user, $new_pass);
 | |
| 208 | + | |
| 209 | + wp_set_password($new_pass, $user->ID); | |
| 210 | + update_user_meta($user->ID, 'default_password_nag', true); //Set up the Password change nag. | |
| 211 | +	$message = '<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p>';
 | |
| 212 | +	$message .= '<p>' . sprintf(__('Username: %s', 'geodirectory'), $user->user_login) . "</p>";
 | |
| 213 | +	$message .= '<p>' . sprintf(__('Password: %s', 'geodirectory'), $new_pass) . "</p>";
 | |
| 214 | + //$message .= '<p>You can login to : <a href="'.home_url().'/?ptype=login' . "\">Login</a> or the URL is : ".home_url()."/?ptype=login</p>"; | |
| 215 | +	//$message .= '<p>Thank You,<br> '.get_option('blogname').'</p>';
 | |
| 216 | + $user_email = $user_data->user_email; | |
| 217 | + $user_name = geodir_get_client_name($user->ID); | |
| 218 | + $fromEmail = geodir_get_site_email_id(); | |
| 219 | + $fromEmailName = get_site_emailName(); | |
| 220 | +	$title = sprintf(__('[%s] Your new password', 'geodirectory'), get_option('blogname'));
 | |
| 221 | + /** | |
| 222 | + * Filter the password reset email subject part. | |
| 223 | + * | |
| 224 | + * @since 1.0.0 | |
| 225 | + * | |
| 226 | + * @param string $title Password reset email subject. | |
| 227 | + */ | |
| 228 | +	$title = apply_filters('password_reset_title', $title);
 | |
| 229 | + /** | |
| 230 | + * Filter the password reset email message part. | |
| 231 | + * | |
| 232 | + * @since 1.0.0 | |
| 233 | + * | |
| 234 | + * @param string $message Password reset email message. | |
| 235 | + * @param string $new_pass The new password string. | |
| 236 | + */ | |
| 237 | +	$message = apply_filters('password_reset_message', $message, $new_pass);
 | |
| 238 | + //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$user_name,$title,$message,$extra='');///forgot password email | |
| 239 | + geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $user_name, $title, $message, $extra = '', 'forgot_password', $post_id = '', $user->ID);///forgot password email | |
| 240 | + | |
| 241 | + return true; | |
| 242 | 242 | } | 
| 243 | 243 | |
| 244 | 244 | /** | 
| @@ -253,80 +253,80 @@ discard block | ||
| 253 | 253 | */ | 
| 254 | 254 | function geodir_register_new_user($user_login, $user_email) | 
| 255 | 255 |  {
 | 
| 256 | - global $wpdb; | |
| 257 | - $errors = new WP_Error(); | |
| 258 | - | |
| 259 | - | |
| 260 | - $user_login = sanitize_user($user_login); | |
| 261 | -    $user_login = str_replace(",", "", $user_login);
 | |
| 262 | -    $user_email = str_replace(",", "", $user_email);
 | |
| 263 | - /** | |
| 264 | - * Filter the user registration email. | |
| 265 | - * | |
| 266 | - * @since 1.0.0 | |
| 267 | - * | |
| 268 | - * @param string $user_email User registration email. | |
| 269 | - */ | |
| 270 | -    $user_email = apply_filters('user_registration_email', $user_email);
 | |
| 271 | - | |
| 272 | - | |
| 273 | -    if (get_option('geodir_allow_cpass')) {
 | |
| 274 | - $user_pass = $_REQUEST['user_pass']; | |
| 275 | - $user_pass2 = $_REQUEST['user_pass2']; | |
| 276 | - // Check the password | |
| 277 | -        if ($user_pass != $user_pass2) {
 | |
| 278 | -            $errors->add('pass_match', __('ERROR: Passwords do not match.', 'geodirectory'));
 | |
| 279 | -        } elseif (strlen($user_pass) < 7) {
 | |
| 280 | -            $errors->add('pass_match', __('ERROR: Password must be 7 characters or more.', 'geodirectory'));
 | |
| 281 | - } | |
| 282 | - } | |
| 283 | - | |
| 284 | - // Check the username | |
| 285 | - if ($user_login == '') | |
| 286 | -        $errors->add('empty_username', __('ERROR: Please enter a username.', 'geodirectory'));
 | |
| 287 | -    elseif (!validate_username($user_login)) {
 | |
| 288 | -        $errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid.  Please enter a valid username.', 'geodirectory'));
 | |
| 289 | - $user_login = ''; | |
| 290 | - } elseif (username_exists($user_login)) | |
| 291 | -        $errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.', 'geodirectory'));
 | |
| 292 | - | |
| 293 | - // Check the e-mail address | |
| 294 | -    if ($user_email == '') {
 | |
| 295 | -        $errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.', 'geodirectory'));
 | |
| 296 | -    } elseif (!is_email($user_email)) {
 | |
| 297 | -        $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn’t correct.', 'geodirectory'));
 | |
| 298 | - $user_email = ''; | |
| 299 | - } elseif (email_exists($user_email)) | |
| 300 | -        $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.', 'geodirectory'));
 | |
| 301 | - | |
| 302 | - /** | |
| 303 | - * Called when registering a new user. | |
| 304 | - * | |
| 305 | - * This is a WordPress core hook. | |
| 306 | - * | |
| 307 | - * @link https://codex.wordpress.org/Plugin_API/Action_Reference/register_post | |
| 308 | - * @since 1.0.0 | |
| 309 | - */ | |
| 310 | -    do_action('register_post', $user_login, $user_email, $errors);
 | |
| 311 | - /** | |
| 312 | - * Filter the registration error messages. | |
| 313 | - * | |
| 314 | - * @since 1.0.0 | |
| 315 | - * | |
| 316 | - * @param object $errors Registration error messages. | |
| 317 | - */ | |
| 318 | -    $errors = apply_filters('registration_errors', $errors,$user_login,$user_email);
 | |
| 319 | - | |
| 320 | - if ($errors->get_error_code()) | |
| 321 | - return $errors; | |
| 322 | - | |
| 323 | - | |
| 324 | -    if (!isset($user_pass) || $user_pass == '') {
 | |
| 325 | - $user_pass = wp_generate_password(12, false); | |
| 326 | - } | |
| 327 | - $user_id = wp_create_user($user_login, $user_pass, $user_email); | |
| 328 | - $user_web = ''; | |
| 329 | - /*$user_add1 = $_POST['user_add1']; | |
| 256 | + global $wpdb; | |
| 257 | + $errors = new WP_Error(); | |
| 258 | + | |
| 259 | + | |
| 260 | + $user_login = sanitize_user($user_login); | |
| 261 | +	$user_login = str_replace(",", "", $user_login);
 | |
| 262 | +	$user_email = str_replace(",", "", $user_email);
 | |
| 263 | + /** | |
| 264 | + * Filter the user registration email. | |
| 265 | + * | |
| 266 | + * @since 1.0.0 | |
| 267 | + * | |
| 268 | + * @param string $user_email User registration email. | |
| 269 | + */ | |
| 270 | +	$user_email = apply_filters('user_registration_email', $user_email);
 | |
| 271 | + | |
| 272 | + | |
| 273 | +	if (get_option('geodir_allow_cpass')) {
 | |
| 274 | + $user_pass = $_REQUEST['user_pass']; | |
| 275 | + $user_pass2 = $_REQUEST['user_pass2']; | |
| 276 | + // Check the password | |
| 277 | +		if ($user_pass != $user_pass2) {
 | |
| 278 | +			$errors->add('pass_match', __('ERROR: Passwords do not match.', 'geodirectory'));
 | |
| 279 | +		} elseif (strlen($user_pass) < 7) {
 | |
| 280 | +			$errors->add('pass_match', __('ERROR: Password must be 7 characters or more.', 'geodirectory'));
 | |
| 281 | + } | |
| 282 | + } | |
| 283 | + | |
| 284 | + // Check the username | |
| 285 | + if ($user_login == '') | |
| 286 | +		$errors->add('empty_username', __('ERROR: Please enter a username.', 'geodirectory'));
 | |
| 287 | +	elseif (!validate_username($user_login)) {
 | |
| 288 | +		$errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid.  Please enter a valid username.', 'geodirectory'));
 | |
| 289 | + $user_login = ''; | |
| 290 | + } elseif (username_exists($user_login)) | |
| 291 | +		$errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.', 'geodirectory'));
 | |
| 292 | + | |
| 293 | + // Check the e-mail address | |
| 294 | +	if ($user_email == '') {
 | |
| 295 | +		$errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.', 'geodirectory'));
 | |
| 296 | +	} elseif (!is_email($user_email)) {
 | |
| 297 | +		$errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn’t correct.', 'geodirectory'));
 | |
| 298 | + $user_email = ''; | |
| 299 | + } elseif (email_exists($user_email)) | |
| 300 | +		$errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.', 'geodirectory'));
 | |
| 301 | + | |
| 302 | + /** | |
| 303 | + * Called when registering a new user. | |
| 304 | + * | |
| 305 | + * This is a WordPress core hook. | |
| 306 | + * | |
| 307 | + * @link https://codex.wordpress.org/Plugin_API/Action_Reference/register_post | |
| 308 | + * @since 1.0.0 | |
| 309 | + */ | |
| 310 | +	do_action('register_post', $user_login, $user_email, $errors);
 | |
| 311 | + /** | |
| 312 | + * Filter the registration error messages. | |
| 313 | + * | |
| 314 | + * @since 1.0.0 | |
| 315 | + * | |
| 316 | + * @param object $errors Registration error messages. | |
| 317 | + */ | |
| 318 | +	$errors = apply_filters('registration_errors', $errors,$user_login,$user_email);
 | |
| 319 | + | |
| 320 | + if ($errors->get_error_code()) | |
| 321 | + return $errors; | |
| 322 | + | |
| 323 | + | |
| 324 | +	if (!isset($user_pass) || $user_pass == '') {
 | |
| 325 | + $user_pass = wp_generate_password(12, false); | |
| 326 | + } | |
| 327 | + $user_id = wp_create_user($user_login, $user_pass, $user_email); | |
| 328 | + $user_web = ''; | |
| 329 | + /*$user_add1 = $_POST['user_add1']; | |
| 330 | 330 | $user_add2 = $_POST['user_add2']; | 
| 331 | 331 | $user_city = $_POST['user_city']; | 
| 332 | 332 | $user_state = $_POST['user_state']; | 
| @@ -335,77 +335,77 @@ discard block | ||
| 335 | 335 | $user_web = $_POST['user_web']; | 
| 336 | 336 | $user_phone = $_POST['user_phone']; | 
| 337 | 337 | $user_twitter = $_POST['user_twitter']; */ | 
| 338 | - $user_fname = sanitize_user($_POST['user_fname']); | |
| 339 | -    $user_fname = str_replace(",", "", $user_fname);
 | |
| 340 | - | |
| 341 | - /** | |
| 342 | - * Filter the submitted user meta. | |
| 343 | - * | |
| 344 | - * @since 1.0.0 | |
| 345 | - * | |
| 346 | - * @param int $user_id User ID. | |
| 347 | - */ | |
| 348 | -    $user_address_info = apply_filters('geodir_manage_user_meta', array(
 | |
| 349 | - "user_add1" => '', | |
| 350 | - "user_add2" => '', | |
| 351 | - "user_city" => '', | |
| 352 | - "user_state" => '', | |
| 353 | - "user_country" => '', | |
| 354 | - "user_postalcode" => '', | |
| 355 | - "user_phone" => '', | |
| 356 | - "user_twitter" => '', | |
| 357 | - "first_name" => $user_fname, | |
| 358 | - "last_name" => '', | |
| 359 | - ), $user_id); | |
| 360 | -    foreach ($user_address_info as $key => $val) {
 | |
| 361 | - update_user_meta($user_id, $key, $val); // User Address Information Here | |
| 362 | - } | |
| 363 | - //update_user_meta($user_id, 'user_address_info', ($user_address_info)); // User Address Information Here | |
| 364 | - $userName = $user_fname; | |
| 365 | - update_user_meta($user_id, 'first_name', $userName); // User Address Information Here | |
| 366 | - //update_user_meta($user_id, 'last_name', $_POST['user_lname']); // User Address Information Here | |
| 367 | - | |
| 368 | - // Changed by vikas sharma to enable all type of characters in author permalink... | |
| 369 | - $user_nicename = sanitize_title($userName); | |
| 370 | - | |
| 371 | -    $updateUsersql = $wpdb->prepare("update $wpdb->users set user_url=%s, user_nicename=%s, display_name=%s  where ID=%d", array($user_web, $user_nicename, $userName, $user_id));
 | |
| 372 | - | |
| 373 | - $wpdb->query($updateUsersql); | |
| 374 | - | |
| 375 | -    if (!$user_id) {
 | |
| 376 | -        $errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !', 'geodirectory'), get_option('admin_email')));
 | |
| 377 | - return $errors; | |
| 378 | - } | |
| 379 | - global $upload_folder_path; | |
| 380 | - | |
| 381 | -    if ($user_id) {
 | |
| 382 | - | |
| 383 | - /** | |
| 384 | - * Called after registering a user and before the registration email is sent. | |
| 385 | - * | |
| 386 | - * @since 1.0.0 | |
| 387 | - * @param int $user_id The user ID of the registered user. | |
| 388 | - */ | |
| 389 | -        do_action('geodir_user_register', $user_id);
 | |
| 390 | - ///////REGISTRATION EMAIL START////// | |
| 391 | - $fromEmail = geodir_get_site_email_id(); | |
| 392 | - $fromEmailName = get_site_emailName(); | |
| 393 | -        $message = __('<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p>
 | |
| 338 | + $user_fname = sanitize_user($_POST['user_fname']); | |
| 339 | +	$user_fname = str_replace(",", "", $user_fname);
 | |
| 340 | + | |
| 341 | + /** | |
| 342 | + * Filter the submitted user meta. | |
| 343 | + * | |
| 344 | + * @since 1.0.0 | |
| 345 | + * | |
| 346 | + * @param int $user_id User ID. | |
| 347 | + */ | |
| 348 | +	$user_address_info = apply_filters('geodir_manage_user_meta', array(
 | |
| 349 | + "user_add1" => '', | |
| 350 | + "user_add2" => '', | |
| 351 | + "user_city" => '', | |
| 352 | + "user_state" => '', | |
| 353 | + "user_country" => '', | |
| 354 | + "user_postalcode" => '', | |
| 355 | + "user_phone" => '', | |
| 356 | + "user_twitter" => '', | |
| 357 | + "first_name" => $user_fname, | |
| 358 | + "last_name" => '', | |
| 359 | + ), $user_id); | |
| 360 | +	foreach ($user_address_info as $key => $val) {
 | |
| 361 | + update_user_meta($user_id, $key, $val); // User Address Information Here | |
| 362 | + } | |
| 363 | + //update_user_meta($user_id, 'user_address_info', ($user_address_info)); // User Address Information Here | |
| 364 | + $userName = $user_fname; | |
| 365 | + update_user_meta($user_id, 'first_name', $userName); // User Address Information Here | |
| 366 | + //update_user_meta($user_id, 'last_name', $_POST['user_lname']); // User Address Information Here | |
| 367 | + | |
| 368 | + // Changed by vikas sharma to enable all type of characters in author permalink... | |
| 369 | + $user_nicename = sanitize_title($userName); | |
| 370 | + | |
| 371 | +	$updateUsersql = $wpdb->prepare("update $wpdb->users set user_url=%s, user_nicename=%s, display_name=%s  where ID=%d", array($user_web, $user_nicename, $userName, $user_id));
 | |
| 372 | + | |
| 373 | + $wpdb->query($updateUsersql); | |
| 374 | + | |
| 375 | +	if (!$user_id) {
 | |
| 376 | +		$errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !', 'geodirectory'), get_option('admin_email')));
 | |
| 377 | + return $errors; | |
| 378 | + } | |
| 379 | + global $upload_folder_path; | |
| 380 | + | |
| 381 | +	if ($user_id) {
 | |
| 382 | + | |
| 383 | + /** | |
| 384 | + * Called after registering a user and before the registration email is sent. | |
| 385 | + * | |
| 386 | + * @since 1.0.0 | |
| 387 | + * @param int $user_id The user ID of the registered user. | |
| 388 | + */ | |
| 389 | +		do_action('geodir_user_register', $user_id);
 | |
| 390 | + ///////REGISTRATION EMAIL START////// | |
| 391 | + $fromEmail = geodir_get_site_email_id(); | |
| 392 | + $fromEmailName = get_site_emailName(); | |
| 393 | +		$message = __('<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p>
 | |
| 394 | 394 |  <p>' . __('Username:', 'geodirectory') . ' ' . $user_login . '</p>
 | 
| 395 | 395 |  <p>' . __('Password:', 'geodirectory') . ' ' . $user_pass . '</p>');
 | 
| 396 | 396 | |
| 397 | - /////////////customer email////////////// | |
| 398 | - //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$userName,$subject,$client_message,$extra='');///To client email | |
| 399 | - geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $userName, '', $message, '', 'registration', '', $user_id);/// registration email | |
| 400 | - //////REGISTRATION EMAIL END//////// | |
| 401 | - } | |
| 397 | + /////////////customer email////////////// | |
| 398 | + //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$userName,$subject,$client_message,$extra='');///To client email | |
| 399 | + geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $userName, '', $message, '', 'registration', '', $user_id);/// registration email | |
| 400 | + //////REGISTRATION EMAIL END//////// | |
| 401 | + } | |
| 402 | 402 | |
| 403 | -    if (get_option('ptthemes_auto_login')) {
 | |
| 404 | -        $errors->add('auto_login', __('<strong>SUCCESS</strong>: Thank you for registering, please check your email for your login details.', 'geodirectory'));
 | |
| 405 | - return $errors; | |
| 406 | - } | |
| 403 | +	if (get_option('ptthemes_auto_login')) {
 | |
| 404 | +		$errors->add('auto_login', __('<strong>SUCCESS</strong>: Thank you for registering, please check your email for your login details.', 'geodirectory'));
 | |
| 405 | + return $errors; | |
| 406 | + } | |
| 407 | 407 | |
| 408 | - return array($user_id, $user_pass); | |
| 408 | + return array($user_id, $user_pass); | |
| 409 | 409 | } | 
| 410 | 410 | |
| 411 | 411 | /** | 
| @@ -418,317 +418,317 @@ discard block | ||
| 418 | 418 | */ | 
| 419 | 419 | function geodir_user_signup() | 
| 420 | 420 |  {
 | 
| 421 | - global $errors; | |
| 422 | - $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login'; | |
| 423 | - | |
| 424 | - $errors = new WP_Error(); | |
| 425 | - | |
| 426 | - if (isset($_GET['key'])) | |
| 427 | - $action = 'resetpass'; | |
| 428 | - | |
| 429 | - // validate action so as to default to the login screen | |
| 430 | -    if (!in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login')) && false === has_filter('login_form_' . $action))
 | |
| 431 | - $action = 'login'; | |
| 432 | - | |
| 433 | - nocache_headers(); | |
| 434 | - | |
| 435 | -    if (defined('RELOCATE')) { // Move flag is set
 | |
| 436 | - if (isset($_SERVER['PATH_INFO']) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF'])) | |
| 437 | - $_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF']); | |
| 438 | - | |
| 439 | - $schema = (isset($_SERVER['HTTPS']) && geodir_strtolower($_SERVER['HTTPS']) == 'on') ? 'https://' : 'http://'; | |
| 440 | - if (dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != home_url()) | |
| 441 | -            update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']));
 | |
| 442 | - } | |
| 443 | - | |
| 444 | - //Set a cookie now to see if they are supported by the browser. | |
| 445 | - //setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN); | |
| 446 | - if (SITECOOKIEPATH != COOKIEPATH) | |
| 447 | - setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN); | |
| 448 | - | |
| 449 | - /** | |
| 450 | - * Allow plugins to override the default actions, and to add extra actions if they want on the register/signin page. | |
| 451 | - * | |
| 452 | - * Used dynamic hook login_form_$action | |
| 453 | - * | |
| 454 | - * @since 1.0.0 | |
| 455 | - */ | |
| 456 | -    do_action('login_form_' . $action);
 | |
| 457 | - | |
| 458 | -    $http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
 | |
| 459 | - | |
| 460 | - switch ($action): | |
| 461 | - | |
| 462 | - case 'logout' : | |
| 463 | -            //check_admin_referer('log-out');
 | |
| 464 | - wp_logout(); | |
| 465 | - | |
| 466 | - $redirect_to = $_SERVER['HTTP_REFERER']; | |
| 467 | - //$redirect_to = home_url().'/?ptype=login&loggedout=true'; | |
| 468 | - if (isset($_REQUEST['redirect_to'])) | |
| 469 | - $redirect_to = $_REQUEST['redirect_to']; | |
| 470 | - $redirect_to = home_url(); | |
| 471 | - wp_safe_redirect($redirect_to); | |
| 472 | - exit(); | |
| 473 | - | |
| 474 | - break; | |
| 475 | - | |
| 476 | - case 'lostpassword' : | |
| 477 | - case 'retrievepassword' : | |
| 478 | -            if ($http_post) {
 | |
| 479 | - $errors = geodir_retrieve_password(); | |
| 480 | - $error_message = isset($errors->errors['invalid_email'][0]) ? $errors->errors['invalid_email'][0] : ''; | |
| 481 | -                if (!is_wp_error($errors)) {
 | |
| 482 | -                    wp_redirect(geodir_login_url(array('checkemail'=>'confirm')));
 | |
| 483 | - gd_die(); | |
| 484 | -                } else {
 | |
| 485 | -                    wp_redirect(geodir_login_url(array('forgot' => 1, 'emsg'=>'fw')));
 | |
| 486 | - gd_die(); | |
| 487 | - } | |
| 488 | - } | |
| 489 | -            if (isset($_GET['error']) && 'invalidkey' == $_GET['error']) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.', 'geodirectory'));
 | |
| 490 | - /** | |
| 491 | - * Called in the geodir_user_signup() function during the lostpassword case. | |
| 492 | - * | |
| 493 | - * @since 1.0.0 | |
| 494 | - */ | |
| 495 | -        do_action('lost_password');
 | |
| 496 | - $message = '<div class="sucess_msg">' . ENTER_USER_EMAIL_NEW_PW_MSG . '</div>'; | |
| 497 | - $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : ''; | |
| 498 | - | |
| 499 | - break; | |
| 500 | - | |
| 501 | - case 'resetpass' : | |
| 502 | - case 'rp' : | |
| 503 | - $errors = reset_password($_GET['key'], $_GET['login']); | |
| 504 | - | |
| 505 | -            if (!is_wp_error($errors)) {
 | |
| 506 | -                wp_redirect(geodir_login_url(array('checkemail'=>'newpass')));
 | |
| 507 | - exit(); | |
| 508 | - } | |
| 509 | - | |
| 510 | -            wp_redirect(geodir_login_url(array('error'=>'invalidkey','action'=>'lostpassword')));
 | |
| 511 | - exit(); | |
| 512 | - | |
| 513 | - break; | |
| 514 | - | |
| 515 | - case 'register' : | |
| 516 | - ############################### fix by Stiofan - HebTech.co.uk ### SECURITY FIX ############################## | |
| 517 | -            if (!get_option('users_can_register')) {
 | |
| 518 | -                wp_redirect(geodir_login_url(array('emsg'=>'regnewusr')));
 | |
| 519 | - exit(); | |
| 520 | - } | |
| 521 | - ############################### fix by Stiofan - HebTech.co.uk ### SECURITY FIX ############################## | |
| 522 | - global $user_email, $user_fname; | |
| 523 | - $user_login = ''; | |
| 524 | - $user_email = ''; | |
| 525 | -            if ($http_post) {
 | |
| 526 | - $user_login = $_POST['user_email']; | |
| 527 | - $user_email = $_POST['user_email']; | |
| 528 | - $user_fname = $_POST['user_fname']; | |
| 529 | - | |
| 530 | - $errors = geodir_register_new_user($user_login, $user_email); | |
| 531 | - | |
| 532 | - /* display error in registration form */ | |
| 533 | -                if (is_wp_error($errors)) {
 | |
| 534 | - $error_code = $errors->get_error_code(); | |
| 535 | - $error_message = $errors->get_error_message($error_code); | |
| 536 | -                    if (!isset($_POST['user_login']) && ($error_code == 'empty_username' || $error_code == 'invalid_username' || $error_code == 'username_exists')) {
 | |
| 537 | -                        if ($error_code == 'empty_username') {
 | |
| 538 | - $error_code = 'empty_email'; | |
| 539 | -                        } else if ($error_code == 'invalid_username') {
 | |
| 540 | - $error_code = 'invalid_email'; | |
| 541 | -                        } else if ($error_code == 'username_exists') {
 | |
| 542 | - $error_code = 'email_exists'; | |
| 543 | - } | |
| 544 | - | |
| 545 | - $error_message = $errors->get_error_message($error_code); | |
| 546 | - } | |
| 547 | - global $geodir_signup_error; | |
| 548 | - $geodir_signup_error = $error_message; | |
| 549 | - } | |
| 550 | - | |
| 551 | -                if (!is_wp_error($errors)) {
 | |
| 552 | - $_POST['log'] = $user_login; | |
| 553 | - $_POST['pwd'] = $errors[1]; | |
| 554 | - $_POST['testcookie'] = 1; | |
| 555 | - | |
| 556 | - $secure_cookie = ''; | |
| 557 | - // If the user wants ssl but the session is not ssl, force a secure cookie. | |
| 558 | -                    if (!empty($_POST['log'])) {
 | |
| 559 | - $user_name = sanitize_user($_POST['log']); | |
| 560 | -                        if ($user = get_user_by('email', $user_name)) {
 | |
| 561 | -                            if (get_user_option('use_ssl', $user->ID)) {
 | |
| 562 | - $secure_cookie = true; | |
| 563 | - force_ssl_admin(true); | |
| 564 | - } | |
| 565 | - } | |
| 566 | - } | |
| 567 | - | |
| 568 | - $redirect_to = $_REQUEST['redirect_to']; | |
| 569 | - | |
| 570 | -                    if (!isset($_REQUEST['redirect_to']) || $_REQUEST['redirect_to'] == '') {
 | |
| 571 | -                        if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], home_url())) {
 | |
| 572 | - $redirect_to = $_SERVER['HTTP_REFERER']; | |
| 573 | -                        } else {
 | |
| 574 | - $redirect_to = home_url(); | |
| 575 | - } | |
| 576 | - | |
| 577 | - } | |
| 578 | - | |
| 579 | -                    if (isset($_REQUEST['redirect_add_listing']) && $_REQUEST['redirect_add_listing'] != '') {
 | |
| 580 | - | |
| 581 | - $redirect_to = $_REQUEST['redirect_add_listing']; | |
| 582 | - } | |
| 583 | - | |
| 584 | - | |
| 585 | - if (!$secure_cookie && is_ssl() && force_ssl_admin() && !force_ssl_admin() && (0 !== strpos($redirect_to, 'https')) && (0 === strpos($redirect_to, 'http'))) | |
| 586 | - $secure_cookie = false; | |
| 587 | - | |
| 588 | -                    $user = wp_signon('', $secure_cookie);
 | |
| 589 | - | |
| 590 | - $requested_redirect_to = isset($_REQUEST['redirect_add_listing']) && $_REQUEST['redirect_add_listing'] != '' ? $_REQUEST['redirect_add_listing'] : (isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : ''); | |
| 591 | - /** | |
| 592 | - * Filter the login redirect URL. | |
| 593 | - * | |
| 594 | - * @since 1.4.9 | |
| 595 | - * @param string $redirect_to The redirect destination URL. | |
| 596 | - * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter. | |
| 597 | - * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise. | |
| 598 | - */ | |
| 599 | -                    $redirect_to = apply_filters('login_redirect', $redirect_to, $requested_redirect_to, $user);
 | |
| 600 | - | |
| 601 | - | |
| 602 | -                    if (!is_wp_error($user)) {
 | |
| 603 | - wp_safe_redirect($redirect_to); | |
| 604 | - exit(); | |
| 605 | - } | |
| 606 | - exit(); | |
| 607 | - } | |
| 608 | - } | |
| 609 | - | |
| 610 | - break; | |
| 611 | - | |
| 612 | - case 'login' : | |
| 613 | - default: | |
| 614 | - $secure_cookie = ''; | |
| 615 | - | |
| 616 | -            if (!empty($_POST['log'])) {
 | |
| 617 | - $user_name = sanitize_user($_POST['log']); | |
| 618 | -                if ($user = get_user_by('login', $user_name)) {
 | |
| 619 | - | |
| 620 | -                    if (get_user_option('use_ssl', $user->ID)) {
 | |
| 621 | - $secure_cookie = true; | |
| 622 | - force_ssl_admin(true); | |
| 623 | - } | |
| 624 | -                } elseif ($user = get_user_by('email', $user_name)) {
 | |
| 625 | - $_POST['log'] = $user->user_login; // If signing in by email, set the username for normal WP login | |
| 626 | -                    if (get_user_option('use_ssl', $user->ID)) {
 | |
| 627 | - $secure_cookie = true; | |
| 628 | - force_ssl_admin(true); | |
| 629 | - } | |
| 630 | - } | |
| 631 | - } | |
| 632 | - /////////////////////////// | |
| 633 | -            if (isset($_REQUEST['redirect_add_listing'])) {
 | |
| 634 | - $_REQUEST['redirect_to'] = $_REQUEST['redirect_add_listing']; | |
| 635 | - } | |
| 636 | - | |
| 637 | - | |
| 638 | -            if (!isset($_REQUEST['redirect_to']) || $_REQUEST['redirect_to'] == '') {
 | |
| 639 | - if (is_user_logged_in()) : | |
| 640 | - $user_ID = isset($user->ID) ? $user->ID : ''; | |
| 641 | - $author_link = get_author_posts_url($user_ID); | |
| 642 | -                    $default_author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => 'gd_place'), false);
 | |
| 643 | - | |
| 644 | - /** | |
| 645 | - * Filter the author link. | |
| 646 | - * | |
| 647 | - * @since 1.0.0 | |
| 648 | - * | |
| 649 | - * @param string $default_author_link Default author link. | |
| 650 | - * @param int $user_ID The user ID. | |
| 651 | - */ | |
| 652 | -                    $default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_ID);
 | |
| 653 | - | |
| 654 | - $_REQUEST['redirect_to'] = $default_author_link; | |
| 655 | - else: | |
| 656 | - $_REQUEST['redirect_to'] = home_url(); | |
| 657 | - endif; | |
| 658 | - | |
| 659 | - } | |
| 660 | -            if (isset($_REQUEST['redirect_to'])) {
 | |
| 661 | - $redirect_to = $_REQUEST['redirect_to']; | |
| 662 | - // Redirect to https if user wants ssl | |
| 663 | - if ($secure_cookie && false !== strpos($redirect_to, 'wp-admin')) | |
| 664 | -                    $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
 | |
| 665 | -            } else {
 | |
| 666 | - $redirect_to = admin_url(); | |
| 667 | - } | |
| 668 | - | |
| 669 | - if (!$secure_cookie && is_ssl() && force_ssl_admin() && !force_ssl_admin() && (0 !== strpos($redirect_to, 'https')) && (0 === strpos($redirect_to, 'http'))) | |
| 670 | - $secure_cookie = false; | |
| 671 | -            $user = wp_signon('', $secure_cookie);
 | |
| 672 | - | |
| 673 | - | |
| 674 | - /** | |
| 675 | - * Filter the login redirect URL. | |
| 676 | - * | |
| 677 | - * @since 1.4.9 | |
| 678 | - * @param string $redirect_to The redirect destination URL. | |
| 679 | - * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise. | |
| 680 | - */ | |
| 681 | -            $redirect_to = apply_filters('login_redirect', $redirect_to, isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '', $user);
 | |
| 682 | - | |
| 683 | -            if (is_wp_error($user)) {
 | |
| 684 | -                if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], 'ptype=property_submit') && $_POST['log'] != '' && $_POST['pwd'] != '') {
 | |
| 685 | - wp_redirect($_SERVER['HTTP_REFERER'] . '&emsg=1'); | |
| 686 | - } | |
| 687 | - } | |
| 688 | -            if (!is_wp_error($user)) {
 | |
| 689 | - | |
| 690 | - // Some servers are not logging the user in properly after wp_signon, se we set the user here. | |
| 691 | - //wp_set_current_user($user->ID); | |
| 692 | - //echo '###';exit; | |
| 693 | - | |
| 694 | -                if ($redirect_to) {
 | |
| 695 | - wp_redirect($redirect_to); | |
| 696 | -                } else {
 | |
| 697 | - wp_redirect(home_url()); | |
| 698 | - } | |
| 699 | - gd_die(); | |
| 700 | - } | |
| 701 | - | |
| 702 | - $errors = $user; | |
| 703 | - | |
| 704 | - // Clear errors if loggedout is set. | |
| 705 | - if (!empty($_GET['loggedout'])) | |
| 706 | - $errors = new WP_Error(); | |
| 707 | - // If cookies are disabled we can't log in even with a valid user+pass | |
| 708 | - if (isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE])) | |
| 709 | -                $errors->add('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress.", 'geodirectory'));
 | |
| 710 | - | |
| 711 | - // Some parts of this script use the main login form to display a message | |
| 712 | -            if (isset($_GET['loggedout']) && TRUE == $_GET['loggedout']) {
 | |
| 713 | - $successmsg = '<div class="sucess_msg">' . YOU_ARE_LOGED_OUT_MSG . '</div>'; | |
| 714 | -            } elseif (isset($_GET['registration']) && 'disabled' == $_GET['registration']) {
 | |
| 715 | - $successmsg = USER_REG_NOT_ALLOW_MSG; | |
| 716 | -            } elseif (isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail']) {
 | |
| 717 | - $successmsg = EMAIL_CONFIRM_LINK_MSG; | |
| 718 | -            } elseif (isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail']) {
 | |
| 719 | - $successmsg = NEW_PW_EMAIL_MSG; | |
| 720 | -            } elseif (isset($_GET['checkemail']) && 'registered' == $_GET['checkemail']) {
 | |
| 721 | - $successmsg = REG_COMPLETE_MSG; | |
| 722 | - } | |
| 723 | - | |
| 724 | -            if ((isset($_POST['log']) && $_POST['log'] != '' && $errors) || ((!isset($_POST['log']) || $_POST['log'] == '') && isset($_REQUEST['testcookie']) && $_REQUEST['testcookie'])) {
 | |
| 725 | -                if (isset($_REQUEST['pagetype']) && $_REQUEST['pagetype'] != '') {
 | |
| 726 | - wp_redirect($_REQUEST['pagetype'] . '&emsg=1'); | |
| 727 | -                } else {
 | |
| 728 | -                    wp_redirect(geodir_login_url(array('logemsg'=>'1','redirect_to'=>urlencode($_REQUEST['redirect_to']))));
 | |
| 729 | - } | |
| 730 | - gd_die(); | |
| 731 | - } | |
| 732 | - break; | |
| 733 | - endswitch; // end action switch | |
| 421 | + global $errors; | |
| 422 | + $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login'; | |
| 423 | + | |
| 424 | + $errors = new WP_Error(); | |
| 425 | + | |
| 426 | + if (isset($_GET['key'])) | |
| 427 | + $action = 'resetpass'; | |
| 428 | + | |
| 429 | + // validate action so as to default to the login screen | |
| 430 | +	if (!in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login')) && false === has_filter('login_form_' . $action))
 | |
| 431 | + $action = 'login'; | |
| 432 | + | |
| 433 | + nocache_headers(); | |
| 434 | + | |
| 435 | +	if (defined('RELOCATE')) { // Move flag is set
 | |
| 436 | + if (isset($_SERVER['PATH_INFO']) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF'])) | |
| 437 | + $_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF']); | |
| 438 | + | |
| 439 | + $schema = (isset($_SERVER['HTTPS']) && geodir_strtolower($_SERVER['HTTPS']) == 'on') ? 'https://' : 'http://'; | |
| 440 | + if (dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != home_url()) | |
| 441 | +			update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']));
 | |
| 442 | + } | |
| 443 | + | |
| 444 | + //Set a cookie now to see if they are supported by the browser. | |
| 445 | + //setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN); | |
| 446 | + if (SITECOOKIEPATH != COOKIEPATH) | |
| 447 | + setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN); | |
| 448 | + | |
| 449 | + /** | |
| 450 | + * Allow plugins to override the default actions, and to add extra actions if they want on the register/signin page. | |
| 451 | + * | |
| 452 | + * Used dynamic hook login_form_$action | |
| 453 | + * | |
| 454 | + * @since 1.0.0 | |
| 455 | + */ | |
| 456 | +	do_action('login_form_' . $action);
 | |
| 457 | + | |
| 458 | +	$http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
 | |
| 459 | + | |
| 460 | + switch ($action): | |
| 461 | + | |
| 462 | + case 'logout' : | |
| 463 | +			//check_admin_referer('log-out');
 | |
| 464 | + wp_logout(); | |
| 465 | + | |
| 466 | + $redirect_to = $_SERVER['HTTP_REFERER']; | |
| 467 | + //$redirect_to = home_url().'/?ptype=login&loggedout=true'; | |
| 468 | + if (isset($_REQUEST['redirect_to'])) | |
| 469 | + $redirect_to = $_REQUEST['redirect_to']; | |
| 470 | + $redirect_to = home_url(); | |
| 471 | + wp_safe_redirect($redirect_to); | |
| 472 | + exit(); | |
| 473 | + | |
| 474 | + break; | |
| 475 | + | |
| 476 | + case 'lostpassword' : | |
| 477 | + case 'retrievepassword' : | |
| 478 | +			if ($http_post) {
 | |
| 479 | + $errors = geodir_retrieve_password(); | |
| 480 | + $error_message = isset($errors->errors['invalid_email'][0]) ? $errors->errors['invalid_email'][0] : ''; | |
| 481 | +				if (!is_wp_error($errors)) {
 | |
| 482 | +					wp_redirect(geodir_login_url(array('checkemail'=>'confirm')));
 | |
| 483 | + gd_die(); | |
| 484 | +				} else {
 | |
| 485 | +					wp_redirect(geodir_login_url(array('forgot' => 1, 'emsg'=>'fw')));
 | |
| 486 | + gd_die(); | |
| 487 | + } | |
| 488 | + } | |
| 489 | +			if (isset($_GET['error']) && 'invalidkey' == $_GET['error']) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.', 'geodirectory'));
 | |
| 490 | + /** | |
| 491 | + * Called in the geodir_user_signup() function during the lostpassword case. | |
| 492 | + * | |
| 493 | + * @since 1.0.0 | |
| 494 | + */ | |
| 495 | +		do_action('lost_password');
 | |
| 496 | + $message = '<div class="sucess_msg">' . ENTER_USER_EMAIL_NEW_PW_MSG . '</div>'; | |
| 497 | + $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : ''; | |
| 498 | + | |
| 499 | + break; | |
| 500 | + | |
| 501 | + case 'resetpass' : | |
| 502 | + case 'rp' : | |
| 503 | + $errors = reset_password($_GET['key'], $_GET['login']); | |
| 504 | + | |
| 505 | +			if (!is_wp_error($errors)) {
 | |
| 506 | +				wp_redirect(geodir_login_url(array('checkemail'=>'newpass')));
 | |
| 507 | + exit(); | |
| 508 | + } | |
| 509 | + | |
| 510 | +			wp_redirect(geodir_login_url(array('error'=>'invalidkey','action'=>'lostpassword')));
 | |
| 511 | + exit(); | |
| 512 | + | |
| 513 | + break; | |
| 514 | + | |
| 515 | + case 'register' : | |
| 516 | + ############################### fix by Stiofan - HebTech.co.uk ### SECURITY FIX ############################## | |
| 517 | +			if (!get_option('users_can_register')) {
 | |
| 518 | +				wp_redirect(geodir_login_url(array('emsg'=>'regnewusr')));
 | |
| 519 | + exit(); | |
| 520 | + } | |
| 521 | + ############################### fix by Stiofan - HebTech.co.uk ### SECURITY FIX ############################## | |
| 522 | + global $user_email, $user_fname; | |
| 523 | + $user_login = ''; | |
| 524 | + $user_email = ''; | |
| 525 | +			if ($http_post) {
 | |
| 526 | + $user_login = $_POST['user_email']; | |
| 527 | + $user_email = $_POST['user_email']; | |
| 528 | + $user_fname = $_POST['user_fname']; | |
| 529 | + | |
| 530 | + $errors = geodir_register_new_user($user_login, $user_email); | |
| 531 | + | |
| 532 | + /* display error in registration form */ | |
| 533 | +				if (is_wp_error($errors)) {
 | |
| 534 | + $error_code = $errors->get_error_code(); | |
| 535 | + $error_message = $errors->get_error_message($error_code); | |
| 536 | +					if (!isset($_POST['user_login']) && ($error_code == 'empty_username' || $error_code == 'invalid_username' || $error_code == 'username_exists')) {
 | |
| 537 | +						if ($error_code == 'empty_username') {
 | |
| 538 | + $error_code = 'empty_email'; | |
| 539 | +						} else if ($error_code == 'invalid_username') {
 | |
| 540 | + $error_code = 'invalid_email'; | |
| 541 | +						} else if ($error_code == 'username_exists') {
 | |
| 542 | + $error_code = 'email_exists'; | |
| 543 | + } | |
| 544 | + | |
| 545 | + $error_message = $errors->get_error_message($error_code); | |
| 546 | + } | |
| 547 | + global $geodir_signup_error; | |
| 548 | + $geodir_signup_error = $error_message; | |
| 549 | + } | |
| 550 | + | |
| 551 | +				if (!is_wp_error($errors)) {
 | |
| 552 | + $_POST['log'] = $user_login; | |
| 553 | + $_POST['pwd'] = $errors[1]; | |
| 554 | + $_POST['testcookie'] = 1; | |
| 555 | + | |
| 556 | + $secure_cookie = ''; | |
| 557 | + // If the user wants ssl but the session is not ssl, force a secure cookie. | |
| 558 | +					if (!empty($_POST['log'])) {
 | |
| 559 | + $user_name = sanitize_user($_POST['log']); | |
| 560 | +						if ($user = get_user_by('email', $user_name)) {
 | |
| 561 | +							if (get_user_option('use_ssl', $user->ID)) {
 | |
| 562 | + $secure_cookie = true; | |
| 563 | + force_ssl_admin(true); | |
| 564 | + } | |
| 565 | + } | |
| 566 | + } | |
| 567 | + | |
| 568 | + $redirect_to = $_REQUEST['redirect_to']; | |
| 569 | + | |
| 570 | +					if (!isset($_REQUEST['redirect_to']) || $_REQUEST['redirect_to'] == '') {
 | |
| 571 | +						if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], home_url())) {
 | |
| 572 | + $redirect_to = $_SERVER['HTTP_REFERER']; | |
| 573 | +						} else {
 | |
| 574 | + $redirect_to = home_url(); | |
| 575 | + } | |
| 576 | + | |
| 577 | + } | |
| 578 | + | |
| 579 | +					if (isset($_REQUEST['redirect_add_listing']) && $_REQUEST['redirect_add_listing'] != '') {
 | |
| 580 | + | |
| 581 | + $redirect_to = $_REQUEST['redirect_add_listing']; | |
| 582 | + } | |
| 583 | + | |
| 584 | + | |
| 585 | + if (!$secure_cookie && is_ssl() && force_ssl_admin() && !force_ssl_admin() && (0 !== strpos($redirect_to, 'https')) && (0 === strpos($redirect_to, 'http'))) | |
| 586 | + $secure_cookie = false; | |
| 587 | + | |
| 588 | +					$user = wp_signon('', $secure_cookie);
 | |
| 589 | + | |
| 590 | + $requested_redirect_to = isset($_REQUEST['redirect_add_listing']) && $_REQUEST['redirect_add_listing'] != '' ? $_REQUEST['redirect_add_listing'] : (isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : ''); | |
| 591 | + /** | |
| 592 | + * Filter the login redirect URL. | |
| 593 | + * | |
| 594 | + * @since 1.4.9 | |
| 595 | + * @param string $redirect_to The redirect destination URL. | |
| 596 | + * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter. | |
| 597 | + * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise. | |
| 598 | + */ | |
| 599 | +					$redirect_to = apply_filters('login_redirect', $redirect_to, $requested_redirect_to, $user);
 | |
| 600 | + | |
| 601 | + | |
| 602 | +					if (!is_wp_error($user)) {
 | |
| 603 | + wp_safe_redirect($redirect_to); | |
| 604 | + exit(); | |
| 605 | + } | |
| 606 | + exit(); | |
| 607 | + } | |
| 608 | + } | |
| 609 | + | |
| 610 | + break; | |
| 611 | + | |
| 612 | + case 'login' : | |
| 613 | + default: | |
| 614 | + $secure_cookie = ''; | |
| 615 | + | |
| 616 | +			if (!empty($_POST['log'])) {
 | |
| 617 | + $user_name = sanitize_user($_POST['log']); | |
| 618 | +				if ($user = get_user_by('login', $user_name)) {
 | |
| 619 | + | |
| 620 | +					if (get_user_option('use_ssl', $user->ID)) {
 | |
| 621 | + $secure_cookie = true; | |
| 622 | + force_ssl_admin(true); | |
| 623 | + } | |
| 624 | +				} elseif ($user = get_user_by('email', $user_name)) {
 | |
| 625 | + $_POST['log'] = $user->user_login; // If signing in by email, set the username for normal WP login | |
| 626 | +					if (get_user_option('use_ssl', $user->ID)) {
 | |
| 627 | + $secure_cookie = true; | |
| 628 | + force_ssl_admin(true); | |
| 629 | + } | |
| 630 | + } | |
| 631 | + } | |
| 632 | + /////////////////////////// | |
| 633 | +			if (isset($_REQUEST['redirect_add_listing'])) {
 | |
| 634 | + $_REQUEST['redirect_to'] = $_REQUEST['redirect_add_listing']; | |
| 635 | + } | |
| 636 | + | |
| 637 | + | |
| 638 | +			if (!isset($_REQUEST['redirect_to']) || $_REQUEST['redirect_to'] == '') {
 | |
| 639 | + if (is_user_logged_in()) : | |
| 640 | + $user_ID = isset($user->ID) ? $user->ID : ''; | |
| 641 | + $author_link = get_author_posts_url($user_ID); | |
| 642 | +					$default_author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => 'gd_place'), false);
 | |
| 643 | + | |
| 644 | + /** | |
| 645 | + * Filter the author link. | |
| 646 | + * | |
| 647 | + * @since 1.0.0 | |
| 648 | + * | |
| 649 | + * @param string $default_author_link Default author link. | |
| 650 | + * @param int $user_ID The user ID. | |
| 651 | + */ | |
| 652 | +					$default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_ID);
 | |
| 653 | + | |
| 654 | + $_REQUEST['redirect_to'] = $default_author_link; | |
| 655 | + else: | |
| 656 | + $_REQUEST['redirect_to'] = home_url(); | |
| 657 | + endif; | |
| 658 | + | |
| 659 | + } | |
| 660 | +			if (isset($_REQUEST['redirect_to'])) {
 | |
| 661 | + $redirect_to = $_REQUEST['redirect_to']; | |
| 662 | + // Redirect to https if user wants ssl | |
| 663 | + if ($secure_cookie && false !== strpos($redirect_to, 'wp-admin')) | |
| 664 | +					$redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
 | |
| 665 | +			} else {
 | |
| 666 | + $redirect_to = admin_url(); | |
| 667 | + } | |
| 668 | + | |
| 669 | + if (!$secure_cookie && is_ssl() && force_ssl_admin() && !force_ssl_admin() && (0 !== strpos($redirect_to, 'https')) && (0 === strpos($redirect_to, 'http'))) | |
| 670 | + $secure_cookie = false; | |
| 671 | +			$user = wp_signon('', $secure_cookie);
 | |
| 672 | + | |
| 673 | + | |
| 674 | + /** | |
| 675 | + * Filter the login redirect URL. | |
| 676 | + * | |
| 677 | + * @since 1.4.9 | |
| 678 | + * @param string $redirect_to The redirect destination URL. | |
| 679 | + * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise. | |
| 680 | + */ | |
| 681 | +			$redirect_to = apply_filters('login_redirect', $redirect_to, isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '', $user);
 | |
| 682 | + | |
| 683 | +			if (is_wp_error($user)) {
 | |
| 684 | +				if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], 'ptype=property_submit') && $_POST['log'] != '' && $_POST['pwd'] != '') {
 | |
| 685 | + wp_redirect($_SERVER['HTTP_REFERER'] . '&emsg=1'); | |
| 686 | + } | |
| 687 | + } | |
| 688 | +			if (!is_wp_error($user)) {
 | |
| 689 | + | |
| 690 | + // Some servers are not logging the user in properly after wp_signon, se we set the user here. | |
| 691 | + //wp_set_current_user($user->ID); | |
| 692 | + //echo '###';exit; | |
| 693 | + | |
| 694 | +				if ($redirect_to) {
 | |
| 695 | + wp_redirect($redirect_to); | |
| 696 | +				} else {
 | |
| 697 | + wp_redirect(home_url()); | |
| 698 | + } | |
| 699 | + gd_die(); | |
| 700 | + } | |
| 701 | + | |
| 702 | + $errors = $user; | |
| 703 | + | |
| 704 | + // Clear errors if loggedout is set. | |
| 705 | + if (!empty($_GET['loggedout'])) | |
| 706 | + $errors = new WP_Error(); | |
| 707 | + // If cookies are disabled we can't log in even with a valid user+pass | |
| 708 | + if (isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE])) | |
| 709 | +				$errors->add('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress.", 'geodirectory'));
 | |
| 710 | + | |
| 711 | + // Some parts of this script use the main login form to display a message | |
| 712 | +			if (isset($_GET['loggedout']) && TRUE == $_GET['loggedout']) {
 | |
| 713 | + $successmsg = '<div class="sucess_msg">' . YOU_ARE_LOGED_OUT_MSG . '</div>'; | |
| 714 | +			} elseif (isset($_GET['registration']) && 'disabled' == $_GET['registration']) {
 | |
| 715 | + $successmsg = USER_REG_NOT_ALLOW_MSG; | |
| 716 | +			} elseif (isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail']) {
 | |
| 717 | + $successmsg = EMAIL_CONFIRM_LINK_MSG; | |
| 718 | +			} elseif (isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail']) {
 | |
| 719 | + $successmsg = NEW_PW_EMAIL_MSG; | |
| 720 | +			} elseif (isset($_GET['checkemail']) && 'registered' == $_GET['checkemail']) {
 | |
| 721 | + $successmsg = REG_COMPLETE_MSG; | |
| 722 | + } | |
| 723 | + | |
| 724 | +			if ((isset($_POST['log']) && $_POST['log'] != '' && $errors) || ((!isset($_POST['log']) || $_POST['log'] == '') && isset($_REQUEST['testcookie']) && $_REQUEST['testcookie'])) {
 | |
| 725 | +				if (isset($_REQUEST['pagetype']) && $_REQUEST['pagetype'] != '') {
 | |
| 726 | + wp_redirect($_REQUEST['pagetype'] . '&emsg=1'); | |
| 727 | +				} else {
 | |
| 728 | +					wp_redirect(geodir_login_url(array('logemsg'=>'1','redirect_to'=>urlencode($_REQUEST['redirect_to']))));
 | |
| 729 | + } | |
| 730 | + gd_die(); | |
| 731 | + } | |
| 732 | + break; | |
| 733 | + endswitch; // end action switch | |
| 734 | 734 | } | 
| 735 | 735 | \ No newline at end of file | 
| @@ -22,7 +22,7 @@ discard block | ||
| 22 | 22 |          if ($redirect) {
 | 
| 23 | 23 | ?> | 
| 24 | 24 | <script type="text/javascript"> | 
| 25 | - window.location.href = '<?php echo geodir_login_url();?>'; | |
| 25 | + window.location.href = '<?php echo geodir_login_url(); ?>'; | |
| 26 | 26 | </script> | 
| 27 | 27 | <?php | 
| 28 | 28 | } else | 
| @@ -47,7 +47,7 @@ discard block | ||
| 47 | 47 |              wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
 | 
| 48 | 48 | exit(); | 
| 49 | 49 |          } else {
 | 
| 50 | -            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
 | |
| 50 | +            wp_redirect('https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
 | |
| 51 | 51 | exit(); | 
| 52 | 52 | } | 
| 53 | 53 | } | 
| @@ -60,7 +60,7 @@ discard block | ||
| 60 | 60 | * @param string $message Login message. | 
| 61 | 61 | */ | 
| 62 | 62 |      $message = apply_filters('login_message', $message);
 | 
| 63 | - if (!empty($message)) echo $message . "\n"; | |
| 63 | + if (!empty($message)) echo $message."\n"; | |
| 64 | 64 | |
| 65 | 65 | } | 
| 66 | 66 | |
| @@ -208,9 +208,9 @@ discard block | ||
| 208 | 208 | |
| 209 | 209 | wp_set_password($new_pass, $user->ID); | 
| 210 | 210 | update_user_meta($user->ID, 'default_password_nag', true); //Set up the Password change nag. | 
| 211 | -    $message = '<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p>';
 | |
| 212 | -    $message .= '<p>' . sprintf(__('Username: %s', 'geodirectory'), $user->user_login) . "</p>";
 | |
| 213 | -    $message .= '<p>' . sprintf(__('Password: %s', 'geodirectory'), $new_pass) . "</p>";
 | |
| 211 | +    $message = '<p><b>'.__('Your login Information :', 'geodirectory').'</b></p>';
 | |
| 212 | +    $message .= '<p>'.sprintf(__('Username: %s', 'geodirectory'), $user->user_login)."</p>";
 | |
| 213 | +    $message .= '<p>'.sprintf(__('Password: %s', 'geodirectory'), $new_pass)."</p>";
 | |
| 214 | 214 | //$message .= '<p>You can login to : <a href="'.home_url().'/?ptype=login' . "\">Login</a> or the URL is : ".home_url()."/?ptype=login</p>"; | 
| 215 | 215 |      //$message .= '<p>Thank You,<br> '.get_option('blogname').'</p>';
 | 
| 216 | 216 | $user_email = $user_data->user_email; | 
| @@ -236,7 +236,7 @@ discard block | ||
| 236 | 236 | */ | 
| 237 | 237 |      $message = apply_filters('password_reset_message', $message, $new_pass);
 | 
| 238 | 238 | //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$user_name,$title,$message,$extra='');///forgot password email | 
| 239 | - geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $user_name, $title, $message, $extra = '', 'forgot_password', $post_id = '', $user->ID);///forgot password email | |
| 239 | + geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $user_name, $title, $message, $extra = '', 'forgot_password', $post_id = '', $user->ID); ///forgot password email | |
| 240 | 240 | |
| 241 | 241 | return true; | 
| 242 | 242 | } | 
| @@ -315,7 +315,7 @@ discard block | ||
| 315 | 315 | * | 
| 316 | 316 | * @param object $errors Registration error messages. | 
| 317 | 317 | */ | 
| 318 | -    $errors = apply_filters('registration_errors', $errors,$user_login,$user_email);
 | |
| 318 | +    $errors = apply_filters('registration_errors', $errors, $user_login, $user_email);
 | |
| 319 | 319 | |
| 320 | 320 | if ($errors->get_error_code()) | 
| 321 | 321 | return $errors; | 
| @@ -390,13 +390,13 @@ discard block | ||
| 390 | 390 | ///////REGISTRATION EMAIL START////// | 
| 391 | 391 | $fromEmail = geodir_get_site_email_id(); | 
| 392 | 392 | $fromEmailName = get_site_emailName(); | 
| 393 | -        $message = __('<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p>
 | |
| 394 | -<p>' . __('Username:', 'geodirectory') . ' ' . $user_login . '</p>
 | |
| 395 | -<p>' . __('Password:', 'geodirectory') . ' ' . $user_pass . '</p>');
 | |
| 393 | +        $message = __('<p><b>'.__('Your login Information :', 'geodirectory').'</b></p>
 | |
| 394 | +<p>' . __('Username:', 'geodirectory').' '.$user_login.'</p>
 | |
| 395 | +<p>' . __('Password:', 'geodirectory').' '.$user_pass.'</p>');
 | |
| 396 | 396 | |
| 397 | 397 | /////////////customer email////////////// | 
| 398 | 398 | //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$userName,$subject,$client_message,$extra='');///To client email | 
| 399 | - geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $userName, '', $message, '', 'registration', '', $user_id);/// registration email | |
| 399 | + geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $userName, '', $message, '', 'registration', '', $user_id); /// registration email | |
| 400 | 400 | //////REGISTRATION EMAIL END//////// | 
| 401 | 401 | } | 
| 402 | 402 | |
| @@ -427,7 +427,7 @@ discard block | ||
| 427 | 427 | $action = 'resetpass'; | 
| 428 | 428 | |
| 429 | 429 | // validate action so as to default to the login screen | 
| 430 | -    if (!in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login')) && false === has_filter('login_form_' . $action))
 | |
| 430 | +    if (!in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login')) && false === has_filter('login_form_'.$action))
 | |
| 431 | 431 | $action = 'login'; | 
| 432 | 432 | |
| 433 | 433 | nocache_headers(); | 
| @@ -437,8 +437,8 @@ discard block | ||
| 437 | 437 | $_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF']); | 
| 438 | 438 | |
| 439 | 439 | $schema = (isset($_SERVER['HTTPS']) && geodir_strtolower($_SERVER['HTTPS']) == 'on') ? 'https://' : 'http://'; | 
| 440 | - if (dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != home_url()) | |
| 441 | -            update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']));
 | |
| 440 | + if (dirname($schema.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']) != home_url()) | |
| 441 | +            update_option('siteurl', dirname($schema.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']));
 | |
| 442 | 442 | } | 
| 443 | 443 | |
| 444 | 444 | //Set a cookie now to see if they are supported by the browser. | 
| @@ -453,7 +453,7 @@ discard block | ||
| 453 | 453 | * | 
| 454 | 454 | * @since 1.0.0 | 
| 455 | 455 | */ | 
| 456 | -    do_action('login_form_' . $action);
 | |
| 456 | +    do_action('login_form_'.$action);
 | |
| 457 | 457 | |
| 458 | 458 |      $http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
 | 
| 459 | 459 | |
| @@ -493,7 +493,7 @@ discard block | ||
| 493 | 493 | * @since 1.0.0 | 
| 494 | 494 | */ | 
| 495 | 495 |          do_action('lost_password');
 | 
| 496 | - $message = '<div class="sucess_msg">' . ENTER_USER_EMAIL_NEW_PW_MSG . '</div>'; | |
| 496 | + $message = '<div class="sucess_msg">'.ENTER_USER_EMAIL_NEW_PW_MSG.'</div>'; | |
| 497 | 497 | $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : ''; | 
| 498 | 498 | |
| 499 | 499 | break; | 
| @@ -507,7 +507,7 @@ discard block | ||
| 507 | 507 | exit(); | 
| 508 | 508 | } | 
| 509 | 509 | |
| 510 | -            wp_redirect(geodir_login_url(array('error'=>'invalidkey','action'=>'lostpassword')));
 | |
| 510 | +            wp_redirect(geodir_login_url(array('error'=>'invalidkey', 'action'=>'lostpassword')));
 | |
| 511 | 511 | exit(); | 
| 512 | 512 | |
| 513 | 513 | break; | 
| @@ -682,7 +682,7 @@ discard block | ||
| 682 | 682 | |
| 683 | 683 |              if (is_wp_error($user)) {
 | 
| 684 | 684 |                  if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], 'ptype=property_submit') && $_POST['log'] != '' && $_POST['pwd'] != '') {
 | 
| 685 | - wp_redirect($_SERVER['HTTP_REFERER'] . '&emsg=1'); | |
| 685 | + wp_redirect($_SERVER['HTTP_REFERER'].'&emsg=1'); | |
| 686 | 686 | } | 
| 687 | 687 | } | 
| 688 | 688 |              if (!is_wp_error($user)) {
 | 
| @@ -710,7 +710,7 @@ discard block | ||
| 710 | 710 | |
| 711 | 711 | // Some parts of this script use the main login form to display a message | 
| 712 | 712 |              if (isset($_GET['loggedout']) && TRUE == $_GET['loggedout']) {
 | 
| 713 | - $successmsg = '<div class="sucess_msg">' . YOU_ARE_LOGED_OUT_MSG . '</div>'; | |
| 713 | + $successmsg = '<div class="sucess_msg">'.YOU_ARE_LOGED_OUT_MSG.'</div>'; | |
| 714 | 714 |              } elseif (isset($_GET['registration']) && 'disabled' == $_GET['registration']) {
 | 
| 715 | 715 | $successmsg = USER_REG_NOT_ALLOW_MSG; | 
| 716 | 716 |              } elseif (isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail']) {
 | 
| @@ -723,9 +723,9 @@ discard block | ||
| 723 | 723 | |
| 724 | 724 |              if ((isset($_POST['log']) && $_POST['log'] != '' && $errors) || ((!isset($_POST['log']) || $_POST['log'] == '') && isset($_REQUEST['testcookie']) && $_REQUEST['testcookie'])) {
 | 
| 725 | 725 |                  if (isset($_REQUEST['pagetype']) && $_REQUEST['pagetype'] != '') {
 | 
| 726 | - wp_redirect($_REQUEST['pagetype'] . '&emsg=1'); | |
| 726 | + wp_redirect($_REQUEST['pagetype'].'&emsg=1'); | |
| 727 | 727 |                  } else {
 | 
| 728 | -                    wp_redirect(geodir_login_url(array('logemsg'=>'1','redirect_to'=>urlencode($_REQUEST['redirect_to']))));
 | |
| 728 | +                    wp_redirect(geodir_login_url(array('logemsg'=>'1', 'redirect_to'=>urlencode($_REQUEST['redirect_to']))));
 | |
| 729 | 729 | } | 
| 730 | 730 | gd_die(); | 
| 731 | 731 | } | 
| @@ -25,11 +25,13 @@ discard block | ||
| 25 | 25 | window.location.href = '<?php echo geodir_login_url();?>'; | 
| 26 | 26 | </script> | 
| 27 | 27 | <?php | 
| 28 | - } else | |
| 29 | - return false; | |
| 30 | - } else | |
| 31 | - return true; | |
| 32 | -} | |
| 28 | +        } else { | |
| 29 | + return false; | |
| 30 | + } | |
| 31 | +    } else { | |
| 32 | + return true; | |
| 33 | + } | |
| 34 | + } | |
| 33 | 35 | |
| 34 | 36 | /** | 
| 35 | 37 | * Redirect to SSL url, if SSL is being used. | 
| @@ -60,7 +62,9 @@ discard block | ||
| 60 | 62 | * @param string $message Login message. | 
| 61 | 63 | */ | 
| 62 | 64 |      $message = apply_filters('login_message', $message);
 | 
| 63 | - if (!empty($message)) echo $message . "\n"; | |
| 65 | +    if (!empty($message)) { | |
| 66 | + echo $message . "\n"; | |
| 67 | + } | |
| 64 | 68 | |
| 65 | 69 | } | 
| 66 | 70 | |
| @@ -141,14 +145,16 @@ discard block | ||
| 141 | 145 | global $wpdb; | 
| 142 | 146 | |
| 143 | 147 | $errors = new WP_Error(); | 
| 144 | - if (empty($_POST['user_login']) && empty($_POST['user_email'])) | |
| 145 | -        $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.', 'geodirectory'));
 | |
| 148 | +    if (empty($_POST['user_login']) && empty($_POST['user_email'])) { | |
| 149 | +            $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.', 'geodirectory')); | |
| 150 | + } | |
| 146 | 151 | |
| 147 | 152 |      if (strpos($_POST['user_login'], '@')) {
 | 
| 148 | 153 | //$user_data = get_user_by_email(trim($_POST['user_login'])); | 
| 149 | 154 |          $user_data = get_user_by('email', trim($_POST['user_login']));
 | 
| 150 | - if (empty($user_data)) | |
| 151 | -            $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.', 'geodirectory'));
 | |
| 155 | +        if (empty($user_data)) { | |
| 156 | +                    $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.', 'geodirectory')); | |
| 157 | + } | |
| 152 | 158 |      } else {
 | 
| 153 | 159 | $login = trim($_POST['user_login']); | 
| 154 | 160 |          $user_data = get_user_by('email', $login);
 | 
| @@ -161,8 +167,9 @@ discard block | ||
| 161 | 167 | */ | 
| 162 | 168 |      do_action('lostpassword_post');
 | 
| 163 | 169 | |
| 164 | - if ($errors->get_error_code()) | |
| 165 | - return $errors; | |
| 170 | +    if ($errors->get_error_code()) { | |
| 171 | + return $errors; | |
| 172 | + } | |
| 166 | 173 | |
| 167 | 174 |      if (!$user_data) {
 | 
| 168 | 175 |          $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.', 'geodirectory'));
 | 
| @@ -192,8 +199,9 @@ discard block | ||
| 192 | 199 | ) | 
| 193 | 200 | ); | 
| 194 | 201 | |
| 195 | - if (empty($user)) | |
| 196 | -        return new WP_Error('invalid_key', __('Invalid key', 'geodirectory'));
 | |
| 202 | +    if (empty($user)) { | |
| 203 | +            return new WP_Error('invalid_key', __('Invalid key', 'geodirectory')); | |
| 204 | + } | |
| 197 | 205 | |
| 198 | 206 | $new_pass = wp_generate_password(12, false); | 
| 199 | 207 | |
| @@ -282,13 +290,14 @@ discard block | ||
| 282 | 290 | } | 
| 283 | 291 | |
| 284 | 292 | // Check the username | 
| 285 | - if ($user_login == '') | |
| 286 | -        $errors->add('empty_username', __('ERROR: Please enter a username.', 'geodirectory'));
 | |
| 287 | -    elseif (!validate_username($user_login)) {
 | |
| 293 | +    if ($user_login == '') { | |
| 294 | +            $errors->add('empty_username', __('ERROR: Please enter a username.', 'geodirectory')); | |
| 295 | +    } elseif (!validate_username($user_login)) {
 | |
| 288 | 296 |          $errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid.  Please enter a valid username.', 'geodirectory'));
 | 
| 289 | 297 | $user_login = ''; | 
| 290 | - } elseif (username_exists($user_login)) | |
| 291 | -        $errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.', 'geodirectory'));
 | |
| 298 | +    } elseif (username_exists($user_login)) { | |
| 299 | +            $errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.', 'geodirectory')); | |
| 300 | + } | |
| 292 | 301 | |
| 293 | 302 | // Check the e-mail address | 
| 294 | 303 |      if ($user_email == '') {
 | 
| @@ -296,8 +305,9 @@ discard block | ||
| 296 | 305 |      } elseif (!is_email($user_email)) {
 | 
| 297 | 306 |          $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn’t correct.', 'geodirectory'));
 | 
| 298 | 307 | $user_email = ''; | 
| 299 | - } elseif (email_exists($user_email)) | |
| 300 | -        $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.', 'geodirectory'));
 | |
| 308 | +    } elseif (email_exists($user_email)) { | |
| 309 | +            $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.', 'geodirectory')); | |
| 310 | + } | |
| 301 | 311 | |
| 302 | 312 | /** | 
| 303 | 313 | * Called when registering a new user. | 
| @@ -317,8 +327,9 @@ discard block | ||
| 317 | 327 | */ | 
| 318 | 328 |      $errors = apply_filters('registration_errors', $errors,$user_login,$user_email);
 | 
| 319 | 329 | |
| 320 | - if ($errors->get_error_code()) | |
| 321 | - return $errors; | |
| 330 | +    if ($errors->get_error_code()) { | |
| 331 | + return $errors; | |
| 332 | + } | |
| 322 | 333 | |
| 323 | 334 | |
| 324 | 335 |      if (!isset($user_pass) || $user_pass == '') {
 | 
| @@ -423,28 +434,33 @@ discard block | ||
| 423 | 434 | |
| 424 | 435 | $errors = new WP_Error(); | 
| 425 | 436 | |
| 426 | - if (isset($_GET['key'])) | |
| 427 | - $action = 'resetpass'; | |
| 437 | +    if (isset($_GET['key'])) { | |
| 438 | + $action = 'resetpass'; | |
| 439 | + } | |
| 428 | 440 | |
| 429 | 441 | // validate action so as to default to the login screen | 
| 430 | -    if (!in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login')) && false === has_filter('login_form_' . $action))
 | |
| 431 | - $action = 'login'; | |
| 442 | +    if (!in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login')) && false === has_filter('login_form_' . $action)) { | |
| 443 | + $action = 'login'; | |
| 444 | + } | |
| 432 | 445 | |
| 433 | 446 | nocache_headers(); | 
| 434 | 447 | |
| 435 | 448 |      if (defined('RELOCATE')) { // Move flag is set
 | 
| 436 | - if (isset($_SERVER['PATH_INFO']) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF'])) | |
| 437 | - $_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF']); | |
| 449 | +        if (isset($_SERVER['PATH_INFO']) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF'])) { | |
| 450 | + $_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF']); | |
| 451 | + } | |
| 438 | 452 | |
| 439 | 453 | $schema = (isset($_SERVER['HTTPS']) && geodir_strtolower($_SERVER['HTTPS']) == 'on') ? 'https://' : 'http://'; | 
| 440 | - if (dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != home_url()) | |
| 441 | -            update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']));
 | |
| 454 | +        if (dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != home_url()) { | |
| 455 | +                    update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'])); | |
| 456 | + } | |
| 442 | 457 | } | 
| 443 | 458 | |
| 444 | 459 | //Set a cookie now to see if they are supported by the browser. | 
| 445 | 460 | //setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN); | 
| 446 | - if (SITECOOKIEPATH != COOKIEPATH) | |
| 447 | - setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN); | |
| 461 | +    if (SITECOOKIEPATH != COOKIEPATH) { | |
| 462 | + setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN); | |
| 463 | + } | |
| 448 | 464 | |
| 449 | 465 | /** | 
| 450 | 466 | * Allow plugins to override the default actions, and to add extra actions if they want on the register/signin page. | 
| @@ -465,8 +481,9 @@ discard block | ||
| 465 | 481 | |
| 466 | 482 | $redirect_to = $_SERVER['HTTP_REFERER']; | 
| 467 | 483 | //$redirect_to = home_url().'/?ptype=login&loggedout=true'; | 
| 468 | - if (isset($_REQUEST['redirect_to'])) | |
| 469 | - $redirect_to = $_REQUEST['redirect_to']; | |
| 484 | +            if (isset($_REQUEST['redirect_to'])) { | |
| 485 | + $redirect_to = $_REQUEST['redirect_to']; | |
| 486 | + } | |
| 470 | 487 | $redirect_to = home_url(); | 
| 471 | 488 | wp_safe_redirect($redirect_to); | 
| 472 | 489 | exit(); | 
| @@ -486,7 +503,9 @@ discard block | ||
| 486 | 503 | gd_die(); | 
| 487 | 504 | } | 
| 488 | 505 | } | 
| 489 | -            if (isset($_GET['error']) && 'invalidkey' == $_GET['error']) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.', 'geodirectory'));
 | |
| 506 | +            if (isset($_GET['error']) && 'invalidkey' == $_GET['error']) { | |
| 507 | +            	$errors->add('invalidkey', __('Sorry, that key does not appear to be valid.', 'geodirectory')); | |
| 508 | + } | |
| 490 | 509 | /** | 
| 491 | 510 | * Called in the geodir_user_signup() function during the lostpassword case. | 
| 492 | 511 | * | 
| @@ -582,8 +601,9 @@ discard block | ||
| 582 | 601 | } | 
| 583 | 602 | |
| 584 | 603 | |
| 585 | - if (!$secure_cookie && is_ssl() && force_ssl_admin() && !force_ssl_admin() && (0 !== strpos($redirect_to, 'https')) && (0 === strpos($redirect_to, 'http'))) | |
| 586 | - $secure_cookie = false; | |
| 604 | +                    if (!$secure_cookie && is_ssl() && force_ssl_admin() && !force_ssl_admin() && (0 !== strpos($redirect_to, 'https')) && (0 === strpos($redirect_to, 'http'))) { | |
| 605 | + $secure_cookie = false; | |
| 606 | + } | |
| 587 | 607 | |
| 588 | 608 |                      $user = wp_signon('', $secure_cookie);
 | 
| 589 | 609 | |
| @@ -652,22 +672,26 @@ discard block | ||
| 652 | 672 |                      $default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_ID);
 | 
| 653 | 673 | |
| 654 | 674 | $_REQUEST['redirect_to'] = $default_author_link; | 
| 655 | - else: | |
| 656 | - $_REQUEST['redirect_to'] = home_url(); | |
| 675 | +                else { | |
| 676 | + : | |
| 677 | + $_REQUEST['redirect_to'] = home_url(); | |
| 678 | + } | |
| 657 | 679 | endif; | 
| 658 | 680 | |
| 659 | 681 | } | 
| 660 | 682 |              if (isset($_REQUEST['redirect_to'])) {
 | 
| 661 | 683 | $redirect_to = $_REQUEST['redirect_to']; | 
| 662 | 684 | // Redirect to https if user wants ssl | 
| 663 | - if ($secure_cookie && false !== strpos($redirect_to, 'wp-admin')) | |
| 664 | -                    $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
 | |
| 685 | +                if ($secure_cookie && false !== strpos($redirect_to, 'wp-admin')) { | |
| 686 | +                                    $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to); | |
| 687 | + } | |
| 665 | 688 |              } else {
 | 
| 666 | 689 | $redirect_to = admin_url(); | 
| 667 | 690 | } | 
| 668 | 691 | |
| 669 | - if (!$secure_cookie && is_ssl() && force_ssl_admin() && !force_ssl_admin() && (0 !== strpos($redirect_to, 'https')) && (0 === strpos($redirect_to, 'http'))) | |
| 670 | - $secure_cookie = false; | |
| 692 | +            if (!$secure_cookie && is_ssl() && force_ssl_admin() && !force_ssl_admin() && (0 !== strpos($redirect_to, 'https')) && (0 === strpos($redirect_to, 'http'))) { | |
| 693 | + $secure_cookie = false; | |
| 694 | + } | |
| 671 | 695 |              $user = wp_signon('', $secure_cookie);
 | 
| 672 | 696 | |
| 673 | 697 | |
| @@ -702,11 +726,13 @@ discard block | ||
| 702 | 726 | $errors = $user; | 
| 703 | 727 | |
| 704 | 728 | // Clear errors if loggedout is set. | 
| 705 | - if (!empty($_GET['loggedout'])) | |
| 706 | - $errors = new WP_Error(); | |
| 729 | +            if (!empty($_GET['loggedout'])) { | |
| 730 | + $errors = new WP_Error(); | |
| 731 | + } | |
| 707 | 732 | // If cookies are disabled we can't log in even with a valid user+pass | 
| 708 | - if (isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE])) | |
| 709 | -                $errors->add('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress.", 'geodirectory'));
 | |
| 733 | +            if (isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE])) { | |
| 734 | +                            $errors->add('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress.", 'geodirectory')); | |
| 735 | + } | |
| 710 | 736 | |
| 711 | 737 | // Some parts of this script use the main login form to display a message | 
| 712 | 738 |              if (isset($_GET['loggedout']) && TRUE == $_GET['loggedout']) {
 | 
| @@ -393,7 +393,7 @@ | ||
| 393 | 393 | * @global object $post The current post object. | 
| 394 | 394 | * @global object $geodirectory Not yet implemented. | 
| 395 | 395 | * @param string $slug The template slug. | 
| 396 | - * @param null $name The template name. | |
| 396 | + * @param string $name The template name. | |
| 397 | 397 | */ | 
| 398 | 398 | function geodir_get_template_part($slug = '', $name = NULL) | 
| 399 | 399 |  {
 | 
| @@ -47,16 +47,19 @@ discard block | ||
| 47 | 47 | |
| 48 | 48 | if ($listing_page_id != '' && (is_page($listing_page_id) || ($is_wpml && !empty($wp->query_vars['page_id']))) && isset($_REQUEST['listing_type']) | 
| 49 | 49 | && in_array($_REQUEST['listing_type'], geodir_get_posttypes()) | 
| 50 | - ) | |
| 51 | - $post_type = sanitize_text_field($_REQUEST['listing_type']); | |
| 50 | +            ) { | |
| 51 | + $post_type = sanitize_text_field($_REQUEST['listing_type']); | |
| 52 | + } | |
| 52 | 53 |              if (empty($post_type) && !isset($_REQUEST['pid'])) {
 | 
| 53 | 54 | $pagename = $wp->query_vars['pagename']; | 
| 54 | 55 | $post_types = geodir_get_posttypes(); | 
| 55 | - if (!empty($post_types)) | |
| 56 | - $post_type = $post_types[0]; | |
| 56 | +                if (!empty($post_types)) { | |
| 57 | + $post_type = $post_types[0]; | |
| 58 | + } | |
| 57 | 59 | |
| 58 | - if($sc_post_type != '' ) | |
| 59 | - $post_type = $sc_post_type; | |
| 60 | +				if($sc_post_type != '' ) { | |
| 61 | + $post_type = $sc_post_type; | |
| 62 | + } | |
| 60 | 63 | |
| 61 | 64 |                  if ($is_wpml && !empty($wp->query_vars['page_id'])) {
 | 
| 62 | 65 |  					wp_redirect(geodir_getlink(get_permalink($wp->query_vars['page_id']), array('listing_type' => $post_type)));
 | 
| @@ -71,14 +74,16 @@ discard block | ||
| 71 | 74 | $success_page_id = geodir_success_page_id(); | 
| 72 | 75 | if ($success_page_id != '' && is_page($success_page_id) && isset($_REQUEST['listing_type']) | 
| 73 | 76 | && in_array($_REQUEST['listing_type'], geodir_get_posttypes()) | 
| 74 | - ) | |
| 75 | - $post_type = sanitize_text_field($_REQUEST['listing_type']); | |
| 77 | +            ) { | |
| 78 | + $post_type = sanitize_text_field($_REQUEST['listing_type']); | |
| 79 | + } | |
| 76 | 80 |              return $template = locate_template(array("geodirectory/{$post_type}-success.php", "geodirectory/listing-success.php"));
 | 
| 77 | 81 | break; | 
| 78 | 82 | case 'detail': | 
| 79 | 83 | case 'preview': | 
| 80 | - if (in_array(get_post_type(), geodir_get_posttypes())) | |
| 81 | - $post_type = get_post_type(); | |
| 84 | +            if (in_array(get_post_type(), geodir_get_posttypes())) { | |
| 85 | + $post_type = get_post_type(); | |
| 86 | + } | |
| 82 | 87 |              return $template = locate_template(array("geodirectory/single-{$post_type}.php", "geodirectory/listing-detail.php"));
 | 
| 83 | 88 | break; | 
| 84 | 89 | case 'listing': | 
| @@ -184,7 +189,9 @@ discard block | ||
| 184 | 189 | |
| 185 | 190 |          $template = geodir_locate_template('signup');
 | 
| 186 | 191 | |
| 187 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-signup.php'; | |
| 192 | +        if (!$template) { | |
| 193 | + $template = geodir_plugin_path() . '/geodirectory-templates/geodir-signup.php'; | |
| 194 | + } | |
| 188 | 195 | |
| 189 | 196 | /** | 
| 190 | 197 | * Filter the signup template path. | 
| @@ -202,7 +209,9 @@ discard block | ||
| 202 | 209 | |
| 203 | 210 |              $template = geodir_locate_template('information');
 | 
| 204 | 211 | |
| 205 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php'; | |
| 212 | +            if (!$template) { | |
| 213 | + $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php'; | |
| 214 | + } | |
| 206 | 215 | /** | 
| 207 | 216 | * Filter the information template path. | 
| 208 | 217 | * | 
| @@ -219,7 +228,9 @@ discard block | ||
| 219 | 228 |              if (!$is_current_user_owner) {
 | 
| 220 | 229 |                  $template = geodir_locate_template('information');
 | 
| 221 | 230 | |
| 222 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php'; | |
| 231 | +                if (!$template) { | |
| 232 | + $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php'; | |
| 233 | + } | |
| 223 | 234 | /** | 
| 224 | 235 | * Filter the information template path. | 
| 225 | 236 | * | 
| @@ -241,7 +252,9 @@ discard block | ||
| 241 | 252 | |
| 242 | 253 |          $template = geodir_locate_template('add-listing');
 | 
| 243 | 254 | |
| 244 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/add-listing.php'; | |
| 255 | +        if (!$template) { | |
| 256 | + $template = geodir_plugin_path() . '/geodirectory-templates/add-listing.php'; | |
| 257 | + } | |
| 245 | 258 | /** | 
| 246 | 259 | * Filter the add listing template path. | 
| 247 | 260 | * | 
| @@ -258,7 +271,9 @@ discard block | ||
| 258 | 271 | |
| 259 | 272 |          $template = geodir_locate_template('preview');
 | 
| 260 | 273 | |
| 261 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php'; | |
| 274 | +        if (!$template) { | |
| 275 | + $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php'; | |
| 276 | + } | |
| 262 | 277 | /** | 
| 263 | 278 | * Filter the preview template path. | 
| 264 | 279 | * | 
| @@ -274,7 +289,9 @@ discard block | ||
| 274 | 289 | |
| 275 | 290 |          $template = geodir_locate_template('success');
 | 
| 276 | 291 | |
| 277 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-success.php'; | |
| 292 | +        if (!$template) { | |
| 293 | + $template = geodir_plugin_path() . '/geodirectory-templates/listing-success.php'; | |
| 294 | + } | |
| 278 | 295 | /** | 
| 279 | 296 | * Filter the success template path. | 
| 280 | 297 | * | 
| @@ -289,7 +306,9 @@ discard block | ||
| 289 | 306 | |
| 290 | 307 |          $template = geodir_locate_template('detail');
 | 
| 291 | 308 | |
| 292 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php'; | |
| 309 | +        if (!$template) { | |
| 310 | + $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php'; | |
| 311 | + } | |
| 293 | 312 | /** | 
| 294 | 313 | * Filter the detail template path. | 
| 295 | 314 | * | 
| @@ -304,7 +323,9 @@ discard block | ||
| 304 | 323 | |
| 305 | 324 |          $template = geodir_locate_template('listing');
 | 
| 306 | 325 | |
| 307 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-listing.php'; | |
| 326 | +        if (!$template) { | |
| 327 | + $template = geodir_plugin_path() . '/geodirectory-templates/geodir-listing.php'; | |
| 328 | + } | |
| 308 | 329 | /** | 
| 309 | 330 | * Filter the listing template path. | 
| 310 | 331 | * | 
| @@ -319,7 +340,9 @@ discard block | ||
| 319 | 340 | |
| 320 | 341 |          $template = geodir_locate_template('search');
 | 
| 321 | 342 | |
| 322 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-search.php'; | |
| 343 | +        if (!$template) { | |
| 344 | + $template = geodir_plugin_path() . '/geodirectory-templates/geodir-search.php'; | |
| 345 | + } | |
| 323 | 346 | /** | 
| 324 | 347 | * Filter the search template path. | 
| 325 | 348 | * | 
| @@ -334,7 +357,9 @@ discard block | ||
| 334 | 357 | |
| 335 | 358 |          $template = geodir_locate_template('author');
 | 
| 336 | 359 | |
| 337 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-author.php'; | |
| 360 | +        if (!$template) { | |
| 361 | + $template = geodir_plugin_path() . '/geodirectory-templates/geodir-author.php'; | |
| 362 | + } | |
| 338 | 363 | /** | 
| 339 | 364 | * Filter the author template path. | 
| 340 | 365 | * | 
| @@ -355,7 +380,9 @@ discard block | ||
| 355 | 380 | |
| 356 | 381 |              $template = geodir_locate_template('geodir-home');
 | 
| 357 | 382 | |
| 358 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-home.php'; | |
| 383 | +            if (!$template) { | |
| 384 | + $template = geodir_plugin_path() . '/geodirectory-templates/geodir-home.php'; | |
| 385 | + } | |
| 359 | 386 | /** | 
| 360 | 387 | * Filter the home page template path. | 
| 361 | 388 | * | 
| @@ -368,7 +395,9 @@ discard block | ||
| 368 | 395 | |
| 369 | 396 |              $template = geodir_locate_template('location');
 | 
| 370 | 397 | |
| 371 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-location.php'; | |
| 398 | +            if (!$template) { | |
| 399 | + $template = geodir_plugin_path() . '/geodirectory-templates/geodir-location.php'; | |
| 400 | + } | |
| 372 | 401 | /** | 
| 373 | 402 | * Filter the location template path. | 
| 374 | 403 | * | 
| @@ -377,8 +406,9 @@ discard block | ||
| 377 | 406 | */ | 
| 378 | 407 |              return $template = apply_filters('geodir_template_location', $template);
 | 
| 379 | 408 | |
| 380 | - } else | |
| 381 | - return $template; | |
| 409 | +        } else { | |
| 410 | + return $template; | |
| 411 | + } | |
| 382 | 412 | |
| 383 | 413 | } | 
| 384 | 414 | |
| @@ -432,8 +462,10 @@ discard block | ||
| 432 | 462 | * @since 1.0.0 | 
| 433 | 463 | */ | 
| 434 | 464 | include($template); | 
| 435 | - else: | |
| 436 | -        locate_template(array("geodirectory/" . $template_name), true, false);
 | |
| 465 | +    else { | |
| 466 | + : | |
| 467 | +        locate_template(array("geodirectory/" . $template_name), true, false); | |
| 468 | + } | |
| 437 | 469 | endif; | 
| 438 | 470 | |
| 439 | 471 | } | 
| @@ -19,18 +19,18 @@ discard block | ||
| 19 | 19 | */ | 
| 20 | 20 | function geodir_locate_template($template = '') | 
| 21 | 21 |  {
 | 
| 22 | - global $post_type, $wp, $post; | |
| 23 | - $fields = array(); | |
| 22 | + global $post_type, $wp, $post; | |
| 23 | + $fields = array(); | |
| 24 | 24 | |
| 25 | - switch ($template): | |
| 26 | - case 'signup': | |
| 27 | -            return $template = locate_template(array("geodirectory/geodir-signup.php"));
 | |
| 28 | - break; | |
| 29 | - case 'add-listing': | |
| 25 | + switch ($template): | |
| 26 | + case 'signup': | |
| 27 | +			return $template = locate_template(array("geodirectory/geodir-signup.php"));
 | |
| 28 | + break; | |
| 29 | + case 'add-listing': | |
| 30 | 30 | |
| 31 | - $sc_post_type = ''; | |
| 31 | + $sc_post_type = ''; | |
| 32 | 32 |  			if (is_page() && isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
 | 
| 33 | - $listing_page_id = $post->ID; | |
| 33 | + $listing_page_id = $post->ID; | |
| 34 | 34 | |
| 35 | 35 | $regex_pattern = get_shortcode_regex(); | 
| 36 | 36 |  				preg_match('/'.$regex_pattern.'/s', $post->post_content, $regex_matches);
 | 
| @@ -39,100 +39,100 @@ discard block | ||
| 39 | 39 | $shortcode_atts = shortcode_parse_atts($regex_matches[3]); | 
| 40 | 40 | $sc_post_type = !empty($shortcode_atts) && isset($shortcode_atts['listing_type']) && !empty($shortcode_atts['listing_type']) ? $shortcode_atts['listing_type'] : ''; | 
| 41 | 41 | } | 
| 42 | -            } else {
 | |
| 43 | - $listing_page_id = geodir_add_listing_page_id(); | |
| 44 | - } | |
| 42 | +			} else {
 | |
| 43 | + $listing_page_id = geodir_add_listing_page_id(); | |
| 44 | + } | |
| 45 | 45 | |
| 46 | 46 |  			$is_wpml = function_exists('icl_object_id') ? true : false;
 | 
| 47 | 47 | |
| 48 | - if ($listing_page_id != '' && (is_page($listing_page_id) || ($is_wpml && !empty($wp->query_vars['page_id']))) && isset($_REQUEST['listing_type']) | |
| 49 | - && in_array($_REQUEST['listing_type'], geodir_get_posttypes()) | |
| 50 | - ) | |
| 51 | - $post_type = sanitize_text_field($_REQUEST['listing_type']); | |
| 52 | -            if (empty($post_type) && !isset($_REQUEST['pid'])) {
 | |
| 53 | - $pagename = $wp->query_vars['pagename']; | |
| 54 | - $post_types = geodir_get_posttypes(); | |
| 55 | - if (!empty($post_types)) | |
| 56 | - $post_type = $post_types[0]; | |
| 48 | + if ($listing_page_id != '' && (is_page($listing_page_id) || ($is_wpml && !empty($wp->query_vars['page_id']))) && isset($_REQUEST['listing_type']) | |
| 49 | + && in_array($_REQUEST['listing_type'], geodir_get_posttypes()) | |
| 50 | + ) | |
| 51 | + $post_type = sanitize_text_field($_REQUEST['listing_type']); | |
| 52 | +			if (empty($post_type) && !isset($_REQUEST['pid'])) {
 | |
| 53 | + $pagename = $wp->query_vars['pagename']; | |
| 54 | + $post_types = geodir_get_posttypes(); | |
| 55 | + if (!empty($post_types)) | |
| 56 | + $post_type = $post_types[0]; | |
| 57 | 57 | |
| 58 | 58 | if($sc_post_type != '' ) | 
| 59 | 59 | $post_type = $sc_post_type; | 
| 60 | 60 | |
| 61 | -                if ($is_wpml && !empty($wp->query_vars['page_id'])) {
 | |
| 61 | +				if ($is_wpml && !empty($wp->query_vars['page_id'])) {
 | |
| 62 | 62 |  					wp_redirect(geodir_getlink(get_permalink($wp->query_vars['page_id']), array('listing_type' => $post_type)));
 | 
| 63 | 63 |  				} else {
 | 
| 64 | 64 | wp_redirect(trailingslashit(get_site_url()) . $pagename . '/?listing_type=' . $post_type); | 
| 65 | 65 | } | 
| 66 | - gd_die(); | |
| 67 | - } | |
| 68 | -            return $template = locate_template(array("geodirectory/add-{$post_type}.php", "geodirectory/add-listing.php"));
 | |
| 69 | - break; | |
| 70 | - case 'success': | |
| 71 | - $success_page_id = geodir_success_page_id(); | |
| 72 | - if ($success_page_id != '' && is_page($success_page_id) && isset($_REQUEST['listing_type']) | |
| 73 | - && in_array($_REQUEST['listing_type'], geodir_get_posttypes()) | |
| 74 | - ) | |
| 75 | - $post_type = sanitize_text_field($_REQUEST['listing_type']); | |
| 76 | -            return $template = locate_template(array("geodirectory/{$post_type}-success.php", "geodirectory/listing-success.php"));
 | |
| 77 | - break; | |
| 78 | - case 'detail': | |
| 79 | - case 'preview': | |
| 80 | - if (in_array(get_post_type(), geodir_get_posttypes())) | |
| 81 | - $post_type = get_post_type(); | |
| 82 | -            return $template = locate_template(array("geodirectory/single-{$post_type}.php", "geodirectory/listing-detail.php"));
 | |
| 83 | - break; | |
| 84 | - case 'listing': | |
| 85 | - $templates = array(); | |
| 86 | -            if (is_post_type_archive() && in_array(get_post_type(), geodir_get_posttypes())) {
 | |
| 87 | - $post_type = get_post_type(); | |
| 88 | - $templates[] = "geodirectory/archive-$post_type.php"; | |
| 89 | - } | |
| 90 | - | |
| 91 | - | |
| 92 | -            if (is_tax() && geodir_get_taxonomy_posttype()) {
 | |
| 93 | - $query_obj = get_queried_object(); | |
| 94 | - $curr_taxonomy = isset($query_obj->taxonomy) ? $query_obj->taxonomy : ''; | |
| 95 | - $curr_term = isset($query_obj->slug) ? $query_obj->slug : ''; | |
| 96 | - $templates[] = "geodirectory/taxonomy-$curr_taxonomy-$curr_term.php"; | |
| 97 | - $templates[] = "geodirectory/taxonomy-$curr_taxonomy.php"; | |
| 98 | - } | |
| 99 | - | |
| 100 | - $templates[] = "geodirectory/geodir-listing.php"; | |
| 101 | - | |
| 102 | - return $template = locate_template($templates); | |
| 103 | - break; | |
| 104 | - case 'information': | |
| 105 | -            return $template = locate_template(array("geodirectory/geodir-information.php"));
 | |
| 106 | - break; | |
| 107 | - case 'author': | |
| 108 | -            return $template = locate_template(array("geodirectory/geodir-author.php"));
 | |
| 109 | - break; | |
| 110 | - case 'search': | |
| 111 | -            return $template = locate_template(array("geodirectory/geodir-search.php"));
 | |
| 112 | - break; | |
| 113 | - case 'location': | |
| 114 | -            return $template = locate_template(array("geodirectory/geodir-location.php"));
 | |
| 115 | - break; | |
| 116 | - case 'geodir-home': | |
| 117 | -            return $template = locate_template(array("geodirectory/geodir-home.php"));
 | |
| 118 | - break; | |
| 119 | - case 'listing-listview': | |
| 120 | -            $template = locate_template(array("geodirectory/listing-listview.php"));
 | |
| 121 | -            if (!$template) {
 | |
| 122 | - $template = geodir_plugin_path() . '/geodirectory-templates/listing-listview.php'; | |
| 123 | - } | |
| 124 | - return $template; | |
| 125 | - break; | |
| 126 | - case 'widget-listing-listview': | |
| 127 | -            $template = locate_template(array("geodirectory/widget-listing-listview.php"));
 | |
| 128 | -            if (!$template) {
 | |
| 129 | - $template = geodir_plugin_path() . '/geodirectory-templates/widget-listing-listview.php'; | |
| 130 | - } | |
| 131 | - return $template; | |
| 132 | - break; | |
| 133 | - endswitch; | |
| 134 | - | |
| 135 | - return false; | |
| 66 | + gd_die(); | |
| 67 | + } | |
| 68 | +			return $template = locate_template(array("geodirectory/add-{$post_type}.php", "geodirectory/add-listing.php"));
 | |
| 69 | + break; | |
| 70 | + case 'success': | |
| 71 | + $success_page_id = geodir_success_page_id(); | |
| 72 | + if ($success_page_id != '' && is_page($success_page_id) && isset($_REQUEST['listing_type']) | |
| 73 | + && in_array($_REQUEST['listing_type'], geodir_get_posttypes()) | |
| 74 | + ) | |
| 75 | + $post_type = sanitize_text_field($_REQUEST['listing_type']); | |
| 76 | +			return $template = locate_template(array("geodirectory/{$post_type}-success.php", "geodirectory/listing-success.php"));
 | |
| 77 | + break; | |
| 78 | + case 'detail': | |
| 79 | + case 'preview': | |
| 80 | + if (in_array(get_post_type(), geodir_get_posttypes())) | |
| 81 | + $post_type = get_post_type(); | |
| 82 | +			return $template = locate_template(array("geodirectory/single-{$post_type}.php", "geodirectory/listing-detail.php"));
 | |
| 83 | + break; | |
| 84 | + case 'listing': | |
| 85 | + $templates = array(); | |
| 86 | +			if (is_post_type_archive() && in_array(get_post_type(), geodir_get_posttypes())) {
 | |
| 87 | + $post_type = get_post_type(); | |
| 88 | + $templates[] = "geodirectory/archive-$post_type.php"; | |
| 89 | + } | |
| 90 | + | |
| 91 | + | |
| 92 | +			if (is_tax() && geodir_get_taxonomy_posttype()) {
 | |
| 93 | + $query_obj = get_queried_object(); | |
| 94 | + $curr_taxonomy = isset($query_obj->taxonomy) ? $query_obj->taxonomy : ''; | |
| 95 | + $curr_term = isset($query_obj->slug) ? $query_obj->slug : ''; | |
| 96 | + $templates[] = "geodirectory/taxonomy-$curr_taxonomy-$curr_term.php"; | |
| 97 | + $templates[] = "geodirectory/taxonomy-$curr_taxonomy.php"; | |
| 98 | + } | |
| 99 | + | |
| 100 | + $templates[] = "geodirectory/geodir-listing.php"; | |
| 101 | + | |
| 102 | + return $template = locate_template($templates); | |
| 103 | + break; | |
| 104 | + case 'information': | |
| 105 | +			return $template = locate_template(array("geodirectory/geodir-information.php"));
 | |
| 106 | + break; | |
| 107 | + case 'author': | |
| 108 | +			return $template = locate_template(array("geodirectory/geodir-author.php"));
 | |
| 109 | + break; | |
| 110 | + case 'search': | |
| 111 | +			return $template = locate_template(array("geodirectory/geodir-search.php"));
 | |
| 112 | + break; | |
| 113 | + case 'location': | |
| 114 | +			return $template = locate_template(array("geodirectory/geodir-location.php"));
 | |
| 115 | + break; | |
| 116 | + case 'geodir-home': | |
| 117 | +			return $template = locate_template(array("geodirectory/geodir-home.php"));
 | |
| 118 | + break; | |
| 119 | + case 'listing-listview': | |
| 120 | +			$template = locate_template(array("geodirectory/listing-listview.php"));
 | |
| 121 | +			if (!$template) {
 | |
| 122 | + $template = geodir_plugin_path() . '/geodirectory-templates/listing-listview.php'; | |
| 123 | + } | |
| 124 | + return $template; | |
| 125 | + break; | |
| 126 | + case 'widget-listing-listview': | |
| 127 | +			$template = locate_template(array("geodirectory/widget-listing-listview.php"));
 | |
| 128 | +			if (!$template) {
 | |
| 129 | + $template = geodir_plugin_path() . '/geodirectory-templates/widget-listing-listview.php'; | |
| 130 | + } | |
| 131 | + return $template; | |
| 132 | + break; | |
| 133 | + endswitch; | |
| 134 | + | |
| 135 | + return false; | |
| 136 | 136 | |
| 137 | 137 | } | 
| 138 | 138 | |
| @@ -151,255 +151,255 @@ discard block | ||
| 151 | 151 | function geodir_template_loader($template) | 
| 152 | 152 |  {
 | 
| 153 | 153 | |
| 154 | - global $wp_query; | |
| 155 | - | |
| 156 | - /** | |
| 157 | - * Filter the custom page list. | |
| 158 | - * | |
| 159 | - * @since 1.0.0 | |
| 160 | - */ | |
| 161 | -    $geodir_custom_page_list = apply_filters('geodir_set_custom_pages', array(
 | |
| 162 | - 'geodir_signup_page' => | |
| 163 | -            apply_filters('geodir_set_custom_signup_page', false),
 | |
| 164 | - 'geodir_add_listing_page' => | |
| 165 | -            apply_filters('geodir_set_custom_add_listing_page', false),
 | |
| 166 | - 'geodir_preview_page' => | |
| 167 | -            apply_filters('geodir_set_custom_preview_page', false),
 | |
| 168 | - 'geodir_listing_success_page' => | |
| 169 | -            apply_filters('geodir_set_custom_listing_success_page', false),
 | |
| 170 | - 'geodir_listing_detail_page' => | |
| 171 | -            apply_filters('geodir_set_custom_listing_detail_page', false),
 | |
| 172 | - 'geodir_listing_page' => | |
| 173 | -            apply_filters('geodir_set_custom_listing_page', false),
 | |
| 174 | - 'geodir_search_page' => | |
| 175 | -            apply_filters('geodir_set_custom_search_page', false),
 | |
| 176 | - 'geodir_author_page' => | |
| 177 | -            apply_filters('geodir_set_custom_author_page', false),
 | |
| 178 | - 'geodir_home_map_page' => | |
| 179 | -            apply_filters('geodir_set_custom_home_map_page', false)
 | |
| 180 | - )); | |
| 181 | - | |
| 182 | - | |
| 183 | -    if (geodir_is_page('login') || $geodir_custom_page_list['geodir_signup_page']) {
 | |
| 184 | - | |
| 185 | -        $template = geodir_locate_template('signup');
 | |
| 186 | - | |
| 187 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-signup.php'; | |
| 188 | - | |
| 189 | - /** | |
| 190 | - * Filter the signup template path. | |
| 191 | - * | |
| 192 | - * @since 1.0.0 | |
| 193 | - * @param string $template The template path. | |
| 194 | - */ | |
| 195 | -        return $template = apply_filters('geodir_template_signup', $template);
 | |
| 196 | - } | |
| 197 | - | |
| 198 | -    if (geodir_is_page('add-listing') || $geodir_custom_page_list['geodir_add_listing_page']) {
 | |
| 199 | -        if (!geodir_is_default_location_set()) {
 | |
| 200 | - global $information; | |
| 201 | -            $information = sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>');
 | |
| 202 | - | |
| 203 | -            $template = geodir_locate_template('information');
 | |
| 204 | - | |
| 205 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php'; | |
| 206 | - /** | |
| 207 | - * Filter the information template path. | |
| 208 | - * | |
| 209 | - * @since 1.0.0 | |
| 210 | - * @param string $template The template path. | |
| 211 | - */ | |
| 212 | -            return $template = apply_filters('geodir_template_information', $template);
 | |
| 213 | - } | |
| 214 | - // check if pid exists in the record if yes then check if this post belongs to the user who is logged in. | |
| 215 | -        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
 | |
| 216 | - /// WPML | |
| 217 | -            if (geodir_is_wpml() && $duplicate_of = wpml_get_master_post_from_duplicate((int)$_GET['pid'])) {
 | |
| 218 | - global $sitepress; | |
| 154 | + global $wp_query; | |
| 155 | + | |
| 156 | + /** | |
| 157 | + * Filter the custom page list. | |
| 158 | + * | |
| 159 | + * @since 1.0.0 | |
| 160 | + */ | |
| 161 | +	$geodir_custom_page_list = apply_filters('geodir_set_custom_pages', array(
 | |
| 162 | + 'geodir_signup_page' => | |
| 163 | +			apply_filters('geodir_set_custom_signup_page', false),
 | |
| 164 | + 'geodir_add_listing_page' => | |
| 165 | +			apply_filters('geodir_set_custom_add_listing_page', false),
 | |
| 166 | + 'geodir_preview_page' => | |
| 167 | +			apply_filters('geodir_set_custom_preview_page', false),
 | |
| 168 | + 'geodir_listing_success_page' => | |
| 169 | +			apply_filters('geodir_set_custom_listing_success_page', false),
 | |
| 170 | + 'geodir_listing_detail_page' => | |
| 171 | +			apply_filters('geodir_set_custom_listing_detail_page', false),
 | |
| 172 | + 'geodir_listing_page' => | |
| 173 | +			apply_filters('geodir_set_custom_listing_page', false),
 | |
| 174 | + 'geodir_search_page' => | |
| 175 | +			apply_filters('geodir_set_custom_search_page', false),
 | |
| 176 | + 'geodir_author_page' => | |
| 177 | +			apply_filters('geodir_set_custom_author_page', false),
 | |
| 178 | + 'geodir_home_map_page' => | |
| 179 | +			apply_filters('geodir_set_custom_home_map_page', false)
 | |
| 180 | + )); | |
| 181 | + | |
| 182 | + | |
| 183 | +	if (geodir_is_page('login') || $geodir_custom_page_list['geodir_signup_page']) {
 | |
| 184 | + | |
| 185 | +		$template = geodir_locate_template('signup');
 | |
| 186 | + | |
| 187 | + if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-signup.php'; | |
| 188 | + | |
| 189 | + /** | |
| 190 | + * Filter the signup template path. | |
| 191 | + * | |
| 192 | + * @since 1.0.0 | |
| 193 | + * @param string $template The template path. | |
| 194 | + */ | |
| 195 | +		return $template = apply_filters('geodir_template_signup', $template);
 | |
| 196 | + } | |
| 197 | + | |
| 198 | +	if (geodir_is_page('add-listing') || $geodir_custom_page_list['geodir_add_listing_page']) {
 | |
| 199 | +		if (!geodir_is_default_location_set()) {
 | |
| 200 | + global $information; | |
| 201 | +			$information = sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>');
 | |
| 202 | + | |
| 203 | +			$template = geodir_locate_template('information');
 | |
| 204 | + | |
| 205 | + if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php'; | |
| 206 | + /** | |
| 207 | + * Filter the information template path. | |
| 208 | + * | |
| 209 | + * @since 1.0.0 | |
| 210 | + * @param string $template The template path. | |
| 211 | + */ | |
| 212 | +			return $template = apply_filters('geodir_template_information', $template);
 | |
| 213 | + } | |
| 214 | + // check if pid exists in the record if yes then check if this post belongs to the user who is logged in. | |
| 215 | +		if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
 | |
| 216 | + /// WPML | |
| 217 | +			if (geodir_is_wpml() && $duplicate_of = wpml_get_master_post_from_duplicate((int)$_GET['pid'])) {
 | |
| 218 | + global $sitepress; | |
| 219 | 219 | |
| 220 | - $lang_of_duplicate = geodir_get_language_for_element($duplicate_of, 'post_' . get_post_type($duplicate_of)); | |
| 221 | - $sitepress->switch_lang($lang_of_duplicate, true); | |
| 220 | + $lang_of_duplicate = geodir_get_language_for_element($duplicate_of, 'post_' . get_post_type($duplicate_of)); | |
| 221 | + $sitepress->switch_lang($lang_of_duplicate, true); | |
| 222 | 222 | |
| 223 | - $redirect_to = get_permalink(geodir_add_listing_page_id()); | |
| 224 | - $_GET['pid'] = $duplicate_of; | |
| 225 | -                if (!empty($_GET)) {
 | |
| 226 | - $redirect_to = add_query_arg($_GET, $redirect_to); | |
| 227 | - } | |
| 228 | - wp_redirect($redirect_to); | |
| 229 | - exit; | |
| 230 | - } | |
| 231 | - /// WPML | |
| 223 | + $redirect_to = get_permalink(geodir_add_listing_page_id()); | |
| 224 | + $_GET['pid'] = $duplicate_of; | |
| 225 | +				if (!empty($_GET)) {
 | |
| 226 | + $redirect_to = add_query_arg($_GET, $redirect_to); | |
| 227 | + } | |
| 228 | + wp_redirect($redirect_to); | |
| 229 | + exit; | |
| 230 | + } | |
| 231 | + /// WPML | |
| 232 | 232 | |
| 233 | - global $information; | |
| 234 | -            $information = __('This listing does not belong to your account, please check the listing id carefully.', 'geodirectory');
 | |
| 235 | - $is_current_user_owner = geodir_listing_belong_to_current_user(); | |
| 236 | -            if (!$is_current_user_owner) {
 | |
| 237 | -                $template = geodir_locate_template('information');
 | |
| 238 | - | |
| 239 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php'; | |
| 240 | - /** | |
| 241 | - * Filter the information template path. | |
| 242 | - * | |
| 243 | - * @since 1.0.0 | |
| 244 | - * @param string $template The template path. | |
| 245 | - */ | |
| 246 | -                return $template = apply_filters('geodir_template_information', $template);
 | |
| 247 | - } | |
| 233 | + global $information; | |
| 234 | +			$information = __('This listing does not belong to your account, please check the listing id carefully.', 'geodirectory');
 | |
| 235 | + $is_current_user_owner = geodir_listing_belong_to_current_user(); | |
| 236 | +			if (!$is_current_user_owner) {
 | |
| 237 | +				$template = geodir_locate_template('information');
 | |
| 238 | + | |
| 239 | + if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php'; | |
| 240 | + /** | |
| 241 | + * Filter the information template path. | |
| 242 | + * | |
| 243 | + * @since 1.0.0 | |
| 244 | + * @param string $template The template path. | |
| 245 | + */ | |
| 246 | +				return $template = apply_filters('geodir_template_information', $template);
 | |
| 247 | + } | |
| 248 | + | |
| 248 | 249 | |
| 250 | + } | |
| 249 | 251 | |
| 250 | - } | |
| 252 | + //geodir_is_login(true); | |
| 253 | + global $current_user; | |
| 254 | +		if (!$current_user->ID) {
 | |
| 255 | +			wp_redirect(geodir_login_url(array('redirect_add_listing'=>urlencode(geodir_curPageURL()))), 302);
 | |
| 256 | + exit; | |
| 257 | + } | |
| 251 | 258 | |
| 252 | - //geodir_is_login(true); | |
| 253 | - global $current_user; | |
| 254 | -        if (!$current_user->ID) {
 | |
| 255 | -            wp_redirect(geodir_login_url(array('redirect_add_listing'=>urlencode(geodir_curPageURL()))), 302);
 | |
| 256 | - exit; | |
| 257 | - } | |
| 259 | +		$template = geodir_locate_template('add-listing');
 | |
| 258 | 260 | |
| 259 | -        $template = geodir_locate_template('add-listing');
 | |
| 260 | - | |
| 261 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/add-listing.php'; | |
| 262 | - /** | |
| 263 | - * Filter the add listing template path. | |
| 264 | - * | |
| 265 | - * @since 1.0.0 | |
| 266 | - * @param string $template The template path. | |
| 267 | - */ | |
| 268 | -        return $template = apply_filters('geodir_template_add_listing', $template);
 | |
| 269 | - } | |
| 261 | + if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/add-listing.php'; | |
| 262 | + /** | |
| 263 | + * Filter the add listing template path. | |
| 264 | + * | |
| 265 | + * @since 1.0.0 | |
| 266 | + * @param string $template The template path. | |
| 267 | + */ | |
| 268 | +		return $template = apply_filters('geodir_template_add_listing', $template);
 | |
| 269 | + } | |
| 270 | 270 | |
| 271 | 271 | |
| 272 | -    if (geodir_is_page('preview') || $geodir_custom_page_list['geodir_preview_page']) {
 | |
| 273 | - global $preview; | |
| 274 | - $preview = true; | |
| 272 | +	if (geodir_is_page('preview') || $geodir_custom_page_list['geodir_preview_page']) {
 | |
| 273 | + global $preview; | |
| 274 | + $preview = true; | |
| 275 | 275 | |
| 276 | -        $template = geodir_locate_template('preview');
 | |
| 276 | +		$template = geodir_locate_template('preview');
 | |
| 277 | 277 | |
| 278 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php'; | |
| 279 | - /** | |
| 280 | - * Filter the preview template path. | |
| 281 | - * | |
| 282 | - * @since 1.0.0 | |
| 283 | - * @param string $template The template path. | |
| 284 | - */ | |
| 285 | -        return $template = apply_filters('geodir_template_preview', $template);
 | |
| 278 | + if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php'; | |
| 279 | + /** | |
| 280 | + * Filter the preview template path. | |
| 281 | + * | |
| 282 | + * @since 1.0.0 | |
| 283 | + * @param string $template The template path. | |
| 284 | + */ | |
| 285 | +		return $template = apply_filters('geodir_template_preview', $template);
 | |
| 286 | 286 | |
| 287 | - } | |
| 287 | + } | |
| 288 | 288 | |
| 289 | 289 | |
| 290 | -    if (geodir_is_page('listing-success') || $geodir_custom_page_list['geodir_listing_success_page']) {
 | |
| 290 | +	if (geodir_is_page('listing-success') || $geodir_custom_page_list['geodir_listing_success_page']) {
 | |
| 291 | 291 | |
| 292 | -        $template = geodir_locate_template('success');
 | |
| 292 | +		$template = geodir_locate_template('success');
 | |
| 293 | 293 | |
| 294 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-success.php'; | |
| 295 | - /** | |
| 296 | - * Filter the success template path. | |
| 297 | - * | |
| 298 | - * @since 1.0.0 | |
| 299 | - * @param string $template The template path. | |
| 300 | - */ | |
| 301 | -        return $template = apply_filters('geodir_template_success', $template);
 | |
| 294 | + if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-success.php'; | |
| 295 | + /** | |
| 296 | + * Filter the success template path. | |
| 297 | + * | |
| 298 | + * @since 1.0.0 | |
| 299 | + * @param string $template The template path. | |
| 300 | + */ | |
| 301 | +		return $template = apply_filters('geodir_template_success', $template);
 | |
| 302 | 302 | |
| 303 | - } | |
| 303 | + } | |
| 304 | 304 | |
| 305 | -    if (geodir_is_page('detail') || $geodir_custom_page_list['geodir_listing_detail_page']) {
 | |
| 305 | +	if (geodir_is_page('detail') || $geodir_custom_page_list['geodir_listing_detail_page']) {
 | |
| 306 | 306 | |
| 307 | -        $template = geodir_locate_template('detail');
 | |
| 307 | +		$template = geodir_locate_template('detail');
 | |
| 308 | 308 | |
| 309 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php'; | |
| 310 | - /** | |
| 311 | - * Filter the detail template path. | |
| 312 | - * | |
| 313 | - * @since 1.0.0 | |
| 314 | - * @param string $template The template path. | |
| 315 | - */ | |
| 316 | -        return $template = apply_filters('geodir_template_detail', $template);
 | |
| 309 | + if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php'; | |
| 310 | + /** | |
| 311 | + * Filter the detail template path. | |
| 312 | + * | |
| 313 | + * @since 1.0.0 | |
| 314 | + * @param string $template The template path. | |
| 315 | + */ | |
| 316 | +		return $template = apply_filters('geodir_template_detail', $template);
 | |
| 317 | 317 | |
| 318 | - } | |
| 318 | + } | |
| 319 | 319 | |
| 320 | -    if (geodir_is_page('listing') || $geodir_custom_page_list['geodir_listing_page']) {
 | |
| 320 | +	if (geodir_is_page('listing') || $geodir_custom_page_list['geodir_listing_page']) {
 | |
| 321 | 321 | |
| 322 | -        $template = geodir_locate_template('listing');
 | |
| 322 | +		$template = geodir_locate_template('listing');
 | |
| 323 | 323 | |
| 324 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-listing.php'; | |
| 325 | - /** | |
| 326 | - * Filter the listing template path. | |
| 327 | - * | |
| 328 | - * @since 1.0.0 | |
| 329 | - * @param string $template The template path. | |
| 330 | - */ | |
| 331 | -        return $template = apply_filters('geodir_template_listing', $template);
 | |
| 324 | + if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-listing.php'; | |
| 325 | + /** | |
| 326 | + * Filter the listing template path. | |
| 327 | + * | |
| 328 | + * @since 1.0.0 | |
| 329 | + * @param string $template The template path. | |
| 330 | + */ | |
| 331 | +		return $template = apply_filters('geodir_template_listing', $template);
 | |
| 332 | 332 | |
| 333 | - } | |
| 333 | + } | |
| 334 | 334 | |
| 335 | -    if (geodir_is_page('search') || $geodir_custom_page_list['geodir_search_page']) {
 | |
| 335 | +	if (geodir_is_page('search') || $geodir_custom_page_list['geodir_search_page']) {
 | |
| 336 | 336 | |
| 337 | -        $template = geodir_locate_template('search');
 | |
| 337 | +		$template = geodir_locate_template('search');
 | |
| 338 | 338 | |
| 339 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-search.php'; | |
| 340 | - /** | |
| 341 | - * Filter the search template path. | |
| 342 | - * | |
| 343 | - * @since 1.0.0 | |
| 344 | - * @param string $template The template path. | |
| 345 | - */ | |
| 346 | -        return $template = apply_filters('geodir_template_search', $template);
 | |
| 339 | + if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-search.php'; | |
| 340 | + /** | |
| 341 | + * Filter the search template path. | |
| 342 | + * | |
| 343 | + * @since 1.0.0 | |
| 344 | + * @param string $template The template path. | |
| 345 | + */ | |
| 346 | +		return $template = apply_filters('geodir_template_search', $template);
 | |
| 347 | 347 | |
| 348 | - } | |
| 348 | + } | |
| 349 | 349 | |
| 350 | -    if (geodir_is_page('author') || $geodir_custom_page_list['geodir_author_page']) {
 | |
| 350 | +	if (geodir_is_page('author') || $geodir_custom_page_list['geodir_author_page']) {
 | |
| 351 | 351 | |
| 352 | -        $template = geodir_locate_template('author');
 | |
| 352 | +		$template = geodir_locate_template('author');
 | |
| 353 | 353 | |
| 354 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-author.php'; | |
| 355 | - /** | |
| 356 | - * Filter the author template path. | |
| 357 | - * | |
| 358 | - * @since 1.0.0 | |
| 359 | - * @param string $template The template path. | |
| 360 | - */ | |
| 361 | -        return $template = apply_filters('geodir_template_author', $template);
 | |
| 354 | + if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-author.php'; | |
| 355 | + /** | |
| 356 | + * Filter the author template path. | |
| 357 | + * | |
| 358 | + * @since 1.0.0 | |
| 359 | + * @param string $template The template path. | |
| 360 | + */ | |
| 361 | +		return $template = apply_filters('geodir_template_author', $template);
 | |
| 362 | 362 | |
| 363 | - } | |
| 363 | + } | |
| 364 | 364 | |
| 365 | -    if ( geodir_is_page('home') || geodir_is_page('location')) {
 | |
| 365 | +	if ( geodir_is_page('home') || geodir_is_page('location')) {
 | |
| 366 | 366 | |
| 367 | - global $post, $wp_query; | |
| 367 | + global $post, $wp_query; | |
| 368 | 368 | |
| 369 | -        if (geodir_is_page('home') || ('page' == get_option('show_on_front') && isset($post->ID) && $post->ID == get_option('page_on_front'))
 | |
| 370 | - || (is_home() && !$wp_query->is_posts_page) | |
| 371 | -        ) {
 | |
| 369 | +		if (geodir_is_page('home') || ('page' == get_option('show_on_front') && isset($post->ID) && $post->ID == get_option('page_on_front'))
 | |
| 370 | + || (is_home() && !$wp_query->is_posts_page) | |
| 371 | +		) {
 | |
| 372 | 372 | |
| 373 | -            $template = geodir_locate_template('geodir-home');
 | |
| 373 | +			$template = geodir_locate_template('geodir-home');
 | |
| 374 | 374 | |
| 375 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-home.php'; | |
| 376 | - /** | |
| 377 | - * Filter the home page template path. | |
| 378 | - * | |
| 379 | - * @since 1.0.0 | |
| 380 | - * @param string $template The template path. | |
| 381 | - */ | |
| 382 | -            return $template = apply_filters('geodir_template_homepage', $template);
 | |
| 375 | + if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-home.php'; | |
| 376 | + /** | |
| 377 | + * Filter the home page template path. | |
| 378 | + * | |
| 379 | + * @since 1.0.0 | |
| 380 | + * @param string $template The template path. | |
| 381 | + */ | |
| 382 | +			return $template = apply_filters('geodir_template_homepage', $template);
 | |
| 383 | 383 | |
| 384 | -        } elseif (geodir_is_page('location')) {
 | |
| 384 | +		} elseif (geodir_is_page('location')) {
 | |
| 385 | 385 | |
| 386 | -            $template = geodir_locate_template('location');
 | |
| 386 | +			$template = geodir_locate_template('location');
 | |
| 387 | 387 | |
| 388 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-location.php'; | |
| 389 | - /** | |
| 390 | - * Filter the location template path. | |
| 391 | - * | |
| 392 | - * @since 1.0.0 | |
| 393 | - * @param string $template The template path. | |
| 394 | - */ | |
| 395 | -            return $template = apply_filters('geodir_template_location', $template);
 | |
| 388 | + if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-location.php'; | |
| 389 | + /** | |
| 390 | + * Filter the location template path. | |
| 391 | + * | |
| 392 | + * @since 1.0.0 | |
| 393 | + * @param string $template The template path. | |
| 394 | + */ | |
| 395 | +			return $template = apply_filters('geodir_template_location', $template);
 | |
| 396 | 396 | |
| 397 | - } else | |
| 398 | - return $template; | |
| 397 | + } else | |
| 398 | + return $template; | |
| 399 | 399 | |
| 400 | - } | |
| 400 | + } | |
| 401 | 401 | |
| 402 | - return $template; | |
| 402 | + return $template; | |
| 403 | 403 | } | 
| 404 | 404 | |
| 405 | 405 | /** | 
| @@ -414,44 +414,44 @@ discard block | ||
| 414 | 414 | */ | 
| 415 | 415 | function geodir_get_template_part($slug = '', $name = NULL) | 
| 416 | 416 |  {
 | 
| 417 | - global $geodirectory, $post; | |
| 418 | - /** | |
| 419 | - * Called at the start for the geodir_get_template_part() function. | |
| 420 | - * | |
| 421 | -     * Used dynamic hook name: geodir_get_template_part_{$slug}
 | |
| 422 | - * | |
| 423 | - * @since 1.0.0 | |
| 424 | - * @package GeoDirectory | |
| 425 | - * @param string $slug The template slug. | |
| 426 | - * @param string $name The template name. | |
| 427 | - */ | |
| 428 | -    do_action("geodir_get_template_part_{$slug}", $slug, $name);
 | |
| 429 | - $templates = array(); | |
| 430 | - $name = (string)$name; | |
| 431 | -    if ('' !== $name) {
 | |
| 432 | -        $template_name = "{$slug}-{$name}.php";
 | |
| 433 | - | |
| 434 | -    } else {
 | |
| 435 | -        $template_name = "{$slug}.php";
 | |
| 436 | - } | |
| 437 | - | |
| 438 | -    if (!locate_template(array("geodirectory/" . $template_name))) :
 | |
| 439 | - /** | |
| 440 | - * Filter the template part with slug and name. | |
| 441 | - * | |
| 442 | - * @since 1.0.0 | |
| 443 | - * @param string $template_name The template name. | |
| 444 | - */ | |
| 445 | -        $template = apply_filters("geodir_template_part-{$slug}-{$name}", geodir_plugin_path() . '/geodirectory-templates/' . $template_name);
 | |
| 446 | - /** | |
| 447 | - * Includes the template part with slug and name. | |
| 448 | - * | |
| 449 | - * @since 1.0.0 | |
| 450 | - */ | |
| 451 | - include($template); | |
| 452 | - else: | |
| 453 | -        locate_template(array("geodirectory/" . $template_name), true, false);
 | |
| 454 | - endif; | |
| 417 | + global $geodirectory, $post; | |
| 418 | + /** | |
| 419 | + * Called at the start for the geodir_get_template_part() function. | |
| 420 | + * | |
| 421 | +	 * Used dynamic hook name: geodir_get_template_part_{$slug}
 | |
| 422 | + * | |
| 423 | + * @since 1.0.0 | |
| 424 | + * @package GeoDirectory | |
| 425 | + * @param string $slug The template slug. | |
| 426 | + * @param string $name The template name. | |
| 427 | + */ | |
| 428 | +	do_action("geodir_get_template_part_{$slug}", $slug, $name);
 | |
| 429 | + $templates = array(); | |
| 430 | + $name = (string)$name; | |
| 431 | +	if ('' !== $name) {
 | |
| 432 | +		$template_name = "{$slug}-{$name}.php";
 | |
| 433 | + | |
| 434 | +	} else {
 | |
| 435 | +		$template_name = "{$slug}.php";
 | |
| 436 | + } | |
| 437 | + | |
| 438 | +	if (!locate_template(array("geodirectory/" . $template_name))) :
 | |
| 439 | + /** | |
| 440 | + * Filter the template part with slug and name. | |
| 441 | + * | |
| 442 | + * @since 1.0.0 | |
| 443 | + * @param string $template_name The template name. | |
| 444 | + */ | |
| 445 | +		$template = apply_filters("geodir_template_part-{$slug}-{$name}", geodir_plugin_path() . '/geodirectory-templates/' . $template_name);
 | |
| 446 | + /** | |
| 447 | + * Includes the template part with slug and name. | |
| 448 | + * | |
| 449 | + * @since 1.0.0 | |
| 450 | + */ | |
| 451 | + include($template); | |
| 452 | + else: | |
| 453 | +		locate_template(array("geodirectory/" . $template_name), true, false);
 | |
| 454 | + endif; | |
| 455 | 455 | |
| 456 | 456 | } | 
| 457 | 457 | |
| @@ -467,23 +467,23 @@ discard block | ||
| 467 | 467 | */ | 
| 468 | 468 | function geodir_core_post_view_extra_class($class, $all_postypes = '') | 
| 469 | 469 |  {
 | 
| 470 | - global $post; | |
| 470 | + global $post; | |
| 471 | 471 | |
| 472 | -    if (!$all_postypes) {
 | |
| 473 | - $all_postypes = geodir_get_posttypes(); | |
| 474 | - } | |
| 472 | +	if (!$all_postypes) {
 | |
| 473 | + $all_postypes = geodir_get_posttypes(); | |
| 474 | + } | |
| 475 | 475 | |
| 476 | - $gdp_post_id = !empty($post) && isset($post->ID) ? $post->ID : NULL; | |
| 477 | - $gdp_post_type = $gdp_post_id > 0 && isset($post->post_type) ? $post->post_type : NULL; | |
| 478 | - $gdp_post_type = $gdp_post_type != '' && !empty($all_postypes) && in_array($gdp_post_type, $all_postypes) ? $gdp_post_type : NULL; | |
| 476 | + $gdp_post_id = !empty($post) && isset($post->ID) ? $post->ID : NULL; | |
| 477 | + $gdp_post_type = $gdp_post_id > 0 && isset($post->post_type) ? $post->post_type : NULL; | |
| 478 | + $gdp_post_type = $gdp_post_type != '' && !empty($all_postypes) && in_array($gdp_post_type, $all_postypes) ? $gdp_post_type : NULL; | |
| 479 | 479 | |
| 480 | -    if ($gdp_post_id && $gdp_post_type) {
 | |
| 481 | - $append_class = 'gd-post-' . $gdp_post_type; | |
| 482 | - $append_class .= isset($post->is_featured) && $post->is_featured > 0 ? ' gd-post-featured' : ''; | |
| 483 | - $class = $class != '' ? $class . ' ' . $append_class : $append_class; | |
| 484 | - } | |
| 480 | +	if ($gdp_post_id && $gdp_post_type) {
 | |
| 481 | + $append_class = 'gd-post-' . $gdp_post_type; | |
| 482 | + $append_class .= isset($post->is_featured) && $post->is_featured > 0 ? ' gd-post-featured' : ''; | |
| 483 | + $class = $class != '' ? $class . ' ' . $append_class : $append_class; | |
| 484 | + } | |
| 485 | 485 | |
| 486 | - return $class; | |
| 486 | + return $class; | |
| 487 | 487 | } | 
| 488 | 488 | |
| 489 | 489 | /** | 
| @@ -497,7 +497,7 @@ discard block | ||
| 497 | 497 | * @param bool $favorite Listing Optional. Are favorite listings results? Default: false. | 
| 498 | 498 | */ | 
| 499 | 499 |  function geodir_display_message_not_found_on_listing($template_listview = 'listing-listview', $favorite = false) {
 | 
| 500 | -    if ($favorite) {
 | |
| 500 | +	if ($favorite) {
 | |
| 501 | 501 |  		$message = __('No favorite listings found which match your selection.', 'geodirectory');
 | 
| 502 | 502 |  	} else {
 | 
| 503 | 503 |  		$message = __('No listings found which match your selection.', 'geodirectory');
 | 
| @@ -55,13 +55,13 @@ discard block | ||
| 55 | 55 | if (!empty($post_types)) | 
| 56 | 56 | $post_type = $post_types[0]; | 
| 57 | 57 | |
| 58 | - if($sc_post_type != '' ) | |
| 58 | + if ($sc_post_type != '') | |
| 59 | 59 | $post_type = $sc_post_type; | 
| 60 | 60 | |
| 61 | 61 |                  if ($is_wpml && !empty($wp->query_vars['page_id'])) {
 | 
| 62 | 62 |  					wp_redirect(geodir_getlink(get_permalink($wp->query_vars['page_id']), array('listing_type' => $post_type)));
 | 
| 63 | 63 |  				} else {
 | 
| 64 | - wp_redirect(trailingslashit(get_site_url()) . $pagename . '/?listing_type=' . $post_type); | |
| 64 | + wp_redirect(trailingslashit(get_site_url()).$pagename.'/?listing_type='.$post_type); | |
| 65 | 65 | } | 
| 66 | 66 | gd_die(); | 
| 67 | 67 | } | 
| @@ -119,14 +119,14 @@ discard block | ||
| 119 | 119 | case 'listing-listview': | 
| 120 | 120 |              $template = locate_template(array("geodirectory/listing-listview.php"));
 | 
| 121 | 121 |              if (!$template) {
 | 
| 122 | - $template = geodir_plugin_path() . '/geodirectory-templates/listing-listview.php'; | |
| 122 | + $template = geodir_plugin_path().'/geodirectory-templates/listing-listview.php'; | |
| 123 | 123 | } | 
| 124 | 124 | return $template; | 
| 125 | 125 | break; | 
| 126 | 126 | case 'widget-listing-listview': | 
| 127 | 127 |              $template = locate_template(array("geodirectory/widget-listing-listview.php"));
 | 
| 128 | 128 |              if (!$template) {
 | 
| 129 | - $template = geodir_plugin_path() . '/geodirectory-templates/widget-listing-listview.php'; | |
| 129 | + $template = geodir_plugin_path().'/geodirectory-templates/widget-listing-listview.php'; | |
| 130 | 130 | } | 
| 131 | 131 | return $template; | 
| 132 | 132 | break; | 
| @@ -184,7 +184,7 @@ discard block | ||
| 184 | 184 | |
| 185 | 185 |          $template = geodir_locate_template('signup');
 | 
| 186 | 186 | |
| 187 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-signup.php'; | |
| 187 | + if (!$template) $template = geodir_plugin_path().'/geodirectory-templates/geodir-signup.php'; | |
| 188 | 188 | |
| 189 | 189 | /** | 
| 190 | 190 | * Filter the signup template path. | 
| @@ -198,11 +198,11 @@ discard block | ||
| 198 | 198 |      if (geodir_is_page('add-listing') || $geodir_custom_page_list['geodir_add_listing_page']) {
 | 
| 199 | 199 |          if (!geodir_is_default_location_set()) {
 | 
| 200 | 200 | global $information; | 
| 201 | -            $information = sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>');
 | |
| 201 | +            $information = sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\''.admin_url('admin.php?page=geodirectory&tab=default_location_settings').'\'>', '</a>');
 | |
| 202 | 202 | |
| 203 | 203 |              $template = geodir_locate_template('information');
 | 
| 204 | 204 | |
| 205 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php'; | |
| 205 | + if (!$template) $template = geodir_plugin_path().'/geodirectory-templates/geodir-information.php'; | |
| 206 | 206 | /** | 
| 207 | 207 | * Filter the information template path. | 
| 208 | 208 | * | 
| @@ -214,10 +214,10 @@ discard block | ||
| 214 | 214 | // check if pid exists in the record if yes then check if this post belongs to the user who is logged in. | 
| 215 | 215 |          if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
 | 
| 216 | 216 | /// WPML | 
| 217 | -            if (geodir_is_wpml() && $duplicate_of = wpml_get_master_post_from_duplicate((int)$_GET['pid'])) {
 | |
| 217 | +            if (geodir_is_wpml() && $duplicate_of = wpml_get_master_post_from_duplicate((int) $_GET['pid'])) {
 | |
| 218 | 218 | global $sitepress; | 
| 219 | 219 | |
| 220 | - $lang_of_duplicate = geodir_get_language_for_element($duplicate_of, 'post_' . get_post_type($duplicate_of)); | |
| 220 | + $lang_of_duplicate = geodir_get_language_for_element($duplicate_of, 'post_'.get_post_type($duplicate_of)); | |
| 221 | 221 | $sitepress->switch_lang($lang_of_duplicate, true); | 
| 222 | 222 | |
| 223 | 223 | $redirect_to = get_permalink(geodir_add_listing_page_id()); | 
| @@ -236,7 +236,7 @@ discard block | ||
| 236 | 236 |              if (!$is_current_user_owner) {
 | 
| 237 | 237 |                  $template = geodir_locate_template('information');
 | 
| 238 | 238 | |
| 239 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php'; | |
| 239 | + if (!$template) $template = geodir_plugin_path().'/geodirectory-templates/geodir-information.php'; | |
| 240 | 240 | /** | 
| 241 | 241 | * Filter the information template path. | 
| 242 | 242 | * | 
| @@ -258,7 +258,7 @@ discard block | ||
| 258 | 258 | |
| 259 | 259 |          $template = geodir_locate_template('add-listing');
 | 
| 260 | 260 | |
| 261 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/add-listing.php'; | |
| 261 | + if (!$template) $template = geodir_plugin_path().'/geodirectory-templates/add-listing.php'; | |
| 262 | 262 | /** | 
| 263 | 263 | * Filter the add listing template path. | 
| 264 | 264 | * | 
| @@ -275,7 +275,7 @@ discard block | ||
| 275 | 275 | |
| 276 | 276 |          $template = geodir_locate_template('preview');
 | 
| 277 | 277 | |
| 278 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php'; | |
| 278 | + if (!$template) $template = geodir_plugin_path().'/geodirectory-templates/listing-detail.php'; | |
| 279 | 279 | /** | 
| 280 | 280 | * Filter the preview template path. | 
| 281 | 281 | * | 
| @@ -291,7 +291,7 @@ discard block | ||
| 291 | 291 | |
| 292 | 292 |          $template = geodir_locate_template('success');
 | 
| 293 | 293 | |
| 294 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-success.php'; | |
| 294 | + if (!$template) $template = geodir_plugin_path().'/geodirectory-templates/listing-success.php'; | |
| 295 | 295 | /** | 
| 296 | 296 | * Filter the success template path. | 
| 297 | 297 | * | 
| @@ -306,7 +306,7 @@ discard block | ||
| 306 | 306 | |
| 307 | 307 |          $template = geodir_locate_template('detail');
 | 
| 308 | 308 | |
| 309 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php'; | |
| 309 | + if (!$template) $template = geodir_plugin_path().'/geodirectory-templates/listing-detail.php'; | |
| 310 | 310 | /** | 
| 311 | 311 | * Filter the detail template path. | 
| 312 | 312 | * | 
| @@ -321,7 +321,7 @@ discard block | ||
| 321 | 321 | |
| 322 | 322 |          $template = geodir_locate_template('listing');
 | 
| 323 | 323 | |
| 324 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-listing.php'; | |
| 324 | + if (!$template) $template = geodir_plugin_path().'/geodirectory-templates/geodir-listing.php'; | |
| 325 | 325 | /** | 
| 326 | 326 | * Filter the listing template path. | 
| 327 | 327 | * | 
| @@ -336,7 +336,7 @@ discard block | ||
| 336 | 336 | |
| 337 | 337 |          $template = geodir_locate_template('search');
 | 
| 338 | 338 | |
| 339 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-search.php'; | |
| 339 | + if (!$template) $template = geodir_plugin_path().'/geodirectory-templates/geodir-search.php'; | |
| 340 | 340 | /** | 
| 341 | 341 | * Filter the search template path. | 
| 342 | 342 | * | 
| @@ -351,7 +351,7 @@ discard block | ||
| 351 | 351 | |
| 352 | 352 |          $template = geodir_locate_template('author');
 | 
| 353 | 353 | |
| 354 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-author.php'; | |
| 354 | + if (!$template) $template = geodir_plugin_path().'/geodirectory-templates/geodir-author.php'; | |
| 355 | 355 | /** | 
| 356 | 356 | * Filter the author template path. | 
| 357 | 357 | * | 
| @@ -362,7 +362,7 @@ discard block | ||
| 362 | 362 | |
| 363 | 363 | } | 
| 364 | 364 | |
| 365 | -    if ( geodir_is_page('home') || geodir_is_page('location')) {
 | |
| 365 | +    if (geodir_is_page('home') || geodir_is_page('location')) {
 | |
| 366 | 366 | |
| 367 | 367 | global $post, $wp_query; | 
| 368 | 368 | |
| @@ -372,7 +372,7 @@ discard block | ||
| 372 | 372 | |
| 373 | 373 |              $template = geodir_locate_template('geodir-home');
 | 
| 374 | 374 | |
| 375 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-home.php'; | |
| 375 | + if (!$template) $template = geodir_plugin_path().'/geodirectory-templates/geodir-home.php'; | |
| 376 | 376 | /** | 
| 377 | 377 | * Filter the home page template path. | 
| 378 | 378 | * | 
| @@ -385,7 +385,7 @@ discard block | ||
| 385 | 385 | |
| 386 | 386 |              $template = geodir_locate_template('location');
 | 
| 387 | 387 | |
| 388 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-location.php'; | |
| 388 | + if (!$template) $template = geodir_plugin_path().'/geodirectory-templates/geodir-location.php'; | |
| 389 | 389 | /** | 
| 390 | 390 | * Filter the location template path. | 
| 391 | 391 | * | 
| @@ -427,7 +427,7 @@ discard block | ||
| 427 | 427 | */ | 
| 428 | 428 |      do_action("geodir_get_template_part_{$slug}", $slug, $name);
 | 
| 429 | 429 | $templates = array(); | 
| 430 | - $name = (string)$name; | |
| 430 | + $name = (string) $name; | |
| 431 | 431 |      if ('' !== $name) {
 | 
| 432 | 432 |          $template_name = "{$slug}-{$name}.php";
 | 
| 433 | 433 | |
| @@ -435,14 +435,14 @@ discard block | ||
| 435 | 435 |          $template_name = "{$slug}.php";
 | 
| 436 | 436 | } | 
| 437 | 437 | |
| 438 | -    if (!locate_template(array("geodirectory/" . $template_name))) :
 | |
| 438 | +    if (!locate_template(array("geodirectory/".$template_name))) :
 | |
| 439 | 439 | /** | 
| 440 | 440 | * Filter the template part with slug and name. | 
| 441 | 441 | * | 
| 442 | 442 | * @since 1.0.0 | 
| 443 | 443 | * @param string $template_name The template name. | 
| 444 | 444 | */ | 
| 445 | -        $template = apply_filters("geodir_template_part-{$slug}-{$name}", geodir_plugin_path() . '/geodirectory-templates/' . $template_name);
 | |
| 445 | +        $template = apply_filters("geodir_template_part-{$slug}-{$name}", geodir_plugin_path().'/geodirectory-templates/'.$template_name);
 | |
| 446 | 446 | /** | 
| 447 | 447 | * Includes the template part with slug and name. | 
| 448 | 448 | * | 
| @@ -450,7 +450,7 @@ discard block | ||
| 450 | 450 | */ | 
| 451 | 451 | include($template); | 
| 452 | 452 | else: | 
| 453 | -        locate_template(array("geodirectory/" . $template_name), true, false);
 | |
| 453 | +        locate_template(array("geodirectory/".$template_name), true, false);
 | |
| 454 | 454 | endif; | 
| 455 | 455 | |
| 456 | 456 | } | 
| @@ -478,9 +478,9 @@ discard block | ||
| 478 | 478 | $gdp_post_type = $gdp_post_type != '' && !empty($all_postypes) && in_array($gdp_post_type, $all_postypes) ? $gdp_post_type : NULL; | 
| 479 | 479 | |
| 480 | 480 |      if ($gdp_post_id && $gdp_post_type) {
 | 
| 481 | - $append_class = 'gd-post-' . $gdp_post_type; | |
| 481 | + $append_class = 'gd-post-'.$gdp_post_type; | |
| 482 | 482 | $append_class .= isset($post->is_featured) && $post->is_featured > 0 ? ' gd-post-featured' : ''; | 
| 483 | - $class = $class != '' ? $class . ' ' . $append_class : $append_class; | |
| 483 | + $class = $class != '' ? $class.' '.$append_class : $append_class; | |
| 484 | 484 | } | 
| 485 | 485 | |
| 486 | 486 | return $class; | 
| @@ -512,7 +512,7 @@ discard block | ||
| 512 | 512 | */ | 
| 513 | 513 |  	$message = apply_filters('geodir_message_listing_not_found', $message, $template_listview, $favorite);
 | 
| 514 | 514 | |
| 515 | - echo '<li class="no-listing">' . $message . '</li>'; | |
| 515 | + echo '<li class="no-listing">'.$message.'</li>'; | |
| 516 | 516 | } | 
| 517 | 517 | |
| 518 | 518 | /** | 
| @@ -541,7 +541,7 @@ discard block | ||
| 541 | 541 |  function geodir_convert_listing_view_class($columns = '') {
 | 
| 542 | 542 | $class = ''; | 
| 543 | 543 | |
| 544 | -	switch ((int)$columns) {
 | |
| 544 | +	switch ((int) $columns) {
 | |
| 545 | 545 | case 1: | 
| 546 | 546 | $class = ''; | 
| 547 | 547 | break; | 
| @@ -606,7 +606,7 @@ discard block | ||
| 606 | 606 | $html .= '<option value=""></option>'; | 
| 607 | 607 |  		if (!empty($star_texts) && is_array($star_texts)) {
 | 
| 608 | 608 |  			foreach ($star_texts as $i => $text) {
 | 
| 609 | - $html .= '<option ' . selected((int)($i + 1), (int)$default, false) . ' value="' . (int)($i + 1) . '">' . $text . '</option>'; | |
| 609 | + $html .= '<option '.selected((int) ($i + 1), (int) $default, false).' value="'.(int) ($i + 1).'">'.$text.'</option>'; | |
| 610 | 610 | } | 
| 611 | 611 |  		} else {
 | 
| 612 | 612 | $html .= '<option value="1">1</option>'; | 
| @@ -635,14 +635,14 @@ discard block | ||
| 635 | 635 |  function geodir_font_awesome_rating_stars_html($html, $rating, $star_count = 5) {
 | 
| 636 | 636 |  	if (get_option('geodir_reviewrating_enable_font_awesome') == '1') {
 | 
| 637 | 637 | $rating = min($rating, $star_count); | 
| 638 | - $full_stars = floor( $rating ); | |
| 639 | - $half_stars = ceil( $rating - $full_stars ); | |
| 638 | + $full_stars = floor($rating); | |
| 639 | + $half_stars = ceil($rating - $full_stars); | |
| 640 | 640 | $empty_stars = $star_count - $full_stars - $half_stars; | 
| 641 | 641 | |
| 642 | 642 | $html = '<div class="gd-star-rating gd-fa-star-rating">'; | 
| 643 | - $html .= str_repeat( '<i class="fa fa-star gd-full-star"></i>', $full_stars ); | |
| 644 | - $html .= str_repeat( '<i class="fa fa-star-o fa-star-half-full gd-half-star"></i>', $half_stars ); | |
| 645 | - $html .= str_repeat( '<i class="fa fa-star-o gd-empty-star"></i>', $empty_stars); | |
| 643 | +		$html .= str_repeat('<i class="fa fa-star gd-full-star"></i>', $full_stars);
 | |
| 644 | +		$html .= str_repeat('<i class="fa fa-star-o fa-star-half-full gd-half-star"></i>', $half_stars);
 | |
| 645 | +		$html .= str_repeat('<i class="fa fa-star-o gd-empty-star"></i>', $empty_stars);
 | |
| 646 | 646 | $html .= '</div>'; | 
| 647 | 647 | } | 
| 648 | 648 | |
| @@ -661,7 +661,7 @@ discard block | ||
| 661 | 661 |  		$full_color = get_option('geodir_reviewrating_fa_full_rating_color', '#757575');
 | 
| 662 | 662 |  		if ($full_color != '#757575') {
 | 
| 663 | 663 | echo '<style type="text/css">.br-theme-fontawesome-stars .br-widget a.br-active:after,.br-theme-fontawesome-stars .br-widget a.br-selected:after, | 
| 664 | -			.gd-star-rating i.fa {color:' . stripslashes($full_color) . '!important;}</style>';
 | |
| 664 | +			.gd-star-rating i.fa {color:' . stripslashes($full_color).'!important;}</style>';
 | |
| 665 | 665 | } | 
| 666 | 666 | } | 
| 667 | 667 | } | 
| 668 | 668 | \ No newline at end of file |