Completed
Pull Request — master (#207)
by Kiran
05:27
created
geodirectory-functions/post_functions.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -26,11 +26,11 @@  discard block
 block discarded – undo
26 26
 
27 27
     if (!isset($default_cat) || empty($default_cat)) {
28 28
         $default_cat = isset($post_cat_array[0]) ? $post_cat_array[0] : '';
29
-    }else{
30
-        if(!is_int($default_cat)){
29
+    } else {
30
+        if (!is_int($default_cat)) {
31 31
             $category = get_term_by('name', $default_cat, $taxonomy);
32
-            if(isset($category->term_id)){
33
-                $default_cat =  $category->term_id;
32
+            if (isset($category->term_id)) {
33
+                $default_cat = $category->term_id;
34 34
             }
35 35
         }
36 36
 
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
         $send_post_submit_mail = false;
228 228
 
229 229
         // unhook this function so it doesn't loop infinitely
230
-        remove_action('save_post', 'geodir_post_information_save',10,2);
230
+        remove_action('save_post', 'geodir_post_information_save', 10, 2);
231 231
 
232 232
         if (isset($request_info['pid']) && $request_info['pid'] != '') {
233 233
             $post['ID'] = $request_info['pid'];
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
         }
252 252
 
253 253
         // re-hook this function
254
-        add_action('save_post', 'geodir_post_information_save',10,2);
254
+        add_action('save_post', 'geodir_post_information_save', 10, 2);
255 255
 
256 256
         $post_tags = '';
257 257
         if (!isset($request_info['post_tags'])) {
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
         $payment_info = array();
276 276
         $package_info = array();
277 277
 
278
-        $package_info = (array)geodir_post_package_info($package_info, $post);
278
+        $package_info = (array) geodir_post_package_info($package_info, $post);
279 279
 
280 280
         $post_package_id = geodir_get_post_meta($last_post_id, 'package_id');
281 281
 
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
                 $tmpimgArr = trim($request_info['post_images'], ",");
475 475
                 $tmpimgArr = explode(",", $tmpimgArr);
476 476
                 geodir_save_post_images($last_post_id, $tmpimgArr, $dummy);
477
-            } else{
477
+            } else {
478 478
                 geodir_save_post_images($last_post_id, $request_info['post_images'], $dummy);
479 479
             }
480 480
 
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 
659 659
             $post_meta_set_query = trim($post_meta_set_query, ", ");
660 660
 
661
-            $post_meta_set_query = str_replace('%', '%%', $post_meta_set_query);// escape %
661
+            $post_meta_set_query = str_replace('%', '%%', $post_meta_set_query); // escape %
662 662
 
663 663
             /**
664 664
              * Called before saving the listing info.
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
                 $file_path = '';
929 929
                 /* --------- start ------- */
930 930
 
931
-                $split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m]));
931
+                $split_img_path = explode(str_replace(array('http://', 'https://'), '', $uploads['baseurl']), str_replace(array('http://', 'https://'), '', $post_image[$m]));
932 932
 
933 933
                 $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
934 934
 
@@ -985,20 +985,20 @@  discard block
 block discarded – undo
985 985
                         }
986 986
 
987 987
                         $external_img = false;
988
-                        if (strpos(str_replace(array('http://','https://'),'',$curr_img_url), str_replace(array('http://','https://'),'',$uploads['baseurl'])) !== false) {
988
+                        if (strpos(str_replace(array('http://', 'https://'), '', $curr_img_url), str_replace(array('http://', 'https://'), '', $uploads['baseurl'])) !== false) {
989 989
                         } else {
990 990
                             $external_img = true;
991 991
                         }
992 992
 
993 993
                         if ($dummy || $external_img) {
994 994
                             $uploaded_file = array();
995
-                            $uploaded = (array)fetch_remote_file($curr_img_url);
995
+                            $uploaded = (array) fetch_remote_file($curr_img_url);
996 996
 
997 997
                             if (isset($uploaded['error']) && empty($uploaded['error'])) {
998 998
                                 $new_name = basename($uploaded['file']);
999 999
                                 $uploaded_file = $uploaded;
1000
-                            }else{
1001
-                                print_r($uploaded);exit;
1000
+                            } else {
1001
+                                print_r($uploaded); exit;
1002 1002
                             }
1003 1003
                             $external_img = false;
1004 1004
                         } else {
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
                                 $file_path = $sub_dir . '/' . $new_name;
1032 1032
                             }
1033 1033
 
1034
-                            $postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path);
1034
+                            $postcurr_images[] = str_replace(array('http://', 'https://'), '', $uploads['baseurl'] . $file_path);
1035 1035
 
1036 1036
                             if ($menu_order == 1) {
1037 1037
 
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
                 } else {
1070 1070
                     $valid_file_ids[] = $find_image;
1071 1071
 
1072
-                    $postcurr_images[] = str_replace(array('http://','https://'),'',$post_image[$m]);
1072
+                    $postcurr_images[] = str_replace(array('http://', 'https://'), '', $post_image[$m]);
1073 1073
 
1074 1074
                     $wpdb->query(
1075 1075
                         $wpdb->prepare(
@@ -1103,9 +1103,9 @@  discard block
 block discarded – undo
1103 1103
 
1104 1104
                 foreach ($post_images as $img) {
1105 1105
 
1106
-                    if (!in_array(str_replace(array('http://','https://'),'',$img->src), $postcurr_images)) {
1106
+                    if (!in_array(str_replace(array('http://', 'https://'), '', $img->src), $postcurr_images)) {
1107 1107
 
1108
-                        $invalid_files[] = (object)array('src' => $img->src);
1108
+                        $invalid_files[] = (object) array('src' => $img->src);
1109 1109
 
1110 1110
                     }
1111 1111
 
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
 
1114 1114
             }
1115 1115
 
1116
-            $invalid_files = (object)$invalid_files;
1116
+            $invalid_files = (object) $invalid_files;
1117 1117
         }
1118 1118
 
1119 1119
         $remove_files[] = $post_id;
@@ -1247,7 +1247,7 @@  discard block
 block discarded – undo
1247 1247
         }
1248 1248
 
1249 1249
         if (!in_array($post_type, geodir_get_posttypes())) {
1250
-            return false;// if not a GD CPT return;
1250
+            return false; // if not a GD CPT return;
1251 1251
         }
1252 1252
 
1253 1253
         $table = $plugin_prefix . $post_type . '_detail';
@@ -1284,7 +1284,7 @@  discard block
 block discarded – undo
1284 1284
              * @param string $uploads_url The server upload directory url.
1285 1285
              * @param string $uploads_baseurl The uploads dir base url.
1286 1286
              */
1287
-            $img_arr['src'] = apply_filters('geodir_get_featured_image_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1287
+            $img_arr['src'] = apply_filters('geodir_get_featured_image_src', $uploads_url . '/' . $file_name, $file_name, $uploads_url, $uploads_baseurl);
1288 1288
             $img_arr['path'] = $uploads_path . '/' . $file_name;
1289 1289
             $width = 0;
1290 1290
             $height = 0;
@@ -1345,7 +1345,7 @@  discard block
 block discarded – undo
1345 1345
         }
1346 1346
 
1347 1347
         if (!empty($img_arr))
1348
-            return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path );
1348
+            return (object) $img_arr; //return (object)array( 'src' => $file_url, 'path' => $file_path );
1349 1349
         else
1350 1350
             return false;
1351 1351
     }
@@ -1444,7 +1444,7 @@  discard block
 block discarded – undo
1444 1444
                 * @param string $uploads_url The server upload directory url.
1445 1445
                 * @param string $uploads_baseurl The uploads dir base url.
1446 1446
                 */
1447
-                $img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1447
+                $img_arr['src'] = apply_filters('geodir_get_images_src', $uploads_url . '/' . $file_name, $file_name, $uploads_url, $uploads_baseurl);
1448 1448
                 $img_arr['path'] = $uploads_path . '/' . $file_name;
1449 1449
                 $width = 0;
1450 1450
                 $height = 0;
@@ -1462,11 +1462,11 @@  discard block
 block discarded – undo
1462 1462
                 $img_arr['content'] = $attechment->content; // add the description to the array
1463 1463
                 $img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1.
1464 1464
 
1465
-                $return_arr[] = (object)$img_arr;
1465
+                $return_arr[] = (object) $img_arr;
1466 1466
 
1467 1467
                 $counter++;
1468 1468
             }
1469
-            return (object)$return_arr;
1469
+            return (object) $return_arr;
1470 1470
         } else if ($no_images) {
1471 1471
             $default_img = '';
1472 1472
             $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
@@ -1505,7 +1505,7 @@  discard block
 block discarded – undo
1505 1505
                 $img_arr['title'] = $file_info['filename']; // add the title to the array
1506 1506
                 $img_arr['content'] = $file_info['filename']; // add the description to the array
1507 1507
 
1508
-                $return_arr[] = (object)$img_arr;
1508
+                $return_arr[] = (object) $img_arr;
1509 1509
 
1510 1510
                 return $return_arr;
1511 1511
             } else
@@ -1532,8 +1532,8 @@  discard block
 block discarded – undo
1532 1532
 
1533 1533
         $html = '';
1534 1534
         if (!empty($request)) {
1535
-            if (!is_object($request)){
1536
-                $request = (object)$request;
1535
+            if (!is_object($request)) {
1536
+                $request = (object) $request;
1537 1537
             }
1538 1538
 
1539 1539
             if (isset($request->src) && !isset($request->path)) {
@@ -1547,7 +1547,7 @@  discard block
 block discarded – undo
1547 1547
             $img_no_http = str_replace(array("http://", "https://"), "", $request->path);
1548 1548
             $upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']);
1549 1549
             if (strpos($img_no_http, $upload_no_http) !== false) {
1550
-                $request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path);
1550
+                $request->path = str_replace($img_no_http, $upload_dir['basedir'], $request->path);
1551 1551
             }
1552 1552
             
1553 1553
             $width = 0;
@@ -1562,7 +1562,7 @@  discard block
 block discarded – undo
1562 1562
             $image->width = $width;
1563 1563
             $image->height = $height;
1564 1564
 
1565
-            $max_size = (object)geodir_get_imagesize($size);
1565
+            $max_size = (object) geodir_get_imagesize($size);
1566 1566
 
1567 1567
             if (!is_wp_error($max_size)) {
1568 1568
                 if ($image->width) {
@@ -1574,7 +1574,7 @@  discard block
 block discarded – undo
1574 1574
                         $width_per = 100;
1575 1575
                 }
1576 1576
 
1577
-                if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
1577
+                if (is_admin() && !isset($_REQUEST['geodir_ajax'])) {
1578 1578
                     $html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '"  /></div>';
1579 1579
                 } else {
1580 1580
                     $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
@@ -1902,7 +1902,7 @@  discard block
 block discarded – undo
1902 1902
                                     } ?>"><img alt="bubble image" style="max-height:50px;"
1903 1903
                                                src="<?php echo $post_images[0]; ?>"/></a></div>
1904 1904
                             <?php
1905
-                            }else{
1905
+                            } else {
1906 1906
                                 echo '<div class="geodir-bubble_image"></div>';
1907 1907
                             }
1908 1908
                         } else {
@@ -1910,7 +1910,7 @@  discard block
 block discarded – undo
1910 1910
                                 ?>
1911 1911
                                 <div class="geodir-bubble_image"><a href="<?php echo $plink; ?>"><?php echo $image; ?></a></div>
1912 1912
                             <?php
1913
-                            }else{
1913
+                            } else {
1914 1914
                                 echo '<div class="geodir-bubble_image"></div>';
1915 1915
                             }
1916 1916
                         }
@@ -1944,7 +1944,7 @@  discard block
 block discarded – undo
1944 1944
                              * @param object $postinfo_obj The posts info as an object.
1945 1945
                              * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
1946 1946
                              */
1947
-                            do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview );
1947
+                            do_action('geodir_infowindow_meta_after', $postinfo_obj, $post_preview);
1948 1948
                             ?>
1949 1949
                         </div>
1950 1950
                         <?php
@@ -1956,10 +1956,10 @@  discard block
 block discarded – undo
1956 1956
                             <div class="geodir-bubble-meta-fade"></div>
1957 1957
 
1958 1958
                             <div class="geodir-bubble-meta-bottom">
1959
-                                <span class="geodir-bubble-rating"><?php echo $rating_star;?></span>
1959
+                                <span class="geodir-bubble-rating"><?php echo $rating_star; ?></span>
1960 1960
 
1961 1961
                                 <span
1962
-                                    class="geodir-bubble-fav"><?php echo geodir_favourite_html($post_author, $ID);?></span>
1962
+                                    class="geodir-bubble-fav"><?php echo geodir_favourite_html($post_author, $ID); ?></span>
1963 1963
                   <span class="geodir-bubble-reviews"><a href="<?php echo get_comments_link($ID); ?>"
1964 1964
                                                          class="geodir-pcomments"><i class="fa fa-comments"></i>
1965 1965
                           <?php echo get_comments_number($ID); ?>
@@ -2254,7 +2254,7 @@  discard block
 block discarded – undo
2254 2254
          */
2255 2255
         do_action('geodir_before_add_from_favorite', $post_id);
2256 2256
 
2257
-        echo '<a href="javascript:void(0);" title="' . $remove_favourite_text . '" class="geodir-addtofav geodir-removetofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'remove\');"><i class="'. $favourite_icon .'"></i> ' . $unfavourite_text . '</a>';
2257
+        echo '<a href="javascript:void(0);" title="' . $remove_favourite_text . '" class="geodir-addtofav geodir-removetofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'remove\');"><i class="' . $favourite_icon . '"></i> ' . $unfavourite_text . '</a>';
2258 2258
 
2259 2259
         /**
2260 2260
          * Called after adding the post from favourites.
@@ -2333,7 +2333,7 @@  discard block
 block discarded – undo
2333 2333
          */
2334 2334
         do_action('geodir_before_remove_from_favorite', $post_id);
2335 2335
 
2336
-        echo '<a href="javascript:void(0);"  title="' . $add_favourite_text . '" class="geodir-addtofav geodir-addtofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'add\');"><i class="'. $favourite_icon .'"></i> ' . $favourite_text . '</a>';
2336
+        echo '<a href="javascript:void(0);"  title="' . $add_favourite_text . '" class="geodir-addtofav geodir-addtofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'add\');"><i class="' . $favourite_icon . '"></i> ' . $favourite_text . '</a>';
2337 2337
 
2338 2338
         /**
2339 2339
          * Called after removing the post from favourites.
@@ -2428,10 +2428,10 @@  discard block
 block discarded – undo
2428 2428
             $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2429 2429
 
2430 2430
         if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
2431
-            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"  ><a
2431
+            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id; ?>"  ><a
2432 2432
                 class="geodir-removetofav-icon" href="javascript:void(0);"
2433
-                onclick="javascript:addToFavourite(<?php echo $post_id;?>,'remove');"
2434
-                title="<?php echo $remove_favourite_text;?>"><i class="<?php echo $unfavourite_icon; ?>"></i> <?php echo $unfavourite_text;?>
2433
+                onclick="javascript:addToFavourite(<?php echo $post_id; ?>,'remove');"
2434
+                title="<?php echo $remove_favourite_text; ?>"><i class="<?php echo $unfavourite_icon; ?>"></i> <?php echo $unfavourite_text; ?>
2435 2435
             </a>   </span><?php
2436 2436
 
2437 2437
         } else {
@@ -2441,11 +2441,11 @@  discard block
 block discarded – undo
2441 2441
             } else
2442 2442
                 $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2443 2443
 
2444
-            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon"
2444
+            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id; ?>"><a class="geodir-addtofav-icon"
2445 2445
                                                                                         href="javascript:void(0);"
2446
-                                                                                        onclick="<?php echo $script_text;?>"
2447
-                                                                                        title="<?php echo $add_favourite_text;?>"><i
2448
-                    class="<?php echo $favourite_icon; ?>"></i> <?php echo $favourite_text;?></a></span>
2446
+                                                                                        onclick="<?php echo $script_text; ?>"
2447
+                                                                                        title="<?php echo $add_favourite_text; ?>"><i
2448
+                    class="<?php echo $favourite_icon; ?>"></i> <?php echo $favourite_text; ?></a></span>
2449 2449
         <?php }
2450 2450
     }
2451 2451
 }
@@ -3044,15 +3044,15 @@  discard block
 block discarded – undo
3044 3044
  * @since 1.4.9
3045 3045
  * @package GeoDirectory
3046 3046
  */
3047
-function geodir_fb_like_thumbnail(){
3047
+function geodir_fb_like_thumbnail() {
3048 3048
 
3049 3049
     // return if not a single post
3050
-    if(!is_single()){return;}
3050
+    if (!is_single()) {return; }
3051 3051
 
3052 3052
     global $post;
3053
-    if(isset($post->featured_image) && $post->featured_image){
3053
+    if (isset($post->featured_image) && $post->featured_image) {
3054 3054
         $upload_dir = wp_upload_dir();
3055
-        $thumb = $upload_dir['baseurl'].$post->featured_image;
3055
+        $thumb = $upload_dir['baseurl'] . $post->featured_image;
3056 3056
         echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$thumb\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n";
3057 3057
 
3058 3058
     }
Please login to merge, or discard this patch.