@@ -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,16 +949,18 @@ 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(); |
942 | 958 | if (is_array($meta) && isset($meta['src']) && $meta['src'] != '') { |
943 | 959 | $file_info = pathinfo($meta['src']); |
944 | 960 | |
945 | - if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
946 | - $sub_dir = $file_info['dirname']; |
|
961 | + if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') { |
|
962 | + $sub_dir = $file_info['dirname']; |
|
963 | + } |
|
947 | 964 | |
948 | 965 | $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
949 | 966 | $uploads_baseurl = $uploads['baseurl']; |
@@ -987,8 +1004,9 @@ discard block |
||
987 | 1004 | public function show_field_color($field, $meta) |
988 | 1005 | { |
989 | 1006 | |
990 | - if (empty($meta)) |
|
991 | - $meta = '#'; |
|
1007 | + if (empty($meta)) { |
|
1008 | + $meta = '#'; |
|
1009 | + } |
|
992 | 1010 | |
993 | 1011 | $this->show_field_begin($field, $meta); |
994 | 1012 | |
@@ -1011,8 +1029,9 @@ discard block |
||
1011 | 1029 | public function show_field_checkbox_list($field, $meta) |
1012 | 1030 | { |
1013 | 1031 | |
1014 | - if (!is_array($meta)) |
|
1015 | - $meta = (array)$meta; |
|
1032 | + if (!is_array($meta)) { |
|
1033 | + $meta = (array)$meta; |
|
1034 | + } |
|
1016 | 1035 | |
1017 | 1036 | $this->show_field_begin($field, $meta); |
1018 | 1037 | |
@@ -1072,7 +1091,9 @@ discard block |
||
1072 | 1091 | { |
1073 | 1092 | global $post; |
1074 | 1093 | |
1075 | - if (!is_array($meta)) $meta = (array)$meta; |
|
1094 | + if (!is_array($meta)) { |
|
1095 | + $meta = (array)$meta; |
|
1096 | + } |
|
1076 | 1097 | $this->show_field_begin($field, $meta); |
1077 | 1098 | $options = $field['options']; |
1078 | 1099 | $posts = get_posts($options['args']); |
@@ -1110,7 +1131,9 @@ discard block |
||
1110 | 1131 | { |
1111 | 1132 | global $post; |
1112 | 1133 | |
1113 | - if (!is_array($meta)) $meta = (array)$meta; |
|
1134 | + if (!is_array($meta)) { |
|
1135 | + $meta = (array)$meta; |
|
1136 | + } |
|
1114 | 1137 | $this->show_field_begin($field, $meta); |
1115 | 1138 | $options = $field['options']; |
1116 | 1139 | $terms = get_terms($options['taxonomy'], $options['args']); |
@@ -1144,17 +1167,20 @@ discard block |
||
1144 | 1167 | { |
1145 | 1168 | |
1146 | 1169 | $taxnow = ''; |
1147 | - if (isset($_POST['taxonomy'])) |
|
1148 | - $taxnow = $_POST['taxonomy']; |
|
1170 | + if (isset($_POST['taxonomy'])) { |
|
1171 | + $taxnow = $_POST['taxonomy']; |
|
1172 | + } |
|
1149 | 1173 | |
1150 | 1174 | if (!isset($term_id) // Check Revision |
1151 | 1175 | || (!in_array($taxnow, $this->_meta_box['pages'])) // Check if current taxonomy type is supported. |
1152 | 1176 | || (!check_admin_referer(basename(__FILE__), 'tax_meta_class_nonce')) // Check nonce - Security |
1153 | 1177 | || (!current_user_can('manage_categories')) |
1154 | - ) // Check permission |
|
1178 | + ) { |
|
1179 | + // Check permission |
|
1155 | 1180 | { |
1156 | 1181 | return $term_id; |
1157 | 1182 | } |
1183 | + } |
|
1158 | 1184 | |
1159 | 1185 | |
1160 | 1186 | foreach ($this->_fields as $field) { |
@@ -1248,8 +1274,9 @@ discard block |
||
1248 | 1274 | { |
1249 | 1275 | $name = $field['id']; |
1250 | 1276 | $this->delete_tax_meta($term_id, $name); |
1251 | - if ($new === '' || $new === array()) |
|
1252 | - return; |
|
1277 | + if ($new === '' || $new === array()) { |
|
1278 | + return; |
|
1279 | + } |
|
1253 | 1280 | |
1254 | 1281 | $this->update_tax_meta($term_id, $name, $new); |
1255 | 1282 | } |
@@ -1269,8 +1296,9 @@ discard block |
||
1269 | 1296 | $name = $field['id']; |
1270 | 1297 | |
1271 | 1298 | $this->delete_tax_meta($term_id, $name); |
1272 | - if ($new === '' || $new === array() || $new['id'] == '' || $new['src'] == '') |
|
1273 | - return; |
|
1299 | + if ($new === '' || $new === array() || $new['id'] == '' || $new['src'] == '') { |
|
1300 | + return; |
|
1301 | + } |
|
1274 | 1302 | |
1275 | 1303 | $this->update_tax_meta($term_id, $name, $new); |
1276 | 1304 | } |
@@ -1317,8 +1345,9 @@ discard block |
||
1317 | 1345 | break; |
1318 | 1346 | } |
1319 | 1347 | } |
1320 | - if (!$this->is_array_empty($n)) |
|
1321 | - $temp[] = $n; |
|
1348 | + if (!$this->is_array_empty($n)) { |
|
1349 | + $temp[] = $n; |
|
1350 | + } |
|
1322 | 1351 | } |
1323 | 1352 | if (isset($temp) && count($temp) > 0 && !$this->is_array_empty($temp)) { |
1324 | 1353 | $this->update_tax_meta($term_id, $field['id'], $temp); |
@@ -1346,14 +1375,16 @@ discard block |
||
1346 | 1375 | { |
1347 | 1376 | |
1348 | 1377 | $name = $field['id']; |
1349 | - if (empty($_FILES[$name])) |
|
1350 | - return; |
|
1378 | + if (empty($_FILES[$name])) { |
|
1379 | + return; |
|
1380 | + } |
|
1351 | 1381 | $this->fix_file_array($_FILES[$name]); |
1352 | 1382 | foreach ($_FILES[$name] as $position => $fileitem) { |
1353 | 1383 | |
1354 | 1384 | $file = wp_handle_upload($fileitem, array('test_form' => false)); |
1355 | - if (empty($file['file'])) |
|
1356 | - continue; |
|
1385 | + if (empty($file['file'])) { |
|
1386 | + continue; |
|
1387 | + } |
|
1357 | 1388 | $filename = $file['file']; |
1358 | 1389 | |
1359 | 1390 | $attachment = array( |
@@ -1391,14 +1422,16 @@ discard block |
||
1391 | 1422 | { |
1392 | 1423 | |
1393 | 1424 | $name = $field['id']; |
1394 | - if (empty($_FILES[$name])) |
|
1395 | - return; |
|
1425 | + if (empty($_FILES[$name])) { |
|
1426 | + return; |
|
1427 | + } |
|
1396 | 1428 | $this->fix_file_array($_FILES[$name]); |
1397 | 1429 | foreach ($_FILES[$name] as $position => $fileitem) { |
1398 | 1430 | |
1399 | 1431 | $file = wp_handle_upload($fileitem, array('test_form' => false)); |
1400 | - if (empty($file['file'])) |
|
1401 | - continue; |
|
1432 | + if (empty($file['file'])) { |
|
1433 | + continue; |
|
1434 | + } |
|
1402 | 1435 | $filename = $file['file']; |
1403 | 1436 | |
1404 | 1437 | $attachment = array( |
@@ -1453,8 +1486,9 @@ discard block |
||
1453 | 1486 | { |
1454 | 1487 | if(is_array($this->_fields)) { |
1455 | 1488 | foreach ($this->_fields as $field) { |
1456 | - if ($type == $field['type']) |
|
1457 | - return true; |
|
1489 | + if ($type == $field['type']) { |
|
1490 | + return true; |
|
1491 | + } |
|
1458 | 1492 | } |
1459 | 1493 | } |
1460 | 1494 | return false; |
@@ -1992,18 +2026,21 @@ discard block |
||
1992 | 2026 | */ |
1993 | 2027 | public function is_array_empty($array) |
1994 | 2028 | { |
1995 | - if (!is_array($array)) |
|
1996 | - return true; |
|
2029 | + if (!is_array($array)) { |
|
2030 | + return true; |
|
2031 | + } |
|
1997 | 2032 | |
1998 | 2033 | foreach ($array as $a) { |
1999 | 2034 | if (is_array($a)) { |
2000 | 2035 | foreach ($a as $sub_a) { |
2001 | - if (!empty($sub_a) && $sub_a != '') |
|
2002 | - return false; |
|
2036 | + if (!empty($sub_a) && $sub_a != '') { |
|
2037 | + return false; |
|
2038 | + } |
|
2003 | 2039 | } |
2004 | 2040 | } else { |
2005 | - if (!empty($a) && $a != '') |
|
2006 | - return false; |
|
2041 | + if (!empty($a) && $a != '') { |
|
2042 | + return false; |
|
2043 | + } |
|
2007 | 2044 | } |
2008 | 2045 | } |
2009 | 2046 | return true; |
@@ -203,8 +203,9 @@ discard block |
||
203 | 203 | ############################################################# |
204 | 204 | function manage_category_custom_fields($deprecated, $column_name, $term_id) |
205 | 205 | { |
206 | - if ($column_name == 'cat_ID_num') |
|
207 | - echo $term_id; |
|
206 | + if ($column_name == 'cat_ID_num') { |
|
207 | + echo $term_id; |
|
208 | + } |
|
208 | 209 | |
209 | 210 | if ($column_name == 'cat_icon') { |
210 | 211 | $term_icon_url = get_tax_meta($term_id, 'ct_cat_icon'); |
@@ -240,8 +241,9 @@ discard block |
||
240 | 241 | |
241 | 242 | if ($column_name == 'cat_default_img') { |
242 | 243 | $cat_default_img = get_tax_meta($term_id, 'ct_cat_default_img'); |
243 | - if ($cat_default_img != '') |
|
244 | - echo '<img src="' . $cat_default_img['src'] . '" style="max-height:60px;max-width:60px;"/>'; |
|
244 | + if ($cat_default_img != '') { |
|
245 | + echo '<img src="' . $cat_default_img['src'] . '" style="max-height:60px;max-width:60px;"/>'; |
|
246 | + } |
|
245 | 247 | |
246 | 248 | } |
247 | 249 | } |
@@ -249,11 +251,12 @@ discard block |
||
249 | 251 | function geodir_get_default_catimage($term_id, $post_type = 'gd_place') |
250 | 252 | { |
251 | 253 | |
252 | - if ($cat_default_img = get_tax_meta($term_id, 'ct_cat_default_img', '', $post_type)) |
|
253 | - return $cat_default_img; |
|
254 | - else |
|
255 | - return false; |
|
256 | -} |
|
254 | + if ($cat_default_img = get_tax_meta($term_id, 'ct_cat_default_img', '', $post_type)) { |
|
255 | + return $cat_default_img; |
|
256 | + } else { |
|
257 | + return false; |
|
258 | + } |
|
259 | + } |
|
257 | 260 | |
258 | 261 | //Clear custom fields |
259 | 262 | add_action('in_admin_footer', 'geodir_tax_meta_clear_custom_field'); |