@@ -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); |
@@ -18,11 +18,11 @@ discard block |
||
18 | 18 | */ |
19 | 19 | function geodir_divi_signup_body_class($classes) |
20 | 20 | { |
21 | - if (geodir_is_page('login')) { |
|
22 | - $classes = str_replace('et_right_sidebar', 'et_full_width_page', $classes); |
|
23 | - $classes[] = 'divi-gd-signup'; |
|
24 | - } |
|
25 | - return $classes; |
|
21 | + if (geodir_is_page('login')) { |
|
22 | + $classes = str_replace('et_right_sidebar', 'et_full_width_page', $classes); |
|
23 | + $classes[] = 'divi-gd-signup'; |
|
24 | + } |
|
25 | + return $classes; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | add_action('geodir_wrapper_close', 'geodir_divi_action_wrapper_close', 11); |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | */ |
35 | 35 | function geodir_divi_action_wrapper_close() |
36 | 36 | { |
37 | - if (geodir_is_page('login')) { |
|
38 | - // We need to close extra divs generated by WRAPPER BEFORE MAIN CONTENT (below) because there is no sidebar on this page |
|
39 | - echo '</div></div>'; |
|
40 | - } |
|
37 | + if (geodir_is_page('login')) { |
|
38 | + // We need to close extra divs generated by WRAPPER BEFORE MAIN CONTENT (below) because there is no sidebar on this page |
|
39 | + echo '</div></div>'; |
|
40 | + } |
|
41 | 41 | } |
42 | 42 | \ No newline at end of file |
@@ -126,8 +126,10 @@ |
||
126 | 126 | $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>"; |
127 | 127 | if (preg_match_all("/$regexp/siU", $crums, $matches)) { |
128 | 128 | return $matches[0]; |
129 | - } else return ''; |
|
130 | -} |
|
129 | + } else { |
|
130 | + return ''; |
|
131 | + } |
|
132 | + } |
|
131 | 133 | |
132 | 134 | |
133 | 135 | /** |
@@ -16,36 +16,36 @@ discard block |
||
16 | 16 | */ |
17 | 17 | function multi_news_action_calls() |
18 | 18 | { |
19 | - // REMOVE BREADCRUMB |
|
20 | - remove_action('geodir_detail_before_main_content', 'geodir_breadcrumb', 20); |
|
21 | - remove_action('geodir_listings_before_main_content', 'geodir_breadcrumb', 20); |
|
22 | - remove_action('geodir_author_before_main_content', 'geodir_breadcrumb', 20); |
|
23 | - remove_action('geodir_search_before_main_content', 'geodir_breadcrumb', 20); |
|
24 | - remove_action('geodir_home_before_main_content', 'geodir_breadcrumb', 20); |
|
25 | - remove_action('geodir_location_before_main_content', 'geodir_breadcrumb', 20); |
|
26 | - |
|
27 | - //ADD BREADCRUMS |
|
28 | - add_action('geodir_detail_before_main_content', 'gd_mn_replace_breadcrums', 20); |
|
29 | - add_action('geodir_listings_before_main_content', 'gd_mn_replace_breadcrums', 20); |
|
30 | - add_action('geodir_author_before_main_content', 'gd_mn_replace_breadcrums', 20); |
|
31 | - add_action('geodir_search_before_main_content', 'gd_mn_replace_breadcrums', 20); |
|
32 | - //add_action('geodir_home_before_main_content', 'gd_mn_replace_breadcrums', 20); |
|
33 | - add_action('geodir_location_before_main_content', 'gd_mn_replace_breadcrums', 20); |
|
34 | - |
|
35 | - |
|
36 | - // fix breadcrums |
|
37 | - add_filter('breadcrumbs_plus_items', 'gd_breadcrumbs_plus_items', 1); |
|
38 | - |
|
39 | - // REMOVE PAGE TITLES |
|
40 | - remove_action('geodir_listings_page_title', 'geodir_action_listings_title', 10); |
|
41 | - // remove_action( 'geodir_add_listing_page_title', 'geodir_action_add_listing_page_title',10); |
|
42 | - remove_action('geodir_details_main_content', 'geodir_action_page_title', 20); |
|
43 | - remove_action('geodir_search_page_title', 'geodir_action_search_page_title', 10); |
|
44 | - remove_action('geodir_author_page_title', 'geodir_action_author_page_title', 10); |
|
45 | - |
|
46 | - |
|
47 | - add_action('geodir_wrapper_content_open', 'gd_mn_extra_wrap', 30, 1); |
|
48 | - add_action('geodir_wrapper_content_close', 'gd_mn_extra_wrap_end', 3, 1); |
|
19 | + // REMOVE BREADCRUMB |
|
20 | + remove_action('geodir_detail_before_main_content', 'geodir_breadcrumb', 20); |
|
21 | + remove_action('geodir_listings_before_main_content', 'geodir_breadcrumb', 20); |
|
22 | + remove_action('geodir_author_before_main_content', 'geodir_breadcrumb', 20); |
|
23 | + remove_action('geodir_search_before_main_content', 'geodir_breadcrumb', 20); |
|
24 | + remove_action('geodir_home_before_main_content', 'geodir_breadcrumb', 20); |
|
25 | + remove_action('geodir_location_before_main_content', 'geodir_breadcrumb', 20); |
|
26 | + |
|
27 | + //ADD BREADCRUMS |
|
28 | + add_action('geodir_detail_before_main_content', 'gd_mn_replace_breadcrums', 20); |
|
29 | + add_action('geodir_listings_before_main_content', 'gd_mn_replace_breadcrums', 20); |
|
30 | + add_action('geodir_author_before_main_content', 'gd_mn_replace_breadcrums', 20); |
|
31 | + add_action('geodir_search_before_main_content', 'gd_mn_replace_breadcrums', 20); |
|
32 | + //add_action('geodir_home_before_main_content', 'gd_mn_replace_breadcrums', 20); |
|
33 | + add_action('geodir_location_before_main_content', 'gd_mn_replace_breadcrums', 20); |
|
34 | + |
|
35 | + |
|
36 | + // fix breadcrums |
|
37 | + add_filter('breadcrumbs_plus_items', 'gd_breadcrumbs_plus_items', 1); |
|
38 | + |
|
39 | + // REMOVE PAGE TITLES |
|
40 | + remove_action('geodir_listings_page_title', 'geodir_action_listings_title', 10); |
|
41 | + // remove_action( 'geodir_add_listing_page_title', 'geodir_action_add_listing_page_title',10); |
|
42 | + remove_action('geodir_details_main_content', 'geodir_action_page_title', 20); |
|
43 | + remove_action('geodir_search_page_title', 'geodir_action_search_page_title', 10); |
|
44 | + remove_action('geodir_author_page_title', 'geodir_action_author_page_title', 10); |
|
45 | + |
|
46 | + |
|
47 | + add_action('geodir_wrapper_content_open', 'gd_mn_extra_wrap', 30, 1); |
|
48 | + add_action('geodir_wrapper_content_close', 'gd_mn_extra_wrap_end', 3, 1); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | */ |
58 | 58 | function gd_mn_extra_wrap($page) |
59 | 59 | { |
60 | - if ($page == 'add-listing-page') { |
|
61 | - echo '<div class="site-content page-wrap">'; |
|
62 | - } elseif ($page == 'signup-page') { |
|
63 | - echo '</div><div class="section full-width-section" style="float: left;width:100%;">'; |
|
64 | - } |
|
60 | + if ($page == 'add-listing-page') { |
|
61 | + echo '<div class="site-content page-wrap">'; |
|
62 | + } elseif ($page == 'signup-page') { |
|
63 | + echo '</div><div class="section full-width-section" style="float: left;width:100%;">'; |
|
64 | + } |
|
65 | 65 | |
66 | 66 | } |
67 | 67 | |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | */ |
76 | 76 | function gd_mn_extra_wrap_end($page) |
77 | 77 | { |
78 | - if ($page == 'add-listing-page') { |
|
79 | - echo '</div>'; |
|
80 | - } |
|
78 | + if ($page == 'add-listing-page') { |
|
79 | + echo '</div>'; |
|
80 | + } |
|
81 | 81 | |
82 | 82 | } |
83 | 83 | |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | function gd_mn_replace_breadcrums() |
92 | 92 | { |
93 | 93 | |
94 | - if (mom_option('breadcrumb') != 0) { ?> |
|
94 | + if (mom_option('breadcrumb') != 0) { ?> |
|
95 | 95 | <?php if (mom_option('cats_bread')) { |
96 | - $cclass = ''; |
|
97 | - if (mom_option('cat_slider') == false) { |
|
98 | - $cclass = 'post-crumbs '; |
|
99 | - } |
|
100 | - ?> |
|
96 | + $cclass = ''; |
|
97 | + if (mom_option('cat_slider') == false) { |
|
98 | + $cclass = 'post-crumbs '; |
|
99 | + } |
|
100 | + ?> |
|
101 | 101 | <div class="<?php echo $cclass; ?>entry-crumbs" xmlns:v="http://rdf.data-vocabulary.org/#"> |
102 | 102 | |
103 | 103 | <?php mom_breadcrumb(); ?> |
@@ -119,14 +119,14 @@ discard block |
||
119 | 119 | */ |
120 | 120 | function gd_get_breadcrum_links() |
121 | 121 | { |
122 | - ob_start(); |
|
123 | - geodir_breadcrumb(); |
|
124 | - $crums = ob_get_contents(); |
|
125 | - ob_get_clean(); |
|
126 | - $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>"; |
|
127 | - if (preg_match_all("/$regexp/siU", $crums, $matches)) { |
|
128 | - return $matches[0]; |
|
129 | - } else return ''; |
|
122 | + ob_start(); |
|
123 | + geodir_breadcrumb(); |
|
124 | + $crums = ob_get_contents(); |
|
125 | + ob_get_clean(); |
|
126 | + $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>"; |
|
127 | + if (preg_match_all("/$regexp/siU", $crums, $matches)) { |
|
128 | + return $matches[0]; |
|
129 | + } else return ''; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | |
@@ -140,30 +140,30 @@ discard block |
||
140 | 140 | */ |
141 | 141 | function gd_breadcrumbs_plus_items($items) |
142 | 142 | { //print_r($items);exit; |
143 | - $bits = array(); |
|
144 | - $pieces = gd_get_breadcrum_links(); |
|
145 | - //unset($pieces[0]); |
|
146 | - $bits = $pieces; |
|
143 | + $bits = array(); |
|
144 | + $pieces = gd_get_breadcrum_links(); |
|
145 | + //unset($pieces[0]); |
|
146 | + $bits = $pieces; |
|
147 | 147 | |
148 | - $title = $items['last']; |
|
149 | - if (is_page_geodir_home() || geodir_is_page('location')) { |
|
148 | + $title = $items['last']; |
|
149 | + if (is_page_geodir_home() || geodir_is_page('location')) { |
|
150 | 150 | |
151 | - } elseif (geodir_is_page('listing')) { |
|
151 | + } elseif (geodir_is_page('listing')) { |
|
152 | 152 | |
153 | - } elseif (geodir_is_page('detail')) { |
|
154 | - ob_start(); |
|
155 | - geodir_action_page_title(); |
|
156 | - $title = ob_get_contents(); |
|
157 | - ob_end_clean(); |
|
158 | - } elseif (geodir_is_page('search')) { |
|
159 | - } elseif (geodir_is_page('author')) { |
|
160 | - } |
|
153 | + } elseif (geodir_is_page('detail')) { |
|
154 | + ob_start(); |
|
155 | + geodir_action_page_title(); |
|
156 | + $title = ob_get_contents(); |
|
157 | + ob_end_clean(); |
|
158 | + } elseif (geodir_is_page('search')) { |
|
159 | + } elseif (geodir_is_page('author')) { |
|
160 | + } |
|
161 | 161 | |
162 | - $title = strip_tags($title); |
|
163 | - $items = gd_breadcrumbs_plus_items_add($items, $bits, $title); |
|
162 | + $title = strip_tags($title); |
|
163 | + $items = gd_breadcrumbs_plus_items_add($items, $bits, $title); |
|
164 | 164 | |
165 | 165 | |
166 | - return $items; |
|
166 | + return $items; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | |
@@ -179,28 +179,28 @@ discard block |
||
179 | 179 | */ |
180 | 180 | function gd_breadcrumbs_plus_items_add($items, $bits, $last) |
181 | 181 | { |
182 | - //$pieces = explode("</div>", $items[0]); |
|
183 | - if (is_array($bits)) { |
|
184 | - $items = array(); |
|
185 | - $pieces = ''; |
|
186 | - foreach ($bits as $bit) { |
|
187 | - $pieces .= $bit; |
|
188 | - } |
|
189 | - $items[0] = '<div class="vbreadcrumb" typeof="v:Breadcrumb">' . $pieces . "</div>"; |
|
190 | - if (isset($last) && $last) { |
|
191 | - $items['last'] = $last; |
|
192 | - } |
|
193 | - } |
|
194 | - |
|
195 | - //print_r($items); |
|
196 | - return $items; |
|
182 | + //$pieces = explode("</div>", $items[0]); |
|
183 | + if (is_array($bits)) { |
|
184 | + $items = array(); |
|
185 | + $pieces = ''; |
|
186 | + foreach ($bits as $bit) { |
|
187 | + $pieces .= $bit; |
|
188 | + } |
|
189 | + $items[0] = '<div class="vbreadcrumb" typeof="v:Breadcrumb">' . $pieces . "</div>"; |
|
190 | + if (isset($last) && $last) { |
|
191 | + $items['last'] = $last; |
|
192 | + } |
|
193 | + } |
|
194 | + |
|
195 | + //print_r($items); |
|
196 | + return $items; |
|
197 | 197 | |
198 | 198 | } |
199 | 199 | |
200 | 200 | add_filter('geodir_menu_after_sub_ul','gd_multinews_mobile_menu_caret',10,1); |
201 | 201 | add_filter('geodir_location_switcher_menu_after_sub_ul','gd_multinews_mobile_menu_caret',10,1); |
202 | 202 | function gd_multinews_mobile_menu_caret($html){ |
203 | - $html .= '<i class="responsive-caret"></i>'; |
|
204 | - return $html; |
|
203 | + $html .= '<i class="responsive-caret"></i>'; |
|
204 | + return $html; |
|
205 | 205 | |
206 | 206 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | foreach ($bits as $bit) { |
187 | 187 | $pieces .= $bit; |
188 | 188 | } |
189 | - $items[0] = '<div class="vbreadcrumb" typeof="v:Breadcrumb">' . $pieces . "</div>"; |
|
189 | + $items[0] = '<div class="vbreadcrumb" typeof="v:Breadcrumb">'.$pieces."</div>"; |
|
190 | 190 | if (isset($last) && $last) { |
191 | 191 | $items['last'] = $last; |
192 | 192 | } |
@@ -197,9 +197,9 @@ discard block |
||
197 | 197 | |
198 | 198 | } |
199 | 199 | |
200 | -add_filter('geodir_menu_after_sub_ul','gd_multinews_mobile_menu_caret',10,1); |
|
201 | -add_filter('geodir_location_switcher_menu_after_sub_ul','gd_multinews_mobile_menu_caret',10,1); |
|
202 | -function gd_multinews_mobile_menu_caret($html){ |
|
200 | +add_filter('geodir_menu_after_sub_ul', 'gd_multinews_mobile_menu_caret', 10, 1); |
|
201 | +add_filter('geodir_location_switcher_menu_after_sub_ul', 'gd_multinews_mobile_menu_caret', 10, 1); |
|
202 | +function gd_multinews_mobile_menu_caret($html) { |
|
203 | 203 | $html .= '<i class="responsive-caret"></i>'; |
204 | 204 | return $html; |
205 | 205 |
@@ -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 | } |
@@ -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 |
@@ -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,238 +151,238 @@ 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 | - global $information; |
|
217 | - $information = __('This listing does not belong to your account, please check the listing id carefully.', 'geodirectory'); |
|
218 | - $is_current_user_owner = geodir_listing_belong_to_current_user(); |
|
219 | - if (!$is_current_user_owner) { |
|
220 | - $template = geodir_locate_template('information'); |
|
221 | - |
|
222 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php'; |
|
223 | - /** |
|
224 | - * Filter the information template path. |
|
225 | - * |
|
226 | - * @since 1.0.0 |
|
227 | - * @param string $template The template path. |
|
228 | - */ |
|
229 | - return $template = apply_filters('geodir_template_information', $template); |
|
230 | - } |
|
231 | - |
|
232 | - |
|
233 | - } |
|
234 | - |
|
235 | - //geodir_is_login(true); |
|
236 | - global $current_user; |
|
237 | - if (!$current_user->ID) { |
|
238 | - wp_redirect(geodir_login_url(array('redirect_add_listing'=>urlencode(geodir_curPageURL()))), 302); |
|
239 | - exit; |
|
240 | - } |
|
241 | - |
|
242 | - $template = geodir_locate_template('add-listing'); |
|
243 | - |
|
244 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/add-listing.php'; |
|
245 | - /** |
|
246 | - * Filter the add listing template path. |
|
247 | - * |
|
248 | - * @since 1.0.0 |
|
249 | - * @param string $template The template path. |
|
250 | - */ |
|
251 | - return $template = apply_filters('geodir_template_add_listing', $template); |
|
252 | - } |
|
253 | - |
|
254 | - |
|
255 | - if (geodir_is_page('preview') || $geodir_custom_page_list['geodir_preview_page']) { |
|
256 | - global $preview; |
|
257 | - $preview = true; |
|
258 | - |
|
259 | - $template = geodir_locate_template('preview'); |
|
260 | - |
|
261 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php'; |
|
262 | - /** |
|
263 | - * Filter the preview template path. |
|
264 | - * |
|
265 | - * @since 1.0.0 |
|
266 | - * @param string $template The template path. |
|
267 | - */ |
|
268 | - return $template = apply_filters('geodir_template_preview', $template); |
|
269 | - |
|
270 | - } |
|
271 | - |
|
272 | - |
|
273 | - if (geodir_is_page('listing-success') || $geodir_custom_page_list['geodir_listing_success_page']) { |
|
274 | - |
|
275 | - $template = geodir_locate_template('success'); |
|
276 | - |
|
277 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-success.php'; |
|
278 | - /** |
|
279 | - * Filter the success template path. |
|
280 | - * |
|
281 | - * @since 1.0.0 |
|
282 | - * @param string $template The template path. |
|
283 | - */ |
|
284 | - return $template = apply_filters('geodir_template_success', $template); |
|
285 | - |
|
286 | - } |
|
287 | - |
|
288 | - if (geodir_is_page('detail') || $geodir_custom_page_list['geodir_listing_detail_page']) { |
|
289 | - |
|
290 | - $template = geodir_locate_template('detail'); |
|
291 | - |
|
292 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php'; |
|
293 | - /** |
|
294 | - * Filter the detail template path. |
|
295 | - * |
|
296 | - * @since 1.0.0 |
|
297 | - * @param string $template The template path. |
|
298 | - */ |
|
299 | - return $template = apply_filters('geodir_template_detail', $template); |
|
300 | - |
|
301 | - } |
|
302 | - |
|
303 | - if (geodir_is_page('listing') || $geodir_custom_page_list['geodir_listing_page']) { |
|
304 | - |
|
305 | - $template = geodir_locate_template('listing'); |
|
306 | - |
|
307 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-listing.php'; |
|
308 | - /** |
|
309 | - * Filter the listing template path. |
|
310 | - * |
|
311 | - * @since 1.0.0 |
|
312 | - * @param string $template The template path. |
|
313 | - */ |
|
314 | - return $template = apply_filters('geodir_template_listing', $template); |
|
154 | + global $wp_query; |
|
315 | 155 | |
316 | - } |
|
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 | + } |
|
317 | 197 | |
318 | - if (geodir_is_page('search') || $geodir_custom_page_list['geodir_search_page']) { |
|
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 | + global $information; |
|
217 | + $information = __('This listing does not belong to your account, please check the listing id carefully.', 'geodirectory'); |
|
218 | + $is_current_user_owner = geodir_listing_belong_to_current_user(); |
|
219 | + if (!$is_current_user_owner) { |
|
220 | + $template = geodir_locate_template('information'); |
|
221 | + |
|
222 | + if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php'; |
|
223 | + /** |
|
224 | + * Filter the information template path. |
|
225 | + * |
|
226 | + * @since 1.0.0 |
|
227 | + * @param string $template The template path. |
|
228 | + */ |
|
229 | + return $template = apply_filters('geodir_template_information', $template); |
|
230 | + } |
|
319 | 231 | |
320 | - $template = geodir_locate_template('search'); |
|
321 | 232 | |
322 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-search.php'; |
|
323 | - /** |
|
324 | - * Filter the search template path. |
|
325 | - * |
|
326 | - * @since 1.0.0 |
|
327 | - * @param string $template The template path. |
|
328 | - */ |
|
329 | - return $template = apply_filters('geodir_template_search', $template); |
|
233 | + } |
|
234 | + |
|
235 | + //geodir_is_login(true); |
|
236 | + global $current_user; |
|
237 | + if (!$current_user->ID) { |
|
238 | + wp_redirect(geodir_login_url(array('redirect_add_listing'=>urlencode(geodir_curPageURL()))), 302); |
|
239 | + exit; |
|
240 | + } |
|
241 | + |
|
242 | + $template = geodir_locate_template('add-listing'); |
|
243 | + |
|
244 | + if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/add-listing.php'; |
|
245 | + /** |
|
246 | + * Filter the add listing template path. |
|
247 | + * |
|
248 | + * @since 1.0.0 |
|
249 | + * @param string $template The template path. |
|
250 | + */ |
|
251 | + return $template = apply_filters('geodir_template_add_listing', $template); |
|
252 | + } |
|
330 | 253 | |
331 | - } |
|
332 | 254 | |
333 | - if (geodir_is_page('author') || $geodir_custom_page_list['geodir_author_page']) { |
|
255 | + if (geodir_is_page('preview') || $geodir_custom_page_list['geodir_preview_page']) { |
|
256 | + global $preview; |
|
257 | + $preview = true; |
|
334 | 258 | |
335 | - $template = geodir_locate_template('author'); |
|
259 | + $template = geodir_locate_template('preview'); |
|
336 | 260 | |
337 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-author.php'; |
|
338 | - /** |
|
339 | - * Filter the author template path. |
|
340 | - * |
|
341 | - * @since 1.0.0 |
|
342 | - * @param string $template The template path. |
|
343 | - */ |
|
344 | - return $template = apply_filters('geodir_template_author', $template); |
|
261 | + if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php'; |
|
262 | + /** |
|
263 | + * Filter the preview template path. |
|
264 | + * |
|
265 | + * @since 1.0.0 |
|
266 | + * @param string $template The template path. |
|
267 | + */ |
|
268 | + return $template = apply_filters('geodir_template_preview', $template); |
|
345 | 269 | |
346 | - } |
|
270 | + } |
|
347 | 271 | |
348 | - if ( geodir_is_page('home') || geodir_is_page('location')) { |
|
349 | 272 | |
350 | - global $post, $wp_query; |
|
273 | + if (geodir_is_page('listing-success') || $geodir_custom_page_list['geodir_listing_success_page']) { |
|
351 | 274 | |
352 | - if (geodir_is_page('home') || ('page' == get_option('show_on_front') && isset($post->ID) && $post->ID == get_option('page_on_front')) |
|
353 | - || (is_home() && !$wp_query->is_posts_page) |
|
354 | - ) { |
|
275 | + $template = geodir_locate_template('success'); |
|
355 | 276 | |
356 | - $template = geodir_locate_template('geodir-home'); |
|
277 | + if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-success.php'; |
|
278 | + /** |
|
279 | + * Filter the success template path. |
|
280 | + * |
|
281 | + * @since 1.0.0 |
|
282 | + * @param string $template The template path. |
|
283 | + */ |
|
284 | + return $template = apply_filters('geodir_template_success', $template); |
|
357 | 285 | |
358 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-home.php'; |
|
359 | - /** |
|
360 | - * Filter the home page template path. |
|
361 | - * |
|
362 | - * @since 1.0.0 |
|
363 | - * @param string $template The template path. |
|
364 | - */ |
|
365 | - return $template = apply_filters('geodir_template_homepage', $template); |
|
286 | + } |
|
366 | 287 | |
367 | - } elseif (geodir_is_page('location')) { |
|
288 | + if (geodir_is_page('detail') || $geodir_custom_page_list['geodir_listing_detail_page']) { |
|
368 | 289 | |
369 | - $template = geodir_locate_template('location'); |
|
290 | + $template = geodir_locate_template('detail'); |
|
370 | 291 | |
371 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-location.php'; |
|
372 | - /** |
|
373 | - * Filter the location template path. |
|
374 | - * |
|
375 | - * @since 1.0.0 |
|
376 | - * @param string $template The template path. |
|
377 | - */ |
|
378 | - return $template = apply_filters('geodir_template_location', $template); |
|
292 | + if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php'; |
|
293 | + /** |
|
294 | + * Filter the detail template path. |
|
295 | + * |
|
296 | + * @since 1.0.0 |
|
297 | + * @param string $template The template path. |
|
298 | + */ |
|
299 | + return $template = apply_filters('geodir_template_detail', $template); |
|
300 | + |
|
301 | + } |
|
302 | + |
|
303 | + if (geodir_is_page('listing') || $geodir_custom_page_list['geodir_listing_page']) { |
|
304 | + |
|
305 | + $template = geodir_locate_template('listing'); |
|
306 | + |
|
307 | + if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-listing.php'; |
|
308 | + /** |
|
309 | + * Filter the listing template path. |
|
310 | + * |
|
311 | + * @since 1.0.0 |
|
312 | + * @param string $template The template path. |
|
313 | + */ |
|
314 | + return $template = apply_filters('geodir_template_listing', $template); |
|
315 | + |
|
316 | + } |
|
379 | 317 | |
380 | - } else |
|
381 | - return $template; |
|
318 | + if (geodir_is_page('search') || $geodir_custom_page_list['geodir_search_page']) { |
|
382 | 319 | |
383 | - } |
|
320 | + $template = geodir_locate_template('search'); |
|
384 | 321 | |
385 | - return $template; |
|
322 | + if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-search.php'; |
|
323 | + /** |
|
324 | + * Filter the search template path. |
|
325 | + * |
|
326 | + * @since 1.0.0 |
|
327 | + * @param string $template The template path. |
|
328 | + */ |
|
329 | + return $template = apply_filters('geodir_template_search', $template); |
|
330 | + |
|
331 | + } |
|
332 | + |
|
333 | + if (geodir_is_page('author') || $geodir_custom_page_list['geodir_author_page']) { |
|
334 | + |
|
335 | + $template = geodir_locate_template('author'); |
|
336 | + |
|
337 | + if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-author.php'; |
|
338 | + /** |
|
339 | + * Filter the author template path. |
|
340 | + * |
|
341 | + * @since 1.0.0 |
|
342 | + * @param string $template The template path. |
|
343 | + */ |
|
344 | + return $template = apply_filters('geodir_template_author', $template); |
|
345 | + |
|
346 | + } |
|
347 | + |
|
348 | + if ( geodir_is_page('home') || geodir_is_page('location')) { |
|
349 | + |
|
350 | + global $post, $wp_query; |
|
351 | + |
|
352 | + if (geodir_is_page('home') || ('page' == get_option('show_on_front') && isset($post->ID) && $post->ID == get_option('page_on_front')) |
|
353 | + || (is_home() && !$wp_query->is_posts_page) |
|
354 | + ) { |
|
355 | + |
|
356 | + $template = geodir_locate_template('geodir-home'); |
|
357 | + |
|
358 | + if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-home.php'; |
|
359 | + /** |
|
360 | + * Filter the home page template path. |
|
361 | + * |
|
362 | + * @since 1.0.0 |
|
363 | + * @param string $template The template path. |
|
364 | + */ |
|
365 | + return $template = apply_filters('geodir_template_homepage', $template); |
|
366 | + |
|
367 | + } elseif (geodir_is_page('location')) { |
|
368 | + |
|
369 | + $template = geodir_locate_template('location'); |
|
370 | + |
|
371 | + if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-location.php'; |
|
372 | + /** |
|
373 | + * Filter the location template path. |
|
374 | + * |
|
375 | + * @since 1.0.0 |
|
376 | + * @param string $template The template path. |
|
377 | + */ |
|
378 | + return $template = apply_filters('geodir_template_location', $template); |
|
379 | + |
|
380 | + } else |
|
381 | + return $template; |
|
382 | + |
|
383 | + } |
|
384 | + |
|
385 | + return $template; |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | /** |
@@ -397,44 +397,44 @@ discard block |
||
397 | 397 | */ |
398 | 398 | function geodir_get_template_part($slug = '', $name = NULL) |
399 | 399 | { |
400 | - global $geodirectory, $post; |
|
401 | - /** |
|
402 | - * Called at the start for the geodir_get_template_part() function. |
|
403 | - * |
|
404 | - * Used dynamic hook name: geodir_get_template_part_{$slug} |
|
405 | - * |
|
406 | - * @since 1.0.0 |
|
407 | - * @package GeoDirectory |
|
408 | - * @param string $slug The template slug. |
|
409 | - * @param string $name The template name. |
|
410 | - */ |
|
411 | - do_action("geodir_get_template_part_{$slug}", $slug, $name); |
|
412 | - $templates = array(); |
|
413 | - $name = (string)$name; |
|
414 | - if ('' !== $name) { |
|
415 | - $template_name = "{$slug}-{$name}.php"; |
|
416 | - |
|
417 | - } else { |
|
418 | - $template_name = "{$slug}.php"; |
|
419 | - } |
|
420 | - |
|
421 | - if (!locate_template(array("geodirectory/" . $template_name))) : |
|
422 | - /** |
|
423 | - * Filter the template part with slug and name. |
|
424 | - * |
|
425 | - * @since 1.0.0 |
|
426 | - * @param string $template_name The template name. |
|
427 | - */ |
|
428 | - $template = apply_filters("geodir_template_part-{$slug}-{$name}", geodir_plugin_path() . '/geodirectory-templates/' . $template_name); |
|
429 | - /** |
|
430 | - * Includes the template part with slug and name. |
|
431 | - * |
|
432 | - * @since 1.0.0 |
|
433 | - */ |
|
434 | - include($template); |
|
435 | - else: |
|
436 | - locate_template(array("geodirectory/" . $template_name), true, false); |
|
437 | - endif; |
|
400 | + global $geodirectory, $post; |
|
401 | + /** |
|
402 | + * Called at the start for the geodir_get_template_part() function. |
|
403 | + * |
|
404 | + * Used dynamic hook name: geodir_get_template_part_{$slug} |
|
405 | + * |
|
406 | + * @since 1.0.0 |
|
407 | + * @package GeoDirectory |
|
408 | + * @param string $slug The template slug. |
|
409 | + * @param string $name The template name. |
|
410 | + */ |
|
411 | + do_action("geodir_get_template_part_{$slug}", $slug, $name); |
|
412 | + $templates = array(); |
|
413 | + $name = (string)$name; |
|
414 | + if ('' !== $name) { |
|
415 | + $template_name = "{$slug}-{$name}.php"; |
|
416 | + |
|
417 | + } else { |
|
418 | + $template_name = "{$slug}.php"; |
|
419 | + } |
|
420 | + |
|
421 | + if (!locate_template(array("geodirectory/" . $template_name))) : |
|
422 | + /** |
|
423 | + * Filter the template part with slug and name. |
|
424 | + * |
|
425 | + * @since 1.0.0 |
|
426 | + * @param string $template_name The template name. |
|
427 | + */ |
|
428 | + $template = apply_filters("geodir_template_part-{$slug}-{$name}", geodir_plugin_path() . '/geodirectory-templates/' . $template_name); |
|
429 | + /** |
|
430 | + * Includes the template part with slug and name. |
|
431 | + * |
|
432 | + * @since 1.0.0 |
|
433 | + */ |
|
434 | + include($template); |
|
435 | + else: |
|
436 | + locate_template(array("geodirectory/" . $template_name), true, false); |
|
437 | + endif; |
|
438 | 438 | |
439 | 439 | } |
440 | 440 | |
@@ -450,23 +450,23 @@ discard block |
||
450 | 450 | */ |
451 | 451 | function geodir_core_post_view_extra_class($class, $all_postypes = '') |
452 | 452 | { |
453 | - global $post; |
|
453 | + global $post; |
|
454 | 454 | |
455 | - if (!$all_postypes) { |
|
456 | - $all_postypes = geodir_get_posttypes(); |
|
457 | - } |
|
455 | + if (!$all_postypes) { |
|
456 | + $all_postypes = geodir_get_posttypes(); |
|
457 | + } |
|
458 | 458 | |
459 | - $gdp_post_id = !empty($post) && isset($post->ID) ? $post->ID : NULL; |
|
460 | - $gdp_post_type = $gdp_post_id > 0 && isset($post->post_type) ? $post->post_type : NULL; |
|
461 | - $gdp_post_type = $gdp_post_type != '' && !empty($all_postypes) && in_array($gdp_post_type, $all_postypes) ? $gdp_post_type : NULL; |
|
459 | + $gdp_post_id = !empty($post) && isset($post->ID) ? $post->ID : NULL; |
|
460 | + $gdp_post_type = $gdp_post_id > 0 && isset($post->post_type) ? $post->post_type : NULL; |
|
461 | + $gdp_post_type = $gdp_post_type != '' && !empty($all_postypes) && in_array($gdp_post_type, $all_postypes) ? $gdp_post_type : NULL; |
|
462 | 462 | |
463 | - if ($gdp_post_id && $gdp_post_type) { |
|
464 | - $append_class = 'gd-post-' . $gdp_post_type; |
|
465 | - $append_class .= isset($post->is_featured) && $post->is_featured > 0 ? ' gd-post-featured' : ''; |
|
466 | - $class = $class != '' ? $class . ' ' . $append_class : $append_class; |
|
467 | - } |
|
463 | + if ($gdp_post_id && $gdp_post_type) { |
|
464 | + $append_class = 'gd-post-' . $gdp_post_type; |
|
465 | + $append_class .= isset($post->is_featured) && $post->is_featured > 0 ? ' gd-post-featured' : ''; |
|
466 | + $class = $class != '' ? $class . ' ' . $append_class : $append_class; |
|
467 | + } |
|
468 | 468 | |
469 | - return $class; |
|
469 | + return $class; |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | /** |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | * @param bool $favorite Listing Optional. Are favorite listings results? Default: false. |
481 | 481 | */ |
482 | 482 | function geodir_display_message_not_found_on_listing($template_listview = 'listing-listview', $favorite = false) { |
483 | - if ($favorite) { |
|
483 | + if ($favorite) { |
|
484 | 484 | $message = __('No favorite listings found which match your selection.', 'geodirectory'); |
485 | 485 | } else { |
486 | 486 | $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 | * |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | if (!$is_current_user_owner) { |
220 | 220 | $template = geodir_locate_template('information'); |
221 | 221 | |
222 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php'; |
|
222 | + if (!$template) $template = geodir_plugin_path().'/geodirectory-templates/geodir-information.php'; |
|
223 | 223 | /** |
224 | 224 | * Filter the information template path. |
225 | 225 | * |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | $template = geodir_locate_template('add-listing'); |
243 | 243 | |
244 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/add-listing.php'; |
|
244 | + if (!$template) $template = geodir_plugin_path().'/geodirectory-templates/add-listing.php'; |
|
245 | 245 | /** |
246 | 246 | * Filter the add listing template path. |
247 | 247 | * |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | |
259 | 259 | $template = geodir_locate_template('preview'); |
260 | 260 | |
261 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php'; |
|
261 | + if (!$template) $template = geodir_plugin_path().'/geodirectory-templates/listing-detail.php'; |
|
262 | 262 | /** |
263 | 263 | * Filter the preview template path. |
264 | 264 | * |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | |
275 | 275 | $template = geodir_locate_template('success'); |
276 | 276 | |
277 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-success.php'; |
|
277 | + if (!$template) $template = geodir_plugin_path().'/geodirectory-templates/listing-success.php'; |
|
278 | 278 | /** |
279 | 279 | * Filter the success template path. |
280 | 280 | * |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | |
290 | 290 | $template = geodir_locate_template('detail'); |
291 | 291 | |
292 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php'; |
|
292 | + if (!$template) $template = geodir_plugin_path().'/geodirectory-templates/listing-detail.php'; |
|
293 | 293 | /** |
294 | 294 | * Filter the detail template path. |
295 | 295 | * |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | |
305 | 305 | $template = geodir_locate_template('listing'); |
306 | 306 | |
307 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-listing.php'; |
|
307 | + if (!$template) $template = geodir_plugin_path().'/geodirectory-templates/geodir-listing.php'; |
|
308 | 308 | /** |
309 | 309 | * Filter the listing template path. |
310 | 310 | * |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | |
320 | 320 | $template = geodir_locate_template('search'); |
321 | 321 | |
322 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-search.php'; |
|
322 | + if (!$template) $template = geodir_plugin_path().'/geodirectory-templates/geodir-search.php'; |
|
323 | 323 | /** |
324 | 324 | * Filter the search template path. |
325 | 325 | * |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | |
335 | 335 | $template = geodir_locate_template('author'); |
336 | 336 | |
337 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-author.php'; |
|
337 | + if (!$template) $template = geodir_plugin_path().'/geodirectory-templates/geodir-author.php'; |
|
338 | 338 | /** |
339 | 339 | * Filter the author template path. |
340 | 340 | * |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | |
346 | 346 | } |
347 | 347 | |
348 | - if ( geodir_is_page('home') || geodir_is_page('location')) { |
|
348 | + if (geodir_is_page('home') || geodir_is_page('location')) { |
|
349 | 349 | |
350 | 350 | global $post, $wp_query; |
351 | 351 | |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | |
356 | 356 | $template = geodir_locate_template('geodir-home'); |
357 | 357 | |
358 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-home.php'; |
|
358 | + if (!$template) $template = geodir_plugin_path().'/geodirectory-templates/geodir-home.php'; |
|
359 | 359 | /** |
360 | 360 | * Filter the home page template path. |
361 | 361 | * |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | |
369 | 369 | $template = geodir_locate_template('location'); |
370 | 370 | |
371 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-location.php'; |
|
371 | + if (!$template) $template = geodir_plugin_path().'/geodirectory-templates/geodir-location.php'; |
|
372 | 372 | /** |
373 | 373 | * Filter the location template path. |
374 | 374 | * |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | */ |
411 | 411 | do_action("geodir_get_template_part_{$slug}", $slug, $name); |
412 | 412 | $templates = array(); |
413 | - $name = (string)$name; |
|
413 | + $name = (string) $name; |
|
414 | 414 | if ('' !== $name) { |
415 | 415 | $template_name = "{$slug}-{$name}.php"; |
416 | 416 | |
@@ -418,14 +418,14 @@ discard block |
||
418 | 418 | $template_name = "{$slug}.php"; |
419 | 419 | } |
420 | 420 | |
421 | - if (!locate_template(array("geodirectory/" . $template_name))) : |
|
421 | + if (!locate_template(array("geodirectory/".$template_name))) : |
|
422 | 422 | /** |
423 | 423 | * Filter the template part with slug and name. |
424 | 424 | * |
425 | 425 | * @since 1.0.0 |
426 | 426 | * @param string $template_name The template name. |
427 | 427 | */ |
428 | - $template = apply_filters("geodir_template_part-{$slug}-{$name}", geodir_plugin_path() . '/geodirectory-templates/' . $template_name); |
|
428 | + $template = apply_filters("geodir_template_part-{$slug}-{$name}", geodir_plugin_path().'/geodirectory-templates/'.$template_name); |
|
429 | 429 | /** |
430 | 430 | * Includes the template part with slug and name. |
431 | 431 | * |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | */ |
434 | 434 | include($template); |
435 | 435 | else: |
436 | - locate_template(array("geodirectory/" . $template_name), true, false); |
|
436 | + locate_template(array("geodirectory/".$template_name), true, false); |
|
437 | 437 | endif; |
438 | 438 | |
439 | 439 | } |
@@ -461,9 +461,9 @@ discard block |
||
461 | 461 | $gdp_post_type = $gdp_post_type != '' && !empty($all_postypes) && in_array($gdp_post_type, $all_postypes) ? $gdp_post_type : NULL; |
462 | 462 | |
463 | 463 | if ($gdp_post_id && $gdp_post_type) { |
464 | - $append_class = 'gd-post-' . $gdp_post_type; |
|
464 | + $append_class = 'gd-post-'.$gdp_post_type; |
|
465 | 465 | $append_class .= isset($post->is_featured) && $post->is_featured > 0 ? ' gd-post-featured' : ''; |
466 | - $class = $class != '' ? $class . ' ' . $append_class : $append_class; |
|
466 | + $class = $class != '' ? $class.' '.$append_class : $append_class; |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | return $class; |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | */ |
496 | 496 | $message = apply_filters('geodir_message_listing_not_found', $message, $template_listview, $favorite); |
497 | 497 | |
498 | - echo '<li class="no-listing">' . $message . '</li>'; |
|
498 | + echo '<li class="no-listing">'.$message.'</li>'; |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | /** |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | function geodir_convert_listing_view_class($columns = '') { |
525 | 525 | $class = ''; |
526 | 526 | |
527 | - switch ((int)$columns) { |
|
527 | + switch ((int) $columns) { |
|
528 | 528 | case 1: |
529 | 529 | $class = ''; |
530 | 530 | break; |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | $html .= '<option value=""></option>'; |
590 | 590 | if (!empty($star_texts) && is_array($star_texts)) { |
591 | 591 | foreach ($star_texts as $i => $text) { |
592 | - $html .= '<option ' . selected((int)($i + 1), (int)$default, false) . ' value="' . (int)($i + 1) . '">' . $text . '</option>'; |
|
592 | + $html .= '<option '.selected((int) ($i + 1), (int) $default, false).' value="'.(int) ($i + 1).'">'.$text.'</option>'; |
|
593 | 593 | } |
594 | 594 | } else { |
595 | 595 | $html .= '<option value="1">1</option>'; |
@@ -618,14 +618,14 @@ discard block |
||
618 | 618 | function geodir_font_awesome_rating_stars_html($html, $rating, $star_count = 5) { |
619 | 619 | if (get_option('geodir_reviewrating_enable_font_awesome') == '1') { |
620 | 620 | $rating = min($rating, $star_count); |
621 | - $full_stars = floor( $rating ); |
|
622 | - $half_stars = ceil( $rating - $full_stars ); |
|
621 | + $full_stars = floor($rating); |
|
622 | + $half_stars = ceil($rating - $full_stars); |
|
623 | 623 | $empty_stars = $star_count - $full_stars - $half_stars; |
624 | 624 | |
625 | 625 | $html = '<div class="gd-star-rating gd-fa-star-rating">'; |
626 | - $html .= str_repeat( '<i class="fa fa-star gd-full-star"></i>', $full_stars ); |
|
627 | - $html .= str_repeat( '<i class="fa fa-star-o fa-star-half-full gd-half-star"></i>', $half_stars ); |
|
628 | - $html .= str_repeat( '<i class="fa fa-star-o gd-empty-star"></i>', $empty_stars); |
|
626 | + $html .= str_repeat('<i class="fa fa-star gd-full-star"></i>', $full_stars); |
|
627 | + $html .= str_repeat('<i class="fa fa-star-o fa-star-half-full gd-half-star"></i>', $half_stars); |
|
628 | + $html .= str_repeat('<i class="fa fa-star-o gd-empty-star"></i>', $empty_stars); |
|
629 | 629 | $html .= '</div>'; |
630 | 630 | } |
631 | 631 | |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | $full_color = get_option('geodir_reviewrating_fa_full_rating_color', '#757575'); |
645 | 645 | if ($full_color != '#757575') { |
646 | 646 | 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, |
647 | - .gd-star-rating i.fa {color:' . stripslashes($full_color) . '!important;}</style>'; |
|
647 | + .gd-star-rating i.fa {color:' . stripslashes($full_color).'!important;}</style>'; |
|
648 | 648 | } |
649 | 649 | } |
650 | 650 | } |
651 | 651 | \ No newline at end of file |
@@ -13,8 +13,8 @@ |
||
13 | 13 | * If user is not signed in, redirect home. |
14 | 14 | */ |
15 | 15 | if (get_current_user_id()) { |
16 | - wp_redirect(home_url(), 302); |
|
17 | - exit; |
|
16 | + wp_redirect(home_url(), 302); |
|
17 | + exit; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | // call header |
@@ -15,29 +15,29 @@ discard block |
||
15 | 15 | <?php |
16 | 16 | |
17 | 17 | |
18 | - global $wpdb; |
|
18 | + global $wpdb; |
|
19 | 19 | |
20 | - $post_id = $_REQUEST['pid']; |
|
21 | - $post_info = get_post($post_id); |
|
20 | + $post_id = $_REQUEST['pid']; |
|
21 | + $post_info = get_post($post_id); |
|
22 | 22 | |
23 | - $posted_date = $post_info->post_date; |
|
24 | - $productlink = get_permalink($post_id); |
|
25 | - $siteName = get_bloginfo('name'); |
|
26 | - $siteurl = home_url(); |
|
27 | - $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>'; |
|
23 | + $posted_date = $post_info->post_date; |
|
24 | + $productlink = get_permalink($post_id); |
|
25 | + $siteName = get_bloginfo('name'); |
|
26 | + $siteurl = home_url(); |
|
27 | + $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>'; |
|
28 | 28 | |
29 | - $loginurl = geodir_login_url(); |
|
30 | - $loginurl_link = '<a href="' . $loginurl . '">login</a>'; |
|
29 | + $loginurl = geodir_login_url(); |
|
30 | + $loginurl_link = '<a href="' . $loginurl . '">login</a>'; |
|
31 | 31 | |
32 | - $post_author = $post_info->post_author; |
|
32 | + $post_author = $post_info->post_author; |
|
33 | 33 | |
34 | - $user_info = get_userdata($post_author); |
|
35 | - $username = $user_info->user_login; |
|
36 | - $user_email = $user_info->user_email; |
|
34 | + $user_info = get_userdata($post_author); |
|
35 | + $username = $user_info->user_login; |
|
36 | + $user_email = $user_info->user_email; |
|
37 | 37 | |
38 | - $message = wpautop(__(stripslashes_deep(get_option('geodir_post_added_success_msg_content')),'geodirectory')); |
|
38 | + $message = wpautop(__(stripslashes_deep(get_option('geodir_post_added_success_msg_content')),'geodirectory')); |
|
39 | 39 | |
40 | - /* |
|
40 | + /* |
|
41 | 41 | * Filter the success page message before variable replacements. |
42 | 42 | * |
43 | 43 | * @since 1.5.7 |
@@ -45,13 +45,13 @@ discard block |
||
45 | 45 | * @param object $post_info Post object. |
46 | 46 | * @param object $user_info User object. |
47 | 47 | */ |
48 | - $message = apply_filters('geodir_success_page_msg_before_var_replace', $message,$post_info, $user_info); |
|
48 | + $message = apply_filters('geodir_success_page_msg_before_var_replace', $message,$post_info, $user_info); |
|
49 | 49 | |
50 | - $search_array = array('[#submited_information_link#]', '[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#user_email#]', '[#username#]', '[#login_url#]', '[#posted_date#]'); |
|
51 | - $replace_array = array($productlink, $productlink, $siteurl_link, $post_id, $siteName, $user_email, $username, $loginurl_link, $posted_date); |
|
52 | - $message = str_replace($search_array, $replace_array, $message); |
|
50 | + $search_array = array('[#submited_information_link#]', '[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#user_email#]', '[#username#]', '[#login_url#]', '[#posted_date#]'); |
|
51 | + $replace_array = array($productlink, $productlink, $siteurl_link, $post_id, $siteName, $user_email, $username, $loginurl_link, $posted_date); |
|
52 | + $message = str_replace($search_array, $replace_array, $message); |
|
53 | 53 | |
54 | - /* |
|
54 | + /* |
|
55 | 55 | * Filter the success page message after variable replacements. |
56 | 56 | * |
57 | 57 | * @since 1.5.7 |
@@ -59,15 +59,15 @@ discard block |
||
59 | 59 | * @param object $post_info Post object. |
60 | 60 | * @param object $user_info User object. |
61 | 61 | */ |
62 | - $message = apply_filters('geodir_success_page_msg_after_var_replace', $message,$post_info, $user_info); |
|
62 | + $message = apply_filters('geodir_success_page_msg_after_var_replace', $message,$post_info, $user_info); |
|
63 | 63 | |
64 | 64 | |
65 | 65 | |
66 | - ?> |
|
66 | + ?> |
|
67 | 67 | |
68 | 68 | <?php |
69 | 69 | |
70 | - /* |
|
70 | + /* |
|
71 | 71 | * Action called before the success page message wrapper. |
72 | 72 | * |
73 | 73 | * @since 1.5.7 |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | * @param object $post_info Post object. |
76 | 76 | * @param object $user_info User object. |
77 | 77 | */ |
78 | - do_action('geodir_before_success_page_msg_wrapper', $message,$post_info, $user_info); |
|
79 | - echo '<h5 class="geodir_information">'; |
|
80 | - echo $message; |
|
81 | - echo '</h5>'; |
|
82 | - /* |
|
78 | + do_action('geodir_before_success_page_msg_wrapper', $message,$post_info, $user_info); |
|
79 | + echo '<h5 class="geodir_information">'; |
|
80 | + echo $message; |
|
81 | + echo '</h5>'; |
|
82 | + /* |
|
83 | 83 | * Action called after the success page message wrapper. |
84 | 84 | * |
85 | 85 | * @since 1.5.7 |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * @param object $post_info Post object. |
88 | 88 | * @param object $user_info User object. |
89 | 89 | */ |
90 | - do_action('geodir_after_success_page_msg_wrapper', $message,$post_info, $user_info); |
|
90 | + do_action('geodir_after_success_page_msg_wrapper', $message,$post_info, $user_info); |
|
91 | 91 | |
92 | - ?> |
|
92 | + ?> |
|
93 | 93 | |
94 | 94 | </div> |
95 | 95 | \ No newline at end of file |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | $productlink = get_permalink($post_id); |
25 | 25 | $siteName = get_bloginfo('name'); |
26 | 26 | $siteurl = home_url(); |
27 | - $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>'; |
|
27 | + $siteurl_link = '<a href="'.$siteurl.'">'.$siteurl.'</a>'; |
|
28 | 28 | |
29 | 29 | $loginurl = geodir_login_url(); |
30 | - $loginurl_link = '<a href="' . $loginurl . '">login</a>'; |
|
30 | + $loginurl_link = '<a href="'.$loginurl.'">login</a>'; |
|
31 | 31 | |
32 | 32 | $post_author = $post_info->post_author; |
33 | 33 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $username = $user_info->user_login; |
36 | 36 | $user_email = $user_info->user_email; |
37 | 37 | |
38 | - $message = wpautop(__(stripslashes_deep(get_option('geodir_post_added_success_msg_content')),'geodirectory')); |
|
38 | + $message = wpautop(__(stripslashes_deep(get_option('geodir_post_added_success_msg_content')), 'geodirectory')); |
|
39 | 39 | |
40 | 40 | /* |
41 | 41 | * Filter the success page message before variable replacements. |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param object $post_info Post object. |
46 | 46 | * @param object $user_info User object. |
47 | 47 | */ |
48 | - $message = apply_filters('geodir_success_page_msg_before_var_replace', $message,$post_info, $user_info); |
|
48 | + $message = apply_filters('geodir_success_page_msg_before_var_replace', $message, $post_info, $user_info); |
|
49 | 49 | |
50 | 50 | $search_array = array('[#submited_information_link#]', '[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#user_email#]', '[#username#]', '[#login_url#]', '[#posted_date#]'); |
51 | 51 | $replace_array = array($productlink, $productlink, $siteurl_link, $post_id, $siteName, $user_email, $username, $loginurl_link, $posted_date); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param object $post_info Post object. |
60 | 60 | * @param object $user_info User object. |
61 | 61 | */ |
62 | - $message = apply_filters('geodir_success_page_msg_after_var_replace', $message,$post_info, $user_info); |
|
62 | + $message = apply_filters('geodir_success_page_msg_after_var_replace', $message, $post_info, $user_info); |
|
63 | 63 | |
64 | 64 | |
65 | 65 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * @param object $post_info Post object. |
76 | 76 | * @param object $user_info User object. |
77 | 77 | */ |
78 | - do_action('geodir_before_success_page_msg_wrapper', $message,$post_info, $user_info); |
|
78 | + do_action('geodir_before_success_page_msg_wrapper', $message, $post_info, $user_info); |
|
79 | 79 | echo '<h5 class="geodir_information">'; |
80 | 80 | echo $message; |
81 | 81 | echo '</h5>'; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @param object $post_info Post object. |
88 | 88 | * @param object $user_info User object. |
89 | 89 | */ |
90 | - do_action('geodir_after_success_page_msg_wrapper', $message,$post_info, $user_info); |
|
90 | + do_action('geodir_after_success_page_msg_wrapper', $message, $post_info, $user_info); |
|
91 | 91 | |
92 | 92 | ?> |
93 | 93 |
@@ -190,10 +190,11 @@ discard block |
||
190 | 190 | $instance['listing_width'] = strip_tags($new_instance['listing_width']); |
191 | 191 | $instance['list_sort'] = strip_tags($new_instance['list_sort']); |
192 | 192 | $instance['character_count'] = $new_instance['character_count']; |
193 | - if (isset($new_instance['add_location_filter']) && $new_instance['add_location_filter'] != '') |
|
194 | - $instance['add_location_filter'] = strip_tags($new_instance['add_location_filter']); |
|
195 | - else |
|
196 | - $instance['add_location_filter'] = '0'; |
|
193 | + if (isset($new_instance['add_location_filter']) && $new_instance['add_location_filter'] != '') { |
|
194 | + $instance['add_location_filter'] = strip_tags($new_instance['add_location_filter']); |
|
195 | + } else { |
|
196 | + $instance['add_location_filter'] = '0'; |
|
197 | + } |
|
197 | 198 | |
198 | 199 | $instance['show_featured_only'] = isset($new_instance['show_featured_only']) && $new_instance['show_featured_only'] ? 1 : 0; |
199 | 200 | $instance['show_special_only'] = isset($new_instance['show_special_only']) && $new_instance['show_special_only'] ? 1 : 0; |
@@ -319,8 +320,9 @@ discard block |
||
319 | 320 | |
320 | 321 | $all_postypes = geodir_get_posttypes(); |
321 | 322 | |
322 | - if (!in_array($post_type, $all_postypes)) |
|
323 | - $post_type = 'gd_place'; |
|
323 | + if (!in_array($post_type, $all_postypes)) { |
|
324 | + $post_type = 'gd_place'; |
|
325 | + } |
|
324 | 326 | |
325 | 327 | $category_taxonomy = geodir_get_taxonomies($post_type); |
326 | 328 | $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC')); |
@@ -335,8 +337,9 @@ discard block |
||
335 | 337 | } ?> value="0"><?php _e('All', 'geodirectory'); ?></option> |
336 | 338 | <?php foreach ($categories as $category_obj) { |
337 | 339 | $selected = ''; |
338 | - if (is_array($category) && in_array($category_obj->term_id, $category)) |
|
339 | - echo $selected = 'selected="selected"'; |
|
340 | + if (is_array($category) && in_array($category_obj->term_id, $category)) { |
|
341 | + echo $selected = 'selected="selected"'; |
|
342 | + } |
|
340 | 343 | |
341 | 344 | ?> |
342 | 345 | |
@@ -350,7 +353,12 @@ discard block |
||
350 | 353 | |
351 | 354 | <input type="hidden" name="<?php echo $this->get_field_name('category_title'); ?>" |
352 | 355 | id="<?php echo $this->get_field_id('category_title'); ?>" |
353 | - value="<?php if ($category_title != '') echo $category_title; else echo __('All', 'geodirectory');?>"/> |
|
356 | + value="<?php if ($category_title != '') { |
|
357 | + echo $category_title; |
|
358 | +} else { |
|
359 | + echo __('All', 'geodirectory'); |
|
360 | +} |
|
361 | +?>"/> |
|
354 | 362 | |
355 | 363 | </label> |
356 | 364 | </p> |
@@ -453,7 +461,10 @@ discard block |
||
453 | 461 | <label for="<?php echo $this->get_field_id('add_location_filter'); ?>"> |
454 | 462 | <?php _e('Enable Location Filter:', 'geodirectory');?> |
455 | 463 | <input type="checkbox" id="<?php echo $this->get_field_id('add_location_filter'); ?>" |
456 | - name="<?php echo $this->get_field_name('add_location_filter'); ?>" <?php if ($add_location_filter) echo 'checked="checked"';?> |
|
464 | + name="<?php echo $this->get_field_name('add_location_filter'); ?>" <?php if ($add_location_filter) { |
|
465 | + echo 'checked="checked"'; |
|
466 | +} |
|
467 | +?> |
|
457 | 468 | value="1"/> |
458 | 469 | </label> |
459 | 470 | </p> |
@@ -461,7 +472,10 @@ discard block |
||
461 | 472 | <label for="<?php echo $this->get_field_id('show_featured_only'); ?>"> |
462 | 473 | <?php _e('Show only featured listings:', 'geodirectory');?> <input type="checkbox" |
463 | 474 | id="<?php echo $this->get_field_id('show_featured_only'); ?>" |
464 | - name="<?php echo $this->get_field_name('show_featured_only'); ?>" <?php if ($show_featured_only) echo 'checked="checked"';?> |
|
475 | + name="<?php echo $this->get_field_name('show_featured_only'); ?>" <?php if ($show_featured_only) { |
|
476 | + echo 'checked="checked"'; |
|
477 | +} |
|
478 | +?> |
|
465 | 479 | value="1"/> |
466 | 480 | </label> |
467 | 481 | </p> |
@@ -469,7 +483,10 @@ discard block |
||
469 | 483 | <label for="<?php echo $this->get_field_id('show_special_only'); ?>"> |
470 | 484 | <?php _e('Show only listings with special offers:', 'geodirectory');?> <input type="checkbox" |
471 | 485 | id="<?php echo $this->get_field_id('show_special_only'); ?>" |
472 | - name="<?php echo $this->get_field_name('show_special_only'); ?>" <?php if ($show_special_only) echo 'checked="checked"';?> |
|
486 | + name="<?php echo $this->get_field_name('show_special_only'); ?>" <?php if ($show_special_only) { |
|
487 | + echo 'checked="checked"'; |
|
488 | +} |
|
489 | +?> |
|
473 | 490 | value="1"/> |
474 | 491 | </label> |
475 | 492 | </p> |
@@ -477,7 +494,10 @@ discard block |
||
477 | 494 | <label for="<?php echo $this->get_field_id('with_pics_only'); ?>"> |
478 | 495 | <?php _e('Show only listings with pics:', 'geodirectory');?> <input type="checkbox" |
479 | 496 | id="<?php echo $this->get_field_id('with_pics_only'); ?>" |
480 | - name="<?php echo $this->get_field_name('with_pics_only'); ?>" <?php if ($with_pics_only) echo 'checked="checked"';?> |
|
497 | + name="<?php echo $this->get_field_name('with_pics_only'); ?>" <?php if ($with_pics_only) { |
|
498 | + echo 'checked="checked"'; |
|
499 | +} |
|
500 | +?> |
|
481 | 501 | value="1"/> |
482 | 502 | </label> |
483 | 503 | </p> |
@@ -485,7 +505,10 @@ discard block |
||
485 | 505 | <label for="<?php echo $this->get_field_id('with_videos_only'); ?>"> |
486 | 506 | <?php _e('Show only listings with videos:', 'geodirectory');?> <input type="checkbox" |
487 | 507 | id="<?php echo $this->get_field_id('with_videos_only'); ?>" |
488 | - name="<?php echo $this->get_field_name('with_videos_only'); ?>" <?php if ($with_videos_only) echo 'checked="checked"';?> |
|
508 | + name="<?php echo $this->get_field_name('with_videos_only'); ?>" <?php if ($with_videos_only) { |
|
509 | + echo 'checked="checked"'; |
|
510 | +} |
|
511 | +?> |
|
489 | 512 | value="1"/> |
490 | 513 | </label> |
491 | 514 | </p> |
@@ -14,83 +14,83 @@ discard block |
||
14 | 14 | */ |
15 | 15 | class geodir_popular_post_category extends WP_Widget |
16 | 16 | { |
17 | - /** |
|
18 | - * Register the popular post category widget. |
|
19 | - * |
|
20 | - * @since 1.0.0 |
|
21 | - * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
|
22 | - */ |
|
23 | - public function __construct() { |
|
24 | - $widget_ops = array('classname' => 'geodir_popular_post_category', 'description' => __('GD > Popular Post Category', 'geodirectory')); |
|
25 | - parent::__construct( |
|
26 | - 'popular_post_category', // Base ID |
|
27 | - __('GD > Popular Post Category', 'geodirectory'), // Name |
|
28 | - $widget_ops// Args |
|
29 | - ); |
|
30 | - } |
|
31 | - |
|
32 | - /** |
|
33 | - * Front-end display content for popular post category widget. |
|
34 | - * |
|
35 | - * @since 1.0.0 |
|
36 | - * @since 1.5.1 Declare function public. |
|
37 | - * |
|
38 | - * @param array $args Widget arguments. |
|
39 | - * @param array $instance Saved values from database. |
|
40 | - */ |
|
41 | - public function widget($args, $instance) |
|
42 | - { |
|
43 | - geodir_popular_post_category_output($args, $instance); |
|
44 | - } |
|
45 | - |
|
46 | - /** |
|
47 | - * Sanitize popular post category widget form values as they are saved. |
|
48 | - * |
|
49 | - * @since 1.0.0 |
|
50 | - * @since 1.5.1 Declare function public. |
|
51 | - * @since 1.5.1 Added default_post_type parameter. |
|
52 | - * @since 1.6.9 Added parent_only parameter. |
|
53 | - * |
|
54 | - * @param array $new_instance Values just sent to be saved. |
|
55 | - * @param array $old_instance Previously saved values from database. |
|
56 | - * |
|
57 | - * @return array Updated safe values to be saved. |
|
58 | - */ |
|
59 | - public function update($new_instance, $old_instance) |
|
60 | - { |
|
61 | - //save the widget |
|
62 | - $instance = $old_instance; |
|
63 | - $instance['title'] = strip_tags($new_instance['title']); |
|
64 | - $category_limit = (int)$new_instance['category_limit']; |
|
65 | - $instance['category_limit'] = $category_limit > 0 ? $category_limit : 15; |
|
66 | - $instance['default_post_type'] = isset($new_instance['default_post_type']) ? $new_instance['default_post_type'] : ''; |
|
67 | - $instance['parent_only'] = !empty($new_instance['parent_only']) ? true : false; |
|
68 | - return $instance; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * Back-end popular post category widget settings form. |
|
73 | - * |
|
74 | - * @since 1.0.0 |
|
75 | - * @since 1.5.1 Declare function public. |
|
76 | - * @since 1.5.1 Added option to set default post type. |
|
77 | - * @since 1.6.9 Added option to show parent categories only. |
|
78 | - * |
|
79 | - * @param array $instance Previously saved values from database. |
|
80 | - */ |
|
81 | - public function form($instance) |
|
82 | - { |
|
83 | - //widgetform in backend |
|
84 | - $instance = wp_parse_args((array)$instance, array('title' => '', 'category_limit' => 15, 'default_post_type' => '', 'parent_only' => false)); |
|
85 | - |
|
86 | - $title = strip_tags($instance['title']); |
|
87 | - $category_limit = (int)$instance['category_limit']; |
|
88 | - $category_limit = $category_limit > 0 ? $category_limit : 15; |
|
89 | - $default_post_type = isset($instance['default_post_type']) ? $instance['default_post_type'] : ''; |
|
90 | - $parent_only = !empty($instance['parent_only']) ? true: false; |
|
17 | + /** |
|
18 | + * Register the popular post category widget. |
|
19 | + * |
|
20 | + * @since 1.0.0 |
|
21 | + * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
|
22 | + */ |
|
23 | + public function __construct() { |
|
24 | + $widget_ops = array('classname' => 'geodir_popular_post_category', 'description' => __('GD > Popular Post Category', 'geodirectory')); |
|
25 | + parent::__construct( |
|
26 | + 'popular_post_category', // Base ID |
|
27 | + __('GD > Popular Post Category', 'geodirectory'), // Name |
|
28 | + $widget_ops// Args |
|
29 | + ); |
|
30 | + } |
|
31 | + |
|
32 | + /** |
|
33 | + * Front-end display content for popular post category widget. |
|
34 | + * |
|
35 | + * @since 1.0.0 |
|
36 | + * @since 1.5.1 Declare function public. |
|
37 | + * |
|
38 | + * @param array $args Widget arguments. |
|
39 | + * @param array $instance Saved values from database. |
|
40 | + */ |
|
41 | + public function widget($args, $instance) |
|
42 | + { |
|
43 | + geodir_popular_post_category_output($args, $instance); |
|
44 | + } |
|
45 | + |
|
46 | + /** |
|
47 | + * Sanitize popular post category widget form values as they are saved. |
|
48 | + * |
|
49 | + * @since 1.0.0 |
|
50 | + * @since 1.5.1 Declare function public. |
|
51 | + * @since 1.5.1 Added default_post_type parameter. |
|
52 | + * @since 1.6.9 Added parent_only parameter. |
|
53 | + * |
|
54 | + * @param array $new_instance Values just sent to be saved. |
|
55 | + * @param array $old_instance Previously saved values from database. |
|
56 | + * |
|
57 | + * @return array Updated safe values to be saved. |
|
58 | + */ |
|
59 | + public function update($new_instance, $old_instance) |
|
60 | + { |
|
61 | + //save the widget |
|
62 | + $instance = $old_instance; |
|
63 | + $instance['title'] = strip_tags($new_instance['title']); |
|
64 | + $category_limit = (int)$new_instance['category_limit']; |
|
65 | + $instance['category_limit'] = $category_limit > 0 ? $category_limit : 15; |
|
66 | + $instance['default_post_type'] = isset($new_instance['default_post_type']) ? $new_instance['default_post_type'] : ''; |
|
67 | + $instance['parent_only'] = !empty($new_instance['parent_only']) ? true : false; |
|
68 | + return $instance; |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * Back-end popular post category widget settings form. |
|
73 | + * |
|
74 | + * @since 1.0.0 |
|
75 | + * @since 1.5.1 Declare function public. |
|
76 | + * @since 1.5.1 Added option to set default post type. |
|
77 | + * @since 1.6.9 Added option to show parent categories only. |
|
78 | + * |
|
79 | + * @param array $instance Previously saved values from database. |
|
80 | + */ |
|
81 | + public function form($instance) |
|
82 | + { |
|
83 | + //widgetform in backend |
|
84 | + $instance = wp_parse_args((array)$instance, array('title' => '', 'category_limit' => 15, 'default_post_type' => '', 'parent_only' => false)); |
|
85 | + |
|
86 | + $title = strip_tags($instance['title']); |
|
87 | + $category_limit = (int)$instance['category_limit']; |
|
88 | + $category_limit = $category_limit > 0 ? $category_limit : 15; |
|
89 | + $default_post_type = isset($instance['default_post_type']) ? $instance['default_post_type'] : ''; |
|
90 | + $parent_only = !empty($instance['parent_only']) ? true: false; |
|
91 | 91 | |
92 | - $post_type_options = geodir_get_posttypes('options'); |
|
93 | - ?> |
|
92 | + $post_type_options = geodir_get_posttypes('options'); |
|
93 | + ?> |
|
94 | 94 | <p> |
95 | 95 | <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'geodirectory'); ?> |
96 | 96 | <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>"/> |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | <label for="<?php echo $this->get_field_id('parent_only'); ?>"><?php _e( 'Show parent categories only', 'geodirectory' ); ?></label> |
117 | 117 | </p> |
118 | 118 | <?php |
119 | - } |
|
119 | + } |
|
120 | 120 | } // class geodir_popular_post_category |
121 | 121 | |
122 | 122 | register_widget('geodir_popular_post_category'); |
@@ -130,40 +130,40 @@ discard block |
||
130 | 130 | class geodir_popular_postview extends WP_Widget |
131 | 131 | { |
132 | 132 | |
133 | - /** |
|
133 | + /** |
|
134 | 134 | * Register the popular posts widget. |
135 | 135 | * |
136 | 136 | * @since 1.0.0 |
137 | - * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
|
137 | + * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
|
138 | 138 | */ |
139 | - public function __construct() { |
|
140 | - $widget_ops = array('classname' => 'geodir_popular_post_view', 'description' => __('GD > Popular Post View', 'geodirectory')); |
|
141 | - parent::__construct( |
|
142 | - 'popular_post_view', // Base ID |
|
143 | - __('GD > Popular Post View', 'geodirectory'), // Name |
|
144 | - $widget_ops// Args |
|
145 | - ); |
|
146 | - } |
|
139 | + public function __construct() { |
|
140 | + $widget_ops = array('classname' => 'geodir_popular_post_view', 'description' => __('GD > Popular Post View', 'geodirectory')); |
|
141 | + parent::__construct( |
|
142 | + 'popular_post_view', // Base ID |
|
143 | + __('GD > Popular Post View', 'geodirectory'), // Name |
|
144 | + $widget_ops// Args |
|
145 | + ); |
|
146 | + } |
|
147 | 147 | |
148 | 148 | /** |
149 | 149 | * Front-end display content for popular posts widget. |
150 | 150 | * |
151 | 151 | * @since 1.0.0 |
152 | - * @since 1.5.1 Declare function public. |
|
152 | + * @since 1.5.1 Declare function public. |
|
153 | 153 | * |
154 | 154 | * @param array $args Widget arguments. |
155 | 155 | * @param array $instance Saved values from database. |
156 | 156 | */ |
157 | 157 | public function widget($args, $instance) |
158 | - { |
|
159 | - geodir_popular_postview_output($args, $instance); |
|
160 | - } |
|
158 | + { |
|
159 | + geodir_popular_postview_output($args, $instance); |
|
160 | + } |
|
161 | 161 | |
162 | 162 | /** |
163 | 163 | * Sanitize popular posts widget form values as they are saved. |
164 | 164 | * |
165 | 165 | * @since 1.0.0 |
166 | - * @since 1.5.1 Declare function public. |
|
166 | + * @since 1.5.1 Declare function public. |
|
167 | 167 | * |
168 | 168 | * @param array $new_instance Values just sent to be saved. |
169 | 169 | * @param array $old_instance Previously saved values from database. |
@@ -171,99 +171,99 @@ discard block |
||
171 | 171 | * @return array Updated safe values to be saved. |
172 | 172 | */ |
173 | 173 | public function update($new_instance, $old_instance) |
174 | - { |
|
175 | - //save the widget |
|
176 | - $instance = $old_instance; |
|
177 | - |
|
178 | - if ($new_instance['title'] == '') { |
|
179 | - $title = geodir_ucwords(strip_tags($new_instance['category_title'])); |
|
180 | - //$instance['title'] = $title; |
|
181 | - } |
|
182 | - $instance['title'] = strip_tags($new_instance['title']); |
|
183 | - |
|
184 | - $instance['post_type'] = strip_tags($new_instance['post_type']); |
|
185 | - //$instance['category'] = strip_tags($new_instance['category']); |
|
186 | - $instance['category'] = isset($new_instance['category']) ? $new_instance['category'] : ''; |
|
187 | - $instance['category_title'] = strip_tags($new_instance['category_title']); |
|
188 | - $instance['post_number'] = strip_tags($new_instance['post_number']); |
|
189 | - $instance['layout'] = strip_tags($new_instance['layout']); |
|
190 | - $instance['listing_width'] = strip_tags($new_instance['listing_width']); |
|
191 | - $instance['list_sort'] = strip_tags($new_instance['list_sort']); |
|
192 | - $instance['character_count'] = $new_instance['character_count']; |
|
193 | - if (isset($new_instance['add_location_filter']) && $new_instance['add_location_filter'] != '') |
|
194 | - $instance['add_location_filter'] = strip_tags($new_instance['add_location_filter']); |
|
195 | - else |
|
196 | - $instance['add_location_filter'] = '0'; |
|
197 | - |
|
198 | - $instance['show_featured_only'] = isset($new_instance['show_featured_only']) && $new_instance['show_featured_only'] ? 1 : 0; |
|
199 | - $instance['show_special_only'] = isset($new_instance['show_special_only']) && $new_instance['show_special_only'] ? 1 : 0; |
|
200 | - $instance['with_pics_only'] = isset($new_instance['with_pics_only']) && $new_instance['with_pics_only'] ? 1 : 0; |
|
201 | - $instance['with_videos_only'] = isset($new_instance['with_videos_only']) && $new_instance['with_videos_only'] ? 1 : 0; |
|
202 | - $instance['use_viewing_post_type'] = isset($new_instance['use_viewing_post_type']) && $new_instance['use_viewing_post_type'] ? 1 : 0; |
|
203 | - |
|
204 | - return $instance; |
|
205 | - } |
|
174 | + { |
|
175 | + //save the widget |
|
176 | + $instance = $old_instance; |
|
177 | + |
|
178 | + if ($new_instance['title'] == '') { |
|
179 | + $title = geodir_ucwords(strip_tags($new_instance['category_title'])); |
|
180 | + //$instance['title'] = $title; |
|
181 | + } |
|
182 | + $instance['title'] = strip_tags($new_instance['title']); |
|
183 | + |
|
184 | + $instance['post_type'] = strip_tags($new_instance['post_type']); |
|
185 | + //$instance['category'] = strip_tags($new_instance['category']); |
|
186 | + $instance['category'] = isset($new_instance['category']) ? $new_instance['category'] : ''; |
|
187 | + $instance['category_title'] = strip_tags($new_instance['category_title']); |
|
188 | + $instance['post_number'] = strip_tags($new_instance['post_number']); |
|
189 | + $instance['layout'] = strip_tags($new_instance['layout']); |
|
190 | + $instance['listing_width'] = strip_tags($new_instance['listing_width']); |
|
191 | + $instance['list_sort'] = strip_tags($new_instance['list_sort']); |
|
192 | + $instance['character_count'] = $new_instance['character_count']; |
|
193 | + if (isset($new_instance['add_location_filter']) && $new_instance['add_location_filter'] != '') |
|
194 | + $instance['add_location_filter'] = strip_tags($new_instance['add_location_filter']); |
|
195 | + else |
|
196 | + $instance['add_location_filter'] = '0'; |
|
197 | + |
|
198 | + $instance['show_featured_only'] = isset($new_instance['show_featured_only']) && $new_instance['show_featured_only'] ? 1 : 0; |
|
199 | + $instance['show_special_only'] = isset($new_instance['show_special_only']) && $new_instance['show_special_only'] ? 1 : 0; |
|
200 | + $instance['with_pics_only'] = isset($new_instance['with_pics_only']) && $new_instance['with_pics_only'] ? 1 : 0; |
|
201 | + $instance['with_videos_only'] = isset($new_instance['with_videos_only']) && $new_instance['with_videos_only'] ? 1 : 0; |
|
202 | + $instance['use_viewing_post_type'] = isset($new_instance['use_viewing_post_type']) && $new_instance['use_viewing_post_type'] ? 1 : 0; |
|
203 | + |
|
204 | + return $instance; |
|
205 | + } |
|
206 | 206 | |
207 | 207 | /** |
208 | 208 | * Back-end popular posts widget settings form. |
209 | 209 | * |
210 | 210 | * @since 1.0.0 |
211 | - * @since 1.5.1 Declare function public. |
|
211 | + * @since 1.5.1 Declare function public. |
|
212 | 212 | * |
213 | 213 | * @param array $instance Previously saved values from database. |
214 | 214 | */ |
215 | 215 | public function form($instance) |
216 | - { |
|
217 | - //widgetform in backend |
|
218 | - $instance = wp_parse_args((array)$instance, |
|
219 | - array('title' => '', |
|
220 | - 'post_type' => '', |
|
221 | - 'category' => array(), |
|
222 | - 'category_title' => '', |
|
223 | - 'list_sort' => '', |
|
224 | - 'list_order' => '', |
|
225 | - 'post_number' => '5', |
|
226 | - 'layout' => 'gridview_onehalf', |
|
227 | - 'listing_width' => '', |
|
228 | - 'add_location_filter' => '1', |
|
229 | - 'character_count' => '20', |
|
230 | - 'show_featured_only' => '', |
|
231 | - 'show_special_only' => '', |
|
232 | - 'with_pics_only' => '', |
|
233 | - 'with_videos_only' => '', |
|
234 | - 'use_viewing_post_type' => '' |
|
235 | - ) |
|
236 | - ); |
|
216 | + { |
|
217 | + //widgetform in backend |
|
218 | + $instance = wp_parse_args((array)$instance, |
|
219 | + array('title' => '', |
|
220 | + 'post_type' => '', |
|
221 | + 'category' => array(), |
|
222 | + 'category_title' => '', |
|
223 | + 'list_sort' => '', |
|
224 | + 'list_order' => '', |
|
225 | + 'post_number' => '5', |
|
226 | + 'layout' => 'gridview_onehalf', |
|
227 | + 'listing_width' => '', |
|
228 | + 'add_location_filter' => '1', |
|
229 | + 'character_count' => '20', |
|
230 | + 'show_featured_only' => '', |
|
231 | + 'show_special_only' => '', |
|
232 | + 'with_pics_only' => '', |
|
233 | + 'with_videos_only' => '', |
|
234 | + 'use_viewing_post_type' => '' |
|
235 | + ) |
|
236 | + ); |
|
237 | 237 | |
238 | - $title = strip_tags($instance['title']); |
|
238 | + $title = strip_tags($instance['title']); |
|
239 | 239 | |
240 | - $post_type = strip_tags($instance['post_type']); |
|
240 | + $post_type = strip_tags($instance['post_type']); |
|
241 | 241 | |
242 | - $category = $instance['category']; |
|
242 | + $category = $instance['category']; |
|
243 | 243 | |
244 | - $category_title = strip_tags($instance['category_title']); |
|
244 | + $category_title = strip_tags($instance['category_title']); |
|
245 | 245 | |
246 | - $list_sort = strip_tags($instance['list_sort']); |
|
246 | + $list_sort = strip_tags($instance['list_sort']); |
|
247 | 247 | |
248 | - $list_order = strip_tags($instance['list_order']); |
|
248 | + $list_order = strip_tags($instance['list_order']); |
|
249 | 249 | |
250 | - $post_number = strip_tags($instance['post_number']); |
|
250 | + $post_number = strip_tags($instance['post_number']); |
|
251 | 251 | |
252 | - $layout = strip_tags($instance['layout']); |
|
252 | + $layout = strip_tags($instance['layout']); |
|
253 | 253 | |
254 | - $listing_width = strip_tags($instance['listing_width']); |
|
254 | + $listing_width = strip_tags($instance['listing_width']); |
|
255 | 255 | |
256 | - $add_location_filter = strip_tags($instance['add_location_filter']); |
|
256 | + $add_location_filter = strip_tags($instance['add_location_filter']); |
|
257 | 257 | |
258 | - $character_count = $instance['character_count']; |
|
258 | + $character_count = $instance['character_count']; |
|
259 | 259 | |
260 | - $show_featured_only = isset($instance['show_featured_only']) && $instance['show_featured_only'] ? true : false; |
|
261 | - $show_special_only = isset($instance['show_special_only']) && $instance['show_special_only'] ? true : false; |
|
262 | - $with_pics_only = isset($instance['with_pics_only']) && $instance['with_pics_only'] ? true : false; |
|
263 | - $with_videos_only = isset($instance['with_videos_only']) && $instance['with_videos_only'] ? true : false; |
|
264 | - $use_viewing_post_type = isset($instance['use_viewing_post_type']) && $instance['use_viewing_post_type'] ? true : false; |
|
260 | + $show_featured_only = isset($instance['show_featured_only']) && $instance['show_featured_only'] ? true : false; |
|
261 | + $show_special_only = isset($instance['show_special_only']) && $instance['show_special_only'] ? true : false; |
|
262 | + $with_pics_only = isset($instance['with_pics_only']) && $instance['with_pics_only'] ? true : false; |
|
263 | + $with_videos_only = isset($instance['with_videos_only']) && $instance['with_videos_only'] ? true : false; |
|
264 | + $use_viewing_post_type = isset($instance['use_viewing_post_type']) && $instance['use_viewing_post_type'] ? true : false; |
|
265 | 265 | |
266 | - ?> |
|
266 | + ?> |
|
267 | 267 | |
268 | 268 | <p> |
269 | 269 | <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'geodirectory');?> |
@@ -298,9 +298,9 @@ discard block |
||
298 | 298 | <?php foreach ($postypes as $postypes_obj) { ?> |
299 | 299 | |
300 | 300 | <option <?php if ($post_type == $postypes_obj) { |
301 | - echo 'selected="selected"'; |
|
302 | - } ?> value="<?php echo $postypes_obj; ?>"><?php $extvalue = explode('_', $postypes_obj); |
|
303 | - echo ucfirst($extvalue[1]); ?></option> |
|
301 | + echo 'selected="selected"'; |
|
302 | + } ?> value="<?php echo $postypes_obj; ?>"><?php $extvalue = explode('_', $postypes_obj); |
|
303 | + echo ucfirst($extvalue[1]); ?></option> |
|
304 | 304 | |
305 | 305 | <?php } ?> |
306 | 306 | |
@@ -315,30 +315,30 @@ discard block |
||
315 | 315 | |
316 | 316 | <?php |
317 | 317 | |
318 | - $post_type = ($post_type != '') ? $post_type : 'gd_place'; |
|
318 | + $post_type = ($post_type != '') ? $post_type : 'gd_place'; |
|
319 | 319 | |
320 | - $all_postypes = geodir_get_posttypes(); |
|
320 | + $all_postypes = geodir_get_posttypes(); |
|
321 | 321 | |
322 | - if (!in_array($post_type, $all_postypes)) |
|
323 | - $post_type = 'gd_place'; |
|
322 | + if (!in_array($post_type, $all_postypes)) |
|
323 | + $post_type = 'gd_place'; |
|
324 | 324 | |
325 | - $category_taxonomy = geodir_get_taxonomies($post_type); |
|
326 | - $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC')); |
|
325 | + $category_taxonomy = geodir_get_taxonomies($post_type); |
|
326 | + $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC')); |
|
327 | 327 | |
328 | - ?> |
|
328 | + ?> |
|
329 | 329 | |
330 | 330 | <select multiple="multiple" class="widefat" name="<?php echo $this->get_field_name('category'); ?>[]" |
331 | 331 | onchange="geodir_popular_widget_cat_title(this)"> |
332 | 332 | |
333 | 333 | <option <?php if (!is_array($category) || (is_array($category) && in_array('0', $category))) { |
334 | - echo 'selected="selected"'; |
|
335 | - } ?> value="0"><?php _e('All', 'geodirectory'); ?></option> |
|
334 | + echo 'selected="selected"'; |
|
335 | + } ?> value="0"><?php _e('All', 'geodirectory'); ?></option> |
|
336 | 336 | <?php foreach ($categories as $category_obj) { |
337 | - $selected = ''; |
|
338 | - if (is_array($category) && in_array($category_obj->term_id, $category)) |
|
339 | - echo $selected = 'selected="selected"'; |
|
337 | + $selected = ''; |
|
338 | + if (is_array($category) && in_array($category_obj->term_id, $category)) |
|
339 | + echo $selected = 'selected="selected"'; |
|
340 | 340 | |
341 | - ?> |
|
341 | + ?> |
|
342 | 342 | |
343 | 343 | <option <?php echo $selected; ?> |
344 | 344 | value="<?php echo $category_obj->term_id; ?>"><?php echo ucfirst($category_obj->name); ?></option> |
@@ -363,28 +363,28 @@ discard block |
||
363 | 363 | name="<?php echo $this->get_field_name('list_sort'); ?>"> |
364 | 364 | |
365 | 365 | <option <?php if ($list_sort == 'az') { |
366 | - echo 'selected="selected"'; |
|
367 | - } ?> value="az"><?php _e('A-Z', 'geodirectory'); ?></option> |
|
366 | + echo 'selected="selected"'; |
|
367 | + } ?> value="az"><?php _e('A-Z', 'geodirectory'); ?></option> |
|
368 | 368 | |
369 | 369 | <option <?php if ($list_sort == 'latest') { |
370 | - echo 'selected="selected"'; |
|
371 | - } ?> value="latest"><?php _e('Latest', 'geodirectory'); ?></option> |
|
370 | + echo 'selected="selected"'; |
|
371 | + } ?> value="latest"><?php _e('Latest', 'geodirectory'); ?></option> |
|
372 | 372 | |
373 | 373 | <option <?php if ($list_sort == 'featured') { |
374 | - echo 'selected="selected"'; |
|
375 | - } ?> value="featured"><?php _e('Featured', 'geodirectory'); ?></option> |
|
374 | + echo 'selected="selected"'; |
|
375 | + } ?> value="featured"><?php _e('Featured', 'geodirectory'); ?></option> |
|
376 | 376 | |
377 | 377 | <option <?php if ($list_sort == 'high_review') { |
378 | - echo 'selected="selected"'; |
|
379 | - } ?> value="high_review"><?php _e('Review', 'geodirectory'); ?></option> |
|
378 | + echo 'selected="selected"'; |
|
379 | + } ?> value="high_review"><?php _e('Review', 'geodirectory'); ?></option> |
|
380 | 380 | |
381 | 381 | <option <?php if ($list_sort == 'high_rating') { |
382 | - echo 'selected="selected"'; |
|
383 | - } ?> value="high_rating"><?php _e('Rating', 'geodirectory'); ?></option> |
|
382 | + echo 'selected="selected"'; |
|
383 | + } ?> value="high_rating"><?php _e('Rating', 'geodirectory'); ?></option> |
|
384 | 384 | |
385 | 385 | <option <?php if ($list_sort == 'random') { |
386 | - echo 'selected="selected"'; |
|
387 | - } ?> value="random"><?php _e('Random', 'geodirectory'); ?></option> |
|
386 | + echo 'selected="selected"'; |
|
387 | + } ?> value="random"><?php _e('Random', 'geodirectory'); ?></option> |
|
388 | 388 | |
389 | 389 | </select> |
390 | 390 | </label> |
@@ -407,24 +407,24 @@ discard block |
||
407 | 407 | <select class="widefat" id="<?php echo $this->get_field_id('layout'); ?>" |
408 | 408 | name="<?php echo $this->get_field_name('layout'); ?>"> |
409 | 409 | <option <?php if ($layout == 'gridview_onehalf') { |
410 | - echo 'selected="selected"'; |
|
411 | - } ?> |
|
410 | + echo 'selected="selected"'; |
|
411 | + } ?> |
|
412 | 412 | value="gridview_onehalf"><?php _e('Grid View (Two Columns)', 'geodirectory'); ?></option> |
413 | 413 | <option <?php if ($layout == 'gridview_onethird') { |
414 | - echo 'selected="selected"'; |
|
415 | - } ?> |
|
414 | + echo 'selected="selected"'; |
|
415 | + } ?> |
|
416 | 416 | value="gridview_onethird"><?php _e('Grid View (Three Columns)', 'geodirectory'); ?></option> |
417 | 417 | <option <?php if ($layout == 'gridview_onefourth') { |
418 | - echo 'selected="selected"'; |
|
419 | - } ?> |
|
418 | + echo 'selected="selected"'; |
|
419 | + } ?> |
|
420 | 420 | value="gridview_onefourth"><?php _e('Grid View (Four Columns)', 'geodirectory'); ?></option> |
421 | 421 | <option <?php if ($layout == 'gridview_onefifth') { |
422 | - echo 'selected="selected"'; |
|
423 | - } ?> |
|
422 | + echo 'selected="selected"'; |
|
423 | + } ?> |
|
424 | 424 | value="gridview_onefifth"><?php _e('Grid View (Five Columns)', 'geodirectory'); ?></option> |
425 | 425 | <option <?php if ($layout == 'list') { |
426 | - echo 'selected="selected"'; |
|
427 | - } ?> value="list"><?php _e('List view', 'geodirectory'); ?></option> |
|
426 | + echo 'selected="selected"'; |
|
427 | + } ?> value="list"><?php _e('List view', 'geodirectory'); ?></option> |
|
428 | 428 | |
429 | 429 | </select> |
430 | 430 | </label> |
@@ -494,8 +494,8 @@ discard block |
||
494 | 494 | for="<?php echo $this->get_field_id('use_viewing_post_type'); ?>"><?php _e('Use current viewing post type:', 'geodirectory'); ?> |
495 | 495 | <input type="checkbox" id="<?php echo $this->get_field_id('use_viewing_post_type'); ?>" |
496 | 496 | name="<?php echo $this->get_field_name('use_viewing_post_type'); ?>" <?php if ($use_viewing_post_type) { |
497 | - echo 'checked="checked"'; |
|
498 | - } ?> value="1"/> |
|
497 | + echo 'checked="checked"'; |
|
498 | + } ?> value="1"/> |
|
499 | 499 | </label> |
500 | 500 | </p> |
501 | 501 | |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | </script> |
540 | 540 | |
541 | 541 | <?php |
542 | - } |
|
542 | + } |
|
543 | 543 | } // class geodir_popular_postview |
544 | 544 | |
545 | 545 | register_widget('geodir_popular_postview'); |
546 | 546 | \ No newline at end of file |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | //save the widget |
62 | 62 | $instance = $old_instance; |
63 | 63 | $instance['title'] = strip_tags($new_instance['title']); |
64 | - $category_limit = (int)$new_instance['category_limit']; |
|
64 | + $category_limit = (int) $new_instance['category_limit']; |
|
65 | 65 | $instance['category_limit'] = $category_limit > 0 ? $category_limit : 15; |
66 | 66 | $instance['default_post_type'] = isset($new_instance['default_post_type']) ? $new_instance['default_post_type'] : ''; |
67 | 67 | $instance['parent_only'] = !empty($new_instance['parent_only']) ? true : false; |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | public function form($instance) |
82 | 82 | { |
83 | 83 | //widgetform in backend |
84 | - $instance = wp_parse_args((array)$instance, array('title' => '', 'category_limit' => 15, 'default_post_type' => '', 'parent_only' => false)); |
|
84 | + $instance = wp_parse_args((array) $instance, array('title' => '', 'category_limit' => 15, 'default_post_type' => '', 'parent_only' => false)); |
|
85 | 85 | |
86 | 86 | $title = strip_tags($instance['title']); |
87 | - $category_limit = (int)$instance['category_limit']; |
|
87 | + $category_limit = (int) $instance['category_limit']; |
|
88 | 88 | $category_limit = $category_limit > 0 ? $category_limit : 15; |
89 | 89 | $default_post_type = isset($instance['default_post_type']) ? $instance['default_post_type'] : ''; |
90 | - $parent_only = !empty($instance['parent_only']) ? true: false; |
|
90 | + $parent_only = !empty($instance['parent_only']) ? true : false; |
|
91 | 91 | |
92 | 92 | $post_type_options = geodir_get_posttypes('options'); |
93 | 93 | ?> |
@@ -97,23 +97,23 @@ discard block |
||
97 | 97 | </label> |
98 | 98 | </p> |
99 | 99 | <p> |
100 | - <label for="<?php echo $this->get_field_id('post_type'); ?>"><?php _e('Default post type to use (if not set by page)', 'geodirectory');?> |
|
100 | + <label for="<?php echo $this->get_field_id('post_type'); ?>"><?php _e('Default post type to use (if not set by page)', 'geodirectory'); ?> |
|
101 | 101 | <select class="widefat" id="<?php echo $this->get_field_id('default_post_type'); ?>" name="<?php echo $this->get_field_name('default_post_type'); ?>"> |
102 | 102 | <?php foreach ($post_type_options as $name => $title) { ?> |
103 | - <option value="<?php echo $name;?>" <?php selected($name, $default_post_type);?>><?php echo $title; ?></option> |
|
103 | + <option value="<?php echo $name; ?>" <?php selected($name, $default_post_type); ?>><?php echo $title; ?></option> |
|
104 | 104 | <?php } ?> |
105 | 105 | </select> |
106 | 106 | </label> |
107 | 107 | </p> |
108 | 108 | <p> |
109 | 109 | <label for="<?php echo $this->get_field_id('category_limit'); ?>"><?php _e('Customize categories count to appear by default:', 'geodirectory'); ?> |
110 | - <input class="widefat" id="<?php echo $this->get_field_id('category_limit'); ?>" name="<?php echo $this->get_field_name('category_limit'); ?>" type="text" value="<?php echo (int)esc_attr($category_limit); ?>"/> |
|
110 | + <input class="widefat" id="<?php echo $this->get_field_id('category_limit'); ?>" name="<?php echo $this->get_field_name('category_limit'); ?>" type="text" value="<?php echo (int) esc_attr($category_limit); ?>"/> |
|
111 | 111 | <p class="description" style="padding:0"><?php _e('After categories count reaches this limit option More Categories / Less Categoris will be displayed to show/hide categories. Default: 15', 'geodirectory'); ?></p> |
112 | 112 | </label> |
113 | 113 | </p> |
114 | 114 | <p> |
115 | - <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('parent_only'); ?>" name="<?php echo $this->get_field_name('parent_only'); ?>"<?php checked( $parent_only ); ?> value="1" /> |
|
116 | - <label for="<?php echo $this->get_field_id('parent_only'); ?>"><?php _e( 'Show parent categories only', 'geodirectory' ); ?></label> |
|
115 | + <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('parent_only'); ?>" name="<?php echo $this->get_field_name('parent_only'); ?>"<?php checked($parent_only); ?> value="1" /> |
|
116 | + <label for="<?php echo $this->get_field_id('parent_only'); ?>"><?php _e('Show parent categories only', 'geodirectory'); ?></label> |
|
117 | 117 | </p> |
118 | 118 | <?php |
119 | 119 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | public function form($instance) |
216 | 216 | { |
217 | 217 | //widgetform in backend |
218 | - $instance = wp_parse_args((array)$instance, |
|
218 | + $instance = wp_parse_args((array) $instance, |
|
219 | 219 | array('title' => '', |
220 | 220 | 'post_type' => '', |
221 | 221 | 'category' => array(), |
@@ -266,9 +266,9 @@ discard block |
||
266 | 266 | ?> |
267 | 267 | |
268 | 268 | <p> |
269 | - <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'geodirectory');?> |
|
269 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'geodirectory'); ?> |
|
270 | 270 | <small>(%posttype_singular_label% , |
271 | - %posttype_plural_label% <?php _e('can be used', 'geodirectory');?>) |
|
271 | + %posttype_plural_label% <?php _e('can be used', 'geodirectory'); ?>) |
|
272 | 272 | </small> |
273 | 273 | |
274 | 274 | <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | |
280 | 280 | <p> |
281 | 281 | <label |
282 | - for="<?php echo $this->get_field_id('post_type'); ?>"><?php _e('Post Type:', 'geodirectory');?> |
|
282 | + for="<?php echo $this->get_field_id('post_type'); ?>"><?php _e('Post Type:', 'geodirectory'); ?> |
|
283 | 283 | |
284 | 284 | <?php $postypes = geodir_get_posttypes(); |
285 | 285 | /** |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | |
312 | 312 | <p id="post_type_cats"> |
313 | 313 | <label |
314 | - for="<?php echo $this->get_field_id('category'); ?>"><?php _e('Post Category:', 'geodirectory');?> |
|
314 | + for="<?php echo $this->get_field_id('category'); ?>"><?php _e('Post Category:', 'geodirectory'); ?> |
|
315 | 315 | |
316 | 316 | <?php |
317 | 317 | |
@@ -350,14 +350,14 @@ discard block |
||
350 | 350 | |
351 | 351 | <input type="hidden" name="<?php echo $this->get_field_name('category_title'); ?>" |
352 | 352 | id="<?php echo $this->get_field_id('category_title'); ?>" |
353 | - value="<?php if ($category_title != '') echo $category_title; else echo __('All', 'geodirectory');?>"/> |
|
353 | + value="<?php if ($category_title != '') echo $category_title; else echo __('All', 'geodirectory'); ?>"/> |
|
354 | 354 | |
355 | 355 | </label> |
356 | 356 | </p> |
357 | 357 | |
358 | 358 | <p> |
359 | 359 | <label |
360 | - for="<?php echo $this->get_field_id('list_sort'); ?>"><?php _e('Sort by:', 'geodirectory');?> |
|
360 | + for="<?php echo $this->get_field_id('list_sort'); ?>"><?php _e('Sort by:', 'geodirectory'); ?> |
|
361 | 361 | |
362 | 362 | <select class="widefat" id="<?php echo $this->get_field_id('list_sort'); ?>" |
363 | 363 | name="<?php echo $this->get_field_name('list_sort'); ?>"> |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | <p> |
394 | 394 | |
395 | 395 | <label |
396 | - for="<?php echo $this->get_field_id('post_number'); ?>"><?php _e('Number of posts:', 'geodirectory');?> |
|
396 | + for="<?php echo $this->get_field_id('post_number'); ?>"><?php _e('Number of posts:', 'geodirectory'); ?> |
|
397 | 397 | |
398 | 398 | <input class="widefat" id="<?php echo $this->get_field_id('post_number'); ?>" |
399 | 399 | name="<?php echo $this->get_field_name('post_number'); ?>" type="text" |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | |
404 | 404 | <p> |
405 | 405 | <label for="<?php echo $this->get_field_id('layout'); ?>"> |
406 | - <?php _e('Layout:', 'geodirectory');?> |
|
406 | + <?php _e('Layout:', 'geodirectory'); ?> |
|
407 | 407 | <select class="widefat" id="<?php echo $this->get_field_id('layout'); ?>" |
408 | 408 | name="<?php echo $this->get_field_name('layout'); ?>"> |
409 | 409 | <option <?php if ($layout == 'gridview_onehalf') { |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | |
433 | 433 | <p> |
434 | 434 | <label |
435 | - for="<?php echo $this->get_field_id('listing_width'); ?>"><?php _e('Listing width:', 'geodirectory');?> |
|
435 | + for="<?php echo $this->get_field_id('listing_width'); ?>"><?php _e('Listing width:', 'geodirectory'); ?> |
|
436 | 436 | |
437 | 437 | <input class="widefat" id="<?php echo $this->get_field_id('listing_width'); ?>" |
438 | 438 | name="<?php echo $this->get_field_name('listing_width'); ?>" type="text" |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | |
443 | 443 | <p> |
444 | 444 | <label |
445 | - for="<?php echo $this->get_field_id('character_count'); ?>"><?php _e('Post Content excerpt character count :', 'geodirectory');?> |
|
445 | + for="<?php echo $this->get_field_id('character_count'); ?>"><?php _e('Post Content excerpt character count :', 'geodirectory'); ?> |
|
446 | 446 | <input class="widefat" id="<?php echo $this->get_field_id('character_count'); ?>" |
447 | 447 | name="<?php echo $this->get_field_name('character_count'); ?>" type="text" |
448 | 448 | value="<?php echo esc_attr($character_count); ?>"/> |
@@ -451,41 +451,41 @@ discard block |
||
451 | 451 | |
452 | 452 | <p> |
453 | 453 | <label for="<?php echo $this->get_field_id('add_location_filter'); ?>"> |
454 | - <?php _e('Enable Location Filter:', 'geodirectory');?> |
|
454 | + <?php _e('Enable Location Filter:', 'geodirectory'); ?> |
|
455 | 455 | <input type="checkbox" id="<?php echo $this->get_field_id('add_location_filter'); ?>" |
456 | - name="<?php echo $this->get_field_name('add_location_filter'); ?>" <?php if ($add_location_filter) echo 'checked="checked"';?> |
|
456 | + name="<?php echo $this->get_field_name('add_location_filter'); ?>" <?php if ($add_location_filter) echo 'checked="checked"'; ?> |
|
457 | 457 | value="1"/> |
458 | 458 | </label> |
459 | 459 | </p> |
460 | 460 | <p> |
461 | 461 | <label for="<?php echo $this->get_field_id('show_featured_only'); ?>"> |
462 | - <?php _e('Show only featured listings:', 'geodirectory');?> <input type="checkbox" |
|
462 | + <?php _e('Show only featured listings:', 'geodirectory'); ?> <input type="checkbox" |
|
463 | 463 | id="<?php echo $this->get_field_id('show_featured_only'); ?>" |
464 | - name="<?php echo $this->get_field_name('show_featured_only'); ?>" <?php if ($show_featured_only) echo 'checked="checked"';?> |
|
464 | + name="<?php echo $this->get_field_name('show_featured_only'); ?>" <?php if ($show_featured_only) echo 'checked="checked"'; ?> |
|
465 | 465 | value="1"/> |
466 | 466 | </label> |
467 | 467 | </p> |
468 | 468 | <p> |
469 | 469 | <label for="<?php echo $this->get_field_id('show_special_only'); ?>"> |
470 | - <?php _e('Show only listings with special offers:', 'geodirectory');?> <input type="checkbox" |
|
470 | + <?php _e('Show only listings with special offers:', 'geodirectory'); ?> <input type="checkbox" |
|
471 | 471 | id="<?php echo $this->get_field_id('show_special_only'); ?>" |
472 | - name="<?php echo $this->get_field_name('show_special_only'); ?>" <?php if ($show_special_only) echo 'checked="checked"';?> |
|
472 | + name="<?php echo $this->get_field_name('show_special_only'); ?>" <?php if ($show_special_only) echo 'checked="checked"'; ?> |
|
473 | 473 | value="1"/> |
474 | 474 | </label> |
475 | 475 | </p> |
476 | 476 | <p> |
477 | 477 | <label for="<?php echo $this->get_field_id('with_pics_only'); ?>"> |
478 | - <?php _e('Show only listings with pics:', 'geodirectory');?> <input type="checkbox" |
|
478 | + <?php _e('Show only listings with pics:', 'geodirectory'); ?> <input type="checkbox" |
|
479 | 479 | id="<?php echo $this->get_field_id('with_pics_only'); ?>" |
480 | - name="<?php echo $this->get_field_name('with_pics_only'); ?>" <?php if ($with_pics_only) echo 'checked="checked"';?> |
|
480 | + name="<?php echo $this->get_field_name('with_pics_only'); ?>" <?php if ($with_pics_only) echo 'checked="checked"'; ?> |
|
481 | 481 | value="1"/> |
482 | 482 | </label> |
483 | 483 | </p> |
484 | 484 | <p> |
485 | 485 | <label for="<?php echo $this->get_field_id('with_videos_only'); ?>"> |
486 | - <?php _e('Show only listings with videos:', 'geodirectory');?> <input type="checkbox" |
|
486 | + <?php _e('Show only listings with videos:', 'geodirectory'); ?> <input type="checkbox" |
|
487 | 487 | id="<?php echo $this->get_field_id('with_videos_only'); ?>" |
488 | - name="<?php echo $this->get_field_name('with_videos_only'); ?>" <?php if ($with_videos_only) echo 'checked="checked"';?> |
|
488 | + name="<?php echo $this->get_field_name('with_videos_only'); ?>" <?php if ($with_videos_only) echo 'checked="checked"'; ?> |
|
489 | 489 | value="1"/> |
490 | 490 | </label> |
491 | 491 | </p> |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | |
532 | 532 | } |
533 | 533 | |
534 | - <?php if(is_active_widget( false, false, $this->id_base, true )){ ?> |
|
534 | + <?php if (is_active_widget(false, false, $this->id_base, true)) { ?> |
|
535 | 535 | var post_type = jQuery('#<?php echo $this->get_field_id('post_type'); ?>').val(); |
536 | 536 | |
537 | 537 | <?php } ?> |