@@ -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,54 +1173,54 @@ 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 | |
1203 | 1203 | function geodir_get_cf_value($cf){ |
1204 | - global $gd_session; |
|
1205 | - $value = ''; |
|
1206 | - if (is_admin()) { |
|
1207 | - global $post,$gd_session; |
|
1208 | - |
|
1209 | - if (isset($_REQUEST['post'])) |
|
1210 | - $_REQUEST['pid'] = $_REQUEST['post']; |
|
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 | - return $value; |
|
1204 | + global $gd_session; |
|
1205 | + $value = ''; |
|
1206 | + if (is_admin()) { |
|
1207 | + global $post,$gd_session; |
|
1208 | + |
|
1209 | + if (isset($_REQUEST['post'])) |
|
1210 | + $_REQUEST['pid'] = $_REQUEST['post']; |
|
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 | + return $value; |
|
1224 | 1224 | } |
1225 | 1225 | |
1226 | 1226 | /** |
@@ -1239,422 +1239,422 @@ discard block |
||
1239 | 1239 | * @param string $post_type Optional. The wordpress post type. |
1240 | 1240 | */ |
1241 | 1241 | function geodir_get_custom_fields_html($package_id = '', $default = 'custom', $post_type = 'gd_place') { |
1242 | - global $is_default, $mapzoom, $gd_session; |
|
1242 | + global $is_default, $mapzoom, $gd_session; |
|
1243 | 1243 | |
1244 | - $listing_type = $post_type; |
|
1244 | + $listing_type = $post_type; |
|
1245 | 1245 | |
1246 | - $custom_fields = geodir_post_custom_fields($package_id, $default, $post_type); |
|
1246 | + $custom_fields = geodir_post_custom_fields($package_id, $default, $post_type); |
|
1247 | 1247 | |
1248 | - foreach ($custom_fields as $key => $val) { |
|
1249 | - if(isset($val['extra_fields'])){$extra_fields = $val['extra_fields'];} |
|
1250 | - $val = stripslashes_deep($val); // strip slashes from labels |
|
1251 | - if(isset($val['extra_fields'])){$val['extra_fields'] = $extra_fields;} |
|
1248 | + foreach ($custom_fields as $key => $val) { |
|
1249 | + if(isset($val['extra_fields'])){$extra_fields = $val['extra_fields'];} |
|
1250 | + $val = stripslashes_deep($val); // strip slashes from labels |
|
1251 | + if(isset($val['extra_fields'])){$val['extra_fields'] = $extra_fields;} |
|
1252 | 1252 | |
1253 | - $name = $val['name']; |
|
1254 | - $type = $val['type']; |
|
1255 | - $is_default = $val['is_default']; |
|
1253 | + $name = $val['name']; |
|
1254 | + $type = $val['type']; |
|
1255 | + $is_default = $val['is_default']; |
|
1256 | 1256 | |
1257 | - /* field available to site admin only for edit */ |
|
1258 | - $for_admin_use = isset($val['for_admin_use']) && (int)$val['for_admin_use'] == 1 ? true : false; |
|
1259 | - if ($for_admin_use && !is_super_admin()) { |
|
1260 | - continue; |
|
1261 | - } |
|
1257 | + /* field available to site admin only for edit */ |
|
1258 | + $for_admin_use = isset($val['for_admin_use']) && (int)$val['for_admin_use'] == 1 ? true : false; |
|
1259 | + if ($for_admin_use && !is_super_admin()) { |
|
1260 | + continue; |
|
1261 | + } |
|
1262 | 1262 | |
1263 | - if (is_admin()) { |
|
1264 | - global $post; |
|
1263 | + if (is_admin()) { |
|
1264 | + global $post; |
|
1265 | 1265 | |
1266 | - if (isset($_REQUEST['post'])) |
|
1267 | - $_REQUEST['pid'] = $_REQUEST['post']; |
|
1268 | - } |
|
1266 | + if (isset($_REQUEST['post'])) |
|
1267 | + $_REQUEST['pid'] = $_REQUEST['post']; |
|
1268 | + } |
|
1269 | 1269 | |
1270 | 1270 | |
1271 | 1271 | |
1272 | - /** |
|
1273 | - * Called before the custom fields info is output for submitting a post. |
|
1274 | - * |
|
1275 | - * Used dynamic hook type geodir_before_custom_form_field_$name. |
|
1276 | - * |
|
1277 | - * @since 1.0.0 |
|
1278 | - * @param string $listing_type The post post type. |
|
1279 | - * @param int $package_id The price package ID for the post. |
|
1280 | - * @param array $val The settings array for the field. {@see geodir_custom_field_save()}. |
|
1281 | - * @see 'geodir_after_custom_form_field_$name' |
|
1282 | - */ |
|
1283 | - do_action('geodir_before_custom_form_field_' . $name, $listing_type, $package_id, $val); |
|
1284 | - |
|
1285 | - |
|
1286 | - $custom_field = $val; |
|
1287 | - $html =''; |
|
1288 | - /** |
|
1289 | - * Filter the output for custom fields. |
|
1290 | - * |
|
1291 | - * Here we can remove or add new functions depending on the field type. |
|
1292 | - * |
|
1293 | - * @param string $html The html to be filtered (blank). |
|
1294 | - * @param array $custom_field The custom field array values. |
|
1295 | - */ |
|
1296 | - echo apply_filters("geodir_custom_field_input_{$type}",$html,$custom_field); |
|
1297 | - |
|
1298 | - |
|
1299 | - |
|
1300 | - /** |
|
1301 | - * Called after the custom fields info is output for submitting a post. |
|
1302 | - * |
|
1303 | - * Used dynamic hook type geodir_after_custom_form_field_$name. |
|
1304 | - * |
|
1305 | - * @since 1.0.0 |
|
1306 | - * @param string $listing_type The post post type. |
|
1307 | - * @param int $package_id The price package ID for the post. |
|
1308 | - * @param array $val The settings array for the field. {@see geodir_custom_field_save()}. |
|
1309 | - * @see 'geodir_before_custom_form_field_$name' |
|
1310 | - */ |
|
1311 | - do_action('geodir_after_custom_form_field_' . $name, $listing_type, $package_id, $val); |
|
1312 | - |
|
1313 | - } |
|
1272 | + /** |
|
1273 | + * Called before the custom fields info is output for submitting a post. |
|
1274 | + * |
|
1275 | + * Used dynamic hook type geodir_before_custom_form_field_$name. |
|
1276 | + * |
|
1277 | + * @since 1.0.0 |
|
1278 | + * @param string $listing_type The post post type. |
|
1279 | + * @param int $package_id The price package ID for the post. |
|
1280 | + * @param array $val The settings array for the field. {@see geodir_custom_field_save()}. |
|
1281 | + * @see 'geodir_after_custom_form_field_$name' |
|
1282 | + */ |
|
1283 | + do_action('geodir_before_custom_form_field_' . $name, $listing_type, $package_id, $val); |
|
1284 | + |
|
1285 | + |
|
1286 | + $custom_field = $val; |
|
1287 | + $html =''; |
|
1288 | + /** |
|
1289 | + * Filter the output for custom fields. |
|
1290 | + * |
|
1291 | + * Here we can remove or add new functions depending on the field type. |
|
1292 | + * |
|
1293 | + * @param string $html The html to be filtered (blank). |
|
1294 | + * @param array $custom_field The custom field array values. |
|
1295 | + */ |
|
1296 | + echo apply_filters("geodir_custom_field_input_{$type}",$html,$custom_field); |
|
1297 | + |
|
1298 | + |
|
1299 | + |
|
1300 | + /** |
|
1301 | + * Called after the custom fields info is output for submitting a post. |
|
1302 | + * |
|
1303 | + * Used dynamic hook type geodir_after_custom_form_field_$name. |
|
1304 | + * |
|
1305 | + * @since 1.0.0 |
|
1306 | + * @param string $listing_type The post post type. |
|
1307 | + * @param int $package_id The price package ID for the post. |
|
1308 | + * @param array $val The settings array for the field. {@see geodir_custom_field_save()}. |
|
1309 | + * @see 'geodir_before_custom_form_field_$name' |
|
1310 | + */ |
|
1311 | + do_action('geodir_after_custom_form_field_' . $name, $listing_type, $package_id, $val); |
|
1312 | + |
|
1313 | + } |
|
1314 | 1314 | |
1315 | 1315 | } |
1316 | 1316 | |
1317 | 1317 | |
1318 | 1318 | if (!function_exists('geodir_get_field_infoby')) { |
1319 | - /** |
|
1320 | - * Get custom field using key and value. |
|
1321 | - * |
|
1322 | - * @since 1.0.0 |
|
1323 | - * @package GeoDirectory |
|
1324 | - * @global object $wpdb WordPress Database object. |
|
1325 | - * @param string $key The key you want to look for. |
|
1326 | - * @param string $value The value of the key you want to look for. |
|
1327 | - * @param string $geodir_post_type The post type. |
|
1328 | - * @return bool|mixed Returns field info when available. otherwise returns false. |
|
1329 | - */ |
|
1330 | - function geodir_get_field_infoby($key = '', $value = '', $geodir_post_type = '') |
|
1331 | - { |
|
1332 | - |
|
1333 | - global $wpdb; |
|
1334 | - |
|
1335 | - $filter = $wpdb->get_row( |
|
1336 | - $wpdb->prepare( |
|
1337 | - "SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND " . $key . "='" . $value . "'", |
|
1338 | - array($geodir_post_type) |
|
1339 | - ) |
|
1340 | - ); |
|
1341 | - |
|
1342 | - if ($filter) { |
|
1343 | - return $filter; |
|
1344 | - } else { |
|
1345 | - return false; |
|
1346 | - } |
|
1347 | - |
|
1348 | - } |
|
1319 | + /** |
|
1320 | + * Get custom field using key and value. |
|
1321 | + * |
|
1322 | + * @since 1.0.0 |
|
1323 | + * @package GeoDirectory |
|
1324 | + * @global object $wpdb WordPress Database object. |
|
1325 | + * @param string $key The key you want to look for. |
|
1326 | + * @param string $value The value of the key you want to look for. |
|
1327 | + * @param string $geodir_post_type The post type. |
|
1328 | + * @return bool|mixed Returns field info when available. otherwise returns false. |
|
1329 | + */ |
|
1330 | + function geodir_get_field_infoby($key = '', $value = '', $geodir_post_type = '') |
|
1331 | + { |
|
1332 | + |
|
1333 | + global $wpdb; |
|
1334 | + |
|
1335 | + $filter = $wpdb->get_row( |
|
1336 | + $wpdb->prepare( |
|
1337 | + "SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND " . $key . "='" . $value . "'", |
|
1338 | + array($geodir_post_type) |
|
1339 | + ) |
|
1340 | + ); |
|
1341 | + |
|
1342 | + if ($filter) { |
|
1343 | + return $filter; |
|
1344 | + } else { |
|
1345 | + return false; |
|
1346 | + } |
|
1347 | + |
|
1348 | + } |
|
1349 | 1349 | } |
1350 | 1350 | |
1351 | 1351 | |
1352 | 1352 | function geodir_field_icon_proccess($cf){ |
1353 | 1353 | |
1354 | 1354 | |
1355 | - if (strpos($cf['field_icon'], 'http') !== false) { |
|
1356 | - $field_icon = ' background: url(' . $cf['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;'; |
|
1357 | - } elseif (strpos($cf['field_icon'], 'fa fa-') !== false) { |
|
1358 | - $field_icon = '<i class="' . $cf['field_icon'] . '"></i>'; |
|
1359 | - }else{ |
|
1360 | - $field_icon = $cf['field_icon']; |
|
1361 | - } |
|
1355 | + if (strpos($cf['field_icon'], 'http') !== false) { |
|
1356 | + $field_icon = ' background: url(' . $cf['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;'; |
|
1357 | + } elseif (strpos($cf['field_icon'], 'fa fa-') !== false) { |
|
1358 | + $field_icon = '<i class="' . $cf['field_icon'] . '"></i>'; |
|
1359 | + }else{ |
|
1360 | + $field_icon = $cf['field_icon']; |
|
1361 | + } |
|
1362 | 1362 | |
1363 | - return $field_icon; |
|
1363 | + return $field_icon; |
|
1364 | 1364 | } |
1365 | 1365 | |
1366 | 1366 | if (!function_exists('geodir_show_listing_info')) { |
1367 | - /** |
|
1368 | - * Show listing info depending on field location. |
|
1369 | - * |
|
1370 | - * @since 1.0.0 |
|
1371 | - * @since 1.5.7 Custom fields option values added to db translation. |
|
1372 | - * Changes to display url fields title. |
|
1373 | - * @package GeoDirectory |
|
1374 | - * @global object $wpdb WordPress Database object. |
|
1375 | - * @global object $post The current post object. |
|
1376 | - * @global bool $send_to_friend True if send to friend link already rendered. Otherwise false. |
|
1377 | - * |
|
1378 | - * @param string $fields_location In which page you are going to place this custom fields?. Ex: listing, detail etc. |
|
1379 | - * @return string Returns listing info html. |
|
1380 | - */ |
|
1381 | - function geodir_show_listing_info($fields_location = '') { |
|
1382 | - global $post, $preview, $wpdb, $send_to_friend; |
|
1383 | - |
|
1384 | - $package_info = array(); |
|
1385 | - |
|
1386 | - $package_info = geodir_post_package_info($package_info, $post); |
|
1387 | - $post_package_id = !empty($package_info->pid) ? $package_info->pid : ''; |
|
1388 | - $p_type = !empty($post->post_type) ? $post->post_type : geodir_get_current_posttype(); |
|
1389 | - $send_to_friend = false; |
|
1390 | - |
|
1391 | - ob_start(); |
|
1392 | - $fields_info = geodir_post_custom_fields($post_package_id, 'all', $p_type, $fields_location); |
|
1393 | - |
|
1394 | - if (!empty($fields_info)) { |
|
1395 | - $post = stripslashes_deep($post); // strip slashes |
|
1367 | + /** |
|
1368 | + * Show listing info depending on field location. |
|
1369 | + * |
|
1370 | + * @since 1.0.0 |
|
1371 | + * @since 1.5.7 Custom fields option values added to db translation. |
|
1372 | + * Changes to display url fields title. |
|
1373 | + * @package GeoDirectory |
|
1374 | + * @global object $wpdb WordPress Database object. |
|
1375 | + * @global object $post The current post object. |
|
1376 | + * @global bool $send_to_friend True if send to friend link already rendered. Otherwise false. |
|
1377 | + * |
|
1378 | + * @param string $fields_location In which page you are going to place this custom fields?. Ex: listing, detail etc. |
|
1379 | + * @return string Returns listing info html. |
|
1380 | + */ |
|
1381 | + function geodir_show_listing_info($fields_location = '') { |
|
1382 | + global $post, $preview, $wpdb, $send_to_friend; |
|
1383 | + |
|
1384 | + $package_info = array(); |
|
1385 | + |
|
1386 | + $package_info = geodir_post_package_info($package_info, $post); |
|
1387 | + $post_package_id = !empty($package_info->pid) ? $package_info->pid : ''; |
|
1388 | + $p_type = !empty($post->post_type) ? $post->post_type : geodir_get_current_posttype(); |
|
1389 | + $send_to_friend = false; |
|
1390 | + |
|
1391 | + ob_start(); |
|
1392 | + $fields_info = geodir_post_custom_fields($post_package_id, 'all', $p_type, $fields_location); |
|
1393 | + |
|
1394 | + if (!empty($fields_info)) { |
|
1395 | + $post = stripslashes_deep($post); // strip slashes |
|
1396 | 1396 | |
1397 | - //echo '<div class="geodir-company_info field-group">'; |
|
1398 | - global $field_set_start; |
|
1399 | - $field_set_start = 0; |
|
1400 | - |
|
1401 | - |
|
1402 | - |
|
1403 | - foreach ($fields_info as $type) { |
|
1404 | - if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];} |
|
1405 | - $type = stripslashes_deep($type); // strip slashes |
|
1406 | - if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;} |
|
1407 | - $html = ''; |
|
1408 | - $field_icon = geodir_field_icon_proccess($type); |
|
1409 | - $filed_type = $type['type']; |
|
1410 | - $html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : ''; |
|
1411 | - if($html_var=='post'){$html_var='post_address';} |
|
1412 | - |
|
1413 | - /** |
|
1414 | - * Filter the output for custom fields. |
|
1415 | - * |
|
1416 | - * Here we can remove or add new functions depending on the field type. |
|
1417 | - * |
|
1418 | - * @param string $html The html to be filtered (blank). |
|
1419 | - * @param string $fields_location The location the field is to be show. |
|
1420 | - * @param array $type The array of field values. |
|
1421 | - */ |
|
1422 | - $html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type); |
|
1423 | - |
|
1424 | - $variables_array = array(); |
|
1425 | - |
|
1426 | - |
|
1427 | - if ($type['type'] != 'fieldset'): |
|
1428 | - $variables_array['post_id'] = $post->ID; |
|
1429 | - $variables_array['label'] = __($type['site_title'], 'geodirectory'); |
|
1430 | - $variables_array['value'] = ''; |
|
1431 | - if (isset($post->{$type['htmlvar_name']})) |
|
1432 | - $variables_array['value'] = $post->{$type['htmlvar_name']}; |
|
1433 | - endif; |
|
1434 | - |
|
1435 | - |
|
1436 | - if ($html): |
|
1437 | - |
|
1438 | - /** |
|
1439 | - * Called before a custom fields is output on the frontend. |
|
1440 | - * |
|
1441 | - * @since 1.0.0 |
|
1442 | - * @param string $html_var The HTML variable name for the field. |
|
1443 | - */ |
|
1444 | - do_action("geodir_before_show_{$html_var}"); |
|
1445 | - /** |
|
1446 | - * Filter custom field output. |
|
1447 | - * |
|
1448 | - * @since 1.0.0 |
|
1449 | - * |
|
1450 | - * @param string $html_var The HTML variable name for the field. |
|
1451 | - * @param string $html Custom field unfiltered HTML. |
|
1452 | - * @param array $variables_array Custom field variables array. |
|
1453 | - */ |
|
1454 | - if ($html) echo apply_filters("geodir_show_{$html_var}", $html, $variables_array); |
|
1455 | - |
|
1456 | - /** |
|
1457 | - * Called after a custom fields is output on the frontend. |
|
1458 | - * |
|
1459 | - * @since 1.0.0 |
|
1460 | - * @param string $html_var The HTML variable name for the field. |
|
1461 | - */ |
|
1462 | - do_action("geodir_after_show_{$html_var}"); |
|
1463 | - |
|
1464 | - endif; |
|
1465 | - |
|
1466 | - } |
|
1467 | - |
|
1468 | - //echo '</div>'; |
|
1469 | - |
|
1470 | - } |
|
1471 | - |
|
1472 | - |
|
1473 | - $html = ob_get_clean(); |
|
1474 | - |
|
1475 | - /** |
|
1476 | - * Filter the custom fields over all output. |
|
1477 | - * |
|
1478 | - * @param string $html The html of the custom fields. |
|
1479 | - * @param string $fields_location The location the fields are being output. |
|
1480 | - * @since 1.6.9 |
|
1481 | - */ |
|
1482 | - return apply_filters('geodir_show_listing_info',$html,$fields_location); |
|
1483 | - |
|
1484 | - } |
|
1397 | + //echo '<div class="geodir-company_info field-group">'; |
|
1398 | + global $field_set_start; |
|
1399 | + $field_set_start = 0; |
|
1400 | + |
|
1401 | + |
|
1402 | + |
|
1403 | + foreach ($fields_info as $type) { |
|
1404 | + if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];} |
|
1405 | + $type = stripslashes_deep($type); // strip slashes |
|
1406 | + if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;} |
|
1407 | + $html = ''; |
|
1408 | + $field_icon = geodir_field_icon_proccess($type); |
|
1409 | + $filed_type = $type['type']; |
|
1410 | + $html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : ''; |
|
1411 | + if($html_var=='post'){$html_var='post_address';} |
|
1412 | + |
|
1413 | + /** |
|
1414 | + * Filter the output for custom fields. |
|
1415 | + * |
|
1416 | + * Here we can remove or add new functions depending on the field type. |
|
1417 | + * |
|
1418 | + * @param string $html The html to be filtered (blank). |
|
1419 | + * @param string $fields_location The location the field is to be show. |
|
1420 | + * @param array $type The array of field values. |
|
1421 | + */ |
|
1422 | + $html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type); |
|
1423 | + |
|
1424 | + $variables_array = array(); |
|
1425 | + |
|
1426 | + |
|
1427 | + if ($type['type'] != 'fieldset'): |
|
1428 | + $variables_array['post_id'] = $post->ID; |
|
1429 | + $variables_array['label'] = __($type['site_title'], 'geodirectory'); |
|
1430 | + $variables_array['value'] = ''; |
|
1431 | + if (isset($post->{$type['htmlvar_name']})) |
|
1432 | + $variables_array['value'] = $post->{$type['htmlvar_name']}; |
|
1433 | + endif; |
|
1434 | + |
|
1435 | + |
|
1436 | + if ($html): |
|
1437 | + |
|
1438 | + /** |
|
1439 | + * Called before a custom fields is output on the frontend. |
|
1440 | + * |
|
1441 | + * @since 1.0.0 |
|
1442 | + * @param string $html_var The HTML variable name for the field. |
|
1443 | + */ |
|
1444 | + do_action("geodir_before_show_{$html_var}"); |
|
1445 | + /** |
|
1446 | + * Filter custom field output. |
|
1447 | + * |
|
1448 | + * @since 1.0.0 |
|
1449 | + * |
|
1450 | + * @param string $html_var The HTML variable name for the field. |
|
1451 | + * @param string $html Custom field unfiltered HTML. |
|
1452 | + * @param array $variables_array Custom field variables array. |
|
1453 | + */ |
|
1454 | + if ($html) echo apply_filters("geodir_show_{$html_var}", $html, $variables_array); |
|
1455 | + |
|
1456 | + /** |
|
1457 | + * Called after a custom fields is output on the frontend. |
|
1458 | + * |
|
1459 | + * @since 1.0.0 |
|
1460 | + * @param string $html_var The HTML variable name for the field. |
|
1461 | + */ |
|
1462 | + do_action("geodir_after_show_{$html_var}"); |
|
1463 | + |
|
1464 | + endif; |
|
1465 | + |
|
1466 | + } |
|
1467 | + |
|
1468 | + //echo '</div>'; |
|
1469 | + |
|
1470 | + } |
|
1471 | + |
|
1472 | + |
|
1473 | + $html = ob_get_clean(); |
|
1474 | + |
|
1475 | + /** |
|
1476 | + * Filter the custom fields over all output. |
|
1477 | + * |
|
1478 | + * @param string $html The html of the custom fields. |
|
1479 | + * @param string $fields_location The location the fields are being output. |
|
1480 | + * @since 1.6.9 |
|
1481 | + */ |
|
1482 | + return apply_filters('geodir_show_listing_info',$html,$fields_location); |
|
1483 | + |
|
1484 | + } |
|
1485 | 1485 | } |
1486 | 1486 | |
1487 | 1487 | if (!function_exists('geodir_default_date_format')) { |
1488 | - /** |
|
1489 | - * Returns default date format. |
|
1490 | - * |
|
1491 | - * @since 1.0.0 |
|
1492 | - * @package GeoDirectory |
|
1493 | - * @return mixed|string|void Returns default date format. |
|
1494 | - */ |
|
1495 | - function geodir_default_date_format() |
|
1496 | - { |
|
1497 | - if ($format = get_option('date_format')) |
|
1498 | - return $format; |
|
1499 | - else |
|
1500 | - return 'dd-mm-yy'; |
|
1501 | - } |
|
1488 | + /** |
|
1489 | + * Returns default date format. |
|
1490 | + * |
|
1491 | + * @since 1.0.0 |
|
1492 | + * @package GeoDirectory |
|
1493 | + * @return mixed|string|void Returns default date format. |
|
1494 | + */ |
|
1495 | + function geodir_default_date_format() |
|
1496 | + { |
|
1497 | + if ($format = get_option('date_format')) |
|
1498 | + return $format; |
|
1499 | + else |
|
1500 | + return 'dd-mm-yy'; |
|
1501 | + } |
|
1502 | 1502 | } |
1503 | 1503 | |
1504 | 1504 | if (!function_exists('geodir_get_formated_date')) { |
1505 | - /** |
|
1506 | - * Returns formatted date. |
|
1507 | - * |
|
1508 | - * @since 1.0.0 |
|
1509 | - * @package GeoDirectory |
|
1510 | - * @param string $date Date string to convert. |
|
1511 | - * @return bool|int|string Returns formatted date. |
|
1512 | - */ |
|
1513 | - function geodir_get_formated_date($date) |
|
1514 | - { |
|
1515 | - return mysql2date(get_option('date_format'), $date); |
|
1516 | - } |
|
1505 | + /** |
|
1506 | + * Returns formatted date. |
|
1507 | + * |
|
1508 | + * @since 1.0.0 |
|
1509 | + * @package GeoDirectory |
|
1510 | + * @param string $date Date string to convert. |
|
1511 | + * @return bool|int|string Returns formatted date. |
|
1512 | + */ |
|
1513 | + function geodir_get_formated_date($date) |
|
1514 | + { |
|
1515 | + return mysql2date(get_option('date_format'), $date); |
|
1516 | + } |
|
1517 | 1517 | } |
1518 | 1518 | |
1519 | 1519 | if (!function_exists('geodir_get_formated_time')) { |
1520 | - /** |
|
1521 | - * Returns formatted time. |
|
1522 | - * |
|
1523 | - * @since 1.0.0 |
|
1524 | - * @package GeoDirectory |
|
1525 | - * @param string $time Time string to convert. |
|
1526 | - * @return bool|int|string Returns formatted time. |
|
1527 | - */ |
|
1528 | - function geodir_get_formated_time($time) |
|
1529 | - { |
|
1530 | - return mysql2date(get_option('time_format'), $time, $translate = true); |
|
1531 | - } |
|
1520 | + /** |
|
1521 | + * Returns formatted time. |
|
1522 | + * |
|
1523 | + * @since 1.0.0 |
|
1524 | + * @package GeoDirectory |
|
1525 | + * @param string $time Time string to convert. |
|
1526 | + * @return bool|int|string Returns formatted time. |
|
1527 | + */ |
|
1528 | + function geodir_get_formated_time($time) |
|
1529 | + { |
|
1530 | + return mysql2date(get_option('time_format'), $time, $translate = true); |
|
1531 | + } |
|
1532 | 1532 | } |
1533 | 1533 | |
1534 | 1534 | |
1535 | 1535 | if (!function_exists('geodir_save_post_file_fields')) { |
1536 | - /** |
|
1537 | - * Save post file fields |
|
1538 | - * |
|
1539 | - * @since 1.0.0 |
|
1540 | - * @since 1.4.7 Added `$extra_fields` parameter. |
|
1541 | - * @package GeoDirectory |
|
1542 | - * @global object $wpdb WordPress Database object. |
|
1543 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
1544 | - * @global object $current_user Current user object. |
|
1545 | - * @param int $post_id |
|
1546 | - * @param string $field_id |
|
1547 | - * @param array $post_image |
|
1548 | - * @param array $extra_fields Array of extra fields. |
|
1549 | - */ |
|
1550 | - function geodir_save_post_file_fields($post_id = 0, $field_id = '', $post_image = array(), $extra_fields = array()) |
|
1551 | - { |
|
1536 | + /** |
|
1537 | + * Save post file fields |
|
1538 | + * |
|
1539 | + * @since 1.0.0 |
|
1540 | + * @since 1.4.7 Added `$extra_fields` parameter. |
|
1541 | + * @package GeoDirectory |
|
1542 | + * @global object $wpdb WordPress Database object. |
|
1543 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
1544 | + * @global object $current_user Current user object. |
|
1545 | + * @param int $post_id |
|
1546 | + * @param string $field_id |
|
1547 | + * @param array $post_image |
|
1548 | + * @param array $extra_fields Array of extra fields. |
|
1549 | + */ |
|
1550 | + function geodir_save_post_file_fields($post_id = 0, $field_id = '', $post_image = array(), $extra_fields = array()) |
|
1551 | + { |
|
1552 | 1552 | |
1553 | - global $wpdb, $plugin_prefix, $current_user; |
|
1553 | + global $wpdb, $plugin_prefix, $current_user; |
|
1554 | 1554 | |
1555 | - $post_type = get_post_type($post_id); |
|
1556 | - //echo $field_id; exit; |
|
1557 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
1555 | + $post_type = get_post_type($post_id); |
|
1556 | + //echo $field_id; exit; |
|
1557 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
1558 | 1558 | |
1559 | - $postcurr_images = array(); |
|
1560 | - $postcurr_images = geodir_get_post_meta($post_id, $field_id, true); |
|
1561 | - $file_urls = ''; |
|
1559 | + $postcurr_images = array(); |
|
1560 | + $postcurr_images = geodir_get_post_meta($post_id, $field_id, true); |
|
1561 | + $file_urls = ''; |
|
1562 | 1562 | |
1563 | - if (!empty($post_image)) { |
|
1563 | + if (!empty($post_image)) { |
|
1564 | 1564 | |
1565 | - $invalid_files = array(); |
|
1565 | + $invalid_files = array(); |
|
1566 | 1566 | |
1567 | - //Get and remove all old images of post from database to set by new order |
|
1568 | - $geodir_uploaddir = ''; |
|
1569 | - $uploads = wp_upload_dir(); |
|
1570 | - $uploads_dir = $uploads['path']; |
|
1567 | + //Get and remove all old images of post from database to set by new order |
|
1568 | + $geodir_uploaddir = ''; |
|
1569 | + $uploads = wp_upload_dir(); |
|
1570 | + $uploads_dir = $uploads['path']; |
|
1571 | 1571 | |
1572 | - $geodir_uploadpath = $uploads['path']; |
|
1573 | - $geodir_uploadurl = $uploads['url']; |
|
1574 | - $sub_dir = $uploads['subdir']; |
|
1572 | + $geodir_uploadpath = $uploads['path']; |
|
1573 | + $geodir_uploadurl = $uploads['url']; |
|
1574 | + $sub_dir = $uploads['subdir']; |
|
1575 | 1575 | |
1576 | - $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'] : ''; |
|
1576 | + $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'] : ''; |
|
1577 | 1577 | |
1578 | - for ($m = 0; $m < count($post_image); $m++) { |
|
1578 | + for ($m = 0; $m < count($post_image); $m++) { |
|
1579 | 1579 | |
1580 | - /* --------- start ------- */ |
|
1580 | + /* --------- start ------- */ |
|
1581 | 1581 | |
1582 | - 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)))) { |
|
1582 | + 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)))) { |
|
1583 | 1583 | |
1584 | 1584 | |
1585 | - $curr_img_url = $post_image[$m]; |
|
1586 | - $image_name_arr = explode('/', $curr_img_url); |
|
1587 | - $curr_img_dir = $image_name_arr[count($image_name_arr) - 2]; |
|
1588 | - $filename = end($image_name_arr); |
|
1589 | - $img_name_arr = explode('.', $filename); |
|
1585 | + $curr_img_url = $post_image[$m]; |
|
1586 | + $image_name_arr = explode('/', $curr_img_url); |
|
1587 | + $curr_img_dir = $image_name_arr[count($image_name_arr) - 2]; |
|
1588 | + $filename = end($image_name_arr); |
|
1589 | + $img_name_arr = explode('.', $filename); |
|
1590 | 1590 | |
1591 | - $arr_file_type = wp_check_filetype($filename); |
|
1591 | + $arr_file_type = wp_check_filetype($filename); |
|
1592 | 1592 | |
1593 | - if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) { |
|
1594 | - continue; |
|
1595 | - } |
|
1593 | + if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) { |
|
1594 | + continue; |
|
1595 | + } |
|
1596 | 1596 | |
1597 | - $uploaded_file_type = $arr_file_type['type']; |
|
1598 | - $uploaded_file_ext = $arr_file_type['ext']; |
|
1597 | + $uploaded_file_type = $arr_file_type['type']; |
|
1598 | + $uploaded_file_ext = $arr_file_type['ext']; |
|
1599 | 1599 | |
1600 | - if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) { |
|
1601 | - continue; // Invalid file type. |
|
1602 | - } |
|
1600 | + if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) { |
|
1601 | + continue; // Invalid file type. |
|
1602 | + } |
|
1603 | 1603 | |
1604 | - // Set an array containing a list of acceptable formats |
|
1605 | - //$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'); |
|
1604 | + // Set an array containing a list of acceptable formats |
|
1605 | + //$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'); |
|
1606 | 1606 | |
1607 | - if (!function_exists('wp_handle_upload')) |
|
1608 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
1607 | + if (!function_exists('wp_handle_upload')) |
|
1608 | + require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
1609 | 1609 | |
1610 | - if (!is_dir($geodir_uploadpath)) |
|
1611 | - mkdir($geodir_uploadpath); |
|
1610 | + if (!is_dir($geodir_uploadpath)) |
|
1611 | + mkdir($geodir_uploadpath); |
|
1612 | 1612 | |
1613 | - $new_name = $post_id . '_' . $field_id . '_' . $img_name_arr[0] . '.' . $img_name_arr[1]; |
|
1614 | - $explode_sub_dir = explode("/", $sub_dir); |
|
1615 | - if ($curr_img_dir == end($explode_sub_dir)) { |
|
1616 | - $img_path = $geodir_uploadpath . '/' . $filename; |
|
1617 | - $img_url = $geodir_uploadurl . '/' . $filename; |
|
1618 | - } else { |
|
1619 | - $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
1620 | - $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
1621 | - } |
|
1613 | + $new_name = $post_id . '_' . $field_id . '_' . $img_name_arr[0] . '.' . $img_name_arr[1]; |
|
1614 | + $explode_sub_dir = explode("/", $sub_dir); |
|
1615 | + if ($curr_img_dir == end($explode_sub_dir)) { |
|
1616 | + $img_path = $geodir_uploadpath . '/' . $filename; |
|
1617 | + $img_url = $geodir_uploadurl . '/' . $filename; |
|
1618 | + } else { |
|
1619 | + $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
1620 | + $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
1621 | + } |
|
1622 | 1622 | |
1623 | - $uploaded_file = ''; |
|
1624 | - if (file_exists($img_path)) |
|
1625 | - $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name); |
|
1623 | + $uploaded_file = ''; |
|
1624 | + if (file_exists($img_path)) |
|
1625 | + $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name); |
|
1626 | 1626 | |
1627 | - if ($curr_img_dir != $geodir_uploaddir) { |
|
1628 | - if (file_exists($img_path)) |
|
1629 | - unlink($img_path); |
|
1630 | - } |
|
1627 | + if ($curr_img_dir != $geodir_uploaddir) { |
|
1628 | + if (file_exists($img_path)) |
|
1629 | + unlink($img_path); |
|
1630 | + } |
|
1631 | 1631 | |
1632 | - if (!empty($uploaded_file)) |
|
1633 | - $file_urls = $geodir_uploadurl . '/' . $new_name; |
|
1632 | + if (!empty($uploaded_file)) |
|
1633 | + $file_urls = $geodir_uploadurl . '/' . $new_name; |
|
1634 | 1634 | |
1635 | - } else { |
|
1636 | - $file_urls = $post_image[$m]; |
|
1637 | - } |
|
1638 | - } |
|
1635 | + } else { |
|
1636 | + $file_urls = $post_image[$m]; |
|
1637 | + } |
|
1638 | + } |
|
1639 | 1639 | |
1640 | 1640 | |
1641 | - } |
|
1641 | + } |
|
1642 | 1642 | |
1643 | - //Remove all old attachments and temp images |
|
1644 | - if (!empty($postcurr_images)) { |
|
1643 | + //Remove all old attachments and temp images |
|
1644 | + if (!empty($postcurr_images)) { |
|
1645 | 1645 | |
1646 | - if ($file_urls != $postcurr_images) { |
|
1647 | - $invalid_files[] = (object)array('src' => $postcurr_images); |
|
1648 | - $invalid_files = (object)$invalid_files; |
|
1649 | - } |
|
1650 | - } |
|
1646 | + if ($file_urls != $postcurr_images) { |
|
1647 | + $invalid_files[] = (object)array('src' => $postcurr_images); |
|
1648 | + $invalid_files = (object)$invalid_files; |
|
1649 | + } |
|
1650 | + } |
|
1651 | 1651 | |
1652 | - geodir_save_post_meta($post_id, $field_id, $file_urls); |
|
1652 | + geodir_save_post_meta($post_id, $field_id, $file_urls); |
|
1653 | 1653 | |
1654 | - if (!empty($invalid_files)) |
|
1655 | - geodir_remove_attachments($invalid_files); |
|
1654 | + if (!empty($invalid_files)) |
|
1655 | + geodir_remove_attachments($invalid_files); |
|
1656 | 1656 | |
1657 | - } |
|
1657 | + } |
|
1658 | 1658 | } |
1659 | 1659 | |
1660 | 1660 | |
@@ -1669,76 +1669,76 @@ discard block |
||
1669 | 1669 | */ |
1670 | 1670 | function geodir_custom_upload_mimes($existing_mimes = array()) |
1671 | 1671 | { |
1672 | - $existing_mimes['wif'] = 'text/plain'; |
|
1673 | - $existing_mimes['jpg|jpeg'] = 'image/jpeg'; |
|
1674 | - $existing_mimes['gif'] = 'image/gif'; |
|
1675 | - $existing_mimes['png'] = 'image/png'; |
|
1676 | - $existing_mimes['pdf'] = 'application/pdf'; |
|
1677 | - $existing_mimes['txt'] = 'text/text'; |
|
1678 | - $existing_mimes['csv'] = 'application/octet-stream'; |
|
1679 | - $existing_mimes['doc'] = 'application/msword'; |
|
1680 | - $existing_mimes['xla|xls|xlt|xlw'] = 'application/vnd.ms-excel'; |
|
1681 | - $existing_mimes['docx'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; |
|
1682 | - $existing_mimes['xlsx'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; |
|
1683 | - return $existing_mimes; |
|
1672 | + $existing_mimes['wif'] = 'text/plain'; |
|
1673 | + $existing_mimes['jpg|jpeg'] = 'image/jpeg'; |
|
1674 | + $existing_mimes['gif'] = 'image/gif'; |
|
1675 | + $existing_mimes['png'] = 'image/png'; |
|
1676 | + $existing_mimes['pdf'] = 'application/pdf'; |
|
1677 | + $existing_mimes['txt'] = 'text/text'; |
|
1678 | + $existing_mimes['csv'] = 'application/octet-stream'; |
|
1679 | + $existing_mimes['doc'] = 'application/msword'; |
|
1680 | + $existing_mimes['xla|xls|xlt|xlw'] = 'application/vnd.ms-excel'; |
|
1681 | + $existing_mimes['docx'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; |
|
1682 | + $existing_mimes['xlsx'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; |
|
1683 | + return $existing_mimes; |
|
1684 | 1684 | } |
1685 | 1685 | |
1686 | 1686 | if (!function_exists('geodir_plupload_action')) { |
1687 | 1687 | |
1688 | - /** |
|
1689 | - * Get upload directory path details |
|
1690 | - * |
|
1691 | - * @since 1.0.0 |
|
1692 | - * @package GeoDirectory |
|
1693 | - * @global object $current_user Current user object. |
|
1694 | - * @param array $upload Array of upload directory data with keys of 'path','url', 'subdir, 'basedir', and 'error'. |
|
1695 | - * @return mixed Returns upload directory details as an array. |
|
1696 | - */ |
|
1697 | - function geodir_upload_dir($upload) |
|
1698 | - { |
|
1699 | - global $current_user; |
|
1700 | - $upload['subdir'] = $upload['subdir'] . '/temp_' . $current_user->data->ID; |
|
1701 | - $upload['path'] = $upload['basedir'] . $upload['subdir']; |
|
1702 | - $upload['url'] = $upload['baseurl'] . $upload['subdir']; |
|
1703 | - return $upload; |
|
1704 | - } |
|
1705 | - |
|
1706 | - /** |
|
1707 | - * Handles place file and image upload. |
|
1708 | - * |
|
1709 | - * @since 1.0.0 |
|
1710 | - * @package GeoDirectory |
|
1711 | - */ |
|
1712 | - function geodir_plupload_action() |
|
1713 | - { |
|
1714 | - // check ajax nonce |
|
1715 | - $imgid = $_POST["imgid"]; |
|
1716 | - |
|
1717 | - check_ajax_referer($imgid . 'pluploadan'); |
|
1718 | - |
|
1719 | - // handle custom file uploaddir |
|
1720 | - add_filter('upload_dir', 'geodir_upload_dir'); |
|
1721 | - |
|
1722 | - // change file orientation if needed |
|
1723 | - $fixed_file = geodir_exif($_FILES[$imgid . 'async-upload']); |
|
1724 | - |
|
1725 | - // handle file upload |
|
1726 | - $status = wp_handle_upload($fixed_file, array('test_form' => true, 'action' => 'plupload_action')); |
|
1727 | - // remove handle custom file uploaddir |
|
1728 | - remove_filter('upload_dir', 'geodir_upload_dir'); |
|
1729 | - |
|
1730 | - if(!isset($status['url']) && isset($status['error'])){ |
|
1731 | - print_r($status); |
|
1732 | - } |
|
1733 | - |
|
1734 | - // send the uploaded file url in response |
|
1735 | - if (isset($status['url'])) { |
|
1736 | - echo $status['url']; |
|
1737 | - } else { |
|
1738 | - echo 'x'; |
|
1739 | - } |
|
1740 | - exit; |
|
1741 | - } |
|
1688 | + /** |
|
1689 | + * Get upload directory path details |
|
1690 | + * |
|
1691 | + * @since 1.0.0 |
|
1692 | + * @package GeoDirectory |
|
1693 | + * @global object $current_user Current user object. |
|
1694 | + * @param array $upload Array of upload directory data with keys of 'path','url', 'subdir, 'basedir', and 'error'. |
|
1695 | + * @return mixed Returns upload directory details as an array. |
|
1696 | + */ |
|
1697 | + function geodir_upload_dir($upload) |
|
1698 | + { |
|
1699 | + global $current_user; |
|
1700 | + $upload['subdir'] = $upload['subdir'] . '/temp_' . $current_user->data->ID; |
|
1701 | + $upload['path'] = $upload['basedir'] . $upload['subdir']; |
|
1702 | + $upload['url'] = $upload['baseurl'] . $upload['subdir']; |
|
1703 | + return $upload; |
|
1704 | + } |
|
1705 | + |
|
1706 | + /** |
|
1707 | + * Handles place file and image upload. |
|
1708 | + * |
|
1709 | + * @since 1.0.0 |
|
1710 | + * @package GeoDirectory |
|
1711 | + */ |
|
1712 | + function geodir_plupload_action() |
|
1713 | + { |
|
1714 | + // check ajax nonce |
|
1715 | + $imgid = $_POST["imgid"]; |
|
1716 | + |
|
1717 | + check_ajax_referer($imgid . 'pluploadan'); |
|
1718 | + |
|
1719 | + // handle custom file uploaddir |
|
1720 | + add_filter('upload_dir', 'geodir_upload_dir'); |
|
1721 | + |
|
1722 | + // change file orientation if needed |
|
1723 | + $fixed_file = geodir_exif($_FILES[$imgid . 'async-upload']); |
|
1724 | + |
|
1725 | + // handle file upload |
|
1726 | + $status = wp_handle_upload($fixed_file, array('test_form' => true, 'action' => 'plupload_action')); |
|
1727 | + // remove handle custom file uploaddir |
|
1728 | + remove_filter('upload_dir', 'geodir_upload_dir'); |
|
1729 | + |
|
1730 | + if(!isset($status['url']) && isset($status['error'])){ |
|
1731 | + print_r($status); |
|
1732 | + } |
|
1733 | + |
|
1734 | + // send the uploaded file url in response |
|
1735 | + if (isset($status['url'])) { |
|
1736 | + echo $status['url']; |
|
1737 | + } else { |
|
1738 | + echo 'x'; |
|
1739 | + } |
|
1740 | + exit; |
|
1741 | + } |
|
1742 | 1742 | } |
1743 | 1743 | |
1744 | 1744 | /** |
@@ -1753,17 +1753,17 @@ discard block |
||
1753 | 1753 | */ |
1754 | 1754 | function geodir_get_video($post_id) |
1755 | 1755 | { |
1756 | - global $wpdb, $plugin_prefix; |
|
1756 | + global $wpdb, $plugin_prefix; |
|
1757 | 1757 | |
1758 | - $post_type = get_post_type($post_id); |
|
1758 | + $post_type = get_post_type($post_id); |
|
1759 | 1759 | |
1760 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
1760 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
1761 | 1761 | |
1762 | - $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_video FROM " . $table . " WHERE post_id=%d", array($post_id))); |
|
1762 | + $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_video FROM " . $table . " WHERE post_id=%d", array($post_id))); |
|
1763 | 1763 | |
1764 | - if ($results) { |
|
1765 | - return $results[0]->geodir_video; |
|
1766 | - } |
|
1764 | + if ($results) { |
|
1765 | + return $results[0]->geodir_video; |
|
1766 | + } |
|
1767 | 1767 | |
1768 | 1768 | } |
1769 | 1769 | |
@@ -1779,40 +1779,40 @@ discard block |
||
1779 | 1779 | */ |
1780 | 1780 | function geodir_get_special_offers($post_id) |
1781 | 1781 | { |
1782 | - global $wpdb, $plugin_prefix; |
|
1782 | + global $wpdb, $plugin_prefix; |
|
1783 | 1783 | |
1784 | - $post_type = get_post_type($post_id); |
|
1784 | + $post_type = get_post_type($post_id); |
|
1785 | 1785 | |
1786 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
1786 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
1787 | 1787 | |
1788 | - $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_special_offers FROM " . $table . " WHERE post_id=%d", array($post_id))); |
|
1788 | + $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_special_offers FROM " . $table . " WHERE post_id=%d", array($post_id))); |
|
1789 | 1789 | |
1790 | - if ($results) { |
|
1791 | - return $results[0]->geodir_special_offers; |
|
1792 | - } |
|
1790 | + if ($results) { |
|
1791 | + return $results[0]->geodir_special_offers; |
|
1792 | + } |
|
1793 | 1793 | |
1794 | 1794 | } |
1795 | 1795 | |
1796 | 1796 | if (!function_exists('geodir_max_upload_size')) { |
1797 | - /** |
|
1798 | - * Get max upload file size |
|
1799 | - * |
|
1800 | - * @since 1.0.0 |
|
1801 | - * @package GeoDirectory |
|
1802 | - * @return mixed|void Returns max upload file size. |
|
1803 | - */ |
|
1804 | - function geodir_max_upload_size() |
|
1805 | - { |
|
1806 | - $max_filesize = (float)get_option('geodir_upload_max_filesize', 2); |
|
1807 | - |
|
1808 | - if ($max_filesize > 0 && $max_filesize < 1) { |
|
1809 | - $max_filesize = (int)($max_filesize * 1024) . 'kb'; |
|
1810 | - } else { |
|
1811 | - $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb'; |
|
1812 | - } |
|
1813 | - /** Filter documented in geodirectory-functions/general_functions.php **/ |
|
1814 | - return apply_filters('geodir_default_image_upload_size_limit', $max_filesize); |
|
1815 | - } |
|
1797 | + /** |
|
1798 | + * Get max upload file size |
|
1799 | + * |
|
1800 | + * @since 1.0.0 |
|
1801 | + * @package GeoDirectory |
|
1802 | + * @return mixed|void Returns max upload file size. |
|
1803 | + */ |
|
1804 | + function geodir_max_upload_size() |
|
1805 | + { |
|
1806 | + $max_filesize = (float)get_option('geodir_upload_max_filesize', 2); |
|
1807 | + |
|
1808 | + if ($max_filesize > 0 && $max_filesize < 1) { |
|
1809 | + $max_filesize = (int)($max_filesize * 1024) . 'kb'; |
|
1810 | + } else { |
|
1811 | + $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb'; |
|
1812 | + } |
|
1813 | + /** Filter documented in geodirectory-functions/general_functions.php **/ |
|
1814 | + return apply_filters('geodir_default_image_upload_size_limit', $max_filesize); |
|
1815 | + } |
|
1816 | 1816 | } |
1817 | 1817 | |
1818 | 1818 | |
@@ -1830,33 +1830,33 @@ discard block |
||
1830 | 1830 | */ |
1831 | 1831 | function geodir_add_custom_sort_options($fields, $post_type) |
1832 | 1832 | { |
1833 | - global $wpdb; |
|
1833 | + global $wpdb; |
|
1834 | 1834 | |
1835 | - if ($post_type != '') { |
|
1835 | + if ($post_type != '') { |
|
1836 | 1836 | |
1837 | - $all_postypes = geodir_get_posttypes(); |
|
1837 | + $all_postypes = geodir_get_posttypes(); |
|
1838 | 1838 | |
1839 | - if (in_array($post_type, $all_postypes)) { |
|
1839 | + if (in_array($post_type, $all_postypes)) { |
|
1840 | 1840 | |
1841 | - $custom_fields = $wpdb->get_results( |
|
1842 | - $wpdb->prepare( |
|
1843 | - "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", |
|
1844 | - array($post_type) |
|
1845 | - ), 'ARRAY_A' |
|
1846 | - ); |
|
1841 | + $custom_fields = $wpdb->get_results( |
|
1842 | + $wpdb->prepare( |
|
1843 | + "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", |
|
1844 | + array($post_type) |
|
1845 | + ), 'ARRAY_A' |
|
1846 | + ); |
|
1847 | 1847 | |
1848 | - if (!empty($custom_fields)) { |
|
1848 | + if (!empty($custom_fields)) { |
|
1849 | 1849 | |
1850 | - foreach ($custom_fields as $val) { |
|
1851 | - $fields[] = $val; |
|
1852 | - } |
|
1853 | - } |
|
1850 | + foreach ($custom_fields as $val) { |
|
1851 | + $fields[] = $val; |
|
1852 | + } |
|
1853 | + } |
|
1854 | 1854 | |
1855 | - } |
|
1855 | + } |
|
1856 | 1856 | |
1857 | - } |
|
1857 | + } |
|
1858 | 1858 | |
1859 | - return $fields; |
|
1859 | + return $fields; |
|
1860 | 1860 | } |
1861 | 1861 | |
1862 | 1862 | |
@@ -1872,76 +1872,76 @@ discard block |
||
1872 | 1872 | function geodir_get_custom_sort_options($post_type = '') |
1873 | 1873 | { |
1874 | 1874 | |
1875 | - global $wpdb; |
|
1876 | - |
|
1877 | - if ($post_type != '') { |
|
1878 | - |
|
1879 | - $all_postypes = geodir_get_posttypes(); |
|
1880 | - |
|
1881 | - if (!in_array($post_type, $all_postypes)) |
|
1882 | - return false; |
|
1883 | - |
|
1884 | - $fields = array(); |
|
1885 | - |
|
1886 | - $fields[] = array( |
|
1887 | - 'post_type' => $post_type, |
|
1888 | - 'data_type' => '', |
|
1889 | - 'field_type' => 'random', |
|
1890 | - 'site_title' => 'Random', |
|
1891 | - 'htmlvar_name' => 'post_title', |
|
1892 | - 'field_icon' => 'fa fa-random', |
|
1893 | - 'description' => __('Random sort (not recommended for large sites)', 'geodirectory') |
|
1894 | - ); |
|
1895 | - |
|
1896 | - $fields[] = array( |
|
1897 | - 'post_type' => $post_type, |
|
1898 | - 'data_type' => '', |
|
1899 | - 'field_type' => 'datetime', |
|
1900 | - 'site_title' => __('Add date', 'geodirectory'), |
|
1901 | - 'htmlvar_name' => 'post_date', |
|
1902 | - 'field_icon' => 'fa fa-calendar', |
|
1903 | - 'description' => __('Sort by date added', 'geodirectory') |
|
1904 | - ); |
|
1905 | - $fields[] = array( |
|
1906 | - 'post_type' => $post_type, |
|
1907 | - 'data_type' => '', |
|
1908 | - 'field_type' => 'bigint', |
|
1909 | - 'site_title' => __('Review', 'geodirectory'), |
|
1910 | - 'htmlvar_name' => 'comment_count', |
|
1911 | - 'field_icon' => 'fa fa-commenting-o', |
|
1912 | - 'description' => __('Sort by the number of reviews', 'geodirectory') |
|
1913 | - ); |
|
1914 | - $fields[] = array( |
|
1915 | - 'post_type' => $post_type, |
|
1916 | - 'data_type' => '', |
|
1917 | - 'field_type' => 'float', |
|
1918 | - 'site_title' => __('Rating', 'geodirectory'), |
|
1919 | - 'htmlvar_name' => 'overall_rating', |
|
1920 | - 'field_icon' => 'fa fa-star-o', |
|
1921 | - 'description' => __('Sort by the overall rating value', 'geodirectory') |
|
1922 | - ); |
|
1923 | - $fields[] = array( |
|
1924 | - 'post_type' => $post_type, |
|
1925 | - 'data_type' => '', |
|
1926 | - 'field_type' => 'text', |
|
1927 | - 'site_title' => __('Title', 'geodirectory'), |
|
1928 | - 'htmlvar_name' => 'post_title', |
|
1929 | - 'field_icon' => 'fa fa-sort-alpha-desc', |
|
1930 | - 'description' => __('Sort alphabetically by title', 'geodirectory') |
|
1931 | - ); |
|
1932 | - |
|
1933 | - /** |
|
1934 | - * Hook to add custom sort options. |
|
1935 | - * |
|
1936 | - * @since 1.0.0 |
|
1937 | - * @param array $fields Unmodified sort options array. |
|
1938 | - * @param string $post_type Post type. |
|
1939 | - */ |
|
1940 | - return $fields = apply_filters('geodir_add_custom_sort_options', $fields, $post_type); |
|
1941 | - |
|
1942 | - } |
|
1943 | - |
|
1944 | - return false; |
|
1875 | + global $wpdb; |
|
1876 | + |
|
1877 | + if ($post_type != '') { |
|
1878 | + |
|
1879 | + $all_postypes = geodir_get_posttypes(); |
|
1880 | + |
|
1881 | + if (!in_array($post_type, $all_postypes)) |
|
1882 | + return false; |
|
1883 | + |
|
1884 | + $fields = array(); |
|
1885 | + |
|
1886 | + $fields[] = array( |
|
1887 | + 'post_type' => $post_type, |
|
1888 | + 'data_type' => '', |
|
1889 | + 'field_type' => 'random', |
|
1890 | + 'site_title' => 'Random', |
|
1891 | + 'htmlvar_name' => 'post_title', |
|
1892 | + 'field_icon' => 'fa fa-random', |
|
1893 | + 'description' => __('Random sort (not recommended for large sites)', 'geodirectory') |
|
1894 | + ); |
|
1895 | + |
|
1896 | + $fields[] = array( |
|
1897 | + 'post_type' => $post_type, |
|
1898 | + 'data_type' => '', |
|
1899 | + 'field_type' => 'datetime', |
|
1900 | + 'site_title' => __('Add date', 'geodirectory'), |
|
1901 | + 'htmlvar_name' => 'post_date', |
|
1902 | + 'field_icon' => 'fa fa-calendar', |
|
1903 | + 'description' => __('Sort by date added', 'geodirectory') |
|
1904 | + ); |
|
1905 | + $fields[] = array( |
|
1906 | + 'post_type' => $post_type, |
|
1907 | + 'data_type' => '', |
|
1908 | + 'field_type' => 'bigint', |
|
1909 | + 'site_title' => __('Review', 'geodirectory'), |
|
1910 | + 'htmlvar_name' => 'comment_count', |
|
1911 | + 'field_icon' => 'fa fa-commenting-o', |
|
1912 | + 'description' => __('Sort by the number of reviews', 'geodirectory') |
|
1913 | + ); |
|
1914 | + $fields[] = array( |
|
1915 | + 'post_type' => $post_type, |
|
1916 | + 'data_type' => '', |
|
1917 | + 'field_type' => 'float', |
|
1918 | + 'site_title' => __('Rating', 'geodirectory'), |
|
1919 | + 'htmlvar_name' => 'overall_rating', |
|
1920 | + 'field_icon' => 'fa fa-star-o', |
|
1921 | + 'description' => __('Sort by the overall rating value', 'geodirectory') |
|
1922 | + ); |
|
1923 | + $fields[] = array( |
|
1924 | + 'post_type' => $post_type, |
|
1925 | + 'data_type' => '', |
|
1926 | + 'field_type' => 'text', |
|
1927 | + 'site_title' => __('Title', 'geodirectory'), |
|
1928 | + 'htmlvar_name' => 'post_title', |
|
1929 | + 'field_icon' => 'fa fa-sort-alpha-desc', |
|
1930 | + 'description' => __('Sort alphabetically by title', 'geodirectory') |
|
1931 | + ); |
|
1932 | + |
|
1933 | + /** |
|
1934 | + * Hook to add custom sort options. |
|
1935 | + * |
|
1936 | + * @since 1.0.0 |
|
1937 | + * @param array $fields Unmodified sort options array. |
|
1938 | + * @param string $post_type Post type. |
|
1939 | + */ |
|
1940 | + return $fields = apply_filters('geodir_add_custom_sort_options', $fields, $post_type); |
|
1941 | + |
|
1942 | + } |
|
1943 | + |
|
1944 | + return false; |
|
1945 | 1945 | } |
1946 | 1946 | |
1947 | 1947 | |
@@ -1957,117 +1957,117 @@ discard block |
||
1957 | 1957 | function godir_set_sort_field_order($field_ids = array()) |
1958 | 1958 | { |
1959 | 1959 | |
1960 | - global $wpdb; |
|
1960 | + global $wpdb; |
|
1961 | 1961 | |
1962 | - $count = 0; |
|
1963 | - if (!empty($field_ids)): |
|
1964 | - foreach ($field_ids as $id) { |
|
1962 | + $count = 0; |
|
1963 | + if (!empty($field_ids)): |
|
1964 | + foreach ($field_ids as $id) { |
|
1965 | 1965 | |
1966 | - $cf = trim($id, '_'); |
|
1966 | + $cf = trim($id, '_'); |
|
1967 | 1967 | |
1968 | - $post_meta_info = $wpdb->query( |
|
1969 | - $wpdb->prepare( |
|
1970 | - "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
1968 | + $post_meta_info = $wpdb->query( |
|
1969 | + $wpdb->prepare( |
|
1970 | + "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
1971 | 1971 | sort_order=%d |
1972 | 1972 | where id= %d", |
1973 | - array($count, $cf) |
|
1974 | - ) |
|
1975 | - ); |
|
1976 | - $count++; |
|
1977 | - } |
|
1978 | - |
|
1979 | - return $field_ids; |
|
1980 | - else: |
|
1981 | - return false; |
|
1982 | - endif; |
|
1973 | + array($count, $cf) |
|
1974 | + ) |
|
1975 | + ); |
|
1976 | + $count++; |
|
1977 | + } |
|
1978 | + |
|
1979 | + return $field_ids; |
|
1980 | + else: |
|
1981 | + return false; |
|
1982 | + endif; |
|
1983 | 1983 | } |
1984 | 1984 | |
1985 | 1985 | |
1986 | 1986 | if (!function_exists('geodir_custom_sort_field_save')) { |
1987 | - /** |
|
1988 | - * Save or Update custom sort fields into the database. |
|
1989 | - * |
|
1990 | - * @since 1.0.0 |
|
1991 | - * @package GeoDirectory |
|
1992 | - * @global object $wpdb WordPress Database object. |
|
1993 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
1994 | - * @param array $request_field { |
|
1995 | - * Attributes of the Request field. |
|
1996 | - * |
|
1997 | - * @type string $action Ajax action name. |
|
1998 | - * @type string $manage_field_type Manage field type Default "sorting_options". |
|
1999 | - * @type string $create_field Do you want to create this field?. |
|
2000 | - * @type string $field_ins_upd Field created or updated?. |
|
2001 | - * @type string $_wpnonce Nonce value. |
|
2002 | - * @type string $listing_type The Post type. |
|
2003 | - * @type string $field_type Field Type. |
|
2004 | - * @type string $field_id Field ID. |
|
2005 | - * @type string $data_type Data Type. |
|
2006 | - * @type string $htmlvar_name HTML variable name. |
|
2007 | - * @type string $site_title Section title which you wish to display in frontend. |
|
2008 | - * @type string $is_default Is this default sorting?. |
|
2009 | - * @type string $is_active If not active then the field will not be displayed anywhere. |
|
2010 | - * @type string $sort_order Sort Order. |
|
2011 | - * |
|
2012 | - * } |
|
2013 | - * @param bool $default Not yet implemented. |
|
2014 | - * @return int Returns the last affected db table row id. |
|
2015 | - */ |
|
2016 | - function geodir_custom_sort_field_save($request_field = array(), $default = false) |
|
2017 | - { |
|
2018 | - |
|
2019 | - global $wpdb, $plugin_prefix; |
|
2020 | - |
|
2021 | - $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : ''; |
|
2022 | - |
|
2023 | - $cf = trim($result_str, '_'); |
|
2024 | - |
|
2025 | - /*-------- check duplicate validation --------*/ |
|
2026 | - |
|
2027 | - $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : ''; |
|
2028 | - $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
2029 | - |
|
2030 | - $post_type = $request_field['listing_type']; |
|
2031 | - $data_type = isset($request_field['data_type']) ? $request_field['data_type'] : ''; |
|
2032 | - $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : ''; |
|
2033 | - $site_title = isset($request_field['site_title']) ? $request_field['site_title'] : ''; |
|
2034 | - $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
2035 | - $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : 0; |
|
2036 | - $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : 0; |
|
2037 | - $is_default = isset($request_field['is_default']) ? $request_field['is_default'] : ''; |
|
2038 | - $asc = isset($request_field['asc']) ? $request_field['asc'] : 0; |
|
2039 | - $desc = isset($request_field['desc']) ? $request_field['desc'] : 0; |
|
2040 | - $asc_title = isset($request_field['asc_title']) ? $request_field['asc_title'] : ''; |
|
2041 | - $desc_title = isset($request_field['desc_title']) ? $request_field['desc_title'] : ''; |
|
2042 | - |
|
2043 | - $default_order = ''; |
|
2044 | - if ($is_default != '') { |
|
2045 | - $default_order = $is_default; |
|
2046 | - $is_default = '1'; |
|
2047 | - } |
|
2048 | - |
|
2049 | - |
|
2050 | - $check_html_variable = $wpdb->get_var( |
|
2051 | - $wpdb->prepare( |
|
2052 | - "select htmlvar_name from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s and field_type=%s ", |
|
2053 | - array($cehhtmlvar_name, $post_type, $field_type) |
|
2054 | - ) |
|
2055 | - ); |
|
2056 | - |
|
2057 | - if ($is_default == 1) { |
|
2058 | - |
|
2059 | - $wpdb->query($wpdb->prepare("update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set is_default='0', default_order='' where post_type = %s", array($post_type))); |
|
2060 | - |
|
2061 | - } |
|
2062 | - |
|
2063 | - |
|
2064 | - if (!$check_html_variable) { |
|
2065 | - |
|
2066 | - $wpdb->query( |
|
2067 | - |
|
2068 | - $wpdb->prepare( |
|
2069 | - |
|
2070 | - "insert into " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
1987 | + /** |
|
1988 | + * Save or Update custom sort fields into the database. |
|
1989 | + * |
|
1990 | + * @since 1.0.0 |
|
1991 | + * @package GeoDirectory |
|
1992 | + * @global object $wpdb WordPress Database object. |
|
1993 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
1994 | + * @param array $request_field { |
|
1995 | + * Attributes of the Request field. |
|
1996 | + * |
|
1997 | + * @type string $action Ajax action name. |
|
1998 | + * @type string $manage_field_type Manage field type Default "sorting_options". |
|
1999 | + * @type string $create_field Do you want to create this field?. |
|
2000 | + * @type string $field_ins_upd Field created or updated?. |
|
2001 | + * @type string $_wpnonce Nonce value. |
|
2002 | + * @type string $listing_type The Post type. |
|
2003 | + * @type string $field_type Field Type. |
|
2004 | + * @type string $field_id Field ID. |
|
2005 | + * @type string $data_type Data Type. |
|
2006 | + * @type string $htmlvar_name HTML variable name. |
|
2007 | + * @type string $site_title Section title which you wish to display in frontend. |
|
2008 | + * @type string $is_default Is this default sorting?. |
|
2009 | + * @type string $is_active If not active then the field will not be displayed anywhere. |
|
2010 | + * @type string $sort_order Sort Order. |
|
2011 | + * |
|
2012 | + * } |
|
2013 | + * @param bool $default Not yet implemented. |
|
2014 | + * @return int Returns the last affected db table row id. |
|
2015 | + */ |
|
2016 | + function geodir_custom_sort_field_save($request_field = array(), $default = false) |
|
2017 | + { |
|
2018 | + |
|
2019 | + global $wpdb, $plugin_prefix; |
|
2020 | + |
|
2021 | + $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : ''; |
|
2022 | + |
|
2023 | + $cf = trim($result_str, '_'); |
|
2024 | + |
|
2025 | + /*-------- check duplicate validation --------*/ |
|
2026 | + |
|
2027 | + $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : ''; |
|
2028 | + $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
2029 | + |
|
2030 | + $post_type = $request_field['listing_type']; |
|
2031 | + $data_type = isset($request_field['data_type']) ? $request_field['data_type'] : ''; |
|
2032 | + $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : ''; |
|
2033 | + $site_title = isset($request_field['site_title']) ? $request_field['site_title'] : ''; |
|
2034 | + $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : ''; |
|
2035 | + $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : 0; |
|
2036 | + $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : 0; |
|
2037 | + $is_default = isset($request_field['is_default']) ? $request_field['is_default'] : ''; |
|
2038 | + $asc = isset($request_field['asc']) ? $request_field['asc'] : 0; |
|
2039 | + $desc = isset($request_field['desc']) ? $request_field['desc'] : 0; |
|
2040 | + $asc_title = isset($request_field['asc_title']) ? $request_field['asc_title'] : ''; |
|
2041 | + $desc_title = isset($request_field['desc_title']) ? $request_field['desc_title'] : ''; |
|
2042 | + |
|
2043 | + $default_order = ''; |
|
2044 | + if ($is_default != '') { |
|
2045 | + $default_order = $is_default; |
|
2046 | + $is_default = '1'; |
|
2047 | + } |
|
2048 | + |
|
2049 | + |
|
2050 | + $check_html_variable = $wpdb->get_var( |
|
2051 | + $wpdb->prepare( |
|
2052 | + "select htmlvar_name from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s and field_type=%s ", |
|
2053 | + array($cehhtmlvar_name, $post_type, $field_type) |
|
2054 | + ) |
|
2055 | + ); |
|
2056 | + |
|
2057 | + if ($is_default == 1) { |
|
2058 | + |
|
2059 | + $wpdb->query($wpdb->prepare("update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set is_default='0', default_order='' where post_type = %s", array($post_type))); |
|
2060 | + |
|
2061 | + } |
|
2062 | + |
|
2063 | + |
|
2064 | + if (!$check_html_variable) { |
|
2065 | + |
|
2066 | + $wpdb->query( |
|
2067 | + |
|
2068 | + $wpdb->prepare( |
|
2069 | + |
|
2070 | + "insert into " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
2071 | 2071 | post_type = %s, |
2072 | 2072 | data_type = %s, |
2073 | 2073 | field_type = %s, |
@@ -2082,23 +2082,23 @@ discard block |
||
2082 | 2082 | asc_title = %s, |
2083 | 2083 | desc_title = %s", |
2084 | 2084 | |
2085 | - 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) |
|
2086 | - ) |
|
2085 | + 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) |
|
2086 | + ) |
|
2087 | 2087 | |
2088 | - ); |
|
2088 | + ); |
|
2089 | 2089 | |
2090 | 2090 | |
2091 | - $lastid = $wpdb->insert_id; |
|
2091 | + $lastid = $wpdb->insert_id; |
|
2092 | 2092 | |
2093 | - $lastid = trim($lastid); |
|
2093 | + $lastid = trim($lastid); |
|
2094 | 2094 | |
2095 | - } else { |
|
2095 | + } else { |
|
2096 | 2096 | |
2097 | - $wpdb->query( |
|
2097 | + $wpdb->query( |
|
2098 | 2098 | |
2099 | - $wpdb->prepare( |
|
2099 | + $wpdb->prepare( |
|
2100 | 2100 | |
2101 | - "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
2101 | + "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set |
|
2102 | 2102 | post_type = %s, |
2103 | 2103 | data_type = %s, |
2104 | 2104 | field_type = %s, |
@@ -2114,123 +2114,123 @@ discard block |
||
2114 | 2114 | desc_title = %s |
2115 | 2115 | where id = %d", |
2116 | 2116 | |
2117 | - 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) |
|
2118 | - ) |
|
2117 | + 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) |
|
2118 | + ) |
|
2119 | 2119 | |
2120 | - ); |
|
2120 | + ); |
|
2121 | 2121 | |
2122 | - $lastid = trim($cf); |
|
2122 | + $lastid = trim($cf); |
|
2123 | 2123 | |
2124 | - } |
|
2124 | + } |
|
2125 | 2125 | |
2126 | 2126 | |
2127 | - return (int)$lastid; |
|
2127 | + return (int)$lastid; |
|
2128 | 2128 | |
2129 | - } |
|
2129 | + } |
|
2130 | 2130 | } |
2131 | 2131 | |
2132 | 2132 | |
2133 | 2133 | if (!function_exists('geodir_custom_sort_field_delete')) { |
2134 | - /** |
|
2135 | - * Delete a custom sort field using field id. |
|
2136 | - * @since 1.0.0 |
|
2137 | - * @package GeoDirectory |
|
2138 | - * @global object $wpdb WordPress Database object. |
|
2139 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
2140 | - * @param string $field_id The field ID. |
|
2141 | - * @return int|string Returns field id when successful deletion, else returns 0. |
|
2142 | - */ |
|
2143 | - function geodir_custom_sort_field_delete($field_id = '') |
|
2144 | - { |
|
2145 | - |
|
2146 | - global $wpdb, $plugin_prefix; |
|
2147 | - if ($field_id != '') { |
|
2148 | - $cf = trim($field_id, '_'); |
|
2149 | - |
|
2150 | - $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where id= %d ", array($cf))); |
|
2151 | - |
|
2152 | - return $field_id; |
|
2153 | - |
|
2154 | - } else |
|
2155 | - return 0; |
|
2156 | - |
|
2157 | - } |
|
2134 | + /** |
|
2135 | + * Delete a custom sort field using field id. |
|
2136 | + * @since 1.0.0 |
|
2137 | + * @package GeoDirectory |
|
2138 | + * @global object $wpdb WordPress Database object. |
|
2139 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
2140 | + * @param string $field_id The field ID. |
|
2141 | + * @return int|string Returns field id when successful deletion, else returns 0. |
|
2142 | + */ |
|
2143 | + function geodir_custom_sort_field_delete($field_id = '') |
|
2144 | + { |
|
2145 | + |
|
2146 | + global $wpdb, $plugin_prefix; |
|
2147 | + if ($field_id != '') { |
|
2148 | + $cf = trim($field_id, '_'); |
|
2149 | + |
|
2150 | + $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where id= %d ", array($cf))); |
|
2151 | + |
|
2152 | + return $field_id; |
|
2153 | + |
|
2154 | + } else |
|
2155 | + return 0; |
|
2156 | + |
|
2157 | + } |
|
2158 | 2158 | } |
2159 | 2159 | |
2160 | 2160 | |
2161 | 2161 | if (!function_exists('geodir_custom_sort_field_adminhtml')) { |
2162 | - /** |
|
2163 | - * Custom sort field admin html. |
|
2164 | - * |
|
2165 | - * @since 1.0.0 |
|
2166 | - * @package GeoDirectory |
|
2167 | - * @global object $wpdb WordPress Database object. |
|
2168 | - * @param string $field_type The form field type. |
|
2169 | - * @param object|int $result_str The custom field results object or row id. |
|
2170 | - * @param string $field_ins_upd When set to "submit" displays form. |
|
2171 | - * @param bool $default when set to true field will be for admin use only. |
|
2172 | - */ |
|
2173 | - function geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key='') |
|
2174 | - { |
|
2175 | - global $wpdb; |
|
2176 | - $cf = $result_str; |
|
2177 | - if (!is_object($cf)) { |
|
2178 | - $field_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE id = %d", array($cf))); |
|
2179 | - } else { |
|
2180 | - $field_info = $cf; |
|
2181 | - $result_str = $cf->id; |
|
2182 | - } |
|
2183 | - |
|
2184 | - $field_info = stripslashes_deep($field_info); // strip slashes |
|
2185 | - |
|
2186 | - if (!isset($field_info->post_type)) { |
|
2187 | - $post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
2188 | - } else { |
|
2189 | - $post_type = $field_info->post_type; |
|
2190 | - } |
|
2191 | - |
|
2192 | - |
|
2193 | - $htmlvar_name = isset($field_type_key) ? $field_type_key : ''; |
|
2194 | - |
|
2195 | - $site_title = ''; |
|
2196 | - if ($site_title == '') |
|
2197 | - $site_title = isset($field_info->site_title) ? $field_info->site_title : ''; |
|
2198 | - |
|
2199 | - if ($site_title == '') { |
|
2200 | - $fields = geodir_get_custom_sort_options($post_type); |
|
2201 | - |
|
2202 | - foreach ($fields as $val) { |
|
2203 | - $val = stripslashes_deep($val); // strip slashes |
|
2204 | - |
|
2205 | - if ($val['field_type'] == $field_type && $val['htmlvar_name'] == $htmlvar_name) { |
|
2206 | - $site_title = isset($val['site_title']) ? $val['site_title'] : ''; |
|
2207 | - } |
|
2208 | - } |
|
2209 | - } |
|
2210 | - |
|
2211 | - if ($htmlvar_name == '') |
|
2212 | - $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : ''; |
|
2213 | - |
|
2214 | - $nonce = wp_create_nonce('custom_fields_' . $result_str); |
|
2215 | - |
|
2216 | - $field_icon = '<i class="fa fa-cog" aria-hidden="true"></i>'; |
|
2217 | - $cso_arr = geodir_get_custom_sort_options($post_type); |
|
2218 | - |
|
2219 | - $cur_field_type = (isset($cf->field_type)) ? $cf->field_type : esc_html($_REQUEST['field_type']); |
|
2220 | - foreach($cso_arr as $cso){ |
|
2221 | - if($cur_field_type==$cso['field_type']){ |
|
2222 | - |
|
2223 | - if (isset($cso['field_icon']) && strpos($cso['field_icon'], 'fa fa-') !== false) { |
|
2224 | - $field_icon = '<i class="'.$cso['field_icon'].'" aria-hidden="true"></i>'; |
|
2225 | - }elseif(isset($cso['field_icon']) && $cso['field_icon']){ |
|
2226 | - $field_icon = '<b style="background-image: url("'.$cso['field_icon'].'")"></b>'; |
|
2227 | - } |
|
2228 | - |
|
2229 | - } |
|
2230 | - } |
|
2231 | - |
|
2232 | - $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name.$field_type : rand(5, 500); |
|
2233 | - ?> |
|
2162 | + /** |
|
2163 | + * Custom sort field admin html. |
|
2164 | + * |
|
2165 | + * @since 1.0.0 |
|
2166 | + * @package GeoDirectory |
|
2167 | + * @global object $wpdb WordPress Database object. |
|
2168 | + * @param string $field_type The form field type. |
|
2169 | + * @param object|int $result_str The custom field results object or row id. |
|
2170 | + * @param string $field_ins_upd When set to "submit" displays form. |
|
2171 | + * @param bool $default when set to true field will be for admin use only. |
|
2172 | + */ |
|
2173 | + function geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key='') |
|
2174 | + { |
|
2175 | + global $wpdb; |
|
2176 | + $cf = $result_str; |
|
2177 | + if (!is_object($cf)) { |
|
2178 | + $field_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE id = %d", array($cf))); |
|
2179 | + } else { |
|
2180 | + $field_info = $cf; |
|
2181 | + $result_str = $cf->id; |
|
2182 | + } |
|
2183 | + |
|
2184 | + $field_info = stripslashes_deep($field_info); // strip slashes |
|
2185 | + |
|
2186 | + if (!isset($field_info->post_type)) { |
|
2187 | + $post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
2188 | + } else { |
|
2189 | + $post_type = $field_info->post_type; |
|
2190 | + } |
|
2191 | + |
|
2192 | + |
|
2193 | + $htmlvar_name = isset($field_type_key) ? $field_type_key : ''; |
|
2194 | + |
|
2195 | + $site_title = ''; |
|
2196 | + if ($site_title == '') |
|
2197 | + $site_title = isset($field_info->site_title) ? $field_info->site_title : ''; |
|
2198 | + |
|
2199 | + if ($site_title == '') { |
|
2200 | + $fields = geodir_get_custom_sort_options($post_type); |
|
2201 | + |
|
2202 | + foreach ($fields as $val) { |
|
2203 | + $val = stripslashes_deep($val); // strip slashes |
|
2204 | + |
|
2205 | + if ($val['field_type'] == $field_type && $val['htmlvar_name'] == $htmlvar_name) { |
|
2206 | + $site_title = isset($val['site_title']) ? $val['site_title'] : ''; |
|
2207 | + } |
|
2208 | + } |
|
2209 | + } |
|
2210 | + |
|
2211 | + if ($htmlvar_name == '') |
|
2212 | + $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : ''; |
|
2213 | + |
|
2214 | + $nonce = wp_create_nonce('custom_fields_' . $result_str); |
|
2215 | + |
|
2216 | + $field_icon = '<i class="fa fa-cog" aria-hidden="true"></i>'; |
|
2217 | + $cso_arr = geodir_get_custom_sort_options($post_type); |
|
2218 | + |
|
2219 | + $cur_field_type = (isset($cf->field_type)) ? $cf->field_type : esc_html($_REQUEST['field_type']); |
|
2220 | + foreach($cso_arr as $cso){ |
|
2221 | + if($cur_field_type==$cso['field_type']){ |
|
2222 | + |
|
2223 | + if (isset($cso['field_icon']) && strpos($cso['field_icon'], 'fa fa-') !== false) { |
|
2224 | + $field_icon = '<i class="'.$cso['field_icon'].'" aria-hidden="true"></i>'; |
|
2225 | + }elseif(isset($cso['field_icon']) && $cso['field_icon']){ |
|
2226 | + $field_icon = '<b style="background-image: url("'.$cso['field_icon'].'")"></b>'; |
|
2227 | + } |
|
2228 | + |
|
2229 | + } |
|
2230 | + } |
|
2231 | + |
|
2232 | + $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name.$field_type : rand(5, 500); |
|
2233 | + ?> |
|
2234 | 2234 | |
2235 | 2235 | <li class="text" id="licontainer_<?php echo $result_str;?>"> |
2236 | 2236 | <form><!-- we need to wrap in a form so we can use radio buttons with same name --> |
@@ -2239,7 +2239,7 @@ discard block |
||
2239 | 2239 | ondblclick="show_hide('field_frm<?php echo $result_str;?>')"> |
2240 | 2240 | <?php |
2241 | 2241 | |
2242 | - ?> |
|
2242 | + ?> |
|
2243 | 2243 | |
2244 | 2244 | <div title="<?php _e('Click to remove field', 'geodirectory');?>" |
2245 | 2245 | onclick="delete_sort_field('<?php echo $result_str;?>', '<?php echo $nonce;?>', this)" |
@@ -2254,17 +2254,17 @@ discard block |
||
2254 | 2254 | |
2255 | 2255 | <div id="field_frm<?php echo $result_str;?>" class="field_frm" |
2256 | 2256 | style="display:<?php if ($field_ins_upd == 'submit') { |
2257 | - echo 'block;'; |
|
2258 | - } else { |
|
2259 | - echo 'none;'; |
|
2260 | - } ?>"> |
|
2257 | + echo 'block;'; |
|
2258 | + } else { |
|
2259 | + echo 'none;'; |
|
2260 | + } ?>"> |
|
2261 | 2261 | <input type="hidden" name="_wpnonce" value="<?php echo $nonce; ?>"/> |
2262 | 2262 | <input type="hidden" name="listing_type" id="listing_type" value="<?php echo $post_type;?>"/> |
2263 | 2263 | <input type="hidden" name="field_type" id="field_type" value="<?php echo $field_type;?>"/> |
2264 | 2264 | <input type="hidden" name="field_id" id="field_id" value="<?php echo $result_str;?>"/> |
2265 | 2265 | <input type="hidden" name="data_type" id="data_type" value="<?php if (isset($field_info->data_type)) { |
2266 | - echo $field_info->data_type; |
|
2267 | - }?>"/> |
|
2266 | + echo $field_info->data_type; |
|
2267 | + }?>"/> |
|
2268 | 2268 | <input type="hidden" name="htmlvar_name" id="htmlvar_name" value="<?php echo $htmlvar_name;?>"/> |
2269 | 2269 | |
2270 | 2270 | |
@@ -2287,14 +2287,14 @@ discard block |
||
2287 | 2287 | |
2288 | 2288 | <input type="radio" id="asc_yes<?php echo $radio_id;?>" name="asc" class="gdri-enabled" value="1" |
2289 | 2289 | <?php if ($value == '1') { |
2290 | - echo 'checked'; |
|
2291 | - } ?>/> |
|
2290 | + echo 'checked'; |
|
2291 | + } ?>/> |
|
2292 | 2292 | <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> |
2293 | 2293 | |
2294 | 2294 | <input type="radio" id="asc_no<?php echo $radio_id;?>" name="asc" class="gdri-disabled" value="0" |
2295 | 2295 | <?php if ($value == '0' || !$value) { |
2296 | - echo 'checked'; |
|
2297 | - } ?>/> |
|
2296 | + echo 'checked'; |
|
2297 | + } ?>/> |
|
2298 | 2298 | <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> |
2299 | 2299 | |
2300 | 2300 | </div> |
@@ -2331,8 +2331,8 @@ discard block |
||
2331 | 2331 | |
2332 | 2332 | <input type="radio" name="is_default" |
2333 | 2333 | value="<?php echo $htmlvar_name; ?>_asc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name . '_asc') { |
2334 | - echo 'checked="checked"'; |
|
2335 | - } ?>/> |
|
2334 | + echo 'checked="checked"'; |
|
2335 | + } ?>/> |
|
2336 | 2336 | </div> |
2337 | 2337 | |
2338 | 2338 | </li> |
@@ -2352,14 +2352,14 @@ discard block |
||
2352 | 2352 | |
2353 | 2353 | <input type="radio" id="desc_yes<?php echo $radio_id;?>" name="desc" class="gdri-enabled" value="1" |
2354 | 2354 | <?php if ($value == '1') { |
2355 | - echo 'checked'; |
|
2356 | - } ?>/> |
|
2355 | + echo 'checked'; |
|
2356 | + } ?>/> |
|
2357 | 2357 | <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> |
2358 | 2358 | |
2359 | 2359 | <input type="radio" id="desc_no<?php echo $radio_id;?>" name="desc" class="gdri-disabled" value="0" |
2360 | 2360 | <?php if ($value == '0' || !$value) { |
2361 | - echo 'checked'; |
|
2362 | - } ?>/> |
|
2361 | + echo 'checked'; |
|
2362 | + } ?>/> |
|
2363 | 2363 | <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> |
2364 | 2364 | |
2365 | 2365 | </div> |
@@ -2395,8 +2395,8 @@ discard block |
||
2395 | 2395 | |
2396 | 2396 | <input type="radio" name="is_default" |
2397 | 2397 | value="<?php echo $htmlvar_name; ?>_desc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name . '_desc') { |
2398 | - echo 'checked="checked"'; |
|
2399 | - } ?>/> |
|
2398 | + echo 'checked="checked"'; |
|
2399 | + } ?>/> |
|
2400 | 2400 | </div> |
2401 | 2401 | |
2402 | 2402 | </li> |
@@ -2438,8 +2438,8 @@ discard block |
||
2438 | 2438 | |
2439 | 2439 | <input type="checkbox" name="is_default" |
2440 | 2440 | value="<?php echo $field_type; ?>" <?php if (isset($value) && $value == '1') { |
2441 | - echo 'checked="checked"'; |
|
2442 | - } ?>/> |
|
2441 | + echo 'checked="checked"'; |
|
2442 | + } ?>/> |
|
2443 | 2443 | </div> |
2444 | 2444 | |
2445 | 2445 | |
@@ -2462,14 +2462,14 @@ discard block |
||
2462 | 2462 | |
2463 | 2463 | <input type="radio" id="is_active_yes<?php echo $radio_id;?>" name="is_active" class="gdri-enabled" value="1" |
2464 | 2464 | <?php if ($value == '1') { |
2465 | - echo 'checked'; |
|
2466 | - } ?>/> |
|
2465 | + echo 'checked'; |
|
2466 | + } ?>/> |
|
2467 | 2467 | <label for="is_active_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label> |
2468 | 2468 | |
2469 | 2469 | <input type="radio" id="is_active_no<?php echo $radio_id;?>" name="is_active" class="gdri-disabled" value="0" |
2470 | 2470 | <?php if ($value == '0' || !$value) { |
2471 | - echo 'checked'; |
|
2472 | - } ?>/> |
|
2471 | + echo 'checked'; |
|
2472 | + } ?>/> |
|
2473 | 2473 | <label for="is_active_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label> |
2474 | 2474 | |
2475 | 2475 | </div> |
@@ -2479,8 +2479,8 @@ discard block |
||
2479 | 2479 | |
2480 | 2480 | <input type="hidden" readonly="readonly" name="sort_order" id="sort_order" |
2481 | 2481 | value="<?php if (isset($field_info->sort_order)) { |
2482 | - echo esc_attr($field_info->sort_order); |
|
2483 | - }?>" size="50"/> |
|
2482 | + echo esc_attr($field_info->sort_order); |
|
2483 | + }?>" size="50"/> |
|
2484 | 2484 | |
2485 | 2485 | |
2486 | 2486 | |
@@ -2504,38 +2504,38 @@ discard block |
||
2504 | 2504 | </form> |
2505 | 2505 | </li> <?php |
2506 | 2506 | |
2507 | - } |
|
2507 | + } |
|
2508 | 2508 | } |
2509 | 2509 | |
2510 | 2510 | if (!function_exists('check_field_visibility')) { |
2511 | - /** |
|
2512 | - * Check field visibility as per price package. |
|
2513 | - * |
|
2514 | - * @since 1.0.0 |
|
2515 | - * @package GeoDirectory |
|
2516 | - * @global object $wpdb WordPress Database object. |
|
2517 | - * @global array $geodir_addon_list List of active GeoDirectory extensions. |
|
2518 | - * @param int|string $package_id The package ID. |
|
2519 | - * @param string $field_name The field name. |
|
2520 | - * @param string $post_type Optional. The wordpress post type. |
|
2521 | - * @return bool Returns true when field visible, otherwise false. |
|
2522 | - */ |
|
2523 | - function check_field_visibility($package_id, $field_name, $post_type) |
|
2524 | - { |
|
2525 | - global $wpdb, $geodir_addon_list; |
|
2526 | - if (!(isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes')) { |
|
2527 | - return true; |
|
2528 | - } |
|
2529 | - if (!$package_id || !$field_name || !$post_type) { |
|
2530 | - return true; |
|
2531 | - } |
|
2532 | - $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)); |
|
2533 | - |
|
2534 | - if ($wpdb->get_var($sql)) { |
|
2535 | - return true; |
|
2536 | - } |
|
2537 | - return false; |
|
2538 | - } |
|
2511 | + /** |
|
2512 | + * Check field visibility as per price package. |
|
2513 | + * |
|
2514 | + * @since 1.0.0 |
|
2515 | + * @package GeoDirectory |
|
2516 | + * @global object $wpdb WordPress Database object. |
|
2517 | + * @global array $geodir_addon_list List of active GeoDirectory extensions. |
|
2518 | + * @param int|string $package_id The package ID. |
|
2519 | + * @param string $field_name The field name. |
|
2520 | + * @param string $post_type Optional. The wordpress post type. |
|
2521 | + * @return bool Returns true when field visible, otherwise false. |
|
2522 | + */ |
|
2523 | + function check_field_visibility($package_id, $field_name, $post_type) |
|
2524 | + { |
|
2525 | + global $wpdb, $geodir_addon_list; |
|
2526 | + if (!(isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes')) { |
|
2527 | + return true; |
|
2528 | + } |
|
2529 | + if (!$package_id || !$field_name || !$post_type) { |
|
2530 | + return true; |
|
2531 | + } |
|
2532 | + $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)); |
|
2533 | + |
|
2534 | + if ($wpdb->get_var($sql)) { |
|
2535 | + return true; |
|
2536 | + } |
|
2537 | + return false; |
|
2538 | + } |
|
2539 | 2539 | } |
2540 | 2540 | |
2541 | 2541 | /** |
@@ -2551,43 +2551,43 @@ discard block |
||
2551 | 2551 | */ |
2552 | 2552 | function geodir_string_to_options($input = '', $translated = false) |
2553 | 2553 | { |
2554 | - $return = array(); |
|
2555 | - if ($input != '') { |
|
2556 | - $input = trim($input); |
|
2557 | - $input = rtrim($input, ","); |
|
2558 | - $input = ltrim($input, ","); |
|
2559 | - $input = trim($input); |
|
2560 | - } |
|
2561 | - |
|
2562 | - $input_arr = explode(',', $input); |
|
2563 | - |
|
2564 | - if (!empty($input_arr)) { |
|
2565 | - foreach ($input_arr as $input_str) { |
|
2566 | - $input_str = trim($input_str); |
|
2567 | - |
|
2568 | - if (strpos($input_str, "/") !== false) { |
|
2569 | - $input_str = explode("/", $input_str, 2); |
|
2570 | - $label = trim($input_str[0]); |
|
2571 | - if ($translated && $label != '') { |
|
2572 | - $label = __($label, 'geodirectory'); |
|
2573 | - } |
|
2574 | - $label = ucfirst($label); |
|
2575 | - $value = trim($input_str[1]); |
|
2576 | - } else { |
|
2577 | - $value = $input_str; |
|
2578 | - if ($translated && $input_str != '') { |
|
2579 | - $input_str = __($input_str, 'geodirectory'); |
|
2580 | - } |
|
2581 | - $label = ucfirst($input_str); |
|
2582 | - } |
|
2583 | - |
|
2584 | - if ($label != '') { |
|
2585 | - $return[] = array('label' => $label, 'value' => $value, 'optgroup' => NULL); |
|
2586 | - } |
|
2587 | - } |
|
2588 | - } |
|
2589 | - |
|
2590 | - return $return; |
|
2554 | + $return = array(); |
|
2555 | + if ($input != '') { |
|
2556 | + $input = trim($input); |
|
2557 | + $input = rtrim($input, ","); |
|
2558 | + $input = ltrim($input, ","); |
|
2559 | + $input = trim($input); |
|
2560 | + } |
|
2561 | + |
|
2562 | + $input_arr = explode(',', $input); |
|
2563 | + |
|
2564 | + if (!empty($input_arr)) { |
|
2565 | + foreach ($input_arr as $input_str) { |
|
2566 | + $input_str = trim($input_str); |
|
2567 | + |
|
2568 | + if (strpos($input_str, "/") !== false) { |
|
2569 | + $input_str = explode("/", $input_str, 2); |
|
2570 | + $label = trim($input_str[0]); |
|
2571 | + if ($translated && $label != '') { |
|
2572 | + $label = __($label, 'geodirectory'); |
|
2573 | + } |
|
2574 | + $label = ucfirst($label); |
|
2575 | + $value = trim($input_str[1]); |
|
2576 | + } else { |
|
2577 | + $value = $input_str; |
|
2578 | + if ($translated && $input_str != '') { |
|
2579 | + $input_str = __($input_str, 'geodirectory'); |
|
2580 | + } |
|
2581 | + $label = ucfirst($input_str); |
|
2582 | + } |
|
2583 | + |
|
2584 | + if ($label != '') { |
|
2585 | + $return[] = array('label' => $label, 'value' => $value, 'optgroup' => NULL); |
|
2586 | + } |
|
2587 | + } |
|
2588 | + } |
|
2589 | + |
|
2590 | + return $return; |
|
2591 | 2591 | } |
2592 | 2592 | |
2593 | 2593 | /** |
@@ -2602,66 +2602,66 @@ discard block |
||
2602 | 2602 | */ |
2603 | 2603 | function geodir_string_values_to_options($option_values = '', $translated = false) |
2604 | 2604 | { |
2605 | - $options = array(); |
|
2606 | - if ($option_values == '') { |
|
2607 | - return NULL; |
|
2608 | - } |
|
2609 | - |
|
2610 | - if (strpos($option_values, "{/optgroup}") !== false) { |
|
2611 | - $option_values_arr = explode("{/optgroup}", $option_values); |
|
2612 | - |
|
2613 | - foreach ($option_values_arr as $optgroup) { |
|
2614 | - if (strpos($optgroup, "{optgroup}") !== false) { |
|
2615 | - $optgroup_arr = explode("{optgroup}", $optgroup); |
|
2616 | - |
|
2617 | - $count = 0; |
|
2618 | - foreach ($optgroup_arr as $optgroup_str) { |
|
2619 | - $count++; |
|
2620 | - $optgroup_str = trim($optgroup_str); |
|
2621 | - |
|
2622 | - $optgroup_label = ''; |
|
2623 | - if (strpos($optgroup_str, "|") !== false) { |
|
2624 | - $optgroup_str_arr = explode("|", $optgroup_str, 2); |
|
2625 | - $optgroup_label = trim($optgroup_str_arr[0]); |
|
2626 | - if ($translated && $optgroup_label != '') { |
|
2627 | - $optgroup_label = __($optgroup_label, 'geodirectory'); |
|
2628 | - } |
|
2629 | - $optgroup_label = ucfirst($optgroup_label); |
|
2630 | - $optgroup_str = $optgroup_str_arr[1]; |
|
2631 | - } |
|
2632 | - |
|
2633 | - $optgroup3 = geodir_string_to_options($optgroup_str, $translated); |
|
2634 | - |
|
2635 | - if ($count > 1 && $optgroup_label != '' && !empty($optgroup3)) { |
|
2636 | - $optgroup_start = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'start')); |
|
2637 | - $optgroup_end = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'end')); |
|
2638 | - $optgroup3 = array_merge($optgroup_start, $optgroup3, $optgroup_end); |
|
2639 | - } |
|
2640 | - $options = array_merge($options, $optgroup3); |
|
2641 | - } |
|
2642 | - } else { |
|
2643 | - $optgroup1 = geodir_string_to_options($optgroup, $translated); |
|
2644 | - $options = array_merge($options, $optgroup1); |
|
2645 | - } |
|
2646 | - } |
|
2647 | - } else { |
|
2648 | - $options = geodir_string_to_options($option_values, $translated); |
|
2649 | - } |
|
2650 | - |
|
2651 | - return $options; |
|
2605 | + $options = array(); |
|
2606 | + if ($option_values == '') { |
|
2607 | + return NULL; |
|
2608 | + } |
|
2609 | + |
|
2610 | + if (strpos($option_values, "{/optgroup}") !== false) { |
|
2611 | + $option_values_arr = explode("{/optgroup}", $option_values); |
|
2612 | + |
|
2613 | + foreach ($option_values_arr as $optgroup) { |
|
2614 | + if (strpos($optgroup, "{optgroup}") !== false) { |
|
2615 | + $optgroup_arr = explode("{optgroup}", $optgroup); |
|
2616 | + |
|
2617 | + $count = 0; |
|
2618 | + foreach ($optgroup_arr as $optgroup_str) { |
|
2619 | + $count++; |
|
2620 | + $optgroup_str = trim($optgroup_str); |
|
2621 | + |
|
2622 | + $optgroup_label = ''; |
|
2623 | + if (strpos($optgroup_str, "|") !== false) { |
|
2624 | + $optgroup_str_arr = explode("|", $optgroup_str, 2); |
|
2625 | + $optgroup_label = trim($optgroup_str_arr[0]); |
|
2626 | + if ($translated && $optgroup_label != '') { |
|
2627 | + $optgroup_label = __($optgroup_label, 'geodirectory'); |
|
2628 | + } |
|
2629 | + $optgroup_label = ucfirst($optgroup_label); |
|
2630 | + $optgroup_str = $optgroup_str_arr[1]; |
|
2631 | + } |
|
2632 | + |
|
2633 | + $optgroup3 = geodir_string_to_options($optgroup_str, $translated); |
|
2634 | + |
|
2635 | + if ($count > 1 && $optgroup_label != '' && !empty($optgroup3)) { |
|
2636 | + $optgroup_start = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'start')); |
|
2637 | + $optgroup_end = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'end')); |
|
2638 | + $optgroup3 = array_merge($optgroup_start, $optgroup3, $optgroup_end); |
|
2639 | + } |
|
2640 | + $options = array_merge($options, $optgroup3); |
|
2641 | + } |
|
2642 | + } else { |
|
2643 | + $optgroup1 = geodir_string_to_options($optgroup, $translated); |
|
2644 | + $options = array_merge($options, $optgroup1); |
|
2645 | + } |
|
2646 | + } |
|
2647 | + } else { |
|
2648 | + $options = geodir_string_to_options($option_values, $translated); |
|
2649 | + } |
|
2650 | + |
|
2651 | + return $options; |
|
2652 | 2652 | } |
2653 | 2653 | |
2654 | 2654 | |
2655 | 2655 | function geodir_cfa_data_type_text($output,$result_str,$cf,$field_info){ |
2656 | - ob_start(); |
|
2657 | - |
|
2658 | - $dt_value = ''; |
|
2659 | - if (isset($field_info->data_type)) { |
|
2660 | - $dt_value = esc_attr($field_info->data_type); |
|
2661 | - }elseif(isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']){ |
|
2662 | - $dt_value = $cf['defaults']['data_type']; |
|
2663 | - } |
|
2664 | - ?> |
|
2656 | + ob_start(); |
|
2657 | + |
|
2658 | + $dt_value = ''; |
|
2659 | + if (isset($field_info->data_type)) { |
|
2660 | + $dt_value = esc_attr($field_info->data_type); |
|
2661 | + }elseif(isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']){ |
|
2662 | + $dt_value = $cf['defaults']['data_type']; |
|
2663 | + } |
|
2664 | + ?> |
|
2665 | 2665 | <li> |
2666 | 2666 | <label for="data_type"><?php _e('Field Data Type ? :', 'geodirectory'); ?></label> |
2667 | 2667 | <div class="gd-cf-input-wrap"> |
@@ -2670,16 +2670,16 @@ discard block |
||
2670 | 2670 | onchange="javascript:gd_data_type_changed(this, '<?php echo $result_str; ?>');"> |
2671 | 2671 | <option |
2672 | 2672 | value="XVARCHAR" <?php if ($dt_value == 'VARCHAR') { |
2673 | - echo 'selected="selected"'; |
|
2674 | - } ?>><?php _e('CHARACTER', 'geodirectory'); ?></option> |
|
2673 | + echo 'selected="selected"'; |
|
2674 | + } ?>><?php _e('CHARACTER', 'geodirectory'); ?></option> |
|
2675 | 2675 | <option |
2676 | 2676 | value="INT" <?php if ($dt_value == 'INT') { |
2677 | - echo 'selected="selected"'; |
|
2678 | - } ?>><?php _e('NUMBER', 'geodirectory'); ?></option> |
|
2677 | + echo 'selected="selected"'; |
|
2678 | + } ?>><?php _e('NUMBER', 'geodirectory'); ?></option> |
|
2679 | 2679 | <option |
2680 | 2680 | value="FLOAT" <?php if ($dt_value == 'FLOAT') { |
2681 | - echo 'selected="selected"'; |
|
2682 | - } ?>><?php _e('DECIMAL', 'geodirectory'); ?></option> |
|
2681 | + echo 'selected="selected"'; |
|
2682 | + } ?>><?php _e('DECIMAL', 'geodirectory'); ?></option> |
|
2683 | 2683 | </select> |
2684 | 2684 | <br/> <span><?php _e('Select Custom Field type', 'geodirectory'); ?></span> |
2685 | 2685 | |
@@ -2687,13 +2687,13 @@ discard block |
||
2687 | 2687 | </li> |
2688 | 2688 | |
2689 | 2689 | <?php |
2690 | - $value = ''; |
|
2691 | - if (isset($field_info->decimal_point)) { |
|
2692 | - $value = esc_attr($field_info->decimal_point); |
|
2693 | - }elseif(isset($cf['defaults']['decimal_point']) && $cf['defaults']['decimal_point']){ |
|
2694 | - $value = $cf['defaults']['decimal_point']; |
|
2695 | - } |
|
2696 | - ?> |
|
2690 | + $value = ''; |
|
2691 | + if (isset($field_info->decimal_point)) { |
|
2692 | + $value = esc_attr($field_info->decimal_point); |
|
2693 | + }elseif(isset($cf['defaults']['decimal_point']) && $cf['defaults']['decimal_point']){ |
|
2694 | + $value = $cf['defaults']['decimal_point']; |
|
2695 | + } |
|
2696 | + ?> |
|
2697 | 2697 | |
2698 | 2698 | <li class="decimal-point-wrapper" |
2699 | 2699 | style="<?php echo ($dt_value == 'FLOAT') ? '' : 'display:none' ?>"> |
@@ -2702,7 +2702,7 @@ discard block |
||
2702 | 2702 | <select name="decimal_point" id="decimal_point"> |
2703 | 2703 | <option value=""><?php echo _e('Select', 'geodirectory'); ?></option> |
2704 | 2704 | <?php for ($i = 1; $i <= 10; $i++) { |
2705 | - $selected = $i == $value ? 'selected="selected"' : ''; ?> |
|
2705 | + $selected = $i == $value ? 'selected="selected"' : ''; ?> |
|
2706 | 2706 | <option value="<?php echo $i; ?>" <?php echo $selected; ?>><?php echo $i; ?></option> |
2707 | 2707 | <?php } ?> |
2708 | 2708 | </select> |
@@ -2711,8 +2711,8 @@ discard block |
||
2711 | 2711 | </li> |
2712 | 2712 | <?php |
2713 | 2713 | |
2714 | - $output = ob_get_clean(); |
|
2715 | - return $output; |
|
2714 | + $output = ob_get_clean(); |
|
2715 | + return $output; |
|
2716 | 2716 | } |
2717 | 2717 | add_filter('geodir_cfa_data_type_text','geodir_cfa_data_type_text',10,4); |
2718 | 2718 | |
@@ -2748,9 +2748,9 @@ discard block |
||
2748 | 2748 | |
2749 | 2749 | |
2750 | 2750 | function geodir_cfa_advanced_editor_geodir_special_offers($output,$result_str,$cf,$field_info){ |
2751 | - if($field_info->htmlvar_name != 'geodir_special_offers'){return '';} |
|
2752 | - ob_start(); |
|
2753 | - ?> |
|
2751 | + if($field_info->htmlvar_name != 'geodir_special_offers'){return '';} |
|
2752 | + ob_start(); |
|
2753 | + ?> |
|
2754 | 2754 | <li> |
2755 | 2755 | <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'); ?> |
2756 | 2756 | <div class="gdcf-tooltip"> |
@@ -2761,13 +2761,13 @@ discard block |
||
2761 | 2761 | <div class="gd-cf-input-wrap"> |
2762 | 2762 | |
2763 | 2763 | <?php |
2764 | - $selected = ''; |
|
2765 | - if (isset($field_info->extra_fields)) |
|
2766 | - $advanced_editor = unserialize($field_info->extra_fields); |
|
2764 | + $selected = ''; |
|
2765 | + if (isset($field_info->extra_fields)) |
|
2766 | + $advanced_editor = unserialize($field_info->extra_fields); |
|
2767 | 2767 | |
2768 | - if (!empty($advanced_editor) && is_array($advanced_editor) && in_array('1', $advanced_editor)) |
|
2769 | - $selected = 'checked="checked"'; |
|
2770 | - ?> |
|
2768 | + if (!empty($advanced_editor) && is_array($advanced_editor) && in_array('1', $advanced_editor)) |
|
2769 | + $selected = 'checked="checked"'; |
|
2770 | + ?> |
|
2771 | 2771 | |
2772 | 2772 | <input type="checkbox" name="advanced_editor[]" id="advanced_editor" |
2773 | 2773 | value="1" <?php echo $selected; ?>/> |
@@ -2776,22 +2776,22 @@ discard block |
||
2776 | 2776 | </li> |
2777 | 2777 | <?php |
2778 | 2778 | |
2779 | - $output = ob_get_clean(); |
|
2780 | - return $output; |
|
2779 | + $output = ob_get_clean(); |
|
2780 | + return $output; |
|
2781 | 2781 | } |
2782 | 2782 | add_filter('geodir_cfa_advanced_editor_textarea','geodir_cfa_advanced_editor_geodir_special_offers',10,4); |
2783 | 2783 | |
2784 | 2784 | |
2785 | 2785 | function geodir_cfa_validation_pattern_text($output,$result_str,$cf,$field_info){ |
2786 | - ob_start(); |
|
2787 | - |
|
2788 | - $value = ''; |
|
2789 | - if (isset($field_info->validation_pattern)) { |
|
2790 | - $value = esc_attr($field_info->validation_pattern); |
|
2791 | - }elseif(isset($cf['defaults']['validation_pattern']) && $cf['defaults']['validation_pattern']){ |
|
2792 | - $value = esc_attr($cf['defaults']['validation_pattern']); |
|
2793 | - } |
|
2794 | - ?> |
|
2786 | + ob_start(); |
|
2787 | + |
|
2788 | + $value = ''; |
|
2789 | + if (isset($field_info->validation_pattern)) { |
|
2790 | + $value = esc_attr($field_info->validation_pattern); |
|
2791 | + }elseif(isset($cf['defaults']['validation_pattern']) && $cf['defaults']['validation_pattern']){ |
|
2792 | + $value = esc_attr($cf['defaults']['validation_pattern']); |
|
2793 | + } |
|
2794 | + ?> |
|
2795 | 2795 | <li> |
2796 | 2796 | <label for="validation_pattern" class="gd-cf-tooltip-wrap"> |
2797 | 2797 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Validation Pattern:', 'geodirectory'); ?> |
@@ -2805,13 +2805,13 @@ discard block |
||
2805 | 2805 | </div> |
2806 | 2806 | </li> |
2807 | 2807 | <?php |
2808 | - $value = ''; |
|
2809 | - if (isset($field_info->validation_msg)) { |
|
2810 | - $value = esc_attr($field_info->validation_msg); |
|
2811 | - }elseif(isset($cf['defaults']['validation_msg']) && $cf['defaults']['validation_msg']){ |
|
2812 | - $value = esc_attr($cf['defaults']['validation_msg']); |
|
2813 | - } |
|
2814 | - ?> |
|
2808 | + $value = ''; |
|
2809 | + if (isset($field_info->validation_msg)) { |
|
2810 | + $value = esc_attr($field_info->validation_msg); |
|
2811 | + }elseif(isset($cf['defaults']['validation_msg']) && $cf['defaults']['validation_msg']){ |
|
2812 | + $value = esc_attr($cf['defaults']['validation_msg']); |
|
2813 | + } |
|
2814 | + ?> |
|
2815 | 2815 | <li> |
2816 | 2816 | <label for="validation_msg" class="gd-cf-tooltip-wrap"> |
2817 | 2817 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Validation Message:', 'geodirectory'); ?> |
@@ -2826,21 +2826,21 @@ discard block |
||
2826 | 2826 | </li> |
2827 | 2827 | <?php |
2828 | 2828 | |
2829 | - $output = ob_get_clean(); |
|
2830 | - return $output; |
|
2829 | + $output = ob_get_clean(); |
|
2830 | + return $output; |
|
2831 | 2831 | } |
2832 | 2832 | add_filter('geodir_cfa_validation_pattern_text','geodir_cfa_validation_pattern_text',10,4); |
2833 | 2833 | |
2834 | 2834 | |
2835 | 2835 | function geodir_cfa_htmlvar_name_taxonomy($output,$result_str,$cf,$field_info){ |
2836 | - ob_start(); |
|
2837 | - global $post_type; |
|
2838 | - |
|
2839 | - if (!isset($field_info->post_type)) { |
|
2840 | - $post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
2841 | - } else |
|
2842 | - $post_type = $field_info->post_type; |
|
2843 | - ?> |
|
2836 | + ob_start(); |
|
2837 | + global $post_type; |
|
2838 | + |
|
2839 | + if (!isset($field_info->post_type)) { |
|
2840 | + $post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
2841 | + } else |
|
2842 | + $post_type = $field_info->post_type; |
|
2843 | + ?> |
|
2844 | 2844 | <li style="display: none;"> |
2845 | 2845 | <label for="htmlvar_name" class="gd-cf-tooltip-wrap"> |
2846 | 2846 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Select taxonomy:', 'geodirectory'); ?> |
@@ -2851,15 +2851,15 @@ discard block |
||
2851 | 2851 | <div class="gd-cf-input-wrap"> |
2852 | 2852 | <select name="htmlvar_name" id="htmlvar_name"> |
2853 | 2853 | <?php |
2854 | - $gd_taxonomy = geodir_get_taxonomies($post_type); |
|
2854 | + $gd_taxonomy = geodir_get_taxonomies($post_type); |
|
2855 | 2855 | |
2856 | - foreach ($gd_taxonomy as $gd_tax) { |
|
2857 | - ?> |
|
2856 | + foreach ($gd_taxonomy as $gd_tax) { |
|
2857 | + ?> |
|
2858 | 2858 | <option <?php if (isset($field_info->htmlvar_name) && $field_info->htmlvar_name == $gd_tax) { |
2859 | - echo 'selected="selected"'; |
|
2860 | - }?> id="<?php echo $gd_tax;?>"><?php echo $gd_tax;?></option><?php |
|
2861 | - } |
|
2862 | - ?> |
|
2859 | + echo 'selected="selected"'; |
|
2860 | + }?> id="<?php echo $gd_tax;?>"><?php echo $gd_tax;?></option><?php |
|
2861 | + } |
|
2862 | + ?> |
|
2863 | 2863 | </select> |
2864 | 2864 | </div> |
2865 | 2865 | </li> |
@@ -2875,49 +2875,49 @@ discard block |
||
2875 | 2875 | |
2876 | 2876 | <select name="cat_display_type" id="cat_display_type"> |
2877 | 2877 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'ajax_chained') { |
2878 | - echo 'selected="selected"'; |
|
2879 | - }?> value="ajax_chained"><?php _e('Ajax Chained', 'geodirectory');?></option> |
|
2878 | + echo 'selected="selected"'; |
|
2879 | + }?> value="ajax_chained"><?php _e('Ajax Chained', 'geodirectory');?></option> |
|
2880 | 2880 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'select') { |
2881 | - echo 'selected="selected"'; |
|
2882 | - }?> value="select"><?php _e('Select', 'geodirectory');?></option> |
|
2881 | + echo 'selected="selected"'; |
|
2882 | + }?> value="select"><?php _e('Select', 'geodirectory');?></option> |
|
2883 | 2883 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'multiselect') { |
2884 | - echo 'selected="selected"'; |
|
2885 | - }?> value="multiselect"><?php _e('Multiselect', 'geodirectory');?></option> |
|
2884 | + echo 'selected="selected"'; |
|
2885 | + }?> value="multiselect"><?php _e('Multiselect', 'geodirectory');?></option> |
|
2886 | 2886 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'checkbox') { |
2887 | - echo 'selected="selected"'; |
|
2888 | - }?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option> |
|
2887 | + echo 'selected="selected"'; |
|
2888 | + }?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option> |
|
2889 | 2889 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'radio') { |
2890 | - echo 'selected="selected"'; |
|
2891 | - }?> value="radio"><?php _e('Radio', 'geodirectory');?></option> |
|
2890 | + echo 'selected="selected"'; |
|
2891 | + }?> value="radio"><?php _e('Radio', 'geodirectory');?></option> |
|
2892 | 2892 | </select> |
2893 | 2893 | </div> |
2894 | 2894 | </li> |
2895 | 2895 | <?php |
2896 | 2896 | |
2897 | - $output = ob_get_clean(); |
|
2898 | - return $output; |
|
2897 | + $output = ob_get_clean(); |
|
2898 | + return $output; |
|
2899 | 2899 | } |
2900 | 2900 | add_filter('geodir_cfa_htmlvar_name_taxonomy','geodir_cfa_htmlvar_name_taxonomy',10,4); |
2901 | 2901 | |
2902 | 2902 | |
2903 | 2903 | function geodir_cfa_extra_fields_address($output,$result_str,$cf,$field_info){ |
2904 | 2904 | |
2905 | - ob_start(); |
|
2906 | - if (isset($field_info->extra_fields) && $field_info->extra_fields != '') { |
|
2907 | - $address = stripslashes_deep(unserialize($field_info->extra_fields)); |
|
2908 | - } |
|
2905 | + ob_start(); |
|
2906 | + if (isset($field_info->extra_fields) && $field_info->extra_fields != '') { |
|
2907 | + $address = stripslashes_deep(unserialize($field_info->extra_fields)); |
|
2908 | + } |
|
2909 | 2909 | |
2910 | - $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500); |
|
2911 | - ?> |
|
2910 | + $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500); |
|
2911 | + ?> |
|
2912 | 2912 | <?php |
2913 | - /** |
|
2914 | - * Called on the add custom fields settings page before the address field is output. |
|
2915 | - * |
|
2916 | - * @since 1.0.0 |
|
2917 | - * @param array $address The address settings array. |
|
2918 | - * @param object $field_info Extra fields info. |
|
2919 | - */ |
|
2920 | - do_action('geodir_address_extra_admin_fields', $address, $field_info); ?> |
|
2913 | + /** |
|
2914 | + * Called on the add custom fields settings page before the address field is output. |
|
2915 | + * |
|
2916 | + * @since 1.0.0 |
|
2917 | + * @param array $address The address settings array. |
|
2918 | + * @param object $field_info Extra fields info. |
|
2919 | + */ |
|
2920 | + do_action('geodir_address_extra_admin_fields', $address, $field_info); ?> |
|
2921 | 2921 | |
2922 | 2922 | <li> |
2923 | 2923 | <label for="show_zip" class="gd-cf-tooltip-wrap"> |
@@ -2930,14 +2930,14 @@ discard block |
||
2930 | 2930 | |
2931 | 2931 | <input type="radio" id="show_zip_yes<?php echo $radio_id;?>" name="extra[show_zip]" class="gdri-enabled" value="1" |
2932 | 2932 | <?php if (isset($address['show_zip']) && $address['show_zip'] == '1') { |
2933 | - echo 'checked'; |
|
2934 | - } ?>/> |
|
2933 | + echo 'checked'; |
|
2934 | + } ?>/> |
|
2935 | 2935 | <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> |
2936 | 2936 | |
2937 | 2937 | <input type="radio" id="show_zip_no<?php echo $radio_id;?>" name="extra[show_zip]" class="gdri-disabled" value="0" |
2938 | 2938 | <?php if ((isset($address['show_zip']) && !$address['show_zip']) || !isset($address['show_zip'])) { |
2939 | - echo 'checked'; |
|
2940 | - } ?>/> |
|
2939 | + echo 'checked'; |
|
2940 | + } ?>/> |
|
2941 | 2941 | <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> |
2942 | 2942 | |
2943 | 2943 | |
@@ -2954,8 +2954,8 @@ discard block |
||
2954 | 2954 | <div class="gd-cf-input-wrap"> |
2955 | 2955 | <input type="text" name="extra[zip_lable]" id="zip_lable" |
2956 | 2956 | value="<?php if (isset($address['zip_lable'])) { |
2957 | - echo esc_attr($address['zip_lable']); |
|
2958 | - }?>"/> |
|
2957 | + echo esc_attr($address['zip_lable']); |
|
2958 | + }?>"/> |
|
2959 | 2959 | </div> |
2960 | 2960 | </li> |
2961 | 2961 | |
@@ -2972,8 +2972,8 @@ discard block |
||
2972 | 2972 | <div class="gd-cf-input-wrap"> |
2973 | 2973 | <input type="text" name="extra[map_lable]" id="map_lable" |
2974 | 2974 | value="<?php if (isset($address['map_lable'])) { |
2975 | - echo esc_attr($address['map_lable']); |
|
2976 | - }?>"/> |
|
2975 | + echo esc_attr($address['map_lable']); |
|
2976 | + }?>"/> |
|
2977 | 2977 | </div> |
2978 | 2978 | </li> |
2979 | 2979 | |
@@ -2988,14 +2988,14 @@ discard block |
||
2988 | 2988 | |
2989 | 2989 | <input type="radio" id="show_mapzoom_yes<?php echo $radio_id;?>" name="extra[show_mapzoom]" class="gdri-enabled" value="1" |
2990 | 2990 | <?php if (isset($address['show_mapzoom']) && $address['show_mapzoom'] == '1') { |
2991 | - echo 'checked'; |
|
2992 | - } ?>/> |
|
2991 | + echo 'checked'; |
|
2992 | + } ?>/> |
|
2993 | 2993 | <label for="show_mapzoom_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label> |
2994 | 2994 | |
2995 | 2995 | <input type="radio" id="show_mapzoom_no<?php echo $radio_id;?>" name="extra[show_mapzoom]" class="gdri-disabled" value="0" |
2996 | 2996 | <?php if ((isset($address['show_mapzoom']) && !$address['show_mapzoom']) || !isset($address['show_mapzoom'])) { |
2997 | - echo 'checked'; |
|
2998 | - } ?>/> |
|
2997 | + echo 'checked'; |
|
2998 | + } ?>/> |
|
2999 | 2999 | <label for="show_mapzoom_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label> |
3000 | 3000 | |
3001 | 3001 | </div> |
@@ -3012,14 +3012,14 @@ discard block |
||
3012 | 3012 | |
3013 | 3013 | <input type="radio" id="show_mapview_yes<?php echo $radio_id;?>" name="extra[show_mapview]" class="gdri-enabled" value="1" |
3014 | 3014 | <?php if (isset($address['show_mapview']) && $address['show_mapview'] == '1') { |
3015 | - echo 'checked'; |
|
3016 | - } ?>/> |
|
3015 | + echo 'checked'; |
|
3016 | + } ?>/> |
|
3017 | 3017 | <label for="show_mapview_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label> |
3018 | 3018 | |
3019 | 3019 | <input type="radio" id="show_mapview_no<?php echo $radio_id;?>" name="extra[show_mapview]" class="gdri-disabled" value="0" |
3020 | 3020 | <?php if ((isset($address['show_mapview']) && !$address['show_mapview']) || !isset($address['show_mapview'])) { |
3021 | - echo 'checked'; |
|
3022 | - } ?>/> |
|
3021 | + echo 'checked'; |
|
3022 | + } ?>/> |
|
3023 | 3023 | <label for="show_mapview_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label> |
3024 | 3024 | |
3025 | 3025 | </div> |
@@ -3036,8 +3036,8 @@ discard block |
||
3036 | 3036 | <div class="gd-cf-input-wrap"> |
3037 | 3037 | <input type="text" name="extra[mapview_lable]" id="mapview_lable" |
3038 | 3038 | value="<?php if (isset($address['mapview_lable'])) { |
3039 | - echo esc_attr($address['mapview_lable']); |
|
3040 | - }?>"/> |
|
3039 | + echo esc_attr($address['mapview_lable']); |
|
3040 | + }?>"/> |
|
3041 | 3041 | </div> |
3042 | 3042 | </li> |
3043 | 3043 | <li> |
@@ -3051,29 +3051,29 @@ discard block |
||
3051 | 3051 | |
3052 | 3052 | <input type="radio" id="show_latlng_yes<?php echo $radio_id;?>" name="extra[show_latlng]" class="gdri-enabled" value="1" |
3053 | 3053 | <?php if (isset($address['show_latlng']) && $address['show_latlng'] == '1') { |
3054 | - echo 'checked'; |
|
3055 | - } ?>/> |
|
3054 | + echo 'checked'; |
|
3055 | + } ?>/> |
|
3056 | 3056 | <label for="show_latlng_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label> |
3057 | 3057 | |
3058 | 3058 | <input type="radio" id="show_latlng_no<?php echo $radio_id;?>" name="extra[show_latlng]" class="gdri-disabled" value="0" |
3059 | 3059 | <?php if ((isset($address['show_latlng']) && !$address['show_latlng']) || !isset($address['show_latlng'])) { |
3060 | - echo 'checked'; |
|
3061 | - } ?>/> |
|
3060 | + echo 'checked'; |
|
3061 | + } ?>/> |
|
3062 | 3062 | <label for="show_latlng_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label> |
3063 | 3063 | |
3064 | 3064 | </div> |
3065 | 3065 | </li> |
3066 | 3066 | <?php |
3067 | 3067 | |
3068 | - $html = ob_get_clean(); |
|
3069 | - return $output.$html; |
|
3068 | + $html = ob_get_clean(); |
|
3069 | + return $output.$html; |
|
3070 | 3070 | } |
3071 | 3071 | add_filter('geodir_cfa_extra_fields_address','geodir_cfa_extra_fields_address',10,4); |
3072 | 3072 | |
3073 | 3073 | |
3074 | 3074 | function geodir_cfa_extra_fields_multiselect($output,$result_str,$cf,$field_info){ |
3075 | - ob_start(); |
|
3076 | - ?> |
|
3075 | + ob_start(); |
|
3076 | + ?> |
|
3077 | 3077 | <li> |
3078 | 3078 | <label for="multi_display_type" class="gd-cf-tooltip-wrap"> |
3079 | 3079 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Multiselect display type :', 'geodirectory'); ?> |
@@ -3085,14 +3085,14 @@ discard block |
||
3085 | 3085 | |
3086 | 3086 | <select name="multi_display_type" id="multi_display_type"> |
3087 | 3087 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'select') { |
3088 | - echo 'selected="selected"'; |
|
3089 | - }?> value="select"><?php _e('Select', 'geodirectory');?></option> |
|
3088 | + echo 'selected="selected"'; |
|
3089 | + }?> value="select"><?php _e('Select', 'geodirectory');?></option> |
|
3090 | 3090 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'checkbox') { |
3091 | - echo 'selected="selected"'; |
|
3092 | - }?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option> |
|
3091 | + echo 'selected="selected"'; |
|
3092 | + }?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option> |
|
3093 | 3093 | <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'radio') { |
3094 | - echo 'selected="selected"'; |
|
3095 | - }?> value="radio"><?php _e('Radio', 'geodirectory');?></option> |
|
3094 | + echo 'selected="selected"'; |
|
3095 | + }?> value="radio"><?php _e('Radio', 'geodirectory');?></option> |
|
3096 | 3096 | </select> |
3097 | 3097 | |
3098 | 3098 | <br/> |
@@ -3100,25 +3100,25 @@ discard block |
||
3100 | 3100 | </li> |
3101 | 3101 | <?php |
3102 | 3102 | |
3103 | - $html = ob_get_clean(); |
|
3104 | - return $output.$html; |
|
3103 | + $html = ob_get_clean(); |
|
3104 | + return $output.$html; |
|
3105 | 3105 | } |
3106 | 3106 | add_filter('geodir_cfa_extra_fields_multiselect','geodir_cfa_extra_fields_multiselect',10,4); |
3107 | 3107 | |
3108 | 3108 | |
3109 | 3109 | function geodir_cfa_extra_fields_smr($output,$result_str,$cf,$field_info){ |
3110 | 3110 | |
3111 | - ob_start(); |
|
3111 | + ob_start(); |
|
3112 | 3112 | |
3113 | - $value = ''; |
|
3114 | - if (isset($field_info->option_values)) { |
|
3115 | - $value = esc_attr($field_info->option_values); |
|
3116 | - }elseif(isset($cf['defaults']['option_values']) && $cf['defaults']['option_values']){ |
|
3117 | - $value = esc_attr($cf['defaults']['option_values']); |
|
3118 | - } |
|
3113 | + $value = ''; |
|
3114 | + if (isset($field_info->option_values)) { |
|
3115 | + $value = esc_attr($field_info->option_values); |
|
3116 | + }elseif(isset($cf['defaults']['option_values']) && $cf['defaults']['option_values']){ |
|
3117 | + $value = esc_attr($cf['defaults']['option_values']); |
|
3118 | + } |
|
3119 | 3119 | |
3120 | - $field_type = isset($field_info->field_type) ? $field_info->field_type : ''; |
|
3121 | - ?> |
|
3120 | + $field_type = isset($field_info->field_type) ? $field_info->field_type : ''; |
|
3121 | + ?> |
|
3122 | 3122 | <li> |
3123 | 3123 | <label for="option_values" class="gd-cf-tooltip-wrap"> |
3124 | 3124 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Option Values :', 'geodirectory'); ?> |
@@ -3145,8 +3145,8 @@ discard block |
||
3145 | 3145 | </li> |
3146 | 3146 | <?php |
3147 | 3147 | |
3148 | - $html = ob_get_clean(); |
|
3149 | - return $output.$html; |
|
3148 | + $html = ob_get_clean(); |
|
3149 | + return $output.$html; |
|
3150 | 3150 | } |
3151 | 3151 | add_filter('geodir_cfa_extra_fields_multiselect','geodir_cfa_extra_fields_smr',10,4); |
3152 | 3152 | add_filter('geodir_cfa_extra_fields_select','geodir_cfa_extra_fields_smr',10,4); |
@@ -3154,12 +3154,12 @@ discard block |
||
3154 | 3154 | |
3155 | 3155 | |
3156 | 3156 | function geodir_cfa_extra_fields_datepicker($output,$result_str,$cf,$field_info){ |
3157 | - ob_start(); |
|
3158 | - $extra = array(); |
|
3159 | - if (isset($field_info->extra_fields) && $field_info->extra_fields != '') { |
|
3160 | - $extra = unserialize($field_info->extra_fields); |
|
3161 | - } |
|
3162 | - ?> |
|
3157 | + ob_start(); |
|
3158 | + $extra = array(); |
|
3159 | + if (isset($field_info->extra_fields) && $field_info->extra_fields != '') { |
|
3160 | + $extra = unserialize($field_info->extra_fields); |
|
3161 | + } |
|
3162 | + ?> |
|
3163 | 3163 | <li> |
3164 | 3164 | <label for="date_format" class="gd-cf-tooltip-wrap"> |
3165 | 3165 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Date Format :', 'geodirectory'); ?> |
@@ -3169,52 +3169,52 @@ discard block |
||
3169 | 3169 | </label> |
3170 | 3170 | <div class="gd-cf-input-wrap" style="overflow:inherit;"> |
3171 | 3171 | <?php |
3172 | - $date_formats = array( |
|
3173 | - 'm/d/Y', |
|
3174 | - 'd/m/Y', |
|
3175 | - 'Y/m/d', |
|
3176 | - 'm-d-Y', |
|
3177 | - 'd-m-Y', |
|
3178 | - 'Y-m-d', |
|
3179 | - 'F j, Y', |
|
3180 | - ); |
|
3181 | - /** |
|
3182 | - * Filter the custom field date format options. |
|
3183 | - * |
|
3184 | - * @since 1.6.5 |
|
3185 | - * @param array $date_formats The PHP date format array. |
|
3186 | - */ |
|
3187 | - $date_formats = apply_filters('geodir_date_formats',$date_formats); |
|
3188 | - ?> |
|
3172 | + $date_formats = array( |
|
3173 | + 'm/d/Y', |
|
3174 | + 'd/m/Y', |
|
3175 | + 'Y/m/d', |
|
3176 | + 'm-d-Y', |
|
3177 | + 'd-m-Y', |
|
3178 | + 'Y-m-d', |
|
3179 | + 'F j, Y', |
|
3180 | + ); |
|
3181 | + /** |
|
3182 | + * Filter the custom field date format options. |
|
3183 | + * |
|
3184 | + * @since 1.6.5 |
|
3185 | + * @param array $date_formats The PHP date format array. |
|
3186 | + */ |
|
3187 | + $date_formats = apply_filters('geodir_date_formats',$date_formats); |
|
3188 | + ?> |
|
3189 | 3189 | <select name="extra[date_format]" id="date_format"> |
3190 | 3190 | <?php |
3191 | - foreach($date_formats as $format){ |
|
3192 | - $selected = ''; |
|
3193 | - if(!empty($extra) && esc_attr($extra['date_format'])==$format){ |
|
3194 | - $selected = "selected='selected'"; |
|
3195 | - } |
|
3196 | - echo "<option $selected value='$format'>$format (".date_i18n( $format, time()).")</option>"; |
|
3197 | - } |
|
3198 | - ?> |
|
3191 | + foreach($date_formats as $format){ |
|
3192 | + $selected = ''; |
|
3193 | + if(!empty($extra) && esc_attr($extra['date_format'])==$format){ |
|
3194 | + $selected = "selected='selected'"; |
|
3195 | + } |
|
3196 | + echo "<option $selected value='$format'>$format (".date_i18n( $format, time()).")</option>"; |
|
3197 | + } |
|
3198 | + ?> |
|
3199 | 3199 | </select> |
3200 | 3200 | |
3201 | 3201 | </div> |
3202 | 3202 | </li> |
3203 | 3203 | <?php |
3204 | 3204 | |
3205 | - $html = ob_get_clean(); |
|
3206 | - return $output.$html; |
|
3205 | + $html = ob_get_clean(); |
|
3206 | + return $output.$html; |
|
3207 | 3207 | } |
3208 | 3208 | add_filter('geodir_cfa_extra_fields_datepicker','geodir_cfa_extra_fields_datepicker',10,4); |
3209 | 3209 | |
3210 | 3210 | |
3211 | 3211 | function geodir_cfa_extra_fields_file($output,$result_str,$cf,$field_info){ |
3212 | - ob_start(); |
|
3213 | - $allowed_file_types = geodir_allowed_mime_types(); |
|
3212 | + ob_start(); |
|
3213 | + $allowed_file_types = geodir_allowed_mime_types(); |
|
3214 | 3214 | |
3215 | - $extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : ''; |
|
3216 | - $gd_file_types = !empty($extra_fields) && !empty($extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : array('*'); |
|
3217 | - ?> |
|
3215 | + $extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : ''; |
|
3216 | + $gd_file_types = !empty($extra_fields) && !empty($extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : array('*'); |
|
3217 | + ?> |
|
3218 | 3218 | <li> |
3219 | 3219 | <label for="gd_file_types" class="gd-cf-tooltip-wrap"> |
3220 | 3220 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Allowed file types :', 'geodirectory'); ?> |
@@ -3237,33 +3237,33 @@ discard block |
||
3237 | 3237 | </li> |
3238 | 3238 | <?php |
3239 | 3239 | |
3240 | - $html = ob_get_clean(); |
|
3241 | - return $output.$html; |
|
3240 | + $html = ob_get_clean(); |
|
3241 | + return $output.$html; |
|
3242 | 3242 | } |
3243 | 3243 | add_filter('geodir_cfa_extra_fields_file','geodir_cfa_extra_fields_file',10,4); |
3244 | 3244 | |
3245 | 3245 | function geodir_cfa_extra_fields_text($output,$result_str,$cf,$field_info){ |
3246 | - ob_start(); |
|
3246 | + ob_start(); |
|
3247 | 3247 | |
3248 | - $extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : ''; |
|
3248 | + $extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : ''; |
|
3249 | 3249 | // print_r($cf);echo '###'; |
3250 | 3250 | |
3251 | 3251 | |
3252 | 3252 | |
3253 | - $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500); |
|
3253 | + $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500); |
|
3254 | 3254 | |
3255 | 3255 | |
3256 | - $value = ''; |
|
3257 | - if ($extra_fields && isset($extra_fields['is_price'])) { |
|
3258 | - $value = esc_attr($extra_fields['is_price']); |
|
3259 | - }elseif(isset($cf['defaults']['extra_fields']['is_price']) && $cf['defaults']['extra_fields']['is_price']){ |
|
3260 | - $value = esc_attr($cf['defaults']['extra_fields']['is_price']); |
|
3261 | - } |
|
3256 | + $value = ''; |
|
3257 | + if ($extra_fields && isset($extra_fields['is_price'])) { |
|
3258 | + $value = esc_attr($extra_fields['is_price']); |
|
3259 | + }elseif(isset($cf['defaults']['extra_fields']['is_price']) && $cf['defaults']['extra_fields']['is_price']){ |
|
3260 | + $value = esc_attr($cf['defaults']['extra_fields']['is_price']); |
|
3261 | + } |
|
3262 | 3262 | |
3263 | - $show_price_extra = ($value==1) ? 1 : 0; |
|
3263 | + $show_price_extra = ($value==1) ? 1 : 0; |
|
3264 | 3264 | |
3265 | - $show_price = (isset($field_info->data_type) && ($field_info->data_type=='INT' && $field_info->data_type=='FLOAT')) ? 1 : 0; |
|
3266 | - ?> |
|
3265 | + $show_price = (isset($field_info->data_type) && ($field_info->data_type=='INT' && $field_info->data_type=='FLOAT')) ? 1 : 0; |
|
3266 | + ?> |
|
3267 | 3267 | <li class="gdcf-price-extra-set" <?php if(!$show_price){ echo "style='display:none;'";}?>> |
3268 | 3268 | <label for="is_price" class="gd-cf-tooltip-wrap"> |
3269 | 3269 | <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Display as price? :', 'geodirectory'); ?> |
@@ -3275,14 +3275,14 @@ discard block |
||
3275 | 3275 | |
3276 | 3276 | <input type="radio" id="is_price_yes<?php echo $radio_id;?>" name="extra[is_price]" class="gdri-enabled" value="1" |
3277 | 3277 | <?php if ($value == '1') { |
3278 | - echo 'checked'; |
|
3279 | - } ?>/> |
|
3278 | + echo 'checked'; |
|
3279 | + } ?>/> |
|
3280 | 3280 | <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> |
3281 | 3281 | |
3282 | 3282 | <input type="radio" id="is_price_no<?php echo $radio_id;?>" name="extra[is_price]" class="gdri-disabled" value="0" |
3283 | 3283 | <?php if ($value == '0' || !$value) { |
3284 | - echo 'checked'; |
|
3285 | - } ?>/> |
|
3284 | + echo 'checked'; |
|
3285 | + } ?>/> |
|
3286 | 3286 | <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> |
3287 | 3287 | |
3288 | 3288 | </div> |
@@ -3290,13 +3290,13 @@ discard block |
||
3290 | 3290 | |
3291 | 3291 | <?php |
3292 | 3292 | |
3293 | - $value = ''; |
|
3294 | - if ($extra_fields && isset($extra_fields['thousand_separator'])) { |
|
3295 | - $value = esc_attr($extra_fields['thousand_separator']); |
|
3296 | - }elseif(isset($cf['defaults']['extra_fields']['thousand_separator']) && $cf['defaults']['extra_fields']['thousand_separator']){ |
|
3297 | - $value = esc_attr($cf['defaults']['extra_fields']['thousand_separator']); |
|
3298 | - } |
|
3299 | - ?> |
|
3293 | + $value = ''; |
|
3294 | + if ($extra_fields && isset($extra_fields['thousand_separator'])) { |
|
3295 | + $value = esc_attr($extra_fields['thousand_separator']); |
|
3296 | + }elseif(isset($cf['defaults']['extra_fields']['thousand_separator']) && $cf['defaults']['extra_fields']['thousand_separator']){ |
|
3297 | + $value = esc_attr($cf['defaults']['extra_fields']['thousand_separator']); |
|
3298 | + } |
|
3299 | + ?> |
|
3300 | 3300 | <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>> |
3301 | 3301 | <label for="thousand_separator" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Thousand separator :', 'geodirectory');?> |
3302 | 3302 | <div class="gdcf-tooltip"> |
@@ -3317,13 +3317,13 @@ discard block |
||
3317 | 3317 | |
3318 | 3318 | <?php |
3319 | 3319 | |
3320 | - $value = ''; |
|
3321 | - if ($extra_fields && isset($extra_fields['decimal_separator'])) { |
|
3322 | - $value = esc_attr($extra_fields['decimal_separator']); |
|
3323 | - }elseif(isset($cf['defaults']['extra_fields']['decimal_separator']) && $cf['defaults']['extra_fields']['decimal_separator']){ |
|
3324 | - $value = esc_attr($cf['defaults']['extra_fields']['decimal_separator']); |
|
3325 | - } |
|
3326 | - ?> |
|
3320 | + $value = ''; |
|
3321 | + if ($extra_fields && isset($extra_fields['decimal_separator'])) { |
|
3322 | + $value = esc_attr($extra_fields['decimal_separator']); |
|
3323 | + }elseif(isset($cf['defaults']['extra_fields']['decimal_separator']) && $cf['defaults']['extra_fields']['decimal_separator']){ |
|
3324 | + $value = esc_attr($cf['defaults']['extra_fields']['decimal_separator']); |
|
3325 | + } |
|
3326 | + ?> |
|
3327 | 3327 | <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>> |
3328 | 3328 | <label for="decimal_separator" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Decimal separator :', 'geodirectory');?> |
3329 | 3329 | <div class="gdcf-tooltip"> |
@@ -3340,13 +3340,13 @@ discard block |
||
3340 | 3340 | |
3341 | 3341 | <?php |
3342 | 3342 | |
3343 | - $value = ''; |
|
3344 | - if ($extra_fields && isset($extra_fields['decimal_display'])) { |
|
3345 | - $value = esc_attr($extra_fields['decimal_display']); |
|
3346 | - }elseif(isset($cf['defaults']['extra_fields']['decimal_display']) && $cf['defaults']['extra_fields']['decimal_display']){ |
|
3347 | - $value = esc_attr($cf['defaults']['extra_fields']['decimal_display']); |
|
3348 | - } |
|
3349 | - ?> |
|
3343 | + $value = ''; |
|
3344 | + if ($extra_fields && isset($extra_fields['decimal_display'])) { |
|
3345 | + $value = esc_attr($extra_fields['decimal_display']); |
|
3346 | + }elseif(isset($cf['defaults']['extra_fields']['decimal_display']) && $cf['defaults']['extra_fields']['decimal_display']){ |
|
3347 | + $value = esc_attr($cf['defaults']['extra_fields']['decimal_display']); |
|
3348 | + } |
|
3349 | + ?> |
|
3350 | 3350 | <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>> |
3351 | 3351 | <label for="decimal_display" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Decimal display :', 'geodirectory');?> |
3352 | 3352 | <div class="gdcf-tooltip"> |
@@ -3363,13 +3363,13 @@ discard block |
||
3363 | 3363 | |
3364 | 3364 | <?php |
3365 | 3365 | |
3366 | - $value = ''; |
|
3367 | - if ($extra_fields && isset($extra_fields['currency_symbol'])) { |
|
3368 | - $value = esc_attr($extra_fields['currency_symbol']); |
|
3369 | - }elseif(isset($cf['defaults']['extra_fields']['currency_symbol']) && $cf['defaults']['extra_fields']['currency_symbol']){ |
|
3370 | - $value = esc_attr($cf['defaults']['extra_fields']['currency_symbol']); |
|
3371 | - } |
|
3372 | - ?> |
|
3366 | + $value = ''; |
|
3367 | + if ($extra_fields && isset($extra_fields['currency_symbol'])) { |
|
3368 | + $value = esc_attr($extra_fields['currency_symbol']); |
|
3369 | + }elseif(isset($cf['defaults']['extra_fields']['currency_symbol']) && $cf['defaults']['extra_fields']['currency_symbol']){ |
|
3370 | + $value = esc_attr($cf['defaults']['extra_fields']['currency_symbol']); |
|
3371 | + } |
|
3372 | + ?> |
|
3373 | 3373 | <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>> |
3374 | 3374 | <label for="currency_symbol" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Currency symbol :', 'geodirectory');?> |
3375 | 3375 | <div class="gdcf-tooltip"> |
@@ -3384,13 +3384,13 @@ discard block |
||
3384 | 3384 | |
3385 | 3385 | <?php |
3386 | 3386 | |
3387 | - $value = ''; |
|
3388 | - if ($extra_fields && isset($extra_fields['currency_symbol_placement'])) { |
|
3389 | - $value = esc_attr($extra_fields['currency_symbol_placement']); |
|
3390 | - }elseif(isset($cf['defaults']['extra_fields']['currency_symbol_placement']) && $cf['defaults']['extra_fields']['currency_symbol_placement']){ |
|
3391 | - $value = esc_attr($cf['defaults']['extra_fields']['currency_symbol_placement']); |
|
3392 | - } |
|
3393 | - ?> |
|
3387 | + $value = ''; |
|
3388 | + if ($extra_fields && isset($extra_fields['currency_symbol_placement'])) { |
|
3389 | + $value = esc_attr($extra_fields['currency_symbol_placement']); |
|
3390 | + }elseif(isset($cf['defaults']['extra_fields']['currency_symbol_placement']) && $cf['defaults']['extra_fields']['currency_symbol_placement']){ |
|
3391 | + $value = esc_attr($cf['defaults']['extra_fields']['currency_symbol_placement']); |
|
3392 | + } |
|
3393 | + ?> |
|
3394 | 3394 | <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>> |
3395 | 3395 | <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');?> |
3396 | 3396 | <div class="gdcf-tooltip"> |
@@ -3408,225 +3408,225 @@ discard block |
||
3408 | 3408 | |
3409 | 3409 | <?php |
3410 | 3410 | |
3411 | - $html = ob_get_clean(); |
|
3412 | - return $output.$html; |
|
3411 | + $html = ob_get_clean(); |
|
3412 | + return $output.$html; |
|
3413 | 3413 | } |
3414 | 3414 | add_filter('geodir_cfa_extra_fields_text','geodir_cfa_extra_fields_text',10,4); |
3415 | 3415 | |
3416 | 3416 | function geodir_default_custom_fields($post_type='gd_place',$package_id=''){ |
3417 | - $fields = array(); |
|
3418 | - $package = ($package_id=='') ? '' : array($package_id); |
|
3419 | - |
|
3420 | - $fields[] = array('listing_type' => $post_type, |
|
3421 | - 'data_type' => 'VARCHAR', |
|
3422 | - 'field_type' => 'taxonomy', |
|
3423 | - 'admin_title' => __('Category', 'geodirectory'), |
|
3424 | - 'admin_desc' => __('SELECT listing category FROM here. SELECT at least one CATEGORY', 'geodirectory'), |
|
3425 | - 'site_title' => __('Category', 'geodirectory'), |
|
3426 | - 'htmlvar_name' => $post_type.'category', |
|
3427 | - 'default_value' => '', |
|
3428 | - 'is_default' => '1', |
|
3429 | - 'is_admin' => '1', |
|
3430 | - 'is_required' => '1', |
|
3431 | - 'show_in' => '[detail]', |
|
3432 | - 'show_on_pkg' => $package, |
|
3433 | - 'clabels' => __('Category', 'geodirectory')); |
|
3434 | - |
|
3435 | - $fields[] = array('listing_type' => $post_type, |
|
3436 | - 'data_type' => 'VARCHAR', |
|
3437 | - 'field_type' => 'address', |
|
3438 | - 'admin_title' => __('Address', 'geodirectory'), |
|
3439 | - 'admin_desc' => ADDRESS_MSG, |
|
3440 | - 'site_title' => __('Address', 'geodirectory'), |
|
3441 | - 'htmlvar_name' => 'post', |
|
3442 | - 'default_value' => '', |
|
3443 | - 'option_values' => '', |
|
3444 | - 'is_default' => '1', |
|
3445 | - 'is_admin' => '1', |
|
3446 | - 'is_required' => '1', |
|
3447 | - 'show_in' => '[detail],[mapbubble]', |
|
3448 | - 'show_on_pkg' => $package, |
|
3449 | - 'required_msg' => __('Address fields are required', 'geodirectory'), |
|
3450 | - 'clabels' => __('Address', 'geodirectory'), |
|
3451 | - 'extra' => array('show_city' => 1, 'city_lable' => __('City', 'geodirectory'), |
|
3452 | - 'show_region' => 1, 'region_lable' => __('Region', 'geodirectory'), |
|
3453 | - 'show_country' => 1, 'country_lable' => __('Country', 'geodirectory'), |
|
3454 | - 'show_zip' => 1, 'zip_lable' => __('Zip/Post Code', 'geodirectory'), |
|
3455 | - 'show_map' => 1, 'map_lable' => __('Set Address On Map', 'geodirectory'), |
|
3456 | - 'show_mapview' => 1, 'mapview_lable' => __('Select Map View', 'geodirectory'), |
|
3457 | - 'show_mapzoom' => 1, 'mapzoom_lable' => 'hidden', |
|
3458 | - 'show_latlng' => 1)); |
|
3459 | - |
|
3460 | - $fields[] = array('listing_type' => $post_type, |
|
3461 | - 'data_type' => 'VARCHAR', |
|
3462 | - 'field_type' => 'text', |
|
3463 | - 'admin_title' => __('Time', 'geodirectory'), |
|
3464 | - 'admin_desc' => __('Enter Business or Listing Timing Information.<br/>eg. : 10.00 am to 6 pm every day', 'geodirectory'), |
|
3465 | - 'site_title' => __('Time', 'geodirectory'), |
|
3466 | - 'htmlvar_name' => 'timing', |
|
3467 | - 'default_value' => '', |
|
3468 | - 'option_values' => '', |
|
3469 | - 'is_default' => '1', |
|
3470 | - 'is_admin' => '1', |
|
3471 | - 'show_in' => '[detail],[mapbubble]', |
|
3472 | - 'show_on_pkg' => $package, |
|
3473 | - 'clabels' => __('Time', 'geodirectory')); |
|
3474 | - |
|
3475 | - $fields[] = array('listing_type' => $post_type, |
|
3476 | - 'data_type' => 'VARCHAR', |
|
3477 | - 'field_type' => 'phone', |
|
3478 | - 'admin_title' => __('Phone', 'geodirectory'), |
|
3479 | - 'admin_desc' => __('You can enter phone number,cell phone number etc.', 'geodirectory'), |
|
3480 | - 'site_title' => __('Phone', 'geodirectory'), |
|
3481 | - 'htmlvar_name' => 'contact', |
|
3482 | - 'default_value' => '', |
|
3483 | - 'option_values' => '', |
|
3484 | - 'is_default' => '1', |
|
3485 | - 'is_admin' => '1', |
|
3486 | - 'show_in' => '[detail],[mapbubble]', |
|
3487 | - 'show_on_pkg' => $package, |
|
3488 | - 'clabels' => __('Phone', 'geodirectory')); |
|
3489 | - |
|
3490 | - $fields[] = array('listing_type' => $post_type, |
|
3491 | - 'data_type' => 'VARCHAR', |
|
3492 | - 'field_type' => 'email', |
|
3493 | - 'admin_title' => __('Email', 'geodirectory'), |
|
3494 | - 'admin_desc' => __('You can enter your business or listing email.', 'geodirectory'), |
|
3495 | - 'site_title' => __('Email', 'geodirectory'), |
|
3496 | - 'htmlvar_name' => 'email', |
|
3497 | - 'default_value' => '', |
|
3498 | - 'option_values' => '', |
|
3499 | - 'is_default' => '1', |
|
3500 | - 'is_admin' => '1', |
|
3501 | - 'show_in' => '[detail]', |
|
3502 | - 'show_on_pkg' => $package, |
|
3503 | - 'clabels' => __('Email', 'geodirectory')); |
|
3504 | - |
|
3505 | - $fields[] = array('listing_type' => $post_type, |
|
3506 | - 'data_type' => 'VARCHAR', |
|
3507 | - 'field_type' => 'url', |
|
3508 | - 'admin_title' => __('Website', 'geodirectory'), |
|
3509 | - 'admin_desc' => __('You can enter your business or listing website.', 'geodirectory'), |
|
3510 | - 'site_title' => __('Website', 'geodirectory'), |
|
3511 | - 'htmlvar_name' => 'website', |
|
3512 | - 'default_value' => '', |
|
3513 | - 'option_values' => '', |
|
3514 | - 'is_default' => '1', |
|
3515 | - 'is_admin' => '1', |
|
3516 | - 'show_in' => '[detail]', |
|
3517 | - 'show_on_pkg' => $package, |
|
3518 | - 'clabels' => __('Website', 'geodirectory')); |
|
3519 | - |
|
3520 | - $fields[] = array('listing_type' => $post_type, |
|
3521 | - 'data_type' => 'VARCHAR', |
|
3522 | - 'field_type' => 'url', |
|
3523 | - 'admin_title' => __('Twitter', 'geodirectory'), |
|
3524 | - 'admin_desc' => __('You can enter your business or listing twitter url.', 'geodirectory'), |
|
3525 | - 'site_title' => __('Twitter', 'geodirectory'), |
|
3526 | - 'htmlvar_name' => 'twitter', |
|
3527 | - 'default_value' => '', |
|
3528 | - 'option_values' => '', |
|
3529 | - 'is_default' => '1', |
|
3530 | - 'is_admin' => '1', |
|
3531 | - 'show_in' => '[detail]', |
|
3532 | - 'show_on_pkg' => $package, |
|
3533 | - 'clabels' => __('Twitter', 'geodirectory')); |
|
3534 | - |
|
3535 | - $fields[] = array('listing_type' => $post_type, |
|
3536 | - 'data_type' => 'VARCHAR', |
|
3537 | - 'field_type' => 'url', |
|
3538 | - 'admin_title' => __('Facebook', 'geodirectory'), |
|
3539 | - 'admin_desc' => __('You can enter your business or listing facebook url.', 'geodirectory'), |
|
3540 | - 'site_title' => __('Facebook', 'geodirectory'), |
|
3541 | - 'htmlvar_name' => 'facebook', |
|
3542 | - 'default_value' => '', |
|
3543 | - 'option_values' => '', |
|
3544 | - 'is_default' => '1', |
|
3545 | - 'is_admin' => '1', |
|
3546 | - 'show_in' => '[detail]', |
|
3547 | - 'show_on_pkg' => $package, |
|
3548 | - 'clabels' => __('Facebook', 'geodirectory')); |
|
3549 | - |
|
3550 | - $fields[] = array('listing_type' => $post_type, |
|
3551 | - 'data_type' => 'TEXT', |
|
3552 | - 'field_type' => 'textarea', |
|
3553 | - 'admin_title' => __('Video', 'geodirectory'), |
|
3554 | - 'admin_desc' => __('Add video code here, YouTube etc.', 'geodirectory'), |
|
3555 | - 'site_title' => __('Video', 'geodirectory'), |
|
3556 | - 'htmlvar_name' => 'video', |
|
3557 | - 'default_value' => '', |
|
3558 | - 'option_values' => '', |
|
3559 | - 'is_default' => '0', |
|
3560 | - 'is_admin' => '1', |
|
3561 | - 'show_in' => '[owntab]', |
|
3562 | - 'show_on_pkg' => $package, |
|
3563 | - 'clabels' => __('Video', 'geodirectory')); |
|
3564 | - |
|
3565 | - $fields[] = array('listing_type' => $post_type, |
|
3566 | - 'data_type' => 'TEXT', |
|
3567 | - 'field_type' => 'textarea', |
|
3568 | - 'admin_title' => __('Special Offers', 'geodirectory'), |
|
3569 | - 'admin_desc' => __('Note: List out any special offers (optional)', 'geodirectory'), |
|
3570 | - 'site_title' => __('Special Offers', 'geodirectory'), |
|
3571 | - 'htmlvar_name' => 'special_offers', |
|
3572 | - 'default_value' => '', |
|
3573 | - 'option_values' => '', |
|
3574 | - 'is_default' => '0', |
|
3575 | - 'is_admin' => '1', |
|
3576 | - 'show_in' => '[owntab]', |
|
3577 | - 'show_on_pkg' => $package, |
|
3578 | - 'clabels' => __('Special Offers', 'geodirectory')); |
|
3579 | - |
|
3580 | - /** |
|
3581 | - * Filter the array of default custom fields DB table data. |
|
3582 | - * |
|
3583 | - * @since 1.6.6 |
|
3584 | - * @param string $fields The default custom fields as an array. |
|
3585 | - */ |
|
3586 | - $fields = apply_filters('geodir_default_custom_fields', $fields); |
|
3587 | - |
|
3588 | - return $fields; |
|
3417 | + $fields = array(); |
|
3418 | + $package = ($package_id=='') ? '' : array($package_id); |
|
3419 | + |
|
3420 | + $fields[] = array('listing_type' => $post_type, |
|
3421 | + 'data_type' => 'VARCHAR', |
|
3422 | + 'field_type' => 'taxonomy', |
|
3423 | + 'admin_title' => __('Category', 'geodirectory'), |
|
3424 | + 'admin_desc' => __('SELECT listing category FROM here. SELECT at least one CATEGORY', 'geodirectory'), |
|
3425 | + 'site_title' => __('Category', 'geodirectory'), |
|
3426 | + 'htmlvar_name' => $post_type.'category', |
|
3427 | + 'default_value' => '', |
|
3428 | + 'is_default' => '1', |
|
3429 | + 'is_admin' => '1', |
|
3430 | + 'is_required' => '1', |
|
3431 | + 'show_in' => '[detail]', |
|
3432 | + 'show_on_pkg' => $package, |
|
3433 | + 'clabels' => __('Category', 'geodirectory')); |
|
3434 | + |
|
3435 | + $fields[] = array('listing_type' => $post_type, |
|
3436 | + 'data_type' => 'VARCHAR', |
|
3437 | + 'field_type' => 'address', |
|
3438 | + 'admin_title' => __('Address', 'geodirectory'), |
|
3439 | + 'admin_desc' => ADDRESS_MSG, |
|
3440 | + 'site_title' => __('Address', 'geodirectory'), |
|
3441 | + 'htmlvar_name' => 'post', |
|
3442 | + 'default_value' => '', |
|
3443 | + 'option_values' => '', |
|
3444 | + 'is_default' => '1', |
|
3445 | + 'is_admin' => '1', |
|
3446 | + 'is_required' => '1', |
|
3447 | + 'show_in' => '[detail],[mapbubble]', |
|
3448 | + 'show_on_pkg' => $package, |
|
3449 | + 'required_msg' => __('Address fields are required', 'geodirectory'), |
|
3450 | + 'clabels' => __('Address', 'geodirectory'), |
|
3451 | + 'extra' => array('show_city' => 1, 'city_lable' => __('City', 'geodirectory'), |
|
3452 | + 'show_region' => 1, 'region_lable' => __('Region', 'geodirectory'), |
|
3453 | + 'show_country' => 1, 'country_lable' => __('Country', 'geodirectory'), |
|
3454 | + 'show_zip' => 1, 'zip_lable' => __('Zip/Post Code', 'geodirectory'), |
|
3455 | + 'show_map' => 1, 'map_lable' => __('Set Address On Map', 'geodirectory'), |
|
3456 | + 'show_mapview' => 1, 'mapview_lable' => __('Select Map View', 'geodirectory'), |
|
3457 | + 'show_mapzoom' => 1, 'mapzoom_lable' => 'hidden', |
|
3458 | + 'show_latlng' => 1)); |
|
3459 | + |
|
3460 | + $fields[] = array('listing_type' => $post_type, |
|
3461 | + 'data_type' => 'VARCHAR', |
|
3462 | + 'field_type' => 'text', |
|
3463 | + 'admin_title' => __('Time', 'geodirectory'), |
|
3464 | + 'admin_desc' => __('Enter Business or Listing Timing Information.<br/>eg. : 10.00 am to 6 pm every day', 'geodirectory'), |
|
3465 | + 'site_title' => __('Time', 'geodirectory'), |
|
3466 | + 'htmlvar_name' => 'timing', |
|
3467 | + 'default_value' => '', |
|
3468 | + 'option_values' => '', |
|
3469 | + 'is_default' => '1', |
|
3470 | + 'is_admin' => '1', |
|
3471 | + 'show_in' => '[detail],[mapbubble]', |
|
3472 | + 'show_on_pkg' => $package, |
|
3473 | + 'clabels' => __('Time', 'geodirectory')); |
|
3474 | + |
|
3475 | + $fields[] = array('listing_type' => $post_type, |
|
3476 | + 'data_type' => 'VARCHAR', |
|
3477 | + 'field_type' => 'phone', |
|
3478 | + 'admin_title' => __('Phone', 'geodirectory'), |
|
3479 | + 'admin_desc' => __('You can enter phone number,cell phone number etc.', 'geodirectory'), |
|
3480 | + 'site_title' => __('Phone', 'geodirectory'), |
|
3481 | + 'htmlvar_name' => 'contact', |
|
3482 | + 'default_value' => '', |
|
3483 | + 'option_values' => '', |
|
3484 | + 'is_default' => '1', |
|
3485 | + 'is_admin' => '1', |
|
3486 | + 'show_in' => '[detail],[mapbubble]', |
|
3487 | + 'show_on_pkg' => $package, |
|
3488 | + 'clabels' => __('Phone', 'geodirectory')); |
|
3489 | + |
|
3490 | + $fields[] = array('listing_type' => $post_type, |
|
3491 | + 'data_type' => 'VARCHAR', |
|
3492 | + 'field_type' => 'email', |
|
3493 | + 'admin_title' => __('Email', 'geodirectory'), |
|
3494 | + 'admin_desc' => __('You can enter your business or listing email.', 'geodirectory'), |
|
3495 | + 'site_title' => __('Email', 'geodirectory'), |
|
3496 | + 'htmlvar_name' => 'email', |
|
3497 | + 'default_value' => '', |
|
3498 | + 'option_values' => '', |
|
3499 | + 'is_default' => '1', |
|
3500 | + 'is_admin' => '1', |
|
3501 | + 'show_in' => '[detail]', |
|
3502 | + 'show_on_pkg' => $package, |
|
3503 | + 'clabels' => __('Email', 'geodirectory')); |
|
3504 | + |
|
3505 | + $fields[] = array('listing_type' => $post_type, |
|
3506 | + 'data_type' => 'VARCHAR', |
|
3507 | + 'field_type' => 'url', |
|
3508 | + 'admin_title' => __('Website', 'geodirectory'), |
|
3509 | + 'admin_desc' => __('You can enter your business or listing website.', 'geodirectory'), |
|
3510 | + 'site_title' => __('Website', 'geodirectory'), |
|
3511 | + 'htmlvar_name' => 'website', |
|
3512 | + 'default_value' => '', |
|
3513 | + 'option_values' => '', |
|
3514 | + 'is_default' => '1', |
|
3515 | + 'is_admin' => '1', |
|
3516 | + 'show_in' => '[detail]', |
|
3517 | + 'show_on_pkg' => $package, |
|
3518 | + 'clabels' => __('Website', 'geodirectory')); |
|
3519 | + |
|
3520 | + $fields[] = array('listing_type' => $post_type, |
|
3521 | + 'data_type' => 'VARCHAR', |
|
3522 | + 'field_type' => 'url', |
|
3523 | + 'admin_title' => __('Twitter', 'geodirectory'), |
|
3524 | + 'admin_desc' => __('You can enter your business or listing twitter url.', 'geodirectory'), |
|
3525 | + 'site_title' => __('Twitter', 'geodirectory'), |
|
3526 | + 'htmlvar_name' => 'twitter', |
|
3527 | + 'default_value' => '', |
|
3528 | + 'option_values' => '', |
|
3529 | + 'is_default' => '1', |
|
3530 | + 'is_admin' => '1', |
|
3531 | + 'show_in' => '[detail]', |
|
3532 | + 'show_on_pkg' => $package, |
|
3533 | + 'clabels' => __('Twitter', 'geodirectory')); |
|
3534 | + |
|
3535 | + $fields[] = array('listing_type' => $post_type, |
|
3536 | + 'data_type' => 'VARCHAR', |
|
3537 | + 'field_type' => 'url', |
|
3538 | + 'admin_title' => __('Facebook', 'geodirectory'), |
|
3539 | + 'admin_desc' => __('You can enter your business or listing facebook url.', 'geodirectory'), |
|
3540 | + 'site_title' => __('Facebook', 'geodirectory'), |
|
3541 | + 'htmlvar_name' => 'facebook', |
|
3542 | + 'default_value' => '', |
|
3543 | + 'option_values' => '', |
|
3544 | + 'is_default' => '1', |
|
3545 | + 'is_admin' => '1', |
|
3546 | + 'show_in' => '[detail]', |
|
3547 | + 'show_on_pkg' => $package, |
|
3548 | + 'clabels' => __('Facebook', 'geodirectory')); |
|
3549 | + |
|
3550 | + $fields[] = array('listing_type' => $post_type, |
|
3551 | + 'data_type' => 'TEXT', |
|
3552 | + 'field_type' => 'textarea', |
|
3553 | + 'admin_title' => __('Video', 'geodirectory'), |
|
3554 | + 'admin_desc' => __('Add video code here, YouTube etc.', 'geodirectory'), |
|
3555 | + 'site_title' => __('Video', 'geodirectory'), |
|
3556 | + 'htmlvar_name' => 'video', |
|
3557 | + 'default_value' => '', |
|
3558 | + 'option_values' => '', |
|
3559 | + 'is_default' => '0', |
|
3560 | + 'is_admin' => '1', |
|
3561 | + 'show_in' => '[owntab]', |
|
3562 | + 'show_on_pkg' => $package, |
|
3563 | + 'clabels' => __('Video', 'geodirectory')); |
|
3564 | + |
|
3565 | + $fields[] = array('listing_type' => $post_type, |
|
3566 | + 'data_type' => 'TEXT', |
|
3567 | + 'field_type' => 'textarea', |
|
3568 | + 'admin_title' => __('Special Offers', 'geodirectory'), |
|
3569 | + 'admin_desc' => __('Note: List out any special offers (optional)', 'geodirectory'), |
|
3570 | + 'site_title' => __('Special Offers', 'geodirectory'), |
|
3571 | + 'htmlvar_name' => 'special_offers', |
|
3572 | + 'default_value' => '', |
|
3573 | + 'option_values' => '', |
|
3574 | + 'is_default' => '0', |
|
3575 | + 'is_admin' => '1', |
|
3576 | + 'show_in' => '[owntab]', |
|
3577 | + 'show_on_pkg' => $package, |
|
3578 | + 'clabels' => __('Special Offers', 'geodirectory')); |
|
3579 | + |
|
3580 | + /** |
|
3581 | + * Filter the array of default custom fields DB table data. |
|
3582 | + * |
|
3583 | + * @since 1.6.6 |
|
3584 | + * @param string $fields The default custom fields as an array. |
|
3585 | + */ |
|
3586 | + $fields = apply_filters('geodir_default_custom_fields', $fields); |
|
3587 | + |
|
3588 | + return $fields; |
|
3589 | 3589 | } |
3590 | 3590 | |
3591 | 3591 | function geodir_currency_format_number($number='',$cf=''){ |
3592 | 3592 | |
3593 | - $cs = isset($cf['extra_fields']) ? maybe_unserialize($cf['extra_fields']) : ''; |
|
3593 | + $cs = isset($cf['extra_fields']) ? maybe_unserialize($cf['extra_fields']) : ''; |
|
3594 | 3594 | |
3595 | - $symbol = isset($cs['currency_symbol']) ? $cs['currency_symbol'] : '$'; |
|
3596 | - $decimals = isset($cf['decimal_point']) && $cf['decimal_point'] ? $cf['decimal_point'] : 2; |
|
3597 | - $decimal_display = !empty($cf['decimal_display']) ? $cf['decimal_display'] : (!empty($cs['decimal_display']) ? $cs['decimal_display'] : 'if'); |
|
3598 | - $decimalpoint = '.'; |
|
3595 | + $symbol = isset($cs['currency_symbol']) ? $cs['currency_symbol'] : '$'; |
|
3596 | + $decimals = isset($cf['decimal_point']) && $cf['decimal_point'] ? $cf['decimal_point'] : 2; |
|
3597 | + $decimal_display = !empty($cf['decimal_display']) ? $cf['decimal_display'] : (!empty($cs['decimal_display']) ? $cs['decimal_display'] : 'if'); |
|
3598 | + $decimalpoint = '.'; |
|
3599 | 3599 | |
3600 | - if(isset($cs['decimal_separator']) && $cs['decimal_separator']=='comma'){ |
|
3601 | - $decimalpoint = ','; |
|
3602 | - } |
|
3600 | + if(isset($cs['decimal_separator']) && $cs['decimal_separator']=='comma'){ |
|
3601 | + $decimalpoint = ','; |
|
3602 | + } |
|
3603 | 3603 | |
3604 | - $separator = ','; |
|
3604 | + $separator = ','; |
|
3605 | 3605 | |
3606 | - if(isset($cs['thousand_separator'])){ |
|
3607 | - if($cs['thousand_separator']=='comma'){$separator = ',';} |
|
3608 | - if($cs['thousand_separator']=='slash'){$separator = '\\';} |
|
3609 | - if($cs['thousand_separator']=='period'){$separator = '.';} |
|
3610 | - if($cs['thousand_separator']=='space'){$separator = ' ';} |
|
3611 | - if($cs['thousand_separator']=='none'){$separator = '';} |
|
3612 | - } |
|
3606 | + if(isset($cs['thousand_separator'])){ |
|
3607 | + if($cs['thousand_separator']=='comma'){$separator = ',';} |
|
3608 | + if($cs['thousand_separator']=='slash'){$separator = '\\';} |
|
3609 | + if($cs['thousand_separator']=='period'){$separator = '.';} |
|
3610 | + if($cs['thousand_separator']=='space'){$separator = ' ';} |
|
3611 | + if($cs['thousand_separator']=='none'){$separator = '';} |
|
3612 | + } |
|
3613 | 3613 | |
3614 | - $currency_symbol_placement = isset($cs['currency_symbol_placement']) ? $cs['currency_symbol_placement'] : 'left'; |
|
3614 | + $currency_symbol_placement = isset($cs['currency_symbol_placement']) ? $cs['currency_symbol_placement'] : 'left'; |
|
3615 | 3615 | |
3616 | - if($decimals>0 && $decimal_display=='if'){ |
|
3617 | - if(is_int($number) || floor( $number ) == $number) |
|
3618 | - $decimals = 0; |
|
3619 | - } |
|
3616 | + if($decimals>0 && $decimal_display=='if'){ |
|
3617 | + if(is_int($number) || floor( $number ) == $number) |
|
3618 | + $decimals = 0; |
|
3619 | + } |
|
3620 | 3620 | |
3621 | - $number = number_format($number,$decimals,$decimalpoint,$separator); |
|
3621 | + $number = number_format($number,$decimals,$decimalpoint,$separator); |
|
3622 | 3622 | |
3623 | 3623 | |
3624 | 3624 | |
3625 | - if($currency_symbol_placement=='left'){ |
|
3626 | - $number = $symbol . $number; |
|
3627 | - }else{ |
|
3628 | - $number = $number . $symbol; |
|
3629 | - } |
|
3625 | + if($currency_symbol_placement=='left'){ |
|
3626 | + $number = $symbol . $number; |
|
3627 | + }else{ |
|
3628 | + $number = $number . $symbol; |
|
3629 | + } |
|
3630 | 3630 | |
3631 | 3631 | |
3632 | 3632 | return $number; |