@@ -20,492 +20,492 @@ discard block |
||
20 | 20 | function geodir_set_postcat_structure($post_id, $taxonomy, $default_cat = '', $category_str = '') |
21 | 21 | { |
22 | 22 | |
23 | - $post_cat_ids = geodir_get_post_meta($post_id, $taxonomy); |
|
24 | - if (!empty($post_cat_ids)) |
|
25 | - $post_cat_array = explode(",", trim($post_cat_ids, ",")); |
|
26 | - |
|
27 | - if (!isset($default_cat) || empty($default_cat)) { |
|
28 | - $default_cat = isset($post_cat_array[0]) ? $post_cat_array[0] : ''; |
|
29 | - }else{ |
|
30 | - if(!is_int($default_cat)){ |
|
31 | - $category = get_term_by('name', $default_cat, $taxonomy); |
|
32 | - if(isset($category->term_id)){ |
|
33 | - $default_cat = $category->term_id; |
|
34 | - } |
|
35 | - } |
|
23 | + $post_cat_ids = geodir_get_post_meta($post_id, $taxonomy); |
|
24 | + if (!empty($post_cat_ids)) |
|
25 | + $post_cat_array = explode(",", trim($post_cat_ids, ",")); |
|
26 | + |
|
27 | + if (!isset($default_cat) || empty($default_cat)) { |
|
28 | + $default_cat = isset($post_cat_array[0]) ? $post_cat_array[0] : ''; |
|
29 | + }else{ |
|
30 | + if(!is_int($default_cat)){ |
|
31 | + $category = get_term_by('name', $default_cat, $taxonomy); |
|
32 | + if(isset($category->term_id)){ |
|
33 | + $default_cat = $category->term_id; |
|
34 | + } |
|
35 | + } |
|
36 | 36 | |
37 | - } |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - geodir_save_post_meta($post_id, 'default_category', $default_cat); |
|
40 | + geodir_save_post_meta($post_id, 'default_category', $default_cat); |
|
41 | 41 | |
42 | - if (isset($category_str) && empty($category_str)) { |
|
42 | + if (isset($category_str) && empty($category_str)) { |
|
43 | 43 | |
44 | - $post_cat_str = ''; |
|
45 | - $post_categories = array(); |
|
46 | - if (isset($post_cat_array) && is_array($post_cat_array) && !empty($post_cat_array)) { |
|
47 | - $post_cat_str = implode(",y:#", $post_cat_array); |
|
48 | - $post_cat_str .= ",y:"; |
|
49 | - $post_cat_str = substr_replace($post_cat_str, ',y,d:', strpos($post_cat_str, ',y:'), strlen(',y:')); |
|
50 | - } |
|
51 | - $post_categories[$taxonomy] = $post_cat_str; |
|
52 | - $category_str = $post_categories; |
|
53 | - } |
|
44 | + $post_cat_str = ''; |
|
45 | + $post_categories = array(); |
|
46 | + if (isset($post_cat_array) && is_array($post_cat_array) && !empty($post_cat_array)) { |
|
47 | + $post_cat_str = implode(",y:#", $post_cat_array); |
|
48 | + $post_cat_str .= ",y:"; |
|
49 | + $post_cat_str = substr_replace($post_cat_str, ',y,d:', strpos($post_cat_str, ',y:'), strlen(',y:')); |
|
50 | + } |
|
51 | + $post_categories[$taxonomy] = $post_cat_str; |
|
52 | + $category_str = $post_categories; |
|
53 | + } |
|
54 | 54 | |
55 | - $change_cat_str = $category_str[$taxonomy]; |
|
55 | + $change_cat_str = $category_str[$taxonomy]; |
|
56 | 56 | |
57 | - $default_pos = strpos($change_cat_str, 'd:'); |
|
57 | + $default_pos = strpos($change_cat_str, 'd:'); |
|
58 | 58 | |
59 | - if ($default_pos === false) { |
|
59 | + if ($default_pos === false) { |
|
60 | 60 | |
61 | - $change_cat_str = str_replace($default_cat . ',y:', $default_cat . ',y,d:', $change_cat_str); |
|
61 | + $change_cat_str = str_replace($default_cat . ',y:', $default_cat . ',y,d:', $change_cat_str); |
|
62 | 62 | |
63 | - } |
|
63 | + } |
|
64 | 64 | |
65 | - $category_str[$taxonomy] = $change_cat_str; |
|
65 | + $category_str[$taxonomy] = $change_cat_str; |
|
66 | 66 | |
67 | - update_post_meta($post_id, 'post_categories', $category_str); |
|
67 | + update_post_meta($post_id, 'post_categories', $category_str); |
|
68 | 68 | |
69 | 69 | } |
70 | 70 | |
71 | 71 | |
72 | 72 | if (!function_exists('geodir_save_listing')) { |
73 | - /** |
|
74 | - * Saves listing in the database using given information. |
|
75 | - * |
|
76 | - * @since 1.0.0 |
|
77 | - * @since 1.5.4 New parameter $wp_error added. |
|
78 | - * @since 1.6.18 Admin use only date field should not lost value if saved by user - FIXED |
|
79 | - * @package GeoDirectory |
|
80 | - * @global object $wpdb WordPress Database object. |
|
81 | - * @global object $post The current post object. |
|
82 | - * @global object $current_user Current user object. |
|
83 | - * @global object $gd_session GeoDirectory Session object. |
|
84 | - * @param array $request_info { |
|
85 | - * Array of request info arguments. |
|
86 | - * |
|
87 | - * @type string $action Ajax action name. |
|
88 | - * @type string $geodir_ajax Ajax type. |
|
89 | - * @type string $ajax_action Ajax action. |
|
90 | - * @type string $listing_type Listing type. |
|
91 | - * @type string $pid Default Post ID. |
|
92 | - * @type string $preview Todo Desc needed. |
|
93 | - * @type string $add_listing_page_id Add listing page ID. |
|
94 | - * @type string $post_title Listing title. |
|
95 | - * @type string $post_desc Listing Description. |
|
96 | - * @type string $post_tags Listing tags. |
|
97 | - * @type array $cat_limit Category limit. |
|
98 | - * @type array $post_category Category IDs. |
|
99 | - * @type array $post_category_str Category string. |
|
100 | - * @type string $post_default_category Default category ID. |
|
101 | - * @type string $post_address Listing address. |
|
102 | - * @type string $geodir_location_add_listing_country_val Add listing country value. |
|
103 | - * @type string $post_country Listing country. |
|
104 | - * @type string $geodir_location_add_listing_region_val Add listing region value. |
|
105 | - * @type string $post_region Listing region. |
|
106 | - * @type string $geodir_location_add_listing_city_val Add listing city value. |
|
107 | - * @type string $post_city Listing city. |
|
108 | - * @type string $post_zip Listing zip. |
|
109 | - * @type string $post_latitude Listing latitude. |
|
110 | - * @type string $post_longitude Listing longitude. |
|
111 | - * @type string $post_mapview Listing mapview. Default "ROADMAP". |
|
112 | - * @type string $post_mapzoom Listing mapzoom Default "9". |
|
113 | - * @type string $geodir_timing Business timing info. |
|
114 | - * @type string $geodir_contact Contact number. |
|
115 | - * @type string $geodir_email Business contact email. |
|
116 | - * @type string $geodir_website Business website. |
|
117 | - * @type string $geodir_twitter Twitter link. |
|
118 | - * @type string $geodir_facebook Facebook link. |
|
119 | - * @type string $geodir_video Video link. |
|
120 | - * @type string $geodir_special_offers Special offers. |
|
121 | - * @type string $post_images Post image urls. |
|
122 | - * @type string $post_imagesimage_limit Post images limit. |
|
123 | - * @type string $post_imagestotImg Todo Desc needed. |
|
124 | - * @type string $geodir_accept_term_condition Has accepted terms and conditions?. |
|
125 | - * @type string $geodir_spamblocker Todo Desc needed. |
|
126 | - * @type string $geodir_filled_by_spam_bot Todo Desc needed. |
|
127 | - * |
|
128 | - * } |
|
129 | - * @param bool $dummy Optional. Is this a dummy listing? Default false. |
|
130 | - * @param bool $wp_error Optional. Allow return of WP_Error on failure. Default false. |
|
131 | - * @return int|string|WP_Error Created post id or WP_Error on failure. |
|
132 | - */ |
|
133 | - function geodir_save_listing($request_info = array(), $dummy = false, $wp_error = false) |
|
134 | - { |
|
135 | - global $wpdb, $current_user, $gd_session; |
|
136 | - |
|
137 | - $last_post_id = ''; |
|
138 | - |
|
139 | - if ($gd_session->get('listing') && !$dummy) { |
|
140 | - $request_info = array(); |
|
141 | - $request_session = $gd_session->get('listing'); |
|
142 | - $request_info = array_merge($_REQUEST, $request_session); |
|
143 | - } else if (!$gd_session->get('listing') && !$dummy) { |
|
144 | - global $post; |
|
73 | + /** |
|
74 | + * Saves listing in the database using given information. |
|
75 | + * |
|
76 | + * @since 1.0.0 |
|
77 | + * @since 1.5.4 New parameter $wp_error added. |
|
78 | + * @since 1.6.18 Admin use only date field should not lost value if saved by user - FIXED |
|
79 | + * @package GeoDirectory |
|
80 | + * @global object $wpdb WordPress Database object. |
|
81 | + * @global object $post The current post object. |
|
82 | + * @global object $current_user Current user object. |
|
83 | + * @global object $gd_session GeoDirectory Session object. |
|
84 | + * @param array $request_info { |
|
85 | + * Array of request info arguments. |
|
86 | + * |
|
87 | + * @type string $action Ajax action name. |
|
88 | + * @type string $geodir_ajax Ajax type. |
|
89 | + * @type string $ajax_action Ajax action. |
|
90 | + * @type string $listing_type Listing type. |
|
91 | + * @type string $pid Default Post ID. |
|
92 | + * @type string $preview Todo Desc needed. |
|
93 | + * @type string $add_listing_page_id Add listing page ID. |
|
94 | + * @type string $post_title Listing title. |
|
95 | + * @type string $post_desc Listing Description. |
|
96 | + * @type string $post_tags Listing tags. |
|
97 | + * @type array $cat_limit Category limit. |
|
98 | + * @type array $post_category Category IDs. |
|
99 | + * @type array $post_category_str Category string. |
|
100 | + * @type string $post_default_category Default category ID. |
|
101 | + * @type string $post_address Listing address. |
|
102 | + * @type string $geodir_location_add_listing_country_val Add listing country value. |
|
103 | + * @type string $post_country Listing country. |
|
104 | + * @type string $geodir_location_add_listing_region_val Add listing region value. |
|
105 | + * @type string $post_region Listing region. |
|
106 | + * @type string $geodir_location_add_listing_city_val Add listing city value. |
|
107 | + * @type string $post_city Listing city. |
|
108 | + * @type string $post_zip Listing zip. |
|
109 | + * @type string $post_latitude Listing latitude. |
|
110 | + * @type string $post_longitude Listing longitude. |
|
111 | + * @type string $post_mapview Listing mapview. Default "ROADMAP". |
|
112 | + * @type string $post_mapzoom Listing mapzoom Default "9". |
|
113 | + * @type string $geodir_timing Business timing info. |
|
114 | + * @type string $geodir_contact Contact number. |
|
115 | + * @type string $geodir_email Business contact email. |
|
116 | + * @type string $geodir_website Business website. |
|
117 | + * @type string $geodir_twitter Twitter link. |
|
118 | + * @type string $geodir_facebook Facebook link. |
|
119 | + * @type string $geodir_video Video link. |
|
120 | + * @type string $geodir_special_offers Special offers. |
|
121 | + * @type string $post_images Post image urls. |
|
122 | + * @type string $post_imagesimage_limit Post images limit. |
|
123 | + * @type string $post_imagestotImg Todo Desc needed. |
|
124 | + * @type string $geodir_accept_term_condition Has accepted terms and conditions?. |
|
125 | + * @type string $geodir_spamblocker Todo Desc needed. |
|
126 | + * @type string $geodir_filled_by_spam_bot Todo Desc needed. |
|
127 | + * |
|
128 | + * } |
|
129 | + * @param bool $dummy Optional. Is this a dummy listing? Default false. |
|
130 | + * @param bool $wp_error Optional. Allow return of WP_Error on failure. Default false. |
|
131 | + * @return int|string|WP_Error Created post id or WP_Error on failure. |
|
132 | + */ |
|
133 | + function geodir_save_listing($request_info = array(), $dummy = false, $wp_error = false) |
|
134 | + { |
|
135 | + global $wpdb, $current_user, $gd_session; |
|
136 | + |
|
137 | + $last_post_id = ''; |
|
138 | + |
|
139 | + if ($gd_session->get('listing') && !$dummy) { |
|
140 | + $request_info = array(); |
|
141 | + $request_session = $gd_session->get('listing'); |
|
142 | + $request_info = array_merge($_REQUEST, $request_session); |
|
143 | + } else if (!$gd_session->get('listing') && !$dummy) { |
|
144 | + global $post; |
|
145 | 145 | |
146 | - $gd_post = $post; |
|
147 | - if (!empty($gd_post) && is_array($gd_post)) { |
|
148 | - $gd_post = (object)$post; |
|
146 | + $gd_post = $post; |
|
147 | + if (!empty($gd_post) && is_array($gd_post)) { |
|
148 | + $gd_post = (object)$post; |
|
149 | 149 | |
150 | - // Fix WPML duplicate. |
|
151 | - if (geodir_is_wpml() && !empty($request_info['action']) && $request_info['action'] == 'editpost' && !empty($request_info['icl_trid']) && !isset($post['post_date'])) { |
|
152 | - return false; |
|
153 | - } |
|
154 | - } |
|
150 | + // Fix WPML duplicate. |
|
151 | + if (geodir_is_wpml() && !empty($request_info['action']) && $request_info['action'] == 'editpost' && !empty($request_info['icl_trid']) && !isset($post['post_date'])) { |
|
152 | + return false; |
|
153 | + } |
|
154 | + } |
|
155 | 155 | |
156 | - $request_info['pid'] = !empty($gd_post->ID) ? $gd_post->ID : (!empty($request_info['post_id']) ? $request_info['post_id'] : NULL); |
|
157 | - $request_info['post_title'] = $request_info['post_title']; |
|
158 | - $request_info['listing_type'] = !empty($gd_post->post_type) ? $gd_post->post_type : (!empty($request_info['post_type']) ? $request_info['post_type'] : get_post_type($request_info['pid'])); |
|
159 | - $request_info['post_desc'] = $request_info['content']; |
|
160 | - } else if (!$dummy) { |
|
161 | - return false; |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * Filter the request_info array. |
|
166 | - * |
|
167 | - * You can use this filter to modify request_info array. |
|
168 | - * |
|
169 | - * @since 1.0.0 |
|
170 | - * @package GeoDirectory |
|
171 | - * @param array $request_info See {@see geodir_save_listing()} for accepted args. |
|
172 | - */ |
|
173 | - $request_info = apply_filters('geodir_action_get_request_info', $request_info); |
|
174 | - |
|
175 | - // Check if we need to save post location as new location |
|
176 | - $location_result = geodir_get_default_location(); |
|
177 | - |
|
178 | - if ($location_result->location_id > 0) { |
|
179 | - if (isset($request_info['post_city']) && isset($request_info['post_region'])) { |
|
180 | - $request_info['post_location'] = array( |
|
181 | - 'city' => $request_info['post_city'], |
|
182 | - 'region' => isset($request_info['post_region']) ? $request_info['post_region'] : '', |
|
183 | - 'country' => isset($request_info['post_country']) ? $request_info['post_country'] : '', |
|
184 | - 'geo_lat' => isset($request_info['post_latitude']) ? $request_info['post_latitude'] : '', |
|
185 | - 'geo_lng' => isset($request_info['post_longitude']) ? $request_info['post_longitude'] : '' |
|
186 | - ); |
|
187 | - |
|
188 | - $post_location_info = $request_info['post_location']; |
|
189 | - |
|
190 | - if ($location_id = geodir_add_new_location($post_location_info)) { |
|
191 | - $post_location_id = $location_id; |
|
192 | - } |
|
193 | - } else { |
|
194 | - $post_location_id = $location_result->location_id; |
|
195 | - } |
|
196 | - } else { |
|
197 | - $post_location_id = $location_result->location_id; |
|
198 | - } |
|
199 | - |
|
200 | - if ($dummy) { |
|
201 | - $post_status = 'publish'; |
|
202 | - } else { |
|
203 | - $post_status = geodir_new_post_default_status(); |
|
204 | - } |
|
205 | - |
|
206 | - if (isset($request_info['pid']) && $request_info['pid'] != '') { |
|
207 | - $post_status = get_post_status($request_info['pid']); |
|
208 | - } |
|
209 | - |
|
210 | - /* fix change of slug on every title edit */ |
|
211 | - if (!isset($request_info['post_name'])) { |
|
212 | - $request_info['post_name'] = $request_info['post_title']; |
|
213 | - |
|
214 | - if (!empty($request_info['pid'])) { |
|
215 | - $post_info = get_post($request_info['pid']); |
|
216 | - |
|
217 | - if (!empty($post_info) && isset($post_info->post_name)) { |
|
218 | - $request_info['post_name'] = $post_info->post_name; |
|
219 | - } |
|
220 | - } |
|
221 | - } |
|
222 | - |
|
223 | - $post = array( |
|
224 | - 'post_content' => $request_info['post_desc'], |
|
225 | - 'post_status' => $post_status, |
|
226 | - 'post_title' => $request_info['post_title'], |
|
227 | - 'post_name' => $request_info['post_name'], |
|
228 | - 'post_type' => $request_info['listing_type'] |
|
229 | - ); |
|
230 | - |
|
231 | - /** |
|
232 | - * Called before a listing is saved to the database. |
|
233 | - * |
|
234 | - * @since 1.0.0 |
|
235 | - * @param object $post The post object. |
|
236 | - */ |
|
237 | - do_action_ref_array('geodir_before_save_listing', $post); |
|
156 | + $request_info['pid'] = !empty($gd_post->ID) ? $gd_post->ID : (!empty($request_info['post_id']) ? $request_info['post_id'] : NULL); |
|
157 | + $request_info['post_title'] = $request_info['post_title']; |
|
158 | + $request_info['listing_type'] = !empty($gd_post->post_type) ? $gd_post->post_type : (!empty($request_info['post_type']) ? $request_info['post_type'] : get_post_type($request_info['pid'])); |
|
159 | + $request_info['post_desc'] = $request_info['content']; |
|
160 | + } else if (!$dummy) { |
|
161 | + return false; |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * Filter the request_info array. |
|
166 | + * |
|
167 | + * You can use this filter to modify request_info array. |
|
168 | + * |
|
169 | + * @since 1.0.0 |
|
170 | + * @package GeoDirectory |
|
171 | + * @param array $request_info See {@see geodir_save_listing()} for accepted args. |
|
172 | + */ |
|
173 | + $request_info = apply_filters('geodir_action_get_request_info', $request_info); |
|
174 | + |
|
175 | + // Check if we need to save post location as new location |
|
176 | + $location_result = geodir_get_default_location(); |
|
177 | + |
|
178 | + if ($location_result->location_id > 0) { |
|
179 | + if (isset($request_info['post_city']) && isset($request_info['post_region'])) { |
|
180 | + $request_info['post_location'] = array( |
|
181 | + 'city' => $request_info['post_city'], |
|
182 | + 'region' => isset($request_info['post_region']) ? $request_info['post_region'] : '', |
|
183 | + 'country' => isset($request_info['post_country']) ? $request_info['post_country'] : '', |
|
184 | + 'geo_lat' => isset($request_info['post_latitude']) ? $request_info['post_latitude'] : '', |
|
185 | + 'geo_lng' => isset($request_info['post_longitude']) ? $request_info['post_longitude'] : '' |
|
186 | + ); |
|
187 | + |
|
188 | + $post_location_info = $request_info['post_location']; |
|
189 | + |
|
190 | + if ($location_id = geodir_add_new_location($post_location_info)) { |
|
191 | + $post_location_id = $location_id; |
|
192 | + } |
|
193 | + } else { |
|
194 | + $post_location_id = $location_result->location_id; |
|
195 | + } |
|
196 | + } else { |
|
197 | + $post_location_id = $location_result->location_id; |
|
198 | + } |
|
238 | 199 | |
239 | - $send_post_submit_mail = false; |
|
200 | + if ($dummy) { |
|
201 | + $post_status = 'publish'; |
|
202 | + } else { |
|
203 | + $post_status = geodir_new_post_default_status(); |
|
204 | + } |
|
240 | 205 | |
241 | - // unhook this function so it doesn't loop infinitely |
|
242 | - remove_action('save_post', 'geodir_post_information_save',10,2); |
|
206 | + if (isset($request_info['pid']) && $request_info['pid'] != '') { |
|
207 | + $post_status = get_post_status($request_info['pid']); |
|
208 | + } |
|
243 | 209 | |
244 | - if (isset($request_info['pid']) && $request_info['pid'] != '') { |
|
245 | - $post['ID'] = $request_info['pid']; |
|
210 | + /* fix change of slug on every title edit */ |
|
211 | + if (!isset($request_info['post_name'])) { |
|
212 | + $request_info['post_name'] = $request_info['post_title']; |
|
246 | 213 | |
247 | - $last_post_id = wp_update_post($post, $wp_error); |
|
248 | - } else { |
|
249 | - $last_post_id = wp_insert_post($post, $wp_error); |
|
214 | + if (!empty($request_info['pid'])) { |
|
215 | + $post_info = get_post($request_info['pid']); |
|
250 | 216 | |
251 | - if (!$dummy && $last_post_id) { |
|
252 | - $send_post_submit_mail = true; // we move post_submit email from here so the rest of the variables are added to the db first(was breaking permalink in email) |
|
253 | - //geodir_sendEmail('','',$current_user->user_email,$current_user->display_name,'','',$request_info,'post_submit',$last_post_id,$current_user->ID); |
|
254 | - } |
|
255 | - } |
|
217 | + if (!empty($post_info) && isset($post_info->post_name)) { |
|
218 | + $request_info['post_name'] = $post_info->post_name; |
|
219 | + } |
|
220 | + } |
|
221 | + } |
|
222 | + |
|
223 | + $post = array( |
|
224 | + 'post_content' => $request_info['post_desc'], |
|
225 | + 'post_status' => $post_status, |
|
226 | + 'post_title' => $request_info['post_title'], |
|
227 | + 'post_name' => $request_info['post_name'], |
|
228 | + 'post_type' => $request_info['listing_type'] |
|
229 | + ); |
|
230 | + |
|
231 | + /** |
|
232 | + * Called before a listing is saved to the database. |
|
233 | + * |
|
234 | + * @since 1.0.0 |
|
235 | + * @param object $post The post object. |
|
236 | + */ |
|
237 | + do_action_ref_array('geodir_before_save_listing', $post); |
|
238 | + |
|
239 | + $send_post_submit_mail = false; |
|
240 | + |
|
241 | + // unhook this function so it doesn't loop infinitely |
|
242 | + remove_action('save_post', 'geodir_post_information_save',10,2); |
|
243 | + |
|
244 | + if (isset($request_info['pid']) && $request_info['pid'] != '') { |
|
245 | + $post['ID'] = $request_info['pid']; |
|
246 | + |
|
247 | + $last_post_id = wp_update_post($post, $wp_error); |
|
248 | + } else { |
|
249 | + $last_post_id = wp_insert_post($post, $wp_error); |
|
250 | + |
|
251 | + if (!$dummy && $last_post_id) { |
|
252 | + $send_post_submit_mail = true; // we move post_submit email from here so the rest of the variables are added to the db first(was breaking permalink in email) |
|
253 | + //geodir_sendEmail('','',$current_user->user_email,$current_user->display_name,'','',$request_info,'post_submit',$last_post_id,$current_user->ID); |
|
254 | + } |
|
255 | + } |
|
256 | 256 | |
257 | - if ($wp_error && is_wp_error($last_post_id)) { |
|
258 | - return $last_post_id; // Return WP_Error on save failure. |
|
259 | - } |
|
257 | + if ($wp_error && is_wp_error($last_post_id)) { |
|
258 | + return $last_post_id; // Return WP_Error on save failure. |
|
259 | + } |
|
260 | 260 | |
261 | - if (!$last_post_id) { |
|
262 | - return false; // Save failure. |
|
263 | - } |
|
261 | + if (!$last_post_id) { |
|
262 | + return false; // Save failure. |
|
263 | + } |
|
264 | 264 | |
265 | - // re-hook this function |
|
266 | - add_action('save_post', 'geodir_post_information_save',10,2); |
|
265 | + // re-hook this function |
|
266 | + add_action('save_post', 'geodir_post_information_save',10,2); |
|
267 | 267 | |
268 | - $post_tags = ''; |
|
269 | - if (!isset($request_info['post_tags'])) { |
|
268 | + $post_tags = ''; |
|
269 | + if (!isset($request_info['post_tags'])) { |
|
270 | 270 | |
271 | - $post_type = $request_info['listing_type']; |
|
272 | - $post_tags = implode(",", wp_get_object_terms($last_post_id, $post_type . '_tags', array('fields' => 'names'))); |
|
271 | + $post_type = $request_info['listing_type']; |
|
272 | + $post_tags = implode(",", wp_get_object_terms($last_post_id, $post_type . '_tags', array('fields' => 'names'))); |
|
273 | 273 | |
274 | - } |
|
274 | + } |
|
275 | 275 | |
276 | - $gd_post_info = array( |
|
277 | - "post_title" => $request_info['post_title'], |
|
278 | - "post_tags" => isset($request_info['post_tags']) ? $request_info['post_tags'] : $post_tags, |
|
279 | - "post_status" => $post_status, |
|
280 | - "post_location_id" => $post_location_id, |
|
281 | - "claimed" => isset($request_info['claimed']) ? $request_info['claimed'] : '', |
|
282 | - "businesses" => isset($request_info['a_businesses']) ? $request_info['a_businesses'] : '', |
|
283 | - "submit_time" => time(), |
|
284 | - "submit_ip" => $_SERVER['REMOTE_ADDR'], |
|
285 | - ); |
|
276 | + $gd_post_info = array( |
|
277 | + "post_title" => $request_info['post_title'], |
|
278 | + "post_tags" => isset($request_info['post_tags']) ? $request_info['post_tags'] : $post_tags, |
|
279 | + "post_status" => $post_status, |
|
280 | + "post_location_id" => $post_location_id, |
|
281 | + "claimed" => isset($request_info['claimed']) ? $request_info['claimed'] : '', |
|
282 | + "businesses" => isset($request_info['a_businesses']) ? $request_info['a_businesses'] : '', |
|
283 | + "submit_time" => time(), |
|
284 | + "submit_ip" => $_SERVER['REMOTE_ADDR'], |
|
285 | + ); |
|
286 | 286 | |
287 | - $payment_info = array(); |
|
288 | - $package_info = array(); |
|
287 | + $payment_info = array(); |
|
288 | + $package_info = array(); |
|
289 | 289 | |
290 | - $package_info = (array)geodir_post_package_info($package_info, $post); |
|
290 | + $package_info = (array)geodir_post_package_info($package_info, $post); |
|
291 | 291 | |
292 | - $post_package_id = geodir_get_post_meta($last_post_id, 'package_id'); |
|
292 | + $post_package_id = geodir_get_post_meta($last_post_id, 'package_id'); |
|
293 | 293 | |
294 | - if (!empty($package_info) && !$post_package_id) { |
|
295 | - if (isset($package_info['days']) && $package_info['days'] != 0) { |
|
296 | - $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['days'] . " days")); |
|
297 | - } else { |
|
298 | - $payment_info['expire_date'] = 'Never'; |
|
299 | - } |
|
294 | + if (!empty($package_info) && !$post_package_id) { |
|
295 | + if (isset($package_info['days']) && $package_info['days'] != 0) { |
|
296 | + $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['days'] . " days")); |
|
297 | + } else { |
|
298 | + $payment_info['expire_date'] = 'Never'; |
|
299 | + } |
|
300 | 300 | |
301 | - $payment_info['package_id'] = $package_info['pid']; |
|
302 | - $payment_info['alive_days'] = $package_info['days']; |
|
303 | - $payment_info['is_featured'] = $package_info['is_featured']; |
|
301 | + $payment_info['package_id'] = $package_info['pid']; |
|
302 | + $payment_info['alive_days'] = $package_info['days']; |
|
303 | + $payment_info['is_featured'] = $package_info['is_featured']; |
|
304 | 304 | |
305 | - $gd_post_info = array_merge($gd_post_info, $payment_info); |
|
306 | - } |
|
305 | + $gd_post_info = array_merge($gd_post_info, $payment_info); |
|
306 | + } |
|
307 | 307 | |
308 | - $custom_metaboxes = geodir_post_custom_fields('', 'all', $request_info['listing_type']); |
|
308 | + $custom_metaboxes = geodir_post_custom_fields('', 'all', $request_info['listing_type']); |
|
309 | 309 | |
310 | - foreach ($custom_metaboxes as $key => $val): |
|
310 | + foreach ($custom_metaboxes as $key => $val): |
|
311 | 311 | |
312 | - $name = $val['name']; |
|
313 | - $type = $val['type']; |
|
314 | - $extrafields = $val['extra_fields']; |
|
312 | + $name = $val['name']; |
|
313 | + $type = $val['type']; |
|
314 | + $extrafields = $val['extra_fields']; |
|
315 | 315 | |
316 | - if (trim($type) == 'address') { |
|
317 | - $prefix = $name . '_'; |
|
318 | - $address = $prefix . 'address'; |
|
316 | + if (trim($type) == 'address') { |
|
317 | + $prefix = $name . '_'; |
|
318 | + $address = $prefix . 'address'; |
|
319 | 319 | |
320 | - if (isset($request_info[$address]) && $request_info[$address] != '') { |
|
321 | - $gd_post_info[$address] = wp_slash($request_info[$address]); |
|
322 | - } |
|
320 | + if (isset($request_info[$address]) && $request_info[$address] != '') { |
|
321 | + $gd_post_info[$address] = wp_slash($request_info[$address]); |
|
322 | + } |
|
323 | 323 | |
324 | - if ($extrafields != '') { |
|
325 | - $extrafields = unserialize($extrafields); |
|
324 | + if ($extrafields != '') { |
|
325 | + $extrafields = unserialize($extrafields); |
|
326 | 326 | |
327 | 327 | |
328 | - if (!isset($request_info[$prefix . 'city']) || $request_info[$prefix . 'city'] == '') { |
|
328 | + if (!isset($request_info[$prefix . 'city']) || $request_info[$prefix . 'city'] == '') { |
|
329 | 329 | |
330 | - $location_result = geodir_get_default_location(); |
|
330 | + $location_result = geodir_get_default_location(); |
|
331 | 331 | |
332 | - $gd_post_info[$prefix . 'city'] = $location_result->city; |
|
333 | - $gd_post_info[$prefix . 'region'] = $location_result->region; |
|
334 | - $gd_post_info[$prefix . 'country'] = $location_result->country; |
|
332 | + $gd_post_info[$prefix . 'city'] = $location_result->city; |
|
333 | + $gd_post_info[$prefix . 'region'] = $location_result->region; |
|
334 | + $gd_post_info[$prefix . 'country'] = $location_result->country; |
|
335 | 335 | |
336 | - $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location |
|
336 | + $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location |
|
337 | 337 | |
338 | - } else { |
|
338 | + } else { |
|
339 | 339 | |
340 | - $gd_post_info[$prefix . 'city'] = $request_info[$prefix . 'city']; |
|
341 | - $gd_post_info[$prefix . 'region'] = $request_info[$prefix . 'region']; |
|
342 | - $gd_post_info[$prefix . 'country'] = $request_info[$prefix . 'country']; |
|
340 | + $gd_post_info[$prefix . 'city'] = $request_info[$prefix . 'city']; |
|
341 | + $gd_post_info[$prefix . 'region'] = $request_info[$prefix . 'region']; |
|
342 | + $gd_post_info[$prefix . 'country'] = $request_info[$prefix . 'country']; |
|
343 | 343 | |
344 | - //----------set post locations when import dummy data------- |
|
345 | - $location_result = geodir_get_default_location(); |
|
344 | + //----------set post locations when import dummy data------- |
|
345 | + $location_result = geodir_get_default_location(); |
|
346 | 346 | |
347 | - $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location |
|
348 | - //----------------------------------------------------------------- |
|
347 | + $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location |
|
348 | + //----------------------------------------------------------------- |
|
349 | 349 | |
350 | - } |
|
350 | + } |
|
351 | 351 | |
352 | 352 | |
353 | - if (isset($extrafields['show_zip']) && $extrafields['show_zip'] && isset($request_info[$prefix . 'zip'])) { |
|
354 | - $gd_post_info[$prefix . 'zip'] = $request_info[$prefix . 'zip']; |
|
355 | - } |
|
353 | + if (isset($extrafields['show_zip']) && $extrafields['show_zip'] && isset($request_info[$prefix . 'zip'])) { |
|
354 | + $gd_post_info[$prefix . 'zip'] = $request_info[$prefix . 'zip']; |
|
355 | + } |
|
356 | 356 | |
357 | 357 | |
358 | - if (isset($extrafields['show_map']) && $extrafields['show_map']) { |
|
358 | + if (isset($extrafields['show_map']) && $extrafields['show_map']) { |
|
359 | 359 | |
360 | - if (isset($request_info[$prefix . 'latitude']) && $request_info[$prefix . 'latitude'] != '') { |
|
361 | - $gd_post_info[$prefix . 'latitude'] = $request_info[$prefix . 'latitude']; |
|
362 | - } |
|
360 | + if (isset($request_info[$prefix . 'latitude']) && $request_info[$prefix . 'latitude'] != '') { |
|
361 | + $gd_post_info[$prefix . 'latitude'] = $request_info[$prefix . 'latitude']; |
|
362 | + } |
|
363 | 363 | |
364 | - if (isset($request_info[$prefix . 'longitude']) && $request_info[$prefix . 'longitude'] != '') { |
|
365 | - $gd_post_info[$prefix . 'longitude'] = $request_info[$prefix . 'longitude']; |
|
366 | - } |
|
364 | + if (isset($request_info[$prefix . 'longitude']) && $request_info[$prefix . 'longitude'] != '') { |
|
365 | + $gd_post_info[$prefix . 'longitude'] = $request_info[$prefix . 'longitude']; |
|
366 | + } |
|
367 | 367 | |
368 | - if (isset($request_info[$prefix . 'mapview']) && $request_info[$prefix . 'mapview'] != '') { |
|
369 | - $gd_post_info[$prefix . 'mapview'] = $request_info[$prefix . 'mapview']; |
|
370 | - } |
|
368 | + if (isset($request_info[$prefix . 'mapview']) && $request_info[$prefix . 'mapview'] != '') { |
|
369 | + $gd_post_info[$prefix . 'mapview'] = $request_info[$prefix . 'mapview']; |
|
370 | + } |
|
371 | 371 | |
372 | - if (isset($request_info[$prefix . 'mapzoom']) && $request_info[$prefix . 'mapzoom'] != '') { |
|
373 | - $gd_post_info[$prefix . 'mapzoom'] = $request_info[$prefix . 'mapzoom']; |
|
374 | - } |
|
372 | + if (isset($request_info[$prefix . 'mapzoom']) && $request_info[$prefix . 'mapzoom'] != '') { |
|
373 | + $gd_post_info[$prefix . 'mapzoom'] = $request_info[$prefix . 'mapzoom']; |
|
374 | + } |
|
375 | 375 | |
376 | - } |
|
376 | + } |
|
377 | 377 | |
378 | - // show lat lng |
|
379 | - if (isset($extrafields['show_latlng']) && $extrafields['show_latlng'] && isset($request_info[$prefix . 'latlng'])) { |
|
380 | - $gd_post_info[$prefix . 'latlng'] = $request_info[$prefix . 'latlng']; |
|
381 | - } |
|
382 | - } |
|
378 | + // show lat lng |
|
379 | + if (isset($extrafields['show_latlng']) && $extrafields['show_latlng'] && isset($request_info[$prefix . 'latlng'])) { |
|
380 | + $gd_post_info[$prefix . 'latlng'] = $request_info[$prefix . 'latlng']; |
|
381 | + } |
|
382 | + } |
|
383 | 383 | |
384 | - } elseif (trim($type) == 'file') { |
|
385 | - if (isset($request_info[$name])) { |
|
386 | - $request_files = array(); |
|
387 | - if ($request_info[$name] != '') |
|
388 | - $request_files = explode(",", $request_info[$name]); |
|
384 | + } elseif (trim($type) == 'file') { |
|
385 | + if (isset($request_info[$name])) { |
|
386 | + $request_files = array(); |
|
387 | + if ($request_info[$name] != '') |
|
388 | + $request_files = explode(",", $request_info[$name]); |
|
389 | 389 | |
390 | - $extrafields = $extrafields != '' ? maybe_unserialize($extrafields) : NULL; |
|
391 | - geodir_save_post_file_fields($last_post_id, $name, $request_files, $extrafields); |
|
392 | - } |
|
393 | - } elseif (trim($type) == 'datepicker') { |
|
394 | - if (isset($request_info[$name])) { |
|
395 | - $datetime = ''; |
|
390 | + $extrafields = $extrafields != '' ? maybe_unserialize($extrafields) : NULL; |
|
391 | + geodir_save_post_file_fields($last_post_id, $name, $request_files, $extrafields); |
|
392 | + } |
|
393 | + } elseif (trim($type) == 'datepicker') { |
|
394 | + if (isset($request_info[$name])) { |
|
395 | + $datetime = ''; |
|
396 | 396 | |
397 | - if (!empty($request_info[$name])) { |
|
398 | - $date_format = geodir_default_date_format(); |
|
399 | - if (isset($val['extra_fields']) && $val['extra_fields'] != '') { |
|
400 | - $extra_fields = unserialize($val['extra_fields']); |
|
401 | - $date_format = isset($extra_fields['date_format']) && $extra_fields['date_format'] != '' ? $extra_fields['date_format'] : $date_format; |
|
402 | - } |
|
403 | - |
|
404 | - // check if we need to change the format or not |
|
405 | - $date_format_len = strlen(str_replace(' ', '', $date_format)); |
|
406 | - if($date_format_len>5){// if greater then 5 then it's the old style format. |
|
397 | + if (!empty($request_info[$name])) { |
|
398 | + $date_format = geodir_default_date_format(); |
|
399 | + if (isset($val['extra_fields']) && $val['extra_fields'] != '') { |
|
400 | + $extra_fields = unserialize($val['extra_fields']); |
|
401 | + $date_format = isset($extra_fields['date_format']) && $extra_fields['date_format'] != '' ? $extra_fields['date_format'] : $date_format; |
|
402 | + } |
|
403 | + |
|
404 | + // check if we need to change the format or not |
|
405 | + $date_format_len = strlen(str_replace(' ', '', $date_format)); |
|
406 | + if($date_format_len>5){// if greater then 5 then it's the old style format. |
|
407 | 407 | |
408 | - $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format |
|
409 | - $replace = array('d','j','l','m','n','F','Y');//PHP date format |
|
408 | + $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format |
|
409 | + $replace = array('d','j','l','m','n','F','Y');//PHP date format |
|
410 | 410 | |
411 | - $date_format = str_replace($search, $replace, $date_format); |
|
411 | + $date_format = str_replace($search, $replace, $date_format); |
|
412 | 412 | |
413 | - $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $request_info[$name]) : $request_info[$name]; |
|
413 | + $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $request_info[$name]) : $request_info[$name]; |
|
414 | 414 | |
415 | - }else{ |
|
416 | - $post_htmlvar_value = $request_info[$name]; |
|
417 | - } |
|
415 | + }else{ |
|
416 | + $post_htmlvar_value = $request_info[$name]; |
|
417 | + } |
|
418 | 418 | |
419 | - $post_htmlvar_value = geodir_date($post_htmlvar_value, 'Y-m-d', $date_format); // save as sql format Y-m-d |
|
420 | - $datetime = geodir_maybe_untranslate_date($post_htmlvar_value); // maybe untranslate date string if it was translated |
|
421 | - } |
|
419 | + $post_htmlvar_value = geodir_date($post_htmlvar_value, 'Y-m-d', $date_format); // save as sql format Y-m-d |
|
420 | + $datetime = geodir_maybe_untranslate_date($post_htmlvar_value); // maybe untranslate date string if it was translated |
|
421 | + } |
|
422 | 422 | |
423 | - $gd_post_info[$name] = $datetime; |
|
424 | - } |
|
425 | - } else if ($type == 'multiselect') { |
|
426 | - if (isset($request_info[$name])) { |
|
427 | - $gd_post_info[$name] = $request_info[$name]; |
|
428 | - } else { |
|
429 | - if (isset($request_info['gd_field_' . $name])) { |
|
430 | - $gd_post_info[$name] = ''; /* fix de-select for multiselect */ |
|
431 | - } |
|
432 | - } |
|
433 | - } else if (isset($request_info[$name])) { |
|
434 | - $gd_post_info[$name] = $request_info[$name]; |
|
435 | - } |
|
423 | + $gd_post_info[$name] = $datetime; |
|
424 | + } |
|
425 | + } else if ($type == 'multiselect') { |
|
426 | + if (isset($request_info[$name])) { |
|
427 | + $gd_post_info[$name] = $request_info[$name]; |
|
428 | + } else { |
|
429 | + if (isset($request_info['gd_field_' . $name])) { |
|
430 | + $gd_post_info[$name] = ''; /* fix de-select for multiselect */ |
|
431 | + } |
|
432 | + } |
|
433 | + } else if (isset($request_info[$name])) { |
|
434 | + $gd_post_info[$name] = $request_info[$name]; |
|
435 | + } |
|
436 | 436 | |
437 | - endforeach; |
|
437 | + endforeach; |
|
438 | 438 | |
439 | - if (isset($request_info['post_dummy']) && $request_info['post_dummy'] != '') { |
|
440 | - $gd_post_info['post_dummy'] = $request_info['post_dummy']; |
|
441 | - } |
|
439 | + if (isset($request_info['post_dummy']) && $request_info['post_dummy'] != '') { |
|
440 | + $gd_post_info['post_dummy'] = $request_info['post_dummy']; |
|
441 | + } |
|
442 | 442 | |
443 | - // Save post detail info in detail table |
|
444 | - if (!empty($gd_post_info)) { |
|
445 | - geodir_save_post_info($last_post_id, $gd_post_info); |
|
446 | - } |
|
443 | + // Save post detail info in detail table |
|
444 | + if (!empty($gd_post_info)) { |
|
445 | + geodir_save_post_info($last_post_id, $gd_post_info); |
|
446 | + } |
|
447 | 447 | |
448 | 448 | |
449 | - // Set categories to the listing |
|
450 | - if (isset($request_info['post_category']) && !empty($request_info['post_category'])) { |
|
451 | - $post_category = array(); |
|
449 | + // Set categories to the listing |
|
450 | + if (isset($request_info['post_category']) && !empty($request_info['post_category'])) { |
|
451 | + $post_category = array(); |
|
452 | 452 | |
453 | - foreach ($request_info['post_category'] as $taxonomy => $cat) { |
|
453 | + foreach ($request_info['post_category'] as $taxonomy => $cat) { |
|
454 | 454 | |
455 | - if ($dummy) |
|
456 | - $post_category = $cat; |
|
457 | - else { |
|
455 | + if ($dummy) |
|
456 | + $post_category = $cat; |
|
457 | + else { |
|
458 | 458 | |
459 | - if (!is_array($cat) && strstr($cat, ',')) |
|
460 | - $cat = explode(',', $cat); |
|
459 | + if (!is_array($cat) && strstr($cat, ',')) |
|
460 | + $cat = explode(',', $cat); |
|
461 | 461 | |
462 | - if (!empty($cat) && is_array($cat)) |
|
463 | - $post_category = array_map('intval', $cat); |
|
464 | - } |
|
462 | + if (!empty($cat) && is_array($cat)) |
|
463 | + $post_category = array_map('intval', $cat); |
|
464 | + } |
|
465 | 465 | |
466 | - wp_set_object_terms($last_post_id, $post_category, $taxonomy); |
|
467 | - } |
|
466 | + wp_set_object_terms($last_post_id, $post_category, $taxonomy); |
|
467 | + } |
|
468 | 468 | |
469 | - $post_default_category = isset($request_info['post_default_category']) ? $request_info['post_default_category'] : ''; |
|
469 | + $post_default_category = isset($request_info['post_default_category']) ? $request_info['post_default_category'] : ''; |
|
470 | 470 | |
471 | - $post_category_str = isset($request_info['post_category_str']) ? $request_info['post_category_str'] : ''; |
|
472 | - geodir_set_postcat_structure($last_post_id, $taxonomy, $post_default_category, $post_category_str); |
|
471 | + $post_category_str = isset($request_info['post_category_str']) ? $request_info['post_category_str'] : ''; |
|
472 | + geodir_set_postcat_structure($last_post_id, $taxonomy, $post_default_category, $post_category_str); |
|
473 | 473 | |
474 | - } |
|
474 | + } |
|
475 | 475 | |
476 | - $post_tags = ''; |
|
477 | - // Set tags to the listing |
|
478 | - if (isset($request_info['post_tags']) && !is_array($request_info['post_tags']) && !empty($request_info['post_tags'])) { |
|
479 | - $post_tags = explode(",", $request_info['post_tags']); |
|
480 | - } elseif (isset($request_info['post_tags']) && is_array($request_info['post_tags'])) { |
|
481 | - if ($dummy) |
|
482 | - $post_tags = $request_info['post_tags']; |
|
483 | - } else { |
|
484 | - if ($dummy) |
|
485 | - $post_tags = array($request_info['post_title']); |
|
486 | - } |
|
476 | + $post_tags = ''; |
|
477 | + // Set tags to the listing |
|
478 | + if (isset($request_info['post_tags']) && !is_array($request_info['post_tags']) && !empty($request_info['post_tags'])) { |
|
479 | + $post_tags = explode(",", $request_info['post_tags']); |
|
480 | + } elseif (isset($request_info['post_tags']) && is_array($request_info['post_tags'])) { |
|
481 | + if ($dummy) |
|
482 | + $post_tags = $request_info['post_tags']; |
|
483 | + } else { |
|
484 | + if ($dummy) |
|
485 | + $post_tags = array($request_info['post_title']); |
|
486 | + } |
|
487 | 487 | |
488 | - if (is_array($post_tags)) { |
|
489 | - $taxonomy = $request_info['listing_type'] . '_tags'; |
|
490 | - wp_set_object_terms($last_post_id, $post_tags, $taxonomy); |
|
491 | - } |
|
488 | + if (is_array($post_tags)) { |
|
489 | + $taxonomy = $request_info['listing_type'] . '_tags'; |
|
490 | + wp_set_object_terms($last_post_id, $post_tags, $taxonomy); |
|
491 | + } |
|
492 | 492 | |
493 | 493 | |
494 | - // Insert attachment |
|
494 | + // Insert attachment |
|
495 | 495 | |
496 | - if (isset($request_info['post_images']) && !is_wp_error($last_post_id)) { |
|
497 | - if (!$dummy) { |
|
498 | - $tmpimgArr = trim($request_info['post_images'], ","); |
|
499 | - $tmpimgArr = explode(",", $tmpimgArr); |
|
500 | - geodir_save_post_images($last_post_id, $tmpimgArr, $dummy); |
|
501 | - } else{ |
|
502 | - geodir_save_post_images($last_post_id, $request_info['post_images'], $dummy); |
|
503 | - } |
|
496 | + if (isset($request_info['post_images']) && !is_wp_error($last_post_id)) { |
|
497 | + if (!$dummy) { |
|
498 | + $tmpimgArr = trim($request_info['post_images'], ","); |
|
499 | + $tmpimgArr = explode(",", $tmpimgArr); |
|
500 | + geodir_save_post_images($last_post_id, $tmpimgArr, $dummy); |
|
501 | + } else{ |
|
502 | + geodir_save_post_images($last_post_id, $request_info['post_images'], $dummy); |
|
503 | + } |
|
504 | 504 | |
505 | 505 | |
506 | - } elseif (!isset($request_info['post_images']) || $request_info['post_images'] == '') { |
|
506 | + } elseif (!isset($request_info['post_images']) || $request_info['post_images'] == '') { |
|
507 | 507 | |
508 | - /* Delete Attachments |
|
508 | + /* Delete Attachments |
|
509 | 509 | $postcurr_images = geodir_get_images($last_post_id); |
510 | 510 | |
511 | 511 | $wpdb->query( |
@@ -521,34 +521,34 @@ discard block |
||
521 | 521 | geodir_save_post_info($last_post_id, $gd_post_featured_img); |
522 | 522 | */ |
523 | 523 | |
524 | - } |
|
524 | + } |
|
525 | 525 | |
526 | - geodir_remove_temp_images(); |
|
527 | - geodir_set_wp_featured_image($last_post_id); |
|
526 | + geodir_remove_temp_images(); |
|
527 | + geodir_set_wp_featured_image($last_post_id); |
|
528 | 528 | |
529 | - /** |
|
530 | - * Called after a listing is saved to the database and before any email have been sent. |
|
531 | - * |
|
532 | - * @since 1.0.0 |
|
533 | - * @param int $last_post_id The saved post ID. |
|
534 | - * @param array $request_info The post details in an array. |
|
535 | - * @see 'geodir_after_save_listinginfo' |
|
536 | - */ |
|
537 | - do_action('geodir_after_save_listing', $last_post_id, $request_info); |
|
529 | + /** |
|
530 | + * Called after a listing is saved to the database and before any email have been sent. |
|
531 | + * |
|
532 | + * @since 1.0.0 |
|
533 | + * @param int $last_post_id The saved post ID. |
|
534 | + * @param array $request_info The post details in an array. |
|
535 | + * @see 'geodir_after_save_listinginfo' |
|
536 | + */ |
|
537 | + do_action('geodir_after_save_listing', $last_post_id, $request_info); |
|
538 | 538 | |
539 | - //die; |
|
539 | + //die; |
|
540 | 540 | |
541 | - if ($send_post_submit_mail) { // if new post send out email |
|
542 | - $to_name = geodir_get_client_name($current_user->ID); |
|
543 | - geodir_sendEmail('', '', $current_user->user_email, $to_name, '', '', $request_info, 'post_submit', $last_post_id, $current_user->ID); |
|
544 | - } |
|
545 | - /* |
|
541 | + if ($send_post_submit_mail) { // if new post send out email |
|
542 | + $to_name = geodir_get_client_name($current_user->ID); |
|
543 | + geodir_sendEmail('', '', $current_user->user_email, $to_name, '', '', $request_info, 'post_submit', $last_post_id, $current_user->ID); |
|
544 | + } |
|
545 | + /* |
|
546 | 546 | * Unset the session so we don't loop. |
547 | 547 | */ |
548 | - $gd_session->un_set('listing'); |
|
549 | - return $last_post_id; |
|
548 | + $gd_session->un_set('listing'); |
|
549 | + return $last_post_id; |
|
550 | 550 | |
551 | - } |
|
551 | + } |
|
552 | 552 | |
553 | 553 | } |
554 | 554 | |
@@ -567,611 +567,611 @@ discard block |
||
567 | 567 | function geodir_get_post_info($post_id = '') |
568 | 568 | { |
569 | 569 | |
570 | - global $wpdb, $plugin_prefix, $post, $post_info; |
|
570 | + global $wpdb, $plugin_prefix, $post, $post_info; |
|
571 | 571 | |
572 | - if ($post_id == '' && !empty($post)) |
|
573 | - $post_id = $post->ID; |
|
572 | + if ($post_id == '' && !empty($post)) |
|
573 | + $post_id = $post->ID; |
|
574 | 574 | |
575 | - $post_type = get_post_type($post_id); |
|
575 | + $post_type = get_post_type($post_id); |
|
576 | 576 | |
577 | - $all_postypes = geodir_get_posttypes(); |
|
577 | + $all_postypes = geodir_get_posttypes(); |
|
578 | 578 | |
579 | - if (!in_array($post_type, $all_postypes)) |
|
580 | - return false; |
|
579 | + if (!in_array($post_type, $all_postypes)) |
|
580 | + return false; |
|
581 | 581 | |
582 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
582 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
583 | 583 | |
584 | - /** |
|
585 | - * Apply Filter to change Post info |
|
586 | - * |
|
587 | - * You can use this filter to change Post info. |
|
588 | - * |
|
589 | - * @since 1.0.0 |
|
590 | - * @package GeoDirectory |
|
591 | - */ |
|
592 | - $query = apply_filters('geodir_post_info_query', $wpdb->prepare("SELECT p.*,pd.* FROM " . $wpdb->posts . " p," . $table . " pd |
|
584 | + /** |
|
585 | + * Apply Filter to change Post info |
|
586 | + * |
|
587 | + * You can use this filter to change Post info. |
|
588 | + * |
|
589 | + * @since 1.0.0 |
|
590 | + * @package GeoDirectory |
|
591 | + */ |
|
592 | + $query = apply_filters('geodir_post_info_query', $wpdb->prepare("SELECT p.*,pd.* FROM " . $wpdb->posts . " p," . $table . " pd |
|
593 | 593 | WHERE p.ID = pd.post_id |
594 | 594 | AND pd.post_id = %d", $post_id)); |
595 | 595 | |
596 | - $post_detail = $wpdb->get_row($query); |
|
596 | + $post_detail = $wpdb->get_row($query); |
|
597 | 597 | |
598 | - return (!empty($post_detail)) ? $post_info = $post_detail : $post_info = false; |
|
598 | + return (!empty($post_detail)) ? $post_info = $post_detail : $post_info = false; |
|
599 | 599 | |
600 | 600 | } |
601 | 601 | |
602 | 602 | |
603 | 603 | if (!function_exists('geodir_save_post_info')) { |
604 | - /** |
|
605 | - * Saves post detail info in detail table. |
|
606 | - * |
|
607 | - * @since 1.0.0 |
|
608 | - * @package GeoDirectory |
|
609 | - * @global object $wpdb WordPress Database object. |
|
610 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
611 | - * @param int $post_id The post ID. |
|
612 | - * @param array $postinfo_array { |
|
613 | - * Post info that needs to be saved in detail table. |
|
614 | - * |
|
615 | - * @type string $post_title Listing title. |
|
616 | - * @type string $post_tags Listing tags. |
|
617 | - * @type string $post_status Listing post status. |
|
618 | - * @type string $post_location_id Listing location ID. |
|
619 | - * @type string $claimed Todo Desc needed. |
|
620 | - * @type string $businesses Todo Desc needed. |
|
621 | - * @type int $submit_time Submitted time in unix timestamp. |
|
622 | - * @type string $submit_ip Submitted IP. |
|
623 | - * @type string $expire_date Listing expiration date. |
|
624 | - * @type int $package_id Listing package ID. |
|
625 | - * @type int $alive_days Todo Desc needed. |
|
626 | - * @type int $is_featured Is this a featured listing?. |
|
627 | - * @type string $post_address Listing address. |
|
628 | - * @type string $post_city Listing city. |
|
629 | - * @type string $post_region Listing region. |
|
630 | - * @type string $post_country Listing country. |
|
631 | - * @type string $post_locations Listing locations. |
|
632 | - * @type string $post_zip Listing zip. |
|
633 | - * @type string $post_latitude Listing latitude. |
|
634 | - * @type string $post_longitude Listing longitude. |
|
635 | - * @type string $post_mapview Listing mapview. Default "ROADMAP". |
|
636 | - * @type string $post_mapzoom Listing mapzoom Default "9". |
|
637 | - * @type string $geodir_timing Business timing info. |
|
638 | - * @type string $geodir_contact Contact number. |
|
639 | - * @type string $geodir_email Business contact email. |
|
640 | - * @type string $geodir_website Business website. |
|
641 | - * @type string $geodir_twitter Twitter link. |
|
642 | - * @type string $geodir_facebook Facebook link. |
|
643 | - * @type string $geodir_video Video link. |
|
644 | - * @type string $geodir_special_offers Special offers. |
|
645 | - * |
|
646 | - * } |
|
647 | - * @return bool |
|
648 | - */ |
|
649 | - function geodir_save_post_info($post_id, $postinfo_array = array()) |
|
650 | - { |
|
651 | - global $wpdb, $plugin_prefix; |
|
652 | - |
|
653 | - $post_type = get_post_type($post_id); |
|
654 | - |
|
655 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
656 | - |
|
657 | - /** |
|
658 | - * Filter to change Post info |
|
659 | - * |
|
660 | - * You can use this filter to change Post info. |
|
661 | - * |
|
662 | - * @since 1.0.0 |
|
663 | - * @package GeoDirectory |
|
664 | - * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args. |
|
665 | - * @param int $post_id The post ID. |
|
666 | - */ |
|
667 | - $postmeta = apply_filters('geodir_listinginfo_request', $postinfo_array, $post_id); |
|
604 | + /** |
|
605 | + * Saves post detail info in detail table. |
|
606 | + * |
|
607 | + * @since 1.0.0 |
|
608 | + * @package GeoDirectory |
|
609 | + * @global object $wpdb WordPress Database object. |
|
610 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
611 | + * @param int $post_id The post ID. |
|
612 | + * @param array $postinfo_array { |
|
613 | + * Post info that needs to be saved in detail table. |
|
614 | + * |
|
615 | + * @type string $post_title Listing title. |
|
616 | + * @type string $post_tags Listing tags. |
|
617 | + * @type string $post_status Listing post status. |
|
618 | + * @type string $post_location_id Listing location ID. |
|
619 | + * @type string $claimed Todo Desc needed. |
|
620 | + * @type string $businesses Todo Desc needed. |
|
621 | + * @type int $submit_time Submitted time in unix timestamp. |
|
622 | + * @type string $submit_ip Submitted IP. |
|
623 | + * @type string $expire_date Listing expiration date. |
|
624 | + * @type int $package_id Listing package ID. |
|
625 | + * @type int $alive_days Todo Desc needed. |
|
626 | + * @type int $is_featured Is this a featured listing?. |
|
627 | + * @type string $post_address Listing address. |
|
628 | + * @type string $post_city Listing city. |
|
629 | + * @type string $post_region Listing region. |
|
630 | + * @type string $post_country Listing country. |
|
631 | + * @type string $post_locations Listing locations. |
|
632 | + * @type string $post_zip Listing zip. |
|
633 | + * @type string $post_latitude Listing latitude. |
|
634 | + * @type string $post_longitude Listing longitude. |
|
635 | + * @type string $post_mapview Listing mapview. Default "ROADMAP". |
|
636 | + * @type string $post_mapzoom Listing mapzoom Default "9". |
|
637 | + * @type string $geodir_timing Business timing info. |
|
638 | + * @type string $geodir_contact Contact number. |
|
639 | + * @type string $geodir_email Business contact email. |
|
640 | + * @type string $geodir_website Business website. |
|
641 | + * @type string $geodir_twitter Twitter link. |
|
642 | + * @type string $geodir_facebook Facebook link. |
|
643 | + * @type string $geodir_video Video link. |
|
644 | + * @type string $geodir_special_offers Special offers. |
|
645 | + * |
|
646 | + * } |
|
647 | + * @return bool |
|
648 | + */ |
|
649 | + function geodir_save_post_info($post_id, $postinfo_array = array()) |
|
650 | + { |
|
651 | + global $wpdb, $plugin_prefix; |
|
652 | + |
|
653 | + $post_type = get_post_type($post_id); |
|
654 | + |
|
655 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
656 | + |
|
657 | + /** |
|
658 | + * Filter to change Post info |
|
659 | + * |
|
660 | + * You can use this filter to change Post info. |
|
661 | + * |
|
662 | + * @since 1.0.0 |
|
663 | + * @package GeoDirectory |
|
664 | + * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args. |
|
665 | + * @param int $post_id The post ID. |
|
666 | + */ |
|
667 | + $postmeta = apply_filters('geodir_listinginfo_request', $postinfo_array, $post_id); |
|
668 | + |
|
669 | + $query_string_escaped = ''; |
|
670 | + $query_string_array = array(); |
|
671 | + |
|
672 | + if (!empty($postmeta) && $post_id) { |
|
673 | + |
|
674 | + $columns = $wpdb->get_col("show columns from $table"); |
|
675 | + foreach ($postmeta as $mkey => $mval) { |
|
676 | + if(in_array($mkey,$columns)) { |
|
677 | + if (is_array($mval)) { |
|
678 | + $mval = implode(",", $mval); |
|
679 | + } |
|
680 | + $query_string_escaped .= " $mkey = %s, "; // we can set the key here as we check if the column exists above |
|
681 | + $query_string_array[] = stripslashes($mval); // we strip slashes as we are using wpdb prepare |
|
668 | 682 | |
669 | - $query_string_escaped = ''; |
|
670 | - $query_string_array = array(); |
|
683 | + } |
|
684 | + } |
|
671 | 685 | |
672 | - if (!empty($postmeta) && $post_id) { |
|
686 | + $query_string_escaped = trim($query_string_escaped, ", "); |
|
673 | 687 | |
674 | - $columns = $wpdb->get_col("show columns from $table"); |
|
675 | - foreach ($postmeta as $mkey => $mval) { |
|
676 | - if(in_array($mkey,$columns)) { |
|
677 | - if (is_array($mval)) { |
|
678 | - $mval = implode(",", $mval); |
|
679 | - } |
|
680 | - $query_string_escaped .= " $mkey = %s, "; // we can set the key here as we check if the column exists above |
|
681 | - $query_string_array[] = stripslashes($mval); // we strip slashes as we are using wpdb prepare |
|
688 | + if (empty($query_string_array) || trim($query_string_escaped) == '') { |
|
689 | + return false; |
|
690 | + } |
|
682 | 691 | |
683 | - } |
|
684 | - } |
|
692 | + $query_string_array = str_replace(array("'%", "%'"), array("'%%", "%%'"), $query_string_array); |
|
685 | 693 | |
686 | - $query_string_escaped = trim($query_string_escaped, ", "); |
|
687 | 694 | |
688 | - if (empty($query_string_array) || trim($query_string_escaped) == '') { |
|
689 | - return false; |
|
690 | - } |
|
695 | + /** |
|
696 | + * Called before saving the listing info. |
|
697 | + * |
|
698 | + * @since 1.0.0 |
|
699 | + * @package GeoDirectory |
|
700 | + * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args. |
|
701 | + * @param int $post_id The post ID. |
|
702 | + */ |
|
703 | + do_action('geodir_before_save_listinginfo', $postinfo_array, $post_id); |
|
691 | 704 | |
692 | - $query_string_array = str_replace(array("'%", "%'"), array("'%%", "%%'"), $query_string_array); |
|
705 | + if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) { |
|
693 | 706 | |
707 | + $query_string_array[] = $post_id; |
|
708 | + $wpdb->query( |
|
709 | + $wpdb->prepare( |
|
710 | + "UPDATE " . $table . " SET " . $query_string_escaped . " where post_id =%d", |
|
711 | + $query_string_array |
|
712 | + ) |
|
713 | + ); |
|
694 | 714 | |
695 | - /** |
|
696 | - * Called before saving the listing info. |
|
697 | - * |
|
698 | - * @since 1.0.0 |
|
699 | - * @package GeoDirectory |
|
700 | - * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args. |
|
701 | - * @param int $post_id The post ID. |
|
702 | - */ |
|
703 | - do_action('geodir_before_save_listinginfo', $postinfo_array, $post_id); |
|
704 | 715 | |
705 | - if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) { |
|
716 | + } else { |
|
706 | 717 | |
707 | - $query_string_array[] = $post_id; |
|
708 | - $wpdb->query( |
|
709 | - $wpdb->prepare( |
|
710 | - "UPDATE " . $table . " SET " . $query_string_escaped . " where post_id =%d", |
|
711 | - $query_string_array |
|
712 | - ) |
|
713 | - ); |
|
718 | + array_unshift($query_string_array, $post_id); |
|
719 | + $wpdb->query( |
|
720 | + $wpdb->prepare( |
|
721 | + "INSERT INTO " . $table . " SET post_id = %d," . $query_string_escaped, |
|
722 | + $query_string_array |
|
723 | + ) |
|
724 | + ); |
|
725 | + |
|
726 | + } |
|
714 | 727 | |
728 | + /** |
|
729 | + * Called after saving the listing info. |
|
730 | + * |
|
731 | + * @since 1.0.0 |
|
732 | + * @package GeoDirectory |
|
733 | + * @param array $postinfo_array Post info that needs to be saved in detail table. |
|
734 | + * @param int $post_id The post ID. |
|
735 | + * @see 'geodir_after_save_listing' |
|
736 | + */ |
|
737 | + do_action('geodir_after_save_listinginfo', $postinfo_array, $post_id); |
|
738 | + |
|
739 | + return true; |
|
740 | + } else |
|
741 | + return false; |
|
715 | 742 | |
716 | - } else { |
|
743 | + } |
|
744 | +} |
|
717 | 745 | |
718 | - array_unshift($query_string_array, $post_id); |
|
719 | - $wpdb->query( |
|
720 | - $wpdb->prepare( |
|
721 | - "INSERT INTO " . $table . " SET post_id = %d," . $query_string_escaped, |
|
722 | - $query_string_array |
|
723 | - ) |
|
724 | - ); |
|
725 | - |
|
726 | - } |
|
727 | 746 | |
728 | - /** |
|
729 | - * Called after saving the listing info. |
|
730 | - * |
|
731 | - * @since 1.0.0 |
|
732 | - * @package GeoDirectory |
|
733 | - * @param array $postinfo_array Post info that needs to be saved in detail table. |
|
734 | - * @param int $post_id The post ID. |
|
735 | - * @see 'geodir_after_save_listing' |
|
736 | - */ |
|
737 | - do_action('geodir_after_save_listinginfo', $postinfo_array, $post_id); |
|
747 | +if (!function_exists('geodir_save_post_meta')) { |
|
748 | + /** |
|
749 | + * Save or update post custom fields. |
|
750 | + * |
|
751 | + * @since 1.0.0 |
|
752 | + * @package GeoDirectory |
|
753 | + * @global object $wpdb WordPress Database object. |
|
754 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
755 | + * @param int $post_id The post ID. |
|
756 | + * @param string $postmeta Detail table column name. |
|
757 | + * @param string $meta_value Detail table column value. |
|
758 | + * @return void|bool |
|
759 | + */ |
|
760 | + function geodir_save_post_meta($post_id, $postmeta = '', $meta_value = '') |
|
761 | + { |
|
762 | + |
|
763 | + global $wpdb, $plugin_prefix; |
|
764 | + |
|
765 | + $post_type = get_post_type($post_id); |
|
766 | + |
|
767 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
768 | + |
|
769 | + if ($postmeta != '' && geodir_column_exist($table, $postmeta) && $post_id) { |
|
770 | + |
|
771 | + if (is_array($meta_value)) { |
|
772 | + $meta_value = implode(",", $meta_value); |
|
773 | + } |
|
738 | 774 | |
739 | - return true; |
|
740 | - } else |
|
741 | - return false; |
|
775 | + if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) { |
|
742 | 776 | |
743 | - } |
|
744 | -} |
|
777 | + $wpdb->query( |
|
778 | + $wpdb->prepare( |
|
779 | + "UPDATE " . $table . " SET " . $postmeta . " = '" . $meta_value . "' where post_id =%d", |
|
780 | + array($post_id) |
|
781 | + ) |
|
782 | + ); |
|
745 | 783 | |
784 | + } else { |
|
746 | 785 | |
747 | -if (!function_exists('geodir_save_post_meta')) { |
|
748 | - /** |
|
749 | - * Save or update post custom fields. |
|
750 | - * |
|
751 | - * @since 1.0.0 |
|
752 | - * @package GeoDirectory |
|
753 | - * @global object $wpdb WordPress Database object. |
|
754 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
755 | - * @param int $post_id The post ID. |
|
756 | - * @param string $postmeta Detail table column name. |
|
757 | - * @param string $meta_value Detail table column value. |
|
758 | - * @return void|bool |
|
759 | - */ |
|
760 | - function geodir_save_post_meta($post_id, $postmeta = '', $meta_value = '') |
|
761 | - { |
|
762 | - |
|
763 | - global $wpdb, $plugin_prefix; |
|
764 | - |
|
765 | - $post_type = get_post_type($post_id); |
|
766 | - |
|
767 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
768 | - |
|
769 | - if ($postmeta != '' && geodir_column_exist($table, $postmeta) && $post_id) { |
|
770 | - |
|
771 | - if (is_array($meta_value)) { |
|
772 | - $meta_value = implode(",", $meta_value); |
|
773 | - } |
|
774 | - |
|
775 | - if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) { |
|
776 | - |
|
777 | - $wpdb->query( |
|
778 | - $wpdb->prepare( |
|
779 | - "UPDATE " . $table . " SET " . $postmeta . " = '" . $meta_value . "' where post_id =%d", |
|
780 | - array($post_id) |
|
781 | - ) |
|
782 | - ); |
|
783 | - |
|
784 | - } else { |
|
785 | - |
|
786 | - $wpdb->query( |
|
787 | - $wpdb->prepare( |
|
788 | - "INSERT INTO " . $table . " SET post_id = %d, " . $postmeta . " = '" . $meta_value . "'", |
|
789 | - array($post_id) |
|
790 | - ) |
|
791 | - ); |
|
792 | - } |
|
793 | - |
|
794 | - |
|
795 | - } else |
|
796 | - return false; |
|
797 | - } |
|
786 | + $wpdb->query( |
|
787 | + $wpdb->prepare( |
|
788 | + "INSERT INTO " . $table . " SET post_id = %d, " . $postmeta . " = '" . $meta_value . "'", |
|
789 | + array($post_id) |
|
790 | + ) |
|
791 | + ); |
|
792 | + } |
|
793 | + |
|
794 | + |
|
795 | + } else |
|
796 | + return false; |
|
797 | + } |
|
798 | 798 | } |
799 | 799 | |
800 | 800 | if (!function_exists('geodir_delete_post_meta')) { |
801 | - /** |
|
802 | - * Delete post custom fields. |
|
803 | - * |
|
804 | - * @since 1.0.0 |
|
805 | - * @package GeoDirectory |
|
806 | - * @global object $wpdb WordPress Database object. |
|
807 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
808 | - * @param int $post_id The post ID. |
|
809 | - * @param string $postmeta Detail table column name. |
|
810 | - * @todo check if this is depreciated |
|
811 | - * @todo Fix unknown variable mval |
|
812 | - * @return bool |
|
813 | - */ |
|
814 | - function geodir_delete_post_meta($post_id, $postmeta) |
|
815 | - { |
|
816 | - |
|
817 | - global $wpdb, $plugin_prefix; |
|
818 | - |
|
819 | - $post_type = get_post_type($post_id); |
|
820 | - |
|
821 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
822 | - |
|
823 | - if (is_array($postmeta) && !empty($postmeta) && $post_id) { |
|
824 | - $post_meta_set_query = ''; |
|
825 | - |
|
826 | - foreach ($postmeta as $mkey) { |
|
827 | - if ($mval != '') |
|
828 | - $post_meta_set_query .= $mkey . " = '', "; |
|
829 | - } |
|
830 | - |
|
831 | - $post_meta_set_query = trim($post_meta_set_query, ", "); |
|
801 | + /** |
|
802 | + * Delete post custom fields. |
|
803 | + * |
|
804 | + * @since 1.0.0 |
|
805 | + * @package GeoDirectory |
|
806 | + * @global object $wpdb WordPress Database object. |
|
807 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
808 | + * @param int $post_id The post ID. |
|
809 | + * @param string $postmeta Detail table column name. |
|
810 | + * @todo check if this is depreciated |
|
811 | + * @todo Fix unknown variable mval |
|
812 | + * @return bool |
|
813 | + */ |
|
814 | + function geodir_delete_post_meta($post_id, $postmeta) |
|
815 | + { |
|
816 | + |
|
817 | + global $wpdb, $plugin_prefix; |
|
818 | + |
|
819 | + $post_type = get_post_type($post_id); |
|
820 | + |
|
821 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
822 | + |
|
823 | + if (is_array($postmeta) && !empty($postmeta) && $post_id) { |
|
824 | + $post_meta_set_query = ''; |
|
825 | + |
|
826 | + foreach ($postmeta as $mkey) { |
|
827 | + if ($mval != '') |
|
828 | + $post_meta_set_query .= $mkey . " = '', "; |
|
829 | + } |
|
830 | + |
|
831 | + $post_meta_set_query = trim($post_meta_set_query, ", "); |
|
832 | 832 | |
833 | - if (empty($post_meta_set_query) || trim($post_meta_set_query) == '') { |
|
834 | - return false; |
|
835 | - } |
|
836 | - |
|
837 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') { |
|
838 | - |
|
839 | - $wpdb->query( |
|
840 | - $wpdb->prepare( |
|
841 | - "UPDATE " . $table . " SET " . $post_meta_set_query . " where post_id = %d", |
|
842 | - array($post_id) |
|
843 | - ) |
|
844 | - ); |
|
845 | - |
|
846 | - return true; |
|
847 | - } |
|
848 | - |
|
849 | - } elseif ($postmeta != '' && $post_id) { |
|
850 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') { |
|
851 | - |
|
852 | - $wpdb->query( |
|
853 | - $wpdb->prepare( |
|
854 | - "UPDATE " . $table . " SET " . $postmeta . "= '' where post_id = %d", |
|
855 | - array($post_id) |
|
856 | - ) |
|
857 | - ); |
|
858 | - |
|
859 | - return true; |
|
860 | - } |
|
861 | - |
|
862 | - } else |
|
863 | - return false; |
|
864 | - } |
|
833 | + if (empty($post_meta_set_query) || trim($post_meta_set_query) == '') { |
|
834 | + return false; |
|
835 | + } |
|
836 | + |
|
837 | + if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') { |
|
838 | + |
|
839 | + $wpdb->query( |
|
840 | + $wpdb->prepare( |
|
841 | + "UPDATE " . $table . " SET " . $post_meta_set_query . " where post_id = %d", |
|
842 | + array($post_id) |
|
843 | + ) |
|
844 | + ); |
|
845 | + |
|
846 | + return true; |
|
847 | + } |
|
848 | + |
|
849 | + } elseif ($postmeta != '' && $post_id) { |
|
850 | + if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') { |
|
851 | + |
|
852 | + $wpdb->query( |
|
853 | + $wpdb->prepare( |
|
854 | + "UPDATE " . $table . " SET " . $postmeta . "= '' where post_id = %d", |
|
855 | + array($post_id) |
|
856 | + ) |
|
857 | + ); |
|
858 | + |
|
859 | + return true; |
|
860 | + } |
|
861 | + |
|
862 | + } else |
|
863 | + return false; |
|
864 | + } |
|
865 | 865 | } |
866 | 866 | |
867 | 867 | |
868 | 868 | if (!function_exists('geodir_get_post_meta')) { |
869 | - /** |
|
870 | - * Get post custom meta. |
|
871 | - * |
|
872 | - * @since 1.0.0 |
|
873 | - * @since 1.6.20 Hook added to filter value. |
|
874 | - * @package GeoDirectory |
|
875 | - * @global object $wpdb WordPress Database object. |
|
876 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
877 | - * @param int $post_id The post ID. |
|
878 | - * @param string $meta_key The meta key to retrieve. |
|
879 | - * @param bool $single Optional. Whether to return a single value. Default false. |
|
880 | - * @todo single variable not yet implemented. |
|
881 | - * @return bool|mixed|null|string Will be an array if $single is false. Will be value of meta data field if $single is true. |
|
882 | - */ |
|
883 | - function geodir_get_post_meta($post_id, $meta_key, $single = false) { |
|
884 | - if (!$post_id) { |
|
885 | - return false; |
|
886 | - } |
|
887 | - global $wpdb, $plugin_prefix; |
|
888 | - |
|
889 | - $all_postypes = geodir_get_posttypes(); |
|
890 | - |
|
891 | - $post_type = get_post_type($post_id); |
|
892 | - |
|
893 | - if (!in_array($post_type, $all_postypes)) |
|
894 | - return false; |
|
895 | - |
|
896 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
897 | - |
|
898 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $meta_key . "'") != '') { |
|
899 | - $meta_value = $wpdb->get_var($wpdb->prepare("SELECT " . $meta_key . " from " . $table . " where post_id = %d", array($post_id))); |
|
869 | + /** |
|
870 | + * Get post custom meta. |
|
871 | + * |
|
872 | + * @since 1.0.0 |
|
873 | + * @since 1.6.20 Hook added to filter value. |
|
874 | + * @package GeoDirectory |
|
875 | + * @global object $wpdb WordPress Database object. |
|
876 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
877 | + * @param int $post_id The post ID. |
|
878 | + * @param string $meta_key The meta key to retrieve. |
|
879 | + * @param bool $single Optional. Whether to return a single value. Default false. |
|
880 | + * @todo single variable not yet implemented. |
|
881 | + * @return bool|mixed|null|string Will be an array if $single is false. Will be value of meta data field if $single is true. |
|
882 | + */ |
|
883 | + function geodir_get_post_meta($post_id, $meta_key, $single = false) { |
|
884 | + if (!$post_id) { |
|
885 | + return false; |
|
886 | + } |
|
887 | + global $wpdb, $plugin_prefix; |
|
888 | + |
|
889 | + $all_postypes = geodir_get_posttypes(); |
|
890 | + |
|
891 | + $post_type = get_post_type($post_id); |
|
892 | + |
|
893 | + if (!in_array($post_type, $all_postypes)) |
|
894 | + return false; |
|
895 | + |
|
896 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
897 | + |
|
898 | + if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $meta_key . "'") != '') { |
|
899 | + $meta_value = $wpdb->get_var($wpdb->prepare("SELECT " . $meta_key . " from " . $table . " where post_id = %d", array($post_id))); |
|
900 | 900 | |
901 | - if ($meta_value && $meta_value !== '') { |
|
902 | - $meta_value = maybe_serialize($meta_value); |
|
903 | - } |
|
904 | - } else { |
|
905 | - $meta_value = false; |
|
906 | - } |
|
901 | + if ($meta_value && $meta_value !== '') { |
|
902 | + $meta_value = maybe_serialize($meta_value); |
|
903 | + } |
|
904 | + } else { |
|
905 | + $meta_value = false; |
|
906 | + } |
|
907 | 907 | |
908 | - /** |
|
909 | - * Filter the listing custom meta. |
|
910 | - * |
|
911 | - * @since 1.6.20 |
|
912 | - * |
|
913 | - * @param bool|mixed|null|string $meta_value Will be an array if $single is false. Will be value of meta data field if $single is true. |
|
914 | - * @param int $post_id The post ID. |
|
915 | - * @param string $meta_key The meta key to retrieve. |
|
916 | - * @param bool $single Optional. Whether to return a single value. Default false. |
|
917 | - */ |
|
918 | - return apply_filters( 'geodir_get_post_meta', $meta_value, $post_id, $meta_key, $single ); |
|
919 | - } |
|
908 | + /** |
|
909 | + * Filter the listing custom meta. |
|
910 | + * |
|
911 | + * @since 1.6.20 |
|
912 | + * |
|
913 | + * @param bool|mixed|null|string $meta_value Will be an array if $single is false. Will be value of meta data field if $single is true. |
|
914 | + * @param int $post_id The post ID. |
|
915 | + * @param string $meta_key The meta key to retrieve. |
|
916 | + * @param bool $single Optional. Whether to return a single value. Default false. |
|
917 | + */ |
|
918 | + return apply_filters( 'geodir_get_post_meta', $meta_value, $post_id, $meta_key, $single ); |
|
919 | + } |
|
920 | 920 | } |
921 | 921 | |
922 | 922 | |
923 | 923 | if (!function_exists('geodir_save_post_images')) { |
924 | - /** |
|
925 | - * Save post attachments. |
|
926 | - * |
|
927 | - * @since 1.0.0 |
|
928 | - * @package GeoDirectory |
|
929 | - * @global object $wpdb WordPress Database object. |
|
930 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
931 | - * @global object $current_user Current user object. |
|
932 | - * @param int $post_id The post ID. |
|
933 | - * @param array $post_image Post image urls as an array. |
|
934 | - * @param bool $dummy Optional. Is this a dummy listing? Default false. |
|
935 | - */ |
|
936 | - function geodir_save_post_images($post_id = 0, $post_image = array(), $dummy = false) |
|
937 | - { |
|
924 | + /** |
|
925 | + * Save post attachments. |
|
926 | + * |
|
927 | + * @since 1.0.0 |
|
928 | + * @package GeoDirectory |
|
929 | + * @global object $wpdb WordPress Database object. |
|
930 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
931 | + * @global object $current_user Current user object. |
|
932 | + * @param int $post_id The post ID. |
|
933 | + * @param array $post_image Post image urls as an array. |
|
934 | + * @param bool $dummy Optional. Is this a dummy listing? Default false. |
|
935 | + */ |
|
936 | + function geodir_save_post_images($post_id = 0, $post_image = array(), $dummy = false) |
|
937 | + { |
|
938 | 938 | |
939 | 939 | |
940 | - global $wpdb, $plugin_prefix, $current_user; |
|
940 | + global $wpdb, $plugin_prefix, $current_user; |
|
941 | 941 | |
942 | - $post_type = get_post_type($post_id); |
|
942 | + $post_type = get_post_type($post_id); |
|
943 | 943 | |
944 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
944 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
945 | 945 | |
946 | - $post_images = geodir_get_images($post_id); |
|
946 | + $post_images = geodir_get_images($post_id); |
|
947 | 947 | |
948 | - $wpdb->query( |
|
949 | - $wpdb->prepare( |
|
950 | - "UPDATE " . $table . " SET featured_image = '' where post_id =%d", |
|
951 | - array($post_id) |
|
952 | - ) |
|
953 | - ); |
|
948 | + $wpdb->query( |
|
949 | + $wpdb->prepare( |
|
950 | + "UPDATE " . $table . " SET featured_image = '' where post_id =%d", |
|
951 | + array($post_id) |
|
952 | + ) |
|
953 | + ); |
|
954 | 954 | |
955 | - $invalid_files = $post_images; |
|
956 | - $valid_file_ids = array(); |
|
957 | - $valid_files_condition = ''; |
|
958 | - $geodir_uploaddir = ''; |
|
955 | + $invalid_files = $post_images; |
|
956 | + $valid_file_ids = array(); |
|
957 | + $valid_files_condition = ''; |
|
958 | + $geodir_uploaddir = ''; |
|
959 | 959 | |
960 | - $remove_files = array(); |
|
960 | + $remove_files = array(); |
|
961 | 961 | |
962 | - if (!empty($post_image)) { |
|
962 | + if (!empty($post_image)) { |
|
963 | 963 | |
964 | - $uploads = wp_upload_dir(); |
|
965 | - $uploads_dir = $uploads['path']; |
|
964 | + $uploads = wp_upload_dir(); |
|
965 | + $uploads_dir = $uploads['path']; |
|
966 | 966 | |
967 | - $geodir_uploadpath = $uploads['path']; |
|
968 | - $geodir_uploadurl = $uploads['url']; |
|
969 | - $sub_dir = isset($uploads['subdir']) ? $uploads['subdir'] : ''; |
|
967 | + $geodir_uploadpath = $uploads['path']; |
|
968 | + $geodir_uploadurl = $uploads['url']; |
|
969 | + $sub_dir = isset($uploads['subdir']) ? $uploads['subdir'] : ''; |
|
970 | 970 | |
971 | - $invalid_files = array(); |
|
972 | - $postcurr_images = array(); |
|
971 | + $invalid_files = array(); |
|
972 | + $postcurr_images = array(); |
|
973 | 973 | |
974 | - for ($m = 0; $m < count($post_image); $m++) { |
|
975 | - $menu_order = $m + 1; |
|
974 | + for ($m = 0; $m < count($post_image); $m++) { |
|
975 | + $menu_order = $m + 1; |
|
976 | 976 | |
977 | - $file_path = ''; |
|
978 | - /* --------- start ------- */ |
|
977 | + $file_path = ''; |
|
978 | + /* --------- start ------- */ |
|
979 | 979 | |
980 | - $split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m])); |
|
980 | + $split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m])); |
|
981 | 981 | |
982 | - $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : ''; |
|
982 | + $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : ''; |
|
983 | 983 | |
984 | 984 | |
985 | - if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE file=%s AND post_id = %d", array($split_img_file_path, $post_id)))) { |
|
985 | + if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE file=%s AND post_id = %d", array($split_img_file_path, $post_id)))) { |
|
986 | 986 | |
987 | - /* --------- end ------- */ |
|
988 | - $curr_img_url = $post_image[$m]; |
|
987 | + /* --------- end ------- */ |
|
988 | + $curr_img_url = $post_image[$m]; |
|
989 | 989 | |
990 | - $image_name_arr = explode('/', $curr_img_url); |
|
990 | + $image_name_arr = explode('/', $curr_img_url); |
|
991 | 991 | |
992 | - $count_image_name_arr = count($image_name_arr) - 2; |
|
992 | + $count_image_name_arr = count($image_name_arr) - 2; |
|
993 | 993 | |
994 | - $count_image_name_arr = ($count_image_name_arr >= 0) ? $count_image_name_arr : 0; |
|
994 | + $count_image_name_arr = ($count_image_name_arr >= 0) ? $count_image_name_arr : 0; |
|
995 | 995 | |
996 | - $curr_img_dir = $image_name_arr[$count_image_name_arr]; |
|
996 | + $curr_img_dir = $image_name_arr[$count_image_name_arr]; |
|
997 | 997 | |
998 | - $filename = end($image_name_arr); |
|
999 | - if (strpos($filename, '?') !== false) { |
|
1000 | - list($filename) = explode('?', $filename); |
|
1001 | - } |
|
998 | + $filename = end($image_name_arr); |
|
999 | + if (strpos($filename, '?') !== false) { |
|
1000 | + list($filename) = explode('?', $filename); |
|
1001 | + } |
|
1002 | 1002 | |
1003 | - $curr_img_dir = str_replace($uploads['baseurl'], "", $curr_img_url); |
|
1004 | - $curr_img_dir = str_replace($filename, "", $curr_img_dir); |
|
1003 | + $curr_img_dir = str_replace($uploads['baseurl'], "", $curr_img_url); |
|
1004 | + $curr_img_dir = str_replace($filename, "", $curr_img_dir); |
|
1005 | 1005 | |
1006 | - $img_name_arr = explode('.', $filename); |
|
1006 | + $img_name_arr = explode('.', $filename); |
|
1007 | 1007 | |
1008 | - $file_title = isset($img_name_arr[0]) ? $img_name_arr[0] : $filename; |
|
1009 | - if (!empty($img_name_arr) && count($img_name_arr) > 2) { |
|
1010 | - $new_img_name_arr = $img_name_arr; |
|
1011 | - if (isset($new_img_name_arr[count($img_name_arr) - 1])) { |
|
1012 | - unset($new_img_name_arr[count($img_name_arr) - 1]); |
|
1013 | - $file_title = implode('.', $new_img_name_arr); |
|
1014 | - } |
|
1015 | - } |
|
1016 | - $file_title = sanitize_file_name($file_title); |
|
1017 | - $file_name = sanitize_file_name($filename); |
|
1008 | + $file_title = isset($img_name_arr[0]) ? $img_name_arr[0] : $filename; |
|
1009 | + if (!empty($img_name_arr) && count($img_name_arr) > 2) { |
|
1010 | + $new_img_name_arr = $img_name_arr; |
|
1011 | + if (isset($new_img_name_arr[count($img_name_arr) - 1])) { |
|
1012 | + unset($new_img_name_arr[count($img_name_arr) - 1]); |
|
1013 | + $file_title = implode('.', $new_img_name_arr); |
|
1014 | + } |
|
1015 | + } |
|
1016 | + $file_title = sanitize_file_name($file_title); |
|
1017 | + $file_name = sanitize_file_name($filename); |
|
1018 | 1018 | |
1019 | - $arr_file_type = wp_check_filetype($filename); |
|
1019 | + $arr_file_type = wp_check_filetype($filename); |
|
1020 | 1020 | |
1021 | - $uploaded_file_type = $arr_file_type['type']; |
|
1021 | + $uploaded_file_type = $arr_file_type['type']; |
|
1022 | 1022 | |
1023 | - // Set an array containing a list of acceptable formats |
|
1024 | - $allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png'); |
|
1023 | + // Set an array containing a list of acceptable formats |
|
1024 | + $allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png'); |
|
1025 | 1025 | |
1026 | - // If the uploaded file is the right format |
|
1027 | - if (in_array($uploaded_file_type, $allowed_file_types)) { |
|
1028 | - if (!function_exists('wp_handle_upload')) { |
|
1029 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
1030 | - } |
|
1026 | + // If the uploaded file is the right format |
|
1027 | + if (in_array($uploaded_file_type, $allowed_file_types)) { |
|
1028 | + if (!function_exists('wp_handle_upload')) { |
|
1029 | + require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
1030 | + } |
|
1031 | 1031 | |
1032 | - if (!is_dir($geodir_uploadpath)) { |
|
1033 | - mkdir($geodir_uploadpath); |
|
1034 | - } |
|
1032 | + if (!is_dir($geodir_uploadpath)) { |
|
1033 | + mkdir($geodir_uploadpath); |
|
1034 | + } |
|
1035 | 1035 | |
1036 | - $external_img = false; |
|
1037 | - if (strpos( str_replace( array('http://','https://'),'',$curr_img_url ), str_replace(array('http://','https://'),'',$uploads['baseurl'] ) ) !== false) { |
|
1038 | - } else { |
|
1039 | - $external_img = true; |
|
1040 | - } |
|
1036 | + $external_img = false; |
|
1037 | + if (strpos( str_replace( array('http://','https://'),'',$curr_img_url ), str_replace(array('http://','https://'),'',$uploads['baseurl'] ) ) !== false) { |
|
1038 | + } else { |
|
1039 | + $external_img = true; |
|
1040 | + } |
|
1041 | 1041 | |
1042 | - if ($dummy || $external_img) { |
|
1043 | - $uploaded_file = array(); |
|
1044 | - $uploaded = (array)fetch_remote_file($curr_img_url); |
|
1042 | + if ($dummy || $external_img) { |
|
1043 | + $uploaded_file = array(); |
|
1044 | + $uploaded = (array)fetch_remote_file($curr_img_url); |
|
1045 | 1045 | |
1046 | - if (isset($uploaded['error']) && empty($uploaded['error'])) { |
|
1047 | - $new_name = basename($uploaded['file']); |
|
1048 | - $uploaded_file = $uploaded; |
|
1049 | - }else{ |
|
1050 | - print_r($uploaded);exit; |
|
1051 | - } |
|
1052 | - $external_img = false; |
|
1053 | - } else { |
|
1054 | - $new_name = $post_id . '_' . $file_name; |
|
1046 | + if (isset($uploaded['error']) && empty($uploaded['error'])) { |
|
1047 | + $new_name = basename($uploaded['file']); |
|
1048 | + $uploaded_file = $uploaded; |
|
1049 | + }else{ |
|
1050 | + print_r($uploaded);exit; |
|
1051 | + } |
|
1052 | + $external_img = false; |
|
1053 | + } else { |
|
1054 | + $new_name = $post_id . '_' . $file_name; |
|
1055 | 1055 | |
1056 | - if ($curr_img_dir == $sub_dir) { |
|
1057 | - $img_path = $geodir_uploadpath . '/' . $filename; |
|
1058 | - $img_url = $geodir_uploadurl . '/' . $filename; |
|
1059 | - } else { |
|
1060 | - $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
1061 | - $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
1062 | - } |
|
1056 | + if ($curr_img_dir == $sub_dir) { |
|
1057 | + $img_path = $geodir_uploadpath . '/' . $filename; |
|
1058 | + $img_url = $geodir_uploadurl . '/' . $filename; |
|
1059 | + } else { |
|
1060 | + $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
1061 | + $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
1062 | + } |
|
1063 | 1063 | |
1064 | - $uploaded_file = ''; |
|
1064 | + $uploaded_file = ''; |
|
1065 | 1065 | |
1066 | - if (file_exists($img_path)) { |
|
1067 | - $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name); |
|
1068 | - $file_path = ''; |
|
1069 | - } else if (file_exists($uploads['basedir'] . $curr_img_dir . $filename)) { |
|
1070 | - $uploaded_file = true; |
|
1071 | - $file_path = $curr_img_dir . '/' . $filename; |
|
1072 | - } |
|
1066 | + if (file_exists($img_path)) { |
|
1067 | + $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name); |
|
1068 | + $file_path = ''; |
|
1069 | + } else if (file_exists($uploads['basedir'] . $curr_img_dir . $filename)) { |
|
1070 | + $uploaded_file = true; |
|
1071 | + $file_path = $curr_img_dir . '/' . $filename; |
|
1072 | + } |
|
1073 | 1073 | |
1074 | - if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path)) |
|
1075 | - unlink($img_path); |
|
1076 | - } |
|
1074 | + if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path)) |
|
1075 | + unlink($img_path); |
|
1076 | + } |
|
1077 | 1077 | |
1078 | - if (!empty($uploaded_file)) { |
|
1079 | - if (!isset($file_path) || !$file_path) { |
|
1080 | - $file_path = $sub_dir . '/' . $new_name; |
|
1081 | - } |
|
1078 | + if (!empty($uploaded_file)) { |
|
1079 | + if (!isset($file_path) || !$file_path) { |
|
1080 | + $file_path = $sub_dir . '/' . $new_name; |
|
1081 | + } |
|
1082 | 1082 | |
1083 | - $postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path); |
|
1083 | + $postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path); |
|
1084 | 1084 | |
1085 | - if ($menu_order == 1) { |
|
1085 | + if ($menu_order == 1) { |
|
1086 | 1086 | |
1087 | - $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id))); |
|
1087 | + $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id))); |
|
1088 | 1088 | |
1089 | - } |
|
1089 | + } |
|
1090 | 1090 | |
1091 | - // Set up options array to add this file as an attachment |
|
1092 | - $attachment = array(); |
|
1093 | - $attachment['post_id'] = $post_id; |
|
1094 | - $attachment['title'] = $file_title; |
|
1095 | - $attachment['content'] = ''; |
|
1096 | - $attachment['file'] = $file_path; |
|
1097 | - $attachment['mime_type'] = $uploaded_file_type; |
|
1098 | - $attachment['menu_order'] = $menu_order; |
|
1099 | - $attachment['is_featured'] = 0; |
|
1091 | + // Set up options array to add this file as an attachment |
|
1092 | + $attachment = array(); |
|
1093 | + $attachment['post_id'] = $post_id; |
|
1094 | + $attachment['title'] = $file_title; |
|
1095 | + $attachment['content'] = ''; |
|
1096 | + $attachment['file'] = $file_path; |
|
1097 | + $attachment['mime_type'] = $uploaded_file_type; |
|
1098 | + $attachment['menu_order'] = $menu_order; |
|
1099 | + $attachment['is_featured'] = 0; |
|
1100 | 1100 | |
1101 | - $attachment_set = ''; |
|
1101 | + $attachment_set = ''; |
|
1102 | 1102 | |
1103 | - foreach ($attachment as $key => $val) { |
|
1104 | - if ($val != '') |
|
1105 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
1106 | - } |
|
1103 | + foreach ($attachment as $key => $val) { |
|
1104 | + if ($val != '') |
|
1105 | + $attachment_set .= $key . " = '" . $val . "', "; |
|
1106 | + } |
|
1107 | 1107 | |
1108 | - $attachment_set = trim($attachment_set, ", "); |
|
1108 | + $attachment_set = trim($attachment_set, ", "); |
|
1109 | + |
|
1110 | + $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set); |
|
1109 | 1111 | |
1110 | - $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set); |
|
1112 | + $valid_file_ids[] = $wpdb->insert_id; |
|
1113 | + } |
|
1111 | 1114 | |
1112 | - $valid_file_ids[] = $wpdb->insert_id; |
|
1113 | - } |
|
1115 | + } |
|
1114 | 1116 | |
1115 | - } |
|
1116 | 1117 | |
1118 | + } else { |
|
1119 | + $valid_file_ids[] = $find_image; |
|
1117 | 1120 | |
1118 | - } else { |
|
1119 | - $valid_file_ids[] = $find_image; |
|
1120 | - |
|
1121 | - $postcurr_images[] = str_replace(array('http://','https://'),'',$post_image[$m]); |
|
1121 | + $postcurr_images[] = str_replace(array('http://','https://'),'',$post_image[$m]); |
|
1122 | 1122 | |
1123 | - $wpdb->query( |
|
1124 | - $wpdb->prepare( |
|
1125 | - "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d where file =%s AND post_id =%d", |
|
1126 | - array($menu_order, $split_img_path[1], $post_id) |
|
1127 | - ) |
|
1128 | - ); |
|
1123 | + $wpdb->query( |
|
1124 | + $wpdb->prepare( |
|
1125 | + "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d where file =%s AND post_id =%d", |
|
1126 | + array($menu_order, $split_img_path[1], $post_id) |
|
1127 | + ) |
|
1128 | + ); |
|
1129 | 1129 | |
1130 | - if ($menu_order == 1) |
|
1131 | - $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id))); |
|
1130 | + if ($menu_order == 1) |
|
1131 | + $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id))); |
|
1132 | 1132 | |
1133 | - } |
|
1133 | + } |
|
1134 | 1134 | |
1135 | 1135 | |
1136 | - } |
|
1136 | + } |
|
1137 | 1137 | |
1138 | - if (!empty($valid_file_ids)) { |
|
1138 | + if (!empty($valid_file_ids)) { |
|
1139 | 1139 | |
1140 | - $remove_files = $valid_file_ids; |
|
1140 | + $remove_files = $valid_file_ids; |
|
1141 | 1141 | |
1142 | - $remove_files_length = count($remove_files); |
|
1143 | - $remove_files_format = array_fill(0, $remove_files_length, '%d'); |
|
1144 | - $format = implode(',', $remove_files_format); |
|
1145 | - $valid_files_condition = " ID NOT IN ($format) AND "; |
|
1142 | + $remove_files_length = count($remove_files); |
|
1143 | + $remove_files_format = array_fill(0, $remove_files_length, '%d'); |
|
1144 | + $format = implode(',', $remove_files_format); |
|
1145 | + $valid_files_condition = " ID NOT IN ($format) AND "; |
|
1146 | 1146 | |
1147 | - } |
|
1147 | + } |
|
1148 | 1148 | |
1149 | - //Get and remove all old images of post from database to set by new order |
|
1149 | + //Get and remove all old images of post from database to set by new order |
|
1150 | 1150 | |
1151 | - if (!empty($post_images)) { |
|
1151 | + if (!empty($post_images)) { |
|
1152 | 1152 | |
1153 | - foreach ($post_images as $img) { |
|
1153 | + foreach ($post_images as $img) { |
|
1154 | 1154 | |
1155 | - if (!in_array(str_replace(array('http://','https://'),'',$img->src), $postcurr_images)) { |
|
1155 | + if (!in_array(str_replace(array('http://','https://'),'',$img->src), $postcurr_images)) { |
|
1156 | 1156 | |
1157 | - $invalid_files[] = (object)array('src' => $img->src); |
|
1157 | + $invalid_files[] = (object)array('src' => $img->src); |
|
1158 | 1158 | |
1159 | - } |
|
1159 | + } |
|
1160 | 1160 | |
1161 | - } |
|
1161 | + } |
|
1162 | 1162 | |
1163 | - } |
|
1163 | + } |
|
1164 | 1164 | |
1165 | - $invalid_files = (object)$invalid_files; |
|
1166 | - } |
|
1165 | + $invalid_files = (object)$invalid_files; |
|
1166 | + } |
|
1167 | 1167 | |
1168 | - $remove_files[] = $post_id; |
|
1168 | + $remove_files[] = $post_id; |
|
1169 | 1169 | |
1170 | - $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files)); |
|
1170 | + $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files)); |
|
1171 | 1171 | |
1172 | - if (!empty($invalid_files)) |
|
1173 | - geodir_remove_attachments($invalid_files); |
|
1174 | - } |
|
1172 | + if (!empty($invalid_files)) |
|
1173 | + geodir_remove_attachments($invalid_files); |
|
1174 | + } |
|
1175 | 1175 | |
1176 | 1176 | } |
1177 | 1177 | |
@@ -1185,12 +1185,12 @@ discard block |
||
1185 | 1185 | function geodir_remove_temp_images() |
1186 | 1186 | { |
1187 | 1187 | |
1188 | - global $current_user; |
|
1188 | + global $current_user; |
|
1189 | 1189 | |
1190 | - $uploads = wp_upload_dir(); |
|
1191 | - $uploads_dir = $uploads['path']; |
|
1190 | + $uploads = wp_upload_dir(); |
|
1191 | + $uploads_dir = $uploads['path']; |
|
1192 | 1192 | |
1193 | - /* if(is_dir($uploads_dir.'/temp_'.$current_user->data->ID)){ |
|
1193 | + /* if(is_dir($uploads_dir.'/temp_'.$current_user->data->ID)){ |
|
1194 | 1194 | |
1195 | 1195 | $dirPath = $uploads_dir.'/temp_'.$current_user->data->ID; |
1196 | 1196 | if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') { |
@@ -1207,8 +1207,8 @@ discard block |
||
1207 | 1207 | rmdir($dirPath); |
1208 | 1208 | } */ |
1209 | 1209 | |
1210 | - $dirname = $uploads_dir . '/temp_' . $current_user->ID; |
|
1211 | - geodir_delete_directory($dirname); |
|
1210 | + $dirname = $uploads_dir . '/temp_' . $current_user->ID; |
|
1211 | + geodir_delete_directory($dirname); |
|
1212 | 1212 | } |
1213 | 1213 | |
1214 | 1214 | |
@@ -1222,131 +1222,131 @@ discard block |
||
1222 | 1222 | */ |
1223 | 1223 | function geodir_delete_directory($dirname) |
1224 | 1224 | { |
1225 | - $dir_handle = ''; |
|
1226 | - if (is_dir($dirname)) |
|
1227 | - $dir_handle = opendir($dirname); |
|
1228 | - if (!$dir_handle) |
|
1229 | - return false; |
|
1230 | - while ($file = readdir($dir_handle)) { |
|
1231 | - if ($file != "." && $file != "..") { |
|
1232 | - if (!is_dir($dirname . "/" . $file)) |
|
1233 | - unlink($dirname . "/" . $file); |
|
1234 | - else |
|
1235 | - geodir_delete_directory($dirname . '/' . $file); |
|
1236 | - } |
|
1237 | - } |
|
1238 | - closedir($dir_handle); |
|
1239 | - rmdir($dirname); |
|
1240 | - return true; |
|
1225 | + $dir_handle = ''; |
|
1226 | + if (is_dir($dirname)) |
|
1227 | + $dir_handle = opendir($dirname); |
|
1228 | + if (!$dir_handle) |
|
1229 | + return false; |
|
1230 | + while ($file = readdir($dir_handle)) { |
|
1231 | + if ($file != "." && $file != "..") { |
|
1232 | + if (!is_dir($dirname . "/" . $file)) |
|
1233 | + unlink($dirname . "/" . $file); |
|
1234 | + else |
|
1235 | + geodir_delete_directory($dirname . '/' . $file); |
|
1236 | + } |
|
1237 | + } |
|
1238 | + closedir($dir_handle); |
|
1239 | + rmdir($dirname); |
|
1240 | + return true; |
|
1241 | 1241 | |
1242 | 1242 | } |
1243 | 1243 | |
1244 | 1244 | |
1245 | 1245 | if (!function_exists('geodir_remove_attachments')) { |
1246 | - /** |
|
1247 | - * Remove post attachments. |
|
1248 | - * |
|
1249 | - * @since 1.0.0 |
|
1250 | - * @package GeoDirectory |
|
1251 | - * @param array $postcurr_images Array of image objects. |
|
1252 | - */ |
|
1253 | - function geodir_remove_attachments($postcurr_images = array()) |
|
1254 | - { |
|
1255 | - // Unlink all past images of post |
|
1256 | - if (!empty($postcurr_images)) { |
|
1257 | - |
|
1258 | - $uploads = wp_upload_dir(); |
|
1259 | - $uploads_dir = $uploads['path']; |
|
1260 | - |
|
1261 | - foreach ($postcurr_images as $postimg) { |
|
1262 | - $image_name_arr = explode('/', $postimg->src); |
|
1263 | - $filename = end($image_name_arr); |
|
1264 | - if (file_exists($uploads_dir . '/' . $filename)) |
|
1265 | - unlink($uploads_dir . '/' . $filename); |
|
1266 | - } |
|
1267 | - |
|
1268 | - } // endif |
|
1269 | - // Unlink all past images of post end |
|
1270 | - } |
|
1246 | + /** |
|
1247 | + * Remove post attachments. |
|
1248 | + * |
|
1249 | + * @since 1.0.0 |
|
1250 | + * @package GeoDirectory |
|
1251 | + * @param array $postcurr_images Array of image objects. |
|
1252 | + */ |
|
1253 | + function geodir_remove_attachments($postcurr_images = array()) |
|
1254 | + { |
|
1255 | + // Unlink all past images of post |
|
1256 | + if (!empty($postcurr_images)) { |
|
1257 | + |
|
1258 | + $uploads = wp_upload_dir(); |
|
1259 | + $uploads_dir = $uploads['path']; |
|
1260 | + |
|
1261 | + foreach ($postcurr_images as $postimg) { |
|
1262 | + $image_name_arr = explode('/', $postimg->src); |
|
1263 | + $filename = end($image_name_arr); |
|
1264 | + if (file_exists($uploads_dir . '/' . $filename)) |
|
1265 | + unlink($uploads_dir . '/' . $filename); |
|
1266 | + } |
|
1267 | + |
|
1268 | + } // endif |
|
1269 | + // Unlink all past images of post end |
|
1270 | + } |
|
1271 | 1271 | } |
1272 | 1272 | |
1273 | 1273 | if (!function_exists('geodir_get_featured_image')) { |
1274 | - /** |
|
1275 | - * Gets the post featured image. |
|
1276 | - * |
|
1277 | - * @since 1.0.0 |
|
1278 | - * @package GeoDirectory |
|
1279 | - * @global object $wpdb WordPress Database object. |
|
1280 | - * @global object $post The current post object. |
|
1281 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
1282 | - * @param int|string $post_id The post ID. |
|
1283 | - * @param string $size Optional. Thumbnail size. Default: thumbnail. |
|
1284 | - * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. |
|
1285 | - * @param bool|string $file Optional. The file path from which you want to get the image details. Default: false. |
|
1286 | - * @return bool|object Image details as an object. |
|
1287 | - */ |
|
1288 | - function geodir_get_featured_image($post_id = '', $size = '', $no_image = false, $file = false) |
|
1289 | - { |
|
1290 | - |
|
1291 | - /*$img_arr['src'] = get_the_post_thumbnail_url( $post_id, 'medium');//medium/thumbnail |
|
1274 | + /** |
|
1275 | + * Gets the post featured image. |
|
1276 | + * |
|
1277 | + * @since 1.0.0 |
|
1278 | + * @package GeoDirectory |
|
1279 | + * @global object $wpdb WordPress Database object. |
|
1280 | + * @global object $post The current post object. |
|
1281 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
1282 | + * @param int|string $post_id The post ID. |
|
1283 | + * @param string $size Optional. Thumbnail size. Default: thumbnail. |
|
1284 | + * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. |
|
1285 | + * @param bool|string $file Optional. The file path from which you want to get the image details. Default: false. |
|
1286 | + * @return bool|object Image details as an object. |
|
1287 | + */ |
|
1288 | + function geodir_get_featured_image($post_id = '', $size = '', $no_image = false, $file = false) |
|
1289 | + { |
|
1290 | + |
|
1291 | + /*$img_arr['src'] = get_the_post_thumbnail_url( $post_id, 'medium');//medium/thumbnail |
|
1292 | 1292 | $img_arr['path'] = ''; |
1293 | 1293 | $img_arr['width'] = ''; |
1294 | 1294 | $img_arr['height'] = ''; |
1295 | 1295 | $img_arr['title'] = ''; |
1296 | 1296 | return (object)$img_arr;*/ |
1297 | - global $wpdb, $plugin_prefix, $post; |
|
1297 | + global $wpdb, $plugin_prefix, $post; |
|
1298 | + |
|
1299 | + if (isset($post->ID) && isset($post->post_type) && $post->ID == $post_id) { |
|
1300 | + $post_type = $post->post_type; |
|
1301 | + } else { |
|
1302 | + $post_type = get_post_type($post_id); |
|
1303 | + } |
|
1304 | + |
|
1305 | + if (!in_array($post_type, geodir_get_posttypes())) { |
|
1306 | + return false;// if not a GD CPT return; |
|
1307 | + } |
|
1308 | + |
|
1309 | + |
|
1310 | + /** |
|
1311 | + * Filter to force the list images to be smaller. |
|
1312 | + * @since 1.6.18 |
|
1313 | + */ |
|
1314 | + if( $size=='list-thumb' && apply_filters('geodir_use_small_list_img',false) ){ |
|
1315 | + $fimg = get_the_post_thumbnail_url($post_id,'medium'); |
|
1316 | + if($fimg){ |
|
1317 | + $uploads = wp_upload_dir(); |
|
1318 | + $uploads_baseurl = $uploads['baseurl']; |
|
1319 | + $file = str_replace($uploads_baseurl,'',$fimg); |
|
1320 | + } |
|
1321 | + } |
|
1322 | + |
|
1323 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
1298 | 1324 | |
1299 | - if (isset($post->ID) && isset($post->post_type) && $post->ID == $post_id) { |
|
1300 | - $post_type = $post->post_type; |
|
1301 | - } else { |
|
1302 | - $post_type = get_post_type($post_id); |
|
1303 | - } |
|
1325 | + if (!$file) { |
|
1326 | + if (isset($post->featured_image)) { |
|
1327 | + $file = $post->featured_image; |
|
1328 | + } else { |
|
1329 | + $file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM " . $table . " WHERE post_id = %d", array($post_id))); |
|
1330 | + } |
|
1331 | + } |
|
1332 | + |
|
1333 | + if ($file != NULL && $file != '' && (($uploads = wp_upload_dir()) && false === $uploads['error'])) { |
|
1334 | + $img_arr = array(); |
|
1304 | 1335 | |
1305 | - if (!in_array($post_type, geodir_get_posttypes())) { |
|
1306 | - return false;// if not a GD CPT return; |
|
1307 | - } |
|
1336 | + $file_info = pathinfo($file); |
|
1337 | + $sub_dir = ''; |
|
1338 | + if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') { |
|
1339 | + $sub_dir = stripslashes_deep($file_info['dirname']); |
|
1340 | + } |
|
1308 | 1341 | |
1342 | + $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
1343 | + $uploads_baseurl = $uploads['baseurl']; |
|
1344 | + $uploads_path = $uploads['path']; |
|
1309 | 1345 | |
1310 | - /** |
|
1311 | - * Filter to force the list images to be smaller. |
|
1312 | - * @since 1.6.18 |
|
1313 | - */ |
|
1314 | - if( $size=='list-thumb' && apply_filters('geodir_use_small_list_img',false) ){ |
|
1315 | - $fimg = get_the_post_thumbnail_url($post_id,'medium'); |
|
1316 | - if($fimg){ |
|
1317 | - $uploads = wp_upload_dir(); |
|
1318 | - $uploads_baseurl = $uploads['baseurl']; |
|
1319 | - $file = str_replace($uploads_baseurl,'',$fimg); |
|
1320 | - } |
|
1321 | - } |
|
1322 | - |
|
1323 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
1324 | - |
|
1325 | - if (!$file) { |
|
1326 | - if (isset($post->featured_image)) { |
|
1327 | - $file = $post->featured_image; |
|
1328 | - } else { |
|
1329 | - $file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM " . $table . " WHERE post_id = %d", array($post_id))); |
|
1330 | - } |
|
1331 | - } |
|
1332 | - |
|
1333 | - if ($file != NULL && $file != '' && (($uploads = wp_upload_dir()) && false === $uploads['error'])) { |
|
1334 | - $img_arr = array(); |
|
1335 | - |
|
1336 | - $file_info = pathinfo($file); |
|
1337 | - $sub_dir = ''; |
|
1338 | - if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') { |
|
1339 | - $sub_dir = stripslashes_deep($file_info['dirname']); |
|
1340 | - } |
|
1341 | - |
|
1342 | - $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
1343 | - $uploads_baseurl = $uploads['baseurl']; |
|
1344 | - $uploads_path = $uploads['path']; |
|
1345 | - |
|
1346 | - $file_name = $file_info['basename']; |
|
1347 | - |
|
1348 | - $uploads_url = $uploads_baseurl . $sub_dir; |
|
1349 | - /* |
|
1346 | + $file_name = $file_info['basename']; |
|
1347 | + |
|
1348 | + $uploads_url = $uploads_baseurl . $sub_dir; |
|
1349 | + /* |
|
1350 | 1350 | * Allows the filter of image src for such things as CDN change. |
1351 | 1351 | * |
1352 | 1352 | * @since 1.5.7 |
@@ -1355,158 +1355,158 @@ discard block |
||
1355 | 1355 | * @param string $uploads_url The server upload directory url. |
1356 | 1356 | * @param string $uploads_baseurl The uploads dir base url. |
1357 | 1357 | */ |
1358 | - $img_arr['src'] = apply_filters('geodir_get_featured_image_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl); |
|
1359 | - $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
1360 | - $width = 0; |
|
1361 | - $height = 0; |
|
1362 | - if (is_file($img_arr['path']) && file_exists($img_arr['path'])) { |
|
1363 | - $imagesize = getimagesize($img_arr['path']); |
|
1364 | - $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
1365 | - $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
1366 | - } |
|
1367 | - $img_arr['width'] = $width; |
|
1368 | - $img_arr['height'] = $height; |
|
1369 | - $img_arr['title'] = ''; |
|
1370 | - } elseif ($post_images = geodir_get_images($post_id, $size, $no_image, 1)) { |
|
1371 | - foreach ($post_images as $image) { |
|
1372 | - return $image; |
|
1373 | - } |
|
1374 | - } else if ($no_image) { |
|
1375 | - $img_arr = array(); |
|
1376 | - |
|
1377 | - $default_img = ''; |
|
1378 | - if (isset($post->default_category) && $post->default_category) { |
|
1379 | - $default_cat = $post->default_category; |
|
1380 | - } else { |
|
1381 | - $default_cat = geodir_get_post_meta($post_id, 'default_category', true); |
|
1382 | - } |
|
1383 | - |
|
1384 | - if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) |
|
1385 | - $default_img = $default_catimg['src']; |
|
1386 | - elseif ($no_image) { |
|
1387 | - $default_img = get_option('geodir_listing_no_img'); |
|
1388 | - } |
|
1389 | - |
|
1390 | - if (!empty($default_img)) { |
|
1391 | - $uploads = wp_upload_dir(); // Array of key => value pairs |
|
1392 | - $uploads_baseurl = $uploads['baseurl']; |
|
1393 | - $uploads_path = $uploads['path']; |
|
1394 | - |
|
1395 | - $img_arr = array(); |
|
1396 | - |
|
1397 | - $file_info = pathinfo($default_img); |
|
1398 | - |
|
1399 | - $file_name = $file_info['basename']; |
|
1400 | - |
|
1401 | - $img_arr['src'] = $default_img; |
|
1402 | - $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
1403 | - |
|
1404 | - $width = 0; |
|
1405 | - $height = 0; |
|
1406 | - if (is_file($img_arr['path']) && file_exists($img_arr['path'])) { |
|
1407 | - $imagesize = getimagesize($img_arr['path']); |
|
1408 | - $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
1409 | - $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
1410 | - } |
|
1411 | - $img_arr['width'] = $width; |
|
1412 | - $img_arr['height'] = $height; |
|
1413 | - |
|
1414 | - $img_arr['title'] = ''; // add the title to the array |
|
1415 | - } |
|
1416 | - } |
|
1417 | - |
|
1418 | - if (!empty($img_arr)) |
|
1419 | - return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path ); |
|
1420 | - else |
|
1421 | - return false; |
|
1422 | - } |
|
1358 | + $img_arr['src'] = apply_filters('geodir_get_featured_image_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl); |
|
1359 | + $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
1360 | + $width = 0; |
|
1361 | + $height = 0; |
|
1362 | + if (is_file($img_arr['path']) && file_exists($img_arr['path'])) { |
|
1363 | + $imagesize = getimagesize($img_arr['path']); |
|
1364 | + $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
1365 | + $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
1366 | + } |
|
1367 | + $img_arr['width'] = $width; |
|
1368 | + $img_arr['height'] = $height; |
|
1369 | + $img_arr['title'] = ''; |
|
1370 | + } elseif ($post_images = geodir_get_images($post_id, $size, $no_image, 1)) { |
|
1371 | + foreach ($post_images as $image) { |
|
1372 | + return $image; |
|
1373 | + } |
|
1374 | + } else if ($no_image) { |
|
1375 | + $img_arr = array(); |
|
1376 | + |
|
1377 | + $default_img = ''; |
|
1378 | + if (isset($post->default_category) && $post->default_category) { |
|
1379 | + $default_cat = $post->default_category; |
|
1380 | + } else { |
|
1381 | + $default_cat = geodir_get_post_meta($post_id, 'default_category', true); |
|
1382 | + } |
|
1383 | + |
|
1384 | + if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) |
|
1385 | + $default_img = $default_catimg['src']; |
|
1386 | + elseif ($no_image) { |
|
1387 | + $default_img = get_option('geodir_listing_no_img'); |
|
1388 | + } |
|
1389 | + |
|
1390 | + if (!empty($default_img)) { |
|
1391 | + $uploads = wp_upload_dir(); // Array of key => value pairs |
|
1392 | + $uploads_baseurl = $uploads['baseurl']; |
|
1393 | + $uploads_path = $uploads['path']; |
|
1394 | + |
|
1395 | + $img_arr = array(); |
|
1396 | + |
|
1397 | + $file_info = pathinfo($default_img); |
|
1398 | + |
|
1399 | + $file_name = $file_info['basename']; |
|
1400 | + |
|
1401 | + $img_arr['src'] = $default_img; |
|
1402 | + $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
1403 | + |
|
1404 | + $width = 0; |
|
1405 | + $height = 0; |
|
1406 | + if (is_file($img_arr['path']) && file_exists($img_arr['path'])) { |
|
1407 | + $imagesize = getimagesize($img_arr['path']); |
|
1408 | + $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
1409 | + $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
1410 | + } |
|
1411 | + $img_arr['width'] = $width; |
|
1412 | + $img_arr['height'] = $height; |
|
1413 | + |
|
1414 | + $img_arr['title'] = ''; // add the title to the array |
|
1415 | + } |
|
1416 | + } |
|
1417 | + |
|
1418 | + if (!empty($img_arr)) |
|
1419 | + return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path ); |
|
1420 | + else |
|
1421 | + return false; |
|
1422 | + } |
|
1423 | 1423 | } |
1424 | 1424 | |
1425 | 1425 | if (!function_exists('geodir_show_featured_image')) { |
1426 | - /** |
|
1427 | - * Gets the post featured image. |
|
1428 | - * |
|
1429 | - * @since 1.0.0 |
|
1430 | - * @package GeoDirectory |
|
1431 | - * @param int|string $post_id The post ID. |
|
1432 | - * @param string $size Optional. Thumbnail size. Default: thumbnail. |
|
1433 | - * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. |
|
1434 | - * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true. |
|
1435 | - * @param bool|string $fimage Optional. The file path from which you want to get the image details. Default: false. |
|
1436 | - * @return bool|string Returns image html. |
|
1437 | - */ |
|
1438 | - function geodir_show_featured_image($post_id = '', $size = 'thumbnail', $no_image = false, $echo = true, $fimage = false) |
|
1439 | - { |
|
1440 | - $image = geodir_get_featured_image($post_id, $size, $no_image, $fimage); |
|
1441 | - |
|
1442 | - $html = geodir_show_image($image, $size, $no_image, false); |
|
1443 | - |
|
1444 | - if (!empty($html) && $echo) { |
|
1445 | - echo $html; |
|
1446 | - } elseif (!empty($html)) { |
|
1447 | - return $html; |
|
1448 | - } else |
|
1449 | - return false; |
|
1450 | - } |
|
1426 | + /** |
|
1427 | + * Gets the post featured image. |
|
1428 | + * |
|
1429 | + * @since 1.0.0 |
|
1430 | + * @package GeoDirectory |
|
1431 | + * @param int|string $post_id The post ID. |
|
1432 | + * @param string $size Optional. Thumbnail size. Default: thumbnail. |
|
1433 | + * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. |
|
1434 | + * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true. |
|
1435 | + * @param bool|string $fimage Optional. The file path from which you want to get the image details. Default: false. |
|
1436 | + * @return bool|string Returns image html. |
|
1437 | + */ |
|
1438 | + function geodir_show_featured_image($post_id = '', $size = 'thumbnail', $no_image = false, $echo = true, $fimage = false) |
|
1439 | + { |
|
1440 | + $image = geodir_get_featured_image($post_id, $size, $no_image, $fimage); |
|
1441 | + |
|
1442 | + $html = geodir_show_image($image, $size, $no_image, false); |
|
1443 | + |
|
1444 | + if (!empty($html) && $echo) { |
|
1445 | + echo $html; |
|
1446 | + } elseif (!empty($html)) { |
|
1447 | + return $html; |
|
1448 | + } else |
|
1449 | + return false; |
|
1450 | + } |
|
1451 | 1451 | } |
1452 | 1452 | |
1453 | 1453 | if (!function_exists('geodir_get_images')) { |
1454 | - /** |
|
1455 | - * Gets the post images. |
|
1456 | - * |
|
1457 | - * @since 1.0.0 |
|
1458 | - * @package GeoDirectory |
|
1459 | - * @global object $wpdb WordPress Database object. |
|
1460 | - * @param int $post_id The post ID. |
|
1461 | - * @param string $img_size Optional. Thumbnail size. |
|
1462 | - * @param bool $no_images Optional. Do you want to return the default image when no image is available? Default: false. |
|
1463 | - * @param bool $add_featured Optional. Do you want to include featured images too? Default: true. |
|
1464 | - * @param int|string $limit Optional. Number of images. |
|
1465 | - * @return array|bool Returns images as an array. Each item is an object. |
|
1466 | - */ |
|
1467 | - function geodir_get_images($post_id = 0, $img_size = '', $no_images = false, $add_featured = true, $limit = '') |
|
1468 | - { |
|
1469 | - global $wpdb; |
|
1470 | - if ($limit) { |
|
1471 | - $limit_q = " LIMIT $limit "; |
|
1472 | - } else { |
|
1473 | - $limit_q = ''; |
|
1474 | - } |
|
1475 | - $not_featured = ''; |
|
1476 | - $sub_dir = ''; |
|
1477 | - if (!$add_featured) |
|
1478 | - $not_featured = " AND is_featured = 0 "; |
|
1479 | - |
|
1480 | - $arrImages = $wpdb->get_results( |
|
1481 | - $wpdb->prepare( |
|
1482 | - "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d" . $not_featured . " ORDER BY menu_order ASC, ID DESC $limit_q ", |
|
1483 | - array('%image%', $post_id) |
|
1484 | - ) |
|
1485 | - ); |
|
1486 | - |
|
1487 | - $counter = 0; |
|
1488 | - $return_arr = array(); |
|
1489 | - |
|
1490 | - if (!empty($arrImages)) { |
|
1491 | - foreach ($arrImages as $attechment) { |
|
1492 | - |
|
1493 | - $img_arr = array(); |
|
1494 | - $img_arr['id'] = $attechment->ID; |
|
1495 | - $img_arr['user_id'] = isset($attechment->user_id) ? $attechment->user_id : 0; |
|
1496 | - |
|
1497 | - $file_info = pathinfo($attechment->file); |
|
1498 | - |
|
1499 | - if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
1500 | - $sub_dir = stripslashes_deep($file_info['dirname']); |
|
1501 | - |
|
1502 | - $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
1503 | - $uploads_baseurl = $uploads['baseurl']; |
|
1504 | - $uploads_path = $uploads['path']; |
|
1505 | - |
|
1506 | - $file_name = $file_info['basename']; |
|
1507 | - |
|
1508 | - $uploads_url = $uploads_baseurl . $sub_dir; |
|
1509 | - /* |
|
1454 | + /** |
|
1455 | + * Gets the post images. |
|
1456 | + * |
|
1457 | + * @since 1.0.0 |
|
1458 | + * @package GeoDirectory |
|
1459 | + * @global object $wpdb WordPress Database object. |
|
1460 | + * @param int $post_id The post ID. |
|
1461 | + * @param string $img_size Optional. Thumbnail size. |
|
1462 | + * @param bool $no_images Optional. Do you want to return the default image when no image is available? Default: false. |
|
1463 | + * @param bool $add_featured Optional. Do you want to include featured images too? Default: true. |
|
1464 | + * @param int|string $limit Optional. Number of images. |
|
1465 | + * @return array|bool Returns images as an array. Each item is an object. |
|
1466 | + */ |
|
1467 | + function geodir_get_images($post_id = 0, $img_size = '', $no_images = false, $add_featured = true, $limit = '') |
|
1468 | + { |
|
1469 | + global $wpdb; |
|
1470 | + if ($limit) { |
|
1471 | + $limit_q = " LIMIT $limit "; |
|
1472 | + } else { |
|
1473 | + $limit_q = ''; |
|
1474 | + } |
|
1475 | + $not_featured = ''; |
|
1476 | + $sub_dir = ''; |
|
1477 | + if (!$add_featured) |
|
1478 | + $not_featured = " AND is_featured = 0 "; |
|
1479 | + |
|
1480 | + $arrImages = $wpdb->get_results( |
|
1481 | + $wpdb->prepare( |
|
1482 | + "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d" . $not_featured . " ORDER BY menu_order ASC, ID DESC $limit_q ", |
|
1483 | + array('%image%', $post_id) |
|
1484 | + ) |
|
1485 | + ); |
|
1486 | + |
|
1487 | + $counter = 0; |
|
1488 | + $return_arr = array(); |
|
1489 | + |
|
1490 | + if (!empty($arrImages)) { |
|
1491 | + foreach ($arrImages as $attechment) { |
|
1492 | + |
|
1493 | + $img_arr = array(); |
|
1494 | + $img_arr['id'] = $attechment->ID; |
|
1495 | + $img_arr['user_id'] = isset($attechment->user_id) ? $attechment->user_id : 0; |
|
1496 | + |
|
1497 | + $file_info = pathinfo($attechment->file); |
|
1498 | + |
|
1499 | + if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
1500 | + $sub_dir = stripslashes_deep($file_info['dirname']); |
|
1501 | + |
|
1502 | + $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
1503 | + $uploads_baseurl = $uploads['baseurl']; |
|
1504 | + $uploads_path = $uploads['path']; |
|
1505 | + |
|
1506 | + $file_name = $file_info['basename']; |
|
1507 | + |
|
1508 | + $uploads_url = $uploads_baseurl . $sub_dir; |
|
1509 | + /* |
|
1510 | 1510 | * Allows the filter of image src for such things as CDN change. |
1511 | 1511 | * |
1512 | 1512 | * @since 1.5.7 |
@@ -1515,533 +1515,533 @@ discard block |
||
1515 | 1515 | * @param string $uploads_url The server upload directory url. |
1516 | 1516 | * @param string $uploads_baseurl The uploads dir base url. |
1517 | 1517 | */ |
1518 | - $img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl); |
|
1519 | - $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
1520 | - $width = 0; |
|
1521 | - $height = 0; |
|
1522 | - if (is_file($img_arr['path']) && file_exists($img_arr['path'])) { |
|
1523 | - $imagesize = getimagesize($img_arr['path']); |
|
1524 | - $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
1525 | - $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
1526 | - } |
|
1527 | - $img_arr['width'] = $width; |
|
1528 | - $img_arr['height'] = $height; |
|
1529 | - |
|
1530 | - $img_arr['file'] = $file_name; // add the title to the array |
|
1531 | - $img_arr['title'] = $attechment->title; // add the title to the array |
|
1532 | - $img_arr['caption'] = isset($attechment->caption) ? $attechment->caption : ''; // add the caption to the array |
|
1533 | - $img_arr['content'] = $attechment->content; // add the description to the array |
|
1534 | - $img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1. |
|
1535 | - |
|
1536 | - $return_arr[] = (object)$img_arr; |
|
1537 | - |
|
1538 | - $counter++; |
|
1539 | - } |
|
1540 | - //return (object)$return_arr; |
|
1541 | - /** |
|
1542 | - * Filter the images array so things can be changed. |
|
1543 | - * |
|
1544 | - * @since 1.6.20 |
|
1545 | - * @param array $return_arr The array of image objects. |
|
1546 | - */ |
|
1547 | - return apply_filters('geodir_get_images_arr',$return_arr); |
|
1548 | - } else if ($no_images) { |
|
1549 | - $default_img = ''; |
|
1550 | - $default_cat = geodir_get_post_meta($post_id, 'default_category', true); |
|
1551 | - $post_type = get_post_type($post_id); |
|
1552 | - if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) |
|
1553 | - $default_img = $default_catimg['src']; |
|
1554 | - elseif ($no_images) { |
|
1555 | - $default_img = get_option('geodir_listing_no_img'); |
|
1556 | - } |
|
1557 | - |
|
1558 | - if (!empty($default_img)) { |
|
1559 | - $uploads = wp_upload_dir(); // Array of key => value pairs |
|
1518 | + $img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl); |
|
1519 | + $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
1520 | + $width = 0; |
|
1521 | + $height = 0; |
|
1522 | + if (is_file($img_arr['path']) && file_exists($img_arr['path'])) { |
|
1523 | + $imagesize = getimagesize($img_arr['path']); |
|
1524 | + $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
1525 | + $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
1526 | + } |
|
1527 | + $img_arr['width'] = $width; |
|
1528 | + $img_arr['height'] = $height; |
|
1529 | + |
|
1530 | + $img_arr['file'] = $file_name; // add the title to the array |
|
1531 | + $img_arr['title'] = $attechment->title; // add the title to the array |
|
1532 | + $img_arr['caption'] = isset($attechment->caption) ? $attechment->caption : ''; // add the caption to the array |
|
1533 | + $img_arr['content'] = $attechment->content; // add the description to the array |
|
1534 | + $img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1. |
|
1535 | + |
|
1536 | + $return_arr[] = (object)$img_arr; |
|
1537 | + |
|
1538 | + $counter++; |
|
1539 | + } |
|
1540 | + //return (object)$return_arr; |
|
1541 | + /** |
|
1542 | + * Filter the images array so things can be changed. |
|
1543 | + * |
|
1544 | + * @since 1.6.20 |
|
1545 | + * @param array $return_arr The array of image objects. |
|
1546 | + */ |
|
1547 | + return apply_filters('geodir_get_images_arr',$return_arr); |
|
1548 | + } else if ($no_images) { |
|
1549 | + $default_img = ''; |
|
1550 | + $default_cat = geodir_get_post_meta($post_id, 'default_category', true); |
|
1551 | + $post_type = get_post_type($post_id); |
|
1552 | + if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) |
|
1553 | + $default_img = $default_catimg['src']; |
|
1554 | + elseif ($no_images) { |
|
1555 | + $default_img = get_option('geodir_listing_no_img'); |
|
1556 | + } |
|
1557 | + |
|
1558 | + if (!empty($default_img)) { |
|
1559 | + $uploads = wp_upload_dir(); // Array of key => value pairs |
|
1560 | 1560 | |
1561 | - $image_path = $default_img; |
|
1562 | - if (!path_is_absolute($image_path)) { |
|
1563 | - $image_path = str_replace($uploads['baseurl'], $uploads['basedir'], $image_path); |
|
1564 | - } |
|
1565 | - |
|
1566 | - $file_info = pathinfo($default_img); |
|
1567 | - $file_name = $file_info['basename']; |
|
1568 | - |
|
1569 | - $width = ''; |
|
1570 | - $height = ''; |
|
1571 | - if (is_file($image_path) && file_exists($image_path)) { |
|
1572 | - $imagesize = getimagesize($image_path); |
|
1573 | - $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
1574 | - $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
1575 | - } |
|
1561 | + $image_path = $default_img; |
|
1562 | + if (!path_is_absolute($image_path)) { |
|
1563 | + $image_path = str_replace($uploads['baseurl'], $uploads['basedir'], $image_path); |
|
1564 | + } |
|
1565 | + |
|
1566 | + $file_info = pathinfo($default_img); |
|
1567 | + $file_name = $file_info['basename']; |
|
1568 | + |
|
1569 | + $width = ''; |
|
1570 | + $height = ''; |
|
1571 | + if (is_file($image_path) && file_exists($image_path)) { |
|
1572 | + $imagesize = getimagesize($image_path); |
|
1573 | + $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
1574 | + $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
1575 | + } |
|
1576 | 1576 | |
1577 | - $img_arr = array(); |
|
1578 | - $img_arr['src'] = $default_img; |
|
1579 | - $img_arr['path'] = $image_path; |
|
1580 | - $img_arr['width'] = $width; |
|
1581 | - $img_arr['height'] = $height; |
|
1582 | - $img_arr['file'] = $file_name; // add the title to the array |
|
1583 | - $img_arr['title'] = $file_info['filename']; // add the title to the array |
|
1584 | - $img_arr['content'] = $file_info['filename']; // add the description to the array |
|
1585 | - |
|
1586 | - $return_arr[] = (object)$img_arr; |
|
1587 | - |
|
1588 | - /** |
|
1589 | - * Filter the images array so things can be changed. |
|
1590 | - * |
|
1591 | - * @since 1.6.20 |
|
1592 | - * @param array $return_arr The array of image objects. |
|
1593 | - */ |
|
1594 | - return apply_filters('geodir_get_images_arr',$return_arr); |
|
1595 | - } else |
|
1596 | - return false; |
|
1597 | - } |
|
1598 | - } |
|
1577 | + $img_arr = array(); |
|
1578 | + $img_arr['src'] = $default_img; |
|
1579 | + $img_arr['path'] = $image_path; |
|
1580 | + $img_arr['width'] = $width; |
|
1581 | + $img_arr['height'] = $height; |
|
1582 | + $img_arr['file'] = $file_name; // add the title to the array |
|
1583 | + $img_arr['title'] = $file_info['filename']; // add the title to the array |
|
1584 | + $img_arr['content'] = $file_info['filename']; // add the description to the array |
|
1585 | + |
|
1586 | + $return_arr[] = (object)$img_arr; |
|
1587 | + |
|
1588 | + /** |
|
1589 | + * Filter the images array so things can be changed. |
|
1590 | + * |
|
1591 | + * @since 1.6.20 |
|
1592 | + * @param array $return_arr The array of image objects. |
|
1593 | + */ |
|
1594 | + return apply_filters('geodir_get_images_arr',$return_arr); |
|
1595 | + } else |
|
1596 | + return false; |
|
1597 | + } |
|
1598 | + } |
|
1599 | 1599 | } |
1600 | 1600 | |
1601 | 1601 | if (!function_exists('geodir_show_image')) { |
1602 | - /** |
|
1603 | - * Show image using image details. |
|
1604 | - * |
|
1605 | - * @since 1.0.0 |
|
1606 | - * @package GeoDirectory |
|
1607 | - * @param array|object $request Image info either as an array or object. |
|
1608 | - * @param string $size Optional. Thumbnail size. Default: thumbnail. |
|
1609 | - * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. |
|
1610 | - * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true. |
|
1611 | - * @return bool|string Returns image html. |
|
1612 | - */ |
|
1613 | - function geodir_show_image($request = array(), $size = 'thumbnail', $no_image = false, $echo = true) |
|
1614 | - { |
|
1615 | - $image = new stdClass(); |
|
1616 | - |
|
1617 | - $html = ''; |
|
1618 | - if (!empty($request)) { |
|
1619 | - if (!is_object($request)){ |
|
1620 | - $request = (object)$request; |
|
1621 | - } |
|
1622 | - |
|
1623 | - if (isset($request->src) && !isset($request->path)) { |
|
1624 | - $request->path = $request->src; |
|
1625 | - } |
|
1626 | - |
|
1627 | - /* |
|
1602 | + /** |
|
1603 | + * Show image using image details. |
|
1604 | + * |
|
1605 | + * @since 1.0.0 |
|
1606 | + * @package GeoDirectory |
|
1607 | + * @param array|object $request Image info either as an array or object. |
|
1608 | + * @param string $size Optional. Thumbnail size. Default: thumbnail. |
|
1609 | + * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. |
|
1610 | + * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true. |
|
1611 | + * @return bool|string Returns image html. |
|
1612 | + */ |
|
1613 | + function geodir_show_image($request = array(), $size = 'thumbnail', $no_image = false, $echo = true) |
|
1614 | + { |
|
1615 | + $image = new stdClass(); |
|
1616 | + |
|
1617 | + $html = ''; |
|
1618 | + if (!empty($request)) { |
|
1619 | + if (!is_object($request)){ |
|
1620 | + $request = (object)$request; |
|
1621 | + } |
|
1622 | + |
|
1623 | + if (isset($request->src) && !isset($request->path)) { |
|
1624 | + $request->path = $request->src; |
|
1625 | + } |
|
1626 | + |
|
1627 | + /* |
|
1628 | 1628 | * getimagesize() works faster from path than url so we try and get path if we can. |
1629 | 1629 | */ |
1630 | - $upload_dir = wp_upload_dir(); |
|
1631 | - $img_no_http = str_replace(array("http://", "https://"), "", $request->path); |
|
1632 | - $upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']); |
|
1633 | - if (strpos($img_no_http, $upload_no_http) !== false) { |
|
1634 | - $request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path); |
|
1635 | - } |
|
1630 | + $upload_dir = wp_upload_dir(); |
|
1631 | + $img_no_http = str_replace(array("http://", "https://"), "", $request->path); |
|
1632 | + $upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']); |
|
1633 | + if (strpos($img_no_http, $upload_no_http) !== false) { |
|
1634 | + $request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path); |
|
1635 | + } |
|
1636 | 1636 | |
1637 | - $width = 0; |
|
1638 | - $height = 0; |
|
1639 | - if (is_file($request->path) && file_exists($request->path)) { |
|
1640 | - $imagesize = getimagesize($request->path); |
|
1641 | - $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
1642 | - $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
1643 | - } |
|
1644 | - |
|
1645 | - $image->src = $request->src; |
|
1646 | - $image->width = $width; |
|
1647 | - $image->height = $height; |
|
1648 | - |
|
1649 | - $max_size = (object)geodir_get_imagesize($size); |
|
1650 | - |
|
1651 | - if (!is_wp_error($max_size)) { |
|
1652 | - if ($image->width) { |
|
1653 | - if ($image->height >= $image->width) { |
|
1654 | - $width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2); |
|
1655 | - } else if ($image->width < ($max_size->h)) { |
|
1656 | - $width_per = round((($image->width / $max_size->w) * 100), 2); |
|
1657 | - } else |
|
1658 | - $width_per = 100; |
|
1659 | - } |
|
1660 | - |
|
1661 | - if (is_admin() && !isset($_REQUEST['geodir_ajax'])){ |
|
1662 | - $html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '" /></div>'; |
|
1663 | - } else { |
|
1664 | - if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){ |
|
1665 | - $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>'; |
|
1666 | - }else{ |
|
1667 | - //$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>'; |
|
1668 | - //$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>'; |
|
1669 | - $html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>'; |
|
1670 | - |
|
1671 | - } |
|
1672 | - |
|
1673 | - } |
|
1674 | - } |
|
1675 | - } |
|
1676 | - |
|
1677 | - if (!empty($html) && $echo) { |
|
1678 | - echo $html; |
|
1679 | - } elseif (!empty($html)) { |
|
1680 | - return $html; |
|
1681 | - } else |
|
1682 | - return false; |
|
1683 | - } |
|
1684 | -} |
|
1637 | + $width = 0; |
|
1638 | + $height = 0; |
|
1639 | + if (is_file($request->path) && file_exists($request->path)) { |
|
1640 | + $imagesize = getimagesize($request->path); |
|
1641 | + $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
1642 | + $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
1643 | + } |
|
1685 | 1644 | |
1686 | -if (!function_exists('geodir_set_post_terms')) { |
|
1687 | - /** |
|
1688 | - * Set post Categories. |
|
1689 | - * |
|
1690 | - * @since 1.0.0 |
|
1691 | - * @package GeoDirectory |
|
1692 | - * @global object $wpdb WordPress Database object. |
|
1693 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
1694 | - * @param int $post_id The post ID. |
|
1695 | - * @param array $terms An array of term objects. |
|
1696 | - * @param array $tt_ids An array of term taxonomy IDs. |
|
1697 | - * @param string $taxonomy Taxonomy slug. |
|
1698 | - */ |
|
1699 | - function geodir_set_post_terms($post_id, $terms, $tt_ids, $taxonomy) |
|
1700 | - { |
|
1701 | - global $wpdb, $plugin_prefix; |
|
1645 | + $image->src = $request->src; |
|
1646 | + $image->width = $width; |
|
1647 | + $image->height = $height; |
|
1702 | 1648 | |
1703 | - $post_type = get_post_type($post_id); |
|
1649 | + $max_size = (object)geodir_get_imagesize($size); |
|
1704 | 1650 | |
1705 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
1651 | + if (!is_wp_error($max_size)) { |
|
1652 | + if ($image->width) { |
|
1653 | + if ($image->height >= $image->width) { |
|
1654 | + $width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2); |
|
1655 | + } else if ($image->width < ($max_size->h)) { |
|
1656 | + $width_per = round((($image->width / $max_size->w) * 100), 2); |
|
1657 | + } else |
|
1658 | + $width_per = 100; |
|
1659 | + } |
|
1706 | 1660 | |
1707 | - if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) { |
|
1661 | + if (is_admin() && !isset($_REQUEST['geodir_ajax'])){ |
|
1662 | + $html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '" /></div>'; |
|
1663 | + } else { |
|
1664 | + if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){ |
|
1665 | + $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>'; |
|
1666 | + }else{ |
|
1667 | + //$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>'; |
|
1668 | + //$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>'; |
|
1669 | + $html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>'; |
|
1708 | 1670 | |
1709 | - if ($taxonomy == $post_type . '_tags') { |
|
1710 | - if (isset($_POST['action']) && $_POST['action'] == 'inline-save') { |
|
1711 | - geodir_save_post_meta($post_id, 'post_tags', $terms); |
|
1712 | - } |
|
1713 | - } elseif ($taxonomy == $post_type . 'category') { |
|
1714 | - $srcharr = array('"', '\\'); |
|
1715 | - $replarr = array(""", ''); |
|
1671 | + } |
|
1716 | 1672 | |
1717 | - $post_obj = get_post($post_id); |
|
1673 | + } |
|
1674 | + } |
|
1675 | + } |
|
1676 | + |
|
1677 | + if (!empty($html) && $echo) { |
|
1678 | + echo $html; |
|
1679 | + } elseif (!empty($html)) { |
|
1680 | + return $html; |
|
1681 | + } else |
|
1682 | + return false; |
|
1683 | + } |
|
1684 | +} |
|
1718 | 1685 | |
1719 | - $cat_ids = array('0'); |
|
1720 | - if (is_array($tt_ids)) |
|
1721 | - $cat_ids = $tt_ids; |
|
1686 | +if (!function_exists('geodir_set_post_terms')) { |
|
1687 | + /** |
|
1688 | + * Set post Categories. |
|
1689 | + * |
|
1690 | + * @since 1.0.0 |
|
1691 | + * @package GeoDirectory |
|
1692 | + * @global object $wpdb WordPress Database object. |
|
1693 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
1694 | + * @param int $post_id The post ID. |
|
1695 | + * @param array $terms An array of term objects. |
|
1696 | + * @param array $tt_ids An array of term taxonomy IDs. |
|
1697 | + * @param string $taxonomy Taxonomy slug. |
|
1698 | + */ |
|
1699 | + function geodir_set_post_terms($post_id, $terms, $tt_ids, $taxonomy) |
|
1700 | + { |
|
1701 | + global $wpdb, $plugin_prefix; |
|
1702 | + |
|
1703 | + $post_type = get_post_type($post_id); |
|
1704 | + |
|
1705 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
1706 | + |
|
1707 | + if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) { |
|
1708 | + |
|
1709 | + if ($taxonomy == $post_type . '_tags') { |
|
1710 | + if (isset($_POST['action']) && $_POST['action'] == 'inline-save') { |
|
1711 | + geodir_save_post_meta($post_id, 'post_tags', $terms); |
|
1712 | + } |
|
1713 | + } elseif ($taxonomy == $post_type . 'category') { |
|
1714 | + $srcharr = array('"', '\\'); |
|
1715 | + $replarr = array(""", ''); |
|
1722 | 1716 | |
1717 | + $post_obj = get_post($post_id); |
|
1723 | 1718 | |
1724 | - if (!empty($cat_ids)) { |
|
1725 | - $cat_ids_array = $cat_ids; |
|
1726 | - $cat_ids_length = count($cat_ids_array); |
|
1727 | - $cat_ids_format = array_fill(0, $cat_ids_length, '%d'); |
|
1728 | - $format = implode(',', $cat_ids_format); |
|
1719 | + $cat_ids = array('0'); |
|
1720 | + if (is_array($tt_ids)) |
|
1721 | + $cat_ids = $tt_ids; |
|
1729 | 1722 | |
1730 | - $cat_ids_array_del = $cat_ids_array; |
|
1731 | - $cat_ids_array_del[] = $post_id; |
|
1732 | 1723 | |
1733 | - $wpdb->get_var( |
|
1734 | - $wpdb->prepare( |
|
1735 | - "DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ", |
|
1736 | - $cat_ids_array_del |
|
1737 | - ) |
|
1738 | - ); |
|
1724 | + if (!empty($cat_ids)) { |
|
1725 | + $cat_ids_array = $cat_ids; |
|
1726 | + $cat_ids_length = count($cat_ids_array); |
|
1727 | + $cat_ids_format = array_fill(0, $cat_ids_length, '%d'); |
|
1728 | + $format = implode(',', $cat_ids_format); |
|
1739 | 1729 | |
1730 | + $cat_ids_array_del = $cat_ids_array; |
|
1731 | + $cat_ids_array_del[] = $post_id; |
|
1740 | 1732 | |
1741 | - $post_term = $wpdb->get_col( |
|
1742 | - $wpdb->prepare( |
|
1743 | - "SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id", |
|
1744 | - $cat_ids_array |
|
1745 | - ) |
|
1746 | - ); |
|
1733 | + $wpdb->get_var( |
|
1734 | + $wpdb->prepare( |
|
1735 | + "DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ", |
|
1736 | + $cat_ids_array_del |
|
1737 | + ) |
|
1738 | + ); |
|
1747 | 1739 | |
1748 | - } |
|
1749 | 1740 | |
1750 | - $post_marker_json = ''; |
|
1741 | + $post_term = $wpdb->get_col( |
|
1742 | + $wpdb->prepare( |
|
1743 | + "SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id", |
|
1744 | + $cat_ids_array |
|
1745 | + ) |
|
1746 | + ); |
|
1747 | + |
|
1748 | + } |
|
1751 | 1749 | |
1752 | - if (!empty($post_term)): |
|
1750 | + $post_marker_json = ''; |
|
1753 | 1751 | |
1754 | - foreach ($post_term as $cat_id): |
|
1752 | + if (!empty($post_term)): |
|
1755 | 1753 | |
1756 | - $term_icon_url = geodir_get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type); |
|
1757 | - $term_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : ''; |
|
1754 | + foreach ($post_term as $cat_id): |
|
1758 | 1755 | |
1759 | - $post_title = $post_obj->title; |
|
1760 | - $title = str_replace($srcharr, $replarr, $post_title); |
|
1756 | + $term_icon_url = geodir_get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type); |
|
1757 | + $term_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : ''; |
|
1761 | 1758 | |
1762 | - $lat = geodir_get_post_meta($post_id, 'post_latitude', true); |
|
1763 | - $lng = geodir_get_post_meta($post_id, 'post_longitude', true); |
|
1759 | + $post_title = $post_obj->title; |
|
1760 | + $title = str_replace($srcharr, $replarr, $post_title); |
|
1764 | 1761 | |
1765 | - $timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true))); |
|
1766 | - $timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true); |
|
1762 | + $lat = geodir_get_post_meta($post_id, 'post_latitude', true); |
|
1763 | + $lng = geodir_get_post_meta($post_id, 'post_longitude', true); |
|
1767 | 1764 | |
1768 | - $json = '{'; |
|
1769 | - $json .= '"id":"' . $post_id . '",'; |
|
1770 | - $json .= '"lat_pos": "' . $lat . '",'; |
|
1771 | - $json .= '"long_pos": "' . $lng . '",'; |
|
1772 | - $json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",'; |
|
1773 | - $json .= '"icon":"' . $term_icon . '",'; |
|
1774 | - $json .= '"group":"catgroup' . $cat_id . '"'; |
|
1775 | - $json .= '}'; |
|
1765 | + $timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true))); |
|
1766 | + $timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true); |
|
1776 | 1767 | |
1768 | + $json = '{'; |
|
1769 | + $json .= '"id":"' . $post_id . '",'; |
|
1770 | + $json .= '"lat_pos": "' . $lat . '",'; |
|
1771 | + $json .= '"long_pos": "' . $lng . '",'; |
|
1772 | + $json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",'; |
|
1773 | + $json .= '"icon":"' . $term_icon . '",'; |
|
1774 | + $json .= '"group":"catgroup' . $cat_id . '"'; |
|
1775 | + $json .= '}'; |
|
1777 | 1776 | |
1778 | - if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true)) |
|
1779 | - $post_marker_json = $json; |
|
1780 | 1777 | |
1778 | + if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true)) |
|
1779 | + $post_marker_json = $json; |
|
1781 | 1780 | |
1782 | - if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . GEODIR_ICON_TABLE . " WHERE post_id = %d AND cat_id = %d", array($post_id, $cat_id)))) { |
|
1783 | 1781 | |
1784 | - $json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET |
|
1782 | + if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . GEODIR_ICON_TABLE . " WHERE post_id = %d AND cat_id = %d", array($post_id, $cat_id)))) { |
|
1783 | + |
|
1784 | + $json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET |
|
1785 | 1785 | post_title = %s, |
1786 | 1786 | json = %s |
1787 | 1787 | WHERE post_id = %d AND cat_id = %d ", |
1788 | - array($post_title, $json, $post_id, $cat_id)); |
|
1788 | + array($post_title, $json, $post_id, $cat_id)); |
|
1789 | 1789 | |
1790 | - } else { |
|
1790 | + } else { |
|
1791 | 1791 | |
1792 | - $json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET |
|
1792 | + $json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET |
|
1793 | 1793 | post_id = %d, |
1794 | 1794 | post_title = %s, |
1795 | 1795 | cat_id = %d, |
1796 | 1796 | json = %s", |
1797 | - array($post_id, $post_title, $cat_id, $json)); |
|
1797 | + array($post_id, $post_title, $cat_id, $json)); |
|
1798 | 1798 | |
1799 | - } |
|
1799 | + } |
|
1800 | 1800 | |
1801 | - $wpdb->query($json_query); |
|
1801 | + $wpdb->query($json_query); |
|
1802 | 1802 | |
1803 | - endforeach; |
|
1803 | + endforeach; |
|
1804 | 1804 | |
1805 | - endif; |
|
1805 | + endif; |
|
1806 | 1806 | |
1807 | - if (!empty($post_term) && is_array($post_term)) { |
|
1808 | - $categories = implode(',', $post_term); |
|
1807 | + if (!empty($post_term) && is_array($post_term)) { |
|
1808 | + $categories = implode(',', $post_term); |
|
1809 | 1809 | |
1810 | - if ($categories != '' && $categories != 0) $categories = ',' . $categories . ','; |
|
1810 | + if ($categories != '' && $categories != 0) $categories = ',' . $categories . ','; |
|
1811 | 1811 | |
1812 | - if (empty($post_marker_json)) |
|
1813 | - $post_marker_json = isset($json) ? $json : ''; |
|
1812 | + if (empty($post_marker_json)) |
|
1813 | + $post_marker_json = isset($json) ? $json : ''; |
|
1814 | 1814 | |
1815 | - if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) { |
|
1815 | + if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) { |
|
1816 | 1816 | |
1817 | - $wpdb->query( |
|
1818 | - $wpdb->prepare( |
|
1819 | - "UPDATE " . $table . " SET |
|
1817 | + $wpdb->query( |
|
1818 | + $wpdb->prepare( |
|
1819 | + "UPDATE " . $table . " SET |
|
1820 | 1820 | " . $taxonomy . " = %s, |
1821 | 1821 | marker_json = %s |
1822 | 1822 | where post_id = %d", |
1823 | - array($categories, $post_marker_json, $post_id) |
|
1824 | - ) |
|
1825 | - ); |
|
1823 | + array($categories, $post_marker_json, $post_id) |
|
1824 | + ) |
|
1825 | + ); |
|
1826 | 1826 | |
1827 | - if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') { |
|
1827 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') { |
|
1828 | 1828 | |
1829 | - $categories = trim($categories, ','); |
|
1829 | + $categories = trim($categories, ','); |
|
1830 | 1830 | |
1831 | - if ($categories) { |
|
1831 | + if ($categories) { |
|
1832 | 1832 | |
1833 | - $categories = explode(',', $categories); |
|
1833 | + $categories = explode(',', $categories); |
|
1834 | 1834 | |
1835 | - $default_category = geodir_get_post_meta($post_id, 'default_category', true); |
|
1835 | + $default_category = geodir_get_post_meta($post_id, 'default_category', true); |
|
1836 | 1836 | |
1837 | - if (!in_array($default_category, $categories)) { |
|
1837 | + if (!in_array($default_category, $categories)) { |
|
1838 | 1838 | |
1839 | - $wpdb->query( |
|
1840 | - $wpdb->prepare( |
|
1841 | - "UPDATE " . $table . " SET |
|
1839 | + $wpdb->query( |
|
1840 | + $wpdb->prepare( |
|
1841 | + "UPDATE " . $table . " SET |
|
1842 | 1842 | default_category = %s |
1843 | 1843 | where post_id = %d", |
1844 | - array($categories[0], $post_id) |
|
1845 | - ) |
|
1846 | - ); |
|
1844 | + array($categories[0], $post_id) |
|
1845 | + ) |
|
1846 | + ); |
|
1847 | 1847 | |
1848 | - $default_category = $categories[0]; |
|
1848 | + $default_category = $categories[0]; |
|
1849 | 1849 | |
1850 | - } |
|
1850 | + } |
|
1851 | 1851 | |
1852 | - if ($default_category == '') |
|
1853 | - $default_category = $categories[0]; |
|
1852 | + if ($default_category == '') |
|
1853 | + $default_category = $categories[0]; |
|
1854 | 1854 | |
1855 | - geodir_set_postcat_structure($post_id, $taxonomy, $default_category, ''); |
|
1855 | + geodir_set_postcat_structure($post_id, $taxonomy, $default_category, ''); |
|
1856 | 1856 | |
1857 | - } |
|
1857 | + } |
|
1858 | 1858 | |
1859 | - } |
|
1859 | + } |
|
1860 | 1860 | |
1861 | 1861 | |
1862 | - } else { |
|
1862 | + } else { |
|
1863 | 1863 | |
1864 | - $wpdb->query( |
|
1865 | - $wpdb->prepare( |
|
1866 | - "INSERT INTO " . $table . " SET |
|
1864 | + $wpdb->query( |
|
1865 | + $wpdb->prepare( |
|
1866 | + "INSERT INTO " . $table . " SET |
|
1867 | 1867 | post_id = %d, |
1868 | 1868 | " . $taxonomy . " = %s, |
1869 | 1869 | marker_json = %s ", |
1870 | 1870 | |
1871 | - array($post_id, $categories, $post_marker_json) |
|
1872 | - ) |
|
1873 | - ); |
|
1874 | - } |
|
1875 | - } |
|
1876 | - } |
|
1877 | - } |
|
1878 | - } |
|
1871 | + array($post_id, $categories, $post_marker_json) |
|
1872 | + ) |
|
1873 | + ); |
|
1874 | + } |
|
1875 | + } |
|
1876 | + } |
|
1877 | + } |
|
1878 | + } |
|
1879 | 1879 | } |
1880 | 1880 | |
1881 | 1881 | if (!function_exists('geodir_get_infowindow_html')) { |
1882 | - /** |
|
1883 | - * Set post Map Marker info html. |
|
1884 | - * |
|
1885 | - * @since 1.0.0 |
|
1886 | - * @since 1.5.4 Modified to add new action "geodir_infowindow_meta_before". |
|
1887 | - * @since 1.6.16 Changes for disable review stars for certain post type. |
|
1888 | - * @since 1.6.18 Fix: Map marker not showing custom fields in bubble info. |
|
1889 | - * @package GeoDirectory |
|
1890 | - * @global array $geodir_addon_list List of active GeoDirectory extensions. |
|
1891 | - * @global object $gd_session GeoDirectory Session object. |
|
1892 | - * @param object $postinfo_obj The post details object. |
|
1893 | - * @param string $post_preview Is this a post preview?. |
|
1894 | - * @global object $post WordPress Post object. |
|
1895 | - * @return mixed|string|void |
|
1896 | - */ |
|
1897 | - function geodir_get_infowindow_html($postinfo_obj, $post_preview = '') { |
|
1898 | - global $preview, $post, $gd_session; |
|
1899 | - $srcharr = array("'", "/", "-", '"', '\\'); |
|
1900 | - $replarr = array("′", "⁄", "–", "“", ''); |
|
1901 | - |
|
1902 | - if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') { |
|
1903 | - $ID = ''; |
|
1904 | - $plink = ''; |
|
1905 | - |
|
1906 | - if (isset($postinfo_obj->pid)) { |
|
1907 | - $ID = $postinfo_obj->pid; |
|
1908 | - $plink = get_permalink($ID); |
|
1909 | - } |
|
1910 | - |
|
1911 | - $title = str_replace($srcharr, $replarr, ($postinfo_obj->post_title)); |
|
1912 | - $lat = $postinfo_obj->post_latitude; |
|
1913 | - $lng = $postinfo_obj->post_longitude; |
|
1914 | - } else { |
|
1915 | - $ID = $postinfo_obj->post_id; |
|
1916 | - $title = str_replace($srcharr, $replarr, htmlentities($postinfo_obj->post_title, ENT_COMPAT, 'UTF-8')); // fix by Stiofan |
|
1917 | - $title = wp_specialchars_decode($title); // Fixed #post-320722 on 2016-12-08 |
|
1918 | - $plink = get_permalink($ID); |
|
1919 | - $lat = htmlentities(geodir_get_post_meta($ID, 'post_latitude', true)); |
|
1920 | - $lng = htmlentities(geodir_get_post_meta($ID, 'post_longitude', true)); |
|
1921 | - } |
|
1882 | + /** |
|
1883 | + * Set post Map Marker info html. |
|
1884 | + * |
|
1885 | + * @since 1.0.0 |
|
1886 | + * @since 1.5.4 Modified to add new action "geodir_infowindow_meta_before". |
|
1887 | + * @since 1.6.16 Changes for disable review stars for certain post type. |
|
1888 | + * @since 1.6.18 Fix: Map marker not showing custom fields in bubble info. |
|
1889 | + * @package GeoDirectory |
|
1890 | + * @global array $geodir_addon_list List of active GeoDirectory extensions. |
|
1891 | + * @global object $gd_session GeoDirectory Session object. |
|
1892 | + * @param object $postinfo_obj The post details object. |
|
1893 | + * @param string $post_preview Is this a post preview?. |
|
1894 | + * @global object $post WordPress Post object. |
|
1895 | + * @return mixed|string|void |
|
1896 | + */ |
|
1897 | + function geodir_get_infowindow_html($postinfo_obj, $post_preview = '') { |
|
1898 | + global $preview, $post, $gd_session; |
|
1899 | + $srcharr = array("'", "/", "-", '"', '\\'); |
|
1900 | + $replarr = array("′", "⁄", "–", "“", ''); |
|
1901 | + |
|
1902 | + if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') { |
|
1903 | + $ID = ''; |
|
1904 | + $plink = ''; |
|
1905 | + |
|
1906 | + if (isset($postinfo_obj->pid)) { |
|
1907 | + $ID = $postinfo_obj->pid; |
|
1908 | + $plink = get_permalink($ID); |
|
1909 | + } |
|
1910 | + |
|
1911 | + $title = str_replace($srcharr, $replarr, ($postinfo_obj->post_title)); |
|
1912 | + $lat = $postinfo_obj->post_latitude; |
|
1913 | + $lng = $postinfo_obj->post_longitude; |
|
1914 | + } else { |
|
1915 | + $ID = $postinfo_obj->post_id; |
|
1916 | + $title = str_replace($srcharr, $replarr, htmlentities($postinfo_obj->post_title, ENT_COMPAT, 'UTF-8')); // fix by Stiofan |
|
1917 | + $title = wp_specialchars_decode($title); // Fixed #post-320722 on 2016-12-08 |
|
1918 | + $plink = get_permalink($ID); |
|
1919 | + $lat = htmlentities(geodir_get_post_meta($ID, 'post_latitude', true)); |
|
1920 | + $lng = htmlentities(geodir_get_post_meta($ID, 'post_longitude', true)); |
|
1921 | + } |
|
1922 | 1922 | |
1923 | - // Some theme overwrites global gd listing $post |
|
1924 | - if (!empty($ID) && (!empty($post->ID) && $post->ID != $ID) || empty($post)) { |
|
1925 | - $post = geodir_get_post_info($ID); |
|
1926 | - } |
|
1923 | + // Some theme overwrites global gd listing $post |
|
1924 | + if (!empty($ID) && (!empty($post->ID) && $post->ID != $ID) || empty($post)) { |
|
1925 | + $post = geodir_get_post_info($ID); |
|
1926 | + } |
|
1927 | 1927 | |
1928 | - $post_type = $ID ? get_post_type($ID) : ''; |
|
1929 | - |
|
1930 | - // filter field as per price package |
|
1931 | - global $geodir_addon_list; |
|
1932 | - if ($post_type && defined('GEODIRPAYMENT_VERSION')) { |
|
1933 | - $package_id = isset($postinfo_obj->package_id) && $postinfo_obj->package_id ? $postinfo_obj->package_id : NULL; |
|
1934 | - $field_name = 'geodir_contact'; |
|
1935 | - if (!check_field_visibility($package_id, $field_name, $post_type)) { |
|
1936 | - $contact = ''; |
|
1937 | - } |
|
1938 | - |
|
1939 | - $field_name = 'geodir_timing'; |
|
1940 | - if (!check_field_visibility($package_id, $field_name, $post_type)) { |
|
1941 | - $timing = ''; |
|
1942 | - } |
|
1943 | - } |
|
1944 | - |
|
1945 | - if ($lat && $lng) { |
|
1946 | - ob_start(); ?> |
|
1928 | + $post_type = $ID ? get_post_type($ID) : ''; |
|
1929 | + |
|
1930 | + // filter field as per price package |
|
1931 | + global $geodir_addon_list; |
|
1932 | + if ($post_type && defined('GEODIRPAYMENT_VERSION')) { |
|
1933 | + $package_id = isset($postinfo_obj->package_id) && $postinfo_obj->package_id ? $postinfo_obj->package_id : NULL; |
|
1934 | + $field_name = 'geodir_contact'; |
|
1935 | + if (!check_field_visibility($package_id, $field_name, $post_type)) { |
|
1936 | + $contact = ''; |
|
1937 | + } |
|
1938 | + |
|
1939 | + $field_name = 'geodir_timing'; |
|
1940 | + if (!check_field_visibility($package_id, $field_name, $post_type)) { |
|
1941 | + $timing = ''; |
|
1942 | + } |
|
1943 | + } |
|
1944 | + |
|
1945 | + if ($lat && $lng) { |
|
1946 | + ob_start(); ?> |
|
1947 | 1947 | <div class="gd-bubble" style=""> |
1948 | 1948 | <div class="gd-bubble-inside"> |
1949 | 1949 | <?php |
1950 | - $comment_count = ''; |
|
1951 | - $rating_star = ''; |
|
1952 | - if ($ID != '' && $post_type != '' && !geodir_cpt_has_rating_disabled($post_type)) { |
|
1953 | - $rating_star = ''; |
|
1954 | - $comment_count = geodir_get_review_count_total($ID); |
|
1955 | - |
|
1956 | - if (!$preview) { |
|
1957 | - $post_avgratings = geodir_get_post_rating($ID); |
|
1958 | - |
|
1959 | - $rating_star = geodir_get_rating_stars($post_avgratings, $ID, false); |
|
1960 | - |
|
1961 | - /** |
|
1962 | - * Filter to change rating stars |
|
1963 | - * |
|
1964 | - * You can use this filter to change Rating stars. |
|
1965 | - * |
|
1966 | - * @since 1.0.0 |
|
1967 | - * @package GeoDirectory |
|
1968 | - * @param string $rating_star Rating stars. |
|
1969 | - * @param float $post_avgratings Average ratings of the post. |
|
1970 | - * @param int $ID The post ID. |
|
1971 | - */ |
|
1972 | - $rating_star = apply_filters('geodir_review_rating_stars_on_infowindow', $rating_star, $post_avgratings, $ID); |
|
1973 | - } |
|
1974 | - } |
|
1975 | - ?> |
|
1950 | + $comment_count = ''; |
|
1951 | + $rating_star = ''; |
|
1952 | + if ($ID != '' && $post_type != '' && !geodir_cpt_has_rating_disabled($post_type)) { |
|
1953 | + $rating_star = ''; |
|
1954 | + $comment_count = geodir_get_review_count_total($ID); |
|
1955 | + |
|
1956 | + if (!$preview) { |
|
1957 | + $post_avgratings = geodir_get_post_rating($ID); |
|
1958 | + |
|
1959 | + $rating_star = geodir_get_rating_stars($post_avgratings, $ID, false); |
|
1960 | + |
|
1961 | + /** |
|
1962 | + * Filter to change rating stars |
|
1963 | + * |
|
1964 | + * You can use this filter to change Rating stars. |
|
1965 | + * |
|
1966 | + * @since 1.0.0 |
|
1967 | + * @package GeoDirectory |
|
1968 | + * @param string $rating_star Rating stars. |
|
1969 | + * @param float $post_avgratings Average ratings of the post. |
|
1970 | + * @param int $ID The post ID. |
|
1971 | + */ |
|
1972 | + $rating_star = apply_filters('geodir_review_rating_stars_on_infowindow', $rating_star, $post_avgratings, $ID); |
|
1973 | + } |
|
1974 | + } |
|
1975 | + ?> |
|
1976 | 1976 | <div class="geodir-bubble_desc"> |
1977 | 1977 | <h4> |
1978 | 1978 | <a href="<?php if ($plink != '') { |
1979 | - echo $plink; |
|
1980 | - } else { |
|
1981 | - echo 'javascript:void(0);'; |
|
1982 | - } ?>"><?php echo $title; ?></a> |
|
1979 | + echo $plink; |
|
1980 | + } else { |
|
1981 | + echo 'javascript:void(0);'; |
|
1982 | + } ?>"><?php echo $title; ?></a> |
|
1983 | 1983 | </h4> |
1984 | 1984 | <?php |
1985 | - if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') { |
|
1986 | - $post_images = array(); |
|
1987 | - if (!empty($postinfo_obj->post_images)) { |
|
1988 | - $post_images = explode(",", $postinfo_obj->post_images); |
|
1989 | - } |
|
1990 | - |
|
1991 | - if (!empty($post_images)) { |
|
1992 | - ?> |
|
1985 | + if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') { |
|
1986 | + $post_images = array(); |
|
1987 | + if (!empty($postinfo_obj->post_images)) { |
|
1988 | + $post_images = explode(",", $postinfo_obj->post_images); |
|
1989 | + } |
|
1990 | + |
|
1991 | + if (!empty($post_images)) { |
|
1992 | + ?> |
|
1993 | 1993 | <div class="geodir-bubble_image"><a href="<?php if ($plink != '') { |
1994 | - echo $plink; |
|
1995 | - } else { |
|
1996 | - echo 'javascript:void(0);'; |
|
1997 | - } ?>"><img alt="bubble image" style="max-height:50px;" |
|
1994 | + echo $plink; |
|
1995 | + } else { |
|
1996 | + echo 'javascript:void(0);'; |
|
1997 | + } ?>"><img alt="bubble image" style="max-height:50px;" |
|
1998 | 1998 | src="<?php echo $post_images[0]; ?>"/></a></div> |
1999 | 1999 | <?php |
2000 | - }else{ |
|
2001 | - echo '<div class="geodir-bubble_image"></div>'; |
|
2002 | - } |
|
2003 | - } else { |
|
2004 | - if ($image = geodir_show_featured_image($ID, 'widget-thumb', true, false, $postinfo_obj->featured_image)) { |
|
2005 | - ?> |
|
2000 | + }else{ |
|
2001 | + echo '<div class="geodir-bubble_image"></div>'; |
|
2002 | + } |
|
2003 | + } else { |
|
2004 | + if ($image = geodir_show_featured_image($ID, 'widget-thumb', true, false, $postinfo_obj->featured_image)) { |
|
2005 | + ?> |
|
2006 | 2006 | <div class="geodir-bubble_image"><a href="<?php echo $plink; ?>"><?php echo $image; ?></a></div> |
2007 | 2007 | <?php |
2008 | - }else{ |
|
2009 | - echo '<div class="geodir-bubble_image"></div>'; |
|
2010 | - } |
|
2011 | - } |
|
2012 | - ?> |
|
2008 | + }else{ |
|
2009 | + echo '<div class="geodir-bubble_image"></div>'; |
|
2010 | + } |
|
2011 | + } |
|
2012 | + ?> |
|
2013 | 2013 | <div class="geodir-bubble-meta-side"> |
2014 | 2014 | <?php |
2015 | - /** |
|
2016 | - * Fires before the meta info in the map info window. |
|
2017 | - * |
|
2018 | - * This can be used to add more info to the map info window before the normal meta info. |
|
2019 | - * |
|
2020 | - * @since 1.5.4 |
|
2021 | - * @param int $ID The post id. |
|
2022 | - * @param object $postinfo_obj The posts info as an object. |
|
2023 | - * @param bool|string $post_preview True if currently in post preview page. Empty string if not. * |
|
2024 | - */ |
|
2025 | - do_action('geodir_infowindow_meta_before', $ID, $postinfo_obj, $post_preview); |
|
2026 | - |
|
2027 | - echo geodir_show_listing_info('mapbubble'); |
|
2028 | - |
|
2029 | - /** |
|
2030 | - * Fires after the meta info in the map info window. |
|
2031 | - * |
|
2032 | - * This can be used to add more info to the map info window after the normal meta info. |
|
2033 | - * |
|
2034 | - * @since 1.4.2 |
|
2035 | - * @param object $postinfo_obj The posts info as an object. |
|
2036 | - * @param bool|string $post_preview True if currently in post preview page. Empty string if not. * |
|
2037 | - */ |
|
2038 | - do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview ); |
|
2039 | - ?> |
|
2015 | + /** |
|
2016 | + * Fires before the meta info in the map info window. |
|
2017 | + * |
|
2018 | + * This can be used to add more info to the map info window before the normal meta info. |
|
2019 | + * |
|
2020 | + * @since 1.5.4 |
|
2021 | + * @param int $ID The post id. |
|
2022 | + * @param object $postinfo_obj The posts info as an object. |
|
2023 | + * @param bool|string $post_preview True if currently in post preview page. Empty string if not. * |
|
2024 | + */ |
|
2025 | + do_action('geodir_infowindow_meta_before', $ID, $postinfo_obj, $post_preview); |
|
2026 | + |
|
2027 | + echo geodir_show_listing_info('mapbubble'); |
|
2028 | + |
|
2029 | + /** |
|
2030 | + * Fires after the meta info in the map info window. |
|
2031 | + * |
|
2032 | + * This can be used to add more info to the map info window after the normal meta info. |
|
2033 | + * |
|
2034 | + * @since 1.4.2 |
|
2035 | + * @param object $postinfo_obj The posts info as an object. |
|
2036 | + * @param bool|string $post_preview True if currently in post preview page. Empty string if not. * |
|
2037 | + */ |
|
2038 | + do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview ); |
|
2039 | + ?> |
|
2040 | 2040 | </div> |
2041 | 2041 | <?php |
2042 | - if ($ID) { |
|
2043 | - $post_author = isset($postinfo_obj->post_author) ? $postinfo_obj->post_author : get_post_field('post_author', $ID); |
|
2044 | - ?> |
|
2042 | + if ($ID) { |
|
2043 | + $post_author = isset($postinfo_obj->post_author) ? $postinfo_obj->post_author : get_post_field('post_author', $ID); |
|
2044 | + ?> |
|
2045 | 2045 | <div class="geodir-bubble-meta-fade"></div> |
2046 | 2046 | <div class="geodir-bubble-meta-bottom"> |
2047 | 2047 | <?php if ($rating_star != '') { ?> |
@@ -2057,69 +2057,69 @@ discard block |
||
2057 | 2057 | </div> |
2058 | 2058 | </div> |
2059 | 2059 | <?php |
2060 | - $html = ob_get_clean(); |
|
2061 | - /** |
|
2062 | - * Filter to change infowindow html |
|
2063 | - * |
|
2064 | - * You can use this filter to change infowindow html. |
|
2065 | - * |
|
2066 | - * @since 1.0.0 |
|
2067 | - * @package GeoDirectory |
|
2068 | - * @param string $html Infowindow html. |
|
2069 | - * @param object $postinfo_obj The Post object. |
|
2070 | - * @param bool|string $post_preview Is this a post preview? |
|
2071 | - */ |
|
2072 | - $html = apply_filters('geodir_custom_infowindow_html', $html, $postinfo_obj, $post_preview); |
|
2073 | - return $html; |
|
2074 | - } |
|
2075 | - } |
|
2060 | + $html = ob_get_clean(); |
|
2061 | + /** |
|
2062 | + * Filter to change infowindow html |
|
2063 | + * |
|
2064 | + * You can use this filter to change infowindow html. |
|
2065 | + * |
|
2066 | + * @since 1.0.0 |
|
2067 | + * @package GeoDirectory |
|
2068 | + * @param string $html Infowindow html. |
|
2069 | + * @param object $postinfo_obj The Post object. |
|
2070 | + * @param bool|string $post_preview Is this a post preview? |
|
2071 | + */ |
|
2072 | + $html = apply_filters('geodir_custom_infowindow_html', $html, $postinfo_obj, $post_preview); |
|
2073 | + return $html; |
|
2074 | + } |
|
2075 | + } |
|
2076 | 2076 | } |
2077 | 2077 | |
2078 | 2078 | |
2079 | 2079 | if (!function_exists('geodir_new_post_default_status')) { |
2080 | - /** |
|
2081 | - * Default post status for new posts. |
|
2082 | - * |
|
2083 | - * @since 1.0.0 |
|
2084 | - * @package GeoDirectory |
|
2085 | - * @return string Returns the default post status for new posts. Ex: draft, publish etc. |
|
2086 | - */ |
|
2087 | - function geodir_new_post_default_status() |
|
2088 | - { |
|
2089 | - if (get_option('geodir_new_post_default_status')) |
|
2090 | - return get_option('geodir_new_post_default_status'); |
|
2091 | - else |
|
2092 | - return 'publish'; |
|
2093 | - |
|
2094 | - } |
|
2080 | + /** |
|
2081 | + * Default post status for new posts. |
|
2082 | + * |
|
2083 | + * @since 1.0.0 |
|
2084 | + * @package GeoDirectory |
|
2085 | + * @return string Returns the default post status for new posts. Ex: draft, publish etc. |
|
2086 | + */ |
|
2087 | + function geodir_new_post_default_status() |
|
2088 | + { |
|
2089 | + if (get_option('geodir_new_post_default_status')) |
|
2090 | + return get_option('geodir_new_post_default_status'); |
|
2091 | + else |
|
2092 | + return 'publish'; |
|
2093 | + |
|
2094 | + } |
|
2095 | 2095 | } |
2096 | 2096 | |
2097 | 2097 | if (!function_exists('geodir_change_post_status')) { |
2098 | - /** |
|
2099 | - * Change post status of a post. |
|
2100 | - * |
|
2101 | - * @global object $wpdb WordPress Database object. |
|
2102 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
2103 | - * @param int|string $post_id The post ID. |
|
2104 | - * @param string $status New post status. Ex: draft, publish etc. |
|
2105 | - */ |
|
2106 | - function geodir_change_post_status($post_id = '', $status = '') |
|
2107 | - { |
|
2108 | - global $wpdb, $plugin_prefix; |
|
2109 | - |
|
2110 | - $post_type = get_post_type($post_id); |
|
2111 | - |
|
2112 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
2113 | - |
|
2114 | - $wpdb->query( |
|
2115 | - $wpdb->prepare( |
|
2116 | - "UPDATE " . $table . " SET post_status=%s WHERE post_id=%d", |
|
2117 | - array($status, $post_id) |
|
2118 | - ) |
|
2119 | - ); |
|
2120 | - |
|
2121 | - |
|
2122 | - } |
|
2098 | + /** |
|
2099 | + * Change post status of a post. |
|
2100 | + * |
|
2101 | + * @global object $wpdb WordPress Database object. |
|
2102 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
2103 | + * @param int|string $post_id The post ID. |
|
2104 | + * @param string $status New post status. Ex: draft, publish etc. |
|
2105 | + */ |
|
2106 | + function geodir_change_post_status($post_id = '', $status = '') |
|
2107 | + { |
|
2108 | + global $wpdb, $plugin_prefix; |
|
2109 | + |
|
2110 | + $post_type = get_post_type($post_id); |
|
2111 | + |
|
2112 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
2113 | + |
|
2114 | + $wpdb->query( |
|
2115 | + $wpdb->prepare( |
|
2116 | + "UPDATE " . $table . " SET post_status=%s WHERE post_id=%d", |
|
2117 | + array($status, $post_id) |
|
2118 | + ) |
|
2119 | + ); |
|
2120 | + |
|
2121 | + |
|
2122 | + } |
|
2123 | 2123 | } |
2124 | 2124 | |
2125 | 2125 | /** |
@@ -2133,13 +2133,13 @@ discard block |
||
2133 | 2133 | */ |
2134 | 2134 | function geodir_set_post_status($pid, $status) |
2135 | 2135 | { |
2136 | - if ($pid) { |
|
2137 | - global $wpdb; |
|
2138 | - $my_post = array(); |
|
2139 | - $my_post['post_status'] = $status; |
|
2140 | - $my_post['ID'] = $pid; |
|
2141 | - $last_postid = wp_update_post($my_post); |
|
2142 | - } |
|
2136 | + if ($pid) { |
|
2137 | + global $wpdb; |
|
2138 | + $my_post = array(); |
|
2139 | + $my_post['post_status'] = $status; |
|
2140 | + $my_post['ID'] = $pid; |
|
2141 | + $last_postid = wp_update_post($my_post); |
|
2142 | + } |
|
2143 | 2143 | } |
2144 | 2144 | |
2145 | 2145 | |
@@ -2155,384 +2155,384 @@ discard block |
||
2155 | 2155 | */ |
2156 | 2156 | function geodir_update_poststatus($new_status, $old_status, $post) |
2157 | 2157 | { |
2158 | - global $wpdb; |
|
2158 | + global $wpdb; |
|
2159 | 2159 | |
2160 | - $geodir_posttypes = geodir_get_posttypes(); |
|
2160 | + $geodir_posttypes = geodir_get_posttypes(); |
|
2161 | 2161 | |
2162 | - if (!wp_is_post_revision($post->ID) && in_array($post->post_type, $geodir_posttypes)) { |
|
2162 | + if (!wp_is_post_revision($post->ID) && in_array($post->post_type, $geodir_posttypes)) { |
|
2163 | 2163 | |
2164 | - geodir_change_post_status($post->ID, $new_status); |
|
2165 | - } |
|
2164 | + geodir_change_post_status($post->ID, $new_status); |
|
2165 | + } |
|
2166 | 2166 | } |
2167 | 2167 | |
2168 | 2168 | |
2169 | 2169 | if (!function_exists('geodir_update_listing_info')) { |
2170 | - /** |
|
2171 | - * Update post info. |
|
2172 | - * |
|
2173 | - * @since 1.0.0 |
|
2174 | - * @package GeoDirectory |
|
2175 | - * @global object $wpdb WordPress Database object. |
|
2176 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
2177 | - * @param int $updatingpost The updating post ID. |
|
2178 | - * @param int $temppost The temporary post ID. |
|
2179 | - * @todo fix post_id variable |
|
2180 | - */ |
|
2181 | - function geodir_update_listing_info($updatingpost, $temppost) |
|
2182 | - { |
|
2183 | - |
|
2184 | - global $wpdb, $plugin_prefix; |
|
2185 | - |
|
2186 | - $post_type = get_post_type($post_id); |
|
2187 | - |
|
2188 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
2189 | - |
|
2190 | - $wpdb->query( |
|
2191 | - $wpdb->prepare( |
|
2192 | - "UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d", |
|
2193 | - array($updatingpost, $temppost) |
|
2194 | - ) |
|
2195 | - ); |
|
2196 | - |
|
2197 | - $wpdb->query( |
|
2198 | - $wpdb->prepare( |
|
2199 | - "UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d", |
|
2200 | - array($updatingpost, $temppost) |
|
2201 | - ) |
|
2202 | - ); |
|
2203 | - |
|
2204 | - /* Update Attachments*/ |
|
2205 | - |
|
2206 | - $wpdb->query( |
|
2207 | - $wpdb->prepare( |
|
2208 | - "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d", |
|
2209 | - array($updatingpost, $temppost) |
|
2210 | - ) |
|
2211 | - ); |
|
2212 | - |
|
2213 | - } |
|
2170 | + /** |
|
2171 | + * Update post info. |
|
2172 | + * |
|
2173 | + * @since 1.0.0 |
|
2174 | + * @package GeoDirectory |
|
2175 | + * @global object $wpdb WordPress Database object. |
|
2176 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
2177 | + * @param int $updatingpost The updating post ID. |
|
2178 | + * @param int $temppost The temporary post ID. |
|
2179 | + * @todo fix post_id variable |
|
2180 | + */ |
|
2181 | + function geodir_update_listing_info($updatingpost, $temppost) |
|
2182 | + { |
|
2183 | + |
|
2184 | + global $wpdb, $plugin_prefix; |
|
2185 | + |
|
2186 | + $post_type = get_post_type($post_id); |
|
2187 | + |
|
2188 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
2189 | + |
|
2190 | + $wpdb->query( |
|
2191 | + $wpdb->prepare( |
|
2192 | + "UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d", |
|
2193 | + array($updatingpost, $temppost) |
|
2194 | + ) |
|
2195 | + ); |
|
2196 | + |
|
2197 | + $wpdb->query( |
|
2198 | + $wpdb->prepare( |
|
2199 | + "UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d", |
|
2200 | + array($updatingpost, $temppost) |
|
2201 | + ) |
|
2202 | + ); |
|
2203 | + |
|
2204 | + /* Update Attachments*/ |
|
2205 | + |
|
2206 | + $wpdb->query( |
|
2207 | + $wpdb->prepare( |
|
2208 | + "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d", |
|
2209 | + array($updatingpost, $temppost) |
|
2210 | + ) |
|
2211 | + ); |
|
2212 | + |
|
2213 | + } |
|
2214 | 2214 | } |
2215 | 2215 | |
2216 | 2216 | |
2217 | 2217 | if (!function_exists('geodir_delete_listing_info')) { |
2218 | - /** |
|
2219 | - * Delete Listing info from details table for the given post id. |
|
2220 | - * |
|
2221 | - * @since 1.0.0 |
|
2222 | - * @package GeoDirectory |
|
2223 | - * @global object $wpdb WordPress Database object. |
|
2224 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
2225 | - * @param int $deleted_postid The post ID. |
|
2226 | - * @param bool $force Optional. Do you want to force delete it? Default: false. |
|
2227 | - * @return bool|void |
|
2228 | - */ |
|
2229 | - function geodir_delete_listing_info($deleted_postid, $force = false) |
|
2230 | - { |
|
2231 | - global $wpdb, $plugin_prefix; |
|
2232 | - |
|
2233 | - // check for multisite deletions |
|
2234 | - if (strpos($plugin_prefix, $wpdb->prefix) !== false) { |
|
2235 | - } else { |
|
2236 | - return; |
|
2237 | - } |
|
2238 | - |
|
2239 | - $post_type = get_post_type($deleted_postid); |
|
2240 | - |
|
2241 | - $all_postypes = geodir_get_posttypes(); |
|
2242 | - |
|
2243 | - if (!in_array($post_type, $all_postypes)) |
|
2244 | - return false; |
|
2245 | - |
|
2246 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
2247 | - |
|
2248 | - /* Delete custom post meta*/ |
|
2249 | - $wpdb->query( |
|
2250 | - $wpdb->prepare( |
|
2251 | - "DELETE FROM " . $table . " WHERE `post_id` = %d", |
|
2252 | - array($deleted_postid) |
|
2253 | - ) |
|
2254 | - ); |
|
2255 | - |
|
2256 | - /* Delete post map icons*/ |
|
2257 | - |
|
2258 | - $wpdb->query( |
|
2259 | - $wpdb->prepare( |
|
2260 | - "DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d", |
|
2261 | - array($deleted_postid) |
|
2262 | - ) |
|
2263 | - ); |
|
2264 | - |
|
2265 | - /* Delete Attachments*/ |
|
2266 | - $postcurr_images = geodir_get_images($deleted_postid); |
|
2267 | - |
|
2268 | - $wpdb->query( |
|
2269 | - $wpdb->prepare( |
|
2270 | - "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d", |
|
2271 | - array($deleted_postid) |
|
2272 | - ) |
|
2273 | - ); |
|
2274 | - geodir_remove_attachments($postcurr_images); |
|
2275 | - |
|
2276 | - } |
|
2218 | + /** |
|
2219 | + * Delete Listing info from details table for the given post id. |
|
2220 | + * |
|
2221 | + * @since 1.0.0 |
|
2222 | + * @package GeoDirectory |
|
2223 | + * @global object $wpdb WordPress Database object. |
|
2224 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
2225 | + * @param int $deleted_postid The post ID. |
|
2226 | + * @param bool $force Optional. Do you want to force delete it? Default: false. |
|
2227 | + * @return bool|void |
|
2228 | + */ |
|
2229 | + function geodir_delete_listing_info($deleted_postid, $force = false) |
|
2230 | + { |
|
2231 | + global $wpdb, $plugin_prefix; |
|
2232 | + |
|
2233 | + // check for multisite deletions |
|
2234 | + if (strpos($plugin_prefix, $wpdb->prefix) !== false) { |
|
2235 | + } else { |
|
2236 | + return; |
|
2237 | + } |
|
2238 | + |
|
2239 | + $post_type = get_post_type($deleted_postid); |
|
2240 | + |
|
2241 | + $all_postypes = geodir_get_posttypes(); |
|
2242 | + |
|
2243 | + if (!in_array($post_type, $all_postypes)) |
|
2244 | + return false; |
|
2245 | + |
|
2246 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
2247 | + |
|
2248 | + /* Delete custom post meta*/ |
|
2249 | + $wpdb->query( |
|
2250 | + $wpdb->prepare( |
|
2251 | + "DELETE FROM " . $table . " WHERE `post_id` = %d", |
|
2252 | + array($deleted_postid) |
|
2253 | + ) |
|
2254 | + ); |
|
2255 | + |
|
2256 | + /* Delete post map icons*/ |
|
2257 | + |
|
2258 | + $wpdb->query( |
|
2259 | + $wpdb->prepare( |
|
2260 | + "DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d", |
|
2261 | + array($deleted_postid) |
|
2262 | + ) |
|
2263 | + ); |
|
2264 | + |
|
2265 | + /* Delete Attachments*/ |
|
2266 | + $postcurr_images = geodir_get_images($deleted_postid); |
|
2267 | + |
|
2268 | + $wpdb->query( |
|
2269 | + $wpdb->prepare( |
|
2270 | + "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d", |
|
2271 | + array($deleted_postid) |
|
2272 | + ) |
|
2273 | + ); |
|
2274 | + geodir_remove_attachments($postcurr_images); |
|
2275 | + |
|
2276 | + } |
|
2277 | 2277 | } |
2278 | 2278 | |
2279 | 2279 | |
2280 | 2280 | if (!function_exists('geodir_add_to_favorite')) { |
2281 | - /** |
|
2282 | - * This function would add listing to favorite listing. |
|
2283 | - * |
|
2284 | - * @since 1.0.0 |
|
2285 | - * @package GeoDirectory |
|
2286 | - * @global object $current_user Current user object. |
|
2287 | - * @param int $post_id The post ID. |
|
2288 | - */ |
|
2289 | - function geodir_add_to_favorite($post_id) |
|
2290 | - { |
|
2291 | - |
|
2292 | - global $current_user; |
|
2293 | - |
|
2294 | - /** |
|
2295 | - * Filter to modify "Unfavorite" text |
|
2296 | - * |
|
2297 | - * You can use this filter to rename "Unfavorite" text to something else. |
|
2298 | - * |
|
2299 | - * @since 1.0.0 |
|
2300 | - * @package GeoDirectory |
|
2301 | - */ |
|
2302 | - $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT); |
|
2303 | - |
|
2304 | - /** |
|
2305 | - * Filter to modify "Remove from Favorites" text |
|
2306 | - * |
|
2307 | - * You can use this filter to rename "Remove from Favorites" text to something else. |
|
2308 | - * |
|
2309 | - * @since 1.0.0 |
|
2310 | - * @package GeoDirectory |
|
2311 | - */ |
|
2312 | - $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT); |
|
2313 | - |
|
2314 | - /** |
|
2315 | - * Filter to modify "fa fa-heart" icon |
|
2316 | - * |
|
2317 | - * You can use this filter to change "fa fa-heart" icon to something else. |
|
2318 | - * |
|
2319 | - * @since 1.0.0 |
|
2320 | - * @package GeoDirectory |
|
2321 | - */ |
|
2322 | - $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart'); |
|
2323 | - |
|
2324 | - $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true); |
|
2325 | - $user_meta_data = !empty($user_meta_data) && is_array($user_meta_data) ? $user_meta_data : array(); |
|
2326 | - |
|
2327 | - if (empty($user_meta_data) || (!empty($user_meta_data) && !in_array($post_id, $user_meta_data))) { |
|
2328 | - $user_meta_data[] = $post_id; |
|
2329 | - } |
|
2330 | - |
|
2331 | - update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data); |
|
2281 | + /** |
|
2282 | + * This function would add listing to favorite listing. |
|
2283 | + * |
|
2284 | + * @since 1.0.0 |
|
2285 | + * @package GeoDirectory |
|
2286 | + * @global object $current_user Current user object. |
|
2287 | + * @param int $post_id The post ID. |
|
2288 | + */ |
|
2289 | + function geodir_add_to_favorite($post_id) |
|
2290 | + { |
|
2291 | + |
|
2292 | + global $current_user; |
|
2293 | + |
|
2294 | + /** |
|
2295 | + * Filter to modify "Unfavorite" text |
|
2296 | + * |
|
2297 | + * You can use this filter to rename "Unfavorite" text to something else. |
|
2298 | + * |
|
2299 | + * @since 1.0.0 |
|
2300 | + * @package GeoDirectory |
|
2301 | + */ |
|
2302 | + $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT); |
|
2303 | + |
|
2304 | + /** |
|
2305 | + * Filter to modify "Remove from Favorites" text |
|
2306 | + * |
|
2307 | + * You can use this filter to rename "Remove from Favorites" text to something else. |
|
2308 | + * |
|
2309 | + * @since 1.0.0 |
|
2310 | + * @package GeoDirectory |
|
2311 | + */ |
|
2312 | + $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT); |
|
2313 | + |
|
2314 | + /** |
|
2315 | + * Filter to modify "fa fa-heart" icon |
|
2316 | + * |
|
2317 | + * You can use this filter to change "fa fa-heart" icon to something else. |
|
2318 | + * |
|
2319 | + * @since 1.0.0 |
|
2320 | + * @package GeoDirectory |
|
2321 | + */ |
|
2322 | + $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart'); |
|
2323 | + |
|
2324 | + $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true); |
|
2325 | + $user_meta_data = !empty($user_meta_data) && is_array($user_meta_data) ? $user_meta_data : array(); |
|
2326 | + |
|
2327 | + if (empty($user_meta_data) || (!empty($user_meta_data) && !in_array($post_id, $user_meta_data))) { |
|
2328 | + $user_meta_data[] = $post_id; |
|
2329 | + } |
|
2330 | + |
|
2331 | + update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data); |
|
2332 | + |
|
2333 | + /** |
|
2334 | + * Called before adding the post from favourites. |
|
2335 | + * |
|
2336 | + * @since 1.0.0 |
|
2337 | + * @package GeoDirectory |
|
2338 | + * @param int $post_id The post ID. |
|
2339 | + */ |
|
2340 | + do_action('geodir_before_add_from_favorite', $post_id); |
|
2341 | + |
|
2342 | + echo '<a href="javascript:void(0);" title="' . $remove_favourite_text . '" class="geodir-removetofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'remove\');"><i class="'. $favourite_icon .'"></i> ' . $unfavourite_text . '</a>'; |
|
2343 | + |
|
2344 | + /** |
|
2345 | + * Called after adding the post from favourites. |
|
2346 | + * |
|
2347 | + * @since 1.0.0 |
|
2348 | + * @package GeoDirectory |
|
2349 | + * @param int $post_id The post ID. |
|
2350 | + */ |
|
2351 | + do_action('geodir_after_add_from_favorite', $post_id); |
|
2332 | 2352 | |
2333 | - /** |
|
2334 | - * Called before adding the post from favourites. |
|
2335 | - * |
|
2336 | - * @since 1.0.0 |
|
2337 | - * @package GeoDirectory |
|
2338 | - * @param int $post_id The post ID. |
|
2339 | - */ |
|
2340 | - do_action('geodir_before_add_from_favorite', $post_id); |
|
2341 | - |
|
2342 | - echo '<a href="javascript:void(0);" title="' . $remove_favourite_text . '" class="geodir-removetofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'remove\');"><i class="'. $favourite_icon .'"></i> ' . $unfavourite_text . '</a>'; |
|
2343 | - |
|
2344 | - /** |
|
2345 | - * Called after adding the post from favourites. |
|
2346 | - * |
|
2347 | - * @since 1.0.0 |
|
2348 | - * @package GeoDirectory |
|
2349 | - * @param int $post_id The post ID. |
|
2350 | - */ |
|
2351 | - do_action('geodir_after_add_from_favorite', $post_id); |
|
2352 | - |
|
2353 | - } |
|
2353 | + } |
|
2354 | 2354 | } |
2355 | 2355 | |
2356 | 2356 | if (!function_exists('geodir_remove_from_favorite')) { |
2357 | - /** |
|
2358 | - * This function would remove the favourited property earlier. |
|
2359 | - * |
|
2360 | - * @since 1.0.0 |
|
2361 | - * @package GeoDirectory |
|
2362 | - * @global object $current_user Current user object. |
|
2363 | - * @param int $post_id The post ID. |
|
2364 | - */ |
|
2365 | - function geodir_remove_from_favorite($post_id) |
|
2366 | - { |
|
2367 | - global $current_user; |
|
2368 | - |
|
2369 | - /** |
|
2370 | - * Filter to modify "Add to Favorites" text |
|
2371 | - * |
|
2372 | - * You can use this filter to rename "Add to Favorites" text to something else. |
|
2373 | - * |
|
2374 | - * @since 1.0.0 |
|
2375 | - * @package GeoDirectory |
|
2376 | - */ |
|
2377 | - $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT); |
|
2378 | - |
|
2379 | - /** |
|
2380 | - * Filter to modify "Favourite" text |
|
2381 | - * |
|
2382 | - * You can use this filter to rename "Favourite" text to something else. |
|
2383 | - * |
|
2384 | - * @since 1.0.0 |
|
2385 | - * @package GeoDirectory |
|
2386 | - */ |
|
2387 | - $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT); |
|
2388 | - |
|
2389 | - /** |
|
2390 | - * Filter to modify "fa fa-heart" icon |
|
2391 | - * |
|
2392 | - * You can use this filter to change "fa fa-heart" icon to something else. |
|
2393 | - * |
|
2394 | - * @since 1.0.0 |
|
2395 | - * @package GeoDirectory |
|
2396 | - */ |
|
2397 | - $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart'); |
|
2398 | - |
|
2399 | - $user_meta_data = array(); |
|
2400 | - $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true); |
|
2401 | - |
|
2402 | - if (!empty($user_meta_data)) { |
|
2403 | - |
|
2404 | - if (($key = array_search($post_id, $user_meta_data)) !== false) { |
|
2405 | - unset($user_meta_data[$key]); |
|
2406 | - } |
|
2357 | + /** |
|
2358 | + * This function would remove the favourited property earlier. |
|
2359 | + * |
|
2360 | + * @since 1.0.0 |
|
2361 | + * @package GeoDirectory |
|
2362 | + * @global object $current_user Current user object. |
|
2363 | + * @param int $post_id The post ID. |
|
2364 | + */ |
|
2365 | + function geodir_remove_from_favorite($post_id) |
|
2366 | + { |
|
2367 | + global $current_user; |
|
2368 | + |
|
2369 | + /** |
|
2370 | + * Filter to modify "Add to Favorites" text |
|
2371 | + * |
|
2372 | + * You can use this filter to rename "Add to Favorites" text to something else. |
|
2373 | + * |
|
2374 | + * @since 1.0.0 |
|
2375 | + * @package GeoDirectory |
|
2376 | + */ |
|
2377 | + $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT); |
|
2378 | + |
|
2379 | + /** |
|
2380 | + * Filter to modify "Favourite" text |
|
2381 | + * |
|
2382 | + * You can use this filter to rename "Favourite" text to something else. |
|
2383 | + * |
|
2384 | + * @since 1.0.0 |
|
2385 | + * @package GeoDirectory |
|
2386 | + */ |
|
2387 | + $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT); |
|
2388 | + |
|
2389 | + /** |
|
2390 | + * Filter to modify "fa fa-heart" icon |
|
2391 | + * |
|
2392 | + * You can use this filter to change "fa fa-heart" icon to something else. |
|
2393 | + * |
|
2394 | + * @since 1.0.0 |
|
2395 | + * @package GeoDirectory |
|
2396 | + */ |
|
2397 | + $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart'); |
|
2398 | + |
|
2399 | + $user_meta_data = array(); |
|
2400 | + $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true); |
|
2401 | + |
|
2402 | + if (!empty($user_meta_data)) { |
|
2403 | + |
|
2404 | + if (($key = array_search($post_id, $user_meta_data)) !== false) { |
|
2405 | + unset($user_meta_data[$key]); |
|
2406 | + } |
|
2407 | 2407 | |
2408 | - } |
|
2408 | + } |
|
2409 | 2409 | |
2410 | - update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data); |
|
2410 | + update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data); |
|
2411 | 2411 | |
2412 | - /** |
|
2413 | - * Called before removing the post from favourites. |
|
2414 | - * |
|
2415 | - * @since 1.0.0 |
|
2416 | - * @package GeoDirectory |
|
2417 | - * @param int $post_id The post ID. |
|
2418 | - */ |
|
2419 | - do_action('geodir_before_remove_from_favorite', $post_id); |
|
2412 | + /** |
|
2413 | + * Called before removing the post from favourites. |
|
2414 | + * |
|
2415 | + * @since 1.0.0 |
|
2416 | + * @package GeoDirectory |
|
2417 | + * @param int $post_id The post ID. |
|
2418 | + */ |
|
2419 | + do_action('geodir_before_remove_from_favorite', $post_id); |
|
2420 | 2420 | |
2421 | - echo '<a href="javascript:void(0);" title="' . $add_favourite_text . '" class="geodir-addtofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'add\');"><i class="'. $favourite_icon .'"></i> ' . $favourite_text . '</a>'; |
|
2421 | + echo '<a href="javascript:void(0);" title="' . $add_favourite_text . '" class="geodir-addtofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'add\');"><i class="'. $favourite_icon .'"></i> ' . $favourite_text . '</a>'; |
|
2422 | 2422 | |
2423 | - /** |
|
2424 | - * Called after removing the post from favourites. |
|
2425 | - * |
|
2426 | - * @since 1.0.0 |
|
2427 | - * @package GeoDirectory |
|
2428 | - * @param int $post_id The post ID. |
|
2429 | - */ |
|
2430 | - do_action('geodir_after_remove_from_favorite', $post_id); |
|
2423 | + /** |
|
2424 | + * Called after removing the post from favourites. |
|
2425 | + * |
|
2426 | + * @since 1.0.0 |
|
2427 | + * @package GeoDirectory |
|
2428 | + * @param int $post_id The post ID. |
|
2429 | + */ |
|
2430 | + do_action('geodir_after_remove_from_favorite', $post_id); |
|
2431 | 2431 | |
2432 | - } |
|
2432 | + } |
|
2433 | 2433 | } |
2434 | 2434 | |
2435 | 2435 | if (!function_exists('geodir_favourite_html')) { |
2436 | - /** |
|
2437 | - * This function would display the html content for add to favorite or remove from favorite. |
|
2438 | - * |
|
2439 | - * @since 1.0.0 |
|
2440 | - * @package GeoDirectory |
|
2441 | - * @global object $current_user Current user object. |
|
2442 | - * @global object $post The current post object. |
|
2443 | - * @param int $user_id The user ID. |
|
2444 | - * @param int $post_id The post ID. |
|
2445 | - */ |
|
2446 | - function geodir_favourite_html($user_id, $post_id) |
|
2447 | - { |
|
2448 | - |
|
2449 | - global $current_user, $post; |
|
2450 | - |
|
2451 | - /** |
|
2452 | - * Filter to modify "Add to Favorites" text |
|
2453 | - * |
|
2454 | - * You can use this filter to rename "Add to Favorites" text to something else. |
|
2455 | - * |
|
2456 | - * @since 1.0.0 |
|
2457 | - * @package GeoDirectory |
|
2458 | - */ |
|
2459 | - $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT); |
|
2460 | - |
|
2461 | - /** |
|
2462 | - * Filter to modify "Favourite" text |
|
2463 | - * |
|
2464 | - * You can use this filter to rename "Favourite" text to something else. |
|
2465 | - * |
|
2466 | - * @since 1.0.0 |
|
2467 | - * @package GeoDirectory |
|
2468 | - */ |
|
2469 | - $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT); |
|
2470 | - |
|
2471 | - /** |
|
2472 | - * Filter to modify "Unfavorite" text |
|
2473 | - * |
|
2474 | - * You can use this filter to rename "Unfavorite" text to something else. |
|
2475 | - * |
|
2476 | - * @since 1.0.0 |
|
2477 | - * @package GeoDirectory |
|
2478 | - */ |
|
2479 | - $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT); |
|
2480 | - |
|
2481 | - /** |
|
2482 | - * Filter to modify "Remove from Favorites" text |
|
2483 | - * |
|
2484 | - * You can use this filter to rename "Remove from Favorites" text to something else. |
|
2485 | - * |
|
2486 | - * @since 1.0.0 |
|
2487 | - * @package GeoDirectory |
|
2488 | - */ |
|
2489 | - $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT); |
|
2490 | - |
|
2491 | - /** |
|
2492 | - * Filter to modify "fa fa-heart" icon |
|
2493 | - * |
|
2494 | - * You can use this filter to change "fa fa-heart" icon to something else. |
|
2495 | - * |
|
2496 | - * @since 1.0.0 |
|
2497 | - * @package GeoDirectory |
|
2498 | - */ |
|
2499 | - $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart'); |
|
2500 | - |
|
2501 | - /** |
|
2502 | - * Filter to modify "fa fa-heart" icon for "remove from favorites" link |
|
2503 | - * |
|
2504 | - * You can use this filter to change "fa fa-heart" icon to something else. |
|
2505 | - * |
|
2506 | - * @since 1.0.0 |
|
2507 | - * @package GeoDirectory |
|
2508 | - */ |
|
2509 | - $unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart'); |
|
2510 | - |
|
2511 | - $user_meta_data = ''; |
|
2512 | - if (isset($current_user->data->ID)) |
|
2513 | - $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true); |
|
2514 | - |
|
2515 | - if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) { |
|
2516 | - ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>" ><a |
|
2436 | + /** |
|
2437 | + * This function would display the html content for add to favorite or remove from favorite. |
|
2438 | + * |
|
2439 | + * @since 1.0.0 |
|
2440 | + * @package GeoDirectory |
|
2441 | + * @global object $current_user Current user object. |
|
2442 | + * @global object $post The current post object. |
|
2443 | + * @param int $user_id The user ID. |
|
2444 | + * @param int $post_id The post ID. |
|
2445 | + */ |
|
2446 | + function geodir_favourite_html($user_id, $post_id) |
|
2447 | + { |
|
2448 | + |
|
2449 | + global $current_user, $post; |
|
2450 | + |
|
2451 | + /** |
|
2452 | + * Filter to modify "Add to Favorites" text |
|
2453 | + * |
|
2454 | + * You can use this filter to rename "Add to Favorites" text to something else. |
|
2455 | + * |
|
2456 | + * @since 1.0.0 |
|
2457 | + * @package GeoDirectory |
|
2458 | + */ |
|
2459 | + $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT); |
|
2460 | + |
|
2461 | + /** |
|
2462 | + * Filter to modify "Favourite" text |
|
2463 | + * |
|
2464 | + * You can use this filter to rename "Favourite" text to something else. |
|
2465 | + * |
|
2466 | + * @since 1.0.0 |
|
2467 | + * @package GeoDirectory |
|
2468 | + */ |
|
2469 | + $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT); |
|
2470 | + |
|
2471 | + /** |
|
2472 | + * Filter to modify "Unfavorite" text |
|
2473 | + * |
|
2474 | + * You can use this filter to rename "Unfavorite" text to something else. |
|
2475 | + * |
|
2476 | + * @since 1.0.0 |
|
2477 | + * @package GeoDirectory |
|
2478 | + */ |
|
2479 | + $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT); |
|
2480 | + |
|
2481 | + /** |
|
2482 | + * Filter to modify "Remove from Favorites" text |
|
2483 | + * |
|
2484 | + * You can use this filter to rename "Remove from Favorites" text to something else. |
|
2485 | + * |
|
2486 | + * @since 1.0.0 |
|
2487 | + * @package GeoDirectory |
|
2488 | + */ |
|
2489 | + $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT); |
|
2490 | + |
|
2491 | + /** |
|
2492 | + * Filter to modify "fa fa-heart" icon |
|
2493 | + * |
|
2494 | + * You can use this filter to change "fa fa-heart" icon to something else. |
|
2495 | + * |
|
2496 | + * @since 1.0.0 |
|
2497 | + * @package GeoDirectory |
|
2498 | + */ |
|
2499 | + $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart'); |
|
2500 | + |
|
2501 | + /** |
|
2502 | + * Filter to modify "fa fa-heart" icon for "remove from favorites" link |
|
2503 | + * |
|
2504 | + * You can use this filter to change "fa fa-heart" icon to something else. |
|
2505 | + * |
|
2506 | + * @since 1.0.0 |
|
2507 | + * @package GeoDirectory |
|
2508 | + */ |
|
2509 | + $unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart'); |
|
2510 | + |
|
2511 | + $user_meta_data = ''; |
|
2512 | + if (isset($current_user->data->ID)) |
|
2513 | + $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true); |
|
2514 | + |
|
2515 | + if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) { |
|
2516 | + ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>" ><a |
|
2517 | 2517 | class="geodir-removetofav-icon" href="javascript:void(0);" |
2518 | 2518 | onclick="javascript:addToFavourite(<?php echo $post_id;?>,'remove');" |
2519 | 2519 | title="<?php echo $remove_favourite_text;?>"><i class="<?php echo $unfavourite_icon; ?>"></i> <?php echo $unfavourite_text;?> |
2520 | 2520 | </a> </span><?php |
2521 | 2521 | |
2522 | - } else { |
|
2522 | + } else { |
|
2523 | 2523 | |
2524 | - if (!isset($current_user->data->ID) || $current_user->data->ID == '') { |
|
2525 | - $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\''; |
|
2526 | - } else |
|
2527 | - $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')'; |
|
2524 | + if (!isset($current_user->data->ID) || $current_user->data->ID == '') { |
|
2525 | + $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\''; |
|
2526 | + } else |
|
2527 | + $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')'; |
|
2528 | 2528 | |
2529 | - ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon" |
|
2529 | + ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon" |
|
2530 | 2530 | href="javascript:void(0);" |
2531 | 2531 | onclick="<?php echo $script_text;?>" |
2532 | 2532 | title="<?php echo $add_favourite_text;?>"><i |
2533 | 2533 | class="<?php echo $favourite_icon; ?>"></i> <?php echo $favourite_text;?></a></span> |
2534 | 2534 | <?php } |
2535 | - } |
|
2535 | + } |
|
2536 | 2536 | } |
2537 | 2537 | |
2538 | 2538 | |
@@ -2549,54 +2549,54 @@ discard block |
||
2549 | 2549 | function geodir_get_cat_postcount($term = array()) |
2550 | 2550 | { |
2551 | 2551 | |
2552 | - if (!empty($term)) { |
|
2552 | + if (!empty($term)) { |
|
2553 | 2553 | |
2554 | - global $wpdb, $plugin_prefix; |
|
2554 | + global $wpdb, $plugin_prefix; |
|
2555 | 2555 | |
2556 | - $where = ''; |
|
2557 | - $join = ''; |
|
2558 | - if (get_query_var('gd_country') != '' || get_query_var('gd_region') != '' || get_query_var('gd_city') != '') { |
|
2559 | - $taxonomy_obj = get_taxonomy($term->taxonomy); |
|
2556 | + $where = ''; |
|
2557 | + $join = ''; |
|
2558 | + if (get_query_var('gd_country') != '' || get_query_var('gd_region') != '' || get_query_var('gd_city') != '') { |
|
2559 | + $taxonomy_obj = get_taxonomy($term->taxonomy); |
|
2560 | 2560 | |
2561 | - $post_type = $taxonomy_obj->object_type[0]; |
|
2561 | + $post_type = $taxonomy_obj->object_type[0]; |
|
2562 | 2562 | |
2563 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
2563 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
2564 | 2564 | |
2565 | - /** |
|
2566 | - * Filter to modify the 'join' query |
|
2567 | - * |
|
2568 | - * @since 1.0.0 |
|
2569 | - * @package GeoDirectory |
|
2570 | - * @param object|array $term category / term object that need to be processed. |
|
2571 | - * @param string $join The join query. |
|
2572 | - */ |
|
2573 | - $join = apply_filters('geodir_cat_post_count_join', $join, $term); |
|
2565 | + /** |
|
2566 | + * Filter to modify the 'join' query |
|
2567 | + * |
|
2568 | + * @since 1.0.0 |
|
2569 | + * @package GeoDirectory |
|
2570 | + * @param object|array $term category / term object that need to be processed. |
|
2571 | + * @param string $join The join query. |
|
2572 | + */ |
|
2573 | + $join = apply_filters('geodir_cat_post_count_join', $join, $term); |
|
2574 | 2574 | |
2575 | - /** |
|
2576 | - * Filter to modify the 'where' query |
|
2577 | - * |
|
2578 | - * @since 1.0.0 |
|
2579 | - * @package GeoDirectory |
|
2580 | - * @param object|array $term category / term object that need to be processed. |
|
2581 | - * @param string $where The where query. |
|
2582 | - */ |
|
2583 | - $where = apply_filters('geodir_cat_post_count_where', $where, $term); |
|
2575 | + /** |
|
2576 | + * Filter to modify the 'where' query |
|
2577 | + * |
|
2578 | + * @since 1.0.0 |
|
2579 | + * @package GeoDirectory |
|
2580 | + * @param object|array $term category / term object that need to be processed. |
|
2581 | + * @param string $where The where query. |
|
2582 | + */ |
|
2583 | + $where = apply_filters('geodir_cat_post_count_where', $where, $term); |
|
2584 | 2584 | |
2585 | - $count_query = "SELECT count(post_id) FROM |
|
2585 | + $count_query = "SELECT count(post_id) FROM |
|
2586 | 2586 | " . $table . " as pd " . $join . " |
2587 | 2587 | WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id . "'," . $term->taxonomy . ") " . $where; |
2588 | 2588 | |
2589 | - $cat_post_count = $wpdb->get_var($count_query); |
|
2590 | - if (empty($cat_post_count) || is_wp_error($cat_post_count)) |
|
2591 | - $cat_post_count = 0; |
|
2589 | + $cat_post_count = $wpdb->get_var($count_query); |
|
2590 | + if (empty($cat_post_count) || is_wp_error($cat_post_count)) |
|
2591 | + $cat_post_count = 0; |
|
2592 | 2592 | |
2593 | - return $cat_post_count; |
|
2593 | + return $cat_post_count; |
|
2594 | 2594 | |
2595 | - } else |
|
2595 | + } else |
|
2596 | 2596 | |
2597 | - return $term->count; |
|
2598 | - } |
|
2599 | - return false; |
|
2597 | + return $term->count; |
|
2598 | + } |
|
2599 | + return false; |
|
2600 | 2600 | |
2601 | 2601 | } |
2602 | 2602 | |
@@ -2609,17 +2609,17 @@ discard block |
||
2609 | 2609 | */ |
2610 | 2610 | function geodir_allow_post_type_frontend() |
2611 | 2611 | { |
2612 | - $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend'); |
|
2612 | + $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend'); |
|
2613 | 2613 | |
2614 | - if (!is_admin() && isset($_REQUEST['listing_type']) |
|
2615 | - && !empty($geodir_allow_posttype_frontend) |
|
2616 | - && !in_array($_REQUEST['listing_type'], $geodir_allow_posttype_frontend) |
|
2617 | - ) { |
|
2614 | + if (!is_admin() && isset($_REQUEST['listing_type']) |
|
2615 | + && !empty($geodir_allow_posttype_frontend) |
|
2616 | + && !in_array($_REQUEST['listing_type'], $geodir_allow_posttype_frontend) |
|
2617 | + ) { |
|
2618 | 2618 | |
2619 | - wp_redirect(home_url()); |
|
2620 | - exit; |
|
2619 | + wp_redirect(home_url()); |
|
2620 | + exit; |
|
2621 | 2621 | |
2622 | - } |
|
2622 | + } |
|
2623 | 2623 | |
2624 | 2624 | } |
2625 | 2625 | |
@@ -2636,20 +2636,20 @@ discard block |
||
2636 | 2636 | */ |
2637 | 2637 | function geodir_excerpt_length($length) |
2638 | 2638 | { |
2639 | - global $wp_query, $geodir_is_widget_listing; |
|
2639 | + global $wp_query, $geodir_is_widget_listing; |
|
2640 | 2640 | if ($geodir_is_widget_listing) { |
2641 | 2641 | return $length; |
2642 | 2642 | } |
2643 | 2643 | |
2644 | - if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit')) |
|
2645 | - $length = get_option('geodir_desc_word_limit'); |
|
2646 | - elseif (get_query_var('excerpt_length')) |
|
2647 | - $length = get_query_var('excerpt_length'); |
|
2644 | + if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit')) |
|
2645 | + $length = get_option('geodir_desc_word_limit'); |
|
2646 | + elseif (get_query_var('excerpt_length')) |
|
2647 | + $length = get_query_var('excerpt_length'); |
|
2648 | 2648 | |
2649 | - if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit')) |
|
2650 | - $length = get_option('geodir_author_desc_word_limit'); |
|
2649 | + if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit')) |
|
2650 | + $length = get_option('geodir_author_desc_word_limit'); |
|
2651 | 2651 | |
2652 | - return $length; |
|
2652 | + return $length; |
|
2653 | 2653 | } |
2654 | 2654 | |
2655 | 2655 | /** |
@@ -2664,13 +2664,13 @@ discard block |
||
2664 | 2664 | */ |
2665 | 2665 | function geodir_excerpt_more($more) |
2666 | 2666 | { |
2667 | - global $post; |
|
2668 | - $all_postypes = geodir_get_posttypes(); |
|
2669 | - if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) { |
|
2670 | - return ' <a href="' . get_permalink($post->ID) . '">' . READ_MORE_TXT . '</a>'; |
|
2671 | - } |
|
2667 | + global $post; |
|
2668 | + $all_postypes = geodir_get_posttypes(); |
|
2669 | + if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) { |
|
2670 | + return ' <a href="' . get_permalink($post->ID) . '">' . READ_MORE_TXT . '</a>'; |
|
2671 | + } |
|
2672 | 2672 | |
2673 | - return $more; |
|
2673 | + return $more; |
|
2674 | 2674 | } |
2675 | 2675 | |
2676 | 2676 | |
@@ -2687,63 +2687,63 @@ discard block |
||
2687 | 2687 | */ |
2688 | 2688 | function geodir_update_markers_oncatedit($term_id, $tt_id, $taxonomy) |
2689 | 2689 | { |
2690 | - global $plugin_prefix, $wpdb; |
|
2690 | + global $plugin_prefix, $wpdb; |
|
2691 | 2691 | |
2692 | - $gd_taxonomies = geodir_get_taxonomies(); |
|
2692 | + $gd_taxonomies = geodir_get_taxonomies(); |
|
2693 | 2693 | |
2694 | - if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) { |
|
2694 | + if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) { |
|
2695 | 2695 | |
2696 | - $geodir_post_type = geodir_get_taxonomy_posttype($taxonomy); |
|
2697 | - $table = $plugin_prefix . $geodir_post_type . '_detail'; |
|
2696 | + $geodir_post_type = geodir_get_taxonomy_posttype($taxonomy); |
|
2697 | + $table = $plugin_prefix . $geodir_post_type . '_detail'; |
|
2698 | 2698 | |
2699 | - $path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']); |
|
2700 | - $term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png'; |
|
2699 | + $path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']); |
|
2700 | + $term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png'; |
|
2701 | 2701 | |
2702 | - $posts = $wpdb->get_results( |
|
2703 | - $wpdb->prepare( |
|
2704 | - "SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ", |
|
2705 | - array($term_id, $taxonomy) |
|
2706 | - ) |
|
2707 | - ); |
|
2702 | + $posts = $wpdb->get_results( |
|
2703 | + $wpdb->prepare( |
|
2704 | + "SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ", |
|
2705 | + array($term_id, $taxonomy) |
|
2706 | + ) |
|
2707 | + ); |
|
2708 | 2708 | |
2709 | - if (!empty($posts)): |
|
2710 | - foreach ($posts as $post_obj) { |
|
2709 | + if (!empty($posts)): |
|
2710 | + foreach ($posts as $post_obj) { |
|
2711 | 2711 | |
2712 | - $lat = $post_obj->post_latitude; |
|
2713 | - $lng = $post_obj->post_longitude; |
|
2712 | + $lat = $post_obj->post_latitude; |
|
2713 | + $lng = $post_obj->post_longitude; |
|
2714 | 2714 | |
2715 | - $json = '{'; |
|
2716 | - $json .= '"id":"' . $post_obj->post_id . '",'; |
|
2717 | - $json .= '"lat_pos": "' . $lat . '",'; |
|
2718 | - $json .= '"long_pos": "' . $lng . '",'; |
|
2719 | - $json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",'; |
|
2720 | - $json .= '"icon":"' . $term_icon . '",'; |
|
2721 | - $json .= '"group":"catgroup' . $term_id . '"'; |
|
2722 | - $json .= '}'; |
|
2715 | + $json = '{'; |
|
2716 | + $json .= '"id":"' . $post_obj->post_id . '",'; |
|
2717 | + $json .= '"lat_pos": "' . $lat . '",'; |
|
2718 | + $json .= '"long_pos": "' . $lng . '",'; |
|
2719 | + $json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",'; |
|
2720 | + $json .= '"icon":"' . $term_icon . '",'; |
|
2721 | + $json .= '"group":"catgroup' . $term_id . '"'; |
|
2722 | + $json .= '}'; |
|
2723 | 2723 | |
2724 | - if ($post_obj->default_category == $term_id) { |
|
2724 | + if ($post_obj->default_category == $term_id) { |
|
2725 | 2725 | |
2726 | - $wpdb->query( |
|
2727 | - $wpdb->prepare( |
|
2728 | - "UPDATE " . $table . " SET marker_json = %s where post_id = %d", |
|
2729 | - array($json, $post_obj->post_id) |
|
2730 | - ) |
|
2731 | - ); |
|
2732 | - } |
|
2726 | + $wpdb->query( |
|
2727 | + $wpdb->prepare( |
|
2728 | + "UPDATE " . $table . " SET marker_json = %s where post_id = %d", |
|
2729 | + array($json, $post_obj->post_id) |
|
2730 | + ) |
|
2731 | + ); |
|
2732 | + } |
|
2733 | 2733 | |
2734 | - $wpdb->query( |
|
2735 | - $wpdb->prepare( |
|
2736 | - "UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d", |
|
2737 | - array($json, $post_obj->post_id, $term_id) |
|
2738 | - ) |
|
2739 | - ); |
|
2734 | + $wpdb->query( |
|
2735 | + $wpdb->prepare( |
|
2736 | + "UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d", |
|
2737 | + array($json, $post_obj->post_id, $term_id) |
|
2738 | + ) |
|
2739 | + ); |
|
2740 | 2740 | |
2741 | - } |
|
2741 | + } |
|
2742 | 2742 | |
2743 | 2743 | |
2744 | - endif; |
|
2744 | + endif; |
|
2745 | 2745 | |
2746 | - } |
|
2746 | + } |
|
2747 | 2747 | |
2748 | 2748 | } |
2749 | 2749 | |
@@ -2757,14 +2757,14 @@ discard block |
||
2757 | 2757 | */ |
2758 | 2758 | function geodir_get_listing_author($listing_id = '') |
2759 | 2759 | { |
2760 | - if ($listing_id == '') { |
|
2761 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
2762 | - $listing_id = $_REQUEST['pid']; |
|
2763 | - } |
|
2764 | - } |
|
2765 | - $listing = get_post(strip_tags($listing_id)); |
|
2766 | - $listing_author_id = $listing->post_author; |
|
2767 | - return $listing_author_id; |
|
2760 | + if ($listing_id == '') { |
|
2761 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
2762 | + $listing_id = $_REQUEST['pid']; |
|
2763 | + } |
|
2764 | + } |
|
2765 | + $listing = get_post(strip_tags($listing_id)); |
|
2766 | + $listing_author_id = $listing->post_author; |
|
2767 | + return $listing_author_id; |
|
2768 | 2768 | } |
2769 | 2769 | |
2770 | 2770 | |
@@ -2779,11 +2779,11 @@ discard block |
||
2779 | 2779 | */ |
2780 | 2780 | function geodir_lisiting_belong_to_user($listing_id, $user_id) |
2781 | 2781 | { |
2782 | - $listing_author_id = geodir_get_listing_author($listing_id); |
|
2783 | - if ($listing_author_id == $user_id) |
|
2784 | - return true; |
|
2785 | - else |
|
2786 | - return false; |
|
2782 | + $listing_author_id = geodir_get_listing_author($listing_id); |
|
2783 | + if ($listing_author_id == $user_id) |
|
2784 | + return true; |
|
2785 | + else |
|
2786 | + return false; |
|
2787 | 2787 | |
2788 | 2788 | } |
2789 | 2789 | |
@@ -2799,17 +2799,17 @@ discard block |
||
2799 | 2799 | */ |
2800 | 2800 | function geodir_listing_belong_to_current_user($listing_id = '', $exclude_admin = true) |
2801 | 2801 | { |
2802 | - global $current_user; |
|
2803 | - if ($exclude_admin) { |
|
2804 | - foreach ($current_user->caps as $key => $caps) { |
|
2805 | - if (geodir_strtolower($key) == 'administrator') { |
|
2806 | - return true; |
|
2807 | - break; |
|
2808 | - } |
|
2809 | - } |
|
2810 | - } |
|
2811 | - |
|
2812 | - return geodir_lisiting_belong_to_user($listing_id, $current_user->ID); |
|
2802 | + global $current_user; |
|
2803 | + if ($exclude_admin) { |
|
2804 | + foreach ($current_user->caps as $key => $caps) { |
|
2805 | + if (geodir_strtolower($key) == 'administrator') { |
|
2806 | + return true; |
|
2807 | + break; |
|
2808 | + } |
|
2809 | + } |
|
2810 | + } |
|
2811 | + |
|
2812 | + return geodir_lisiting_belong_to_user($listing_id, $current_user->ID); |
|
2813 | 2813 | } |
2814 | 2814 | |
2815 | 2815 | |
@@ -2825,17 +2825,17 @@ discard block |
||
2825 | 2825 | function geodir_only_supportable_attachments_remove($file) |
2826 | 2826 | { |
2827 | 2827 | |
2828 | - global $wpdb; |
|
2828 | + global $wpdb; |
|
2829 | 2829 | |
2830 | - $matches = array(); |
|
2830 | + $matches = array(); |
|
2831 | 2831 | |
2832 | - $pattern = '/-\d+x\d+\./'; |
|
2833 | - preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE); |
|
2832 | + $pattern = '/-\d+x\d+\./'; |
|
2833 | + preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE); |
|
2834 | 2834 | |
2835 | - if (empty($matches)) |
|
2836 | - return ''; |
|
2837 | - else |
|
2838 | - return $file; |
|
2835 | + if (empty($matches)) |
|
2836 | + return ''; |
|
2837 | + else |
|
2838 | + return $file; |
|
2839 | 2839 | |
2840 | 2840 | } |
2841 | 2841 | |
@@ -2852,78 +2852,78 @@ discard block |
||
2852 | 2852 | function geodir_set_wp_featured_image($post_id) |
2853 | 2853 | { |
2854 | 2854 | |
2855 | - global $wpdb, $plugin_prefix; |
|
2856 | - $uploads = wp_upload_dir(); |
|
2855 | + global $wpdb, $plugin_prefix; |
|
2856 | + $uploads = wp_upload_dir(); |
|
2857 | 2857 | // print_r($uploads ) ; |
2858 | - $post_first_image = $wpdb->get_results( |
|
2859 | - $wpdb->prepare( |
|
2860 | - "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1 ", array($post_id) |
|
2861 | - ) |
|
2862 | - ); |
|
2858 | + $post_first_image = $wpdb->get_results( |
|
2859 | + $wpdb->prepare( |
|
2860 | + "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1 ", array($post_id) |
|
2861 | + ) |
|
2862 | + ); |
|
2863 | 2863 | |
2864 | - $old_attachment_name = ''; |
|
2865 | - $post_thumbnail_id = ''; |
|
2866 | - if (has_post_thumbnail($post_id)) { |
|
2864 | + $old_attachment_name = ''; |
|
2865 | + $post_thumbnail_id = ''; |
|
2866 | + if (has_post_thumbnail($post_id)) { |
|
2867 | 2867 | |
2868 | - if (has_post_thumbnail($post_id)) { |
|
2868 | + if (has_post_thumbnail($post_id)) { |
|
2869 | 2869 | |
2870 | - $post_thumbnail_id = get_post_thumbnail_id($post_id); |
|
2870 | + $post_thumbnail_id = get_post_thumbnail_id($post_id); |
|
2871 | 2871 | |
2872 | - $old_attachment_name = basename(get_attached_file($post_thumbnail_id)); |
|
2872 | + $old_attachment_name = basename(get_attached_file($post_thumbnail_id)); |
|
2873 | 2873 | |
2874 | - } |
|
2875 | - } |
|
2876 | - |
|
2877 | - if (!empty($post_first_image)) { |
|
2874 | + } |
|
2875 | + } |
|
2878 | 2876 | |
2879 | - $post_type = get_post_type($post_id); |
|
2877 | + if (!empty($post_first_image)) { |
|
2880 | 2878 | |
2881 | - $table_name = $plugin_prefix . $post_type . '_detail'; |
|
2879 | + $post_type = get_post_type($post_id); |
|
2882 | 2880 | |
2883 | - $wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id); |
|
2881 | + $table_name = $plugin_prefix . $post_type . '_detail'; |
|
2884 | 2882 | |
2885 | - $new_attachment_name = basename($post_first_image[0]->file); |
|
2883 | + $wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id); |
|
2886 | 2884 | |
2887 | - if (geodir_strtolower($new_attachment_name) != geodir_strtolower($old_attachment_name)) { |
|
2885 | + $new_attachment_name = basename($post_first_image[0]->file); |
|
2888 | 2886 | |
2889 | - if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) { |
|
2887 | + if (geodir_strtolower($new_attachment_name) != geodir_strtolower($old_attachment_name)) { |
|
2890 | 2888 | |
2891 | - add_filter('wp_delete_file', 'geodir_only_supportable_attachments_remove'); |
|
2889 | + if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) { |
|
2892 | 2890 | |
2893 | - wp_delete_attachment($post_thumbnail_id); |
|
2891 | + add_filter('wp_delete_file', 'geodir_only_supportable_attachments_remove'); |
|
2894 | 2892 | |
2895 | - } |
|
2896 | - $filename = $uploads['basedir'] . $post_first_image[0]->file; |
|
2893 | + wp_delete_attachment($post_thumbnail_id); |
|
2897 | 2894 | |
2898 | - $attachment = array( |
|
2899 | - 'post_mime_type' => $post_first_image[0]->mime_type, |
|
2900 | - 'guid' => $uploads['baseurl'] . $post_first_image[0]->file, |
|
2901 | - 'post_parent' => $post_id, |
|
2902 | - 'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title), |
|
2903 | - 'post_content' => '' |
|
2904 | - ); |
|
2895 | + } |
|
2896 | + $filename = $uploads['basedir'] . $post_first_image[0]->file; |
|
2897 | + |
|
2898 | + $attachment = array( |
|
2899 | + 'post_mime_type' => $post_first_image[0]->mime_type, |
|
2900 | + 'guid' => $uploads['baseurl'] . $post_first_image[0]->file, |
|
2901 | + 'post_parent' => $post_id, |
|
2902 | + 'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title), |
|
2903 | + 'post_content' => '' |
|
2904 | + ); |
|
2905 | 2905 | |
2906 | 2906 | |
2907 | - $id = wp_insert_attachment($attachment, $filename, $post_id); |
|
2907 | + $id = wp_insert_attachment($attachment, $filename, $post_id); |
|
2908 | 2908 | |
2909 | - if (!is_wp_error($id)) { |
|
2909 | + if (!is_wp_error($id)) { |
|
2910 | 2910 | |
2911 | - set_post_thumbnail($post_id, $id); |
|
2911 | + set_post_thumbnail($post_id, $id); |
|
2912 | 2912 | |
2913 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
2914 | - wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); |
|
2913 | + require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
2914 | + wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); |
|
2915 | 2915 | |
2916 | - } |
|
2916 | + } |
|
2917 | 2917 | |
2918 | - } |
|
2918 | + } |
|
2919 | 2919 | |
2920 | - } else { |
|
2921 | - //set_post_thumbnail($post_id,-1); |
|
2920 | + } else { |
|
2921 | + //set_post_thumbnail($post_id,-1); |
|
2922 | 2922 | |
2923 | - if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) |
|
2924 | - wp_delete_attachment($post_thumbnail_id); |
|
2923 | + if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) |
|
2924 | + wp_delete_attachment($post_thumbnail_id); |
|
2925 | 2925 | |
2926 | - } |
|
2926 | + } |
|
2927 | 2927 | } |
2928 | 2928 | |
2929 | 2929 | |
@@ -2938,53 +2938,53 @@ discard block |
||
2938 | 2938 | */ |
2939 | 2939 | function gd_copy_original_translation() |
2940 | 2940 | { |
2941 | - if (function_exists('icl_object_id')) { |
|
2942 | - global $wpdb, $table_prefix, $plugin_prefix; |
|
2943 | - $post_id = absint($_POST['post_id']); |
|
2944 | - $upload_dir = wp_upload_dir(); |
|
2945 | - $post_type = get_post_type($_POST['post_id']); |
|
2946 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
2947 | - |
|
2948 | - $post_arr = $wpdb->get_results($wpdb->prepare( |
|
2949 | - "SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1", |
|
2950 | - array($post_id) |
|
2951 | - ) |
|
2952 | - , ARRAY_A); |
|
2953 | - |
|
2954 | - $arrImages = $wpdb->get_results( |
|
2955 | - $wpdb->prepare( |
|
2956 | - "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ", |
|
2957 | - array('%image%', $post_id) |
|
2958 | - ) |
|
2959 | - ); |
|
2960 | - if ($arrImages) { |
|
2961 | - $image_arr = array(); |
|
2962 | - foreach ($arrImages as $img) { |
|
2963 | - $image_arr[] = $upload_dir['baseurl'] . $img->file; |
|
2964 | - } |
|
2965 | - $comma_separated = implode(",", $image_arr); |
|
2966 | - $post_arr[0]['post_images'] = $comma_separated; |
|
2967 | - } |
|
2968 | - |
|
2969 | - |
|
2970 | - $cats = $post_arr[0][$post_arr[0]['post_type'] . 'category']; |
|
2971 | - $cat_arr = array_filter(explode(",", $cats)); |
|
2972 | - $trans_cat = array(); |
|
2973 | - foreach ($cat_arr as $cat) { |
|
2974 | - $trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'] . 'category', false); |
|
2975 | - } |
|
2976 | - |
|
2977 | - |
|
2978 | - $post_arr[0]['categories'] = array_filter($trans_cat); |
|
2941 | + if (function_exists('icl_object_id')) { |
|
2942 | + global $wpdb, $table_prefix, $plugin_prefix; |
|
2943 | + $post_id = absint($_POST['post_id']); |
|
2944 | + $upload_dir = wp_upload_dir(); |
|
2945 | + $post_type = get_post_type($_POST['post_id']); |
|
2946 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
2947 | + |
|
2948 | + $post_arr = $wpdb->get_results($wpdb->prepare( |
|
2949 | + "SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1", |
|
2950 | + array($post_id) |
|
2951 | + ) |
|
2952 | + , ARRAY_A); |
|
2953 | + |
|
2954 | + $arrImages = $wpdb->get_results( |
|
2955 | + $wpdb->prepare( |
|
2956 | + "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ", |
|
2957 | + array('%image%', $post_id) |
|
2958 | + ) |
|
2959 | + ); |
|
2960 | + if ($arrImages) { |
|
2961 | + $image_arr = array(); |
|
2962 | + foreach ($arrImages as $img) { |
|
2963 | + $image_arr[] = $upload_dir['baseurl'] . $img->file; |
|
2964 | + } |
|
2965 | + $comma_separated = implode(",", $image_arr); |
|
2966 | + $post_arr[0]['post_images'] = $comma_separated; |
|
2967 | + } |
|
2968 | + |
|
2969 | + |
|
2970 | + $cats = $post_arr[0][$post_arr[0]['post_type'] . 'category']; |
|
2971 | + $cat_arr = array_filter(explode(",", $cats)); |
|
2972 | + $trans_cat = array(); |
|
2973 | + foreach ($cat_arr as $cat) { |
|
2974 | + $trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'] . 'category', false); |
|
2975 | + } |
|
2976 | + |
|
2977 | + |
|
2978 | + $post_arr[0]['categories'] = array_filter($trans_cat); |
|
2979 | 2979 | //print_r($image_arr); |
2980 | - //print_r($arrImages); |
|
2981 | - //echo $_REQUEST['lang']; |
|
2980 | + //print_r($arrImages); |
|
2981 | + //echo $_REQUEST['lang']; |
|
2982 | 2982 | //print_r($post_arr); |
2983 | 2983 | //print_r($trans_cat); |
2984 | - echo json_encode($post_arr[0]); |
|
2984 | + echo json_encode($post_arr[0]); |
|
2985 | 2985 | |
2986 | - } |
|
2987 | - die(); |
|
2986 | + } |
|
2987 | + die(); |
|
2988 | 2988 | } |
2989 | 2989 | |
2990 | 2990 | |
@@ -3004,54 +3004,54 @@ discard block |
||
3004 | 3004 | function geodir_get_custom_fields_type($listing_type = '') |
3005 | 3005 | { |
3006 | 3006 | |
3007 | - global $wpdb; |
|
3007 | + global $wpdb; |
|
3008 | 3008 | |
3009 | - if ($listing_type == '') |
|
3010 | - $listing_type = 'gd_place'; |
|
3009 | + if ($listing_type == '') |
|
3010 | + $listing_type = 'gd_place'; |
|
3011 | 3011 | |
3012 | - $fields_info = array(); |
|
3012 | + $fields_info = array(); |
|
3013 | 3013 | |
3014 | - $get_data = $wpdb->get_results( |
|
3015 | - $wpdb->prepare( |
|
3016 | - "SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'", |
|
3017 | - array($listing_type) |
|
3018 | - ) |
|
3019 | - ); |
|
3014 | + $get_data = $wpdb->get_results( |
|
3015 | + $wpdb->prepare( |
|
3016 | + "SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'", |
|
3017 | + array($listing_type) |
|
3018 | + ) |
|
3019 | + ); |
|
3020 | 3020 | |
3021 | - if (!empty($get_data)) { |
|
3021 | + if (!empty($get_data)) { |
|
3022 | 3022 | |
3023 | - foreach ($get_data as $data) { |
|
3023 | + foreach ($get_data as $data) { |
|
3024 | 3024 | |
3025 | - if ($data->field_type == 'address') { |
|
3025 | + if ($data->field_type == 'address') { |
|
3026 | 3026 | |
3027 | - $extra_fields = unserialize($data->extra_fields); |
|
3027 | + $extra_fields = unserialize($data->extra_fields); |
|
3028 | 3028 | |
3029 | - $prefix = $data->htmlvar_name . '_'; |
|
3029 | + $prefix = $data->htmlvar_name . '_'; |
|
3030 | 3030 | |
3031 | - $fields_info[$prefix . 'address'] = $data->field_type; |
|
3031 | + $fields_info[$prefix . 'address'] = $data->field_type; |
|
3032 | 3032 | |
3033 | - if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) |
|
3034 | - $fields_info[$prefix . 'zip'] = $data->field_type; |
|
3033 | + if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) |
|
3034 | + $fields_info[$prefix . 'zip'] = $data->field_type; |
|
3035 | 3035 | |
3036 | - } else { |
|
3036 | + } else { |
|
3037 | 3037 | |
3038 | - $fields_info[$data->htmlvar_name] = $data->field_type; |
|
3038 | + $fields_info[$data->htmlvar_name] = $data->field_type; |
|
3039 | 3039 | |
3040 | - } |
|
3040 | + } |
|
3041 | 3041 | |
3042 | - } |
|
3042 | + } |
|
3043 | 3043 | |
3044 | - } |
|
3044 | + } |
|
3045 | 3045 | |
3046 | - /** |
|
3047 | - * Filter to modify custom fields info using listing post type. |
|
3048 | - * |
|
3049 | - * @since 1.0.0 |
|
3050 | - * @package GeoDirectory |
|
3051 | - * @return array $fields_info Custom fields info. |
|
3052 | - * @param string $listing_type The listing post type. |
|
3053 | - */ |
|
3054 | - return apply_filters('geodir_get_custom_fields_type', $fields_info, $listing_type); |
|
3046 | + /** |
|
3047 | + * Filter to modify custom fields info using listing post type. |
|
3048 | + * |
|
3049 | + * @since 1.0.0 |
|
3050 | + * @package GeoDirectory |
|
3051 | + * @return array $fields_info Custom fields info. |
|
3052 | + * @param string $listing_type The listing post type. |
|
3053 | + */ |
|
3054 | + return apply_filters('geodir_get_custom_fields_type', $fields_info, $listing_type); |
|
3055 | 3055 | } |
3056 | 3056 | |
3057 | 3057 | |
@@ -3066,58 +3066,58 @@ discard block |
||
3066 | 3066 | */ |
3067 | 3067 | function geodir_function_post_updated($post_ID, $post_after, $post_before) |
3068 | 3068 | { |
3069 | - $post_type = get_post_type($post_ID); |
|
3069 | + $post_type = get_post_type($post_ID); |
|
3070 | 3070 | |
3071 | - if ($post_type != '' && in_array($post_type, geodir_get_posttypes())) { |
|
3072 | - // send notification to client when post moves from draft to publish |
|
3073 | - if (!empty($post_after->post_status) && $post_after->post_status == 'publish' && !empty($post_before->post_status) && ($post_before->post_status == 'draft' || $post_before->post_status == 'auto-draft')) { |
|
3074 | - $post_author_id = !empty($post_after->post_author) ? $post_after->post_author : NULL; |
|
3075 | - $post_author_data = get_userdata($post_author_id); |
|
3071 | + if ($post_type != '' && in_array($post_type, geodir_get_posttypes())) { |
|
3072 | + // send notification to client when post moves from draft to publish |
|
3073 | + if (!empty($post_after->post_status) && $post_after->post_status == 'publish' && !empty($post_before->post_status) && ($post_before->post_status == 'draft' || $post_before->post_status == 'auto-draft')) { |
|
3074 | + $post_author_id = !empty($post_after->post_author) ? $post_after->post_author : NULL; |
|
3075 | + $post_author_data = get_userdata($post_author_id); |
|
3076 | 3076 | |
3077 | - $to_name = geodir_get_client_name($post_author_id); |
|
3077 | + $to_name = geodir_get_client_name($post_author_id); |
|
3078 | 3078 | |
3079 | - $from_email = geodir_get_site_email_id(); |
|
3080 | - $from_name = get_site_emailName(); |
|
3081 | - $to_email = $post_author_data->user_email; |
|
3079 | + $from_email = geodir_get_site_email_id(); |
|
3080 | + $from_name = get_site_emailName(); |
|
3081 | + $to_email = $post_author_data->user_email; |
|
3082 | 3082 | |
3083 | - if (!is_email($to_email) && !empty($post_author_data->user_email)) { |
|
3084 | - $to_email = $post_author_data->user_email; |
|
3085 | - } |
|
3083 | + if (!is_email($to_email) && !empty($post_author_data->user_email)) { |
|
3084 | + $to_email = $post_author_data->user_email; |
|
3085 | + } |
|
3086 | 3086 | |
3087 | - $message_type = 'listing_published'; |
|
3087 | + $message_type = 'listing_published'; |
|
3088 | 3088 | |
3089 | - if (get_option('geodir_post_published_email_subject') == '') { |
|
3090 | - update_option('geodir_post_published_email_subject', __('Listing Published Successfully', 'geodirectory')); |
|
3091 | - } |
|
3089 | + if (get_option('geodir_post_published_email_subject') == '') { |
|
3090 | + update_option('geodir_post_published_email_subject', __('Listing Published Successfully', 'geodirectory')); |
|
3091 | + } |
|
3092 | 3092 | |
3093 | - if (get_option('geodir_post_published_email_content') == '') { |
|
3094 | - update_option('geodir_post_published_email_content', __("<p>Dear [#client_name#],</p><p>Your listing [#listing_link#] has been published. This email is just for your information.</p><p>[#listing_link#]</p><br><p>Thank you for your contribution.</p><p>[#site_name#]</p>", 'geodirectory')); |
|
3095 | - } |
|
3093 | + if (get_option('geodir_post_published_email_content') == '') { |
|
3094 | + update_option('geodir_post_published_email_content', __("<p>Dear [#client_name#],</p><p>Your listing [#listing_link#] has been published. This email is just for your information.</p><p>[#listing_link#]</p><br><p>Thank you for your contribution.</p><p>[#site_name#]</p>", 'geodirectory')); |
|
3095 | + } |
|
3096 | 3096 | |
3097 | - /** |
|
3098 | - * Called before sending the email when listing gets published. |
|
3099 | - * |
|
3100 | - * @since 1.0.0 |
|
3101 | - * @package GeoDirectory |
|
3102 | - * @param object $post_after The post object after update. |
|
3103 | - * @param object $post_before The post object before update. |
|
3104 | - */ |
|
3105 | - do_action('geodir_before_listing_published_email', $post_after, $post_before); |
|
3106 | - if (is_email($to_email)) { |
|
3107 | - geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID); |
|
3108 | - } |
|
3097 | + /** |
|
3098 | + * Called before sending the email when listing gets published. |
|
3099 | + * |
|
3100 | + * @since 1.0.0 |
|
3101 | + * @package GeoDirectory |
|
3102 | + * @param object $post_after The post object after update. |
|
3103 | + * @param object $post_before The post object before update. |
|
3104 | + */ |
|
3105 | + do_action('geodir_before_listing_published_email', $post_after, $post_before); |
|
3106 | + if (is_email($to_email)) { |
|
3107 | + geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID); |
|
3108 | + } |
|
3109 | 3109 | |
3110 | - /** |
|
3111 | - * Called after sending the email when listing gets published. |
|
3112 | - * |
|
3113 | - * @since 1.0.0 |
|
3114 | - * @package GeoDirectory |
|
3115 | - * @param object $post_after The post object after update. |
|
3116 | - * @param object $post_before The post object before update. |
|
3117 | - */ |
|
3118 | - do_action('geodir_after_listing_published_email', $post_after, $post_before); |
|
3119 | - } |
|
3120 | - } |
|
3110 | + /** |
|
3111 | + * Called after sending the email when listing gets published. |
|
3112 | + * |
|
3113 | + * @since 1.0.0 |
|
3114 | + * @package GeoDirectory |
|
3115 | + * @param object $post_after The post object after update. |
|
3116 | + * @param object $post_before The post object before update. |
|
3117 | + */ |
|
3118 | + do_action('geodir_after_listing_published_email', $post_after, $post_before); |
|
3119 | + } |
|
3120 | + } |
|
3121 | 3121 | } |
3122 | 3122 | |
3123 | 3123 | add_action('wp_head', 'geodir_fb_like_thumbnail'); |
@@ -3131,14 +3131,14 @@ discard block |
||
3131 | 3131 | */ |
3132 | 3132 | function geodir_fb_like_thumbnail(){ |
3133 | 3133 | |
3134 | - // return if not a single post |
|
3135 | - if(!is_single()){return;} |
|
3134 | + // return if not a single post |
|
3135 | + if(!is_single()){return;} |
|
3136 | 3136 | |
3137 | - global $post; |
|
3138 | - if(isset($post->featured_image) && $post->featured_image){ |
|
3139 | - $upload_dir = wp_upload_dir(); |
|
3140 | - $thumb = $upload_dir['baseurl'].$post->featured_image; |
|
3141 | - echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$thumb\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n"; |
|
3137 | + global $post; |
|
3138 | + if(isset($post->featured_image) && $post->featured_image){ |
|
3139 | + $upload_dir = wp_upload_dir(); |
|
3140 | + $thumb = $upload_dir['baseurl'].$post->featured_image; |
|
3141 | + echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$thumb\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n"; |
|
3142 | 3142 | |
3143 | - } |
|
3143 | + } |
|
3144 | 3144 | } |
3145 | 3145 | \ No newline at end of file |
@@ -10,52 +10,52 @@ discard block |
||
10 | 10 | global $wpdb, $table_prefix; |
11 | 11 | |
12 | 12 | if (!function_exists('geodir_column_exist')) { |
13 | - /** |
|
14 | - * Check table column exist or not. |
|
15 | - * |
|
16 | - * @since 1.0.0 |
|
17 | - * @package GeoDirectory |
|
18 | - * @global object $wpdb WordPress Database object. |
|
19 | - * @param string $db The table name. |
|
20 | - * @param string $column The column name. |
|
21 | - * @return bool If column exists returns true. Otherwise false. |
|
22 | - */ |
|
23 | - function geodir_column_exist($db, $column) |
|
24 | - { |
|
25 | - global $wpdb; |
|
26 | - $exists = false; |
|
27 | - $columns = $wpdb->get_col("show columns from $db"); |
|
28 | - foreach ($columns as $c) { |
|
29 | - if ($c == $column) { |
|
30 | - $exists = true; |
|
31 | - break; |
|
32 | - } |
|
33 | - } |
|
34 | - return $exists; |
|
35 | - } |
|
13 | + /** |
|
14 | + * Check table column exist or not. |
|
15 | + * |
|
16 | + * @since 1.0.0 |
|
17 | + * @package GeoDirectory |
|
18 | + * @global object $wpdb WordPress Database object. |
|
19 | + * @param string $db The table name. |
|
20 | + * @param string $column The column name. |
|
21 | + * @return bool If column exists returns true. Otherwise false. |
|
22 | + */ |
|
23 | + function geodir_column_exist($db, $column) |
|
24 | + { |
|
25 | + global $wpdb; |
|
26 | + $exists = false; |
|
27 | + $columns = $wpdb->get_col("show columns from $db"); |
|
28 | + foreach ($columns as $c) { |
|
29 | + if ($c == $column) { |
|
30 | + $exists = true; |
|
31 | + break; |
|
32 | + } |
|
33 | + } |
|
34 | + return $exists; |
|
35 | + } |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | if (!function_exists('geodir_add_column_if_not_exist')) { |
39 | - /** |
|
40 | - * Add column if table column not exist. |
|
41 | - * |
|
42 | - * @since 1.0.0 |
|
43 | - * @package GeoDirectory |
|
44 | - * @global object $wpdb WordPress Database object. |
|
45 | - * @param string $db The table name. |
|
46 | - * @param string $column The column name. |
|
47 | - * @param string $column_attr The column attributes. |
|
48 | - */ |
|
49 | - function geodir_add_column_if_not_exist($db, $column, $column_attr = "VARCHAR( 255 ) NOT NULL") |
|
50 | - { |
|
51 | - global $wpdb; |
|
52 | - $result = 0;// no rows affected |
|
53 | - if (!geodir_column_exist($db, $column)) { |
|
54 | - if (!empty($db) && !empty($column)) |
|
55 | - $result = $wpdb->query("ALTER TABLE `$db` ADD `$column` $column_attr"); |
|
56 | - } |
|
57 | - return $result; |
|
58 | - } |
|
39 | + /** |
|
40 | + * Add column if table column not exist. |
|
41 | + * |
|
42 | + * @since 1.0.0 |
|
43 | + * @package GeoDirectory |
|
44 | + * @global object $wpdb WordPress Database object. |
|
45 | + * @param string $db The table name. |
|
46 | + * @param string $column The column name. |
|
47 | + * @param string $column_attr The column attributes. |
|
48 | + */ |
|
49 | + function geodir_add_column_if_not_exist($db, $column, $column_attr = "VARCHAR( 255 ) NOT NULL") |
|
50 | + { |
|
51 | + global $wpdb; |
|
52 | + $result = 0;// no rows affected |
|
53 | + if (!geodir_column_exist($db, $column)) { |
|
54 | + if (!empty($db) && !empty($column)) |
|
55 | + $result = $wpdb->query("ALTER TABLE `$db` ADD `$column` $column_attr"); |
|
56 | + } |
|
57 | + return $result; |
|
58 | + } |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -72,706 +72,706 @@ discard block |
||
72 | 72 | */ |
73 | 73 | function geodir_post_custom_fields($package_id = '', $default = 'all', $post_type = 'gd_place', $fields_location = 'none') |
74 | 74 | { |
75 | - global $wpdb, $geodir_post_custom_fields_cache; |
|
76 | - |
|
77 | - $cache_stored = $post_type . '_' . $package_id . '_' . $default . '_' . $fields_location; |
|
78 | - |
|
79 | - if (array_key_exists($cache_stored, $geodir_post_custom_fields_cache)) { |
|
80 | - return $geodir_post_custom_fields_cache[$cache_stored]; |
|
81 | - } |
|
82 | - |
|
83 | - $default_query = ''; |
|
84 | - |
|
85 | - if ($default == 'default') |
|
86 | - $default_query .= " and is_admin IN ('1') "; |
|
87 | - elseif ($default == 'custom') |
|
88 | - $default_query .= " and is_admin = '0' "; |
|
89 | - |
|
90 | - if ($fields_location == 'none') { |
|
91 | - } else{ |
|
92 | - $fields_location = esc_sql( $fields_location ); |
|
93 | - $default_query .= " and show_in LIKE '%%[$fields_location]%%' "; |
|
94 | - } |
|
95 | - |
|
96 | - $post_meta_info = $wpdb->get_results( |
|
97 | - $wpdb->prepare( |
|
98 | - "select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where is_active = '1' and post_type = %s {$default_query} order by sort_order asc,admin_title asc", |
|
99 | - array($post_type) |
|
100 | - ) |
|
101 | - ); |
|
102 | - |
|
103 | - |
|
104 | - $return_arr = array(); |
|
105 | - if ($post_meta_info) { |
|
106 | - |
|
107 | - foreach ($post_meta_info as $post_meta_info_obj) { |
|
108 | - |
|
109 | - $custom_fields = array( |
|
110 | - "name" => $post_meta_info_obj->htmlvar_name, |
|
111 | - "label" => $post_meta_info_obj->clabels, |
|
112 | - "default" => $post_meta_info_obj->default_value, |
|
113 | - "type" => $post_meta_info_obj->field_type, |
|
114 | - "desc" => $post_meta_info_obj->admin_desc); |
|
115 | - |
|
116 | - if ($post_meta_info_obj->field_type) { |
|
117 | - $options = explode(',', $post_meta_info_obj->option_values); |
|
118 | - $custom_fields["options"] = $options; |
|
119 | - } |
|
120 | - |
|
121 | - foreach ($post_meta_info_obj as $key => $val) { |
|
122 | - $custom_fields[$key] = $val; |
|
123 | - } |
|
124 | - |
|
125 | - $pricearr = array(); |
|
126 | - $pricearr = explode(',', $post_meta_info_obj->packages); |
|
127 | - |
|
128 | - if ($package_id != '' && in_array($package_id, $pricearr)) { |
|
129 | - $return_arr[$post_meta_info_obj->sort_order] = $custom_fields; |
|
130 | - } elseif ($package_id == '') { |
|
131 | - $return_arr[$post_meta_info_obj->sort_order] = $custom_fields; |
|
132 | - } |
|
133 | - } |
|
134 | - } |
|
135 | - $geodir_post_custom_fields_cache[$cache_stored] = $return_arr; |
|
136 | - |
|
137 | - if (has_filter('geodir_filter_geodir_post_custom_fields')) { |
|
138 | - /** |
|
139 | - * Filter the post custom fields array. |
|
140 | - * |
|
141 | - * @since 1.0.0 |
|
142 | - * |
|
143 | - * @param array $return_arr Post custom fields array. |
|
144 | - * @param int|string $package_id The package ID. |
|
145 | - * @param string $post_type Optional. The wordpress post type. |
|
146 | - * @param string $fields_location Optional. Where exactly are you going to place this custom fields?. |
|
147 | - */ |
|
148 | - $return_arr = apply_filters('geodir_filter_geodir_post_custom_fields', $return_arr, $package_id, $post_type, $fields_location); |
|
149 | - } |
|
150 | - |
|
151 | - return $return_arr; |
|
75 | + global $wpdb, $geodir_post_custom_fields_cache; |
|
76 | + |
|
77 | + $cache_stored = $post_type . '_' . $package_id . '_' . $default . '_' . $fields_location; |
|
78 | + |
|
79 | + if (array_key_exists($cache_stored, $geodir_post_custom_fields_cache)) { |
|
80 | + return $geodir_post_custom_fields_cache[$cache_stored]; |
|
81 | + } |
|
82 | + |
|
83 | + $default_query = ''; |
|
84 | + |
|
85 | + if ($default == 'default') |
|
86 | + $default_query .= " and is_admin IN ('1') "; |
|
87 | + elseif ($default == 'custom') |
|
88 | + $default_query .= " and is_admin = '0' "; |
|
89 | + |
|
90 | + if ($fields_location == 'none') { |
|
91 | + } else{ |
|
92 | + $fields_location = esc_sql( $fields_location ); |
|
93 | + $default_query .= " and show_in LIKE '%%[$fields_location]%%' "; |
|
94 | + } |
|
95 | + |
|
96 | + $post_meta_info = $wpdb->get_results( |
|
97 | + $wpdb->prepare( |
|
98 | + "select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where is_active = '1' and post_type = %s {$default_query} order by sort_order asc,admin_title asc", |
|
99 | + array($post_type) |
|
100 | + ) |
|
101 | + ); |
|
102 | + |
|
103 | + |
|
104 | + $return_arr = array(); |
|
105 | + if ($post_meta_info) { |
|
106 | + |
|
107 | + foreach ($post_meta_info as $post_meta_info_obj) { |
|
108 | + |
|
109 | + $custom_fields = array( |
|
110 | + "name" => $post_meta_info_obj->htmlvar_name, |
|
111 | + "label" => $post_meta_info_obj->clabels, |
|
112 | + "default" => $post_meta_info_obj->default_value, |
|
113 | + "type" => $post_meta_info_obj->field_type, |
|
114 | + "desc" => $post_meta_info_obj->admin_desc); |
|
115 | + |
|
116 | + if ($post_meta_info_obj->field_type) { |
|
117 | + $options = explode(',', $post_meta_info_obj->option_values); |
|
118 | + $custom_fields["options"] = $options; |
|
119 | + } |
|
120 | + |
|
121 | + foreach ($post_meta_info_obj as $key => $val) { |
|
122 | + $custom_fields[$key] = $val; |
|
123 | + } |
|
124 | + |
|
125 | + $pricearr = array(); |
|
126 | + $pricearr = explode(',', $post_meta_info_obj->packages); |
|
127 | + |
|
128 | + if ($package_id != '' && in_array($package_id, $pricearr)) { |
|
129 | + $return_arr[$post_meta_info_obj->sort_order] = $custom_fields; |
|
130 | + } elseif ($package_id == '') { |
|
131 | + $return_arr[$post_meta_info_obj->sort_order] = $custom_fields; |
|
132 | + } |
|
133 | + } |
|
134 | + } |
|
135 | + $geodir_post_custom_fields_cache[$cache_stored] = $return_arr; |
|
136 | + |
|
137 | + if (has_filter('geodir_filter_geodir_post_custom_fields')) { |
|
138 | + /** |
|
139 | + * Filter the post custom fields array. |
|
140 | + * |
|
141 | + * @since 1.0.0 |
|
142 | + * |
|
143 | + * @param array $return_arr Post custom fields array. |
|
144 | + * @param int|string $package_id The package ID. |
|
145 | + * @param string $post_type Optional. The wordpress post type. |
|
146 | + * @param string $fields_location Optional. Where exactly are you going to place this custom fields?. |
|
147 | + */ |
|
148 | + $return_arr = apply_filters('geodir_filter_geodir_post_custom_fields', $return_arr, $package_id, $post_type, $fields_location); |
|
149 | + } |
|
150 | + |
|
151 | + return $return_arr; |
|
152 | 152 | } |
153 | 153 | |
154 | - /** |
|
155 | - * Adds admin html for custom fields. |
|
156 | - * |
|
157 | - * @since 1.0.0 |
|
158 | - * @package GeoDirectory |
|
159 | - * @global object $wpdb WordPress Database object. |
|
160 | - * @param string $field_type The form field type. |
|
161 | - * @param object|int $result_str The custom field results object or row id. |
|
162 | - * @param string $field_ins_upd When set to "submit" displays form. |
|
163 | - * @param string $field_type_key The key of the custom field. |
|
164 | - */ |
|
165 | - function geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key ='') |
|
166 | - { |
|
167 | - global $wpdb; |
|
168 | - $cf = $result_str; |
|
169 | - if (!is_object($cf)) { |
|
170 | - |
|
171 | - $field_info = $wpdb->get_row($wpdb->prepare("select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf))); |
|
172 | - |
|
173 | - } else { |
|
174 | - $field_info = $cf; |
|
175 | - $result_str = $cf->id; |
|
176 | - } |
|
177 | - /** |
|
178 | - * Contains custom field html. |
|
179 | - * |
|
180 | - * @since 1.0.0 |
|
181 | - */ |
|
182 | - include('custom_field_html.php'); |
|
183 | - |
|
184 | - } |
|
154 | + /** |
|
155 | + * Adds admin html for custom fields. |
|
156 | + * |
|
157 | + * @since 1.0.0 |
|
158 | + * @package GeoDirectory |
|
159 | + * @global object $wpdb WordPress Database object. |
|
160 | + * @param string $field_type The form field type. |
|
161 | + * @param object|int $result_str The custom field results object or row id. |
|
162 | + * @param string $field_ins_upd When set to "submit" displays form. |
|
163 | + * @param string $field_type_key The key of the custom field. |
|
164 | + */ |
|
165 | + function geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key ='') |
|
166 | + { |
|
167 | + global $wpdb; |
|
168 | + $cf = $result_str; |
|
169 | + if (!is_object($cf)) { |
|
170 | + |
|
171 | + $field_info = $wpdb->get_row($wpdb->prepare("select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf))); |
|
172 | + |
|
173 | + } else { |
|
174 | + $field_info = $cf; |
|
175 | + $result_str = $cf->id; |
|
176 | + } |
|
177 | + /** |
|
178 | + * Contains custom field html. |
|
179 | + * |
|
180 | + * @since 1.0.0 |
|
181 | + */ |
|
182 | + include('custom_field_html.php'); |
|
183 | + |
|
184 | + } |
|
185 | 185 | |
186 | 186 | |
187 | 187 | if (!function_exists('geodir_custom_field_delete')) { |
188 | - /** |
|
189 | - * Delete custom field using field id. |
|
190 | - * |
|
191 | - * @since 1.0.0 |
|
192 | - * @since 1.5.7 Delete field from sorting fields table when custom field deleted. |
|
193 | - * @package GeoDirectory |
|
194 | - * @global object $wpdb WordPress Database object. |
|
195 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
196 | - * @param string $field_id The custom field ID. |
|
197 | - * @return int|string If field deleted successfully, returns field id. Otherwise returns 0. |
|
198 | - */ |
|
199 | - function geodir_custom_field_delete($field_id = '') { |
|
200 | - global $wpdb, $plugin_prefix; |
|
201 | - |
|
202 | - if ($field_id != '') { |
|
203 | - $cf = trim($field_id, '_'); |
|
204 | - |
|
205 | - if ($field = $wpdb->get_row($wpdb->prepare("select htmlvar_name,post_type,field_type from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)))) { |
|
206 | - $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d ", array($cf))); |
|
207 | - |
|
208 | - $post_type = $field->post_type; |
|
209 | - $htmlvar_name = $field->htmlvar_name; |
|
210 | - |
|
211 | - if ($post_type != '' && $htmlvar_name != '') { |
|
212 | - $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name=%s AND post_type=%s LIMIT 1", array($htmlvar_name, $post_type))); |
|
213 | - } |
|
214 | - |
|
215 | - /** |
|
216 | - * Called after a custom field is deleted. |
|
217 | - * |
|
218 | - * @since 1.0.0 |
|
219 | - * @param string $cf The fields ID. |
|
220 | - * @param string $field->htmlvar_name The html variable name for the field. |
|
221 | - * @param string $post_type The post type the field belongs to. |
|
222 | - */ |
|
223 | - do_action('geodir_after_custom_field_deleted', $cf, $field->htmlvar_name, $post_type); |
|
224 | - |
|
225 | - if ($field->field_type == 'address') { |
|
226 | - $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_address`"); |
|
227 | - $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_city`"); |
|
228 | - $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_region`"); |
|
229 | - $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_country`"); |
|
230 | - $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_zip`"); |
|
231 | - $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_latitude`"); |
|
232 | - $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_longitude`"); |
|
233 | - $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapview`"); |
|
234 | - $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapzoom`"); |
|
235 | - } else { |
|
236 | - if ($field->field_type != 'fieldset') { |
|
237 | - $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "`"); |
|
238 | - } |
|
239 | - } |
|
240 | - |
|
241 | - return $field_id; |
|
242 | - } else |
|
243 | - return 0; |
|
244 | - } else |
|
245 | - return 0; |
|
246 | - } |
|
188 | + /** |
|
189 | + * Delete custom field using field id. |
|
190 | + * |
|
191 | + * @since 1.0.0 |
|
192 | + * @since 1.5.7 Delete field from sorting fields table when custom field deleted. |
|
193 | + * @package GeoDirectory |
|
194 | + * @global object $wpdb WordPress Database object. |
|
195 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
196 | + * @param string $field_id The custom field ID. |
|
197 | + * @return int|string If field deleted successfully, returns field id. Otherwise returns 0. |
|
198 | + */ |
|
199 | + function geodir_custom_field_delete($field_id = '') { |
|
200 | + global $wpdb, $plugin_prefix; |
|
201 | + |
|
202 | + if ($field_id != '') { |
|
203 | + $cf = trim($field_id, '_'); |
|
204 | + |
|
205 | + if ($field = $wpdb->get_row($wpdb->prepare("select htmlvar_name,post_type,field_type from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)))) { |
|
206 | + $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d ", array($cf))); |
|
207 | + |
|
208 | + $post_type = $field->post_type; |
|
209 | + $htmlvar_name = $field->htmlvar_name; |
|
210 | + |
|
211 | + if ($post_type != '' && $htmlvar_name != '') { |
|
212 | + $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name=%s AND post_type=%s LIMIT 1", array($htmlvar_name, $post_type))); |
|
213 | + } |
|
214 | + |
|
215 | + /** |
|
216 | + * Called after a custom field is deleted. |
|
217 | + * |
|
218 | + * @since 1.0.0 |
|
219 | + * @param string $cf The fields ID. |
|
220 | + * @param string $field->htmlvar_name The html variable name for the field. |
|
221 | + * @param string $post_type The post type the field belongs to. |
|
222 | + */ |
|
223 | + do_action('geodir_after_custom_field_deleted', $cf, $field->htmlvar_name, $post_type); |
|
224 | + |
|
225 | + if ($field->field_type == 'address') { |
|
226 | + $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_address`"); |
|
227 | + $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_city`"); |
|
228 | + $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_region`"); |
|
229 | + $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_country`"); |
|
230 | + $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_zip`"); |
|
231 | + $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_latitude`"); |
|
232 | + $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_longitude`"); |
|
233 | + $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapview`"); |
|
234 | + $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapzoom`"); |
|
235 | + } else { |
|
236 | + if ($field->field_type != 'fieldset') { |
|
237 | + $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "`"); |
|
238 | + } |
|
239 | + } |
|
240 | + |
|
241 | + return $field_id; |
|
242 | + } else |
|
243 | + return 0; |
|
244 | + } else |
|
245 | + return 0; |
|
246 | + } |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | if (!function_exists('geodir_custom_field_save')) { |
250 | - /** |
|
251 | - * Save or Update custom fields into the database. |
|
252 | - * |
|
253 | - * @since 1.0.0 |
|
254 | - * @since 1.5.6 Fix for saving multiselect custom field "Display Type" on first attempt. |
|
255 | - * @package GeoDirectory |
|
256 | - * @global object $wpdb WordPress Database object. |
|
257 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
258 | - * @param array $request_field { |
|
259 | - * Attributes of the request field array. |
|
260 | - * |
|
261 | - * @type string $action Ajax Action name. Default "geodir_ajax_action". |
|
262 | - * @type string $manage_field_type Field type Default "custom_fields". |
|
263 | - * @type string $create_field Create field Default "true". |
|
264 | - * @type string $field_ins_upd Field ins upd Default "submit". |
|
265 | - * @type string $_wpnonce WP nonce value. |
|
266 | - * @type string $listing_type Listing type Example "gd_place". |
|
267 | - * @type string $field_type Field type Example "radio". |
|
268 | - * @type string $field_id Field id Example "12". |
|
269 | - * @type string $data_type Data type Example "VARCHAR". |
|
270 | - * @type string $is_active Either "1" or "0". If "0" is used then the field will not be displayed anywhere. |
|
271 | - * @type array $show_on_pkg Package list to display this field. |
|
272 | - * @type string $admin_title Personal comment, it would not be displayed anywhere except in custom field settings. |
|
273 | - * @type string $site_title Section title which you wish to display in frontend. |
|
274 | - * @type string $admin_desc Section description which will appear in frontend. |
|
275 | - * @type string $htmlvar_name Html variable name. This should be a unique name. |
|
276 | - * @type string $clabels Section Title which will appear in backend. |
|
277 | - * @type string $default_value The default value (for "link" this will be used as the link text). |
|
278 | - * @type string $sort_order The display order of this field in backend. e.g. 5. |
|
279 | - * @type string $is_default Either "1" or "0". If "0" is used then the field will be displayed as main form field or additional field. |
|
280 | - * @type string $for_admin_use Either "1" or "0". If "0" is used then only site admin can edit this field. |
|
281 | - * @type string $is_required Use "1" to set field as required. |
|
282 | - * @type string $required_msg Enter text for error message if field required and have not full fill requirement. |
|
283 | - * @type string $show_on_listing Want to show this on listing page?. |
|
284 | - * @type string $show_in What locations to show the custom field in. |
|
285 | - * @type string $show_on_detail Want to show this in More Info tab on detail page?. |
|
286 | - * @type string $show_as_tab Want to display this as a tab on detail page? If "1" then "Show on detail page?" must be Yes. |
|
287 | - * @type string $option_values Option Values should be separated by comma. |
|
288 | - * @type string $field_icon Upload icon using media and enter its url path, or enter font awesome class. |
|
289 | - * @type string $css_class Enter custom css class for field custom style. |
|
290 | - * @type array $extra_fields An array of extra fields to store. |
|
291 | - * |
|
292 | - * } |
|
293 | - * @param bool $default Not yet implemented. |
|
294 | - * @return int|string If field is unique returns inserted row id. Otherwise returns error string. |
|
295 | - */ |
|
296 | - function geodir_custom_field_save($request_field = array(), $default = false) |
|
297 | - { |
|
298 | - |
|
299 | - global $wpdb, $plugin_prefix; |
|
300 | - |
|
301 | - $old_html_variable = ''; |
|
302 | - |
|
303 | - $data_type = trim($request_field['data_type']); |
|
304 | - |
|
305 | - $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : ''; |
|
306 | - |
|
307 | - // some servers fail if a POST value is VARCHAR so we change it. |
|
308 | - if(isset($request_field['data_type']) && $request_field['data_type']=='XVARCHAR'){ |
|
309 | - $request_field['data_type'] = 'VARCHAR'; |
|
310 | - } |
|
311 | - |
|
312 | - $cf = trim($result_str, '_'); |
|
313 | - |
|
314 | - |
|
315 | - /*-------- check duplicate validation --------*/ |
|
316 | - |
|
317 | - $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
318 | - $post_type = $request_field['listing_type']; |
|
319 | - |
|
320 | - if ($request_field['field_type'] != 'address' && $request_field['field_type'] != 'taxonomy' && $request_field['field_type'] != 'fieldset') { |
|
321 | - $cehhtmlvar_name = 'geodir_' . $cehhtmlvar_name; |
|
322 | - } |
|
323 | - |
|
324 | - $check_html_variable = $wpdb->get_var( |
|
325 | - $wpdb->prepare( |
|
326 | - "select htmlvar_name from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id <> %d and htmlvar_name = %s and post_type = %s ", |
|
327 | - array($cf, $cehhtmlvar_name, $post_type) |
|
328 | - ) |
|
329 | - ); |
|
330 | - |
|
331 | - |
|
332 | - if (!$check_html_variable || $request_field['field_type'] == 'fieldset') { |
|
333 | - |
|
334 | - if ($cf != '') { |
|
335 | - |
|
336 | - $post_meta_info = $wpdb->get_row( |
|
337 | - $wpdb->prepare( |
|
338 | - "select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id = %d", |
|
339 | - array($cf) |
|
340 | - ) |
|
341 | - ); |
|
342 | - |
|
343 | - } |
|
344 | - |
|
345 | - if (!empty($post_meta_info)) { |
|
346 | - $post_val = $post_meta_info; |
|
347 | - $old_html_variable = $post_val->htmlvar_name; |
|
348 | - |
|
349 | - } |
|
350 | - |
|
351 | - |
|
352 | - |
|
353 | - if ($post_type == '') $post_type = 'gd_place'; |
|
354 | - |
|
355 | - |
|
356 | - $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
357 | - |
|
358 | - $admin_title = $request_field['admin_title']; |
|
359 | - $site_title = $request_field['site_title']; |
|
360 | - $data_type = $request_field['data_type']; |
|
361 | - $field_type = $request_field['field_type']; |
|
362 | - $field_type_key = isset($request_field['field_type_key']) ? $request_field['field_type_key'] : $field_type; |
|
363 | - $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
364 | - $admin_desc = $request_field['admin_desc']; |
|
365 | - $clabels = isset($request_field['clabels']) ? $request_field['clabels'] : ''; |
|
366 | - $default_value = isset($request_field['default_value']) ? $request_field['default_value'] : ''; |
|
367 | - $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : ''; |
|
368 | - $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : ''; |
|
369 | - $is_required = isset($request_field['is_required']) ? $request_field['is_required'] : ''; |
|
370 | - $required_msg = isset($request_field['required_msg']) ? $request_field['required_msg'] : ''; |
|
371 | - $css_class = isset($request_field['css_class']) ? $request_field['css_class'] : ''; |
|
372 | - $field_icon = isset($request_field['field_icon']) ? $request_field['field_icon'] : ''; |
|
373 | - $show_on_listing = isset($request_field['show_on_listing']) ? $request_field['show_on_listing'] : ''; |
|
374 | - $show_in = isset($request_field['show_in']) ? $request_field['show_in'] : ''; |
|
375 | - $show_on_detail = isset($request_field['show_on_detail']) ? $request_field['show_on_detail'] : ''; |
|
376 | - $show_as_tab = isset($request_field['show_as_tab']) ? $request_field['show_as_tab'] : ''; |
|
377 | - $decimal_point = isset($request_field['decimal_point']) ? trim($request_field['decimal_point']) : ''; // decimal point for DECIMAL data type |
|
378 | - $decimal_point = $decimal_point > 0 ? ($decimal_point > 10 ? 10 : $decimal_point) : ''; |
|
379 | - $validation_pattern = isset($request_field['validation_pattern']) ? $request_field['validation_pattern'] : ''; |
|
380 | - $validation_msg = isset($request_field['validation_msg']) ? $request_field['validation_msg'] : ''; |
|
381 | - $for_admin_use = isset($request_field['for_admin_use']) ? $request_field['for_admin_use'] : ''; |
|
250 | + /** |
|
251 | + * Save or Update custom fields into the database. |
|
252 | + * |
|
253 | + * @since 1.0.0 |
|
254 | + * @since 1.5.6 Fix for saving multiselect custom field "Display Type" on first attempt. |
|
255 | + * @package GeoDirectory |
|
256 | + * @global object $wpdb WordPress Database object. |
|
257 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
258 | + * @param array $request_field { |
|
259 | + * Attributes of the request field array. |
|
260 | + * |
|
261 | + * @type string $action Ajax Action name. Default "geodir_ajax_action". |
|
262 | + * @type string $manage_field_type Field type Default "custom_fields". |
|
263 | + * @type string $create_field Create field Default "true". |
|
264 | + * @type string $field_ins_upd Field ins upd Default "submit". |
|
265 | + * @type string $_wpnonce WP nonce value. |
|
266 | + * @type string $listing_type Listing type Example "gd_place". |
|
267 | + * @type string $field_type Field type Example "radio". |
|
268 | + * @type string $field_id Field id Example "12". |
|
269 | + * @type string $data_type Data type Example "VARCHAR". |
|
270 | + * @type string $is_active Either "1" or "0". If "0" is used then the field will not be displayed anywhere. |
|
271 | + * @type array $show_on_pkg Package list to display this field. |
|
272 | + * @type string $admin_title Personal comment, it would not be displayed anywhere except in custom field settings. |
|
273 | + * @type string $site_title Section title which you wish to display in frontend. |
|
274 | + * @type string $admin_desc Section description which will appear in frontend. |
|
275 | + * @type string $htmlvar_name Html variable name. This should be a unique name. |
|
276 | + * @type string $clabels Section Title which will appear in backend. |
|
277 | + * @type string $default_value The default value (for "link" this will be used as the link text). |
|
278 | + * @type string $sort_order The display order of this field in backend. e.g. 5. |
|
279 | + * @type string $is_default Either "1" or "0". If "0" is used then the field will be displayed as main form field or additional field. |
|
280 | + * @type string $for_admin_use Either "1" or "0". If "0" is used then only site admin can edit this field. |
|
281 | + * @type string $is_required Use "1" to set field as required. |
|
282 | + * @type string $required_msg Enter text for error message if field required and have not full fill requirement. |
|
283 | + * @type string $show_on_listing Want to show this on listing page?. |
|
284 | + * @type string $show_in What locations to show the custom field in. |
|
285 | + * @type string $show_on_detail Want to show this in More Info tab on detail page?. |
|
286 | + * @type string $show_as_tab Want to display this as a tab on detail page? If "1" then "Show on detail page?" must be Yes. |
|
287 | + * @type string $option_values Option Values should be separated by comma. |
|
288 | + * @type string $field_icon Upload icon using media and enter its url path, or enter font awesome class. |
|
289 | + * @type string $css_class Enter custom css class for field custom style. |
|
290 | + * @type array $extra_fields An array of extra fields to store. |
|
291 | + * |
|
292 | + * } |
|
293 | + * @param bool $default Not yet implemented. |
|
294 | + * @return int|string If field is unique returns inserted row id. Otherwise returns error string. |
|
295 | + */ |
|
296 | + function geodir_custom_field_save($request_field = array(), $default = false) |
|
297 | + { |
|
298 | + |
|
299 | + global $wpdb, $plugin_prefix; |
|
300 | + |
|
301 | + $old_html_variable = ''; |
|
302 | + |
|
303 | + $data_type = trim($request_field['data_type']); |
|
304 | + |
|
305 | + $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : ''; |
|
306 | + |
|
307 | + // some servers fail if a POST value is VARCHAR so we change it. |
|
308 | + if(isset($request_field['data_type']) && $request_field['data_type']=='XVARCHAR'){ |
|
309 | + $request_field['data_type'] = 'VARCHAR'; |
|
310 | + } |
|
311 | + |
|
312 | + $cf = trim($result_str, '_'); |
|
313 | + |
|
314 | + |
|
315 | + /*-------- check duplicate validation --------*/ |
|
316 | + |
|
317 | + $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
318 | + $post_type = $request_field['listing_type']; |
|
319 | + |
|
320 | + if ($request_field['field_type'] != 'address' && $request_field['field_type'] != 'taxonomy' && $request_field['field_type'] != 'fieldset') { |
|
321 | + $cehhtmlvar_name = 'geodir_' . $cehhtmlvar_name; |
|
322 | + } |
|
323 | + |
|
324 | + $check_html_variable = $wpdb->get_var( |
|
325 | + $wpdb->prepare( |
|
326 | + "select htmlvar_name from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id <> %d and htmlvar_name = %s and post_type = %s ", |
|
327 | + array($cf, $cehhtmlvar_name, $post_type) |
|
328 | + ) |
|
329 | + ); |
|
330 | + |
|
331 | + |
|
332 | + if (!$check_html_variable || $request_field['field_type'] == 'fieldset') { |
|
333 | + |
|
334 | + if ($cf != '') { |
|
335 | + |
|
336 | + $post_meta_info = $wpdb->get_row( |
|
337 | + $wpdb->prepare( |
|
338 | + "select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id = %d", |
|
339 | + array($cf) |
|
340 | + ) |
|
341 | + ); |
|
342 | + |
|
343 | + } |
|
344 | + |
|
345 | + if (!empty($post_meta_info)) { |
|
346 | + $post_val = $post_meta_info; |
|
347 | + $old_html_variable = $post_val->htmlvar_name; |
|
348 | + |
|
349 | + } |
|
350 | + |
|
351 | + |
|
352 | + |
|
353 | + if ($post_type == '') $post_type = 'gd_place'; |
|
354 | + |
|
355 | + |
|
356 | + $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
357 | + |
|
358 | + $admin_title = $request_field['admin_title']; |
|
359 | + $site_title = $request_field['site_title']; |
|
360 | + $data_type = $request_field['data_type']; |
|
361 | + $field_type = $request_field['field_type']; |
|
362 | + $field_type_key = isset($request_field['field_type_key']) ? $request_field['field_type_key'] : $field_type; |
|
363 | + $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
364 | + $admin_desc = $request_field['admin_desc']; |
|
365 | + $clabels = isset($request_field['clabels']) ? $request_field['clabels'] : ''; |
|
366 | + $default_value = isset($request_field['default_value']) ? $request_field['default_value'] : ''; |
|
367 | + $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : ''; |
|
368 | + $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : ''; |
|
369 | + $is_required = isset($request_field['is_required']) ? $request_field['is_required'] : ''; |
|
370 | + $required_msg = isset($request_field['required_msg']) ? $request_field['required_msg'] : ''; |
|
371 | + $css_class = isset($request_field['css_class']) ? $request_field['css_class'] : ''; |
|
372 | + $field_icon = isset($request_field['field_icon']) ? $request_field['field_icon'] : ''; |
|
373 | + $show_on_listing = isset($request_field['show_on_listing']) ? $request_field['show_on_listing'] : ''; |
|
374 | + $show_in = isset($request_field['show_in']) ? $request_field['show_in'] : ''; |
|
375 | + $show_on_detail = isset($request_field['show_on_detail']) ? $request_field['show_on_detail'] : ''; |
|
376 | + $show_as_tab = isset($request_field['show_as_tab']) ? $request_field['show_as_tab'] : ''; |
|
377 | + $decimal_point = isset($request_field['decimal_point']) ? trim($request_field['decimal_point']) : ''; // decimal point for DECIMAL data type |
|
378 | + $decimal_point = $decimal_point > 0 ? ($decimal_point > 10 ? 10 : $decimal_point) : ''; |
|
379 | + $validation_pattern = isset($request_field['validation_pattern']) ? $request_field['validation_pattern'] : ''; |
|
380 | + $validation_msg = isset($request_field['validation_msg']) ? $request_field['validation_msg'] : ''; |
|
381 | + $for_admin_use = isset($request_field['for_admin_use']) ? $request_field['for_admin_use'] : ''; |
|
382 | 382 | |
383 | 383 | |
384 | - if(is_array($show_in)){ |
|
385 | - $show_in = implode(",", $request_field['show_in']); |
|
386 | - } |
|
384 | + if(is_array($show_in)){ |
|
385 | + $show_in = implode(",", $request_field['show_in']); |
|
386 | + } |
|
387 | 387 | |
388 | - if ($field_type != 'address' && $field_type != 'taxonomy' && $field_type != 'fieldset') { |
|
389 | - $htmlvar_name = 'geodir_' . $htmlvar_name; |
|
390 | - } |
|
388 | + if ($field_type != 'address' && $field_type != 'taxonomy' && $field_type != 'fieldset') { |
|
389 | + $htmlvar_name = 'geodir_' . $htmlvar_name; |
|
390 | + } |
|
391 | 391 | |
392 | - $option_values = ''; |
|
393 | - if (isset($request_field['option_values'])) |
|
394 | - $option_values = $request_field['option_values']; |
|
392 | + $option_values = ''; |
|
393 | + if (isset($request_field['option_values'])) |
|
394 | + $option_values = $request_field['option_values']; |
|
395 | 395 | |
396 | - $cat_sort = isset($request_field['cat_sort']) ? $request_field['cat_sort'] : '0'; |
|
396 | + $cat_sort = isset($request_field['cat_sort']) ? $request_field['cat_sort'] : '0'; |
|
397 | 397 | |
398 | - $cat_filter = isset($request_field['cat_filter']) ? $request_field['cat_filter'] : '0'; |
|
398 | + $cat_filter = isset($request_field['cat_filter']) ? $request_field['cat_filter'] : '0'; |
|
399 | 399 | |
400 | - if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg'])) |
|
401 | - $price_pkg = implode(",", $request_field['show_on_pkg']); |
|
402 | - else { |
|
403 | - $package_info = array(); |
|
400 | + if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg'])) |
|
401 | + $price_pkg = implode(",", $request_field['show_on_pkg']); |
|
402 | + else { |
|
403 | + $package_info = array(); |
|
404 | 404 | |
405 | - $package_info = geodir_post_package_info($package_info, '', $post_type); |
|
406 | - $price_pkg = !empty($package_info->pid) ? $package_info->pid : ''; |
|
407 | - } |
|
405 | + $package_info = geodir_post_package_info($package_info, '', $post_type); |
|
406 | + $price_pkg = !empty($package_info->pid) ? $package_info->pid : ''; |
|
407 | + } |
|
408 | 408 | |
409 | 409 | |
410 | - if (isset($request_field['extra']) && !empty($request_field['extra'])) |
|
411 | - $extra_fields = $request_field['extra']; |
|
410 | + if (isset($request_field['extra']) && !empty($request_field['extra'])) |
|
411 | + $extra_fields = $request_field['extra']; |
|
412 | 412 | |
413 | - if (isset($request_field['is_default']) && $request_field['is_default'] != '') |
|
414 | - $is_default = $request_field['is_default']; |
|
415 | - else |
|
416 | - $is_default = '0'; |
|
413 | + if (isset($request_field['is_default']) && $request_field['is_default'] != '') |
|
414 | + $is_default = $request_field['is_default']; |
|
415 | + else |
|
416 | + $is_default = '0'; |
|
417 | 417 | |
418 | - if (isset($request_field['is_admin']) && $request_field['is_admin'] != '') |
|
419 | - $is_admin = $request_field['is_admin']; |
|
420 | - else |
|
421 | - $is_admin = '0'; |
|
418 | + if (isset($request_field['is_admin']) && $request_field['is_admin'] != '') |
|
419 | + $is_admin = $request_field['is_admin']; |
|
420 | + else |
|
421 | + $is_admin = '0'; |
|
422 | 422 | |
423 | 423 | |
424 | - if ($is_active == '') $is_active = 1; |
|
425 | - if ($is_required == '') $is_required = 0; |
|
424 | + if ($is_active == '') $is_active = 1; |
|
425 | + if ($is_required == '') $is_required = 0; |
|
426 | 426 | |
427 | 427 | |
428 | - if ($sort_order == '') { |
|
428 | + if ($sort_order == '') { |
|
429 | 429 | |
430 | - $last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM " . GEODIR_CUSTOM_FIELDS_TABLE); |
|
430 | + $last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM " . GEODIR_CUSTOM_FIELDS_TABLE); |
|
431 | 431 | |
432 | - $sort_order = (int)$last_order + 1; |
|
433 | - } |
|
432 | + $sort_order = (int)$last_order + 1; |
|
433 | + } |
|
434 | 434 | |
435 | - $default_value_add = ''; |
|
435 | + $default_value_add = ''; |
|
436 | 436 | |
437 | 437 | |
438 | - if (!empty($post_meta_info)) { |
|
439 | - switch ($field_type): |
|
438 | + if (!empty($post_meta_info)) { |
|
439 | + switch ($field_type): |
|
440 | 440 | |
441 | - case 'address': |
|
441 | + case 'address': |
|
442 | 442 | |
443 | - if ($htmlvar_name != '') { |
|
444 | - $prefix = $htmlvar_name . '_'; |
|
445 | - } |
|
446 | - $old_prefix = $old_html_variable . '_'; |
|
443 | + if ($htmlvar_name != '') { |
|
444 | + $prefix = $htmlvar_name . '_'; |
|
445 | + } |
|
446 | + $old_prefix = $old_html_variable . '_'; |
|
447 | 447 | |
448 | 448 | |
449 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "address` `" . $prefix . "address` VARCHAR( 254 ) NULL"; |
|
449 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "address` `" . $prefix . "address` VARCHAR( 254 ) NULL"; |
|
450 | 450 | |
451 | - if ($default_value != '') { |
|
452 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
453 | - } |
|
451 | + if ($default_value != '') { |
|
452 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
453 | + } |
|
454 | 454 | |
455 | - $wpdb->query($meta_field_add); |
|
455 | + $wpdb->query($meta_field_add); |
|
456 | 456 | |
457 | - if ($extra_fields != '') { |
|
457 | + if ($extra_fields != '') { |
|
458 | 458 | |
459 | - if (isset($extra_fields['show_city']) && $extra_fields['show_city']) { |
|
459 | + if (isset($extra_fields['show_city']) && $extra_fields['show_city']) { |
|
460 | 460 | |
461 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "city'"); |
|
462 | - if ($is_column) { |
|
463 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "city` `" . $prefix . "city` VARCHAR( 50 ) NULL"; |
|
461 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "city'"); |
|
462 | + if ($is_column) { |
|
463 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "city` `" . $prefix . "city` VARCHAR( 50 ) NULL"; |
|
464 | 464 | |
465 | - if ($default_value != '') { |
|
466 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
467 | - } |
|
465 | + if ($default_value != '') { |
|
466 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
467 | + } |
|
468 | 468 | |
469 | - $wpdb->query($meta_field_add); |
|
470 | - } else { |
|
469 | + $wpdb->query($meta_field_add); |
|
470 | + } else { |
|
471 | 471 | |
472 | - $meta_field_add = "VARCHAR( 50 ) NULL"; |
|
473 | - if ($default_value != '') { |
|
474 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
475 | - } |
|
476 | - geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add); |
|
472 | + $meta_field_add = "VARCHAR( 50 ) NULL"; |
|
473 | + if ($default_value != '') { |
|
474 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
475 | + } |
|
476 | + geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add); |
|
477 | 477 | |
478 | - } |
|
478 | + } |
|
479 | 479 | |
480 | 480 | |
481 | - } |
|
481 | + } |
|
482 | 482 | |
483 | 483 | |
484 | - if (isset($extra_fields['show_region']) && $extra_fields['show_region']) { |
|
484 | + if (isset($extra_fields['show_region']) && $extra_fields['show_region']) { |
|
485 | 485 | |
486 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "region'"); |
|
486 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "region'"); |
|
487 | 487 | |
488 | - if ($is_column) { |
|
489 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "region` `" . $prefix . "region` VARCHAR( 50 ) NULL"; |
|
488 | + if ($is_column) { |
|
489 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "region` `" . $prefix . "region` VARCHAR( 50 ) NULL"; |
|
490 | 490 | |
491 | - if ($default_value != '') { |
|
492 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
493 | - } |
|
491 | + if ($default_value != '') { |
|
492 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
493 | + } |
|
494 | 494 | |
495 | - $wpdb->query($meta_field_add); |
|
496 | - } else { |
|
497 | - $meta_field_add = "VARCHAR( 50 ) NULL"; |
|
498 | - if ($default_value != '') { |
|
499 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
500 | - } |
|
495 | + $wpdb->query($meta_field_add); |
|
496 | + } else { |
|
497 | + $meta_field_add = "VARCHAR( 50 ) NULL"; |
|
498 | + if ($default_value != '') { |
|
499 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
500 | + } |
|
501 | 501 | |
502 | - geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add); |
|
503 | - } |
|
502 | + geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add); |
|
503 | + } |
|
504 | 504 | |
505 | - } |
|
506 | - if (isset($extra_fields['show_country']) && $extra_fields['show_country']) { |
|
505 | + } |
|
506 | + if (isset($extra_fields['show_country']) && $extra_fields['show_country']) { |
|
507 | 507 | |
508 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "country'"); |
|
508 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "country'"); |
|
509 | 509 | |
510 | - if ($is_column) { |
|
510 | + if ($is_column) { |
|
511 | 511 | |
512 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "country` `" . $prefix . "country` VARCHAR( 50 ) NULL"; |
|
512 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "country` `" . $prefix . "country` VARCHAR( 50 ) NULL"; |
|
513 | 513 | |
514 | - if ($default_value != '') { |
|
515 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
516 | - } |
|
514 | + if ($default_value != '') { |
|
515 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
516 | + } |
|
517 | 517 | |
518 | - $wpdb->query($meta_field_add); |
|
519 | - } else { |
|
518 | + $wpdb->query($meta_field_add); |
|
519 | + } else { |
|
520 | 520 | |
521 | - $meta_field_add = "VARCHAR( 50 ) NULL"; |
|
522 | - if ($default_value != '') { |
|
523 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
524 | - } |
|
521 | + $meta_field_add = "VARCHAR( 50 ) NULL"; |
|
522 | + if ($default_value != '') { |
|
523 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
524 | + } |
|
525 | 525 | |
526 | - geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add); |
|
526 | + geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add); |
|
527 | 527 | |
528 | - } |
|
528 | + } |
|
529 | 529 | |
530 | - } |
|
531 | - if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) { |
|
530 | + } |
|
531 | + if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) { |
|
532 | 532 | |
533 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "zip'"); |
|
533 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "zip'"); |
|
534 | 534 | |
535 | - if ($is_column) { |
|
535 | + if ($is_column) { |
|
536 | 536 | |
537 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "zip` `" . $prefix . "zip` VARCHAR( 50 ) NULL"; |
|
537 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "zip` `" . $prefix . "zip` VARCHAR( 50 ) NULL"; |
|
538 | 538 | |
539 | - if ($default_value != '') { |
|
540 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
541 | - } |
|
539 | + if ($default_value != '') { |
|
540 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
541 | + } |
|
542 | 542 | |
543 | - $wpdb->query($meta_field_add); |
|
544 | - } else { |
|
543 | + $wpdb->query($meta_field_add); |
|
544 | + } else { |
|
545 | 545 | |
546 | - $meta_field_add = "VARCHAR( 50 ) NULL"; |
|
547 | - if ($default_value != '') { |
|
548 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
549 | - } |
|
546 | + $meta_field_add = "VARCHAR( 50 ) NULL"; |
|
547 | + if ($default_value != '') { |
|
548 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
549 | + } |
|
550 | 550 | |
551 | - geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add); |
|
551 | + geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add); |
|
552 | 552 | |
553 | - } |
|
553 | + } |
|
554 | 554 | |
555 | - } |
|
556 | - if (isset($extra_fields['show_map']) && $extra_fields['show_map']) { |
|
555 | + } |
|
556 | + if (isset($extra_fields['show_map']) && $extra_fields['show_map']) { |
|
557 | 557 | |
558 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latitude'"); |
|
559 | - if ($is_column) { |
|
558 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latitude'"); |
|
559 | + if ($is_column) { |
|
560 | 560 | |
561 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latitude` `" . $prefix . "latitude` VARCHAR( 20 ) NULL"; |
|
561 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latitude` `" . $prefix . "latitude` VARCHAR( 20 ) NULL"; |
|
562 | 562 | |
563 | - if ($default_value != '') { |
|
564 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
565 | - } |
|
563 | + if ($default_value != '') { |
|
564 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
565 | + } |
|
566 | 566 | |
567 | - $wpdb->query($meta_field_add); |
|
568 | - } else { |
|
567 | + $wpdb->query($meta_field_add); |
|
568 | + } else { |
|
569 | 569 | |
570 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL"; |
|
571 | - $meta_field_add = "VARCHAR( 20 ) NULL"; |
|
572 | - if ($default_value != '') { |
|
573 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
574 | - } |
|
570 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL"; |
|
571 | + $meta_field_add = "VARCHAR( 20 ) NULL"; |
|
572 | + if ($default_value != '') { |
|
573 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
574 | + } |
|
575 | 575 | |
576 | - geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add); |
|
576 | + geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add); |
|
577 | 577 | |
578 | - } |
|
578 | + } |
|
579 | 579 | |
580 | 580 | |
581 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "longitude'"); |
|
581 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "longitude'"); |
|
582 | 582 | |
583 | - if ($is_column) { |
|
584 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "longitude` `" . $prefix . "longitude` VARCHAR( 20 ) NULL"; |
|
583 | + if ($is_column) { |
|
584 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "longitude` `" . $prefix . "longitude` VARCHAR( 20 ) NULL"; |
|
585 | 585 | |
586 | - if ($default_value != '') { |
|
587 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
588 | - } |
|
586 | + if ($default_value != '') { |
|
587 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
588 | + } |
|
589 | 589 | |
590 | - $wpdb->query($meta_field_add); |
|
591 | - } else { |
|
590 | + $wpdb->query($meta_field_add); |
|
591 | + } else { |
|
592 | 592 | |
593 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL"; |
|
594 | - $meta_field_add = "VARCHAR( 20 ) NULL"; |
|
595 | - if ($default_value != '') { |
|
596 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
597 | - } |
|
593 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL"; |
|
594 | + $meta_field_add = "VARCHAR( 20 ) NULL"; |
|
595 | + if ($default_value != '') { |
|
596 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
597 | + } |
|
598 | 598 | |
599 | - geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add); |
|
600 | - } |
|
599 | + geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add); |
|
600 | + } |
|
601 | 601 | |
602 | - } |
|
603 | - if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) { |
|
602 | + } |
|
603 | + if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) { |
|
604 | 604 | |
605 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapview'"); |
|
605 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapview'"); |
|
606 | 606 | |
607 | - if ($is_column) { |
|
608 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapview` `" . $prefix . "mapview` VARCHAR( 15 ) NULL"; |
|
607 | + if ($is_column) { |
|
608 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapview` `" . $prefix . "mapview` VARCHAR( 15 ) NULL"; |
|
609 | 609 | |
610 | - if ($default_value != '') { |
|
611 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
612 | - } |
|
610 | + if ($default_value != '') { |
|
611 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
612 | + } |
|
613 | 613 | |
614 | - $wpdb->query($meta_field_add); |
|
615 | - } else { |
|
614 | + $wpdb->query($meta_field_add); |
|
615 | + } else { |
|
616 | 616 | |
617 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL"; |
|
617 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL"; |
|
618 | 618 | |
619 | - $meta_field_add = "VARCHAR( 15 ) NULL"; |
|
620 | - if ($default_value != '') { |
|
621 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
622 | - } |
|
619 | + $meta_field_add = "VARCHAR( 15 ) NULL"; |
|
620 | + if ($default_value != '') { |
|
621 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
622 | + } |
|
623 | 623 | |
624 | - geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add); |
|
625 | - } |
|
624 | + geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add); |
|
625 | + } |
|
626 | 626 | |
627 | 627 | |
628 | - } |
|
629 | - if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) { |
|
628 | + } |
|
629 | + if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) { |
|
630 | 630 | |
631 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapzoom'"); |
|
632 | - if ($is_column) { |
|
633 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapzoom` `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL"; |
|
631 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapzoom'"); |
|
632 | + if ($is_column) { |
|
633 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapzoom` `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL"; |
|
634 | 634 | |
635 | - if ($default_value != '') { |
|
636 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
637 | - } |
|
635 | + if ($default_value != '') { |
|
636 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
637 | + } |
|
638 | 638 | |
639 | - $wpdb->query($meta_field_add); |
|
639 | + $wpdb->query($meta_field_add); |
|
640 | 640 | |
641 | - } else { |
|
641 | + } else { |
|
642 | 642 | |
643 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL"; |
|
643 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL"; |
|
644 | 644 | |
645 | - $meta_field_add = "VARCHAR( 3 ) NULL"; |
|
646 | - if ($default_value != '') { |
|
647 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
648 | - } |
|
645 | + $meta_field_add = "VARCHAR( 3 ) NULL"; |
|
646 | + if ($default_value != '') { |
|
647 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
648 | + } |
|
649 | 649 | |
650 | - geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add); |
|
651 | - } |
|
650 | + geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add); |
|
651 | + } |
|
652 | 652 | |
653 | - } |
|
654 | - // show lat lng |
|
655 | - if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) { |
|
656 | - $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latlng'"); |
|
653 | + } |
|
654 | + // show lat lng |
|
655 | + if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) { |
|
656 | + $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latlng'"); |
|
657 | 657 | |
658 | - if ($is_column) { |
|
659 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latlng` `" . $prefix . "latlng` VARCHAR( 3 ) NULL"; |
|
660 | - $meta_field_add .= " DEFAULT '1'"; |
|
658 | + if ($is_column) { |
|
659 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latlng` `" . $prefix . "latlng` VARCHAR( 3 ) NULL"; |
|
660 | + $meta_field_add .= " DEFAULT '1'"; |
|
661 | 661 | |
662 | - $wpdb->query($meta_field_add); |
|
663 | - } else { |
|
664 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL"; |
|
662 | + $wpdb->query($meta_field_add); |
|
663 | + } else { |
|
664 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL"; |
|
665 | 665 | |
666 | - $meta_field_add = "VARCHAR( 3 ) NULL"; |
|
667 | - $meta_field_add .= " DEFAULT '1'"; |
|
666 | + $meta_field_add = "VARCHAR( 3 ) NULL"; |
|
667 | + $meta_field_add .= " DEFAULT '1'"; |
|
668 | 668 | |
669 | - geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add); |
|
670 | - } |
|
669 | + geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add); |
|
670 | + } |
|
671 | 671 | |
672 | - } |
|
673 | - }// end extra |
|
672 | + } |
|
673 | + }// end extra |
|
674 | 674 | |
675 | - break; |
|
675 | + break; |
|
676 | 676 | |
677 | - case 'checkbox': |
|
678 | - case 'multiselect': |
|
679 | - case 'select': |
|
680 | - case 'taxonomy': |
|
677 | + case 'checkbox': |
|
678 | + case 'multiselect': |
|
679 | + case 'select': |
|
680 | + case 'taxonomy': |
|
681 | 681 | |
682 | - $op_size = '500'; |
|
682 | + $op_size = '500'; |
|
683 | 683 | |
684 | - // only make the field as big as it needs to be. |
|
685 | - if(isset($option_values) && $option_values && $field_type=='select'){ |
|
686 | - $option_values_arr = explode(',',$option_values); |
|
687 | - if(is_array($option_values_arr)){ |
|
688 | - $op_max = 0; |
|
689 | - foreach($option_values_arr as $op_val){ |
|
690 | - if(strlen($op_val) && strlen($op_val)>$op_max){$op_max = strlen($op_val);} |
|
691 | - } |
|
692 | - if($op_max){$op_size =$op_max; } |
|
693 | - } |
|
694 | - }elseif(isset($option_values) && $option_values && $field_type=='multiselect'){ |
|
695 | - if(strlen($option_values)){ |
|
696 | - $op_size = strlen($option_values); |
|
697 | - } |
|
698 | - } |
|
684 | + // only make the field as big as it needs to be. |
|
685 | + if(isset($option_values) && $option_values && $field_type=='select'){ |
|
686 | + $option_values_arr = explode(',',$option_values); |
|
687 | + if(is_array($option_values_arr)){ |
|
688 | + $op_max = 0; |
|
689 | + foreach($option_values_arr as $op_val){ |
|
690 | + if(strlen($op_val) && strlen($op_val)>$op_max){$op_max = strlen($op_val);} |
|
691 | + } |
|
692 | + if($op_max){$op_size =$op_max; } |
|
693 | + } |
|
694 | + }elseif(isset($option_values) && $option_values && $field_type=='multiselect'){ |
|
695 | + if(strlen($option_values)){ |
|
696 | + $op_size = strlen($option_values); |
|
697 | + } |
|
698 | + } |
|
699 | 699 | |
700 | - $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "`VARCHAR( $op_size ) NULL"; |
|
700 | + $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "`VARCHAR( $op_size ) NULL"; |
|
701 | 701 | |
702 | - if ($default_value != '') { |
|
703 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
704 | - } |
|
702 | + if ($default_value != '') { |
|
703 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
704 | + } |
|
705 | 705 | |
706 | - $alter_result = $wpdb->query($meta_field_add); |
|
707 | - if($alter_result===false){ |
|
708 | - return __('Column change failed, you may have too many columns.','geodirectory'); |
|
709 | - } |
|
706 | + $alter_result = $wpdb->query($meta_field_add); |
|
707 | + if($alter_result===false){ |
|
708 | + return __('Column change failed, you may have too many columns.','geodirectory'); |
|
709 | + } |
|
710 | 710 | |
711 | - if (isset($request_field['cat_display_type'])) |
|
712 | - $extra_fields = $request_field['cat_display_type']; |
|
711 | + if (isset($request_field['cat_display_type'])) |
|
712 | + $extra_fields = $request_field['cat_display_type']; |
|
713 | 713 | |
714 | - if (isset($request_field['multi_display_type'])) |
|
715 | - $extra_fields = $request_field['multi_display_type']; |
|
714 | + if (isset($request_field['multi_display_type'])) |
|
715 | + $extra_fields = $request_field['multi_display_type']; |
|
716 | 716 | |
717 | 717 | |
718 | - break; |
|
718 | + break; |
|
719 | 719 | |
720 | - case 'textarea': |
|
721 | - case 'html': |
|
722 | - case 'url': |
|
723 | - case 'file': |
|
720 | + case 'textarea': |
|
721 | + case 'html': |
|
722 | + case 'url': |
|
723 | + case 'file': |
|
724 | 724 | |
725 | - $alter_result = $wpdb->query("ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` TEXT NULL"); |
|
726 | - if($alter_result===false){ |
|
727 | - return __('Column change failed, you may have too many columns.','geodirectory'); |
|
728 | - } |
|
729 | - if (isset($request_field['advanced_editor'])) |
|
730 | - $extra_fields = $request_field['advanced_editor']; |
|
731 | - |
|
732 | - break; |
|
725 | + $alter_result = $wpdb->query("ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` TEXT NULL"); |
|
726 | + if($alter_result===false){ |
|
727 | + return __('Column change failed, you may have too many columns.','geodirectory'); |
|
728 | + } |
|
729 | + if (isset($request_field['advanced_editor'])) |
|
730 | + $extra_fields = $request_field['advanced_editor']; |
|
731 | + |
|
732 | + break; |
|
733 | 733 | |
734 | - case 'fieldset': |
|
735 | - // Nothing happened for fieldset |
|
736 | - break; |
|
734 | + case 'fieldset': |
|
735 | + // Nothing happened for fieldset |
|
736 | + break; |
|
737 | 737 | |
738 | - default: |
|
739 | - if ($data_type != 'VARCHAR' && $data_type != '') { |
|
740 | - if ($data_type == 'FLOAT' && $decimal_point > 0) { |
|
741 | - $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` DECIMAL(11, " . (int)$decimal_point . ") NULL"; |
|
742 | - } else { |
|
743 | - $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` " . $data_type . " NULL"; |
|
744 | - } |
|
745 | - |
|
746 | - if (is_numeric($default_value) && $default_value != '') { |
|
747 | - $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
748 | - } |
|
749 | - } else { |
|
750 | - $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` VARCHAR( 254 ) NULL"; |
|
751 | - if ($default_value != '') { |
|
752 | - $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
753 | - } |
|
754 | - } |
|
755 | - |
|
756 | - $alter_result = $wpdb->query($default_value_add); |
|
757 | - if($alter_result===false){ |
|
758 | - return __('Column change failed, you may have too many columns.','geodirectory'); |
|
759 | - } |
|
760 | - break; |
|
761 | - endswitch; |
|
762 | - |
|
763 | - $extra_field_query = ''; |
|
764 | - if (!empty($extra_fields)) { |
|
765 | - $extra_field_query = serialize($extra_fields); |
|
766 | - } |
|
767 | - |
|
768 | - $decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : ''; |
|
769 | - |
|
770 | - $wpdb->query( |
|
771 | - |
|
772 | - $wpdb->prepare( |
|
773 | - |
|
774 | - "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set |
|
738 | + default: |
|
739 | + if ($data_type != 'VARCHAR' && $data_type != '') { |
|
740 | + if ($data_type == 'FLOAT' && $decimal_point > 0) { |
|
741 | + $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` DECIMAL(11, " . (int)$decimal_point . ") NULL"; |
|
742 | + } else { |
|
743 | + $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` " . $data_type . " NULL"; |
|
744 | + } |
|
745 | + |
|
746 | + if (is_numeric($default_value) && $default_value != '') { |
|
747 | + $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
748 | + } |
|
749 | + } else { |
|
750 | + $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` VARCHAR( 254 ) NULL"; |
|
751 | + if ($default_value != '') { |
|
752 | + $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
753 | + } |
|
754 | + } |
|
755 | + |
|
756 | + $alter_result = $wpdb->query($default_value_add); |
|
757 | + if($alter_result===false){ |
|
758 | + return __('Column change failed, you may have too many columns.','geodirectory'); |
|
759 | + } |
|
760 | + break; |
|
761 | + endswitch; |
|
762 | + |
|
763 | + $extra_field_query = ''; |
|
764 | + if (!empty($extra_fields)) { |
|
765 | + $extra_field_query = serialize($extra_fields); |
|
766 | + } |
|
767 | + |
|
768 | + $decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : ''; |
|
769 | + |
|
770 | + $wpdb->query( |
|
771 | + |
|
772 | + $wpdb->prepare( |
|
773 | + |
|
774 | + "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set |
|
775 | 775 | post_type = %s, |
776 | 776 | admin_title = %s, |
777 | 777 | site_title = %s, |
@@ -805,308 +805,308 @@ discard block |
||
805 | 805 | for_admin_use = %s |
806 | 806 | where id = %d", |
807 | 807 | |
808 | - array($post_type, $admin_title, $site_title, $field_type, $field_type_key, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_required, $required_msg, $css_class, $field_icon, $field_icon, $show_on_listing, $show_in, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point,$validation_pattern,$validation_msg, $for_admin_use, $cf) |
|
809 | - ) |
|
808 | + array($post_type, $admin_title, $site_title, $field_type, $field_type_key, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_required, $required_msg, $css_class, $field_icon, $field_icon, $show_on_listing, $show_in, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point,$validation_pattern,$validation_msg, $for_admin_use, $cf) |
|
809 | + ) |
|
810 | 810 | |
811 | - ); |
|
811 | + ); |
|
812 | 812 | |
813 | - $lastid = trim($cf); |
|
813 | + $lastid = trim($cf); |
|
814 | 814 | |
815 | 815 | |
816 | - $wpdb->query( |
|
817 | - $wpdb->prepare( |
|
818 | - "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
816 | + $wpdb->query( |
|
817 | + $wpdb->prepare( |
|
818 | + "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
819 | 819 | site_title=%s |
820 | 820 | where post_type = %s and htmlvar_name = %s", |
821 | - array($site_title, $post_type, $htmlvar_name) |
|
822 | - ) |
|
823 | - ); |
|
824 | - |
|
825 | - |
|
826 | - if ($cat_sort == '') |
|
827 | - $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name))); |
|
828 | - |
|
829 | - |
|
830 | - /** |
|
831 | - * Called after all custom fields are saved for a post. |
|
832 | - * |
|
833 | - * @since 1.0.0 |
|
834 | - * @param int $lastid The post ID. |
|
835 | - */ |
|
836 | - do_action('geodir_after_custom_fields_updated', $lastid); |
|
837 | - |
|
838 | - } else { |
|
839 | - |
|
840 | - switch ($field_type): |
|
841 | - |
|
842 | - case 'address': |
|
843 | - |
|
844 | - $data_type = ''; |
|
845 | - |
|
846 | - if ($htmlvar_name != '') { |
|
847 | - $prefix = $htmlvar_name . '_'; |
|
848 | - } |
|
849 | - $old_prefix = $old_html_variable; |
|
850 | - |
|
851 | - //$meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."address` VARCHAR( 254 ) NULL"; |
|
852 | - |
|
853 | - $meta_field_add = "VARCHAR( 254 ) NULL"; |
|
854 | - if ($default_value != '') { |
|
855 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
856 | - } |
|
857 | - |
|
858 | - geodir_add_column_if_not_exist($detail_table, $prefix . "address", $meta_field_add); |
|
859 | - //$wpdb->query($meta_field_add); |
|
860 | - |
|
861 | - |
|
862 | - if (!empty($extra_fields)) { |
|
821 | + array($site_title, $post_type, $htmlvar_name) |
|
822 | + ) |
|
823 | + ); |
|
824 | + |
|
825 | + |
|
826 | + if ($cat_sort == '') |
|
827 | + $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name))); |
|
828 | + |
|
829 | + |
|
830 | + /** |
|
831 | + * Called after all custom fields are saved for a post. |
|
832 | + * |
|
833 | + * @since 1.0.0 |
|
834 | + * @param int $lastid The post ID. |
|
835 | + */ |
|
836 | + do_action('geodir_after_custom_fields_updated', $lastid); |
|
837 | + |
|
838 | + } else { |
|
839 | + |
|
840 | + switch ($field_type): |
|
841 | + |
|
842 | + case 'address': |
|
843 | + |
|
844 | + $data_type = ''; |
|
845 | + |
|
846 | + if ($htmlvar_name != '') { |
|
847 | + $prefix = $htmlvar_name . '_'; |
|
848 | + } |
|
849 | + $old_prefix = $old_html_variable; |
|
850 | + |
|
851 | + //$meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."address` VARCHAR( 254 ) NULL"; |
|
852 | + |
|
853 | + $meta_field_add = "VARCHAR( 254 ) NULL"; |
|
854 | + if ($default_value != '') { |
|
855 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
856 | + } |
|
857 | + |
|
858 | + geodir_add_column_if_not_exist($detail_table, $prefix . "address", $meta_field_add); |
|
859 | + //$wpdb->query($meta_field_add); |
|
860 | + |
|
861 | + |
|
862 | + if (!empty($extra_fields)) { |
|
863 | 863 | |
864 | - if (isset($extra_fields['show_city']) && $extra_fields['show_city']) { |
|
865 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "city` VARCHAR( 30 ) NULL"; |
|
866 | - $meta_field_add = "VARCHAR( 30 ) NULL"; |
|
867 | - if ($default_value != '') { |
|
868 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
869 | - } |
|
870 | - |
|
871 | - geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add); |
|
872 | - //$wpdb->query($meta_field_add); |
|
873 | - } |
|
874 | - if (isset($extra_fields['show_region']) && $extra_fields['show_region']) { |
|
875 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "region` VARCHAR( 30 ) NULL"; |
|
876 | - $meta_field_add = "VARCHAR( 30 ) NULL"; |
|
877 | - if ($default_value != '') { |
|
878 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
879 | - } |
|
880 | - |
|
881 | - geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add); |
|
882 | - //$wpdb->query($meta_field_add); |
|
883 | - } |
|
884 | - if (isset($extra_fields['show_country']) && $extra_fields['show_country']) { |
|
885 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "country` VARCHAR( 30 ) NULL"; |
|
886 | - |
|
887 | - $meta_field_add = "VARCHAR( 30 ) NULL"; |
|
888 | - if ($default_value != '') { |
|
889 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
890 | - } |
|
891 | - |
|
892 | - geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add); |
|
893 | - //$wpdb->query($meta_field_add); |
|
894 | - } |
|
895 | - if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) { |
|
896 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "zip` VARCHAR( 15 ) NULL"; |
|
897 | - $meta_field_add = "VARCHAR( 15 ) NULL"; |
|
898 | - if ($default_value != '') { |
|
899 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
900 | - } |
|
901 | - |
|
902 | - geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add); |
|
903 | - //$wpdb->query($meta_field_add); |
|
904 | - } |
|
905 | - if (isset($extra_fields['show_map']) && $extra_fields['show_map']) { |
|
906 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL"; |
|
907 | - $meta_field_add = "VARCHAR( 20 ) NULL"; |
|
908 | - if ($default_value != '') { |
|
909 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
910 | - } |
|
911 | - |
|
912 | - geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add); |
|
913 | - //$wpdb->query($meta_field_add); |
|
914 | - |
|
915 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL"; |
|
916 | - |
|
917 | - $meta_field_add = "VARCHAR( 20 ) NULL"; |
|
918 | - if ($default_value != '') { |
|
919 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
920 | - } |
|
921 | - |
|
922 | - geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add); |
|
923 | - |
|
924 | - //$wpdb->query($meta_field_add); |
|
925 | - } |
|
926 | - if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) { |
|
927 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL"; |
|
928 | - |
|
929 | - $meta_field_add = "VARCHAR( 15 ) NULL"; |
|
930 | - if ($default_value != '') { |
|
931 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
932 | - } |
|
933 | - |
|
934 | - geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add); |
|
935 | - |
|
936 | - //$wpdb->query($meta_field_add); |
|
937 | - } |
|
938 | - if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) { |
|
939 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL"; |
|
940 | - |
|
941 | - $meta_field_add = "VARCHAR( 3 ) NULL"; |
|
942 | - if ($default_value != '') { |
|
943 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
944 | - } |
|
945 | - |
|
946 | - geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add); |
|
947 | - |
|
948 | - //$wpdb->query($meta_field_add); |
|
949 | - } |
|
950 | - // show lat lng |
|
951 | - if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) { |
|
952 | - $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL"; |
|
953 | - |
|
954 | - $meta_field_add = "VARCHAR( 3 ) NULL"; |
|
955 | - $meta_field_add .= " DEFAULT '1'"; |
|
956 | - |
|
957 | - geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add); |
|
958 | - //$wpdb->query($meta_field_add); |
|
959 | - } |
|
960 | - } |
|
961 | - |
|
962 | - break; |
|
963 | - |
|
964 | - case 'checkbox': |
|
965 | - $data_type = 'TINYINT'; |
|
966 | - |
|
967 | - $meta_field_add = $data_type . "( 1 ) NOT NULL "; |
|
968 | - if ((int)$default_value === 1) { |
|
969 | - $meta_field_add .= " DEFAULT '1'"; |
|
970 | - } |
|
971 | - |
|
972 | - $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
973 | - if ($add_result === false) { |
|
974 | - return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory'); |
|
975 | - } |
|
976 | - break; |
|
977 | - case 'multiselect': |
|
978 | - case 'select': |
|
979 | - $data_type = 'VARCHAR'; |
|
980 | - $op_size = '500'; |
|
981 | - |
|
982 | - // only make the field as big as it needs to be. |
|
983 | - if (isset($option_values) && $option_values && $field_type == 'select') { |
|
984 | - $option_values_arr = explode(',', $option_values); |
|
985 | - |
|
986 | - if (is_array($option_values_arr)) { |
|
987 | - $op_max = 0; |
|
988 | - |
|
989 | - foreach ($option_values_arr as $op_val) { |
|
990 | - if (strlen($op_val) && strlen($op_val) > $op_max) { |
|
991 | - $op_max = strlen($op_val); |
|
992 | - } |
|
993 | - } |
|
994 | - |
|
995 | - if ($op_max) { |
|
996 | - $op_size = $op_max; |
|
997 | - } |
|
998 | - } |
|
999 | - } elseif (isset($option_values) && $option_values && $field_type == 'multiselect') { |
|
1000 | - if (strlen($option_values)) { |
|
1001 | - $op_size = strlen($option_values); |
|
1002 | - } |
|
1003 | - |
|
1004 | - if (isset($request_field['multi_display_type'])) { |
|
1005 | - $extra_fields = $request_field['multi_display_type']; |
|
1006 | - } |
|
1007 | - } |
|
1008 | - |
|
1009 | - $meta_field_add = $data_type . "( $op_size ) NULL "; |
|
1010 | - if ($default_value != '') { |
|
1011 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
1012 | - } |
|
1013 | - |
|
1014 | - $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
1015 | - if ($add_result === false) { |
|
1016 | - return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory'); |
|
1017 | - } |
|
1018 | - break; |
|
1019 | - case 'textarea': |
|
1020 | - case 'html': |
|
1021 | - case 'url': |
|
1022 | - case 'file': |
|
1023 | - |
|
1024 | - $data_type = 'TEXT'; |
|
1025 | - |
|
1026 | - $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL "; |
|
1027 | - |
|
1028 | - $meta_field_add = $data_type . " NULL "; |
|
1029 | - /*if($default_value != '') |
|
864 | + if (isset($extra_fields['show_city']) && $extra_fields['show_city']) { |
|
865 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "city` VARCHAR( 30 ) NULL"; |
|
866 | + $meta_field_add = "VARCHAR( 30 ) NULL"; |
|
867 | + if ($default_value != '') { |
|
868 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
869 | + } |
|
870 | + |
|
871 | + geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add); |
|
872 | + //$wpdb->query($meta_field_add); |
|
873 | + } |
|
874 | + if (isset($extra_fields['show_region']) && $extra_fields['show_region']) { |
|
875 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "region` VARCHAR( 30 ) NULL"; |
|
876 | + $meta_field_add = "VARCHAR( 30 ) NULL"; |
|
877 | + if ($default_value != '') { |
|
878 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
879 | + } |
|
880 | + |
|
881 | + geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add); |
|
882 | + //$wpdb->query($meta_field_add); |
|
883 | + } |
|
884 | + if (isset($extra_fields['show_country']) && $extra_fields['show_country']) { |
|
885 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "country` VARCHAR( 30 ) NULL"; |
|
886 | + |
|
887 | + $meta_field_add = "VARCHAR( 30 ) NULL"; |
|
888 | + if ($default_value != '') { |
|
889 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
890 | + } |
|
891 | + |
|
892 | + geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add); |
|
893 | + //$wpdb->query($meta_field_add); |
|
894 | + } |
|
895 | + if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) { |
|
896 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "zip` VARCHAR( 15 ) NULL"; |
|
897 | + $meta_field_add = "VARCHAR( 15 ) NULL"; |
|
898 | + if ($default_value != '') { |
|
899 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
900 | + } |
|
901 | + |
|
902 | + geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add); |
|
903 | + //$wpdb->query($meta_field_add); |
|
904 | + } |
|
905 | + if (isset($extra_fields['show_map']) && $extra_fields['show_map']) { |
|
906 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL"; |
|
907 | + $meta_field_add = "VARCHAR( 20 ) NULL"; |
|
908 | + if ($default_value != '') { |
|
909 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
910 | + } |
|
911 | + |
|
912 | + geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add); |
|
913 | + //$wpdb->query($meta_field_add); |
|
914 | + |
|
915 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL"; |
|
916 | + |
|
917 | + $meta_field_add = "VARCHAR( 20 ) NULL"; |
|
918 | + if ($default_value != '') { |
|
919 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
920 | + } |
|
921 | + |
|
922 | + geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add); |
|
923 | + |
|
924 | + //$wpdb->query($meta_field_add); |
|
925 | + } |
|
926 | + if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) { |
|
927 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL"; |
|
928 | + |
|
929 | + $meta_field_add = "VARCHAR( 15 ) NULL"; |
|
930 | + if ($default_value != '') { |
|
931 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
932 | + } |
|
933 | + |
|
934 | + geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add); |
|
935 | + |
|
936 | + //$wpdb->query($meta_field_add); |
|
937 | + } |
|
938 | + if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) { |
|
939 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL"; |
|
940 | + |
|
941 | + $meta_field_add = "VARCHAR( 3 ) NULL"; |
|
942 | + if ($default_value != '') { |
|
943 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
944 | + } |
|
945 | + |
|
946 | + geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add); |
|
947 | + |
|
948 | + //$wpdb->query($meta_field_add); |
|
949 | + } |
|
950 | + // show lat lng |
|
951 | + if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) { |
|
952 | + $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL"; |
|
953 | + |
|
954 | + $meta_field_add = "VARCHAR( 3 ) NULL"; |
|
955 | + $meta_field_add .= " DEFAULT '1'"; |
|
956 | + |
|
957 | + geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add); |
|
958 | + //$wpdb->query($meta_field_add); |
|
959 | + } |
|
960 | + } |
|
961 | + |
|
962 | + break; |
|
963 | + |
|
964 | + case 'checkbox': |
|
965 | + $data_type = 'TINYINT'; |
|
966 | + |
|
967 | + $meta_field_add = $data_type . "( 1 ) NOT NULL "; |
|
968 | + if ((int)$default_value === 1) { |
|
969 | + $meta_field_add .= " DEFAULT '1'"; |
|
970 | + } |
|
971 | + |
|
972 | + $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
973 | + if ($add_result === false) { |
|
974 | + return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory'); |
|
975 | + } |
|
976 | + break; |
|
977 | + case 'multiselect': |
|
978 | + case 'select': |
|
979 | + $data_type = 'VARCHAR'; |
|
980 | + $op_size = '500'; |
|
981 | + |
|
982 | + // only make the field as big as it needs to be. |
|
983 | + if (isset($option_values) && $option_values && $field_type == 'select') { |
|
984 | + $option_values_arr = explode(',', $option_values); |
|
985 | + |
|
986 | + if (is_array($option_values_arr)) { |
|
987 | + $op_max = 0; |
|
988 | + |
|
989 | + foreach ($option_values_arr as $op_val) { |
|
990 | + if (strlen($op_val) && strlen($op_val) > $op_max) { |
|
991 | + $op_max = strlen($op_val); |
|
992 | + } |
|
993 | + } |
|
994 | + |
|
995 | + if ($op_max) { |
|
996 | + $op_size = $op_max; |
|
997 | + } |
|
998 | + } |
|
999 | + } elseif (isset($option_values) && $option_values && $field_type == 'multiselect') { |
|
1000 | + if (strlen($option_values)) { |
|
1001 | + $op_size = strlen($option_values); |
|
1002 | + } |
|
1003 | + |
|
1004 | + if (isset($request_field['multi_display_type'])) { |
|
1005 | + $extra_fields = $request_field['multi_display_type']; |
|
1006 | + } |
|
1007 | + } |
|
1008 | + |
|
1009 | + $meta_field_add = $data_type . "( $op_size ) NULL "; |
|
1010 | + if ($default_value != '') { |
|
1011 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
1012 | + } |
|
1013 | + |
|
1014 | + $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
1015 | + if ($add_result === false) { |
|
1016 | + return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory'); |
|
1017 | + } |
|
1018 | + break; |
|
1019 | + case 'textarea': |
|
1020 | + case 'html': |
|
1021 | + case 'url': |
|
1022 | + case 'file': |
|
1023 | + |
|
1024 | + $data_type = 'TEXT'; |
|
1025 | + |
|
1026 | + $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL "; |
|
1027 | + |
|
1028 | + $meta_field_add = $data_type . " NULL "; |
|
1029 | + /*if($default_value != '') |
|
1030 | 1030 | { $meta_field_add .= " DEFAULT '".$default_value."'"; }*/ |
1031 | 1031 | |
1032 | - $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
1033 | - if ($add_result === false) { |
|
1034 | - return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory'); |
|
1035 | - } |
|
1032 | + $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
1033 | + if ($add_result === false) { |
|
1034 | + return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory'); |
|
1035 | + } |
|
1036 | 1036 | |
1037 | - break; |
|
1037 | + break; |
|
1038 | 1038 | |
1039 | - case 'datepicker': |
|
1039 | + case 'datepicker': |
|
1040 | 1040 | |
1041 | - $data_type = 'DATE'; |
|
1041 | + $data_type = 'DATE'; |
|
1042 | 1042 | |
1043 | - $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL "; |
|
1043 | + $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL "; |
|
1044 | 1044 | |
1045 | - $meta_field_add = $data_type . " NULL "; |
|
1045 | + $meta_field_add = $data_type . " NULL "; |
|
1046 | 1046 | |
1047 | - $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
1048 | - if ($add_result === false) { |
|
1049 | - return __('Column creation failed, you may have too many columns or the default value must have in valid date format.', 'geodirectory'); |
|
1050 | - } |
|
1047 | + $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
1048 | + if ($add_result === false) { |
|
1049 | + return __('Column creation failed, you may have too many columns or the default value must have in valid date format.', 'geodirectory'); |
|
1050 | + } |
|
1051 | 1051 | |
1052 | - break; |
|
1052 | + break; |
|
1053 | 1053 | |
1054 | - case 'time': |
|
1054 | + case 'time': |
|
1055 | 1055 | |
1056 | - $data_type = 'TIME'; |
|
1056 | + $data_type = 'TIME'; |
|
1057 | 1057 | |
1058 | - $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL "; |
|
1058 | + $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL "; |
|
1059 | 1059 | |
1060 | - $meta_field_add = $data_type . " NULL "; |
|
1060 | + $meta_field_add = $data_type . " NULL "; |
|
1061 | 1061 | |
1062 | - $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
1063 | - if ($add_result === false) { |
|
1064 | - return __('Column creation failed, you may have too many columns or the default value must have in valid time format.', 'geodirectory'); |
|
1065 | - } |
|
1062 | + $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
1063 | + if ($add_result === false) { |
|
1064 | + return __('Column creation failed, you may have too many columns or the default value must have in valid time format.', 'geodirectory'); |
|
1065 | + } |
|
1066 | 1066 | |
1067 | - break; |
|
1067 | + break; |
|
1068 | 1068 | |
1069 | - default: |
|
1069 | + default: |
|
1070 | 1070 | |
1071 | - if ($data_type != 'VARCHAR' && $data_type != '') { |
|
1072 | - $meta_field_add = $data_type . " NULL "; |
|
1071 | + if ($data_type != 'VARCHAR' && $data_type != '') { |
|
1072 | + $meta_field_add = $data_type . " NULL "; |
|
1073 | 1073 | |
1074 | - if ($data_type == 'FLOAT' && $decimal_point > 0) { |
|
1075 | - $meta_field_add = "DECIMAL(11, " . (int)$decimal_point . ") NULL "; |
|
1076 | - } |
|
1074 | + if ($data_type == 'FLOAT' && $decimal_point > 0) { |
|
1075 | + $meta_field_add = "DECIMAL(11, " . (int)$decimal_point . ") NULL "; |
|
1076 | + } |
|
1077 | 1077 | |
1078 | - if (is_numeric($default_value) && $default_value != '') { |
|
1079 | - $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
1080 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
1081 | - } |
|
1082 | - } else { |
|
1083 | - $meta_field_add = " VARCHAR( 254 ) NULL "; |
|
1078 | + if (is_numeric($default_value) && $default_value != '') { |
|
1079 | + $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
1080 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
1081 | + } |
|
1082 | + } else { |
|
1083 | + $meta_field_add = " VARCHAR( 254 ) NULL "; |
|
1084 | 1084 | |
1085 | - if ($default_value != '') { |
|
1086 | - $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
1087 | - $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
1088 | - } |
|
1089 | - } |
|
1085 | + if ($default_value != '') { |
|
1086 | + $default_value_add .= " DEFAULT '" . $default_value . "'"; |
|
1087 | + $meta_field_add .= " DEFAULT '" . $default_value . "'"; |
|
1088 | + } |
|
1089 | + } |
|
1090 | 1090 | |
1091 | - $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
1092 | - if ($add_result === false) { |
|
1093 | - return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory'); |
|
1094 | - } |
|
1095 | - break; |
|
1096 | - endswitch; |
|
1091 | + $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add); |
|
1092 | + if ($add_result === false) { |
|
1093 | + return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory'); |
|
1094 | + } |
|
1095 | + break; |
|
1096 | + endswitch; |
|
1097 | 1097 | |
1098 | - $extra_field_query = ''; |
|
1099 | - if (!empty($extra_fields)) { |
|
1100 | - $extra_field_query = serialize($extra_fields); |
|
1101 | - } |
|
1098 | + $extra_field_query = ''; |
|
1099 | + if (!empty($extra_fields)) { |
|
1100 | + $extra_field_query = serialize($extra_fields); |
|
1101 | + } |
|
1102 | 1102 | |
1103 | - $decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : ''; |
|
1103 | + $decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : ''; |
|
1104 | 1104 | |
1105 | - $wpdb->query( |
|
1105 | + $wpdb->query( |
|
1106 | 1106 | |
1107 | - $wpdb->prepare( |
|
1107 | + $wpdb->prepare( |
|
1108 | 1108 | |
1109 | - "insert into " . GEODIR_CUSTOM_FIELDS_TABLE . " set |
|
1109 | + "insert into " . GEODIR_CUSTOM_FIELDS_TABLE . " set |
|
1110 | 1110 | post_type = %s, |
1111 | 1111 | admin_title = %s, |
1112 | 1112 | site_title = %s, |
@@ -1139,26 +1139,26 @@ discard block |
||
1139 | 1139 | validation_msg = %s, |
1140 | 1140 | for_admin_use = %s ", |
1141 | 1141 | |
1142 | - array($post_type, $admin_title, $site_title, $field_type, $field_type_key, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_admin, $is_required, $required_msg, $css_class, $field_icon, $show_on_listing,$show_in, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point,$validation_pattern,$validation_msg, $for_admin_use) |
|
1142 | + array($post_type, $admin_title, $site_title, $field_type, $field_type_key, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_admin, $is_required, $required_msg, $css_class, $field_icon, $show_on_listing,$show_in, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point,$validation_pattern,$validation_msg, $for_admin_use) |
|
1143 | 1143 | |
1144 | - ) |
|
1144 | + ) |
|
1145 | 1145 | |
1146 | - ); |
|
1146 | + ); |
|
1147 | 1147 | |
1148 | - $lastid = $wpdb->insert_id; |
|
1148 | + $lastid = $wpdb->insert_id; |
|
1149 | 1149 | |
1150 | - $lastid = trim($lastid); |
|
1150 | + $lastid = trim($lastid); |
|
1151 | 1151 | |
1152 | - } |
|
1152 | + } |
|
1153 | 1153 | |
1154 | - return (int)$lastid; |
|
1154 | + return (int)$lastid; |
|
1155 | 1155 | |
1156 | 1156 | |
1157 | - } else { |
|
1158 | - return 'HTML Variable Name should be a unique name'; |
|
1159 | - } |
|
1157 | + } else { |
|
1158 | + return 'HTML Variable Name should be a unique name'; |
|
1159 | + } |
|
1160 | 1160 | |
1161 | - } |
|
1161 | + } |
|
1162 | 1162 | } |
1163 | 1163 | |
1164 | 1164 | /** |
@@ -1173,63 +1173,63 @@ discard block |
||
1173 | 1173 | function godir_set_field_order($field_ids = array()) |
1174 | 1174 | { |
1175 | 1175 | |
1176 | - global $wpdb; |
|
1176 | + global $wpdb; |
|
1177 | 1177 | |
1178 | - $count = 0; |
|
1179 | - if (!empty($field_ids)): |
|
1180 | - $post_meta_info = false; |
|
1181 | - foreach ($field_ids as $id) { |
|
1178 | + $count = 0; |
|
1179 | + if (!empty($field_ids)): |
|
1180 | + $post_meta_info = false; |
|
1181 | + foreach ($field_ids as $id) { |
|
1182 | 1182 | |
1183 | - $cf = trim($id, '_'); |
|
1183 | + $cf = trim($id, '_'); |
|
1184 | 1184 | |
1185 | - $post_meta_info = $wpdb->query( |
|
1186 | - $wpdb->prepare( |
|
1187 | - "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set |
|
1185 | + $post_meta_info = $wpdb->query( |
|
1186 | + $wpdb->prepare( |
|
1187 | + "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set |
|
1188 | 1188 | sort_order=%d |
1189 | 1189 | where id= %d", |
1190 | - array($count, $cf) |
|
1191 | - ) |
|
1192 | - ); |
|
1193 | - $count++; |
|
1194 | - } |
|
1195 | - |
|
1196 | - return $post_meta_info; |
|
1197 | - else: |
|
1198 | - return false; |
|
1199 | - endif; |
|
1190 | + array($count, $cf) |
|
1191 | + ) |
|
1192 | + ); |
|
1193 | + $count++; |
|
1194 | + } |
|
1195 | + |
|
1196 | + return $post_meta_info; |
|
1197 | + else: |
|
1198 | + return false; |
|
1199 | + endif; |
|
1200 | 1200 | } |
1201 | 1201 | |
1202 | 1202 | function geodir_get_cf_value($cf) { |
1203 | - global $gd_session; |
|
1204 | - $value = ''; |
|
1205 | - if (is_admin()) { |
|
1206 | - global $post; |
|
1207 | - |
|
1208 | - if (isset($_REQUEST['post'])) { |
|
1209 | - $_REQUEST['pid'] = (int)$_REQUEST['post']; |
|
1210 | - } |
|
1211 | - } |
|
1212 | - |
|
1213 | - if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) { |
|
1214 | - $post = $gd_ses_listing; |
|
1215 | - $value = isset($post[$cf['name']]) ? $post[$cf['name']] : ''; |
|
1216 | - } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
1217 | - $value = geodir_get_post_meta($_REQUEST['pid'], $cf['name'], true); |
|
1218 | - } else { |
|
1219 | - if ($value == '') { |
|
1220 | - $value = $cf['default']; |
|
1221 | - } |
|
1222 | - } |
|
1203 | + global $gd_session; |
|
1204 | + $value = ''; |
|
1205 | + if (is_admin()) { |
|
1206 | + global $post; |
|
1207 | + |
|
1208 | + if (isset($_REQUEST['post'])) { |
|
1209 | + $_REQUEST['pid'] = (int)$_REQUEST['post']; |
|
1210 | + } |
|
1211 | + } |
|
1212 | + |
|
1213 | + if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) { |
|
1214 | + $post = $gd_ses_listing; |
|
1215 | + $value = isset($post[$cf['name']]) ? $post[$cf['name']] : ''; |
|
1216 | + } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
1217 | + $value = geodir_get_post_meta($_REQUEST['pid'], $cf['name'], true); |
|
1218 | + } else { |
|
1219 | + if ($value == '') { |
|
1220 | + $value = $cf['default']; |
|
1221 | + } |
|
1222 | + } |
|
1223 | 1223 | |
1224 | - /** |
|
1225 | - * Filter the custom field value. |
|
1226 | - * |
|
1227 | - * @since 1.6.20 |
|
1228 | - * |
|
1229 | - * @param mixed $value Custom field value. |
|
1230 | - * @param array $cf Custom field info. |
|
1231 | - */ |
|
1232 | - return apply_filters( 'geodir_get_cf_value', $value, $cf ); |
|
1224 | + /** |
|
1225 | + * Filter the custom field value. |
|
1226 | + * |
|
1227 | + * @since 1.6.20 |
|
1228 | + * |
|
1229 | + * @param mixed $value Custom field value. |
|
1230 | + * @param array $cf Custom field info. |
|
1231 | + */ |
|
1232 | + return apply_filters( 'geodir_get_cf_value', $value, $cf ); |
|
1233 | 1233 | } |
1234 | 1234 | |
1235 | 1235 | /** |
@@ -1248,422 +1248,422 @@ discard block |
||
1248 | 1248 | * @param string $post_type Optional. The wordpress post type. |
1249 | 1249 | */ |
1250 | 1250 | function geodir_get_custom_fields_html($package_id = '', $default = 'custom', $post_type = 'gd_place') { |
1251 | - global $is_default, $mapzoom, $gd_session; |
|
1251 | + global $is_default, $mapzoom, $gd_session; |
|
1252 | 1252 | |
1253 | - $listing_type = $post_type; |
|
1253 | + $listing_type = $post_type; |
|
1254 | 1254 | |
1255 | - $custom_fields = geodir_post_custom_fields($package_id, $default, $post_type); |
|
1255 | + $custom_fields = geodir_post_custom_fields($package_id, $default, $post_type); |
|
1256 | 1256 | |
1257 | - foreach ($custom_fields as $key => $val) { |
|
1258 | - if(isset($val['extra_fields'])){$extra_fields = $val['extra_fields'];} |
|
1259 | - $val = stripslashes_deep($val); // strip slashes from labels |
|
1260 | - if(isset($val['extra_fields'])){$val['extra_fields'] = $extra_fields;} |
|
1257 | + foreach ($custom_fields as $key => $val) { |
|
1258 | + if(isset($val['extra_fields'])){$extra_fields = $val['extra_fields'];} |
|
1259 | + $val = stripslashes_deep($val); // strip slashes from labels |
|
1260 | + if(isset($val['extra_fields'])){$val['extra_fields'] = $extra_fields;} |
|
1261 | 1261 | |
1262 | - $name = $val['name']; |
|
1263 | - $type = $val['type']; |
|
1264 | - $is_default = $val['is_default']; |
|
1262 | + $name = $val['name']; |
|
1263 | + $type = $val['type']; |
|
1264 | + $is_default = $val['is_default']; |
|
1265 | 1265 | |
1266 | - /* field available to site admin only for edit */ |
|
1267 | - $for_admin_use = isset($val['for_admin_use']) && (int)$val['for_admin_use'] == 1 ? true : false; |
|
1268 | - if ($for_admin_use && !is_super_admin()) { |
|
1269 | - continue; |
|
1270 | - } |
|
1266 | + /* field available to site admin only for edit */ |
|
1267 | + $for_admin_use = isset($val['for_admin_use']) && (int)$val['for_admin_use'] == 1 ? true : false; |
|
1268 | + if ($for_admin_use && !is_super_admin()) { |
|
1269 | + continue; |
|
1270 | + } |
|
1271 | 1271 | |
1272 | - if (is_admin()) { |
|
1273 | - global $post; |
|
1272 | + if (is_admin()) { |
|
1273 | + global $post; |
|
1274 | 1274 | |
1275 | - if (isset($_REQUEST['post'])) |
|
1276 | - $_REQUEST['pid'] = $_REQUEST['post']; |
|
1277 | - } |
|
1275 | + if (isset($_REQUEST['post'])) |
|
1276 | + $_REQUEST['pid'] = $_REQUEST['post']; |
|
1277 | + } |
|
1278 | 1278 | |
1279 | 1279 | |
1280 | 1280 | |
1281 | - /** |
|
1282 | - * Called before the custom fields info is output for submitting a post. |
|
1283 | - * |
|
1284 | - * Used dynamic hook type geodir_before_custom_form_field_$name. |
|
1285 | - * |
|
1286 | - * @since 1.0.0 |
|
1287 | - * @param string $listing_type The post post type. |
|
1288 | - * @param int $package_id The price package ID for the post. |
|
1289 | - * @param array $val The settings array for the field. {@see geodir_custom_field_save()}. |
|
1290 | - * @see 'geodir_after_custom_form_field_$name' |
|
1291 | - */ |
|
1292 | - do_action('geodir_before_custom_form_field_' . $name, $listing_type, $package_id, $val); |
|
1293 | - |
|
1294 | - |
|
1295 | - $custom_field = $val; |
|
1296 | - $html =''; |
|
1297 | - /** |
|
1298 | - * Filter the output for custom fields. |
|
1299 | - * |
|
1300 | - * Here we can remove or add new functions depending on the field type. |
|
1301 | - * |
|
1302 | - * @param string $html The html to be filtered (blank). |
|
1303 | - * @param array $custom_field The custom field array values. |
|
1304 | - */ |
|
1305 | - echo apply_filters("geodir_custom_field_input_{$type}",$html,$custom_field); |
|
1306 | - |
|
1307 | - |
|
1308 | - |
|
1309 | - /** |
|
1310 | - * Called after the custom fields info is output for submitting a post. |
|
1311 | - * |
|
1312 | - * Used dynamic hook type geodir_after_custom_form_field_$name. |
|
1313 | - * |
|
1314 | - * @since 1.0.0 |
|
1315 | - * @param string $listing_type The post post type. |
|
1316 | - * @param int $package_id The price package ID for the post. |
|
1317 | - * @param array $val The settings array for the field. {@see geodir_custom_field_save()}. |
|
1318 | - * @see 'geodir_before_custom_form_field_$name' |
|
1319 | - */ |
|
1320 | - do_action('geodir_after_custom_form_field_' . $name, $listing_type, $package_id, $val); |
|
1321 | - |
|
1322 | - } |
|
1281 | + /** |
|
1282 | + * Called before the custom fields info is output for submitting a post. |
|
1283 | + * |
|
1284 | + * Used dynamic hook type geodir_before_custom_form_field_$name. |
|
1285 | + * |
|
1286 | + * @since 1.0.0 |
|
1287 | + * @param string $listing_type The post post type. |
|
1288 | + * @param int $package_id The price package ID for the post. |
|
1289 | + * @param array $val The settings array for the field. {@see geodir_custom_field_save()}. |
|
1290 | + * @see 'geodir_after_custom_form_field_$name' |
|
1291 | + */ |
|
1292 | + do_action('geodir_before_custom_form_field_' . $name, $listing_type, $package_id, $val); |
|
1293 | + |
|
1294 | + |
|
1295 | + $custom_field = $val; |
|
1296 | + $html =''; |
|
1297 | + /** |
|
1298 | + * Filter the output for custom fields. |
|
1299 | + * |
|
1300 | + * Here we can remove or add new functions depending on the field type. |
|
1301 | + * |
|
1302 | + * @param string $html The html to be filtered (blank). |
|
1303 | + * @param array $custom_field The custom field array values. |
|
1304 | + */ |
|
1305 | + echo apply_filters("geodir_custom_field_input_{$type}",$html,$custom_field); |
|
1306 | + |
|
1307 | + |
|
1308 | + |
|
1309 | + /** |
|
1310 | + * Called after the custom fields info is output for submitting a post. |
|
1311 | + * |
|
1312 | + * Used dynamic hook type geodir_after_custom_form_field_$name. |
|
1313 | + * |
|
1314 | + * @since 1.0.0 |
|
1315 | + * @param string $listing_type The post post type. |
|
1316 | + * @param int $package_id The price package ID for the post. |
|
1317 | + * @param array $val The settings array for the field. {@see geodir_custom_field_save()}. |
|
1318 | + * @see 'geodir_before_custom_form_field_$name' |
|
1319 | + */ |
|
1320 | + do_action('geodir_after_custom_form_field_' . $name, $listing_type, $package_id, $val); |
|
1321 | + |
|
1322 | + } |
|
1323 | 1323 | |
1324 | 1324 | } |
1325 | 1325 | |
1326 | 1326 | |
1327 | 1327 | if (!function_exists('geodir_get_field_infoby')) { |
1328 | - /** |
|
1329 | - * Get custom field using key and value. |
|
1330 | - * |
|
1331 | - * @since 1.0.0 |
|
1332 | - * @package GeoDirectory |
|
1333 | - * @global object $wpdb WordPress Database object. |
|
1334 | - * @param string $key The key you want to look for. |
|
1335 | - * @param string $value The value of the key you want to look for. |
|
1336 | - * @param string $geodir_post_type The post type. |
|
1337 | - * @return bool|mixed Returns field info when available. otherwise returns false. |
|
1338 | - */ |
|
1339 | - function geodir_get_field_infoby($key = '', $value = '', $geodir_post_type = '') |
|
1340 | - { |
|
1341 | - |
|
1342 | - global $wpdb; |
|
1343 | - |
|
1344 | - $filter = $wpdb->get_row( |
|
1345 | - $wpdb->prepare( |
|
1346 | - "SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND " . $key . "='" . $value . "'", |
|
1347 | - array($geodir_post_type) |
|
1348 | - ) |
|
1349 | - ); |
|
1350 | - |
|
1351 | - if ($filter) { |
|
1352 | - return $filter; |
|
1353 | - } else { |
|
1354 | - return false; |
|
1355 | - } |
|
1356 | - |
|
1357 | - } |
|
1328 | + /** |
|
1329 | + * Get custom field using key and value. |
|
1330 | + * |
|
1331 | + * @since 1.0.0 |
|
1332 | + * @package GeoDirectory |
|
1333 | + * @global object $wpdb WordPress Database object. |
|
1334 | + * @param string $key The key you want to look for. |
|
1335 | + * @param string $value The value of the key you want to look for. |
|
1336 | + * @param string $geodir_post_type The post type. |
|
1337 | + * @return bool|mixed Returns field info when available. otherwise returns false. |
|
1338 | + */ |
|
1339 | + function geodir_get_field_infoby($key = '', $value = '', $geodir_post_type = '') |
|
1340 | + { |
|
1341 | + |
|
1342 | + global $wpdb; |
|
1343 | + |
|
1344 | + $filter = $wpdb->get_row( |
|
1345 | + $wpdb->prepare( |
|
1346 | + "SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND " . $key . "='" . $value . "'", |
|
1347 | + array($geodir_post_type) |
|
1348 | + ) |
|
1349 | + ); |
|
1350 | + |
|
1351 | + if ($filter) { |
|
1352 | + return $filter; |
|
1353 | + } else { |
|
1354 | + return false; |
|
1355 | + } |
|
1356 | + |
|
1357 | + } |
|
1358 | 1358 | } |
1359 | 1359 | |
1360 | 1360 | |
1361 | 1361 | function geodir_field_icon_proccess($cf){ |
1362 | 1362 | |
1363 | 1363 | |
1364 | - if (strpos($cf['field_icon'], 'http') !== false) { |
|
1365 | - $field_icon = ' background: url(' . $cf['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;'; |
|
1366 | - } elseif (strpos($cf['field_icon'], 'fa fa-') !== false) { |
|
1367 | - $field_icon = '<i class="' . $cf['field_icon'] . '"></i>'; |
|
1368 | - }else{ |
|
1369 | - $field_icon = $cf['field_icon']; |
|
1370 | - } |
|
1364 | + if (strpos($cf['field_icon'], 'http') !== false) { |
|
1365 | + $field_icon = ' background: url(' . $cf['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;'; |
|
1366 | + } elseif (strpos($cf['field_icon'], 'fa fa-') !== false) { |
|
1367 | + $field_icon = '<i class="' . $cf['field_icon'] . '"></i>'; |
|
1368 | + }else{ |
|
1369 | + $field_icon = $cf['field_icon']; |
|
1370 | + } |
|
1371 | 1371 | |
1372 | - return $field_icon; |
|
1372 | + return $field_icon; |
|
1373 | 1373 | } |
1374 | 1374 | |
1375 | 1375 | if (!function_exists('geodir_show_listing_info')) { |
1376 | - /** |
|
1377 | - * Show listing info depending on field location. |
|
1378 | - * |
|
1379 | - * @since 1.0.0 |
|
1380 | - * @since 1.5.7 Custom fields option values added to db translation. |
|
1381 | - * Changes to display url fields title. |
|
1382 | - * @package GeoDirectory |
|
1383 | - * @global object $wpdb WordPress Database object. |
|
1384 | - * @global object $post The current post object. |
|
1385 | - * @global bool $send_to_friend True if send to friend link already rendered. Otherwise false. |
|
1386 | - * |
|
1387 | - * @param string $fields_location In which page you are going to place this custom fields?. Ex: listing, detail etc. |
|
1388 | - * @return string Returns listing info html. |
|
1389 | - */ |
|
1390 | - function geodir_show_listing_info($fields_location = '') { |
|
1391 | - global $post, $preview, $wpdb, $send_to_friend; |
|
1392 | - |
|
1393 | - $package_info = array(); |
|
1394 | - |
|
1395 | - $package_info = geodir_post_package_info($package_info, $post); |
|
1396 | - $post_package_id = !empty($package_info->pid) ? $package_info->pid : ''; |
|
1397 | - $p_type = !empty($post->post_type) ? $post->post_type : geodir_get_current_posttype(); |
|
1398 | - $send_to_friend = false; |
|
1399 | - |
|
1400 | - ob_start(); |
|
1401 | - $fields_info = geodir_post_custom_fields($post_package_id, 'all', $p_type, $fields_location); |
|
1402 | - |
|
1403 | - if (!empty($fields_info)) { |
|
1404 | - $post = stripslashes_deep($post); // strip slashes |
|
1376 | + /** |
|
1377 | + * Show listing info depending on field location. |
|
1378 | + * |
|
1379 | + * @since 1.0.0 |
|
1380 | + * @since 1.5.7 Custom fields option values added to db translation. |
|
1381 | + * Changes to display url fields title. |
|
1382 | + * @package GeoDirectory |
|
1383 | + * @global object $wpdb WordPress Database object. |
|
1384 | + * @global object $post The current post object. |
|
1385 | + * @global bool $send_to_friend True if send to friend link already rendered. Otherwise false. |
|
1386 | + * |
|
1387 | + * @param string $fields_location In which page you are going to place this custom fields?. Ex: listing, detail etc. |
|
1388 | + * @return string Returns listing info html. |
|
1389 | + */ |
|
1390 | + function geodir_show_listing_info($fields_location = '') { |
|
1391 | + global $post, $preview, $wpdb, $send_to_friend; |
|
1392 | + |
|
1393 | + $package_info = array(); |
|
1394 | + |
|
1395 | + $package_info = geodir_post_package_info($package_info, $post); |
|
1396 | + $post_package_id = !empty($package_info->pid) ? $package_info->pid : ''; |
|
1397 | + $p_type = !empty($post->post_type) ? $post->post_type : geodir_get_current_posttype(); |
|
1398 | + $send_to_friend = false; |
|
1399 | + |
|
1400 | + ob_start(); |
|
1401 | + $fields_info = geodir_post_custom_fields($post_package_id, 'all', $p_type, $fields_location); |
|
1402 | + |
|
1403 | + if (!empty($fields_info)) { |
|
1404 | + $post = stripslashes_deep($post); // strip slashes |
|
1405 | 1405 | |
1406 | - //echo '<div class="geodir-company_info field-group">'; |
|
1407 | - global $field_set_start; |
|
1408 | - $field_set_start = 0; |
|
1409 | - |
|
1410 | - |
|
1411 | - |
|
1412 | - foreach ($fields_info as $type) { |
|
1413 | - if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];} |
|
1414 | - $type = stripslashes_deep($type); // strip slashes |
|
1415 | - if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;} |
|
1416 | - $html = ''; |
|
1417 | - $field_icon = geodir_field_icon_proccess($type); |
|
1418 | - $filed_type = $type['type']; |
|
1419 | - $html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : ''; |
|
1420 | - if($html_var=='post'){$html_var='post_address';} |
|
1421 | - |
|
1422 | - /** |
|
1423 | - * Filter the output for custom fields. |
|
1424 | - * |
|
1425 | - * Here we can remove or add new functions depending on the field type. |
|
1426 | - * |
|
1427 | - * @param string $html The html to be filtered (blank). |
|
1428 | - * @param string $fields_location The location the field is to be show. |
|
1429 | - * @param array $type The array of field values. |
|
1430 | - */ |
|
1431 | - $html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type); |
|
1432 | - |
|
1433 | - $variables_array = array(); |
|
1434 | - |
|
1435 | - |
|
1436 | - if ($type['type'] != 'fieldset'): |
|
1437 | - $variables_array['post_id'] = !empty($post->ID) ? $post->ID : (!empty($post->pid) ? $post->pid : NULL); |
|
1438 | - $variables_array['label'] = __($type['site_title'], 'geodirectory'); |
|
1439 | - $variables_array['value'] = ''; |
|
1440 | - if (isset($post->{$type['htmlvar_name']})) |
|
1441 | - $variables_array['value'] = $post->{$type['htmlvar_name']}; |
|
1442 | - endif; |
|
1443 | - |
|
1444 | - |
|
1445 | - if ($html): |
|
1446 | - |
|
1447 | - /** |
|
1448 | - * Called before a custom fields is output on the frontend. |
|
1449 | - * |
|
1450 | - * @since 1.0.0 |
|
1451 | - * @param string $html_var The HTML variable name for the field. |
|
1452 | - */ |
|
1453 | - do_action("geodir_before_show_{$html_var}"); |
|
1454 | - /** |
|
1455 | - * Filter custom field output. |
|
1456 | - * |
|
1457 | - * @since 1.0.0 |
|
1458 | - * |
|
1459 | - * @param string $html_var The HTML variable name for the field. |
|
1460 | - * @param string $html Custom field unfiltered HTML. |
|
1461 | - * @param array $variables_array Custom field variables array. |
|
1462 | - */ |
|
1463 | - if ($html) echo apply_filters("geodir_show_{$html_var}", $html, $variables_array); |
|
1464 | - |
|
1465 | - /** |
|
1466 | - * Called after a custom fields is output on the frontend. |
|
1467 | - * |
|
1468 | - * @since 1.0.0 |
|
1469 | - * @param string $html_var The HTML variable name for the field. |
|
1470 | - */ |
|
1471 | - do_action("geodir_after_show_{$html_var}"); |
|
1472 | - |
|
1473 | - endif; |
|
1474 | - |
|
1475 | - } |
|
1476 | - |
|
1477 | - //echo '</div>'; |
|
1478 | - |
|
1479 | - } |
|
1480 | - |
|
1481 | - |
|
1482 | - $html = ob_get_clean(); |
|
1483 | - |
|
1484 | - /** |
|
1485 | - * Filter the custom fields over all output. |
|
1486 | - * |
|
1487 | - * @param string $html The html of the custom fields. |
|
1488 | - * @param string $fields_location The location the fields are being output. |
|
1489 | - * @since 1.6.9 |
|
1490 | - */ |
|
1491 | - return apply_filters('geodir_show_listing_info',$html,$fields_location); |
|
1492 | - |
|
1493 | - } |
|
1406 | + //echo '<div class="geodir-company_info field-group">'; |
|
1407 | + global $field_set_start; |
|
1408 | + $field_set_start = 0; |
|
1409 | + |
|
1410 | + |
|
1411 | + |
|
1412 | + foreach ($fields_info as $type) { |
|
1413 | + if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];} |
|
1414 | + $type = stripslashes_deep($type); // strip slashes |
|
1415 | + if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;} |
|
1416 | + $html = ''; |
|
1417 | + $field_icon = geodir_field_icon_proccess($type); |
|
1418 | + $filed_type = $type['type']; |
|
1419 | + $html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : ''; |
|
1420 | + if($html_var=='post'){$html_var='post_address';} |
|
1421 | + |
|
1422 | + /** |
|
1423 | + * Filter the output for custom fields. |
|
1424 | + * |
|
1425 | + * Here we can remove or add new functions depending on the field type. |
|
1426 | + * |
|
1427 | + * @param string $html The html to be filtered (blank). |
|
1428 | + * @param string $fields_location The location the field is to be show. |
|
1429 | + * @param array $type The array of field values. |
|
1430 | + */ |
|
1431 | + $html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type); |
|
1432 | + |
|
1433 | + $variables_array = array(); |
|
1434 | + |
|
1435 | + |
|
1436 | + if ($type['type'] != 'fieldset'): |
|
1437 | + $variables_array['post_id'] = !empty($post->ID) ? $post->ID : (!empty($post->pid) ? $post->pid : NULL); |
|
1438 | + $variables_array['label'] = __($type['site_title'], 'geodirectory'); |
|
1439 | + $variables_array['value'] = ''; |
|
1440 | + if (isset($post->{$type['htmlvar_name']})) |
|
1441 | + $variables_array['value'] = $post->{$type['htmlvar_name']}; |
|
1442 | + endif; |
|
1443 | + |
|
1444 | + |
|
1445 | + if ($html): |
|
1446 | + |
|
1447 | + /** |
|
1448 | + * Called before a custom fields is output on the frontend. |
|
1449 | + * |
|
1450 | + * @since 1.0.0 |
|
1451 | + * @param string $html_var The HTML variable name for the field. |
|
1452 | + */ |
|
1453 | + do_action("geodir_before_show_{$html_var}"); |
|
1454 | + /** |
|
1455 | + * Filter custom field output. |
|
1456 | + * |
|
1457 | + * @since 1.0.0 |
|
1458 | + * |
|
1459 | + * @param string $html_var The HTML variable name for the field. |
|
1460 | + * @param string $html Custom field unfiltered HTML. |
|
1461 | + * @param array $variables_array Custom field variables array. |
|
1462 | + */ |
|
1463 | + if ($html) echo apply_filters("geodir_show_{$html_var}", $html, $variables_array); |
|
1464 | + |
|
1465 | + /** |
|
1466 | + * Called after a custom fields is output on the frontend. |
|
1467 | + * |
|
1468 | + * @since 1.0.0 |
|
1469 | + * @param string $html_var The HTML variable name for the field. |
|
1470 | + */ |
|
1471 | + do_action("geodir_after_show_{$html_var}"); |
|
1472 | + |
|
1473 | + endif; |
|
1474 | + |
|
1475 | + } |
|
1476 | + |
|
1477 | + //echo '</div>'; |
|
1478 | + |
|
1479 | + } |
|
1480 | + |
|
1481 | + |
|
1482 | + $html = ob_get_clean(); |
|
1483 | + |
|
1484 | + /** |
|
1485 | + * Filter the custom fields over all output. |
|
1486 | + * |
|
1487 | + * @param string $html The html of the custom fields. |
|
1488 | + * @param string $fields_location The location the fields are being output. |
|
1489 | + * @since 1.6.9 |
|
1490 | + */ |
|
1491 | + return apply_filters('geodir_show_listing_info',$html,$fields_location); |
|
1492 | + |
|
1493 | + } |
|
1494 | 1494 | } |
1495 | 1495 | |
1496 | 1496 | if (!function_exists('geodir_default_date_format')) { |
1497 | - /** |
|
1498 | - * Returns default date format. |
|
1499 | - * |
|
1500 | - * @since 1.0.0 |
|
1501 | - * @package GeoDirectory |
|
1502 | - * @return mixed|string|void Returns default date format. |
|
1503 | - */ |
|
1504 | - function geodir_default_date_format() |
|
1505 | - { |
|
1506 | - if ($format = get_option('date_format')) |
|
1507 | - return $format; |
|
1508 | - else |
|
1509 | - return 'dd-mm-yy'; |
|
1510 | - } |
|
1497 | + /** |
|
1498 | + * Returns default date format. |
|
1499 | + * |
|
1500 | + * @since 1.0.0 |
|
1501 | + * @package GeoDirectory |
|
1502 | + * @return mixed|string|void Returns default date format. |
|
1503 | + */ |
|
1504 | + function geodir_default_date_format() |
|
1505 | + { |
|
1506 | + if ($format = get_option('date_format')) |
|
1507 | + return $format; |
|
1508 | + else |
|
1509 | + return 'dd-mm-yy'; |
|
1510 | + } |
|
1511 | 1511 | } |
1512 | 1512 | |
1513 | 1513 | if (!function_exists('geodir_get_formated_date')) { |
1514 | - /** |
|
1515 | - * Returns formatted date. |
|
1516 | - * |
|
1517 | - * @since 1.0.0 |
|
1518 | - * @package GeoDirectory |
|
1519 | - * @param string $date Date string to convert. |
|
1520 | - * @return bool|int|string Returns formatted date. |
|
1521 | - */ |
|
1522 | - function geodir_get_formated_date($date) |
|
1523 | - { |
|
1524 | - return mysql2date(get_option('date_format'), $date); |
|
1525 | - } |
|
1514 | + /** |
|
1515 | + * Returns formatted date. |
|
1516 | + * |
|
1517 | + * @since 1.0.0 |
|
1518 | + * @package GeoDirectory |
|
1519 | + * @param string $date Date string to convert. |
|
1520 | + * @return bool|int|string Returns formatted date. |
|
1521 | + */ |
|
1522 | + function geodir_get_formated_date($date) |
|
1523 | + { |
|
1524 | + return mysql2date(get_option('date_format'), $date); |
|
1525 | + } |
|
1526 | 1526 | } |
1527 | 1527 | |
1528 | 1528 | if (!function_exists('geodir_get_formated_time')) { |
1529 | - /** |
|
1530 | - * Returns formatted time. |
|
1531 | - * |
|
1532 | - * @since 1.0.0 |
|
1533 | - * @package GeoDirectory |
|
1534 | - * @param string $time Time string to convert. |
|
1535 | - * @return bool|int|string Returns formatted time. |
|
1536 | - */ |
|
1537 | - function geodir_get_formated_time($time) |
|
1538 | - { |
|
1539 | - return mysql2date(get_option('time_format'), $time, $translate = true); |
|
1540 | - } |
|
1529 | + /** |
|
1530 | + * Returns formatted time. |
|
1531 | + * |
|
1532 | + * @since 1.0.0 |
|
1533 | + * @package GeoDirectory |
|
1534 | + * @param string $time Time string to convert. |
|
1535 | + * @return bool|int|string Returns formatted time. |
|
1536 | + */ |
|
1537 | + function geodir_get_formated_time($time) |
|
1538 | + { |
|
1539 | + return mysql2date(get_option('time_format'), $time, $translate = true); |
|
1540 | + } |
|
1541 | 1541 | } |
1542 | 1542 | |
1543 | 1543 | |
1544 | 1544 | if (!function_exists('geodir_save_post_file_fields')) { |
1545 | - /** |
|
1546 | - * Save post file fields |
|
1547 | - * |
|
1548 | - * @since 1.0.0 |
|
1549 | - * @since 1.4.7 Added `$extra_fields` parameter. |
|
1550 | - * @package GeoDirectory |
|
1551 | - * @global object $wpdb WordPress Database object. |
|
1552 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
1553 | - * @global object $current_user Current user object. |
|
1554 | - * @param int $post_id |
|
1555 | - * @param string $field_id |
|
1556 | - * @param array $post_image |
|
1557 | - * @param array $extra_fields Array of extra fields. |
|
1558 | - */ |
|
1559 | - function geodir_save_post_file_fields($post_id = 0, $field_id = '', $post_image = array(), $extra_fields = array()) |
|
1560 | - { |
|
1545 | + /** |
|
1546 | + * Save post file fields |
|
1547 | + * |
|
1548 | + * @since 1.0.0 |
|
1549 | + * @since 1.4.7 Added `$extra_fields` parameter. |
|
1550 | + * @package GeoDirectory |
|
1551 | + * @global object $wpdb WordPress Database object. |
|
1552 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
1553 | + * @global object $current_user Current user object. |
|
1554 | + * @param int $post_id |
|
1555 | + * @param string $field_id |
|
1556 | + * @param array $post_image |
|
1557 | + * @param array $extra_fields Array of extra fields. |
|
1558 | + */ |
|
1559 | + function geodir_save_post_file_fields($post_id = 0, $field_id = '', $post_image = array(), $extra_fields = array()) |
|
1560 | + { |
|
1561 | 1561 | |
1562 | - global $wpdb, $plugin_prefix, $current_user; |
|
1562 | + global $wpdb, $plugin_prefix, $current_user; |
|
1563 | 1563 | |
1564 | - $post_type = get_post_type($post_id); |
|
1565 | - //echo $field_id; exit; |
|
1566 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
1564 | + $post_type = get_post_type($post_id); |
|
1565 | + //echo $field_id; exit; |
|
1566 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
1567 | 1567 | |
1568 | - $postcurr_images = array(); |
|
1569 | - $postcurr_images = geodir_get_post_meta($post_id, $field_id, true); |
|
1570 | - $file_urls = ''; |
|
1568 | + $postcurr_images = array(); |
|
1569 | + $postcurr_images = geodir_get_post_meta($post_id, $field_id, true); |
|
1570 | + $file_urls = ''; |
|
1571 | 1571 | |
1572 | - if (!empty($post_image)) { |
|
1572 | + if (!empty($post_image)) { |
|
1573 | 1573 | |
1574 | - $invalid_files = array(); |
|
1574 | + $invalid_files = array(); |
|
1575 | 1575 | |
1576 | - //Get and remove all old images of post from database to set by new order |
|
1577 | - $geodir_uploaddir = ''; |
|
1578 | - $uploads = wp_upload_dir(); |
|
1579 | - $uploads_dir = $uploads['path']; |
|
1576 | + //Get and remove all old images of post from database to set by new order |
|
1577 | + $geodir_uploaddir = ''; |
|
1578 | + $uploads = wp_upload_dir(); |
|
1579 | + $uploads_dir = $uploads['path']; |
|
1580 | 1580 | |
1581 | - $geodir_uploadpath = $uploads['path']; |
|
1582 | - $geodir_uploadurl = $uploads['url']; |
|
1583 | - $sub_dir = $uploads['subdir']; |
|
1581 | + $geodir_uploadpath = $uploads['path']; |
|
1582 | + $geodir_uploadurl = $uploads['url']; |
|
1583 | + $sub_dir = $uploads['subdir']; |
|
1584 | 1584 | |
1585 | - $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : ''; |
|
1585 | + $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : ''; |
|
1586 | 1586 | |
1587 | - for ($m = 0; $m < count($post_image); $m++) { |
|
1587 | + for ($m = 0; $m < count($post_image); $m++) { |
|
1588 | 1588 | |
1589 | - /* --------- start ------- */ |
|
1589 | + /* --------- start ------- */ |
|
1590 | 1590 | |
1591 | - if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM " . $table . " WHERE $field_id = %s AND post_id = %d", array($post_image[$m], $post_id)))) { |
|
1591 | + if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM " . $table . " WHERE $field_id = %s AND post_id = %d", array($post_image[$m], $post_id)))) { |
|
1592 | 1592 | |
1593 | 1593 | |
1594 | - $curr_img_url = $post_image[$m]; |
|
1595 | - $image_name_arr = explode('/', $curr_img_url); |
|
1596 | - $curr_img_dir = $image_name_arr[count($image_name_arr) - 2]; |
|
1597 | - $filename = end($image_name_arr); |
|
1598 | - $img_name_arr = explode('.', $filename); |
|
1594 | + $curr_img_url = $post_image[$m]; |
|
1595 | + $image_name_arr = explode('/', $curr_img_url); |
|
1596 | + $curr_img_dir = $image_name_arr[count($image_name_arr) - 2]; |
|
1597 | + $filename = end($image_name_arr); |
|
1598 | + $img_name_arr = explode('.', $filename); |
|
1599 | 1599 | |
1600 | - $arr_file_type = wp_check_filetype($filename); |
|
1600 | + $arr_file_type = wp_check_filetype($filename); |
|
1601 | 1601 | |
1602 | - if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) { |
|
1603 | - continue; |
|
1604 | - } |
|
1602 | + if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) { |
|
1603 | + continue; |
|
1604 | + } |
|
1605 | 1605 | |
1606 | - $uploaded_file_type = $arr_file_type['type']; |
|
1607 | - $uploaded_file_ext = $arr_file_type['ext']; |
|
1606 | + $uploaded_file_type = $arr_file_type['type']; |
|
1607 | + $uploaded_file_ext = $arr_file_type['ext']; |
|
1608 | 1608 | |
1609 | - if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) { |
|
1610 | - continue; // Invalid file type. |
|
1611 | - } |
|
1609 | + if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) { |
|
1610 | + continue; // Invalid file type. |
|
1611 | + } |
|
1612 | 1612 | |
1613 | - // Set an array containing a list of acceptable formats |
|
1614 | - //$allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/octet-stream', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain'); |
|
1613 | + // Set an array containing a list of acceptable formats |
|
1614 | + //$allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/octet-stream', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain'); |
|
1615 | 1615 | |
1616 | - if (!function_exists('wp_handle_upload')) |
|
1617 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
1616 | + if (!function_exists('wp_handle_upload')) |
|
1617 | + require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
1618 | 1618 | |
1619 | - if (!is_dir($geodir_uploadpath)) |
|
1620 | - mkdir($geodir_uploadpath); |
|
1619 | + if (!is_dir($geodir_uploadpath)) |
|
1620 | + mkdir($geodir_uploadpath); |
|
1621 | 1621 | |
1622 | - $new_name = $post_id . '_' . $field_id . '_' . $img_name_arr[0] . '.' . $img_name_arr[1]; |
|
1623 | - $explode_sub_dir = explode("/", $sub_dir); |
|
1624 | - if ($curr_img_dir == end($explode_sub_dir)) { |
|
1625 | - $img_path = $geodir_uploadpath . '/' . $filename; |
|
1626 | - $img_url = $geodir_uploadurl . '/' . $filename; |
|
1627 | - } else { |
|
1628 | - $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
1629 | - $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
1630 | - } |
|
1622 | + $new_name = $post_id . '_' . $field_id . '_' . $img_name_arr[0] . '.' . $img_name_arr[1]; |
|
1623 | + $explode_sub_dir = explode("/", $sub_dir); |
|
1624 | + if ($curr_img_dir == end($explode_sub_dir)) { |
|
1625 | + $img_path = $geodir_uploadpath . '/' . $filename; |
|
1626 | + $img_url = $geodir_uploadurl . '/' . $filename; |
|
1627 | + } else { |
|
1628 | + $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
1629 | + $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
1630 | + } |
|
1631 | 1631 | |
1632 | - $uploaded_file = ''; |
|
1633 | - if (file_exists($img_path)) |
|
1634 | - $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name); |
|
1632 | + $uploaded_file = ''; |
|
1633 | + if (file_exists($img_path)) |
|
1634 | + $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name); |
|
1635 | 1635 | |
1636 | - if ($curr_img_dir != $geodir_uploaddir) { |
|
1637 | - if (file_exists($img_path)) |
|
1638 | - unlink($img_path); |
|
1639 | - } |
|
1636 | + if ($curr_img_dir != $geodir_uploaddir) { |
|
1637 | + if (file_exists($img_path)) |
|
1638 | + unlink($img_path); |
|
1639 | + } |
|
1640 | 1640 | |
1641 | - if (!empty($uploaded_file)) |
|
1642 | - $file_urls = $geodir_uploadurl . '/' . $new_name; |
|
1641 | + if (!empty($uploaded_file)) |
|
1642 | + $file_urls = $geodir_uploadurl . '/' . $new_name; |
|
1643 | 1643 | |
1644 | - } else { |
|
1645 | - $file_urls = $post_image[$m]; |
|
1646 | - } |
|
1647 | - } |
|
1644 | + } else { |
|
1645 | + $file_urls = $post_image[$m]; |
|
1646 | + } |
|
1647 | + } |
|
1648 | 1648 | |
1649 | 1649 | |
1650 | - } |
|
1650 | + } |
|
1651 | 1651 | |
1652 | - //Remove all old attachments and temp images |
|
1653 | - if (!empty($postcurr_images)) { |
|
1652 | + //Remove all old attachments and temp images |
|
1653 | + if (!empty($postcurr_images)) { |
|
1654 | 1654 | |
1655 | - if ($file_urls != $postcurr_images) { |
|
1656 | - $invalid_files[] = (object)array('src' => $postcurr_images); |
|
1657 | - $invalid_files = (object)$invalid_files; |
|
1658 | - } |
|
1659 | - } |
|
1655 | + if ($file_urls != $postcurr_images) { |
|
1656 | + $invalid_files[] = (object)array('src' => $postcurr_images); |
|
1657 | + $invalid_files = (object)$invalid_files; |
|
1658 | + } |
|
1659 | + } |
|
1660 | 1660 | |
1661 | - geodir_save_post_meta($post_id, $field_id, $file_urls); |
|
1661 | + geodir_save_post_meta($post_id, $field_id, $file_urls); |
|
1662 | 1662 | |
1663 | - if (!empty($invalid_files)) |
|
1664 | - geodir_remove_attachments($invalid_files); |
|
1663 | + if (!empty($invalid_files)) |
|
1664 | + geodir_remove_attachments($invalid_files); |
|
1665 | 1665 | |
1666 | - } |
|
1666 | + } |
|
1667 | 1667 | } |
1668 | 1668 | |
1669 | 1669 | |
@@ -1678,76 +1678,76 @@ discard block |
||
1678 | 1678 | */ |
1679 | 1679 | function geodir_custom_upload_mimes($existing_mimes = array()) |
1680 | 1680 | { |
1681 | - $existing_mimes['wif'] = 'text/plain'; |
|
1682 | - $existing_mimes['jpg|jpeg'] = 'image/jpeg'; |
|
1683 | - $existing_mimes['gif'] = 'image/gif'; |
|
1684 | - $existing_mimes['png'] = 'image/png'; |
|
1685 | - $existing_mimes['pdf'] = 'application/pdf'; |
|
1686 | - $existing_mimes['txt'] = 'text/text'; |
|
1687 | - $existing_mimes['csv'] = 'application/octet-stream'; |
|
1688 | - $existing_mimes['doc'] = 'application/msword'; |
|
1689 | - $existing_mimes['xla|xls|xlt|xlw'] = 'application/vnd.ms-excel'; |
|
1690 | - $existing_mimes['docx'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; |
|
1691 | - $existing_mimes['xlsx'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; |
|
1692 | - return $existing_mimes; |
|
1681 | + $existing_mimes['wif'] = 'text/plain'; |
|
1682 | + $existing_mimes['jpg|jpeg'] = 'image/jpeg'; |
|
1683 | + $existing_mimes['gif'] = 'image/gif'; |
|
1684 | + $existing_mimes['png'] = 'image/png'; |
|
1685 | + $existing_mimes['pdf'] = 'application/pdf'; |
|
1686 | + $existing_mimes['txt'] = 'text/text'; |
|
1687 | + $existing_mimes['csv'] = 'application/octet-stream'; |
|
1688 | + $existing_mimes['doc'] = 'application/msword'; |
|
1689 | + $existing_mimes['xla|xls|xlt|xlw'] = 'application/vnd.ms-excel'; |
|
1690 | + $existing_mimes['docx'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; |
|
1691 | + $existing_mimes['xlsx'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; |
|
1692 | + return $existing_mimes; |
|
1693 | 1693 | } |
1694 | 1694 | |
1695 | 1695 | if (!function_exists('geodir_plupload_action')) { |
1696 | 1696 | |
1697 | - /** |
|
1698 | - * Get upload directory path details |
|
1699 | - * |
|
1700 | - * @since 1.0.0 |
|
1701 | - * @package GeoDirectory |
|
1702 | - * @global object $current_user Current user object. |
|
1703 | - * @param array $upload Array of upload directory data with keys of 'path','url', 'subdir, 'basedir', and 'error'. |
|
1704 | - * @return mixed Returns upload directory details as an array. |
|
1705 | - */ |
|
1706 | - function geodir_upload_dir($upload) |
|
1707 | - { |
|
1708 | - global $current_user; |
|
1709 | - $upload['subdir'] = $upload['subdir'] . '/temp_' . $current_user->data->ID; |
|
1710 | - $upload['path'] = $upload['basedir'] . $upload['subdir']; |
|
1711 | - $upload['url'] = $upload['baseurl'] . $upload['subdir']; |
|
1712 | - return $upload; |
|
1713 | - } |
|
1714 | - |
|
1715 | - /** |
|
1716 | - * Handles place file and image upload. |
|
1717 | - * |
|
1718 | - * @since 1.0.0 |
|
1719 | - * @package GeoDirectory |
|
1720 | - */ |
|
1721 | - function geodir_plupload_action() |
|
1722 | - { |
|
1723 | - // check ajax nonce |
|
1724 | - $imgid = $_POST["imgid"]; |
|
1725 | - |
|
1726 | - check_ajax_referer($imgid . 'pluploadan'); |
|
1727 | - |
|
1728 | - // handle custom file uploaddir |
|
1729 | - add_filter('upload_dir', 'geodir_upload_dir'); |
|
1730 | - |
|
1731 | - // change file orientation if needed |
|
1732 | - $fixed_file = geodir_exif($_FILES[$imgid . 'async-upload']); |
|
1733 | - |
|
1734 | - // handle file upload |
|
1735 | - $status = wp_handle_upload($fixed_file, array('test_form' => true, 'action' => 'plupload_action')); |
|
1736 | - // remove handle custom file uploaddir |
|
1737 | - remove_filter('upload_dir', 'geodir_upload_dir'); |
|
1738 | - |
|
1739 | - if(!isset($status['url']) && isset($status['error'])){ |
|
1740 | - print_r($status); |
|
1741 | - } |
|
1742 | - |
|
1743 | - // send the uploaded file url in response |
|
1744 | - if (isset($status['url'])) { |
|
1745 | - echo $status['url']; |
|
1746 | - } else { |
|
1747 | - echo 'x'; |
|
1748 | - } |
|
1749 | - exit; |
|
1750 | - } |
|
1697 | + /** |
|
1698 | + * Get upload directory path details |
|
1699 | + * |
|
1700 | + * @since 1.0.0 |
|
1701 | + * @package GeoDirectory |
|
1702 | + * @global object $current_user Current user object. |
|
1703 | + * @param array $upload Array of upload directory data with keys of 'path','url', 'subdir, 'basedir', and 'error'. |
|
1704 | + * @return mixed Returns upload directory details as an array. |
|
1705 | + */ |
|
1706 | + function geodir_upload_dir($upload) |
|
1707 | + { |
|
1708 | + global $current_user; |
|
1709 | + $upload['subdir'] = $upload['subdir'] . '/temp_' . $current_user->data->ID; |
|
1710 | + $upload['path'] = $upload['basedir'] . $upload['subdir']; |
|
1711 | + $upload['url'] = $upload['baseurl'] . $upload['subdir']; |
|
1712 | + return $upload; |
|
1713 | + } |
|
1714 | + |
|
1715 | + /** |
|
1716 | + * Handles place file and image upload. |
|
1717 | + * |
|
1718 | + * @since 1.0.0 |
|
1719 | + * @package GeoDirectory |
|
1720 | + */ |
|
1721 | + function geodir_plupload_action() |
|
1722 | + { |
|
1723 | + // check ajax nonce |
|
1724 | + $imgid = $_POST["imgid"]; |
|
1725 | + |
|
1726 | + check_ajax_referer($imgid . 'pluploadan'); |
|
1727 | + |
|
1728 | + // handle custom file uploaddir |
|
1729 | + add_filter('upload_dir', 'geodir_upload_dir'); |
|
1730 | + |
|
1731 | + // change file orientation if needed |
|
1732 | + $fixed_file = geodir_exif($_FILES[$imgid . 'async-upload']); |
|
1733 | + |
|
1734 | + // handle file upload |
|
1735 | + $status = wp_handle_upload($fixed_file, array('test_form' => true, 'action' => 'plupload_action')); |
|
1736 | + // remove handle custom file uploaddir |
|
1737 | + remove_filter('upload_dir', 'geodir_upload_dir'); |
|
1738 | + |
|
1739 | + if(!isset($status['url']) && isset($status['error'])){ |
|
1740 | + print_r($status); |
|
1741 | + } |
|
1742 | + |
|
1743 | + // send the uploaded file url in response |
|
1744 | + if (isset($status['url'])) { |
|
1745 | + echo $status['url']; |
|
1746 | + } else { |
|
1747 | + echo 'x'; |
|
1748 | + } |
|
1749 | + exit; |
|
1750 | + } |
|
1751 | 1751 | } |
1752 | 1752 | |
1753 | 1753 | /** |
@@ -1762,17 +1762,17 @@ discard block |
||
1762 | 1762 | */ |
1763 | 1763 | function geodir_get_video($post_id) |
1764 | 1764 | { |
1765 | - global $wpdb, $plugin_prefix; |
|
1765 | + global $wpdb, $plugin_prefix; |
|
1766 | 1766 | |
1767 | - $post_type = get_post_type($post_id); |
|
1767 | + $post_type = get_post_type($post_id); |
|
1768 | 1768 | |
1769 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
1769 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
1770 | 1770 | |
1771 | - $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_video FROM " . $table . " WHERE post_id=%d", array($post_id))); |
|
1771 | + $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_video FROM " . $table . " WHERE post_id=%d", array($post_id))); |
|
1772 | 1772 | |
1773 | - if ($results) { |
|
1774 | - return $results[0]->geodir_video; |
|
1775 | - } |
|
1773 | + if ($results) { |
|
1774 | + return $results[0]->geodir_video; |
|
1775 | + } |
|
1776 | 1776 | |
1777 | 1777 | } |
1778 | 1778 | |
@@ -1788,40 +1788,40 @@ discard block |
||
1788 | 1788 | */ |
1789 | 1789 | function geodir_get_special_offers($post_id) |
1790 | 1790 | { |
1791 | - global $wpdb, $plugin_prefix; |
|
1791 | + global $wpdb, $plugin_prefix; |
|
1792 | 1792 | |
1793 | - $post_type = get_post_type($post_id); |
|
1793 | + $post_type = get_post_type($post_id); |
|
1794 | 1794 | |
1795 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
1795 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
1796 | 1796 | |
1797 | - $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_special_offers FROM " . $table . " WHERE post_id=%d", array($post_id))); |
|
1797 | + $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_special_offers FROM " . $table . " WHERE post_id=%d", array($post_id))); |
|
1798 | 1798 | |
1799 | - if ($results) { |
|
1800 | - return $results[0]->geodir_special_offers; |
|
1801 | - } |
|
1799 | + if ($results) { |
|
1800 | + return $results[0]->geodir_special_offers; |
|
1801 | + } |
|
1802 | 1802 | |
1803 | 1803 | } |
1804 | 1804 | |
1805 | 1805 | if (!function_exists('geodir_max_upload_size')) { |
1806 | - /** |
|
1807 | - * Get max upload file size |
|
1808 | - * |
|
1809 | - * @since 1.0.0 |
|
1810 | - * @package GeoDirectory |
|
1811 | - * @return mixed|void Returns max upload file size. |
|
1812 | - */ |
|
1813 | - function geodir_max_upload_size() |
|
1814 | - { |
|
1815 | - $max_filesize = (float)get_option('geodir_upload_max_filesize', 2); |
|
1816 | - |
|
1817 | - if ($max_filesize > 0 && $max_filesize < 1) { |
|
1818 | - $max_filesize = (int)($max_filesize * 1024) . 'kb'; |
|
1819 | - } else { |
|
1820 | - $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb'; |
|
1821 | - } |
|
1822 | - /** Filter documented in geodirectory-functions/general_functions.php **/ |
|
1823 | - return apply_filters('geodir_default_image_upload_size_limit', $max_filesize); |
|
1824 | - } |
|
1806 | + /** |
|
1807 | + * Get max upload file size |
|
1808 | + * |
|
1809 | + * @since 1.0.0 |
|
1810 | + * @package GeoDirectory |
|
1811 | + * @return mixed|void Returns max upload file size. |
|
1812 | + */ |
|
1813 | + function geodir_max_upload_size() |
|
1814 | + { |
|
1815 | + $max_filesize = (float)get_option('geodir_upload_max_filesize', 2); |
|
1816 | + |
|
1817 | + if ($max_filesize > 0 && $max_filesize < 1) { |
|
1818 | + $max_filesize = (int)($max_filesize * 1024) . 'kb'; |
|
1819 | + } else { |
|
1820 | + $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb'; |
|
1821 | + } |
|
1822 | + /** Filter documented in geodirectory-functions/general_functions.php **/ |
|
1823 | + return apply_filters('geodir_default_image_upload_size_limit', $max_filesize); |
|
1824 | + } |
|
1825 | 1825 | } |
1826 | 1826 | |
1827 | 1827 | |
@@ -1839,33 +1839,33 @@ discard block |
||
1839 | 1839 | */ |
1840 | 1840 | function geodir_add_custom_sort_options($fields, $post_type) |
1841 | 1841 | { |
1842 | - global $wpdb; |
|
1842 | + global $wpdb; |
|
1843 | 1843 | |
1844 | - if ($post_type != '') { |
|
1844 | + if ($post_type != '') { |
|
1845 | 1845 | |
1846 | - $all_postypes = geodir_get_posttypes(); |
|
1846 | + $all_postypes = geodir_get_posttypes(); |
|
1847 | 1847 | |
1848 | - if (in_array($post_type, $all_postypes)) { |
|
1848 | + if (in_array($post_type, $all_postypes)) { |
|
1849 | 1849 | |
1850 | - $custom_fields = $wpdb->get_results( |
|
1851 | - $wpdb->prepare( |
|
1852 | - "select post_type,data_type,field_type,site_title,htmlvar_name,field_icon from " . GEODIR_CUSTOM_FIELDS_TABLE . " where post_type = %s and is_active='1' and cat_sort='1' AND field_type != 'address' order by sort_order asc", |
|
1853 | - array($post_type) |
|
1854 | - ), 'ARRAY_A' |
|
1855 | - ); |
|
1850 | + $custom_fields = $wpdb->get_results( |
|
1851 | + $wpdb->prepare( |
|
1852 | + "select post_type,data_type,field_type,site_title,htmlvar_name,field_icon from " . GEODIR_CUSTOM_FIELDS_TABLE . " where post_type = %s and is_active='1' and cat_sort='1' AND field_type != 'address' order by sort_order asc", |
|
1853 | + array($post_type) |
|
1854 | + ), 'ARRAY_A' |
|
1855 | + ); |
|
1856 | 1856 | |
1857 | - if (!empty($custom_fields)) { |
|
1857 | + if (!empty($custom_fields)) { |
|
1858 | 1858 | |
1859 | - foreach ($custom_fields as $val) { |
|
1860 | - $fields[] = $val; |
|
1861 | - } |
|
1862 | - } |
|
1859 | + foreach ($custom_fields as $val) { |
|
1860 | + $fields[] = $val; |
|
1861 | + } |
|
1862 | + } |
|
1863 | 1863 | |
1864 | - } |
|
1864 | + } |
|
1865 | 1865 | |
1866 | - } |
|
1866 | + } |
|
1867 | 1867 | |
1868 | - return $fields; |
|
1868 | + return $fields; |
|
1869 | 1869 | } |
1870 | 1870 | |
1871 | 1871 | |
@@ -1881,76 +1881,76 @@ discard block |
||
1881 | 1881 | function geodir_get_custom_sort_options($post_type = '') |
1882 | 1882 | { |
1883 | 1883 | |
1884 | - global $wpdb; |
|
1885 | - |
|
1886 | - if ($post_type != '') { |
|
1887 | - |
|
1888 | - $all_postypes = geodir_get_posttypes(); |
|
1889 | - |
|
1890 | - if (!in_array($post_type, $all_postypes)) |
|
1891 | - return false; |
|
1892 | - |
|
1893 | - $fields = array(); |
|
1894 | - |
|
1895 | - $fields[] = array( |
|
1896 | - 'post_type' => $post_type, |
|
1897 | - 'data_type' => '', |
|
1898 | - 'field_type' => 'random', |
|
1899 | - 'site_title' => 'Random', |
|
1900 | - 'htmlvar_name' => 'post_title', |
|
1901 | - 'field_icon' => 'fa fa-random', |
|
1902 | - 'description' => __('Random sort (not recommended for large sites)', 'geodirectory') |
|
1903 | - ); |
|
1904 | - |
|
1905 | - $fields[] = array( |
|
1906 | - 'post_type' => $post_type, |
|
1907 | - 'data_type' => '', |
|
1908 | - 'field_type' => 'datetime', |
|
1909 | - 'site_title' => __('Add date', 'geodirectory'), |
|
1910 | - 'htmlvar_name' => 'post_date', |
|
1911 | - 'field_icon' => 'fa fa-calendar', |
|
1912 | - 'description' => __('Sort by date added', 'geodirectory') |
|
1913 | - ); |
|
1914 | - $fields[] = array( |
|
1915 | - 'post_type' => $post_type, |
|
1916 | - 'data_type' => '', |
|
1917 | - 'field_type' => 'bigint', |
|
1918 | - 'site_title' => __('Review', 'geodirectory'), |
|
1919 | - 'htmlvar_name' => 'comment_count', |
|
1920 | - 'field_icon' => 'fa fa-commenting-o', |
|
1921 | - 'description' => __('Sort by the number of reviews', 'geodirectory') |
|
1922 | - ); |
|
1923 | - $fields[] = array( |
|
1924 | - 'post_type' => $post_type, |
|
1925 | - 'data_type' => '', |
|
1926 | - 'field_type' => 'float', |
|
1927 | - 'site_title' => __('Rating', 'geodirectory'), |
|
1928 | - 'htmlvar_name' => 'overall_rating', |
|
1929 | - 'field_icon' => 'fa fa-star-o', |
|
1930 | - 'description' => __('Sort by the overall rating value', 'geodirectory') |
|
1931 | - ); |
|
1932 | - $fields[] = array( |
|
1933 | - 'post_type' => $post_type, |
|
1934 | - 'data_type' => '', |
|
1935 | - 'field_type' => 'text', |
|
1936 | - 'site_title' => __('Title', 'geodirectory'), |
|
1937 | - 'htmlvar_name' => 'post_title', |
|
1938 | - 'field_icon' => 'fa fa-sort-alpha-desc', |
|
1939 | - 'description' => __('Sort alphabetically by title', 'geodirectory') |
|
1940 | - ); |
|
1941 | - |
|
1942 | - /** |
|
1943 | - * Hook to add custom sort options. |
|
1944 | - * |
|
1945 | - * @since 1.0.0 |
|
1946 | - * @param array $fields Unmodified sort options array. |
|
1947 | - * @param string $post_type Post type. |
|
1948 | - */ |
|
1949 | - return $fields = apply_filters('geodir_add_custom_sort_options', $fields, $post_type); |
|
1950 | - |
|
1951 | - } |
|
1952 | - |
|
1953 | - return false; |
|
1884 | + global $wpdb; |
|
1885 | + |
|
1886 | + if ($post_type != '') { |
|
1887 | + |
|
1888 | + $all_postypes = geodir_get_posttypes(); |
|
1889 | + |
|
1890 | + if (!in_array($post_type, $all_postypes)) |
|
1891 | + return false; |
|
1892 | + |
|
1893 | + $fields = array(); |
|
1894 | + |
|
1895 | + $fields[] = array( |
|
1896 | + 'post_type' => $post_type, |
|
1897 | + 'data_type' => '', |
|
1898 | + 'field_type' => 'random', |
|
1899 | + 'site_title' => 'Random', |
|
1900 | + 'htmlvar_name' => 'post_title', |
|
1901 | + 'field_icon' => 'fa fa-random', |
|
1902 | + 'description' => __('Random sort (not recommended for large sites)', 'geodirectory') |
|
1903 | + ); |
|
1904 | + |
|
1905 | + $fields[] = array( |
|
1906 | + 'post_type' => $post_type, |
|
1907 | + 'data_type' => '', |
|
1908 | + 'field_type' => 'datetime', |
|
1909 | + 'site_title' => __('Add date', 'geodirectory'), |
|
1910 | + 'htmlvar_name' => 'post_date', |
|
1911 | + 'field_icon' => 'fa fa-calendar', |
|
1912 | + 'description' => __('Sort by date added', 'geodirectory') |
|
1913 | + ); |
|
1914 | + $fields[] = array( |
|
1915 | + 'post_type' => $post_type, |
|
1916 | + 'data_type' => '', |
|
1917 | + 'field_type' => 'bigint', |
|
1918 | + 'site_title' => __('Review', 'geodirectory'), |
|
1919 | + 'htmlvar_name' => 'comment_count', |
|
1920 | + 'field_icon' => 'fa fa-commenting-o', |
|
1921 | + 'description' => __('Sort by the number of reviews', 'geodirectory') |
|
1922 | + ); |
|
1923 | + $fields[] = array( |
|
1924 | + 'post_type' => $post_type, |
|
1925 | + 'data_type' => '', |
|
1926 | + 'field_type' => 'float', |
|
1927 | + 'site_title' => __('Rating', 'geodirectory'), |
|
1928 | + 'htmlvar_name' => 'overall_rating', |
|
1929 | + 'field_icon' => 'fa fa-star-o', |
|
1930 | + 'description' => __('Sort by the overall rating value', 'geodirectory') |
|
1931 | + ); |
|
1932 | + $fields[] = array( |
|
1933 | + 'post_type' => $post_type, |
|
1934 | + 'data_type' => '', |
|
1935 | + 'field_type' => 'text', |
|
1936 | + 'site_title' => __('Title', 'geodirectory'), |
|
1937 | + 'htmlvar_name' => 'post_title', |
|
1938 | + 'field_icon' => 'fa fa-sort-alpha-desc', |
|
1939 | + 'description' => __('Sort alphabetically by title', 'geodirectory') |
|
1940 | + ); |
|
1941 | + |
|
1942 | + /** |
|
1943 | + * Hook to add custom sort options. |
|
1944 | + * |
|
1945 | + * @since 1.0.0 |
|
1946 | + * @param array $fields Unmodified sort options array. |
|
1947 | + * @param string $post_type Post type. |
|
1948 | + */ |
|
1949 | + return $fields = apply_filters('geodir_add_custom_sort_options', $fields, $post_type); |
|
1950 | + |
|
1951 | + } |
|
1952 | + |
|
1953 | + return false; |
|
1954 | 1954 | } |
1955 | 1955 | |
1956 | 1956 | |
@@ -1966,117 +1966,117 @@ discard block |
||
1966 | 1966 | function godir_set_sort_field_order($field_ids = array()) |
1967 | 1967 | { |
1968 | 1968 | |
1969 | - global $wpdb; |
|
1969 | + global $wpdb; |
|
1970 | 1970 | |
1971 | - $count = 0; |
|
1972 | - if (!empty($field_ids)): |
|
1973 | - foreach ($field_ids as $id) { |
|
1971 | + $count = 0; |
|
1972 | + if (!empty($field_ids)): |
|
1973 | + foreach ($field_ids as $id) { |
|
1974 | 1974 | |
1975 | - $cf = trim($id, '_'); |
|
1975 | + $cf = trim($id, '_'); |
|
1976 | 1976 | |
1977 | - $post_meta_info = $wpdb->query( |
|
1978 | - $wpdb->prepare( |
|
1979 | - "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
1977 | + $post_meta_info = $wpdb->query( |
|
1978 | + $wpdb->prepare( |
|
1979 | + "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
1980 | 1980 | sort_order=%d |
1981 | 1981 | where id= %d", |
1982 | - array($count, $cf) |
|
1983 | - ) |
|
1984 | - ); |
|
1985 | - $count++; |
|
1986 | - } |
|
1987 | - |
|
1988 | - return $field_ids; |
|
1989 | - else: |
|
1990 | - return false; |
|
1991 | - endif; |
|
1982 | + array($count, $cf) |
|
1983 | + ) |
|
1984 | + ); |
|
1985 | + $count++; |
|
1986 | + } |
|
1987 | + |
|
1988 | + return $field_ids; |
|
1989 | + else: |
|
1990 | + return false; |
|
1991 | + endif; |
|
1992 | 1992 | } |
1993 | 1993 | |
1994 | 1994 | |
1995 | 1995 | if (!function_exists('geodir_custom_sort_field_save')) { |
1996 | - /** |
|
1997 | - * Save or Update custom sort fields into the database. |
|
1998 | - * |
|
1999 | - * @since 1.0.0 |
|
2000 | - * @package GeoDirectory |
|
2001 | - * @global object $wpdb WordPress Database object. |
|
2002 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
2003 | - * @param array $request_field { |
|
2004 | - * Attributes of the Request field. |
|
2005 | - * |
|
2006 | - * @type string $action Ajax action name. |
|
2007 | - * @type string $manage_field_type Manage field type Default "sorting_options". |
|
2008 | - * @type string $create_field Do you want to create this field?. |
|
2009 | - * @type string $field_ins_upd Field created or updated?. |
|
2010 | - * @type string $_wpnonce Nonce value. |
|
2011 | - * @type string $listing_type The Post type. |
|
2012 | - * @type string $field_type Field Type. |
|
2013 | - * @type string $field_id Field ID. |
|
2014 | - * @type string $data_type Data Type. |
|
2015 | - * @type string $htmlvar_name HTML variable name. |
|
2016 | - * @type string $site_title Section title which you wish to display in frontend. |
|
2017 | - * @type string $is_default Is this default sorting?. |
|
2018 | - * @type string $is_active If not active then the field will not be displayed anywhere. |
|
2019 | - * @type string $sort_order Sort Order. |
|
2020 | - * |
|
2021 | - * } |
|
2022 | - * @param bool $default Not yet implemented. |
|
2023 | - * @return int Returns the last affected db table row id. |
|
2024 | - */ |
|
2025 | - function geodir_custom_sort_field_save($request_field = array(), $default = false) |
|
2026 | - { |
|
2027 | - |
|
2028 | - global $wpdb, $plugin_prefix; |
|
2029 | - |
|
2030 | - $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : ''; |
|
2031 | - |
|
2032 | - $cf = trim($result_str, '_'); |
|
2033 | - |
|
2034 | - /*-------- check duplicate validation --------*/ |
|
2035 | - |
|
2036 | - $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : ''; |
|
2037 | - $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
2038 | - |
|
2039 | - $post_type = $request_field['listing_type']; |
|
2040 | - $data_type = isset($request_field['data_type']) ? $request_field['data_type'] : ''; |
|
2041 | - $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : ''; |
|
2042 | - $site_title = isset($request_field['site_title']) ? $request_field['site_title'] : ''; |
|
2043 | - $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
2044 | - $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : 0; |
|
2045 | - $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : 0; |
|
2046 | - $is_default = isset($request_field['is_default']) ? $request_field['is_default'] : ''; |
|
2047 | - $asc = isset($request_field['asc']) ? $request_field['asc'] : 0; |
|
2048 | - $desc = isset($request_field['desc']) ? $request_field['desc'] : 0; |
|
2049 | - $asc_title = isset($request_field['asc_title']) ? $request_field['asc_title'] : ''; |
|
2050 | - $desc_title = isset($request_field['desc_title']) ? $request_field['desc_title'] : ''; |
|
2051 | - |
|
2052 | - $default_order = ''; |
|
2053 | - if ($is_default != '') { |
|
2054 | - $default_order = $is_default; |
|
2055 | - $is_default = '1'; |
|
2056 | - } |
|
2057 | - |
|
2058 | - |
|
2059 | - $check_html_variable = $wpdb->get_var( |
|
2060 | - $wpdb->prepare( |
|
2061 | - "select htmlvar_name from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s and field_type=%s ", |
|
2062 | - array($cehhtmlvar_name, $post_type, $field_type) |
|
2063 | - ) |
|
2064 | - ); |
|
2065 | - |
|
2066 | - if ($is_default == 1) { |
|
2067 | - |
|
2068 | - $wpdb->query($wpdb->prepare("update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set is_default='0', default_order='' where post_type = %s", array($post_type))); |
|
2069 | - |
|
2070 | - } |
|
2071 | - |
|
2072 | - |
|
2073 | - if (!$check_html_variable) { |
|
2074 | - |
|
2075 | - $wpdb->query( |
|
2076 | - |
|
2077 | - $wpdb->prepare( |
|
2078 | - |
|
2079 | - "insert into " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
1996 | + /** |
|
1997 | + * Save or Update custom sort fields into the database. |
|
1998 | + * |
|
1999 | + * @since 1.0.0 |
|
2000 | + * @package GeoDirectory |
|
2001 | + * @global object $wpdb WordPress Database object. |
|
2002 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
2003 | + * @param array $request_field { |
|
2004 | + * Attributes of the Request field. |
|
2005 | + * |
|
2006 | + * @type string $action Ajax action name. |
|
2007 | + * @type string $manage_field_type Manage field type Default "sorting_options". |
|
2008 | + * @type string $create_field Do you want to create this field?. |
|
2009 | + * @type string $field_ins_upd Field created or updated?. |
|
2010 | + * @type string $_wpnonce Nonce value. |
|
2011 | + * @type string $listing_type The Post type. |
|
2012 | + * @type string $field_type Field Type. |
|
2013 | + * @type string $field_id Field ID. |
|
2014 | + * @type string $data_type Data Type. |
|
2015 | + * @type string $htmlvar_name HTML variable name. |
|
2016 | + * @type string $site_title Section title which you wish to display in frontend. |
|
2017 | + * @type string $is_default Is this default sorting?. |
|
2018 | + * @type string $is_active If not active then the field will not be displayed anywhere. |
|
2019 | + * @type string $sort_order Sort Order. |
|
2020 | + * |
|
2021 | + * } |
|
2022 | + * @param bool $default Not yet implemented. |
|
2023 | + * @return int Returns the last affected db table row id. |
|
2024 | + */ |
|
2025 | + function geodir_custom_sort_field_save($request_field = array(), $default = false) |
|
2026 | + { |
|
2027 | + |
|
2028 | + global $wpdb, $plugin_prefix; |
|
2029 | + |
|
2030 | + $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : ''; |
|
2031 | + |
|
2032 | + $cf = trim($result_str, '_'); |
|
2033 | + |
|
2034 | + /*-------- check duplicate validation --------*/ |
|
2035 | + |
|
2036 | + $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : ''; |
|
2037 | + $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
2038 | + |
|
2039 | + $post_type = $request_field['listing_type']; |
|
2040 | + $data_type = isset($request_field['data_type']) ? $request_field['data_type'] : ''; |
|
2041 | + $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : ''; |
|
2042 | + $site_title = isset($request_field['site_title']) ? $request_field['site_title'] : ''; |
|
2043 | + $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
2044 | + $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : 0; |
|
2045 | + $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : 0; |
|
2046 | + $is_default = isset($request_field['is_default']) ? $request_field['is_default'] : ''; |
|
2047 | + $asc = isset($request_field['asc']) ? $request_field['asc'] : 0; |
|
2048 | + $desc = isset($request_field['desc']) ? $request_field['desc'] : 0; |
|
2049 | + $asc_title = isset($request_field['asc_title']) ? $request_field['asc_title'] : ''; |
|
2050 | + $desc_title = isset($request_field['desc_title']) ? $request_field['desc_title'] : ''; |
|
2051 | + |
|
2052 | + $default_order = ''; |
|
2053 | + if ($is_default != '') { |
|
2054 | + $default_order = $is_default; |
|
2055 | + $is_default = '1'; |
|
2056 | + } |
|
2057 | + |
|
2058 | + |
|
2059 | + $check_html_variable = $wpdb->get_var( |
|
2060 | + $wpdb->prepare( |
|
2061 | + "select htmlvar_name from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s and field_type=%s ", |
|
2062 | + array($cehhtmlvar_name, $post_type, $field_type) |
|
2063 | + ) |
|
2064 | + ); |
|
2065 | + |
|
2066 | + if ($is_default == 1) { |
|
2067 | + |
|
2068 | + $wpdb->query($wpdb->prepare("update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set is_default='0', default_order='' where post_type = %s", array($post_type))); |
|
2069 | + |
|
2070 | + } |
|
2071 | + |
|
2072 | + |
|
2073 | + if (!$check_html_variable) { |
|
2074 | + |
|
2075 | + $wpdb->query( |
|
2076 | + |
|
2077 | + $wpdb->prepare( |
|
2078 | + |
|
2079 | + "insert into " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
2080 | 2080 | post_type = %s, |
2081 | 2081 | data_type = %s, |
2082 | 2082 | field_type = %s, |
@@ -2091,23 +2091,23 @@ discard block |
||
2091 | 2091 | asc_title = %s, |
2092 | 2092 | desc_title = %s", |
2093 | 2093 | |
2094 | - array($post_type, $data_type, $field_type, $site_title, $htmlvar_name, $sort_order, $is_active, $is_default, $default_order, $asc, $desc, $asc_title, $desc_title) |
|
2095 | - ) |
|
2094 | + array($post_type, $data_type, $field_type, $site_title, $htmlvar_name, $sort_order, $is_active, $is_default, $default_order, $asc, $desc, $asc_title, $desc_title) |
|
2095 | + ) |
|
2096 | 2096 | |
2097 | - ); |
|
2097 | + ); |
|
2098 | 2098 | |
2099 | 2099 | |
2100 | - $lastid = $wpdb->insert_id; |
|
2100 | + $lastid = $wpdb->insert_id; |
|
2101 | 2101 | |
2102 | - $lastid = trim($lastid); |
|
2102 | + $lastid = trim($lastid); |
|
2103 | 2103 | |
2104 | - } else { |
|
2104 | + } else { |
|
2105 | 2105 | |
2106 | - $wpdb->query( |
|
2106 | + $wpdb->query( |
|
2107 | 2107 | |
2108 | - $wpdb->prepare( |
|
2108 | + $wpdb->prepare( |
|
2109 | 2109 | |
2110 | - "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
2110 | + "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
2111 | 2111 | post_type = %s, |
2112 | 2112 | data_type = %s, |
2113 | 2113 | field_type = %s, |
@@ -2123,123 +2123,123 @@ discard block |
||
2123 | 2123 | desc_title = %s |
2124 | 2124 | where id = %d", |
2125 | 2125 | |
2126 | - array($post_type, $data_type, $field_type, $site_title, $htmlvar_name, $sort_order, $is_active, $is_default, $default_order, $asc, $desc, $asc_title, $desc_title, $cf) |
|
2127 | - ) |
|
2126 | + array($post_type, $data_type, $field_type, $site_title, $htmlvar_name, $sort_order, $is_active, $is_default, $default_order, $asc, $desc, $asc_title, $desc_title, $cf) |
|
2127 | + ) |
|
2128 | 2128 | |
2129 | - ); |
|
2129 | + ); |
|
2130 | 2130 | |
2131 | - $lastid = trim($cf); |
|
2131 | + $lastid = trim($cf); |
|
2132 | 2132 | |
2133 | - } |
|
2133 | + } |
|
2134 | 2134 | |
2135 | 2135 | |
2136 | - return (int)$lastid; |
|
2136 | + return (int)$lastid; |
|
2137 | 2137 | |
2138 | - } |
|
2138 | + } |
|
2139 | 2139 | } |
2140 | 2140 | |
2141 | 2141 | |
2142 | 2142 | if (!function_exists('geodir_custom_sort_field_delete')) { |
2143 | - /** |
|
2144 | - * Delete a custom sort field using field id. |
|
2145 | - * @since 1.0.0 |
|
2146 | - * @package GeoDirectory |
|
2147 | - * @global object $wpdb WordPress Database object. |
|
2148 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
2149 | - * @param string $field_id The field ID. |
|
2150 | - * @return int|string Returns field id when successful deletion, else returns 0. |
|
2151 | - */ |
|
2152 | - function geodir_custom_sort_field_delete($field_id = '') |
|
2153 | - { |
|
2154 | - |
|
2155 | - global $wpdb, $plugin_prefix; |
|
2156 | - if ($field_id != '') { |
|
2157 | - $cf = trim($field_id, '_'); |
|
2158 | - |
|
2159 | - $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where id= %d ", array($cf))); |
|
2160 | - |
|
2161 | - return $field_id; |
|
2162 | - |
|
2163 | - } else |
|
2164 | - return 0; |
|
2165 | - |
|
2166 | - } |
|
2143 | + /** |
|
2144 | + * Delete a custom sort field using field id. |
|
2145 | + * @since 1.0.0 |
|
2146 | + * @package GeoDirectory |
|
2147 | + * @global object $wpdb WordPress Database object. |
|
2148 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
2149 | + * @param string $field_id The field ID. |
|
2150 | + * @return int|string Returns field id when successful deletion, else returns 0. |
|
2151 | + */ |
|
2152 | + function geodir_custom_sort_field_delete($field_id = '') |
|
2153 | + { |
|
2154 | + |
|
2155 | + global $wpdb, $plugin_prefix; |
|
2156 | + if ($field_id != '') { |
|
2157 | + $cf = trim($field_id, '_'); |
|
2158 | + |
|
2159 | + $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where id= %d ", array($cf))); |
|
2160 | + |
|
2161 | + return $field_id; |
|
2162 | + |
|
2163 | + } else |
|
2164 | + return 0; |
|
2165 | + |
|
2166 | + } |
|
2167 | 2167 | } |
2168 | 2168 | |
2169 | 2169 | |
2170 | 2170 | if (!function_exists('geodir_custom_sort_field_adminhtml')) { |
2171 | - /** |
|
2172 | - * Custom sort field admin html. |
|
2173 | - * |
|
2174 | - * @since 1.0.0 |
|
2175 | - * @package GeoDirectory |
|
2176 | - * @global object $wpdb WordPress Database object. |
|
2177 | - * @param string $field_type The form field type. |
|
2178 | - * @param object|int $result_str The custom field results object or row id. |
|
2179 | - * @param string $field_ins_upd When set to "submit" displays form. |
|
2180 | - * @param bool $default when set to true field will be for admin use only. |
|
2181 | - */ |
|
2182 | - function geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key='') |
|
2183 | - { |
|
2184 | - global $wpdb; |
|
2185 | - $cf = $result_str; |
|
2186 | - if (!is_object($cf)) { |
|
2187 | - $field_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE id = %d", array($cf))); |
|
2188 | - } else { |
|
2189 | - $field_info = $cf; |
|
2190 | - $result_str = $cf->id; |
|
2191 | - } |
|
2192 | - |
|
2193 | - $field_info = stripslashes_deep($field_info); // strip slashes |
|
2194 | - |
|
2195 | - if (!isset($field_info->post_type)) { |
|
2196 | - $post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
2197 | - } else { |
|
2198 | - $post_type = $field_info->post_type; |
|
2199 | - } |
|
2200 | - |
|
2201 | - |
|
2202 | - $htmlvar_name = isset($field_type_key) ? $field_type_key : ''; |
|
2203 | - |
|
2204 | - $site_title = ''; |
|
2205 | - if ($site_title == '') |
|
2206 | - $site_title = isset($field_info->site_title) ? $field_info->site_title : ''; |
|
2207 | - |
|
2208 | - if ($site_title == '') { |
|
2209 | - $fields = geodir_get_custom_sort_options($post_type); |
|
2210 | - |
|
2211 | - foreach ($fields as $val) { |
|
2212 | - $val = stripslashes_deep($val); // strip slashes |
|
2213 | - |
|
2214 | - if ($val['field_type'] == $field_type && $val['htmlvar_name'] == $htmlvar_name) { |
|
2215 | - $site_title = isset($val['site_title']) ? $val['site_title'] : ''; |
|
2216 | - } |
|
2217 | - } |
|
2218 | - } |
|
2219 | - |
|
2220 | - if ($htmlvar_name == '') |
|
2221 | - $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : ''; |
|
2222 | - |
|
2223 | - $nonce = wp_create_nonce('custom_fields_' . $result_str); |
|
2224 | - |
|
2225 | - $field_icon = '<i class="fa fa-cog" aria-hidden="true"></i>'; |
|
2226 | - $cso_arr = geodir_get_custom_sort_options($post_type); |
|
2227 | - |
|
2228 | - $cur_field_type = (isset($cf->field_type)) ? $cf->field_type : esc_html($_REQUEST['field_type']); |
|
2229 | - foreach($cso_arr as $cso){ |
|
2230 | - if($cur_field_type==$cso['field_type']){ |
|
2231 | - |
|
2232 | - if (isset($cso['field_icon']) && strpos($cso['field_icon'], 'fa fa-') !== false) { |
|
2233 | - $field_icon = '<i class="'.$cso['field_icon'].'" aria-hidden="true"></i>'; |
|
2234 | - }elseif(isset($cso['field_icon']) && $cso['field_icon']){ |
|
2235 | - $field_icon = '<b style="background-image: url("'.$cso['field_icon'].'")"></b>'; |
|
2236 | - } |
|
2237 | - |
|
2238 | - } |
|
2239 | - } |
|
2240 | - |
|
2241 | - $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name.$field_type : rand(5, 500); |
|
2242 | - ?> |
|
2171 | + /** |
|
2172 | + * Custom sort field admin html. |
|
2173 | + * |
|
2174 | + * @since 1.0.0 |
|
2175 | + * @package GeoDirectory |
|
2176 | + * @global object $wpdb WordPress Database object. |
|
2177 | + * @param string $field_type The form field type. |
|
2178 | + * @param object|int $result_str The custom field results object or row id. |
|
2179 | + * @param string $field_ins_upd When set to "submit" displays form. |
|
2180 | + * @param bool $default when set to true field will be for admin use only. |
|
2181 | + */ |
|
2182 | + function geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key='') |
|
2183 | + { |
|
2184 | + global $wpdb; |
|
2185 | + $cf = $result_str; |
|
2186 | + if (!is_object($cf)) { |
|
2187 | + $field_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE id = %d", array($cf))); |
|
2188 | + } else { |
|
2189 | + $field_info = $cf; |
|
2190 | + $result_str = $cf->id; |
|
2191 | + } |
|
2192 | + |
|
2193 | + $field_info = stripslashes_deep($field_info); // strip slashes |
|
2194 | + |
|
2195 | + if (!isset($field_info->post_type)) { |
|
2196 | + $post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
2197 | + } else { |
|
2198 | + $post_type = $field_info->post_type; |
|
2199 | + } |
|
2200 | + |
|
2201 | + |
|
2202 | + $htmlvar_name = isset($field_type_key) ? $field_type_key : ''; |
|
2203 | + |
|
2204 | + $site_title = ''; |
|
2205 | + if ($site_title == '') |
|
2206 | + $site_title = isset($field_info->site_title) ? $field_info->site_title : ''; |
|
2207 | + |
|
2208 | + if ($site_title == '') { |
|
2209 | + $fields = geodir_get_custom_sort_options($post_type); |
|
2210 | + |
|
2211 | + foreach ($fields as $val) { |
|
2212 | + $val = stripslashes_deep($val); // strip slashes |
|
2213 | + |
|
2214 | + if ($val['field_type'] == $field_type && $val['htmlvar_name'] == $htmlvar_name) { |
|
2215 | + $site_title = isset($val['site_title']) ? $val['site_title'] : ''; |
|
2216 | + } |
|
2217 | + } |
|
2218 | + } |
|
2219 | + |
|
2220 | + if ($htmlvar_name == '') |
|
2221 | + $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : ''; |
|
2222 | + |
|
2223 | + $nonce = wp_create_nonce('custom_fields_' . $result_str); |
|
2224 | + |
|
2225 | + $field_icon = '<i class="fa fa-cog" aria-hidden="true"></i>'; |
|
2226 | + $cso_arr = geodir_get_custom_sort_options($post_type); |
|
2227 | + |
|
2228 | + $cur_field_type = (isset($cf->field_type)) ? $cf->field_type : esc_html($_REQUEST['field_type']); |
|
2229 | + foreach($cso_arr as $cso){ |
|
2230 | + if($cur_field_type==$cso['field_type']){ |
|
2231 | + |
|
2232 | + if (isset($cso['field_icon']) && strpos($cso['field_icon'], 'fa fa-') !== false) { |
|
2233 | + $field_icon = '<i class="'.$cso['field_icon'].'" aria-hidden="true"></i>'; |
|
2234 | + }elseif(isset($cso['field_icon']) && $cso['field_icon']){ |
|
2235 | + $field_icon = '<b style="background-image: url("'.$cso['field_icon'].'")"></b>'; |
|
2236 | + } |
|
2237 | + |
|
2238 | + } |
|
2239 | + } |
|
2240 | + |
|
2241 | + $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name.$field_type : rand(5, 500); |
|
2242 | + ?> |
|
2243 | 2243 | |
2244 | 2244 | <li class="text" id="licontainer_<?php echo $result_str;?>"> |
2245 | 2245 | <form><!-- we need to wrap in a form so we can use radio buttons with same name --> |
@@ -2248,7 +2248,7 @@ discard block |
||
2248 | 2248 | ondblclick="show_hide('field_frm<?php echo $result_str;?>')"> |
2249 | 2249 | <?php |
2250 | 2250 | |
2251 | - ?> |
|
2251 | + ?> |
|
2252 | 2252 | |
2253 | 2253 | <div title="<?php _e('Click to remove field', 'geodirectory');?>" |
2254 | 2254 | onclick="delete_sort_field('<?php echo $result_str;?>', '<?php echo $nonce;?>', this)" |
@@ -2263,17 +2263,17 @@ discard block |
||
2263 | 2263 | |
2264 | 2264 | <div id="field_frm<?php echo $result_str;?>" class="field_frm" |
2265 | 2265 | style="display:<?php if ($field_ins_upd == 'submit') { |
2266 | - echo 'block;'; |
|
2267 | - } else { |
|
2268 | - echo 'none;'; |
|
2269 | - } ?>"> |
|
2266 | + echo 'block;'; |
|
2267 | + } else { |
|
2268 | + echo 'none;'; |
|
2269 | + } ?>"> |
|
2270 | 2270 | <input type="hidden" name="_wpnonce" value="<?php echo $nonce; ?>"/> |
2271 | 2271 | <input type="hidden" name="listing_type" id="listing_type" value="<?php echo $post_type;?>"/> |
2272 | 2272 | <input type="hidden" name="field_type" id="field_type" value="<?php echo $field_type;?>"/> |
2273 | 2273 | <input type="hidden" name="field_id" id="field_id" value="<?php echo $result_str;?>"/> |
2274 | 2274 | <input type="hidden" name="data_type" id="data_type" value="<?php if (isset($field_info->data_type)) { |
2275 | - echo $field_info->data_type; |
|
2276 | - }?>"/> |
|
2275 | + echo $field_info->data_type; |
|
2276 | + }?>"/> |
|
2277 | 2277 | <input type="hidden" name="htmlvar_name" id="htmlvar_name" value="<?php echo $htmlvar_name;?>"/> |
2278 | 2278 | |
2279 | 2279 | |
@@ -2296,14 +2296,14 @@ discard block |
||
2296 | 2296 | |
2297 | 2297 | <input type="radio" id="asc_yes<?php echo $radio_id;?>" name="asc" class="gdri-enabled" value="1" |
2298 | 2298 | <?php if ($value == '1') { |
2299 | - echo 'checked'; |
|
2300 | - } ?>/> |
|
2299 | + echo 'checked'; |
|
2300 | + } ?>/> |
|
2301 | 2301 | <label onclick="show_hide_radio(this,'show','cfs-asc-title');" for="asc_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label> |
2302 | 2302 | |
2303 | 2303 | <input type="radio" id="asc_no<?php echo $radio_id;?>" name="asc" class="gdri-disabled" value="0" |
2304 | 2304 | <?php if ($value == '0' || !$value) { |
2305 | - echo 'checked'; |
|
2306 | - } ?>/> |
|
2305 | + echo 'checked'; |
|
2306 | + } ?>/> |
|
2307 | 2307 | <label onclick="show_hide_radio(this,'hide','cfs-asc-title');" for="asc_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label> |
2308 | 2308 | |
2309 | 2309 | </div> |
@@ -2340,8 +2340,8 @@ discard block |
||
2340 | 2340 | |
2341 | 2341 | <input type="radio" name="is_default" |
2342 | 2342 | value="<?php echo $htmlvar_name; ?>_asc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name . '_asc') { |
2343 | - echo 'checked="checked"'; |
|
2344 | - } ?>/> |
|
2343 | + echo 'checked="checked"'; |
|
2344 | + } ?>/> |
|
2345 | 2345 | </div> |
2346 | 2346 | |
2347 | 2347 | </li> |
@@ -2361,14 +2361,14 @@ discard block |
||
2361 | 2361 | |
2362 | 2362 | <input type="radio" id="desc_yes<?php echo $radio_id;?>" name="desc" class="gdri-enabled" value="1" |
2363 | 2363 | <?php if ($value == '1') { |
2364 | - echo 'checked'; |
|
2365 | - } ?>/> |
|
2364 | + echo 'checked'; |
|
2365 | + } ?>/> |
|
2366 | 2366 | <label onclick="show_hide_radio(this,'show','cfs-desc-title');" for="desc_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label> |
2367 | 2367 | |
2368 | 2368 | <input type="radio" id="desc_no<?php echo $radio_id;?>" name="desc" class="gdri-disabled" value="0" |
2369 | 2369 | <?php if ($value == '0' || !$value) { |
2370 | - echo 'checked'; |
|
2371 | - } ?>/> |
|
2370 | + echo 'checked'; |
|
2371 | + } ?>/> |
|
2372 | 2372 | <label onclick="show_hide_radio(this,'hide','cfs-desc-title');" for="desc_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label> |
2373 | 2373 | |
2374 | 2374 | </div> |
@@ -2404,8 +2404,8 @@ discard block |
||
2404 | 2404 | |
2405 | 2405 | <input type="radio" name="is_default" |
2406 | 2406 | value="<?php echo $htmlvar_name; ?>_desc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name . '_desc') { |
2407 | - echo 'checked="checked"'; |
|
2408 | - } ?>/> |
|
2407 | + echo 'checked="checked"'; |
|
2408 | + } ?>/> |
|
2409 | 2409 | </div> |
2410 | 2410 | |
2411 | 2411 | </li> |
@@ -2447,8 +2447,8 @@ discard block |
||
2447 | 2447 | |
2448 | 2448 | <input type="checkbox" name="is_default" |
2449 | 2449 | value="<?php echo $field_type; ?>" <?php if (isset($value) && $value == '1') { |
2450 | - echo 'checked="checked"'; |
|
2451 | - } ?>/> |
|
2450 | + echo 'checked="checked"'; |
|
2451 | + } ?>/> |
|
2452 | 2452 | </div> |
2453 | 2453 | |
2454 | 2454 | |
@@ -2471,14 +2471,14 @@ discard block |
||
2471 | 2471 | |
2472 | 2472 | <input type="radio" id="is_active_yes<?php echo $radio_id;?>" name="is_active" class="gdri-enabled" value="1" |
2473 | 2473 | <?php if ($value == '1') { |
2474 | - echo 'checked'; |
|
2475 | - } ?>/> |
|
2474 | + echo 'checked'; |
|
2475 | + } ?>/> |
|
2476 | 2476 | <label for="is_active_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label> |
2477 | 2477 | |
2478 | 2478 | <input type="radio" id="is_active_no<?php echo $radio_id;?>" name="is_active" class="gdri-disabled" value="0" |
2479 | 2479 | <?php if ($value == '0' || !$value) { |
2480 | - echo 'checked'; |
|
2481 | - } ?>/> |
|
2480 | + echo 'checked'; |
|
2481 | + } ?>/> |
|
2482 | 2482 | <label for="is_active_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label> |
2483 | 2483 | |
2484 | 2484 | </div> |
@@ -2488,8 +2488,8 @@ discard block |
||
2488 | 2488 | |
2489 | 2489 | <input type="hidden" readonly="readonly" name="sort_order" id="sort_order" |
2490 | 2490 | value="<?php if (isset($field_info->sort_order)) { |
2491 | - echo esc_attr($field_info->sort_order); |
|
2492 | - }?>" size="50"/> |
|
2491 | + echo esc_attr($field_info->sort_order); |
|
2492 | + }?>" size="50"/> |
|
2493 | 2493 | |
2494 | 2494 | |
2495 | 2495 | |
@@ -2513,38 +2513,38 @@ discard block |
||
2513 | 2513 | </form> |
2514 | 2514 | </li> <?php |
2515 | 2515 | |
2516 | - } |
|
2516 | + } |
|
2517 | 2517 | } |
2518 | 2518 | |
2519 | 2519 | if (!function_exists('check_field_visibility')) { |
2520 | - /** |
|
2521 | - * Check field visibility as per price package. |
|
2522 | - * |
|
2523 | - * @since 1.0.0 |
|
2524 | - * @package GeoDirectory |
|
2525 | - * @global object $wpdb WordPress Database object. |
|
2526 | - * @global array $geodir_addon_list List of active GeoDirectory extensions. |
|
2527 | - * @param int|string $package_id The package ID. |
|
2528 | - * @param string $field_name The field name. |
|
2529 | - * @param string $post_type Optional. The wordpress post type. |
|
2530 | - * @return bool Returns true when field visible, otherwise false. |
|
2531 | - */ |
|
2532 | - function check_field_visibility($package_id, $field_name, $post_type) |
|
2533 | - { |
|
2534 | - global $wpdb, $geodir_addon_list; |
|
2535 | - if (!(isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes')) { |
|
2536 | - return true; |
|
2537 | - } |
|
2538 | - if (!$package_id || !$field_name || !$post_type) { |
|
2539 | - return true; |
|
2540 | - } |
|
2541 | - $sql = $wpdb->prepare("SELECT id FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE is_active='1' AND htmlvar_name=%s AND post_type=%s AND FIND_IN_SET(%s, packages)", array($field_name, $post_type, (int)$package_id)); |
|
2542 | - |
|
2543 | - if ($wpdb->get_var($sql)) { |
|
2544 | - return true; |
|
2545 | - } |
|
2546 | - return false; |
|
2547 | - } |
|
2520 | + /** |
|
2521 | + * Check field visibility as per price package. |
|
2522 | + * |
|
2523 | + * @since 1.0.0 |
|
2524 | + * @package GeoDirectory |
|
2525 | + * @global object $wpdb WordPress Database object. |
|
2526 | + * @global array $geodir_addon_list List of active GeoDirectory extensions. |
|
2527 | + * @param int|string $package_id The package ID. |
|
2528 | + * @param string $field_name The field name. |
|
2529 | + * @param string $post_type Optional. The wordpress post type. |
|
2530 | + * @return bool Returns true when field visible, otherwise false. |
|
2531 | + */ |
|
2532 | + function check_field_visibility($package_id, $field_name, $post_type) |
|
2533 | + { |
|
2534 | + global $wpdb, $geodir_addon_list; |
|
2535 | + if (!(isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes')) { |
|
2536 | + return true; |
|
2537 | + } |
|
2538 | + if (!$package_id || !$field_name || !$post_type) { |
|
2539 | + return true; |
|
2540 | + } |
|
2541 | + $sql = $wpdb->prepare("SELECT id FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE is_active='1' AND htmlvar_name=%s AND post_type=%s AND FIND_IN_SET(%s, packages)", array($field_name, $post_type, (int)$package_id)); |
|
2542 | + |
|
2543 | + if ($wpdb->get_var($sql)) { |
|
2544 | + return true; |
|
2545 | + } |
|
2546 | + return false; |
|
2547 | + } |
|
2548 | 2548 | } |
2549 | 2549 | |
2550 | 2550 | /** |
@@ -2560,43 +2560,43 @@ discard block |
||
2560 | 2560 | */ |
2561 | 2561 | function geodir_string_to_options($input = '', $translated = false) |
2562 | 2562 | { |
2563 | - $return = array(); |
|
2564 | - if ($input != '') { |
|
2565 | - $input = trim($input); |
|
2566 | - $input = rtrim($input, ","); |
|
2567 | - $input = ltrim($input, ","); |
|
2568 | - $input = trim($input); |
|
2569 | - } |
|
2570 | - |
|
2571 | - $input_arr = explode(',', $input); |
|
2572 | - |
|
2573 | - if (!empty($input_arr)) { |
|
2574 | - foreach ($input_arr as $input_str) { |
|
2575 | - $input_str = trim($input_str); |
|
2576 | - |
|
2577 | - if (strpos($input_str, "/") !== false) { |
|
2578 | - $input_str = explode("/", $input_str, 2); |
|
2579 | - $label = trim($input_str[0]); |
|
2580 | - if ($translated && $label != '') { |
|
2581 | - $label = __($label, 'geodirectory'); |
|
2582 | - } |
|
2583 | - $label = geodir_utf8_ucfirst($label); |
|
2584 | - $value = trim($input_str[1]); |
|
2585 | - } else { |
|
2586 | - $value = $input_str; |
|
2587 | - if ($translated && $input_str != '') { |
|
2588 | - $input_str = __($input_str, 'geodirectory'); |
|
2589 | - } |
|
2590 | - $label = geodir_utf8_ucfirst($input_str); |
|
2591 | - } |
|
2592 | - |
|
2593 | - if ($label != '') { |
|
2594 | - $return[] = array('label' => $label, 'value' => $value, 'optgroup' => NULL); |
|
2595 | - } |
|
2596 | - } |
|
2597 | - } |
|
2598 | - |
|
2599 | - return $return; |
|
2563 | + $return = array(); |
|
2564 | + if ($input != '') { |
|
2565 | + $input = trim($input); |
|
2566 | + $input = rtrim($input, ","); |
|
2567 | + $input = ltrim($input, ","); |
|
2568 | + $input = trim($input); |
|
2569 | + } |
|
2570 | + |
|
2571 | + $input_arr = explode(',', $input); |
|
2572 | + |
|
2573 | + if (!empty($input_arr)) { |
|
2574 | + foreach ($input_arr as $input_str) { |
|
2575 | + $input_str = trim($input_str); |
|
2576 | + |
|
2577 | + if (strpos($input_str, "/") !== false) { |
|
2578 | + $input_str = explode("/", $input_str, 2); |
|
2579 | + $label = trim($input_str[0]); |
|
2580 | + if ($translated && $label != '') { |
|
2581 | + $label = __($label, 'geodirectory'); |
|
2582 | + } |
|
2583 | + $label = geodir_utf8_ucfirst($label); |
|
2584 | + $value = trim($input_str[1]); |
|
2585 | + } else { |
|
2586 | + $value = $input_str; |
|
2587 | + if ($translated && $input_str != '') { |
|
2588 | + $input_str = __($input_str, 'geodirectory'); |
|
2589 | + } |
|
2590 | + $label = geodir_utf8_ucfirst($input_str); |
|
2591 | + } |
|
2592 | + |
|
2593 | + if ($label != '') { |
|
2594 | + $return[] = array('label' => $label, 'value' => $value, 'optgroup' => NULL); |
|
2595 | + } |
|
2596 | + } |
|
2597 | + } |
|
2598 | + |
|
2599 | + return $return; |
|
2600 | 2600 | } |
2601 | 2601 | |
2602 | 2602 | /** |
@@ -2611,66 +2611,66 @@ discard block |
||
2611 | 2611 | */ |
2612 | 2612 | function geodir_string_values_to_options($option_values = '', $translated = false) |
2613 | 2613 | { |
2614 | - $options = array(); |
|
2615 | - if ($option_values == '') { |
|
2616 | - return NULL; |
|
2617 | - } |
|
2618 | - |
|
2619 | - if (strpos($option_values, "{/optgroup}") !== false) { |
|
2620 | - $option_values_arr = explode("{/optgroup}", $option_values); |
|
2621 | - |
|
2622 | - foreach ($option_values_arr as $optgroup) { |
|
2623 | - if (strpos($optgroup, "{optgroup}") !== false) { |
|
2624 | - $optgroup_arr = explode("{optgroup}", $optgroup); |
|
2625 | - |
|
2626 | - $count = 0; |
|
2627 | - foreach ($optgroup_arr as $optgroup_str) { |
|
2628 | - $count++; |
|
2629 | - $optgroup_str = trim($optgroup_str); |
|
2630 | - |
|
2631 | - $optgroup_label = ''; |
|
2632 | - if (strpos($optgroup_str, "|") !== false) { |
|
2633 | - $optgroup_str_arr = explode("|", $optgroup_str, 2); |
|
2634 | - $optgroup_label = trim($optgroup_str_arr[0]); |
|
2635 | - if ($translated && $optgroup_label != '') { |
|
2636 | - $optgroup_label = __($optgroup_label, 'geodirectory'); |
|
2637 | - } |
|
2638 | - $optgroup_label = geodir_utf8_ucfirst($optgroup_label); |
|
2639 | - $optgroup_str = $optgroup_str_arr[1]; |
|
2640 | - } |
|
2641 | - |
|
2642 | - $optgroup3 = geodir_string_to_options($optgroup_str, $translated); |
|
2643 | - |
|
2644 | - if ($count > 1 && $optgroup_label != '' && !empty($optgroup3)) { |
|
2645 | - $optgroup_start = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'start')); |
|
2646 | - $optgroup_end = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'end')); |
|
2647 | - $optgroup3 = array_merge($optgroup_start, $optgroup3, $optgroup_end); |
|
2648 | - } |
|
2649 | - $options = array_merge($options, $optgroup3); |
|
2650 | - } |
|
2651 | - } else { |
|
2652 | - $optgroup1 = geodir_string_to_options($optgroup, $translated); |
|
2653 | - $options = array_merge($options, $optgroup1); |
|
2654 | - } |
|
2655 | - } |
|
2656 | - } else { |
|
2657 | - $options = geodir_string_to_options($option_values, $translated); |
|
2658 | - } |
|
2659 | - |
|
2660 | - return $options; |
|
2614 | + $options = array(); |
|
2615 | + if ($option_values == '') { |
|
2616 | + return NULL; |
|
2617 | + } |
|
2618 | + |
|
2619 | + if (strpos($option_values, "{/optgroup}") !== false) { |
|
2620 | + $option_values_arr = explode("{/optgroup}", $option_values); |
|
2621 | + |
|
2622 | + foreach ($option_values_arr as $optgroup) { |
|
2623 | + if (strpos($optgroup, "{optgroup}") !== false) { |
|
2624 | + $optgroup_arr = explode("{optgroup}", $optgroup); |
|
2625 | + |
|
2626 | + $count = 0; |
|
2627 | + foreach ($optgroup_arr as $optgroup_str) { |
|
2628 | + $count++; |
|
2629 | + $optgroup_str = trim($optgroup_str); |
|
2630 | + |
|
2631 | + $optgroup_label = ''; |
|
2632 | + if (strpos($optgroup_str, "|") !== false) { |
|
2633 | + $optgroup_str_arr = explode("|", $optgroup_str, 2); |
|
2634 | + $optgroup_label = trim($optgroup_str_arr[0]); |
|
2635 | + if ($translated && $optgroup_label != '') { |
|
2636 | + $optgroup_label = __($optgroup_label, 'geodirectory'); |
|
2637 | + } |
|
2638 | + $optgroup_label = geodir_utf8_ucfirst($optgroup_label); |
|
2639 | + $optgroup_str = $optgroup_str_arr[1]; |
|
2640 | + } |
|
2641 | + |
|
2642 | + $optgroup3 = geodir_string_to_options($optgroup_str, $translated); |
|
2643 | + |
|
2644 | + if ($count > 1 && $optgroup_label != '' && !empty($optgroup3)) { |
|
2645 | + $optgroup_start = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'start')); |
|
2646 | + $optgroup_end = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'end')); |
|
2647 | + $optgroup3 = array_merge($optgroup_start, $optgroup3, $optgroup_end); |
|
2648 | + } |
|
2649 | + $options = array_merge($options, $optgroup3); |
|
2650 | + } |
|
2651 | + } else { |
|
2652 | + $optgroup1 = geodir_string_to_options($optgroup, $translated); |
|
2653 | + $options = array_merge($options, $optgroup1); |
|
2654 | + } |
|
2655 | + } |
|
2656 | + } else { |
|
2657 | + $options = geodir_string_to_options($option_values, $translated); |
|
2658 | + } |
|
2659 | + |
|
2660 | + return $options; |
|
2661 | 2661 | } |
2662 | 2662 | |
2663 | 2663 | |
2664 | 2664 | function geodir_cfa_data_type_text($output,$result_str,$cf,$field_info){ |
2665 | - ob_start(); |
|
2666 | - |
|
2667 | - $dt_value = ''; |
|
2668 | - if (isset($field_info->data_type)) { |
|
2669 | - $dt_value = esc_attr($field_info->data_type); |
|
2670 | - }elseif(isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']){ |
|
2671 | - $dt_value = $cf['defaults']['data_type']; |
|
2672 | - } |
|
2673 | - ?> |
|
2665 | + ob_start(); |
|
2666 | + |
|
2667 | + $dt_value = ''; |
|
2668 | + if (isset($field_info->data_type)) { |
|
2669 | + $dt_value = esc_attr($field_info->data_type); |
|
2670 | + }elseif(isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']){ |
|
2671 | + $dt_value = $cf['defaults']['data_type']; |
|
2672 | + } |
|
2673 | + ?> |
|
2674 | 2674 | <li> |
2675 | 2675 | <label for="data_type"><?php _e('Field Data Type ? :', 'geodirectory'); ?></label> |
2676 | 2676 | <div class="gd-cf-input-wrap"> |
@@ -2679,16 +2679,16 @@ discard block |
||
2679 | 2679 | onchange="javascript:gd_data_type_changed(this, '<?php echo $result_str; ?>');"> |
2680 | 2680 | <option |
2681 | 2681 | value="XVARCHAR" <?php if ($dt_value == 'VARCHAR') { |
2682 | - echo 'selected="selected"'; |
|
2683 | - } ?>><?php _e('CHARACTER', 'geodirectory'); ?></option> |
|
2682 | + echo 'selected="selected"'; |
|
2683 | + } ?>><?php _e('CHARACTER', 'geodirectory'); ?></option> |
|
2684 | 2684 | <option |
2685 | 2685 | value="INT" <?php if ($dt_value == 'INT') { |
2686 | - echo 'selected="selected"'; |
|
2687 | - } ?>><?php _e('NUMBER', 'geodirectory'); ?></option> |
|
2686 | + echo 'selected="selected"'; |
|
2687 | + } ?>><?php _e('NUMBER', 'geodirectory'); ?></option> |
|
2688 | 2688 | <option |
2689 | 2689 | value="FLOAT" <?php if ($dt_value == 'FLOAT') { |
2690 | - echo 'selected="selected"'; |
|
2691 | - } ?>><?php _e('DECIMAL', 'geodirectory'); ?></option> |
|
2690 | + echo 'selected="selected"'; |
|
2691 | + } ?>><?php _e('DECIMAL', 'geodirectory'); ?></option> |
|
2692 | 2692 | </select> |
2693 | 2693 | <br/> <span><?php _e('Select Custom Field type', 'geodirectory'); ?></span> |
2694 | 2694 | |
@@ -2696,13 +2696,13 @@ discard block |
||
2696 | 2696 | </li> |
2697 | 2697 | |
2698 | 2698 | <?php |
2699 | - $value = ''; |
|
2700 | - if (isset($field_info->decimal_point)) { |
|
2701 | - $value = esc_attr($field_info->decimal_point); |
|
2702 | - }elseif(isset($cf['defaults']['decimal_point']) && $cf['defaults']['decimal_point']){ |
|
2703 | - $value = $cf['defaults']['decimal_point']; |
|
2704 | - } |
|
2705 | - ?> |
|
2699 | + $value = ''; |
|
2700 | + if (isset($field_info->decimal_point)) { |
|
2701 | + $value = esc_attr($field_info->decimal_point); |
|
2702 | + }elseif(isset($cf['defaults']['decimal_point']) && $cf['defaults']['decimal_point']){ |
|
2703 | + $value = $cf['defaults']['decimal_point']; |
|
2704 | + } |
|
2705 | + ?> |
|
2706 | 2706 | |
2707 | 2707 | <li class="decimal-point-wrapper" |
2708 | 2708 | style="<?php echo ($dt_value == 'FLOAT') ? '' : 'display:none' ?>"> |
@@ -2711,7 +2711,7 @@ discard block |
||
2711 | 2711 | <select name="decimal_point" id="decimal_point"> |
2712 | 2712 | <option value=""><?php echo _e('Select', 'geodirectory'); ?></option> |
2713 | 2713 | <?php for ($i = 1; $i <= 10; $i++) { |
2714 | - $selected = $i == $value ? 'selected="selected"' : ''; ?> |
|
2714 | + $selected = $i == $value ? 'selected="selected"' : ''; ?> |
|
2715 | 2715 | <option value="<?php echo $i; ?>" <?php echo $selected; ?>><?php echo $i; ?></option> |
2716 | 2716 | <?php } ?> |
2717 | 2717 | </select> |
@@ -2720,8 +2720,8 @@ discard block |
||
2720 | 2720 | </li> |
2721 | 2721 | <?php |
2722 | 2722 | |
2723 | - $output = ob_get_clean(); |
|
2724 | - return $output; |
|
2723 | + $output = ob_get_clean(); |
|
2724 | + return $output; |
|
2725 | 2725 | } |
2726 | 2726 | add_filter('geodir_cfa_data_type_text','geodir_cfa_data_type_text',10,4); |
2727 | 2727 | |
@@ -2757,9 +2757,9 @@ discard block |
||
2757 | 2757 | |
2758 | 2758 | |
2759 | 2759 | function geodir_cfa_advanced_editor_geodir_special_offers($output,$result_str,$cf,$field_info){ |
2760 | - if($field_info->htmlvar_name != 'geodir_special_offers'){return '';} |
|
2761 | - ob_start(); |
|
2762 | - ?> |
|
2760 | + if($field_info->htmlvar_name != 'geodir_special_offers'){return '';} |
|
2761 | + ob_start(); |
|
2762 | + ?> |
|
2763 | 2763 | <li> |
2764 | 2764 | <label for="advanced_editor" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Show advanced editor :', 'geodirectory'); ?> |
2765 | 2765 | <div class="gdcf-tooltip"> |
@@ -2770,13 +2770,13 @@ discard block |
||
2770 | 2770 | <div class="gd-cf-input-wrap"> |
2771 | 2771 | |
2772 | 2772 | <?php |
2773 | - $selected = ''; |
|
2774 | - if (isset($field_info->extra_fields)) |
|
2775 | - $advanced_editor = unserialize($field_info->extra_fields); |
|
2773 | + $selected = ''; |
|
2774 | + if (isset($field_info->extra_fields)) |
|
2775 | + $advanced_editor = unserialize($field_info->extra_fields); |
|
2776 | 2776 | |
2777 | - if (!empty($advanced_editor) && is_array($advanced_editor) && in_array('1', $advanced_editor)) |
|
2778 | - $selected = 'checked="checked"'; |
|
2779 | - ?> |
|
2777 | + if (!empty($advanced_editor) && is_array($advanced_editor) && in_array('1', $advanced_editor)) |
|
2778 | + $selected = 'checked="checked"'; |
|
2779 | + ?> |
|
2780 | 2780 | |
2781 | 2781 | <input type="checkbox" name="advanced_editor[]" id="advanced_editor" |
2782 | 2782 | value="1" <?php echo $selected; ?>/> |
@@ -2785,22 +2785,22 @@ discard block |
||
2785 | 2785 | </li> |
2786 | 2786 | <?php |
2787 | 2787 | |
2788 | - $output = ob_get_clean(); |
|
2789 | - return $output; |
|
2788 | + $output = ob_get_clean(); |
|
2789 | + return $output; |
|
2790 | 2790 | } |
2791 | 2791 | add_filter('geodir_cfa_advanced_editor_textarea','geodir_cfa_advanced_editor_geodir_special_offers',10,4); |
2792 | 2792 | |
2793 | 2793 | |
2794 | 2794 | function geodir_cfa_validation_pattern_text($output,$result_str,$cf,$field_info){ |
2795 | - ob_start(); |
|
2796 | - |
|
2797 | - $value = ''; |
|
2798 | - if (isset($field_info->validation_pattern)) { |
|
2799 | - $value = esc_attr($field_info->validation_pattern); |
|
2800 | - }elseif(isset($cf['defaults']['validation_pattern']) && $cf['defaults']['validation_pattern']){ |
|
2801 | - $value = esc_attr($cf['defaults']['validation_pattern']); |
|
2802 | - } |
|
2803 | - ?> |
|
2795 | + ob_start(); |
|
2796 | + |
|
2797 | + $value = ''; |
|
2798 | + if (isset($field_info->validation_pattern)) { |
|
2799 | + $value = esc_attr($field_info->validation_pattern); |
|
2800 | + }elseif(isset($cf['defaults']['validation_pattern']) && $cf['defaults']['validation_pattern']){ |
|
2801 | + $value = esc_attr($cf['defaults']['validation_pattern']); |
|
2802 | + } |
|
2803 | + ?> |
|
2804 | 2804 | <li> |
2805 | 2805 | <label for="validation_pattern" class="gd-cf-tooltip-wrap"> |
2806 | 2806 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Validation Pattern:', 'geodirectory'); ?> |
@@ -2814,13 +2814,13 @@ discard block |
||
2814 | 2814 | </div> |
2815 | 2815 | </li> |
2816 | 2816 | <?php |
2817 | - $value = ''; |
|
2818 | - if (isset($field_info->validation_msg)) { |
|
2819 | - $value = esc_attr($field_info->validation_msg); |
|
2820 | - }elseif(isset($cf['defaults']['validation_msg']) && $cf['defaults']['validation_msg']){ |
|
2821 | - $value = esc_attr($cf['defaults']['validation_msg']); |
|
2822 | - } |
|
2823 | - ?> |
|
2817 | + $value = ''; |
|
2818 | + if (isset($field_info->validation_msg)) { |
|
2819 | + $value = esc_attr($field_info->validation_msg); |
|
2820 | + }elseif(isset($cf['defaults']['validation_msg']) && $cf['defaults']['validation_msg']){ |
|
2821 | + $value = esc_attr($cf['defaults']['validation_msg']); |
|
2822 | + } |
|
2823 | + ?> |
|
2824 | 2824 | <li> |
2825 | 2825 | <label for="validation_msg" class="gd-cf-tooltip-wrap"> |
2826 | 2826 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Validation Message:', 'geodirectory'); ?> |
@@ -2835,21 +2835,21 @@ discard block |
||
2835 | 2835 | </li> |
2836 | 2836 | <?php |
2837 | 2837 | |
2838 | - $output = ob_get_clean(); |
|
2839 | - return $output; |
|
2838 | + $output = ob_get_clean(); |
|
2839 | + return $output; |
|
2840 | 2840 | } |
2841 | 2841 | add_filter('geodir_cfa_validation_pattern_text','geodir_cfa_validation_pattern_text',10,4); |
2842 | 2842 | |
2843 | 2843 | |
2844 | 2844 | function geodir_cfa_htmlvar_name_taxonomy($output,$result_str,$cf,$field_info){ |
2845 | - ob_start(); |
|
2846 | - global $post_type; |
|
2847 | - |
|
2848 | - if (!isset($field_info->post_type)) { |
|
2849 | - $post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
2850 | - } else |
|
2851 | - $post_type = $field_info->post_type; |
|
2852 | - ?> |
|
2845 | + ob_start(); |
|
2846 | + global $post_type; |
|
2847 | + |
|
2848 | + if (!isset($field_info->post_type)) { |
|
2849 | + $post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
2850 | + } else |
|
2851 | + $post_type = $field_info->post_type; |
|
2852 | + ?> |
|
2853 | 2853 | <li style="display: none;"> |
2854 | 2854 | <label for="htmlvar_name" class="gd-cf-tooltip-wrap"> |
2855 | 2855 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Select taxonomy:', 'geodirectory'); ?> |
@@ -2860,15 +2860,15 @@ discard block |
||
2860 | 2860 | <div class="gd-cf-input-wrap"> |
2861 | 2861 | <select name="htmlvar_name" id="htmlvar_name"> |
2862 | 2862 | <?php |
2863 | - $gd_taxonomy = geodir_get_taxonomies($post_type); |
|
2863 | + $gd_taxonomy = geodir_get_taxonomies($post_type); |
|
2864 | 2864 | |
2865 | - foreach ($gd_taxonomy as $gd_tax) { |
|
2866 | - ?> |
|
2865 | + foreach ($gd_taxonomy as $gd_tax) { |
|
2866 | + ?> |
|
2867 | 2867 | <option <?php if (isset($field_info->htmlvar_name) && $field_info->htmlvar_name == $gd_tax) { |
2868 | - echo 'selected="selected"'; |
|
2869 | - }?> id="<?php echo $gd_tax;?>"><?php echo $gd_tax;?></option><?php |
|
2870 | - } |
|
2871 | - ?> |
|
2868 | + echo 'selected="selected"'; |
|
2869 | + }?> id="<?php echo $gd_tax;?>"><?php echo $gd_tax;?></option><?php |
|
2870 | + } |
|
2871 | + ?> |
|
2872 | 2872 | </select> |
2873 | 2873 | </div> |
2874 | 2874 | </li> |
@@ -2884,49 +2884,49 @@ discard block |
||
2884 | 2884 | |
2885 | 2885 | <select name="cat_display_type" id="cat_display_type"> |
2886 | 2886 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'ajax_chained') { |
2887 | - echo 'selected="selected"'; |
|
2888 | - }?> value="ajax_chained"><?php _e('Ajax Chained', 'geodirectory');?></option> |
|
2887 | + echo 'selected="selected"'; |
|
2888 | + }?> value="ajax_chained"><?php _e('Ajax Chained', 'geodirectory');?></option> |
|
2889 | 2889 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'select') { |
2890 | - echo 'selected="selected"'; |
|
2891 | - }?> value="select"><?php _e('Select', 'geodirectory');?></option> |
|
2890 | + echo 'selected="selected"'; |
|
2891 | + }?> value="select"><?php _e('Select', 'geodirectory');?></option> |
|
2892 | 2892 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'multiselect') { |
2893 | - echo 'selected="selected"'; |
|
2894 | - }?> value="multiselect"><?php _e('Multiselect', 'geodirectory');?></option> |
|
2893 | + echo 'selected="selected"'; |
|
2894 | + }?> value="multiselect"><?php _e('Multiselect', 'geodirectory');?></option> |
|
2895 | 2895 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'checkbox') { |
2896 | - echo 'selected="selected"'; |
|
2897 | - }?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option> |
|
2896 | + echo 'selected="selected"'; |
|
2897 | + }?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option> |
|
2898 | 2898 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'radio') { |
2899 | - echo 'selected="selected"'; |
|
2900 | - }?> value="radio"><?php _e('Radio', 'geodirectory');?></option> |
|
2899 | + echo 'selected="selected"'; |
|
2900 | + }?> value="radio"><?php _e('Radio', 'geodirectory');?></option> |
|
2901 | 2901 | </select> |
2902 | 2902 | </div> |
2903 | 2903 | </li> |
2904 | 2904 | <?php |
2905 | 2905 | |
2906 | - $output = ob_get_clean(); |
|
2907 | - return $output; |
|
2906 | + $output = ob_get_clean(); |
|
2907 | + return $output; |
|
2908 | 2908 | } |
2909 | 2909 | add_filter('geodir_cfa_htmlvar_name_taxonomy','geodir_cfa_htmlvar_name_taxonomy',10,4); |
2910 | 2910 | |
2911 | 2911 | |
2912 | 2912 | function geodir_cfa_extra_fields_address($output,$result_str,$cf,$field_info){ |
2913 | 2913 | |
2914 | - ob_start(); |
|
2915 | - if (isset($field_info->extra_fields) && $field_info->extra_fields != '') { |
|
2916 | - $address = stripslashes_deep(unserialize($field_info->extra_fields)); |
|
2917 | - } |
|
2914 | + ob_start(); |
|
2915 | + if (isset($field_info->extra_fields) && $field_info->extra_fields != '') { |
|
2916 | + $address = stripslashes_deep(unserialize($field_info->extra_fields)); |
|
2917 | + } |
|
2918 | 2918 | |
2919 | - $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500); |
|
2920 | - ?> |
|
2919 | + $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500); |
|
2920 | + ?> |
|
2921 | 2921 | <?php |
2922 | - /** |
|
2923 | - * Called on the add custom fields settings page before the address field is output. |
|
2924 | - * |
|
2925 | - * @since 1.0.0 |
|
2926 | - * @param array $address The address settings array. |
|
2927 | - * @param object $field_info Extra fields info. |
|
2928 | - */ |
|
2929 | - do_action('geodir_address_extra_admin_fields', $address, $field_info); ?> |
|
2922 | + /** |
|
2923 | + * Called on the add custom fields settings page before the address field is output. |
|
2924 | + * |
|
2925 | + * @since 1.0.0 |
|
2926 | + * @param array $address The address settings array. |
|
2927 | + * @param object $field_info Extra fields info. |
|
2928 | + */ |
|
2929 | + do_action('geodir_address_extra_admin_fields', $address, $field_info); ?> |
|
2930 | 2930 | |
2931 | 2931 | <li> |
2932 | 2932 | <label for="show_zip" class="gd-cf-tooltip-wrap"> |
@@ -2939,14 +2939,14 @@ discard block |
||
2939 | 2939 | |
2940 | 2940 | <input type="radio" id="show_zip_yes<?php echo $radio_id;?>" name="extra[show_zip]" class="gdri-enabled" value="1" |
2941 | 2941 | <?php if (isset($address['show_zip']) && $address['show_zip'] == '1') { |
2942 | - echo 'checked'; |
|
2943 | - } ?>/> |
|
2942 | + echo 'checked'; |
|
2943 | + } ?>/> |
|
2944 | 2944 | <label onclick="show_hide_radio(this,'show','cf-zip-lable');" for="show_zip_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label> |
2945 | 2945 | |
2946 | 2946 | <input type="radio" id="show_zip_no<?php echo $radio_id;?>" name="extra[show_zip]" class="gdri-disabled" value="0" |
2947 | 2947 | <?php if ((isset($address['show_zip']) && !$address['show_zip']) || !isset($address['show_zip'])) { |
2948 | - echo 'checked'; |
|
2949 | - } ?>/> |
|
2948 | + echo 'checked'; |
|
2949 | + } ?>/> |
|
2950 | 2950 | <label onclick="show_hide_radio(this,'hide','cf-zip-lable');" for="show_zip_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label> |
2951 | 2951 | |
2952 | 2952 | |
@@ -2963,8 +2963,8 @@ discard block |
||
2963 | 2963 | <div class="gd-cf-input-wrap"> |
2964 | 2964 | <input type="text" name="extra[zip_lable]" id="zip_lable" |
2965 | 2965 | value="<?php if (isset($address['zip_lable'])) { |
2966 | - echo esc_attr($address['zip_lable']); |
|
2967 | - }?>"/> |
|
2966 | + echo esc_attr($address['zip_lable']); |
|
2967 | + }?>"/> |
|
2968 | 2968 | </div> |
2969 | 2969 | </li> |
2970 | 2970 | |
@@ -2981,8 +2981,8 @@ discard block |
||
2981 | 2981 | <div class="gd-cf-input-wrap"> |
2982 | 2982 | <input type="text" name="extra[map_lable]" id="map_lable" |
2983 | 2983 | value="<?php if (isset($address['map_lable'])) { |
2984 | - echo esc_attr($address['map_lable']); |
|
2985 | - }?>"/> |
|
2984 | + echo esc_attr($address['map_lable']); |
|
2985 | + }?>"/> |
|
2986 | 2986 | </div> |
2987 | 2987 | </li> |
2988 | 2988 | |
@@ -2997,14 +2997,14 @@ discard block |
||
2997 | 2997 | |
2998 | 2998 | <input type="radio" id="show_mapzoom_yes<?php echo $radio_id;?>" name="extra[show_mapzoom]" class="gdri-enabled" value="1" |
2999 | 2999 | <?php if (isset($address['show_mapzoom']) && $address['show_mapzoom'] == '1') { |
3000 | - echo 'checked'; |
|
3001 | - } ?>/> |
|
3000 | + echo 'checked'; |
|
3001 | + } ?>/> |
|
3002 | 3002 | <label for="show_mapzoom_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label> |
3003 | 3003 | |
3004 | 3004 | <input type="radio" id="show_mapzoom_no<?php echo $radio_id;?>" name="extra[show_mapzoom]" class="gdri-disabled" value="0" |
3005 | 3005 | <?php if ((isset($address['show_mapzoom']) && !$address['show_mapzoom']) || !isset($address['show_mapzoom'])) { |
3006 | - echo 'checked'; |
|
3007 | - } ?>/> |
|
3006 | + echo 'checked'; |
|
3007 | + } ?>/> |
|
3008 | 3008 | <label for="show_mapzoom_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label> |
3009 | 3009 | |
3010 | 3010 | </div> |
@@ -3021,14 +3021,14 @@ discard block |
||
3021 | 3021 | |
3022 | 3022 | <input type="radio" id="show_mapview_yes<?php echo $radio_id;?>" name="extra[show_mapview]" class="gdri-enabled" value="1" |
3023 | 3023 | <?php if (isset($address['show_mapview']) && $address['show_mapview'] == '1') { |
3024 | - echo 'checked'; |
|
3025 | - } ?>/> |
|
3024 | + echo 'checked'; |
|
3025 | + } ?>/> |
|
3026 | 3026 | <label for="show_mapview_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label> |
3027 | 3027 | |
3028 | 3028 | <input type="radio" id="show_mapview_no<?php echo $radio_id;?>" name="extra[show_mapview]" class="gdri-disabled" value="0" |
3029 | 3029 | <?php if ((isset($address['show_mapview']) && !$address['show_mapview']) || !isset($address['show_mapview'])) { |
3030 | - echo 'checked'; |
|
3031 | - } ?>/> |
|
3030 | + echo 'checked'; |
|
3031 | + } ?>/> |
|
3032 | 3032 | <label for="show_mapview_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label> |
3033 | 3033 | |
3034 | 3034 | </div> |
@@ -3045,8 +3045,8 @@ discard block |
||
3045 | 3045 | <div class="gd-cf-input-wrap"> |
3046 | 3046 | <input type="text" name="extra[mapview_lable]" id="mapview_lable" |
3047 | 3047 | value="<?php if (isset($address['mapview_lable'])) { |
3048 | - echo esc_attr($address['mapview_lable']); |
|
3049 | - }?>"/> |
|
3048 | + echo esc_attr($address['mapview_lable']); |
|
3049 | + }?>"/> |
|
3050 | 3050 | </div> |
3051 | 3051 | </li> |
3052 | 3052 | <li> |
@@ -3060,29 +3060,29 @@ discard block |
||
3060 | 3060 | |
3061 | 3061 | <input type="radio" id="show_latlng_yes<?php echo $radio_id;?>" name="extra[show_latlng]" class="gdri-enabled" value="1" |
3062 | 3062 | <?php if (isset($address['show_latlng']) && $address['show_latlng'] == '1') { |
3063 | - echo 'checked'; |
|
3064 | - } ?>/> |
|
3063 | + echo 'checked'; |
|
3064 | + } ?>/> |
|
3065 | 3065 | <label for="show_latlng_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label> |
3066 | 3066 | |
3067 | 3067 | <input type="radio" id="show_latlng_no<?php echo $radio_id;?>" name="extra[show_latlng]" class="gdri-disabled" value="0" |
3068 | 3068 | <?php if ((isset($address['show_latlng']) && !$address['show_latlng']) || !isset($address['show_latlng'])) { |
3069 | - echo 'checked'; |
|
3070 | - } ?>/> |
|
3069 | + echo 'checked'; |
|
3070 | + } ?>/> |
|
3071 | 3071 | <label for="show_latlng_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label> |
3072 | 3072 | |
3073 | 3073 | </div> |
3074 | 3074 | </li> |
3075 | 3075 | <?php |
3076 | 3076 | |
3077 | - $html = ob_get_clean(); |
|
3078 | - return $output.$html; |
|
3077 | + $html = ob_get_clean(); |
|
3078 | + return $output.$html; |
|
3079 | 3079 | } |
3080 | 3080 | add_filter('geodir_cfa_extra_fields_address','geodir_cfa_extra_fields_address',10,4); |
3081 | 3081 | |
3082 | 3082 | |
3083 | 3083 | function geodir_cfa_extra_fields_multiselect($output,$result_str,$cf,$field_info){ |
3084 | - ob_start(); |
|
3085 | - ?> |
|
3084 | + ob_start(); |
|
3085 | + ?> |
|
3086 | 3086 | <li> |
3087 | 3087 | <label for="multi_display_type" class="gd-cf-tooltip-wrap"> |
3088 | 3088 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Multiselect display type :', 'geodirectory'); ?> |
@@ -3094,14 +3094,14 @@ discard block |
||
3094 | 3094 | |
3095 | 3095 | <select name="multi_display_type" id="multi_display_type"> |
3096 | 3096 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'select') { |
3097 | - echo 'selected="selected"'; |
|
3098 | - }?> value="select"><?php _e('Select', 'geodirectory');?></option> |
|
3097 | + echo 'selected="selected"'; |
|
3098 | + }?> value="select"><?php _e('Select', 'geodirectory');?></option> |
|
3099 | 3099 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'checkbox') { |
3100 | - echo 'selected="selected"'; |
|
3101 | - }?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option> |
|
3100 | + echo 'selected="selected"'; |
|
3101 | + }?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option> |
|
3102 | 3102 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'radio') { |
3103 | - echo 'selected="selected"'; |
|
3104 | - }?> value="radio"><?php _e('Radio', 'geodirectory');?></option> |
|
3103 | + echo 'selected="selected"'; |
|
3104 | + }?> value="radio"><?php _e('Radio', 'geodirectory');?></option> |
|
3105 | 3105 | </select> |
3106 | 3106 | |
3107 | 3107 | <br/> |
@@ -3109,25 +3109,25 @@ discard block |
||
3109 | 3109 | </li> |
3110 | 3110 | <?php |
3111 | 3111 | |
3112 | - $html = ob_get_clean(); |
|
3113 | - return $output.$html; |
|
3112 | + $html = ob_get_clean(); |
|
3113 | + return $output.$html; |
|
3114 | 3114 | } |
3115 | 3115 | add_filter('geodir_cfa_extra_fields_multiselect','geodir_cfa_extra_fields_multiselect',10,4); |
3116 | 3116 | |
3117 | 3117 | |
3118 | 3118 | function geodir_cfa_extra_fields_smr($output,$result_str,$cf,$field_info){ |
3119 | 3119 | |
3120 | - ob_start(); |
|
3120 | + ob_start(); |
|
3121 | 3121 | |
3122 | - $value = ''; |
|
3123 | - if (isset($field_info->option_values)) { |
|
3124 | - $value = esc_attr($field_info->option_values); |
|
3125 | - }elseif(isset($cf['defaults']['option_values']) && $cf['defaults']['option_values']){ |
|
3126 | - $value = esc_attr($cf['defaults']['option_values']); |
|
3127 | - } |
|
3122 | + $value = ''; |
|
3123 | + if (isset($field_info->option_values)) { |
|
3124 | + $value = esc_attr($field_info->option_values); |
|
3125 | + }elseif(isset($cf['defaults']['option_values']) && $cf['defaults']['option_values']){ |
|
3126 | + $value = esc_attr($cf['defaults']['option_values']); |
|
3127 | + } |
|
3128 | 3128 | |
3129 | - $field_type = isset($field_info->field_type) ? $field_info->field_type : ''; |
|
3130 | - ?> |
|
3129 | + $field_type = isset($field_info->field_type) ? $field_info->field_type : ''; |
|
3130 | + ?> |
|
3131 | 3131 | <li> |
3132 | 3132 | <label for="option_values" class="gd-cf-tooltip-wrap"> |
3133 | 3133 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Option Values :', 'geodirectory'); ?> |
@@ -3154,8 +3154,8 @@ discard block |
||
3154 | 3154 | </li> |
3155 | 3155 | <?php |
3156 | 3156 | |
3157 | - $html = ob_get_clean(); |
|
3158 | - return $output.$html; |
|
3157 | + $html = ob_get_clean(); |
|
3158 | + return $output.$html; |
|
3159 | 3159 | } |
3160 | 3160 | add_filter('geodir_cfa_extra_fields_multiselect','geodir_cfa_extra_fields_smr',10,4); |
3161 | 3161 | add_filter('geodir_cfa_extra_fields_select','geodir_cfa_extra_fields_smr',10,4); |
@@ -3163,12 +3163,12 @@ discard block |
||
3163 | 3163 | |
3164 | 3164 | |
3165 | 3165 | function geodir_cfa_extra_fields_datepicker($output,$result_str,$cf,$field_info){ |
3166 | - ob_start(); |
|
3167 | - $extra = array(); |
|
3168 | - if (isset($field_info->extra_fields) && $field_info->extra_fields != '') { |
|
3169 | - $extra = unserialize($field_info->extra_fields); |
|
3170 | - } |
|
3171 | - ?> |
|
3166 | + ob_start(); |
|
3167 | + $extra = array(); |
|
3168 | + if (isset($field_info->extra_fields) && $field_info->extra_fields != '') { |
|
3169 | + $extra = unserialize($field_info->extra_fields); |
|
3170 | + } |
|
3171 | + ?> |
|
3172 | 3172 | <li> |
3173 | 3173 | <label for="date_format" class="gd-cf-tooltip-wrap"> |
3174 | 3174 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Date Format :', 'geodirectory'); ?> |
@@ -3178,52 +3178,52 @@ discard block |
||
3178 | 3178 | </label> |
3179 | 3179 | <div class="gd-cf-input-wrap" style="overflow:inherit;"> |
3180 | 3180 | <?php |
3181 | - $date_formats = array( |
|
3182 | - 'm/d/Y', |
|
3183 | - 'd/m/Y', |
|
3184 | - 'Y/m/d', |
|
3185 | - 'm-d-Y', |
|
3186 | - 'd-m-Y', |
|
3187 | - 'Y-m-d', |
|
3188 | - 'F j, Y', |
|
3189 | - ); |
|
3190 | - /** |
|
3191 | - * Filter the custom field date format options. |
|
3192 | - * |
|
3193 | - * @since 1.6.5 |
|
3194 | - * @param array $date_formats The PHP date format array. |
|
3195 | - */ |
|
3196 | - $date_formats = apply_filters('geodir_date_formats',$date_formats); |
|
3197 | - ?> |
|
3181 | + $date_formats = array( |
|
3182 | + 'm/d/Y', |
|
3183 | + 'd/m/Y', |
|
3184 | + 'Y/m/d', |
|
3185 | + 'm-d-Y', |
|
3186 | + 'd-m-Y', |
|
3187 | + 'Y-m-d', |
|
3188 | + 'F j, Y', |
|
3189 | + ); |
|
3190 | + /** |
|
3191 | + * Filter the custom field date format options. |
|
3192 | + * |
|
3193 | + * @since 1.6.5 |
|
3194 | + * @param array $date_formats The PHP date format array. |
|
3195 | + */ |
|
3196 | + $date_formats = apply_filters('geodir_date_formats',$date_formats); |
|
3197 | + ?> |
|
3198 | 3198 | <select name="extra[date_format]" id="date_format"> |
3199 | 3199 | <?php |
3200 | - foreach($date_formats as $format){ |
|
3201 | - $selected = ''; |
|
3202 | - if(!empty($extra) && esc_attr($extra['date_format'])==$format){ |
|
3203 | - $selected = "selected='selected'"; |
|
3204 | - } |
|
3205 | - echo "<option $selected value='$format'>$format (".date_i18n( $format, time()).")</option>"; |
|
3206 | - } |
|
3207 | - ?> |
|
3200 | + foreach($date_formats as $format){ |
|
3201 | + $selected = ''; |
|
3202 | + if(!empty($extra) && esc_attr($extra['date_format'])==$format){ |
|
3203 | + $selected = "selected='selected'"; |
|
3204 | + } |
|
3205 | + echo "<option $selected value='$format'>$format (".date_i18n( $format, time()).")</option>"; |
|
3206 | + } |
|
3207 | + ?> |
|
3208 | 3208 | </select> |
3209 | 3209 | |
3210 | 3210 | </div> |
3211 | 3211 | </li> |
3212 | 3212 | <?php |
3213 | 3213 | |
3214 | - $html = ob_get_clean(); |
|
3215 | - return $output.$html; |
|
3214 | + $html = ob_get_clean(); |
|
3215 | + return $output.$html; |
|
3216 | 3216 | } |
3217 | 3217 | add_filter('geodir_cfa_extra_fields_datepicker','geodir_cfa_extra_fields_datepicker',10,4); |
3218 | 3218 | |
3219 | 3219 | |
3220 | 3220 | function geodir_cfa_extra_fields_file($output,$result_str,$cf,$field_info){ |
3221 | - ob_start(); |
|
3222 | - $allowed_file_types = geodir_allowed_mime_types(); |
|
3221 | + ob_start(); |
|
3222 | + $allowed_file_types = geodir_allowed_mime_types(); |
|
3223 | 3223 | |
3224 | - $extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : ''; |
|
3225 | - $gd_file_types = !empty($extra_fields) && !empty($extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : array('*'); |
|
3226 | - ?> |
|
3224 | + $extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : ''; |
|
3225 | + $gd_file_types = !empty($extra_fields) && !empty($extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : array('*'); |
|
3226 | + ?> |
|
3227 | 3227 | <li> |
3228 | 3228 | <label for="gd_file_types" class="gd-cf-tooltip-wrap"> |
3229 | 3229 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Allowed file types :', 'geodirectory'); ?> |
@@ -3246,33 +3246,33 @@ discard block |
||
3246 | 3246 | </li> |
3247 | 3247 | <?php |
3248 | 3248 | |
3249 | - $html = ob_get_clean(); |
|
3250 | - return $output.$html; |
|
3249 | + $html = ob_get_clean(); |
|
3250 | + return $output.$html; |
|
3251 | 3251 | } |
3252 | 3252 | add_filter('geodir_cfa_extra_fields_file','geodir_cfa_extra_fields_file',10,4); |
3253 | 3253 | |
3254 | 3254 | function geodir_cfa_extra_fields_text($output,$result_str,$cf,$field_info){ |
3255 | - ob_start(); |
|
3255 | + ob_start(); |
|
3256 | 3256 | |
3257 | - $extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : ''; |
|
3257 | + $extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : ''; |
|
3258 | 3258 | // print_r($cf);echo '###'; |
3259 | 3259 | |
3260 | 3260 | |
3261 | 3261 | |
3262 | - $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500); |
|
3262 | + $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500); |
|
3263 | 3263 | |
3264 | 3264 | |
3265 | - $value = ''; |
|
3266 | - if ($extra_fields && isset($extra_fields['is_price'])) { |
|
3267 | - $value = esc_attr($extra_fields['is_price']); |
|
3268 | - }elseif(isset($cf['defaults']['extra_fields']['is_price']) && $cf['defaults']['extra_fields']['is_price']){ |
|
3269 | - $value = esc_attr($cf['defaults']['extra_fields']['is_price']); |
|
3270 | - } |
|
3265 | + $value = ''; |
|
3266 | + if ($extra_fields && isset($extra_fields['is_price'])) { |
|
3267 | + $value = esc_attr($extra_fields['is_price']); |
|
3268 | + }elseif(isset($cf['defaults']['extra_fields']['is_price']) && $cf['defaults']['extra_fields']['is_price']){ |
|
3269 | + $value = esc_attr($cf['defaults']['extra_fields']['is_price']); |
|
3270 | + } |
|
3271 | 3271 | |
3272 | - $show_price_extra = ($value==1) ? 1 : 0; |
|
3272 | + $show_price_extra = ($value==1) ? 1 : 0; |
|
3273 | 3273 | |
3274 | - $show_price = (isset($field_info->data_type) && ($field_info->data_type=='INT' && $field_info->data_type=='FLOAT')) ? 1 : 0; |
|
3275 | - ?> |
|
3274 | + $show_price = (isset($field_info->data_type) && ($field_info->data_type=='INT' && $field_info->data_type=='FLOAT')) ? 1 : 0; |
|
3275 | + ?> |
|
3276 | 3276 | <li class="gdcf-price-extra-set" <?php if(!$show_price){ echo "style='display:none;'";}?>> |
3277 | 3277 | <label for="is_price" class="gd-cf-tooltip-wrap"> |
3278 | 3278 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Display as price? :', 'geodirectory'); ?> |
@@ -3284,14 +3284,14 @@ discard block |
||
3284 | 3284 | |
3285 | 3285 | <input type="radio" id="is_price_yes<?php echo $radio_id;?>" name="extra[is_price]" class="gdri-enabled" value="1" |
3286 | 3286 | <?php if ($value == '1') { |
3287 | - echo 'checked'; |
|
3288 | - } ?>/> |
|
3287 | + echo 'checked'; |
|
3288 | + } ?>/> |
|
3289 | 3289 | <label onclick="show_hide_radio(this,'show','gdcf-price-extra');" for="is_price_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label> |
3290 | 3290 | |
3291 | 3291 | <input type="radio" id="is_price_no<?php echo $radio_id;?>" name="extra[is_price]" class="gdri-disabled" value="0" |
3292 | 3292 | <?php if ($value == '0' || !$value) { |
3293 | - echo 'checked'; |
|
3294 | - } ?>/> |
|
3293 | + echo 'checked'; |
|
3294 | + } ?>/> |
|
3295 | 3295 | <label onclick="show_hide_radio(this,'hide','gdcf-price-extra');" for="is_price_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label> |
3296 | 3296 | |
3297 | 3297 | </div> |
@@ -3299,13 +3299,13 @@ discard block |
||
3299 | 3299 | |
3300 | 3300 | <?php |
3301 | 3301 | |
3302 | - $value = ''; |
|
3303 | - if ($extra_fields && isset($extra_fields['thousand_separator'])) { |
|
3304 | - $value = esc_attr($extra_fields['thousand_separator']); |
|
3305 | - }elseif(isset($cf['defaults']['extra_fields']['thousand_separator']) && $cf['defaults']['extra_fields']['thousand_separator']){ |
|
3306 | - $value = esc_attr($cf['defaults']['extra_fields']['thousand_separator']); |
|
3307 | - } |
|
3308 | - ?> |
|
3302 | + $value = ''; |
|
3303 | + if ($extra_fields && isset($extra_fields['thousand_separator'])) { |
|
3304 | + $value = esc_attr($extra_fields['thousand_separator']); |
|
3305 | + }elseif(isset($cf['defaults']['extra_fields']['thousand_separator']) && $cf['defaults']['extra_fields']['thousand_separator']){ |
|
3306 | + $value = esc_attr($cf['defaults']['extra_fields']['thousand_separator']); |
|
3307 | + } |
|
3308 | + ?> |
|
3309 | 3309 | <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>> |
3310 | 3310 | <label for="thousand_separator" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Thousand separator :', 'geodirectory');?> |
3311 | 3311 | <div class="gdcf-tooltip"> |
@@ -3326,13 +3326,13 @@ discard block |
||
3326 | 3326 | |
3327 | 3327 | <?php |
3328 | 3328 | |
3329 | - $value = ''; |
|
3330 | - if ($extra_fields && isset($extra_fields['decimal_separator'])) { |
|
3331 | - $value = esc_attr($extra_fields['decimal_separator']); |
|
3332 | - }elseif(isset($cf['defaults']['extra_fields']['decimal_separator']) && $cf['defaults']['extra_fields']['decimal_separator']){ |
|
3333 | - $value = esc_attr($cf['defaults']['extra_fields']['decimal_separator']); |
|
3334 | - } |
|
3335 | - ?> |
|
3329 | + $value = ''; |
|
3330 | + if ($extra_fields && isset($extra_fields['decimal_separator'])) { |
|
3331 | + $value = esc_attr($extra_fields['decimal_separator']); |
|
3332 | + }elseif(isset($cf['defaults']['extra_fields']['decimal_separator']) && $cf['defaults']['extra_fields']['decimal_separator']){ |
|
3333 | + $value = esc_attr($cf['defaults']['extra_fields']['decimal_separator']); |
|
3334 | + } |
|
3335 | + ?> |
|
3336 | 3336 | <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>> |
3337 | 3337 | <label for="decimal_separator" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Decimal separator :', 'geodirectory');?> |
3338 | 3338 | <div class="gdcf-tooltip"> |
@@ -3349,13 +3349,13 @@ discard block |
||
3349 | 3349 | |
3350 | 3350 | <?php |
3351 | 3351 | |
3352 | - $value = ''; |
|
3353 | - if ($extra_fields && isset($extra_fields['decimal_display'])) { |
|
3354 | - $value = esc_attr($extra_fields['decimal_display']); |
|
3355 | - }elseif(isset($cf['defaults']['extra_fields']['decimal_display']) && $cf['defaults']['extra_fields']['decimal_display']){ |
|
3356 | - $value = esc_attr($cf['defaults']['extra_fields']['decimal_display']); |
|
3357 | - } |
|
3358 | - ?> |
|
3352 | + $value = ''; |
|
3353 | + if ($extra_fields && isset($extra_fields['decimal_display'])) { |
|
3354 | + $value = esc_attr($extra_fields['decimal_display']); |
|
3355 | + }elseif(isset($cf['defaults']['extra_fields']['decimal_display']) && $cf['defaults']['extra_fields']['decimal_display']){ |
|
3356 | + $value = esc_attr($cf['defaults']['extra_fields']['decimal_display']); |
|
3357 | + } |
|
3358 | + ?> |
|
3359 | 3359 | <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>> |
3360 | 3360 | <label for="decimal_display" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Decimal display :', 'geodirectory');?> |
3361 | 3361 | <div class="gdcf-tooltip"> |
@@ -3372,13 +3372,13 @@ discard block |
||
3372 | 3372 | |
3373 | 3373 | <?php |
3374 | 3374 | |
3375 | - $value = ''; |
|
3376 | - if ($extra_fields && isset($extra_fields['currency_symbol'])) { |
|
3377 | - $value = esc_attr($extra_fields['currency_symbol']); |
|
3378 | - }elseif(isset($cf['defaults']['extra_fields']['currency_symbol']) && $cf['defaults']['extra_fields']['currency_symbol']){ |
|
3379 | - $value = esc_attr($cf['defaults']['extra_fields']['currency_symbol']); |
|
3380 | - } |
|
3381 | - ?> |
|
3375 | + $value = ''; |
|
3376 | + if ($extra_fields && isset($extra_fields['currency_symbol'])) { |
|
3377 | + $value = esc_attr($extra_fields['currency_symbol']); |
|
3378 | + }elseif(isset($cf['defaults']['extra_fields']['currency_symbol']) && $cf['defaults']['extra_fields']['currency_symbol']){ |
|
3379 | + $value = esc_attr($cf['defaults']['extra_fields']['currency_symbol']); |
|
3380 | + } |
|
3381 | + ?> |
|
3382 | 3382 | <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>> |
3383 | 3383 | <label for="currency_symbol" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Currency symbol :', 'geodirectory');?> |
3384 | 3384 | <div class="gdcf-tooltip"> |
@@ -3393,13 +3393,13 @@ discard block |
||
3393 | 3393 | |
3394 | 3394 | <?php |
3395 | 3395 | |
3396 | - $value = ''; |
|
3397 | - if ($extra_fields && isset($extra_fields['currency_symbol_placement'])) { |
|
3398 | - $value = esc_attr($extra_fields['currency_symbol_placement']); |
|
3399 | - }elseif(isset($cf['defaults']['extra_fields']['currency_symbol_placement']) && $cf['defaults']['extra_fields']['currency_symbol_placement']){ |
|
3400 | - $value = esc_attr($cf['defaults']['extra_fields']['currency_symbol_placement']); |
|
3401 | - } |
|
3402 | - ?> |
|
3396 | + $value = ''; |
|
3397 | + if ($extra_fields && isset($extra_fields['currency_symbol_placement'])) { |
|
3398 | + $value = esc_attr($extra_fields['currency_symbol_placement']); |
|
3399 | + }elseif(isset($cf['defaults']['extra_fields']['currency_symbol_placement']) && $cf['defaults']['extra_fields']['currency_symbol_placement']){ |
|
3400 | + $value = esc_attr($cf['defaults']['extra_fields']['currency_symbol_placement']); |
|
3401 | + } |
|
3402 | + ?> |
|
3403 | 3403 | <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>> |
3404 | 3404 | <label for="currency_symbol_placement" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Currency symbol placement :', 'geodirectory');?> |
3405 | 3405 | <div class="gdcf-tooltip"> |
@@ -3417,225 +3417,225 @@ discard block |
||
3417 | 3417 | |
3418 | 3418 | <?php |
3419 | 3419 | |
3420 | - $html = ob_get_clean(); |
|
3421 | - return $output.$html; |
|
3420 | + $html = ob_get_clean(); |
|
3421 | + return $output.$html; |
|
3422 | 3422 | } |
3423 | 3423 | add_filter('geodir_cfa_extra_fields_text','geodir_cfa_extra_fields_text',10,4); |
3424 | 3424 | |
3425 | 3425 | function geodir_default_custom_fields($post_type='gd_place',$package_id=''){ |
3426 | - $fields = array(); |
|
3427 | - $package = ($package_id=='') ? '' : array($package_id); |
|
3428 | - |
|
3429 | - $fields[] = array('listing_type' => $post_type, |
|
3430 | - 'data_type' => 'VARCHAR', |
|
3431 | - 'field_type' => 'taxonomy', |
|
3432 | - 'admin_title' => __('Category', 'geodirectory'), |
|
3433 | - 'admin_desc' => __('SELECT listing category FROM here. SELECT at least one CATEGORY', 'geodirectory'), |
|
3434 | - 'site_title' => __('Category', 'geodirectory'), |
|
3435 | - 'htmlvar_name' => $post_type.'category', |
|
3436 | - 'default_value' => '', |
|
3437 | - 'is_default' => '1', |
|
3438 | - 'is_admin' => '1', |
|
3439 | - 'is_required' => '1', |
|
3440 | - 'show_in' => '[detail]', |
|
3441 | - 'show_on_pkg' => $package, |
|
3442 | - 'clabels' => __('Category', 'geodirectory')); |
|
3443 | - |
|
3444 | - $fields[] = array('listing_type' => $post_type, |
|
3445 | - 'data_type' => 'VARCHAR', |
|
3446 | - 'field_type' => 'address', |
|
3447 | - 'admin_title' => __('Address', 'geodirectory'), |
|
3448 | - 'admin_desc' => ADDRESS_MSG, |
|
3449 | - 'site_title' => __('Address', 'geodirectory'), |
|
3450 | - 'htmlvar_name' => 'post', |
|
3451 | - 'default_value' => '', |
|
3452 | - 'option_values' => '', |
|
3453 | - 'is_default' => '1', |
|
3454 | - 'is_admin' => '1', |
|
3455 | - 'is_required' => '1', |
|
3456 | - 'show_in' => '[detail],[mapbubble]', |
|
3457 | - 'show_on_pkg' => $package, |
|
3458 | - 'required_msg' => __('Address fields are required', 'geodirectory'), |
|
3459 | - 'clabels' => __('Address', 'geodirectory'), |
|
3460 | - 'extra' => array('show_city' => 1, 'city_lable' => __('City', 'geodirectory'), |
|
3461 | - 'show_region' => 1, 'region_lable' => __('Region', 'geodirectory'), |
|
3462 | - 'show_country' => 1, 'country_lable' => __('Country', 'geodirectory'), |
|
3463 | - 'show_zip' => 1, 'zip_lable' => __('Zip/Post Code', 'geodirectory'), |
|
3464 | - 'show_map' => 1, 'map_lable' => __('Set Address On Map', 'geodirectory'), |
|
3465 | - 'show_mapview' => 1, 'mapview_lable' => __('Select Map View', 'geodirectory'), |
|
3466 | - 'show_mapzoom' => 1, 'mapzoom_lable' => 'hidden', |
|
3467 | - 'show_latlng' => 1)); |
|
3468 | - |
|
3469 | - $fields[] = array('listing_type' => $post_type, |
|
3470 | - 'data_type' => 'VARCHAR', |
|
3471 | - 'field_type' => 'text', |
|
3472 | - 'admin_title' => __('Time', 'geodirectory'), |
|
3473 | - 'admin_desc' => __('Enter Business or Listing Timing Information.<br/>eg. : 10.00 am to 6 pm every day', 'geodirectory'), |
|
3474 | - 'site_title' => __('Time', 'geodirectory'), |
|
3475 | - 'htmlvar_name' => 'timing', |
|
3476 | - 'default_value' => '', |
|
3477 | - 'option_values' => '', |
|
3478 | - 'is_default' => '1', |
|
3479 | - 'is_admin' => '1', |
|
3480 | - 'show_in' => '[detail],[mapbubble]', |
|
3481 | - 'show_on_pkg' => $package, |
|
3482 | - 'clabels' => __('Time', 'geodirectory')); |
|
3483 | - |
|
3484 | - $fields[] = array('listing_type' => $post_type, |
|
3485 | - 'data_type' => 'VARCHAR', |
|
3486 | - 'field_type' => 'phone', |
|
3487 | - 'admin_title' => __('Phone', 'geodirectory'), |
|
3488 | - 'admin_desc' => __('You can enter phone number,cell phone number etc.', 'geodirectory'), |
|
3489 | - 'site_title' => __('Phone', 'geodirectory'), |
|
3490 | - 'htmlvar_name' => 'contact', |
|
3491 | - 'default_value' => '', |
|
3492 | - 'option_values' => '', |
|
3493 | - 'is_default' => '1', |
|
3494 | - 'is_admin' => '1', |
|
3495 | - 'show_in' => '[detail],[mapbubble]', |
|
3496 | - 'show_on_pkg' => $package, |
|
3497 | - 'clabels' => __('Phone', 'geodirectory')); |
|
3498 | - |
|
3499 | - $fields[] = array('listing_type' => $post_type, |
|
3500 | - 'data_type' => 'VARCHAR', |
|
3501 | - 'field_type' => 'email', |
|
3502 | - 'admin_title' => __('Email', 'geodirectory'), |
|
3503 | - 'admin_desc' => __('You can enter your business or listing email.', 'geodirectory'), |
|
3504 | - 'site_title' => __('Email', 'geodirectory'), |
|
3505 | - 'htmlvar_name' => 'email', |
|
3506 | - 'default_value' => '', |
|
3507 | - 'option_values' => '', |
|
3508 | - 'is_default' => '1', |
|
3509 | - 'is_admin' => '1', |
|
3510 | - 'show_in' => '[detail]', |
|
3511 | - 'show_on_pkg' => $package, |
|
3512 | - 'clabels' => __('Email', 'geodirectory')); |
|
3513 | - |
|
3514 | - $fields[] = array('listing_type' => $post_type, |
|
3515 | - 'data_type' => 'VARCHAR', |
|
3516 | - 'field_type' => 'url', |
|
3517 | - 'admin_title' => __('Website', 'geodirectory'), |
|
3518 | - 'admin_desc' => __('You can enter your business or listing website.', 'geodirectory'), |
|
3519 | - 'site_title' => __('Website', 'geodirectory'), |
|
3520 | - 'htmlvar_name' => 'website', |
|
3521 | - 'default_value' => '', |
|
3522 | - 'option_values' => '', |
|
3523 | - 'is_default' => '1', |
|
3524 | - 'is_admin' => '1', |
|
3525 | - 'show_in' => '[detail]', |
|
3526 | - 'show_on_pkg' => $package, |
|
3527 | - 'clabels' => __('Website', 'geodirectory')); |
|
3528 | - |
|
3529 | - $fields[] = array('listing_type' => $post_type, |
|
3530 | - 'data_type' => 'VARCHAR', |
|
3531 | - 'field_type' => 'url', |
|
3532 | - 'admin_title' => __('Twitter', 'geodirectory'), |
|
3533 | - 'admin_desc' => __('You can enter your business or listing twitter url.', 'geodirectory'), |
|
3534 | - 'site_title' => __('Twitter', 'geodirectory'), |
|
3535 | - 'htmlvar_name' => 'twitter', |
|
3536 | - 'default_value' => '', |
|
3537 | - 'option_values' => '', |
|
3538 | - 'is_default' => '1', |
|
3539 | - 'is_admin' => '1', |
|
3540 | - 'show_in' => '[detail]', |
|
3541 | - 'show_on_pkg' => $package, |
|
3542 | - 'clabels' => __('Twitter', 'geodirectory')); |
|
3543 | - |
|
3544 | - $fields[] = array('listing_type' => $post_type, |
|
3545 | - 'data_type' => 'VARCHAR', |
|
3546 | - 'field_type' => 'url', |
|
3547 | - 'admin_title' => __('Facebook', 'geodirectory'), |
|
3548 | - 'admin_desc' => __('You can enter your business or listing facebook url.', 'geodirectory'), |
|
3549 | - 'site_title' => __('Facebook', 'geodirectory'), |
|
3550 | - 'htmlvar_name' => 'facebook', |
|
3551 | - 'default_value' => '', |
|
3552 | - 'option_values' => '', |
|
3553 | - 'is_default' => '1', |
|
3554 | - 'is_admin' => '1', |
|
3555 | - 'show_in' => '[detail]', |
|
3556 | - 'show_on_pkg' => $package, |
|
3557 | - 'clabels' => __('Facebook', 'geodirectory')); |
|
3558 | - |
|
3559 | - $fields[] = array('listing_type' => $post_type, |
|
3560 | - 'data_type' => 'TEXT', |
|
3561 | - 'field_type' => 'textarea', |
|
3562 | - 'admin_title' => __('Video', 'geodirectory'), |
|
3563 | - 'admin_desc' => __('Add video code here, YouTube etc.', 'geodirectory'), |
|
3564 | - 'site_title' => __('Video', 'geodirectory'), |
|
3565 | - 'htmlvar_name' => 'video', |
|
3566 | - 'default_value' => '', |
|
3567 | - 'option_values' => '', |
|
3568 | - 'is_default' => '0', |
|
3569 | - 'is_admin' => '1', |
|
3570 | - 'show_in' => '[owntab]', |
|
3571 | - 'show_on_pkg' => $package, |
|
3572 | - 'clabels' => __('Video', 'geodirectory')); |
|
3573 | - |
|
3574 | - $fields[] = array('listing_type' => $post_type, |
|
3575 | - 'data_type' => 'TEXT', |
|
3576 | - 'field_type' => 'textarea', |
|
3577 | - 'admin_title' => __('Special Offers', 'geodirectory'), |
|
3578 | - 'admin_desc' => __('Note: List out any special offers (optional)', 'geodirectory'), |
|
3579 | - 'site_title' => __('Special Offers', 'geodirectory'), |
|
3580 | - 'htmlvar_name' => 'special_offers', |
|
3581 | - 'default_value' => '', |
|
3582 | - 'option_values' => '', |
|
3583 | - 'is_default' => '0', |
|
3584 | - 'is_admin' => '1', |
|
3585 | - 'show_in' => '[owntab]', |
|
3586 | - 'show_on_pkg' => $package, |
|
3587 | - 'clabels' => __('Special Offers', 'geodirectory')); |
|
3588 | - |
|
3589 | - /** |
|
3590 | - * Filter the array of default custom fields DB table data. |
|
3591 | - * |
|
3592 | - * @since 1.6.6 |
|
3593 | - * @param string $fields The default custom fields as an array. |
|
3594 | - */ |
|
3595 | - $fields = apply_filters('geodir_default_custom_fields', $fields); |
|
3596 | - |
|
3597 | - return $fields; |
|
3426 | + $fields = array(); |
|
3427 | + $package = ($package_id=='') ? '' : array($package_id); |
|
3428 | + |
|
3429 | + $fields[] = array('listing_type' => $post_type, |
|
3430 | + 'data_type' => 'VARCHAR', |
|
3431 | + 'field_type' => 'taxonomy', |
|
3432 | + 'admin_title' => __('Category', 'geodirectory'), |
|
3433 | + 'admin_desc' => __('SELECT listing category FROM here. SELECT at least one CATEGORY', 'geodirectory'), |
|
3434 | + 'site_title' => __('Category', 'geodirectory'), |
|
3435 | + 'htmlvar_name' => $post_type.'category', |
|
3436 | + 'default_value' => '', |
|
3437 | + 'is_default' => '1', |
|
3438 | + 'is_admin' => '1', |
|
3439 | + 'is_required' => '1', |
|
3440 | + 'show_in' => '[detail]', |
|
3441 | + 'show_on_pkg' => $package, |
|
3442 | + 'clabels' => __('Category', 'geodirectory')); |
|
3443 | + |
|
3444 | + $fields[] = array('listing_type' => $post_type, |
|
3445 | + 'data_type' => 'VARCHAR', |
|
3446 | + 'field_type' => 'address', |
|
3447 | + 'admin_title' => __('Address', 'geodirectory'), |
|
3448 | + 'admin_desc' => ADDRESS_MSG, |
|
3449 | + 'site_title' => __('Address', 'geodirectory'), |
|
3450 | + 'htmlvar_name' => 'post', |
|
3451 | + 'default_value' => '', |
|
3452 | + 'option_values' => '', |
|
3453 | + 'is_default' => '1', |
|
3454 | + 'is_admin' => '1', |
|
3455 | + 'is_required' => '1', |
|
3456 | + 'show_in' => '[detail],[mapbubble]', |
|
3457 | + 'show_on_pkg' => $package, |
|
3458 | + 'required_msg' => __('Address fields are required', 'geodirectory'), |
|
3459 | + 'clabels' => __('Address', 'geodirectory'), |
|
3460 | + 'extra' => array('show_city' => 1, 'city_lable' => __('City', 'geodirectory'), |
|
3461 | + 'show_region' => 1, 'region_lable' => __('Region', 'geodirectory'), |
|
3462 | + 'show_country' => 1, 'country_lable' => __('Country', 'geodirectory'), |
|
3463 | + 'show_zip' => 1, 'zip_lable' => __('Zip/Post Code', 'geodirectory'), |
|
3464 | + 'show_map' => 1, 'map_lable' => __('Set Address On Map', 'geodirectory'), |
|
3465 | + 'show_mapview' => 1, 'mapview_lable' => __('Select Map View', 'geodirectory'), |
|
3466 | + 'show_mapzoom' => 1, 'mapzoom_lable' => 'hidden', |
|
3467 | + 'show_latlng' => 1)); |
|
3468 | + |
|
3469 | + $fields[] = array('listing_type' => $post_type, |
|
3470 | + 'data_type' => 'VARCHAR', |
|
3471 | + 'field_type' => 'text', |
|
3472 | + 'admin_title' => __('Time', 'geodirectory'), |
|
3473 | + 'admin_desc' => __('Enter Business or Listing Timing Information.<br/>eg. : 10.00 am to 6 pm every day', 'geodirectory'), |
|
3474 | + 'site_title' => __('Time', 'geodirectory'), |
|
3475 | + 'htmlvar_name' => 'timing', |
|
3476 | + 'default_value' => '', |
|
3477 | + 'option_values' => '', |
|
3478 | + 'is_default' => '1', |
|
3479 | + 'is_admin' => '1', |
|
3480 | + 'show_in' => '[detail],[mapbubble]', |
|
3481 | + 'show_on_pkg' => $package, |
|
3482 | + 'clabels' => __('Time', 'geodirectory')); |
|
3483 | + |
|
3484 | + $fields[] = array('listing_type' => $post_type, |
|
3485 | + 'data_type' => 'VARCHAR', |
|
3486 | + 'field_type' => 'phone', |
|
3487 | + 'admin_title' => __('Phone', 'geodirectory'), |
|
3488 | + 'admin_desc' => __('You can enter phone number,cell phone number etc.', 'geodirectory'), |
|
3489 | + 'site_title' => __('Phone', 'geodirectory'), |
|
3490 | + 'htmlvar_name' => 'contact', |
|
3491 | + 'default_value' => '', |
|
3492 | + 'option_values' => '', |
|
3493 | + 'is_default' => '1', |
|
3494 | + 'is_admin' => '1', |
|
3495 | + 'show_in' => '[detail],[mapbubble]', |
|
3496 | + 'show_on_pkg' => $package, |
|
3497 | + 'clabels' => __('Phone', 'geodirectory')); |
|
3498 | + |
|
3499 | + $fields[] = array('listing_type' => $post_type, |
|
3500 | + 'data_type' => 'VARCHAR', |
|
3501 | + 'field_type' => 'email', |
|
3502 | + 'admin_title' => __('Email', 'geodirectory'), |
|
3503 | + 'admin_desc' => __('You can enter your business or listing email.', 'geodirectory'), |
|
3504 | + 'site_title' => __('Email', 'geodirectory'), |
|
3505 | + 'htmlvar_name' => 'email', |
|
3506 | + 'default_value' => '', |
|
3507 | + 'option_values' => '', |
|
3508 | + 'is_default' => '1', |
|
3509 | + 'is_admin' => '1', |
|
3510 | + 'show_in' => '[detail]', |
|
3511 | + 'show_on_pkg' => $package, |
|
3512 | + 'clabels' => __('Email', 'geodirectory')); |
|
3513 | + |
|
3514 | + $fields[] = array('listing_type' => $post_type, |
|
3515 | + 'data_type' => 'VARCHAR', |
|
3516 | + 'field_type' => 'url', |
|
3517 | + 'admin_title' => __('Website', 'geodirectory'), |
|
3518 | + 'admin_desc' => __('You can enter your business or listing website.', 'geodirectory'), |
|
3519 | + 'site_title' => __('Website', 'geodirectory'), |
|
3520 | + 'htmlvar_name' => 'website', |
|
3521 | + 'default_value' => '', |
|
3522 | + 'option_values' => '', |
|
3523 | + 'is_default' => '1', |
|
3524 | + 'is_admin' => '1', |
|
3525 | + 'show_in' => '[detail]', |
|
3526 | + 'show_on_pkg' => $package, |
|
3527 | + 'clabels' => __('Website', 'geodirectory')); |
|
3528 | + |
|
3529 | + $fields[] = array('listing_type' => $post_type, |
|
3530 | + 'data_type' => 'VARCHAR', |
|
3531 | + 'field_type' => 'url', |
|
3532 | + 'admin_title' => __('Twitter', 'geodirectory'), |
|
3533 | + 'admin_desc' => __('You can enter your business or listing twitter url.', 'geodirectory'), |
|
3534 | + 'site_title' => __('Twitter', 'geodirectory'), |
|
3535 | + 'htmlvar_name' => 'twitter', |
|
3536 | + 'default_value' => '', |
|
3537 | + 'option_values' => '', |
|
3538 | + 'is_default' => '1', |
|
3539 | + 'is_admin' => '1', |
|
3540 | + 'show_in' => '[detail]', |
|
3541 | + 'show_on_pkg' => $package, |
|
3542 | + 'clabels' => __('Twitter', 'geodirectory')); |
|
3543 | + |
|
3544 | + $fields[] = array('listing_type' => $post_type, |
|
3545 | + 'data_type' => 'VARCHAR', |
|
3546 | + 'field_type' => 'url', |
|
3547 | + 'admin_title' => __('Facebook', 'geodirectory'), |
|
3548 | + 'admin_desc' => __('You can enter your business or listing facebook url.', 'geodirectory'), |
|
3549 | + 'site_title' => __('Facebook', 'geodirectory'), |
|
3550 | + 'htmlvar_name' => 'facebook', |
|
3551 | + 'default_value' => '', |
|
3552 | + 'option_values' => '', |
|
3553 | + 'is_default' => '1', |
|
3554 | + 'is_admin' => '1', |
|
3555 | + 'show_in' => '[detail]', |
|
3556 | + 'show_on_pkg' => $package, |
|
3557 | + 'clabels' => __('Facebook', 'geodirectory')); |
|
3558 | + |
|
3559 | + $fields[] = array('listing_type' => $post_type, |
|
3560 | + 'data_type' => 'TEXT', |
|
3561 | + 'field_type' => 'textarea', |
|
3562 | + 'admin_title' => __('Video', 'geodirectory'), |
|
3563 | + 'admin_desc' => __('Add video code here, YouTube etc.', 'geodirectory'), |
|
3564 | + 'site_title' => __('Video', 'geodirectory'), |
|
3565 | + 'htmlvar_name' => 'video', |
|
3566 | + 'default_value' => '', |
|
3567 | + 'option_values' => '', |
|
3568 | + 'is_default' => '0', |
|
3569 | + 'is_admin' => '1', |
|
3570 | + 'show_in' => '[owntab]', |
|
3571 | + 'show_on_pkg' => $package, |
|
3572 | + 'clabels' => __('Video', 'geodirectory')); |
|
3573 | + |
|
3574 | + $fields[] = array('listing_type' => $post_type, |
|
3575 | + 'data_type' => 'TEXT', |
|
3576 | + 'field_type' => 'textarea', |
|
3577 | + 'admin_title' => __('Special Offers', 'geodirectory'), |
|
3578 | + 'admin_desc' => __('Note: List out any special offers (optional)', 'geodirectory'), |
|
3579 | + 'site_title' => __('Special Offers', 'geodirectory'), |
|
3580 | + 'htmlvar_name' => 'special_offers', |
|
3581 | + 'default_value' => '', |
|
3582 | + 'option_values' => '', |
|
3583 | + 'is_default' => '0', |
|
3584 | + 'is_admin' => '1', |
|
3585 | + 'show_in' => '[owntab]', |
|
3586 | + 'show_on_pkg' => $package, |
|
3587 | + 'clabels' => __('Special Offers', 'geodirectory')); |
|
3588 | + |
|
3589 | + /** |
|
3590 | + * Filter the array of default custom fields DB table data. |
|
3591 | + * |
|
3592 | + * @since 1.6.6 |
|
3593 | + * @param string $fields The default custom fields as an array. |
|
3594 | + */ |
|
3595 | + $fields = apply_filters('geodir_default_custom_fields', $fields); |
|
3596 | + |
|
3597 | + return $fields; |
|
3598 | 3598 | } |
3599 | 3599 | |
3600 | 3600 | function geodir_currency_format_number($number='',$cf=''){ |
3601 | 3601 | |
3602 | - $cs = isset($cf['extra_fields']) ? maybe_unserialize($cf['extra_fields']) : ''; |
|
3602 | + $cs = isset($cf['extra_fields']) ? maybe_unserialize($cf['extra_fields']) : ''; |
|
3603 | 3603 | |
3604 | - $symbol = isset($cs['currency_symbol']) ? $cs['currency_symbol'] : '$'; |
|
3605 | - $decimals = isset($cf['decimal_point']) && $cf['decimal_point'] ? $cf['decimal_point'] : 2; |
|
3606 | - $decimal_display = !empty($cf['decimal_display']) ? $cf['decimal_display'] : (!empty($cs['decimal_display']) ? $cs['decimal_display'] : 'if'); |
|
3607 | - $decimalpoint = '.'; |
|
3604 | + $symbol = isset($cs['currency_symbol']) ? $cs['currency_symbol'] : '$'; |
|
3605 | + $decimals = isset($cf['decimal_point']) && $cf['decimal_point'] ? $cf['decimal_point'] : 2; |
|
3606 | + $decimal_display = !empty($cf['decimal_display']) ? $cf['decimal_display'] : (!empty($cs['decimal_display']) ? $cs['decimal_display'] : 'if'); |
|
3607 | + $decimalpoint = '.'; |
|
3608 | 3608 | |
3609 | - if(isset($cs['decimal_separator']) && $cs['decimal_separator']=='comma'){ |
|
3610 | - $decimalpoint = ','; |
|
3611 | - } |
|
3609 | + if(isset($cs['decimal_separator']) && $cs['decimal_separator']=='comma'){ |
|
3610 | + $decimalpoint = ','; |
|
3611 | + } |
|
3612 | 3612 | |
3613 | - $separator = ','; |
|
3613 | + $separator = ','; |
|
3614 | 3614 | |
3615 | - if(isset($cs['thousand_separator'])){ |
|
3616 | - if($cs['thousand_separator']=='comma'){$separator = ',';} |
|
3617 | - if($cs['thousand_separator']=='slash'){$separator = '\\';} |
|
3618 | - if($cs['thousand_separator']=='period'){$separator = '.';} |
|
3619 | - if($cs['thousand_separator']=='space'){$separator = ' ';} |
|
3620 | - if($cs['thousand_separator']=='none'){$separator = '';} |
|
3621 | - } |
|
3615 | + if(isset($cs['thousand_separator'])){ |
|
3616 | + if($cs['thousand_separator']=='comma'){$separator = ',';} |
|
3617 | + if($cs['thousand_separator']=='slash'){$separator = '\\';} |
|
3618 | + if($cs['thousand_separator']=='period'){$separator = '.';} |
|
3619 | + if($cs['thousand_separator']=='space'){$separator = ' ';} |
|
3620 | + if($cs['thousand_separator']=='none'){$separator = '';} |
|
3621 | + } |
|
3622 | 3622 | |
3623 | - $currency_symbol_placement = isset($cs['currency_symbol_placement']) ? $cs['currency_symbol_placement'] : 'left'; |
|
3623 | + $currency_symbol_placement = isset($cs['currency_symbol_placement']) ? $cs['currency_symbol_placement'] : 'left'; |
|
3624 | 3624 | |
3625 | - if($decimals>0 && $decimal_display=='if'){ |
|
3626 | - if(is_int($number) || floor( $number ) == $number) |
|
3627 | - $decimals = 0; |
|
3628 | - } |
|
3625 | + if($decimals>0 && $decimal_display=='if'){ |
|
3626 | + if(is_int($number) || floor( $number ) == $number) |
|
3627 | + $decimals = 0; |
|
3628 | + } |
|
3629 | 3629 | |
3630 | - $number = number_format($number,$decimals,$decimalpoint,$separator); |
|
3630 | + $number = number_format($number,$decimals,$decimalpoint,$separator); |
|
3631 | 3631 | |
3632 | 3632 | |
3633 | 3633 | |
3634 | - if($currency_symbol_placement=='left'){ |
|
3635 | - $number = $symbol . $number; |
|
3636 | - }else{ |
|
3637 | - $number = $number . $symbol; |
|
3638 | - } |
|
3634 | + if($currency_symbol_placement=='left'){ |
|
3635 | + $number = $symbol . $number; |
|
3636 | + }else{ |
|
3637 | + $number = $number . $symbol; |
|
3638 | + } |
|
3639 | 3639 | |
3640 | 3640 | |
3641 | 3641 | return $number; |